akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, A, B, C;
    cin >> N >> A >> B >> C;
    bool ans = true;

    vector<string> S(N);
    REP(i,N){
        cin >> S[i];
    }

    vector<char> reply(N);
    REP(i,N){
        string s = S[i];
        if(s == "AB"){
            if(A == 0 && B == 0){
                ans = false;
                break;
            }

            if(A == B){
                if(i == N-1 || S[i+1] == s){
                    A++, B--;
                    reply[i] = 'A';
                }
                else if(S[i+1] == "BC"){
                    A--, B++;
                    reply[i] = 'B';
                }
                else if(S[i+1] == "AC"){
                    A++, B--;
                    reply[i] = 'A';
                }
            }
            else if(A > B){
                A--, B++;
                reply[i] = 'B';
            }
            else{
                A++, B--;
                reply[i] = 'A';
            }
        }
        else if(s == "BC"){
            if(B == 0 && C == 0){
                ans = false;
                break;
            }

            if(B == C){
                if(i == N-1 || S[i+1] == s){
                    B++, C--;
                    reply[i] = 'B';
                }
                else if(S[i+1] == "AC"){
                    B--, C++;
                    reply[i] = 'C';
                }
                else if(S[i+1] == "AB"){
                    B++, C--;
                    reply[i] = 'B';
                }
            }
            else if(B > C){
                B--, C++;
                reply[i] = 'C';
            }
            else{
                B++, C--;
                reply[i] = 'B';
            }
        }
        else if(s == "AC"){
            if(A == 0 && C == 0){
                ans = false;
                break;
            }

            if(A == C){
                if(i == N-1 || S[i+1] == s){
                    A++, C--;
                    reply[i] = 'A';
                }
                else if(S[i+1] == "BC"){
                    A--, C++;
                    reply[i] = 'C';
                }
                else if(S[i+1] == "AB"){
                    A++, C--;
                    reply[i] = 'A';
                }
            }
            else if(A > C){
                A--, C++;
                reply[i] = 'C';
            }
            else{
                A++, C--;
                reply[i] = 'A';
            }
        }
    }

    if(ans){
        cout << "Yes" << endl;
        for(auto&& c : reply)
            cout << c << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 6396
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

foods=[a,b,c,d,e]

ans=0

for i in range(5):
    
    ans+=(foods[i]//10)*10
    foods[i]=foods[i]%10
    
while 0 in foods:
    foods.remove(0)
foods.sort()

if foods!=[]:
    ans+=(foods[0]+(len(foods)-1)*10)
print(ans)


Measured memory_bytes: 3064
N=int(input())
cnt=[int(i) for i in input().split()]
dict={}
for i in range(len(cnt)):
  if cnt[i] in dict:
    dict[cnt[i]]+=1
  else:
    dict[cnt[i]]=1

ans=0
for j,k in dict.items():
  if int(j)>k:
    ans+=k
  else:
    ans+=k-int(j)
print(ans)

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

#define ll long long
#define NIL 0
#define INF 1e18
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define vl vector<ll>
#define vvl vector<vector<ll>> 
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pb push_back
#define F first
#define S second
#define pp pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define rpk(i,k,n) for(int i=k;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++) 
#define RPK(i,k,n) for(int i=k;i<=n;i++) 
#define ritr(i,gr) for(auto i=gr.begin();i!=gr.end();i++)

const int M = 1e9+7;

int V, E, i, j, k, u, v, x, y, p, q, r, t, n,m;
vi *g;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cin>>n;
    int a[n];
    vvl dp(n, vl(n,0));
    ll sum = 0;
    rep(i,n) cin>>a[i], sum+=a[i];
    rep(i,n) dp[i][i] = a[i];
    for(int i=0,j=1;j<n;j++,i++) dp[i][j] = max(dp[i][j-1], dp[i+1][j]);
    
    RPK(j,2,n-1) {
        k = j;
        for(int i=0;k<n;k++,i++) {
            dp[i][k] = 
            max(
                a[i]+min(dp[i+1][k-1], dp[i+2][k]), 
                a[k]+min(dp[i][k-2], dp[i+1][k-1])
                );
        }
    }

    cout<<2*dp[0][n-1]-sum<<endl;
    
    
}
    
    
    

Measured memory_bytes: 73680
#include <bits/stdc++.h>
using namespace std;
int n , candy , x[200] , ans;
int main(){
	cin >> n >> candy;
	for(int i = 1 ; i <= n ; i++){
		cin >> x[i];
	}
	sort(x + 1 , x + n + 1);
	for(int i = 1 ; i <= n ; i++){
		if(candy - x[i] < 0){
			break;
		}
		else{
			candy -= x[i];
			ans++;
		}
	}
	if(candy > 0 && ans == n) cout << ans-1 << endl;
	else cout << ans << endl;
}
// soal B analysis 0

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

int n, k, a[200001], num, ans;

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        scanf("%d", &num);
        a[num]++;
    }
    sort(a + 1, a + n + 1);
    for (int i = n - k; a[i]; i--) ans += a[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int GCD(int a,int b){
	if(a==0){
		return b;
    }
  	return GCD(b%a,a);
}
int gcd(int a, int b,int c){
	int res;
  	res=GCD(GCD(a,b),c);
  	return res;
}
int main(){
  int K;
  cin>>K;
  int sum=0;
  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
		sum=sum+gcd(i,j,k);
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)

typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll L,T;
vector<pair<ll,int> >X;
vector<ll>fin;
ll ans[114514];
int main(){
	cin>>N>>L>>T;
	rep(i,N){
		ll x;
		int w;
		cin>>x>>w;
		if(w==2)w=-1;
		X.pb(mp(x,w));
		fin.pb(((x+w*T)%L + L)%L);
	}
	ll firstpos=fin[0];
	sort(all(fin));
	
	int dir=X[0].second;
	int zure;
	if(dir==1){
		for(int i=0;i<N;i++){
			if(fin[i]==firstpos)zure=i;
		}
	}else{
		for(int i=N-1;i>=0;i--){
			if(fin[i]==firstpos)zure=i;
		}
		
	}
	
	ll pos=X[0].first;
	ll cnt=0;
	rep(i,N){
		ll now_pos=X[i].first;
		if(i>0&&X[i].second!=dir){
			if(dir==1){
				if(now_pos<pos){
					now_pos+=L;
				}
				ll M=now_pos-pos;
				if(M<=2*T){
					cnt++;
					cnt+=(2*T-M)/L;
				}
			}else{
				if(now_pos>pos){
					pos+=L;
				}
				ll M=pos-now_pos;
				if(M<=2*T){
					cnt++;
					cnt+=(2*T-M)/L;
				}
			}
		}
		cnt%=N;
	}
	//cout<<cnt<<endl;
	if(dir==-1)cnt=(N-cnt)%N;
	/*int hoge=(1+cnt)%N;
	if(hoge==0)hoge=N;*/

	rep(i,N){
		int num=zure-cnt+i;
		num+=N;
		num%=N;
		cout<<fin[num]<<endl;
	}
}


Measured memory_bytes: 4592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

struct edge{
  ll to;
  ll cost,time;
  edge() {}
  edge(ll to, ll cost,ll time) : to(to), cost(cost),time(time){};
};
auto cmp = [](edge a, edge b){
  return a.time > b.time;
};

vector<ll> dijkstra(ll s, vector<vector<edge>> &g,ll ss,ll mx,vector<ll> &c,vector<ll> &d)
{
  priority_queue<edge, vector<edge>, decltype(cmp)> q(cmp);
  vector<vector<ll>> dist(g.size(), vector<ll>(mx+1,INF) );
  if(ss>mx)ss=mx;
  dist[s][ss] = 0;
  q.push({s, ss ,0});

  while (!q.empty())
  {
    auto p = q.top();
    q.pop();

    rep(i, g[p.to].size())
    {
      edge e = g[p.to][i];
      if(e.cost>p.cost)continue;
      if(dist[e.to][p.cost-e.cost]<=p.time+e.time)continue;

      dist[e.to][p.cost-e.cost] = e.time+p.time;
      edge r={e.to,p.cost-e.cost,e.time+p.time};
      q.push(r);
    }


    edge r={p.to,(p.cost+c[p.to]>=mx?mx:p.cost+c[p.to]),p.time+d[p.to]};
    if(dist[p.to][r.cost]>r.time){
      dist[p.to][r.cost]=r.time;
      q.push(r);
    }
  }
  vector<ll> dis(g.size(),0);
  rep(i,g.size())dis[i]=*min_element(dist[i].begin(),dist[i].end());
  return dis;
}

int main()
{
ll n , m , ss ,mx=0;
cin >> n >> m >> ss ;
vector<vector<edge>> g(n);
rep(i, m)
{
  ll a, b, c,d;
  cin >> a >> b >> c >>d;
  mx=max(mx,c);
  g[a-1].emplace_back(b-1, c,d);
  g[b-1].emplace_back(a-1, c,d);
}
vector<ll> c(n,0);
vector<ll> d(n,0);
rep(i,n){
  cin >> c[i] >> d[i] ;
}
mx*=n;
vector<ll> ans = dijkstra(0, g,ss,mx,c,d);
rep(i,n)if(i!=0)cout << ans[i] << endl;
return 0;
}

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

int main(){
  int h,n;
  cin >> h >> n;
  int sum;
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    sum += a;
  }
  if(h-sum >0){cout << "No" << endl;}else{cout << "Yes" << endl;}
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
	int n = 0;
	int S[13], H[13], C[13], D[13];
	
	int i = 0, j = 0;

	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if(i == 0)
			{
				S[j] = 0;
			}
			else if(i == 1)
			{
				H[j] = 0;
			}
			else if(i == 2)
			{
				C[j] = 0;
			}
			else if(i == 3)
			{
				D[j] = 0;
			}
		}
	}
	
	char mark = '0';
	int rank = 0;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		//fflush(stdin);
		scanf("%*c%c", &mark);
		//fflush(stdin);
		scanf("%d", &rank);
		//fflush(stdin);
		//printf("mark = %c\n", mark);
		//printf("rank = %d\n", rank);
		
		if(mark == 'S')
		{
			S[rank - 1] = 1;
			//printf("S[%d] = %d\n", rank, S[rank - 1]);
			//printf("rank = %d\n", rank);
		}
		else if(mark == 'H')
		{
			H[rank - 1] = 1;
		}
		else if(mark == 'C')
		{
			C[rank - 1] = 1;
		}
		else if(mark == 'D')
		{
			D[rank - 1] = 1;
		}
	}
	//printf("%d\n", rank);
	//printf("%d\n", S[rank]);
	//printf("\n");
	for(i = 0; i < 4; i++)
	{
		for(j = 0; j < 13; j++)
		{
			if(i == 0)
			{
				if(S[j] == 0)
				{
					printf("S %d\n", j + 1);
				}
			}
			else if(i == 1)
			{
				if(H[j] == 0)
				{
					printf("H %d\n", j + 1);
				}
			}
			else if(i == 2)
			{
				if(C[j] == 0)
				{
					printf("C %d\n", j + 1);
				}
			}
			else if(i == 3)
			{
				if(D[j] == 0)
				{
					printf("D %d\n", j + 1);
				}
			}
		}
	}
	return 0;
}

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

