akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }

    REP(i, 1, n){
        a[i] += a[i - 1];
    }

    lint ans = LLINF;

    REP(i, 1, n - 2){
        auto it1 = upper_bound(a.begin() + 1, a.begin() + i, a[i] / 2LL);
        auto it2 = upper_bound(a.begin() + i + 2, a.begin() + (n - 1), a[i] + (a[n - 1] - a[i]) / 2LL);

        vector<lint> p(2), q(2), r(2), s(2);
        p[0] = *(it1 - 1);
        q[0] = a[i] - *(it1 - 1);
        r[0] = *(it2 - 1) - a[i];
        s[0] = a.back() - *(it2 - 1);

        if(it1 == a.begin() + i){
            p[1] = p[0];
            q[1] = q[0];
        }else{
            p[1] = *it1;
            q[1] = a[i] - *it1;
        }

        if(it2 == a.begin() + (n - 1)){
            r[1] = r[0];
            s[1] = s[0];
        }else{
            r[1] = *it2 - a[i];
            s[1] = a.back() - *it2;
        }

        rep(j, 2){
            rep(k, 2){
                ans = min(ans, max({p[j], q[j], r[k], s[k]}) - min({p[j], q[j], r[k], s[k]}));
            }
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define MAX 1000000
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  long long  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

int arr[100005];

int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
ll n,a,b,c,p,q,cnt=0,sum=0;
 for(int i=0;i<3;i++)
  cin>>arr[i];
sort(arr,arr+3);
cout<<arr[0]+arr[1]<<endl;



return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n<105){
      System.out.println(0);
    }else if(n<135){
      System.out.println(1);
    }else if(n<165){
      System.out.println(2);
    }else if(n<189){
      System.out.println(3);
    }else if(n<195){
      System.out.println(4);
    }else{
      System.out.println(5);
    }
    
  }
  

  
}


Measured memory_bytes: 23764
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N, A, B, C, i;
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        int [] D = new int[N];
        for(i = 0; i < N; i++){
            D[i] = sc.nextInt();
        }
        Arrays.sort(D);
        for(i = N - 1; i >= 0; i--){
          if((double)D[i] / B > (double)C / A){
               C = C + D[i];
               A = A + B;
              }
        }
        System.out.println(C/A);
    }
}

Measured memory_bytes: 18152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1e9+7
#define MOD 1e9+7
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

P p[100];
bool f[100];

void print_Preorder(int id){
	cout << " " << id;
	if (p[id].first != -1)print_Preorder(p[id].first);
	if (p[id].second != -1)print_Preorder(p[id].second);
}

void print_Inorder(int id){
	if (p[id].first != -1)print_Inorder(p[id].first);
	cout << " " << id;
	if (p[id].second != -1)print_Inorder(p[id].second);
}

void print_Postorder(int id){
	if (p[id].first != -1)print_Postorder(p[id].first);
	if (p[id].second != -1)print_Postorder(p[id].second);
	cout << " " << id;
}

int main(){
	int n, s;
	cin >> n;
	REP(i, n){
		int id, l, r;
		cin >> id >> l >> r;
		if (i == 0)s = id;
		p[id] = P(l, r);
		if (l != -1)f[l] = 1;
		if (r != -1)f[r] = 1;
	}
	REP(i, n){
		if (!f[i])s = i;
	}
	cout << "Preorder" << endl;
	print_Preorder(s);
	cout << endl;
	cout << "Inorder" << endl;
	print_Inorder(s);
	cout << endl;
	cout << "Postorder" << endl;
	print_Postorder(s);
	cout << endl;
}

Measured memory_bytes: 3088
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    txt = input()
    if txt == "AC":
        AC += 1
    elif txt == "WA":
        WA += 1
    elif txt == "TLE":
        TLE += 1
    else:
        RE += 1

print(f"AC x {AC}")
print(f"WA x {WA}")
print(f"TLE x {TLE}")
print(f"RE x {RE}")


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            var Cap = new List<long>();
            for (int i = 0; i < 5; i++)
            {
                Cap.Add(long.Parse(Console.ReadLine()));
            }
            long x = Cap.Min()==1 ? -1:0;
            x += n/Cap.Min() + 5;
            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 28216
import java.util.Scanner;

public class Main {

	static int input_N;
	static int input_M;
	static int input_X;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		input_N = sc.nextInt();
		input_M = sc.nextInt();
		input_X = sc.nextInt();
		int[][] sankosho = new int[input_N][input_M+1];

		int[] sum = new int[input_M+1];
		int depth = input_N;

		int result = -1;

		for(int i=0;i<input_N;i++) {
			for(int j=0;j<input_M+1;j++) {
				sankosho[i][j] = sc.nextInt();
			}
		}
		sc.close();

