akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

struct RBST{
    #define RBST_INF INT_MAX

    struct node{
        node *lch,*rch;
        int val,mi,cnt;
        node(int val):val(val),mi(val),cnt(1){
            lch=rch=NULL;
        }
    };

    RBST():root(NULL){srand(time(NULL));}
    node *root;

    inline int count(node *t){return !t?0:t->cnt;}
    inline int mini(node *t){return !t?RBST_INF:t->mi;}

    node *update(node *t){
        if(!t)return t;
        t->cnt=count(t->lch)+count(t->rch)+1;
        t->mi=min(min(mini(t->lch),mini(t->rch)),t->val);
        return t;
    }

    node *merge(node *a,node *b){
        if(!a)return b;
        if(!b)return a;

        if(rand()%(count(a)+count(b))<count(a)){
            a->rch=merge(a->rch,b);
            return update(a);
        }
        else{
            b->lch=merge(a,b->lch);
            return update(b);
        }
    }

    pair<node *,node *>split(node *t,int k){
        if(!t)return make_pair(t,t);
        if(k<=count(t->lch)){
            pair<node *,node *>s=split(t->lch,k);
            t->lch=s.second;
            return make_pair(s.first,update(t));
        }
        else{
            pair<node *,node *>s=split(t->rch,k-count(t->lch)-1);
            t->rch=s.first;
            return make_pair(update(t),s.second);
        }
    }

    void insert(int k,int val){
        pair<node *,node *>s=split(root,k);
        root=merge(s.first,new node(val));
        root=merge(root,s.second);
    }

    void erase(int k){
        pair<node *,node *>s1,s2;
        s1=split(root,k);
        s2=split(s1.second,1);

        root=merge(s1.first,s2.second);
    }

    int getMin(int l,int r){
        pair<node *,node *>s1,s2;
        int ret;

        s1=split(root,l);
        s2=split(s1.second,r-l);
        ret=mini(s2.first);
        root=merge(s1.first,s2.first);
        root=merge(root,s2.second);
        return ret;
    }

    void update(int k,int val){
        erase(k);
        insert(k,val);
    }

    void shift(int l,int r){
        pair<node *,node *>s1,s2,s3;

        s1=split(root,l);
        s2=split(s1.second,r-l-1);
        s3=split(s2.second,1);

        root=merge(s1.first,s3.first);
        root=merge(root,s2.first);
        root=merge(root,s3.second);
    }
};

int N,Q;
RBST T;

int main(){
    scanf("%d%d",&N,&Q);
    for(int i=0;i<N;i++){
        int a;
        scanf("%d",&a);
        T.insert(i,a);
    }

    while(Q--){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        if(x==0){
            T.shift(y,z+1);
        }
        else if(x==1){
            printf("%d\n",T.getMin(y,z+1));
        }
        else{
            T.update(y,z);
        }
    }

    return 0;
}

Measured memory_bytes: 13704
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;

const int N = 1e6 + 6;
int x,n;
int fix[N];
int answer,dis =  1e9;
int main(){

        cin >> x >> n;
        for(int i = 1; i <= n; i++){
                int a;
                cin >> a;
                fix[a] = 1;
        }

        for(int i = 0; i <= 101; i++){
                if(fix[i] == 1) continue;
                if(dis > abs(x-i)){
                        answer = i;
                        dis = abs(x-i);
                }
        }

        cout << answer << endl;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <math.h>
int main(void)
{
    int A[100][100];
    int B[100];
    int C[100]={0};
    int i,j,n,m;
    
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++){ 
        for(j=0; j<m; j++){
            scanf("%d",&A[i][j]);
        }
    }  
        for(j=0; j<m; j++){
            scanf("%d",&B[j]);
        }
        for(i=0; i<n; i++){
            for(j=0; j<m; j++){
                C[i]+=A[i][j]*B[j];
            }
        }
      for(i=0; i<n; i++){
          printf("%d\n",C[i]);
      }  
    
   
    
    return 0;
    
}


Measured memory_bytes: 2104
import java.io.*;
import java.util.*;
public class Main {
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}
		return ans;
	}
	static long[] splitL() throws IOException
	{
		String[] cmd=br.readLine().split(" ");
		long[] ans=new long[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Long.valueOf(cmd[i]);
		}
		return ans;
	}
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		br=new BufferedReader(new InputStreamReader(System.in));
		int[]ar=split();
		int n=ar[0];
		int k=ar[1];
		int[] arr=split();
		boolean[]dp=new boolean[k+1];
		Arrays.fill(dp,false);
		for(int i=1;i<=k;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i-arr[j]<0)
					break;
				if(!dp[i-arr[j]])
				{
					dp[i]=true;
					break;
				}
			}
		}
		System.out.println(dp[k]?"First":"Second");
	}
}


Measured memory_bytes: 33740
#include <iostream>
#include <map>
#include <algorithm>
#include <string>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;

