akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
use proconio::marker::*;
use proconio::*;
use rand::prelude::*;
use std::time::*;

#[derive(Debug)]
struct State {
    D: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
    t: Vec<usize>,
    lasts: Vec<usize>,
    d: usize,
    score: i64,
}

impl State {
    fn new(D: usize, c: Vec<i64>, s: Vec<Vec<i64>>) -> State {
        State {
            D,
            c,
            s,
            t: vec![0; D],
            lasts: vec![0; 26],
            d: 0,
            score: 0,
        }
    }

    fn calc(&mut self) -> i64 {
        let mut score = self.s[self.d][self.t[self.d]];

        self.lasts[self.t[self.d]] = self.d + 1;
        for i in 0..26 {
            score -= (self.d + 1 - self.lasts[i]) as i64 * self.c[i];
        }

        self.d += 1;
        score
    }

    fn result(&self) -> i64 {
        let mut score = 0;
        let mut lasts = vec![0; 26];
        for d in 0..self.D {
            score += self.s[d][self.t[d]];
            let l = lasts[self.t[d]];
            lasts[self.t[d]] = d + 1;
            score -= self.c[self.t[d]] * ((d - l) * (d - l + 1) / 2) as i64;
        }

        for i in 0..26 {
            let l = lasts[i];
            score -= self.c[i] * ((self.D - l) * (self.D - l + 1) / 2) as i64;
        }

        score
    }
}

fn main() {
    input! {
        D: usize,
        c: [i64; 26],
        s: [[i64; 26]; D],
    };
    let mut obj = State::new(D, c, s);
    let mut rng = thread_rng();
    let time = SystemTime::now();
    let mut pre_score = -1000000;

    loop {
        let d = rng.gen_range(0, D);
        let q = rng.gen_range(0, 26);
        let tq = obj.t[d];
        obj.t[d] = q;
        let score = obj.result();
        if score > pre_score {
            pre_score = score;
        } else {
            obj.t[d] = tq;
        }

        if time.elapsed().unwrap().as_millis() > 1900 {
            break;
        }
    }

    for &t in &obj.t {
        println!("{}", t + 1);
    }
}


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

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

    char c=s[0];
    int i;
    for(i=1;i<s.length();i++)
    {
        if(s[i]!=c)
        {
            cout<<"Yes"<<endl;
            break;
        }
        
    }
    if(i==s.length())
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, a[100010], b[100010], c[100010];
long long f(int *arr) {
	long long res = 0;
	for (int i = 1; i < n; i++) res += abs(arr[i] - arr[i - 1]);
	return res;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	sort(a, a + n);
	int p = n - 1;
	for (int i = 1; i < n; i += 2) b[i] = a[p--];
	b[0] = a[p--];
	for (int i = n - 1; i >= 0; i--) if (!b[i]) b[i] = a[p--];
	p = n - 1;
	for (int i = 2; i < n; i += 2) c[i] = a[p--];
	c[0] = a[p--];
	for (int i = n - 1; i >= 0; i--) if (!c[i]) c[i] = a[p--];
	printf("%lld", max(f(b), f(c)));
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
int n, k, a[100009];
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> a[i];
	int ret = 1 << 30;
	for (int i = k - 1; i < n; ++i) {
		int r = a[i], l = a[i - k + 1];
		if (l > 0) l = 0;
		if (r < 0) r = 0;
		ret = min(ret, (-l) * 2 + r);
		ret = min(ret, (-l) + r * 2);
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n;
	int cs = 0;
	while(cin >> n, n){
		vi a(n), b(n);
		rep(i, n) cin >> a[i]; sort(all(a), greater<int>());
		rep(i, n) cin >> b[i]; sort(all(b), greater<int>());
		/*
		if(++cs != 2) continue;
		dbg(a);
		dbg(b);
		
		deque<int> d;
		*/
		for(int i = 0, j = 0; i < n - 1; i++){
			/*
			if(d.size()){
				assert(d.front() >= a[i]);
				if(d.front() > a[i]) { d.pop_front(); continue; }
			}
			if(a[i] == b[j]){
				d.pb(b[j++]);
				continue;
			}
			*/
			
			if(a[i] <= b[j])  j++;
			
			if((i+1) / 2 < i+1 - j){
				/*
				dbg(i, j);
				rep(k, d.size()) cerr<<d[k]<<" "; cerr<<endl;
				*/
				cout << i+1 << endl;
				goto END;
			}
		}
		cout << "NA" << endl;
		END:;
	}
	return 0;
}


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int i;
    for (i = 0; ; i++) {
        if ((i + 1) * z + y * i > x) break;
    }
    cout << i - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define WHITE 1
#define BLACK 2
#define NIL -2

int A[101][101], pi[101], w[101][101], n;

int main(){
  int i, j, sum=0;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &A[i][j]);
      w[i][j] = A[i][j];
    }
  }
  prim();
  for(i=0; i<n; i++){
    if(w[i][pi[i]] != -1){
      sum += w[i][pi[i]];
    }
  }
  printf("%d\n", sum);
  return 0;
}

