akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd

def input(): return sys.stdin.readline().strip()
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class SegTree:
    """
    以下のクエリを処理する
    1.update:  i番目の値をxに更新する
    2.get_val: 区間[l, r)の値を得る
    """
 
    def __init__(self, n, func, init):
        """
        :param n: 要素数
        :param func: 値の操作に使う関数(min, max, addなど)
        :param init: 要素の初期値
        """
        n += 1
        self.n = n
        self.func = func
        self.init = init
        # nより大きい2の冪数
        n2 = 1
        while n2 < n:
            n2 <<= 1
        self.n2 = n2
        self.tree = [self.init] * (n2 << 1)
 
    def update(self, i, x):
        """
        i番目の値をxに更新
        :param i: index(0-indexed)
        :param x: update value
        """
        i += self.n2
        self.tree[i] = x
        while i > 1:
            self.tree[i >> 1] = x = self.func(x, self.tree[i ^ 1])
            i >>= 1
 
    def get_val(self, a, b):
        """
        [a, b)の値を得る
        :param a: index(0-indexed)
        :param b: index(0-indexed)
        """
        l = a + self.n2
        r = b + self.n2
        s = self.init
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.tree[r])
            if l & 1:
                s = self.func(s, self.tree[l])
                l += 1
            l >>= 1
            r >>= 1
        return s

N=INT()
A=LIST()

st=SegTree(N+2, gcd, 0)
for i in range(N):
    st.update(i+1, A[i])

ans=0
for i in range(1, N+1):
    ans=max(ans, gcd(st.get_val(0, i), st.get_val(i+1, N+2)))
print(ans)


Measured memory_bytes: 89580
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	string s;

	cin >> s;

	int n = stoi(s), fx = 0;

	for (int i = 0; i < s.size(); i++)
	{
		fx += s[i] - '0';
	}

	if (n%fx == 0)cout << "Yes\n";
	else  cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
    
class Main{
   
static final PrintWriter out=new PrintWriter(System.out);
static final int MOD=10007;
    
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line);
int[] pic=new int[n];
line=br.readLine();
for(int i=0;i<n;i++) pic[i]=bit(line.charAt(i));
int[][] dp=new int[n][1<<3];
for(int i=0;i<1<<3;i++){
if((i&(1<<0))!=0&&(i&pic[0])!=0) dp[0][i]=1;
}
for(int i=1;i<n;i++)
for(int j=1;j<(1<<3);j++)
for(int k=1;k<(1<<3);k++)
if((k&pic[i])!=0){
if((j&pic[i])!=0) dp[i][k]+=dp[i-1][j];
else if((j&k)!=0) dp[i][k]+=dp[i-1][j];
dp[i][k]%=MOD;
}
int ans=0;
for(int i=1;i<1<<3;i++) ans+=dp[n-1][i];
out.println(ans%MOD);
out.flush();
}
}
  
public static int bit(char c){
if(c=='J') return 1<<0;
else if(c=='O') return 1<<1;
else return 1<<2;
}
}

Measured memory_bytes: 18600
#include <stdio.h>
bool used[1000005];int RideBack[79000],last=0;
int bin_search(int val) {int left=0,right=last-1,ans=0;while (left<=right) {int center=(left+right)>>1;if (RideBack[center]>val) right=center-1;else left=center+1,ans=left;} return ans;}
int main() {
    int i;for (i=2;i<=1000000;used[i++]=true);
    for (i=2;i<=1000;i++) if (used[i]) for (int j=i*i;j<=1000000;j+=i) used[j]=false;
    for (i=2;i<=1000000;i++) if (used[i]) RideBack[last++]=i;
    while (scanf("%d",&i)!=EOF) printf("%d\n",bin_search(i));return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void)
{
	int hen1, hen2, tai;
	int ct_c;
	int ct_h;
	
	ct_c = ct_h = 0;
	while (scanf("%d, %d, %d", &hen1, &hen2, &tai) != EOF){
		if (tai * tai - (hen1 * hen1 + hen2 * hen2) == 0){
			ct_c++;
		}
		else if (hen1 == hen2){
			ct_h++;
		}
	}
	
	printf("%d\n%d\n", ct_c, ct_h);
	
	return (0);
}

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

