akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdint.h>
#include<inttypes.h>
#include<math.h>
 
int_fast32_t insertion_sort(int_fast32_t *a, int_fast32_t n, int_fast32_t g)
{
    int_fast32_t cnt = 0;
    for(int_fast32_t i=g; i<n; ++i){
        int_fast32_t v = a[i];
        int_fast32_t j = i - g;
        while(j >= 0 && a[j] > v){
            a[j+g] = a[j];
            j -= g;
            ++cnt;
        }
        a[j+g] = v;
    }
    return cnt;
}
 
void shell_sort(int_fast32_t *a, int_fast32_t n)
{
    int_fast32_t cnt = 0;
    int_fast32_t m   = log(2.0*n+1.0)/log(3.0);
    int_fast32_t g[m];
    g[m-1] = 1;
    for(int_fast32_t i=1; i<m; ++i)
        g[m-i-1] = g[m-i]*3+1;
 
    for(int_fast32_t i=0; i<m; ++i)
        cnt += insertion_sort(a, n, g[i]);
 
    printf("%"PRIdFAST32"\n", m);
    printf("%"PRIdFAST32, g[0]);
    for(int_fast32_t i=1; i<m; ++i)
        printf(" %"PRIdFAST32, g[i]);
    printf("\n");
    printf("%"PRIdFAST32"\n", cnt);
}
 
int main(void)
{
    int_fast32_t n;
    scanf("%"SCNdFAST32, &n);
 
    int_fast32_t a[n];
    for(uint_fast32_t i=0; i<n; ++i)
        scanf("%"SCNdFAST32, &a[i]);
 
    shell_sort(a, n);
 
    for(uint_fast32_t i=0; i<n; ++i)
        printf("%"PRIdFAST32"\n", a[i]);
 
    return 0;
}

Measured memory_bytes: 9792
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
double INF=1000000000.0;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int k,a[110000]={};
    cin>>k;
    rep(i,k){
        cin>>a[i];
    }
    ll int l=2,r=2;
    for(ll int i=k-1;i>=0;i--){
        if(r<a[i]||(l%a[i]!=0&&l/a[i]==r/a[i])) {cout<<-1;return 0;}
        l=max((l+a[i]-1)/a[i],(ll int)1)*a[i];
        r=(r/a[i])*a[i]+a[i]-1;
    }
    cout<<l<<" "<<r;
    return 0;
}

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

const int N = 2e5 + 7;
vector<int> G[N];
int dfn[N], id, n, q, last[N], pos[N];
long long val[N], ans[N];

void dfs(int u, int fa) {
	dfn[u] = ++id;
	pos[id] = u;
	for (auto v: G[u]) {
		if (v == fa) continue;
		dfs(v, u);
	}
	last[u] = id;
}

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1, 0);
	while (q--) {
		long long x;
		int u;
		scanf("%d%lld", &u, &x);
		val[dfn[u]] += x;
		val[last[u] + 1] -= x;
	}
	for (int i = 1; i <= n; i++) {
		val[i] += val[i - 1];
		ans[pos[i]] = val[i];
	}
	for (int i = 1; i <= n; i++)
		printf("%lld%c", ans[i], " \n"[i == n]);
	return 0;
}

Measured memory_bytes: 28160
use std::cmp;
use std::collections::BinaryHeap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let n: usize = sc.read();
    let mut right = vec![];
    let mut left = vec![];
    for _ in 0..n {
        left.push(sc.read::<i64>());
        right.push(sc.read::<i64>());
    }

    let left_inv = left.iter().map(|&left| -left).collect();
    let right_inv = right.iter().map(|&right| -right).collect();
    let ans1 = solve(left, right);
    let ans2 = solve(right_inv, left_inv);
    println!("{}", cmp::max(ans1, ans2));
}
fn solve(left: Vec<i64>, right: Vec<i64>) -> i64 {
    let n = left.len();

    let mut left_heap = BinaryHeap::new();
    let mut right_heap = BinaryHeap::new();
    for i in 0..n {
        left_heap.push((left[i], i));
        right_heap.push((-right[i], i));
    }

    let mut ans = 0;
    let mut cur = 0;
    let mut used = vec![false; n];
    for i in 0..n {
        let k = if i % 2 == 0 {
            {
                let mut result;
                loop {
                    let (_, k) = left_heap.pop().unwrap();
                    if used[k] {
                        continue;
                    }
                    used[k] = true;
                    result = k;
                    break;
                }
                result
            }
        } else {
            {
                let mut result;
                loop {
                    let (_, k) = right_heap.pop().unwrap();
                    if used[k] {
                        continue;
                    }
                    used[k] = true;
                    result = k;
                    break;
                }
                result
            }
        };

        if left[k] <= cur && cur <= right[k] {
            continue;
        }

        if (left[k] - cur).abs() < (right[k] - cur).abs() {
            ans += (left[k] - cur).abs();
            cur = left[k];
        } else {
            ans += (right[k] - cur).abs();
            cur = right[k];
        }
    }
    ans += cur.abs();
    ans
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 17308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll a,b;
int main() {
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			a++;
		}
		else{
			b++;
		}
	}
	cout << min(a,b)*2;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 998244353//1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000000