prim(){
  int mincost, u, v, i;
  int color[n], d[n];

  for(u=0; u<n; u++){
    d[u] = INT_MAX;
    pi[u] = NIL;
    color[u] = WHITE;
  }

  d[0] = 0;

  while(1){
    mincost = INT_MAX;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }
    if(mincost == INT_MAX){
      break;
    }
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && w[u][v] < d[v] && w[u][v] != -1){
        pi[v] = u;
        d[v] = w[u][v];
      }
    }
  }
}

Measured memory_bytes: 680
import java.util.*;
public class Main {
	public static void main(String[] args)
	{
		//変数
		int count=0;
		boolean sw=false;
		int answer=0;
		int max=Integer.MIN_VALUE;
		int min=Integer.MAX_VALUE;
		String S="";
		
		int slength=0;
		String s="";
		//入力
		Scanner sc = new Scanner(System.in);
		S=sc.next();
		
		//処理
		slength=S.length();
		
		for(int i=0;i<slength;i++)
		{
			s=S.substring(i,i+1);
			if(s.equals("A") || s.equals("C") || s.equals("G") || s.equals("T"))
			{
				count++;
				if(count>max)
				{
					max=count;
				}
			}else
			{
				if(count>max)
				{
					max=count;
				}
				count=0;
			}
		}
		answer=max;
				
		// 出力
		System.out.println(answer);
	}
}

Measured memory_bytes: 23508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define mod 1000000007
#define maxN 1011

int n, i, j, k;
int a, b, c, d;
ll dp[maxN][maxN], aux;
ll comb[maxN][maxN];
ll pre[maxN];

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
    for (i = 0; i <= n; i++) {
        comb[i][0] = 1;

        for (j = 1; j <= i; j++) {
            comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
            if (comb[i][j] >= mod) comb[i][j] -= mod;
        }
    }


    dp[a][0] = 1;
    for (i = a; i <= b; i++) {

        pre[1] = 1;
        for (k = 2; i * k <= n; k++)
            pre[k] = (pre[k - 1] * comb[i * k - 1][i - 1]) % mod;

        for (j = 0; j <= n; j++) {
            if (dp[i][j] == 0) continue;
            dp[i][j] %= mod;

            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;

            for (k = c; k <= d && j + i * k <= n; k++) {
                aux = pre[k];

                dp[i + 1][j + i * k] += (((dp[i][j] * aux) % mod) * comb[j + i * k][i * k]) % mod;
                dp[i + 1][j + i * k] %= mod;
            }
        }
    }

    printf("%lld", dp[b + 1][n] % mod);


    return 0;
}


Measured memory_bytes: 15104
x,y = map(int,input().split())
l = [300000, 200000, 100000]
ans = 0

if x < 4:
    ans += l[x-1]
if y < 4:
    ans += l[y-1]
if x == 1 and y == 1:
    ans += 400000

print(ans)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],ans=1,cnt=1;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	for(int i=1;i<n;i++){
		if(a[i-1]>=a[i]) ans=max(ans,++cnt);
		else cnt=1;
	}
	printf("%d",ans-1);
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(1000000)
n = int(input())
a_list = [int(input()) for _ in range(n)]
def calc_ans(start_num, count, max_count, all_list):
    ans = all_list[start_num-1]
    if ans == 2:
        print(count)
    elif count == max_count:
        print('-1')
    else:
        calc_ans(ans, count+1, max_count, all_list)
calc_ans(1, 1, n, a_list)

Measured memory_bytes: 92968
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rel register ll
#define rec register char
#define gc getchar
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?-1:*p1++)
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
char buf[1<<23],*p1=buf,*p2=buf;
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) pc('-'),x=-x;
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
int ans,k;
int main(){
cin>>k;
for (int i=1;i<=k;++i)
  for (int j=1;j<=k;++j)
    ans+=i&1&&!(j&1);
write(ans);
}

Measured memory_bytes: 256
# python3 (3.4.3)
import sys
input = sys.stdin.readline

# functions
def F(a,b):
    return max(len(str(a)), len(str(b)))

# main
from collections import defaultdict
N = int(input())

ans = F(N,1)

divs = []
for i in range(1,int(N**.5)+1):
    if N%i==0:
        divs.append(i)

