akhauriyash/Code-Regression huggingface dataset:
from math import log
import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    from math import log
    mx = min(int(log(K)) + 100, K)
    for _ in range(mx):
        left_right = [0] + [(i-A[i], i+A[i]) for i in range(1, N+1)]
        ini = [0]*(N+1)
        for i in range(1, 1+N):
            l, r = left_right[i]
            l = max(1, l)
            ini[l] += 1
            if r+1 <= N:
                ini[r+1] -= 1
        is_all_n = True
        A[1] = ini[1]
        if A[1] != N:
            is_all_n = False
        for i in range(2, N+1):
            A[i] = A[i-1] + ini[i]
            if A[i] != N:
                is_all_n = False
        if is_all_n:
            break
    print(*A[1:])
main()

Measured memory_bytes: 219400
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

pair<int, int>getnext(const pair<int, int>&now, const int way) {
	if (now.second % 2) {
		const int dx[] = { -1,0,1,1,1,0 };
		const int dy[] = { 0,1,1,0,-1,-1 };
		return make_pair(now.first + dx[way], now.second + dy[way]);
	}
	else {
		const int dx[] = { -1,-1,0,1,0,-1 };
		const int dy[] = { 0,1,1,0,-1,-1 };
		return make_pair(now.first + dx[way], now.second + dy[way]);
	}
}
int W, H;
int check(const pair<int,int>&p,const vector<vector<int>>&field,const vector<vector<int>>&came) {
	if (p.first < 0 || p.first >= W + 2 || p.second < 0 || p.second >= H + 2)return -1;
	else if (came[p.second][p.first])return -1;
	else if (field[p.second][p.first])return 1;
	else return 0;
}
int main() {cin >> W >> H;
	vector<vector<int>>field(H + 2, vector<int>(W + 2));
	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			cin >> field[i][j];
		}
	}
	queue<pair<int, int>>que;
	vector<vector<int>>came(H + 2, vector<int>(W + 2));
	que.push(make_pair(0, 0));
	came[0][0] = true;
	int ans = 0;
	while (!que.empty()) {
		auto p(que.front());
		que.pop();
		for (int way = 0; way < 6; ++way) {
			auto nextp(getnext(p, way));
			int num = check(nextp, field,came);
			if (num == -1)continue;
			else if (num == 0) {
				came[nextp.second][nextp.first] = true;
				que.push(nextp);
			}
			else {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3244
from math import floor

def solve(n, A):
    B = sorted([a - (i + 1) for i, a in enumerate(A)])
    b = B[n // 2]
    ret = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))
    if n % 2 == 0:
        b = B[n // 2 + 1]
        tmp = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))
        if tmp < ret:
            ret = tmp
    return ret

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))


Measured memory_bytes: 26608
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nk = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            var n = nk[0];
            var k = nk[1];
            var tmp = n / k;
            var answer = tmp * tmp * tmp;
            if (k % 2 == 0)
            {
                if (tmp * k + k / 2 > n) tmp--;
                tmp++;
                answer += tmp * tmp * tmp;
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define findmax(a,b) (a)>(b)?(a):(b)
#define findmin(a,b) (a)<(b)?(a):(b)
#define inout freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define swap(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b)
#define quicksort(a,n) qsort(a,n,sizeof(a[0]),cmp)
#define inputarr(a,n) for(int i=0;i<n;i++){scanf("%d",&a[i]);}
#define printarr(a,n) for(int i=0;i<n;i++){printf("%d ",a[i]);}puts("");
int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}
 
int main() {
    
	//inout;

	long long int a, b;

	long long int v, w;

	long long int t;

	scanf("%lld%lld", &a, &v);
	scanf("%lld%lld", &b, &w);
	scanf("%lld", &t);

	long long int dis = a - b;

	if(dis < 0){dis *= -1;}

	long long int spd = v - w;

	if(spd < 0){
		puts("NO");
		return 0;
	}

	double xd = (double)dis/(double)spd;

	if(xd > (double)t){
		puts("NO");
		return 0;
	}

	else{
		puts("YES");
		return 0;
	}
}

Measured memory_bytes: 1660
s=input()

atd=''
tpd=''
for i, t in enumerate(s):
  
  if t=='g':
      tpd+='0'
  else:
      tpd+='1'
      
  if i%2==0:
      atd+='0'
  else:
      atd+='1'

point=0
for a, t in zip(atd, tpd):
  
    x=int(a)-int(t)
    
    if x==1:
        point+=1
    elif x==-1:
      point-=1
      
      
print(point)

Measured memory_bytes: 3316
#include "bits/stdc++.h"
#define ll long long
using namespace std;

