akhauriyash/Code-Regression huggingface dataset:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)

for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

    
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    diff = t[i+1]-t[i]
    if dist>diff or dist%2!=diff%2:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 46680
#include<stdio.h>
#include<string.h>
int main()
{
    char a[10000];
    int i,n=0,m=0,l,b=0;
    scanf("%s",&a);
    l=strlen(a);
    for(i=0;i<l;i++)
    {
        switch(a[i])
        {
            case 'A':n++;break;
            case 'T':n++;break;
            case 'C':n++;break;
            case 'G':n++;break;
            default: m=m>n?m:n,n=0;break;
        }
    }
    m=m>n?m:n;
    printf("%d\n",m);
    return 0;
}

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

#define MAX_LEN (100000)

int main(int argc, char *argv[]) {
  // read inputs
  char s[MAX_LEN + 1];
  scanf("%s", s);
  const int n = strlen(s);

  // remove all 'x's in s
  char s_nox[MAX_LEN + 2];
  int m = 0, indices[MAX_LEN + 2], is_palindrome = 1;
  s_nox[0] = '_';
  indices[0] = -1;
  for (int i = 0; i < n; i++) {
    const char c = s[i];
    if (c != 'x') {
      m++;
      s_nox[m] = c;
      indices[m] = i;
    }
  }
  s_nox[m + 1] = '_';
  indices[m + 1] = n;
  // check whether s_nox is a palindrome (if its not print -1)
  for (int i = 0; i < (m + 2) / 2; i++) {
    if (s_nox[i] != s_nox[m + 1 - i]) {
      is_palindrome = 0;
      break;
    }
  }
  if (!is_palindrome) {
    printf("-1\n");
    exit(0);
  }

  // When 2 adjacent non-'x' characters have 'x's between them,
  // the corresponding range on the other side must have the same
  // number of 'x's in them.
  int ans = 0;
  for (int i = 1; i < (m + 3) / 2; i++) {
    const int num_x_left = indices[i] - indices[i - 1] - 1;
    const int num_x_right = indices[m + 1 - (i - 1)] - indices[m + 1 - i] - 1;
    ans += abs(num_x_left - num_x_right);
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
void swap(char *,char *);

int main(void){
  int i,j,min,N;
  char a,b,c,d;
  char A[36][3];
  char B[36][3];
  char C[36][3];
  char k[2];
  
  scanf("%d",&N);
  if(N<1 || 36<N){
    exit;
  }

  for(i=0; i<N; i++){
    scanf("%s",A[i]);
    B[i][0] = A[i][0];
    B[i][1] = A[i][1];
  }
  
  for(i=0; i<N; i++){
    for(j=N-1; j>=i+1; j--){
      if((int)A[j][1] < (int)A[j-1][1]){
	k[0] = A[j][0];
	k[1] = A[j][1];
	A[j][0] = A[j-1][0];
	A[j][1] = A[j-1][1];
	A[j-1][0] = k[0];
	A[j-1][1] = k[1];
      }
    }
  }
  
  for(i=0; i<N; i++){
    if(i != 0){
      printf(" ");
    }
    printf("%c%c",A[i][0],A[i][1]);
    C[i][0] = A[i][0];
    C[i][1] = A[i][1];
  }
  printf("\n");
  
  for(i=0; i<N; i++){
    if(A[i][0] != C[i][0])break;
  }
  if(i == N){
    printf("Stable\n");
  }
  else printf("Not stable\n");

  for(i=0; i<N; i++){
    min = i;
    for(j=i; j<N; j++){
      if(B[j][1] < B[min][1]){
	min = j;
      }
    }

    a = B[i][0];
    b = B[i][1];
    c = B[min][0];
    d = B[min][1];

    swap(&a,&c);
    swap(&b,&d);

    B[i][0] = a;
    B[i][1] = b;
    B[min][0] = c;
    B[min][1] = d;
  }
  
  for(i=0; i<N; i++){
    if(i != 0){
      printf(" ");
  }
    printf("%c%c",B[i][0],B[i][1]);
  }
  printf("\n");
  
  for(i=0; i<N; i++){
    if(B[i][0] != C[i][0]){
      break;
    }
  }
  if(i == N){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  return 0;
}


void swap(char *x,char *y){
  char temp;
  temp = *x;
  *x = *y;
  *y = temp;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

bool is_prime(int n) {
  for (int p = 2; p * p <= n; p++) {
    if (n % p == 0) {
      return false;
    }
  }

  return true;
}

vector<pair<int, int>> factorize(int n) {
  vector<pair<int, int>> result;
  for (int p = 2; p * p <= n; p++) {
    if (is_prime(p)) {
      int cnt = 0;
      while (n % p == 0) {
        n /= p;
        cnt++;
      }
      if (cnt > 0) {
        result.push_back(make_pair(p, cnt));
      }
    }
  }
  if (n != 1) {
    result.push_back(make_pair(n, 1));
  }
  return move(result);
}

int totient(const int n) {
  vector<pair<int, int>> fs = factorize(n);
  int result = n;

  for (auto pa : fs) {
    int p, e;
    tie(p, e) = pa;
    result /= p;
    result *= p - 1;
  }
  return result;
}

const int MOD = 2019;

int64_t dpow(int64_t x, int64_t y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return dpow(x * x % MOD, y / 2);
  } else {
    return x * dpow(x, y - 1) % MOD;
  }
}

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

  const int M = totient(2019);
  vector<int> dp(2019, 0);
  dp[0]++;
  int shift = 1;
  int r = 0;
  int i10 = dpow(10, M - 1);
  int64_t result = 0;
  rep(i, s.size()) {
    r = r * 10 + (s[i] - '0');
    r %= MOD;
    result += dp[r * shift % MOD]++;
    shift *= i10;
    shift %= MOD;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3716
function main(arg) {
    arg = parseInt(arg);
    
    if( arg < 1200 ){
        console.log("ABC");
    } else if( arg < 2800 ) {
        console.log("ARC")
    } else {
        console.log("AGC")
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 11340
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
//        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");

    }


    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] prefix = new int[n];
            int[] suffix = new int[n];
            int[] a = new int[n];
            int[] b = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
            }
            for (int i = 0; i < n; i++) {
                b[i] = sc.nextInt();
            }
            prefix[0] = a[0];
            suffix[n - 1] = b[n - 1];
            for (int i = 1; i < n; i++) {
                prefix[i] = a[i] + prefix[i - 1];
            }
            for (int i = n - 2; i >= 0; i--) {
                suffix[i] = b[i] + suffix[i + 1];
            }
            int max = 0;
            for (int i = 0; i < n; i++) {
                max = Math.max(max, prefix[i] + suffix[i]);
            }
            pw.println(max);
        }

    }



    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int ans=2e9,a[100005];
int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
	}
	for(int i=1;i<=n-k+1;i++)
	{
		ans=min(ans,a[i+k-1]-a[i]+min(abs(a[i+k-1]),abs(a[i])));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		if (n % 2 == 0) {
			n/=2;
			System.out.println(n);
		} else {
			n/=2;
			n++;
			System.out.println(n);
		}
		
	}

}

