akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
  int N,T;
  int t[200000];
  cin >> N >> T;
  int x=0;
  for(int i=0;i<N;i++){
    cin >> t[i];
    t[i]=t[i]-x;
    x=x+t[i];
  }
  int count = 0;
  for(int i=1;i<N;i++){
    if(t[i]>T){
      count +=T;
    }else{
      count +=t[i];
    }
  }
  count +=T;
  cout << count <<endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define temp template<typename T>
#define debug(x) cerr<<"Line "<<__LINE__<<": "<<#x<<" = "<<x<<'\n'
#define itr(it,x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define rep(i,a,b) for(int i=a;i<=(int)b;i++)
#define repr(i,a,b) for(int i=a;i>=(int)b;i--)
#define cas(n) printf("Case %d:",(int)n)
#define mem(x,v) memset(x,v,sizeof(x))
#define read(x) freopen(x,"r",stdin)
#define write(x) freopen(x,"w",stdout)
#define all(x) x.begin(),x.end()
#define aut(x,v) for(auto &x:v)
#define ini(n) scanf("%d",&n)
#define inl(n) scanf("%lld",&n)
#define ind(n) scanf("%lf",&n)
#define ins(n) scanf("%s",n)
#define insn(n) scanf(" %[^\n]",n)
#define outi(n) printf("%d",(int)n)
#define outl(n) printf("%lld",(LL)n)
#define outd(n,p) printf("%.*lf",p,(double)n)
#define outs(n) printf("%s",n)
#define sz(x) (int)x.size()
#define nl printf("\n")
#define sp printf(" ")
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

const int inf=0x3f3f3f3f;
const int mod=1000000007;
const int mx=10000005;
const LL  infL=0xf3f3f3f3f3f3f3f;
const double eps=1e-9;
const double pi=acos(-1.0);

