akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
 
template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

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

    bool unite(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main() {
    int N;
    cin>>N;
        UnionFind<int> uf(N); 
 for(int i=0;i<N-1;i++)
 {
 int a,b,c;
cin>>a>>b>>c;
 a--;
   b--;
   uf.unite(a,b,c);  
   }
  cout<<1<<endl; 
  for(int i=1;i<N;i++)
   {
   if(uf.diff(0,i)%2==0) cout<<1<<endl;
   else cout<<0<<endl;
   } 
     
     
     
     
     
     
}
 

Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define gcd __gcd
using namespace std;

int main() {
  ll n,h,w;
  cin>>n>>h>>w;
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ll a,b;
    cin>>a>>b;
    ans+=min(a/h,b/w);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int NOT_FOUND=-1;
int linearSearch(int key,int A[],int n){
	int i=0;
	A[n]=key;
	while(A[i]!=key){
		i++;
	}
	if(i==n){
		return NOT_FOUND;
	}
	else{
		return i;
	}
}
int main(){

	int n,s;
	cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	cin>>s;
	int b[s];
	for(int i=0;i<s;i++){
		cin>>b[i];
	}
	
	int count=0;
	for(int i=0;i<s;i++){
		if(linearSearch(b[i],a,n)!=NOT_FOUND)count++;
	}
	cout<<count<<endl;
	
return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define For(i,l,r) for(res i=(l),_=(r);i<=_;++i)
#define Dor(i,l,r) for(res i=(r),_=(l);i>=_;--i)
#define Sor(i,l,r) for(res i=(l),_=(r);i<_;++i)
#define fz(a,b) memset(a,b,sizeof a)
#define qd(a) while(!a.empty())a.pop()
#define JB(a,b)(T[++t]=b,E[t]=H[a],H[a]=t)
#define ll long long
#define N 100001
#define M 1000000007
int t,A[N];
int main() {
	int a,w=0,v=0;
	cin>>a>>A[1];
	For(i,2,a){
		cin>>A[i];
		if(A[i]<=A[i-1])++v;
		else w=max(w,v),v=0;
	}
	cout<<max(w,v);
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

int n, h, w;
int g[105][105], colour[10005];

void draw(int r, int beg, int c, int dir) //1向右，0向左
{
	if (c <= n) {
		if (dir) {
			if (beg + colour[c] - 1 > w) {
				for (int i = beg; i <= w; ++i) {
					g[r][i] = c;
				}
				colour[c] -= (w - beg + 1);
				draw(r + 1, w, c, !dir);
			}
			else {
				int nextbeg = colour[c] + beg;
				for (int i = beg; i - beg + 1 <= colour[c]; ++i) {
					g[r][i] = c;
				}
				colour[c] = 0;
				draw(r, nextbeg, c + 1, dir);
			}
		}
		else {
			if (beg - colour[c] + 1 < 1) {
				for (int i = beg; i >= 1; --i) {
					g[r][i] = c;
				}
				colour[c] -= (beg - 1 + 1);
				draw(r + 1, 1, c, !dir);
			}
			else {
				int nextbeg = beg - colour[c];
				for (int i = beg; beg - i + 1 <= colour[c]; --i) {
					g[r][i] = c;
				}
				colour[c] = 0;
				draw(r, nextbeg, c + 1, dir);
			}
		}
	}
}

int main()
{
	cin >> h >> w >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> colour[i];
	}
	draw(1, 1, 1, 1);
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cout << g[i][j]<<" ";
		}
		cout << endl;
	}
	//	system("pause");
	return 0;
}

Measured memory_bytes: 384
n,k = map(int, input().split())
a = list(map(int, input().split()))
point = 0
for i in range(n):
    if a[i]==1:
        point=i+1
x = point-1
xa = x%(k-1)
x = (-x)//(k-1)
x = -x
y = n-point
ya = y%(k-1)
y = (-y)//(k-1)
y = -y
ans = x+y
if xa>0 and ya>0 and xa+ya<k:
    ans-=1
print(ans)

Measured memory_bytes: 13880
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 100000
ll kkai[1010];
typedef pair<ll, ll>pii;
vector<pii>dat;
int count(int lb, int ub)
{
	int r = 0;
	for (int i = 0; i < dat.size(); i++)
	{
		if (lb <= dat[i].first&&dat[i].second <= ub)r++;
		else if (lb <= dat[i].first&&dat[i].first <= ub&&ub < dat[i].second)return -1;
		else if (lb <= dat[i].second&&dat[i].second <= ub&&dat[i].first < lb)return -1;
	}
	return r;
}
ll dp[666][666];
ll zdp[666][666];
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	kkai[0] = 1;
	for (int i = 1; i < 1010; i++)kkai[i] = kkai[i - 1] * (i * 2 - 1) % mod;
	for (int i = 0; i < way; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		dat.push_back(make_pair(min(za, zb), max(za, zb)));
	}
	ll ans = 0;
	for (int i = num + num; i >= 1; i--)
	{
		for (int j = i + 1; j <= num + num; j += 2)
		{
			int c = count(i, j);
			if (c < 0)dp[i][j] = 0;
			else dp[i][j] = (kkai[(j - i + 1) / 2 - c] + mod - zdp[i][j]) % mod;
			//printf("%d %d %lld  %lld\n", i, j, dp[i][j], zdp[i][j]);
			zdp[i][j] = (zdp[i][j] + dp[i][j]) % mod;
			for (int k = j + 2; k <= num + num; k += 2)zdp[i][k] = (zdp[i][k] + zdp[i][j] * dp[j + 1][k]) % mod;
			ans += dp[i][j] * kkai[(num + num - (j - i + 1)) / 2 - (way - c)];
			ans %= mod;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N=10;
	int A[N];
	unsigned maxans = 1;
	int count = 0;
	int kisuu[N];
	unsigned subnum = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		maxans = maxans * 3;
		if (A[i] % 2 == 0) {
			kisuu[i] = 2;
		}
		else {
			kisuu[i] = 1;
		}
		subnum = subnum * kisuu[i];
	}
	cout << maxans - subnum << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;


vector<int> dp, a;


void solve()
{
	int n, k;
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	dp.assign(k + 1, 0);

	for (int i = 1; i <= k; i++)
	{
		for (int j = 0; j < n; j++)
		{
			if (i - a[j] >= 0 && dp[i - a[j]] == 0)
			{
				dp[i] = 1;
			}
		}
	}

	if (dp[k])
	{
		cout << "First";
	}
	else
	{
		cout << "Second";
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int N,M;
vector<int> g[100010];

ll dp[100010];
ll ans[100010];
vector<ll> child[100010];

ll dfs(int now,int par){
  ll res=1;
  for(int nex:g[now]){
    if(nex==par) continue;
    ll z=dfs(nex,now);
    child[now].push_back(z);
    res=res*(z+1)%M;
  }
  res=(res+M)%M;
  return dp[now]=res;
}

void solve(int now,int par,ll pans){
  if(par!=-1){
    ll res=pans+1;
    for(int i=0;i<child[now].size();i++){
      res=(res*(child[now][i]+1))%M;
    }
    ans[now]=res;
  }

  int n=child[now].size();
  vector<ll> left(n+2),right(n+2);
  left[0]=1;
  right[n+1]=1;
  for(int i=1;i<=n;i++) left[i]=(left[i-1]*(child[now][i-1]+1)%M)%M;
  for(int i=n;i>=1;i--) right[i]=(right[i+1]*(child[now][i-1]+1)%M)%M;

  int p=0;
  for(int i=0;i<g[now].size();i++){
    if(g[now][i]==par){
      p=1;
      continue;
    }
    solve(g[now][i],now,((left[i-p]*right[i+2-p])%M*(pans+1)%M)%M);
  }
}

int main(){
  cin>>N>>M;
  for(int i=1;i<N;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }

  ans[0]=dfs(0,0);
  solve(0,-1,0);
  for(int i=0;i<N;i++) cout<<(ans[i]+M)%M<<endl;

  return 0;
}


Measured memory_bytes: 24832
#include <cstdio>
#include <algorithm>
int readint() {
	char ch = getchar();
	int res = 0; bool f = false;
	if (ch == '-') {
		f = true;
		ch = getchar_unlocked();
	}
	while ('0' <= ch && ch <= '9') {
		res = res * 10 + ch - '0';
		ch = getchar_unlocked();
	}
	if (f) res = -res;
	return res;
}
int A[50176];
int main() {
	// step #1. read input
	int N = readint();
	int H = (N >> 1);
	for (int i = 0; i < H; ++i) A[i] = readint();
	if (N & 1) readint();
	for (int i = H - 1; i >= 0; --i) A[i] += readint();
	// step #2. calculate the answer
	long long ans = 0;
	for (int i = 1; i < N; ++i) {
		long long sum = 0;
		int pos = i;
		while (pos < H) {
			sum += A[pos];
			ans = std::max(ans, sum);
			pos += i;
		}
		if ((N - 1) % i != 0) {
			pos = (N - 1) - pos;
			while (pos >= i) {
				sum += A[pos];
				ans = std::max(ans, sum);
				pos -= i;
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1796
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
signed main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b)puts("delicious");
	else if (b - a <= x)puts("safe");
	else puts("dangerous");
	getchar(); getchar();
	return 0;
}

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

class Program
{
    static void Main()
    {
        var sc = new StreamScanner(OpenStandardInput());
        var N = sc.Integer();
        var A = new int[N];
        var s = 0L;
        for (int i = 0; i < A.Length; i++)
        {
            var k = sc.Integer();
            A[i] = k;
            if ((i & 1) == 0) s += k;
            else s -= k;
        }

        var ans = new long[N];
        ans[0] = s;
        for (int i = 1; i < ans.Length; i++)
        {
            ans[i] = (A[i - 1] - (ans[i - 1] >> 1)) * 2;
        }
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        WriteLine(string.Join(" ", ans));
        Out.Flush();
    }
}

public class StreamScanner
{
    public StreamScanner(System.IO.Stream stream)
    {
        str = stream;
    }

    public readonly System.IO.Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof;

    public bool IsEndOfStream
    {
        get { return isEof; }
    }

    private byte read()
    {
        if (isEof) return 0;
        if (ptr < len) return buf[ptr++];
        ptr = 0;
        if ((len = str.Read(buf, 0, 1024)) > 0) return buf[ptr++];
        isEof = true;
        return 0;
    }

    public long Long()
    {
        if (isEof) return long.MinValue;
        long ret = 0;
        byte b;
        var ng = false;
        do b = read(); while (b != 0 && b != '-' && (b < '0' || '9' < b));
        if (b == 0) return long.MinValue;
        if (b == '-')
        {
            ng = true;
            b = read();
        }
        for (; ; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            ret = ret * 10 + b - '0';
        }
    }

    public int Integer()
    {
        return (isEof) ? int.MinValue : (int)Long();
    }
}


Measured memory_bytes: 23260
#include <bits/stdc++.h>
struct __fastio__{ __fastio__() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } __fast_io__;
template<class T, class U> bool chmin (T &a, const U &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T, class U> bool chmax (T &a, const U &b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
	int x;
	std::cin >> x;
	std::cout << (x ^ 1) << '\n';
}

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

int n, k; 
ll a[200005];

bool f(double m) {
	ll s = 0;
	for(int i=0;i<n;i++) {
		ll t = (ll)(a[i] / m);
		if(t * m < a[i]) t++;
		s += max(0LL, t-1);
	}
	return s <= k;
}

int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		scanf("%lld", &a[i]);
	}
	double l = 0, r = 1e9;
	double ans = 1e9;

	while(abs(r - l) > 1e-6) {
		double m = (r+l)/2;
		if(f(m)) {
			ans = m;
			r = m;
		}
		else {
			l = m; 
		}
	}
	int a;
	for(int i=ans-1;i<=ans+1;i++) {
		if(abs(ans - double(i)) < 1e-6) {
			a = i;
			break;
		}
		else if (i < ans) continue;
		else {
			a = i;
			break;
		}
	}
	cout << a << endl;

}


Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
string s,t,b="~";
bool check(string a1,string b1)
{
	for(int i=0;i<a1.size();i++)
	{
		if(a1[i]!='?'&&a1[i]!=b1[i])
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>s>>t;
	for(int i=0;i<=(int)s.size()-(int)t.size();i++)
	{       
		string temp=s.substr(i,t.size());
		if(check(temp,t))
		{ 
			string tem=s;	
			for(int j=i;j<i+t.size();j++)
			{
				tem[j]=t[j-i];
			}
			for(int j=0;j<i;j++)
			{
				if(tem[j]=='?')
					tem[j]='a';
			}
			for(int j=i+t.size();j<tem.size();j++)
			{
				if(tem[j]=='?')
					tem[j]='a';				
			}	
			b=min(b,tem);					
		}
	}
	if(b=="~")
		cout<<"UNRESTORABLE";
	else
		cout<<b;
	return 0;		 
}

Measured memory_bytes: 256
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p){return (p.x!=x)?p.x<x:p.y<y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Polygon{
  vector<Point>v;
  
  Polygon(){}
  Polygon(int n){v.resize(n);}
  
  bool isConvex() {
    for (int i=0; i<v.size();i++){
      if (ccw(prev(v,i),curr(v,i),next(v,i))==-1)return false;
    }
    return true;
  }
};

int main(void){

  int n;
  cin >> n;
  Polygon p(n);

  for(int i=0;i<n;i++)
    cin >> p.v[i].x >> p.v[i].y;

  cout << p.isConvex() << endl;

  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int F;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> F;

    int C = (F - 30) / 2;

    cout << C << endl;
}



Measured memory_bytes: 3160
def match(c1, c2):
    return c1 == "?" or c2 == "?" or c1 == c2

M = 2000
a = input().strip()
b = input().strip()
c = input().strip()
A = len(a)
B = len(b)
C = len(c)

ab = [0] * 20000
ac = [0] * 20000
bc = [0] * 20000

for i in range(A):
    for j in range(B):
        if not match(a[i], b[j]):
            ab[i - j + 10000] = 1
for i in range(A):
    for j in range(C):
        if not match(a[i], c[j]):
            ac[i - j + 10000] = 1
for i in range(B):
    for j in range(C):
        if not match(b[i], c[j]):
            bc[i - j + 10000] = 1

ans = A + B + C
for i in range(-2 * M, 2 * M + 1):
    for j in range(-2 * M, 2 * M + 1):
        if (not ab[i + 10000]) and (not ac[j + 10000]) and (not bc[j - i + 10000]):
            l = min(0, i, j)
            r = max(A, B + i, C + j)
            ans = min(ans, r - l)

print(ans)

Measured memory_bytes: 56112
def digit_sum(n):
    ret=0
    while(n>0):
        ret+=n%10
        n=int(n/10)
    return ret

n=int(input())
ans=1000
for i in range(1,int(n/2)+1):
    tmp=digit_sum(i)+digit_sum(n-i)
    if ans>tmp:
        ans=tmp
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
 
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    char c[] = sc.next().toCharArray();
    int n = 0;
    int a;
    for(int i = 0; i < c.length; i++){
      a = c[i]-48;
      n += a;
    }
    if(n%9==0){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


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

int main() {
  int n, q;
  cin >> n >> q;
  vector<list<int>> vli(n);
  for (int i = 0; i < q; i++) {
    int a;
    cin >> a;

    if (a == 0) {
      int t, x;
      cin >> t >> x;
      vli.at(t).push_back(x);
    }

    if (a == 1) {
      int t;
      cin >> t;
      if (vli.at(t).empty()) {
        cout << endl;
      } else {
        for (auto itr = vli.at(t).begin(); itr != vli.at(t).end(); itr++) {
          if (itr == --vli.at(t).end()) {
            cout << *itr << endl;
          } else {
            cout << *itr << " ";
          }
        }
      }
    }
    
    if (a == 2) {
      int s, t;
      cin >> s >> t;
      vli.at(t).splice(vli.at(t).end(), move(vli.at(s)));
    }
  }
}



Measured memory_bytes: 18600
def main():
    s = list(str(input()))
    if s[5] == '1':
        print('TBD')
    elif s[6] != '1' and s[6] != '2' and s[6] != '3' and s[6] != '4':
        print('TBD')
    else:
        print('Heisei')

main()

Measured memory_bytes: 9008
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] x = new int[5];
        for(int i = 0; i<5; i++){
            x[i] = sc.nextInt();
        }
        for(int i = 0; i<5; i++){
            if(x[i] == 0){
                System.out.println(i+1);
            }
        }
    }
}

Measured memory_bytes: 35560
/**
 *      ABC 102 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N; cin >> N;
    int x;
    vector<int> A;
    for (int i = 0; i < N; ++i) {
        cin >> x;
        A.push_back(x);
    }
    sort(A.begin(), A.end());
	cout << A.at(N - 1) - A.at(0) << endl;
  
    return 0;    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;

  int sum = 0;
  for(int i = 1; i <= k; i++) {
    if(i <= a) sum++;
    else if(i <= a+b) continue;
    else sum--;
  }
  cout << sum << endl;
}

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

typedef long long int ll;

char input[1005][1005];
ll ans[1005][1005];
ll M=1000000007;

bool isPrime(ll n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
}

int main()
{
    ios::sync_with_stdio(false);

    ll i,j,k,l,m,n;

    ll h,w;

    cin >> h >> w;


    for(i=1;i<=h;i++)
    {
        cin >> input[i];
    }

    ans[1][1] = 1;

    for(i=1;i<=h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(input[i][j]=='#')
            {
                ans[i][j+1] = -1;
            }
        }
    }


    for(i=1;i<=h;i++)
    {
        for(j=1;j<=w;j++)
        {
            if(ans[i][j] != -1)
            {
                if(j!=w)
                {
                    if(ans[i][j+1] != -1)
                    {
                        ans[i][j+1] = ans[i][j+1]%M+ans[i][j]%M;

                        ans[i][j+1] = ans[i][j+1]%M;
                    }
                }

                if(i!=h)
                {
                    if(ans[i+1][j] != -1)
                    {
                        ans[i+1][j] = ans[i+1][j]%M+ans[i][j]%M;
                        ans[i+1][j] = ans[i+1][j]%M;
                    }
                }
            }
        }
    }

    // for(i=1;i<=h;i++)
    // {
    //     for(j=1;j<=w;j++)
    //     {
    //         cout << ans[i][j]%M << " ";
    //     }
    //     cout << '\n';
    // }

    cout << ans[h][w] << '\n';
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  for(int a = 1; a <= n; ++a){
    ans += (n - 1)/a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
d = input().split()
N = int(d[0])
M = int(d[1])
d = input().split()
As = [int(num) for num in d]
As.sort()


def main():
    lis = []
    for i in range(1, M+1):
        d = input().split()
        b = int(d[0])
        c = int(d[1])
        lis.append([c, b])
    lis = sorted(lis,key=lambda x:(-x[0], x[1]))
    count = 0
    asum = 0
    tmp = [0 for i in range(N)]
    for c, b in lis:
        if count < N:
            for i in range(count, b+count):
                if i < N:
                    tmp[i] = c
            count += b
    for i in range(N):
        if tmp[i] > As[i]:
            asum += tmp[i]
        else:
            asum += As[i]
    print(asum)
        

if __name__ == '__main__':
    main()





Measured memory_bytes: 43048
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(void) {
	int N;
	cin >> N;
	string ans;
	while (N != 0) {
		//cout << N << " " << "ans : " << ans << endl;
		if (N % 2 != 0) {
			N--;
			ans = "1" + ans;
		}
		else {
			ans = "0" + ans;
		}
		N /= -2;
	}
	if (ans == "")ans = "0";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()

int main() {
	ll n;
	cin >> n;
	ll a[n];
	ll b[n];
	rep(i, n) {
		b[i] = 0;
	}
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
		b[a[i] - 1]++;
	}
	rep(i, n) {
		ans += b[i] * (b[i] - 1) / 2;
	}
	
	rep(i, n) {
		cout << ans - b[a[i] - 1] * (b[a[i] - 1] - 1) / 2 + (b[a[i] - 1] - 2) * (b[a[i] - 1] - 1) / 2 << endl;
	}
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
    using namespace std;
     
    #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define rep(i,a,b) for(int i=a; i<b; i++)
    #define ll long long
    #define pb push_back
    #define inf 1e+18L
    #define MOD 1000000007
     
    bool isPalin(string s, int i, int j)
    {
        for(int x=i, y=j; x < y; x++, y--)
        {
            if(s[x] != s[y]) return false;
        }
        return true;
    }
     
    int main()
    {
        FastIO
        string s;
        cin >> s;
        int n = s.size();
        if(isPalin(s,0,n-1))
        {
            if(isPalin(s,0,(n-1)/2 - 1))
            {
                if(isPalin(s,(n+3)/2 - 1, n-1))
                {
                    cout << "Yes\n";
                }
                else cout << "No\n";
            }
            else cout << "No\n";
        }
        else cout << "No\n";
        return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  cout << 1110 - n << '\n';
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

W, H, x, y = MAP()

if (x == W - x) and (y == H - y):
	split = 1
else:
	split = 0
print(W*H/2, split)

Measured memory_bytes: 60608
#include<iostream>
using namespace std;
int t[100];
int m,n,L,R,M;


bool check(int x){
  int cnt=0,cnt2=0,sum=0;
  
  while(cnt<n&&cnt2<m){
    if(sum+t[cnt]>x){
      sum=0;
      cnt2++;
    }else{
      sum+=t[cnt];
      cnt++;
    }
  }
  
  if(cnt==n)return true;
  else return false;
}

int main(){
  while(cin>>m>>n){
    if(m==0&&n==0)break;
    R=0;
    for(int i=0;i<n;i++){
      cin>>t[i];
      R+=t[i];
    }

    L=0;
    M=(L+R)/2;

    while(1){
      if(check(M)==true&&check(M-1)==false){
	break;
      }else if(check(M)){
	R=M;
	M=(L+R)/2;
      }else{
	L=M+1;
	M=(L+R)/2;
      }
    }
    cout<<M<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
    int main(){
    long long int k,a,b,ans=1;
    scanf("%lld%lld%lld",&k,&a,&b);
      if(k-1>=a){
        k-=a-1;
        ans=a;
        if(b-a>2){
      if(k&1)ans++;
        ans+=(b-a)*(k>>1);
      }
      else ans+=k;
      }
      else{
      ans+=k;
      }
      printf("%lld\n",ans);
    }

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

int main(){
    int k; cin >> k;
    string s; cin >> s;

    if(s.size() <= k){
        put(s);
    }else{
        put(s.substr(0,k) + "...");
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

ll powmod(ll x, ll n, ll m = MOD) {
    ll ans = 1;
    while(n) {
        if(n & 1) {
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}
inline ll invmod(ll x, ll m = MOD) {
    return powmod(x, m - 2);
}

const int N = 111111;
int a[N];
int n, k;

ll fact[N], invfact[N];
void initfact(ll m = MOD) {
    fact[0] = 1;
    invfact[0] = 1;
    rep(i, 1, N - 1) {
        fact[i] = fact[i - 1] * i % m;
        invfact[i] = invmod(fact[i]);
    }
}
inline ll ncr(ll n, ll r, ll m = MOD) {
    if(r < 0 || r > n) return 0;
    if(r == 0 || r == n) return 1;
    return fact[n] * invfact[r] % m * invfact[n - r] % m;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    initfact();
    rep(i, 1, n) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    int ans = 0;
    rep(i, k, n) {
        ans += a[i] * ncr(i - 1, k - 1) % MOD;
        ans %= MOD;
    }
    rep(i, 1, n - k + 1) {
        ans -= a[i] * ncr(n - i, k - 1) % MOD;
        ans = (ans % MOD + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

int		main(void)
{
	int a, b, k;

	cin >> a >> b >> k;
	set<int> ans;

	for (int i = 0; i < k && i <= b - a; i++)
		ans.insert(a + i);
	for (int j = b; j > b - k && j >= a; j--)
		ans.insert(j);
	for (auto itr = ans.begin(); itr != ans.end(); itr++)
		cout << *itr << endl;
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [None] * M
for i in range(M):
    PX[i] = tuple(map(int, input().split()))

for Pi, Xi in PX:
    d = Xi - T[Pi - 1]
    print(sum(T) + d)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int A[100];
    int N,i,sw;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    sw=bubbleSort(A,N);
    for(i=0;i<N;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d",sw);
    printf("\n");
    return 0;
}

int bubbleSort(int A[],int N){
    int i=0,flag=1,sw=0;
    int j,t;
    while(flag){
        flag=0;
        for(j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
               t=A[j];
               A[j]=A[j-1];
               A[j-1]=t;
               flag=1;
               sw++;
            }
        }
        i++;
    }
    return sw;
}

Measured memory_bytes: 1792
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    while(S.length > 0) {
        let last5 = S.slice(-5).join("");
        let last6 = S.slice(-6).join("");
        let last7 = S.slice(-7).join("");
        
        if(last5 === "erase" || last5 === "dream") {
            S.splice(S.length - 5, 5);
        } else if(last6 === "eraser") {
            S.splice(S.length - 6, 6);
        } else if(last7 === "dreamer") {
            S.splice(S.length - 7, 7);
        } else {
            console.log("NO");
            return;
        }
    }
    
    console.log("YES");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 15052
import java.io.*;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;


public class Main {

	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long)(1e9+7);
	public static void main(String[] args) {
		 FastReader sc = new FastReader();
		 int n = sc.nextInt();
		 Pair[] p = new Pair[n];
		 for(int i=0;i<n;++i) p[i] = new Pair(sc.nextInt(),sc.nextInt());
		 Arrays.sort(p,new Comparator<Pair>() {

			@Override
			public int compare(Pair o1, Pair o2) {
				if(o1.b == o2.b) return o1.a-o2.a;
				else return o1.b-o2.b;
			
			}
			 
		 });
		 
		 long sum = 0;
		 boolean yes = true;
		 for(int i=0;i<n;++i) {
			 sum+=p[i].a;
			 if(sum>p[i].b) {
				 yes = false;
				 break;
			 }
		 }
		 if(yes) out.println("Yes");
		 else out.println("No");
		 
		 
		 out.close();
		 
	}
	
static class Pair{
	int a;
	int b;
	Pair(int a,int b){
		this.a = a;
		this.b = b;
	}
}

}		 





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

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

  int x = B - A + 1;
  if (x <= K) {
    for (int i = A; i <= B; i++) cout << i << endl;
  } else if ((x + 1) / 2 <= K) {
    for (int i = A; i <= B; i++) cout << i << endl;
  } else {
    for (int i = A; i < A + K; i++) cout << i << endl;
    for (int i = B - K + 1; i <= B; i++) cout << i << endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<int> p(n), q(n), r(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  rep(i, n) r[i] = i+1;

  int cnt = 0;
  int pi, qi;
  do{
    if(r == p)
      pi = cnt;
    if(r == q)
      qi = cnt;
    cnt++;
  }while(next_permutation(r.begin(), r.end()));

  cout << abs(pi-qi) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int x,y,s=0;
	cin>>x>>y;
	for(int i=1,a;i<=y;i++)cin>>a,s+=a;
	if(s>=x)puts("Yes");
	else puts("No");
}


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

typedef struct q{
  char name[100];
  int t;
}QU;

QU Q[LEN+1];
int head, tail, n;

int main(){
  int elaps = 0, c;
  int i, q;
  QU u;
  scanf("%d %d", &n, &q);
  head = 1;
  tail = n+1;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  while(head != tail) {
    u = Q[head];
    head = (head+1) % LEN;
    if(q > u.t) c = u.t;
    else c = q;
    u.t -= c;
    elaps += c;
    if(u.t > 0) {
      Q[tail] = u;
      tail = (tail+1) % LEN;
    }
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }



  return 0;
}



Measured memory_bytes: 11880
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    
    Arrays.sort(a);
    double sum=(a[0]+a[1])/2.0;
    for(int i=2;i<n;i++){
      sum=((sum+a[i])/2.0);
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

char alpha[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'};

int main() {
    char c;
    cin >> c;
    rep(i, 26) {
        if(c == alpha[i]) {
            out(alpha[i+1]);
        }
    }
    re0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = map(int, input().split())
    if a*b > 0 and c*d > 0 and a*c < 0:
        print(max(a*d, b*c))
    else:
        print(max(a*c, b*d, 0))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define DEBUG2(x, y) cerr << #x << ": " << x << " " << #y << ": " << y << "\n"
#define DEBUG3(x, y, z)                                                        \
  cerr << #x << ": " << x << " " << #y << ": " << y << " " << #z << ": " << z  \
       << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
#define pint pair< int, int >
#define ld long double
using namespace std;
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 (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567, INF2 = INF * INF;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vec< int > a(N);
  int sum = 0;
  REP(i, N) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum % (N * (N + 1) / 2) != 0) {
    print("NO");
  } else {
    int cnt = 0;
    sum /= N * (N + 1) / 2;
    REP(i, N) {
      int diff = sum + a[i] - a[(i + 1) % N];
      if (diff % N == 0 && diff >= 0) {
        cnt++;
      }
    }
    if (cnt == N)
      print("YES");
    else
      print("NO");
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int H,W,M;
    cin>>H>>W>>M;
    vector<int> h(M),w(M);
    vector<int> hcnt(H),vcnt(W);//水平/垂直方向の爆発対象の和
    rep(i,M){
        cin>>h[i]>>w[i];
        hcnt[h[i]-1]++;
        vcnt[w[i]-1]++;
    }
    int maxh=0,maxw=0;//最大値
    rep(i,H){
        maxh=max(maxh,hcnt[i]);
    }
    rep(i,W){
        maxw=max(maxw,vcnt[i]);
    }
    //基本的には最大数はhcntのmaxとvcntのmaxの和だが、それを満足させる交差点にすべて爆発対象があるときは1引いたものが答え
    vector<int> kosah(H,0);//満足させる交差点のy座標なら1を、そうでないならば0を入れる
    vector<int> kosaw(W,0);//満足させる交差点のx座標なら1を、そうでないならば0を入れる
    rep(i,H){
        if(hcnt[i]<maxh){
            continue;
        }else{
            kosah[i]=1;
        }
    }
    rep(i,W){
        if(vcnt[i]<maxw){
            continue;
        }else{
            kosaw[i]=1;
        }
    }
    int ans=maxh+maxw;

    //各障害物が満足交差点上か判断し、満足交差点上の障害物の数を数える
    int satiscnt=0;
    rep(i,M){
        //その障害物が満足交差点か否か
        // cout << h[i] << ":" << w[i] << endl;
        if(kosah[h[i]-1]==1&&kosaw[w[i]-1]==1){
            satiscnt++;
            // cout << "ok" << endl;
        }else{
            continue;
        }
    }
    int sh=0,sw=0;
    rep(i,H){
        sh=sh+kosah[i];
    }
    rep(i,W){
        sw=sw+kosaw[i];
    }
    //満足交差点上の障害物数より小さいか？
    if(satiscnt==sh*sw){
        cout << ans-1 << endl;
        
    }else{
       cout << ans  << endl;
        
    }
    // cout << satiscnt << endl;
    // rep(i,H){
    // cout << kosah[i] << endl;        
    // }
    // rep(i,W){
    // cout << kosaw[i] << endl;        
    // }
    // cout << sh << ":" << sw << endl;
    // cout << kosah[2] <<":" << kosaw[0] << endl;
    // rep(i,H){
    //     cout << hcnt[i] << endl;
    // }
    // rep(i,W){
    //     cout << vcnt[i] << endl;
    // }
    return 0;
}

Measured memory_bytes: 10304
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,n,sum=0;
    cin >> n;
    for(a=1;a<=n;a++)
    {
        for(b=1;b<=n;b++)
        {
            for(c=1;c<=n;c++)
            {
                int i=1;
                int d=1;
                    while(i<=a && i<=b && i<=c)
                    {
                        if(a%i==0 && b%i==0 && c%i ==0)
                        {
                          d=i;
                        }
                        i++;
                    }
                    sum+=d;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
/* * * * * * * * * * * **
*                      *
*	   saurabh8522	   *
*	  I will handle	   *
*		   IT.		   *
*                      *
* * * * * * * * * * * **/
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ld long double
#define zero(a) memset((a),0,sizeof((a)))
#define one(a) memset((a),1,sizeof((a)))
#define minus(a) memset((a),-1,sizeof((a)))
#define all(g) g.begin(),g.end()
#define ppb pop_back
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll extgcd(ll a,ll b,ll& x,ll& y){if(b==0){x=1;y=0;return a;}else{int g=extgcd(b,a%b,y,x);y-=a/b*x;return g;}}
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll numdigit(ll n){return floor(log10(n)) + 1;}
bool isPowerTwo (ll x) { return x && (!(x&(x-1))); } 
// ll dp[3001][3001];
// ll find(string &s,string &t,ll i,ll j){
// 	if(i<0||j<0) return 0;
// 	ll &ans=dp[i][j];
// 	if(ans!=-1) return ans;
// 	ans=0;
// 	if(s[i]==t[j]){
// 		ans=1+find(s,t,i-1,j-1);
// 	}
// 	else ans=max(ans,max(find(s,t,i,j-1),find(s,t,i-1,j)));
// 	return ans;
// }
int  main(){
	FastRead;
	ll t=1;
	// cin>>t;


	while(t--){
		string s,u;
		cin>>s>>u;
		// cout<<s<<" "<<u<<endl;
		ll n=s.size(),m=u.size();
		// cout<<n<<" "<<m<<endl;
		ll dp[n][m];

			for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				dp[i][j]=0;
			}
		}				// minus(dp);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(s[i]==u[j]){
					dp[i][j]=(i==0||j==0)?1:dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=max((i==0)?0:dp[i-1][j],(j==0)?0:dp[i][j-1]);
				}
				// cout<<i<<" "<<j<<endl;
			}
		}
		// find(s,u,n-1,m-1);
		string ans="";
		int i=n-1,j=m-1;
		// cout<<dp[n-1][m-1]<<endl;
		while(i>=0&&j>=0){
			if(s[i]==u[j]){
				ans+=s[i];
				i--;j--;
				continue;
			}
			if(i==0&&j==0){break;}
			// if(i>0){
				if(dp[i][j]==dp[i-1][j]&&i>0){
					i--;
				}
			// }
			else{
				j--;
			}
		}
		reverse(ans.begin(),ans.end());
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 70528
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	char s[3];
	cin >> s[0] >> s[1] >> s[2];

	int result = 0;
	for (size_t i = 0; i < 3; i++)
	{
		if (s[i] == '1')
		{
			result++;
		}
	}
	cout << result << endl;
	return 0;
}