#define N 10000001
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,k;
   cin>>n>>k;
   k=min(k,300LL);
   int a[n];
   rep(i,0,n)cin>>a[i];
   for(int j=0;j<k;j++)
   {
       vi cnt(n+1);
       for(int i=0;i<n;i++)
       {
            cnt[max(i - a[i],0LL)]++;
            cnt[min(n,i + a[i] + 1)]--;
       }
       for(int i=0;i<n;i++)
       {
           a[i]=cnt[i];
           cnt[i+1]+=cnt[i];
       }
   }
   for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
}


Measured memory_bytes: 6736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

void solve(){

	int a , b , c;
	cin>>a>>b>>c;

	set<int> s = {a , b , c};

	if(s.size()==2){

		cout<<"Yes\n";
		return ;
	}

	cout<<"No\n";
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 256
n,m,q = map(int,input().split())
a,b,c,d = [],[],[],[]
ans = 0
A = [1]

for i in range(q):
    ai,bi,ci,di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

def dfs(A):
    global ans
    if n == len(A):
        now = 0
        for i in range(q):
            if A[b[i]-1] - A[a[i]-1] == c[i]:
                now += d[i]
        ans  = max(ans,now)
        return

    for i in range(A[-1], m+1):
        A.append(i)
        dfs(A)
        A.pop() #最後の要素を削除
dfs(A)
print(ans)


Measured memory_bytes: 9232
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
string s,t;
cin>>s>>t;
cout<<t+s<<endl;
return 0;
}


Measured memory_bytes: 256
# ABC 100
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def db(x): 
    global debug
    if debug: print(x)
debug = True
N = getInt()
A = getIntList()
def power2(n):
    pw = 0
    while n%2==0:
        pw += 1
        n //= 2
    return pw
count = 0
for i in range(N):
    count += power2(A[i])
print(count)



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

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<string(c-a,'R')<<string(d-b,'U');
    cout<<string(c-a,'L')<<string(d-b,'D');
    cout<<'D'<<string(c-a+1,'R')<<string(d-b+1,'U')<<'L';
    cout<<'U'<<string(c-a+1,'L')<<string(d-b+1,'D')<<'R'<<endl;
}


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

int main(){
  int i=0;
  int cnt=0;
  char yo[3];
  char ji[3];
  scanf("%s",ji);
  scanf("%s",yo);
  if(yo[0]==ji[0])
    cnt++;
  if(yo[1]==ji[1])
    cnt++;
  if(yo[2]==ji[2])
    cnt++;
  printf("%d",cnt);
}


Measured memory_bytes: 128
/*
 *  author: kiran bhanushali
 *  handle: kinibha
 *  time:
 *  email:kiranbhanushali143.kb143@gmail.com
 */


#include<bits/stdc++.h>
using namespace std;

#define int  long long 
  

int32_t main(){
    
    int a , b;cin>>a>>b;
    int outlet = 1,ans=0;
    while(outlet<b){
        --outlet;
        ans++;
        outlet+= a;
    }
    cout<<ans<<endl;
 
    return 0;
}


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

vector<vector<int>> node;
vector<int> a,b;
vector<bool> done;
map<pair<int,int>,int> color;

void dfs(int from, int forbidden) {
	int val = 0;
	for(int i=0;i<node[from].size();i++) {
		int to = node[from][i];
		if(color.count(make_pair(from,to))) {
			continue;
		}
		if(val == forbidden) {
			val++;
		}
		color[make_pair(from,to)] = val;
		color[make_pair(to,from)] = val;
		dfs(to,val);
		val++;
	}
}

