akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int count = 0;
        double z = 0;
        PrintWriter out = new PrintWriter(System.out);
        for (int l = 1; l <= N; l++) {
            for (int i = 1; i <= Math.sqrt(N); i++) {
                for (int j = 1; j <= Math.sqrt(N); j++) {
                    z = (-i - j + Math.sqrt((i + j) * (i + j) - 4 * (i * i + j * j + i * j - l))) / 2;
                    if (z == (int) z && z > 0 && i * i + j * j + z * z + i * j + j * z + z * i == l) {
                        count++;
                    }
                }
            }
            out.println(count);
            out.flush();
            count = 0;
        }
        sc.close();
    }
}

Measured memory_bytes: 42440
#include<iostream>
int main() {
	char a[100],b[5]="YAKI";
	int i = 0;
	std::cin >> a;
	for (i = 0; i < 4; i++) {
		if (a[i] != b[i]) break;
	}
	if (i == 4)std::cout << "Yes" << std::endl;
	else std::cout <<"No"<<std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
 
int main(void) {
    int i,alpha[26]={0};
    char string[1201];
    while (fgets(string,sizeof(string),stdin)!=NULL) {
        for (i=0; i<strlen(string); i++) {
            if (isalpha(string[i])) {
                if (islower(string[i])) {
                    alpha[string[i]-'a']++;
                } else {
                    alpha[string[i]-'A']++;
                }
            }
        }
    }
    for (i=0; i<26; i++) printf("%c : %d\n",i+'a',alpha[i]);
    return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N, 0);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	int Q;
	cin >> Q;
	int t, x, d;
	for (int i = 0; i < Q; i++) {
		cin >> t >> x >> d;
		if (res == 0) {
			x--;
			if (t == 1) {
				B[x] += d;
				if (B[x] > A[x]) {
					res = x + 1;
				}
			}
			else {
				B[x] -= d;
				if (B[x] < 0){
					res = x + 1;
				}
			}

		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3216
// Aizu Vol-1 0191: Baby Tree
// 2017.8.23 bal4u@uu
// 2017.10.30 retry

#include <stdio.h>
#include <string.h>

double d[102][102];
double t[102][102];

int main()
{
	int n, m, i, j, k;
	double ans;

	while (scanf("%d%d", &n, &m) && n) {
		for (i = 0; i < n; i++) for (j = 0; j < n; j++) scanf("%lf", d[i]+j);
		memset(t, 0, sizeof(t));
		for (i = 0; i < n; i++) t[0][i] = 1;
		for (k = 1; k < m; k++) {
			for (i = 0; i < n; i++) for (j = 0; j < n; j++) {
				double x = t[k-1][i] * d[i][j];
				if (x > t[k][j]) t[k][j] = x; 
			}
		}
		for (ans = 0, i = 0; i < n; i++) if (t[m-1][i] > ans) ans = t[m-1][i];
		printf("%.2lf\n", ans);
	}
	return 0;
}

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

public class Main {

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
	      Scanner  sc=new Scanner(System.in);
	      PrintWriter out=new PrintWriter(System.out);
	        int n=sc.nextInt();
	       long a[]=new long[3*n];
	        for(int i=0;i<3*n;i++) {
	          a[i]=sc.nextLong();  
	        }
	        long ans=Long.MIN_VALUE;
	        PriorityQueue<Long> pq=new PriorityQueue<>();
	        ArrayList<Long> sum=new ArrayList<>();
	        ArrayList<Long> sum2=new ArrayList<>();
	        long summ=0;
	        for(int i=0;i<n;i++) {
	          pq.add(a[i]);
	          summ+=a[i];
	          
	        }
	       sum.add(summ);
	        for(int i=n;i<2*n;i++) {
	          pq.add(a[i]);
	          summ+=a[i];
	           summ-= pq.poll();
	        
	          
	            sum.add(summ);
	          
	        }
	        PriorityQueue<Long> pq1=new PriorityQueue<>(Collections.reverseOrder());
	        long summ1=0;
         for(int i=3*n-1;i>=2*n;i--) {
           pq1.add(a[i]);
           summ1+=a[i];
           
         }
         sum2.add(summ1);
         for(int i=2*n-1;i>=n;i--) {
           pq1.add(a[i]);
           summ1+=a[i];
            summ1-= pq1.poll();
            
             
             sum2.add(summ1);
           
         }
         
         for(int i=0;i<=n;i++) {
           ans=Math.max(sum.get(i)-sum2.get(n-i),ans);
         }

	        System.out.println(ans);
	}
	static long solve(PriorityQueue<Long> pq) {
	  
	  long sum=0;
	    
	       while(!pq.isEmpty()) {
	         sum+=pq.poll();
	       
	       }
	       return sum;
	}
 static long solve1(long a[],int i,int j,int n) {
   
   PriorityQueue<Long> pq=new PriorityQueue<>();
   for(int k=i;k<j;k++) {
   
     pq.add(a[k]);
   }
   
   long sum=0;
  while(n!=0) {
    sum+=pq.poll();
    n--;
  }
  return sum;
}
	
	static int  prime[]=new int[100001];
	static void sieve() {
	  Arrays.fill(prime,1);
	  prime[0]=0;
	  prime[1]=1;
	  for(int i=2;i*i<100001;i++) {
	   if(prime[i]!=0) {
	     for(int j=i;j<10001;j+=i) {
	       prime[j]=0;
	     }
	   }
	  }
	}
	      static long gcd(long a, long b) 
	      { 
	          if (a == 0) 
	              return b; 
	          return gcd(b % a, a); 
	      } 

static long nCr(int n,int r) {
  int dp[][]=new int[2001][2001];
  for(int i=0;i<2001;i++) {
    dp[0][i]=0;
  }
  for(int i=0;i<2001;i++) {
    dp[i][0]=1;
  }
  for(int i=1;i<2001;i++) {
    for(int j=1;j<2001;j++) {
      if(i==j) {
        dp[i][j]=1;
      }else {
        dp[i][j]=dp[i-1][j-1]+dp[i][j-1];
      }
    }
  }
  return dp[n][r];
}


      
}
class pair {
  int src;
 int  des;
 long val;
  pair(int src,int des,long val){
    this.src=src;
    this.des=des;
    this.val=val;
    
  }

//  @Override
//  public int compareTo(pair o) {
//   
//    return this.wt-o.wt;
//  }
}

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

const int dx[4] = { 0, 0, -1, 1 };
const int dy[4] = { -1, 1, 0, 0 };
const char mov[] = "UDLR";
const char tank[] = "^v<>";

int h, w, d, x, y;
string map[22], command;

int main()
{
    int t, n;
    cin >> t;
    map[0] = "######################";

    for(int i = 0; i < t; ++i)
    {
        cin >> h >> w;
        for(int j = 1; j <= h; ++j) {
            cin >> map[j];
            map[j] = "#" + map[j] + "#";
            for(int k = 0; k < 4; ++k)
                if(map[j].find(tank[k]) != string::npos)
                    y = j, x = map[j].find(tank[k]), d = k, map[y][x] = '.';
        }
        map[h+1] = map[0];
        cin >> n >> command;

        for(int j = 0; j < n; ++j)
        {
            for(int k = 0; k < 4; ++k)
                if(command[j] == mov[k]) {
                    d = k;
                    if(map[y+dy[d]][x+dx[d]] == '.')
                        x += dx[d], y += dy[d];
                }

            if(command[j] == 'S')
                for(int xx = x, yy = y; map[yy][xx] != '#'; xx += dx[d], yy += dy[d])
                    if(map[yy][xx] == '*') { map[yy][xx] = '.'; break; }
        }

        map[y][x] = tank[d];

        if(i) cout << endl;
        for(int j = 1; j <= h; ++j)
            cout << map[j].substr(1, w) << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(0); cin.tie(0);
void input(){
 #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
 #endif	
}
/*****************************************************************************/


 int main(){ 
	//input();
	speed	

	int n;	cin>>n;
	int k; 	cin>>k;
	int sum=0;

	for (int i=0;i<n;i++){
		int x; 	cin>>x;
		if (x>=k)
			sum++;
	}
	cout<<sum;

 return 0;
}

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

signed main(){
	int K,A,B; cin>>K>>A>>B;
	bool ans=false;
	for(int i=0;i<1000;i++){
		if(A<=K*i and K*i<=B)ans=true;
	}
	cout<<(ans ? "OK" : "NG")<<endl;
}

Measured memory_bytes: 3672
N=int(input())
import sys
input=sys.stdin.readline
X=[(-10**10,0)]
Y=[(-10**10,0)]

for i in range(N):
    x,y=map(int,input().split())
    X.append((x,i+1))
    Y.append((y,i+1))
X.append((10**10,N+1))
Y.append((10**10,N+1))
X.sort()
Y.sort()

#print(X,Y)

L=[[]for i in range(N+1)]
for i in range(1,N+1):
    L[X[i][1]].append((X[i][0]-X[i-1][0],X[i-1][1]))
    L[X[i][1]].append((X[i+1][0]-X[i][0],X[i+1][1]))
for i in range(1,N+1):
    L[Y[i][1]].append((Y[i][0]-Y[i-1][0],Y[i-1][1]))
    L[Y[i][1]].append((Y[i+1][0]-Y[i][0],Y[i+1][1]))
#print(L)
C=[1 for i in range(N+2)]
C[0]=0
C[-1]=0
C[1]=0
import heapq
ans=0
Q=L[1]
heapq.heapify(Q)
for i in range(10**6):
    #print(ans,Q)
    #print(C)
    if len(Q)==0:
        break
    q=heapq.heappop(Q)
    if C[q[1]]==0:
        continue
    else:
        C[q[1]]=0
        ans+=q[0]
        for j in range(4):
            if C[L[q[1]][j][1]]==1:
                heapq.heappush(Q,L[q[1]][j])
print(ans)

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

int main()
  {string s;
  cin >> s;
  int m = (s.size() - 1) / 2;
  string t = s;
  reverse(begin(t), end(t));
  cout << (s == t && s.substr(0, m) == s.substr(m + 1) ? "Yes" : "No") << endl;
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>//solved by *ALIKHAN*
#define ll long long
#define ld long double
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define ppb pop_back
#define mp make_pair
#define all(n) n.begin(), n.end()
#define timefaster ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18;
int a[N] , b[N] , c[N] , sum;
int main(){
	timefaster;
	int n ;
	cin >> n;
	for(int i = 0;i < n;i ++){
	 	cin >> a[i];
	 	a[i] --;
	}
	for(int i = 0;i < n;i ++) cin >> b[i];
	for(int i = 0;i < n - 1;i ++) cin >> c[i];
	for(int i = 0;i < n;i ++){
		sum += b[a[i]];
		if(i > 0 && a[i] == a[i - 1] + 1) sum += c[a[i - 1]];  	
	}
	cout << sum;
}// Aksay sila

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

/*
   AtCoder contest code
   coder : yoichidon
 */

public class Main {
    public static String longer(String x, String y){
        if(x.length() > y.length()) return x;
        else return y;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] p = new double[N];
        for(int n=0;n<N;n++) p[n]=sc.nextDouble();

        double[][] dp = new double[N][N+1];
        dp[0][1] = p[0];
        dp[0][0] = 1 - p[0];

        for(int n=1; n<N; n++) for(int head=0; head<=n+1; head++){
            dp[n][head] = dp[n-1][head] * (1-p[n]) + (head==0?0: dp[n-1][head-1] * p[n]);
        }

        double ans = 0;
        for(int head=N; head>N-head; head--) ans += dp[N-1][head];
        System.out.println(ans);

    }
}


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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k - 1] += 32;
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

int main() {
	int s;
	int m;
	int h;
	std::cin >> s;

	h = s / 3600;
	m = s % 3600/60;
	s = s % 3600 % 60;

	std::cout << h << ":" << m << ":" << s << std::endl;
	return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[100010];
int main() {
    scanf("%s",s);
    int n=strlen(s),ans=0;
    for(int i=0;i<n-1;i++) ans+=(s[i]!=s[i+1]);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1LL << 50;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}

ll check(const string& s){
    ll res = 0;
    ll cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'X') res += cnt;
        else cnt++;
    }
    return res;
}
int main(){
    string s; cin >> s;

    ll A = 0; ll ans = 0;
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == 'A'){
            A++;
        } else if (s.substr(i,2) == "BC"){
            ans += A;
            i++;
        } else {
            A = 0;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=998244353;

int main(){
	ll N;
	cin >> N;
	vll D(N);
	for(int i=0; i<N; i++){
		cin >> D[i];
	}

	ll prevcount=1;
	ll count=0;
	ll ans=1;

	if(D[0]!=0){
		cout << 0 << endl;
		return 0;
	}

	vll counts(N,0);
	for(int i=0; i<N; i++){
		counts[D[i]]++;
	}
	if(counts[0]!=1){
		cout << 0 << endl;
		return 0;
	}
	ll sum=counts[0];
	ll a;
	int i;
	for(i=1; i<N; i++){
		if(counts[i]==0){
			cout << 0 << endl;
			return 0;
		}
		a=1;
		for(int j=0; j<counts[i]; j++){
			a *= counts[i-1];
			a %= mod;
		}
		ans *= a;
		ans %= mod;
		sum+=counts[i];
		if(sum==N) break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if ( C-(A-B) < 0 ) {
        printf("%d\n",0);
    }
    else {
        printf("%d\n",C-(A-B)); 
    }
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use {
    itertools::Itertools,
    proconio::{fastout, input, marker::*},
    std::cmp::*,
    std::collections::*,
    std::io::Write,
    std::ops::*,
};

macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
        mut b: [usize; n],
    }

    let mut cnt_a = vec![0; n + 1];
    let mut cnt_b = vec![0; n + 1];
    for &a in a.iter() {
        cnt_a[a] += 1;
    }
    for &a in b.iter() {
        cnt_b[a] += 1;
    }
    let mut q = std::collections::BTreeSet::<_>::new();
    for i in 0..=n {
        if cnt_a[i] + cnt_b[i] > n {
            println!("No");
            return;
        }
        let c = cnt_a[i] + cnt_b[i];
        if c > 0 {
            q.insert((c, i, cnt_a[i], cnt_b[i]));
        }
    }

    let mut ch = vec![vec![]; n + 1];
    let mut stock = vec![];
    while let Some(&(c, i, an, bn)) = q.iter().rev().next() {
        q.remove(&(c, i, an, bn));
        if an == 0 {
            stock.push((i, bn));
            continue;
        }
        if let Some((j, d)) = stock.pop() {
            ch[i].push(j);
            if d > 1 {
                stock.push((j, d - 1));
            }
        } else {
            let mut x = (0, 0, 0, 0);
            let mut y = (0, 0, 0, 0);
            for &(c, j, am, bm) in q.iter().rev() {
                if bm > 0 {
                    ch[i].push(j);
                    x = (c, j, am, bm);
                    y = (c - 1, j, am, bm - 1);
                    break;
                }
            }
            q.remove(&x);
            if y.0 > 0 {
                q.insert(y);
            }
        }
        if c > 1 {
            if an == 1 {
                stock.push((i, bn));
            } else {
                q.insert((c - 1, i, an - 1, bn));
            }
        }
    }

    let mut ans = vec![0; n];
    for i in 0..n {
        ans[i] = ch[a[i]].pop().unwrap();
    }

    println!("Yes");
    println!("{}", ans.iter().join(" "));
}


Measured memory_bytes: 28412
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	string A;
	cin >> A;
	int cnt[26] = { 0 };
	LL sum = 0;
	for (int i = A.size() - 1; i >= 0; i--) {
		sum += (A.size() - 1 - i) - cnt[A[i]-'a'];
		cnt[A[i] - 'a']++;
	}
	cout << sum + 1 << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int x1,x2,x3,x4,y1,y2,y3,y4;
  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  x4 = x1 + y1 - y2;
  y4 = y1 + x2 - x1;
  x3 = x2 + y1 - y2;
  y3 = y2 + x2 - x1;
  printf("%d %d %d %d",x3,y3,x4,y4);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define M 100050
#define N 1050
typedef long long ll;
class edge{
	public:int to,nxt,f;
}e[M<<1];
int head[N],Top=1;
inline void add(int u,int v){
	e[++Top].to=v;
	e[Top].nxt=head[u];
	head[u]=Top;
	e[Top].f=1;
	
	e[++Top].to=u;
	e[Top].nxt=head[v];
	head[v]=Top;
	e[Top].f=0;
}
#define min(a,b) ((a)<(b)?(a):(b))
#define id(x) (((x)-1)/m+1)
int S,T,cur[N],dep[N];
int dfs(int u,int flw){
	if(u==T) return flw;
//	printf("** %d\n",u);
	for(int &i=cur[u],v;i;i=e[i].nxt){
		v=e[i].to;
		if(e[i].f<=0||dep[v]!=dep[u]+1)continue;
		int flow=dfs(v,min(flw,e[i].f));
		if(flow){
			e[i].f-=flow;
			e[i^1].f+=flow;
			return flow;
		}
	}
}
std::queue<int> q;
bool bfs(){
	for(int i=1;i<=T;++i)
		dep[i]=0;
	dep[S]=1;
	q.push(S);
	while(!q.empty()){
		int u=q.front();q.pop();
//		printf("** %d\n",u);
		for(int i=head[u],v;i;i=e[i].nxt){
			v=e[i].to;
			if(dep[v]==0&&e[i].f>0){
				dep[v]=dep[u]+1;
				q.push(v);
			}
		}
	}
	return dep[T];
}
void dinic(){
	while(bfs()){
//		printf("\n**");
//		for(int i=1;i<=T;++i)
//			printf(" %d",dep[i]);
//		printf("\n\n");
		for(int i=1;i<=T;++i)
			cur[i]=head[i];
		while(dfs(S,10000));
//		for(int i=2;i<=Top;i+=2)
//			printf("** %d %d\n",e[i].f,e[i+1].f);
	}
}
int n,m,a[250][250],b[250][250];
std::vector<int> c[250][250];
void update(int x,int i,int j){
//	printf("*** %d %d %d\n",b[i][j],c[i][x].back(),c[i][x].size());
	b[i][j]=c[i][x].back();
	c[i][x].pop_back();
}
void work(int num){
	for(int i=1;i<=n;++i){
		add(S,i);
		add(i+n,T);
	}
	dinic();
//	printf("** %d\n",num);
	for(int i=n+1;i<=2*n;++i){
//		printf("** %d\n",i);
		for(int j=head[i];j;j=e[j].nxt){
//			printf("*** %d\n",j);
			if(e[j].f){
//				printf("** %d %d %d\n",i-n,e[j].to,num);
				e[j].f=0;
				update(i-n,e[j].to,num);
			}
		}
	}
}
int main(){
	scanf("%d%d",&n,&m);
	S=n*2+1;
	T=S+1;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			scanf("%d",&a[i][j]);
//			printf("** %d %d\n",i,id(a[i][j]));
			c[i][id(a[i][j])].push_back(a[i][j]);
			add(i,n+id(a[i][j]));
		}
	for(int i=1;i<=m;++i){
		work(i);
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			a[id(b[i][j])][j]=b[i][j];
			printf("%d ",b[i][j]);
		}puts("");
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j)
			printf("%d ",a[i][j]);
		puts("");
	}
	return 0;
}
/*
3 2
2 6
4 3
1 5
*/

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