int main()
{
    ll n;

    cin >> n;

    ll a[n + 5], sum = 0, ans = 1e18;

    for(ll i = 0; i < n; i++) cin >> a[i];

    for(ll i = 1; i <= 100; i++){
        sum = 0;

        for(ll j = 0; j < n; j++){
            ll x = (i - a[j]);
            sum += (x * x);
        }

        ans = min(sum, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//template---{{{
#include <bits/stdc++.h>

using namespace std;

//DEFINE---{{{
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b); i > (a); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
//end.DEFINE---}}}

//end.template ---}}}

int main() {
  int N, K;
  vector<int> A;

  cin >> N >> K;

  int i;
  int sum = 0;
  REP(i, N) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  for (i = 0; i < K; ++i) {
    A[i] = 1;
  }
  sum++;

  while (i < N) {
    i += K - 1;
    sum++;
  }

  cout << sum << endl;

  return (0);
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n),ans;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = n-1;i >= 0;--i) {
        int cnt = 0;
        for (int j = i;j < n;j += i+1) cnt += b[j];
        cnt &= 1;
        if (cnt != a[i]) {
            b[i] = 1;
            ans.push_back(i+1);
        }
    }
    int m = ans.size();
    cout << m << endl;
    for (int i = 0;i < m;++i) cout << ans[i] << " \n"[i == m-1];
    return 0;
}

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        int zeroCount = 0;
        int oneCount = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                zeroCount++;
            }
            else {
                oneCount++;
            }
        }

        System.out.println(Math.min(zeroCount, oneCount) * 2);

    }
}


Measured memory_bytes: 27092
N, M = map(int, input().split())
# P_S = [ input().split() for _ in range(M)]

AC = 0
WA = 0
WA_dict = {i: 0 for i in range(1, N+1)}
AC_dict = {i: 0 for i in range(1, N+1)}

for _ in range(M):
    p, s = input().split()
    if AC_dict[int(p)]==1:
        continue
    elif s=='WA':
        WA_dict[int(p)] += 1
    else:
        AC += 1
        AC_dict[int(p)] = 1
        WA += WA_dict[int(p)]
print(AC, WA)

Measured memory_bytes: 64356
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S = _S()
    Q = I()
    Querys = [LS() for _ in range(Q)]
    rev_flg = -1
    dq = collections.deque(S)
    for q in Querys:
        if q[0]=='1':
            rev_flg *= -1
        else:
            ti,fi,ci = q
            if int(fi)*rev_flg in (1,-2):
                dq.append(ci)
            else:
                dq.appendleft(ci)

    print("".join(dq)[::-1] if rev_flg==1 else "".join(dq))

main()



