akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n;
	cin>>n;
	vector<pii> a(n);
	rep(i,n){
		int z;cin>>z;
		a[i]=make_pair(z,i+1);
	}
	sort(all(a));
	rep(i,n) cout<<a[i].second<<endl;

	return 0;
}



Measured memory_bytes: 4820
#include <cstdio>

using namespace std;

int a[100000];

int gcd(int x, int y) {
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main() {
    int n, k, g = 0, m = 0, i;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    
    for (i = 0; i < n; i++) {
        g = gcd(g, a[i]);
        if (a[i] > m) m = a[i];
    }
    
    if (k > m || (g > 1 && k % g != 0)) {
        puts("IMPOSSIBLE");
    } else {
        puts("POSSIBLE");
    }
    
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  for (ll i = 0; i < 3; i++) {
    char c;
    cin >> c;
    if (c == '7') {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}



Measured memory_bytes: 3604
n = int(input())
li = list(map(int,input().split()))	

#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
print(gcdlist(li))

Measured memory_bytes: 14252
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
typedef long long int lli;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define JUGAD freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
using namespace std;

int main(){
    FAST;
    int n,k;
    cin>>n>>k;
    int ar[10]={0};
    for(int i=0;i<k;i++){
        int c;cin>>c;
        ar[c]=1;
    }
    while(true){
        bool flag=1;
        int x=n;
        while(x){
            int r=x%10;
            if(ar[r]==1){flag=0;break;}
            x/=10;
        }
        if(flag){cout<<n<<endl;return 0;}
        else{n++;}
    }
}




Measured memory_bytes: 3640
#include<stdio.h>
int main(){
  int h,w,n,i,j,f=1,b=0,a=0,t=-1,d[310][310]={};
  char s[310][310];
  scanf("%d %d %d",&h,&w,&n);
  for(i=0;i<h;i++)scanf("%s",s[i]);
  for(i=0;i<h;i++){
    b=a=a+f;
    f=0;
    for(j=0;j<w;j++){
      //d[i][j]=a;
      if(s[i][j]=='#'){
	if(f==1)a++;
	f=1;
      }
      d[i][j]=a;
    }
    if(f==1&&t==-1)t=i;
    if(f==0){
      for(j=0;j<w;j++)d[i][j]=d[i-1][j];
    }
  }
  for(i=0;i<w;i++){
    for(j=0;j<t;j++)d[j][i]=d[t][i];
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)printf("%d%c",d[i][j],j+1==w?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		int[] ar = new int[N];
		
		for (int i = 0,j; i < N; i++) {
			 ar[i] = sc.nextInt();
		}

		int cnt = 0;
		
		for (int i = 0; i < N; i++){
			for(int j = N - 1; j > i; j-- ){
				if (ar[j] < ar[j - 1]){
					ar[j - 1] -= ar[j];
					ar[j] += ar[j - 1];
					ar[j - 1] = ar[j] - ar[j - 1];
					cnt++;
				}
			}
		}

		for (int i = 0; i < N - 1; i++) {
			System.out.print(ar[i] + " ");
		}
		System.out.println(ar[N - 1]);
		
		System.out.println(cnt);
	}
}

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

    ll X;
	cin >> X;
	long long int a = 100;
	int count = 0;
	while (a < X) {
		a  = a*1.01;
		count++;
    
 
	}
  
  cout << count << endl;

	
  return 0;
}

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


int main(){


    long long int n;
    cin>>n;

    map<long long int,char>mp;

    char x='a';

    mp[0]='z';

    for(long long  i=1;i<26;i++){
        mp[i]=x;
        x++;

    }

    vector<char>vec;
    while(1){
        long long int z=n%26;

        vec.push_back(mp[z]);


        n=n/26;

        if(z==0)
            n--;


        if(n<=0)
            break;


    }

    for(int i=vec.size()-1;i>=0;i--)
        cout<<vec[i];


    cout<<endl;



    return 0;
}


Measured memory_bytes: 3628
x = int(input())

if x >= 400 and x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)

Measured memory_bytes: 61656
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc155/tasks/abc155_c

import collections
n = int(input())
buf = []
for _ in range(n):
    buf.append(input())
c = collections.Counter(buf)
max_count = c.most_common()[0][1]
ans = []
for k, v in c.items():
    if v == max_count:
        ans.append(k)
ans.sort()
for name in ans:
    print(name)


Measured memory_bytes: 45084
# coding: utf-8
# Your code here!

n = list(input())
op_cnt = len(n) - 1
a = []
li = []
ctr = 0
for i in range(2 ** op_cnt):
    op = [""] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"
    for p_n, p_o in zip(n, op + [""]):
        a.append(p_n)
        a.append(p_o)
    li = list(map(int, ''.join(a).split("+")))
    ctr += sum(li)
    a.clear()
print(ctr)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l,r) l+(r-l)/2
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}