void solve()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int bt = h1 * 60 + m1;
    int et = h2 * 60 + m2;
    int ans = et - bt - k;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

string ex(int x){
    string s = "";
    int a = x;
    int d = 0;
    while(a > 0){
        a /= 10;
        d++;
    }
    REP(i,6-d){
        s += "0";
    }
    s += to_string(x);
    return s;
}

int main(){
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>> Y(M);
    REP(i,M) cin >> Y[i].first >> Y[i].second;
    vector<pair<int,int>> X(M);
    REP(i,M) X[i].first = Y[i].first, X[i].second = Y[i].second;
    sort(X.begin(),X.end());
    vector<map<int,int>> Ma;
    map<int,int> num;

    int n[100100];
    REP(i,100100) n[i] = 1;
    int count = 0;
    REP(i,M){
        if(i==0){
            map<int,int> m;
            Ma.push_back(m);
            Ma[count][X[i].second] = n[count];
            num[X[i].first] = count;
        }
        else{
            if(X[i].first == X[i-1].first){
                if(Ma[count].count(X[i].second)) num[X[i].first] = count;
                else{
                    n[count]++;
                    Ma[count][X[i].second] = n[count];
                    num[X[i].first] = count;
                }
            }
            else{
                count++;
                map<int,int> m;
                Ma.push_back(m);
                Ma[count][X[i].second] = n[count];
                num[X[i].first] = count;
            }
        }
    }

    int res = 0;
    REP(i,M){
        cout << ex(Y[i].first) << ex(Ma[num[Y[i].first]][Y[i].second]) << endl;
    }
}

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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val,typename Number>
//use ll or int for gcd
Val gcd(Val a, Val b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
//count vector and return pair (count,vector item)
template <typename Val,typename Number>
void count_vector(vector<Val>* A,vector<pair<Number,Val>>*R){
  sort(A->begin(),A->end());
  int count = 1;
  rep(i,A->size()){
    if(i<A->size()-1){
      if(A->at(i)==A->at(i+1))count++;
      else{
        R->push_back(make_pair(count,A->at(i)));
        count = 1;
      }
    }else{
      R->push_back(make_pair(count,A->at(i)));
      count = 1;
    }
  }
}

//---------------------------------------------------------------

int main(){
  int N,M;
  int s=0;
  cin>>N>>M;
  string ans = "Yes";
  vec A(N);
  rep(i,N){
    cin>>A.at(i);
    s+=A.at(i);
  }
  sort(A.begin(),A.end(),greater<int>());
  rep(i,M){
    double kijun = 1/(double)(4*M);
    double rate = (double)A.at(i)/s;

    if(rate<kijun){
      ans = "No";
      break;
    }
  }


  cout<<ans<<endl;




}


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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll r;
  cin >>r;
  cout << r*2.0*3.14159 << endl;



}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin>>p[i];
    }
    sort(all(p));
    int ans=0;
    for (int i = 0; i < k; i++)
    {
        ans+=p[i];
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
x = int(input())
if x == 2:
    print(x)
    exit(0)
while True:
    
    for i in range(2,int(x**0.5) +3):
        if x %i == 0:
            break
    if i == int(x**0.5) +2:
        print(x)
        break
        
    

    
    
    
    
    
    x += 1

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int mod=998244353,INF=1e9+7;
const int N=1002020;
int n,gr[N],f[N],x1[N],suf[N];
struct Robot{int x,d;}rb[N];
bool cmp(const Robot &x,const Robot &y){return x.x<y.x;}
struct Fenwick_Tree{
	int c[N];
	int lowbit(int x){return x & (-x);}
	void add(int x,int y){for(;x<=n;x+=lowbit(x))c[x]=max(c[x],y);}
	int ask(int x){int r=0;for(;x;x-=lowbit(x))r=max(r,c[x]);return r;}
}tr;
int read(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		rb[i].x=read(),rb[i].d=read();
	sort(rb+1,rb+n+1,cmp);
//	for(int i=1;i<=n;i++)cout<<rb[i].x<<"("<<rb[i].d<<") ";cout<<endl;
	for(int i=1;i<=n;i++)x1[i]=rb[i].x;
	x1[n+1]=INF;
	for(int i=n;i>=1;i--){
		int th=lower_bound(x1+1,x1+n+2,rb[i].x+rb[i].d)-x1; --th;
		gr[i]=max(i,tr.ask(th)); tr.add(i,gr[i]);
	}
	f[n+1]=1;
	for(int i=n;i>=1;i--)
		f[i]=(f[i+1]+f[gr[i]+1])%mod;
	cout<<f[1]<<endl;
	return 0;
}

Measured memory_bytes: 8244
#include<bits/stdc++.h>
using namespace std;
long long xo(long long t){
    int s = t%4;
    if(s==0){
        return t;
    }else if(s==1){
        return 1;
    }else if(s==2){
        return t+1;
    }else{
        return 0;
    }
}
int main(){
    long long a,b;
    cin>>a>>b;
    long long aa = xo(a-1);
    long long bb = xo(b);
    cout<<(bb^aa)<<endl;
    return 0;
}

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

const int MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int S;
  cin >> S;
  vector<long long> dp(2001);
  dp[0] = 1;
  for(int i = 0; i <= 2000; i++){
    for(int j = 0; j + 3 <= i; j++){  
      dp[i] += dp[j]; 
      dp[i] %= MOD;
    }
  }
  cout << dp[S] <<endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i= a ; i < b ; ++i)
