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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, k;
vector<ll> pos, neg;

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

    cin>>n>>k;
    for (int i=0; i<n; i++) {
	ll x;
	cin>>x;
	if (x>0) {
	    pos.push_back(x);
	} else if (x<0) {
	    neg.push_back(x);
	}
    }

    if (int(pos.size()+neg.size())<k) {
	out(0);
    }


    bool pcan = false;

    for (int i=0; i<=k && i<=int(neg.size()); i+=2) {
	int pneed=k-i;
	if (pneed <= int(pos.size())) {
	    pcan=true;
	}
    }


    auto sim = [&](vector<ll> pos, vector<ll> neg, int take, int k) {
	if (take>0 && pos.empty()) return vector<ll>();
	vector<ll> v;
	sort(pos.begin(), pos.end());
	if (take==1) {
	    v.push_back(pos.back()); pos.pop_back();
	    k--;
	}

	if (k%2==1) return vector<ll>();

	multiset<ll> mpos(pos.begin(), pos.end());
	multiset<ll> mneg;
	for (ll x: neg) mneg.insert(-x);

	while (k>0) {
	    if ((int)mneg.size() <= 1) {
		ll a = *mpos.rbegin(); mpos.erase(--mpos.end());
		ll b = *mpos.rbegin(); mpos.erase(--mpos.end());
		v.push_back(a);
		v.push_back(b);
	    } else if ((int)mpos.size() <= 1) {
		ll a = *mneg.rbegin(); mneg.erase(--mneg.end());
		ll b = *mneg.rbegin(); mneg.erase(--mneg.end());
		v.push_back(a);
		v.push_back(b);
	    } else {
		ll resp = 1;
		auto iter = --mpos.end();
		resp *= (*iter); --iter; resp *= (*iter);
		
		ll resn = 1;
		iter = --mneg.end();
		resn *= (*iter); --iter; resn *= (*iter);

		if (resp >= resn) {
		    auto iter = --mpos.end();
		    v.push_back(*iter);
		    --iter;
		    v.push_back(*iter);
		    mpos.erase(--mpos.end());
		    mpos.erase(--mpos.end());
		} else {
		    auto iter = --mneg.end();
		    v.push_back(*iter);
		    --iter;
		    v.push_back(*iter);
		    mneg.erase(--mneg.end());
		    mneg.erase(--mneg.end());
		}
	    }

	    k -= 2;
	}

	return v;
    };


    auto pick = [&](vector<ll> v0, vector<ll> v1) {
	if (v0.empty()) return v1;
	if (v1.empty()) return v0;
	assert(false);
	return v0;
    };

    if (pcan) {
	// parity of k determines how many pos to take
	vector<ll> v0 = sim(pos, neg, 0, k);
	vector<ll> v1 = sim(pos, neg, 1, k);
	vector<ll> res = pick(v0, v1);

	ll ans = 1;
	for (ll x: res) {
	    ans *= x;
	    ans %= mod;
	}

	ans %= mod;
	ans += mod;
	ans %= mod;
	cout<<ans<<endl;
	
    } else {
	if (int(pos.size()+neg.size())<n) {
	    out(0);
	}
	vector<ll> all;
	for (ll x: pos) all.push_back(x);
	for (ll x: neg) all.push_back(-x);

	sort(all.begin(), all.end());
	ll res=1;
	for (int i=0; i<k; i++) {
	    res=res*all[i]%mod;
	}
	res *= -1;
	res %= mod;
	res += mod;
	res %= mod;
	cout<<res<<endl;	
    }
    
    
    
    return 0;
}


Measured memory_bytes: 17300
h, w = map(int, input().split())

smap = [''.join('.' for _ in range(w+2))]
for _ in range(h):
  smap.append('.' + input().strip() + '.')
smap.append(''.join('.' for _ in range(w+2)))

is_black = True
for i, sline in enumerate(smap):
  for j, s in enumerate(sline):
    if s == '#':
      if smap[i][j-1] == '.' and smap[i][j+1] == '.' and smap[i-1][j] == '.' and smap[i+1][j] == '.':
        is_black = False

if is_black:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int cnt=1;
    for(int i=1;i<n;i++)
    {
        bool flag=true;
        for(int j=i-1;j>=0;j--)
        {
            if(a[j]>a[i])
            {
                flag=false;
                break;
            }


        }
        if(flag)
            cnt++;
    }
    cout<<cnt<<"\n";
}


Measured memory_bytes: 256
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)

a = 0
b = 0

for i in range(1,x+1):
  if (i % 2) != 0:
    a += y[i-1]
  else:
    b += y[i-1]

print(a-b)

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