int main() {
	int n;
	cin >> n;
	a = vector<int>(n);
	b = vector<int>(n);
	done = vector<bool>(n, false);
	node = vector<vector<int>>(n);
	for(int i=0;i<n-1;i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		a[i] = x, b[i] = y;
		node[x].push_back(y);
		node[y].push_back(x);
	}
	int num = 0;
	for(int i=1;i<n;i++) {
		if((int)node[num].size() < (int)node[i].size()) {
			num = i;
		}
	}
	
	dfs(num, -1);

	cout << (int)node[num].size() << endl;
	for(int i=0;i<n-1;i++) {
		cout << color[make_pair(a[i],b[i])] + 1 << endl;
	}
}

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

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

int main() {
  int N,A,B; cin >>N >>A >>B;
  cout <<((B-A)%2==0 ? "Alice":"Borys") <<endl;
  return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>

int main(void){
  int tH, tA, aH, aA,Tw,Aw;
  scanf("%d %d %d %d",&tH, &tA, &aH, &aA);
  	
  /*(A / D)回目攻撃のときAのHPが0以下＝Tの(B / C)回目の攻撃のとき*/
  Tw = (tH + aA - 1) / aA; 
  Aw = (aH + tA - 1) / tA; 
  
  if(Tw >= Aw)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}

Measured memory_bytes: 1648
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mx 100000000
#define pb push_back
#define mp make_pair
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()


ll md=1e9+7;
ll __gcd(ll a, ll b) {if(b==0) return a; return __gcd(b, a%b);}
ll poww(ll a, ll b) {ll res=1;while(b) {if(b&1){res*=a;res%=md;}a*=a;a%=md;b>>=1;}return res;}
void ainp(int arr[], int n) {for(int i=0;i<n;i++) cin>>arr[i];}

const ll N=3e5+5;

void fun()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);}


signed main()
{  
fun();
int t;
//cin>>t;
t=1;
while(t--)
{
	ll sum=0,i;
	string s;
	cin>>s;
	for(i=0;i<s.length();i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9==0)
	Yes
	else
	No
}
}



Measured memory_bytes: 3716
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;
#define dbg(x) cout << #x << " has a value of: " << x << "\n";
#define usize(x) (int)(x.size())
#define plist(x)                       \
    for (int i = 0; i < usize(x); i++) \
        cout << "eleman " << i << " = " << x[i] << "\n";
#define foreach(x) for (auto item : x)
#define fill(s, x)              \
    for (int i = 0; i < x; i++) \
        cin >> s[i];
#define in(veriler, a) (veriler.find(a) != veriler.end())
#define btw(x, y, z) x >= y&& x <= z;
std::ostream& operator<<(std::ostream& os, pair<int,int> p) {
    os << p.first << ", " << p.second;
    return os;
}
#ifdef ONLINE_JUDGE
#define fio ios_base::sync_with_stdio(false);cin.tie(null);
#else
#define fio //a
#endif

vector<vector<pii> > adj;
void dijk(int start,vector<lli>& dist,vector<lli>& pre){
	set<pii> nodes;
	int len=dist.size();
	dist=vector<lli>(len,1e17);
	nodes.insert(pii(0,start));
	dist[start]=0;
	pre=vector<lli>(len,-1);
	while(!nodes.empty())
	{
		auto sim=*nodes.begin();		
		nodes.erase(sim);
		for(auto u:adj[sim.second]){
			if(dist[sim.second]+u.second<dist[u.first]){
				if(nodes.find(pii(dist[u.first],u.first))!=nodes.end())
					nodes.erase(pii(dist[u.first],u.first));
				dist[u.first]=dist[sim.second]+u.second;
				pre[u.first]=sim.second;
				nodes.insert(pii(dist[u.first],u.first));
			}
		}
	}	
}
int color[201];
lli tree=true; 
bool bpCheck(int node,int parent=-1){
	for(auto u:adj[node]){
		int item=u.first;
		if(item==parent)continue;
		if(color[item]!=-1&&color[item]==color[node])return false;
		if(color[item]==-1){
			color[item]=abs(color[node]-1);
			if(!bpCheck(item,node)){
				return false;
			}
		}
	}
	return node;
}
int main(){
	fio
	int n;
	cin>>n;
	adj=vector<vector<pii> >(n+1);
	for (int i = 0; i < 201; i++)
	{
		color[i]=-1;
	}
	
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			char c;
			cin>>c;
			if(c>48)adj[i].push_back(pii(j,1));
		}
	}
	color[1]=1;
	if(!bpCheck(1,-1)){
		cout<<-1<<"\n";
		return 0;
	}
	lli nmx=0;
	for (int i = 1; i <=n ; i++)
	{
		vector<lli> dists(n+1),pre(n+1);
		dijk(i,dists,pre);
		for (int i = 1; i <=n ; i++)
		{
			nmx=max(nmx,dists[i]);
		}
		
	}
	cout<<nmx+1<<"\n";
	return 0;
}


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

