akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	int d;
	cin>>d;
	cout<<a+b+c+max<int>({a,b,c})*pow(2,d)-max<int>({a,b,c})<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn=1000100;
int n;
int m;
int ans;
int last;
int t[maxn],p[maxn],x[maxn];

int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>t[i];
	cin>>m;
	for(int i=1;i<=m;i++){
		ans=0;
		cin>>p[i]>>x[i];
		last=t[p[i]];
		t[p[i]]=x[i];
		for(int j=1;j<=n;j++){
			ans+=t[j];
		}
		t[p[i]]=last;
		cout<<ans<<'\n';
	}
	return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cassert>
using namespace std;
#define MAX 100
#define rep(i, n) for ( int i = 0; i < n; i++ )

class Button{
public:
  int x1, y1, x2, y2;
  string target;
  Button(int x1, int y1, int x2, int y2, string target):x1(x1), y1(y1), x2(x2), y2(y2), target(target){}
};

class Page{
public:
  string name;
  int H, W;
  vector<Button> B;
  Page(string name="", int W=0, int H=0):name(name), W(W), H(H){}

  string click(int x, int y){
    rep(i, B.size()){
      Button b = B[i];

      if ( b.x1 <= x && x <= b.x2 &&
	   b.y1 <= y && y <= b.y2 ) {
	//assert( b.x1 != x );
	//assert( b.y1 != y );
	//assert( b.x2 != x );
	//assert( b.y2 != y );
	return b.target;
      }
    }
    return name;
  }

  bool over(int a, int b, int c, int d ){
    int p1, p2, p3, p4;
    if ( a <= c ){
      p1 = a; p2 = b; p3 = c; p4 = d;
    } else {
      p1 = c; p2 = d; p3 = a; p4 = b;
    }
    return  p2 >= p3;
  }
  void buttonCheck(){
    for ( int i = 0; i < (int)(B.size())-1; i++ ){
      for ( int j = i+1; j < B.size(); j++ ){
	Button b1 = B[i];
	Button b2 = B[j];
	
	if ( over(b1.x1, b1.x2, b2.x1, b2.x2) &&
	     over(b1.y1, b1.y2, b2.y1, b2.y2) ){
	  assert(false);
	}
	
      }
    }
  }
};

int n, H, W;
Page P[MAX];
map<string, int> PI;


void simulate(){
  int q; cin >> q;
  string com, target;
  int history[10000], x, y, cur, top, forward;
  top = forward = 0;

  cur = 0;
  history[top] = cur;

  rep(p, q){
    cin >> com;
    if ( com == "click" ){
      cin >> x >> y;
      assert( 1 <= x && x <= W );
      assert( 1 <= y && y <= H );
      target = P[cur].click(x, y);
      assert( PI.find(target) != PI.end());
      if ( target != P[cur].name ){
	cur = PI[target];
	history[++top] = PI[target];
	forward = top;
      }
    } else if ( com == "forward" ){
      if ( top < forward){
	top++;
	cur = history[top];
      }
    } else if ( com == "back"){
      if ( top > 0 ){
	top--;
	cur = history[top];
      }
    } else if ( com == "show" ){
      cout << P[cur].name << endl;
    } else assert(false);

  }
}