int main(){
  int K;
  cin >> K;
  int d = 1, r = 7%K, m = 7%K, flag = 0;
  map<int,int> e;
  while(m != 0){
    if(e.count(m)){
      flag = 1;
      break;
    }
    else{
      e[m] = 1;
    }
    r = (r*10)%K;
    m = (m+r)%K;
    d++;
  }
  if(flag) cout << -1;
  else cout << d;
       
  return 0;
}

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




























int main () {
    int N;
    cin >> N;
    
    vector<int64_t> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    int64_t result = 0;
    int64_t n = 1000000000 + 7;

    int sum = 0;

    for (int i = N - 2; i >= 0; i--) {
        sum += a[i + 1];
        sum %= n;
        result += a[i] * sum;
        result %= n;
    }

    cout << result << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
char s[1010];
int main() {
    scanf("%s",s);
    int n=strlen(s),x=0,y=0;
    for(int i=0;i<n;i++) {
	if(s[i]=='N') x|=1;
	else if(s[i]=='S') x|=2;
	else if(s[i]=='W') y|=1;
	else y|=2;
    }
    puts(((!x||x==3)&&(!y||y==3))?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long unsigned int u64;
u64 min(const u64 a, const u64 b) {
    return a < b ? a : b;
}
u64 max(const u64 a, const u64 b) {
    return a > b ? a : b;
}
u64 numdigits(u64 n) { 
    int i;
    for(i = 0; n != 0; n /= 10, i++);
    return i;
}
u64 f(u64 a, u64 b) {
    return max(numdigits(a), numdigits(b));
}
u64 solve(u64 n) {
    u64 minf = 4000;
    for(u64 i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            u64 a = i;
            u64 b = n / i;
            minf = min(minf, f(a, b));
        }
    }
    return minf;
}
int main(void) {
    u64 n;
    scanf("%llu", &n);
    printf("%llu", solve(n));
    return 0;
}


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

const int max_N = 1e5 + 5;
int N, M;
vector<int> g[max_N];
int d[max_N];

int dfs(int x){
  if(d[x] > 0) return d[x];
  int mx = 0;
  for(int i: g[x]){
    mx = max(mx, dfs(i) + 1);
  }
  d[x] = mx;
  return mx;
}

int main(){
  cin >> N >> M;
  for (int i=0; i<M; i++){
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
  }

  for (int i=0; i<N; i++){
    d[i] = 0;
  }

  int ans = 0;
  for (int i=0; i<N; i++){
    if (d[i] == 0) ans = max(ans, dfs(i));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8192
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

int main(){

	int N,table[200030],a,b,S,tmp;

	for(int i = 0; i < 200030; i++)table[i] = 0;

	scanf("%d",&N);

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d",&a,&b);
		table[a+b]++;
	}

	for(int i = 0; i < 200030; i++){
		if(table[i] > 1){
			tmp = table[i];
			table[i] = 0;
			S = 2;
			for(int k = 0; tmp != 0;k++,tmp /= S){
				if(tmp%S == 1){
					table[i+k]++;
				}
			}
		}
	}

	for(int i = 0; i < 200030; i++){
		if(table[i] != 0){
			printf("%d 0\n",i);
		}
	}

    return 0;
}

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    str s, t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n=0,m=0,d=0,a,b,c,k,num=0;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	if(a>=b&&a>=c)
	{
		for(i=0;i<k;i++)
			a*=2;
	}
	else if(b>a&&b>c)
	{
		for(i=0;i<k;i++)
			b*=2;
	}
	else if(c>a&&c>b)
	{
		for(i=0;i<k;i++)
			c*=2;
	}
	num=a+b+c; 
	printf("%d",num);
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
	int a =	sc.nextInt();
	char op = sc.next().charAt(0);
	int b =	sc.nextInt();
	if(op=='+') System.out.println(a+b);
	else System.out.println(a-b);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    vector<bool> good(N, true);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (H[a] > H[b]) {
            good[b] = false;
        } else if (H[a] < H[b]) {
            good[a] = false;
        } else {
            good[a] = false;
            good[b] = false;
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (good[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3788
# -*- coding: utf-8 -*-
# 整数の入力


def main():
    # a, b
    a = int(input())
    s = input()
    print(process(a, s))


def process(a, s):
    if a >= 3200:
        return s
    else:
        return 'red'


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
P = LIST()
C = LIST()

loop_point = [0]*N
loop_count = [0]*N
searched = [0]*N

for i in range(N):
    if searched[i]:
        continue
    idx = i
    points = 0
    cnt = 0
    while not searched[P[idx]-1]:
        idx = P[idx]-1
        searched[idx] = 1
        cnt += 1
        points += C[idx]
    loop_count[i] = cnt
    loop_point[i] = points
    while not loop_point[P[idx]-1]:
        idx_next = P[idx]-1
        loop_count[idx_next] = loop_count[idx]
        loop_point[idx_next] = loop_point[idx]
        idx = idx_next

ans = -INF
for i in range(N):
    p = 0
    idx = i
    loop = loop_point[i] > 0 and K > loop_count[i]
    for j in range(1, min(K+1, loop_count[i]+1)):
        idx = P[idx]-1
        p += C[idx]
        if loop:
            final_p = p + loop_point[i]*((K-j)//loop_count[i])
        else:
            final_p = p
        ans = ans if ans > final_p else final_p
print(ans)


Measured memory_bytes: 75384
#include<stdio.h>

int main( ) {
	const int IN = 10;
	int mh[IN];
	int cd = 10000;
	int cu = 0;
	int i;

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

	while( 1 ) {
		if( cu >= 3 ) {
			break;
		}
		for( i = 0; i < IN; i++ ) {
			if( cd == mh[ i ] ) {
				if(cu < 3) {
					printf("%d\n",mh[ i ]);
				}
				cu++;
			}
		}
		cd--;
	}
	return 0;
}

Measured memory_bytes: 600
s=str(input())
t=str(input())

l="abcdefghijklmnopqrstuvwxyz"

ss=''.join(sorted(s))
st=''.join(sorted(t))
str=''.join(sorted(t,reverse=True))

if l.index(str[0])>l.index(ss[0]):
  ans="Yes"
elif len(t)>len(s) and ss in st:
  ans="Yes"
else:
  ans="No"
  
print(ans)


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

const int M = 1000005;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> cnt(M);
    for (int x : a) {
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x) cnt[i]++;
    }
    int ans = 0;
    for (int x : a) {
        if (cnt[x] == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7984
import java.util.*;

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

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

		if(N*M >= N+M){
			if(N*M > N-M) System.out.println(N*M);
			else System.out.println(N-M);
		}
		else{
			if(N+M > N-M) System.out.println(N+M);
			else System.out.println(N-M);
		}
	}
}

Measured memory_bytes: 24404
# coding:utf-8

n = int(input())

words = [str(input()) for _ in range(n)]

_word = str()
able = True

for index, word in enumerate(words):
    if index == 0:
        _word = word
    else:
        if ( word not in words[:index]) & (word[0] == _word[-1]):
            _word = word
        else:
            able = False
            break

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

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

int main() {
  
  ll h;
  cin >> h;
 
  ll ans = 0, cnt = 1;
  while(1) {
    h /= 2;
    ans += cnt;
    cnt *= 2;
    if (h == 0) break;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;


namespace AtCoderWorkspace
{
    class Program
    {
        static void Main(string[] args)
        {
            var cin = new Scanner();
            var N = cin.nextInt();

            int[] w = new int[N];
            for(int i = 0; i<N; i++)
            {
                w[i] = cin.nextInt();
            }

            var list = new List<int>();

            for(int t= 1; t < N; t++)
            {
                int left = 0;
                int right = 0;
                for (int i = 0; i < N; i++)
                {                    
                    if (t < i)
                    {
                        right += w[i];
                    }
                    else
                    {
                        left += w[i];
                    }
                }
                list.Add(Math.Abs(left - right));
            }
                                   
            Console.WriteLine(list.Min());
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstring>
#include <iostream>
#define oo 2139062143
#define fi first
#define se second
#define fo(i,x,y) for (int i=(x);i<=(y);++i)
using namespace std;
typedef pair<int,int> PI;
const int N=20,M=262144*2+100;
int n,m,a[M];
PI v[M][2];
int main()
{
	// freopen("D:/LiuYuanHao/a.in","r",stdin);
	scanf("%d",&n);m=1<<n;
	fo(i,0,m-1) scanf("%d",&a[i]),v[i][0].fi=a[i],v[i][0].se=i;
	fo(i,0,m-1)
	{
		fo(l,0,n)
		if(!((1<<l)&i))
		{
			int q=i|(1<<l);			
			fo(k,0,1)
				if(v[i][k].fi>v[q][0].fi) v[q][1]=v[q][0],v[q][0]=v[i][k];
				else if(v[i][k].fi>v[q][1].fi&&v[i][k].se!=v[q][0].se) v[q][1]=v[i][k];
		}
	}
	int ans=0;
	fo(i,1,m-1)
	{
		ans=max(ans,v[i][0].fi+v[i][1].fi);
		printf("%d\n",ans);
	}
	return 0;
}













Measured memory_bytes: 13312
import java.util.*;
 
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
   
    int K = sc.nextInt();
    int X = sc.nextInt();     

    if( 500 * K >= X){
      // 500*KがX以上の場合
      System.out.println("Yes");
    }else{
      //それ以外
       System.out.println("No");
    }
  }
 }

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

using ll = long long;

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

int main(){
    int N;
    cin >> N;
    ll cnt = 0;
    rep2(i, 1, N+1){
         cnt += N / i;
         if(N % i == 0) cnt--;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3628
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3 5 7"""
        output = """10"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 2 9"""
        output = """6"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """20 20 19"""
        output = """0"""
        self.assertIO(input, output)

def  resolve():
    (A,B,T)=(int(i) for i in  input().split())
    print(int(T/A)*B)
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 52076
#include<cstdio>
#include<vector>
int a[105],b[105];
int c[105],d[105];
std::vector<int>g[205];
int vis[205];
int match[205];

int dfs(int u){
    for(int v: g[u]){
        if(!vis[v]){
            vis[v] = 1;
            if(match[v]==0 || dfs(match[v])){
                match[v] = u;
                return 1;
            }
        }
    }
    return 0;
}

int getBestMatch(int n){
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int i = 1; i <= 2*n; i++) vis[i] = 0;
        ans += dfs(i);
    }
    return ans;
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d%d",&a[i],&b[i]);
    for(int i = 1; i <= n; i++) scanf("%d%d",&c[i],&d[i]);
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(c[j]>a[i] && d[j]>b[i]){
                int u = i, v = j+n;
                g[u].push_back(v);
                g[v].push_back(u);
            }
        }
    }
    printf("%d\n",getBestMatch(n));
    return 0;
}


Measured memory_bytes: 3264
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let a:usize = scan.next();
	let b:usize = scan.next();
	let c:usize = scan.next();

	for i in 1..(a * b) {
		if i % a == 0 && (i - c) % b == 0 {
			println!("YES");
			return;
		}
	}

	println!("NO");
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int r, D;
	long long x;
	cin >> r >> D >> x;
	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << "\n";
	}
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var a = make([]int, n+1)
	var time = make([]int, n+1)
	visited := []int{1}
	for i := 1; i <= n; i++ {
		fmt.Scan(&a[i])
	}
	tmp := 1
	for i := 1; i <= k; i++ {
		next := a[tmp]
		if time[next] != 0 {
			cycle := i - time[next]
			dest := (k-time[next])%cycle + time[next]
			tmp = visited[dest]
			break
		}
		time[next] = i
		visited = append(visited, next)
		tmp = next
	}
	fmt.Print(tmp)
}


Measured memory_bytes: 12352
a,b=map(int,input().split())
import math
x=min(math.floor(a/0.08),math.floor(b/0.1))
y=max(math.floor((a+1)/0.08),math.floor((b+1)/0.1))
for i in range(x,y):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        print(i)
        exit()
print(-1)
    

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int a[3][MAXN],n,tg[3],to[MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<3;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&a[i][j]);
	for(int i=1;i<=n;i++)
	{
		to[i]=a[1][i]/3+1;
		if(!((a[0][i]%3==1&&a[1][i]==a[0][i]+1&&a[2][i]==a[0][i]+2)||(a[0][i]%3==0&&a[1][i]==a[0][i]-1&&a[2][i]==a[0][i]-2))||((to[i]&1)!=(i&1)))
		{
			printf("No\n");
			return 0;
		}
		tg[i&1]^=(a[0][i]>a[1][i]);
	}
	for(int i=1;i<=n;i++)
	{
		while(to[i]!=i)
		{
			tg[i&1^1]^=1;
			swap(to[i],to[to[i]]);
		}
	}
	if(tg[0]||tg[1]) printf("No\n");
	else printf("Yes\n");
}


Measured memory_bytes: 1792
#import<bits/stdc++.h>
#define LL long long
using namespace std;
int a,b,c,i,j,k,m,n,s,t,x,y,z[100005];
int dgs(int x){int s=0;for(;x;x/=10)s+=x%10;return s;}
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int max2(int x,int y){return x>y?x:y;}
int max3(int x,int y,int z){return x>y?x>z?x:z:y>z?y:z;}
int min2(int x,int y){return x<y?x:y;}
int min3(int x,int y,int z){return x<y?x<z?x:z:y<z?y:z;}
int prime(int x){if(x<2||x%6^1&&x%6^5)return x==2|x==3;for(int i=5;i*i<=x;i+=6)if(x%i<1||x%(i+2)<1)return 0;return 1;}
char e[5];
main()
{
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",z+i);sort(z,z+n);
//for(i=0;++i<n-1;)s+=z[i]>z[i-1]&&z[i]<z[i+1]||z[i]<z[i-1]&&z[i]>z[i+1];
printf("%d",z[n/2]-z[n/2-1]);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll k,ans=0;
    cin>>k;
    for (ll a = 1; a <= k; a++)
    {
        for (ll b = 1; b <= k; b++)
        {
            for (ll c = 1; c <= k; c++)
            {
                ans+= __gcd(a,__gcd(b,c));
            }            
        }        
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
import math
A = [int(i) for i in input().split()]
A.sort()
count = 0
count = A[2] - A[1]
A[1] = count + A[1]
A[0] = count + A[0]
d = math.ceil((A[2]-A[0])/2)
count = count + d
A[0] = 2*d+A[0]
d = abs(A[2]-A[0])
count = count + d

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
int main () {
  long int N;
  long int res = 0;
  cin >> N;

  // find N = a(m+1) and sum up every m (1 <= m <= 10^12)
  int n = sqrt(N);
  for (long int i = 1; i < n+1; i++) {
    if (N%i == 0 && N/i!=i) {
      long int m = N/i - 1;
      if (m > i) {
	res+=m;
      } else {
	int a = m + 1;
	m = i-1;
      	if (m != 0 && m > a) {
      	  res+=m;
	}
      }
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in =new Scanner(new BufferedInputStream(System.in));
		while(in.hasNext())
		{
			BigInteger a = in.nextBigInteger(),b = in.nextBigInteger();
			System.out.println(a.multiply(b));
		}
		in.close();
	}

}


Measured memory_bytes: 246052
n = int(input())


def prime_factorize(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n != 1:
        res.append(n)
    return res


fac = prime_factorize(n)

from collections import Counter

ctr = Counter(fac)

ans = 0
for val in ctr.values():
    cnt = 1
    while val - cnt >= 0:
        ans += 1
        val -= cnt
        cnt += 1


print(ans)


Measured memory_bytes: 83452
import java.util.*;
public class Main {
    public static void main(String[] args) {


        Scanner sc = new Scanner(System.in);
       int r = sc.nextInt();
       int g = sc.nextInt();
       int b = sc.nextInt();
       if((10*g + b)%4 ==0){
           System.out.println("YES");
       }else{
           System.out.println("NO");
       }
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long n, r, t;
    cin >>  n >> t;
    vector<int> temp;
    temp.clear();
    while(n)
    {
        temp.push_back(n%t);
        n = n/t;
    }
    cout << temp.size();
    return 0;
}


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

int main() {
  int m, f, b;
  cin >> m >> f >> b;

  if (b <= m) cout << 0 << endl;
  else if (m < b && b <= m + f) cout << b - m << endl;
  else cout << "NA" << endl;

  return 0;
}


Measured memory_bytes: 3092
N, H = map(int, input().split())
# N < 10**5
# H < 10**9
# A<=B<=10**9

B = [0]*N
maxA = 0
for i in range(N):
    a, b = [int(x) for x in input().split()]
    B[i] = b
    maxA = max(maxA, a)

# 投げる奴の候補
B = sorted([b for b in B if b > maxA], reverse=True)

cnt = 0
for b in B:
    cnt += 1
    H -= b
    if H <= 0:
        break
if H > 0:
    q, r = divmod(H, maxA)
    cnt += q + (1 if r > 0 else 0)
print(cnt)


Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
#include <iomanip>
using namespace std;
 
int main(){
  long double n,m,d;
  cin >> n >> m >> d;
  if(d!=0){
   cout << setprecision(10)<<2*(m-1)/(n*n)*(n-d)*1.000000001 << endl;
  }
  else{
   cout << setprecision(10)<<(m-1)/n << endl;
  }
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,B;
	B=100000000000000;
	cin>>N;
	for(int i=0; i<N; i++ ){
		int a,A=0;
		cin>>a;
		for(int j=0;a%2==0;j++){
		A++;
		a/=2;
		}
		if(A<B){
			B=A;
		}
	}
	cout<<B<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[I() for i in range(n)]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b
x=lis[0]
for i in range(n-1):
    y=lis[i+1]
    x=lcm(x,y)
print(x)

    
            
        
        
    

    
        
    
    
    

Measured memory_bytes: 65724
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define di deque<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
#define mxn (ll)1e5
#define INF = 1e18L + 5;
int main(){
    ll n,k;
    cin>>n>>k;
    vi v(n);
    vi vis(n,0);
    for(ll i=0;i<n;i++){
        cin>>v[i];
    }
    ll p = 1;
    vi arr;
    bool f = false;
    while(k--){
        if(vis[p-1]==1) {
            arr.pb(p);
        }
        if(vis[p-1]==2){
            k++;
            //cout<<k<<" "<<p<<endl;
            f = true;
            break;
        }
        vis[p-1]++;
        p = v[p-1];
    }

    if(f){
        ll t = k%(arr.size());
        cout<<arr[t]<<endl;
    }
    else{
        cout<<p<<endl;
    }


}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<long double> vld;
typedef long long ll;
typedef long double ld;
#define PI 3.14159265358979323846
#define sqr(a) ((a) * (a))
#define len(V) (int)V.size()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define fix(a) fixed << setprecision(a)
#define readv(x) for(auto &_ : (x)) {cin >> _;}
#define printv(x) for(auto &_ : (x)) {cout << _ << ' ';} cout << endl
#define EPS 1e-6
#define MAXN 100047


void solve(){
	string s; cin >> s;
	vector<bool> a(123);
	
	for (auto el : s){
		if (a[(int)el]){
			cout << "no\n";
			return;
		}
		a[(int)el] = true;
	}
	cout << "yes\n";
}

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


Measured memory_bytes: 3640
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
#define INF 2000000000
#define REP(i,b,n) for(int i = (b); i < n; i++)
#define rREP(i,b,n) for(int i = n; i >= b; i--)
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const string lowercase = "abcdefghijklmnopqrstuvwxyz";
const string uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int gcd(int a, int b){return b ? gcd(b, a % b): a;}

int main()
{
    int N, T;
    cin >> N >> T;
    int ans = INF;
    bool isTLE = true;
    REP(i,0,N){
        int ci, ti;
        cin >> ci >> ti;
        if(ti <= T){
            ans = min(ans, ci);
            isTLE = false;
        }
    }
    if(isTLE) cout << "TLE" << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
lis = []
rank1 = []
for i in range(5):
  lis.append(input())
  rank1.append( 10 if lis[-1][-1] == "0" else int(lis[-1][-1]))

min_index = rank1.index(min(rank1))
  
ans = 0
for i in range(5):
  if i == min_index:
    continue
  ans = (ans + int(lis[i]) + 9)//10*10
ans += int(lis[min_index])

print(ans)



Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i, n, x=0;
    scanf("%d", &n);
    if(n == 10|n == 100|n == 1000|n == 10000|n == 100000) x = x+9;
    x = x + n/100000 + n%100000/10000 + n%10000/1000 + n%1000/100 + n%100/10 + n%10;
    printf("%d", x);
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a==5&&b==5&&c==7){
        cout << "YES" << endl;
    }else if(a==5&&b==7&&c==5){
        cout << "YES" << endl;
    }else if(a==7&&b==5&&c==5){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
//By Don4ick 
//#define _GLIBCXX_DEBUG

#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 105;

using namespace std;

int n, m, a[N][N], dp[N][N][N][N];

int get(int x1, int y1, int x2, int y2)
{
	if (x1 != x2 && y1 != y2)
		assert(false);	
	return max(0, a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1]);
}

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

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m;
	int x = -1, y = -1;
	forn(i, n)
	{
		string s;
		cin >> s;
		for (int j = 0; j < (int)s.size(); j++)
		{		
			if (s[j] == 'E')
			{
				x = i, y = j + 1;
			}
			else if (s[j] == 'o')
			{
				a[i][j + 1] = 1;
			}
		}
	}
	forn(i, n)
		forn(j, m)
			a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
	//~solve
	int ans = 0;
	for (int l = 0; l <= x - 1; l++)
	{	
		for (int r = 0; r <= n - x; r++)
		{
			for (int u = 0; u <= y - 1; u++)
			{
				for (int d = 0; d <= m - y; d++)
				{
					if (l < x - 1 && x - l - 1 >= r + 1)
						dp[l + 1][r][u][d] = max(dp[l + 1][r][u][d], dp[l][r][u][d] + get(x - l - 1, max(d + 1, y - u), x - l - 1, min(m - u, y + d)));
					if (r < n - x && x + r + 1 <= n - l)
						dp[l][r + 1][u][d] = max(dp[l][r + 1][u][d], dp[l][r][u][d]	+ get(x + r + 1, max(d + 1, y - u), x + r + 1, min(m - u, y + d)));
					if (u < y - 1 && y - u - 1 >= d + 1)
						dp[l][r][u + 1][d] = max(dp[l][r][u + 1][d], dp[l][r][u][d] + get(max(r + 1, x - l), y - u - 1, min(x + r, n - l), y - u - 1));
					if (d < m - y && y + d + 1 <= m - u)
						dp[l][r][u][d + 1] = max(dp[l][r][u][d + 1], dp[l][r][u][d] + get(max(r + 1, x - l), y + d + 1, min(x + r, n - l), y + d + 1));
					ans = max(ans, dp[l][r][u][d]);
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 230016
#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 a, b, c, d;
  cin >> a >> b >> c >> d;

  int secnd_start_time = max(a, c);
  int first_end_time = min(b, d);

  int double_time = first_end_time - secnd_start_time;

  cout << max(double_time, 0) << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n;
  cin>>n;
  vector<int> a(n+1);
  rep(i,n){
    cin>>a[i+1];
  }

  vector<int> b;
  bool c[300000]={};

  RFOR(i,n,1){
    int res=0;
    int j=i;
    while(j<=n){
      if(c[j]) res=(res+1)%2;
      j+=i;
    }
    if(res!=a[i]){
      b.PB(i);
      c[i]=true;
    }
  }

  sort(all(b));
  cout<<b.size()<<endl;
  for(int t:b){
    cout<<t<<endl;

  }

}

Measured memory_bytes: 3956
def resolve():
    n = int(input())
    S = [tuple(map(int, input().split())) for i in range(2)]
    ans = 0
    for i in range(n):
        sum = 0
        for j in range(0, i+1):
            sum += S[0][j]
            if j == i:
                sum += S[1][j]
        for k in range(i+1, n):
            sum += S[1][k]
        ans = max(sum, ans)

    print(ans)
if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long i64;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const i64 INF_LONG = 1LL << 62;
const i64 INF_LONG_NEG = INF_LONG * -1;

int main()
{
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> A(N+9, 0);
    rep(i, Q)
    {
        int tmp; cin >> tmp;
        ++A[tmp];
    }

    rep(i, N){
        if (A[i + 1] > Q - K) puts("Yes");
        else puts("No");
    }


    return 0;
}


Measured memory_bytes: 1024
K,A,B = map(int,input().split())

if B-A < 3:
  print(1+K)
  exit()

ans = 1

N = K - (A-1)
if N >= 2:
  ans += A-1
  ans += (B-A)*(N//2) + N%2
else:
  ans += K
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<stack>
#include<map>
#include<iostream>
#include<algorithm>
#define m(a,b) memset(a,b,sizeof(a));
using namespace std;
typedef long long LL;
typedef pair<int,int>PII;
const int inf = 1 << 30;
const int maxn = 1e5;
map<int,int>mp;
map<int,int>::iterator it;
int ans = 0;
int main(){
	int n;
	char num[3][3];
	for(int i = 0;i<3;i++){
		for(int j = 0;j<3;j++){
			cin >> num[i][j];
		}
	}
	printf("%c%c%c\n",num[0][0],num[1][1],num[2][2]);
	return 0;
}

Measured memory_bytes: 256
N, K, Q = gets.split.map!(&:to_i)

cnt = Array.new(N, 0)
Q.times.map do
  a = gets.to_i
  cnt[a-1] += 1
end

cnt.each do |c|
  if K - (Q - c) > 0
    puts 'Yes'
  else
    puts 'No'
  end
end


Measured memory_bytes: 4020
import collections
n = int(input())
d_list = list(map(int, input().split()))
m = int(input())
t_list = list(map(int, input().split()))

if m > n:
    print("NO")
    exit()

d_c = collections.Counter(d_list)
t_c = collections.Counter(t_list)

for i in t_c:
    if t_c[i] <= d_c[i]:
        continue
    else:
        print("NO")
        exit()

print("YES")


Measured memory_bytes: 57188
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.size();
	int ans=-1,sum=0;
	for (int i=0;i<len;i++)
	{
		if (s[i]!='A'&&s[i]!='T'&&s[i]!='G'&&s[i]!='C')
		{
			ans=max(ans,sum);
			sum=0;
			continue;
		}
		sum++;
	}
	printf("%d",max(sum,ans));
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;

    vs64 s(n + 1);
    s[0] = 0;
    s64 a;
    rep (i, n)
    {
        cin >> a;
        s[i + 1] = s[i] + a;
    }

    s64 x, y;
    s64 ans = (s64)1e18;
    for (int i = 1; i < n; ++i)
    {
        x = s[i];
        y = s[n] - s[i];
        ans = MIN(ans, abs(x - y));
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
using Graph = vector<vector<int>>;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ
/*






*/
//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vint num(n) ;
  int ans = 0 ;
  REP(i,n){
    cin >> num[i] ;
  }
  queue<char> Q ;
  REP(i,n-1){
    if(num[i]<num[i+1]){
      Q.push('+') ;
    }
    else if(num[i]>num[i+1]){
      Q.push('-') ;
    }
    else{
      Q.push('0') ;
    }
  }
  
  char a = '0' ;
  while(!Q.empty()){
    char c = Q.front() ;
    Q.pop() ;
    if(c=='+'){
      if(a=='0' || a=='+'){
        a = '+' ;
      }
      else{
        a = '0' ;
        ans++ ;
      }
    }
    if(c=='-'){
      if(a=='0' || a=='-'){
        a = '-' ;
      }
      else{
        a = '0' ;
        ans++ ;
      }
    }
  }
  
  cout << ans+1 <<endl ;
    
  
      
  
  
  
  return 0 ;
}



Measured memory_bytes: 768
#include<iostream>
#include<climits>
using namespace std;
#define ll long long int
ll arr[100001];
ll dp[100001];

int solve(int n,int k)
{
    dp[1]=0;
    //dp[2]=abs(arr[2]-arr[1]);
   ll m=0;
    
    for(ll i=2;i<=n;i++)
    {   
    	ll ans =INT_MAX;
        for(int j=1;j<=k;j++)
        {
        	if(i>j)
        	{
        		 m=dp[i-j]+abs(arr[i]-arr[i-j]);
        		ans = min(ans,m);
        	}
        }
        dp[i]=ans;
    }
   // for(int i=1;i<=n;i++)  cout<<dp[i]<<endl;

      return dp[n];

}
int main()
{
    ll n;  cin>>n;
    ll k; cin>>k;
    
    for(int i=1;i<=n;i++)  cin>>arr[i];

    cout<<solve(n,k)<<endl;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

#define MAX_N 100005
ll K;

struct data{
  ll l,m,r;
  data(ll l=0,ll m=0,ll r=0) : l(l),m(m),r(r) {}
};

data merge(data a,data b){
  if(a.l==-1)return b;
  if(b.l==-1)return a;
  
  ll M=a.m+b.m;
  if( (a.r+b.l)%K>0 ){
    M+=(a.r+b.l);
  }
  return data(a.l,M,b.r);
}

#define segN (1<<17)
struct segtree{
  data t[ segN*2 ];
  void update(int i,data d){
    i+=(segN-1);
    t[i]=d;
    while(i){
      i=(i-1)/2;
      t[i]=merge(t[i*2+1],t[i*2+2]);
    }
  }

  data tmp;

  void dfs(int a,int b,int k,int l,int r){
    if(b<=l||r<=a)return;
    
    if(a<=l&&r<=b){
      tmp=merge(tmp,t[k]);
    }else{
      int m=(l+r)/2;
      dfs(a,b,k*2+1,l,m);
      dfs(a,b,k*2+2,m,r);
    }
  }
  
  data get(int a,int b){
    tmp=data(-1,-1,-1);
    dfs(a,b,0,0,segN);
    return tmp;
  }
};

segtree T;
int N,Q; // K
vector<int> G[MAX_N];
vector<int> vd;
map<int,int> mp;
map< P , int > edges;


int parent[MAX_N];
int size[MAX_N];
int head[MAX_N];
int depth[MAX_N];

void rec(int pos,int prev){
  parent[pos]=prev;
  size[pos]=1;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    depth[to]=depth[pos]+1;
    rec(to,pos);
    size[pos]+=size[to];
  }
}

void rec2(int pos,int prev){

  vd.push_back(pos);
  int maxi=-1;
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev)continue;
    if(maxi==-1 || size[to]>size[maxi])maxi=to;
  }

  if(maxi==-1)return;
  
  head[maxi]=head[pos];  
  rec2(maxi,pos);

  
  for(int i=0;i<(int)G[pos].size();i++){
    int to=G[pos][i];
    if(to==prev||to==maxi)continue;
    rec2(to,pos);
  }
}

int lca(int a,int b){
  while(1){
    int A=head[a];
    int B=head[b];
    if(A==B){
      if(depth[a]<depth[b])return a;
      else return b;
    }
    if(depth[A]>depth[B])a=parent[A];
    else b=parent[B];
  }
  return -1;
}

ll solve(int id){
  if(id==0)return 0;
  
  data res=data(-1,-1,-1);

  while(id!=-1){
    int next=head[id];
    data d=T.get( mp[next], mp[id]+1 );
    res=merge(d,res);
    if(id==0)break;
    id=parent[next];
  }
  
  return res.m;
}

int main(){
  cin>>N>>K;
  
  for(int i=0;i<N-1;i++){
    ll a,b,c;
    cin>>a>>b>>c;
    G[a].push_back(b);
    G[b].push_back(a);

    edges[ P(a,b) ]=c;
    edges[ P(b,a) ]=c;
  }

  for(int i=0;i<N;i++)head[i]=i;
  
  rec(0,-1);
  rec2(0,-1);
  
  /*
  for(int i=0;i<N;i++){
    cout<<"head["<<i<<"]="<<head[i]<<endl;
  }
  */
  
  for(int i=0;i<N;i++)mp[ vd[i] ]=i;

  for(int i=1;i<N;i++){
    int pos=i;
    int par=parent[pos];
    int cost=edges[ P(pos,par) ];
    T.update( mp[pos] , data( cost , 0, 0 ) );
  }

  cin>>Q;
  for(int i=0;i<Q;i++){
    
    string str;
    ll a,b;
    cin>>str>>a>>b;
    
    if(str=="send"){
      int c=lca(a,b);

      
      cout<< solve(a)+solve(b)-solve(c)*2LL <<endl;
    }
    
    if(str=="add"){
      data d=T.get( mp[a], mp[a]+1 );
      d.l+=b;
      d.r+=b;
      T.update( mp[a], d );
    }
  }
  
  return 0;
}

Measured memory_bytes: 36492