int main() {
  int N,M,X;
  cin>>N>>M>>X;
  vector<int>ryo(N);
  int bak=0;
  int srt=0;
  for(int i=0;i<M;i++) {
    int a;
    cin>>a;
    ryo.at(a-1)=a;
  }
  for(int i=X-1;i<N;i++) {
    if(ryo.at(i)) {
      srt++;
    }
  }
  for(int i=X-1;i>=0;i--) {
    if(ryo.at(i)) {
      bak++;
    }
  }
  cout<<min(bak,srt)<<endl;
}

Measured memory_bytes: 256
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


MOD = 10**9+7
d = {}
ans = 1
n = int(input())
for i in range(2, n+1):
    x = factorization(i)
    for j in x:
        if j[0] in d:
            d[j[0]] += j[1]
        else:
            d[j[0]] = j[1]
for i in d.values():
    ans *= (i+1)
    ans %= MOD
print(ans)


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

using namespace std;

int main(){
	int h,n;
  int temp;
  cin >> h >> n;
  for(int i=0; i<n;i++){
  		cin >> temp;
  		h -= temp;
  		if(h < 1) break;
  	}

  if (h>=1){
    cout<<"No";
  }else{
    cout<<"Yes";
  }

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char ch[101];
	int i,num,count = 0;
	cin >> ch;
	for(i=0;i<101;i++){
		if(ch[i]=='\0')	break;
	}
	num = ch[0];
	if(ch[0]==65) count++;
	for(int x=1;x<i;x++){
		if(num >= ch[x]){
			count++;
		}
		num = ch[x];
	}
	cout << count << endl;
  return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		
		int h = a/3600;
		int m =a%3600 / 60;
		int s =a%3600 % 60;
		
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 26072
K, A, B = map(int, input().split())
if A >= B:
	print(1 + K)
else:
	if A-1 >= K or B-A == 1: print(1 + K)
	else:
		rem = K - A + 1
		increase = rem // 2
		crush = rem % 2
		print(A + (B-A)*increase + crush)

Measured memory_bytes: 2940
from collections import defaultdict
import heapq as hq
d = int(input())
c = [0]+list(map(int,input().split()))
s = [0]
for i in range(d):
    s.append([0]+list(map(int,input().split())))
dic = defaultdict(int)
contest = [[] for _ in range(27)]
contests = [-1]*(d+1)
for i in range(1,d+1):
    maxscore = 0
    maxcontest = -1
    for k in range(1,27):
        score = 0
        score += s[i][k]
        score += c[k]*(i-dic[k])
        if score > maxscore:
            maxscore = score
            maxcontest = k
    print(maxcontest)
    dic[maxcontest] = i

Measured memory_bytes: 68776
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
typedef long long ll;
using namespace std;
int gNum(int);

int main()
{
	int x, y;
	cin >> x;
	cin >> y;
	if (gNum(x)==gNum(y))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

int gNum(int a)
{
	int g;
	if (a==4|| a == 6 || a == 9 || a == 11)
	{
		g = 2;
	}
	else if (a == 2)
	{
		g = 3;
	}
	else
	{
		g = 1;
	}
	return g;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String p = scan.next();
        String judge = "No";
        
        List<Integer> s_markList = new ArrayList<Integer>();


        for (int i = 0; i < s.length(); i++) {
            if(p.charAt(0) == s.charAt(i)){
                s_markList.add(i);
            }
        }
        
   
        Iterator<Integer> it = s_markList.iterator();
        while(it.hasNext()){
            Integer e =it.next();
            String ss = s;
            if(p.length() > s.length()-e){
                ss = s + s;
             
            }
            int f = 0;
          
            for(int i = e; i < e + p.length(); i++){
             
                if(ss.charAt(i) == p.charAt(f)){

                    if(f == p.length()-1){
    
                        judge = "Yes";
                        break;
                    }

                    f++;
                }else{
                    break;
                }
            }
        }
        
        System.out.println(judge);
        
    }
}



Measured memory_bytes: 26312
///
// File:  2149.cpp
// Author: ymiyamoto
//
// Created on Fri Nov 10 14:52:30 2017
//
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N, A, B, C, X;
    cin >> N >> A >> B >> C >> X;

    if (N == 0) break;

    vector<uint32_t> arr;
    for (uint32_t i = 0; i < N; i++) {
      uint32_t val;
      cin >> val;
      arr.push_back(val);
    }

    uint32_t x = X;
    uint32_t found = 0;
    int32_t end_frame = -1;
    for (uint32_t i = 0; i <= 10000; i++) {
      if (x == arr[found]) {
        found++;
        if (found == arr.size()) {
          end_frame = i;
          goto end;
        }
      }
      x = (A * x + B) % C;
    }
  end:
    cout << end_frame << endl;
  }

  return 0;
}

