akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N;
	long long L, T;
	scanf("%d %lld %lld", &N, &L, &T);
	int W[N];
	long long X[N], Xf[N];
	for (int i = 0; i < N; ++i) scanf("%lld %d", &X[i], &W[i]);
	for (int i = 0; i < N; ++i) {
		if (W[i] == 1) Xf[i] = (X[i] + T) % L;
		else Xf[i] = ((X[i] - T) % L + L) % L;
	}
	long long cnt = 0, sp = Xf[0];
	for (int i = 1; i < N; ++i) {
		if (W[i] != W[0]) {
			if (W[0] == 1 && 2 * T > X[i] - X[0]) cnt += (2 * T - X[i] + X[0] + L - 1) / L;
			else if (W[0] == 2 && 2 * T > L + X[0] - X[i]) cnt -= (2 * T - X[0] + X[i] - 1) / L;
		}
	}
	cnt = (cnt % N + N) % N;
	sort(Xf, Xf + N);
	int fidx;
	if (W[0] == 1) fidx = lower_bound(Xf, Xf + N, sp) - Xf;
	else fidx = upper_bound(Xf, Xf + N, sp) - Xf - 1;
	long long ans[N];
	for (int i = 0; i < N; ++i) ans[(cnt + i) % N] = Xf[(fidx + i) % N];
	for (int i = 0; i < N; ++i) printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 4448
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace Line
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var s = cin.Read;
            WriteLine(s.Count(x => x == '1'));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11348
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int k;
int sums[2000][2000][2] = {};

int getnum(int x1, int y1, int x2, int y2, int c) {
	int result = sums[x2][y2][c];
	if (x1 > 0) result -= sums[x1 - 1][y2][c];
	if (y1 > 0) result -= sums[x2][y1 - 1][c];
	if (x1 > 0 && y1 > 0) result += sums[x1 - 1][y1 - 1][c];
	return result;
}

int solve(int i, int j, int c) {
	int result = getnum(i, j, i + k - 1, j + k - 1, c);
	if (i > 0 && j > 0) result += getnum(0, 0, i - 1, j - 1, c);
	if (i > 0) result += getnum(0, j + k, i - 1, 2 * k - 1, c);
	if (j > 0) result += getnum(i + k, 0, 2 * k - 1, j - 1, c);
	result += getnum(i + k, j + k, 2 * k - 1, 2 * k - 1, c);
	// cout << "\t" << result << endl;
	if (i > 0) result += getnum(0, j, i - 1, j + k - 1, !c);
	if (j > 0) result += getnum(i, 0, i + k - 1, j - 1, !c);
	result += getnum(i + k, j, 2 * k - 1, j + k - 1, !c);
	result += getnum(i, j + k, i + k - 1, 2 * k - 1, !c);
	// cout << "\t" << result << endl;
	return result;
}

