akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> a >> b;
  	print1(a==b?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if( a == b && b == c) {
    cout << 1 << endl;
  }else if( a != b && b != c && a!=c){
    cout << 3 << endl;
  }else{
    cout << 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
void sor(vel &v) {
	sort(v.begin(), v.end());
}
int nibl(vel &v, int tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] <= tan) return up;
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) lo = mi;
		if (tan < v[mi]) up = mi;
	}
	return lo;
}
int rui(int a, int n, int p) {
	if (n == 0) {
		return 1;
	}
	int x = rui(a, n / 2, p);
	x *= x;
	x = x % p;
	int bai = 1;
	if (n % 2 == 1) {
		bai = a % p;
	}
	x *= bai;
	x = x % p;
	return x;
}
int inv(int a, int p) {
	a = a % p;
	return rui(a, p - 2, p);
}
int vmax(vel &v) {
	int ans = v[0];
	for (int i = 1; i < v.size(); i++) mmax(ans, v[i]);
	return ans;
}
int vmin(vel &v) {
	int ans = v[0];
	for (int i = 1; i < v.size(); i++) mmin(ans, v[i]);
	return ans;
}
int way(int st, int go, vel &x, vel&y, vel &kai, int p,vel&ink) {
	int dx = x[go] - x[st];
	int dy = y[go] - y[st];
	if (dx >= 0 and dy >= 0) {
		int ans = kai[dx + dy];
		ans *= ink[dx];
		ans = ans % p;
		ans *= ink[dy];
		ans = ans % p;
		return ans;
	}
	return 0;
}
signed main() {
	int pr = 1000;
	pr *= pr * pr;
	pr += 7;
	int dz = 200000;
	vel kai(dz + 1, 1);
	for (int i = 1; i <= dz; i++) {
		kai[i] = (kai[i - 1] * i) % pr;
	}
	vel ink((dz+2) / 2, 1);
	for (int i = 1; i <= dz / 2; i++) {
		ink[i] = inv(kai[i], pr);
	}
	int h, w, n;
	cin >> h >> w >> n;
	n += 2;
	vel x(n);
	vel y(n);
	x[0] = 0;
	y[0] = 0;
	x[n - 1] = w - 1;
	y[n - 1] = h - 1;
	for (int i = 1; i <= n - 2; i++) {
		cin >> y[i] >> x[i];
		y[i]--; x[i]--;
	}
	vvel hyo(n, vel(n, 0));//j ha i yori migisita
	vel koms(n, 0);//i yori mo migisita no kosuu
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j and x[i] <= x[j] and y[i] <= y[j]) {
				hyo[i][j] = 1;
				koms[i]++;
			}
		}
	}
	vel maxi(n);
	vel nmax(n);
	vel ze(n, 0);
	maxi[0] = n - 1;
	int ko = 1;
	int ran = n - 1;
	vel rank(n);
	while (ko != 0) {
		int nko = 0;
		nmax = ze;
		for (int i = 0; i < ko; i++) {
			int xx = maxi[i];
			rank[ran] = xx;
			ran--;
			for (int j = 0; j < n; j++) {
				if (hyo[j][xx] == 1) {
					koms[j]--;
					if (koms[j] == 0) {
						nmax[nko] = j;
						nko++;
					}
				}
			}
		}
		ko = nko;
		maxi = nmax;
	}
	int go = n - 1;
	vel dp(n - 1);
	for (int st = n - 2; st >= 0; st--) {
		dp[st] = way(rank[st], rank[go], x, y, kai, pr,ink);
		for (int mi = st + 1; mi < go; mi++) {
			dp[st] += pr - ((way(rank[st], rank[mi], x, y, kai, pr,ink)*dp[mi]) % pr);
			dp[st] = dp[st] % pr;
		}
	}
	cout << dp[0] << endl;
}

Measured memory_bytes: 73344
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  map<ll, int> sqs;
  for (ll i = 3; i <= 100000; ++i) {
    sqs[i * i] = i;
  }

  int N;
  while (scanf("%d", &N) != EOF) {
    map<vector<ll>, int> cnt;

    for (int i : range(N)) {
      ll x;
      scanf("%lld", &x);

      vector<ll> v;
      //for (int i = 2; i * i <= 100000; ++i) {
      for (int i = 2; i <= 2160; ++i) {
        if (x % i != 0) continue;
        ll r = 0;
        while (x % i == 0) {
          x /= i;
          r = (r + 1) % 3;
        }
        if (r) {
          v.push_back(i);
          v.push_back(r);
        }
      }

      if (x > 1) {
        if (sqs.find(x) != sqs.end()) {
          v.push_back(sqs[x]);
          v.push_back(2);
        } else {
          v.push_back(x);
          v.push_back(1);
        }
      }

      //for (auto y : v) cout << y << " " ;
      //cout << endl;
      cnt[v]++;
    }

    ll res = 0;
    for (auto& it : cnt) {
      vector<ll> now = it.first, cmp = now;
      if (now.size() == 0) {
        // special element
        res += 1;
        continue;
      }

      for (int i = 1; i < cmp.size(); i += 2) cmp[i] = 3 - cmp[i];
      if (cnt.find(cmp) != cnt.end() && now > cmp) continue;

      res += max(it.second, cnt[cmp]);
    }
    printf("%lld\n", res);
  }
}


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