Measured memory_bytes: 22996
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const LL MOD = 1000000007;// 10^9+7
const int INF = (1 << 30);


//変数
LL N, A, B;
vector<LL> h;






//サブ関数
//入力
void input()
{
	cin >> N >> A >> B;
	LL tmp;
	REP(i, N) {
		cin >> tmp;
		h.push_back(tmp);
	}
}

bool judge(
	const LL& time, 
	const LL& A,
	const LL& B,
	vector<LL> h)
{
	for_each(h.begin(), h.end(), [&B,&time](LL& n) 
	{
		n -= B * time; 
	});

	LL res = 0;
	LL diff = A - B;
	for (auto num : h) if (num > 0) 
		res += ceil((float)num / diff);
	return res <= time;
}


//計算
void calc()
{
	LL l = 0, r = INF;
	while (r - l > 1) {
		LL mid = (l + r) / 2;
		if (judge(mid,A,B,h)) {
			r = mid;
		}
		else {
			l = mid;
		}
	}
	if (judge(l, A, B, h)) {
		cout << l << endl;
	}
	else {
		cout << r << endl;
	}
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 1908
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

signed main(void) {
	ll i, j, k, l;
	ll a[3];
	rep(i, 3) cin >> a[i];
	sort(a, a + 3);
	rep(i, 3) {
		if (a[i] % 2 == 0) {
			puts("0"); return 0;
		}
	}
	cout << a[0]*a[1] << endl;
}

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

template<class T>
void prvec(vector<T>& v) {
	for (T n: v) cout << n << " ";
	cout << "\n";
}

const int MAXN = 100005;
const int MAXM = 100005;
vector<pair<int, int>> vec[MAXN];
string ans[MAXM];
int N, M;

int main() {
	// freopen("./input.txt", "r", stdin);
	int N, M;
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		int P, Y;
		cin >> P >> Y;
		vec[P].push_back({Y, i});
	}
	for (int i = 1; i <= N; i++) {
		sort(vec[i].begin(), vec[i].end());
		int sz = vec[i].size();
		string prefix = to_string(i);
		int len = prefix.length();
		string padding = string(6 - len, '0');
		prefix = padding + prefix;
		for (int j = 0; j < sz; j++) {
			int idx = vec[i][j].second;
			string suffix = to_string(j + 1);
			len = suffix.length();
			padding = string(6 - len, '0');
			suffix = padding + suffix;
			ans[idx] = prefix + suffix;
		}
	}
	for (int i = 1; i <= M; i++){
		cout << ans[i] << "\n";
	}

	return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define endl "\n"
const int N = 1000;
int pos[N];
using namespace std;

int main()
{
	int x,n; cin >> x >> n;
	int a[N], max=0, diff, k, flag=1;
	if(n==0) flag=0;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		pos[a[i]] = 1;
		if(a[i] > max) max = a[i];
	}
	max=max+1;
	for(int i=0;i<=max;i++) {
		if(pos[i] == 1) continue;
		else {
			if(i==0) {
			int temp = x-i;
			if(temp < 0) temp*=-1;
			diff = temp; k=i;
			}
			else{
			int temp = x-i;
			if(temp < 0) temp*=-1;
			if(temp < diff){ diff = temp; k=i;}
		}}
	}
	if(flag == 0) cout << x << endl;
	else
	cout << k<< endl;
}


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