Measured memory_bytes: 384
H, W = map(int, input().split())
if (H%3) * (W%3) == 0:
  print(0)
  quit()

ans = H * W
w1 = W // 2
w2 = W - w1
S1 = (H - 1) * w1; T1 = W * ((H-1)//2)
S2 = (H - 1) * w2; T2 = W * (H-1) - T1
S3 = W
h = H - 1
for i in range(H-1):
  diff1 = max(S1, S2, S3) - min(S1, S2, S3)
  diff2 = max(T1, T2, S3) - min(T1, T2, S3)
  ans = min(ans, diff1, diff2)
  S1 -= w1; S2 -= w2; S3 += W
  h -= 1
  T1 = W * (h//2)
  T2 = W*h - T1

h1 = H // 2
h2 = H - h1
S1 = (W - 1) * h1; T1 = H * ((W-1)//2)
S2 = (W - 1) * h2; T2 = H * (W-1) - T1
S3 = H
w = W - 1
for i in range(W-1):
  diff1 = max(S1, S2, S3) - min(S1, S2, S3)
  diff2 = max(T1, T2, S3) - min(T1, T2, S3)
  ans = min(ans, diff1, diff2)
  S1 -= h1; S2 -= h2; S3 += H
  w -= 1
  T1 = H * (w//2)
  T2 = H*w - T1

print(ans)

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

int main(){
	int n;
  	cin >> n;
  	vector<int> h(n);
  	rep(i, n) cin >> h[i];
  	
  	int ans = 0, tt = 0;
  	for(int i = n-1; i >= 0; i--){
    	if(h[i] <= h[i-1]) tt++;
      	else tt = 0;
      	ans = max(ans, tt);
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3776
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;

#define dbg(x1) cout<<#x1<<" = "<<(x1)<<endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<(x1)<<" "<<#x2<<" = "<<(x2)<<" "<<#x3<<" = "<<(x3)<<endl

int main() {
    //freopen(".in", "r", stdin);
    ll n, m;
    scanf("%lld%lld", &n, &m);
    ll ans = 0;
    ans += min(n, m / 2);
    n -= ans;
    m -= ans * 2;
    ans += (m / 4);
    printf("%lld\n", ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
int abs(int x){
    if(x<0) return -x;
    else return x;
}
int main() {
    string s;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        cout<<s[i];
    }
    cout<<endl;

}

Measured memory_bytes: 3612
N, K, Q = list(map(int,input().split()))
A = [int(input()) for _ in range(Q)]
num_ans = [0] * N
for a in A:
  num_ans[a-1] += 1
for i in range(N):
  if(Q-num_ans[i] < K):
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 8640
#include <stdio.h>

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

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

  int b[n];
  for(int j=0;j<n;j++){
    b[a[j]-1]=j+1;
  }
  
  for(int l=0;l<n;l++){
    printf("%d ",b[l]);
  }
  printf("\n");
  return 0;
  
}

Measured memory_bytes: 1536