int main()
{
    //read("in.txt"),write("out.txt");
    int x,y;
    ini(x),ini(y);
    outi(x+y/2),nl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll BOTTLE[4], N, ans = 0;
	pair<ll, ll> pB[4];

	rep(i, 4) cin >> BOTTLE[i];
	cin >> N;

	pB[0] = make_pair(BOTTLE[0] * 8, 0);
	pB[1] = make_pair(BOTTLE[1] * 4, 1);
	pB[2] = make_pair(BOTTLE[2] * 2, 2);
	pB[3] = make_pair(BOTTLE[3] * 1, 3);

	sort(pB, pB + 4);

	rep(i, 4) {
		if (N == 0) break;

		if (pB[i].second == 0) {
			ans += BOTTLE[0] * (N * 4);
			N = 0;
		}
		else if (pB[i].second == 1) {
			ans += BOTTLE[1] * (N * 2);
			N = 0;
		}
		else if (pB[i].second == 2) {
			ans += BOTTLE[2] * (N * 1);
			N = 0;
		}
		else if (pB[i].second == 3) {
			ans += BOTTLE[3] * (N / 2);
			N %= 2;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
int a[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    int cur = 1;
    for(int i = 0; i < N; i++){
        if(a[i] == cur){
            cur++;
        }
    }
    if(cur == 1){
        cout << -1 << endl;
    }else{
        cout << N-(cur-1) << endl;
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int N,L,S,N1,N2,N3,N4,N5,N6,i,temp,j,cnt,flg,flg1;
	int a[4];

	scanf("%d",&N);
	while(!(N==0000)){
		cnt=0;
		flg=0;
		while(!(N==6174)){
			cnt++;
			N1=N/1000;/*6!*/
			N2=N%1000;/*174*/
			N3=N2/100;/*1!*/
			N4=N2%100;/*74*/
			N5=N4/10;/*7*/
			N6=N4%10;/*4!*/
			if(N1==N3 && N1==N5 && N1==N6){
				printf("NA\n");
				flg=1;
				break;
			}
			else{
				a[0]=N1;
				a[1]=N3;
				a[2]=N5;
				a[3]=N6;
				for(i=0;i<4;i++){
					for(j=i+1;j<4;j++){
						if(a[i]<a[j]){
							temp=a[j];
							a[j]=a[i];
							a[i]=temp;	
						}
					}
				}
				N1=a[0]*1000;
				N3=a[1]*100;
				N5=a[2]*10;
				N6=a[3];
				L=N1+N3+N5+N6;
				for(i=0;i<4;i++){
					for(j=i+1;j<4;j++){
						if(a[i]>a[j]){
							temp=a[i];
							a[i]=a[j];
							a[j]=temp;	
						}
						
					}
				}
				N1=a[0]*1000;
				N3=a[1]*100;
				N5=a[2]*10;
				N6=a[3];
				S=N1+N3+N5+N6;
				N=L-S;
			}
		}
		if(flg==0){
			printf("%d\n",cnt);
		}
		scanf("%d",&N);
	}
	return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

vector<vector<ll>> G;
vector<ll> dist;
vector<ll> used;
ll N, M;
void init(ll n){
    G.resize(3*n);
    dist.resize(3*n, INF);
    used.resize(3*n, 0);
}

void dijkstra(ll s){
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push(P(0, s));
    while(pq.size()){
        P p = pq.top(); pq.pop();
        ll d = p.first;
        ll v = p.second;
        if(used[v] or d>dist[v]+1) continue;
        used[v] = 1;
        for(ll i=0; i<G[v].size(); i++){
            ll nv = G[v][i];
            if(used[nv])continue;
            if(dist[nv]>dist[v]+1){
                dist[nv] = dist[v]+1;
                pq.push(P(dist[nv], nv));
            }
        }
    }
}

void bfs(ll s){
    queue<ll> q;
    q.push(s);
    while(q.size()){
        ll v = q.front(); q.pop();
        if(used[v]) continue;
        used[v] = 1;
        for(ll i=0; i<G[v].size(); i++){
            ll nv = G[v][i];
            if(used[nv]) continue;
            q.push(nv); 
            dist[nv] = dist[v] + 1;
        }
    }
}

signed main(){
    cin>>N>>M;
    init(N);
    REP(i, M){
        ll u, v;cin>>u>>v;
        u--,v--;
        REP(j, 3){
            G[j*N+u].push_back(((j+1)%3)*N+v);
        }
    }
    ll S, T; cin >> S >> T;
    S--, T--;
    dist[0*N+S] = 0;
    dijkstra(S);
    if(dist[0*N+T]==INF) cout<<-1<<endl;
    else cout << dist[T]/3 << endl;
    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
	using namespace std;
	#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
	#define ll long long int


	int main()
	{
		FAST;
		//ll testcase;
		//cin>>testcase;
		//for(ll t=0;t<testcase;t++)
		{
			//use long long
			//donot memeset other than 0 or 1 or -1
			//segmentation fault-> check for uninitialized global variable or out of bounds
			//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
			//dont rush to writing code think through the logic	
			int n,x;
			cin>>x>>n;
			bool flag=false;
			for(int i=0;i<=x;i++)
			{
				if(2*i+4*(x-i)==n)
				{
					cout<<"Yes\n";
					flag=true;
					break;
				}
			}
			if(!flag)
				cout<<"No\n";
		}
		return 0;
	}



































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

static const int NMAX = 50000;
static const int INFTY = (1<<29);

int main(){
    int n,m;
    int C[21];
    int T[NMAX+1];
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        cin >> C[i];
    }
    
    for(int i=0; i<=NMAX; i++) T[i] = INFTY;
    T[0] = 0;
    for(int i=1; i<=m; i++){
        for(int j=0; j+C[i]<=n; j++){
            T[j+C[i]] = min(T[j+C[i]],T[j]+1);
        }
    }
    cout << T[n] << endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,m,n) for(int i=m;i<n;i++)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<int> vec;
typedef vector<vec> mat;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
const int INF = 1e9;
const int mod = 1e9 + 7;
const int MAX = 200005;

vector<int> g[MAX];
bool used[MAX] = {0};

int N, M;

void is_connected(int v) {
    if(used[v]) return;
    used[v] = true;
    for(int i=0;i<g[v].size();++i) {
        is_connected(g[v][i]);
    }
}
int main(){
    cin >> N >> M;
    for(int i=0;i<N;++i) {
        int k;
        cin >> k;
        int l;
        for(int j=0;j<k;++j)  {
            cin >> l;
            g[i].push_back(N+l);
            g[N+l].push_back(i);
        }
    }

    is_connected(0);
    for(int i=0;i<N;++i) {
        if(used[i] == false)  {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 8704
#include <stdio.h>
struct Node {
  int parent;
  int left;
  int right;
};
int n;
struct Node tree[30];
int dipth[30],height[30];
void getdip(int,int);
int gettree(int);
int getsibling(int);
void printtree(int);
int main(){
  int i,id,left,right,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].parent=tree[i].left=tree[i].right=-1;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left=left;
    tree[id].right=right;
    if(left!=-1)tree[left].parent=id;
    if(right!=-1)tree[right].parent=id;
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)root=i;
  }
  getdip(root,0);
  getheight(root);
  for(i=0;i<n;i++)printtree(i);
  return 0;
}
int getheight(int root){
  int h1=0,h2=0;
  if(tree[root].left!=-1)h1=getheight(tree[root].left)+1;
  if(tree[root].right!=-1)h2=getheight(tree[root].right)+1;
  if(h1>h2)height[root]=h1;
  else height[root]=h2;
  return height[root];
}
int getsibling(int num){
  if(tree[num].parent==-1)return -1;
  if(tree[tree[num].parent].left!=num&&tree[tree[num].parent].left!=-1)return tree[tree[num]\
.parent].left;
  else if(tree[tree[num].parent].right!=num&&tree[tree[num].parent].right!=-1)return tree[tr\
ee[num].parent].right;
  return -1;
}
void getdip(int r,int d){
  if(r==-1)return;
  dipth[r]=d;
  if(tree[r].right!=-1)getdip(tree[r].right,d+1);
  if(tree[r].left!=-1)getdip(tree[r].left,d+1);
}
void printtree(int i){
  int m,j=0,digree=0;
  if(tree[i].right!=-1)digree++;
  if(tree[i].left!=-1)digree++;
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree\
[i].parent,getsibling(i),digree,dipth[i],height[i]);
  if(tree[i].parent==-1)printf("root");
  else if(tree[i].left==-1&&tree[i].right==-1)printf("leaf");
  else printf("internal node");
  printf("\n");
}



Measured memory_bytes: 2108
#include<stdio.h>

#define WHITE 2
#define GRAY 1
#define BLACK 0

#define INF 1000000


int color[100];
int num[100][100];
int d[100];
int p[100];

void find(int);

int main(){
  int n,m;
  int v,l,p;
  int i,j;
  

  scanf("%d",&n);

  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      num[i][j]=-1;
  }
} 


  for(i=0;i<n;i++){
    scanf("%d%d",&m,&p);
    for(j=0;j<p;j++){
      scanf("%d%d",&v,&l);
      num[m][v]=l;/*?????????v??????????????????????????£??\*/
    }

  }

  
  find(n);

  return 0;
}

void find(int n){
  int i,j,u,r,s;
  int mincost;
  int sum=0;

  for(i=0;i<n;i++){
    d[i]=INF;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=INF;
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }    
    if(mincost==INF) break;

    color[u]=BLACK;
      
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && num[u][i]!=-1){
	if(num[u][i]+d[u]<d[i]){
	  d[i]=num[u][i]+d[u];
	  p[i]=u;	
	  color[i]=GRAY;
	}
      }
   }
  }


  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
}

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