using namespace std;

char s[100007];
int x[1000007];
int cnt;

void connect(int x, int y) {
	cout<<x<<' '<<y<<endl;
}

int main() {
	scanf("%s", s+1);
	int len=strlen(s+1);
	for(int i=1; i<=len-1; i++) {
		if (s[i]!=s[len-i]) {
			cout<<-1<<endl;
			return 0;
		}
	}
	if (s[1]=='1'&&s[len-1]=='1'&&s[len]=='0') {
		for(int i=1; i<=len; i++) {
			if (s[i]=='1') x[++cnt]=i;
		}
		int last=1;
		for(int i=2; i<=cnt; i++) {
			for(int j=last; j<x[i]; j++) {
				connect(j, x[i]);
			}
			last=x[i];
		}
		connect(x[cnt], len);
	}
	else cout<<-1<<endl;




	return 0;
}


Measured memory_bytes: 1920
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=500005;

long long n,a,b,c,d;
long long L,R;

int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for (long long i=0;i<n;++i){
		L=a+i*d-(n-1-i)*c;
		R=a+i*c-(n-1-i)*d;
		if (L>R) swap(L,R);
//		printf("%d 	%lld %lld\n",i,L,R);
		if (L<=b && b<=R){
			puts("YES");
			return 0;
		}
	}
	puts("NO");
}
	

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

int main() {
  int N, K, a=0;
  cin >> N >> K;
  
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    if (x<K-x) {
      a += x*2;
    }
    else if (x>=K-x) {
      a += (K-x)*2;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
const int mod =1e9+7;
typedef long long ll;
int ans[N],k=0;
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if(a+b-1>n || n>1ll*a*b)
    {
        puts("-1");
    }
    else
    {
        for(int i=n-a+1;i<=n;i++)
            ans[++k]=i;
        n-=a;
        for(int i=2;i<=b;i++)
        {
            int h=min(a,n-b+i);
            for(int j=n-h+1;j<=n;j++)
                ans[++k]=j;
            n-=h;
        }
    }
    for(int i=1;i<=k;i++)
        printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 3328
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    N = II()
    P = LMIIS()
    Q = LMIIS()
    from math import factorial

    def index(P):
        candidates = list(range(1,N+1))
        ans = 0
        f = factorial(N-1)
        for i in range(N-1):
            ans += candidates.index(P[i]) * f
            candidates.remove(P[i])
            f //= N-i-1
        return ans + 1

    print(abs(index(P)-index(Q)))

    



   




if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep(i,N) {
       cin >> C.at(i);
       rep(j,M) cin >> A[i][j];
    }

    int mi = 1 << 30;
    for (int bit = 1; bit < 1<<N; bit++){
        vector<int> sum(N, 0);
        int money = 0;
        for (int i = 0; i < N; i++) {
            if (bit & 1 << i) {
                rep(j, M) sum[j] += A[i][j];
                money += C[i];
            }
        }
        bool found = true;
        rep(j, M) if (sum[j] < X) found = false; 
        if (found) {
           mi = min(mi, money); 
        }
    }
    if (mi == 1<<30) {
        cout << -1 << endl;
    } else {
        cout << mi << endl;
    }
}

Measured memory_bytes: 3568
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s;cin>>s;
  int i,j,k;
  int count=0;
  int tmp;
  for(i=0;i<s.length();i++){
    tmp=s[i]-'0';
    if(tmp==i%2) count++;
  }

  if(count>s.length()/2) count=s.length()-count;
  cout<<count<<endl;
}


Measured memory_bytes: 512
n = int(input())
s = list(map(int,input().split()))
q = int(input())
t = list(map(int,input().split()))
count = 0
for i in t:
    left = 0;right = n
    while left < right:
        mid = (left+right)//2
        if s[mid] == i:
            count += 1
            break
        elif i < s[mid]:
            right = mid
        else:
            left = mid + 1
print(count)