main(){
  string name, target;
  int  m, x1, y1, x2, y2;
  while( cin >> n && n ){
    cin >> W >> H;
    assert( 1 <= n && n <= 100 );
    rep(i, n){
      cin >> name >> m;
      assert( name.size() <= 20 );
      char h = name[0];
      assert( !('0' <= h && h <= '9') );
      assert( m <= 100);
      P[i] = Page(name, W, H);
      rep(j, m){
	cin >> x1 >> y1 >> x2 >> y2 >> target;
	assert( 0 <= x1 && x1 <= W);
	assert( 0 <= x2 && x2 <= W);
	assert( 0 <= y1 && y1 <= H);
	assert( 0 <= y2 && y2 <= H);
	P[i].B.push_back(Button(x1, y1, x2, y2, target));
      }
      PI[name] = i;

      P[i].buttonCheck();
    }
    simulate();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    int n;
    cin >> n;
    vi aux(n);
    for(int &i : aux)
        cin >> i;
    int one = 0;
    int even = 0;
    int four = 0;
    for(int i : aux){
        if(i % 4 == 0)
            four++;
        if(!(i & 1) && i % 4 != 0)
            even++;
        if(i & 1)
            one++;
    }
    if(even == 0)
        if(one <= four + 1)
            cout << "Yes\n";
        else
            cout << "No\n";
    else{
        if(one <= four)
            cout << "Yes\n";
        else
            cout << "No\n";
    } 
    return 0;
}   

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[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'};
char moji2[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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
struct UnionFind{
    int par[MAX];
    int kosuu[MAX];
    UnionFind(int n){
        REP(i,n) par[i]=i;
        REP(i,n) kosuu[i] = 1;
    }

    int root(int x){
        int tmp;
        if(par[x]==x) return x;
        else{
            tmp=root(par[x]);
            par[x]=tmp;
            return tmp;
        }
    }

    bool same(int x,int y){
        return root(x) == root(y);
    }

    void unite(int x,int y){
        if(not same(x,y)){ 
        kosuu[root(y)] += kosuu[root(x)];
        par[root(x)] = root(y);
        }
    }

    int renketu_kosuu(int x){
        return kosuu[root(x)];
    }
};


signed main(){
    int n,m;
    cin >> n >> m;
    int cost[n];
    REP(i,n) cin >> cost[i];
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    UnionFind U(n);

    REP(i,m){
        int a,b;
        cin >> a >> b;
        U.unite(a,b);
    }

    reversed_priority_queue< pair<int,int>> Q[n];
    REP(i,n){
        Q[U.root(i)].push( mp(cost[i],i));
    }

    int ans = 0;
    int k = 0;
    bool vis[n];
    REP(i,n) vis[i] = false;
    REP(i,n){
        if(Q[i].size() == 0) continue;
        ans += Q[i].top().fi;
        vis[Q[i].top().se] = true;
        Q[i].pop();
        k ++;
    }
    if(k == 1){
        cout << 0 << endl;
        return 0;
    }
    if(2 * k - 2 > n){
        cout << "Impossible" << endl;
        return 0;
    }

    vector<int> huga;
    REP(i,n){
        if(vis[i] == false) huga.push_back(cost[i]);
    }

    Sort(huga);
    REP(i,k-2) ans += huga[i];
    cout << ans << endl;

}

Measured memory_bytes: 10480
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int Judge=0;
 unsigned  int N;
 cin>>N;
  vector<unsigned long int> vec(N+1);
  vec.at(N)=1000000001;
  vec.at(0)=vec.at(0)-1;
  for(unsigned int i=0;i<N;i++)
  {
   cin>>vec.at(i);
  }
  for(unsigned int i=0;i<N;i++)
  {
    if(vec.at(i)>vec.at(i+1))
    {
      Judge=1;
      break;
    }
    if(vec.at(i)+1<=vec.at(i+1))
    {
    vec.at(i+1)--;
    }
  }
  
  if(Judge==1)
  {
   cout<<"No"<<endl;
  }
  else 
  {
   cout<<"Yes"<<endl;
  }
  
}

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

class dice{
    public:
    int d[7];

    dice(){ //??????????????????????????????
    	
    }

    void east(){
    	d[0]=d[1],d[1]=d[4],d[4]=d[6],d[6]=d[3],d[3]=d[0];
    }

    void west(){
    	d[0]=d[4],d[4]=d[1],d[1]=d[3],d[3]=d[6],d[6]=d[0];
    }

    void north(){
    	d[0]=d[5],d[5]=d[1],d[1]=d[2],d[2]=d[6],d[6]=d[0];
    }

    void south(){
    	d[0]=d[2],d[2]=d[1],d[1]=d[5],d[5]=d[6],d[6]=d[0];
    }

};

int main(){
	string n;	
	dice A;
	for(int i=1; i<7; i++){
		cin >> A.d[i];
	}
	cin >> n;

	for(int i=0; i<n.size(); i++){
		
		if(n[i]=='E')A.east();
		else if(n[i]=='W')A.west();
		else if(n[i]=='N')A.north();
		else if(n[i]=='S')A.south();
	}

	cout << A.d[1] << endl;
    
    //for(int i=0; i<7; i++){ //test=ok
	//   cout << A.d[i] << " ";
	//}
	//cout << endl;

	return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int D, N;
	string S;
	cin >> S >> D;

	int dp[10010][110][2] = { 0 };

	N = S.size();

	dp[0][0][0] = 1;

	REP(i, N) {

		int a = S[i] - '0';

		REP(j, D) {
			REP(k, 10) {
				int nd = (k + j) % D;

				if (k < a) {
					dp[i + 1][nd][1] += dp[i][j][1] + dp[i][j][0];
					dp[i + 1][nd][1] %= mod;
				}
				else if (k > a) {
					dp[i + 1][nd][1] += dp[i][j][1];
					dp[i + 1][nd][1] %= mod;
				}
				else {
					dp[i + 1][nd][1] += dp[i][j][1];
					dp[i + 1][nd][0] += dp[i][j][0];
					dp[i + 1][nd][1] %= mod;
					dp[i + 1][nd][0] %= mod;
				}
			}
		}
	}


	cout << (dp[N][0][0] + dp[N][0][1] + mod - 1) % mod << endl;

	return 0;
}



Measured memory_bytes: 17664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  sort(a,a+n);
  ll z=1;
  rep(i,n)z=z*2%MOD;
  ll y[n+1];
  y[0]=1;
  rep(i,n)y[i+1]=(y[i]*2)%MOD;
  ll ans=0;
  rep(i,n){
    ans=(ans+(a[n-i-1]*y[n-i-1])%MOD*(y[i]+(i*y[max(0,i-1)])%MOD))%MOD;
  }
  cout << ans*z%MOD << endl;
}


Measured memory_bytes: 6680
#include<iostream>
using namespace std;
int main(){
	for(int n;cin>>n,n;){
		while(n--){
			int m,e,j;	cin>>m>>e>>j;
			if(m==100 || e==100 || j==100)	cout<<'A'<<endl;
			else if(m+e>=180)	cout<<'A'<<endl;
			else if(m+e+j>=240)	cout<<'A'<<endl;
			else if(m+e+j>=210)	cout<<'B'<<endl;
			else if(m+e+j>=150 && (m>=80 || e>=80))	cout<<'B'<<endl;
			else	cout<<'C'<<endl;
		}
	}
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> Yes(100001,0);
	FOR(i,0,100001){
		ll x = i*8 + 1;
		ll p = sqrt(x);
		if(p*p==x){
			if(p%2==0)cout << 6666666666666666 << endl;
			Yes[i]=(1+p)/2;
		}
	}
	ll N;
	cin >> N;
	if(Yes[N]==0){
		cout << "No" << endl;
		return 0;
	}
	ll K = Yes[N];
	// tyouten -> K
	// hen -> N
	bool same[K+1][K+1]={false};
	vector< vector<ll> > Si;
	Si.resize(K+1);
	ll num=1;
	FOR(i,1,K+1){
		FOR(j,1,K+1){
			if(j==i)continue;
			if(not same[i][j]){
				same[i][j] = same[j][i] = true;
				Si[i].push_back(num);
				Si[j].push_back(num);
				num++;
			}
		}
	}
	if(num!=N+1){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << K << endl;
	FOR(i,1,K+1){
		cout << Si[i].size() << " ";
		FOR(j,0,Si[i].size()){
			cout << Si[i][j] << " ";
		}
		cout << endl;
	}
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

const int MOD=1e9+7;
long long D[2][100001];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	int N, K, A;
	cin>>N>>K;
	D[0][K]=1;
	for(int i=1;i<=N;i++) {
		cin>>A;
		D[i&1][0]=D[(i-1)&1][A];
		for(int j=1;j<=K;j++) {
			D[i&1][j]=((D[(i-1)&1][min(j+A,K)]-D[(i-1)&1][j-1]+MOD)%MOD+D[i&1][j-1])%MOD;
		}
	}
	cout<<D[N&1][0]<<'\n';
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		
		int[] S;
		int[] T;
		int C = 0;
		
		Scanner keyboard = new Scanner(System.in);
		
		int S_length = keyboard.nextInt();
		S = new int[S_length];
		
		keyboard.nextLine();
		
		String S_inputString = keyboard.nextLine();
		
		Scanner S_input = new Scanner(S_inputString);
		
		int T_length = keyboard.nextInt();
		T = new int[T_length];
		
		keyboard.nextLine();
		
		String T_inputString = keyboard.nextLine();
		
		Scanner T_input = new Scanner(T_inputString);
		
		for(int i = 0; i < S_length; i++) {
			S[i] = S_input.nextInt();
		}
		
		for(int i = 0; i < T_length; i++) {
			T[i] = T_input.nextInt();
		}
		
		for(int i = 0; i < T.length; i++) {
			if(contains(T[i], S)) C++;
		}
		
		System.out.println(C);
		
	}
	
	public static boolean contains(int query, int[] check) {
		
		boolean containsInt = false;
		
		int low_index = 0;
		int high_index = check.length - 1;
		int middle_index = check.length / 2;
//		int iteration = 0;
		
		while(containsInt == false && high_index - low_index > 1) {
			
//			iteration++;
//			
//			System.out.println("----------------");
//			System.out.println("Query: " + query);
//			System.out.println("Iteration: " + iteration);
//			System.out.println("L: " + low_index);
//			System.out.println("M: " + middle_index);
//			System.out.println("H: " + high_index);
			
			if(check[middle_index] == query) {
				containsInt = true;
			}
			else if(check[middle_index] > query) {
				high_index = middle_index;
				middle_index = (high_index + low_index) / 2;
			}
			else if(check[middle_index] < query) {
				low_index = middle_index;
				middle_index = (high_index + low_index) / 2;
			}
			
		}
		
		if(check[high_index] == query) {
			containsInt = true;
		}
		
		return containsInt;
		
	}
}


Measured memory_bytes: 111576
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	vector<llint>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	llint cnt = 0;
	int tmp = 0;
	rep(i, n - 1) {
		cnt += a[i];
		if (cnt * 2 < a[i + 1]) {
			tmp = i + 1;
		}
	}
	cout << n - tmp << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int a, b;
	int j;
	
	for(j = 0; ; j++) {
		int i;
		int count = 0;
		
		scanf("%d %d", &a, &b);
		if(a == 0 && b == 0) break;
		if(j != 0) putchar('\n');
		
		for(i = 0; i < b - a + 1; i++) {
			int year;
			
			year = a + i;
			if(!(year % 4)) {
				if(!(year % 400)) {
					printf("%d\n", year);
					count++;
				}
				else if((year % 100)) {
					printf("%d\n", year);
					count++;
				}
			}
		}
		if(count == 0) puts("NA");
	}
	
	return 0;
}