#include <cstdio>
#include <climits>
#include <cstdlib>



using namespace std;

int main(){
  string S;
  cin >> S;

  bool HEISEI = true;
  if(S[5] == '1'){
    HEISEI = false;
  }else{
    if(S[6] == '1' || S[6] == '2' || S[6] == '3' || S[6] == '4'){
      HEISEI = true;
    }else{
      HEISEI = false;
    }
  }

  if(HEISEI){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }

  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int mod = 1e+9 + 7;

bool br[100010];
ll dp[100010];

int main() {
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++){
		int a;
		cin >> a;
		br[a] = true;
	}


	dp[0] = 1;
	for (int i = 0; i < n; i++){
		if (br[i] == true)continue;

		if (br[i + 1] == false&&i+1<=n) {
			(dp[i + 1] += dp[i]) %= mod;
		}

		if (br[i + 2] == false&&i+2<=n) {
			(dp[i + 2] += dp[i]) %= mod;
		}
	}

	cout << dp[n] << endl;

}


Measured memory_bytes: 1152
K = int(input())

if K==0:
    print(2)
    print(0,0)
else:
    Ans = []
    N = K%50
    M = (K-1)//50
    if K%50==0:
        N = 50
    for i in range(N):
        Ans.append(50-i + M)
    for i in range(50-N):
        Ans.append(50-N-1 + M)
    
    print(50)
    print(" ".join(map(str,Ans)))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>

