akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.length();
  bool ok = true;
  if(s[0] != '1' || s[n - 1] != '0') ok = false;
  FOR(i,0,n/2-1) {
    if(s[i] != s[n - 2 - i]) ok = false;
  }
  if(!ok) {
    cout << -1 << endl;
    return 0;
  }

  //ok
  int last = 2;
  cout << "1 2" << endl;
  FOR(i,1,n-1) {
    cout << last <<  " " << i + 2 << endl;
    if(s[i] == '1') {
      last = i + 2;
    }
  }
}

Measured memory_bytes: 1616
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let w: Vec<i32> = (0..n).map(|_| input()).collect();

    let s: i32 = w.iter().sum();
    let mut ans = i32::max_value();
    for t in 0..n {
        let s1: i32 = w[0..t].iter().sum();
        let s2: i32 = s - s1;
        ans = std::cmp::min(ans, (s1 - s2).abs());
    }
    println!("{}", ans);
}


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

//階乗
ll factorial(ll num){ll sum = 1; for(ll i=1;i<=num;i++) sum*=i; return sum;}
//素数判定
bool isPrime(ll num){if(num<2){return false;}else if(num==2){return true;}else if(num%2==0){return false;} double sqrtNum=sqrt(num);for(int i=3;i<=sqrtNum;i+=2){if(num%i==0)return false;}return true;}

int main(){
  vector<int> n(3);
  rep(i,3) cin >> n[i];
  int k;
  cin >> k;
  sort(n.begin(),n.end());
  rep(i,k) n[2] *= 2;
  int ans = 0;
  rep(i,3) ans += n[i];
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define maxn 100001
using namespace std;
int f[maxn],h[maxn],n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	memset(f,0x3f3f3f3f,sizeof(f));
	f[1]=0,f[2]=abs(h[1]-h[2]);
	for(int i=3;i<=n;i++)
		for(int j=i-1;j>=max(i-k,1);j--)
			f[i]=min(f[i],abs(h[j]-h[i])+f[j]);
	cout<<f[n];
	return 0;
}

Measured memory_bytes: 1024
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))


N, X, Y = LI()
X -= 1
Y -= 1
anss = [0 for i in range(N)]

for i in range(N):
    for j in range(i + 1, N):
        anss[min(
            abs(i - j), 
            abs(X - i) + 1 + abs(j - Y),
            abs(Y - i) + 1 + abs(X - j)
        )] += 1

for i in range(1, N):
    print(anss[i])


Measured memory_bytes: 6348
//Single_Source_Shortest_Path_I
/*
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3
*/
#include <iostream>
using namespace std;
static const int INF = (1<<21);