#define INF 1LL << 60

using Weight = long long;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src_, int dst_, Weight weight_) : src(src_), dst(dst_), weight(weight_) { }
};
bool operator<(const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : e.dst < f.dst;
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void edgesToGraph(const Edges &edges, int V, Graph &g) {
	g.resize(V);
	for (auto e : edges) g[e.src].push_back(e);
}

void edgesToGraphUndir(const Edges &edges, int V, Graph &g) {
	g.resize(V);
	for (auto e : edges) {
		g[e.src].push_back(e);
		g[e.dst].push_back(Edge(e.dst, e.src, e.weight));
	}
}

void dijkstra(const Graph &g, int start,
	vector<Weight> &dist, vector<int> &prev) {
	size_t V = g.size();
	dist.assign(V, INF); dist[start] = 0;
	prev.assign(V, -1);
	priority_queue<Edge> q;
	for (q.push(Edge(-2, start, 0)); !q.empty(); ) {
		Edge e = q.top(); q.pop();
		if (prev[e.dst] != -1) continue;
		prev[e.dst] = e.src;
		for (auto a : g[e.dst]) {
			if (dist[a.dst] > e.weight + a.weight) {
				dist[a.dst] = e.weight + a.weight;
				q.push(Edge(a.src, a.dst, e.weight + a.weight));
			}
		}
	}
}

vector<int> buildPath(const vector<int> &prev, int end) {
	vector<int> path;
	for (int u = end; u >= 0; u = prev[u])
		path.push_back(u);
	reverse(path.begin(), path.end());
	return path;
}

int main() {
	int V, E, r; //頂点数
	cin >> V >> E >> r;
	Edges edges;

	for (int i = 0; i < E; ++i) {
		long long s, t, d;
		cin >> s >> t >> d;
		edges.emplace_back(s, t, d);
	}
	Graph g;
	edgesToGraph(edges, V, g);

	vector<Weight> dist;
	vector<int> prev;

	dijkstra(g, r, dist, prev);

	for (int i = 0; i < dist.size(); ++i) {
		if (dist[i] == INF) {
			cout << "INF" << endl;
		}
		else {
			cout << dist[i] << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 28472
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=b;i++){
		if(i*a%b==c){
			cout<<"YES"<<endl;
			return 0;
		}
	} 
	cout<<"NO"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
inline char nc() {
	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef long long ll;
const int maxn = 1e5 + 50;
ll m;
int n, Q;
int A[maxn], B[maxn];
bool C[maxn];
int k;
namespace us {
	int fa[maxn];
	void init() {
		for(int i = 1; i <= n; ++i) {
			fa[i] = i;
		}
	}
	int find(int a) {
		return a == fa[a] ? a : fa[a] = find(fa[a]);
	}
	bool merge(int a, int b) {
		a = find(a);
		b = find(b);
		if(a == b) return 0;
		fa[a] = b; return 1;
	}
}
bool solve() {
	if(m == n - 1) {
		for(int i = 1; i <= Q; ++i) {
			if(C[i] == 1) return 0;
		}
		return 1;
	}
	for(int i = 1; i <= Q; ++i) if(C[i] == 1) {
		if(us :: find(A[i]) == us :: find(B[i])) {
			return 0;
		}
	}
	return m <= n + (ll)k * (k - 3) / 2;
}
int main() {
	read(n), read(m), read(Q);
	k = n;
	us :: init();
	for(int i = 1; i <= Q; ++i) {
		read(A[i]), read(B[i]), read(C[i]);
		if(C[i] == 0) {
			if(us :: merge(A[i], B[i])) --k;
		}
	}
	puts(solve() ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef struct edge
{
	ll from,to;
	ll cost;
};
typedef struct points
{
	ll x,y;
	ll id;
};
bool xcmp(points a,points b)
{
	return a.x<b.x;
}
bool ycmp(points a,points b)
{
	return a.y<b.y;
}
bool cmp(edge a, edge b)
{
	return a.cost<b.cost;
}
int find(int x,int par[])
{
	while(x!=par[x])
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}
int main()
{
	int n; cin>>n;
	points v[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>v[i].x>>v[i].y;
		v[i].id=i;
	}
	
	vector<edge>e;
	sort(v+1,v+n+1,xcmp);
	for(int i=1;i<n;i++)
	{
		edge xx;
		xx.from=v[i].id;
		xx.to=v[i+1].id;
		xx.cost=v[i+1].x-v[i].x;
		e.push_back(xx);
	}
	sort(v+1,v+n+1,ycmp);
	for(int i=1;i<n;i++)
	{
		edge xx;
		xx.from=v[i].id;
		xx.to=v[i+1].id;
		xx.cost=v[i+1].y-v[i].y;
		e.push_back(xx);
	}
	sort(e.begin(),e.end(),cmp);
	int par[n+1];
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
	}
    ll ans=0;
	for(int i=0;i<e.size();i++)
	{
		int x=e[i].from;
		int y=e[i].to;
		int root1=find(x,par);
		int root2=find(y,par);
		if(root1!=root2)
		{
			ans+=e[i].cost;
			par[root2]=root1;
		}
	}
	cout<<ans<<endl;
}

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

int main(void) {
    int64_t n;
    int last;
    int cnt = 0;

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

    last = p[0];
    for(int i=1;i<n-1;i++) {
        if(((last < p[i]) && (p[i] < p[i+1])) || ((last > p[i]) && (p[i] > p[i+1]))) {
            cnt++;
        } 
        last = p[i];
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=a+b;
    int y=c+d;
    
    if(x==y)cout<<"Balanced"<<endl;
    else if(x>y)cout<<"Left"<<endl;
    else if(x<y)cout<<"Right"<<endl;
}


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

int main()
{
  int N;
  while(cin >> N){
    vector<int> v;
    int last;
    for(int i = 0; i < N; ++i){
      int t;
      cin >> t;
      if(i==N-1){
	last = t;
	break;
      }else v.push_back(t);
    }
    long long dp[N][21];
    for(int i = 0; i < N; ++i){
      for(int j = 0; j < 21; ++j){
	dp[i][j] = 0;
      }
    }
    dp[0][v[0]]=1;
    for(int i = 1; i < v.size(); ++i){
      for(int j = 0; j < 21; ++j){
	if( dp[i-1][j] > 0 ){
	  if( j + v[i] < 21 )
	    dp[i][j+v[i]] += dp[i-1][j];
	  if( j - v[i] >= 0 )
	    dp[i][j-v[i]] += dp[i-1][j];
	}
      }
    }
    long long res = 0;
    for(int i = 0; i < 21; ++i){
      res += dp[(int)v.size()-1][i];
    }
    res = dp[(int)v.size()-1][last];
    cout << res << endl;
  }
    
  return 0;
}

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

int main(int argc, char const *argv[]) {
    int x;
    for (int i = 1; ; i++) {
        cin >> x;
        if (x == 0) {
            break;
        } else {
            cout << "Case " << i << ": " << x << endl;
        }
    }
    return 0;
}



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

typedef long long LL;

const int N=200000;

int n;
LL cnt,sum;

void into(){
  scanf("%d",&n);
  for (int i=1;i<=n;++i){
	LL d,c;
	scanf("%lld%lld",&d,&c);
	cnt+=c;sum+=d*c;
  }
}

void work(){
}

void outo(){
  printf("%lld\n",cnt-1+(sum-1)/9);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,M;
    cin>>N>>M;
    vll ball(N,1); //ボールの個数を格納
    vector<bool> red(N,false); //赤いボールが入っている可能性のある箱をture
    red[0]=true;

    ll x,y;
    FOR(i,0,M){
        cin>>x>>y;x--;y--;
        if(red[x]) red[y]=true;
        if(ball[x]==1) red[x]=false;
        ball[x]--;ball[y]++;
    }

    //集計
    ll ans=0;
    FOR(i,0,N)
        if(red[i])ans++;

    cout<<ans<<endl;

    return 0;
}


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

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

Measured memory_bytes: 3052
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int price[3];
	int x, y;
	cin >> price[0] >> price[1] >> price[2] >> x >> y;
	
	int ans = 0;
	int k = min(x, y);


	if (2 * price[2] <= price[0] + price[1]) {
		ans += 2 * price[2] * k;
	}
	else {
		ans += price[0] * k;
		ans += price[1] * k;
	}

	x -= k;
	y -= k;

	if (x == 0) {
		if (2 * price[2] < price[1]) ans += 2 * price[2] * y;
		else ans += price[1] * y;
	}
	else {
		if (2 * price[2] < price[0]) ans += 2 * price[2] * x;
		else ans += price[0] * x;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 998244353
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif

const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}
ll n,a[N],ans;
int main(){
#ifdef Devil_Gary
    freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
#endif
	n=read(),ans=1000;
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(i==1) continue;
		if(a[i]>a[i-1]){
			ll tmp=ans;
			ans=tmp%a[i-1]+(tmp/a[i-1])*a[i];
		}
	
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int N_MAX = 200001;
int p = 1000000007;
int c[200001]; // 頂点iの属する集合番号
int nc[200001]; // 集合jの要素数
int pc[200001]; // 集合jの先頭の要素番号
int pi[200001]; // 頂点iと同じ集合の要素へのポインタ
int bi[200001];
long res[200001];
long rev(int i,int n){
  if(i>=n-2) return 1;
  if(res[i]>=0) return res[i];
  long re;
  re=(rev(bi[i],n)+rev(i+1,n))%p;
  res[i]=re;
  return re;
}
int main()
{
  int n;
  int i;
  cin >> n;
  fill(res,res+n,-1);
  fill(nc,nc+N_MAX,0);
  fill(pc,pc+N_MAX,-1);
  fill(pi,pi+n,-1);
  fill(bi,bi+n,-1);
  for(i=0;i<n;){
    cin >> c[i];
    if(i>=1&&c[i]==c[i-1])
      n--;
    else {
      pi[i]=pc[c[i]];
      pc[c[i]]=i;
      bi[pi[i]]=i;
      nc[c[i]]++;
      i++;
    }
  }
  long re=rev(0,n);
  cout << re << endl;
  return 0;
}

Measured memory_bytes: 15104
H, W= map(int, input().split())
A = [input() for i in range(H)]

v_list = []
reverse_list = [""]*W
h_list = []

# 1行全てが "." のとき削除する関数
def delete(h, input, output):
    for i in range(h):
        if "#" in input[i]:
            output.append(input[i])

delete(H, A, v_list)

# 転置する関数
for i in range(W):
    for j in range(len(v_list)):
        reverse_list[i] = reverse_list[i] + v_list[j][i]


delete(W, reverse_list, h_list)

result_list = [""]*(len(h_list[0]))

# 転置する関数
for i in range(len(h_list[0])):
    for j in range(len(h_list)):
        result_list[i] = result_list[i] + h_list[j][i]

for s in result_list:
    print(s)


Measured memory_bytes: 3064
S = list(input().split())
a = []

kazu = []
for i in range(1+10**6):
    kazu.append(str(i))


for i in range(len(S)):
    if S[i] in kazu:
        a.append(int(S[i]))

    elif S[i] == "+":
        x = a.pop()
        y = a.pop()
        a.append(x+y)
    
    elif S[i] == "-":
        x = a.pop()
        y = a.pop()
        a.append(y-x)

    elif S[i] == "*":
        x = a.pop()
        y = a.pop()
        a.append(x*y)
        
print(a[0])



Measured memory_bytes: 69060
N,M=[int(a) for a in input().split()]
LR=[[int(a) for a in input().split()] for _ in range(M)]
L1,R1=-10**10,10**10
for L, R in LR:
    L1 = max(L1, L)
    R1 = min(R1, R)
print(max(R1-L1+1, 0))

Measured memory_bytes: 60196
n = int(input())
r = []
for i in range(n):
    r.append(int(input()))

min_v = r[0]
max_p = -1000000000
for i in range(1,n):
    max_p = max(max_p,r[i]-min_v)
    min_v = min(min_v,r[i])
print(max_p)

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

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

int A[3][3];
int B[3][3];
int N;
vector<int> b;

int main() {
    rep(i, 3)rep(j, 3) {
        cin >> A[i][j];
    }
    cin >> N;
    b.resize(N);
    rep(i, N) cin >> b[i];

    // rep(i, 3)rep(j, 3) {
    //     cout << B[i][j];
    // }
    rep(i, 3)rep(j, 3) {
        rep(k, N) {
            if (A[i][j] == b[k]) {
                B[i][j] = 1;
            }
        }
    }

    // rep(i, 3) {
    //     rep(j, 3) {
    //         cout << B[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    string ans = "No";
    // 行
    rep(i, 3) {
        bool tmp = true;
        rep(j, 3) {
            if (B[i][j] == 0) {
                tmp = false;
                break;
            }
        }
        if (tmp) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    // 列
    rep(i, 3) {
        bool tmp = true;
        rep(j, 3) {
            if (B[j][i] == 0) {
                tmp = false;
                break;
            }
        }
        if (tmp) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    // 斜め
    if (B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1) {
        cout << "Yes" << endl;
        return 0;
    }
    if (B[0][2] == 1 && B[1][1] == 1 && B[2][0] == 1) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(dead_code)]

use std::io;
fn main() {
    solve_c();
}

fn solve_c() {
    let mut rc = String::new();
    io::stdin().read_line(&mut rc).unwrap();
    let rc: Vec<_> = rc.trim()
        .split(' ')
        .map(|s| s.parse::<usize>().unwrap())
        .collect();
    let r = rc[0];
    let c = rc[1];

    let mut mat = vec![0; c];
    for _i in 0..r {
        let mut row = String::new();
        io::stdin().read_line(&mut row).unwrap();
        let row: Vec<_> = row.trim()
            .split(' ')
            .map(|s| s.parse::<u32>().unwrap())
            .collect();

        let mut row_sum = 0;
        for (j, x) in row.into_iter().enumerate() {
            mat[j] += x;
            row_sum += x;
            print!("{} ", x);
        }
        println!("{}", row_sum);
    }
    let mut col_sum = 0;
    for x in mat {
        col_sum += x;
        print!("{} ", x);
    }
    println!("{}", col_sum);
}



Measured memory_bytes: 5040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		char x = sc.next().charAt(0);
		char y = sc.next().charAt(0);

		System.out.println(x > y ? ">" :
			x < y ? "<" : "=");
	}

}


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

int main(){
  int N,K,ans;
  cin >> N >> K;
  
  for(int i=0; i<N ; i++){
    int x;
    cin >> x;
    
    if( x >= K-x ){
      ans += 2*(K-x);}
    
    else{
      ans += 2*x;}
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    string s,abc = "ABC",arc = "ARC";
    cin >> s;

    if(s == abc){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
  

    return 0;
}



Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main(){

ll n;
cin>>n;

map<int , char>m;

for(int i=1; i<=26; i++){
	m[i] = 'a'+i-1;
}
string str = "";
while(n>0){
	int re = n%26;
	if(re==0)re=26,n-=1;
	str+=m[re];
	n/=26;
}
reverse(str.begin(), str.end());
cout<<str<<endl;
return 0;
}

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

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	int n;
	int not_clear = 0;
	int a[100];
	cin >> n;
	seiyaku_check(n,1,100);
	
	for(int i=0;i<n;i++){
		cin >> a[i];
		seiyaku_check(a[i],1,1000);
	}
	
	for(int j=0;j<n;j++){
			if(a[j]%2 == 0){
				if((a[j]%3 != 0)&&(a[j]%5 != 0)){
					not_clear += 1;
					break;
				}
			}	
	}
	
	if(not_clear == 0)cout << "APPROVED" <<endl;
	else cout << "DENIED" <<endl;
	
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	string s = to_string(n);
	int sz = s.size() - 1;

	if (s[sz] == '3') puts("bon");
	else if (s[sz] == '0' || s[sz] == '1' || s[sz] == '6' || s[sz] == '8') puts("pon");
	else puts("hon");
	return 0;
}


Measured memory_bytes: 3692
import java.util.*;
import java.io.*;

class Main{
    static int q;
    static int A[][];
    static int p[];
    static int m[][];
    public static void main(String args[]){
	int i,j,k=1,n=0,ans=0;
	A = new int[100][100];
	m = new int[100][100];
	Scanner scan = new Scanner(System.in);
	n = scan.nextInt();
	p = new int[n+1];

	for(i=0;i<n;i++){
	    for(j=0;j<2;j++){
		A[i][j] = scan.nextInt();
	    }
	    if(i==0){
		p[0] = A[0][0];
	    }
	    p[k] = A[i][1];
	    k++;
	}
	matrixChainOrder(p);
	System.out.println(m[1][n]);
    }

    static void matrixChainOrder(int p[]){
	int n,i,j,k,l;
	n = p.length-1;
	for(i=1;i<=n;i++){
	    m[i][i] = 0;
	}
	for(l=2;l<=n;l++){
	    for(i=1;i<=n-l+1;i++){
		j = i+l-1;
		m[i][j] = 2147483647;
		for(k=i;k<=j-1;k++){
		    q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
		    m[i][j] = min(m[i][j],q);
		}
	    }
	}
    }

    static int min(int x,int y){
	if(x<y){
	    return x;
	}
	else {
	    return y;
	}
    }
}



Measured memory_bytes: 26528
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string str;
  cin >> str;
  for (int bit = 0; bit < (1<<3); ++bit) {
    int res = 0;
    string ans = "";
    ans += str[0];
    res += str[0] - '0';
    rep(i,3) {
      if (bit & (1<<i)) {
        ans += '+';
        ans += str[i+1];
        res += str[i+1] - '0';
      }
      else {
        ans += '-';
        ans += str[i+1];
        res -= str[i+1] - '0';
      }
    }
    if (res == 7) {
      cout << ans << "=7" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var count = 0;

            for(int i=0; i<N-2; i++)
            {
                if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') count++;
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define strep(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
#define rs resize
int main()
{
   std::ios::sync_with_stdio(false);
   int n,i,a;
   cin>>n;
   deque<int> dq;
   rep(i,0,n)
   {
         cin>>a;
         if(n&1)
         {
            if(i%2==0)
             dq.push_front(a);
            else
             dq.pb(a);
         }
         else
         {
            if(i%2==1)
             dq.push_front(a);
            else
             dq.pb(a);
         }
   }
   while(!dq.empty())
   {
       cout<<dq.front()<<" ";
       dq.pop_front();
   }
   return 0;
}


Measured memory_bytes: 3072
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	int n;cin>>n;
	ll arr[n];
	loop(n,i,0)cin>>arr[i];
	vll gcdl(n,arr[0]),gcdr(n,arr[n-1]);
	loop(n,i,1)gcdl[i]=__gcd(gcdl[i-1],arr[i]);
	for(int i=n-2;i>=0;i--)gcdr[i]=__gcd(gcdr[i+1],arr[i]);
	ll res=max(gcdl[n-2],gcdr[1]);
	loop(n-1,i,1){
		res=max(res,__gcd(gcdl[i-1],gcdr[i+1]));
	}
	cout<<res<<endl;
}


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

int main() {
	ll n;
	vector<ll> a(5);
	cin >> n;
	rep(i, 5) cin >> a[i];
	ll x = (ll)1e15 + 5;
	rep(i, 5) x = min(x, a[i]);

	if (x >= n) {
		cout << 5 << endl;
	}
	else {
		cout << (n + x - 1) / x + 4 << endl;
	}

}

Measured memory_bytes: 256
// finish date: 2018/07/14
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi a(N);
    rep(i, N) {
        cin >> a[i];
    }
    int cnt = 0;
    FOR(i, 1, N) {
        if (a[i] == a[i - 1]) {
            a[i] = -1;
            cnt++;
        }
    }
    cout<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def main():
    n = int(std_in())
    ans = 0
    neg = 0
    for a in range(1, n + 1):
        b, c = divmod(n, a)
        ans += b
        if c == 0:
            neg += 1

    print(ans - neg)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	Scanner sc = new Scanner(System.in);
	int amt = sc.nextInt();
	if(amt%1000!=0){
	    System.out.println(1000-(amt%1000));
	}else{
	    System.out.println(0);
	}
	sc.close();
      }
}


Measured memory_bytes: 35716
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll i,j,k;
	ll ans;
	ll a,b,N;
	cin >> N;
	cout << N*(N-1)/2;
    return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <utility>
#include <functional>
#include <tuple>

template <class T>
using greater_queue = std::priority_queue<T, std::deque<T>, std::greater<T>>;

template <class Weight>
struct edge {
  size_t src, dst;
  Weight cost;

  edge(size_t src, size_t dst, Weight cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const edge<Weight> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  graph(size_t n): std::vector<std::vector<edge<Weight>>>(n) {}

  void connect_with(size_t src, size_t dst, Weight cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
    (*this)[dst].emplace_back(dst, src, cost);
  }

  void connect_to(size_t src, size_t dst, Weight cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
  }
};

template <class Tp>
constexpr Tp inf = (Tp(1) << (8*sizeof(Tp)-3));

template <class Weight>
std::vector<Weight> shortest(const graph<Weight>& g, size_t s) {
  // based-on Dijkstra algorithm
  size_t V = g.size();
  std::vector<Weight> res(V, inf<Weight>);
  res[s] = 0;
  greater_queue<std::pair<Weight, size_t>> q;
  q.emplace(0, s);
  while (!q.empty()) {
    size_t v;
    Weight w;
    std::tie(w, v) = q.top();
    q.pop();
    if (res[v] < w) continue;
    for (const auto& e: g[v])
      if (res[e.dst] > res[e.src] + e.cost) {
        res[e.dst] = res[e.src] + e.cost;
        q.emplace(res[e.dst], e.dst);
      }
  }
  
  return res;
}

int main() {
  size_t N;
  scanf("%zu", &N);

  graph<intmax_t> g(N);
  for (size_t i = 1; i < N; ++i) {
    size_t a, b;
    intmax_t c;
    scanf("%zu %zu %jd", &a, &b, &c);
    --a;
    --b;
    g.connect_with(a, b, c);
  }

  int Q;
  size_t K;
  scanf("%d %zu", &Q, &K);
  --K;

  auto dist = shortest(g, K);
  for (int i = 0; i < Q; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;
    printf("%jd\n", dist[x]+dist[y]);
  }
}


Measured memory_bytes: 11696
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<vector<int> > xy(3000, vector<int>(2));
  int cnt = 0;
  REP(i, 3000){
    int x, y;
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    xy[i][0] = x;
    xy[i][1] = y;
    cnt++;
  }
  REP(i, cnt){
    if(xy[i][0] > xy[i][1]){
      int tmp;
      tmp = xy[i][0];
      xy[i][0] = xy[i][1];
      xy[i][1] = tmp; 
    }
    cout << xy[i][0] << " " << xy[i][1] << endl;
  }
}



Measured memory_bytes: 3232
#include<stdio.h>
int main(){
  int a = 0, n; scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int b, c; scanf("%d %d", &b, &c);
    if(b == c){
      a++;
      if(a == 3) break;
    }
    else a = 0;
  }
  if(a < 3) a = 0;
  a ? printf("Yes\n") : printf("No\n");
  return 0;
}

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

long long solve(long long i,long long j){
    while(1){
        if(i<j){
            long long p=i;
            i=j;
            j=p;
        }
        i%=j;
        if(i==0)return j;
    }
}


int main(void){
    int n;
    cin>>n;
    long long ans=1;
    for(int i=0;i<n;i++){
        long long t;
        cin>>t;
        long long r=solve(ans,t);
        ans=ans/r*t;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dij geo2 kruskal graph uf lca BIT

signed main()
{
    int2(s, c);

    int ans = min(s, c/2);
    c -= ans * 2;

    if (c > 0) {
        ans += c / 4;
    }

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


    return 0;
}


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (auto &v : vec)
    cin >> v;

  int cnt = 0;
  for (int i = 1; i < n - 1; ++i) {
    int a = vec[i - 1];
    int b = vec[i];
    int c = vec[i + 1];

    bool det1 = a < b && b <= c;
    bool det2 = a == b && a < c;
    bool det3 = c < b && b <= a;
    bool det4 = c == b && c < a;
    cnt += det1 || det2 || det3 || det4;
  }
  cout << cnt << endl;
}

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

using namespace std;

template<class T>
ostream& operator<<(ostream& os, const vector<T> &vec){
    os << "[";
    for(int i=0;i<vec.size();i++){
        os << (i==0?"":" ") << vec[i];
    }
    os <<  "]";
    return os;
}


int main(){
    int n;
    cin >> n;
    map<int,int> mondai;
    for(int i=0;i<n;i++){
        int tt;
        cin >> tt;
        mondai[tt]++;
    }
    int m;
    cin >> m;

    for(int i=0;i<m;i++){
        int t;
        cin >> t;
        if(!mondai.count(t) || mondai[t] == 0)
        {
            cout << "NO" << endl;
            return 0;
        }
        else{
            mondai[t]--;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>

template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}

template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}

template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

#endif
#if __has_include(<any>)
#include <any>
#endif

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

using namespace std;

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.size() > k){
        cout << s.substr(0, k) << "...\n";
    }
    else{
        cout << s << '\n';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 3656
program tenka1_2017_c
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: n,a,b,c


    read*, n

    do a=1,3500
        do b=1,3500
            if (4*a*b-n*a-n*b <= 0) cycle
            if (mod(n*a*b, 4*a*b-n*a-n*b)==0) then
                c = (n*a*b)/(4*a*b-n*a-n*b)
                print'(*(i0,1x))', a,b,c
                stop
            end if
        end do
    end do
end program tenka1_2017_c

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<queue>
#include<string>
#include<cmath>
#include<tuple>
#define INF 1111111
using namespace std;
typedef pair<int,int> P;
typedef tuple<int,int,int> tup;
typedef long long ll;

int main() {
  int n,i;
  cin >> n >> i;
  
  cout << n-i+1 << endl;
  
}

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

std::unordered_map<int, int> memo;

int fibonacci(int n) {
    if (memo.find(n) != memo.end()) {
        return memo[n];
    } else if (n == 0 || n == 1) {
        return 1;
    } else {
        int fib = fibonacci(n - 1) + fibonacci(n - 2);
        memo[n] = fib;
        return fib;
    }
}

int main() {
    int n;
    std::cin >> n;

    std::cout << fibonacci(n) << std::endl;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,m,mh,mw,ans;
    mw=0;
    mh=0;
    ans=0;
    cin>>h>>w>>m;
    int arrh[h]={};
    int arr[w]={};
    map<tuple<int,int>,bool> ma;
    vector<int> vech={};
    vector<int> vecw={};
    fr(i,m){
        int hh,ww;
        cin>>hh>>ww;
        ++arrh[hh-1];
        ++arr[ww-1];
        ma.insert(make_pair(make_tuple(hh-1,ww-1),1));
    }
    fr(i,h){
        if(arrh[mh]<arrh[i]) mh=i;
    }
    fr(i,h){
        if(arrh[mh]==arrh[i]) vech.push_back(i);
    }
    fr(i,w){
        if(arr[mw]<arr[i]) mw=i;
    }
    fr(i,w){
        if(arr[mw]==arr[i]) vecw.push_back(i);
    }
    if(vech.size()*vecw.size()>300000){
        cout<<arrh[mh]+arr[mw];
        exit(0);
    }
    fr(i,vech.size()){
        fr(l,vecw.size()){
            if(ma[make_tuple(vech[i],vecw[l])]==0) ans=1;
        }
    }
    cout<<arrh[mh]+arr[mw]-1+ans;
}


Measured memory_bytes: 28500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int K;
	string S;
	cin >> K >> S;
	if (S.length() <= K) {
		cout << S << endl;
	} else {
		cout << S.substr(0, K) << "..." << endl;
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
    int D;
    cin >> D;
    vector<ll> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) cin >> s.at(i).at(j);
    }
    vector<int> t(D, 1);
    //for (int i = 0; i < D; i++) cin >> t.at(i);
    vector<int> dp(26, 0);
    ll ans = 0;
    int ans_c = 0;

    for (int i = 0; i < D; i++) {
        ll ans_pre = ans;
        for (int j = 0; j < 26; j++) {
            ll satisfy = s.at(i).at(j);
            ll tmp = ans_pre;
            tmp += satisfy;
            for (int k = 0; k < 26; k++) {
                if (k == j) continue;
                else tmp -= c.at(k) * (ll)(i + 1 - dp.at(k));
            }
            //if (i == 4 && j == 12) cout << "13: " << tmp << endl;
            if (tmp > ans) {
                ans = tmp;
                ans_c = j;
            }
        }
        //cout << ans << endl;
        dp.at(ans_c) = i + 1;
        //cout << "ans_c: " << ans_c << ", dp.at(ans_c): " << dp.at(ans_c) << endl;
        t.at(i) = ans_c + 1;
    }

    for (int i = 0; i < D; i++) {
        cout << t.at(i) << endl;
        //if (i < D - 1) cout << " ";
    }
    
    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n, k;
    cin >> n >> k;
    vector<lint> x(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
    }
    lint ret = inf;
    for (int i = 0; i <= n - k; ++i) {
        lint c;
        if (x[i + k - 1] <= 0) {
            c = -x[i];
        } else if (x[i] >= 0) {
            c = x[i + k - 1];
        } else {
            c = (x[i + k - 1] - x[i]) + min(-x[i], x[i + k - 1]);
        }
        ret = min(ret, c);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
B = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))
C = np.array(sorted([int(x) for x in str(input()).split(' ')], reverse=True))

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

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

int main(){
    int D, G;
    cin >> D >> G;
    pair<int,int> a[D];
    for(int i = 0; i < D; ++ i){
        cin >> a[i].first >> a[i].second;
    }

    int ans = 1e9;
    for(int bit = 0; bit < (1 << D); ++ bit){

        int score = 0, cnt = 0;
        for(int i = 0; i < D; ++ i){
            if(bit & (1 << i)){
                score += a[i].first * (i + 1) * 100 + a[i].second;
                cnt += a[i].first;
            }
        }

        if(score < G){
            for(int i = D - 1; i >= 0; -- i){
                bool f = false;
                if(!(bit & (1 << i))){
                    f = true;
                    for(int j = 1; j < a[i].first; ++ j){
                        score += (i + 1) * 100;
                        cnt++;
                        if(score >= G){
                            break;
                        }
                    }
                }
                if(f) break;
            }
        }

        if(score < G) continue;

        ans = min(ans, cnt);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256