Measured memory_bytes: 616
/*
    f[i][j] 表示 已经出现过 i种颜色的球，
	并且还剩j种颜色的球没有被匹配的方案数。
	
	考虑加入一种新球的话:
	f[i+1][j+1] += f[i][j] * (n-i) * C(k*i-j+1,k-2) 
	
	考虑加入一种白球的话:
	f[i][j-1] += f[i][j] 
	
	初始化 f[0][0] = 1 
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2005;
const int ha=1000000007;
int jc[maxn*maxn],ni[maxn*maxn];
int n,k,f[maxn][maxn];

inline int add(int x,int y){
	x+=y;
	return x>=ha?x-ha:x;
}

inline int ksm(int x,int y){
	int an=1;
	for(;y;y>>=1,x=x*(ll)x%ha) if(y&1) an=an*(ll)x%ha;
	return an;
}

inline void init(){
	jc[0]=1;
	for(int i=1;i<=4004000;i++) jc[i]=jc[i-1]*(ll)i%ha;
	ni[4004000]=ksm(jc[4004000],ha-2);
	for(int i=4004000;i;i--) ni[i-1]=ni[i]*(ll)i%ha;
}

inline int getC(int x,int y){
	return jc[x]*(ll)ni[y]%ha*(ll)ni[x-y]%ha;
}

inline void dp(){
	f[0][0]=1;
	for(int i=0;i<=n;i++)
	    for(int j=i;j>=0;j--) if(f[i][j]){
	    	f[i+1][j+1]=add(f[i+1][j+1],f[i][j]*(ll)(n-i)%ha*(ll)getC(k*(i+1)-j-2,k-2)%ha);
	    	if(j) f[i][j-1]=add(f[i][j-1],f[i][j]);
		}
	
	/*
	for(int i=0;i<=n;i++){
	    for(int j=0;j<=i;j++) printf("%d ",f[i][j]);
	    puts("");
	}
	*/
}