Measured memory_bytes: 43940
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        sc.close();
        String[] S = s.split(" ");
        int a = Integer.parseInt(S[0]);
        int b = Integer.parseInt(S[1]);
        int count = 0;

        for(int i = 0; i < 2; i++) {
            if(a > b) {
                count += a;
                a--;             
            }else{
                count += b;
                b--;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> s(n+1);
    s[0] = 0;
    for(ll i=0; i<n; i++){
       cin >> a[i]; 
       s[i+1] = s[i] + a[i];
    }

    ll ans = 0;
    ll count = 1;
    sort(s.begin(), s.end());
    ll t = s[0];
    for(int i=1; i<n+1; i++){
        if(t != s[i]){
            // printf("count:%d\n", count);
            ans += count * (count - 1) / 2;
            count = 1;
            t = s[i];
        }else if(i==n){
            count++;
            // printf("count:%d\n", count);
            ans += count * (count - 1) / 2;
        }else{
            count++;
        }
    }

    // for(ll i=0; i<n; i++){
    //     for(ll j=i+1; j<n+1; j++){
    //         if(s[i] == s[j]) ans++;
    //     }
    // }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int N;
  get(N);
  vector<ll> A(N + 1), B(N);
  getv(A);
  getv(B);
  ll ans = 0;
  FOR(i, N) {
    ll s = min(A[i], B[i]);
    A[i] -= s;
    B[i] -= s;
    ans += s;
    ll s2 = min(A[i + 1], B[i]);
    B[i] -= s2;
    A[i + 1] -= s2;
    ans += s2;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define PB push_back
#define F first
#define S second
using namespace std;
typedef pair<int,int>P;
typedef vector<int>V;
typedef vector<P>VP;
typedef queue<P>Q_P;
typedef priority_queue<P,VP,greater<P>>PQ;
V v[5001];
VP v1[5001];
int main(void){
	int n,m;
	P pp[5001],ppp;
	int x,y;
	int cost,now,next,MAX;
	int flg[5001],d[5001],flag;
	int i,j;
	PQ que1;
	Q_P que;
	cin>>n>>m;
	for(i=1;i<=n;i++)	cin>>pp[i].F>>pp[i].S;
	for(i=0;i<m;i++){
		cin>>x>>y;
		v[x].PB(y);
		v[y].PB(x);
	}
	for(i=1;i<=n;i++){
	    for(j=1;j<=n;j++)   flg[j]=0;
	    flg[i]=1;
		que.push(P(i,0));
		while(!que.empty()){
			ppp=que.front();
			now=ppp.F;	cost=ppp.S;
			que.pop();
			for(j=0;j<(int)v[now].size();j++){
				next=v[now][j];
				if(cost+1<=pp[i].S){
					if(flg[next]==0){
			            v1[i].PB(P(next,pp[i].F));
						que.push(P(next,cost+1));
			            flg[next]=1;
					}
				}
			}
		}
	}
	// for(i=1;i<=n;i++){
	   // printf("now_town=%d ",i);
		// for(j=0;j<(int)v1[i].size();j++){
			// printf("next_town=%d cost=%d    ",v1[i][j].F,v1[i][j].S);
		// }
		// printf("\n");
	// }
	for(i=1;i<=n;i++)   flg[i]=0;
	que1.push(P(0,1));
	while(!que1.empty()){
		//printf("check\n");
	    ppp=que1.top();
	    cost=ppp.F; now=ppp.S;
	    que1.pop();
		flag=0;
		for(j=1;j<=n;j++)	if(flg[j]==0)	flag=1;
		if(flag==0)	break;	
	    if(flg[now]==0){
			// printf("check\n");
	       d[now]=cost;
	       flg[now]=1;
	       for(j=0;j<v1[now].size();j++){
	            next=v1[now][j].F;
	            cost=v1[now][j].S;
	            if(flg[next]==0){
					// printf("check1\n");
	                que1.push(P(d[now]+cost,next));
	            }
	       }
	    }
	}
	cout<<d[n]<<endl;
	return 0;
}


Measured memory_bytes: 192956
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();

		if(a + b == c){
			System.out.println("Yes");
		}
		else if(b + c == a){
			System.out.println("Yes");
		}	
		else if(a + c == b){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 1000000007;
#define INV_10 299473306;
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	long long sum=0;
	cin >> n;
	for(int i = 1; i <= n; i++)
		if(i%3!=0 && i%5!=0)
			sum+=i;
	cout << sum << '\n';
}

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

long long x, y, z, k, a[1009], b[1009], c[1009];
vector<long long>vec;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> x >> y >> z >> k;
    for(int i = 0; i < x; ++i) { cin >> a[i]; }
    sort(a, a+x, greater<long long>());
    for(int i = 0; i < y; ++i) { cin >> b[i]; }
    sort(b, b+y, greater<long long>());
    for(int i = 0; i < z; ++i) { cin >> c[i]; }
    sort(c, c+z, greater<long long>());

    for(int l = 0; l < x; ++l) {
        for(int m = 0; m < y; ++m) {
            for(int n = 0; n < z; ++n) {
                if((l+1)*(m+1)*(n+1) <= k) {
                    vec.push_back(a[l] + b[m] + c[n]);
                }
                else { break; }
            }
        }
    }

    sort(vec.begin(), vec.end(), greater<long long>());
    for(int i = 0; i < k; ++i) { cout << vec[i] << "\n"; }
    return 0;
}

Measured memory_bytes: 1400
n = int(input())
H = list(map(int, input().split()))
ans = 0
r = 0
for l in range(n):
    while r < n - 1 and H[r] >= H[r+1]:
        r += 1
    ans = max(ans, r - l)
    if r == l:
        r += 1
print(ans)


Measured memory_bytes: 14224
#template
def inputlist(): return [int(k) for k in input().split()]
import sys
sys.setrecursionlimit(10**6)
#template
N,K = inputlist()
A = inputlist()
seen = [False]*(N+1)
dic = {n:0 for n in range(1,N+1)}
for i in range(N):
    dic[i+1] = A[i]

def search(i,count):
    seen[i] = True
    next_i = dic[i]
    if seen[next_i]:
        count+=1
        return [next_i,count]
    count+=1
    return search(next_i,count)
key,count_sum = search(1,0)

def find(i,count):
    if i == key:
        return count
    count+=1
    return find(dic[i],count)

tmp = find(1,0)
if K < count_sum:
    ans = 1
    for i in range(K):
        ans = dic[ans]
    print(ans)
    exit()

d = count_sum-tmp
Ka = K-tmp

mod = Ka % d

loop = []
loop.append(key)
def dfs(i):
    next_i = dic[i]
    if next_i == key:
        return False
    loop.append(next_i)
    return dfs(next_i)
dfs(key)

print(loop[mod])

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

using vi = vector<int>;

int is_palin(string s)
{
    s.erase(remove(begin(s), end(s), 'x'), end(s));

    auto t = s;

    reverse(begin(t), end(t));

    return s == t;
}

int main()
{
    ios_base::sync_with_stdio(0);

    string s; cin >> s;

    if(!is_palin(s))
    {
        cout << -1 << endl;
        return 0;
    }

    auto t = s;

    t.erase(remove(begin(t), end(t), 'x'), end(t));

    int n = s.size();
    int tn = t.size();

    if(!tn)
    {
        cout << 0 << endl;
        return 0;
    }

    vi l(tn), r(tn);

    for(int i = 0, j = 0, x = 0; i < n; i++)
    {
        if(s[i] == 'x') x++;
        else
        {
            l[j++] = x;
            x = 0;
        }
    }

    for(int i = n - 1, j = tn - 1, x = 0; i >= 0; i--)
    {
        if(s[i] == 'x') x++;
        else
        {
            r[j--] = x;
            x = 0;
        }
    }

    int ans = 0;

    for(int i = 0, j = tn - 1; i <= j; i++, j--)
        ans += abs(l[i] - r[j]);

    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

const long long MOD = 1e9+7;

#define ALL(A) A.begin(),A.end()

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

void ALLOUT_NUMBER(vector<ll> V)
{
    ll N = V.size();
    for(ll i=0;i<N;i++)
    {
        cout << V[i];
        if(i<N-1) cout << ' ';
    }
    cout << endl;
}

class Mll
{
    public:
    ll x;

    Mll() : x(0){}
    Mll(ll x=0) : x((x%MOD+MOD)%MOD){}

    Mll operator-() const
    {
        return Mll(-x);
    }

    Mll& operator+=(const Mll& A)
    {
        if((x += A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator-=(const Mll& A)
    {
        if((x += MOD - A.x) >= MOD) x -= MOD;
        return *this;
    }
    Mll& operator*=(const Mll& A)
    {
        (x *= A.x) %= MOD;
        return *this;
    }
    
    Mll operator+(const Mll& A)
    {
        Mll res(*this);
        return res+=A;
    }
    Mll operator-(const Mll& A)
    {
        Mll res(*this);
        return res-=A;
    }
    Mll operator*(const Mll& A)
    {
        Mll res(*this);
        return res*=A;
    }
    
    Mll pow(ll t) const // t乗
    {
        if(t==0) return 1;
        Mll A = pow(t>>1);
        A *= A;
        if(t&1) A *= *this;
        return A;
    }

    // for prime mod
    Mll inv() const
    {
        return pow(MOD-2);
    }
    Mll& operator/=(const Mll& A)
    {
        return (*this) *= A.inv();
    }
    Mll operator/(const Mll& A) const
    {
        Mll res(*this);
        return res/=A;
    }

    friend ostream& operator<<(ostream& os, const Mll& M)
    {
        os << M.x;
        return os;
    }
};

vector<Mll> ALLIN_MLL(ll N)
{
    vector<ll> numbers_ll(N);
    ALLIN1_NUMBER(numbers_ll);

    vector<Mll> numbers_Mll;
    for(ll i=0;i<N;i++)
    {
        Mll add(numbers_ll[i]);
        numbers_Mll.push_back(add);
    }

    return numbers_Mll;
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

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

    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif 
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};


int n,m;
int ans;
signed main(){
	
	string s;
    cin>>n>>s;
    int t=1;
    rep(i,n/2){
        if(s[i]!=s[s.size()/2+i]){
            t=0;
        }
    }
	if(t && n%2==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
for j in range(min(k, 42)):
    bit = [0 for _ in range(n)]
    for i in range(n):
        bit[max(i - a[i], 0)] += 1
        if i + a[i] + 1 < n:
            bit[i + a[i] + 1] -= 1
    result = [bit[0]]
    for i in range(n - 1):
        result.append(bit[i + 1] + result[-1])
    a = result
print(' '.join(list(map(str, a))))


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

int main() {
	unsigned long long h, w,result;
	cin >> h >> w;
	result =(long long) h * w / 2;
	if (h * w % 2 == 1) {
		result++;
	} 
	if(h==1||w==1){
		result = 1;
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/16/20 07:31:34
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  string s; cin>>s;
  int cnt[3] = {};
  map<char, int> cmap;
  cmap['R']=0;
  cmap['G']=1;
  cmap['B']=2;
  for (auto c:s)
    cnt[cmap[c]]++;
  ll ans = (ll)cnt[0]*cnt[1]*cnt[2];
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int k = j+j-i;
      if (k >= n) continue;
      if (s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k])
        ans--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;


#[fastout]
fn main() {
    input! {
    n: usize,
    s: Chars
    }
    let mut ans = 0;
    for i in 0..n - 2 {
        if s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' {ans += 1}
    }
    println!("{}", ans);
}



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

using namespace std;

int main() {
    int a[3];
    for (int i = 0; i < 3; i++) {
        scanf("%d", a + i);
    }
    sort(a, a + 3);
    if (a[0] == 5 && a[1] == 5 && a[2] == 7)
        puts("YES");
    else 
        puts("NO");
    return 0;
}

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

void solve(long long H, long long A){
    if (H % A) cout << H / A + 1 << '\n';
    else cout << H / A << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long

// abどちらが大きくてもいけるよ
signed gcd(int a,int b){
    return b ? gcd(b, a % b) : a;
}
// 使う時はgcdも呼び出してあげよう
signed ngcd(vector<int> a){
    int res = a.at(0);
    for(int i = 1;i < a.size() && res != 1;i ++){
        res = gcd(res,a.at(i));
    }

    return res;
}




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

    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i ++){
        cin >> a.at(i);
    }

    if(n == 2){
        cout << max(a.at(0),a.at(1)) << endl;;
        return 0;
    }

    vector<int> l(n),r(n),total(n);

    l.at(0) = a.at(0);
    l.at(1) = gcd(a.at(0),a.at(1));
    for(int i = 2;i < n;i ++){
        l.at(i) = gcd(l.at(i-1),a.at(i));
    }

    r.at(n-1) = a.at(n-1);
    r.at(n-2) = gcd(a.at(n-1),a.at(n-2));
    for(int i = n-3;i >= 0;i --){
        r.at(i) = gcd(a.at(i),r.at(i+1));
    }

    total.at(0) = r.at(1);
    total.at(n-1) = l.at(n-2);
    for(int i = 1;i < n-1;i ++){
        total.at(i) = gcd(l.at(i-1),r.at(i+1));
    }

    int ans = 1;
    for(int i = 0;i < n;i ++){
        ans = max(ans,total.at(i));
    }

    cout << ans << endl;
}







Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

bool ok[200];

void solve(){
    int x, y;
    cin >> x >> y;
    int ans = 0;
    if(x == 1){
        ans += 300000;
    }
    if(x == 2){
        ans += 200000;
    }
    if(x == 3){
        ans += 100000;
    }
    if(y == 1){
        ans += 300000;
    }
    if(y == 2){
        ans += 200000;
    }
    if(y == 3){
        ans += 100000;
    }
    if(x == 1 && y == 1) ans += 400000;
    cout << ans;
}


int main(){
    int q = 1;
    //cin >> q;
    while(q--) solve();
}
// vse dolzhny vyiti v internet po hhtp


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b<a+c&&a+b<b+c)
        cout<<a+b;
    else if(b+c<a+c)
        cout<<b+c;
    else cout<<a+c;
    return 0;
}


Measured memory_bytes: 3680
#include <stdio.h>
#include <string.h>
 
#define xyMAX 1001
#define qMAX 151
 
char x[xyMAX],y[xyMAX];
 
int lcs(char x[],char y[]){
  int a,b,i,j;
  int c[xyMAX][xyMAX];
  a = strlen(x);
  b = strlen(y);
  for(i=1; i<=a; i++) c[i][0] = 0;
  for(j=1; j<=b; j++) c[0][j] = 0;
  for(i=1; i<=a; i++){
    for(j=1; j<=b; j++){
      if(x[i-1] == y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j] >= c[i][j-1])c[i][j]=c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  return c[a][b];
 
}
 
 
int main(){
  int i,j,num;
  scanf("%d",&num);
  for(i=0; i<num; i++){
    scanf("%s%s",x,y);
    printf("%d\n",lcs(x,y));
  }
  return 0;
 
}

Measured memory_bytes: 4520
#[allow(dead_code)]
fn main() {
    let (w, h) = i::u2();
    let (x, y) = i::u2();

    let w = w as f64;
    let h = h as f64;
    let x = x as f64;
    let y = y as f64;
    println!(
        "{} {}",
        w * h / 2.0,
        if x == w / 2.0 && y == h / 2.0 { 1 } else { 0 }
    );
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=55;
int n,a[N],b[N],chu[N][N],bian[N][N];
ll ans;
int main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=1;i<=n;i++)b[i]=read();
	for(int i=0;i<=50;i++)for(int j=0;j<=50;j++)chu[i][j]=1e9;
	for(int i=0;i<=50;i++){
		chu[i][i]=0;
		for(int j=0;j<i;j++){
			for(int k=1;k<=i;k++)chu[i][j]=min(chu[i][j],max(chu[i%k][j],k));
		}
	}
	for(int i=1;i<=n;i++)if(chu[a[i]][b[i]]>100){
		puts("-1"); return 0;
	}
	for(int i=1;i<=n;i++)bian[i][a[i]]=1;
	for(int i=50;i;i--){
		bool flag=0;
		for(int j=1;j<=n;j++){
			bool fff=0;
			for(int k=0;k<=50;k++)if(bian[j][k]&&chu[k][b[j]]<i){
				fff=1; break;
			}
			if(!fff)flag=1;
		}
		if(flag){
			ans+=(ll)1<<i;
			for(int j=1;j<=n;j++)for(int k=0;k<=50;k++)if(bian[j][k])bian[j][k%i]=1;
		}
	}
	cout<<ans<<endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << abs(a-b) << endl;

    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
int main(void){
	int x;
	int retry;
	do {
		scanf("%d",&x);
		if(x == 0){
			puts("1");
			retry = 1;
		}
		else if(x == 1){
			puts("0");
			retry = 1;
		}else{
			printf("retry\n");
			retry = 0;
		}
	}while (retry == 0);
	return 0;
}

Measured memory_bytes: 1564
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int l = t.length;
		int min = l;
			for(int i = 0; i < s.length-l+1; i++) {
				int count = 0;
				for(int j = 0; j < l; j++) {
					if(s[i+j]!=t[j])count++;
				}
				if(count<min)min=count;
			}
			System.out.println(min);
	}
}

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

class Disjonset{
public:
    vector<int> p;
    Disjonset(int n){
        p.resize(n);
        for(int i=0;i<n;i++){
            p[i] = i;
        }
    }
    
    bool same(int x,int y){
        return findParent(x) == findParent(y);
    }
    void unite(int x,int y){
        x = findParent(x);
        y = findParent(y);
        p[x] = y;
    }
    
    int findParent(int x){
        if(x!=p[x]){
            p[x] = findParent(p[x]);
        }
        return p[x];
    }
};

class Edge{
public:
    //?????¶?????????????????¨??????
    int source,target,cost;
    Edge(int source=0, int target=0, int cost=0):
    source(source),target(target),cost(cost){}
    bool operator < (const Edge &e) const {
        return cost < e.cost;
    }
};




int kruskal(int N,vector<Edge> edges){
    Disjonset d = Disjonset(N+1);
    int totalCost = 0;
    sort(edges.begin(),edges.end());
    for(int i=0;i<edges.size();i++){
        if(!(d.same(edges[i].source,edges[i].target))){
            totalCost += edges[i].cost;
            d.unite(edges[i].source,edges[i].target);
        }
    }
    return totalCost;
}

int main(int argc, const char * argv[]) {
    int V,E;
    cin >> V >> E;
    vector<Edge> edges;
    for(int i=0;i<E;i++){
        int s,t,c;
        cin >> s>>t>>c;
        edges.push_back(Edge(s,t,c));
    }
    
    cout << kruskal(V, edges) << endl;
    
    return 0;
}

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

int main(){
    int a[32]={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 n;
    cin>>n;
    cout<<a[n-1];
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    long long a,b,n;
    cin>>a>>b>>n;
    long long ans=0;
    if(n>=b-1) ans=a*(b-1)/b;
    else ans=a*n/b;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
N = int(input())

res = []
if N != 0:
    while N != 0:
        q, r = divmod(N, -2)

        if r in {0, 1}:
            N = q
        else:
            r = N - (-2) * (q + 1)
            N = q + 1
        res.append(r)
else:
    res.append(0)

print("".join(list(map(str, res[::-1]))))

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N;

    void input() {
        cin >> N;
    }

    int snuke(int n) {
        int ret = 0;
        while (n > 0) {
            ret += (n % 10);
            n /= 10;
        }
        return ret;
    }

    void solve() {
        input();
        int snu = snuke(N);
        if (N % snu) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }

    }
};


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

    Solve().solve();

    return 0;
}


Measured memory_bytes: 256
n = input()
a = list(str(n))
if a[0]>a[1]:
    print(int(a[0])*111)
if a[0]==a[1]:
    if a[1]>=a[2]:
        print(int(a[0])*111)
    else:
        print((1+int(a[0]))*111)
if a[0]<a[1]:
    print((1+int(a[0]))*111)

          

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

using namespace std;

int main(void){
    int n,i;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++)
        cin >> a[i];
    sort(a.begin(),a.end());
    for(i=0;i<n-1;i++)
        if(a[i]==a[i+1])
            break;
    if(i==n-1)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

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

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll s;cin>>s;
  ll x,y;
  x=(1000000000-s%1000000000)%1000000000;
  y=(s+x)/1000000000;
  cout<<0<<' '<<0<<' '<<1000000000<<' '<<1<<' '<<x<<' '<<y<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#define ll long long
using namespace std;
ll dp[100010];
vector<pair<pair<ll, ll>, pair<ll, ll>>> vt;
int main()
{
	memset(dp, -1, sizeof(dp));
	ll n, m;
	scanf("%lld %lld", &n, &m);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		ll q, w, e;
		scanf("%lld %lld %lld", &q, &w, &e);
		sum += q * w;
		ll xx = (m - q)*e + q * w;
		vt.push_back({ {xx,q},{w,e} });
	}
	sort(vt.begin(), vt.end());
	reverse(vt.begin(), vt.end());
	ll mm = 0;
	ll ch = 0;
	ll sum1 = 0;
	ll sum2 = 0;
	ll dap = 0;
	for (int i = 0; i < n; i++) {
		dap += m;
		sum1 += vt[i].first.first;
		if (sum1 >= sum) {
			dap -= m;
			sum2 = sum1 - vt[i].first.first;
			ch = i;
			break;
		}
	}
	ll gap = 1e16;
	for (int i = 0; i < ch; i++) {
		ll xx = sum-(sum1 - vt[i].first.first);
		ll oo = (xx + vt[i].second.first - 1) / vt[i].second.first;
		oo = min(oo,(xx-vt[i].first.second*vt[i].second.first+vt[i].second.second*vt[i].first.second + vt[i].second.second - 1) / vt[i].second.second);
		gap = min(gap, oo);
	}
	for (int i = ch; i < n; i++) {
		ll xx = sum - sum2;
		ll oo = (xx + vt[i].second.first - 1) / vt[i].second.first;
		oo = min(oo, (xx - vt[i].first.second*vt[i].second.first + vt[i].second.second*vt[i].first.second + vt[i].second.second - 1) / vt[i].second.second);
		gap = min(gap, oo);
	}
	if (gap != 1e16)
		dap += gap;
	printf("%lld\n", dap);
}

Measured memory_bytes: 7024
using System;
using System.Linq;

public class AtCoder
{
  public static void Main()
  {
    var input = Console.ReadLine().Trim().Split().Select(e => int.Parse(e)).ToArray();
    var a = input[0];
    var b = input[1];
    var c = input[2];

    var ans = "NO";

    var total=0;
    for (var i = 0; i < b; i++)
    {
      if ((a * i) % b == c)
      {
        ans = "YES";
        break;
      }
    }

    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 13268
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] c = nextIntArray(sc, m);

		sc.close();

		int[][] dp = new int[m + 1][n + 1]; // dp[i][j] i-1番目の種類まで使用してj円となるように選んだ時のコイン枚数の最小値
		for (int i = 0; i <= m; i++) {
			for (int j = 1; j <= n; j++) {
				dp[i][j] = 100100100;
			}
		}

		for (int i = 0; i < m; i++) {
			for (int j = 0; j <= n; j++) {

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

				if (j >= c[i]) {
					dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i + 1][j - c[i]] + 1);
				}

			}
		}

		out.println(dp[m][n]);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}



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

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

  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}


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