class A7{
  struct Tree{
    public int id;
    public int parent;
    public int depth;
    public int[] childlen;
    public string type;
  }

  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    var tree = new Tree[n];

    for(int i = 0;i < n;i++) tree[i].parent = -1;
    for(int i = 0;i < n;i++){
      int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      //int[] A = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      var id = input[0];
      tree[id].id = id;

      var k = input[1];
      if(k == 0) tree[id].type = "leaf";
      else tree[id].type = "internal node";
      tree[id].childlen = new int[k];
      for(int j = 0;j < k;j++){
        tree[id].childlen[j] = input[2 + j];
        tree[input[2 + j]].parent = id;
      }
    }
    for(int i = 0;i < n;i++){
      if(tree[i].parent == -1){
        tree[i].type = "root";
        Depth(tree,i,0);
        break;
      }
    }
    for(int i = 0;i < n;i++){
      Console.Write("node ");
      Console.Write(tree[i].id);
      Console.Write(": parent = ");
      Console.Write(tree[i].parent);
      Console.Write(", depth = ");
      Console.Write(tree[i].depth);
      Console.Write(", ");
      Console.Write(tree[i].type);
      Console.Write(", [");
      Console.Write(string.Join(", ",Array.ConvertAll(tree[i].childlen, (e) => e.ToString())));
      Console.WriteLine("]");
    }
  }

  static void Depth(Tree[] tree,int id,int depth){
    tree[id].depth = depth;
    for(int i = 0;i < tree[id].childlen.Length;i++)
      Depth(tree,tree[id].childlen[i],depth + 1);
    }
}



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

int main(){
  string S;
  cin>>S;
  bool bo=false;
  for(int i=0;i<S.size();i++){
    if(i==0){
      if(S[i]!='A'){
        cout<<"WA"<<endl;
        return 0;
      }
    }else if('A'<=S[i] && S[i]<='Z'){
      if(i==1 || i==S.size()-1 || S[i]!='C' || bo){
        cout<<"WA"<<endl;
        return 0;
      }else
        bo=true;
    }
  }
  if(bo)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 200002

int n;
int a[MAXN];
int d[MAXN];

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d", &n);
	ll s = 0;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		s += a[i];
	}

	ll ts = 1LL * n * (n + 1) / 2;
	if (s % ts != 0) {
		puts("NO");
		return 0;
	}
	ll k = s / ts;

	ll t = 0;
	for (int i = 0; i < n; ++i) {
		d[i] = a[(i + 1) % n] - a[i];
		if (k - d[i] < 0 || (k - d[i]) % n != 0) {
			puts("NO");
			return 0;
		}
		t += (k - d[i]) / n;
	}

	puts(t == k ? "YES" : "NO");

	return 0;
}


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

const int N = 1e5 + 5;

int tab[N];

int main() {
  int n, x;
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &x);
    tab[x + 2] ++;
    tab[x + 1] ++;
    tab[x] ++;
  }
  int mx = 0, ans = 0;
  for (int i = 0; i < N; i ++)
    if (mx < tab[i]) {
      mx = tab[i];
      ans = i - 1;
    }
  printf("%d\n", mx);
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	int N;
	cin >> N;
	int L = 0;
	while (1) {
		L++;
		if (L * (L + 1) >= 2 * N) {
			break;
		}
	}
	for (int i = 1; i <= L; i++) {
		if (i == L * (L + 1) / 2 - N) {
			continue;
		}
		else {
			cout << i << endl;
		}
		
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int swp[MAXN];

int32_t main() {
    $
    int n, m, l, r;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        swp[l]++;
        swp[r + 1]--;
    }
    int ans = -INF, cnt = 0;
    for (int i = 1; i <= n; ++i) {
        swp[i] += swp[i - 1];
        if (swp[i] != m) {
            cnt = 0;
        }
        cnt += (swp[i] == m);
        ans = max(ans, cnt);
    }
    cout << ans << '\n';
}   



Measured memory_bytes: 640
#include<bits/stdc++.h>
int n,a,k,s,x;
int main(){
	for(scanf("%d",&n);n--;){
		scanf("%d%d",&a,&k);
		for(;a%k;)x=(a+k-1)/k,a-=(a-(k-1)*(x-1))/x*x;s^=a/k;
	}
	puts(s?"Takahashi":"Aoki");
	return 0;
}

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