int main(){
	init();
	scanf("%d%d",&n,&k);
	if(k==1) puts("1");
	else{
		dp();
		printf("%d\n",f[n][0]);
	}
	return 0;
}

Measured memory_bytes: 46464
function Main(input) {
    var A = parseInt(input[0], 10);
    var B = parseInt(input[1], 10);

    if (A >= 13) {
        console.log(B);
    } else if (6 <= A && A <= 12) {
        console.log(B/2);
    } else {
        console.log('0');
    }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  string A[N];
  int C[4]={};
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]=="AC")C[0]++;
    if(A[i]=="WA")C[1]++;
    if(A[i]=="TLE")C[2]++;
    if(A[i]=="RE")C[3]++;
  }
  cout<<"AC"<<" x "<<C[0]<<endl;
  cout<<"WA"<<" x "<<C[1]<<endl;
  cout<<"TLE"<<" x "<<C[2]<<endl;
  cout<<"RE"<<" x "<<C[3];
  


  return 0;
  
}

  


Measured memory_bytes: 6752
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
using namespace std;
typedef long long LL;
template<typename T>inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}
inline void File(){
    freopen("fuck.in","r",stdin);
    freopen("fuck.out","w",stdout);
}

const int maxn=55555+5;
int n;
int ans[maxn],cnt,p,ccnt;
bool s1[55555+5],s2[55555<<1+5],s3[55555*3+5],s4[55555*4+5];

int pri[maxn];
bool isp[maxn];