int N;
int A[110],B[110];
int main(){
	cin >> N;
	A[0] = 0;B[0] = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		A[i] += A[i-1];
	}
	for(int i=1;i<=N;i++){
		cin >> B[i];
		B[i] += B[i-1];
	}
	int ans = 0;
	for(int i=1;i<=N;i++){
		if(ans < A[i]+B[N]-B[i-1]) ans = A[i]+B[N]-B[i-1];
	}
	cout << ans << endl;
}

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

int paper[14][14] = {{0}};

void small(int x, int y) {
	paper[x + 2][y + 1]++;
	paper[x + 1][y + 2]++;
	paper[x + 2][y + 2]++;
	paper[x + 3][y + 2]++;
	paper[x + 2][y + 3]++;
}

void medium(int x, int y) {
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			paper[x + j][y + i]++;
		}
	}
}

void big(int x, int y) {
	paper[x + 2][y]++;
	paper[x][y + 2]++;
	paper[x + 4][y + 2]++;
	paper[x + 2][y + 4]++;
	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			paper[x + j][y + i]++;
		}
	}
}

int main() {
	int x, y, z, white = 0, con = 0;

	while (scanf("%d,%d,%d", &x, &y, &z) != EOF) {
		if (z == 1) {
			small(x, y);
		}
		else if (z == 2) {
			medium(x, y);
		}
		else if (z == 3) {
			big(x, y);
		}
	}
	for (int i = 2; i < 12; i++) {
		for (int j = 2; j < 12; j++) {
			if (paper[i][j] == 0) {
				white++;
			}
			if (paper[i][j] > con) {
				con = paper[i][j];
			}
		}
	}
	cout << white << endl << con << endl;
}

Measured memory_bytes: 3104
from itertools import product
A, B, C, D = list(input())
l = len(A)

for ops in product(["+", "-"], repeat=3):
  eq = A + ops[0] + B + ops[1] + C + ops[2] + D
  x = eval(eq)
  if x == 7:
    break
print(eq + "=7")

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