		//12冊ある参考書を総当りするコードを書きたい。
		result = serchSankosho(sankosho,sum,result,depth-1);

		// 出力
		System.out.println(result);

	}

	static int serchSankosho(int[][] sankosho,int[] sum,int result,int depth) {

		if(depth < 0) {
			for(int i=1;i<input_M+1;i++) {
				if(sum[i] < input_X ) {
					return result;
				}
			}

			if(sum[0] < result || result < 0) {
				return sum[0];
			}
			else {
				return result;
			}

		}

		int[] sum_bak = sum.clone();
		result = serchSankosho(sankosho,sum,result,depth-1);

		sum = sum_bak;
		for(int i=0;i<input_M+1;i++) {
			sum[i] = sum[i] + sankosho[depth][i];
		}
		result = serchSankosho(sankosho,sum,result,depth-1);

		return result;
	}

}


Measured memory_bytes: 29252
def main():
    N = map(int, input().split())
    A = list(map(int, input().split()))
    max_list = [0]*(len(A))
    max_list[0] = A[0]
    for i in range(1, len(A)):
        max_list[i] = max(max_list[i - 1], A[i])
    diff_sum = 0
    for i in range(len(A)):
        diff_sum += max_list[i] - A[i]
    return diff_sum

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 94096
import java.util.*;
public class Main{
  static long ans = 0;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] arr = sc.next().toCharArray();
    calc(1,0,arr[0]-'0',arr);
    System.out.println(ans);
  }
  static void calc(int idx,long sum,long add,char[] arr){
    if(idx==arr.length){
      ans+=sum+add;
      return;
    }
    int x = arr[idx]-'0';
    calc(idx+1,sum+add,x,arr);
    calc(idx+1,sum,x+add*10,arr);
  }
}


Measured memory_bytes: 21844
n,k = map(int,input().split())
a = [int(i) - 1 for i in input().split()]
r = []
nx = 0
sr = set([])
for i in range(n):
    r.append(nx)
    sr.add(nx)
    if k < i:
        print(r[k] + 1)
        break
    tnx = a[nx]
    if tnx in sr:
        m = r.index(a[nx])
        d = i - m + 1
        k = k - m
        k = k % d
        print(r[k + m] + 1)
        break  
    nx = tnx


Measured memory_bytes: 32260
n = int(input())
p = list(map(int,input().split()))
m=0

for i in range(1,n-1):
  if (p[i-1]<p[i]<p[i+1]) or (p[i-1]>p[i]>p[i+1]):
    m +=1
  else:
    m +=0

    
print(m)



Measured memory_bytes: 2940
N=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
count=0
for i in range(N):
  if len(make_divisors(i+1))==8 and (i+1)%2!=0:
    count+=1
print(count)

Measured memory_bytes: 3060
import itertools

def main():
	N, K = [int(n) for n in input().split(" ")]
	D = [1] * 10
	for d in input().split(" "):
		D[int(d)] = 0
	L = [str(i) for i, v in enumerate(D) if v == 1]

	digit = len(str(N))
	cand = []
	for n in list(itertools.product(L, repeat=digit)):
		p = int("".join(list(n)))
		if p >= N:
			cand.append(p)
	if len(cand):
		print(min(cand))
	else:
		if L[0] == "0":
			print(str(L[1]) + "0" * digit)
		else:
			print(str(L[0]) * (digit + 1))


main()

Measured memory_bytes: 9656
#include<stdio.h>
#include<algorithm>
using namespace std;


int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a == b && c != a)
	{
		printf("Yes\n");
	}
	else if(a == c && b != a)
	{
		printf("Yes\n");
	}
	else if(b == c && a != b)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class33
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int count = 0;
            char test = S[0];
            for(int i = 1; i < N; i++)
            {
                if (test == S[i])
                    continue;
                count++;
                test = S[i];
            }
            Console.WriteLine(count+1);
        }
    }
}


Measured memory_bytes: 11232
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.next().length();
        String ans = "";
        for (int i = 0; i < n; i++) {
            ans += "x";
        }
        System.out.println(ans);
        sc.close();
    }
}

Measured memory_bytes: 25172
from itertools import product

a, b, c, d, e, f = map(int, input().split())