int main() {
	int n;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		x %= 2 * k;
		y %= 2 * k;
		if (c == 'B')
			sums[x][y][0]++;
		else
			sums[x][y][1]++;
	}
	for (int i = 0; i < 2 * k; i++) {
		for (int j = 1; j < 2 * k; j++) {
			for (int p = 0; p < 2; p++) {
				sums[i][j][p] += sums[i][j - 1][p];
			}
		}
	}
	for (int i = 0; i < 2 * k; i++) {
		for (int j = 1; j < 2 * k; j++) {
			for (int p = 0; p < 2; p++) {
				sums[j][i][p] += sums[j - 1][i][p];
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			for (int p = 0; p < 2; p++) {
				// cout << i << " " << j << " " << p << endl;
				// cout << solve(i, j, p) << endl;
				ans = max(ans, solve(i, j, p));
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 31488
#include<iostream>
using namespace std;
int main(){
  long long N,M,a,b,count=0;
  cin>>N>>M;
  long long H[N],t[N]={};
  for(int k=0;k<N;k++){
    cin>>H[k];
  }
  for(int k=0;k<M;k++){
    cin>>a>>b;
    if(H[a-1]==H[b-1]) t[a-1]=1,t[b-1]=1;
    else if(H[a-1]>H[b-1]) t[b-1]=1;
    else t[a-1]=1;
  }
  for(int k=0;k<N;k++){
    if(t[k]==0) count+=1;
  }
  cout<<count;
}

Measured memory_bytes: 5172
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

long long d, g;
vector<pair<long long, long long>> p;

long long solve();

int main() {
  cin >> d >> g;
  p.resize(d);
  for(int i = 0; i < d; ++i) cin >> p[i].fi >> p[i].se;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 1e9;
  for(int i = 0; i < (1 << d); ++i) {
    long long nows = 0, nowcnt = 0;
    for(int j = 0; j < d; ++j)
      if((i >> j) & 1) {
        nows += p[j].fi * (1 + j) * 100 + p[j].se;
        nowcnt += p[j].fi;
      }
    if(nows >= g) {
      ans = min(ans, nowcnt);
      continue;
    }
    for(int j = 0; j < d; ++j)
      if(!((i >> j) & 1) &&
         g - nows <= (j + 1) * 100 * p[j].fi) {
        ans = min(ans,
                  nowcnt + (g - nows + (j + 1) * 100 - 1) /
                               ((j + 1) * 100));
      }
  }
  return ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,all[100005]={0},ban[100005]={0};
    scanf("%d",&n);
    for(int i = 1;i<=n;i++)
        scanf("%d",&all[i]);
    for(int i = 1;i<=n;i++)
    {
        ban[all[i]]=i;
    }
    for(int i = 1;i<=n;i++)
    {
        printf("%d ",ban[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	unordered_map<string,int> m;
	cin >> n;
	while(n--){
		string s;
		cin >> s;
		sort(s.begin(),s.end());
		++m[s];
	}
	ll ans = 0;
	for(auto&p:m){
		ll x = p.second;
		ans += x*(x-1)/2;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 10660
// atc.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <string>
#include    <algorithm>
using namespace std;

int main()
{
	string S;
	cin >> S;

	if (S == "ABC") {
		cout << "ARC";
	}
	else {
		cout << "ABC";
	}

	return 0;

}


Measured memory_bytes: 3632
/* 0-1 Knapsack Problem II
 *
 * Input
 * N W
 * v1 w1
 * :
 *
 * Constraints
 * 1 ≤ N ≤ 100
 * 1 ≤ vi ≤ 100
 * 1 ≤ wi ≤ 10,000,000
 * 1 ≤ W ≤ 1,000,000,000
 */

#include <algorithm>
#include <iostream>
#include <vector>

#define MAXV 110
#define MAXN 110
#define INF 1 << 30

using namespace std;
struct item {
  int v, w;
};

int dp[MAXN][MAXV * MAXN];
int main() {
  for (int i = 0; i < MAXN; ++i)
    fill(dp[i], dp[i] + (MAXV * MAXN), INF);
  int n, w;
  cin >> n >> w;
  vector<item> knap;
  int maxv = -1;
  for (int i = 0, nextv, nextw; i < n; ++i) {
    cin >> nextv >> nextw;
    knap.push_back({nextv, nextw});
    maxv = max(nextv, maxv);
  }

  for (int i = 0; i < n; ++i)
    dp[i][0] = 0;
  int vlim = n * maxv;
  for (int v = 1; v <= knap[0].v; ++v)
    dp[0][v] = knap[0].w;
  for (int i = 1; i < n; ++i)
    for (int v = 1; v <= vlim; ++v)
      dp[i][v] =
          min(knap[i].w + dp[i - 1][max(0, v - knap[i].v)], dp[i - 1][v]);
  cout << lower_bound(dp[n - 1], dp[n - 1] + vlim + 1, w + 1) - dp[n - 1] - 1
       << endl;
}


Measured memory_bytes: 8356
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
long double nibeki(long double a){
    double t = 1;
    while(a > t){
        t = 2*t;
    }
    return t;
}
int main(){
    long double n,k;
    cin >> n >> k;
    long double ans = 0;
    long double tem;
    long double tem2;
    for(int i = 1;i<=n;i++){
        tem = nibeki(k/i);
        tem2 = (1/tem)*(1/n);
        ans+=tem2;
    }
    cout << setprecision(10) << ans << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a == b){
        cout << "Draw" << endl;
        return 0;
    }
    if(a == 1){
        cout << "Alice" << endl;
        return 0;
    } else if (b == 1){
        cout << "Bob" << endl;
        return 0;
    }
    if(a < b){
        cout << "Bob" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
//  int  a ,b, c, d, e, X, Y ,r;
  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  long long min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld%lld%lld", &a,&b,&c);
  d=a/(b+c);
  
  X=a-((b+c)*(d));
//  printf("%lld\n", (b*(j))+X);
  if(X<=b)  printf("%lld\n", (b*(d))+X);
  else printf("%lld\n", (b*(d+1)));
  
  
return 0;
}


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

int main(void) {
  int H, W;
  cin >> H >> W;
  H += 2;
  W += 2;
  char map[H][W];
  for (int w = 0; w < W; w++) map[H - 1][w] = map[0][w] = '#';
  for (int h = 1; h < H - 1; h++) {
    map[h][0] = '#';
    cin >> map[h] + 1;
    map[h][W - 1] = '#';
  }

  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      cout << map[h][w];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const ll MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  ll n,T;
  cin >> n >> T;
  vector<ll>t(n);
  for(int i=0;i<n;i++) cin >> t[i];
  ll sum = T;
  for(int i=0;i<n-1;i++){
    sum += min(t[i+1]-t[i],T);
  }
  cout<< sum <<endl;

}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int N, Y;
    cin >> N >> Y;
    for (int x=0; x<=N; ++x) {
        for (int y=0; y<=N-x; ++y) {
            int z=N-x-y;
            if (Y == 10000*x+5000*y+1000*z) {
                cout << x << ' ' << y << ' ' << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
k = 0
liss = list(s)
for i in range(len(s) - 2):
    if (liss[i] == 'A') & (liss[i + 1] == 'B') & (liss[i + 2] == 'C'):
        k += 1
print(k)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const long long INF = (long long) 1e18;
const int mod = (int) 1e9+7;
const int MAXN = (int) 3e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n, m;
ll dp[MAXN];
vector<int> adj[MAXN];

void dfs(int a){
    if(dp[a] != -1) return ;
    dp[a] = 0;
    for(int i: adj[a]){
        dfs(i);
        dp[a] = max(dp[a], dp[i] + 1);
    }
}




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);

    #ifdef Local
        freopen("../IO/int.txt","r",stdin);
        freopen("../IO/out.txt","w",stdout);
    #endif

    cin>>n>>m;

    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
    }
    for(int i = 1; i <= n; i++){
        dp[i] = -1;
    }
    ll mx = 0;
    for(int i = 1; i <= n; i++){
        if(dp[i] == -1){
            dfs(i);
        }
        mx = max(mx, dp[i]);
    }
    cout<<mx<<endl;

    #ifdef Local
        cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
    #endif
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> vec(m);
  for(int i=0;i<m;++i){
	int k;
    cin >> k;
	vec.at(i).resize(k);
	for(int j=0;j<k;++j){
	  cin >> vec.at(i).at(j);
	  --vec.at(i).at(j);
	}
  }
  vector<int> p(m);
  for(int i=0;i<m;++i){
    cin >> p.at(i);
  }
  int ans=0;
  for(int i=0;i<(1<<n);++i){
	bool ok=true;
	for(int j=0;j<m;++j){
	  int c=0;
	  for(int id:vec.at(j)){
		if((i>>id)&1){
		  ++c;
		}
	  }
	  c%=2;
	  if(c!=p.at(j)){
		ok=false;
	  }
	}
	if(ok){
	  ++ans;
	}
  }
  cout << ans << endl;
}

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

const int N = 3005;

int n, a[N], head[N], tot;
struct edge { int to, nxt; } e[N << 1];

void link(int x, int y) {
	e[++tot] = (edge) { y, head[x] }, head[x] = tot;
	e[++tot] = (edge) { x, head[y] }, head[y] = tot;
}

bool dfs(int x, int f = 0) {
	for (int i = head[x]; i; i = e[i].nxt)
		if (e[i].to != f && a[e[i].to] < a[x] && !dfs(e[i].to, x))
			return 1;
	return 0;
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
		std::cin >> a[i];
	for (int i = 1, x, y; i < n; ++i)
		std::cin >> x >> y, link(x, y);
	for (int i = 1; i <= n; ++i)
		if (dfs(i)) std::cout << i << ' ';
	std::cout << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>


int main()
{
  int n,  q ,C=0,i,j,left,right,mid;

  scanf("%d",&n);
  int S[n];
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  int T[q];
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }


  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      
      mid=(left+right)/2;
      if(T[i]==S[mid]){
	C++;
	break;
      }
      
      else if(T[i]<S[mid]){
	right=mid;
      }
      
      else{
      left=mid+1;
      }
    }
  }

   printf("%d\n",C);

  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll a, b;
	cin >> n >> a >> b;
	a -= b;
	vector<ll> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	ll ng = 0, ok = 1e9;
	while (ok - ng > 1) {
		ll mid = (ok + ng) / 2;
		ll cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += max((h[i] - mid * b + a - 1) / a, 0LL); 
		}
		if (cnt > mid) ng = mid;
		else ok = mid;
	}
	cout << ok << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;

int main(){
  int H, W;
  cin >> H >> W;
  vvi dp(10, vi(10, INT_INF));
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
     cin >> dp.at(i).at(j);
    }
  }
  vi counter(10, 0);
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      int A;
      cin >> A;
      if(A != -1) counter.at(A)++;
    }
  }



  for(int k = 0; k < 10; k++){
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
        chmin(dp.at(i).at(j), dp.at(i).at(k) + dp.at(k).at(j));
      }
    }
  }

  int result = 0;
  for(int i = 0; i < 10; i++){
    result += dp.at(i).at(1) * counter.at(i);
  }
  cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int A,B,X;
        A=sc.nextInt();
        B=sc.nextInt();
        X=sc.nextInt();
        if ( X % 500 != 0){
            X += 500 - X%500;
        }
        int a = 0;
        int b = 0;
        if ( A < B ) {
            a = X/1000 + ((X%1000>0)?1:0);
        } else if ( A > 2*B ){
            b = X/500;
        } else {
            a = X/1000; X %= 1000;
            b = X/500;
        }
        System.out.println(A*a + B*b);
    }
}


