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

// dump macro{{{
// http://www.creativ.xyz/dump-cpp-652
#define DUMPOUT cerr // 変数ダンプ先。coutかcerr

#ifdef PCM
// 引数はいくつでもどんな型でも可（ストリーム出力演算子があればOK）
#define dump(...) DUMPOUT<<"  "; \
  DUMPOUT<<#__VA_ARGS__; \
  DUMPOUT<<":=> "; \
  dump_func(__VA_ARGS__); DUMPOUT<<"in ["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;
#define dump_1d(x,n) DUMPOUT <<"  " \
  <<#x<<"["<<#n<<"]"<<":=> {"; \
  rep(i,n){ DUMPOUT << x[i] << (((i)==(n-1))?"}":", "); } DUMPOUT <<" in [" << __LINE__ << "]" << endl;

#define dump_2d(x,n,m) DUMPOUT <<"  " \
    <<#x<<"["<<#n<<"]"<<"["<<#m<<"]"<<":=> \n"; \
    rep(i,n)rep(j,m){ DUMPOUT << ((j==0)?"     |":" ") << x[i][j] << (((j)==(m-1))?"|\n":" "); } \
    DUMPOUT <<"  in [" << __LINE__ << "]" << endl;
#else
#define dump(...) 42
#define dump_1d(...) 42
#define dump_2d(...) 42
#endif

// デバッグ用変数ダンプ関数
void dump_func() {
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail)
{
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) {
        DUMPOUT << " ";
    }
    else {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}/*}}}*/

#define rep(i, x) for(int i = 0; i < (int)(x); i++)/*{{{*/
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i >= n;i--)
#define foreach(x,a) for(auto& (x) : (a) )
#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define INF 2147483647
#define INFLL 1000000000000000000LL
#define MOD 1000000007/*}}}*/

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;/*{{{*/
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<pii,vii,greater<pii> > spq;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*}}}*/

// global variables

bool isprime(int n){
  FOR(i, 2, n){
    if (n%i==0) return false;
  }
  return true;
}

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

  ll res = 1;
  FOR(i, 2, n+1){
    ll count = 0;
    if (isprime(i)){
      int tmp = i;
      while (true){
        count += n/tmp;
        tmp *= i;
        if (tmp > n) break;
      }
    }
    res *= (count+1);
    res %= MOD;
  }

  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    ll C[N];
    rep(i,N) C[i] = 1;
    ll H[N];
    rep(i,N) cin >> H[i];
    ll A,B;
    rep(i,M){
        cin >> A >> B;
        if(H[A-1]==H[B-1]){
            C[A-1]--;
            C[B-1]--;
        }
        else if(H[A-1]>H[B-1]) C[B-1]--;
        else C[A-1]--;
    }
    ll out = 0;
    rep(i,N){
        if(C[i]>0) out++;
    }
    cout << out << endl;
    return 0;
}


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

int main(){
  char s;
  cin >> s;
  if(65<=(int)s && (int)s<=90){
    cout <<'A'<<endl;
    return 0;
  }
  else{
    cout <<'a'<<endl;
    return 0;
  }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    string s;
    cin >> s;
    int n = sz(s);
    vi a(n + 1, 0);
    re(n) if (s[i] == '<') a[i + 1] = a[i] + 1;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '>') {
            a[i] = max(a[i], a[i + 1] + 1);
        }
    }
    // re(n + 1) cout << a[i] << ' '; cout << endl;
    cout << accumulate(all(a), 0ll);
    return 0;
}


Measured memory_bytes: 2844
import math

n = int(input())
nn = int(math.sqrt(n))+1

ans = [0] * n
for x in range(1,nn):
    for y in range(1,nn):
        for z in range(1,nn):
            f = x**2+y**2+z**2+x*y+y*z+z*x
            if f <= n:
                ans[f-1] += 1

for a in ans:
    print(a)



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