inline void Sieve(){
	mem(isp,1);
	isp[1]=0;
	for(Rint i=2;i<=55555;i++){
		if(isp[i])pri[++ccnt]=i;
		for(Rint j=1;j<=ccnt&&i*pri[j]<=55555;j++){
			isp[i*pri[j]]=0;
			if(i%pri[j]==0)break;
		}
	}
}
inline bool work(){
	while(cnt<n){
		bool flag=0;
		if(p>ccnt)return false;
		while(1){
			if(flag)break;
			flag=1;
			for(Rint i=1;i<=55555*4;i++){
				if(!s4[i])continue;
				if(isp[i+pri[p]]){flag=0;break;}
			}
			if(!flag){p++;continue;}
			ans[++cnt]=pri[p];
			int x=pri[p];
			for(Rint i=1;i<=55555*3;i++){
				if(!s3[i])continue;
				s4[i+x]=1;
			}
			for(Rint i=1;i<=55555*2;i++){
				if(!s2[i])continue;
				s3[i+x]=1;
			}
			for(Rint i=1;i<=55555;i++){
				if(!s1[i])continue;
				s2[i+x]=1;
			}
			s1[x]=1;
		}
	}
	return true;
}
inline void dfs();
inline void init(){
	ans[++cnt]=2;ans[++cnt]=3;ans[++cnt]=5;ans[++cnt]=7;p=5;
	s1[2]=1;s1[3]=1;s1[5]=1;s1[7]=1;
	s2[5]=1;s2[7]=1;s2[9]=1;s2[8]=1;s2[10]=1;s2[12]=1;
	s3[10]=1;s3[12]=1;s3[15]=1;
	s4[17]=1;
}

int main(){
    //File();
	read(n);
	Sieve();
	int p=0;
	for(Rint i=1;i<=ccnt;i++){
		if(pri[i]%5==1)printf("%d ",pri[i]),p++;
		if(p==n)return 0;
	}
	return 0;
}


Measured memory_bytes: 384
//package atcoder.beginner_171;

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main (String[] args) throws Exception {

        String s = "5 3\n" +
                "50 100 80 120 80";

//        br = new BufferedReader(new StringReader(s));
        br = new BufferedReader(new InputStreamReader(System.in));
        bw = new BufferedWriter(new OutputStreamWriter(System.out));

        rl(); int N=nin(), K=nin();
        rl(); int[] A=new int[N]; for(int i=0; i<A.length; ++i) A[i]=nin();
        Arrays.parallelSort(A);
        int sum=0;
        for(int i=0; i<K; ++i) sum+=A[i];


        bw.write(Integer.toString(sum));
        bw.newLine();
        bw.flush();

    }

    static BufferedReader br;
    static BufferedWriter bw;
    static StringTokenizer st;
    static void rl() throws Exception{
        st = new StringTokenizer(br.readLine());
    }
    static long nlo(){
        return Long.parseLong(st.nextToken());
    }
    static int nin(){
        return Integer.parseInt(st.nextToken());
    }
    /*private static void te(){
      }*/
    static double ndo(){
        return Double.parseDouble(st.nextToken());
    }
    static char[] nca(){
        return st.nextToken().toCharArray();
    }
    static String nstr(){
        return st.nextToken();
    }
}

Measured memory_bytes: 33048
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	int X;
	scanf("%d", &X);

	int tmp = 0, tmpmax = 0;
	for (int a = 1; a < 100; a++) {
		for (int b = 2; b < 100; b++) {
			tmp = pow(a,b);
			if (tmp <= X && tmpmax < tmp) {
				tmpmax = tmp;
			}
		}
	}
	int ans = 0;
	ans = tmpmax;
	printf("%d\n", ans);


#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
	int w;
	int ans=0;
	cin>>w;
	if(w==-1) break;
	if(w<=10) cout<<4280-1150<<endl;
	else if(w<=20) cout<<4280-(1150+(w-10)*125)<<endl;
	else if(w<=30) cout<<4280-(1150+1250+(w-20)*140)<<endl;
	else cout<<4280-(1150+1400+1250+(w-30)*160)<<endl;
    }
    return 0;
}




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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M + 1; j++)
    {
      if (j == 0)
        cin >> C[i];
      else
        cin >> A[i][j - 1];
    }
  }
  bool can = false;
  ll ans = INT_INF;
  for (int bit = 0; bit < (1 << N); bit++)
  {
    bool ok = true;
    vector<int> u(M);
    ll tmp = 0;
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i))
      {
        tmp += C[i];
        for (int j = 0; j < M; j++)
        {
          u[j] += A[i][j];
        }
      }
    }
    for (int i = 0; i < M; i++)
    {
      if (u[i] < X)
        ok = false;
    }
    if (ok)
    {
      can = true;
      ans = min(tmp, ans);
    }
  }
  if (can)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int p[100000];