Measured memory_bytes: 16704
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
i32 dp[404][404];//aの値,bの値,料金
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n,m_a,m_b;
cin >> n >> m_a >> m_b;
vector<i32> a(n),b(n),c(n);
rep(i,n)cin >> a[i] >> b[i] >> c[i];
rep(i,404){
    rep(j,404){
        dp[i][j] = 1e9;
    }
}
dp[0][0] = 0;
rep(i,n){
    for(i32 j = 400; 0 <= j; j--){
        for(i32 k = 400; 0 <= k; k--) {
            if(dp[j][k] != 1e9){
                dp[j + a[i]][k + b[i]] = min(dp[j][k] + c[i],dp[j + a[i]][k + b[i]]);
            }
        }
    }
}
i64 ans = 1e9;
for(i32 i = 1; i * max(m_a,m_b) <= 400; i++){
        if(dp[i * m_a][i * m_b] != 1e9)ans = min(ans,dp[i * m_a][i * m_b]);
}
cout << (ans == 1e9 ? -1 : ans) << endl;
}

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

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

ll n,a[30][30];
ll dp[30][1<<21]={0};
ll modp=1e+9+7;

ll cal(ll i,ll S){
    if(dp[i][S]!=-1){
        return dp[i][S];
    }
    ll res=0;
    rep(j,n){
        int k=(S>>j);
        if((k&1)&&a[i-1][j]==1){
            res+=cal(i-1,S-((k&1)<<j));
        }
    }
    return dp[i][S]=res%modp;
}

signed main() {
	cin>>n;
    rep(i,n){
        rep(j,n){
            cin>>a[i][j];
        }
    }

    rep(i,n+1){
        rep(j,1<<n){
            dp[i][j]=-1;
            if(i==0){
                dp[i][j]=0;
            }
        }
    }
    dp[0][0]=1;
	
    cout<<cal(n,(1<<n)-1)<<endl;
	
    /*
    rep(i,n+1){
        rep(j,1<<n){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    */

	return 0;
}


Measured memory_bytes: 362752
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>
#include <queue>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N,Y; cin>>N>>Y;
  int x = -1, y = -1, z = -1;

  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= N-i; j++) {
      int k = N - j - i;
      if(i*10000 + j*5000 + k*1000 == Y) {
        x = i, y = j, z = k;
      }
    }
  }

  printf("%d %d %d\n", x,y,z);
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int W = scan.nextInt();
        int H = scan.nextInt();
        int x = scan.nextInt();
        int y = scan.nextInt();
        int r = scan.nextInt();
        
        if(((x - r) >= 0 && (x + r) <= W) && ((y - r) >= 0 && (y + r) <= H)){
           System.out.println("Yes");
        }else{
           System.out.println("No");
        }
    }
}

Measured memory_bytes: 26292
#include <bits/stdc++.h>
#define int long long
const int MOD=1e9+7;
using pii=std::pair<int,int>;
using namespace std;

const int maxq = 55;

int n, m, q, a[maxq], b[maxq], c[maxq], d[maxq];

