akhauriyash/Code-Regression huggingface dataset:
class Dice
  def initialize(t,s,e,w,n,b)
    @all = [ [t,s,e,w,n,b],[t,e,n,s,w,b],[t,n,w,e,s,b],[t,w,s,n,e,b],
             [s,t,w,e,b,n],[s,w,b,t,e,n],[s,b,e,w,t,n],[s,e,t,b,w,n],
             [e,t,s,n,b,w],[e,s,b,t,n,w],[e,b,n,s,t,w],[e,n,t,b,s,w],
             [w,t,n,s,b,e],[w,n,b,t,s,e],[w,b,s,n,t,e],[w,s,t,b,n,e],
             [n,t,e,w,b,s],[n,e,b,t,w,s],[n,b,w,e,t,s],[n,w,t,b,e,s],
             [b,s,w,e,n,t],[b,w,n,s,e,t],[b,n,e,w,s,t],[b,e,s,n,w,t] ]
    @val = @all.map{|v| v.join(",")}.min
  end
  def val
    return @val
  end
end

n = gets.chomp.to_i
d = []
flag = false
for i in 1..n do
  t,s,e,w,n,b = gets.chomp.split(" ").map{|x| x.to_i}
  d[i-1] = Dice.new(t,s,e,w,n,b)
  for j in 1..i-1 do
    if d[i-1].val == d[j-1].val
      flag = true
      break
    end
  end
  if flag
    break
  end
end
if flag
  printf("No\n")
else
  printf("Yes\n")
end


Measured memory_bytes: 7016
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct node{
  int id;
  int k;
  int parent;
  int *c;
}node;

void printTree(node*,int);
int depth(node*,int,int);

int main(){
  node *tree;
  int i,j,n,id,k;

  scanf("%d",&n);

  tree = (node *)malloc(sizeof(node)*n);

  for(i=0;i<n;i++) tree[i].parent = -1;

  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    tree[id].c = (int *)malloc(k*sizeof(int));
    tree[id].id=id;
    tree[id].k=k;
    for(j=0;j<tree[id].k;j++){
      scanf("%d",&tree[id].c[j]);
      tree[tree[id].c[j]].parent = id;
    }
  }

  printTree(tree,n);
    
  return 0;
}

void printTree(node* tree,int n){
  int i,j,d;
  
  for(i=0;i<n;i++){
    d=depth(tree,i,0);
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,d);
    if(d == 0) printf("root, [");
    else if(tree[i].k == 0) printf("leaf, [");
    else printf("internal node, [");
    for(j=0;j<tree[i].k;j++){
      if(j != 0) printf(", ");
      printf("%d",tree[i].c[j]);
    }
    printf("]\n");
  }
  
  return;
}

int depth(node* tree,int c,int d){
  if(tree[c].parent == NIL) return d;
  else{
    d++;
    return depth(tree,tree[c].parent,d);
  }
}
  

Measured memory_bytes: 6472
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int X[MAX_N], num[MAX_N + 3];

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

    cin >> N;

    int amax = 0;
    for (int i = 0; i < N; i++) {
        cin >> X[i];
        amax = max(amax, X[i]);
    }

    for (int i = 0; i < N; i++) {
        for (int j = -1; j <= 1; j++) {
            num[X[i] + j + 1]++;
        }
    }

    sort(num, num + amax + 2, greater<int>());

    cout << num[0] << "\n";

    return 0;
}

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