using namespace std;

int S[100000];

int main(void) {

    int n;
    scanf("%d", &n);
//    cin >> n;

    for (int i = 0; i < n; ++i) {
//        cin >> S[i];
    scanf("%d", S + i);
    }

    int q, total = 0;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        int left = 0, right = n - 1, mid = 0;
        while (left <= right) {     // '<' ?????¨?????¨??§?????????
            mid = (left + right) / 2;
            if (t > S[mid]) {
                left = mid + 1;
            }
            else if (t < S[mid]) {
                right = mid - 1;
            }
            else {
                ++total;
                break;
            }
        }
    }

    printf("%d\n", total);

    return 0;
}

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

char s[201];

int main()
{
	cin >> s;
	int len = strlen(s);
	for (int i = len-2; i >= 0; i -= 2)
	{
		int flag = 1;
		int l = 0;
		int r = i/2;
		for (; l < i/2; )
		{
			if (s[r++] != s[l++])
			{
				flag = 0;
				break;
			}
		}
		if (flag)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}



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

int main() {
  int D;
  cin >> D;

  if (D == 5 || D == 3 || D == 7) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


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



int main() {
    int a, b;
    cin >> a >> b;
    
    int mn = min(a,b);
    int mx = max(a,b);
    
    rep(i,mx) {
        cout << mn;
    }
    cout << endl;
    
    
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int a, b, c; cin >> a >> b >> c;
    if(a == b) cout << c << endl;
    else if(b == c) cout << a << endl;
    else cout << b << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
int main()
{   
    int n; cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	ll ans = a[0];
	ll index = 1;
	n--;
	n--;
	bool next = false;
	while (n--) {
		ans += a[index];
		if (next) {
			index++;
			next = false;
		}
		else {
			next = true;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
#include<stdio.h>

int main()
{
    int n, i,  cnt=0;
    scanf("%d",&n);
    char s[n];

    scanf("%s", s);
    for(i=1; i<n; i++)
    {
        if(s[i]!=s[i-1])
        {
            cnt++;

        }

    }
    printf("%d\n",cnt+1);

    return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	int cnt = 1;
	for(int i = 1; i < 1000; i++){
		cnt *= k;
		// cout << cnt << endl;
		if(n < cnt){
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int max = 0;
        int min = 1000000000;
        
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            if(min > a[i]){
                min = a[i];
            }
            if(max < a[i]){
                max = a[i];
            }
        }
        System.out.println(max-min);
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <climits>
#include <iostream>
#include <random>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;
using std::lower_bound;
using std::upper_bound;

long count_less_than(const vector<long>& a, long l, long* max) {
  long count = 0;
  int i, j;

  int z = lower_bound(a.begin(), a.end(), 0) - a.begin();

  // Count (a_i, a_j) where a_i >= 0 and a_j >= 0 and j > i.
  i = z;
  j = a.size() - 1;
  for (; i < a.size(); ++i) {
    while (j > i && a[i] * a[j] > l) {
      --j;
    }
    if (i == j) {
      break;
    }
    *max = std::max(*max, a[i] * a[j]);
    count += j - i;
  }

  // Count (a_i, a_j) where a_i >= 0 and a_j < 0 and i > j.
  i = a.size() - 1;
  j = z - 1;
  for (; i >= z; --i) {
    while (j >= 0 && a[i] * a[j] > l) {
      --j;
    }
    if (j < 0) {
      break;
    }
    *max = std::max(*max, a[i] * a[j]);
    count += j + 1;
  }

  // Count (a_i, a_j) where a_i < 0 and i > j.
  i = z - 1;
  j = 0;
  for (; i >= 0; --i) {
    while (i > j && a[i] * a[j] > l) {
      ++j;
    }
    if (i == j) {
      break;
    }
    *max = std::max(*max, a[i] * a[j]);
    count += i - j;
  }

  return count;
}

int main(int argc, char* argv[]) {
  int n;
  long k;
  cin >> n >> k;
  vector<long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  long s = -1000000000000000000L;
  long e = 1000000000000000000L;  // 10^9^2
  long m;

  while (s < e) {
    m = (s + e) / 2;
    if (m == e) {
      --m;
    }
    long unused;
    if (count_less_than(a, m, &unused) < k) {
      s = m + 1;
    } else {
      e = m;
    }
  }
  long max = -1000000000000000000L;

  cerr << "s: " << s << endl;
  cerr << "count: " << count_less_than(a, s, &max) << endl;
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N,X,T;
  cin >> N >> X >> T;
  if (N%X == 0) cout << N/X*T << endl;
  else cout << (N/X+1)*T << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

int D;
vector<int> down(26);
vector<vector<int>> up;

int main() {
    //std::chrono::system_clock::time_point  start, end; // 型は auto で可
    //start = std::chrono::system_clock::now();

    cin>>D;
    rep(i,26)cin>>down.at(i);
    up.resize(D,vector<int>(26));
    rep(i,D)rep(j,26)cin>>up.at(i).at(j);
    vector<vector<int>> tlist(27,vector<int>(D));
    vector<ll> anslist(27);

    rep(future,27){
        ll ans=0;
        vector<ll> human(26,0);
        rep(day,D){
            rep(i,26){
                human.at(i)+=down.at(i);
                ans-=human.at(i);
            }
            int choice=0;
            for(int i=1;i<26;i++){
                ll now=0,ne=0;
                now+=up.at(day).at(choice);
                ne+=up.at(day).at(i);
                now+=human.at(choice)*(future+1)+down.at(choice)*future*(future+1)/2;
                ne+=human.at(i)*(future+1)+down.at(i)*future*(future+1)/2;
                if(ne>now)choice=i;
            }

            ans+=human.at(choice)+up.at(day).at(choice);
            human.at(choice)=0;
            tlist.at(future).at(day)=choice+1;
        }
        anslist.at(future)=ans;
    }

    int goodfuture=0;
    rep(i,27){
        if(anslist.at(i)>anslist.at(goodfuture)){
            goodfuture=i;
        }
    }
    rep(i,D){
        cout<<tlist.at(goodfuture).at(i)<<endl;
    }

    /*ll ans=0;
    vector<ll> human(26,0);
    rep(day,D){
        rep(i,26){
            human.at(i)+=down.at(i);
            ans-=human.at(i);
        }
        int choice=0;
        rep(i,26){
            if(human.at(i)+up.at(day).at(i)>human.at(choice)+up.at(day).at(choice)){
                choice=i;
            }
        }
        ans+=human.at(choice)+up.at(day).at(choice);
        human.at(choice)=0;
        cout<<choice+1<<endl;
    }*/

    //double elapsed;
    
    /*while(elapsed<1950){//時間が許す限り
        
        end = std::chrono::system_clock::now();  // 計測終了時間
        elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    }*/
    
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin >> a >> b;
    if(abs(a-b) <=1)cout << "Brown" << endl;
    else cout << "Alice" << endl;
    return 0;
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
----
-- C
local N = read.n()
local T = {}
local ans = "YES"
for i=1,N do
    local A = read.n()
    T[A] = (T[A] or 0) + 1
    if T[A] == 2 then
        ans = "NO"
    end
end
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vi> graph;

int n;
ll mat[100010][3];

/*ll solve(int r, int c) {
	if (r == n - 1) {
		return mat[r][c];
	}
	if (dp[r][c] != -1) return dp[r][c];
	ll temp, mayor = -1;
	for (int i = 0; i < 3; ++i)
	{
		if (i == c) continue;
		temp = solve(r + 1, i);
		mayor = temp > mayor ? temp : mayor;
	}
	return dp[r][c] = mat[r][c] + mayor;
}*/

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

	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> mat[i][j];
		}
	}
	vector <long long> arr1(3), arr2(3);
	arr1[0] = mat[0][0];
	arr1[1] = mat[0][1];
	arr1[2] = mat[0][2];
	arr2 = arr1;
	for (int i = 1; i < n; ++i)
	{
		arr2[0] = mat[i][0] + max(arr1[1], arr1[2]);
		arr2[1] = mat[i][1] + max(arr1[0], arr1[2]);
		arr2[2] = mat[i][2] + max(arr1[1], arr1[0]);
		if (i < n - 1) arr1.swap(arr2);
	}
	ll mayor = max(arr2[0], max(arr2[1], arr2[2]));
	cout << mayor << "\n";
    return 0;
}


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

int main(){
    ll d, n;
    cin >> d >> n;
    ll base = ll(pow(100, d));
    if (n == 100){
        cout << 101 * base << endl;
    }
    else cout << base * n << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    int[] f = new int[10001];
    int n;

    private void run() {
        n = sc.nextInt();

        for (int i = 1; i <= 100; i++) {
            for (int j = 1; j <= 100; j++) {
                for (int k = 1; k <= 100; k++) {
                    int res = i * i + j * j + k * k + i * j + j * k + k * i;
                    if (res <= n) {
                        f[res]++;
                    }
                }
            }
        }

        for (int i = 1; i <= n; i++) {
            System.out.println(f[i]);
        }
    }
}


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

int main() {
	int N, K;
	cin >> N >> K;
	vector<double> p(N);
	for (int i = 0; i < N; i++) {
		double tmp;
		cin >> tmp;
		p.at(i) = ((1 + tmp) * tmp / 2) / tmp;
	}

	vector<double> DP(N - K + 1);
	for (int i = 0; i < K; i++) {
		DP.at(0) += p.at(i);
	}
	for (int i = 1; i < N - K + 1; i++) {
		DP.at(i) = DP.at(i - 1) - p.at(i - 1) + p.at(i + K - 1);
	}

  	printf("%.10lf\n",*max_element(DP.begin(), DP.end()));
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//arc067_c
//Nの階乗の約数
//素因数分解した値の組み合わせ 素因数が2^x,3^y,4^zの場合: (x+1)*(y+1)*(z+1)
int main(){
  ll N,res;
  cin >> N;
  vector <ll> a(N+1,1);

  ll cnt = 0;
  ll X;

  for(ll i = 2; i <=N; ++i)
  {
    X = i;
      for(ll j = 2; j <= N; ++j)
      {
        if(X == 1)break;
        //割れる間はずっと割る
        while(X % j == 0)
        {
          X /= j;
          a[j]++;
        }
      }
  }

  res = 1;
  REP(i,N+1)
  {
    res = res * a[i] % MOD;
  }

  cout << res << endl;

  return 0;
}

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

using ll = long long;
using P = pair<int, int>;

const int MAX = 2e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int ans[MAX];
bool used[MAX];

int main() {
  // 入力
  int N, x;
  cin >> N >> x;

  // N段目に1か2N-1（最小値と最大値）はありえない
  if (x == 1 || x == 2 * N - 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;

    // N == 2の時だけ別処理
    if (N == 2) {
      cout << 1 << endl << 2 << endl << 3 << endl;
    } else {
      ans[N] = x, used[x] = true;
      if (x == 2) {
        ans[N+1] = x + 1, used[x+1] = true;
        ans[N-1] = x - 1, used[x-1] = true;
        ans[N-2] = x + 2, used[x+2] = true;
      } else {
        ans[N+1] = x - 2, used[x-2] = true;
        ans[N-1] = x + 1, used[x+1] = true;
        ans[N-2] = x - 1, used[x-1] = true;
      }

      x = 1;
      for (int i = 0; i < 2 * N - 1; i++) {
        if (i == N || i == N + 1 || i == N - 1 || i == N - 2) continue;

        while (used[x]) x++;
        ans[i] = x, used[x] = true;
      }

      for (int i = 0; i < 2 * N - 1; i++) {
        cout << ans[i] << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  int n;
  cin>>n;
  ll a[3*n];
  for(i=0;i<3*n;i++) cin>>a[i];
  priority_queue<ll,vector<ll>,greater<ll> > pq;
  ll sum=0;
  for(i=0;i<n;i++){
    pq.push(a[i]);
    sum+=a[i];
  }
  VI v(3*n),w(3*n);
  v[n-1]=sum;
  for(i=n;i<=n+n;i++){
    sum+=a[i];
    pq.push(a[i]);
    sum-=pq.top();
    pq.pop();
    v[i]=sum;
  }
  priority_queue<ll> pq2;
  sum=0;
  for(i=0;i<n;i++){
    pq2.push(a[3*n-1-i]);
    sum+=a[3*n-1-i];
  }
  w[2*n]=sum;
  for(i=n;i<=n+n;i++){
    sum+=a[3*n-1-i];
    pq2.push(a[3*n-1-i]);
    sum-=pq2.top();
    pq2.pop();
    w[3*n-1-i]=sum;
  }
  ll ans=-INF;
  for(i=n-1;i<=2*n-1;i++){
    //cout<<v[i]<<" "<<w[i]<<endl;
    ans=max(ans,v[i]-w[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    char a[45] = "abcdefghijkmnlopqrstuvwxyz";
    char word;
    cin >> word;
    int i=0;
    for (i=0;i<26;i++){
        if(a[i] == word){
            cout << a[i+1];
        }
    }
    return 0;
}

Measured memory_bytes: 888
arr = gets.chomp.split('')
count = 0
until arr.empty?
  if arr.first == arr.last
    arr.pop
    arr.shift
  elsif arr.first == 'x'
    arr.shift
    count += 1
  elsif arr.last == 'x'
    arr.pop
    count += 1
  else
    puts -1
    exit(0)
  end
end
puts count

Measured memory_bytes: 9724
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

int n, m;
vector<int> edges[100005];
bool used[100005];
void solve() {
  cin >> n >> m;
  while(m--) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  used[1] = true;
  used[edges[1][0]] = true;
  deque<int> ret;
  ret.push_front(1);
  ret.push_back(edges[1][0]);
  while(true) {
    bool upd = false;
    for(int out: edges[ret.front()]) {
      if(!used[out]) {
        ret.push_front(out);
        used[out] = true;
        upd = true;
        break;
      }
    }
    if(upd) continue;
    for(int out: edges[ret.back()]) {
      if(!used[out]) {
        ret.push_back(out);
        used[out] = true;
        upd = true;
        break;
      }
    }
    if(upd) continue;
    break;
  }
  cout << ret.size() << "\n";
  int idx = 0;
  for(int out: ret) {
    cout << out;
    if(++idx == ret.size()) cout << "\n";
    else cout << " ";
  }
}

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


Measured memory_bytes: 6784
($n, $m) = split(/ /, <>);

while(<>){
	chomp;
	$_ =~ s/^\d+ //;
	for $i (split(/ /, $_)){
		$f{$i}++;
	}
}

$cnt = 0;
foreach (keys %f){
	$cnt++ if($f{$_} == $n);
}

print "$cnt\n";


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

char dig[5]="ixcm";

int toInt(string& num){
    int ans=0,coef=1;
    for(unsigned int i=0; i<num.length(); i++){
        if('2'<=num[i] && num[i]<='9'){
            coef=num[i]-'0';
        }else{
            for(int j=0; j<4; j++){
                if(dig[j]==num[i]){
                    ans+=coef*pow(10,j);
                }
            }
            coef=1;
        }
    }
    return ans;
}           

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

    for(int i=0; i<n; i++){
        int ans;
        string strA,strB;
        cin >> strA >> strB;
        ans = toInt(strA) + toInt(strB);

        for(int i=3; i>=0; i--){
            int d = ans/pow(10,i);
            if(d == 0) continue;
            else if(d !=1) cout << d;
            cout << dig[i];
            ans -= d*pow(10,i);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3324
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  b, c, d, e, X, Y;
  //  double  c;
  long long  A[100003]={};
  int  B[100003]={};
  int  C[100003]={};

  int  flag[103]={};

//  long long  a, b, c, d, X, Y;
  char s[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
//  int flag=0;
  int tmp=0;
//  int min=1000000;
  long long min=100000001;
  int len=0;
  int cnt=0;
  int num=0;
  double ans=1000;
  int max=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
    scanf("%s", &s);
/*  
  for(i=0;i<a;i++){
//    printf("%lld ",A[i]);
    if(A[i]==1) {
      printf("1\n");
      return 0;
    }
  }    
*/
  s[c-1]=s[c-1]+32;
  printf("%s\n",s);

  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int i = s.nextInt();
		if(i>0&&i<1000){
			System.out.println("ABC");
		}else if(i>=1000&&i<1999){
			System.out.println("ABD");
		}
	}
}

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

int main(void)
{

    long li_inputNum;
    int i_baseNum;
    float d_displayNum = 1;

    scanf("%ld%d", &li_inputNum, &i_baseNum);

    while (pow(i_baseNum, d_displayNum) <= li_inputNum)
    {
        d_displayNum += 1.0;
    }

    long li_displayNum = d_displayNum;

    printf("%ld", li_displayNum);

}

Measured memory_bytes: 128
package main 

import (
  "fmt"
  "sort"
)

func main() {
  var a, b, c int
  fmt.Scan(&a, &b, &c)
  
  val := []int{a, b, c}
  sort.Sort(sort.IntSlice(val))
  
  fmt.Println(val[2]- val[0])
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <map>
#include <cstdio>
#include <cmath>
#include <unordered_map>
#include <iomanip>
using namespace std;

int main(){
  int A, B ;
  cin >> A >> B;
  if (A*B == 2){
    cout << 3 << endl;
  }
  else if (A*B == 3){
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
}

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

int main() {
  string S, front = "", back = "";
  ll Q;
  cin >> S >> Q;
  bool flg = true;
  ll cnt = 0;
  for (ll i = 0; i < Q; ++i) {
    ll ti;
    cin >> ti;
    if (ti == 1) {
      ++cnt;
      flg = !flg;
    } else if (ti == 2) {
      ll fi;
      char ci;
      cin >> fi >> ci;
      if ((fi == 1 && flg) || (fi == 2 && !flg)) {
        front += ci;
      } else if ((fi == 2 && flg) || (fi == 1 && !flg)) {
        back += ci;
      }
    }
  }
  reverse(front.begin(), front.end());
  S = front + S + back;
  if (cnt % 2 == 1) {
    reverse(S.begin(), S.end());
  }
  cout << S << endl;
}

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

int main(){
  int x,y;
  cin >> x >> y;

  for (int i = 0; i <= x; i++)
  {
    int j = x-i;
    if(2*i + 4*j == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  puts("No");  
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int r;
    cin >> r;
    print(3 * r * r);
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2699.cc: Koto Municipal Subway
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_D = 100;
const int MAX_E = 100;
const double DINF = 1e60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

/* main */

int main() {
  for (;;) {
    int d, e;
    scanf("%d%d", &d, &e);
    if (d == 0)  break;

    double mind = DINF;
    for (int x = 0, y = d; x <= y; x++, y--) {
      double d = abs(sqrt((double)(x * x + y * y)) - e);
      if (mind > d) mind = d;
    }

    printf("%.6lf\n", mind);
  }
  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<stdio.h>
#include<unordered_map>
#include<map>
#include<stack>
#include<queue>
#include<iterator>
#include<functional>
#include<climits>
#include<set>
#include<utility>

#define ll long long
#define MOD 1000000007

using namespace std;

void solve () {
	string s,t;
	cin >> s >> t;
	int sLen,tLen;
	sLen = s.length(),tLen = t.length();
	int dp[sLen+1][tLen+1];
	memset(dp,0,sizeof(dp));
	// int ans = 0;
	for (int i = 1;i <= sLen;++i) {
		for (int j = 1;j <= tLen;++j) {
			if (s[i-1] == t[j-1]) {
				dp[i][j] = dp[i-1][j-1]+1;
			} else {
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	string ans = "";
	int i = sLen;
	int j = tLen;
	while (i > 0 && j > 0) {
		if (s[i-1] == t[j-1]) {
			ans += s[i-1];
			--i,--j;
		} else {
			if (dp[i-1][j] > dp[i][j-1]) {
				--i;
			} else {
				--j;
			}
		}
	}
	reverse(ans.begin(),ans.end());
	cout << ans << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}



Measured memory_bytes: 35456