#define rep(i,n) fo(i,0,n)
#define pln(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(n) scanf("%s",n)
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define dbg3(x,y,z) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) <<" , "<< #z <<": "<<(z)<<endl; }
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<ll>>>
#define si set<int>
#define tr(c, it) \
for(decltype(c.begin()) it = c.begin(); it!= c.end(); it++)
#define pis pair<int,string>
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c),x) != c.end())
#define  ones(x)  __builtin_popcount(x)
using namespace std;

int main(){
   long long n , m, x;
   cin >> n >> m >> x;
   vector<vector<long long>> A(n,vll(m));
   vector<long long> C(n);
   for(long long i = 0; i < n; i++){
       cin >> C[i];
       for(long long j = 0; j < m; j++){
           cin >> A[i][j];
       }
   }
    long long mn = 1000000000ll;
   for(long long i = 0; i < (long long)(1 << n); i++){
       bitset<18> b(i);
       long long curr = 0;
       vector<long long> cr(m,0);
       for(long long j = 0; j < n; j++){
           if(b[j]){
               curr += C[j];
               for(long long l = 0; l < m; l++){
                   cr[l] += A[j][l];
               }
           }
       }
       bool f = 1;
       for(long long q = 0; q < m; q++){
           if(cr[q] < x){f = 0;break;}
       }
       if(f){
           mn = min(mn, curr);
       } 
   }
   if(mn < 100000000)cout << mn;
   else cout << "-1";

}

