akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;


public class Main{
  public static void main(String[] args){
    try{
    BufferedReader re = new BufferedReader(new InputStreamReader(System.in));
    String as = re.readLine();
    String aa[] = as.split(" ");
    String aaa = aa[0];
    String bbb = aa[1];  
    int a = Integer.parseInt(aaa);
    int b = Integer.parseInt(bbb);
    int[][] c = new int[b][2];
    int ans = 0;
    int max = 0;
    int min = 0;  
    for(int i = 0;i < b;i++){
      String al = re.readLine();
      String bb[] = al.split(" ");
      String ccc = bb[0];
      String ddd = bb[1];  
      c[i][0] = Integer.parseInt(ccc);
      c[i][1] = Integer.parseInt(ddd);      
    }
      for(int x = 0;x < b;x++){
        if(c[x][0] > max) max = c[x][0];
        if(c[x][1] < min || x == 0) min = c[x][1];
      }  
    for(int x = 1;x <= a;x++){
      if(x >= max && x <= min) ans++;
    }
    System.out.println(ans);
    }catch(IOException e){
      System.out.println(e);
    }
  }
}

Measured memory_bytes: 48012
#include <bits/stdc++.h>

using namespace std;
 
// macro
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define MOD 1000000007
#define M_PI 3.14159265358979323846
#define ll long long
#define ull unsigned long long
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define SORT(ary) sort(begin(ary), end(ary))
#define VL vector<ll>
#define VVL vector<VL>
#define PL pair<ll, ll>
#define VC vector<char>
#define VVC vector<VC>

// Factorial
// need init
ll factorial_memo[5001];
ll factorial(ll n) {
  factorial_memo[0] = 1;
  if(factorial_memo[n] != -1) return factorial_memo[n];
  factorial_memo[n] = (factorial(n-1) * n) % MOD;
  return factorial_memo[n];
}
 
// Combination(nCr)
// need init
ll nCr_memo[5001][5001];
ll nCr(ll n, ll r) {
  if(r*2 > n) r = n-r;
  if(r == 1) return n;
  if(r == 0) return 1;
  if(nCr_memo[n][r] != -1) return nCr_memo[n][r];
  nCr_memo[n][r] = (nCr(n-1, r) + nCr(n-1, r-1)) % MOD;
  return nCr_memo[n][r];
}

ll bridgeDfs(VVL& g, vector<PL>& res, ll v, ll& count, ll from, VL& low, VL& pre) {
  pre[v] = count++;
  low[v] = pre[v];
  for(auto to:g[v]) {
    if (pre[to] == -1) {
      low[v] = min(low[v], bridgeDfs(g, res, to, count, v, low, pre));
      if(low[to] == pre[to]) res.push_back(make_pair(v, to));
    } else {
      if(from == to) continue;
      low[v] = min(low[v], low[to]);
    }
  }
  return low[v];
}

vector<PL> bridges(VVL& g, ll N) {
  vector<PL> res;
  if (N > 0) {
    VL low(N, -1);
    VL pre(N, -1);
    ll count = 0;
    bridgeDfs(g, res, 0, count, -1, low, pre);
  }
  return res;
}

void solve() {
    string s;
    cin >> s;
    REP(i, s.size()-1) {
        if(s.at(i) == 'A' && s.at(i+1) == 'C') {
            cout << "Yes\n";
            return;
        }
    }
    cout << "No";
}



int main() {
  // init
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  ll x;
  cin >> x;
  int up;
  if(x%11==0) up = 0;
  else if(x%11<7) up= 1;
  else if(x%11>=7) up= 2;
  cout << (x/11)*2 + up << endl;
}

Measured memory_bytes: 256
// #include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

struct Card
{
  char pic;
  int num;
};

int partition(Card a[], int p, int r)
{
  int x = a[r].num;
  int i = p - 1;
  for (int j = p; j < r; j++)
    if (a[j].num <= x)
    {
      i++;
      swap(a[i], a[j]);
    }
  swap(a[i + 1], a[r]);
  return i + 1;
}