void solve(){
	int nn;
	cin>>nn;
	int a[nn];
	vector<int>p,n;
	vector<pii>res;
	int ans=0;
	rep(i,nn){
		cin>>a[i];
		if(a[i]>=0)p.pb(a[i]);
		else n.pb(a[i]);
		//s.insert(x);
	}
	sort(p.begin(), p.end());
	sort(n.begin(), n.end());
	if(!n.size()){
		ans=p[0];
		for(int i=1;i<int(p.size())-1;i++){
			res.pb(pii(ans,p[i]));
			ans-=p[i];
		}
		res.pb(pii(p[p.size()-1],ans));
		ans=p[p.size()-1]-ans;
	}
	else if(!p.size()){
		ans=n[n.size()-1];
		for(int i=n.size()-2;i>0;i--){
			res.pb(pii(ans,n[i]));
			ans-=n[i];
		}
		res.pb(pii(ans,n[0]));
		ans-=n[0];
	}
	else{
		ans=p[0];
		for(int i=1;i<n.size();i++){
			res.pb(pii(ans,n[i]));
			ans-=n[i];
		}
		int ans1=n[0];
		for(int i=1;i<p.size();i++){
			res.pb(pii(ans1,p[i]));
			ans1-=p[i];
		}
		res.pb(pii(ans,ans1));
		ans-=ans1;
	}
	cout<<ans<<"\n";
	for(pii p:res)cout<<p.fi<<" "<<p.se<<"\n";
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

long long INF = 1e18;
long long v[200],w[200];
long long dp[200010];
int main(){
    int N;
    long long W;
    cin >> N >> W;
    long long vmax = 0, wmax = 0;
    for(int i = 0 ; i < N ; i++){
        cin >> w[i] >> v[i];
        vmax = max(vmax,v[i]);
        wmax = max(wmax,w[i]);
    }
    if( N <= 30 ){
        vector<int> id[2];
        for(int i = 0 ; i < N ; i++) id[i%2].push_back(i);

        vector< pair<long long,long long> > lst;
        for(int i = 0 ; i < (1<<id[0].size()) ; i++){
            long long vtot = 0, wtot = 0;
            for(int j = 0 ; j < id[0].size() ; j++){
                if( i >> j & 1 ){
                    vtot += v[id[0][j]];
                    wtot += w[id[0][j]];
                }
            }
            lst.push_back(make_pair(wtot,vtot));
        }
        sort(lst.begin(),lst.end());
        for(int i = 1 ; i < lst.size() ; i++)
            lst[i].second = max(lst[i].second,lst[i-1].second);

        long long ans = 0;
        for(int i = 0 ; i < (1<<id[1].size()) ; i++){
            long long vtot = 0, wtot = 0;
            for(int j = 0 ; j < id[1].size() ; j++){
                if( i >> j & 1 ){
                    vtot += v[id[1][j]];
                    wtot += w[id[1][j]];
                }
            }
            if( wtot > W ) continue;
            ans = max(ans,vtot+(*(upper_bound(lst.begin(),lst.end(),make_pair(W-wtot,INF))-1)).second);
        }
        cout << ans << endl;

    }else if( vmax <= 1000 ){
        for(int i = 0 ; i <= 200000 ; i++) dp[i] = INF;
        dp[0] = 0;
        for(int i = 0 ; i < N ; i++){
            for(int j = 200000 ; j >= v[i] ; j--){
                dp[j] = min(dp[j-v[i]]+w[i],dp[j]);
            }
        }
        long long ans = 0;
        for(int i = 0 ; i <= 200000 ; i++){
            if( dp[i] <= W ) ans = i;
        }
        cout << ans << endl;
    }else{
        for(int i = 0 ; i <= 200000 ; i++) dp[i] = -INF;
        dp[0] = 0;
        for(int i = 0 ; i < N ; i++){
            for(int j = 200000 ; j >= w[i] ; j--){
                dp[j] = max(dp[j-w[i]]+v[i],dp[j]);
            }
        }
        long long ans = 0;
        for(int i = 0 ; i <= min(200000ll,W) ; i++){
            ans = max(dp[i],ans);
        }
        cout << ans << endl;
    }
}








Measured memory_bytes: 1792
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  vector<int> d;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    d.push_back(tmp);
  }
  sort(d.begin(), d.end());

  if (d[n / 2] == d[n / 2 - 1])
    cout << 0 << endl;
  else
    cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}