Measured memory_bytes: 3644
import itertools
L, R = map(int, input().split())

if R - L + 1 > 2019:
    remainder_list = [N%2019 for N in range(L, L+2019)]
else:
    remainder_list = [N%2019 for N in range(L, R+1)]  
remainder_list = list(set(remainder_list))
all_list = [(i*j)%2019 for i, j in list(itertools.combinations(remainder_list, 2))]
print(min(all_list))

Measured memory_bytes: 221040
import math

A, B, N = map(int, input().split())

if B - 1 < N:
    x = B - 1
    v = math.floor((A * x) / B) - A * math.floor(x / B)
else:
    v = math.floor((A * N) / B) - A * math.floor(N / B)

print(v)

Measured memory_bytes: 9172
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll x,y; cin >> x >> y; ll sum = 0;
  for(ll i=1; i <= 3; i++){
    if(x == i) sum += (4-i)*100000;
    if(y == i) sum += (4-i)*100000;
  }
  
  if(x == 1 and y == 1) sum += 400000;
  
  cout << sum << endl;
  
  
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1

using namespace std;

const double g=10.0,eps=1e-7;
const int N=100+10,maxn=60000+10,inf=0x3f3f3f;

map<string,int>m;
vector<pii>v[N];
ll num[30];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll n=s.size(),k=0;
    ll ans=n*(n-1)/2+1;
    /*for(int i=0;i<n;i++)
    {
        for(int j=i;j<n;j++)
        {
            string p=s.substr(i,j-i+1);
            reverse(p.begin(),p.end());
            p=s.substr(0,i)+p+s.substr(j+1,n);
            if(!m[p])
            {
                m[p]=++k;
                v[k].pb(mp(i,j));
            }
            else v[m[p]].pb(mp(i,j));
        }
    }
    for(auto x : m)
    {
        for(int i=0;i<v[x.se].size();i++)
            cout<<v[x.se][i].fi<<" "<<v[x.se][i].se<<endl;
        cout<<x.fi<<endl;
    }
    cout<<m.size()<<endl;*/
    for(int i=0;i<n;i++)
        num[(int)(s[i]-'a')]++;
    for(int i=0;i<26;i++)
        ans-=num[i]*(num[i]-1)/2;
    cout<<ans<<endl;
    return 0;
}
/********************
4 2 1 1 2
abracadabra
56 44
6 1 1
********************/