int q[100000];
int r[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    for (int i = 0; i < a; ++i)
        cin >> p[i];
    for (int i = 0; i < b; ++i)
        cin >> q[i];
    for (int i = 0; i < c; ++i)
        cin >> r[i];

    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());
    sort(r, r + c, greater<int>());
    priority_queue<int> pq;
    for (int i = 0; i < x; ++i)
        pq.push(-p[i]);
    for (int i = 0; i < y; ++i)
        pq.push(-q[i]);

    int w = 0;
    ll sol = 0;
    while (!pq.empty())
    {
        int y = -pq.top();
        pq.pop();
        if (w < c && r[w] > y)
            sol += r[w], w++;
        else
            sol += y;
    }
    cout << sol;
}


Measured memory_bytes: 2552
#include <stdio.h>

int main(void)
{
	int n = 1;
	int cou = 0;
	while (n != 0){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			
			cou++;
		}
		printf("%d\n", cou);
		cou = 0;
	}
	
	return (0);
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        boolean[] used = new boolean[55555];
        for (int i = 2; i < 55555; i++) {
            if(used[i])continue;
            if(i%5==1)list.add(i);
            int t = i;
            while(t < 55555){
                used[t] = true;
                t += i;
            }
        }
        System.out.println(list.subList(0, n).stream().map(i -> String.valueOf(i)).collect(Collectors.joining(" ")));
        sc.close();

    }

}


Measured memory_bytes: 26708
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define loop(n) for(int i=0;i<n;++i)
typedef long long ll;
typedef vector<int> vi;
ll i,j=0;

int main(){
    int n,m;cin>>n>>m;
    ll sum = 0;
    int arr[n];loop(n){cin>>arr[i];sum += arr[i];}
    int chosen = 0;
    loop(n){
        if(4*m*arr[i]>=sum)++chosen;
    }
    cout << (chosen>=m?"Yes":"No") << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力


		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int sub = c;
		for(int i = 0;i < 10;i++){
			sub = a*sub - b;
			System.out.println(sub);
		}

	}


	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long long ll;
// cond: a>b
// ax+bx=c
ll extgcd2(ll a,ll b,ll c,ll& x,ll& y){
  ll g=a;x=c/a;y=0;
  if(b) g=extgcd2(b,a%b,c%b,y,x), y+=(c/b)-(a/b)*x;
  return g;
}

int main() {
  while(1) {
    ll a,b,r;
    cin>>a>>b>>r;
    if(!a)break;
    bool rev = a<b;
    if(rev)swap(a,b);
    ll x,y;
    ll g = extgcd2(a,b,r,x,y);
    if(rev){
      swap(x,y);swap(a,b);
    }
    a/=g;b/=g;
    while(abs(x) + abs(y) > abs(x+b) + abs(y-a) ||
        (abs(x) + abs(y) == abs(x+b) + abs(y-a) && abs(a*x) + abs(b*y) > abs(a*(x+b)) + abs(b*(y-a)))) {
      x+=b;y-=a;
    }
    while(abs(x) + abs(y) > abs(x-b) + abs(y+a) ||
        (abs(x) + abs(y) == abs(x-b) + abs(y+a) && abs(a*x) + abs(b*y) > abs(a*(x-b)) + abs(b*(y+a)))) {
      x-=b;y+=a;
    }
    cout << abs(x) << ' ' << abs(y) << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <sstream>
#include <stack>
using namespace std;

string int2mcxi(int n){
    string s;
    char c[4] = {'m', 'c', 'x', 'i'};
    int k = 3;
    while (n > 0){
	if (n % 10){
	    if (n % 10 == 1) s = c[k] + s;
	    else {
		s = c[k] + s;
		s = (char)(n % 10 + '0') + s;
	    }
	}
	n /= 10;
	k--;
    }
    return s;
}

int mcxi2int(string s){
    int num = 0;
    stack<char> st;
    for (int j = 0; j < s.size(); j++){
	if ('2' <= s[j] && s[j] <= '9') st.push(s[j]);
	else {
	    int k;
	    if (st.empty()) k = 1;
	    else {
		k = st.top() - '0';
		st.pop();
	    }
	    
	    if (s[j] == 'm'){
		num += k * 1000;
	    }
	    else if (s[j] == 'c'){
		num += k * 100;
	    }
	    else if (s[j] == 'x'){
		num += k * 10;
	    }
	    else if (s[j] == 'i'){
		num += k * 1;
	    }
	}
    }
    
    return num;
}

int main(){
    int n;
    cin >> n;
    string s1, s2;
    for (int i = 0; i < n; i++){
	cin >> s1 >> s2;
	cout << int2mcxi(mcxi2int(s1) + mcxi2int(s2)) << endl;
    }
}

Measured memory_bytes: 0
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 4e5 + 10;

int a[N], ctr[N], pos[N], nxt[N];
int g[N], depth[N], c_len, c_st;
bool seen[N];

void dfs(int u);

int main() {
	fast_cin();
	int n; ll k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i + n] = a[i];
	}
	for (int i = 2 * n - 1; i >= 0; --i) {
		if (pos[a[i]]) {
			nxt[i] = pos[a[i]];
		} else {
			nxt[i] = 2 * n;
		}
		pos[a[i]] = i;
	}
	g[n] = 0;
	for (int i = n - 1; i >= 0; --i) {
		if ((nxt[i] + 1) >= n) {
			g[i] = nxt[i] + 1;
		} else {
			g[i] = g[nxt[i] + 1];
		}
		if (g[i] < 2 * n) {
			g[i] %= n;
		} else {
			g[i] = n;
		}
	}
	dfs(0);
	--k;
	int s = 0;
	while (k) {
		if (s == c_st) {
			k %= c_len;
		}
		if (k) {
			s = g[s];
			--k;
		}
	}
	vector<int> ans;
	for (int i = s; i < n; ++i) {
		if (ctr[a[i]]) {
			while (ctr[a[i]]) {
				--ctr[ans.back()];
				ans.pop_back();
			}
		} else {
			++ctr[a[i]];
			ans.pb(a[i]);
		}
	}
	for (auto &i : ans) {
		cout << i << ' ';
	}
}