int main(void){
	int w,n,x,y,temp;
	int a[31];
	char c;
	string str;
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	cin >> w >> n;
	for(int i = 0; i < n; i++){
		cin >> str;
		istringstream is(str);
		is >> x >> c >> y;
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

	for(int i = 0; i < w; i++){
		cout << a[i + 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  //"AC"が現れる回数を答える問題
  int N, Q;//Nは文字列Sの長さ，Qは問題の個数
  cin >> N >> Q;
  string S;
  cin >> S;
  vector<int> l(Q); vector<int> r(Q);
  for(int i=0;i<Q;i++)
    cin >> l.at(i) >> r.at(i);

  vector<int> sum(N+1);
  //文字列Sに対する，l[i]番目からr[i]番目までの部分文字列に含まれる"AC"の回数をans[i]に格納

  //先にACの文字列が出る位置をチェックし，累積和をかんがえる
  sum.at(0) = 0;
  for(int i=0;i<N-1;i++){
    if(S.at(i) == 'A' && S.at(i+1) =='C'){
      sum.at(i + 1) = sum.at(i) + 1;
    }else{
      sum.at(i + 1) = sum.at(i);
    }
  }
  sum.at(N) = sum.at(N-1);

  /*for(int i=0;i<sum.size();i++)
    cout << sum.at(i);
  cout << endl; //*/

  for(int i=0;i<Q;i++){
    //cout << "l:" << l.at(i) << "=" << sum.at(l.at(i)-1) << ", r:" << r.at(i) << "=" << sum.at(r.at(i)-1) << endl;
    cout << sum.at(r.at(i)-1) - sum.at(l.at(i)-1) << endl;
  }

}



Measured memory_bytes: 2176
#include<iostream>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int p[501][501]={0,0};
    int count = 0;
    int h[n+1];
    for(int i=0;i<=n;i++) h[i] = 0;
    h[1] = 1;
    int a,b;
    for(int i=0;i<m;i++){
      cin >> a >> b;
      p[a][b] = p[b][a] = 1;
    }
    for(int i=1;i<=n;i++){
      if(p[1][i]!=0){
	h[i] = 1;
	count++;
      }
    }
    for(int i=1;i<=n;i++){
      for(int j=1;j<=n;j++){
	if(h[i]==1){
	  if(p[i][j]!=0&&h[j]==0){
	    count++;
	    h[j] = 2;
	  }
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 2148
#include<cstdio>
    #include<algorithm>
     
    using namespace std;
     
    typedef long long ll;
     
    int main(){
      ll N, M;
      scanf("%lld%lld", &N, &M);
      ll ans = max((ll)0, (N-2) * (M-2));
      if(N==1) ans = M-2;
      if(M==1) ans = N-2;
      if(N==1 && M==1) ans = 1;
      printf("%lld\n", ans);
     
    }

Measured memory_bytes: 128
#B問題
N,K = map(int,input().split())
A = list(map(int,input().split()))
rui = [0]

for i in range(N):
    if i == 0:
        rui.append(A[0])
    else:
        rui.append(rui[-1]+A[i])
    
bubun = []
for i in range(N):
    I = i
    for j in range(N-i):
        J = i+j+1
        bubun.append(rui[J]-rui[I])
    
bubun.sort(reverse=True)
m = 40
MAX = 0
kari = 0
while m > 0:
    kari = 2**(m-1)
    count = 0
    for b in bubun:
        if (MAX+kari)&b == MAX+kari:
            count+=1
            
    if count >= K:
        MAX+=kari
    m-=1
    
print(MAX)

Measured memory_bytes: 66300
# -*- coding: utf-8 -*-
#DISCO C
import sys
import math
import collections
#sys.setrecursionlimit(100000)

#n=int(input())

tmp = input().split()
h,w,k = list(map(lambda a: int(a), tmp))

list = [[0 for i in range(w+1)] for j in range(h)]
for i in range(0,h):
	tmp = input()
	for j in range(0,w):
		if(tmp[j]=='#'):
			list[i][j]+=1
			list[i][w]+=1

ans = [[0 for i in range(w)] for j in range(h)]
index=1
for i in range(0,h):
	if(list[i][w]!=0):
		flg=0
		for j in range(0,w):
			if(list[i][j]==1):
				if(flg==0):
					flg=1
				else:
					index+=1
			ans[i][j] = index
		index+=1
for i in range(1,h):
	if(list[i][w]==0)and(list[i-1][w]!=0):
		for j in range(0,w):
			ans[i][j]=ans[i-1][j]
		list[i][w]=1
for i in range(1,h):
	if(list[h-i-1][w]==0):
		for j in range(0,w):
			ans[h-i-1][j]=ans[h-i][j]
		list[h-i-1][w]=1

#print(list)
#print(ans)


for i in range(0,h):
	outstr=""
	for j in range(0,w):
		outstr+=str(ans[i][j])
		if(j!=w-1):
			outstr+=" "
	print(outstr)

Measured memory_bytes: 8176
import java.util.Scanner;

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		long cnt1=0;
		long cnt2=0;
		for(int i=1; i<=n; i++) {
			if(k%2==1) {
				if(i%k==0) {
					cnt1++;
				}
			}else {
				if(i%k==0) {
					cnt1++;
				}else if(i%(k/2)==0) {
					cnt2++;
				}
			}
		}
		cnt1 = (long)Math.pow(cnt1, 3);
		cnt2 = (long)Math.pow(cnt2, 3);
		System.out.println(cnt1+cnt2);
		sc.close();
	}

}


Measured memory_bytes: 23636
n, k = map(int, input().split())
s = "1" + input() + "1"

ZERO, ONE = [], []
now = "1"
count = 0
for c in s:
    if c == now:
        count += 1
    else:
        if now == "0":
            ZERO.append(count)
        else:
            ONE.append(count)
        now = c
        count = 1
ONE.append(count)
ONE[0] -= 1; ONE[-1] -= 1

m = len(ZERO)
if k >= m:
    print(n)
    exit()

answer = temporary = sum(ZERO[:k]) + sum(ONE[:k + 1])
for i in range(m - k):
    temporary += ZERO[i + k] + ONE[i + k + 1]
    temporary -= ZERO[i] + ONE[i]
    answer = max(answer, temporary)

print(answer)


Measured memory_bytes: 44528
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())
num1=abs(a-b)
if v<=w:
    print("NO")
else:
    num2=v-w
    num3=num1/num2
    if num3<=t:
        print("YES")
    else:
        print("NO")


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

#pragma GCC optimize ("-O3", "unroll-loops")

using namespace std;

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

  size_t n;
  cin >> n;
  vector<int> av; av.reserve(n);
  vector<int> bv; bv.reserve(n);
  while ( av.size() < n ) {
    int tmp;
    cin >> tmp;
    av.push_back(tmp);
  }
  while ( bv.size() < n ) {
    int tmp;
    cin >> tmp;
    bv.push_back(tmp);
  }

  for ( size_t i = 0; i + 3 < n; i += 4 ) {
    av[i + 3] -= av[i + 2];
    av[i + 2] -= av[i + 1];
    av[i + 1] -= av[i];
  }

  const int buf_size = 8192;

  int ret = 0;
  for ( size_t i = 0; i < n; i += buf_size ) {
    int i_max = min(n, i + buf_size);
    size_t j = 0;
    for ( ; j + 3 < n; j += 4 ) {
      int a0 = av[j];
      int a1 = av[j + 1];
      int a2 = av[j + 2];
      int a3 = av[j + 3];
      for ( int ii = i; ii < i_max; ++ii ) {
        int b = bv[ii];
        b += a0;
        ret ^= b;
        b += a1;
        ret ^= b;
        b += a2;
        ret ^= b;
        b += a3;
        ret ^= b;
      }
    }
    for ( ; j < n; ++j ) {
      int a = av[j];
      for ( int ii = i; ii < i_max; ++ii ) {
        ret ^= a + bv[ii];
      }
    }
  }
  cout << ret << endl;

  return 0;
}


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

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int a = x2 - x1;
	int b = y2 - y1;
	int x3, y3, x4, y4;
	x3 = x2 - b;
	y3 = y2 + a;
	x4 = x1 - b;
	y4 = y1 + a;
	cout << x3 << " " << y3 << " "
		<< x4 << " " << y4 << endl;
	return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.Array.IO
import Data.IORef
dist a b c d = abs(a-c)+abs(b-d)
 
main = do
  [n,m] <- map read.words <$> getLine
  a <- newArray (1,n) 0 :: IO ( IOArray Int Int )
  b <- newArray (1,n) 0 :: IO ( IOArray Int Int )
  c <- newArray (1,m) 0 :: IO ( IOArray Int Int )
  d <- newArray (1,m) 0 :: IO ( IOArray Int Int )
  forM [1..n] $ (\i -> do 
    [ai,bi] <- map read . words <$> getLine
    writeArray a i ai
    writeArray b i bi
    return () )
  forM [1..m] $ (\j -> do 
    [cj,dj] <- map read . words <$> getLine
    writeArray c j cj
    writeArray d j dj
    return () )
  forM [1..n] $ ( \i -> do
    rmin <- newIORef (maxBound :: Int)
    rindex <- newIORef 0
    forM [1..m] $ ( \j -> do
      distance <- dist <$> (readArray a i) <*> (readArray b i) <*>(readArray c j) <*> (readArray d j)
      min <- readIORef rmin
      if min > distance then do
        writeIORef rmin distance
        writeIORef rindex j 
      else
        return () )
    (readIORef rindex) >>= print )

Measured memory_bytes: 1020
#include<stdio.h>
#define MAX 3000

int main(){
    int x[MAX], y[MAX];
    int i;

    for(i = 0; i < MAX; i++){
        scanf("%d %d", &x[i], &y[i]);
        if(x[i] == 0 && y[i] == 0) break;
    }

    for(i = 0; i < MAX; i++){
        if(x[i] == 0 && y[i] == 0) break;
        if(x[i] > y[i]) printf("%d %d\n", y[i], x[i]);
        else printf("%d %d\n", x[i], y[i]);
    }

    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    int N;cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    ll sm=2,bi=2;
    bool flag=true;
    for(int i=N-1;i>=0;i--){
        if((sm+A[i]-1)/A[i]*A[i]>bi){
            flag=false;
            break;
        }else{
            sm=(sm+A[i]-1)/A[i]*A[i];
            bi=(bi/A[i]+1)*A[i]-1;
        }
    }
    if(flag) cout<<sm<<" "<<bi<<endl;
    else cout<<-1<<endl;
}


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

int main() {
	vector<int> v(10,0);
	for(int i=0;i<4;i++){
		int n;cin>>n;
		v[n]++;
	}
	if(v[1]!=1){
		cout<<"NO";
		return 0;
	}
	if(v[9]!=1){
		cout<<"NO";
		return 0;
	}
	if(v[7]!=1){
		cout<<"NO";
		return 0;
	}
	if(v[4]!=1){
		cout<<"NO";
		return 0;
	}
	cout<<"YES"<<endl;
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        s: String,
    }
    println!("{}", s.replace(",", " "));
}


Measured memory_bytes: 2100
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

ll gcd(ll a,ll b){
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
int f(int a,int c,int d){
	return a-a/c-a/d+a/lcm(c,d);
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<f(b,c,d)-f(a-1,c,d)<<endl;
}


Measured memory_bytes: 256
while true
  n, p = gets.split(" ").map(&:to_i)

  break if n == 0 && p == 0

  i = 0
  h = Hash.new(0)
  while true
    if p > 0
      p -= 1
      h[i] += 1
      if p == 0 && h.values.select{|j| j > 0}.size == 1
        puts i
        break
      end
    else
      if h[i] > 0
        p = h[i]
        h[i] = 0
      end
    end
    if i == n-1
      i = 0
    else
      i += 1
    end
  end
end

Measured memory_bytes: 13196
#include <iostream>

using namespace std;

int main()
{
  int n, r, x;
  cin >> n;
  int a[n];

  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++){
    x = a[i] * a[i + 1];
    if (a[i] < a[i + 1]){
      swap(a[i], a[i + 1]);
    }
    r = a[i] % a[i + 1];
    while (r != 0){
      a[i] = a[i + 1];
      a[i + 1] = r;
      r = a[i] % a[i + 1];
    }
    a[i + 1] = x / a[i + 1];
  }
  cout << a[n - 1] << endl;

  return (0);
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int main(){
	int n,m,k;
	cin>>n>>m>>k;
	int a=(n-2*k);
	int b=a/m;
	for(int i=b;i>0;i--){
		if((m*i)+(k*(i-1))<=a){
			cout<<i;
			return 0;
		}
		
	}
	return 0;
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n, m, x[SIZE], d[SIZE];

  scanf("%d%d", &n, &m);


  for(int i=0;i<m;i++){
    scanf("%d", x+i);
  }
  sort(x, x+m);

  for(int i=0;i<m-1;i++){
    d[i] = x[i+1] - x[i];
    debug(d[i]);
  }

  sort(d, d+m-1);

  int ans = 0;

  for(int i=0;i<m-n;i++)
    ans += d[i];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int main(){
  int n;cin>>n;
  int ans=0;
  rep(i,500000){
    int tax=i*1.08;
    if(tax==n)ans=i;
  }
  if(ans>0)
  cout<<ans<<endl;
  else
    cout<<":("<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
	std::ios::sync_with_stdio(false);
    cin.tie(0);
	char a,b;
	cin >> a >> b;
	if((a=='H' && b=='H') || (a=='D' && b=='D')){
		cout << "H" << "\n";
	}else if((a=='D' && b=='H')|| (a=='H' && b=='D')){
		cout << "D" << "\n";
	}
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,M,total=0;
	bool check;
	cin>>N>>M;
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
		total+=A[i];
	}
	if(total%(4*M)==0)
		total/=(4*M);
	else
		total=total/(4*M)+1;
	sort(A,A+N);
	for(int i=N-1;i>N-M-1;i--){
		if(A[i]>=total){
			check=true;
			continue;
		}
		else{
			check=false;
			cout<<"No"<<endl;
		}
		if(check==false)
			break;
	}
	if(check==true)
		cout<<"Yes"<<endl;
	
	return 0;
}

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

vector<vector<bool>> con(8, vector<bool> (8, false));
vector<bool> visited(8,false);

int dfs(int v, int n, vector<bool> visited) {
    bool flag = true;
    for(int i = 0; i < n; i++) {
        if(visited.at(i) == false)
        flag = false;
    }
    if(flag) return 1;
    
    int ret = 0;
    for(int i = 0; i < n; i++) {
        if(con.at(v).at(i) == false) continue;
        if(visited.at(i)) continue;
        
        visited.at(i) = true;
        ret += dfs(i, n, visited);
        visited.at(i)=false;
    }
    return ret;
}

int main(void){
    int n,m; cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--; b--;
        con.at(a).at(b) = true;
        con.at(b).at(a) = true;
    }
    visited.at(0) = true;
    cout << dfs(0, n, visited) << endl;
    
}


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

int read() {
    int ans=0,flag=1;
    char ch=getchar();
    while( (ch>'9' || ch<'0') && ch!='-' ) ch=getchar();
    if(ch=='-') flag=-1,ch=getchar();
    while(ch>='0' && ch<='9') ans=ans*10+ch-'0',ch=getchar();
    return ans*flag;
}
int a[200005];
int main()
{
	int n,k;
	cin>>n>>k;
	double sum=0,max;
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=1;i<=k;i++)
		sum+=a[i];
	max=sum;
	for(int i=k+1;i<=n;i++){
		sum=sum+a[i]-a[i-k];
		if(sum>max)
			max=sum;
	}
	double count=(k+max)/2;
	printf("%.12lf",count);
 	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n,m,k;cin>>n>>m>>k;
    vvi v(n,vi(m));
    rep(i,n){
        string s;cin>>s;
        rep(j,m)if(s[j]=='1')v[i][j]++;
    }
    ll ans=inf;
    rep(bit,1<<(n-1)){
        vi id(n);
        ll res=0;
        int c=0;
        rep(i,n){
            id[i]=c;
            if(i==n-1)break;
            if(bit>>i&1)c++;
        }
        vi sum(n);
        bool ok=true;
        rep(i,m){
            rep(j,n)sum[id[j]]+=v[j][i];
            rep(j,n){
                if(sum[j]>k){
                    rep(t,n)sum[t]=0;
                    rep(t,n)sum[id[t]]+=v[t][i];
                    res++;
                    rep(t,n)if(sum[t]>k)ok=false;
                    break;
                }
            }
        }
        if(ok)chmin(ans,res+c);
    }
    out(ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    long long int n;cin>>n;
    set<long long int>s;
    s.insert(n);
    for(long long int i=2;i<=sqrt(n);i++){
        if(n%i!=0){
            continue;
        }
        long long int j = n;
        while(j%i==0){
            j/=i;
        }
        if(j%i==1){
            s.insert(i);
        }
    }
    long long int m = n-1;
    for(long long int i = 1;i<=sqrt(m);i++){
        if(m%i==0){
            s.insert(i);
            s.insert(m/i);
        }
    }
    s.erase(1);
    cout<<s.size()<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


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

int main()
{
    int h, w;
    cin >> h >> w;
    char t[h + 1][w + 1];
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> t[i][j];
        }
    }

    bool f = false;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (t[i][j] == '#')
                break;
            if (j == w - 1)
                f = true;
        }
        if (f)
        {
            for (int j = 0; j < w; j++)
                t[i][j] = ' ';
            f = false;
        }
    }
    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < h; j++)
        {
            if (t[j][i] == '#')
                break;
            if (j == h - 1)
                f = true;
        }
        if (f)
        {
            for (int j = 0; j < h; j++)
                t[j][i] = ' ';
            f = false;
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (t[i][j] == ' ')
                continue;
            cout << t[i][j];
            f = true;
        }
        if (f)
            cout << endl;
        f = false;
    }
}