Measured memory_bytes: 892
#include<stdio.h>
int selectionSort(int A[],int N)
{
	int i,j,t,sw=0,mini;
	for(i=0;i<N-1;i++)
	{
		mini=i;
		for(j=i;j<N;j++)
		{
			if(A[j]<A[mini])mini=j;
		}
		t=A[i];A[i]=A[mini];A[mini]=t;
		if(i != mini)sw++;
	}

	return sw;
}

int main()
{
	int i,N,sw;
	int A[100];

	scanf("%d",&N);

	for(i=0;i<N;i++)
	{
		scanf("%d",&A[i]);
	}

	sw=selectionSort(A,N);

	for(i=0;i<N;i++)
	{
		if(i>0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);

	return 0;
}

Measured memory_bytes: 2756
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a,b;
  bool c=false,d=false,e=false;
  for(int i=0;i<n;i++){
    cin>>a>>b;
    if(a==b){
      if(c&&d){
        cout<<"Yes"<<endl;
        return 0;
      }
      else if(c){
//        cout<<"2"<<endl;
        d=true;
      }
      else{
        c=true;
//        cout<<"1"<<endl;
      }
    }
    else{
      c=false;
      d=false;
      e=false;
    }
//    cout<<a<<" "<<b<<endl;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <unordered_map>

using namespace std ;

typedef long long LL ;

const LL P = 1000000007 ;

unordered_map<LL, LL> m ;

LL n ;
int cnt ;

LL f(int p, LL x){
    if (m.count(x)) return m[x] ; if (x == 0) return m[x] = 1 ; if (x == 1) return m[x] = 2 ;
    return m[x] = ((f(p - 1, x / 2) + f(p - 1, (x - 1) / 2)) % P + f(p - 1, (x - 2) / 2)) % P ;
}
int main(){
    cin >> n ;
    cout << f(log2(n) + 1, n) << endl ;
    return 0 ;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
   long long int N,K,a,i,x=0;
   scanf("%lld%lld",&N,&K);

   for(i=0;i<N;i++)
   {

      scanf("%lld",&a);

      if(a>=K)
      {
         x=x+1;
       }
    }
    printf("%lld",x);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); ++i)
#define repf(i, from, to) for (int i = (from); i < (to); ++i)
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  int t;
  int a;
  V<int> h_list;

  cin >> n >> t >> a;
  h_list.resize(n);
  rep(i, n) {
    cin >> h_list[i];
  }

  int target_i = 0;
  double target_t = t - h_list[0] * 0.006;
  rep(i, n) {
    double current_t = t - h_list[i] * 0.006;

    if(abs(current_t - a) < abs(target_t - a)) {
      target_i = i;
      target_t = current_t;
    }
  }

  cout << target_i + 1 << endl;
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
	int n;
	int p[22];
	cin>>n;
	rep(i,0,n)cin>>p[i];
	int ans=0;
	rep(i,1,n-1){
		if(p[i-1]+p[i]+p[i+1]-max({p[i-1],p[i],p[i+1]})-min({p[i-1],p[i],p[i+1]})==p[i])
			ans++;
	}
	print(ans);
}

Measured memory_bytes: 256
import math
N, K = map(int, input().split())
xs = list(map(int, input().split()))

idx = xs.index(1) # where 1 locates

result = N
for m in range(K):
  L = idx - m
  if L < 0:
    continue
  R = N - K - idx + m
  if R < 0:
    continue
  cnt = lambda a: 0 if a == 0 else math.ceil(a / (K -1))
  result = min(result, 1 + sum(cnt(b) for b in [L, R]))
  
print(result)

Measured memory_bytes: 13812
#![allow(unused)]

extern crate num;

use std::io::{Read, StdinLock};
use std::iter::{FromIterator, Iterator};
use std::str::{FromStr};
use std::string::String;
use num::integer::gcd;

macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

pub fn read_bytes<T: FromIterator<char>>(s: &mut StdinLock) -> T {
    s.bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<T>()
}

pub fn reads(s: &mut StdinLock) -> String {
    read_bytes::<String>(s)
}

pub fn read<T: FromStr>(s: &mut StdinLock) -> T {
    reads(s).parse().ok().unwrap()
}

//==============================================================================
//
// Problem specific code
//
//==============================================================================