void quickSort(Card a[], int p, int r)
{
  if (p < r)
  {
    int q = partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
}

void merge(Card a[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  Card l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (int i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = {'J', 1000000001};
  r[n2] = {'J', 1000000001};

  int i = 0, j = 0;
  for (int k = left; k < right; k++)
    if (l[i].num <= r[j].num)
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      j++;
    }
}

void mergeSort(Card a[], int left, int right)
{
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main()
{
  int n, x;
  char p;
  // scanf("%d", &n);
  cin >> n;

  Card a[n], ms[n];
  for (int i = 0; i < n; i++)
  {
    // scanf("%s%d", &p, &x);
    cin >> p >> x;
    a[i] = {p, x};
    ms[i] = {p, x};
  }

  quickSort(a, 0, n - 1);
  mergeSort(ms, 0, n);

  bool isStable = true;
  for (int i = 0; i < n; i++)
    if (a[i].num != ms[i].num || a[i].pic != ms[i].pic)
    {
      printf("Not stable\n");
      isStable = false;
      break;
    }

  if (isStable)
    printf("Stable\n");

  for (int i = 0; i < n; i++)
    printf("%c %d\n", a[i].pic, a[i].num);

  return 0;
}

Measured memory_bytes: 5384
from collections import deque

n, m = map(int, input().split())

up = [[] for _ in range(n)] # [[]]*nした後にappendするのはNG
down = [[] for _ in range(n)]
used = [0]*n # これならOK
res = [0]*n
cnt = 0

for _ in range(n+m-1):
    p, c = map(int, input().split())
    up[c-1].append(p)
    down[p-1].append(c)

for i in range(n):
    if up[i] == []:
        root = i+1
        res[root-1] = 0
        used[root-1] = 1
        cnt += 1
        break

ptank = deque([root])
ctank = deque([root])
clist = list()

def is_p_used(i):
    for j in up[i-1]:
        if used[j-1]==0:
            return False
    return True

def find_c(p):
    for i in down[p-1]:
        if (is_p_used(i)) & (used[i-1]==0):
            res[i-1] = p
            ctank.append(i)
            clist.append(i)

while cnt < n:
    ptank = ctank
    ctank = deque()
    while len(ptank) != 0:
        find_c(ptank.popleft())
    cnt += len(ctank)
    for i in clist:
        used[i-1] = 1
    clist = list()
    

for i in range(n):
    print(res[i])

Measured memory_bytes: 35748
w, h, n = map(int, input().split())
b = [0, 0]
c = [w, h]
for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if b[0] < x:
            b[0] = x
    elif a == 2:
        if c[0] > x:
            c[0] = x
    elif a == 3:
        if b[1] < y:
            b[1] = y
    else:
        if c[1] > y:
            c[1] = y
d = max(0, (c[0] - b[0])) * max(0, (c[1] - b[1]))
print(d)

Measured memory_bytes: 9108
def main():
    a,b,ab,ac,bc = map(int,input().split())
    price = 0
    if a+b < ab*2:
        price = a*ac + b*bc
    else:
        if ac < bc:
            price += ab*ac*2
            x = bc-ac
            price += min(x*b, x*ab*2)
        else:
            price += ab*bc*2
            x = ac-bc
            price += min(x*a, x*ab*2)
    print(price)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import math

A,B,H,M=map(int,input().split())

dTan=30*H+30*(M/60)
dCho=6*M
angle=abs(dTan-dCho)

print(math.sqrt(pow(A,2)+pow(B,2)-2*A*B*math.cos(math.radians(angle))))

Measured memory_bytes: 9380
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt=0;
    for(int i=0;i<1000;i++){
        int c[3]={i/100,(i/10)%10,i%10};
        int f=0;
        for(int j=0;j<n;j++){
            if(s[j]==('0'+c[f]))f++;//c[f]を文字コードにしてる
            if(f==3)break;
        }
        if(f==3)cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,n;
    int ans=0;
    cin >> n >> a >> b;
    repi(i,1,n+1){
      int k = i;
      int keta_sum=0;
      while(k){
        int val = k%10;
        k /= 10;
        keta_sum+=val;
      }
      if(a<=keta_sum&&keta_sum<=b){
        ans += i;
      }
    }
    cout << ans << endl;
    return 0;
  } 

Measured memory_bytes: 256
// UTPC2010 B. ツ陛ウツつュツつカツチツェツッツカツー

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
	int n, m;
	while(cin >> n >> m, n){
		vector< pair<string, int> > v;
		for(int i=0;i<n;i++){
			string s; int t; cin >> s >> t;
			v.push_back(make_pair(s,t));
		}
		int ans = 0;
		for(int i=0;i<m;i++){
			string s; cin >> s;
			for(int j=0;j<n;j++){
				bool ok = true;
				for(int k=0;k<8;k++)
					if(v[j].first[k]!='*'&&v[j].first[k]!=s[k]) ok = false;
				if(ok){
					ans += v[j].second;
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 932
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;


int main() {
  vi v(7);
  int check=0;
  rep(i,6){
    int a;
    cin >> a;
    v[a] ++;
  }
  rrep(i,4){
    if(v[i]==2){
      check ++;
    }
  }
  if(check==2){
    cout << "YES" << endl;
    return 0;
  }
  
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
C = {}
for _ in range(N):
    A,B = map(int, input().split())
    if A in C:
        C[A].append(B)
    else:
        C[A] = []
        C[A].append(B)
for i in C:
    C[i] = sorted(C[i])[::-1]

answer = 0
tmp = []
heapq.heapify(tmp)

for i in range(M+1):
    if i in C:
        right = C[i]
        for j in right:
            heapq.heappush(tmp,-1*j)
        
    if tmp != []:
        answer += -1*heapq.heappop(tmp)
print(answer)

Measured memory_bytes: 79064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
#define int long long
#define P pair<int,int>

const int INF = 1e12;

signed main() {
    int n,m;
    cin>> n >> m;

    vector<P> keys(m);
    for(int i = 0; i < m; i++){
        int cost, num;
        cin >> cost >> num;
        int id = 0;
        for(int j = 0; j < num; j++){
            int val;
            cin >> val;
            val--;
            id |= 1 << val;
        }
        keys[i].first = id;
        keys[i].second = cost;
    }

    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        for(int i = 0; i < m; i++){
            int next = bit | keys[i].first;
            dp[next] = min(dp[next], dp[bit] + keys[i].second);
        }
    }
    if(dp[(1 << n) - 1] == INF) cout << -1 << endl;
    else cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, a;
    cin >> n;

    map<int, int> mp;
    for(int i = 0; i < n; i++) cin >> a, mp[a]++;

    int ans = 0;
    for(auto x : mp){
        if(x.first == x.second) continue;
        if(x.first > x.second) ans += x.second;
        else ans += x.second - x.first;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
n=int(input())
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))

import sys

a.sort(key=lambda x: x[1])
sum=a[0][0]
for i in range(n-1):
  if sum>a[i][1]:
    print("No")
    sys.exit()
  sum=sum+a[i+1][0]
if sum>a[n-1][1]:
  print("No")
  sys.exit()
print("Yes")
  
  


Measured memory_bytes: 53720
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> v = {a, b, c}, w = {5, 5, 7};
  sort(v.begin(), v.end());

  if (v == w) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

bool isPrime(int x) {
    if (x == 2) {
        return 2;
    }if (x %2 == 0) {
        return false;
    }
    for (int w = 3; w <= sqrt(x); w+=2) {
        if (x % w == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int i, p;
    int count = 0;
    cin >> i;
    for (int j = 0; j < i; j++) {
        cin >> p;
        if (isPrime(p)){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

   int r,g;
     cin>>r>>g;
     
     cout<<2*g-r;
   
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int N, M;
int dist[100010];
bool visited[100010];
vector<pint> adj[100010];

bool dfs(int i, int d){
    if(visited[i]){
        return dist[i] == d;
    }
    visited[i] = true;
    dist[i] = d;
    bool ret = true;
    for(auto p : adj[i]){
        ret &= dfs(p.first, d + p.second);
    }
    return ret;
}

signed main(){
    cin >> N >> M;
    int L, R, D;
    REP(i, M){
        cin >> L >> R >> D;
        L--; R--;
        adj[L].push_back(pint(R, D));
        adj[R].push_back(pint(L, -D));
    }
    bool ans = true;
    REP(i, N){
        if(visited[i]) continue;
        ans &= dfs(i, 0);
    }
    if(ans) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 12032
#include<iostream>
using namespace std;
int main(){
  int n,s;
  while(cin >>n>>s,n||s){
    int magic[101] = {0};
    long long sum = 0;
    for(int i=0,a; i<n; i++){
      cin >>a;
      magic[a]++;
    }
    for(int i=1; i<101; i++){
      for(int j=i; j<101; j++){
	if(i+j>s){
	  if(i!=j){sum+=magic[i]*magic[j];}
	  else{sum+=magic[i]*(magic[i]-1)/2;}
	}
      }
    }
    cout <<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 864
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long *)b )return 1;
    return -1;
}
int main()
{   int i,j,a,b,x,y,n,m,k;
char s[11];
    scanf("%s",s);
    char h[11]="2019/04/30";
    if(strcmp(s,h)<=0)
    printf("Heisei");
    else printf("TBD");

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define P(x) cout << x << endl
#define D(x) P(#x << ": " << x)
#define F(i,n) for (int i=0; i<(int)(n); i++)
#define DEC(i,n) for (int i=(int)(n); --i>=0;)
#define pb push_back
#define ALL(v) v.begin(), v.end()
using namespace std;

signed main() {
    int n,c,k; cin>>n>>c>>k;
    int a[n];
    F(i,n) cin>>a[i];
    sort(a, a+n);
    int cnt=0,people=0,last;
    F(i,n) {
        if (people && last + k < a[i]) {
            cnt++;
            people=0;
        }
        if (!people) last = a[i];
        people++;
        if (people == c) {
            cnt++;
            people=0;
        }
    }
    if (people) cnt++;
    P(cnt);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int main() {
    int A, B;
    cin >> A >> B;
    int n = 1;
    int ans = 0;
    while(n < B) {
        n = n - 1 + A;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
using namespace std;

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

#define inf 10000000000000000

void solve()
{
    ll n;
    cin >> n;
    vector<vector<pair<ll,ll>>> dp(n+1);
    vector<ll> v(n+1);
    for(ll i=1;i<=n;i++)
    {
        cin >> v[i];
        dp[i].resize(n+1);
        
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=n;j++)
        {
            dp[i][j]=make_pair(inf,inf);
        }
        dp[i][i]=make_pair(v[i],v[i]);
    }
    for(ll i=1;i<n;i++)
    {
        ll temp=dp[i][i].first+dp[i+1][i+1].first;
        dp[i][i+1]=make_pair(temp,temp);
    }
    for(ll len=3;len<=n;len++)
    {
        for(ll i=1;i+len-1<=n;i++)
        {
            ll j=i+len-1;
            for(ll k=i;k<j;k++)
            {
                ll temp=0;
                if(k-i+1>1)
                {
                    temp=dp[i][k].first;
                }
                if(j-k>1)
                    temp+=dp[k+1][j].first;
                if(dp[i][j].first>dp[i][k].second+dp[k+1][j].second+temp){
                    dp[i][j].first=dp[i][k].second+dp[k+1][j].second+temp;
                    dp[i][j].second=dp[i][k].second+dp[k+1][j].second;
                }
            }
        }
    }
    cout << dp[1][n].first << endl;

}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 2816
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
# 文字列には注意


def main():
    r = int(input())
    print(2*r*math.pi)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9468
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

ll dp[55][55][3000];

int main(){
  int N,A;
  cin >> N >> A;
  vector<int> x(N);
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 1;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      for(int k=0; k<3000; k++){
        dp[i+1][j][k] += dp[i][j][k];
        dp[i+1][j+1][k+x[i]] += dp[i][j][k];
      }
    }
  }
  ll ans=0;
  for(int i=1; i<=N; i++){
    ans += dp[N][i][i*A];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 71168
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
int read()
{
	int f=1,x=0; char c=getchar();
	while (c>'9'||c<'0') {if (c=='-') f=-1; c=getchar();}
	while (c>='0' && c<='9') {x=x*10+c-'0'; c=getchar();}
	return x*f;
}
int main()
{
	int N=read();
	int a,b,c;
	a=N%10,c=N/100;
	if (a==c) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
using namespace std;

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n,l;
  cin>>n>>l;
  ll bns=100000;
  ll sum=0;
  FOR(i,1,n+1){
    sum+=i+l-1;
    if(bns>abs(i+l-1)){
      bns=abs(i+l-1);
    }
  }
  if(l<0){
    bns=-bns;
  }
  sum-=bns;
  co(sum);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b)
		printf("a > b");
	else if(a == b)
		printf("a == b");
	else
		printf("a < b");
	printf("\n");
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <climits>
#include <map>
#include <assert.h>

using namespace std;

// ????????¨????§???????(???????????? ????????? ??????)
struct Edge {
    int to, cap, rev;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {
        assert(this->cap >= 0);
    }
};

// ?????§????????????O(F|E|)??§?§£???
class FordFulkerson {
public:
    unsigned int num_of_node = 0;   // ???????????°
    map<int, vector<Edge>> G;       // ??°???????????£??\???????????¨???
    vector<bool> used;              // DFS??§?????§??????????????????????????°

    FordFulkerson(unsigned int num_of_node) : num_of_node(num_of_node){
    }

    // from??????to??????????????????cap???????????°?????????????????????
    // ???????????°???????????´??????from??????to??¨to??????from???2?????????????????????
    void add_edge(int from, int to, int cap) {
        this->G[from].push_back(Edge(to, cap, this->G[to].size()));
        this->G[to].push_back(Edge(from, 0, this->G[from].size() - 1));
    }

    // s??????t???????????§???????±??????? O(F|E|)
    int max_flow(int s, int t) {
        int flow = 0;
        while (true) {
            this->used = vector<bool>(this->num_of_node, 0);
            int f = dfs(s, t, INT_MAX);
            if (f == 0) { return flow; }
            flow += f;
        }
    }

private:
    // v??????t???f??????????¢???????????????¢???
    int dfs(int v, int t, int f) {
        if (v == t) { return f; }
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            Edge &e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int V, E;
    cin >> V >> E;
    FordFulkerson ff(V);
    for (int i = 0; i < E; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        ff.add_edge(u, v, c);
    }

    cout << ff.max_flow(0, V - 1) << endl;
    return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep_a(i, start, end) for (int i = (start); i < (n); ++i)
using namespace std;

int main(){
  int n;cin >> n;
  char tmp;
  int count = 0;
  vector<int> hoge(n);
  rep(i, n){
    cin >> tmp;
    hoge[i] = int(tmp - '0');
  }

  // rep_a(i, 1, 4){
  //   cout << i << endl;
  // }

  rep(a, 10){
    rep(b, 10){
      rep(c, 10){
        int a_i = n + 1;
        int b_i = n + 1;
        int c_i = n + 1;

        rep(i, n){
          if (hoge[i] == a){
            a_i = i;
            break;
          }
        }
        if(a_i == n + 1){
          continue;
        }

        rep_a(i, a_i + 1, n){
          if (hoge[i] == b){
            b_i = i;
            break;
          }
        }
        
        if(b_i == n + 1){
          continue;
        }
        
        rep_a(i, b_i + 1, n){
          if (hoge[i] == c){
            c_i = i;
            break;
          }
        }
        
        if(c_i == n + 1){
          continue;
        }

        // cout << a << " " << b << " " << c << endl;;
        count += 1;
        // auto aa = find(hoge.begin(), hoge.end(), a);
        // auto aa = find(hoge.begin(), hoge.end(), a);
      }
    }
  }
  cout << count << endl;
  // rep(i, n){
  //   cout << hoge[i] << endl;
  // }

  // for (int i = 0; i < 10; i++){
  //   /* code */
  // }
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;

public class Main {
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static FastReader s = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    private static int[] rai(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        return arr;
    }

    private static int[][] rai(int n, int m) {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextInt();
            }
        }
        return arr;
    }

    private static long[] ral(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = s.nextLong();
        }
        return arr;
    }

    private static long[][] ral(int n, int m) {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = s.nextLong();
            }
        }
        return arr;
    }

    private static int ri() {
        return s.nextInt();
    }

    private static long rl() {
        return s.nextLong();
    }

    private static String rs() {
        return s.next();
    }
    static int gcd(int a,int b)
    {
        if(b==0)
        {
            return a;
        }
        return gcd(b,a%b);
    }

    static public class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeNode left, TreeNode right)
        {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }


    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
//        int t = ri();
        int t=1;
        while (t-- > 0) {
            int n=ri();
            if(n>=30)
            {
                ans.append("Yes\n");
            }
            else {
                ans.append("No\n");
            }
        }
        out.print(ans.toString());
        out.flush();

    }

}


Measured memory_bytes: 25396
def solve():
    n, k = map(int, input().split())
    h = [int(input()) for _ in range(n)]
    h.sort()
    hk = [h[i+k-1] - h[i] for i in range(n - k + 1)]
    print(min(hk))

if __name__ == '__main__':
    solve()


Measured memory_bytes: 17112
N = int(input())
A = list(map(int, input().split()))
B = [0]*60
for a in A:
    for i in range(len(B)):
        if a & (2**i):
            B[i] += 1
ans = 0
for i, b in enumerate(B):
    ans += 2**i * b * (N-b)
ans %= 10**9+7
print(ans)

Measured memory_bytes: 122808
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>>a;
int N, K;
int ans = 0;

int dfs( int v, int pre ) {
	int ret = 0;
	for( auto n : a[v] ) {
		ret = max( ret, dfs( n, v ) );
	}
	if( (ret == K - 1 && pre != 0) ) {
		ret = 0;
		ans++;
	} else {
		ret++;
	}
	return ret;
}

int main() {
	cin >> N >> K;
	a = vector<vector<int>>( N );
	for( size_t i = 0; i < N; i++ ) {
		int x;
		cin >> x;
		x--;
		if( i == 0 ) {
			if( x != 0 ) {
				ans++;
			}
		} else {
			a[x].push_back( i );
		}
	}
	dfs( 0, 0 );
	cout << ans << endl;
}



Measured memory_bytes: 10368
import java.util.*;

// Do not use int, use long!!

public class Main {
	public static void main(String args[]){
			Scanner sc = new Scanner(System.in);
			
			String s = sc.next();
			//1 operation , w mov left
			//so count each "w" how many "b" exists
			long countb = 0;
			long ans = 0;
			for (int i = 0; i < s.length(); i++) {
				if (s.charAt(i) == 'B') {
					countb++;
				}else{
					ans += countb;
				}
			}

			System.out.println(ans);
			
			sc.close();
		}
	
}

Measured memory_bytes: 26604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];

int main() {
    int n;
    cin >> n;
    vector<int> counter(4);
    rep(i, n) {
        int a;
        cin >> a;
        ++counter[a];
    }

    p[counter[1]][counter[2]][counter[3]] = 1.0;
    for (int c = n; c >= 0; --c) {
        for (int b = n; b >= 0; --b) {
            for (int a = n; a >= 0; --a) {
                if (a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if (a + b + c > n) {
                    continue;
                }
                // dp[a][b][c]

                double p_waste = (double)(n - (a + b + c)) / n;
                // p_waste + p_waste^2 + ... = S
                // 1 + S = S / p_waste
                double ev_waste = p_waste / (1 - p_waste) + 1;
                ev[a][b][c] += ev_waste * p[a][b][c];

                // remove 1 -> dp[a-1][b][c]
                // we will eventually choose one of a+b+c
                if (a != 0) {
                    double p_go = (double)a / (a + b + c);
                    p[a - 1][b][c] += p[a][b][c] * p_go;
                    ev[a - 1][b][c] += ev[a][b][c] * p_go;
                }

                // remove 2 -> dp[a+1][b-1][c]
                if (b != 0) {
                    double p_go = (double)b / (a + b + c);
                    p[a + 1][b - 1][c] += p[a][b][c] * p_go;
                    ev[a + 1][b - 1][c] += ev[a][b][c] * p_go;
                }

                // remove 3
                if (c != 0) {
                    double p_go = (double)c / (a + b + c);
                    p[a][b + 1][c - 1] += p[a][b][c] * p_go;
                    ev[a][b + 1][c - 1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]);  // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

Measured memory_bytes: 438528
n,m = map(int,input().split())#軒数、目標本数
ab = sorted(list(map(int, input().split())) for i in range(n))#値段と個数が格納された小リストが大リストの要素
ans = stock = 0
for i in range(n):#ab[x][y]　x番目のa,bのセットの中からy=1ならbの値y=0ならaの値
    for j in range(ab[i][1]):
        ans +=ab[i][0]
        stock += 1
        if stock == m:
            print(ans)
            exit()

Measured memory_bytes: 27756
#include <cstdio>
#include <vector>
#include <algorithm>

typedef long long i64;
typedef std::pair<int, int> Edge;

const int N = 200 + 10, MOD = 1000000007;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int n, k;
std::vector<int> adj[N];

int f[N], fact[N], ifact[N];

int binom(int n, int m) {
  if (m > n) return 0;
  return (i64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD;
}

void init() {
  int m;
  scanf("%d%d%d", &n, &m, &k);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = (i64)fact[i - 1] * i % MOD;
  ifact[1] = 1;
  for (int i = 2; i < N; ++i) ifact[i] = ((i64)MOD - MOD / i) * ifact[MOD % i] % MOD;
  static int g[N];
  g[0] = 1;
  for (int i = 1; i < N; ++i) g[i] = (i64)g[i - 1] * k % MOD;
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < i; ++j) f[i] = (f[i] + g[gcd(i, j)]) % MOD;
    f[i] = (i64)f[i] * ifact[i] % MOD;
  }
  ifact[0] = 1;
  for (int i = 1; i < N; ++i) ifact[i] = (i64)ifact[i - 1] * ifact[i] % MOD;
}

int ans;
int dfn[N];

void tarjan(int a, int pre) {
  static Edge stk[N];
  static int low[N], top = 0, tot = 0;
  dfn[a] = low[a] = ++tot;
  for (int i = 0; i < adj[a].size(); ++i) {
    int b = adj[a][i];
    if (!dfn[b]) {
      stk[++top] = Edge(a, b);
      int temp = top;
      tarjan(b, a);
      low[a] = std::min(low[a], low[b]);
      if (low[b] >= dfn[a]) {
        static int tag[N], cnt;
        ++cnt;
        int v = 0, e = top - temp + 1;
        for (; top >= temp; --top) {
          int x = stk[top].first, y = stk[top].second;
          if (tag[x] != cnt) ++v, tag[x] = cnt;
          if (tag[y] != cnt) ++v, tag[y] = cnt;
        }
        ans = (i64)ans * (v == e ? f[v] : binom(e + k - 1, k - 1)) % MOD;
      }
    } else if (b != pre) {
      low[a] = std::min(low[a], dfn[b]);
      if (dfn[b] < dfn[a]) stk[++top] = Edge(a, b);
    }
  }
}

int main() {
  init();
  ans = 1;
  for (int i = 1; i <= n; ++i) if (!dfn[i]) tarjan(i, -1);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    int n;
    cin>>n;
    int a[114514];
    int c[114514]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
        c[a[i]-1]++;
        c[a[i]]++;
        c[a[i]+1]++;
    }
    int ans=0;
    for(int i=0;i<100002;i++){
        if(c[i]>=c[ans])ans=i;
    }
    cout<<c[ans]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;

const int maxn = 3005,mo = int(1e9) + 7;

string s;
int a[maxn],m,far[maxn],f[maxn][maxn],co[maxn],n,ans;

int dfs(int l,int r,int c)
{
	if (l == n + 1) return 1;
	if (r < far[l]) c += co[far[l]] - co[r],r = far[l];
	if (~f[l][c]) return f[l][c];
	int ans = 0;
	if (c) ans = (ans + dfs(l + 1,r,c - 1)) % mo;
	if (r - l + 1 - c) ans = (ans + dfs(l + 1,r,c)) % mo;
	return f[l][c] = ans;
}

int main()
{
	cin >> n >> m;
	cin >> s;
	for(int i = 1;i <= n;i ++) a[i] = s[i - 1] - '0',co[i] = co[i - 1] + a[i];
	for(int i = 1,l,r;i <= m;i ++) cin >> l >> r,far[l] = max(far[l],r);
	for(int i = 1;i <= n;i ++) far[i] = max(far[i],far[i - 1]),far[i] = max(far[i],i);
	memset(f,255,sizeof f);
	cout << dfs(1,0,0) << endl;
	return 0;
}


Measured memory_bytes: 35840
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Func<long[]> read = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
		var h = read();
		var k = (int)h[1];
		var s = new int[h[0]].Select(_ => read()).OrderByDescending(x => x[1]).ToArray();

		var g0 = s.Take(k).ToLookup(x => x[0], x => x[1]);
		var l0 = g0.SelectMany(g => g.Skip(1)).OrderBy(x => x).ToList();
		var l1 = s.Where(x => !g0.Contains(x[0])).GroupBy(x => x[0]).Select(g => g.First()[1]).ToList();

		long r = g0.SelectMany(x => x).Sum() + (long)g0.Count * g0.Count, M = r;
		for (int i = 0; i < l0.Count && i < l1.Count; i++) M = Math.Max(M, r += l1[i] - l0[i] + 2 * (g0.Count + i) + 1);
		Console.WriteLine(M);
	}
}


Measured memory_bytes: 38512
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

string S;

signed main(){

    in(S);
    int res=0;
    for(auto e:S) if(e=='o') res++;
    res+=15-S.size();
    show(res);
    YN(res>=8);

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    string str; cin >> str;
    int n = str.size();
    int s[n];
    for(int i=0;i<n;i++) s[i] = str[i]-'0';

    ll ans = 0;
    for(int bit=0;bit<(1<<n-1);bit++){
        int place = 0;
        ans += s[n-1];
        for(int i=n-2;i>=0;i--){
            if(bit & (1<<i)){
                place++;
            }
            else{
                place = 0;
            }
            ans += s[i]*pow(10,place);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int A,B;
    cin >> A >> B;

    cout << 6 - (A + B) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int distance,Time_minutes,displacement,calculation;
 scanf(" %d%d%d",&distance,&Time_minutes,&displacement);
 calculation=Time_minutes*displacement;
 if(calculation>=distance){
  printf("Yes\n");
 }
 else
 printf("No\n");
return 0;
}

Measured memory_bytes: 1648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] B = new int[N - 1];
			for(int i = 0; i < N - 1; i++) {
				B[i] = in.nextInt();
			}
			long ans = 0;
			for(int i = 0; i < N; i++) {
				if(i == 0) {
					ans += B[i];
				} else if(i != N - 1){
					ans += Math.min(B[i], B[i - 1]);	
				} else {
					ans += B[i - 1];
				}
			}
			System.out.println(ans);
			
		}
	}
	
	static boolean permutation_2(String s, String t){
        if(s.length() != t.length()){
            return false;
        }
        
        int[] letters = new int[256]; //文字コードの仮定;
        
        char[] s_array = s.toCharArray();  
        for(char c:s_array){
            letters[c]++;
        }
        
        for(int i=0;i<t.length();i++){
            int c = (int)t.charAt(i);
            if(--letters[c] < 0){
                return false;
            }
        }
        return true;
    }

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 21332
#! /usr/bin/env python3
a, b = input().split()
c = d = 0
if float(a) > 0 and '.' in a : c = a[::-1].find('.')
if float(b) > 0 and '.' in b : d = b[::-1].find('.')
t = int(a.replace('.', '')) * int(b.replace('.', ''))
if t == 0 or len(str(t)) < c+d:
    print(0)
elif c+d < 1:
    print(t)
else:
    print(str(t)[:-(c+d)])

Measured memory_bytes: 9088
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> T(N), X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i] >> X[i] >> Y[i];
  }
  int last_x = 0, last_y = 0, last_t = 0;
  bool ok = true;
  for (int i = 0; i < N; i++) {
    int x = X[i], y = Y[i], t = T[i];
    if (t % 2 != (x + y) % 2) ok = false;
    int d = abs(x - last_x) + abs(y - last_y);
    if (d > t - last_t) ok = false;
    last_x = x;
    last_y = y;
    last_t = t;
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

string S, head="", tail="";
bool rev=false;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> S;
    int Q;
    cin >> Q;

    while(Q--) {
        int op;
        cin >> op;
        if(op == 1) {
            rev ^= 1;
        } else {
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(f == 1) {
                if(rev) {
                    tail += c;
                } else {
                    head += c;
                }
            } else {
                if(rev) {
                    head += c;
                } else {
                    tail += c;
                }
            }
        }
    }
    if(rev) {
        reverse(ALL(S));
        reverse(ALL(tail));
        cout << tail << S << head << endl;
    } else {
        reverse(ALL(head));
        cout << head << S << tail << endl;
    }
    return 0;
}

Measured memory_bytes: 1040
N = int(input())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  return divisors

div = make_divisors(N)
ans = 0
for d in div:
  if d != 1 and N // (d - 1) == N % (d - 1):
    ans += d - 1

print(ans)

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0;i < n;i++){
        cin >> a[i];
        a[i]--;
    }
    vector<long long> c(n,0);
    for (long long i = 0;i < n;i++){
        c[a[i]]++;
    }
    long long sum = 0;
    for (long long i = 0; i < n; i++){
        sum += c[i]*(c[i]-1)/2;
    }
    //cout << sum << endl;

    for (long long i = 0; i < n; i++){
        long long ans = sum;
        ans -= (c[a[i]])*(c[a[i]]-1)/2;
        ans += (c[a[i]]-1)*(c[a[i]]-2)/2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    for (ll& a : A) cin >> a;
    for (ll& b : B) cin >> b;
    vector<ll> asum(N+1), bsum(M+1);
    asum[0] = 0;
    for (int i = 0; i < N; ++i) asum[i+1] = asum[i] + A[i];
    bsum[0] = 0;
    for (int i = 0; i < M; ++i) bsum[i+1] = bsum[i] + B[i];
    int ans = 0;
    for (int i = 0; i <= N; ++i) {
        if (K-asum[i] < 0) continue;
        int bi = upper_bound(begin(bsum), end(bsum), K-asum[i]) - begin(bsum);
        ans = max(ans, i + bi-1);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9592