int solve(int mask, int pos, int ma)
{
    if(pos == n)
    {
        int cursum = 0;
        for(int i = 0; i < q; i++)
        {
            int Aa = (mask >> (4 * a[i])) & 15;
            int Ab = (mask >> (4 * b[i])) & 15;
            if(Ab - Aa == c[i])
                cursum += d[i];
        }
        return cursum;
    }
    int curans = 0;
    for(int j = ma; j <= m; j++)
    {
        int newmask = mask | (j << (4 * pos));
        curans = max(curans, solve(newmask, pos + 1, j));
    }
    return curans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    cout << solve(0, 0, 1) << "\n";
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

const ll N = 105, inf = 9223372036854775807ll;

ll n, l, c[N], d[N], x[N], ans = inf;

vector<ll> adj[N];

void getd (ll D[], ll C, ll P) {
	D[C] = D[P] + 1;
	for(auto &T : adj[C]) {
		if(T == P) continue;
		getd(D, T, C);
	}
}

pll mxd (ll I) {
	getd(d, I, 0);
	pll R = {-1, -1};
	for(ll i=1;i<=n;i++) {
		R = max(R, {d[i], i});
	}
	return R;
}

void solve (ll A, ll B) {
	getd(c, A, 0);
	getd(d, B, 0);
	fill(x+1, x+1+n, 0);
	ll M = 0;
	for(ll i=1;i<=n;i++) {
		ll D = min(c[i], d[i]);
		M = max(M, D);
		x[D] = max(x[D], (ll)adj[i].size());
	}
	if(M != (l+1)/2) return;
	ll R = (A == B ? x[1] : (x[1]-1)*2);
	for(ll i=2;i<=M;i++) {
		if(x[i] == 1) continue;
		if(x[i] != 2 && R >= inf / (x[i] - 1) + 1) return;
		R *= x[i] - 1;
	}
	ans = min(ans, R);
}

int main() {
	scanf("%lld",&n);
	if(n == 2) {
		puts("1 2");
		return 0;
	}
	for(ll i=1;i<n;i++) {
		ll A, B;
		scanf("%lld%lld",&A,&B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	l = mxd(mxd(1).Y).X;
	for(ll i=1;i<=n;i++) {
		solve(i, i);
	}
	for(ll i=1;i<=n;i++) {
		for(auto &T : adj[i]) {
			if(i > T) continue;
			solve(i, T);
		}
	}
	printf("%lld %lld\n",(l+1)/2,ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int n,l,r,a;
string s;
int query(int x)
{
	cout<<x<<'\n';
	fflush(stdout);
	cin>>s;
	int ans=0;
	if(s[0]=='F')
		ans=1;
	else if(s [0]=='M')
		ans=-1;
	return ans;
}
int main(){
	cin>>n;
	l=0,r=n,a=query(0);
	if(a==0)
		return 0;
	while(1)
	{
		int m=(l+r)/2,m2=query(m);
		if(m2==0)
			return 0;
		if(m%2==l%2)
		{
			if(a==m2)
				l=m,a=m2;
			else
				r=m;
		}
		else
		{
			if(a!=m2)	
				l=m,a=m2;
			else
				r=m;
		}
	}
	return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool t=true;
  char s[4];
  for(int i=0;i<4;i++){
    cin>>s[i];
    if(i>0&&s[i]==s[i-1]) t=false;
  }
  if(t)cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
}
  

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,r,kotae[3][1000],kazu,m,aa,aaa,bbb,bb;
	kazu=0;
	while(scanf("%d%d",&a,&b)!=EOF){
		if(b>a){
			m=a;
			a=b;
			a=m;
		}
		aa=a;
		bb=b;
		m=a*b;
		kazu=kazu+1;
		while(b!=0){
			r=a%b;
			a=b;
			b=r;
		}
		kotae[1][kazu]=a;
		aaa=aa;
		bbb=bb;
		while(aaa!=bbb){
			if(aaa<bbb){
				aaa=aaa+aa;
			}else{
				bbb=bbb+bb;
			}
		}
			kotae[2][kazu]=aaa;
		
		
	}
	for(int z=1;z<=kazu;z++){
		printf("%d %d\n",kotae[1][z],kotae[2][z]);
	}
	return 0;
}


Measured memory_bytes: 2056
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int tmp;

	scanf("%d%d%d", &a, &b, &c);
	
	if(a>b){
		tmp = a;
		a = b;
		b = tmp;
	}
	if(b>c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if(a>b){
		tmp = a;
		a = b;
		b = tmp;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int ans=0;
  string t;
  for(char c:s){
    if(t.empty()||t.back()==c) t.push_back(c);
    else t.pop_back(),ans+=2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int h, w;
  cin >> h >> w;
  vector<vector<string>> vec(h+2, vector<string>(w+2));
  for (int i = 0; i < h+2; i++) {
    for (int j = 0; j < w+2; j++) {
      vec.at(i).at(j) = "*";
    }
  }

  string s;
  for (int i = 1; i < h+1; i++) {
    cin >> s;
    for (int j = 1; j < w+1; j++) {
      vec.at(i).at(j) = s[j-1];
    }
  }

  // 処理
  for (int i = 1; i < h+1; i++) {
    for (int j = 1; j < w+1; j++) {
      if(vec.at(i).at(j) == "#"){
        // if(vec.at(i-1).at(j) == "#" || vec.at(i).at(j-1) == "#" || vec.at(i).at(j+1) == "#" || vec.at(i+1).at(j) == "#")  break;

        if(vec.at(i-1).at(j) != "#" && vec.at(i).at(j-1) != "#" && vec.at(i).at(j+1) != "#" && vec.at(i+1).at(j) != "#"){
        cout << "No" << endl;
        return 0;
        }
      }
      // cout << vec.at(i).at(j) << " ";
    }
    // cout << endl;
  }

  cout << "Yes" << endl;

  // // 【確認用】
  // // 全体
  // for (int i = 0; i < h+2; i++) {
  //   for (int j = 0; j < w+2; j++) {
  //     cout << vec.at(i).at(j) << " ";
  //   }
  //   cout << endl;
  // }

  // cout << " " << endl;

  // // 該当のみ
  // for (int i = 1; i < h+1; i++) {
  //   for (int j = 1; j < w+1; j++) {
  //     cout << vec.at(i).at(j) << "";
  //   }
  //   cout << endl;
  // }

  return 0;
}

Measured memory_bytes: 3696
import sys
import math
import fractions
import bisect
import queue
import heapq
from collections import deque
sys.setrecursionlimit(4100000)

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288
INF = 1e18

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行あり整数
x = []
y = []
for i in range(N):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

N行M列の初期化
dp = [[INF] * M for i in range(N)]

'''

S = input()
T = "CODEFESTIVAL2016"

ans = 0
for i in range(len(S)):
    if S[i] != T[i]:
        ans += 1


print(ans)

Measured memory_bytes: 5432
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;

const int N = 110;
char a[N];
char b[N];

int main(){
    IOS;
    cin>>a+1;
    int len = strlen(a+1);
    int f = (len&1)?len/2+1:len/2;
    for(int i = 1; i <= len; i++)b[i] = a[len-i+1];
    int ans = 0;
    for(int i = 1; i <= len; i++){
        if(i>f)break;
        if(a[i]!=b[i])ans++;
    }
    cout<<ans;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
int p[1001];
int x[1001];
int dp[1001];
vector<int> vec[1001];
int edp[1001][5001];

int main(int argc, char const* argv[])
{
	cin >> n;
	for(int i = 1; i < n; i++){
			cin >> p[i];
			p[i]--;
			dp[i] = inf;
			vec[p[i]].pb(i);
	}
	for(int i = 0; i < n; i++)cin >> x[i];
	for(int i = n - 1; i >= 0; i--){
			if(vec[i].size() == 0){
					dp[i] = 0;
					continue;
			}
			for(int j = 0; j <= vec[i].size(); j++){
					for(int k = 0; k <= x[i]; k++){
							edp[j][k] = inf;
					}
			}
			for(int j = 0; j <= x[i]; j++)edp[0][j] = 0;
			for(int j = 0; j < vec[i].size(); j++){
					for(int k = 0; k <= x[i]; k++){
							if(k >= x[vec[i][j]] && edp[j][k-x[vec[i][j]]] < inf)edp[j+1][k] = min(edp[j+1][k], edp[j][k-x[vec[i][j]]] + dp[vec[i][j]]);
							if(k >= dp[vec[i][j]] && edp[j][k-dp[vec[i][j]]] < inf)edp[j+1][k] = min(edp[j+1][k], edp[j][k-dp[vec[i][j]]] + x[vec[i][j]]);
					}
			}
			if(edp[vec[i].size()][x[i]] > inf -1){
					cout << "IMPOSSIBLE" << endl;
					return 0;
			}else{
					dp[i] = edp[vec[i].size()][x[i]];
			}

	}
	cout << "POSSIBLE" << endl;
	return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N, P; cin >> N >> P;
	vll arr (N);
	F0R(i, N) cin >> arr[i];
	
	ll even = 0;
	ll odd = 0;
	F0R(i, N) {
		if (arr[i]&1)
			++odd;
		else 
			++even;
	}	


	ll p2 = 1;
	F0R(i, even) p2 *= 2;

	ll ans = 0;
	for (int x = 0; x <= odd; x += 2) {
		ll num = 1;
		ll den = 1;
		ll del = 1;
		F0R(i, x) {
			num *= (odd - i);
			while (num % del == 0 && del <= x) {
				num /= del; ++del;
			}
		}
		ans += num / den;
	}
	ans *= p2;

	if (P == 0) {
		print(ans);
	} else {
		ll all = 1;
		F0R(i, N) all*=2;
		print(all - ans);
	}
}

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]
a.sort()
a.append(0)
cnt = 1
ans = 0
for i in range(n):
    if a[i+1] == a[i]:
        cnt += 1
    else:
        if cnt > a[i]:
            ans += cnt - a[i]
        elif cnt < a[i]:
            ans += cnt
        cnt = 1

print(ans)

Measured memory_bytes: 14244
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <fstream>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;


int main() {

    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    
//	long long a, b, c, d;
//	cin >> a >> b >> c >> d;
	
//	cout << ( (a * b > c * d) ? a * b : c * d ) << endl;
	
	int n, x = 0;
	
	cin >> n;
	
	int l = n;
	string s;
	cin >> s;
	
	int m = 0;
	
	for(int i = 0; i < n; ++i) {
		if(s[i] == 'I'){
			x = x + 1;
		//	cout << "I - " << x << "\n"; 
		}
		else if(s[i] == 'D'){
			x = x - 1;
		//	cout << "D - " << x << "\n"; 
		}
		
		m = max(x, m);
		
	//	cout << "ITER - " << i << " MAX - " << m << endl;
	}
	
	cout << m << endl;
	
	//system("pause");
    return 0;
}









Measured memory_bytes: 256
<?php
define( "TOP", 0 );
define( "FRONT", 1 );
define( "RIGHT", 2 );
define( "LEFT", 3 );
define( "BACK", 4 );
define( "BOTTOM", 5 );
class Dice
{
	private $labels;
	public function __construct( $labels )
	{
		$this->labels = $labels;
	}
	public function roll( $cmds )
	{
		$len = strlen( $cmds );
		for( $i=0; $i<$len; $i++ ) {
			if( 'E' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[LEFT];
				$this->labels[LEFT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $t;
			} else if( 'S' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[BACK];
				$this->labels[BACK] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[FRONT];
				$this->labels[FRONT] = $t;
			} else if( 'W' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[LEFT];
				$this->labels[LEFT] = $t;
			} else if( 'N' == $cmds[$i] ) {
				$t = $this->labels[TOP];
				$this->labels[TOP] = $this->labels[FRONT];
				$this->labels[FRONT] = $this->labels[BOTTOM];
				$this->labels[BOTTOM] = $this->labels[BACK];
				$this->labels[BACK] = $t;
			} else if( 'M' == $cmds[$i] ) {
				$t = $this->labels[FRONT];
				$this->labels[FRONT] = $this->labels[RIGHT];
				$this->labels[RIGHT] = $this->labels[BACK];
				$this->labels[BACK] = $this->labels[LEFT];
				$this->labels[LEFT] = $t;
			}
		}
	}
	public function getLabel( $face )
	{
		return $this->labels[ $face ];
	}
	public function isEqual( $another )
	{
		$cmds = "NEEENMMMM";
		$len = strlen( $cmds );
		for( $i=0; $i<=5; $i++ ) {
			if( $another->getLabel( TOP ) == $this->getLabel( TOP ) ) {
				for( $j=5; $j<$len; $j++ ) {
					if( $another->getLabel( FRONT ) == $this->getLabel( FRONT ) ) {
						for( $k=TOP; $k<=BOTTOM; $k++ ) {
							if( $another->getLabel($k) != $this->getLabel($k) ) { break; }
						}
						if( 6 == $k ) { return true; }
					}
					$this->roll( $cmds[$j] );
				}
			}
			$this->roll( $cmds[$i] );
		}		
		return false;
	}	
}
	$n = intval( trim( fgets( STDIN ) ) );
	$dices = [];
	for( $i=0; $i<$n; $i++ ) {
		$labels = explode( " ", trim( fgets( STDIN ) ) );
		array_push( $dices, new Dice( $labels ) );
	}
	for( $i=0; $i<$n-1; $i++ ) {
		for( $j=$i+1; $j<$n; $j++ ) {
			if( $dices[$i]->isEqual( $dices[$j] ) ) {
				print "No".PHP_EOL;
				return;
			}
		}
	}
	print "Yes";
?>

Measured memory_bytes: 15684
def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    
    INF = 10 ** 9
    dp = [INF] * (N+1)
    dp[0] = 0
    
    for i in range(1, N):
        for j in range(K, 0, -1):
            if i-j < 0: continue
            dp[i] = min(dp[i], dp[i-j] + abs(A[i] - A[i-j]))

    return dp[N-1]

print(solve())

Measured memory_bytes: 52448
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int time = scanner.nextInt();

        int min_cost=-1;
        for( int i=0; i< count; i++ ) {
            int n = scanner.nextInt();
            int t = scanner.nextInt();
            if( t <= time ) {
                if( min_cost == -1 || min_cost > n )
                min_cost = n;
            }
        }
        if( min_cost == -1 ) {
            System.out.println("TLE");
        } else {
            System.out.println(min_cost);
        }
    }
}

Measured memory_bytes: 21588
#include <stdio.h>

int main(){
    
    int m=0, f=0, r=0, i;
    
    for(i=0; ; i++){
        scanf("%d %d %d", &m, &f, &r);
        if(m==-1 && f==-1 && r==-1){break;
        }else if(m==-1 || f==-1){printf("F\n");
        }else if(m+f>=80){printf("A\n");
        }else if(m+f>=65){printf("B\n");
        }else if(m+f>=50){printf("C\n");
        }else if(m+f>=30 && r>=50){printf("C\n");
        }else if(m+f>=30){printf("D\n");
        }else{printf("F\n");
        }
    }
    
return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;

#define pb push_back
#define mp make_pair

#define mod 1000000007

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define vin(v, n) for (int i = 0; i < (int)(n); i++) cin >> (v)[i];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	vll nums(5);

	vin(nums, 5);

	ll ans = -1;
	for (ll i = 0; i < 5; i++) { if (nums[i] == 0) ans = i + 1; }

	cout << ans << endl;
}


Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			if(scn.nextInt() >= 3200) {
				System.out.println(scn.next());
			} else {
				System.out.println("red");
			}
		}
	}
}


Measured memory_bytes: 23124
def main():
    N = int(input())
    height = list(map(int, input().split(" ")))
    target = [0] * N
    result = 0
    # print(target)
    while not height == target:
        # print(height)
        end = False
        result += 1
        for i in range(N):
            if not end:
                if height[i] > 0:
                    end = True
                    height[i] -= 1
            else:
                if height[i] > 0:
                    height[i] -= 1
                else:
                    break
    print(result)


if __name__ == '__main__':
    main()


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;

int main() {
    double x1, y1, x2, y2, x3, y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
    double d1 = hypot(x1 - x2, y1 - y2);
    double d2 = hypot(x2 - x3, y2 - y3);
    double d3 = hypot(x3 - x1, y3 - y1);
    double s = (d1 + d2 + d3) * 0.5;
    double r = 2 * sqrt(s * (s - d1) * (s - d2) * (s - d3)) / (d1 + d2 + d3);
    auto p = max({d1, d2, d3});
    cout << fixed << setprecision(10) << r * p / (p + 2 * r) << endl;
}


Measured memory_bytes: 256
import math
A, B, N  = map(int, input().split())

max_v = 0
for x in range(-1, min(B, N+1), min(B, N+1)):
    if x <= 0:
        continue
    v = math.floor(A*x/B) - A*math.floor(x/B)
    if max_v < v:
        max_v = v
print(max_v)

Measured memory_bytes: 9188
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}

	slice := strings.Split(s, " ")
	a, _ := strconv.Atoi(slice[0])
	b, _ := strconv.Atoi(slice[1])
	if b == 1 {
		fmt.Println(0)
		return
	}
	n := a // 電源口の数

	ans := 1
	for n < b {
		n += a - 1
		ans++
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
n,m=map(int,input().split())
lis=list(map(int,input().split()))
path=[1 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if lis[a-1] >= lis[b-1]:
    path[b-1] =0
  if lis[a-1] <= lis[b-1]:
    path[a-1] =0
    
print(path.count(1))

Measured memory_bytes: 20104
var
  n,i,j,s:longint;
  a:array[0..100000] of longint;
 procedure kp(l,r:longint);
  var
    i,j,t,mid:longint;
  begin
    i:=l; j:=r; mid:=a[(i+j) div 2];
    repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then
        begin
          t:=a[i]; a[i]:=a[j]; a[j]:=t;
          inc(i); dec(j);
        end;
    until i>j;
    if i<r then kp(i,r);
    if j>l then kp(l,j);
  end;
begin
  readln(n);
  for i:=1 to n do read(a[i]);
  kp(1,n);
  for i:=2 to n do if a[i]=a[i-1] then inc(s);
  if odd(s) then inc(s);
  writeln(n-s);
end.

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  lint l; cin >> l;
  int n; cin >> n;
  V<lint> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    y[i] = l - x[i];
  }
  lint res = 0;
  auto f = [&] {
    V<lint> cx(2 * n + 1);
    for (int i = 0; i < n; ++i) {
      cx[2 * i + 1] = cx[2 * i] + x[i];
      cx[2 * i + 2] = cx[2 * i + 1] + x[i];
    }
    V<lint> cy(2 * n + 1);
    for (int i = 0; i < n; ++i) {
      cy[2 * i + 1] = cy[2 * i] + y[n - 1 - i];
      cy[2 * i + 2] = cy[2 * i + 1] + y[n - 1 - i];
    }
    V<lint> a(n);
    for (int i = 0; i < n; ++i) {
      int j = n - 1 - i;
      a[i] = cx[2 * i + 1 + j] - cx[2 * i + 1];
      a[i] += cy[j] - cy[0];
    }
    for (int i = 0; i < n; ++i) {
      res = max(res, x[i] + a[i]);
    }
  };
  f();
  for (int i = 0; i < n; ++i) {
    swap(x[i], y[n - 1 - i]);
  }
  f();
  cout << res << '\n';
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    string s;cin >> s;
    vector<bool> b(2*n);
    int cnt=0;
    for(int i=1;i<2*n;i++){
        if(s[i-1]!=s[i]){
            b[i]=b[i-1];
        }
        else{
            b[i]=!b[i-1];
        }
        cnt+=b[i];
    }
    if(cnt!=n||s[0]=='W'||s[2*n-1]=='W'){
        cout << 0 << endl;
        return 0;
    }
    ll ans=1;
    ll l=0;
    for(int i=0;i<2*n;i++){
        if(b[i]){
            (ans*=l)%=mod;
            l--;
        }
        else{
            l++;
        }
    }
    for(ll i=1;i<=n;i++){
        (ans*=i)%=mod;
    }
    cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

vector< int > z_algorithm(const vector<ll> &s) {
  vector< int > prefix(s.size());
  for(int i = 1, j = 0; i < (int)s.size(); i++) {
    if(i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while(i + k < (int)s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  prefix[0] = (int) s.size();
  return prefix;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i];
    REP(i, N) cin >> b[i];

    vector<ll> c(N), d(N);
    REP(i, N) c[i] = (a[i]^a[(i+1)%N]);
    REP(i, N) d[i] = (b[i]^b[(i+1)%N]);

    vector<ll> e(3*N);
    REP(i, N){
    	e[i] = d[i];
    	e[N+i] = c[i];
    	e[2*N+i] = c[i];
    }

    auto f = z_algorithm(e);

    /*
    cout << c << endl;
    cout << d << endl;
    cout << e << endl;
    cout << f << endl;
    */

    REP(i, N){
    	if(f[N+i]>=N){
    		ll k = i;
    		ll x = a[k]^b[0];
    		cout << k << " " << x << endl;
    	}
    }
    return 0;
}

Measured memory_bytes: 16768