fn main() {
    let sin = std::io::stdin();
    let mut sin = sin.lock();

    let k: usize = read(&mut sin);

    let mut ans: usize = 0;
    for a in (1..=k) {
        for b in (1..=k) {
            for c in (1..=k) {
                ans += num::integer::gcd(gcd(a, b), c);
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 2136
import fractions

num = input().split()
a, b, c, d = int(num[0])-1, int(num[1]), int(num[2]), int(num[3])

lcd = int(c*d/fractions.gcd(c, d))
warikire = (b//c-a//c)+(b//d-a//d)-(b//lcd-a//lcd)

print(int(b-a-warikire))

Measured memory_bytes: 5176
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,t;
    cin>>n>>t;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll rightm=0;
    map<ll,ll> m;
    for(int i=n-1;i>=0;i--){
        if(rightm>=a[i])m[rightm-a[i]]++;
        if(rightm<a[i])rightm=a[i];
    }
    ll ma=0;
    ll ans=0;
    for(auto &a:m){
        if(ma<a.first){
            ma=a.first;
            ans=a.second;
        }
    }

    cout<<ans<<endl;



    return 0;
}


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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }
ll rud(ll a, ll b) { return (a + b - 1) / b; }

int main(int argc, const char* argv[]) {
	ll a, b;
	cin >> a >> b;

	cout << ( ( (b-1) + (a-1) - 1 ) / (a-1) ) << endl;

	return 0;
}


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

typedef long long ll;

ll N, K;
vector<ll> A, F;

int main() {
  cin >> N >> K;
  A.resize(N);
  F.resize(N);
  for (ll i = 0; i < N; ++i) cin >> A[i];
  for (ll i = 0; i < N; ++i) cin >> F[i];
  sort(A.begin(), A.end(), greater<ll>());
  sort(F.begin(), F.end(), less<ll>());
  ll ng = -1, ok = 1e13;
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    ll cost = 0;
    for (ll i = 0; i < N; ++i) cost += max(0ll, A[i] - mid / F[i]);
    (cost <= K ? ok : ng) = mid;
  }
  cout << ok << endl;
  return 0;
}


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



#define REP(i,n) for (i = 0; i < n; i++)
#define RREP(i,n) for (i = n-1; i > -1; i--)

typedef struct mys
{
  int value, index;

  bool operator< (const mys& fd1) const
  {
    return (this->value < fd1.value);
  }

}hey;


int main()
{
	int n,temp,i;
	cin>>n;
	int b[n-1];
	vector <hey> myvec;

	REP(i,n-1)
	{
		cin>>b[i];
		hey newhey;
		newhey.value = b[i];
		newhey.index = i;
		myvec.push_back(newhey);
	}

	sort(myvec.begin(),myvec.end());

	/*
	REP(i,n-1)
	{
		cout<<myvec[i].value<<" ";
	}
	*/

	int a[n], in;
	REP(i,n)
	{
		a[i] = -1;
	}

	int sum = 0;

	REP(i,n-1)
	{
		in = myvec[i].index;

		if(a[in]==-1 && a[in+1]==-1)
		{
			a[in] = a[in+1] = myvec[i].value;
			sum+=a[in];
			sum+=a[in+1];
		}
		else if(a[in]==-1 && a[in+1]!=-1)
		{
			a[in] = myvec[i].value;
			sum+=a[in];
		}
		else if(a[in]!=-1 && a[in+1]==-1)
		{
			a[in+1] = myvec[i].value;
			sum+=a[in+1];
		}
	}

	/*
	REP(i,n)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
	*/
	cout<<sum<<endl;


	

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static int so[10001],hyo[1300];

int main(){
	int i,j,k,n,m;
	
	so[1]=1;
	for(i=2;i*i<=10000;i++){
		for(j=2*i;j<=10000;j+=i){
			so[j]=1;
		}
	}
	hyo[0]=0;
	j=0;
	for(i=1;i<=10000;i++){
		if(!so[i]){
			++j;
			hyo[j]=hyo[j-1]+i;
		}
	}
	k=j;
	//printf("%d\n",k);
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		
		m=0;
		
		for(i=0;i<k;++i){
			for(j=i+1;j<=k;++j){
				if(hyo[j]-hyo[i]==n)++m;
			}
		}
		printf("%d\n",m);
	}
	return 0;
}

Measured memory_bytes: 800
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a.at(0) << b.at(0) << c.at(0);
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

#define MOD 1000000007

long sum(long a, long b) { return (a + b) % MOD; }

long mult(long a, long b) { return (a * b) % MOD; }

long pow(long a, long b) {
    long res = 1;
    while (b > 0) {
        if (b & 1) {
            res = mult(res, a);
        }
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

long inv(long a) {
    return pow(a, MOD - 2);
}

vector<long> fact_precalc(1, 1);
vector<long> inv_fact_precalc(1, 1);

void ensure_fact(int n) {
    while (n >= fact_precalc.size()) {
        fact_precalc.push_back(mult(fact_precalc.back(), fact_precalc.size()));
        inv_fact_precalc.push_back(inv(fact_precalc.back()));
    }
}

long fact(int n) {
    ensure_fact(n);
    return fact_precalc[n];
}

long inv_fact(int n) {
    ensure_fact(n);
    return inv_fact_precalc[n];
}

long calc_c(int n, int k) {
    long res = fact(n);
    res = mult(res, inv_fact(k));
    res = mult(res, inv_fact(n - k));
    return res;
}

// @author: pashka

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    if (n == 2) {
        cout << 1;
        return 0;
    }
    long res = 0;
    for (int i = 2; i < n; i++) {
        {
            int s = n - 2 - 3;
            int k = i - 3;
            if (k >= 0 && s >= k && s - k <= k) {
                long q = i;
                q = mult(q, calc_c(k, s - k));
                q = mult(q, fact(i - 1));
                q = mult(q, 2);
                q = mult(q, fact(n - 1 - i));
                q = mult(q, i - 2);
//                cout << i << " 1 " << q << "\n";
                res = sum(res, q);
            }
        }
        {
            int s = n - 2 - 4;
            int k = i - 3;
            if (k >= 0 && s >= k && s - k <= k) {
                long q = i;
                q = mult(q, calc_c(k, s - k));
                q = mult(q, fact(i - 1));
                q = mult(q, fact(n - 1 - i));
                q = mult(q, i - 2);
//                cout << i << " 2 " << q << "\n";
                res = sum(res, q);
            }
        }
        {
            int s = n - 2;
            int k = i - 1;
            if (k >= 0 && s >= k && s - k <= k) {
                long q = i;
                q = mult(q, calc_c(k, s - k));
                q = mult(q, fact(i - 1));
                q = mult(q, fact(n - 1 - i));
                q = mult(q, 2);
//                cout << i << " 3 " << q << "\n";
                res = sum(res, q);
            }
        }
    }

    cout << res << "\n";



    return 0;
}

Measured memory_bytes: 16340
#include<cstdio>
#include<algorithm>
#include<cstring>

#define Po min
using namespace std;
typedef long long LL;

const int N=105;
int n,k;
char s[N],t[N];

int main()
{
    scanf("%s %d",s+1,&k);
    n=strlen(s+1);
    s[0]='/';
    
	int f=0;
    
    for(int i=2;i<=n;i++)
        if(s[i]!=s[i-1])
		{
            f=1;
            break;
        }
    if(!f)
	{
        printf("%lld",(LL)n*k/2);
        return 0;
    }
    memcpy(t,s,sizeof(s));
	
    LL cnt=0,ans=0;
    
    for(int i=1;i<=n;i++)
        if(s[i]==s[i-1])
            s[i]='-',cnt++;
    
    if(s[1]!=s[n])
	{
        printf("%lld",cnt*k);
        return 0;
    }
    
    ans=cnt*k+k-1,cnt=0;
    t[1]='-',cnt++;
    
    for(int i=2;i<=n;i++)
        if(t[i]==t[i-1])
            t[i]='-',cnt++;
    
    printf("%lld",Po(ans,cnt*k));
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	int n = s.size();
	cout << s[0] << n - 2 << s[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int N,M;
int X[maxm],Y[maxm],Father[maxm];
long long Ans[maxm],Size[maxm];

int Get(int x){
	return Father[x]==x?x:Father[x]=Get(Father[x]);
}

int main(){
	register int i,Now1,Now2;
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++) scanf("%d%d",X+i,Y+i);
	for(i=1;i<=N;i++) Father[i]=i,Size[i]=1;
	Ans[M]=1ll*N*(N-1);
	for(i=M-1;i;i--){
		Now1=Get(X[i+1]),Now2=Get(Y[i+1]);
		Ans[i]=Ans[i+1];
		if(Now1==Now2) continue;
		Ans[i]-=Size[Now1]*(N-Size[Now1]);
		Ans[i]-=Size[Now2]*(N-Size[Now2]);
		Father[Now2]=Now1;
		Size[Now1]+=Size[Now2];
		Ans[i]+=Size[Now1]*(N-Size[Now1]);
	}
	for(i=1;i<=M;i++){
		printf("%lld\n",Ans[i]>>1);
	}
	return 0;
}

Measured memory_bytes: 4096
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second                                                                                                                                                                                                                                                                                                                
#define f first
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000
#define mod 1000000007
#define inf 1000000000000000000
#define mI2 500000004
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll n;
    cin>>n;
    if(n&1){
        cout<<0<<"\n";
    }else{
        ll ans=0;
        n>>=1;
        while(n){
            ans+=(n/5);
            n/=5;
        }
        cout<<ans<<"\n";
    }
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define bitcount(x) __builtin_popcount(x)

class NODE{
public:	
	int a,b,c;
	NODE(int A,int B,int C){a = A , b = B , c = C;}
};
bool operator<(const NODE &a,const NODE &b){return a.c > b.c;}

int main(){
	int n;
	while(cin >> n , n){
		int m; cin >> m;
		vector<NODE> data[100];
		priority_queue<NODE> Q;
		rep(i,m){
			int a,b,c;
			scanf("%d,%d,%d",&a,&b,&c);
			data[a].push_back(NODE(a,b,c/100-1));
			data[b].push_back(NODE(b,a,c/100-1));
		}
		int ret = 0;
		bool done[100] = {0};
		Q.push(NODE(0,0,0));
		while(Q.size()){
			NODE q = Q.top(); Q.pop();
			if(done[q.b])continue;
			else ret += q.c , done[q.b] = true;
			rep(i,data[q.b].size()) Q.push(data[q.b][i]);
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1e9+7;
void add(ll &a, ll b)
{
    a = (a+b) % MOD;
}

bool ng(int a, int b, int c)
{
    if(a == 0 && b == 1 && c == 2) return true;
    else return false;
}

int main()
{
    int n;
    cin >> n;
    // a, g, c, t : 0, 1, 2, 3
    ll dp[n+1][4][4][4];
    for(int l = 0; l <= n; l++)
    {
    for(int i = 0; i < 4; i++)
    {
      for(int j = 0; j < 4; j++)
      {
        for(int k = 0; k < 4; k++)
        {
          dp[l][i][j][k] = 0;
        }
      }
    }
    }
    dp[0][3][3][3] = 1;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                for(int l = 0; l < 4; l++)
                {
                    for(int m = 0; m < 4; m++)
                    {
                        if(ng(j, k, l)) continue; // agcx
                        if(ng(k, l, m)) continue; // xagc
                        if(ng(k, j, l)) continue; // gacx
                        if(ng(l, k, m)) continue; // xgac
                        if(ng(k, m, l)) continue; // xacg
                        if(ng(j, l, k)) continue; // acgx
                        if(ng(j, l, m)) continue; // axgc
                        if(ng(j, k, m)) continue; // agxc
                        add(dp[i][k][l][m], dp[i-1][j][k][l]);
                    }
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < 4; i++)
    {
        for(int j = 0; j < 4; j++)
        {
            for(int k = 0; k < 4; k++)
            {
                add(ans, dp[n][i][j][k]);
            }
        }
    }
    cout << ans << endl;
}



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

using namespace std;
using ll = long long;

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

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

  int ans = 0;
  rep(i, n) {
    int h;
    cin >> h;
    if (h >= k) ++ans;
  }

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


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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) { init(newn); }
  SegmentTree(const vector<T> &v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for (int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for (int i = n - 1; i; --i) dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while (n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while (k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, dat[l++]);
      if (r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
};

using P = pair<int, int>;
int n;
vector<int> p;
SegmentTree<P> odd, ev;
vector<vector<int>> memo;
vector<P> res, v;

int solve(int l, int r);

int main() {
  cin >> n;
  p.resize(n);
  memo.assign(n, vector<int>(3, -1));
  for (int &x : p) cin >> x;
  {
    auto f = [](P l, P r) { return min(l, r); };
    odd = SegmentTree<P>(n / 2, f, P(2 * n, 2 * n));
    ev = SegmentTree<P>(n / 2, f, P(2 * n, 2 * n));
    for (int i = 0; i < n / 2; ++i) {
      ev.update(i, P(p[2 * i], 2 * i));
      odd.update(i, P(p[2 * i + 1], 2 * i + 1));
    }
  }
  {
    auto f = [](int l, int r) { return v[l] > v[r]; };
    priority_queue<int, vector<int>, decltype(f)> pq(f);
    pq.push(solve(0, n));
    assert(v.size() == n / 2);
    while (pq.size()) {
      int now = pq.top();
      pq.pop();
      res.push_back(v[now]);
      for (int i = 0; i < 3; ++i)
        if (memo[now][i] >= 0) pq.push(memo[now][i]);
    }
  }
  for (int i = 0; i < n / 2; ++i)
    cout << res[i].first << " " << res[i].second << " \n"[i == n / 2 - 1];
  return 0;
}

int solve(int l, int r) {
  if (l >= r) return -1;
  int lid, rid;
  P now;
  if (l & 1) {
    P op = odd.query(l >> 1, r >> 1);
    lid = op.second;
    P ep = ev.query((lid + 1) >> 1, (r + 1) >> 1);
    rid = ep.second;
    now = P(op.first, ep.first);
  } else {
    P ep = ev.query((l + 1) >> 1, (r + 1) >> 1);
    lid = ep.second;
    P op = odd.query(lid >> 1, r >> 1);
    rid = op.second;
    now = P(ep.first, op.first);
  }
  int num = v.size();
  v.emplace_back(now);
  memo[num][0] = solve(l, lid);
  memo[num][1] = solve(lid + 1, rid);
  memo[num][2] = solve(rid + 1, r);
  return num;
}

Measured memory_bytes: 51084
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int N;
  cin>>N;
  co(N+N*N+N*N*N);
}

Measured memory_bytes: 3612
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;

class Program
{   static void Main(string[] args)
    {
        var token = Console.ReadLine().Split(' ').Select(p=>Convert.ToInt32(p)).ToArray();
        var n = token[0];
        var k = token[1];
        var q = token[2];
        var ps = new long[n];
        for(int i = 0;i < q; i++)
        {
            var p = long.Parse(Console.ReadLine()) - 1;
            ps[p]++;
        }
        for(int i = 0;i < n; i++)
        {
            var p = ps[i];
            var sum = k - (q - p);
            if(sum > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

    }
}


Measured memory_bytes: 18272
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define p 1000000007
using namespace std;
inline int get(){
	int n=0;char c;while((c=getchar())||23333){
		if(c>='0'&&c<='9')break;if(c=='-')goto s;
	}n=c-'0';while((c=getchar())||23333){
		if(c>='0'&&c<='9')n=n*10+c-'0';else return(n);
	}s:while((c=getchar())||23333){
		if(c>='0'&&c<='9')n=n*10-c+'0';else return(n);
	}
}
int dp[4001][4001];ll jc[8001],jcny[8001];
inline ll mi(int a,int b){
	ll ans=1,tmp=a;while(b){
		if(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;
	}return(ans);
}int xs[200001],ys[200001];
inline ll cnm(int n,int m){
	ll cjr=jc[n]*jcny[m];cjr%=p;cjr*=jcny[n-m];cjr%=p;return(cjr);
}
int main(){
	int n=get();for(register int i=1;i<=n;i++){
		xs[i]=get();ys[i]=get();dp[2000-xs[i]][2000-ys[i]]++;
	}jc[0]=1;for(register int i=1;i<=8000;i++)jc[i]=(jc[i-1]*i)%p;
	jcny[8000]=mi(jc[8000],p-2);for(register int i=7999;i>=0;i--)jcny[i]=(jcny[i+1]*(i+1))%p;
	for(register int i=0;i<=4000;i++){
		for(register int j=0;j<=4000;j++){
			if(i-1>=0)dp[i][j]+=dp[i-1][j];
			if(j-1>=0)dp[i][j]+=dp[i][j-1];dp[i][j]%=p;
		}
	}ll ans=0;for(register int i=1;i<=n;i++){
		ans+=dp[2000+xs[i]][2000+ys[i]];
		ans-=cnm(xs[i]+xs[i]+ys[i]+ys[i],xs[i]+xs[i]);ans%=p;ans+=p;ans%=p;
	}ans*=mi(2,p-2);ans%=p;cout<<ans<<endl;
	return(0);
}

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

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  
  int count = 0;
  int ans = 101;
  while (true) {
    if (count == k) break;
    ans--;
    if (a % ans == 0 && b % ans == 0) count++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define mod 998244353
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n;
int arr[100000+9];
ll dp[100000];
ll solve(int ind) {
    if (ind+1 == n) {
        return 0;
    }
    if(dp[ind] != -1)
        return dp[ind];
    ll a = 1e18;
    if (ind + 1 < n)
        a = min(a, solve(ind + 1) + abs(arr[ind] - arr[ind + 1]));
    if (ind + 2 < n) {
        a = min(a, solve(ind + 2) + abs(arr[ind + 2] - arr[ind]));
    }
    return dp[ind] = a;
}
int main(){
    cin>>n;
    for(int i = 0;i<n;i++){
        cin>>arr[i];
    }
    memset(dp,-1, sizeof(dp));
    cout<<solve(0);
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(10);
    //cout<<fixed;
    //cout.tie(NULL);
    vector<string>v;

    for(int i=0;i<3;i++)
    {
        string t;
        cin>>t;
        v.pb(t);
    }

    string a=v[0];
    string b=v[1];
    string c=v[2];

    cout<<a[0]<<b[1]<<c[2]<<endl;




    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int> > D(H, vector<int>(W));
	for (int y = 0; y < H; y++)
		for (int x = 0; x < W; x++)
			scanf("%d", &D[y][x]);
	vector<vector<int> > a(H, vector<int>(W));
	for (int y = 0; y < H; y++)
		for (int x = 0; x < W; x++) {
			if (!D[y][x]) continue;
			a[y + 1][x + 1] = D[y][x];
			for (int dy = 0; dy < 3; dy++)
				for (int dx = 0; dx < 3; dx++)
					D[y + dy][x + dx] -= a[y + 1][x + 1];
		}
	set<i_i> s;
	for (int y = 0; y < H; y++)
		for (int x = 0; x < W; x++) {
			if (!a[y][x]) continue;
			int cnt = 0;
			for (int dy = -1; dy <= 1; dy++)
				for (int dx = -1; dx <= 1; dx++)
					cnt += a[y + dy][x + dx];
			if (cnt <= 2 || a[y][x] >= 2)
				s.insert(i_i(y, x));
		}
	vector<i_i> v(s.begin(), s.end());
	cout << v[v.size() - 1].first << ' ';
	cout << v[v.size() - 1].second << ' ';
	cout << v[0].first << ' ';
	cout << v[0].second << endl;
}

Measured memory_bytes: 3112
num=list("0123456789")
a,b=map(int,input().split())
s=input()
 
for i in range(a+b+1):
    if i!=a:
        if s[i] not in num:
            print("No")
            break
    else:
        if s[i]!="-":
            print("No")
            break
else:
    print("Yes")

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if (a > b){
        cout << a + a-1<< endl;
    }
    else if (b > a){
        cout << b + b-1<< endl;
    }

    else{
        cout << b + a<< endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		int k = Integer.parseInt(str[1]);

		if (k != 1)
			System.out.println(n - k);
		else
			System.out.println("0");
	}
}


Measured memory_bytes: 21076
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	string t;
	
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'B'){
			if(t.size()) t.erase(t.end()-1);
		}else{
			t += s[i];
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long double n,dp[3003][3003];
vector<long double>v;
long double f(int i,int h)
{
    if(i==n)
    {
        if(h>n-h)return 1;
        else return 0;
    }
    if(dp[i][h]!=-1)return dp[i][h];
    long double s,ss;
    s=f(i+1,h+1)*v[i];
    ss=f(i+1,h)*(1-v[i]);
    return dp[i][h]=ss+s;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)dp[i][j]=-1;
    }
    for(int i=0;i<n;i++)
    {
        long double x;
        cin>>x;
        v.push_back(x);
    }
    cout<<fixed<<setprecision(10)<<f(0,0);
}


Measured memory_bytes: 141312
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
/////////

void solve(){
  ini(N);
  vi visited(N + 1 , 0);
  deque<P> d;

  d.emplace_back(1 , 1);
  while(1){
    P cur = d.front(); d.pop_front();
    
    if(cur.se == 0) die(cur.fi);
    visited[cur.se] = 1;
    // 1足す
    if(visited[(cur.se + 1) % N] == 0)
      d.emplace_back(cur.fi + 1 , (cur.se + 1) % N);
    // 10倍
    if(visited[(cur.se * 10) % N] == 0)
      d.emplace_front(cur.fi , (cur.se * 10) % N);
  }

}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10 ** 9)

class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x): #要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  #要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

print(abs(min(uf.parents)))

Measured memory_bytes: 14728
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define uint unsigned int
 
const int INF = 1e9 + 7;
 
struct Train {
    int c;
    int s;
    int f;
};
 
int main() {
    int n;
    cin >> n;
 
    vector<Train> t(n - 1);
    for (int i = 0; i < n - 1; ++i) {
        cin >> t[i].c >> t[i].s >> t[i].f;
    }
 
    for (int i = 0; i < n; ++i) {
        vector<int> ti(n, INF);
        ti[i] = 0;
        for (int j = i + 1; j < n; ++j) {
            if (ti[j - 1] < t[j - 1].s) {
                ti[j] = t[j - 1].s + t[j - 1].c;
            } else {
                int rem = ti[j - 1] % t[j - 1].f;
                if (rem > 0) {
                    rem = t[j - 1].f - rem;
                }
                ti[j] = rem + ti[j - 1] + t[j - 1].c;
            }
        }
        cout << ti[n - 1] << '\n';
    }
 
    return 0;
}

Measured memory_bytes: 256
program prob2
    implicit none
    character(105) :: s
    integer :: n, i, ans, anss
    read(*,*) n, s
    ans = 0
    anss = 0
    do i = 1, n
        if(s(i:i) == 'I')then
            ans = ans + 1
        else 
            ans = ans - 1
        end if
        anss = max(anss, ans)
    end do
    write(*,*) anss

    stop
contains
end program prob2

Measured memory_bytes: 2828