vector<int> divisors(int n) {
	
	vector<int> ans;
	for(int i = 1; i*i <= n; i++) {
		if(n % i == 0) {
			ans.push_back(i);
			ans.push_back(n/i);
		}
	}
	
	sort(ans.rbegin(), ans.rend());
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> arr(n);
	int sum = 0;
	for(int& x : arr) {
		cin >> x;
		sum += x;
	}
	
	vector<int> div = divisors(sum);
	for(int x : div) {
		vector<int> a(n);
		for(int i = 0; i < n; i++) {
			a[i] = arr[i] % x;
		}
		
		sort(a.begin(), a.end());
		int up = 0, down = 0;
		for(int i = 0; i < n; i++) {
			up += x - a[i];
		}
		
		for(int i = 0; i < n; i++) {
			down += a[i], up -= x - a[i];
			if(up == down && down <= k) {
				cout << x << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 384
#include<stdio.h>
#define ll long long
using namespace std;

int main(){
    ll n;
    scanf("%lld", &n);

    ll sum = 1;
    for(int i=2; i<=n; i++){
        if((i%3!=0) && (i%5!=0)){
            sum += i;
        }
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 1732
#include <iostream>
#include <cmath>

using namespace std;

int get_head(int a){
    return a / int(pow(10, int(log10(a))));
}

int num( int a, int b, int N){
    int ans = 0;
    for(int i=1; i<=N; i++){
        if(get_head(i) == a && i%10 == b) {
            ans ++;
            i+= 9;
        }
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    int d[100];
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            d[i*10 + j] = num(i, j, N);
        }
    }
    long ans = 0;
    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            ans += long(d[i*10 + j]) * long(d[j*10 + i]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

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

    return arr
def sigma(n):
    s=0
    for i in range(1,n+1):
         s+=i
    return s
ans = 0
for f in factorization(n):
    index = f[1]
    num=1
    while True:
        num+=1
        if index<sigma(num):
            ans+=num-1
            break
print(ans)

Measured memory_bytes: 9504
import sys
import math
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    N = list(map(int,sys.stdin.readline().split()))
    print(N.index(0)+1)

    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 9592
n = int(input())

accnt = 0
wacnt = 0
tlecnt = 0
recnt = 0

for i in range(n):
  query = input()
  if query == 'AC':
    accnt += 1
  elif query == 'WA':
    wacnt +=1
  elif query == 'TLE':
    tlecnt += 1
  else:
    recnt += 1

print('AC x',accnt)
print('WA x',wacnt)
print('TLE x',tlecnt)
print('RE x',recnt)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vb> g(n, vb(n, false));
  vi v;
  rep(i, n - 1) v.push_back(i + 1);
  int ans = 0;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a][b] = g[b][a] = true;
  }
  do {
    bool ok = true;
    rep(k, n - 1) {
      int i = k == 0 ? 0 : v[k - 1];
      int j = v[k];
      if(!g[i][j]) ok = false;
    }
    if(ok) ans++;
  } while(next_permutation(all(v)));
  cout << ans << endl;
}

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


using namespace std;

const int INF = 1e9;

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
  
    int W, H, N; cin >> W >> H >> N;
    int new_w = 0, new_h = 0, ww = W, hh = H;
    vector<int> x(N), y(N), a(N);
    for (int i = 0; i < N; ++i) 
        cin >> x[i] >> y[i] >> a[i];
    for (int i = 0; i < N; ++i) {
        if (a[i] == 1) 
            new_w = max(new_w, x[i]);
        if(a[i] == 2)
            ww = min(ww, x[i]);
        if(a[i] == 3)
            new_h = max(new_h, y[i]);
        if (a[i] == 4)
            hh = min(hh, y[i]);
    }

    if (new_w >= ww || new_h >= hh) {
        cout << 0 << '\n';
    }else {
        cout << (ww - new_w) * (hh - new_h) << '\n';
    }
    
        
    
    

    return 0;
}



Measured memory_bytes: 3592
while 1:
  N = input()
  if int(N) <= 999:
    break
hon = ['2', '4', '5', '7', '9']
pon = ['0', '1', '6', '8']
bon = '3'
N = list(N)
for i in range(len(hon)):
  if N[-1] == hon[i]:
    ans = "hon"
for i in range(len(pon)):
  if N[-1] == pon[i]:
    ans = "pon"
if N[-1] == bon:
  ans = "bon"
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = numeric_limits<ll>::max() / 4;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;

ll least_square(ll S){
    ll high = 1000000001;
    ll low = 1;
    while(high - low > 1){
        ll mid = (high - low)/ 2 + low;
        if(S <= mid * mid){
            high = mid;
        }
        else if(S == mid * mid){
            return mid;
        }
        else {
            low = mid;
        }
    }
    return high;
}

bool check(ll S, ll a, ll b, ll c, ll d){
    return S == abs(a*d - b *c);
}

void sub_main(istream &is) {
    ll S;
    is >> S;
    if(!is) return;

    ll k = least_square(S);
    ll t = k*k - S;
    cout << "0 0 " << k << " 1 " << t << ' ' << k << endl;
    assert(check(S,k, 1, t, k));

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_A.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
n = int(input())
g = [[-1 for _ in range(15)] for _ in range(15)]
for i in range(n) :
    m = int(input())
    for j in range(m) :
        x,y = map(int, input().split())
        #人iが「人xはyである」と証言している
        g[i][x-1] = y

ans = 0
for i in range(1<<n) :
    honests = [0] * n
    for j in range(n) :
        if (i>>j) & 1 :
            honests[j] = 1
    ok = True
    for j in range(n) :
        if honests[j] : #正直者の証言だけ検証する
            for k in range(n) :
                if g[j][k] == -1 :
                    continue
                if g[j][k] != honests[k] :
                    ok = False
    if ok :
        ans = max(ans, honests.count(1))

print(ans)


Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
int n,x,f=1;
int main(){
	for(scanf("%d",&n);n--;){
		scanf("%d",&x);
		if(x%2==0){
			if(x%3&&x%5)f=0;
		}
	}
	puts(f?"APPROVED":"DENIED");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  int a[h][w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      a[i][j]%=2;
    }
  }

  int m=0;
  vector<int> x1,x2;
  vector<int> y1,y2;
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(a[i][j]%2==1){
        a[i][j+1]+=a[i][j];
        x1.push_back(i+1);
        y1.push_back(j+1);
        x2.push_back(i+1);
        y2.push_back(j+2);
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2==1){
      a[i+1][w-1]+=a[i][w-1];
      x1.push_back(i+1);
      y1.push_back(w);
      x2.push_back(i+2);
      y2.push_back(w);
    }
  }
  cout<<x1.size()<<endl;
  for(int i=0;i<x1.size();i++){
    cout<<x1[i]<<" "<<y1[i]<<" "<<x2[i]<<" "<<y2[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 5220
using System;

namespace AOJ_ITP16_OfficialHouse
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int[,,] room = new int[4,3,10]; // [棟][階][部屋]
			for (int i = 0; i < 4; i++)
				for (int j = 0; j < 3; j++)
					for (int k = 0; k < 10; k++)
						room [i,j,k] = 0;

			int b,f,r,v; //b棟f階のr番目の部屋にv人
			int n = int.Parse(Console.ReadLine());
			for (int i=0; i < n; i++) {
			string[] dtmp = Console.ReadLine ().Split (" ".ToCharArray ());
				b = int.Parse (dtmp [0]) -1;
				f = int.Parse (dtmp [1]) -1;
				r = int.Parse (dtmp [2]) -1;
				v = int.Parse (dtmp [3]);

				room [b,f,r] += v;
			}

			for (int i = 0; i < 4; i++){
				for (int j = 0; j < 3; j++){
					for (int k = 0; k < 10; k++){
						Console.Write (" {0}", room [i, j, k]);
					}
					Console.Write("\n");
				}
				if (i != 3)Console.WriteLine("####################");
			}

		}
	}
}

Measured memory_bytes: 5664
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
input:
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 2
1 3 0

output:
0
0
1
1
1
0
1
1
"""


class UnionFind(object):
    def __init__(self, size):
        self.size = size
        self.height_rank = [0] * self.size
        self.ancestors = list(range(self.size))

    def find(self, x):
        if x != self.ancestors[x]:
            self.ancestors[x] = self.find(self.ancestors[x])
        return self.ancestors[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def link(self, x, y):
        if self.height_rank[x] > self.height_rank[y]:
            self.ancestors[y] = x
        else:
            self.ancestors[x] = y
            if self.height_rank[x] == self.height_rank[y]:
                self.height_rank[y] += 1

    def union(self, x, y):
        self.link(self.find(x), self.find(y))


if __name__ == '__main__':
    import sys
    input_ = sys.stdin.readlines()
    e_num, c_num = map(int, input_[0].split())
    cmds = map(lambda x: x.split(), input_[1:])
    case = UnionFind(size=e_num)
    for each in cmds:
        cmd, ele_1, ele_2 = map(int, each)
        if cmd == 0:
            case.union(ele_1, ele_2)
        elif cmd == 1:
            print(int(case.same(ele_1, ele_2)))

Measured memory_bytes: 16476
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}



int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
        
    int x;
    cin>>x;
    cout<<(!x)<<endl;
    
    
    
}


Measured memory_bytes: 3172
#include <stdio.h>
#include <stdbool.h>
#define true 1
#define false 0
#define MAX 1000
#define VMAX 10000

int n , A[MAX] , s;
int B[MAX] , T[VMAX+1];

void sort(int C[])
{
	int flag = 1;
	int tmp;
	while(flag == 1)
	{
		flag = 0;
		for( int j = n-1; j >= 1; j--)
		{
			if(C[j] < C[j-1])
			{
				tmp = C[j];
				C[j] = C[j-1];
				C[j-1] = tmp;
				flag = 1;
			}
		}
	}
}

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

int solve()
{
	int ans = 0;
	
	bool V[MAX];
	for( int i = 0; i < n; i++)
	{
		B[i] = A[i];
		V[i] = false;
	}
	sort(B);
	for( int i = 0; i < n; i++) T[B[i]] = i;
	for( int i = 0; i < n; i++) {
		if(V[i])continue;
		int cur = i;
		int S = 0;
		int m = VMAX;
		int an = 0;
		while(1){
			V[cur] = true;
			an++;
			int v = A[cur];
			m = min(m,v);
			S += v;
			cur = T[v];
			if(V[cur])break;
		}
		ans += min(S+(an-2)*m,m+S+(an+1)*s);
	}
	return ans;
}

int main(void)
{
	scanf("%d",&n);
	s = VMAX;
	for( int i = 0; i < n; i++)
	{
		scanf("%d",&A[i]);
		s = min(s,A[i]);
	}
	int ans = solve();
	printf("%d\n",ans);
}



Measured memory_bytes: 2108
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct unionfind{
	vector<int> data;
	void use(int n){ data.assign(n, -1); }
  void reset(void){ data.clear(); }
	bool unionset(int x, int y){
		x = root(x); y = root(y);
		if(x != y){
			if(data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y){ return root(x) == root(y); }
	int root(int x){ return (data[x] < 0) ? x : data[x] = root(data[x]); }
	int size(int x){ return -data[root(x)]; }
};

signed main(void){
  int i, j;
  unionfind U;
  int x[1001001], y[1001001], cnt[1001001];
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    if(!(n | m))break;

    rep(i, n)cnt[i] = 0;
    rep(i, m)scanf("%d%d", &x[i], &y[i]);
    U.use(n);
    rep(i, m){
      --x[i]; --y[i];
      ++cnt[x[i]]; ++cnt[y[i]];
      if(U.findset(x[i], y[i])){
        puts("no");
        break;
      }else{
        U.unionset(x[i], y[i]);
      }
    }
    if(i == m){
      bool is = true;
      rep(j, n)if(cnt[j] > 2)is = false;
      puts(is ? "yes" : "no");
    }
    U.reset();

//*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 5028
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    string s;
    int n;
    cin>>n;
    cin>>s;
    REP(i,s.size()){
        s[i]=(char)((s[i]-'A'+n)%26+'A');
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <tuple>
#include <iomanip>
#include <iterator>
#define PB push_back
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(c) c.begin(),c.end()
#define SHOWVEC(v) for (auto e : v) cerr << e << ' '; cerr << endl;
#define SHOWP(p) cerr << "[" << p.first << "," << p.second << "]" << endl;
#define Decimal fixed << setprecision(20)
#define FI first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
constexpr int INF = 1100000000;
constexpr ll LLINF = 1100000000000000000;

int main()
{
  double sum = 0;
  int N; cin >> N;
  REP(i, N) {
    int A; cin >> A;
    sum += 1.0 / A;
  }
  cout << Decimal << 1.0/sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int a,b,k;
	cin>>a>>b>>k;
	bool fl=0;
	while(k--){
	    if(!fl){
	        if(a & 1)	            a-=1;
            a/=2;
            b+=a;
	    }
	    else{
	        if(b & 1)   b-=1;
            b/=2;
            a+=b;
	    }
	    fl=(!fl);
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S =sc.next();
      	char[] s = S.toCharArray();
      	if(s[0]==s[1]||s[0]==s[2]||s[1]==s[2]){
        	System.out.println("No");
        }else{
        	System.out.println("Yes");
        }
 		sc.close();
	}
}


Measured memory_bytes: 21716
#include <stdio.h>
int main(){
	int n,h[101]={};
	int max=1,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&h[i]);
	while(max!=0){
		max=0;
		for(int i=0;i<n;i++)
			if (max < h[i])
				max=h[i];
		for(int j=0;j<n;j++)
			if(h[j]==max){
				ans++;
				if(h[j]==h[j+1])
					ans--;
				h[j]--;
			}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream> 
#include<cmath>
#include<algorithm>
using namespace std;
long long n,k,a[200005],b[200005];
bool cmp(const long long &a,const long long &b){
	return a>b;
}
bool check(long long upper){
	long long sum=0;
	for(int i=1;i<=n;++i){
		if(a[i]*b[i]-upper>0)sum+=(a[i]*b[i]-upper)/b[i]+((a[i]*b[i]-upper)%b[i]?1:0);
		if(sum>k)return 0;
	}
	return 1;
}
int main(){
	cin>>n>>k;
	long long l=0,r=0;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i){
		cin>>b[i];
		r = max(r, a[1]*b[i]);
	}
	sort(b+1,b+n+1);
	while(l<r){
		long long mid=l+r>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	cout<<l;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
  int a, b;
  cin >> a >> b;

  // cout << a << " " << b << endl;

  if ((a * b) % 2 == 0)
  {
    cout << "Even" << endl;
  }
  else
  {
    cout << "Odd" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>

using namespace std;

int main(void) {
    int a, n[100], max;
    stack<int> mode;
    
    for (int i = 0; i < 100; i++) {
        n[i] = 0;
    }
    while (cin >> a) {
        n[a - 1]++;
    }
    max = n[99];
    mode.push(99);
    for (int i = 98; i >= 0; i--) {
        if (n[i] > max) {
            while (!mode.empty()) {
                mode.pop();
            }
            max = n[i];
            mode.push(i);
        } else if (n[i] == max) {
            mode.push(i);
        }
    }
    while (!mode.empty()) {
        cout << mode.top() + 1 << endl;
        mode.pop();
    }
    return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

const int inf = 1e9 + 7;
const long long INF = 1e18 + 7;
const int maxn = 2e5 + 7;

int n, a[maxn], dp[maxn];

int main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i], dp[i] = inf;
	dp[1] = 0;
	for (int i = 1; i < n; i++){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	cout << dp[n];
	return 0;
} 

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int N;
int arr[200100];

int main()
{
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> arr[i];
    }
    bool bad = false;
    if (arr[0])
        bad = true;
    for (int i = 1; i < N; i++)
        if (arr[i] > arr[i-1] + 1)
            bad = true;

    if (bad)
    {
        cout << "-1\n";
        return 0;
    }

    long long ans = 0;
    for (int i = N - 1; i >= 1; i--)
    {
        if (i < N - 1 && arr[i] < arr[i+1])
            continue;
        ans += arr[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
double a[110],res = 0;
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a + n);
	res = a[0];
	for(i=0;i<n;i++){
		res = (res + a[i])/2;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
from itertools import product
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
C = []
for i in range(N):
    C.append(A[i].pop(0))
ans = sum(C)+10
for x in product((0,1),repeat=N):
    flag = 0
    for j in range(M):
        cnt = 0
        for i in range(N):
            if x[i]==1:
                cnt += A[i][j]
        if cnt<X:
            flag = 1
            break
    if flag==0:
        tot = 0
        for i in range(N):
            if x[i]==1:
                tot += C[i]
        ans = min(ans,tot)
if ans>sum(C):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 73756
n = int(input())
k = int(input())

digit = len(str(n))
# dp[i桁まで検査済み][lessthan][0以外の個数]
dp = [[[0] * (k + 2) for i in range(2)] for j in range(digit + 1)]
dp[0][0][0] = 1

for a in range(1, digit + 1):
    digitvalue = int(str(n)[a - 1])
    for b in range(2):
        for c in range(k + 1):
            for d in range(10 if b == 1 else digitvalue + 1):
                dp[a][1 if b == 1 else 1 if (d < digitvalue) else 0][c if d == 0 else c + 1] += dp[a - 1][b][c]

print(dp[digit][0][k] + dp[digit][1][k])



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

int main() {
    // input
    int H, W;
    cin >> H >> W;
    char S[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> S[i][j];
        }
    }

    // solve & output
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (S[i][j] == '.') {
                int cnt = 0;
                if (i != 0 && j != 0 && S[i - 1][j - 1] == '#') cnt++;
                if (i != 0 && S[i - 1][j] == '#') cnt++;
                if (i != 0 && j != W - 1 && S[i - 1][j + 1] == '#') cnt++;
                if (j != 0 && S[i][j - 1] == '#') cnt++;
                if (j != W - 1 && S[i][j + 1] == '#') cnt++;
                if (i != H - 1 && j != 0 && S[i + 1][j - 1] == '#') cnt++;
                if (i != H - 1 && S[i + 1][j] == '#') cnt++;
                if (i != H - 1 && j != W - 1 && S[i + 1][j + 1] == '#') cnt++;
                cout << cnt;
            } else {
                cout << S[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque

qx = deque([])
qy = deque([])

nowx = 0
nowy = 0
tmpx = 0
tmpy = 0

ans = -1
ans2 = 0
cnt = 1
m = []

sx=[0,1,0,-1]
sy=[1,0,-1,0]
H,W = map(int, input().split())
for i in range(H):
    m.append(list(input()))
f = 0
p=[[999 for i in range(W)] for j in range(H)]

qx.append(nowx)
qy.append(nowy)
p[nowx][nowy]=0

while(len(qx) > 0 and f == 0):
    nowx = qx.popleft()
    nowy = qy.popleft()
    for i in range(4):
        tmpx = nowx + sx[i]
        tmpy = nowy + sy[i]
        if (tmpx < 0 or tmpx > W-1 or tmpy < 0 or tmpy > H-1):
            continue
        if (m[tmpy][tmpx] == '#'):
            continue
        if (tmpx == W-1 and tmpy == H-1):
            p[tmpy][tmpx] = p[nowy][nowx]+1
            ans = p[nowy][nowx]+1
            f = 1
            break
        if (p[tmpy][tmpx] > p[nowy][nowx]+1):
            p[tmpy][tmpx] = p[nowy][nowx]+1
            qx.append(tmpx)
            qy.append(tmpy)

if(ans == -1):
    ans2 = -1
else:
    ans2 = sum(x.count('.') for x in m) - ans -1 
print(ans2)


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

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef pair <ll ,ll> pll;
typedef pair <int ,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define print(a) {for (auto iiiiiiiiii : a) cout << iiiiiiiiii << ' '; cout << '\n';}
#define fi first
#define se second
#define all(x) (x).begin() , (x).end()

ll next() {ll x; cin >> x; return x;}

const ll inf = 1e18 , mod = 998244353;
const int intf = 2e9 , maxn = 3e5;
const double PI = 3.141592653589 , eps = 1e-9;


void solve(){
    ll a , b , c; cin >> a >> b >> c;
    if (c > a + b && (c - a - b)*(c - a - b) > 4*a*b){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

}


int main()
{
    #ifdef HERE
        freopen("input.txt" , "r" , stdin);
    #else
        //freopen(".in" , "r" , stdin); freopen(".out" , "w" , stdout);
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
    #endif

    for (int t = 1; t--;) solve();

    #ifdef HERE
        cout << setprecision(3) << fixed << "\n\nRuntime: " << (long double)(clock()) / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
/*

*/


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String sin = sc.nextLine();
        int irt = 0;
		if(sin.charAt(0)=='1'){
			irt++;
		}
        if(sin.charAt(1)=='1'){
			irt++;
		}
        if(sin.charAt(2)=='1'){
			irt++;
		}
		System.out.println(irt);
    }
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;

const int N = 105;
int n;
int x[N], y[N], h[N];

int solve( int cx, int cy, long long H ) {
        int cnt = 0;
        int pos = 0;
        int neg = 0;
        for(int i = 0; i < n; i++) {
                long long hh = max( 0LL, H - abs( cx - x[i] ) - abs(cy - y[i]) );
                if( hh == (long long) h[i] )cnt++;
                else if( hh > (long long) h[i] ) pos++;
                else neg++;
        }

        if( cnt == n ) return 0;
        if( pos > neg ) return 1;
        else return -1;

}

int main() {
        scanf("%d", &n);
        for(int i = 0; i < n; i++) scanf("%d %d %d", x + i, y + i, h + i);

        long long st = 1LL, ed = (long long)1e18;


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

                        long long st = 1LL, ed = (long long)1e18;
                        long long H = 1LL;
                        while(st <= ed) {
                                long long mid = (st + ed) >> 1LL;
                                int val = solve(i, j, mid);
                                if( val == 0 ) {
                                        printf("%d %d %lld\n", i, j, mid);
                                        return 0;
                                }
                                if( val == 1 ) {
                                        ed = mid - 1;
                                } else st = mid + 1;


                        }
                }
        }




        return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int A,B;cin>>A>>B;
    vector<vector<char>> S(100,vector<char>(100,'.'));
    for(int i=50;i<100;i++){
        for(int j=0;j<100;j++){
            S[i][j]='#';
        }
    }
    A--;B--;
    for(int i=0;i<=(B-1)/50;i++){
        if(i!=(B-1)/50){
            for(int j=0;j<50;j++){
                S[2*i][2*j]='#';
            }
        }else{
            for(int j=0;j<(B-1)%50+1;j++){
                S[2*i][2*j]='#';
            }
        }
    }
    for(int i=0;i<=(A-1)/50;i++){
        if(i!=(A-1)/50){
            for(int j=0;j<50;j++){
                S[2*i+55][2*j]='.';
            }
        }else{
            for(int j=0;j<(A-1)%50+1;j++){
                S[2*i+55][2*j]='.';
            }
        }
    }
  cout<<100<<" "<<100<<endl;
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            cout<<S[i][j];
        }
        cout<<endl;
    }
    }


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int isSosuu(int num){

	for(int i = 2; i*i <= num; i++){
		if(num % i == 0)return -1;
	}
	return 0;
}


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

	ll Np = N;
	ll ans = 0;

	for(ll i = 2; i*i <= Np; i++){

		ll z = i;
		//cout<<"mz : "<<z<<endl;
		while(Np % z == 0){
			ans++;
		//	cout<<"z : "<<z<<endl;
		//	cout<<"Np : "<<Np<<endl;
			Np = Np / z;
		//	cout<<"NextNp : "<<Np<<endl;
			z = z * i;
		}
		while(Np % i == 0){
			Np = Np / i;
		}
		if(Np == 1)break;
	}
	if(N <= 1){
		cout<<0<<endl;
		return 0;
	}
	if(Np != 1){
		cout<<ans+1<<endl;
		return 0;
	}

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



Measured memory_bytes: 3572
from fractions import gcd
n=int(input())
h=[]
for i in range(n):
    w=list(map(int,input().split()))
    h.append(w)
for i in range(n):
    a,b,c,d=h[i][0],h[i][1],h[i][2],h[i][3]
    if(b>a or b>d):
        print("No")
        continue
    if(b<=c):
        print("Yes")
        continue
    if(b-gcd(b,d)+a%gcd(b,d)<=c):print("Yes")
    else:print("No")
    continue

Measured memory_bytes: 5176
import sys
readline = sys.stdin.readline
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def main():
    A, B, C, D = map(int, readline().rstrip().split())
    ans = B - (B//C + B//D - B//lcm_base(C, D))
    ans -= ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm_base(C, D)))
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5048
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define pb push_back

typedef pair <int,int> P;

void solve() {
    while (true) {
        int m;
        scanf("%d", &m);

        if (!m) break;

        vector<P> star;
        REP(i, m) {
            int x, y;
            scanf("%d %d", &x, &y);
            star.pb(P(x,y));
        }

        int n;
        scanf("%d", &n);

        vector<P> sky;
        REP(i, n) {
            int x, y;
            scanf("%d %d", &x, &y);
            sky.pb(P(x,y));
        }

        map<P, int> diff;
        REP(i, sky.size()) {
            REP(j, star.size()) {
                int diff_x = sky[i].first - star[j].first;
                int diff_y = sky[i].second - star[j].second;
                diff[P(diff_x, diff_y)]++;
            }
        }

        int x, y;
        for(map<P,int>::iterator it = diff.begin(); it != diff.end(); it++) {
            if (it->second == star.size()) {
                x = it->first.first;
				y = it->first.second;
                break;
            }
        }
        
        printf("%d %d\n", x, y);
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 14828
def insertion_sort(A, n, g):
    cnt = 0
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j -= g
            cnt += 1
        A[j + g] = v
    return cnt
def shell_sort(A, n):
    cnt = 0
    G = [1]
    for i in range(1, 100):
        # https://web.archive.org/web/20170212072405/http://www.programming-magic.com/20100507074241/
        # 間隔
        delta = 4 ** i + 3 * 2 ** (i - 1) + 1
        if delta >= n:
            break
        G.append(delta)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt += insertion_sort(A, n, G[i])
    return m, G, cnt
n = int(input())
A = [int(input()) for _ in range(n)]
m, G, cnt = shell_sort(A, n)
print(m)
print(*G)
print(cnt)
print(*A, sep='\n')


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

int main() {
    int n, x;
    while (true) {
        cin >> n >> x;
        int ans = 0;

        if (n == 0 && x == 0) break;


        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                for (int k = j + 1; k <= n; ++k) {
                    if (i + j + k == x) ++ans;
                }
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
int main(){

int N, K, ans;
ans = 0;
cin >> N >> K;

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

sort(table.begin(),table.end());
for (int i = 0; i < K; i++){
    ans = table.at(i) + ans;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>
int bubbleSort(int *,int);

int main(){
  int *akira;
  int i,count,n;

  scanf("%d",&n);
  akira=(int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    scanf("%d",&akira[i]);
  }
  
  count=bubbleSort(akira,n);
  
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",akira[i]);
  }
  printf("\n%d\n",count);
  
  return 0;
}
int bubbleSort(int *akira,int n){
  int i,j,tmp,flag=1,count=0;

  while(flag!=0){
    flag=0;
    for(i=n-1;i>0;i--){
      if(akira[i]<akira[i-1]){
	tmp=akira[i];
	akira[i]=akira[i-1];
	akira[i-1]=tmp;
	count++;
	flag=1;
      }
    }
  }
  return count;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
using T=pair<int,int>;
int N,M;
main(){
  cin>>N>>M;
  priority_queue<T,vector<T>,greater<T>>q;
  for(int i=0;i<M;++i){
    int a,b;
    cin>>a>>b;
    --a;
    --b;
    q.push({b,a});
  }
  int last=-1;
  int n_count=0;
  while(!q.empty()){
    const T pair=q.top();
    q.pop();
    const int left=pair.second;
    const int right=pair.first;
    // printf("left, right = %d, %d\n",left,right);
    if(left<=last)continue;
    last=right-1;
    ++n_count;
  }
  cout<<n_count<<endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

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

    int a = 0;
    //a
    for(int i=0;i<3;i++){
        if(S[i] == 'a')
            a = 1;
    }

    int b = 0;
    //b
    for(int i=0;i<3;i++){
        if(S[i] == 'b')
            b = 1;
    }

    int c = 0;
    //c
    for(int i=0;i<3;i++){
        if(S[i] == 'c')
            c = 1;
    }

    if(a==1 && b==1 && c==1)
        cout << "Yes" << '\n';
    else
        cout << "No" << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char s[4];
    int i, check = 0;

    scanf("%s", s);

    for(i=0; i<3; i++){
        if(s[i] == s[i+1])
            check++;
    }

    if(check == 0)
        printf("Good\n");
    else
        printf("Bad\n");
    
    return 0;
}

Measured memory_bytes: 128
//MIPT Cryptozoology
//Room 265
#define _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:128000000")
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <cmath>
#include <ctime>
#include <stack>
#include <bitset>
#include <set>
#include <map>
#include <cassert>
#include <memory.h>
#include <sstream>

using namespace std;

#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define itn int

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

typedef long long li;
typedef long long i64;
typedef long double ld;
typedef vector<int> vi;
typedef pair <int, int> pi;

void solve(bool);

void precalc();

int TESTNUM = 0;
#define FILENAME ""

int main() {
	string s = FILENAME;
#ifdef YA
	//assert(!s.empty());
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//cerr<<FILENAME<<endl;
	//assert (s != "change me please");
	clock_t start = clock();
#else
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen(FILENAME ".in", "r", stdin);
	//freopen(FILENAME ".out", "w", stdout);
	cin.tie(0);
#endif
	cout.sync_with_stdio(0);
	cout.precision(10);
	cout << fixed;
	precalc();
	int t = 1;
	//cin >> t;
	int test_num = 1;
	while (t--) {
		//cout << "Case #" << test_num++ << ": ";
		++TESTNUM;
		solve(true);
	}
#ifdef YAH
	while (true) {
		solve(false);
	}
#endif
#ifdef YA
	cerr << "\n\n\n" << (clock() - start) / 1.0 / CLOCKS_PER_SEC << "\n\n\n";
#endif
	return 0;
}

//#define int li

/*int pr[] = { 97, 2011 };
int mods[] = { 1000000007, 1000000009 };

const int C = 100500;
int powers[2][C];*/

//int MOD = 1000000007;

//int c[5010][5010];

template<typename T>
T binpow(T q, T w, T mod) {
	if (!w)
		return 1 % mod;
	if (w & 1)
		return q * 1LL * binpow(q, w - 1, mod) % mod;
	return binpow(q * 1LL * q % mod, w / 2, mod);
}

void precalc() {

	/*for (int w = 0; w < 2; ++w) {
	powers[w][0] = 1;
	for (int j = 1; j < C; ++j) {
	powers[w][j] = (powers[w][j - 1] * 1LL * pr[w]) % mods[w];
	}
	}*/

	/*for (int i = 0; i < 5010; ++i) {
	c[i][i] = c[i][0] = 1;
	for (int j = 1; j < i; ++j) {
	c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
	}
	}*/
}

template<typename T>
T gcd(T q, T w) {
	while (w) {
		q %= w;
		swap(q, w);
	}
	return q;
}
template<typename T>
T lcm(T q, T w) {
	return q / gcd(q, w) * w;
}

inline int nxt(){
	int x;
	cin >> x;
	return x;
}

#define int li

void solve(bool read) {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	int all_n = n * (n + 1) / 2;
	if (sum % all_n) {
		cout << "NO\n";
		return;
	}
	int steps = sum / all_n;
	int now = 0;
	for (int i = 0; i < n; ++i) {
		int diff = a[i] - a[(i + 1) % n];
		if ((diff + steps) % n || (diff + steps) < 0) {
			cout << "NO\n";
			return;
		}
		now += (diff + steps) / n;
	}

	if (now == steps) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

}



Measured memory_bytes: 1024
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        k: usize,
        v: [i64; n]
    }
    let mut dp = vec![vec![i64::max_value() >> 1; n + 1]; n];
    dp[0][0] = 0;
    dp[0][1] = v[0];
    for i in 1..n {
        dp[i][0] = 0;
        dp[i][1] = v[i];
        for j in 2..i + 2 {
            for k in 0..i {
                dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0, v[i] - v[k]));
            }
        }
    }
    let mut ans = i64::max_value();
    for i in 0..n {
        ans = min(ans, dp[i][n - k]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import math

n = int(input())
a = [int(x) for x in input().split()]
a.sort()
x = max(a)
a.remove(x)
maxi = 0
mind = x
for i in range(len(a)):
    d = abs((x+1) // 2 - a[i])
    if d < mind:
        maxi = i
        mind = d
print(str(x) + ' ' + str(a[maxi]))


Measured memory_bytes: 62832
#include<bits/stdc++.h>
using namespace std;
int cnt(int n)
{
	int c=0;
	while(n%2==0)
	{
		n=n>>1;
		c++;
	}
	return c;
}
int main() {
	int n,mx=0,ans=1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int l=cnt(i);
		if(mx<l)
		{
			mx=l;
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;
typedef pair<int, char> P;

int mod2(int n) {
    int ans = 0;
    while (n % 2 == 0) {
        n /= 2;
        ans++;
    }
    return ans;
}


int main() {
    int n;
    cin >> n;
    int ans = INF;
    rep(i, n) {
        int a;
        cin >> a;
        cmin(ans, mod2(a));
    }

    cout << ans << endl;

}

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

int main()
{
    int n, i, stamina1=0, stamina2=0, sum=0;
    cin >> n;

    int a[n];
    int avg1, avg2;
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }

    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }

    avg1=floor(sum/double(n));
    avg2=ceil(sum/double(n));

    for(i=0; i<n; i++)
    {
        stamina1=stamina1+(a[i]-avg1)*(a[i]-avg1);
        stamina2=stamina2+(a[i]-avg2)*(a[i]-avg2);
    }

    cout << min(stamina1,stamina2) << endl;

     return 0;
}


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

int main(void)
{
    int a, b, mod;
    cin >> a >> b;

    mod = (a * b) % 2;

    if (mod == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split(" "))
ans = [0 for i in range(N)]

for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if (i <= X and j <= X) or (Y <= i and Y <= j):
      # I, IIIの中
      ans[j - i] += 1
    elif i <= X and Y <= j:
      # i -> I, j -> III
      ans[X - i + 1 + j - Y] += 1
    else:
      # i -> II or j -> IIのとき
      dist = min((j - i), (abs(i - X) + 1 + abs(Y - j)))
      ans[dist] += 1

print('\n'.join([str(s) for s in ans[1:]]))

Measured memory_bytes: 3188