Measured memory_bytes: 720
main(){
    int n,a[128],tmp;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n/2;i++){
        tmp=a[i];
        a[i]=a[n-i-1];
        a[n-i-1]=tmp;
    }
    for(int i=0;i<n-1;i++){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[n-1]);
}


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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll n;
	cin>>n;
	ll yen[]={1,6,9,36,216,1296,7776,46656,81,729,6561,59049};
	ll dp[n];
	dp[0]=0;
	forni(i,n){
		dp[i]=inf;
		for(auto c : yen){
			if(i-c>=0) dp[i] = min(dp[i],dp[i-c]+1);
		}
	}
	cout<<dp[n]<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 1024
#include<bits/stdc++.h>
char s[200020];
int main(){
    scanf("%s",s);
    int blk=0;
    long long sum;
    for(int i=0;s[i]!='\0';++i){
        if(s[i]=='B') ++blk;
        else sum+=blk;
    }
    printf("%lld",sum);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 20 + 2000;
ll dp[N][N]; // Ways to divide a balls into b bins

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

	int k, n;
	cin >> n >> k;
	dp[0][0] = 1;
	for (int i = 1; i < N; ++i) {
		for (int j = 1; j <= i; ++j) {
			dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % MOD;
		}
	}
	for (int i = 1; i <= k; ++i) {
		// Ways to divide k balls into i clusters, and n-k balls into i+1 clusters
		ll mult = dp[k][i];
		ll res = 0;
		for (int j = 0; j <= n-k; ++j) {
			ll mult2 = dp[j][i-1];
			if (j < n-k) mult2 = (mult2 * (2 + dp[n-k-j][2])) % MOD;
			res = (res + mult * mult2) % MOD;
		}
		cout << res << '\n';
	}
}