int main(){

    int n;
    cin>>n;
    int M[100][100];
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            if(i==j)
                M[i][j]=0;
            else
                M[i][j]=INF;
        }
    }
    int w,m,v,u;
    for(int i=0;i<n;i++){
        cin>>u>>m;
        for(int j=0;j<m;j++){
            cin>>v>>w;
            M[u][v]=w;
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                if(M[i][j]>M[i][k]+M[k][j])
                    M[i][j]=M[i][k]+M[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<M[0][i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 3140
n,k = map(int,input().split())
h = list(map(int,input().split()))
k = min(k,n-1)
ans = [0]*(k+1)
temp_min = 10**10
for i in range(1,k+1):
    ans[i] = abs(h[0]-h[i])
for i in range(k+1,n):
    temp_min = 10**10
    for j in range(1,k+1):
        temp_min = min(temp_min,ans[i-j]+abs(h[i]-h[i-j]))
    ans.append(temp_min)
print(ans[-1])

Measured memory_bytes: 57568
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LIN(N)
    for i,a in enumerate(A):
        if i<a:
            print(-1)
            return
    now_lim = 0
    ans = 0
    for i in range(N)[::-1]:
        now_lim-=1
        now_lim = max(0, now_lim)
        # print(i,A[i],now_lim)
        if A[i]<now_lim:
            print(-1)
            return
        elif A[i] == now_lim:
            pass
        else:
            ans += A[i]
        now_lim = max(A[i],now_lim)
        # print(i,ans)
    print(ans)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 82264
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

char a[55][55], b[55][55];
int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
  {
    scanf("%s", a[i]);
  }
  for (int i = 0; i < m; i++)
  {
    scanf("%s", b[i]);
  }
  for (int i = 0; i <= n - m; i++)
  {
    for (int j = 0; j <= n - m; j++)
    {
      int flag = 1;
      for (int ii = 0; ii < m; ii++)
      {
        for (int jj = 0; jj < m; jj++)
        {
          if (a[i + ii][j + jj] != b[ii][jj])
          {
            flag = 0;
            break;
          }
        }
      }
      if (flag)
      {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
}


Measured memory_bytes: 128
N, A = gets.split.map &:to_i
X = gets.split.map &:to_i

dp = Array.new(N+1){Array.new(50*N+1, 0)}
dp[0][0] = 1
X.each do |x|
  N.downto(1) do |j|
    (50*N).downto(x) do |k|
      dp[j][k] += dp[j-1][k-x]
    end
  end
end

p 1.upto(N).map{|i| dp[i][i*A]}.inject :+


Measured memory_bytes: 2812
import sys
input = sys.stdin.readline
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = sorted(list(int(i) for i in input().split()))
  f = sorted(list(int(i) for i in input().split()),reverse = True)
  if sum(a) <= k:
    print(0)
    exit()
  
  ng = 0
  ok = 10**12

  while ok-ng >1 :
    next = (ok+ng)//2
    #a*fの値がnext以下になるか判定する
    tmpk = k
    for i in range(n):
      ta = a[i]
      tf = f[i]
      if ta*tf > next:
        tmpk -= math.ceil((ta*tf-next)/tf)

    if tmpk < 0:
       ng = next
    else:
       ok = next
  print(ok)
    
solve()

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

using namespace std;

int n;

int main(){
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        int k=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) k++;
        }
        if(k==8 && i%2==1) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
 
 
int main(){
    ll x,y,sum,n,m,i,j,ans,dekai,yabai,yabee;
    dekai = 1000000007;
    bool judge = false;
    cin >> x >> y;
    sum = x+y;
    if(sum % 3 == 0){
        judge = true;
    }
    n = -1;
    m = -1;
    if(judge){
        n = (2*y-x)/3;
        m = (2 * x-y)/3;
    }
    if(n >= 0 && m >=0){
   
        //ans = kaijou[n+m]/(kaijou[n]*kaijou[m]);
        ll kaijou[n+m+1];
        kaijou[0] = 1;
        for(i = 1; i <= n+m; i++){
            kaijou[i] = kaijou[i-1] * i % dekai;
        }
 
        yabai = modinv(kaijou[n] * kaijou[m],dekai);
        ans = kaijou[n+m] * yabai % dekai;
    } 
    else{
        ans = 0;
    }
 
    cout << ans << endl;
}
 
 


Measured memory_bytes: 5504
#include<stdio.h>
int main()
{
    int n,m=0,nm;
    scanf("%d",&n);
    nm=n;
    while(n!=0)
    {
        m=(m*10)+(n%10);
        n=n/10;
    }
    if(nm==m)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	vector<int> gp({-1,1,3,1,2,1,2,1,1,2,1,2,1});
	int x,y; cin>>x>>y;
	cout << (gp[x]==gp[y] ? "Yes" : "No") << endl;
	return 0;
}


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

int main(){
    double pai=3.141592653589;
    char w;
    int ans;
    for(;;){
        ans=0;
        for(;;){
            scanf("%c",&w);
            if(w=='\n'){
                printf("%d\n",ans);
                break;
            }else{
                ans+=(static_cast<int>(w)-48);
            }
            if(ans==0){
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3192
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes,no): print(yes) if b else print(no)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right

s=s0()
t=s0()
p0(s==t[:-1],"Yes","No")
    

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

int n;
string s;

int main()
{
  cin >> n;

  while(n--){
    int base = 0;
    int out = 0;
    int score = 0;

    while(cin >> s){
      if(s == "HIT"){
        score += (base >> 2) & 1;
        base = (((1 << 3) - 1) & (base << 1)) | 1;
        continue;
      }
      if(s == "HOMERUN"){
        rep(i, 3) score += (base >> i) & 1;  score += 1;
        base = 0;
        continue;
      }
      if(s == "OUT"){
        out += 1;
        if(out >= 3) break;
      }
    }

    cout << score << endl;
  }

  return 0;
}

Measured memory_bytes: 1208
#![allow(non_snake_case)]

use proconio::input;

fn main() {
    input! {
        S: String,
        T: String,
        A: usize,
        B: usize,
        U: String
    }

    solve(S, A, B, U);
}

fn solve(S: String, A: usize, B: usize, U: String) {
    if S == U {
        println!("{} {}", A - 1, B);
    } else {
        println!("{} {}", A, B - 1);
    }
}


Measured memory_bytes: 2132
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;


int main() {
    ll a,b;
    scanf("%lld %lld",&a,&b);
    if ((max(a,b) - min(a,b)) % 2 == 0) {
        printf("%lld\n",(a+b)/2);
    } else printf("IMPOSSIBLE\n");
    return 0;
} 

Measured memory_bytes: 128
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1 << 30,mod=1000000007;

int n,k;
int dp[52][2505][52];

signed main(){
	scanf("%lld%lld",&n,&k);
	
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++){
		for(int s=0;s<=k;s++){
			for(int j=0;j<=n;j++){
				if(s+2*j<=k){
					(dp[i+1][s+2*j][j]+=dp[i][s][j])%=mod;
					(dp[i+1][s+2*j][j+1]+=dp[i][s][j])%=mod;
					if(j>0){
						(dp[i+1][s+2*j][j-1]+=1ll*j*j*dp[i][s][j]%mod)%=mod;
						(dp[i+1][s+2*j][j]+=2ll*j*dp[i][s][j]%mod)%=mod;
					}
				}
			}
		}
	}
	printf("%lld\n",dp[n][k][0]);

	return 0;
}


Measured memory_bytes: 52096
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
n = inp.shift() * 1
arr = []
max = 0
c = 0
for(i=0;i<n;i++) {
    a = inp.shift() * 1
    arr[i] = new Array(n)
    for(j=0;j<a;j++) {
        l = inp.shift().split(' ')
        x = l[0] - 1
        y = l[1] * 1
        arr[i][x] = y
    }
}

b = []
for(x=Math.pow(2,n)-1;x>=0;x--) {
    ax = new Array(n)
    for(i=0;i<n;i++) {
        ax[i] = 0
    }
    y = x
    i = 0
    while(y) {
        ax[i] = y % 2
        y >>= 1
        i++
    }

    f = 0
    for(i=0;i<n;i++) {
        if (ax[i] != 1) {
            continue;
        } 
        for(j=0;j<n;j++) {
            if (i == j) {
                continue;
            }
            if (arr[i][j] !== undefined) {
                if (ax[j] != arr[i][j]) {
                    f = 1
                    break;
                } 
            }
        }
        if (f) {
            break;
        }
    }
    if (!f) {
        c = ax.filter(x => x == 1).length
        if (max < c) {
            max = c
        }
    }
}

console.log(max)

Measured memory_bytes: 10268
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String last = s.substring(s.length() - 1);
		
		if (!last.equals("s")) {
		  System.out.println(s + "s");
		} else {
		  System.out.println(s + "es");
		}
	}
}

Measured memory_bytes: 38428
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A;
  map<int, int> amap;
  int bmap[1000005];
  for(int i=0;i<1000005;++i) bmap[i] = 0;
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) A.push_back(tmp);
    amap[tmp]++;
  }
  sort(A.begin(), A.end());
  int ans = 0;
  for(int i=0;i<A.size();++i) {
    if(amap[A[i]]==1 && bmap[A[i]]==0) {
      ans++;
      for(int j=1;A[i]*j<=1000000;++j) bmap[A[i]*j]++;
    }
    else if(bmap[A[i]]>0) continue;
    else {
      for(int j=1;A[i]*j<=1000000;++j) bmap[A[i]*j]++;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 17232
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const int inf = 1e9;
int n;
int t[20][20];
int dp[1<<20];

int main() {
    while (1) {
        cin >> n;
        if (!n) break;
        rep(i,n) rep(j,n+1) cin >> t[i][j];
        rep(i,1<<n) dp[i] = inf;
        dp[0] = 0;

        rep(bit,1<<n) {
            if (dp[bit] == inf) continue;
            rep(i,n) {
                if (bit & (1<<i)) continue;
                int mn = t[i][0];
                rep(j,n) {
                    if (bit & (1<<j)) {
                        chmin(mn, t[i][j+1]);
                    }
                }
                chmin(dp[bit|(1<<i)], dp[bit]+mn);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3348
N, T = map(int, input().split())
min_cost = 2000
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        min_cost = min(min_cost, c)
        
if min_cost == 2000:
    print("TLE")
else:
    print(min_cost)

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

ll f(ll n) {
  ll ret = 0;
  while (n > 0) {
    n %= __builtin_popcountll(n);
    ret++;
  }
  return ret;
}

int main()
{
  ll n; cin >> n;
  string s; cin >> s;

  ll d = 0;
  for (int i=0; i<n; i++) {
    if (s[i] == '1') d++;
  }

  ll a = d-1;
  ll b = d+1;

  vector<ll> x(n, 1);
  vector<ll> y(n, 1);
  rep(i, n-1) {
    if (a > 0) x[n-i-2] = (x[n-i-1]*2) % a;
    if (b > 0) y[n-i-2] = (y[n-i-1]*2) % b;
  }

  ll xx = 0;
  ll yy = 0;
  rep(i, n) {
    if (s[i] == '1') {
      xx += x[i]; yy += y[i];
    }
  }

  for (int i=0; i<n; i++) {
    if (s[i] == '1') {
      if (a <= 0) {
        cout << 0 << endl;
        continue;
      }
      ll ans = f((xx + a - x[i]) % a) + 1;
      cout << ans << endl;
    } else {
      ll ans = f((yy + y[i]) % b) + 1;
      cout << ans << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 6704
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  int k=0,ans=0;
  for(int &i:A){
    cin>>i;
    ans+=(i+k)/2;
    if(i==0)
      k=0;
    else
      k=(i+k)%2;
  }
  cout<<ans<<endl;
}

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

#define int long long

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

int N, K;
int A[100000];

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

signed main() {
    cin >> N >> K;
    int m = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        m = max(m, A[i]);
    }
    int x = A[0];
    for (int i = 1; i < N; i++) {
        x = gcd(x, A[i]);
    }
    if (K <= m && K % x == 0) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll n, m;
ll root[500000];
ll sz[500000];
vector<ll> ans;
vector<pii> v;
ll res = 0;

int Root(int x)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x]);
}

void Merge(int a, int b)
{
    a = Root(a);
    b = Root(b);
    if (a == b) return;
    if (sz[a] <= sz[b])
    {
        res += sz[a] * sz[b];
        sz[b] += sz[a];
        root[a] = b;
    }
    else
    {
        res += sz[a] * sz[b];
        sz[a] += sz[b];
        root[b] = a;
    }
}

signed main()
{
    srand(time(NULL));
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) root[i] = i, sz[i] = 1;
    for (int i = 0; i < m; i++)
    {
        pii g;
        cin >> g.first >> g.second;
        v.push_back(g);
    }
    reverse(v.begin(), v.end());
    for (int i = 0; i < m; i++)
    {
        ans.push_back(n * (n - 1) / 2 - res);
        Merge(v[i].fi, v[i].se);
    }
    reverse(all(ans));
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    //*/
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for (int i = 0; i < b; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << '0';
        }

        for (int j = a; j < w; ++j) {
            cout << '1';
        }

        cout << endl;
    }

    for (int i = b; i < h; ++i) {
        for (int j = 0; j < a; ++j) {
            cout << '1';
        }

        for (int j = a; j < w; ++j) {
            cout << '0';
        }

        cout << endl;
    }
}

Measured memory_bytes: 3556
from collections import namedtuple


class UnionFind:
  def __init__(self, n):
    self.par = [i for i in range(n + 1)]
    self.size = [1] * (n + 1)

  def is_same(self, a, b):
    return self.find(a) == self.find(b)

  def unite(self, a, b):
    a = self.find(a)
    b = self.find(b)  
    if self.size[a] < self.size[b]:
      a, b = b, a
    self.par[b] = a
    self.size[a] += self.size[b]

  def size_of(self, a):
    return self.size[self.find(a)]

  def find(self, a):
    if a == self.par[a]:
      return a
    self.par[a] = self.find(self.par[a])
    return self.par[a]

Edge = namedtuple('Edge', 'w s t')

V, E = map(int, input().split())
edges = []

for _ in range(E):
  s, t, w = map(int, input().split())
  edges.append(Edge(w, s, t))

edges.sort()

u = UnionFind(V)
cost = 0

for w, s, t in edges:
  if u.is_same(s, t):
    continue
  u.unite(s, t)
  cost += w

print(cost)



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    vector<int> a(3);

    rep(i, 3) cin >> a[i];
    sort(ALL(a));

    OP(a[0] + a[1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    bool b;
    b = (s[2]==s[3]&&s[4]==s[5]);
    cout<<(b?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            char[] digits = scanner.next().toCharArray();
            Arrays.sort(digits);
            int maximum = 0;
            int minimum = 0;
            for (int j = 0; j < digits.length; j++) {
                maximum = maximum * 10 + (digits[digits.length - j - 1] - '0');
                minimum = minimum * 10 + (digits[j] - '0');
            }
            System.out.println(maximum - minimum);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int A[100010];
  for ( int i = 1; i <= N; i++ ) {
    cin >> A[i];
  }
  A[0] = A[N+1] = 0;
  ll dis = 0;
  for ( int i = 0; i <= N; i++ ) {
    dis += abs(A[i+1]-A[i]);
  }
  
  for ( int i = 1; i <= N; i++ ) {
    cout << dis-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e12 + 5;


ll DFSutils(ll nodeN, vector<ll>&pathLen, vector<vector<ll>>& adjList){
    if(pathLen[nodeN] != -1) return pathLen[nodeN];
    ll curPath = -1;
    for(ll neighNode : adjList[nodeN]){
        curPath = max(curPath, 1 + DFSutils(neighNode, pathLen, adjList));
    }
    pathLen[nodeN] = curPath;
    return curPath;
}

int main(){
	ll N, M; cin >> N >> M;
        vector<vector<ll>> adjList(N + 1);
        vector<ll> pathLen(N + 1, -1);
        for(int nodeN = 1; nodeN <= N; ++nodeN) adjList[0].push_back(nodeN);
        for(ll rep = 0; rep < M; ++rep){
            ll from, to;
            cin >> from >> to;
            adjList[from].push_back(to);
        }
        ll maxPath = DFSutils(0, pathLen, adjList);
        cout << maxPath << endl;
    	return 0;
}

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

int func(int N){
    if (N < 10) return N;
    return func(N / 10) + N % 10;
}
int main() {
    int N;
    cin >> N;
    int s = func(N);

    if(N % s == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

class Osa_k():
    def __init__(self, n):
        self.sieve = list(range(n + 1))
        self.sieve[0] = 1 #素数でない
        self.sieve[1] = 1 #素数でない
        m = int(math.sqrt(n))
        for i in range(2, m + 1):
            if self.sieve[i] < i:
                continue
            for j in range(i * i, n + 1, i):
                if self.sieve[j] == j:
                    self.sieve[j] = i

    def factorize(self, n):
        prime = defaultdict(int)
        if n == 0 or n == 1:
            return n
        opt = n
        while opt > 1:
            prime[self.sieve[opt]] += 1
            opt //= self.sieve[opt]
        return sorted(prime.items())

N = getN()
A = getList()
O = Osa_k(10 ** 6 + 1)

pair = True
primes = set()
x = A[0]
for a in A[1:]:
    x = math.gcd(x, a)
    if pair and a != 1:
        factor = set()
        for i in O.factorize(a):
            factor.add(i[0])
        if not primes.isdisjoint(factor):
            pair = False
        else:
            primes |= factor

if pair:
    print("pairwise coprime")
elif x == 1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 200748
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  int c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    }
  int ans=0;
  for(int i=0;i<n;i++){
    if(c[i]==i+1){
      ans++;
      c[i+1]=c[i];
      }
    }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n,a,b;
	cin>>n>>a>>b;
	ll x=n/(a+b)*a;
	ll p=n%(a+b);
	if(p>=a)x+=a;
	else x+=p;
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    int a,b;
    cin >> k;
    cin >> a >> b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}




Measured memory_bytes: 3632
function Main(input){
	input = input.split("\n");
	var arr = input[1].split(" ").map(Number)
	var m = new Array(200010).fill(0);
	for(var i=0;i<arr.length;i++){
		m[arr[i]]++;
	}
	var sum = 0;
	for(i=0;i<m.length;i++){
		sum += m[i]*(m[i]-1)/2;
	}
	for(i=0;i<arr.length;i++){
		console.log(sum-m[arr[i]]+1);
	}
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 51516
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int num;
    long long int m=0,a=0,r=0,c=0,h=0;
    
    long long int ans=0,mix[10];
    char name[100000][11];
    scanf("%d",&num);
    
    for(int i=0;i<num;i++){
        scanf("%s",name[i]);
        switch(name[i][0]){
            case 'M':
                m++;
                break;
            case 'A':
                a++;
                break;
            case 'R':
                r++;
                break;
            case 'C':
                c++;
                break;
            case 'H':
                h++;
                break;
            default:
                break;
        }
    }
    
    mix[0] = m * a * r;
    mix[1] = m * a * c;
    mix[2] = m * a * h;
    mix[3] = m * r * c;
    mix[4] = m * r * h;
    mix[5] = m * c * h;
    mix[6] = a * r * c;
    mix[7] = a * r * h;
    mix[8] = a * c * h;
    mix[9] = r * c * h;
    
    for(int i = 0; i<10;i++){
        ans += mix[i];
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1280
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read()[0];
    let a: Vec<i64> = read();

    let mut map: HashMap<i64, i64> = HashMap::new();
    for &i in a.iter() {
        let cnt = map.entry(i).or_insert(0);
        *cnt += 1;
    }

    let mut ans = 0;
    for (k, v) in map {
        ans += if k > v { v } else { v - k };
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;
signed main(void)
{
	int c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin>>c[i][j];
		}
	}
	int a = c[0][1] - c[0][0], b = c[0][2] - c[0][1];
	int judge = 0;
	for (int i = 1; i < 3; i++) {
		if (c[i][1] - c[i][0] == a&&c[i][2] - c[i][1] == b);
		else judge = 1;
	}
	a = c[1][0] - c[0][0]; b = c[2][0] - c[1][0];
	for (int j = 1; j < 3; j++) {
		if (c[1][j] - c[0][j] == a&&c[2][j] - c[1][j] == b);
		else judge = 1;
	}
	if (judge == 0)cout << "Yes"; else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

	
	int32_t main(){
		IOS;
		int x;
		cin>>x;
		if(x==0){
			cout<<1<<endl;
		}
		else if(x==1)cout<<0<<endl;
		return 0;
	}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for(int i = 0; i < n; i++)
    cin >> a[i];
    sort(a.begin(),a.end());
    for(int i = 0; i < n - 1; i++){
        if(a[i] <= 0 && a[i + 1] <= 0){
            a[i] *= -1;
            a[i + 1] *= -1;
        }
        if(a[i] <= 0 && a[i + 1] >= 0){
            if(abs(a[i]) > abs(a[i + 1])){
                a[i] *= -1;
                a[i + 1] *= -1;
            }
        }

    }
    for(int i = 0; i < n; i++){
        sum += a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, x;
    cin >> n >> x;
    int l[n];

    if(n == 0) {
        cout << 0 << endl;
        return 0;
    }
    int count = 1, bound = 0;
    for(int i = 0; i < n; i++) {
        cin >> l[i];
        bound += l[i];
        if(bound <= x) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int):
    print(YES if N == M else NO)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>

typedef struct node_{
    int key;
    struct node_* left;
    struct node_* right;
}node;

node* insert(node* nd, int key){
    if(nd==NULL){
        nd = (node*)malloc(sizeof(node));
        nd->key = key;
        nd->left = NULL;
        nd->right = NULL;
    }else{
        if(key < nd->key)nd->left = insert(nd->left,key);
        else if(key > nd->key)nd->right = insert(nd->right,key);
    }
    return nd;
}

void preorder(node* nd){
    if(nd==NULL)return;
    printf(" %d",nd->key);
    preorder(nd->left);
    preorder(nd->right);
}

void inorder(node* nd){
    if(nd==NULL)return;
    inorder(nd->left);
    printf(" %d",nd->key);
    inorder(nd->right);
}

bool find(node* nd, int x){
    if(nd==NULL)return false;
    else if(x<nd->key)return find(nd->left, x);
    else if(x>nd->key)return find(nd->right, x);
    else return true;
}

int main(){
    int i, m, key;
    char command[7];
    node* root = NULL;
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",command);
        switch(command[0]){
        case 'i':
            scanf("%d",&key);
            root = insert(root,key);
            break;
        case 'p':
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
            break;
        case 'f':
            scanf("%d",&key);
            if(find(root,key))printf("yes\n");
            else printf("no\n");
        default:
            break;
        }
    }
    return 0;
}



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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string b;
    cin >> b;
    int len = b.length();
    // sort(b.begin(), b.end());
    int count = 0;
    for(int i =0; i < len; i++)
    {
        if(b[i] == b[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b;
  for (int i=0; i<2; i++) {
    if(a>=b) {
      c += a;
      a--;
    }
    else {
      c += b;
      b--;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
S = input()
if S =='SUN':
    print(7)
elif S =='MON':
    print(6)
elif S =='TUE':
    print(5)
elif S =='WED':
    print(4)
elif S =='THU':
    print(3)
elif S =='FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
package main

import (
	"fmt"
)

func main() {
	var n, k, q int
	fmt.Scanf("%d %d %d", &n, &k, &q)
	a := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Scanf("%d", &a[i])
		a[i]--
	}
	answers := survive(n, k, q, a)
	for _, v := range answers {
		fmt.Println(v)
	}
}

func survive(n, k, q int, a []int) []string {
	wins := make([]int, n)
	for _, v := range a {
		wins[v]++
	}

	survives := make([]string, n)
	for i := 0; i < n; i++ {
		if k-(q-wins[i]) > 0 {
			survives[i] = "Yes"
		} else {
			survives[i] = "No"
		}
	}
	return survives
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    vector<int> a;
    deque<int> b;
    rep(i, n){
        int x;
        cin >> x;
        a.push_back(x);
        if(n%2==i%2){
            b.push_back(x);
        }else{
            b.push_front(x);
        }
    }    

    rep(i, n){
        cout << b[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
using namespace __gnu_pbds;
 
// replace ll  with pair if multiset needed
typedef tree<ll , null_type, greater<ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set secik;
 
const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

	
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
	string s; cin >> s;
	while(s.size() != 3) s.pop_back();
	cout << s;

		
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
//typedef long long ll;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////



int main(){fastio
    ll a,b,t;cin>>a>>b>>t;
    cout<<t/a*b<<endl;
    
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;

namespace ABC16CB
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var s = new HashSet<string>();
            for(int i = 0;i<N;i++){
                s.Add(Console.ReadLine());
            }
            Console.WriteLine(s.Count);
        }
    }
}


Measured memory_bytes: 47368
#include <iostream>
using namespace std;
int main(void){
    int Aj,As,Ar,Ae;
    int Bj,Bs,Br,Be;
    int S,T;
    cin >> Aj >> As >> Ar >> Ae;
    cin >> Bj >> Bs >> Br >> Be;
    S=Aj+As+Ar+Ae;
    T=Bj+Bs+Br+Be;
    if(S>T)     cout << S << endl;
    else if(T>S)cout << T << endl;
    else        cout << S << endl;
}



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

// #define multitest 1
#define Debug 1
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;

void solve()
{
	int x, a;
	cin >> x >> a;
	if (x < a)
		cout << 0;
	else
		cout << 10;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
	return 0;
}

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

int main(){
	int N;
	cin >> N;
	
	
	vector<int> H(N);
	
	for(int i=0;i<N;i++){
		cin >> H[i];
	}
	
	int cnt=1;
	int max = H[0];
	for(int i=0;i<N-1;i++){
		if(max <= H[i+1]){
			cnt++;
			max = H[i+1];
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define a(i) (*(A+(i)-1))
#define b(i) (*(B+(i)-1))

int N;
char *A;
char *B;

int main(int argc, char *argv[]) {
	int sr;
	int inp;
	int i,j;
	int sum;

	sr=scanf("%d", &N);

	A = malloc(sizeof(int)*N);
	B = malloc(sizeof(int)*N);
	for (i=1; i<=N; i++) {
		sr=scanf("%d", &inp);
		a(i) = inp;
		if (i*2>N) b(i) = a(i);
	}

	for (i=N/2; i>=1; i--) {
		sum=a(i);
		for (j=2; j*i<=N; j++) {
			sum+=b(j*i);
		}
		b(i)=sum%2;
	}

	sum=0;
	for (i=1; i<=N; i++) {
		if (b(i)) sum++;
	}
	printf("%d\n", sum);
	for (i=1; i<=N; i++) {
		if (b(i)) {
			printf("%d", i);
			sum--;
			if (sum>0) {
				printf(" ");
			} else {
				printf("\n");
				break;
			}
		}
	}

	return 0;

}

/*
問題文
N
 個の空の箱が横一列に並んでいます。 左から 
i (1≦i≦N) 番目の箱には整数 i が書かれています。

すぬけさんは、それぞれの箱に対してボールを 1 個入れるか何も入れないかを選ぶことができます。

ここで、以下の条件を満たすようなボールの入れ方を、いいボールの入れ方と定めます。

	・1 以上 N 以下の任意の整数 i について、 i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った余りが a_i である。
いいボールの入れ方は存在するでしょうか。存在するならば 1 つ求めてください。

制約
・入力は全て整数である。
・1≦N≦2 × 10^5
・a_i は 0 または 1 である。


N/2番目以降の箱のボールの数はa_i（その箱より大きい倍数の箱はないから)
i番目の箱の数は、iより大きい倍数の箱のボールの和が偶数なら0、奇数なら1

N/2以上の箱のボールの数によって、i≦N/2番目までのボールの和が決まる。

A_i: i番目の箱に入っているボールの数
A_i = a_i (i≧N/2)

A_i+A_2i+A_3i+...+A_(k-1)i+a_ki
*/


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int n;
    string str, cmd, rep;
    
    cin >> str >> n;
    for(int i=0;i<n;i++){
        int a, b;
        cin >> cmd;
        if(cmd=="print"){
            cin >> a >> b;
            for(int j=a;j<b+1;j++){
                cout << str[j];
            }
            cout << endl;
        }
        
        else if(cmd=="reverse"){
            cin >> a >> b;
            string strrev = str.substr(a, b-a+1);
            reverse(strrev.begin(), strrev.end());
            string str1 = str.substr(0, a);
            string str2 = str.substr(b+1);
            str = str1 + strrev + str2;
            //cout << str << endl;
        }
        
        else{
            cin >> a >> b >> rep;
            string str1 = str.substr(0, a);
            string str2 = str.substr(b+1);
            str = str1 + rep + str2;
            //cout << str << endl;
        }
    }
}


Measured memory_bytes: 3204
#include <stdio.h>
int a,b,c;
int count;
int i;
int main(void) {
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<b+1;i++) {
    if(c%i == 0) {
      count++;
    }
  }
  printf("%d\n",count);

return 0;
}

Measured memory_bytes: 596
n,m = map(int,input().split())
alis = list(map(int,input().split()))
lis = [list(map(int,input().split())) for x in range(m)]
for x in alis:
    lis.append([1,x])
lis.sort(reverse=True,key=lambda x:x[1])
ans = 0
for x in lis:
    (number,point) = x
    if number >= n:
        number = n
        ans += number * point
        #print(n)
        #print(ans,'+=',number,'*',point)
        break
    ans += number * point
    n -= number
    #print(n)
    #print(ans,'+=',number,'*',point)
print(ans)
#print(lis)


Measured memory_bytes: 43336
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b; cin >> a >> b;
	int ans = 0;
	for(int i=0;i<2;i++){
		if(a>=b){
			ans += a;
			a--;
		}else{
			ans += b;
			b--;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

  for(int i=0;i<N;i++){
    int p=a[i]-1;
    int q=a[p]-1;
    if(i==q&&p==a[q]-1) ans++;
  }

  //for(int i=0;i<N;i++) cout<<c[i]<<endl;
  cout<<ans/2<<endl;




  }


Measured memory_bytes: 640