int main() {
  int n;
  cin>>n;
  int t=n;
  int a=0;
  while(t>0){
    a+=t%10;
    t/=10;
  }
  if(n%a==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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


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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    int n = s.size();
    int hug=0;
    
    for(int i=0; i<n/2; i++){
        if(s.at(i) != s.at(n-1-i)){
            s.at(n-1-i) = s.at(i);
            hug ++;
        }
    }
    cout << hug << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  int N;
  cin >> N;
  int mi, ma;
  mi = 1 << 30;
  ma = 0;
  rep(i, N)
  {
    int n;
    cin >> n;
    if (mi > n)
      mi = n;
    if (ma < n)
      ma = n;
  }
  cout << ma - mi << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<ll> h(n+1);
  vector< priority_queue<ll> > p(n+1);
  for(int i = 1; i <= n; i++) {
    cin >> h[i];
    p[i].push(h[i]);
  }
  vector<set<int>> s(n+1);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    size_t s1 = s[a].size();
    s[a].insert(b);
    s[b].insert(a);
    if (s1 == s[a].size()) continue;
    p[a].push(h[b]);
    p[b].push(h[a]);
  }

  ll result = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i].size() == 1) {
      result++; 
      continue;
    }
    ll now = p[i].top();
    p[i].pop();
    ll next = p[i].top();
    if (now == h[i] && next != now) {
      result++;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 26488
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int n,m,l;
  double p[100];
  int t[100],v[100];
  double time[100][51],prob[100][51];

  cin >> n >> m >> l;
  for(int i=0;i<n;i++){
    cin >> p[i] >> t[i] >> v[i];
    p[i] /= 100;
  }
  
  for(int i=0;i<n;i++){
    for(int j=0;j<=m;j++)time[i][j] = (double)l/v[i] + t[i]*j;
  }
  
 
  for(int i=0;i<n;i++){
    if(abs(p[i]-1.0)<1e-10){
      for(int j=0;j<m;j++)prob[i][j] = 0.0;
      prob[i][m] = 1.0;
    }else{
      prob[i][0] = pow(1-p[i],m);
      for(int j=1;j<=m;j++){
	prob[i][j] = ( prob[i][j-1] * p[i] * (m-j+1) ) / ( (1-p[i])*j );
      }
    }
  }

  for(int i=0;i<n;i++){
    double ans = 0.0;
    if(!v[i])printf("%.8lf\n",ans);
    else{
      for(int j=0;j<=m;j++){
	double tmp = 1.0;
	for(int k=0;k<n;k++){
	  if(k!=i){
	    double hoge = 0.0;
	    for(int l=m;l>=0;l--){
	      if(time[k][l] > time[i][j]){
		hoge += prob[k][l];
	      }else break;
	    }
	    tmp *= hoge;
	  }
	}
	ans += tmp*prob[i][j];
      }
      printf("%.8lf\n",ans);
    }
  }
}