int main(){
    int H,W;
    
    
    
    while(1){
        cin>>H>>W;
        if (H==0&&W==0) break;
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<"#";
            }
            cout<<"\n";
            
        }
        cout<<endl;
    
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(void) 
{
	int i, j, k, n;
	int data[4][3][10] = {{{0}}};
	scanf("%d", &n);
	for(i = 0; i < n; i++) {
    	int b, f, r, v;
    	scanf("%d %d %d %d", &b, &f, &r, &v);
    	data[b-1][f-1][r-1] += v;
	}
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 3; j++) {
			for(k = 0; k < 10; k++) {
				printf(" %d", data[i][j][k]);
			}
			printf("\n");
		}
		if (i < 3)
			printf("####################\n");
	}
	return 0;
}



Measured memory_bytes: 2088
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

ans = sum(b)
for i in range(1, n):
        if a[i] - a[i-1] == 1:
                ans += c[a[i-1]-1]
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int a[3];
	for(int i = 0; i < 3; i++){
		cin >> a[i];
	}
	sort(a, a + 3);
	if(a[0] + a[1] == a[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
long n,i,j,*nn;
for(;;){
cin>>n;
if(cin.eof())break;
nn=new long [n+1];
nn[1]=0;nn[2]=1;
for(i=3;i<=n;i+=2)nn[i]=1;
for(i=4;i<=n;i+=2)nn[i]=0;
for(i=3;i*i<=n;){
for(j=i;i*j<=n;j+=2)nn[i*j]=0;
i++;while(nn[i]==0)i++;
}
for(i=2,j=0;i<=n;i++)if(nn[i]==1)j++;
cout<<j<<endl;
delete [] nn;
}
return 0;
}

Measured memory_bytes: 9724
package main

import "fmt"

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

	if l, r := a+b, c+d; l > r {
		fmt.Println("Left")
	} else if l == r {
		fmt.Println("Balanced")
	} else {
		fmt.Println("Right")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define rep(i, a, b) for(int i = a; i < b; ++i)

int C(int x) { return x * (x - 1) / 2; }

const int N = 5e5;
int n, a[N], c[N], ans[N], pre, nw, all;

main() {
    cin >> n;
    rep(i, 0, n) {
        cin >> a[i];
        c[a[i]]++;
    }
    all = 0;
    rep(i, 0, n + 1) {
        all += C(c[i]);
    }
    rep(k, 0, n) {
        int x = a[k];
        pre = C(c[x]);
        c[x]--;
        nw = C(c[x]);
        ans[k] = all - pre + nw;
        c[x]++;
    }
    rep(k, 0, n) {
        cout << ans[k] << '\n';
    }
}

Measured memory_bytes: 12288
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n]
    }
    let mut kinds = 0;
    let mut v = vec![0; n];
    for z in a.iter() {
        if v[z - 1] == 0 {
            kinds += 1;
        }
        v[z - 1] += 1;
    }
    v.sort();
    if kinds <= k {
        kinds = 0;
    } else {
        kinds = kinds - k;
    }
    let mut ans = 0;
    for z in v {
        if kinds == 0 {
            break;
        }
        if z > 0 {
            ans += z;
            kinds -= 1;
        }
    }
    println!("{}", ans);

}