lima = [100 * a * i for i in range(f // (100 * a) + 1)]
limb = [100 * b * i for i in range(f // (100 * b) + 1)]
setw = set([i + j for i, j in product(lima, limb) if 0 < i + j <= f])
limc = [c * i for i in range(f // c + 1)]
limd = [d * i for i in range(f // d + 1)]
sets = set([i + j for i, j in product(limc, limd) if 0 < i + j <= f])

cnt, ans = 0, (max(setw), 0)
for w in setw:
    for s in sets:
        if (cnt <= 100 * s / w <= e) and (s + w <= f):
            cnt = 100 * s / w
            ans = s + w, s
else:
    print(*ans)


Measured memory_bytes: 12560
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# S = sys.stdin.readline().rstrip()
# i = 2
# while len(S) - i > 0:
#     l = len(S) - i
#     if S[:l // 2] == S[l // 2:l]:
#         print(l)
#         break
#     i += 2


N = int(sys.stdin.readline())
A = [int(sys.stdin.readline()) for _ in range(N)]

ans = 0
i = 0
for _ in range(N+1):
    i = A[i]-1
    ans += 1
    if i == 1:
        print(ans)
        exit()
print(-1)


Measured memory_bytes: 17596
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int n, m;
vint s(2005), t(2005);
ll dp[2005][2005];

int main()
{
    ciosup;
    cin >> n >> m;
    REP(i,n) cin >> s[i];
    REP(i,m) cin >> t[i];
    REP(i,n+1) dp[i][0] = 1;
    REP(i,m+1) dp[0][i] = 1;

    REP(i,n){
        REP(j,m){
            if (s[i] == t[j]){
                dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1]) % MOD;
            }else{
                dp[i + 1][j + 1] = (((dp[i + 1][j] + dp[i][j + 1]) % MOD) + MOD - dp[i][j]) % MOD;
            }
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 31616
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string s;

int main()
{
    cin >> s;
    int ans = 0;
    rep(i, 4){
        if(s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np
from copy import deepcopy
import math
import itertools
from collections import Counter

N = int(input())
V = list(map(int,input().split()))

V_odd = [V[i] for i in range(N) if i % 2 == 1]
V_even = [V[i] for i in range(N) if i % 2 == 0]


char_common_odd_1 = Counter(V_odd).most_common(2)[0][0]
n_common_odd_1 = Counter(V_odd).most_common(2)[0][1]
char_common_even_1 = Counter(V_even).most_common(2)[0][0]
n_common_even_1 = Counter(V_even).most_common(2)[0][1]


if char_common_odd_1 == char_common_even_1: # 最頻出の文字が同じ場合
  if (n_common_odd_1 == N/2) and (n_common_even_1 == N/2): # 全ての文字が同じ場合
    ans = N/2
  elif (n_common_odd_1 == N/2): # 奇数が同じ文字の場合
    n_common_even_2 = Counter(V_even).most_common(2)[1][1]
    ans = N/2 - n_common_even_2
  elif (n_common_even_1 == N/2): # 偶数が同じ文字の場合
    n_common_odd_2 = Counter(V_odd).most_common(2)[1][1]
    ans = N/2 - n_common_odd_2
  else: # 偶奇それぞれ2種類以上の数字がある場合
    n_common_odd_2 = Counter(V_odd).most_common(2)[1][1]
    n_common_even_2 = Counter(V_even).most_common(2)[1][1]
    var_odd1_even2 = N - n_common_odd_1 - n_common_even_2
    var_odd2_even1 = N - n_common_odd_2 - n_common_even_1
    ans = min(var_odd1_even2, var_odd2_even1)
else: # 最頻出の文字が違う場合
  ans = N - n_common_odd_1 - n_common_even_1
  
print(int(ans))





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

int main()
{
    int n,w;
    cin>>n>>w;
    ll wt[n+1],v[n+1];
    ll dp[n+2][w+2];
    memset(dp,0,sizeof dp);

    for(int i=1;i<=n;i++)
      cin>>wt[i]>>v[i];

    for(int j=wt[1];j<=w;j++)
        dp[1][j]=v[1];

   for(int i=2;i<=n;i++)
   {
    for(int j=0;j<=w;j++)
    {
        if(j-wt[i]>=0)
            dp[i][j]=max(v[i]+dp[i-1][j-wt[i]],dp[i-1][j]);
        else
          dp[i][j]=dp[i-1][j];
    }
   }
   cout<<dp[n][w]<<"\n";
   return 0;

}


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

int main(){
    int N; ll K; cin >> N >> K;
    ll A[100100];
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    ll now = 0LL;
    ll ans = 0LL;
    for(int j=50; j>=0; j--){
        if( ( (1LL<<j) + now) > K ) {continue;}
        int num=0;
        for(int i=0; i<N; i++){
            if(A[i] &  (1LL<<j)) num++;
        }
        if(num <= N/2 ) now +=(1LL<<j);
    }
    for(int i=0; i<N; i++){
        ans += (A[i]^now);
    }
    cout << ans << endl;
//    cout << (1LL<<50) << endl;
}

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

int main(){
    int n; cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i=2; i<=n; ++i) F[i] = F[i-1] + F[i-2];

    cout << F[n] << endl;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

int main(){
    vector<int> a(3);
    for(int i=0; i<3; ++i) cin >> a[i];
    sort(a.begin(), a.end());

    int k; cin >> k;
    for(int i=0; i<k; ++i){
        a[2] *= 2;
    }

    cout << a[0]+a[1]+a[2] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cmath>
using namespace std;
int N;
int A[55]={};
int B[55]={};
int R[55]={};
long long E[55]={};
bool F[55][55]={};
long long ans=0;
bool check(int x)
{
	for(int i=1;i<=N;++i)
	{
		memset(F,0,sizeof(F));
		F[1][A[i]]=1;
		for(int j=1;j<=R[0];++j)
		{
			for(int k=0;k<=50;++k)
			{
				if(F[j][k]) 
				{
					F[j+1][k]=1;
					F[j+1][k%R[j]]=1;
				}
			}
		}
		if(!F[R[0]+1][B[i]])return 0;
	}
	return 1;
}
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=N;++i)
	{
		scanf("%d",&A[i]);
	}
	for(int i=1;i<=N;++i)
	{
		scanf("%d",&B[i]);
		if(B[i]+B[i]+1>A[i]&&B[i]!=A[i])
		{
			printf("-1");
			return 0;
		}
	}
	for(int i=50;i>=1;--i)
	{
		R[0]=0;
		for(int j=1;j<=E[0];++j)R[++R[0]]=E[j];
		for(int j=i-1;j>=1;--j)R[++R[0]]=j;
		if(!check(i))E[++E[0]]=1ll*i;
	}
	for(int i=1;i<=E[0];++i)
	{
		ans+=1ll<<E[i];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W;
string a[110];
int cnt[26];
int amari = 0;
int yoyu = 0;
int one = 0;

int main () {
  cin >> H >> W;
  for (auto i = 0; i < H; ++i) {
    cin >> a[i];
  }
  fill(cnt, cnt+26, 0);
  for (auto i = 0; i < H; ++i) {
    for (auto j = 0; j < W; ++j) {
      cnt[a[i][j] - 'a']++;
    }
  }
  for (auto i = 0; i < 26; ++i) {
    amari += cnt[i]%4;
  }
  if (H%2 != 0 && W%2 != 0) {
    yoyu = H + W - 1;
    one = 1;
  } else if (H%2 == 0 && W%2 != 0) {
    yoyu = H;
  } else if (H%2 != 0 && W%2 == 0) {
    yoyu = W;
  } else {
    yoyu = 0;
  }
  if (amari > yoyu) {
    cout << "No" << endl;
    return 0;
  } else {
    int kisu = 0;
    for (auto i = 0; i < 26; ++i) {
      if (cnt[i]%2 == 1) kisu++;
    }
    if (kisu > one) {
      cout << "No" << endl;
      return 0;      
    }
  }
  cout << "Yes" << endl;
}


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

int main(){
	long long int n, k;
	cin>>n>>k;
	int adj[n][n];
	long long int pts[62][n][n], sm=0, temp, x= pow(10, 9) + 7, ch;

	for (int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>adj[i][j];
			if (adj[i][j]){
				pts[1][i][j] = 1;
				sm++;
			}
			else 
				pts[1][i][j] = 0;
		}
	}
	if (n == 1){
		if (adj[0][0])
			cout<<1;
		else
			cout<<0;
	}
	else{
		int c = 1, pc, cc;
		temp = 1;
		while(temp*2 <= k){
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					pts[c+1][i][j] = 0;
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					for(int k=0;k<n;k++){
						pts[c+1][i][k] = ((pts[c+1][i][k]%x) + ((pts[c][i][j]%x)*(pts[c][j][k]%x)%x))%x;
					}
				}
			}
			temp = temp*2;
			c = c + 1;
		}
		// cout<<temp<<" "<<c<<"\n";
		long long int prev[n][n], curr[n][n];
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				prev[i][j] = pts[c][i][j];
				curr[i][j] = pts[c][i][j];
			}

		ch = temp;
		k = k - temp;
		temp = temp/2;
		c--;
		long long int ans = 0;
		while(k){
			while(temp > k){
				temp = temp/2;
				c--;
			}
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					curr[i][j] = 0;

			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++){
					for(int k=0;k<n;k++){
						curr[i][k] = ((curr[i][k]%x) + (prev[i][j]%x)*(pts[c][j][k]%x))%x;
					}
				}

			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++){
					prev[i][j] = curr[i][j];
					ans= ((ans%x) + (curr[i][j]%x)%x);
				}

			k = k - temp;
			ch += temp;
			// cout<<ch<<" "<<c<<" "<<ans<<"\n";
			ans = 0;
		}
		
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				ans= ((ans%x) + (curr[i][j]%x)%x);

		cout<<ans%x;
	}
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int main(){
    int n;
    while(cin >> n){
        if(n == 0) break;
        vector<int> vec;
        int tmp,a;
        int cnt = 0;
        vector<int> v;
        bool flag = true;
        rep(i,n){
            cin >> a;
            if(i > 0 ){
                if(tmp+1 == a) cnt++;
                else {
                    v.push_back(cnt);
                    flag = true;
                    cnt = 0;
                }
            }
            if(flag == true) {
                vec.push_back(a);
                flag = false;
            }
            tmp = a;
        }
        v.push_back(cnt);
        rep(i,v.size()){
            if(i == 0) {
                if(v[i] > 0) cout << vec[i] << '-' << vec[i]+v[i];
                else cout << vec[i];
            }
            else {
                if(v[i] > 0) cout << " " << vec[i] << '-' << vec[i]+v[i];
                else cout << " " << vec[i];
            }
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;

#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define LL long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<LL,int>
#define PLL pair<LL,LL>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<LL,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





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




LL a[200005],b[200005];

int main()
{
    FAST();
    LL i,k,m,n,x,y,ans=0;
    cin >> n >> m >> k;
    for(i=1;i<=n;i++)cin >> a[i],a[i]+=a[i-1];
    for(i=1;i<=m;i++)cin >> b[i],b[i]+=b[i-1];
    for(i=0;i<=n   &&  a[i] <= k;i++)
    {
        y=i;
        x=k-a[i];
        x=upper_bound(b+1,b+m+1,x)-b-1;
        ans=max(ans,x+y);
    }
    cout << ans;
    return 0;
}


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

int main(){
  int n,m,sumvote=0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    sumvote += a.at(i);
  }
  sort(a.begin(),a.end());
  bool flag = true;
  for(int i=0;i<m;i++){
    if((double)a.at(n-1-i) < ((double)sumvote/(double)(4*m))) flag = false;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cout<<#x<<" = "<<x<<endl;
using namespace std;
typedef long long LL;
inline int read()
{
	int l = 0, f = 1;
	char a = getchar();
	for (; a < '0' || a > '9'; a = getchar())
		if (a == '-') f = -1;
	for (; a >= '0' && a <= '9'; a = getchar())
		l = l * 10+a-48;
	return l * f;
}
int n, a, ans = 0, num[15];
int main()
{
	memset(num, 0, sizeof(num));
	n = read();
	for (int i = 1; i <= n; ++i)
	{
		a = read();
		if (1 <= a && a <= 399) num[1] = 1;
		else if (400 <= a && a <= 799) num[2] = 1;
		else if (800 <= a && a <= 1199) num[3] = 1;
		else if (1200 <= a && a <= 1599) num[4] = 1;
		else if (1600 <= a && a <= 1999) num[5] = 1;
		else if (2000 <= a && a <= 2399) num[6] = 1;
		else if (2400 <= a && a <= 2799) num[7] = 1;
		else if (2800 <= a && a <= 3199) num[8] = 1;
		else if (a >= 3200) num[9]++;
	}
	for (int i = 1; i <= 8; ++i) ans += num[i];
	printf("%d %d\n", (ans == 0 ? 1 : ans), ans+num[9]);
	return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.List;
import java.util.OptionalInt;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> ls = new LinkedList<>();
        for(int i = 0;i < n;i++)
            ls.add(sc.nextInt());
        int sum = ls.stream().mapToInt(e -> e).sum();
        if(sum % 10 != 0)
            System.out.println(sum);
        else
        {
            OptionalInt tmp = ls.stream().mapToInt(e -> e).filter(e -> e % 10 != 0).min();
            if(tmp.isPresent())
                System.out.println(sum - tmp.getAsInt());
            else
                System.out.println(0);
        }
    }
}


Measured memory_bytes: 28884
#include<bits/stdc++.h>
#define int long long
using namespace std;
void test_cases(){
    int n, q;
    cin >> n >> q;
    set<pair<int, int>> x, y;
    x.insert({n, n - 1});
    y.insert({n, n - 1});
    int ans = (n - 2) * (n - 2);
//    cout << ans << '\n';
    while(q > 0){
        q--;
        int a, b;
        cin >> a >> b;
        if(a == 1){
            auto it = y.lower_bound({b, 0});
            pair<int, int> p = *it;
//            cout << p.first << " " << p.second << '\n';
            ans -= (p.second - 1);
            x.insert({p.second, b - 1});
        }
        else{
            auto it = x.lower_bound({b, 0});
            pair<int, int> p = *it;
//            cout << p.first << " " << p.second << '\n';
            ans -= (p.second - 1);
            y.insert({p.second, b - 1});
        }
    }
    cout << ans;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int tt = 1;
//    cin >> tt;
    while(tt--){
        test_cases();
    }
    return 0;
}


Measured memory_bytes: 16104
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#define REP(i, N) for(int i = 0; i < N; ++i)
#define REEP(i, N) for(int i = N - 1; i >= 0; --i)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,m,n) for(int i = m; i < n; ++i)
#define RFOR(i,m,n) for(int i = n - 1; i >= m; --i)
#define CIN(a) cin >> a
#define CIN2(a, b) cin >> a >> b
#define CIN3(a, b, c) cin >> a >> b >> c
#define COUT(a) cout << a << endl
#define COUT2(a, b) cout << a << " " << b << endl
#define COUT3(a, b, c) cout << a << " " << b << " " << c << endl
#define pb(v, a) v.push_back(n)
#define VINT(v, n) vector<int> v(n); REP(i, n) { v[i] = 0 }
#define VINT2(v, n, m) vector<vector<int> > v(n, vector<int>(m)); REP(i, n) { REP(j, m) { v[i][j] = 0 } }
#define VCHAR(v, n) vector<char>v(n)
#define MAX(a, b) a > b ? a : b;
#define MIN(a, b) a < b ? a : b;
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;}
#define sp(n) setprecision(n)
#define INF 100000000

using namespace std;

int main() {
    int a, b, h;
    CIN3(a, b, h);
    COUT((a + b) * h / 2);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    double eye[] = {0.2, 0.6, 1.1};
    int num[4][2] = {0};

    for(;;){
        double a, b;
        if(!(cin >> a >> b))
            break;

        int i = upper_bound(eye, eye+3, a) - eye;
        int j = upper_bound(eye, eye+3, b) - eye;
        ++ num[i][0];
        ++ num[j][1];
    }

    for(int i=3; i>=0; --i)
        cout << num[i][0] << ' ' << num[i][1] << endl;

    return 0;
}

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

#define ll long long

using namespace std;

int main(){
    int n,k,c=0;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
        if(a[i]>=k){
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 640
#include<cstdio>

int a, b, m, aa[100005], bb[100005];

int main() {
  scanf("%d %d %d", &a, &b, &m);
  for (int i = 0; i < a; i++) {
    scanf("%d", &aa[i]);
  }
  for (int i = 0; i < b; i++) {
    scanf("%d", &bb[i]);
  }
  int ma = aa[0];
  int mb = bb[0];
  for (int i = 0; i < a; i++) {
    if (aa[i] < ma) {
      ma = aa[i];
    }
  }
  for (int i = 0; i < b; i++) {
    if (bb[i] < mb) {
      mb = bb[i];
    }
  }
  int res = ma + mb;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    scanf("%d %d %d", &x, &y, &c);
    int cur = aa[x-1] + bb[y-1] - c;
    if (cur < res) {
      res = cur;
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 896
#include<stdio.h>

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

int ket(long long a){
		int r=0;
		while(a>0){
				a=a/10;
				r++;
		}
		return r;
}

int main(){
		int c=0,ans=20000000;
		long long n,i,ncpy;
		long long yks[10000][2];
		scanf("%lld",&n);
		ncpy=n;
		yks[c][0]=1;
		yks[c][1]=n;
		c++;
		for(i=2;i*i<=n;i++){
				if(n%i==0){
						yks[c][0]=i;
						yks[c][1]=n/i;
						c++;
						//n=n/i;
						//i=2;
				}
		}
		for(i=0;i<c;i++)ans=min(ans,max(yks[i][0],yks[i][1]));
		printf("%d\n",max(ket(yks[c-1][0]),ket(yks[c-1][1])));
		return 0;
}


Measured memory_bytes: 128
import heapq

x,y,a,b,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p, reverse = True)[:x]
q = sorted(q, reverse = True)[:y]
r = sorted(r, reverse = True)

pqr = p + q + r
pqr = sorted(pqr, reverse = True)[:x+y]

print(sum(pqr))

Measured memory_bytes: 23272
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<map>
#include<bitset>
#include<utility>
//#include<unordered_map>
#ifdef LOCAL
#include"file.h"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
const double eps = 1e-12;
const double Pi = 3.1415926535897932;
const int dir[4][2] = { -1,0,1,0,0,-1,0,1 };
//const int dir[8][2] = { -2,-1,-2,1,2,-1,2,1,-1,2,-1,-2,1,2,1,-2 };








const int maxn = 2e5 + 5;




int f[maxn];
int h[maxn];

int n, k;

int main() {
#ifdef LOCAL
	fileopen();
#endif

	while (scanf("%d%d", &n, &k) == 2) {
		for (int i = 1; i <= n; i++)
			scanf("%d", &h[i]);

		memset(f, 63, sizeof(f));
		f[1] = 0;

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= k; j++) {
				f[i + j] = min(f[i + j], f[i] + abs(h[i] - h[i + j]));
			}
		}
		printf("%d\n", f[n]);
	}


#ifdef LOCAL
	fileclose();
#endif
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

void solve(){

}

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

    ll n, k;
    cin >> n >> k;
    vi a(n);
    ll ans =0 ;
    for(auto &i: a){
        cin >> i;
        if(i >= k){
            ans++;
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cctype>
#define maxn 200005
#define LL long long
using namespace std;

LL ans,a[maxn];
int n;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]) ,a[i]-=i;
	sort(a+1,a+1+n);
	for(int i=1,j=n;i<j;i++,j--)
		ans+=a[j]-a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 1664
a = list(map(int, input().split()))
a.sort()
b = 0
b = b + (a[2] - a[1]) // 2
b = b + (a[2] - a[0]) // 2
if (a[2] - a[1]) % 2 == 0 and (a[2] - a[0]) % 2 == 0:
    pass
if (a[2] - a[1]) % 2 == 1 and (a[2] - a[0]) % 2 == 0:
    b = b + 2
if (a[2] - a[1]) % 2 == 0 and (a[2] - a[0]) % 2 == 1:
    b = b + 2
if (a[2] - a[1]) % 2 == 1 and (a[2] - a[0]) % 2 == 1:
    b = b + 1
print(b)

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

using namespace std;

typedef pair< pair< int, int >, pair< int, int > > Pi;

int N, T;
vector< pair< pair< int, int >, int > > g[100000], h[100000];

pair< int, int > Dijkstra(int s, int t)
{

  map< pair< int, int >, pair< int, int > > v;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.emplace(make_pair(0, 0), make_pair(s, -1));

  for(auto &e : g[s]) {
    que.emplace(make_pair(0, 0), e.first);
    v[e.first] = {0, 0};
  }


  auto push = [&](pair< int, int > c, pair< int, int > cost)
  {
    if(!v.count(c) || cost < v[c]) {
      que.emplace(cost, c);
      v[c] = cost;
    }
  };

  while(!que.empty()) {
    auto p = que.top();
    que.pop();

    if(p.first > v[p.second]) continue;
    if(p.second.second == -1) {
      if(p.second.first == t) return p.first;
      for(auto &e : g[p.second.first]) {
        push(e.first, {p.first.first + T, p.first.second + 1});
      }
    } else {
      int add = h[p.second.first][p.second.second].first.first;
      if(~add) push({p.second.first, p.second.second - 1}, {p.first.first + add, p.first.second});
      add = h[p.second.first][p.second.second].first.second;
      if(~add) push({p.second.first, p.second.second + 1}, {p.first.first + add, p.first.second});
      push({h[p.second.first][p.second.second].second, -1}, p.first);
    }
  }
  return {-1, -1};
};

int main()
{
  string A, B;
  map< string, int > conv;
  cin >> N >> T;
  cin >> A >> B;
  for(int i = 0; i < N; i++) {
    int sz;
    cin >> sz;
    vector< int > line(sz), tt(sz - 1);
    for(auto &p : line) {
      string s;
      cin >> s;
      if(!conv.count(s)) conv[s] = conv.size() - 1;
      p = conv[s];
    }
    for(int j = 0; j < sz - 1; j++) cin >> tt[j];
    for(int j = 0; j < sz; j++) {
      g[line[j]].emplace_back(make_pair(i, j), 0);
      h[i].emplace_back(make_pair(j == 0 ? -1 : tt[j - 1], j + 1 == sz ? -1 : tt[j]), line[j]);
    }
  }
  auto get = Dijkstra(conv[A], conv[B]);
  if(~get.first) cout << get.first << " " << get.second << endl;
  else cout << get.first << endl;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = (l);x<=(u);x++)
#define RREP(x,l,u) for(ll x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,rt;

int A[maxn];

vector<int> G[maxn];

ll dfs(int u,int f){
	if(sz(G[u])==1)return A[u];
	vector<ll> tmp;
	for(auto v:G[u])if(v!=f){
		ll x=dfs(v,u);
		tmp.PB(x);
	}
	ll sm=0;
	for(auto i:tmp)sm+=i;
	if(sm<A[u]||sm>A[u]*2){
		puts("NO");
		exit(0);
	}
	ll x=sm-A[u];
	ll mx=0;
	for(auto i:tmp)mx=max(mx,i);
	if(x>sm-mx){
		puts("NO");
		exit(0);
	}
	return sm-x*2;
}

void Work(){
	if(n==2){
		puts(A[1]==A[2]?"YES":"NO");
		return;
	}
	REP(i,1,n)if(sz(G[i])>1)rt=i;
	if(!dfs(rt,0))puts("YES");else puts("NO");
}

void Init(){ 
	read(n);
	REP(i,1,n)read(A[i]);
	REP(i,2,n){
		int u,v;
		read(u,v);
		G[u].PB(v);G[v].PB(u);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 14720
#12
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])

b.append(int(k-a[n-1]+a[0]))

c = max(b)
b.remove(c)

print(sum(b))


Measured memory_bytes: 26436
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e9;

void print_a(VL v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    LL a[n], xr = 0;
    loop(i,0,n) {cin>>a[i]; xr = xr ^ a[i];}

    VL ans(n);
    for(int i = 0; i < n; i+=2)
    {
        xr = xr ^ a[i];
        ans[i] = xr;
        xr = xr ^ a[i];
        xr = xr ^ a[i+1];
        ans[i+1] = xr;
        xr = xr ^ a[i+1];
    }

    print_a(ans);

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


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

int n,b,f,r,v;
int residentsNum[4][3][10]={0};

int main(){
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>b>>f>>r>>v;
        residentsNum[b-1][f-1][r-1]+=v;
    }
    for (int i=0;i<4;++i){
        for(int j=0;j<3;++j){
            for(int k=0;k<10;++k){
                cout<<" "<<residentsNum[i][j][k];
            }
            cout<<endl;
        }
        if(i!=3){
            for(int j=0;j<20;++j)cout<<"#";
            cout<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
import sys

# 整数の入力
N, Y = map(int, input().split())

for i in range(N+1):
    M = N + 1 - i
    for j in range(M):
        if Y == 10000*i+5000*j+1000*(N-i-j):
            print('{} {} {}'.format(i, j, N-i-j))
            sys.exit()
else:
    print('-1 -1 -1 ')


Measured memory_bytes: 3060
#include<stdio.h>

void sharp(void){
printf("####################\n");
}


int main(){
int b,f,r,v,n,i,j;
int A[3][10]={0};
int B[3][10]={0};
int C[3][10]={0};
int D[3][10]={0};

scanf("%d", &n);
for(i=0; i<n; i++){
scanf("%d%d%d%d", &b, &f, &r, &v);
	
	if(b==1){
		A[f-1][r-1]+=v; 

	}else if(b==2){
		B[f-1][r-1]+=v; 

	}else if(b==3){
		C[f-1][r-1]+=v;
 
	}else{
		D[f-1][r-1]+=v;
	}
}


for(i=0; i<3; i++){
	for(j=0; j<10; j++){
		printf(" %d", A[i][j]);
	}
	printf("\n");
}

sharp();

for(i=0; i<3; i++){
	for(j=0; j<10; j++){
		printf(" %d", B[i][j]);
	}
	printf("\n");
}

sharp();

for(i=0; i<3; i++){
	for(j=0; j<10; j++){
		printf(" %d", C[i][j]);
	}
	printf("\n");
}

sharp();

for(i=0; i<3; i++){
	for(j=0; j<10; j++){
		printf(" %d", D[i][j]);
	}
	printf("\n");
}

return 0;

}

Measured memory_bytes: 612
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>

// container library
#include <deque>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef vector<string> VS;

// container
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SZ(x) ((int)(x).size())
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)

// constant
// const ll MOD = 1e9 + 7;
const ll INF = 1e6;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define debug(x) cout << #x << " = " << x << endl

// --------------------------------------------------------


int main()
{
    int N, MAX = -INF, MIN = INF;
    int MAXitr, MINitr;
    cin >> N;
    cout << N * 2 - 2 << endl;
    FOR(i, 1, N + 1)
    {
        int a;
        cin >> a;
        if (MAX <= a) {
            MAX = a;
            MAXitr = i;
        }
        if (MIN >= a) {
            MIN = a;
            MINitr = i;
        }
    }

    if (MIN >= 0 || (MAX > 0 && abs(MAX) >= abs(MIN))) {
        FOR(i, 1, N + 1)
        {
            if (i != MAXitr) {
                cout << MAXitr << " " << i << endl;
            }
        }
        FOR(i, 1, N)
        {
            cout << i << " " << i + 1 << endl;
        }
    } else {
        FOR(i, 1, N + 1)
        {
            if (i != MINitr) {
                cout << MINitr << " " << i << endl;
            }
        }
        RFOR(i, N, 2)
        {
            cout << i << " " << i - 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int a=sc.nextInt();
		int b=sc.nextInt();
		print(a*b);
	}
	
	private static void print(Object o) {
		System.out.println(o.toString());
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 32432