Measured memory_bytes: 30720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n,k;
    cin>>n>>k;
    vector<ll>A(n);
    for(auto&x:A)cin>>x;

    ll l = 1, r = 1e9;

    while(l < r)
    {
        ll m = (l+r)/2;
        ll need = 0;
        for(auto&x:A)need+=(x+m-1)/m - 1;

        if(need <= k)r=m;
        else l = m+1;
    }

    cout<<r;
}


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

using namespace std;

typedef long long ll;

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

  ll ans = 0;
  int r = 0;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    for (; r < n; r++) {
      if ((sum ^ a[r]) != (sum + a[r])) {
        break;
      } else {
        sum += a[r];
        ans += r - i + 1;
      }
    }
    sum -= a[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(){
	int n;
	bool cards[4][13];
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			cards[i][j] = false;
		}
	}
	
	std::cin >> n;
	for(int i = 0; i < n; i++){
		char suit;
		int rank;
		std::cin >> suit >> rank;
		switch(suit){
			case 'S':
				suit = 0;
				break;
			case 'H':
				suit = 1;
				break;
			case 'C':
				suit = 2;
				break;
			case 'D':
				suit = 3;
		}
		cards[suit][rank-1] = true;
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 13; j++){
			if(!cards[i][j]){
				char suit;
				switch(i){
					case 0:
						suit = 'S';
						break;
					case 1:
						suit = 'H';
						break;
					case 2:
						suit = 'C';
						break;
					case 3:
						suit = 'D';
				}
				std::cout << suit << ' ' << j+1 << std::endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, M, xp = 0;

  std::cin >> N >> M;

  for (int i = 1, x; i * i <= M; i ++)
    if (M % i == 0) {
      if (M / (x = i) >= N)
        xp = std::max(x, xp);

      if (M / (x = M / i) >= N)
        xp = std::max(x, xp);
    }

  std::cout << xp << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int x,y, temp;
while(1)
{
scanf("%d %d", &x, &y);
if(x==0 && y==0)break;
else if(x>y)
{
temp=x;
x=y;
y=temp;
}
printf("%d %d\n", x, y);
}
return 0;
}


Measured memory_bytes: 2044
#include <iostream>
using namespace std;

int main(){
  int w,n,i,j;
  int f,t;
  int value[31];
  for(i=1;i<31;i++){
    value[i]=i;
  }
  string str;
  cin >> w >> n;
  for(i=0;i<n;i++){
    cin >> str;
    if(str[1]==','){
      f = str[0] - '0';
      if(str.size()==3) t = str[2] - '0';
      else t = (str[2] - '0') * 10 + str[3] - '0';
    }else{
      f = (str[0] - '0') * 10 +  str[1] - '0';
      if(str.size()==4) t = str[3] - '0';
      else t = (str[3] - '0') * 10 + str[4] - '0';
    }
    int buf=value[f];
    value[f]=value[t];
    value[t]=buf;
  }
  for(i=1;i<w+1;i++){
    cout << value[i] << endl;
  }
}



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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define int long long
int a[100];
int dp[100000+2]; //will fp win if i stones remain

signed main()
{
    IOS
    int n, k;

    cin >> n >> k;
    REP(i, n)
    {
        cin >> a[i];
    }

    REP(i, k+1)
    {
        REP(j, n)
        {
            if(i-a[j]>=0 && dp[i-a[j]] == false)
            {
                dp[i] = true;
            }
        }
    }
    cout << (dp[k] ? "First":"Second");
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;

    vector<ll> height(N+10),cost(N+10);
    for(int i=0;i<N;i++){
        cin >> height[i];
    }
    cost[1]=abs(height[1]-height[0]);
    for(int i=2;i<N;i++){
        cost[i]=min(cost[i-2]+abs(height[i]-height[i-2]),cost[i-1]+abs(height[i]-height[i-1]));
    }
    cout << cost[N-1] << endl;
}

Measured memory_bytes: 1792
def is_even_all(nums):
    """
    偶数判定
    :param nums:Int型のList
    :return: 判定結果(Boolean型)
    """
    for i in nums:
        if i % 2 != 0:
            return False

    return True


def divide_by_2(num):
    """
    :param num: 数値(Int型)
    :return: 計算結果
    """
    return int(num / 2)


input()

num_list = list(map(int, input().split()))

# 操作回数
operate_count = 0
can_operate = is_even_all(num_list)

while can_operate:
    operate_count += 1
    num_list = list(map(divide_by_2, num_list))

    can_operate = is_even_all(num_list)

print(operate_count)


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

int main(){
    string e;
    string o;
    int i;
    cin >> o;
    cin >> e;
    
    if (o.size()==e.size()) {
        for (i=0; i < o.size(); i++) {
            cout << o[i] << e[i];
        }
    } else {
        for (i=0; i < e.size(); i++) {
            cout << o[i] << e[i];
        }
        cout << o[o.size()-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int int64_t
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
    fast;
	int K;
	cin >> K;
    int A, B;
    cin >> A >> B;
    for(int i = A; i <= B; i++){
        if (i%K==0){
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
	
}




Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
struct Fordfulkerson{
  const int INF = 1 << 28;
  struct edge{
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<int> used;

  Fordfulkerson(){}
  Fordfulkerson(int sz):n(sz),G(n),used(n){}

  void add_edge(int from,int to,int cap){
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }

  int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    for(int i=0;i<(int)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 flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      fill(used.begin(),used.end(),0);
      int f=dfs(s,t,lim);
      if(f==0) return fl;
      fl+=f;
      lim-=f;
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

};
//main
signed main(){
  int N,M;cin>>N>>M;
  Fordfulkerson fl(600);
  string U;cin>>U;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    if(U[i]=='R')fl.add_edge(0,i+1,a);
    else fl.add_edge(i+1,N+1,a);
  }
  for(int i=0;i<M;i++){
    int s,t,b;cin>>s>>t>>b;
    if(s>t)swap(s,t);
    fl.add_edge(s,t,b);
  }
  cout<<fl.flow(0,N+1)<<endl;
}



Measured memory_bytes: 3292
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n;
    scan(n);
    auto a = readln.split.to!(int[]);

    auto ans = a[0];

    foreach (i ; 1 .. n) {
        ans = gcd(ans, a[i]);
    }

    writeln(ans);
}








void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 4392
N = int(input())
S1 = input()
S2 = input()
if S1[0] == S2[0]:
    ans = 3
    i = 1
else:
    ans = 6
    i = 2
MOD = 1000000007
while i < N:
    if S1[i - 1] == S2[i - 1]:
        ans = ans * 2 % MOD
        if S1[i] != S2[i]:
            i += 1
    else:
        if S1[i] != S2[i]:
            ans = ans * 3 % MOD
            i += 1
    i += 1
print(ans)

Measured memory_bytes: 38384
n=int(input())
if n==100000:
  print(90909)
elif 10000<=n<=99999:
  print((n-10000)+910)
elif 1000<=n<=9999:
  print(909)
elif 100<=n<=999:
  print((n-100)+10)
elif 10<=n<=99:
  print(9)
elif 1<=n<=9:
  print(n)


Measured memory_bytes: 2940
h, w = map(int, input().split())

map_data = [list(input()) for i in range(h)]

for y in range(h):
    for x in range(w):
        if (map_data[y][x] == "."):
            bs = 0
            for yy in range(max(0, y - 1), min(h, y + 2)):
                for xx in range(max(0, x - 1),min(w, x + 2)):
                    bs += map_data[yy][xx] == "#"
            map_data[y][x] = str(bs)

for y in range(h):
    print("".join(map_data[y]))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin >> a;
    vector<int> n(a);
    for(int i=0;i<n.size();i++){
        cin >> n.at(i);
    }
    reverse(n.begin(),n.end());
    for(int i=0;i<n.size();i++){
        if(i+1==n.size()){
            cout << n.at(i);
            break;
        }
        cout << n.at(i) << " ";
    }
cout << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>

typedef struct{
    int p, l, r;
}node;

node nodes[25];

void pre(int id)
{
    if(id == -1)
        return ;
    printf(" %d", id);
    pre(nodes[id].l);
    pre(nodes[id].r);
}

void ino(int id)
{
    if(id == -1)
        return ;
    ino(nodes[id].l);
    printf(" %d", id);
    ino(nodes[id].r);
}

void pos(int id)
{
    if(id == -1)
        return ;
    pos(nodes[id].l);
    pos(nodes[id].r);
    printf(" %d", id);
}

int main(void)
{
    int i, n, s;

    scanf("%d", &n);

    for(i = 0; i < n; i++)
        nodes[i].p = -1;

    for(i = 0; i < n; i++){
        int id, l, r;

        scanf("%d %d %d", &id, &l, &r);

        nodes[id].l = l;
        nodes[id].r = r;
        if(l != -1)
            nodes[l].p = id;
        if(r != -1)
            nodes[r].p = id;
    }
    for(i = 0; i < n; i++){
        if(nodes[i].p == -1)
            s = i;
    }

    printf("Preorder\n");
    pre(s);
    printf("\n");
    printf("Inorder\n");
    ino(s);
    printf("\n");
    printf("Postorder\n");
    pos(s);
    printf("\n");

    return 0;
}

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

int main(){
  long long n,q;
  string s;
  cin >> n >> q >> s;
  vector<long long> l(q),r(q);
  for (int i = 0;i < q;i++){
    cin >> l[i] >> r[i];
    l[i]--; r[i]--;
  }
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1;i < n;i++){
    dp[i] = dp[i-1];
    if (s[i-1] == 'A' && s[i] == 'C') dp[i]++;
  }
  for(int i = 0;i < q;i++){
    cout << dp[r[i]] - dp[l[i]] << endl;
  }
}

Measured memory_bytes: 3072
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<math.h>
#include<cassert>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

int main() {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3) {
		cout << 0 << endl;
		return 0;
	}
	int n = (x + y) / 3;
	x -= n; y -= n;
	if (x < 0 || y < 0) {
		cout << 0 << endl;
		return 0;
	}
	combination c(x + y);
	mint ans = c(x + y, x);
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  ll ans = 0;
  rep (i, n) {
    cin >> a[i];
    sum += a[i];
  }

  rep (i, n) {
    sum -= a[i];
    ans += (sum % MOD) * (a[i]) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4828