ans = len(str(N))
for d in divs:
    if N%d==0:
        ans = min(ans, F(d,N//d))

print(ans)

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

int main() {
  vector<int> vec;
  vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  k --;
  cout << vec.at(k);
}

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

int a,b,c,d,ans;
string s;

int  main()
{
    cin>>a>>b;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(i==b-1){
            if(s[i]=='A')cout<<"a";
            if(s[i]=='B')cout<<"b";
            if(s[i]=='C')cout<<"c";
            continue;
        }
        cout<<s[i];
    }cout<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long k = in.nextLong();
			long a = in.nextLong();
			long b = in.nextLong();

			if (b - a <= 2 || a > k) {
				System.out.println(k + 1);
			} else {
				long tmp = (k - a + 1) / 2;
				System.out.println(1 + (k - tmp * 2) + tmp * (b - a));
			}
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


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

void print(vector<vector<int>>& t) {
    for (auto x: t) {
        for (auto y: x) {
            cout << y << ' ';
        }
        cout << endl;
    }
    cout << endl;
}

int n, m;
int count (vector<vector<int>>& table, int i) {
    int zero = 0;
    int won = 0;
    for (int j = 0; j < n; j++) {
        if (table[i][j] == 0) zero++;
        else if (table[i][j] == 1) won++;
    }
    int more = n / 2 - won;
    // check
    if (more < 0 || zero < more) return 0;
    if (i == n - 1) return 1;
    
    if (more == 0) {
        vector<vector<int>> new_table(table);
        for (int j = 0; j < n; j++) {
            if (new_table[i][j] != 0) continue;
            new_table[i][j] = -1;
            new_table[j][i] = 1;
        }
        return count(new_table, i + 1);
    }
    
    int comb = (1 << more) - 1;
    int ans = 0;
    while (comb < 1 << zero) {
        vector<vector<int>> new_table(table);
        int xx = 0;
        for (int j = 0; j < n; j++) {
            if (new_table[i][j] != 0) continue;
            if ((1 << xx) & comb) {
                new_table[i][j] = 1;
                new_table[j][i] = -1;
            } else {
                new_table[i][j] = -1;
                new_table[j][i] = 1;
            }
            xx++;
        }
        ans += count(new_table, i + 1);

        int x = comb & -comb, y = comb + x;
        comb = ((comb & ~y) / x >> 1) | y;
    }
    return ans;
}

int main() {
    while (1) {
        cin >> n >> m;
        if (n == 0) return 0;
        vector<vector<int>> table(n, vector<int>(n));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    table[i][j] = -100;
                } else {
                    table[i][j] = 0;
                }
            }
        }
        for (int i = 0; i < m; i++) {
            int a, b;
            cin >> a >> b;
            table[a - 1][b - 1] = 1;
            table[b - 1][a - 1] = -1;
        }
        cout << count(table, 0) << endl;
    }
}