const int MOD = 1e9 + 7;
vector<int> b, a;
int n, m, ai, bi, tmp, cnt;
long long ans = 1;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		b.push_back(tmp);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	for (int i = n * m; i >= 1; i--) {
		if (a[ai] == i && b[bi] == i)
			ai++, bi++;
		else if (a[ai] == i)
			ai++, ans *= bi;
		else if (b[bi] == i)
			bi++, ans *= ai;
		else
			ans *= (ai * bi) - cnt;
		cnt++;
		if (ans < 0 || ans == 0)
			return cout << 0, 0;
		ans %= MOD;
	}
	cout << ans;
}

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

using ll=long long;
ll n,ans,M=10000000LL;

int main(){
  cin>>n;
  for(int i=2;i<=min(n,M);i++){
    int j=i;
    while(!(n%j)){
      ans++;n/=j;j*=i;
    }
    while(!(n%i))n/=i;
  }
  cout<<ans+(n>=M)<<endl;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
#define int long long

signed main(){
    int n; cin >> n;
    map<int, bool> num;
    rep(i,n){
        int a; cin >> a;
        num[a] = !num[a];
    }
    int ans = 0;
    for(auto p : num){
        ans += p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

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

        Integer n = sc.nextInt();
        Long[] a, b;
        a = new Long[n];
        b = new Long[n];

        for(int i = 0; i < n; i++){
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
        }

        Integer simeIdx[] = new Integer[n];
        Arrays.setAll(simeIdx, i -> i);
        Arrays.sort(simeIdx, Comparator.comparingLong(i -> b[i]));

        Long time = 0L;
        boolean canClear = true;
        for(int i = 0; i < n; i++){
            time += a[simeIdx[i]];
            if(time > b[simeIdx[i]]){
                canClear = false;
                break;
            }
        }

        if(canClear){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 123076
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>

using namespace std;

int main(){
int a,b,c,d,k;
cin>>a>>b>>c>>d>>k;
int h,j;
h=a*60+b;
j=c*60+d;
int x=j-h;
    cout<<x-k<<endl;


}

Measured memory_bytes: 3636
N = int(input())
AB=[]
for i in range(N):
  a,b = list(map(int, input().strip().split(' ')))
  AB+=[[b,a]]
AB.sort()
tim=0
for i in range(N):
  tim+=AB[i][1]
  if tim>AB[i][0]:print("No");exit()
print("Yes")

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

int main(){
  int N;
  cin >> N;
  int A[N+2];
  A[0] = 0;
  A[N+1] = 0;
  int S = 0;
  int before = 0;
  for(int i=1;i<N+1;i++) cin >> A[i];
  for(int i=1;i<N+2;i++){
    S += abs(A[i]-A[i-1]);
  }
  for(int i=1;i<N+1;i++){
    printf("%lld\n", S - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]));
    //cout << S - abs(A[i+1]-A[i]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]) << endl;
  }
  return 0;
}


Measured memory_bytes: 1664
using System;

class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);

        string ret = "";

             if (a < b)  ret = "a < b";
        else if (a > b)  ret = "a > b";
        else if (a == b) ret = "a == b";

        Console.WriteLine(ret);
    }
}