void dfs(int u) {
	seen[u] = true;
	if (seen[g[u]]) {
		c_st = g[u];
		c_len = depth[u] - depth[g[u]] + 1;
		return;
	}
	depth[g[u]] = depth[u] + 1;
	dfs(g[u]);
}

Measured memory_bytes: 11252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100002
ll dp[MAXN][3];
ll a[MAXN];
ll b[MAXN];
ll c[MAXN];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[1][0] = a[1];
    dp[1][1] = b[1];
    dp[1][2] = c[1];
    for (int i = 2; i <= n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;
    return 0;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	vector<int> ma(a,0);
	int d = 0;
	REP(i,c){
		cin >> d;
		ma[d-1] += 1;
	}
	int ans = 0;
	REP(i,a) {
		if(c-b<ma[i]) cout << "Yes" << endl;
		else 	cout << "No" << endl;
	}
}


Measured memory_bytes: 3792
#include "bits/stdc++.h"

typedef long long ll;

using namespace std;

int main() {
	int r,D,res=0,sum,x,A;
	cin >> r >> D >> x;
	A = x;
	for (int i =1; i < 11; i++)
	{
		sum = r * A - D;
		A = sum;
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
const ll INF = 1e9;
//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);

int main(){
  faster();
  ll ans=0,n,od=0,ev=0;
  cin >> n;
  vl odd(1e5+1),even(1e5+1);
  rep(i,n/2){
    cin >> od >> ev;
    odd[od]++;
    even[ev]++;
  }
  ll mode_odd=0,mode_even=0,temp1=0,temp2=0;
  rep(i,1e5+1){
    if(temp1 < odd[i]){
      temp1 = odd[i];
      mode_odd = i;
    }
    if(temp2 < even[i]){
      temp2 = even[i];
      mode_even = i;
    }
  }
  sort(odd.rbegin(),odd.rend());
  sort(even.rbegin(),even.rend());
  if(mode_even == mode_odd) cout << min(n - odd[1] - even[0] , n - odd[0] - even[1]) << endl;
  else cout << n - odd[0] - even[0] << endl;
}








































//以下、ライブラリ

void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} //ユークリッドの互除法

ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} //桁数取得

ll POW(auto x,auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} //べき乗計算

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main(){
  ll n,m;
  cin >>n >>m;
  ll ans=(1900*m+100*(n-m))*pow(2,m);
  cout << ans << endl;
}

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

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i = 0; i < N; i++){
        std::cin >> A.at(i);
    }

    std::sort(A.begin(), A.end());

    int prev = A.at(0);
    int cnt = 1, ans = 0;
    for(int i = 1; i < N; i++){
        if(prev == A.at(i)){
            cnt++;
        }else{
            ans += (cnt % 2);
            cnt = 1;
        }
        prev = A.at(i);
    }
    ans += (cnt % 2);

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


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

vector<bool> primes(101);
vector<int> p;