Measured memory_bytes: 3044
import bisect
import collections
import copy
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7
INF = float("inf")

N,M,P = map(int,(input().split()))
line = []
for i in range(M):
    a,b,c = map(int,(input().split()))
    line.append([a-1,b-1,-c+P])

min_distance = [INF]*N # min_distance[i] は始点から街iまでの最短距離
min_distance[0] = 0 # 始点から始点への最短距離は0とする

def Bellman_Ford():
    for _ in range(N):
        update = False
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != INF and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = min_distance[s] + d # 最短距離を上書きする
                update = True
        if not update:
            flag = 1
            break

def Bellman_Ford2():
    for _ in range(N):
        for s,g,d in line: # [s,g,d] = [道路の始点,道路の終点,道路の長さ] について、すべての道路を見る
            if min_distance[s] != INF and min_distance[s] + d < min_distance[g]: # 最短経路が確立されている街から伸びる道路を通ることで、距離を短くできるならば、
                min_distance[g] = -INF
                if g == N-1:
                    break
        else:
            continue
        break

flag = 0
Bellman_Ford()

if flag == 1:
    ans = min_distance[N-1]
    print(max(-ans,0))
else:
    Bellman_Ford2()
    ans = min_distance[N-1]
    if ans == -INF:
        print(-1)
    else:
        print(max(-ans,0))

#print(min_distance)


Measured memory_bytes: 75152
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    k = min(k, 20);
    rep(_,k-1){
        string t = s;
        reverse(t.begin(),t.end());
        s += t;
        reverse(s.begin(),s.end());
        string mi = "{";
        rep(i,n+1){
            mi=min(mi,s.substr(i,n));
        }
        s = mi;
        reverse(s.begin(),s.end());
    }
    string t = s;
    reverse(t.begin(),t.end());
    s += t;
    string mi = "{";
    rep(i,n+1){
        mi=min(mi,s.substr(i,n));
    }
    cout<<mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);++i)
#define REP(i,n) for (int i=0;i<=(n);++i)
#define all(x) (x).begin(), (x).end()

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

using namespace std;
typedef long long ll;
const int INF = 10000000;

