akhauriyash/Code-Regression huggingface dataset:
//2019.5.20 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
inline int read() {
    res s=0,ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline LL Read() {
    RG LL s=0;
    res ch=getchar();
    while(ch<'0'||ch>'9')ch=getchar();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return s;
}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace MAIN {
    int n,k;
    int a[(1<<18)+10];
    inline void MAIN(){
        n=read(),k=read();
        if(k>=(1<<n)){puts("-1");return;}
        if(n==1){
            if(k==0)puts("0 0 1 1");
            else puts("-1");
            return;
        }
        a[0]=a[(1<<n)]=k;
        for(res i=0,j=1;i<(1<<n);i++){
            if(i==k)continue;
            a[(1<<n)-j]=a[(1<<n)+j]=i,j++;
        }
        for(res i=0;i<(1<<(n+1));i++)printf("%d ",a[i]);
    }
}
int main() {
//    srand((unsigned)time(NULL));
//    freopen("graph.in","r",stdin);
//    freopen("graph.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

int sum(int n){
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}
int main(){
  int N;
  cin >> N;
  int sum_A, sum_B;
  sum_B = 10000000;
  for(int i = 1; i <= N - 1;i++){
    sum_A = sum(i) + sum(N - i);
    if(sum_B >= sum_A){
      sum_B = sum_A;
    }
  }
  cout << sum_B << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

class RollingHash {
  using ulint = unsigned long long;
  const ulint mod = (1ULL << 61) - 1, mod7 = mod * 7, m30 = (1ULL << 30) - 1, m31 = (1ULL << 31) - 1;
  const unsigned base;
  vector<ulint>  hash, lookup;
  ulint mul(ulint a, ulint b) const {
    ulint au = a >> 31, ad = a & m31, bu = b >> 31, bd = b & m31;
    ulint m = ad * bu + au * bd, mu = m >> 30, md = m & m30;
    return au * bu * 2 + mu + (md << 31) + ad * bd;
  }
  ulint modulo(ulint x) const {
    if ((x = (x & mod) + (x >> 61)) > mod) x -= mod;
    return x;
  }

  public:
  RollingHash(void) : base(10007) {}
  RollingHash(const string &s, const unsigned base = 10007) : base(base) { init(s); }
  void init(const string &s) {
    const int len = s.length();
    hash.assign(len + 1, 0);
    lookup.assign(len + 1, 0);
    lookup[0] = 1;
    for (int i = 0; i < len; ++i) {
      hash[i + 1]   = modulo(mul(hash[i], base) + s[i]);
      lookup[i + 1] = modulo(mul(lookup[i], base));
    }
  }
  ulint get(const int l, const int r) const {
    return modulo(hash[r] + mod7 - mul(hash[l], lookup[r - l]));
  }
  bool same(const int a_begin, const int a_end, const int b_begin, const int b_end) const {
    if (a_end - a_begin != b_end - b_begin) return false;
    return get(a_begin, a_end) == get(b_begin, b_end);
  }
  bool same(const int a_begin, const int a_end, const int b_begin, const int b_end, const RollingHash &b_rh) const {
    if (a_end - a_begin != b_end - b_begin) return false;
    assert(base == b_rh.base);
    return get(a_begin, a_end) == b_rh.get(b_begin, b_end);
  }
};

int main(void) {
  string t, p;
  cin >> t >> p;
  RollingHash trh(t), prh(p);
  if (t.length() < p.length()) return 0;
  int maxl = t.length() - p.length() + 1;
  rep (i, maxl) {
    if (trh.same(i, i + p.length(), 0, p.length(), prh)) {
      cout << i << "\n";
    }
  }
  return 0;
}


Measured memory_bytes: 19744
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
  Q[tail]= x;
  tail = (tail + 1)%LEN;
}

P dequeue(){
  P x= Q[head];
  head = (head + 1)%LEN;
  return x;
}

int min(int a,int b){
  return a<b ? a:b;
}

int main(){
  int elaps = 0,c;
  int i,q;
  P u;
  scanf("%d %d",&n,&q);

  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head =1; tail = n+1;
  //  printf("\n");
  
  while(head != tail){
    u= dequeue();
    c= min(q,u.t);
    u.t -= c;
    elaps += c;

    if(u.t>0)
      enqueue(u);
    else
      printf("%s %d\n",u.name,elaps);
    
  }

  
  return 0;
}



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

int main(){
    int n,k;  cin >> n >> k;
    vector<int> a(n); 
    rep(i,n) cin >> a[i];
    vector<int> num(n+1,0);
    for(int i = 0; i < n; i++) num[a[i]]++;
    sort(num.begin(),num.end(),greater<int>());
    int change = 0;
    for(int i = k; i <= n; i++){
        change += num[i];
    }
    cout << change << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
const int maxn=110;
const int maxe=50010;
struct Edge
{
	int u,v;
	double w;
}edge[maxe];
int nv,ne;
void add(int u,int v,double w)
{
	edge[ne].u=u;
	edge[ne].v=v;
	edge[ne++].w=w;
}
const double inf=1e12;
double In[maxn];
int pre[maxn],ID[maxn],vis[maxn];
double Directed_MST(int root)
{
	double ret=0;
	int i,u,v,cnt;
	while(1)
	{
		for(i=0;i<=nv;++i)In[i]=inf;
		for(i=0;i<ne;++i)
		{
			u=edge[i].u;
			v=edge[i].v;
			if(edge[i].w<In[v]&&u!=v)
			{
				In[v]=edge[i].w;
				pre[v]=u;
			}
		}
		//cout <<"root:"<<root<<" ";for(i=0;i<=nv;++i)cout <<In[i]<<" ";cout <<endl;
		for(i=0;i<=nv;++i)
			if(i!=root&&In[i]==inf)return -1;
		cnt=0;
		memset(ID,-1,sizeof(ID));
		memset(vis,-1,sizeof(vis));
		In[root]=0;
		for(i=0;i<=nv;++i)
		{
			ret+=In[i];
			for(v=i;vis[v]!=i&&ID[v]==-1&&v!=root;v=pre[v])
				vis[v]=i;
			if(v!=root&&ID[v]==-1)
			{
				for(u=pre[v];u!=v;u=pre[u])
					ID[u]=cnt;
				ID[v]=cnt++;
			}
		}
		if(cnt==0)break;
		for(i=0;i<=nv;++i)
			if(ID[i]==-1)ID[i]=cnt++;
		for(i=0;i<ne;++i)
		{
			v=edge[i].v;
			edge[i].u=ID[edge[i].u];
			edge[i].v=ID[edge[i].v];
			if(edge[i].u!=edge[i].v)
				edge[i].w-=In[v];
		}
		nv=cnt-1;
		root=ID[root];
	}
	return ret;
}
int n,m;
#define sqr(v) ((v)*(v))
struct Point
{
	double v[101];
	double length()
	{
		double res=0;
		for(int i=0;i<m;++i)
			res+=sqr(v[i]);
		return res;
	}
	Point operator -(const Point &p)
	{
		Point res;
		for(int i=0;i<m;++i)
			res.v[i]=v[i]-p.v[i];
		return res;
	}
}pt[101];
double len(int a,int b)
{
	double lena=sqrt(pt[a].length()),lenb=sqrt(pt[b].length()),res=0;
	for(int i=0;i<m;++i)
		res+=pt[a].v[i]*pt[b].v[i];
	double cosv=res/lena/lenb;
	return sqr(lenb*sin(acos(cosv)));
}
int main()
{
	int i,j;
	scanf("%d%d",&m,&n);
	for(i=1;i<=n;++i)
	{
		for(j=0;j<m;++j)
		{
			scanf("%lf",&pt[i].v[j]);
		}
		add(0,i,pt[i].length());
	}
	for(i=1;i<=n;++i)
		for(j=1;j<=n;++j)
		{
			if(i==j)continue;
			add(i,j,len(i,j));
		}
	nv=n;
	printf("%.9f\n",Directed_MST(0));
	return 0;
}

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

using namespace std;
const long long MOD=1000000007;
vector<vector<int>> G;
vector<string> node;

long long dfs(int pos){
    long long ret=1;
    if(node[pos][0]=='E'){
        for(auto i:G[pos]){
            ret=ret*dfs(i);
            ret=ret%MOD;
        }
        if(node[pos].size()==2)++ret;
        //cout<<pos<<" "<<ret<<endl;
        return ret%MOD;
    }
    else if(node[pos][0]=='A'){
        --ret;
        for(auto i:G[pos]){
            ret=ret+dfs(i);
            ret=ret%MOD;
        }
        if(node[pos].size()==2)++ret;
        return ret%MOD;
    }
    else{
        for(auto i:G[pos]){
            ret=ret*(dfs(i)+1);
            ret=ret%MOD;
        }
        --ret;
        if(node[pos].size()==2)++ret;
        return ret%MOD;
    }
}

int main(){
    int n;
    cin>>n;
    node.resize(n);
    for (int i = 0; i < n; ++i) {
        cin>>node[i];
    }
    G.resize(n);
    vector<bool> isroot(n,true);
    for (int i = 0; i < n-1; ++i) {
        int s,t;
        cin>>s>>t;
        --s;--t;
        G[s].emplace_back(t);
        isroot[t]=false;
    }
    int root;
    for (int i = 0; i < n; ++i) {
        if(isroot[i]){
            root=i;
            break;
        }
    }
    cout<<dfs(root)<<endl;
    return 0;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    int ans;
    ans=n;
    bool flag=false;
    if(ans>999){
        flag=true;
    }

    
    cout<< (flag?"ABD":"ABC") <<endl;

    return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;
	
	public class Main {
	
		public static void main(String[] args) {
		
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int p[] = new int[n];
			
			
			int sum = 0;
			
			for(int i=0;i<n;i++) {
				p[i] = sc.nextInt();
			}
			
			int min = p[0];
			
			for(int i=0;i<n;i++) {
				if(min>=p[i]) {
					min = p[i];
					sum++;
				}
			}
			
			System.out.println(sum);
			
		}
				
	}

Measured memory_bytes: 85408
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        HashMap<Integer, Integer> frontMod = new HashMap<>();
        HashMap<Integer, Integer> reerMod = new HashMap<>();
        ArrayList<Integer> ans = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            int x = arr[i];
            int y = arr[n - i - 1];
            if (x != y) {
                if (reerMod.containsKey(x)) {
                    int z = reerMod.get(x);
                    if (z == 1) {
                        reerMod.remove(x);
                    } else {
                        reerMod.put(x, z - 1);
                    }
                } else if (frontMod.containsKey(x)) {
                    frontMod.put(x, frontMod.get(x) + 1);
                } else {
                    frontMod.put(x, 1);
                }
                if (frontMod.containsKey(y)) {
                    int z = frontMod.get(y);
                    if (z == 1) {
                        frontMod.remove(y);
                    } else {
                        frontMod.put(y, z - 1);
                    }
                } else if (reerMod.containsKey(y)) {
                    reerMod.put(y, reerMod.get(y) + 1);
                } else {
                    reerMod.put(y, 1);
                }
            }
            if (frontMod.size() == 0 && reerMod.size() == 0) {
                ans.add(i + 1);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < ans.size(); i++) {
            if (i != 0) {
                sb.append(" ");
            }
            sb.append(ans.get(i));
        }
        System.out.println(sb);
    }
}



Measured memory_bytes: 72676
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sumS[2][100010];
int sumT[2][100010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    rep(i, S.length()) sumS[S[i] != 'A'][i + 1]++;
    rep(i, T.length()) sumT[T[i] != 'A'][i + 1]++;
    rep(i, max(S.length(), T.length())) {
        rep(j, 2) {
            sumS[j][i + 1] += sumS[j][i];
            sumT[j][i + 1] += sumT[j][i];
        }
    }
    int Q; cin >> Q;
    rep(i, Q) {
        int a, b, c, d; cin >> a >> b >> c >> d;
        int Sa = sumS[0][b] - sumS[0][a - 1];
        int Sb = sumS[1][b] - sumS[1][a - 1];
        int Ta = sumT[0][d] - sumT[0][c - 1];
        int Tb = sumT[1][d] - sumT[1][c - 1];
        //cout << "*" << Sa << " " << Sb << " " << Ta << " " << Tb << "->" << ((Sa + Sb * 2) % 3 == (Ta + Tb * 2) % 3) << endl;
        if ((Sa + Sb * 2) % 3 == (Ta + Tb * 2) % 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2512
N = int(input())
T_list = [int(i) for i in input().split()]
M = int(input())
M_list = [[int(i) for i in input().split()] for i in range(M)]

base_value = sum(T_list)

for i in range(M):
    print(base_value - (T_list[M_list[i][0]-1] - M_list[i][1]))

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

int main(){
	int h,w; cin>>h>>w;
	h*=2;
	vector<vector<char>> v(h,vector<char>(w));
	for(int i=0; i<h; i+=2){
		rep(j,w){
			cin>>v[i][j];
		}
		rep(j,w){
			v[i+1][j]=v[i][j];
		}
	}
	rep(i,h){
		rep(j,w){
			cout<<v[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long ;
int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    cout<<a[n/2]-a[n/2-1];
}

Measured memory_bytes: 3788
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range((n-3)//2+1):
    for j in range(n-3-i*2+1):
        j1 = j+i+1
        j2 = j+i*2+2
        if s[j] != s[j1] and s[j1] != s[j2] and s[j2] != s[j]:
            ans -= 1
print(ans)

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 200200;

struct edge
{
	int x, y;

	int depth;
	int any;

	edge()
	{
		x = y = -1;
		depth = 0;
		any = 0;
	}
};

vector<edge> E;
VI g[MAX];
VI I[MAX];
VI L[MAX];
VI R[MAX];
VI L2[MAX];
VI R2[MAX];
int D[MAX];
int U[MAX];
int ANY[MAX];
char S[MAX];

int dfs1(int x, int p)
{
	int res = 0;
	ANY[x] = S[x] - '0';
	FOR (i, 0, SZ(g[x]))
	{
		int e = g[x][i];
		int to = E[e].y;
		if (to == p) continue;

		E[e].depth = dfs1(to, x);
		res = max(res, E[e].depth);

		if (ANY[to])
		{
			ANY[x] = 1;
			E[e].any = true;
		}
	}
	return res + 1;
}

void dfs2(int x, int p, int ind)
{
	if (ind != -1)
	{
		int r = I[x][ind];

		int mx = 0;
		int mx2 = 0;
		if (r)
		{
			mx = max(mx, L[p][r - 1]);
			mx2 = max(mx2, L2[p][r - 1]);
		}
		if (r < SZ(g[p]) - 1)
		{
			mx = max(mx, R[p][r + 1]);
			mx2 = max(mx2, R2[p][r + 1]);
		}

		mx++;

		int e = g[x][ind];
		mx2 = max(mx2, S[E[e].y] - '0');

		E[e].depth = mx;
		E[e].any = mx2;
	}

	L[x].resize(SZ(g[x]));
	R[x].resize(SZ(g[x]));

	L2[x].resize(SZ(g[x]));
	R2[x].resize(SZ(g[x]));

	int mx = 0;
	int mx2 = 0;

	U[x] = INF;

	FOR (i, 0, SZ(g[x]))
	{
		int e = g[x][i];
		int val = E[e].depth;

		L[x][i] = R[x][i] = val;
		L2[x][i] = R2[x][i] = E[e].any;

		if (E[e].any)
		{
			U[x] = min(U[x], E[e].depth);
		}

		if (val > mx)
		{
			mx2 = mx;
			mx = val;
		}
		else
		{
			if (val > mx2)
			{
				mx2 = val;
			}
		}
	}

	D[x] = min(mx - 1, mx2 + 1);

	FOR (i, 1, SZ(g[x]))
	{
		L[x][i] = max(L[x][i], L[x][i-1]);
		L2[x][i] = max(L2[x][i], L2[x][i-1]);
	}

	RFOR(i, SZ(g[x]) - 1, 0)
	{
		R[x][i] = max(R[x][i], R[x][i+1]);
		R2[x][i] = max(R2[x][i], R2[x][i+1]);
	}



	FOR (i,0 , SZ(g[x]))
	{
		int e = g[x][i];
		int to = E[e].y;

		if (to == p) continue;
		dfs2(to, x, I[x][i]);
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n-1)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		y--;

		I[x].PB(SZ(g[y]));
		I[y].PB(SZ(g[x]));

		edge e;
		e.x = x; e.y = y;
		g[x].PB(SZ(E));
		E.PB(e);

		e.x = y; e.y = x;
		g[y].PB(SZ(E));
		E.PB(e);
	}

	scanf("%s", S);

	dfs1(0, -1);
	dfs2(0, -1, -1);

	LL res = 0;
	FOR (i, 0, n)
	{
		if (S[i] == '1') res += D[i] + 1;
		else
		{
			if (U[i] <= D[i])
			{
				res += D[i] - U[i] + 1;
			}
		}
	}
	res++;
	cout<<res<<endl;

	/*FOR (i, 0, n)
	{
		cout<<i<<' '<<D[i]<<' '<<U[i]<<endl;
	}
	cout<<endl;

	FOR (i, 0, SZ(E))
	{
		cout<<E[i].x<<' '<<E[i].y<<' '<<E[i].depth<<' '<<E[i].any<<endl;
	}*/



}


Measured memory_bytes: 92520
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
typedef pair<long long int,long long int> P;
struct edge{
    int to;
    int en;
  int snuke;
    edge(int t, int w,int s) : to(t), en(w),snuke(s) { }
};
int main(){
  long long int j,i,n,m,s,t,u,v1,a,b;
  long long int ds[100010],ns[100010],ans[100010];
  const long long int INF=10000000000000000;
  long long int min;
  priority_queue<P,vector<P>,greater<P> > que;
  scanf("%lld %lld %lld %lld\n",&n,&m,&s,&t);
  vector<vector<edge> > g(n+10);
  for(i=1;i<=n;i++){
    ans[i]=0;
  }
  for(i=0;i<m;i++){
    scanf("%lld %lld %lld %lld\n",&u,&v1,&a,&b);
    g[u].push_back(edge(v1,a,b));
    g[v1].push_back(edge(u,a,b));
  }
    for(j=1;j<=n;j++){
      ds[j]=INF,ns[j]=0;
    }
    while(!que.empty()){
      que.pop();
    }
    ds[s]=0,ns[s]=1;
    que.push(P(0,s));
    while(!que.empty()){
      P p=que.top();
      que.pop();
      int v=p.second;
      if(ds[v]<p.first){
        continue;
      }
      for(j=0;j<g[v].size();j++){
        edge us=g[v][j];
        if(ds[us.to]>ds[v]+us.en && ns[us.to]==0){
          ds[us.to]=ds[v]+us.en;
          que.push(P(ds[us.to],us.to));
        }
      }
    }
  for(i=1;i<=n;i++){
    ans[i]+=ds[i];
  }
    for(j=1;j<=n;j++){
      ds[j]=INF,ns[j]=0;
    }
    while(!que.empty()){
      que.pop();
    }
    ds[t]=0,ns[t]=1;
    que.push(P(0,t));
    while(!que.empty()){
      P p=que.top();
      que.pop();
      int v=p.second;
      if(ds[v]<p.first){
        continue;
      }
      for(j=0;j<g[v].size();j++){
        edge us=g[v][j];
        if(ds[us.to]>ds[v]+us.snuke && ns[us.to]==0){
          ds[us.to]=ds[v]+us.snuke;
          que.push(P(ds[us.to],us.to));
        }
      }
    }
  for(i=1;i<=n;i++){
    ans[i]+=ds[i];
  }
  min=ans[n];
  for(i=n-1;i>0;i--){
    if(ans[i]<min){
      min=ans[i];
    }
    else{
      ans[i]=min;
    }
  }
  for(i=1;i<=n;i++){
    printf("%lld\n",1000000000000000-ans[i]);
  }
  return 0;
}

Measured memory_bytes: 11252
#include <bits/stdc++.h>
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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
ll gcd(ll x, ll y) {
    if (x % y == 0LL) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int main() {
  int N;
  cin>>N;
  vector<ll> v(N);
  for(int i = 0; i < N; i++) cin>>v[i];
  vector<ll> beg(N),en(N);
  beg[0]=v[0];
  en[0]=v[N-1];
  for(int i = 1; i < N; i++){
    beg[i]=gcd(beg[i-1],v[i]);
    en[i]=gcd(en[i-1],v[N-1-i]);
  }
  ll ans = 1LL;
  for(int i = 1; i < N-1; i++){
    chmax(ans,gcd(beg[i-1],en[N-2-i]));
  }
  chmax(ans,beg[N-2]);
  chmax(ans,en[N-2]);
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 200;
int N;
string S[MAX_N];

                            
struct edge { int to, cost; };
const int MAX_V = MAX_N, INF = 1e9;

// Vの初期化を忘れない。
int V;
vector<edge> G[MAX_V];
int d[MAX_V];

void add_edge(int v, int u, int cost) {
  G[v].push_back((edge){u, cost});
  G[u].push_back((edge){v, cost});
}

void dijkstra(int s) {
  fill(d, d+V, INF);
  priority_queue<Pii, vector<Pii>, greater<Pii> > pque;
  d[s] = 0;
  pque.push(Pii(0, s));


  while (!pque.empty()) {
    Pii p = pque.top(); pque.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        pque.push(Pii(d[v]+ e.cost, e.to));
      }
    }
  }
}

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

  cin >> N;
  rep(i, N) {
      cin >> S[i];
  }
  V = N;

  rep(i, N) {
    rep(j, N) {
      if (S[i][j] == '1') add_edge(i, j, 1);
    }
  }

  int ans = -1;
  for (int s = 0; s < N; ++s) {
    dijkstra(s);
    vector<Pii> vpii;
    for (int i = 0; i < N; ++i) {
      vpii.push_back(Pii(d[i], i));
    }
    sort(all(vpii));
    vector<vector<int>> vvi(vpii[N-1].fi + 1);
    for (int i = 0; i < N; ++i) {
      vvi[vpii[i].fi].push_back(vpii[i].sc);
    }
    bool ok = true;
    for (int i = 0; i < len(vvi); ++i) {
      vector<int>& sameDistList = vvi[i];
      for (int j = 0; j < len(sameDistList); ++j) {
        for (int k = 0; k < len(sameDistList); ++k) {
          if (S[sameDistList[j]][sameDistList[k]] == '1') {
            ok = false;
            break;
          }
        }
        if (!ok) break;
      }
      if (!ok) break;
    }
    if (ok) {
      ans = max(ans, len(vvi));
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int N; scanf("%d", &N);
  vector<int> v;
  for (int i = 0; i < N; i++) {
    int z;
    scanf("%d", &z);
    z--;
    v.push_back(z);
  }
  int now = 0, c = 0;
  for (;;) {
    if (now == 1) {
      printf("%d\n", c);
      break;
    }
    if (c >= N) {
      printf("-1\n");
      break;
    }
    c++;
    now = v[now];
  }
  return 0;
}

Measured memory_bytes: 3404
#include <bits/stdc++.h>
#define N 111

using namespace std;

int n, arr[N];

int main() {
	int ans = 1000000000;
	int s1 = 0, s2 = 0;
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> arr[i], s2 += arr[i];
	for(int i=0; i<n; i++) {
		s1 += arr[i];
		s2 -= arr[i];
		ans = min(ans, abs(s1 - s2));
	}
	cout << ans << endl;
	return 0;
}   


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 a, b, c;
    cin >> a >> b >> c;
    cout << max(max(10 * a + b + c, a + 10 * b + c), a + b + 10 * c) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;

int t[10][10];
int m[10];

int dfs(int i, int* memo) {
    if (memo[i] == -2) return -1;
//    if (memo[i] > -1) return memo[i];
    if (i == 1) return 0;
    int mn = INT_MAX;
    memo[i] = -2;
    for (int j = 0; j < 10; j++) {
        int cur = dfs(j, memo);
        if (cur != -1) {
            mn = min(mn, cur + t[i][j]);
        }
    }
    memo[i] = -1;
//    memo[i] = mn;
    return mn;
}

void gen() {exit(0);}
int main() {
    #ifdef DEBUG
    freopen("input", "r", stdin);
//    freopen("output", "w", stdout);
//    gen();
    #endif
    int h, w;
    scanf("%d %d", &h, &w);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf(" %d", &t[i][j]);
        }
    }
    for (int i = 0; i < 10; i++) {
        int memo[10];
        fill(memo, memo + 10, -1);
        m[i] = dfs(i, memo);
    }
    int ans = 0;
    forn(i, 0, h) {
        forn(j, 0, w) {
            int x;
            scanf(" %d", &x);
            if (x != -1) {
                ans += m[x];
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

struct node{
    int par;
	vector<int> child;
	ll w = 0;
};

// void dfs(vector<vector<int>> tree, int p, int x){
// 	if(p == -1) return;
// 	score[p] += x;
// 	for(int t : tree[p]){
// 		dfs(tree, t, x);
// 	}
// }

int main(){
	int N, Q;
	cin >> N >> Q;
	node T[N+1];
	int a,b;
	for(int i(1);i<N;++i){
		cin >> a >> b;
		T[a].child.push_back(b);
		T[b].par = a;
	}
	int p,x;
	for(int i(0);i<Q;++i){
		cin >> p >> x;
		T[p].w += x;
	}
	for(int i(1);i<=N;++i){
		for(int j(0);j<T[i].child.size();++j){
			T[T[i].child[j]].w += T[i].w;
		}
	}
	for(int i(1);i<=N;++i){
		cout << T[i].w << endl;
	}
	return 0;
}

Measured memory_bytes: 16512
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_6_&Alang=jp>
 */

func init() {
}

func main() {
	for {
		var m, n, r int
		fmt.Scanf("%d %d %d", &m, &n, &r)
		if m == -1 && n == -1 && r == -1 {
			break
		}
		if F(m,n,r) {
		}else if A(m, n, r) {
		} else if B(m, n, r) {
		} else if C(m, n, r) {
		} else if D(m, n, r) {
		}
	}
}

func A(m, n, r int) bool {
	if m+n >= 80 {
		fmt.Println("A")
		return true
	}
	return false
}

func B(m, n, r int) bool {
	if m+n < 80 && m+n >= 65 {
		fmt.Println("B")
		return true
	}
	return false
}

func C(m, n, r int) bool {
	if m+n < 65 && m+n >= 50 {
		fmt.Println("C")
		return true
	} else if m+n < 50 && m+n >= 30 && r >= 50 {
		fmt.Println("C")
		return true
	}
	return false
}

func D(m, n, r int) bool {
	if m+n < 50 && m+n >= 30 {
		fmt.Println("D")
		return true
	}
	return false
}

func F(m, n, r int) bool {
	if m == -1 || n == -1 || m+n < 30 {
		fmt.Println("F")
		return true
	}
	return false
}

Measured memory_bytes: 1116
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int A;
  int B;
  int C;
  rd(A);
  rd(B);
  rd(C);
  if(A > B){
    swap(A, B);
  }
  if(B > C){
    swap(B, C);
  }
  if(A > B){
    swap(A, B);
  }
  ;
  if(A!=C && (A==B || B==C)){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200217-1

// --- original code ---
// {
//   int A, B, C;
//   rd(A,B,C);
//   sortE(A,B,C);
//   wt(if[A!=C && (A==B || B==C), "Yes", "No"]);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repn(a,b,c) for(int a=b;a<=c;a++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  
#define mod (ll)1000000007
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
//sort pair by second values
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}


ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


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

    int n;
    cin>>n;
    ll k;
    cin>>k;
    bool vis[n+1]={0};
    int a[n+1]={0};
    f1(i,n+1){
        cin>>a[i];
    }

    vector<int> v;
    int curr=1;
    int check=1;
    int next=a[1];

    while(1){
        if(vis[curr]==1){
            v.pb(curr);
            break;
        }
        //cout<<curr<<next<<endl;
        vis[curr]=1;
        next=a[curr];
        v.pb(curr);
        curr=next; 
    }
    // f(i,v.size()){
    //     cout<<v[i]<<endl;
    // }
    
    int st=v.back();
    vi cyc;
    vi ns;
    f(i,v.size()){
        if(v[i]==st){
            for(int j=i;j<v.size()-1;j++){
                cyc.pb(v[j]);
            }
            break;
        }
        else{
            ns.pb(v[i]);
        }
    }
    // f(i,cyc.size()){
    //     cout<<cyc[i]<<endl;
    // }
    if(k<ns.size()){
        cout<<ns[k]<<endl;
    }
    else{
        k=k-(ll)(ns.size());
        int x=cyc.size();
        cout<<cyc[k%(ll)x]<<endl;
    }


    return 0;
}



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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;

int main(){
  string S;
  cin >> S;
  int N = S.size();

  vector<vector<mint>> dp(N, vector<mint>(13, 0));

  if(S[0] == '?'){
    for(int i = 0; i <= 9; i++){
      dp[0][i] = 1;
    }
  } else { 
    int tmp = S[0] - '0';
    dp[0][tmp] = 1;
  }

  for(int i = 0; i < N-1; i++){
    if(S[i+1] != '?'){
      int tmp = S[i+1] - '0';
      for(int j = 0; j <= 12; j++){
        dp[i+1][(10*j+tmp)%13] += dp[i][j];
      }
    } else {
      for(int k = 0; k <= 9; k++){
        for(int j = 0; j <= 12; j++){
          dp[i+1][(10*j + k) % 13] += dp[i][j];
        }
      }
    }
  }

  cout << dp[N-1][5] << endl;

}


Measured memory_bytes: 8960
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
    bool done_something = false;
    stringstream res;
    res << "[";
    for (; begin_iter != end_iter and counter; ++begin_iter) {
        done_something = true;
        counter--;
        res << *begin_iter << ", ";
    }
    string str = res.str();
    if (done_something) {
        str.pop_back();
        str.pop_back();
    }
    str += "]";
    return str;
}

vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
    vector<int> ord(size);
    for (int i = 0; i < size; i++) ord[i] = i;
    sort(ord.begin(), ord.end(), compare);
    return ord;
}

template <typename T>
bool MinPlace(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool MaxPlace(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename Container>
int SZ(const Container& S) { return S.size(); }

template <typename S, typename T>
ostream& operator <<(ostream& out, const pair<S, T>& p) {
    out << "{" << p.first << ", " << p.second << "}";
    return out;
}

template <typename T>
ostream& operator <<(ostream& out, const vector<T>& v) {
    out << "[";
    for (int i = 0; i < (int)v.size(); i++) {
        out << v[i];
        if (i != (int)v.size()-1) out << ", ";
    }
    out << "]";
    return out;
}

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file

    #define dbg_var(x) clog << #x  << ": " << x << endl;
    #define dbg_array(x, len) clog << #x << ": " << print_iterable(x, x+len, -1) << endl;
#else
    #define dbg_var(x)
    #define dbg_array(x, len)
#endif

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

const int MAXN = -1; 

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Remove in problems with online queries!

    int N, A, B;
    cin >> N >> A >> B;
    cout << (((A-B) % 2 == 0) ? "Alice" : "Borys") << "\n";
}



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



int main(){
  ios_base::sync_with_stdio(false);
  
  int n,a;

  cin >> n >> a;

  n %= 500;

  if(n <= a){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
int main(){
	int n=read(); int m=read(); int X=read(); int Y=read();
	int x=-105; rep(i,1,n) x=max(x,read());
	int y=105;  rep(i,1,m) y=min(y,read());
	int pd=0; rep(i,X+1,Y) if ((i>x)&&(i<=y)) { pd=1; break; }
    if (pd) puts("No War"); else puts("War");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c;
    int ans;

    cin >> a >> b >> c;

    if (a == b && b == c) {
        cout << 1 << endl;
    } else if (a != b && b == c) {
        cout << 2 << endl;
    } else if (a == b && b != c) {
        cout << 2 << endl;
    } else if (a != b && a == c) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;

signed main(){
	fast;
	string s, t;
	cin>>s>>t;
	
	int n=s.length();
	int m=t.length();
	
	if(m-n!=1) cout<<"NO";
	else{
		int flag=0;
		for(int i=0; i<n; i++){
			if(s[i]!=t[i]){
				flag=1;
				break;
			}
		}
		
		if(flag==0) cout<<"Yes";
		else cout<<"No";
	}
    return 0; 
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)

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

  
    cout << n*n << endl;
    return 0;
}

Measured memory_bytes: 256
N,M,L = map(int,input().split())
anm=[[0]*M for _ in range(N)]
bml=[[0]*L for _ in range(M)]
cnl=[[0]*L for _ in range(N)]


for n in range(N):
  data = list(map(int,input().split()))
  for m in range(M):
    anm[n][m] = data[m]

for m in range(M):
  data = list(map(int,input().split()))
  for l in range(L):
    bml[m][l] = data[l]

for n in range(N):
  for l in range(L):
    for m in range(M):
      cnl[n][l] += anm[n][m]*bml[m][l]

for n in range(N):
  for l in range(L):
    if l==L-1:
      print("{:d}".format(cnl[n][l]))
    else:
      print("{:d}".format(cnl[n][l]),end=" ")


Measured memory_bytes: 7052
import sys
sys.setrecursionlimit(10**6)
t=input()
tl=list(t)
tln=len(t)
x=0
for x in range(tln):
    if tl[x] == "?":
        if x == tln-1:
            tl[x]="D"
            break
        elif x==0:
            if tl[x+1]=="?":
                tl[x]="P"
                tl[x+1]="D"
            else:
                tl[x]="D"
        elif tl[x-1]=="P":
            tl[x]="D"
        elif tl[x+1]=="?":
            tl[x]="P"
            tl[x+1]="D"
        elif tl[x+1]=="D":
            tl[x]="P"
        else:
            tl[x]="D"
t="".join(tl)
print(t)

Measured memory_bytes: 10844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		
		while(true){
			int sum = 0;
			String S = s.nextLine();
			
			if(S.charAt(0) == '0') break;
			
			for(int i = 0;i < S.length(); i++){
				sum += Integer.parseInt("" + S.charAt(i));
			}	
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26868
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (a, b, c) = readListOfInt()
    println(if(b-a==c-b) "YES" else "NO")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37832
#include <stdio.h>

int dp[50];

int fibonacci(int n){
  if(n==0 || n==1){
    dp[n] = 1;
    return 1;
  }
  if(dp[n] != -1) return dp[n];
  dp[n] = fibonacci(n-1) + fibonacci(n-2);
  return dp[n];
}

int main(){
  int n,i;
  for(i=0;i<50;i++) dp[i] = -1; 

  scanf("%d",&n);
  printf("%d\n",fibonacci(n));

  return 0;
}



Measured memory_bytes: 2112
s = input()
t = input()

def histgram(s):
    h = {}
    for i in range(26):
        ch = chr(i + ord('a'))
        h[ch] = 0
    for ch in s:
        h[ch] += 1
    return h
h_s = histgram(s)
h_t = histgram(t)
s_ = ""
for i in range(26):
    ch = chr(i + ord('a'))
    for j in range(h_s[ch]):
        s_ += ch
t_ = ""
for i in range(25, -1, -1):
    ch = chr(i + ord('a'))
    for j in range(h_t[ch]):
        t_ += ch
ans = s_ < t_

print("Yes" if ans else "No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



int a[200000];
signed main(){
  int n, c, k;
  scanf("%lld%lld%lld", &n, &c, &k);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n);
  int cnt = 0, l = -1, ans = 0;
  rep(i,n){
    cnt++;
    if(l == -1)l = a[i];
    if(i == n-1 or a[i+1]-l > k or cnt == c){
      l = -1;cnt = 0;ans++;continue;
    }
  }
  printf("%lld\n", ans);
	return 0;
}









Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
#define MAX 100000

int A[MAX];

void argCout(int A[],int N,int l){
  for(int i=0;i<N;i++){
    if(i) cout<<" ";
    if(i==l) cout<<"[";
    printf("%d",A[i]);
    if(i==l) cout<<"]";
  }
  cout<<endl;
}

int partition(int A[],int p,int r){
  int x=A[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      swap(A[i],A[j]);
    }
  }
  swap(A[i+1],A[r]);
  return i+1;
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  int l=partition(A,0,n-1);
  argCout(A,n,l);
}



Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 string s ;
 cin >> s ;
 ll k ;
 cin>> k ;
 char ans= '1' ;
 ll m=s.size() ;
 ll p=min(k,m) ;
 rep(i,p) {
   if(s[i]!='1'){
     ans=s[i] ;
     break ;
   }

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

Measured memory_bytes: 256