Measured memory_bytes: 8832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			if (a == 0 & b == 0)
				break;
			for (int i = 0; i < a; i++) {
				for (int j = 0; j < b; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 26856
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n,m;
	rl2(n,m);
	VL ans(n+1,0),pos(n+1,0);
	fr(i,0,m)
	{
		ll x;
		rl(x);
		//x--;
		pos[x]=-1;
	}
	if(pos[1]!=-1)
		ans[1]=1;
	if(pos[2]!=-1&&n>=2)
		ans[2]=1+ans[1];
	fr(i,3,n+1)
	{
		if(pos[i]==-1)
			continue;
		if(i-1>0&&pos[i-1]!=-1&&ans[i-1]!=0)
			ans[i]+=(ans[i-1]);
		
		ans[i]%=mod;

		if(i-2>0&&pos[i-2]!=-1&&ans[i-2]!=0)
		{
			ans[i]+=(ans[i-2]);
		}
		ans[i]%=mod;
	}
	// fr(i,0,n+1)
	// 	cout<<ans[i]<<" ";
	// NL;
	ll ass=ans[n]%mod;
	wl(ass);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=200005,TT=1000000007;
int n,F[4005][4005],fac[8005],inv[8005],A[maxn],B[maxn],ans;
inline int read()
{
	int ret=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=getchar();}
	while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=getchar();}
	return ret*f;
}
inline int QP(int a,int b)
{
	int ret=1,w=a;
	while(b)
	{
		if(b&1) ret=(LL)ret*w%TT;
		w=(LL)w*w%TT;b>>=1;
	}
	return ret;
}
inline int C(int n,int m){return (LL)fac[n]*inv[m]%TT*inv[n-m]%TT;}
int main()
{
	n=read();fac[0]=1;
	for(int i=1;i<=8000;i++){fac[i]=(LL)fac[i-1]*i%TT;inv[i]=QP(fac[i],TT-2);}
	for(int i=1;i<=n;i++)
	{
		A[i]=read();B[i]=read();
		F[2000-A[i]][2000-B[i]]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++)
			F[i][j]=((LL)F[i][j]+(j?F[i][j-1]:0)+(i?F[i-1][j]:0))%TT;
	for(int i=1;i<=n;i++)
	{
		ans=(ans+F[2000+A[i]][2000+B[i]])%TT;
		ans=(ans-C(A[i]+B[i]+A[i]+B[i],A[i]+A[i])+TT)%TT;
	}
	ans=(LL)ans*QP(2,TT-2)%TT;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 64384
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

// conversion
//------------------------------------------
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

// math
//-------------------------------------------
template <class T> inline T sqr(T x) { return x * x; }

// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c)                                                             \
  for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

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

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

void solve(long long N) {
  cout<<N*(N-1)/2<<endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

int main() {
  
  int A, B, C;
  cin >> A >> B >> C;
  
if ( 22 <= A + B + C ) {
  cout << "bust" << endl;
}
  else {
    cout << "win" << endl;
  }
 
} 

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();
		int m = sc.nextInt();
		Cake[] cakes = new Cake[n];
		for (int i = 0; i < n; i++) {
			cakes[i] = new Cake(sc.nextLong(), sc.nextLong(), sc.nextLong());
		}
		long max = Long.MIN_VALUE;
		Arrays.sort(cakes, new Comparator<Cake>() {
		public int compare(Cake c1, Cake c2) {
			return compareLong(c1.x + c1.y + c1.z, c2.x + c2.y + c2.z);
		}
		});
		long totalA = 0;
		long totalB = 0;
		for (int i = 0; i < m; i++) {
			totalA += cakes[i].x + cakes[i].y + cakes[i].z;
			totalB += cakes[n - i - 1].x + cakes[n - i - 1].y + cakes[n - i - 1].z;
		}
		totalA = Math.abs(totalA);
		totalB = Math.abs(totalB);
		max = Math.max(max, totalA);
		max = Math.max(max, totalB);
		
		Arrays.sort(cakes, new Comparator<Cake>() {
		public int compare(Cake c1, Cake c2) {
			return compareLong(- c1.x + c1.y + c1.z, - c2.x + c2.y + c2.z);
		}
		});
		totalA = 0;
		totalB = 0;
		for (int i = 0; i < m; i++) {
			totalA += - cakes[i].x + cakes[i].y + cakes[i].z;
			totalB += - cakes[n - i - 1].x + cakes[n - i - 1].y + cakes[n - i - 1].z;
		}
		totalA = Math.abs(totalA);
		totalB = Math.abs(totalB);
		max = Math.max(max, totalA);
		max = Math.max(max, totalB);
		
		Arrays.sort(cakes, new Comparator<Cake>() {
		public int compare(Cake c1, Cake c2) {
			return compareLong(c1.x - c1.y + c1.z, c2.x - c2.y + c2.z);
		}
		});
		totalA = 0;
		totalB = 0;
		for (int i = 0; i < m; i++) {
			totalA += cakes[i].x - cakes[i].y + cakes[i].z;
			totalB += cakes[n - i - 1].x - cakes[n - i - 1].y + cakes[n - i - 1].z;
		}
		totalA = Math.abs(totalA);
		totalB = Math.abs(totalB);
		max = Math.max(max, totalA);
		max = Math.max(max, totalB);
		
		Arrays.sort(cakes, new Comparator<Cake>() {
		public int compare(Cake c1, Cake c2) {
			return compareLong(c1.x + c1.y - c1.z, c2.x + c2.y - c2.z);
		}
		});
		totalA = 0;
		totalB = 0;
		for (int i = 0; i < m; i++) {
			totalA += cakes[i].x + cakes[i].y - cakes[i].z;
			totalB += cakes[n - i - 1].x + cakes[n - i - 1].y - cakes[n - i - 1].z;
		}
		totalA = Math.abs(totalA);
		totalB = Math.abs(totalB);
		max = Math.max(max, totalA);
		max = Math.max(max, totalB);
		
		System.out.println(max);
	}
	
	static int compareLong(long x, long y) {
		if (x == y) {
			return 0;
		} else if (x < y) {
			return -1;
		} else {
			return 1;
		}
	}
	
	static class Cake {
		long x;
		long y;
		long z;
		public Cake(long x, long y, long z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
	}
}


Measured memory_bytes: 26124
from collections import Counter

n = int(input())
seq = [int(x) for x in input().split()]
c = Counter(seq)
d = dict()
total = 0
for val in c:
    d[(val,0)] = ((c[val]-1) * (c[val]-1- 1)) >> 1
    d[(val,1)] = (c[val] * (c[val]- 1)) >> 1
    total += d[(val,1)]

for i in range(n):
    val = seq[i]
    print(total - d[(val,1)] + d[(val,0)])

Measured memory_bytes: 111436
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n; i++)
#define all(v) (v).begin(), (v).end()
#define decimal fixed << setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
const int INF = 1e9;
const LL LLINF = 1e16;