Measured memory_bytes: 3620
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int k = sc.NextInt();
        int a = sc.NextInt();
        int b = sc.NextInt();

        for (int i = k; i <= b; i += k)
        {
            if (a <= i && i <= b)
            {
                Console.WriteLine("OK");
                return;
            }
        }
        Console.WriteLine("NG");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27488
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int n, q;
	cin >> n >> q;
	vector<int> g(n, 0);
	q *= 2;
	while( q-- ){
		int x; cin >> x; --x; ++g[x];
	}
	for( auto k : g ){
		if( k % 2 == 1 ){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
const int N=15;
const int MOD=998244353;
int n,m;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac[N],inv[N];
long long Pw[N];
void init(int n=10)
{
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=ksm(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	Pw[0]=1;
	for(int i=1;i<=n;i++)
		Pw[i]=Pw[i-1]*2%MOD;
	return;
}
long long C(int n,int m)
{
	if(m>n) return 0;
	else return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int r[N],c[N];
char s[N][N];
long long row[N][N][3],col[N][N][3];
int main()
{
	init();
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			 if(s[i][j]=='.') r[i]|=1<<j,c[j]|=1<<i;
	for(int j=1;j<=m;j++)
		col[n][j][2]=C(m,j)*Pw[m-j]%MOD;
	long long ans=Pw[m];
	for(int i=n;i>=1;i--)
		for(int j=m;j>=1;j--)
		{
			col[i][j][0]=(col[i][j][1]+col[i][j][2])%MOD;
			for(int k=1;k<i;k++)
			{
				int d=i-k;
				row[k][j][1]=(row[k][j][1]+C(i,d)*(col[i][j][2]*2+col[i][j][1])%MOD)%MOD;
				row[k][j][2]=(row[k][j][2]+C(i,d)*(Pw[d]-2)%MOD*col[i][j][2]%MOD)%MOD;
			}
			ans=(ans+col[i][j][2]*(Pw[i]-2)%MOD)%MOD;
			row[i][j][0]=(row[i][j][1]+row[i][j][2])%MOD;
			for(int k=1;k<j;k++)
			{
				int d=j-k;
				col[i][k][1]=(col[i][k][1]+C(j,d)*(row[i][j][2]*2+row[i][j][1])%MOD)%MOD;
				col[i][k][2]=(col[i][k][2]+C(j,d)*(Pw[d]-2)%MOD*row[i][j][2]%MOD)%MOD;
			}
			ans=(ans+row[i][j][2]*(Pw[j]-2)%MOD)%MOD;
		}
	for(int i=1;i<(1<<n);i++)
		for(int j=1;j<(1<<m);j++)
		{
			bool flag=true;
			for(int k=0;k<n;k++)
				if(i&(1<<k))
				{
					int w=r[k]&j;
					if(w==j||w==0)
					{
						flag=false;
						break;
					}
				}
			if(!flag) continue;
			for(int k=0;k<m;k++)
				if(j&(1<<k))
				{
					int w=c[k]&i;
					if(w==i||w==0)
					{
						flag=false;
						break;
					}
				}
			if(!flag) continue;
			int x=__builtin_popcount(i),y=__builtin_popcount(j);
			ans=(ans+(row[x][y][0]+col[x][y][0])%MOD*ksm(C(n,x),MOD-2)%MOD*ksm(C(m,y),MOD-2)%MOD)%MOD;
		}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>

int divide(int, int, int);

int main(void)
{
	int n;
	while (1) {
		scanf("%d", &n);
		if (n == 0) 
			break;
	    int grade[n][3];
		for (int i = 0; i < n; i++) {
			scanf("%d %d %d", &grade[i][0], &grade[i][1], &grade[i][2]);
			divide(grade[i][0], grade[i][1], grade[i][2]);
		}
	}
	return 0;
}

int divide(int m, int e, int j)
{
	if (m == 100 || e == 100 || j == 100 ||
		(m + e) / 2 >= 90 ||
		(m + e + j) / 3 >= 80) {
		printf("A\n");
	} else if ((m + e + j) / 3 >= 70 ||
		       ((m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() { 
    int n;
    cin >> n;
    int count = 0;
    vector<int> a(n);
    int ca = 110;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if(i > 0) {
            if(a[i] == a[i - 1]) {
                count++;
                a[i] = ca;
                ca++;
            }
        }
    }
    cout << count << endl;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n; cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; ++i) {
    ll j = n/i;
    ans += i*j*(j+1)/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
'use strict'

function Main(input){
    let temp = input.trim().split(' ').map((v)=>parseInt(v));
    let n = temp.shift();
    let k = temp.shift();

    let ans = 0;
    for(let i=1;i<=n;i++){
        let j=i;
        let m=0;
        while(j < k){
            j <<= 1;
            m++;
        }
        ans += (1/n)*(1/(1<<m));
    }

    console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9932
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int H,W,K;

bool ok(vector<string> g, vector<int> &x, vector<int> &y) {
	for (auto h : x)
		for (int i=0; i<W; i++)
			g[h][i]='@';
	for (auto w : y)
		for (int i=0; i<H; i++)
			g[i][w]='@';
	int ret=0;
	for (auto row : g)
		for (char ch : row)
			if(ch=='#')
				ret++;
	return ret==K;
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>H>>W>>K;
	vector<string> g(H);
	for (int i=0; i<H; i++)
		cin>>g[i];
	int ret=0;
	for (int a=0; a<(1<<H); a++) {
		for (int b=0; b<(1<<W); b++) {
			vector<int> x,y;
			for (int i=0; i<H; i++)
				if(a&(1<<i)) x.push_back(i);
			for (int i=0; i<W; i++)
				if(b&(1<<i)) y.push_back(i);
			if(ok(g,x,y)) ret++;
		}
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3656
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ADiagonalString solver = new ADiagonalString();
        solver.solve(1, in, out);
        out.close();
    }

    static class ADiagonalString {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String[] cs = new String[3];
            StringBuilder ans = new StringBuilder();
            for (int i = 0; i < 3; i++) {
                cs[i] = in.next();
                ans.append(cs[i].charAt(i));
            }
            out.println(ans);
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



Measured memory_bytes: 21460
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a, int b ){
    int r, tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    int lc;
    cin >> lc;
    int m = lc;
    REP(i,n-1){
        int a;
        cin >> a;
        m = max(a,m);
        lc = gcd(lc,a);
    }
    if(k%lc==0&&m>=k){
        cout << "POSSIBLE\n";
    }else{
        cout << "IMPOSSIBLE\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mk make_pair
int s[30001],ss[30001],c=2;
unordered_set<long long>se;
int main(){
  s[0]=2;s[1]=3;ss[2]=ss[3]=1;
  for(int i=2;i<30001;i++){
    int p=0;
    for(int j=2;j*j<=i;j++)
      if(i%j==0)p++;
    if(!p)ss[i]++,s[c++]=i;
  }
  int n;
  while(cin>>n,n){
    se.clear();
    int sum=0;
    for(int i=0;i<c;i++){
      if(s[i]>n/2+1)break;
      for(int j=0;j<c;j++){
	if(s[j]+s[i]>n)break;
	if(n-s[j]-s[i]>0)
	  if(ss[n-s[j]-s[i]]){
	    int d[3];
	    d[0]=s[i];
	    d[1]=s[j];
	    d[2]=n-s[j]-s[i];
	    sort(d,d+3);
	    if(!se.count(d[0]*10000000000+d[1]*100000+d[2])&&d[0]+d[1]>d[2]){
		se.insert(d[0]*10000000000+d[1]*100000+d[2]);
	        sum++;
	      }
	  }
      }
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 5312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

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

    int N = n;
    while(N >= 2){
        N -= 2;
        bool ok = true;
        rep(i,N/2){
            if(s[i] != s[i+N/2]){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << N << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
S = input()
ans = [0,0]

if 1<=int(S[:2]) and int(S[:2]) <= 12 :
    ans[0] = 1
if 1 <=int(S[2:]) and int(S[2:]) <= 12 :
    ans[1] = 1

if ans == [1,1] :
    print('AMBIGUOUS')
elif ans == [0,0] :
    print('NA')
elif ans == [0,1] :
    print('YYMM')
elif ans == [1,0] :
    print('MMYY')

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

using namespace std;

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

    int cnt = 0 ;
    for(int i = 0; i < n / 2; i++){
        if ( s[i] != s[n - i - 1] )cnt++;
    }
    cout << cnt << endl;

    return 0 ;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

class DisjointSet
{
	private int[] parent;
	private int[] size;
	
	public DisjointSet(int n)
	{
		parent = new int[n];
		size = new int[n];
		for(int i = 0 ; i < n ; i++)
		{
			parent[i] = i;
			size[i] = 1;
		}
	}
	public int find(int v)
	{
		int u = v;
		while(u != parent[u])
			u = parent[u];
		v = parent[v];
		while(v != parent[v])
		{
			int temp = parent[v];
			parent[v] = u;
			size[v] = 1;
			v = temp;
		}
		return u;
	}
	public void union(int a, int b)
	{
		a = find(a);
		b = find(b);
		if(a != b)
		{
			if(size[a] < size[b])
			{
				int temp = a;
				a = b;
				b = temp;
			}
			parent[b] = a;
			size[a] += size[b];
		}
	}
	public int size(int v)
	{
		v = find(v);
		return size[v];
	}
	public boolean isInTheSameSet(int a, int b)
	{
		return find(a) == find(b);
	}
}

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n, m, k;
		int[] ans, direct;
		n = scanner.nextInt();
		m = scanner.nextInt();
		k = scanner.nextInt();
		DisjointSet dsu = new DisjointSet(n + 1); 
		ans = new int[n + 1];
		direct = new int[n + 1];
		for(int i = 0, u, v ; i < m ; i++)
		{
			u = scanner.nextInt();
			v = scanner.nextInt();
			direct[v] += 1;
			direct[u] += 1;
			dsu.union(u, v);
		}
		for(int v = 1 ; v <= n ; v++)
		{
			ans[v] = dsu.size(v) - direct[v] - 1;
		}
		for(int i = 0, u, v ; i < k ; i++)
		{
			u = scanner.nextInt();
			v = scanner.nextInt();
			if(dsu.isInTheSameSet(u, v))
			{
				ans[u] -= 1;
				ans[v] -= 1;
			}
		}
		for(int i = 1 ; i <= n ; i++)
		{
			System.out.print(ans[i] + " ");
		}
	}
}

Measured memory_bytes: 98296
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>









const int N = 2e5 + 10;
ll n, k, a[N], vIdx[N], crr, res, sz, vBgnCclIdx;
vector<ll>v;




void solve()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		vIdx[i] = -1;
	}
	if(k <= n)
	{
		crr = 1;
		for(int i = 1; i <= k; i++)
		{
			crr = a[crr];
		}
		res = crr;
	}
	else
	{
		v.clear();
		v.pb(1);
		vIdx[1] = 0;
		crr = 1;
		while(true)
		{
			crr = a[crr];
			if(vIdx[crr] != -1)
			{
				vBgnCclIdx = vIdx[crr];
				break;
			}
			v.pb(crr);
			sz = v.size();
			vIdx[crr] = sz - 1;
		}
		sz = v.size();
		if(k <= vBgnCclIdx)
		{
			res = v[k];
		}
		else
		{
			k -= vBgnCclIdx;
			res = v[(k % (sz - vBgnCclIdx)) + vBgnCclIdx];
		}
	}
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 8412
#include "bits/stdc++.h"
using namespace std;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int start = max(A, C), end = min(B, D);
	int ans = end - start;
	if (ans < 0) ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)

graph = Hash.new { |h, k| h[k] = [] }
m.times do
  a, b = gets.split.map(&:to_i)
  graph[a].push(b)
  graph[b].push(a)
end

dist = Array.new(n + 1, -1)
dist[1] = 0

que = []
que.push(1)

ans = Array.new(n + 1, -1)

until que.empty?
  v = que.shift

  graph[v].each do |nv|
    next if dist[nv] != -1

    dist[nv] = dist[v] + 1
    que.push(nv)
    ans[nv] = v
  end
end

puts "Yes"
puts ans[2..]


Measured memory_bytes: 35044
import sys
input = sys.stdin.readline

def main():
  n = int(input())
  tree = [[] for _ in range(n)]
  for i in range(n-1):
    v, w = map(int, input().split())
    if v > w:
      v, w = w, v
    tree[w-1].append(v-1)
  
  ans = 0
  count = 0
  for i in range(n):
    count += i+1
    for v in tree[i]:
      count -= v+1
    ans += count
  
  print(ans)
  
if __name__ == "__main__":
  main()


Measured memory_bytes: 35740
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  b.append(a[i]-i-1)
b.sort()
c=b[n//2]
ans=100000000000000000000
for i in range(c-2,c+3):
  temp=0
  for j in range(n):
    temp+=abs(b[j]-i)
  if temp<ans:
    ans=temp
print(ans)

Measured memory_bytes: 99796