Measured memory_bytes: 3144
#include<stdio.h>
int main() {
	int n, k, x, y, z;

	scanf("%d%d%d%d",&n,&k,&x,&y);

	if (n > k) {
		z = x*k + y*(n - k);
	}
	else {
		z = x*n;

	}

	printf("%d",z);

}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51], goal_state, next;
	STATES* p;
	int i, j, n, free_day, k;
	short answer;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		p = free_days + 1;
		for ( i = 30; i != 0; i--, p++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( *p & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = 31 - i;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( *p & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int main() {
	string Sa, Sb, Sc;	cin >> Sa >> Sb >> Sc;
	char f = Sa[0];
	while (true) {
		if (Sa.size() == 0 && f=='a') {
			cout << "A" << endl;
			cin >> Sa;
			return 0;
		}
		if (Sb.size() == 0 && f == 'b') {
			cout << "B" << endl;
			cin >> Sa;
			return 0;
		}
		if (Sc.size() == 0 && f == 'c') {
			cout << "C" << endl;
			cin >> Sa;
			return 0;
		}

		if (f == 'a') {
			f = Sa[0];
			Sa.erase(Sa.begin());
		}
		else if (f == 'b') {
			f = Sb[0];
			Sb.erase(Sb.begin());
		}
		else if (f == 'c') {
			f = Sc[0];
			Sc.erase(Sc.begin());
		}
	}
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let a: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let ans = (0..N).filter(|&i| a[a[i] - 1] == i + 1).count() / 2;

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


Measured memory_bytes: 6396
N, M = map(int,input().split())

def dfs(edge, reach):
  if(all(reach)):
    return 1
  ret = 0
  for e in edges[edge]:
    if(reach[e]):
      continue
    reach[e] = True
    ret += dfs(e, reach)
    reach[e] = False
  return ret

edges = [[] for _ in range(N)]
all_reach = [False for _ in range(N)]

for _ in range(M):
  a, b = map(int,input().split())
  a -= 1
  b -= 1
  edges[a] = edges[a] + [b]
  edges[b] = edges[b] + [a]

all_reach[0] = True
print(dfs(0, all_reach))

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int a = x / 500;
        int b = (x % 500) / 5;
        int res = a*1000 + b*5;
        
        System.out.println(res);
    }
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int total = 0;
	vector<int> arr(n);
	for(int i=0; i<n; ++i){
		cin>>arr[i];
		total ^= arr[i];
	}
	for(int i=0; i<n; ++i){
		cout<<(total ^ arr[i])<<" ";
	}
	cout<<'\n';
	return 0;
}


Measured memory_bytes: 3920
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, k, p[200010], c[200010];
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", p + i);
	c[0] = 0;
	for (int i = 1; i <= n; i++)
		c[i] = p[i] + 1;
	for (int i = 1; i <= n; i++)
		c[i] += c[i - 1];
	int max_e = 0;
	for (int i = k; i <= n; i++)
		max_e = max(max_e, c[i] - c[i - k]);
	printf("%d", max_e / 2);
	if (max_e & 1)
		printf(".5");
	printf("\n");
}

Measured memory_bytes: 1664
mod = 10 ** 9 + 7

s = input()

cur = [0] * 13
cur[0] = 1
d = 1
for c in s[::-1]:
    if c != '?':
        l = [int(c)]
    else:
        l = [j for j in range(10)]
    tmp = [0] * 13
    for j in l:
        for k in range(13):
            ind = (j * d + k) % 13
            tmp[ind] += cur[k]
            tmp[ind] %= mod
    cur = tmp
    d *= 10
    d %= 13
print(cur[5])

Measured memory_bytes: 42860
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << " --> " << x << endl;
#define deb1a(v) cout << #v << "--->" << endl; for (auto it : v)  cout << it << " "; cout << endl;
#define deb2a(v) cout << #v << "--->" << endl;for (auto it:v){for(auto it1 : it){cout << it1 << " ";}cout<< endl;}
#define deb3a(v) cout << #v << "-->" << endl; for(auto it:v){cout << it.fi << " " << it.se << endl;}
#define mod 1000000007
#define so(v) sort(v.begin(),v.end())
#define fi first
#define se second
#define db1(x) cout<<#x<<"="<<x<<endl
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<endl
int power(int x, unsigned int y, int p){ int res = 1;x = x % p;while (y > 0)  { if (y & 1)res = (res*x) % p;y = y>>1;  x = (x*x)% p;} return res;}
// int mI(int a, int m)  {return power(a, m - 2, m);}
vector<vector<int>> dir = {{2, 1}, {2, -1}, {-2, 1}, {-2, -1},{1,2},{1,-2},{-1,2},{-1,-2}};

void solve(){
    int x, y;
    cin >> x >> y;
    if(y%2){
        cout << "No";
        return;
    }
    if(y/2-x<0){
        cout << "No";
        return;
    }
    int a =(int) (y / 2) - x;
    int b = x - a;
    if(a<0||b<0){
        cout << "No";
    }
    else
        cout << "Yes";

}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t = 1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3624
#include <cmath>
#include <limits>
#include<iostream>
using namespace std;
int main()
{
    long long n,m,ans,temp;
    cin >> n ;

    m = sqrt(n);
    ans = n;
    for (long long i = 1; i <= m; ++i)
    {
        if (n % i == 0)
        {
            temp = i + (n / i) -2;
            if (temp < ans)
            {
                ans = temp;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int N = 3000000;
const int MOD = 998244353;

int fact[N];
int ifact[N];

int C(int n, int k) {
  if (k < 0 || k > n) return 0;
  return 1LL * fact[n] * ifact[k] % MOD * ifact[n-k] % MOD;
}

int M(int n, int k) {
  return C(n + k - 1, k - 1);
}

int n, m;

int main() {
  fact[0] = 1;
  for (int i = 1; i < N; ++i) fact[i] = 1LL * fact[i-1] * i % MOD;
  ifact[N-1] = 347057526;
  for (int i = N-2; i >= 0; --i) ifact[i] = 1LL * ifact[i+1] * (i+1) % MOD;
  
  scanf("%d %d", &n, &m);
  
  long long ans = 0;
  for (int odd = 0; odd <= m; ++odd) {
    if (m*3 - odd & 1) continue;
    
    int nn = m*3 - odd >> 1;
    
    long long res1 = 1LL * M(nn, n) - 1LL * M(nn - m, n) * n % MOD;
    long long res2 = 1LL * M(nn - m, n - 1) * n % MOD;
    
    ans = ans + res1 * C(n, odd) % MOD + res2 * C(n-1, odd) % MOD;
  }
  
  ans %= MOD;
  if (ans < 0) ans += MOD;
  
  printf("%lld\n", ans);
  return 0;
}


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



int main() {

    int h,w;
    cin >> h >> w;

    string str[55];

    string tmp1 = "";
    for(int i = 0; i < w + 2; i++) tmp1 += ".";
    str[0] = tmp1;

    string tmp2 = "";
    for(int i = 0; i < h; i++){
        cin >> tmp2;
        str[i + 1] = "." + tmp2 + ".";
    }

    str[h + 1] = tmp1;

    bool can = true;

    for(int i = 1; i < h + 1; i++){
        if(can == false) break;
        for(int j = 1; j < w + 1; j++)
        {
            if(str[i][j] == '#'){
                if(str[i][j-1] == '.'){
                    if(str[i][j+1] == '.'){
                        if(str[i-1][j] == '.'){
                            if(str[i+1][j] == '.'){
                                can = false;
                                break;
                            } 
                        }
                    }
                }
            }
        }    
    }
    if(can){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
lstX = list(map(int, input().split()))
lstY = list(map(int, input().split()))
lstX.sort(reverse=True)
lstY.sort()
#print(lstX)
#print(lstY)
if lstX[0] > X and lstX[0] + 1 <= lstY[0] and lstX[0] + 1 <= Y:
    print('No War')
elif lstX[0] < X and X + 1 <= lstY[0] and X + 1 <= Y:
    print('No War')
else:
    print('War')

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

int main(){
    int a, b, c, i;
    int num = 0;
    
    cin >> a >> b >> c;
    
    for(i = a; i <= b; i ++){
        if(c % i == 0){
            num ++;
        }
    }
    
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 3100
N = int(input())
P = list(map(int,input().split()))

count = 0
for i in range(1, N-1):
  if P[i-1] > P[i] and P[i] > P[i+1]:
    count += 1
  if P[i-1] < P[i] and P[i] < P[i+1]:
    count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define minimum(a,b) if(a>b) a=b;
#define what_is(x) cerr << #x << ": " << x << endl;
typedef vector<vector<ll>> matrix;
const ll INF = 1e9+5;
const int MAX = 2e5+4;
const int MOD = 1e9+7;
const int BIG = 100000005;
//vector<vector<ll>> dp(MAX,vector<ll>(3));
//vector<ll> dp(MAX);
template <typename T> void max_self(T& a,T b)
{
	a=max(a,b);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n*a,b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i=0;i<t;i++)
#define ll long long int
#define ld long double
#define umpl unordered_map<ll,ll> 
#define vl vector<ll>
#define vld vector<ld>
#define vvl vector<vl>
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define pcout(x,p) cout<<fixed<<setprecision(p)<<x
#define all(a) a.begin(),a.end()
#define endl "\n"

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll min(ll a, ll b){return a<b?a:b;}
inline ll ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
inline ll mo(ll a,ll b){if(b<0){b=abs(b)%mod;b=a-b;return (b<0)?b+mod:b;}else{return (a+b)%mod;}}
inline ll pow(ll a,ll b){if(b==0){return 1;}else{if(b%2==0){ll temp=pow(a,b/2);return temp*temp;}
else{return a*pow(a,b-1);}}}

struct comp { 
    template<class T1,class T2,class T3,class T4>
    bool operator()(const pair<T1,T2> &p1,const pair<T3,T4> &p2){
        if(p1.first!=p2.first)return p1.first<p2.first;
        else return p1.second<p2.second;
    }
}; 

int main()
{
    fio;
    ll n,weight;cin>>n>>weight;
    vl w(n),v(n);
    f(n){
        cin>>w[i]>>v[i];
    }
    ll value=0;
    value=accumulate(all(v),value);
    vl dp(value+1,inf);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=value-v[i];j>=0;j--){
            dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
        }
    }
    ll ans;
    for(ll i=0;i<=value;i++){
        if(dp[i]<=weight){
            ans=i;
        }
    }
    cout<<ans<<endl;
}

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

int H,W;
int main() {
	while(true) {
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		for(int i=0; i<H; ++i) {
			for(int k=0; k<W; ++k) {
				if( (i+k) % 2 ) cout << ".";
				else cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int n;
    cin >> n;
    cout << (n + 2 - 1) / 2 << endl;
    return 0;
}

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

using namespace std;

int main(){
    int N,M,count=0;
    cin>>N;
    vector<string> s(N);
    for(int i=0;i<N;++i)cin>>s[i];
    
    cin>>M;
    vector<string> t(M);
    for(int i=0;i<M;++i)cin>>t[i];

        auto calc=[&](string find){
            int buf=0;
                for(string word:s){
                    if(word==find)buf++;
                }
                for(string word:t){
                    if(word==find)buf--;
                }
            return buf;
        };

                    for(string word : s ){
                        count=max(count,calc(word));
                    }

        cout<<count;


}

Measured memory_bytes: 3172
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};



signed main(){
    int n,k,ans=0;
    cin>>n>>k;
    vector<pint> v(n);
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        v[i]=make_pair(a,b);
    }
    sort(v.begin(),v.end());
    rep(i,0,n){
        if(v[i].se<k){
            k-=v[i].se;
            continue;
        }
        cout<<v[i].fi<<endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#define N 100
int main(void){
  int n,i,j,v[N]={},c[N]={},diff[N]={},max=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",v+i);
  }
  for(i=0;i<n;i++){
    scanf("%d",c+i);
  }
  for(i=0;i<n;i++){
    diff[i]=v[i]-c[i];
  }
  for(i=0;i<n;i++){
    if(diff[i]>0){
      max+=diff[i];
    }
  }
  printf("%d\n",max);
  return 0;
}


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


int main(){
  int N;
  cin >> N;
  
  bool ans=false;
  for(int i=1;i<10;i++){
    if( (N%i==0) && (N/i<10) )ans = true;
  }
  
  cout << (ans ? "Yes" : "No") << endl;
}

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

const int N = 3e3 + 5;
const int Mod = 1e9 + 7;

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

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) dp[0][i][0] = 1;
	dp[0][0][1] = 1;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j <= n; j++) {
			//if (dp[i][j] == 0) continue;
			if (j == 0) {
				(dp[i + 1][j][1] += dp[i][j][1]) %= Mod;
				(dp[i + 1][j + 1][1] += dp[i][j][1]) %= Mod;
			} else 
			if (j == n) {
				(dp[i + 1][j][1] += dp[i][j][1]) %= Mod;
				(dp[i + 1][j - 1][1] += dp[i][j][1]) %= Mod;
			} else {
				(dp[i + 1][j][1] += dp[i][j][1]) %= Mod;
				(dp[i + 1][j + 1][1] += dp[i][j][1]) %= Mod;
				(dp[i + 1][j][1] += dp[i][j][1]) %= Mod;
				(dp[i + 1][j - 1][1] += dp[i][j][1]) %= Mod;
			}
			
			if(j > 1) {
				if (j != n) (dp[i + 1][j][0] += dp[i][j][0]) %= Mod;
				if (j != n) (dp[i + 1][j + 1][0] += dp[i][j][0]) %= Mod;
				(dp[i + 1][j][0] += dp[i][j][0]) %= Mod;
				(dp[i + 1][j - 1][0] += dp[i][j][0]) %= Mod;
			}
			
			if (j == 1) {
				(dp[i + 1][j - 1][1] += dp[i][j][0]) %= Mod;
				if (j != n) (dp[i + 1][j][0] += dp[i][j][0]) %= Mod;
				(dp[i + 1][j][1] += dp[i][j][0]) %= Mod;
				if (j != n) (dp[i + 1][j + 1][0] += dp[i][j][0]) %= Mod;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= n; i++) (ans += dp[m][i][1]) %= Mod;
	cout << ans; 
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=1, tmp=0;
vector<ll> T, A, Tmins, Amins;

signed main(){
    cin >> N;
    Tmins.resize(N, 1);
    tmp = 0;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        T.push_back(a);
        if(tmp<a) {
            tmp = a;
            Tmins[i] = tmp;
        }
    }
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    reverse(A.begin(), A.end());
    Amins.resize(N, 1);
    tmp = 0;
    for(int i=0;i<N;i++) {
        if(tmp<A[i]) {
            tmp = A[i];
            Amins[i] = tmp;
        }
    }
    reverse(A.begin(), A.end());
    reverse(Amins.begin(), Amins.end());
    for(int i=0;i<N;i++) {
        A[i] = min(A[i], T[i]);
        Amins[i] = max(Amins[i], Tmins[i]);
        ans *= max(0LL,(A[i]-Amins[i]+1LL));
        ans %= MOD;
    }
    /*
    for(int i=0;i<N;i++) {
        cout << " " << A[i];
    }
    cout << endl;
    for(int i=0;i<N;i++) {
        cout << " " << Amins[i];
    }
    cout << endl;
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6460
import java.io.*;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			try{ 
				int n = Integer.parseInt(reader.readLine());
				if(n == 0){break;}
				if(n == 1){System.out.println("1"); continue;}
				int Sieve[];				//0?????¨????´???° 1?????¨????´???°??§?????????
				Sieve = new int[2*n+1];
				int number = 0;				//?´???°????????°
				int i;
				int j;
				
				for(i=2;i<2*n+1;i+=2){		//2????????°????´???°??§?????????
					Sieve[i] = 1;
				}
				 
				for(i=3;i<2*n+1;i+=1){
					if(Sieve[i]==0){//i????´???°??????
						if(n < i){
							number += 1;
						}
						for(j=i;j<2*n+1;j+=2*i){		//i????????°????´???°??§?????????
							Sieve[j] = 1;
						}
					}
				}
				System.out.println(number);
				
			}
			catch(IOException e){
				System.out.println(e);
			}
		}
		return;

	}

}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

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

const string STR_INF = "-";

void chmax(string &a, string b) {
	if (a == STR_INF
		|| a.size() < b.size()
		|| (a.size() == b.size() && a < b)
	) {
		a = b;
	}
}

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

	int n, m;
	cin >> n >> m;

	vector<int> a(m);
	for (auto &v : a) {
		cin >> v;
	}

	vector<int> match = { 2,5,5,4,5,6,3,7,6 };
	vector<string> dp(1e5, STR_INF);
	dp[0] = "";

	for (int i = 0; i <= n; i++) {
		if (dp[i] == STR_INF) {
			continue;
		}

		for (auto v : a) {
			chmax(dp[i + match[v - 1]], dp[i] + (char)('0' + v));
		}
	}

	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 44416
x,y = map(int,input().split())

t = list(map(int,input().split()))

count = 0

memo = 0

for i in range(x+1):
    #print(i)
    if i == 0:
        count += 1
    else:
        memo += t[i-1]
        if memo <= y:
            count += 1
print(count)

Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
//#define N 1000000007

using namespace std;

int main(){
    lli n,a,gu,ki;
    vector<lli> v;
    lli i;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        v.push_back(a);
    }
    gu=n/2;
    ki=n-gu;
    if(n%2==0){
        rrep(i,gu,0){
            cout<<v[i*2-1]<<" ";
        }
        rep(i,0,ki){
            cout<<v[i*2];
            if(i<ki-1){
                cout<<" ";
            }
        }
    }
    else{
        rrep(i,ki,0){
            cout<<v[i*2-2]<<" ";
        }
        rep(i,0,gu){
            cout<<v[i*2+1];
            if(i<gu-1){
                cout<<" ";
            }
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3824
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def check(H):
    N = len(H)
    for i in range(N):
        if H[i] != 0:
            return False

    return True


def main():
    N = int(input())
    H = list(map(int, input().split()))

    ans = 0
    while True:
        if check(H):
            break

        # 区間分割
        i = 0
        while i < N:
            if H[i] == 0:
                i += 1
            else:
                # 区間が始まる
                ans += 1
                while i < N and H[i] > 0:
                    H[i] -= 1
                    i += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  mod 1000000007
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  vi vector<int>
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  vstr vector<string>
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  vin(v,n) for(int i=0;i<n;i++){ll x;cin>>x; v.pb(x);}
#define  for0(i,n) for(int i=0;i<n;i++)
#define  for1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  eb emplace_back
#define  bs binary_search
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  yes "YES"
#define  no "NO"
#define  PI 3.141592653589793238462643383279502884L
ll Ceil(ll a, ll b) {return a / b + (a % b != 0);}
ll fastModExp(ll a, ll b) { ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
ll Logn(ll n, ll r)
{
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0;
}
// 2- Dimensional vector:- vector<vector<int> > v(n, vector<int> (26, 0));

mpll mpx, mpx2;
int main()
{
    FIFO;
    ll n = 5, k;
    vll v;
    vin(v, n);
    for0(i, n)
    if (v[i] == 0)
        k = i;
    cout << k + 1 << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.*

fun main(args: Array<String>) {
    val n = getInt()
    val ok = getInts().filter { it % 2 == 0 }.all { it % 3 == 0 || it % 5 == 0}
    if (ok) {
        println("APPROVED")
    } else {
        println("DENIED")
    }
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }
fun getLong() = readLine()!!.toLong()
fun getLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 38116
#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
#define REP(i, n) for (i64 (i) = 0; (i) < (n); ++(i))
#define FOR(i, a, b) for (i64 (i) = (a); (i) < (b); ++(i))

int N, ret;
string S;

signed main() {

    cin >> S;
    N = S.size();

    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (cnt % 4 == 0) {
            if (cnt == 4) ++ret;
            cnt = 0;
        }
        if (S[i] == 'L') --cnt;
        else ++cnt;
    }

    if (cnt == 4) ++ret;

    cout << ret << endl;

}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string str;
    int n;
    cin>>n>>str;
    int mx=INT_MIN;
    int x=0;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='I')
        {
            x++;
            mx=max(mx,x);
        }
        else
        {
            x--;
            mx=(max(mx,x));
        }
    }
    cout<<max(mx,0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

long hunt(long h){
    if (h == 1){
        return 1;
    }
    return 2 * hunt(h / 2) + 1;
}

int main(){
    long H;
    
    cin >> H;

    long cnt = 0;

    cnt = hunt(H);
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int[] rb = {0,0};
        for (String s:str.split("")){
            if (s.equals("0")){
                rb[0]++;
            } else {
                rb[1]++;
            }
        }
        System.out.println(Math.min(rb[0],rb[1])*2);
    }
}

Measured memory_bytes: 30676
n,k = map(int, input().split())

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist
mod = 10**9+7
a=find_power(4*10**5+100,mod)
b=find_inv_power(4*10**5+100)

def comb(n,r,mod=10**9+7):
    if n<r:
        return 0
    elif n>=r:
        return (a[n]*b[r]*b[n-r])%(mod)

if n<=k:
    K=comb(2*n-1,n-1,mod)
    print(K)
    exit()

ans=0
for i in range(k+1):
    zs=i
    sm=comb(n,i) * comb(n-1,i)
    sm %= (10**9+7)
    ans+=sm

print(ans%(10**9+7))

Measured memory_bytes: 85428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int x[] = new int[N];
		int dx[] = new int[N];
		int minDx = 1000000000;
		for (int i = 0; i < x.length; i++) {
			x[i] = sc.nextInt();
			dx[i] = Math.abs(X - x[i]);
			if(dx[i] < minDx) {
				minDx = dx[i];
			}
		}

		if(minDx == 1) {
			System.out.println(1);
			return;
		}

		for (int i = 0; i < dx.length; i++) {
			int gcd = gcd(dx[i], minDx);
			if(gcd == 1) {
				System.out.println(1);
				return;
			}
			if(gcd < minDx) {
				minDx = gcd;
			}
		}

		System.out.println(minDx);

		return;
	}

	public static int gcd(int x, int y) {
		int tmp;
		while((tmp = x % y) != 0) {
			x = y;
			y = tmp;
		}
		return y;
	}
}


Measured memory_bytes: 52056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
typedef pair<int,int>pi;
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0)
#define bitseT(y,pos) (1<<pos)|y
#define bitchecK(y,pos) ((1<<pos)&y)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
int ara[100004];
int main()
{
    IOS;
    int n;cin>>n;
    int pos=-1,mx=0;
    for(int i=1;i<=n;i++)
    {
        int a;cin>>a;
        ara[i]=a;
        if(mx<abs(a)){
            mx=abs(a);
            pos=i;
        }
    }
    if(pos==-1){
        cout<<0<<endl;
        return 0;
    }
    vector<pi>ans;
    for(int i=1;i<=n;i++)
    {
        if(ara[i]==0||(ara[i]<0&&ara[pos]>0)||(ara[i]>0&&ara[pos]<0))
        {
            ans.pb({pos,i});
            ara[i]+=ara[pos];
        }
    }
//    cout<<"pos = "<<pos<<" "<<ara[pos]<<endl;
//    prinT(ara,n+1);
    if(ara[pos]>0){
        for(int i=1;i<n;i++)
        {
            ara[i+1]+=ara[i];
            ans.pb({i,i+1});
        }
    }
    else if(ara[pos]<0)
    {
        for(int i=n;i>1;i--)
        {
            ans.pb({i,i-1});
            ara[i-1]+=ara[i];
        }
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++)cout<<ans[i].ff<<" "<<ans[i].ss<<endl;
//    prinT(ara,n+1);
}



/*
6
4 -8 5 2 -4 3

*/


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

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<int> v1(n);
        vector<int> v2(m);
        for(int i=0; i<n; ++i) {
            cin >> v1[i];
        }
        for(int i=0; i<m; ++i) {
            cin >> v2[i];
        }
        int sum1 = accumulate(v1.begin(), v1.end(), 0);
        int sum2 = accumulate(v2.begin(), v2.end(), 0);
        int sub = sum1 - sum2;
        int ret1 = 1000, ret2 = 1000;
        for(int i=0; i<n; ++i) {
            for(int j=0; j<m; ++j) {
                if((v1[i] - v2[j])*2 == sub) {
                    if(ret1 + ret2 > v1[i] + v2[j]) {
                        ret1 = v1[i];
                        ret2 = v2[j];
                    }
                }
            }
        }
        if(ret1 == 1000) cout << -1 << endl;
        else             cout << ret1 << " " << ret2 << endl;
    }
}

Measured memory_bytes: 2964