int column[2][2002][2002];//縦
int row[2][2002][2002];//横
int H, W;

string str[2001];

int main(void) {

	cin >> H >> W;

	for (int i = 0; i < H; i++)
		cin >> str[i];


	for (int i = 0; i < H; i++) {
		for (int j = 1; j <= W; j++) {
			if (str[i][j - 1] == '#') {
				row[0][i][j] = j;
			}
			else {
				row[0][i][j] = row[0][i][j - 1];
			}
		}

		row[1][i][W + 1] = W + 1;
		for (int j = W; j >= 1; j--) {
			if (str[i][j - 1] == '#') {
				row[1][i][j] = j;
			}
			else {
				row[1][i][j] = row[1][i][j + 1];
			}
		}
	}


	for (int j = 0; j < W; j++) {
		for (int i = 1; i <= H; i++) {
			if (str[i - 1][j] == '#') {
				column[0][i][j] = i;
			}
			else {
				column[0][i][j] = column[0][i - 1][j];
			}
		}
		column[1][H + 1][j] = H + 1;
		for (int i = H; i >= 1; i--) {
			if (str[i - 1][j] == '#') {
				column[1][i][j] = i;
			}
			else {
				column[1][i][j] = column[1][i + 1][j];
			}
		}
	}

	int ans = 0;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (str[i][j] == '#') continue;
			int c = column[1][i + 1][j] - column[0][i + 1][j] - 1;
			int r = row[1][i][j + 1] - row[0][i][j + 1] - 1;
			CHMAX(ans, c + r - 1);
		}
	}


	COUT(ans);

	return 0;
}