int main() {
    ll x; cin >> x;
    ll n = 100;
    int ans = 0;
    while(n < x) {
        n += n * 0.01;
        ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;
const ll INF = 100000000000;
// グラフ
using Edge = pair<int, int>;         // {行き先, 重み}
using Graph = vector<vector<Edge>>; // グラフ

vector<int> ans;

void dfs(int v, int p, int c, Graph &G){
  ans[v] = c;
  for(auto e : G[v]){
    if(e.first == p) continue;
    if(e.second % 2 == 0)dfs(e.first, v, c, G);
    else dfs(e.first, v, 1-c, G);
  }
}

int main(){
  int n;
  cin >> n;
  Graph G(n);
  rep(i,n-1){
    int u, v, w;
    cin >> u >> v >> w;
    --u; --v;
    G[u].push_back(Edge(v,w));
    G[v].push_back(Edge(u,w));
  }
  ans.assign(n, 0);
  dfs(0, -1, 1, G);
  rep(i, n){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 11668
a={}
maxnum = 1
while True:
    try:
        ai = int(input())
        if ai not in a:
            a[ai] = 1
        else:
            a[ai] += 1
            if maxnum < a[ai]:
                maxnum = a[ai]
    except:
        break
b = sorted(a.items())
for key, value in b:
    if maxnum==value:
        print(key)



Measured memory_bytes: 5596
n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(n - k): #iはスタート地点
    old = A[i] #Aのj番目の要素をかける
    new = A[i + k]
    
    if old < new:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 31596
#include<stdio.h>

int cnt;

void insertionSort(int *, int, int);
void shellSort(int *, int);

int main()
{
	int i, n;
	scanf("%d", &n);
	int A[n];
	for(i=0; i<n; i++) scanf("%d", &A[i]);
	shellSort(A, n);
	printf("%d\n", cnt);
	for(i=0; i<n; i++) printf("%d\n", A[i]);
	return 0;
}

void insertionSort(int A[], int n, int g)
{
	int i, j, v;
	for(i=g; i<n; i++){
		v=A[i];
		j=i-g;
		while(j>=0 && A[j]>v){
              A[j+g]=A[j];
              j=j-g;
              cnt++;
		}
		A[j+g]=v;
	}
}

void shellSort(int A[], int n) //一定の間隔 g だけ離れた要素のみを対象とした挿入ソートである insertionSort(A, n, g) を、最初は大きい値から g を狭めながら繰り返します。
{
	int i, m;
	int G[100];
	G[0]=1;
	cnt=0;
	for(m=1; G[m-1]*3+1<=n; m++){ //G[m]がnより小さい間
		G[m]=G[m-1]*3+1;
	}
	printf("%d\n", m);
	for(i=m-1; i>=0; i--) {
		if(i==0) printf("%d\n", G[i]);
		else printf("%d ", G[i]);
		insertionSort(A, n, G[i]);
  }
}


Measured memory_bytes: 5620
#include<iostream>
#include<algorithm>
#define N 10000
#define K 10
using namespace std;
int k,d,n,ans=100000000;
bool m[K+2];
void dfs(int res)
{
	if(res>=n && res<ans)
	{
		ans=res;
		return ;
	}
	if(res>=n) return ;
	for(int i=9;i>=0;i--)
		if(!m[i]) dfs(res*10+i);
}
int main()
{
	cin>>n>>k;
	for(int i=1;i<=k;i++)
		cin>>d,m[d]=1;
	for(int i=1;i<10;i++)
		if(!m[i]) dfs(i);
	cout<<ans;
}


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

typedef long long LL;

LL num[233333];
int ton[100050];

int main()
{
    int n;
    cin >> n;
    LL sum = 0;
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &num[i]);
        ton[num[i]]++;
        sum += num[i];
    }
    int q;
    cin >> q;
    for (int i = 1; i <= q; i++)
    {
        int b, c;
        scanf("%d%d", &b, &c);
        sum += ton[b] * (c - b);
        ton[c] += ton[b];
        ton[b] = 0;
        printf("%lld\n", sum);
    }
    return 0;
}

Measured memory_bytes: 4932
/*
* @author:  codancer
* @createTime:  2020-02-17, 09:39:06
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
typedef vector<int> VI;
typedef pair<int,int> pii;
ll n,k,ans,l,r;
ll a[200010];
// bool check(ll x){
// 	ll cnt=0;// the number that less than x
// 	for(int i=1;i<=n;i++){
// 		ll num=0;
// 		if(a[i]==0){
// 			if(x>0) cnt+=n-1;
// 		}else{
// 			if(a[i]>0){
// 				ll h=x/a[i];
// 				if(x%a[i]&&(x>0)){
// 					++h;
// 				}
// 				num=lower_bound(a+1,a+n+1,h)-a-1;
// 			}
// 			else{
// 				ll h=x/a[i];
// 				if(x%a[i]&&(x>0)){
// 					h--;
// 				}
// 				ll great=upper_bound(a+1,a+n+1,h)-a-1;
// 				num=n-great;
// 			}
// 			cnt+=num;
// 			if(a[i]*a[i]<x) --cnt;
// 		}
// 	}
// 	cnt/=2;
// 	return cnt<k;
// }
bool chk(ll x)
{
	ll cnt=0,t1,t2;
	for(int i=1;i<=n;++i)
		if(a[i])
		{
			t1=t2=x/a[i];
			if(x%a[i])
			{
				if((x<0 && a[i]>0) || (x>0 && a[i]<0)) --t1;
				else ++t2;
			}
			if(a[i]<0) cnt+=n+1-(upper_bound(a+1,a+n+1,t1)-a);
			if(a[i]>0) cnt+=lower_bound(a+1,a+n+1,t2)-a-1;
			if(a[i]*a[i]<x) --cnt;
		}else if(x>0) cnt+=n-1;cnt>>=1;return cnt<k;
}
// int main()
// {
// 	scanf("%lld %lld",&n,&k);L=-1e18;R=1e18;
// 	for(int i=1;i<=n;++i) scanf("%lld",&a[i]);sort(a+1,a+n+1);
// 	while(L<=R) {ll mid=L+R>>1;if(chk(mid)) L=mid+1,ans=mid;else R=mid-1;}
// 	printf("%lld\n",ans);return 0;
// }
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	l=-1e18,r=1e18;
	ll ans;
	// cout<<check(-6)<<endl;
	while(l<=r){
		ll mid=l+r>>1;
		if(chk(mid)){
			 l=mid+1;
			 ans=mid;
		}
		else{
			r=mid-1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

static int compare = 0;

static void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int i, j, k;
    int *L, *R;

    L = malloc(sizeof(int) * n1);
    R = malloc(sizeof(int) * n2);
    for ( i = 0; i < n1; i++ ) {
        L[i] = A[left + i];
    }
    for ( i = 0; i < n2; i++ ) {
        R[i] = A[mid + i];
    }

    
    for ( i = 0, j = 0, k = left; k < right; k++ ) {
        compare++;
        if ( (i < n1) && (j < n2) ) {
            if ( L[i] <= R[j] ) {
                A[k] = L[i];
                i++;
            } else {
                A[k] = R[j];
                j++;
            }
        } else if ( i < n1 ) {
            A[k] = L[i];
            i++;
        } else if ( j < n2 ) {
            A[k] = R[j];
            j++;
        } else {
            assert( 0 ) ;
        }
    }
    free(L);
    free(R);

    return;
}

static void MergeSort(int A[], int left, int right) {
    if ( left + 1 >= right ) {
        return;
    }

    int mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    merge(A, left, mid, right);
}

int main(int argc, char* argv[]) {
    int n, i;
    int* S;

    scanf("%d\n", &n);
    S = malloc(sizeof(int) * n);
    for ( i = 0; i < n; i++ ) {
        int s;
        scanf("%d", &s);
        S[i] = s;
        (void)fgetc(stdin);
    }

    MergeSort(S, 0, n);

    for ( i = 0; i < n; i++ ){
        printf("%d", S[i]);
        if ( i + 1 < n ){
            printf(" ");
        }
    }
    printf("\n");

    printf("%d\n", compare);

    return 0;
}



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

int main() {
  int64_t a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if (abs(b - a) - (t * v - t * w) <= 0) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k=nm()
h=nl()

dp = [10**10] * n
dp[0] = 0

for i in range(n):
  for j in range(max(0,i-k),i):
    dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]))

print(dp[n-1])


Measured memory_bytes: 84784
#include<bits/stdc++.h>
using namespace std;
char c[101][101];
int main()
    {
    int a,b,d=0;
    cin>>a>>b;
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
        cin>>c[i][j];
        }
	}
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++)
            {
            	d=0;
            if(c[i][j]=='#') cout<<'#';
            else         
                {
                if(c[i-1][j+1]=='#') d=d+1;
                if(c[i][j+1]=='#') d=d+1;
                if(c[i+1][j+1]=='#') d=d+1;
                if(c[i-1][j]=='#') d=d+1;
                if(c[i+1][j]=='#') d=d+1;
                if(c[i-1][j-1]=='#') d=d+1;
                if(c[i][j-1]=='#') d=d+1;
                if(c[i+1][j-1]=='#') d=d+1;
                cout<<d;
                }
            }
            cout<<endl;
    }   
    return 0;     
    }

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int Lj4PdHRW;
  long long C;
  long long D;
  long long res = -1;
  long long s = 0;
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    rd(D);
    rd(C);
    res += C;
    s += C * D;
  }
  res += (s-1) / 9;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191123-1

// --- original code ---
// {
//   ll C, D, res = -1, s = 0;
//   REP(rd_int()){
//     rd(D, C);
//     res += C;
//     s += C * D;
//   }
//   res += (s-1) / 9;
//   wt(res);
// }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

int main(){
    int a[13] = {0,-1,0,1,0,1,0,0,1,0,1,0};
    int x, y;
    cin >> x >> y;

    bool f = a[x - 1] == a[y - 1];
    auto YesOrNo = [](bool f) { cout <<  (f ? "Yes" : "No") << endl; };
    YesOrNo(f);
}


Measured memory_bytes: 256
/**
     *      ABC 54 A
     *      author  : kyomukyomupurin
     *      created : 2018-09-05 02:36:01
    **/
     
    #include <bits/stdc++.h>
    using namespace std;
     
    int main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        
        int A, B; cin >> A >> B;
        if (A == 1 && B != 1){
            cout << "Alice" << endl;
        }
        else if (B == 1 && A != 1){
            cout << "Bob" << endl;
        }
        else if (A > B){
            cout << "Alice" << endl;
        }
        else if (A < B){
            cout << "Bob" << endl;  
        }
        else {
            cout << "Draw" << endl;
        }
     
        return 0;
    }

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func max(a, b int) int {
  if a < b {
    return b
  }
  return a
}

func min(a, b int) int {
  if a < b {
    return a
  }
  return b
}

func main() {
  var n, a, b int
  fmt.Scan(&n, &a, &b)

  fmt.Printf("%d %d\n", min(a, b), max(0, a + b - n))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long expo(long long base,long long exponent,long long mod)
{
    long long ans=1;
    while(exponent!=0)
	{
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
long long inv[10004];
long long C(long long n,long long r)
{
    long long res=1,cur=1;
    for(long long i=n;i>r;i--)
	{
        res=res*i%1000000007;
        res=res*inv[cur]%1000000007;
        cur++;
    }
    return res;
}
void solve()
{
    long long n,ans=0;
    cin>>n;
    if(n<5)
	{
        cout<<0<<endl;
        return;
    }
    n-=5;
    for(long long i=0;i<12;i++)
	{
        long long r=n-i;
        if(r<0) break;
        if(r%2) continue;
        r/=2;
        ans=(ans+C(11,i)*C(15+r,r)%1000000007)%1000000007;
    }
    cout<<ans<<endl;
}
 
int main(){
    for(long long i=1;i<102;i++) 
	{
		inv[i]=expo(i,1000000005,1000000007);
	}
    long long t=1;
    cin>>t;
    while(t--)
	{
        solve();
    }
    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main(){

  int aj,as,ai,ae,bj,bs,bi,be,S,T;
  scanf("%d%d%d%d",&aj,&as,&ai,&ae);
  scanf("%d%d%d%d",&bj,&bs,&bi,&be);
  S=aj+as+ai+ae;
  T=bj+bs+bi+be;
  if(S>=T)printf("%d\n",S);
  else printf("%d\n",T);
  return 0;
}

Measured memory_bytes: 592
#include <iostream>

using namespace std;

int main(void) {

	int A, B;
	cin >> A >> B;

	int ans = A + B;

	if (A - B > ans) { ans = A - B; }

	if (A*B > ans) { ans = A*B; }

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
// Problem : E - Yutori
// Contest : AtCoder - AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n,k,c;
string s;

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>k>>c>>s;
    vi l(k+1),r(k+1);
    int prev = -1, cnt = 0;
    for(int i=0;i<n;i++){
        if((prev == -1 || i-prev>c) && s[i] == 'o') l[++cnt] = i, prev = i;
        if(cnt == k) break;
    }
    cnt = k+1, prev = -1;
    for(int i=n-1;i>=0;i--){
        if((prev == -1 || prev-i>c) && s[i] == 'o') r[--cnt] = i, prev = i;
        if(cnt == 1) break; 
    }
    vi ans;
    for(int i=1;i<=k;i++){
        if(l[i] == r[i]) ans.pb(l[i]);
    }
    for(auto i : ans) cout<<i+1<<endl;
    return 0;
}


Measured memory_bytes: 8528
loop do
  a,b = gets.split(" ").map(&:to_i)
  break if a == 0 && b == 0
  m = gets.to_i
  koji = Array.new(m) { gets.split(" ").map(&:to_i) }

  dp = Array.new(a+1) {Array.new(b+1){0}}
  dp[1][0] = 1
  koji.each {|co| dp[co[0]][co[1]] = -1}

  1.upto(a) do |i|
    1.upto(b) do |j|
      if dp[i][j] == 0
        dp[i][j] = dp[i-1][j] + dp[i][j-1]
      else
        dp[i][j] = 0
      end
    end
  end
  
  puts dp[a][b]
end

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

using namespace std;

int main(){
  string w;
  cin>>w;
  int judge=0;

  for(char ji='a'; ji<='z'; ji++){
    if(count(w.cbegin(),w.cend(),ji)%2==0){
      judge=2;
    }
    else{ 
      cout<<"No"<<endl;
      judge=1;
      break;
    }
  }

  if(judge==2) cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	var input []int
	for i := 0; i < 6; i++ {
		in, _ := strconv.Atoi(readLine())
		input = append(input, in)
	}
	for i := 0; i < 5; i++ {
		for j := i; j < 5; j++ {
			if input[j]-input[i] > input[5] {
				fmt.Println(":(")
				return
			}
		}
	}
	fmt.Println("Yay!")
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>

int main(){
    int i, j;
    char s[200];
    char t[200];
    int strl;
    int num, sum;
    int ans=0;

    scanf("%s", s);
    scanf("%s", t);
    strl = strlen(s);

    for(i=0; i<strl; i++){
        sum = 0;
        for(j=0; j<strl; j++){
            if(i+j >= strl){
                num = i+j-strl;
            }else{
                num = i+j;
            }
            if(s[num] == t[j]){
                sum += 1;
            }
            //printf("%c", s[num]);
        }
        //printf(" %d\n", sum);
        if(sum == strl){
            ans =1;
            break;
        }
    }

    if(ans == 1){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
void fast()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void solve()
{
  ll n,x,t;
  cin >> n >> x >> t;
  cout << (n+x-1)/x*t << endl ;
}
int main()
{
  fast();
  solve();

return 0;
}


Measured memory_bytes: 3608
while True:
    m, f, r = map(int,input().split())
    grade = ""
    if m == f == r == -1:
        break
    
    if m==-1 or f==-1:
        grade = "F"
    elif m+f >= 80:
        grade = "A"
    elif m+f >= 65:
        grade = "B"
    elif m+f >= 50:
        grade = "C"
    elif m+f < 30:
        grade ="F"
    elif r >= 50:
        grade = "C"
    else:
        grade = "D"
        
    print(grade)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int N, M;
    cin >> N >> M;
    int ret = N * (N-1)/2 + M*(M-1)/2;
    cout << ret << endl;
    return 0;
}


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



int main(void) {
    vector<bool> prime;
    prime.resize(55560, true);
    
    prime[0] = false;
    prime[1] = false;
    
    for (int i = 2; i * i <= 55555; i++)
        if (prime[i])
            for (int j = i + 1; i * j <= 55555; j++)
                if (j % i == 0)
                    prime[j] = false;
    int n, now = 1;
    cin >> n;
    for (int i = 0; i < n; i++) {
        while (true) {
            now++;
            if (prime[now] && now % 5 == 1) {
                cout << now;
                break;
            }
        }
        if (i != n - 1)
            cout << ' ';
        else
            cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int arr[27];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	string s;
	cin >> s;
	for(int i=0;i<s.size();i++)
		arr[s[i]-'a']++;
	for(int i=0;i<26;i++)
	{
		if(arr[i]%2)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7

    a.sort()
    ret = 1
    if k % 2 == 0 or a[-1] >= 0:
        l = 0
        r = -1
        mlt1 = a[0] * a[1]
        mlt2 = a[-2] * a[-1]
        for _ in range(k//2):
            if mlt1 >= mlt2:
                ret *= mlt1 % mod
                l += 2
                if l <= n-2:
                    mlt1 = a[l+1] * a[l]
            else:
                ret *= mlt2 % mod
                r -= 2
                if r >= -n+1:
                    mlt2 = a[r-1] * a[r]
            ret %= mod

        if k % 2 == 1:
            ret *= a[r]
            ret %= mod

    else:
        for i in range(k):
            ret *= a[n-1-i]
            ret %= mod

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 33140
N = int(input())
D = []
for i, a in enumerate(map(int, input().split())):
    D.append((a<<11) + i)
D.sort(reverse=True)
dp = [0]*(N+1)
for i, d in enumerate(D,start=1):
    x, a = d%(1<<11),d>>11
    for j in reversed(range(0, i+1)):
        dp[j] = max((dp[j-1]+a*(x-(j-1)))*(j-1>=0), (dp[j]+a*(N-(i-j)-x))*(j<=i-1))
print(max(dp))

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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vint vstd(n);
    int ans = 0;
    vint a(n);
    REP(i,n){
        cin >> a[i];
        a[i]--;
    }
    int now = 0;
    while(1){
        if(now==1){
            cout << ans << endl;
            return 0;
        }
        if(vstd[now]==1){
            cout << -1 << endl;
            return 0;
        }
        vstd[now]=1;
        now=a[now];
        ans++;
    }

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    sc.close();

    for (long i = X; i < 100007; i++) {
      if (isPrimeNumber(i)) {
        System.out.println(i);
        return;
      }
    }
  }

  private static boolean isPrimeNumber(long num) {
    if (1 >= num) return false;
    if (2 == num) return true;
    long n = (long) Math.sqrt(num);
    for (long i = 2; i <= n; ++i) {
      if (0 == (num % i)) return false;
    }
    return true;
  }
}

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

int main() {
	int k;
	cin>>k;
	if(k%7==0)
	k/=7;
	int ans=0;
	int ini=1;
	if(k%2==0||k%5==0)
	ans=-1;
	else
	while(ini){
	    ans++;
	    //cout<<ini<<" ";
	    ini=ini%k;
	    //cout<<ini<<" ";
	    if(ini==0)
	    break;
	    ini*=10;
	    ini++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0]&&b[b.size() - 1] == c[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N, K; cin >> N >> K;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	vector<ll> sum;

	REP(i, N)
	{
		ll tmp{0};
		for (ll j = i; j < N; ++j)
		{
			tmp += A[j];
			sum.push_back(tmp);
		}
	}

	ll res{0};

	for (ll bit = 40; bit >= 0; --bit)
	{
		ll tmp = res | (1ll<<bit);

		ll cnt{0};
		for (auto &e : sum)
		{
			if ((e & tmp) == tmp)
				++cnt;
		}
		if (cnt >= K)
			res = tmp;
	}

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


Measured memory_bytes: 6132
#include<cstdio>
#include<algorithm>

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

using namespace std;

int h,w,n;

bool gameover(const char B[30][31]){
	rep(i,h) rep(j,w) if(B[i][j]!='.') return false;
	return true;
}

bool vanish(char B[30][31]){
	bool va[30][30]={};
	rep(i,h) rep(j,w) {
		char c=B[i][j];
		if(c=='.') continue;

		if(i+n<=h){
			bool ok=true;
			rep(k,n) if(B[i+k][j]!=c) { ok=false; break; }
			if(ok) rep(k,n) va[i+k][j]=true;
		}
		if(j+n<=w){
			bool ok=true;
			rep(k,n) if(B[i][j+k]!=c) { ok=false; break; }
			if(ok) rep(k,n) va[i][j+k]=true;
		}
	}

	bool ok=false;
	rep(i,h) rep(j,w) if(va[i][j]) B[i][j]='.', ok=true;
	return ok;
}

void fall(char B[30][31]){
	rep(j,w){
		int m=0;
		char s[30];
		for(int i=h-1;i>=0;i--) if(B[i][j]!='.') s[m++]=B[i][j];
		rep(i,h) B[i][j]='.';
		rep(i,m) B[h-i-1][j]=s[i];
	}
}

bool dfs(const char B0[30][31]){
	char B[30][31];
	rep(i,h) rep(j,w) B[i][j]=B0[i][j];

	if(gameover(B)) return true;

	fall(B);
	if(!vanish(B)) return false;
	fall(B);

	return dfs(B);
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	char B[30][31];
	rep(i,h) scanf("%s",B[i]);

	rep(i,h) rep(j,w-1) {
		swap(B[i][j],B[i][j+1]);
		if(dfs(B)){ puts("YES"); return 0; }
		swap(B[i][j],B[i][j+1]);
	}
	puts("NO");

	return 0;
}

Measured memory_bytes: 1036
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
const int INF = 1<<31;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int LL;

int n;
int cnt[1000006];

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

    cin >> n;
    FOR(i,0,n){
        int x;
        cin >> x;
        cnt[x]++;
    }

    FORN(i,1,100000){
        if(cnt[i]>1)
            n-=cnt[i]-1;
    }

    if(n%2==0)
        n--;

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define eps 1e-6
#define ll long long
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define int long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define fi first
#define se second
#define endl "\n"
#define pii pair<int,int>
#define fi first
#define se second
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll Max(ll a,ll b){return a>=b?a:b;}
ll Min(ll a,ll b){return a<=b?a:b;}
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res,t;res=1;t=a%c;while(b){if(b&1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
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;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
using namespace std;
//head file
int main()
{
char s[100];
	cin.getline(s,100);
	int lena = strlen(s);
	int t=0;
	rep(i,0,lena)
    {
		if(s[i]<='z' && s[i] >='a')
		{
			t++;
			cout<<s[i];
		}
		if(t==3)
          break;
	}
	return 0;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll M1, M2, D1, D2;
  vl A;
  cin >> M1 >> D1 >> M2 >> D2;
  if (M1 < M2)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())

dp = np.zeros((N+1, W+1), dtype=int)

for i in range(1, N+1):
    w, v = map(int, input().split())
    dp[i, :w] = dp[i-1, :w]
    dp[i, w:] = np.maximum(dp[i-1, :W-w+1] + v, dp[i-1, w:])

print(dp[-1][-1])

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

int main() {
  int A, B;
  //string op;
  cin >> A >> B;

  if ((A*B)%2 == 0) {
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }
  
  
  // ここにプログラムを追記
}


Measured memory_bytes: 3556
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        String result = "NO";
        if (x == 7 || x == 5 || x == 3) result = "YES";
        System.out.println(result);
    }
}


Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int h,w; cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    string ans;
    REP(i,h) {
        REP(j,w) {
            cin >> s[i][j];
            if(s[i][j]=="snuke") {
                char tmp = j + 65;
                ans = tmp + to_string(i+1);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll F(ll A, ll B) {
  ll a = 0, b = 0;
  while (A) {
    a++;
    A /= 10;
  }
  while (B) {
    b++;
    B /= 10;
  }
  return max(a, b);
}

int main() {
  ll N;
  cin >> N;

  vector<ll> div = divisor(N);
  ll ans = LINF;
  for (ll A : div) {
    ll B = N / A;
    chmin(ans, F(A, B));
  }
  cout << ans << endl;
}

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(input[0] * input[1] / 2);
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
#include <ios>
#include <iomanip>
#include <stdio.h>
#include <iomanip>
#include <queue>
using namespace std;

#define rep(i,N) for(int i=0; i<N; i++)
#define revrep(i,N) for(int i=N-1; i>=0; i--)
#define coutline cout<<"------------ ("<<__LINE__<<")"<<endl;

typedef long long ll;

int main(void)
{
    int r, D;

    vector<int> x(11);

    cin >> r >> D >> x.at(0);

    rep(i,10){
        x.at(i+1) = r * x.at(i) - D;
        cout << x.at(i+1) << endl;
    }

    return 0;
}


Measured memory_bytes: 256