template< int mod >
struct ModInt
{
  int x;

  ModInt() : x(0) {}

  ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p)
  {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p)
  {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p)
  {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p)
  {
    *this *= p.inverse();
    return *this;
  }

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

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const
  {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }

  friend ostream &operator<<(ostream &os, const ModInt< mod > &p)
  {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt< mod > &a)
  {
    long long x;
    is >> x;
    a = ModInt< mod >(x);
    return (is);
  }

};

const int mod = 1e9 + 7;
using modint = ModInt< mod >;


    int ct[26];
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(auto &S: s){
        ct[S%26]++;
    }
    modint ans = 1;
    rep(i, 26){
        ans *= ct[i]+1;
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  string s;cin >> s;
  vector<int> b(n+1),w(n+1);
  for(int i=0;i<n;i++){
    if(s[i]=='#'){
      b[i+1]++;
    }
    else{
      w[i]++;
    }
  }
  for(int i=0;i<n;i++){
    b[i+1]+=b[i];
  }
  for(int i=n-1;i>=0;i--){
    w[i]+=w[i+1];
  }
  int ans=1e6;
  for(int i=0;i<=n;i++){
    ans=min(ans,b[i]+w[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0520-input.txt"));

		while (scan.hasNext()) {
			int m = scan.nextInt();

			if (m == 0)
				break;
			Cnstl c = new Cnstl(m);
			for (int i = 0; i < m; i++)
				c.add(i, scan.nextInt(), scan.nextInt());

			int n = scan.nextInt();
			Map map = new Map(n);
			for (int i = 0; i < n; i++)
				map.add(scan.nextInt(), scan.nextInt());

			map.sort();

			Map.Point v = map.search(c);
			System.out.println(v.x + " " + v.y);
		}
		scan.close();
		System.exit(0);
	}
}

class Map {
	class Point {
		int x;
		int y;

		public Point(int _x, int _y) {
			x = _x;
			y = _y;
		}
	}

	class Pcomp implements Comparator<Point> {
		@Override
		public int compare(Point o1, Point o2) {
			if (o1.x > o2.x)
				return 1;
			else if (o1.x == o2.x)
				return 0;
			else
				return -1;
		}

	}

	List<Point> p = new ArrayList<Point>();

	public Map(int n) {
	}

	public Point search(Cnstl c) {
		for (int i = 0; i < p.size(); i++) {
			int dx = p.get(i).x - c.getX(0);
			int dy = p.get(i).y - c.getY(0);
			if (this.match(c, dx, dy)) {
				return (new Point(dx, dy));
			}
		}
		return null;
	}

	private boolean match(Cnstl c, int dx, int dy) {
		for (int i = 1; i < c.size(); i++)
			if (c.getX(i) + dx < 0 || c.getX(i) + dx > 1000000 || c.getY(i) + dy < 0 || c.getY(i) + dy > 1000000)
				return false;
		for (int i = 1; i < c.size(); i++)
			if (!this.exist(c.getX(i) + dx, c.getY(i) + dy))
				return false;
		return true;
	}

	private boolean exist(int x, int y) {
/*		int si = p.size() / 2;
		int sd = si / 2;
		for (; sd > 5; sd /= 2)
			if (p.get(si).x > x)
				si -= sd;
			else
				si += sd;
*/
		for (int i = 0; i < p.size(); i++)
			if (p.get(i).x == x && p.get(i).y == y)
				return true;
		return false;
	}

	public void sort() {
		Collections.sort(p, new Pcomp());
	}

	public void add(int x, int y) {
		p.add(new Point(x, y));
	}

}

class Cnstl {
	private int[] x;
	private int[] y;

	public Cnstl(int m) {
		x = new int[m];
		y = new int[m];
	}

	public int size() {
		return x.length;
	}

	public int getX(int i) {
		return x[i];
	}

	public int getY(int i) {
		return y[i];
	}

	public void add(int i, int _x, int _y) {
		x[i] = _x;
		y[i] = _y;
	}

}

Measured memory_bytes: 38444
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MO=1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<endl;}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
const int MAXN=86+1;
int dp[MAXN];
void pre_lucas(){
   dp[0]=2;dp[1]=1;
   for(int i=2;i<MAXN;i++)
   	dp[i]=dp[i-1]+dp[i-2];
}
void solve(){
  pre_lucas();
  int n;
  cin>>n;
  cout<<dp[n]<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

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

int dp[105][2][4];

int main(){
  string s;
  int x;
  cin>>s>>x;
  int n=s.size();
  dp[0][0][0]=1;
  for(int i=0; i<n; ++i){
    int D=s[i]-'0';
    for(int j=0; j<2; ++j){
      for(int k=0; k<=x; ++k){
        for(int d=0; d<=(j?9:D); ++d){
          if(k+(d!=0)>x)continue;
          dp[i+1][j||(d<D)][k+(d!=0)]+=dp[i][j][k];
        }
      }
    }
  }
  cout<<dp[n][0][x]+dp[n][1][x]<<endl;
}

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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

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

    X = max(X, -X);
    
    ll ans = X;
    if(X / D >= K) ans -= D*K;
    else{
        ans = X % D;
        ll tmp_K = K - X/D;
        if(tmp_K%2) ans -= D;
    }

    ans = max(ans, -ans);

    cout << ans << endl;
}


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

int n;
int a[3][303];
int x;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2;i++){
        for(int j=1;j<=n;j++){
            scanf("%d",&x);
            a[i][j] = max(a[i-1][j],a[i][j-1]) + x;
        }
    }
    printf("%d\n", a[2][n]);
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> v(n, k - q);
    for(int i=0; i<q; ++i){
        int a;
        cin >> a;
        ++ v[a-1];
    }

    for(int i=0; i<n; ++i){
        if(v[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
let max_m = 2000

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let make_dp a n =
  let dp = Array.make_matrix (n + 1) (max_m + 1) false in
  for i = 1 to n do
    dp.(i).(a.(i-1)) <- true
  done;
  for i = 1 to n do
    for j = 1 to max_m do
      if dp.(i-1).(j) then dp.(i).(j) <- true
      else if j > a.(i-1) && dp.(i-1).(j-a.(i-1)) then dp.(i).(j) <- true;
    done;
  done;
  dp

let () =
  let read_ns () = read_line () |> split_on_char ' ' |> List.map int_of_string in
  let n = read_int () in
  let a = read_ns () |> Array.of_list in
  let _ = read_int () in
  let dp = make_dp a n in
  let m = read_ns () in
  List.iter (fun e -> print_endline (if dp.(n).(e) then "yes" else "no")) m

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

int main(){
    int M, K;
    cin >> M >> K;
    int x = 0;
    int maxX = pow(2, M) - 1;
    if(M < 2){
        if(K == 0){
            rep(i, pow(2, M+1)){
            cout << i/2 << " ";
            }
            cout << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(maxX < K){
        cout << -1 << endl;
        return 0;
    }

    if(K == 0){
        rep(i, pow(2, M+1)){
        cout << i/2 << " ";
        }
        cout << endl;
        return 0;
    }

    vector<int> ans;
    ans.push_back(0);
    ans.push_back(K);
    ans.push_back(0);
    for(int i = 1;i <= maxX; i++){
        if(i == K) continue;
        ans.push_back(i);
    }
    ans.push_back(K);
    for(int i = maxX;i > 0;i--){
        if(i == K) continue;
        ans.push_back(i);
    }

    for(auto i : ans){
        cout << i << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 4776
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    s = input()
    f_flag=0
    
    for i in range(len(s)):
        if i%2 == 0:
            if s[i] == "L":
                f_flag=1
        else:
            if s[i] == "R":
                f_flag=1

    if f_flag==0:
        print("Yes")
    else :
        print("No")
        
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 67564