Measured memory_bytes: 1064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{

    string S;
    cin >> S;
    string s = S.substr(0, (S.size() - 1) / 2);
    string t = s;
    reverse(t.begin(), t.end());

    string u = S.substr((S.size() + 2) / 2, S.size());
    string v = s;
    reverse(v.begin(), v.end());

    if(s == t and u == v ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cmath>

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int k;
int s;

void input() {
  cin >> k >> s;
}

void solve() {
  int ans = 0;

  for (int i = 0; i < k + 1; ++i) {
    for (int j = 0; j < k + 1; ++j) {
      int val = s - (i + j);
      
      if (val > -1 && val < k + 1)
        ++ans;
    }
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 3580
def lcs(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)
    for i in range(a):
        e1 = x[i]
        c2 = c1[:]
        for j in range(b):
            if e1 == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
    
n = int(input().rstrip())
ret = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    ret.append(lcs(s1, s2))
print(*ret, sep="\n")

Measured memory_bytes: 7696
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

int main() {

	ll t1, t2, a1, a2, b1, b2, d, d1, d2, sum;

	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

	d1 = (a1 - b1) * t1;
	d2 = (a2 - b2) * t2;
	d = d1 + d2;
	if (d == 0) {
		cout << "infinity" << endl;
		return 0;
	}

	if ((d1/abs(d1)) * (d2/abs(d2)) < 0 and abs(d1) < abs(d2)) {
		d1 = abs(d1);
		d = abs(d);

		sum = 2 * (d1 / d);
		if (d1 % d != 0) {
			sum++;
		}

		cout << sum << endl;
		return 0;
	}
	else {
		cout << 0 << endl;
		return 0;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        int min = Integer.MAX_VALUE;
        x[0] = 0;
        for (int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }
 
        for (int i=k-1;i<n;i++){
            int abs = Math.abs(x[i]-x[i-k+1]);
            min = Math.min(min,Math.min(Math.abs(x[i])+ abs,Math.abs(x[i-k+1])+ abs));
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 49236
#include <stdio.h>
#include<stdlib.h>
typedef long long int ll;
ll asc(const void* a, const void* b) { return *(ll*)a - *(ll*)b; }
ll desc(const void* a, const void* b) { return *(ll*)b - *(ll*)a; }
int main(void) {
	int n, i, j, t, a1, a2, a3, a4;
	int d[1000000];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &d[i]);
	}
	qsort(d, n, sizeof(int), asc);
	a1 = n / 2;
	a2 = d[a1];
	a3 = d[a1 - 1];
	a4 = a2 - a3;
	printf("%d", a4);

	return 0;
}

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

int main() {
  int H, W;
  
  cin >> H >> W;
  
  string S0, S1, S2;
  string s0, s1, s2;
  int x;
  
  if (H == 1) {
    cin >> S1;
    s1 = "-";
    s1 += S1;
    s1 += "-";
    
    for (int j = 1; j < W+1; j++) {
    if (s1.at(j) == '#')
      cout << "#";
        
    else {
       x = 0;
       for (int k = j; k < j+3; k++){
         if (s1.at(k-1) == '#')
           x++;
       }
      cout << x;
    }
    }
    cout << endl;
  }
  

  
  else { 
    cin >> S1;
    cin >> S2;
    
    for (int i = 0; i < W; i++) {
      S0 += "-";
    }
    
    for (int i = 0; i < H-1; i++) {
        s0 = "-";
        s1 = "-";
        s2 = "-";
        
        s0 += S0;
        s1 += S1;
        s2 += S2;
        
        s0 += "-";
        s1 += "-";
        s2 += "-";
            
      for (int j = 1; j < W+1; j++) {
        if (s1.at(j) == '#')
          cout << "#";
        
        else {
          x = 0;
          for (int k = j; k < j+3; k++) {
            if (s0.at(k-1) == '#')
              x++;
            if (s1.at(k-1) == '#')
              x++;
            if (s2.at(k-1) == '#')
              x++;
          }
          
          cout << x;
        }
      }
      cout << endl;
      
      
      S0 = S1;
      S1 = S2;
      
      if (i == H-2)
        break;
      
      cin >> S2;
    }
    
    for (int j = 1; j < W+1; j++) {
        if (s2.at(j) == '#')
          cout << "#";
        
        else {
          x = 0;
          for (int k = j; k < j+3; k++){
            if (s1.at(k-1) == '#')
              x++;
            if (s2.at(k-1) == '#')
              x++;
          }
          
          cout << x;
        }
        
    }
    cout << endl;
  }
          
}


Measured memory_bytes: 256
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[0 for i in range(w)] for i in range(h)]
c2 = [[0 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == 0:
            n = 0
            k = i
            while k < h:
                if l[k][j] == ".":
                    n +=1
                    k += 1
                else:
                    break
            for r in range(i,k):
                c1[r][j] = n
            
        if c2[i][j] == 0:
            n = 0
            k = j
            while k < w:
                if l[i][k] == ".":
                    n +=1
                    k += 1
                else:
                    break
            for r in range(j,k):
                c2[i][r] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

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

signed main() {
  int H, W; cin >> H >> W;
  vector<string> s(H);
  for(int i = 0; i < H; i++) cin >> s[i];

  for(int i = 0; i < W+2; i++) cout << '#' << (i==W+1 ? "\n" : "");
  for(int i = 0; i < H; i++) cout << '#' << s[i] << '#' << endl;
  for(int i = 0; i < W+2; i++) cout << '#' << (i==W+1 ? "\n" : "");

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		if(s.length() <= k) {
			System.out.println(s);
		}else {
			String ans = s.substring(0,k)+"...";
			System.out.println(ans);
		}
	}
	
	static  class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

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

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

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

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 36372
class Dice
    attr_accessor :top, :front, :right, :left, :back, :bottom

    def initialize(top, front, right, left, back, bottom)
        @top, @front, @right, @left, @back, @bottom \
            = top, front, right, left, back, bottom
    end

    def north
        @top, @front, @bottom, @back \
            = @front, @bottom, @back, @top
    end

    def east
        @top, @right, @bottom, @left \
            = @left, @top, @right, @bottom
    end

    def spin
        @front, @right, @back, @left \
            = @right, @back, @left, @front
    end

    def is_equal?(other)
        for i in 0...6
            (i % 2 == 1)? (self.north): (self.east)
            for j in 0...4
                self.spin
                if (self == other)
                    return true
                end
            end
        end

        return false
    end

    def ==(other)
        @top == other.top && @front == other.front \
            && @right == other.right && @left == other.left \
            && @back == other.back && @bottom == other.bottom
    end

    def self.is_all_different(dices)
        dices.each_with_index do |dice, idx|
            for i in (idx + 1)...dices.size
                if dice.is_equal?(dices[i])
                    return false
                end
            end

            return true
        end
    end
end

n = gets.chomp.to_i

dices = Array.new(n) do
    Dice.new(*(gets.chomp.split.map(&:to_i)))
end

puts ((Dice.is_all_different(dices))? "Yes": "No")

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    cin >> S;

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

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

int main(){
    int k, t, sum = 0;
    cin >> k >> t;
    vector<int> A(t);
    REP(i, t){
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<int>());

    int tmp = A[0];
    for(int i = 1; i < t; i++){
        tmp = tmp - A[i];
    }
    if(tmp > 0) tmp--;    
    if(tmp < 0) tmp = 0;
    cout << tmp << endl;


    return 0;
}

Measured memory_bytes: 256
x = int(input())
if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)

Measured memory_bytes: 9180
def solve():
    N = int(input())
    M = 3501

    for h in range(1, M):
        for n in range(h, M):
            numerator = N * h * n
            denominator = 4 * n * h - N * h - N * n
            if numerator <= 0 or denominator <= 0:
                continue
            if numerator % denominator == 0:
                return h, n, numerator // denominator


h, n, w = solve()
print(h, n, w)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int mod = 1e9 + 7;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> s(n);
  for (auto &e : s) {
    cin >> e;
  }
  sort(begin(s), end(s));

  vector<int> ub(x + 1);
  for (int i = 0; i <= x; i++) {
    ub[i] = upper_bound(begin(s), end(s), i) - begin(s);
  }

  vector<vector<ll>> dp(n + 1, vector<ll>(x + 1));
  dp[0][x] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= x; j++) {
      if (!dp[i][j]) continue;
      int b = ub[j];
      for (int k = 0; k < b; k++) {
        int t = j % s[k];
        dp[i + 1][t] += dp[i][j];
        dp[i + 1][t] %= mod;
      }
      dp[i + 1][j] += (n - b - i) * dp[i][j];
      dp[i + 1][j] %= mod;
    }
  }

  // for (auto e : ub) {
  //   cerr << e << " ";
  // }
  // cerr << endl;
  // for (int i = 0; i <= n; i++) {
  //   cerr << i << " ";
  //   for (int j = 1; j <= x; j++) {
  //     cerr << j << ":" << dp[i][j] << ", ";
  //   }
  //   cerr << endl;
  // }

  ll r = 0;
  for (int j = 1; j <= x; j++) {
    r += j * dp[n][j];
    r %= mod;
  }
  cout << r << endl;
}


Measured memory_bytes: 158976
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i, n){
        cin>>a[i];
    }
    bool frag=false;
    rep(i, n-1){
        if(a[i]>0) continue;
        if(a[i]==0) frag=true;
        a[i]*=-1; a[i+1]*=-1;
    }

    if(a[n-1]<0){
        if(frag) a[n-1]*=-1;
        else{
            a[n-1]*=-1;
            vector<ll>::iterator minit= min_element(a.begin(), a.end());
            size_t minIndex = distance(a.begin(), minit);
            a[minIndex]*=-1;
        }

    }

   
    ll ans=accumulate(a.begin(), a.end(), 0LL);
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long a,b;
char s;
int main()
{
    scanf("%lld %c %lld",&a,&s,&b);
    if(s=='+')
    {
        printf("%lld\n",a+b);
    }
    else
    {
         printf("%lld\n",a-b);
    }
    return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define FOR(i, start, end) for(int64_t i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

signed main() {
  int64_t x;
  cin >> x;  
  int64_t tmpX;
  while(true){
    tmpX = sqrt(x);
    bool isPrime = true;
    FOR(i,2,tmpX+1){
      if(x%i==0){
        isPrime = false;
        break;
      }
    }
    if(isPrime){
      cout << x << endl;
      return 0;
    }
  	if(x%2==0){
      x++;
  	}
    else{
      x += 2;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
from scipy.sparse import csr_matrix
import numpy as np

N = int(input())

XY = [[i] + [int(x) for x in input().split()] for i in range(N)]

edge = set()
for key in [itemgetter(1),itemgetter(2)]:
  XY.sort(key = key)
  for i in range(N-1):
    i1,x1,y1 = XY[i]
    i2,x2,y2 = XY[i+1]
    d = min(abs(x1-x2),abs(y1-y2))
    edge.add((i1,i2,d))
    
row,col,value = zip(*edge)
value = np.array(value,dtype=int)
graph = csr_matrix((value,(row,col)),shape=(N,N))

from scipy.sparse.csgraph import minimum_spanning_tree
tree = minimum_spanning_tree(graph, overwrite = True).astype(int)
answer = tree.sum()
print(answer)


Measured memory_bytes: 101568
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<int> b(n-1);
  for(int i=0;i<n-1;i++)cin>>b[i];
  int ans=b[0]+b[n-2];
  for(int i=0;i<n-2;i++){
    ans+=min(b[i],b[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//幅優先探索(重み付き)
//全て添字で扱うこと
void bfs(ll n, vector<vector<vll>> &next, ll start, vll &color) {
  queue<ll> task;
  task.push(start);

  vll seen(n, 0);
  seen[start] = 1;

  ll depth = 0;
  while (task.size() > 0) {
    ll width = task.size();
    for (ll i = 0; i < width; i++) {
      for (ll j = 0; j < next[task.front()].size(); j++) {
        if (seen[next[task.front()][j][1]] == 0) {
          if (next[task.front()][j][0] % 2 == 0) {
            color[next[task.front()][j][1]] = color[task.front()];
          }
          else color[next[task.front()][j][1]] = (color[task.front()] + 1) % 2;

          task.push(next[task.front()][j][1]);
          seen[next[task.front()][j][1]] = 1;
        }
      }
      task.pop();
    }
    depth++;
  }
  return;
}

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

  vector<vector<vll>> next(n, vector<vll>(0, vll(2)));
  for (ll i = 0; i < n - 1; i++) {
    ll u, v, w;
    cin >> u >> v >> w;
    next[u - 1].push_back({w, v - 1});
    next[v - 1].push_back({w, u - 1});
  }

  vll color(n);
  bfs(n, next, 0LL, color);

  for (ll i = 0; i < n; i++) cout << color[i] << endl;
}

Measured memory_bytes: 16896
#include "bits/stdc++.h"
#define hhh printf("hhh\n")
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0;char c=getchar();while(c<'0'||c>'9')c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x;}

const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-7;



int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    int N=read(), K=read();
    int ans=0;
    for(int i=1; i<=N; ++i) {
        int d=read();
        if(d>=K) ans++;
    }
    cout<<ans<<endl;
}

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

int H, M, N;

int go[4][2];

bool K[1002][1002];

int score[1002][1002];

int C[11][2];

int ans = 0;

void saiki(int sx, int sy, int s){
  if(K[sx][sy]){
    if(score[sx][sy] > s){
      score[sx][sy] = s;
      for(int i = 0; i < 4; i++){
        saiki(sx + go[i][0], sy + go[i][1], s + 1);
      }
    }
  }
}

int main(){
  
  go[0][0] = 1;
  go[0][1] = 0;
  go[1][0] = 0;
  go[1][1] = -1;
  go[2][0] = -1;
  go[2][1] = 0;
  go[3][0] = 0;
  go[3][1] = 1;
  
  for(int i = 0; i <= H + 1; i++){
    for(int j = 0; j <= M + 1; j++){
      score[i][j] = 2147483640;
      K[i][j] = false;
    }
  }
  
  scanf("%d%d%d", &H, &M, &N);
  
  for(int i = 0; i < H; i++){
    char str[M + 1];
    scanf("%s", str);
    for(int j = 0; j < M; j++){
      if(str[j] == '.'){
        K[i + 1][j + 1] = true;
      }else if(str[j] == 'X'){
        K[i + 1][j + 1] = false;
      }else if(str[j] == 'S'){
        C[0][0] = i + 1;
        C[0][1] = j + 1;
        K[i + 1][j + 1] = true;
      }else{
        C[str[j] - '0'][0] = i + 1;
        C[str[j] - '0'][1] = j + 1;
        K[i + 1][j + 1] = true;
      }
    }
  }
  
  for(int i = 0; i < N; i += 2){
    for(int j = 1; j <= H; j++){
      for(int k = 1; k <= M; k++){
        if(K[j][k]){
          score[j][k] = 2147483640;
        }else{
          score[j][k] = -2147483640;
        }
      }
    }
    saiki(C[i + 1][0], C[i + 1][1], 0);
    int aa = score[C[i][0]][C[i][1]];
    int bb;
    if(i + 2 < N){
      bb = score[C[i + 2][0]][C[i + 2][1]];
      ans += bb;
    }
    ans += aa;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 12772
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll mod=1e9+7;
 ll n,ans=0;
 cin>>n;
 vector<ll>a; ll sum[n+10]={};
 ll b;
 rep(i,0,n){
  sc(b);
  push(a,b);
 }
 sort(all(a));
 rep(i,0,n){
  if(i>0)sum[i]=a[i]+sum[i-1];
  else sum[i]=a[i];
 }
 rrp(i,n,0){
  ans++;
  if(i==0)break;
  if(sum[i-1]*2<a[i])break;
 }
 pr(ans);
return 0;}

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


auto solve() {
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int cnt = 0;;
	for (int i = 0; i < n; i++) {
		if (s[i] != t[i]) cnt++;
	}

	return cnt;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//template end



int main(){
   int k,x; scanf("%d%d",&k,&x);
   printf(500*k>=x?"Yes\n":"No\n");
   return 0;
}

Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
int main(){
	
	int a[5];
	
	while(~scanf("%d,%d,%d,%d,%d,",&a[0],&a[1],&a[2],&a[3],&a[4])){
		vector<int> p(15,0);
		bool f=false;
		rep(i,5){
			if(a[i]==1){
				p[14]++;
			}
			p[a[i]]++;
		}
		if(find(p.begin(),p.end()-1,4)!=p.end()-1){
			cout<<"four card"<<endl;
			f=true;
		}
		else if(find(p.begin(),p.end()-1,3)!=p.end()-1&&find(p.begin(),p.end()-1,2)!=p.end()-1){
			cout<<"full house"<<endl;
			f=true;
		}
		else{
			rep(i,5){
				if(a[i]>=1&&a[i]<=10){
					if(p[a[i]]==1&&p[a[i]+1]==1&&p[a[i]+2]==1&&p[a[i]+3]==1&&p[a[i]+4]==1){
						cout<<"straight"<<endl;
						f=true;
						break;
					}
				}
				
			}
		}
			if(!f){
				if(find(p.begin(),p.end()-1,3)!=p.end()-1)
					cout<<"three card"<<endl;
				else{
					int point =0;
				REP(i,14){
					if(p[i]==2)
						point++;
				}
					if(point>=2)
						cout<<"two pair"<<endl;
					else if(point==1)
						cout<<"one pair"<<endl;
					else
						cout<<"null"<<endl;
				}
			}
		
	}
	
}

Measured memory_bytes: 3148
import java.io.PrintWriter;
import java.util.*;


public class Main{

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		double r=in.nextDouble();
		out.printf("%f %f\n",r*r*Math.PI,2*r*Math.PI);
		out.flush();
	}

}



Measured memory_bytes: 28180
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,m,x;
    ll l=0,r=0;
    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
	ll a; cin>>a;
	if(x<a)r++;
	else l++;
    }
    cout<<min(l,r)<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdlib>
using namespace std;
long long gcd(long long y,long long z){
  if(y%z==0) return z;
  else return gcd(z,y%z);
}
int main(){
  long long n,x,agcd,i;cin >> n >> x;
  long long a[n+1];a[0] = x;
  for(i=1;i<=n;i++){
    cin >> a[i];
    if(i==1) agcd = abs(a[1]-a[0]);
    else agcd = gcd(agcd,abs(a[i]-a[i-1]));
  }
  cout << agcd << endl;
}
  

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	map<int,int> cnt;
	rep(i, m){
		int a, b; cin >> a >> b;
		cnt[a]++; cnt[b]++;
	}
	bool ok = 1;
	for(auto i : cnt) if(i.second % 2) ok = 0;
	cout << (ok ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 4352
n, k, q = map(int, input().split())
points = [k] * n


for _ in range(q):
    win = int(input())
    points[win-1] += 1

points = [p-q for p in points]
for i in points:
    if i >= 1:
        print('Yes')
    else:
        print('No')


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

int triangle(long int a, long int b, long int c){
  int maxlen, maxint, yn;
    if(a==b) return(0);
    if(a==c) return(0);
    if(b==c) return(0);
    if(a>b) {
      maxlen=a;
      maxint=0;
    }else{
      maxlen=b;
      maxint=1;
    }
    if(maxlen<c){
      maxlen=c;
      maxint=2;
    }
    if(maxint==0){
      if(a<(b+c)) yn=1;
      else yn=0;}
    if(maxint==1){
      if(b<(a+c)) yn=1;
      else yn=0;}
    if(maxint==2){
      if(c<(a+b)) yn=1;
      else yn=0;}
//    printf("%ld, %ld, %ld, %d\n", a, b, c, yn);
    return (yn);

}

int main(void){
  int n, i, j, k, ans, yn;
  long int L[100];

  ans=0;
  scanf("%d", &n);
  for (i=0; i<n; i++){
    scanf("%ld", &L[i]);
  }
  
  if(n<=2){
    ans=0;
    printf("%d",ans);
    return 0;
  }
  for(i=0; i<n-2; i++){
    for(j=i+1; j<n-1; j++){
      for(k=j+1; k<n; k++){
        yn=triangle(L[i],L[j],L[k]);
        ans+=yn;
      }
    }
  }



  printf("%d", ans);

  return 0;
}

Measured memory_bytes: 1736