void find_p() {
	fill(primes.begin(), primes.end(), true);
	primes[0] = primes[1] = false;
	for(int i = 2; i < 101; i++) {
		for(int j = 2 * i; j < 101; j += i) {
			primes[j] = false;
		}
	}
	for(int i = 0; i < 101; i++) {
		if(primes[i]) {
			p.push_back(i);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n; cin >> n;
	map<int, int> fac;
	for(int i = 1; i <= n; i++) {
		int t = i;
		for(int j = 2; j <= t; j++) {
			while(t % j == 0) {
				fac[j]++;
				t /= j;
			}
		}
	}
	find_p();
	long long ans = 0;
	for(int i = 0; i < p.size(); i++) {
		if(fac[p[i]] >= 74) {
			ans++;
		}
		for(int j = 0; j < p.size(); j++) {
			if(i == j) {
				continue;
			}
			if(fac[p[i]] >= 24 && fac[p[j]] >= 2) {
				ans++;
			}
			if(fac[p[i]] >= 14 && fac[p[j]] >= 4) {
				ans++;
			}
		}
	}
	for(int i = 0; i < p.size(); i++) {
		for(int j = 0; j < p.size(); j++) {
			for(int k = j + 1; k < p.size(); k++) {
				if(i == j || i == k) {
					continue;
				}
				if(fac[p[i]] >= 2 && fac[p[j]] >= 4 && fac[p[k]] >= 4) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 256
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<std::string, int> psi;
typedef pair<int, psi> g;

bool pairCompare(const g& a, const g& b) {
	if (a.second.first == b.second.first){
		return a.second.second > b.second.second;
	 } else {
		 return a.second.first < b.second.first;
	}
}

int main(){

	int n, p;
	string c;
	cin >> n;
	vector<g> h;
	rep(i,n){
		cin >> c >> p;
		h.push_back(g(i+1, psi(c, p)));
	}
	sort(ALL(h), pairCompare);
	rep(i,n){
		cout << h[i].first << endl;
	}
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 1e9;

struct BipartiteMatch {
    int n, m; //left and right
    vector<vector<bool>> matrix;
    vector<int> matched;
    
    BipartiteMatch(int n, int m) : n(n), m(m) {
        matrix.assign(n, vector<bool>(m, false));
        matched.assign(m, -1);
    }
    
    void addEdge(int from, int to) {
        matrix[from][to] = true;
    }
    
    int maxBpm() {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            vector<bool> seen(m, false);
            if (bpm(i, seen)) {
                ans++;
            }
        }
        return ans;
    }
    
    //This is DFS. Could do BFS too.
    bool bpm(int source, vector<bool>& seen) {
        for (int target = 0; target < m; target++) {
            if (matrix[source][target] && !seen[target]) {
                seen[target] = true;
                if (matched[target] == -1 || bpm(matched[target], seen)) {
                    matched[target] = source;
                    return true;
                }
            }
        }
        return false;
    }  
};


int main() {
    int n, m, e;
    //cin >> v >> e >> s >> t;
    cin >> n >> m >> e;
    
    BipartiteMatch bpm(n, m);
   
    for (int i = 0; i < e; i++) {
        int from, to;
        cin >> from >> to;
        bpm.addEdge(from, to);
    }
    int ans = bpm.maxBpm();
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3180
import java.io.*;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
StringTokenizer st=new StringTokenizer(line);
int a=Integer.parseInt(st.nextToken());
int b=Integer.parseInt(st.nextToken());
out.println(gcd(Math.max(a,b),Math.min(a,b)));
out.flush();
}
}

private static long gcd(int a,int b){
if(b==0) return a;
return gcd(b,a%b);
}
}

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

int main() {
    string str;
    cin>>str;
    int n=str.size();
    if(str[n-1]=='s')
    {
        cout<<str+'e'+'s';
        
    }
    else
    {
        cout<<str+'s';
    }
	
	
	return 0;
}


Measured memory_bytes: 3644
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().trim.toInt
  
  def isPrime(x: Int): Boolean = {
    if (x == 2) {
      true
    }
    else if (x < 2 || x % 2 == 0) {
      false
    } else {
      !(3 to scala.math.sqrt(x).toInt by 2).exists(i => x % i == 0)
    }
  }

  println((0 until n).foldLeft(0){ (acc, _) =>
    val x = StdIn.readLine().trim.toInt
    acc + (if(isPrime(x)) 1 else 0)
  })

}



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

using namespace std;
string s;
long long R,L;
int main()
{
 cin>>s;
 for(int i=0;i<s.size();i++)
 {
   if(s[i]=='A')
   {
      L=i;
      break;
   }
 }
 for(int i=s.size()-1;i>=0;i--)
 {
   if(s[i]=='Z')
   {
      R=i;
      break;
   }
 }
 if(L>R)swap(L,R);
 cout<<R-L+1<<endl;
 return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>

using namespace std;
#define ll          long long
#define endl        "\n"
#define inf         10000000002
#define pb          push_back
#define pf          push_front
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(a)      a.begin(),a.end()
#define mp          make_pair
#define MAX         100
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0

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

int main()
{
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      cout.tie(NULL);
      //freopen("inputNew.txt", "r", stdin);

      int a,b,c;
      cin>>a>>b>>c;

      int cnt=0;
      for(int i=c; i<=b; i+=c){
            if(i>=a && i<=b) cnt++;
      }
      cout<<cnt<<endl;

      bye;
}


Measured memory_bytes: 3632