Measured memory_bytes: 8444
#02:02
n,k = map(int,input().split())
judge = [k]
for d in range(30):
  kx = k // 2**d * 2**d
  if kx != 0:
    judge.append(kx)
  else:
    break
l = len(judge)
for i in range(1,l):
  judge[i] -= 1
judge.reverse()
#print(judge)
can = [0 for _ in range(l)]
for _ in range(n):
  a,b = map(int,input().split())
  for i in range(l):
    if a | judge[i] == judge[i]:
      #print(bin(a),bin(judge[i]))
      can[i] += b
  #print(can)
#print(can)
print(max(can))

Measured memory_bytes: 46552
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	probabilities := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%f", &probabilities[i])
	}
	ans := probabilityWithMoreHeads(n, probabilities)
	fmt.Println(ans)
}

func probabilityWithMoreHeads(n int, probabilities []float64) float64 {
	dp := make([]float64, n+1)
	dp[0] = 1.0
	for coins := 0; coins < n; coins++ {
		for j := coins + 1; j >= 0; j-- {
			if j == 0 {
				dp[j] = 0.0 + dp[j]*(1-probabilities[coins])
			} else {
				dp[j] = dp[j-1]*probabilities[coins] + dp[j]*(1-probabilities[coins])
			}
		}
	}
	answer := 0.0
	for heads := 0; heads <= n; heads++ {
		tails := n - heads
		if heads > tails {
			answer += dp[heads]
		}
	}
	return answer
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
	cin>>n>>k;
	int p=n/k,q=0;
	if (k%2==0)
		q=(n+k/2)/k;
	cout<<(long long)p*p*p+(long long)q*q*q;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans=0;
    for(int i=0;i<t.size();i++){
        if(t[i]!=s[i]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

long long luca[87] = {0};

long long lucaN(long long n){
  if(luca[n] != 0 || n<2)	return luca[n];
  else return luca[n] = lucaN(n-1) + lucaN(n-2);
}
int main(){
  long long n;	cin >> n;
  luca[0] = 2;
  luca[1] = 1;
  cout << lucaN(n) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,Mqqq;
  cin >>N>>Mqqq;
  vector<int> x(N,0);vector<int> a(Mqqq);vector<int> b(Mqqq);
  for (int i=0;i<Mqqq;i++){
    cin >>a.at(i)>>b.at(i);
    x.at(a.at(i)-1) ++;
    x.at(b.at(i)-1) ++;
  }
  for (int i=0;i<N;i++){
    cout <<x.at(i)<<endl;
  }
}

Measured memory_bytes: 256