Measured memory_bytes: 26212
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
#define inf LLONG_MAX
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 


int main(){
 
 /*#ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/

ll a,b;
sfl(a);sfl(b);
cout<<max(0LL,a-2*b);














   return 0;
 }

Measured memory_bytes: 256
#include <stdio.h>

typedef long long int ll;

ll solve(ll n) {
    switch(n % 4) {
        case 0: return n; break;
        case 1: return 1; break;
        case 2: return n+1; break;
        case 3: return 0; break;
    }
}

int main() {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    printf("%lld\n", solve(a-1)^solve(b));
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll tmp = c-a-b;
    if(tmp > 0 && tmp*tmp > 4*a*b) print("Yes");
    else print("No");
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3616
import math
import fractions
A,B = map(int, input().split())
gcd = fractions.gcd(A,B)

"""素因数分解"""
def factorization(n):
    array = [[1,1]]
    temp = n
    for i in range(2, int(math.sqrt(n))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            array.append([i, cnt])

    if temp != 1:
        array.append([temp, 1])

    return array

factorization_array = factorization(gcd)
print(len(factorization_array))

Measured memory_bytes: 5048
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>
#include <bitset>

using namespace std;

typedef long double ld;
typedef long long li;
typedef vector<li> vec;
typedef vector<vector<li>> mt;
typedef pair<int, int> pii;

#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(a) int(a.size())

const double PI = 3.14159265358979323846;
const double EPS = 1e-15;
const int INF = 1e9 + 7;
const li LINF = 8e18 + 7;

const int N = 2e5 + 7;

vector<int> g[N];


int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);


	int n, m;
	cin >> n >> m;

	string s;
	cin >> s;

	forn(i, m) {
		int x, y;
		cin >> x >> y;
		x--, y--;

		g[x].push_back(y);
		g[y].push_back(x);
	}

	vector<int> cntA(n), cntB(n);
	set<pair<int, int>> sA, sB;
	forn(i, n) {
		for (int to : g[i]) {
			if (s[to] == 'A') {
				cntA[i]++;
			}
			else {
				cntB[i]++;
			}
		}

		sA.insert({ cntA[i], i });
		sB.insert({ cntB[i], i });
	}

	while (!sA.empty()) {
		if (sA.begin()->first <= 0) {
			int v = sA.begin()->second;

			//cout << v << endl;

			sA.erase({ cntA[v], v });
			sB.erase({ cntB[v], v });

			for (int to : g[v]) {
				if (s[v] == 'A') {
					if (sA.count({ cntA[to], to })) {
						sA.erase({ cntA[to] , to });
						cntA[to]--;
						sA.insert({ cntA[to], to });
					}
				}
				else {
					if (sB.count({ cntB[to], to })) {
						sB.erase({ cntB[to] , to });
						cntB[to]--;
						sB.insert({ cntB[to], to });
					}
				}
			}

			continue;
		}

		if (sB.begin()->first <= 0) {
			int v = sB.begin()->second;

			//cout << v << endl;

			sA.erase({ cntA[v], v });
			sB.erase({ cntB[v], v });

			for (int to : g[v]) {
				if (s[v] == 'A') {
					if (sA.count({ cntA[to], to })) {
						sA.erase({ cntA[to] , to });
						cntA[to]--;
						sA.insert({ cntA[to], to });
					}
				}
				else {
					if (sB.count({ cntB[to], to })) {
						sB.erase({ cntB[to] , to });
						cntB[to]--;
						sB.insert({ cntB[to], to });
					}
				}
			}

			continue;
		}

		break;
	}

	if (!sA.empty() && !sB.empty()) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}

Measured memory_bytes: 29776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;

  ll sum = 0;
  ll cnt = 0;
  while (sum < n) {
    cnt++;
    sum += cnt;
  }

  cerr << sum << endl;
  rep(i, cnt) {
    if (i+1 == sum-n) {
      continue;
    }
    cout << i+1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t, u;
	int a, b;

	cin >> s >> t >> a >> b >> u;
	if(s == u) {
		a--;
	}
	else {
		b--;
	}

	cout << a << " " << b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 200000000;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    int n;
    cin >> n;
    auto p = make_vec<int>(n);
    REP(i, n) { cin >> p.at(i); }

    int ans = 0;
    REP(i, n) { ans += p[i]; }
    cout << ans - ((*max_element(ALL(p))) / 2) << endl;

    return 0;
}


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

int main(){
    int n,m;
    int mi=1000000001;
    int res=-1000000001;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>m;
        if(m-mi>res&&i!=0) res=m-mi;
        if(m<=mi)mi=m;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  // int n;
  // std::cin >> n;
  // std::vector<long long> l(n);
  // for(int i = 0; i < n; i++)
  // {
  //   std::cin >> l[i];
  // }
  // std::sort(l.begin(), l.end());
  
  int n; cin >> n;
  vector<long long> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];
  sort(l.begin(), l.end()); // L をソートしておく (二分探索に必要)

  // long long res = 0;
  
  // long long ans = 0;
  // for(int i = 0; i < n; ++i)
  // {
  //   for(int j = i+1; j < n; ++j)
  //   {
  //     // int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));
  //     int k = std::lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();

  //     ans += std::max(k-(j+1),0);
  //   }
  // }
  // std::cerr << ans << std::endl;
  long long ans = 0;
    
  // a と b を固定
  for (int i = 0; i < n; ++i) {
      for (int j = i+1; j < n; ++j) {
          // c の動ける範囲の右端を求める
          // int k = std::lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
          int k = std::distance(l.begin(),std::lower_bound(l.begin(), l.end(), l[i]+l[j]));

          // c の動ける範囲は、[j+1, k)
          ans += std::max(k - (j+1), 0);
      }
  }
  cout << ans << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int S,K, C=0;
	scanf("%d%d", &K, &S);
	for(int X=0;X<=K;X++){
		for(int Y=0;Y<=K;Y++){
			int Z=S-(X+Y);
			if(Z>=0&&Z<=K)
			C++;
		}
	}
	printf("\n%d", C);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    int p[N+1];

    for(int i = 1; i <= N; i++){
        scanf("%d", &p[i]);
    }

    int c = 0;

    for(int i = 1; i < N; i++){
        if(p[i] == i){
            c++;
            p[i+1] = i;
        }
    }
    if(p[N] == N){
        c++;
    }

    printf("%d\n", c);

    return 0;
}

Measured memory_bytes: 2092
#include <iostream>
#include <algorithm>
#include <cstring>

// bit
unsigned int senbei[10000];

int main() {
	unsigned int r, c;
	while (std::cin >> r >> c, r + c != 0) {
		std::memset(senbei, 0, sizeof(senbei));
		for (unsigned int i = 0; i < r; ++i) {
			for (unsigned int j = 0; j < c; ++j) {
				unsigned int b;
				std::cin >> b;
				senbei[j] |= (b << i);
			}
		}

		const unsigned int maskUp = 1u << r;
		int ans = 0;
		for (unsigned int mask = 0; mask < maskUp; ++mask) {
			int count = 0;

			for (unsigned int i = 0; i < c; ++i) {
				auto reversed = senbei[i] ^ mask;
				int num = 0;
				while (reversed != 0) {
					++num;
					reversed &= reversed - 1;
				}

				count += (num > r / 2 ? num : r - num);
			}

			ans = std::max(ans, count);
		}

		std::cout << ans << std::endl;
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 
const int SEARCH_MAX = 6e3;

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; ++i) cin >> S.at(i);
  
  // 最大値とカウント数
  map<string, int> a;
  int max_val = 0;
  for (int i = 0; i < N; ++i) {
    a[S.at(i)] = a[S.at(i)] + 1;
    max_val = max(max_val, a.at(S.at(i)));
  }
  
  vector<string> List;
  for (auto p : a) {
    if (p.second == max_val) List.push_back(p.first);
  }
  
  sort(List.begin(), List.end());
  for (int i = 0; i < List.size(); ++i) cout << List.at(i) << endl;
}

Measured memory_bytes: 28404
n, m = map(int, raw_input().split())
X = map(int, raw_input().split())
X.sort()
Y = map(int, raw_input().split())
Y.sort()

ya = 0
for i in xrange(m-1):
    ya += (Y[i+1]-Y[i]) * (i+1) * (m-i-1)
xa = 0
for i in xrange(n-1):
    xa += ya * (X[i+1]-X[i]) * (i+1) * (n-i-1)
print xa % (10**9 + 7)

Measured memory_bytes: 14628
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    map<string, ll> S;
    string s;
    for(size_t i=0;i<N; i++)
    {
        cin >> s;
        S[s]++;
    }
    cout << S.size() << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 19284
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<unordered_map>

using namespace std;

int main() 
{ 
	int n;
	cin>>n;
	long long int ar[n+1];
	long long int cum[n+1];
	ar[0]=cum[0]=0;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
		cum[i] = cum[i-1]+ar[i];
	}

	long long int dp[n+1][n+1];
	for(int i=1;i<=n;i++)
		dp[i][i]=0;
	for(int i=1;i<n;i++){
		dp[i][i+1] = ar[i]+ar[i+1];
	}
	// cout<<dp[1][2]<<endl;
	for(int i=3;i<=n;i++){
		for(int j=1;j<=n-i+1;j++){
			int y = j+i-1;
			long long int m = LLONG_MAX;
			for(int k=j;k<y;k++){
				m = min(m,dp[j][k]+dp[k+1][y]+cum[y]-cum[j-1]);
			}
			dp[j][y] = m;
			// cout<<j<<" "<<y<<" "<<m<<endl;
		}
	}
	cout<<dp[1][n];
	// for(int i=1;i<=n;i++){
	// 	for(int j=1;j<=n;j++){
	// 		// cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// 
} 

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define sortV(v) v.begin(),v.end()
//#define mp map<int,int>
//#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n;
   cin>>n;
   int arr[n+1];
   repre(i,1,n)cin>>arr[i];
   int res=0;
   int ans[n+1]={0};
   int temp=n/2;
   for(int i=temp+1;i<=n;i++)
   {
     if(arr[i]==1){ans[i]=1;res++;}
   }
   for(int i=temp;i>=1;i--)
   {
     int sum=0;
     for(int j=i;j<=n;j+=i)
     sum+=ans[j];
     int curr=sum%2;
     if(curr==arr[i])ans[i]=0;
     else {ans[i]=1;res++;}
   }
   cout<<res<<endl;
   repre(i,1,n)
   {
     if(ans[i]!=0)cout<<i<<" ";
   }

   return 0;
}


Measured memory_bytes: 3968
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v;
  for(int i=1;i<=n;i++){
    int p;
    cin>>p;
    v.push_back(p);
  }
  int ans=1;
  int cnt=v[0];
  for(int i=1;i<=n-1;i++){
    if(cnt>v[i]){
      ans+=1;
      cnt=v[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1400
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n, a, b;
    cin >> n >> a >> b;
    if (a > b || (a != b && n == 1))  
        cout << 0, exit(0);
    if (a == b || n == 2)
        cout << 1, exit(0);
    cout << (ll) (b-a) * 1ll * (n-2) + 1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){

	double x1, y1, x2, y2;


	scanf( "%lf %lf %lf %lf", &x1, &y1, &x2, &y2 );


	printf( "%lf\n", hypot(x2-x1,y2-y1) );


	return 0;

}

Measured memory_bytes: 660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    string s;
    cin >> s;
    if(s=="AAA" || s=="BBB"){
	    cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#define rep(i,N) for(long long i=0; i<N; i++)
using namespace std;

long long mod = 1000000007;


auto return_sum(vector<long long> A){
    vector<long long> S(A.size()+1);
    S[0] = 0;
    for(long long i = 0; i < A.size(); i++){
        S[i+1] = (S[i] + A[i]) % mod;
    }
    return S;
}

int main(){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i=0; i<N; i++){
        cin>>A[i];
    }
    vector<long long> S = return_sum(A);
    
    long long sum=0;
    rep(i,N-1){
        sum += (A[i] *(S[N]-S[i+1] + mod)%mod) % mod;
    }
    cout << sum%mod << endl;
}

Measured memory_bytes: 7976
from fractions import gcd

A, B, C, D = map(int, input().split())
E = (C*D)//gcd(C, D)

a = B//C-(A-1)//C
b = B//D-(A-1)//D
c = B//E-(A-1)//E
print(B-A+1-a-b+c)

Measured memory_bytes: 5048
n=int(input())
a=[]
c=[]
count=0
ans=0
for i in range(n):
    x=list(input())
    a.append(x)
for j in range(n):
    a[j].sort()
a.sort()
for k in range(n-1):
    if a[k]==a[k+1]:
        if k==0 or a[k-1]!=a[k]:
            count+=2
        else:
            count+=1
        if k==n-2:
            c.append(count)
    else:
        c.append(count)
        count=0
for l in range(len(c)):
    ans+=int(c[l]*(c[l]-1)/2)
print(ans)

Measured memory_bytes: 25284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n + k);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector<ll> dp(n + k);
    dp.assign(n, INF);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout << dp[n - 1] << endl;

    return 0;
}

Measured memory_bytes: 4820
#include<stdio.h>
int main(){
	int n_snuke;
	scanf("%d", &n_snuke);
	int trt_count[n_snuke+1];
	for(int snuke = 1; snuke <= n_snuke; snuke++)
		trt_count[snuke] = 1;

	int n_trtkinds;
	scanf("%d", &n_trtkinds);
	for(int trt_i = 1; trt_i <= n_trtkinds; trt_i++){
		int n_trt_i, trt_i_to;
		scanf("%d", &n_trt_i);
		for(int trt_i_index = 1; trt_i_index <= n_trt_i; trt_i_index++){
			scanf("%d", &trt_i_to);
			trt_count[trt_i_to] = 0;
		}
	}
	
	int ans = 0;
	for(int snuke = 1; snuke <= n_snuke; snuke++)
		ans += trt_count[snuke];
	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 1732
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np
# from numpy import cumsum  # accumulate

def solve():
    N, K = MI()
    A = LI()

    M = sum(A)
    divs = []
    for i in range(1, int(pow(M, 0.5))+1):
        if M % i: continue
        divs.append(i)
        if i != M//i: divs.append(M//i)
    divs.sort(reverse=True)

    for d in divs:
        B = list(map(lambda x: x%d, A))
        B.sort()
        C = list(map(lambda x: d-x, B))
        # print(d, B, C)
        # print(list(accumulate(B)), list(accumulate(C)))
        Ba = list(accumulate(B))
        Ca = list(accumulate(C))
        for i in range(0, N-1):
            b = Ba[i]
            c = Ca[-1] - Ca[i]
            # print(b, c)
            if b == c and b <= K:
                print(d)
                return
    print(1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <bitset>
#include <random>


int main() {
	long long int a, b, c; std::cin >> a >> b >> c;
	if (c > a + b && (c - a - b) * (c - a - b) > 4 * a * b) {
		std::cout << "Yes\n";
	}
	else {
		std::cout << "No\n";
	}
}

Measured memory_bytes: 888
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

string name[9];

int G[9][2];

int Gnum = 0;

int GM = 0;

int main(void)
{
	for (int i = 0; i < 9; i++)
	{
		cin >> name[i];

		for (int j = 0; j < 2; j++)
		{
			cin >> G[i][j];

		}

	}

	for (int i = 0; i < 9;i++)
	{
		for (int j = 0; j < 2;j++)
		{
			Gnum += G[i][j];

			if (j==0)
			{
				GM += G[i][j] * 200;
			}
			else 
			{
				GM += G[i][j] * 300;
			}
		}

		cout << name[i] << " ";

		cout << Gnum << " " << GM << endl;

		Gnum = GM = 0;
	}


}


Measured memory_bytes: 3220
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct D{int n,s,t,p[15];}D;
D team[55];
int M,T,P,R,i,m,t,p,j;

int cmp(const void *a,const void*b)
{
	D x=(*(D*)a),y=(*(D*)b);
	if(x.s==y.s&&x.t==y.t)return y.n-x.n;
	if(x.s==y.s)return x.t-y.t;
	return y.s-x.s;
}

int main()
{
	for(;scanf("%d%d%d%d",&M,&T,&P,&R),M;)
	{
		memset(team,0,sizeof(team));
		for(i=0;i<T;i++)team[i].n=i+1;
		for(i=0;i<R;i++)
		{
			scanf("%d%d%d%d",&m,&t,&p,&j);
			if(j==0)
			{
				team[t-1].s++;
				team[t-1].t+=m+team[t-1].p[p]*20;
			}
			else
			{
				team[t-1].p[p]++;
			}
		}
		qsort(team,T,sizeof(D),cmp);
		for(i=0;i<T;i++)
			printf("%s%d%s",i==0?"":team[i-1].s==team[i].s&&team[i-1].t==team[i].t?"=":",",team[i].n,i==T-1?"\n":"");
	}
	return 0;
}

Measured memory_bytes: 608
def solve():
    H, W, D = map(int, input().split())

    MAP = {}
    for h in range(H):
        L = list(map(int, input().split()))
        for w in range(W):
            MAP[L[w]] = (h,w)


    A = [0] * (H*W)
    for i in range(D, H*W):
        a, b = MAP[i+1]
        c, d = MAP[i+1-D]
        A[i] = A[i-D] + abs(a-c) + abs(b-d)

    Q = int(input())

    for q in range(Q):
        l, r = map(int, input().split())
        print(A[r-1]-A[l-1])
        

if __name__ == "__main__":
    solve()

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

typedef long long ll;
const int mod = 1e9 + 7;

ll N, M;
vector<ll> p, x, y;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;
 
	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}
 
	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}
 
	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}
 
	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
 
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);
 
		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;
 
		return true;
	}
};

int main() {
    cin >> N >> M;
    p.resize(N);
    rep(i, N) {
        cin >> p[i];
        p[i]--;
    }

    x.resize(M);
    y.resize(M);

    UnionFind uf(N);
    rep(i, M) {
        ll tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--;
        tmp2--;
        x[i] = tmp1;
        y[i] = tmp2;
        uf.connect(tmp1, tmp2);
    }

    ll ans = 0;
    rep(i, N) {
        if (uf.root(i) == uf.root(p[i])) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> num(4,0);
    
    num[a]++;
    num[b]++;
    
    for(int i=1;i<=3;i++){
        if(num[i]==0)
            cout<<i<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
# def primes(n):
#     is_prime = [True] * (n + 1)
#     is_prime[0] = False
#     is_prime[1] = False
#     for i in range(2, int(n**0.5) + 1):
#         if not is_prime[i]:
#             continue
#         for j in range(i * 2, n + 1, i):
#             is_prime[j] = False
#     return [i for i in range(n + 1) if is_prime[i]]
# p = primes(4000)
# p.append(1)

n = int(input())
s = str(input())
numr = s.count("R")
numg = s.count("G")
numb = s.count("B")
ans = numr*numb*numg
for i in range(len(s)):
    if s[i] == "R":
        for j in range(len(s)):
            if s[j] == "G":
                if i<j:
                    if i+2*(j-i) < n and  s[i+2*(j-i)] == "B":
                        ans -= 1
                    if i-(j-i) >= 0 and  s[i-(j-i)] ==  "B":
                        ans -= 1
                if i>j:
                    if i-2*(i-j) >= 0 and  s[i-2*(i-j)] == "B":
                        ans -= 1
                    if i+(i-j) < n and s[i+(i-j)] ==  "B":
                        ans -= 1
                if (i+j)%2 == 0 and s[(i+j)//2] == "B":
                    ans -= 1

print(ans)

Measured memory_bytes: 74404
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <vector>
#include <stack>
#define rep(i, n) for (int i = 0; i < n; i++)

int main(int argc, char *argv[]) {
  int a, b;
  std::cin >> a >> b;
  if (a > b) {
    std::cout << "a > b" << std::endl;
  } else if (a < b) {
    std::cout << "a < b" << std::endl;
  } else {
    std::cout << "a == b" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
  int n;cin>>n;
  int ans=n+(n*n)+(n*n*n);
  cout<<ans<<endl;
    
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
      t=1;
    while(t--)
    solve();
}

Measured memory_bytes: 3592
#include<iostream>
#include<stdio.h>

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  int i,j,res1=0;

  for(i=0; i<s.size(); i++){
    if(i%2==0){
      res1 += (s[i] == '1');
    }else{
      res1 += (s[i] == '0');
    }
  }
  int res2 = s.size() - res1;

  cout << min(res1, res2) << "\n";
  return 0;
}


Measured memory_bytes: 512