Measured memory_bytes: 66944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",n%2==0?n:n*2);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int gcd(int &a, int &b){
  if (a == 0 || b == 0){
    return max(a, b);
  } else {
    int c = min(a, b);
    int d = max(a, b) % min(a, b);
    return gcd(c, d);
  }
}
int main()
{
  int N;
  cin >> N;
  vector<int> A(N+1);
  A.at(0) = 0;
  for (int i = 1; i <= N; i++){
    cin >> A.at(i);
  }
  vector<int> L(N+2);
  L.at(1) = 0;
  vector<int> R(N+2);
  R.at(N+1) = 0;
  for (int i = 1; i <= N; i++){
    L.at(i+1) = gcd(L.at(i), A.at(i));
    int j = N - i + 1;
    R.at(j) = gcd(R.at(j + 1) ,A.at(j));
  }
  int ans = 0;
  for (int i = 1; i <= N; i++){
    ans = max(ans, gcd(L.at(i), R.at(i+1)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<complex>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 320500
#define inf (int)1e9
#define ll long long
#define mm 1000000007
#define eps 1e-13
#define pb push_back
#define low(x) x&(-x)
using namespace std;

ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int a[805],b[805];
int matl[405],lnk[405],matr[405],q[2005000],visb[405],lk[405],slack[405];
int mp[10000005],pmp[10000005],vis[10000005],pri[1000500];
int ans,ptot,n,m,idx,la,lb;
bool fd(int x){
	rep(j,1,lb){
		if (!visb[j]&&pmp[abs(a[x]-b[j])]){
			visb[j]=1;
			if (lk[j]==-1||fd(lk[j])){
				lk[j]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	n=read();
	int mxn=10000001;
	int x;
	rep(i,1,n) x=read(),mp[x]=1;
	//rep(i,1,n) if (mp[a[i]-1]==mp[a[i]]) b[i]=0; else b[i]=1;
	rep(i,0,x) if (mp[i]!=mp[i+1]) {
		if (i%2==0) a[++la]=i; else b[++lb]=i;
	}
	rep(i,2,mxn) {
		if (!vis[i]) pri[++ptot]=i,vis[i]=1,pmp[i]=1;
		rep(j,1,ptot) {
			if (i*pri[j]>mxn) break;
			vis[i*pri[j]]=1;
		}
	}
	clr(lk,-1);
	int ans=0;
	rep(i,1,la) {
		clr(visb,0);
		if (fd(i)) ans++;
	}
	la-=ans;
	lb-=ans;
	if (la%2==1) ans+=3;
	ans+=la/2*2+lb/2*2;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 123136
#include<stdio.h>
main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a < b){
    printf("a < b\n");
  }
  if(a > b){
    printf("a > b\n");
  }
  if(a == b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

class Dict {
private:
  set<string> set_;

public:
  Dict() :
    set_(set<string>())
  {}

  void insert(const string& val) {
    set_.insert(val);
  }

  bool find(const string& val) const {
    auto result = set_.find(val);
    return result == set_.end() ? false : true;
  }
};

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

  Dict dict{};
  for(int i = 0; i < n; i++) {
    string command, value;
    cin >> command >> value;

    if(command == "insert") {
      dict.insert(value);
    } else if(command == "find") {
      if(dict.find(value)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
}



Measured memory_bytes: 32176
n = int(input())
a = list(map(int,input().split()))
sss = 0
for i in range(n):
    sss=sss + a[i]
ppp = 0
qqq = abs(sss - 2 * a[0])
for i in range(n-1):
    ppp=ppp + a[i]
    qo = abs(sss-2*ppp)
    if qqq > qo:
        qqq=qo
        
print(qqq)

Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C;
cin >> A>>B>>C;
 
if(A < C && C < B){
    cout << "Yes";
}else if(A > C && C > B){
    cout << "Yes";
}else{cout << "No";}
  

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll s;
int main(){
    scanf("%lld",&s);
    ll x,y,a,b;
    ll k=sqrt(s);
    ll m=k*k;
    if(m==s){
        printf("%lld %lld %lld %lld %lld %lld",0,0,0,k,k,0);
    }
    else {
        if(m+k>s)y=k+1,a=k-1;
        if(m+k<=s)y=k+1,a=k;
        b=s-a*y;
        x=a+1;
        printf("%lld %lld %lld %lld %lld %lld",a,0,0,b,x,y);
    }
    
    return 0;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

char h[205][205];

int main(){
	for(int i = 1;i <= 200;i++){
		for(int j = 1;j <= 200;j++){
			h[i][j] = '#';
		}
	}
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i = 2;i <= 2 + n - 1;i++){
		for(int j = 2;j <= 2 + m - 1;j++){
			char x;
			scanf(" %c",&x);
			h[i][j] = x;
		}
	}
	for(int i = 1;i <= n + 2;i++){
		for(int j = 1;j <= m + 2;j++){
			if(j == m + 2) printf("%c\n",h[i][j]);
			else printf("%c",h[i][j]);
		}
	}
}

Measured memory_bytes: 256
use std::io::{stdout, Write, BufWriter};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        p: [usize; n],
    }

    let iter = p.iter();
    let iter2 = p.iter();
    let max = iter.max().unwrap();
    let sum : usize = iter2.sum();

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    writeln!(out, "{}", sum - max / 2).unwrap();
}

Measured memory_bytes: 4352
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

int main() {
  std::ios::sync_with_stdio(false);
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  if (y < x) {
    swap(x, y);
    swap(a, b);
  }

  cout << min(x * a + x * b, 2 * x * c) + min((y - x) * b, 2 * (y - x) * c) << endl;
  return 0;
}


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

int main(){
	int n,i,j,tmp = 0,ans = 0;
	cin >> n;
	int h[n];
	for(i = 0; i < n; i++){
		cin >> h[i];
	}

	for(j = 0; j < n-1; j++){
		if(h[j] >= h[j+1]){
			tmp++;
		}
		else if(h[j] < h[j+1]){
			if(tmp > ans){
				ans = tmp;
			}
			tmp = 0;
		}
	}
	if(tmp > ans){
		ans = tmp;
	}
	tmp = 0;

	cout << ans;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 1000010     
                    
int main(){
    int n, m, h[N], ma[N];
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> h[i];
        ma[i] = 0;
    }

    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        ma[a] = max(ma[a], h[b]);
        ma[b] = max(ma[b], h[a]);
    }

    int ans = 0;

    for(int i = 1; i <= n; i++){
        ans += h[i] > ma[i];
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4436
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main(void)
{
    string a;
    while(cin>>a)
    {
        int  joi_ans = 0,ioi_ans = 0;
        for(int i = 0;i < a.size();i++)
        {
            if("JOI" == a.substr(i,3))
            {
                joi_ans++;
            }
            else if("IOI" == a.substr(i,3))
            {
                ioi_ans++;
            }
        }

        printf("%d\n%d\n",joi_ans,ioi_ans);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
const int N = 100 + 7;
int n, a[N], f[N];

bool ok() {
  if (a[n] % 2 == 0) {
    if (a[1] != a[n] / 2) {
      return 0;
    }
    if (a[2] == a[1]) {
      return 0;
    }
  } else {
    if (a[1] != (a[n] + 1) / 2 || a[2] != (a[n] + 1) / 2) {
      return 0;
    }
    if (a[3] == (a[n] + 1) / 2) {
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    f[a[i]]++;
  }
  for (int x = a[1] + 1; x <= a[n]; x++) {
    if (f[x] < 2) {
      return 0;
    }
  }
  return 1;
}

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

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  if (ok()) {
    cout << "Possible\n";
  } else {
    cout << "Impossible\n";
  }
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt = {}
for ai in a:
    if ai in cnt:
        cnt[ai] += 1
    else:
        cnt[ai] = 1
ls = []
for ai, c in cnt.items():
    ls.append((c, ai))
ls.sort()
ans = 0
for i in range(len(ls) - k):
    ans += ls[i][0]
print(ans)

Measured memory_bytes: 102216
let () =
  let a, b, c, x, y = Scanf.scanf "%d %d %d %d %d\n" (fun a b c d e -> a, b, c, d, e) in

  let a1 =
    if x < y
    then c * 2 * x + b * (y - x)
    else c * 2 * y + a * (x - y)
  in
  let a2 = a * x + b * y in
  let a3 = c * 2 * (if x > y then x else y) in

  print_endline (string_of_int (min a1 (min a2 a3)))



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

int n;
int a[234567];
int pos[234567];

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int father = -1;
    long long cnt = 0;
    for (int i = n; i >= 1; i--) {
        father -= 1;
        if (father == a[i]) {
            continue;
        } else if (father > a[i]) {
            cout << -1 << endl;
            return 0;
        } 
        if (i <= a[i]) {
            cout << -1 << endl;
            return 0;
        }
        cnt += a[i];
        father = a[i];
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> t(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int p, x;
		cin >> p >> x;
		cout << sum-t[p-1]+x << endl;
	}
	return 0;
}

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

class Program
{
    static void Main()
    {
        var mb = new ModBinom(2000);
        var NK = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NK[0];
        var K = NK[1];
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        for (int i = 1; i <= K; i++)
        {
            WriteLine(mb.Binom(K - 1, i - 1) * mb.Binom(N - K + 1, i) % ((int)1e9 + 7));
        }
        Out.Flush();
    }
}

class ModBinom
{
    long[] fac;
    long[] finv;
    int mod;

    public ModBinom(int N, int p = (int)1e9 + 7)//N < p  O(N)
    {
        N++;

        fac = new long[N];
        long[] inv = new long[N];
        finv = new long[N];

        fac[0] = fac[1] = 1;
        inv[1] = 1;
        finv[0] = finv[1] = 1;

        for (int i = 2; i < fac.Length; i++)
        {
            fac[i] = fac[i - 1] * i % p;
            inv[i] = p - inv[p % i] * (p / i) % p;
            finv[i] = finv[i - 1] * inv[i] % p;
        }

        mod = p;
    }

    [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
    public long Binom(int n, int k)// O(1)
    {
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
        return fac[n] * finv[k] % mod * finv[n - k] % mod;
    }
}


Measured memory_bytes: 13340
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a > b){
      System.out.println("a > b");
    }else if(a == b){
      System.out.println("a == b");
    }else{
      System.out.println("a < b");
    }
  }
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};


int main(){
  int H,W;
  cin >> H >> W;
  vector<string> s(H); rep(h, H) cin >> s[h];

  vvi dist(H,vi(W,-1));
  queue<pii> q;
  dist[0][0] = 1;
  q.push(mp(0,0));

  while (!q.empty()) {
    pii p = q.front(); q.pop();
    int h = p.first;
    int w = p.second;
    rep(dir, 4){
      int nh = h + dh[dir];
      int nw = w + dw[dir];
      if(nh < 0 || nh == H || nw < 0 || nw == W) continue;
      if(dist[nh][nw] != -1 || s[nh][nw] == '#') continue;
      dist[nh][nw] = dist[h][w] + 1;
      q.push(mp(nh,nw));
    }
  }

  int cnt = 0;
  rep(h, H) rep(w, W) if(s[h][w] == '.') cnt++;
  int ans;
  if(dist[H-1][W-1] == -1) ans = -1;
  else ans = cnt - dist[H-1][W-1];

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

long long gcd(long long a, long long b){
    if(b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    long long temp = gcd(a, b);
    return a * b / temp;
}

long long N(long long a, long long upper){
    return upper / a;
}

long long N2(long long a, long long b, long long upper){
    return N(a, upper) + N(b, upper) - N(lcm(a, b), upper);
}

int main(){

    long long A, B, C, D;
    cin >> A >> B >> C >> D;

    cout << (B - N2(C, D, B)) - ((A - 1) - N2(C, D, A - 1)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int n;
int a[20010] = {}, b[20010] = {};
int p[20010];

void view(){
	for(int i = 1;i <= n;i++){
		if(i != n) cout << a[i] << " ";
		else cout << a[i];
	}
	cout << endl;
	for(int i = 1;i <= n;i++){
		if(i != n) cout << b[i] << " ";
		else cout << b[i];
	}
	cout << endl;
}

int main() {
	cin >> n;
	int in;
	REP(i, n){
		cin >> in;
		p[i] = in;
	}
	// sort(p, p + n);

	for(int i = 1;i <= n;i++){
		a[i] = i;
		b[i] = n - (i - 1);
	}


	int before = -1;
	int plus = n;
	REP(i, n){
		int index = p[i];
		for(int i = index + 1;i <= n;i++){
			a[i] += plus;
		}
		for(int i = index - 1;i >= 0;i--){
			b[i] += plus;
		}
		plus--;
	}

	view();
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
typedef long long ll;
const int mod = 1e9 + 7;

int a[N];
map<int, int>mp;

int find(int x) {
	if (a[x] == x)
		return x;
	return a[x] = find(a[x]);
}

void add(int x, int y) {
	int px = find(x);
	int py = find(y);
	if (px != py)
		a[px] = py;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	mp.clear();
	for (int i = 1; i <= n; i++)
		a[i] = i;
	for (int i = 1; i <= m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		add(x, y);
	}
	for (int i = 1; i <= n; i++)
		find(i);
	/*for (int i = 1; i <= n; i++)
		cout << i << ' ' << a[i] << endl;*/
	for (int i = 1; i <= n; i++)
		mp[a[i]]++;
	int ans = 0;
	map<int, int>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		ans = max(ans, it->second);
		//cout << "mp:" << it->first << ' ' << it->second << endl;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 13816
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
//	for(int i=0;i<n;i++) cout<<a[i];
	int sum=0;
	for(int i=n-1;i>1;i--)
	{
		for(int j=i-1;j>0;j--)
		{
			if(a[i]==a[j]) continue;
			for(int k=j-1;k>=0;k--)
			{
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] < (a[k] + a[j])) 
				{
					sum++;
				}
				
				if(a[k]!=a[i] and a[k]!=a[j] and a[i] >= (a[k] + a[j])) 
				{
					break;
				}
				
			}
		}
	}
	
	cout<<sum;
}


Measured memory_bytes: 3180
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll a[400];
ll s[400];
ll m[400][400];

void init()
{
}

ll rec(int l, int r)
{
    if(l >= r) return 0;
    if(m[l][r] != -1) return m[l][r];
    ll ans = LINF;
    FOR(i, l, r){
        ans = min(ans, rec(l, i) + rec(i+1, r));
    }
    return m[l][r] = ans + s[r] - (l > 0 ? s[l-1] : 0);
}
#if 0
ll rec(int l, int r)
{
    if(l >= r) return 0;
    int mid = l;
    ll plsum, prsum;
    if(r - l > 1){
        FOR(i, l, r+1){
            ll lsum = s[i] - (l > 0 ? s[l-1] : 0);
            ll rsum = s[r] - s[i];
            if(lsum <= rsum){
                mid = i;
                plsum = lsum;
                prsum = rsum;
            }else{
                if(abs(rsum - lsum) <= abs(prsum - plsum)){
                    mid = i;
                }
                break;
            }
        }
    }
    return rec(l, mid) + rec(mid+1, r) + s[r] - (l > 0 ? s[l-1] : 0);
}
#endif

void solve()
{
    REP(i, N) s[i] = a[i] + (i > 0 ? s[i-1] : 0);
    REP(i, N) REP(j, N) m[i][j] = -1;
    cout << rec(0, N-1) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
bool isacgt(char c){
    return (
        c=='A' || c=='C' || c=='G' || c=='T'
    );
}

int func(int n){
    int ans;
    if(n%2==0){
        ans = n/2;
    }else{
        ans = 3*n+1; 
    }
    
    return ans;
}

int main() {

    int s;
    cin >> s;

    int m = 1000000; //10e6
    vector<int> a(m);

    int ans = 0;
    bool forfinish = false;
    rep(i,m){
        if(i==0){
            a[i] = s;
        }else{
            a[i] = func(a[i-1]);
        }
        rep(j,i){
            if(a[j]==a[i]){
                ans = i+1;
                forfinish = true;
                break;
            }
        }
        if(forfinish){
            break;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 7208
#include <iostream>

using namespace std;

string s;
long n;

int main()
{
    int min = 0;
    int black = 0;
    int white = 0;
    cin >> n;
    cin >> s;
    int tmp = 0;

    for (char c: s)
    {
        if (c == '.')
            white++;
    }
    min = white;

    for (char c: s)
    {
        if (c == '.')
        {
            white--;
        }
        else
        {
            black++;
        }
        tmp = black + white;
        if (min > tmp)
            min = tmp;
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 640
#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>;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];

  vector<bool> is_square(1000000, false);
  rep(i, 1000) is_square[i*i] = true;

  int ans = 0;
  rep(i, n) for (int j = i+1; j < n; ++j) {
    int dist = 0;
    rep(k, d) dist += pow(x[i][k] - x[j][k], 2);
    if (is_square[dist]) ++ans;
  }
  cout << ans << endl;
  return 0;
}

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

struct cood{
    double x,y;
};

void koch(int d,cood p1,cood p2){
    if(d==0)return;
    
    cood s,t,u;
    
    s.x=(2.0*p1.x+1.0*p2.x)/3;
    s.y=(2.0*p1.y+1.0*p2.y)/3;
    t.x=(1.0*p1.x+2.0*p2.x)/3;
    t.y=(1.0*p1.y+2.0*p2.y)/3;
    u.x=(t.x-s.x)*0.5-(t.y-s.y)*sqrt(3.0)*0.5+s.x;
    u.y=(t.x-s.x)*sqrt(3.0)*0.5+(t.y-s.y)*0.5+s.y;
    
    koch(d-1,p1,s);
    cout<<s.x<<" "<<s.y<<endl;
    koch(d-1,s,u);
    cout<<u.x<<" "<<u.y<<endl;
    koch(d-1,u,t);
    cout<<t.x<<" "<<t.y<<endl;
    koch(d-1,t,p2);
}
    


int main(){
    cout<<setprecision(8);
    int n;cin>>n;
    
    cood p1,p2;
    p1.x=0.0;
    p1.y=0.0;
    p2.x=100.0;
    p2.y=0.0;
    
    cout<<p1.x<<" "<<p1.y<<endl;
    koch(n,p1,p2);
    cout<<p2.x<<" "<<p2.y<<endl;
    
    return 0;
    
}





Measured memory_bytes: 3288
import math
n = int(input())
pli = list(map(int,input().split()))
qli = list(map(int,input().split()))
a,b = 0,0
for i in range(n-1):
    a += (pli[i]-1)*(math.factorial(n-1-i))
    for j in range(n-1-i):
        if pli[j+i+1] > pli[i]:
            pli[j+i+1] -= 1
for i in range(n-1):
    b += (qli[i]-1)*(math.factorial(n-1-i))
    for j in range(n-1-i):
        if qli[j+i+1] > qli[i]:
            qli[j+i+1] -= 1
print(abs(a-b))

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        v[i] -= c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] > 0) {
            ans += v[i];
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N,A,i;
	scanf("%d",&N);
	scanf("%d",&A);
	i=N%500;
	
	if(i<=A)
		printf("\nYes\n\n");
	else 
		printf("\nNo\n\n");
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {int p,l,r;} Node;
Node T[MAX];
int n;

void preParse(int u){
    if(u==NIL) return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u){
    if(u==NIL) return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

void postParse(int u){
    if(u==NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;

    scanf("%d",&n);
    for(i=0;i<n;i++) T[i].p = NIL;

    for(i=0;i<n;i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l!=NIL) T[l].p = v;
        if (r!=NIL) T[r].p = v;
    }

    for(i=0;i<n;i++) if(T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}



Measured memory_bytes: 2132
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <tuple>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder{
    void judge_outer(bool judge_exp,string ok = "Yes",string ng = "No"){
        if(judge_exp){
            cout << ok << endl;
        }else{
            cout << ng << endl;
        }
    }
    
    int ncr(int left,int right){
        right = min(left - right,right);
        int ans =1;
        for(int i=1;i<=right;i++){
            ans = ans * (left-right+i)/i;
        }
        return ans;
    }
}

using namespace atcoder;

int main(void){
    array<int,static_cast<int>('z')+2> c;
    c.fill(900);
    int roop;
    char m;
    cin >> roop;
    string stk;
    int ac;
    for(int i=0;i<roop;i++){
        cin >> stk;
        sort(stk.begin(),stk.end());
        int j=0;
        
        for(int search=static_cast<int>('a');search<=static_cast<int>('z');search++){
            m=static_cast<char>(search);
            ac = count(stk.begin()+j,stk.end(),m);
            c[search] = min(ac,c[search]);
            j+=ac;
        }
    }
    
    for(int i=static_cast<int>('a');i<=static_cast<int>('z');i++){
        for(int j=0;j<c[i];j++){
            
        if(c[i]==900)break;
        cout << static_cast<char>(i);
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  ulong a[200000];
  cin >> n;

  uint l;
  ulong tmp_sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> l;
    tmp_sum += l;
    a[i] = tmp_sum;
  }

  ulong val = ULONG_MAX, tmp_max, tmp_min;
  int l_pos = 0, r_pos = 2;
  ulong ll_val, lr_val, rl_val, rr_val;
  ulong p,q,r,s;
  for (int c_pos = 1; c_pos < n-2; c_pos++)
  {
    ulong l_diff = ULONG_MAX, r_diff = ULONG_MAX;
    while (1)
    {
      ll_val = a[l_pos];
      lr_val = a[c_pos] - a[l_pos];
      ulong tmp_l_diff = max(ll_val,lr_val) - min(ll_val,lr_val);
      if (tmp_l_diff < l_diff)
      {
        l_diff = tmp_l_diff;
      }
      else
      {
        l_pos--;
        break;
      }
      l_pos++;
    }
    if (r_pos == c_pos) r_pos++;
    while (1)
    {
      rl_val = a[r_pos] - a[c_pos];
      rr_val = a[n-1] - a[r_pos];
      ulong tmp_r_diff = max(rl_val,rr_val) - min(rl_val,rr_val);
      if (tmp_r_diff < r_diff)
      {
        r_diff = tmp_r_diff;
      }
      else
      {
        r_pos--;
        break;
      }
      r_pos++;
    }
    p = a[l_pos];
    q = a[c_pos] - a[l_pos];
    r = a[r_pos] - a[c_pos];
    s = a[n-1] - a[r_pos];
    tmp_max = max(p,max(q,max(r,s)));
    tmp_min = min(p,min(q,min(r,s)));
    if (val > tmp_max - tmp_min) val = tmp_max - tmp_min;
  }

  cout << val << "\n";

}


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

using namespace std;


#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d %d", &a, &b)
#define siii(a, b, c) scanf("%d %d %d", &a, &b, &c)

#define sl(a) scanf("%I64d", &a)
#define sll(a, b) scanf("%I64d %I64d", &a, &b)
#define slll(a, b, c) scanf("%I64d %I64d %I64d", &a, &b, &c)

#define outi(a) printf("%d\n", a)
#define outii(a, b) printf("%d %d\n", a, b)
#define outiii(a, b, c) printf("%d %d %d\n", a, b, c)

#define outl(a) printf("%I64d\n", a)
#define outll(a, b) printf("%I64d %I64d\n", a, b)
#define outlll(a, b, c) printf("%I64d %I64d %I64d\n", a, b, c)

#define cel(n, k) ((n-1)/k+1)
#define sets(a) memset(a, -1, sizeof(a))
#define clr(a) memset(a, 0, sizeof(a))


#define fr(i, n) for(ll i=0; i<n;i++)
#define fr1(i, n) for(ll i=1; i<=n;i++) 

#define readf(f) freopen(f, "r", stdin)
#define writef(f) freopen(f, "w", stdout)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define nl "\n"

template< class T > T sq(T x) { return x * x; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

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


int main()
{

	string s;

	int n, l, v;

	cin>>n;
	cin.ignore(0);
	cin>>s;
	
	

	l = s.length();

	fr(i,l){
		v = ((int)s[i] + n);

		if(v>90)
			v = v%91 + 65;
		cout<<(char)v;
		
	}
	cout<<nl;

    return 0;
}


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

 int main() {
   int N, ans = 0;
   cin >> N;
   vector<int> p(N + 1);

   rep(i, N) cin >> p.at(i + 1);

   for (int i = 1; i <= N; i++) {
     if (p.at(i) == i) {
       if (i == 1) {
         ans++;
         swap(p.at(1), p.at(2));
       }
       else if (i == N) {
         ans++;
         swap(p.at(N - 1), p.at(N));
       }
       else {
         if (p.at(i + 1) == i + 1) {
           ans++;
           swap(p.at(i), p.at(i + 1));
         }
         else {
           swap(p.at(i - 1), p.at(i));
           ans++;
         }
       }
     }
   }
   cout << ans << endl;
 }


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

int main()
{
    int N;
    string s;
    cin >> N >> s;
    for (int i = 0; i < s.size(); i++)
    {
        char c;
        c = char(s[i]);
        c += N;
        if (c > 90) c -= 26;
        cout << c;
    }
    cout << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

typedef double D;
typedef complex<D> P;

#define X real()
#define Y imag()

const D eps=1e-8;
const D inf=1e12;
const D PI=acos(-1);

D cross(P a,P b){ return (conj(a)*b).Y; }

vector<P> convex_hull(vector<P>& ps){
  sort(ps.begin(),ps.end(),[](const P& a,const P& b){ return a.X==b.X?a.Y<b.Y:a.X<b.X; });
  int n=ps.size();
  int k=0;
  vector<P> qs(n*2);
  for(int i=0;i<n;i++){
    while(k>1&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}
D calc_area(vector<P>& poly) {
  D res = 0;
  int sz=poly.size();
  for (int i = 0; i < sz; i++){
    res += cross(poly[i], poly[(i+1)%sz]);
  }
  return res/2.0;
}

bool judge(vector<P>& ps){
  D crt=-1;
  rep(i,ps.size())if(i>=2){
    vector<P> a;
    rep(j,i+1)a.push_back(ps[j]);
    a=convex_hull(a);
    D nxt=calc_area(a);
    if(abs(crt-nxt)<eps)return false;
    crt=nxt;
  }
  return true;
}

int main(){
  int n;
  vector<P> ps;
  cin>>n;
  rep(i,n){
    int x,y;
    cin>>x>>y;
    ps.push_back(P(x,y));
  }
  bool ok=true;
  if(!judge(ps))ok=false;
  reverse(all(ps));
  if(!judge(ps))ok=false;
  if(ok)cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}



Measured memory_bytes: 3196
/*
* @Author: Nazrul Islam
* @Date:   2020-09-19 13:46:14
* @Last Modified by:   Nazrul Islam
* @Last Modified time: 2020-09-19 13:46:50
*/

#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll; 
typedef double dd;
typedef vector<int> vi;
typedef vector<char> vc;
typedef list<int> li;
typedef set<int> si;
typedef map<int,int> mp;
#define pb push_back
#define pf push_front
#define mk make_pair
#define sc scanf
#define pr printf
#define pi acos(-1.0)
#define endl '\n'
// char s[200009];
// char st[200009];
// int a[600][600];
// int b[29][10];
// int a[200009];
// int c[200009];
void solve()
{
	ll n, m, i, j, k, l; 
	string s, s1, s2; cin >> s1 >> s >> s2;
	cout << s1[0] << s[1] << s2[2] << endl;
}
int main()
{
	IO;
	int t; 
	t = 1;
	// cin >> t;
	while(t--)
		solve();
	return 0;
}

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


int dp[101][4][2];


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

  dp[0][0][0] = 1;

  rep(i, n) {
    int Ni = N[i] - '0'; // N の上から i 桁目の数
    rep(j, K+1) rep(k, 2) rep(x, 10) {
      int j2 = j, k2 = k; // 遷移後の状態を表す変数 j2, k2 を，遷移前の状態で初期化

      if (x != 0) ++j2;     // X の上から i 桁目の数 x が非ゼロなら j2 を更新
      if (j2 > K) continue; // 非ゼロの桁の数が K より多いなら無視

      if (!k && (x > Ni)) continue; // X が N より大きい数であることが確定したら無視
      if (x < Ni) k2 = 1;           // X が N より小さい数であることが確定したら k2 を更新

      dp[i+1][j2][k2] += dp[i][j][k]; // 遷移式
    }
  }

  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << '\n';
}


Measured memory_bytes: 3600
while True:
    H, W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            if (w + h) % 2 == 0:
                print('#', end='')
            else:
                print('.', end = '')
        print()
    print()


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1){
    cin >> c.at(i) >> s.at(i) >> f.at(i);
  }
  rep(i, n){
    int pos = i, time = 0;
    while(pos != n-1){
      if(time <= s.at(pos)){
        time = s.at(pos) + c.at(pos);
      }else{
        int m1 = (time+f.at(pos)-1) / f.at(pos);
        time = m1*f.at(pos) + c.at(pos);
      }
      pos++;
    }
    cout << time << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<endl;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  ll n, k;
  cin >> n >> k;
  cout << min(n%k,abs((n%k)-k)) << endl;
  return 0;
}


Measured memory_bytes: 256
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL x, a;
	cin >> x;
	int ans = 0;
	a = 100;
	while (a < x) {
		++ans;
		a = (LL)(a * 1.01);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  const int n=s.size();
  vector<int> v(2019);
  v.at(0)=1;
  int t=0;
  int pow=1;
  for(int i=n-1;i>=0;i--){
    t=(t+(s.at(i)-'0')*pow)%2019;
    v.at(t)+=1;
    pow*=10;
    pow%=2019;
  }
  long long ans=0;
  long long m;
  for(int j=0;j<2019;j++){
    m=v.at(j);
    ans+=m*(m-1)/2;
  }
  cout << ans;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 998244353;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back
map<int,int> f(int n){
   int k=n;
   map<int,int>m;
   for(int i=2;i<=n;i++){
      int j=0;
      while(k%i==0){
         k/=i;
         j++;
      }
      m[i]=j;
   }
   return m;
}

map<int,int> solve(int n){
   map<int,int>res;
   for(int i=2;i<=n;i++){
      //因数分解
      map<int,int>m=f(i);
      for(auto v:m){
         res[v.fi]+=v.se;
      }
   }

   return res;
}

class Combination{
    VI facts,inv_facts;
    public:
    Combination(ll n):facts(n+1),inv_facts(n+1){
        rep(i,n+1)facts[i]=i==0?1:mod_mul(facts[i-1],i);
        for(ll i=n;i>=0;i--)inv_facts[i]=i==n?mod_inv(facts[n]):
        mod_mul(inv_facts[i+1],i+1);
    }
        ll nCr(ll n,ll r){return mod_mul(facts[n],mod_mul(inv_facts[r],inv_facts[n-r]));}
    
};

int n;
int main(){
   cin>>n;
   map<int,int>m=solve(n);
   int num_2=0,num_4=0,num_14=0,num_24=0,num_74=0;
   for(auto v:m){
      if(v.se>=74)num_74++;
      if(v.se>=24)num_24++;
      if(v.se>=14)num_14++;
      if(v.se>=4)num_4++;
      if(v.se>=2)num_2++;
   }
   ll ans=0;
   Combination C(num_2+1);
   ans=num_74+num_24*(max(0,num_2-1))+num_14*(max(0,num_4-1))+C.nCr(num_4,2)*(max(num_2-2,0));
   cout<<ans<<endl;
}

Measured memory_bytes: 3656