akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int c[3];

  for(int i=0;i<3;++i) cin >> c[i];
  sort(c,c+3);
  cout << (c[2]==c[1]+c[0]?"Yes":"No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0  //未访问节点
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
	int v;
	color[u]=GRAY;
	d[u]=++tt;
	for(v=0;v<n;v++)
	{
		if(M[u][v]==0)
			continue;
		if(color[v]==WHITE)
			dfs_visit(v);	
	}	
	color[u]=BLACK;
	f[u]=++tt;
} 

void dfs()
{
	int u;
	for(u=0;u<n;u++)
	{
		color[u]=WHITE;
	}
	tt=0;
	for(u=0;u<n;u++)
	{
		if(color[u]==WHITE)
			dfs_visit(u);
	}
	for(u=0;u<n;u++)
	{
		printf("%d %d %d\n",u+1,d[u],f[u]);
	}
}
int main()
{
	int u,v,k,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
			M[i][j]=0;
	}
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&u,&k);
		u--;
		for(j=0;j<k;j++)
		{
			scanf("%d",&v);
			v--;
			M[u][v]=1;
		}
	}
	dfs();
	return 0;
}



Measured memory_bytes: 2776
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for i := 1; ; i++ {
		sc.Scan()
		s := sc.Text()

		ns := strings.Split(s, " ")

		a, _ := strconv.Atoi(ns[0])
		b, _ := strconv.Atoi(ns[1])

		if a == 0 && b == 0 {
			return
		}

		if a < b {
			fmt.Printf("%d %d\n", a, b)
		} else {
			fmt.Printf("%d %d\n", b, a)
		}
	}
}



Measured memory_bytes: 1184
#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>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
bool table[1025][1025];
int main(){
    int h,w;cin >> h >> w;
    int ch,cw,dh,dw; cin >> ch >> cw >> dh >> dw;
    ch--,cw--,dh--,dw--;
    vector<string> S(h);
    vector<vector<int>> dis(h,vector<int>(w)); 
    rep(i,h) cin >> S[i];
    rep(i,h)rep(j,w){   
        dis[i][j] = -1;
        if(S[i][j]=='#') dis[i][j] = -2;
    }
    dis[ch][cw] = 0;
    deque<P> que;
    que.push_front(P(ch,cw));
    while(!que.empty()){
        int th=que.front().first,tw=que.front().second;que.pop_front();
        if(table[th][tw]) continue;
        table[th][tw]=true;
        for(int i=0;i<4;i++){
            int nh = th + dx[i];
            int nw = tw + dy[i];
            if(nh < 0 || nw < 0 || nh >= h || nw >= w) continue;
            if(S[nh][nw] == '#') continue;
            if(dis[nh][nw]== -1 || dis[nh][nw] > dis[th][tw]){
                dis[nh][nw] = dis[th][tw];
                que.push_front(P(nh,nw));
            }
        }
        for(int i=-2;i<=2;i++){
            for(int j=-2;j<=2;j++){
                int nh = th + i;
                int nw = tw + j;
                if(nh < 0 || nw < 0 || nh >= h || nw >= w) continue;
                if(S[nh][nw] == '#') continue;
                if(dis[nh][nw]== -1 || dis[nh][nw] > dis[th][tw]){
                    dis[nh][nw] = dis[th][tw]+1;
                    que.push_back(P(nh,nw));
                }
            }
        }  
    }
    // rep(i,h){   
    //     rep(j,w){
    //         cout << dis[i][j];
    //     }
    //     cout << endl;
    // }
    cout << dis[dh][dw] << endl;
    return 0;
}


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


int main(){
  int n;
  cin >> n;
  ll ans = 0;
  vector<int> d(n+1);
  for(int i=1; i<=n; i++){
    for (int j=i; j<=n; j+=i){
      d[j]++;
    }
  }
  for(int i=1; i<=n; i++) ans += ll(i) * d[i];
  cout << ans << endl;
}


Measured memory_bytes: 42324
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> l(m);
    vector<int> r(m);
    for (int i = 0; i < m; i++){
        cin >> l[i] >> r[i];
    }

    int max = n + 1;
    int min = -1;
    for (int i = 0; i < m; i++)
    {
        if(l[i] > min)
            min = l[i];
        if(r[i] < max)
            max = r[i];
    }

    int ans;
    ans = max - min + 1;
    if (ans > 0)
        cout << ans << endl;
    else
        cout << "0" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int i, x;
  
  for(int i = 0; i < 5; i++){
    cin >> x;
    if(x == 0){
      cout << i + 1 << endl;
      break;
    }
  }
}

Measured memory_bytes: 3528
import java.util.Scanner;

public class Main {

    static final String ZERO = "0";

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

        String str;
        for (int i = 1; sc.hasNext(); i++) {
            str = sc.nextLine();
            if (ZERO.equals(str)) {
                break;
            }
            sb.append("Case " + i + ": " + str + "\n");
        }

        System.out.print(sb);
    }
}

Measured memory_bytes: 52348
#include <iostream>
#include <cstdio>
#include <algorithm>

template <typename Tp>
inline void read(Tp &x) {
    x = 0;
    bool f = true; char ch = getchar();
    for ( ; ch < '0' || ch > '9'; ch = getchar()) f ^= ch == '-';
    for ( ; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (ch ^ 48);
    x = f ? x : -x;
}

const int N = 2e5 + 7, M = 4e3 + 7, P = 1e9 + 7;

int A[N], B[N], F[M][M], Fac[M * 2], iFac[M * 2];

inline int Power(int a, int x) {
    int res = 1;
    while (x) {
        if (x & 1) res = 1LL * res * a % P;
        a = 1LL * a * a % P;
        x >>= 1;
    }
    return res;
}

inline int Inv(int x) {
    return Power(x, P - 2);
}

inline int C(int n, int m) {
    if (m < 0 || m > n) return 0;
    return 1LL * Fac[n] * iFac[n - m] % P * iFac[m] % P;
}

int main() {
    Fac[0] = 1;
    for (int i = 1; i < M * 2; ++i) Fac[i] = 1LL * Fac[i - 1] * i % P;
    iFac[2 * M - 1] = Inv(Fac[2 * M - 1]);
    for (int i = 2 * M - 2; i >= 0; --i) iFac[i] = 1LL * iFac[i + 1] * (i + 1) % P;    
    int n;
    read(n);
    for (int i = 1; i <= n; ++i) read(A[i]), read(B[i]), ++F[-A[i] + M / 2][-B[i] + M / 2];
    for (int i = 1; i < M; ++i)
        for (int j = 1; j < M; ++j) F[i][j] = (1LL * F[i][j] + F[i - 1][j] + F[i][j - 1]) % P;
    int Ans = 0;
    for (int i = 1; i <= n; ++i) {
        Ans = (Ans + F[A[i] + M / 2][B[i] + M / 2]) % P;
        Ans = (Ans + P - C(2 * (A[i] + B[i]), 2 * A[i])) % P;
    }
    printf("%lld\n", 1LL * Ans * Inv(2) % P);
    return 0;
}

Measured memory_bytes: 68096
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    x = int(input())

    i = 1
    while True:
        if i * (i + 1) // 2 >= x:
            print(i)
            break
        i += 1

if __name__ == '__main__':
    main()
    

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

int main(){
  int k,n,t;
  cin >> k >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);}
  t = vec.at(1)-vec.at(0);
  for(int i=0;i<n-1;i++){
     if(vec.at(i+1)-vec.at(i)>t){
      t = vec.at(i+1)-vec.at(i);}
  }
    if(vec.at(0)+k-vec.at(n-1)>t){
      t = vec.at(0)+k-vec.at(n-1);}
  cout << k-t << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream> 
using namespace std;
#include <algorithm>
typedef long long ll;
ll minn = 1e9;
int main()
{
	ll h,w;
	cin>>h>>w;
	
	for(ll i = 1;i <h;i++){
		ll tmps = i * w;
		ll pos = (h - i)/2;
		ll tmps1 = pos*w;
		
		ll tmps2 = (h - i -pos)*w;
		
		ll mins = min({tmps1,tmps2,tmps});
		
		ll maxs = max({tmps,tmps2,tmps1});
		minn = min({minn,maxs-mins});
		
		pos = w/2;
		
		tmps1 = pos*(h-i);
		
		tmps2 = (w- pos)*(h-i);
		
		mins = min(min(tmps, tmps1), tmps2);
		maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	}
	
		for (ll i = 1; i < w; i++) {
		ll tmps = i * h;
		ll pos = (w - i) / 2;
		ll tmps1 = (pos)*h;
		ll tmps2 = (w - i - pos)*h;
		ll mins = min(min(tmps, tmps1), tmps2);
		ll maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	//	cout << minn << endl;
		pos = h / 2;
		tmps1 = (w - i)*pos;
		tmps2 = (w - i)*(h - pos);
		mins = min(min(tmps, tmps1), tmps2);
		maxs = max(max(tmps, tmps2), tmps1);
		minn = min(minn, maxs - mins);
	//	cout << minn << endl;
	}
	cout << minn << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n,i,j,count;
    int prime[168]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229 ,233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
    while(scanf("%d",&n)!=EOF){
        count=0;
        for(i=2; i<=n; i++){
            j=0;
            while((prime[j]*prime[j])<=i){
                if((i%prime[j])==0 && (i/prime[j])!=1){
                    count--;
                    break;
                }
                j++;
            }
            count++;
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int D;
int C[26];
int S[365][26];
int T[365];

int last[26];
ll s = 0LL;

void score()
{
  REP(i,D){
    s += S[i][T[i]];
    last[T[i]] = (i+1);
    REP(j,26){
      s -= C[j] * (i+1-last[j]);
    }
    cout << s << '\n';
  }
}

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

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];
  REP(i,D){ 
    cin >> T[i];
    T[i]--;
  }
  score();
  return 0;
}


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

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010, mod = 1e9 + 7;

int n;
char s[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	int cnt = 0, res = 0;
	for (int i = 1; i <= n; i ++ )
		if (s[i] == '1')
		{
			res = (res + (LL)qp(2, cnt) * qp(3, n - i) % mod) % mod;
			cnt ++ ;
		}
	res = (res + qp(2, cnt)) % mod;
	
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 384
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =5e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
//c>b>a
int main()
{
	int a,b,c,k;int ans=0;
	scanf("%d %d %d %d",&a,&b,&c,&k);
	while(a>=b)
	{
		b*=2;
		ans++;
	}
	while(b>=c)
	{
		c*=2;
		ans++;
	}
	if(ans<=k) printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        for(int i = 1; i < N; i++) {
            int v = sc.nextInt();
            ++arr[v-1];
        }
        for(int i = 0; i < N; i++) {
            System.out.println(arr[i]);
        }
    }
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;


int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll q, h, s, d;
	ll n;
	cin >> q >> h >> s >> d;
	cin >> n;

	ll ans = 0;
	ans += (n/2) * min(d, min(2*s, min(4*h, 8*q)));
	ans += (n%2) * min(s, min(2*h, 4*q));

	cout << ans << endl;
	


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
 public static void main(String[] args)
    {
        int m1;
        int d1;
        int m2;
        int d2;
        Scanner scan1 = new Scanner(System.in);
        m1 = scan1.nextInt();
        d1 = scan1.nextInt();
        m2 = scan1.nextInt();
        d2 = scan1.nextInt();
        
        if( m1==4 || m1==6 || m1==9 || m1==11)
            if(d1 == 30)
                System.out.println('1');
             else
                 System.out.println('0');
        
        else if(m1==2)
            if(d1 == 28)
               System.out.println('1');
            else
                System.out.println('0');
        
        else
            if(d1 == 31)
               System.out.println('1');
            else
                System.out.println('0');
    }
}


Measured memory_bytes: 24020
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int i, k, s, j, p, t=0;
	cin >> k;
	cin >> s;
	for (i = 0; i <= k; i++) {
		for (j = 0; j <= k; j++) {
				if (s-(i+j)<=k&&s-(i+j)>=0){
					t++;
				}
			}
		}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3604
use std::io::*;
use std::str::FromStr;

const MOD: i64 = 1_000_000_007;

fn mod_pow(x: i64, n: i64, mod_: i64) -> i64 {
    if n > 0 {
        mod_pow(x * x % mod_, n >> 1, mod_) * if n & 1 == 1 { x } else { 1_i64 } % mod_
    } else {
        1_i64
    }
}

struct ModCulc {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
    mod_: i64,
}

impl ModCulc {
    fn new(n: usize, mod_: i64) -> Self {
        let mut f: Vec<i64> = vec![1; n];
        let mut f_i: Vec<i64> = vec![1; n];
        for i in 1..n {
            f[i] = (f[i - 1] * i as i64) % mod_;
            f_i[i] = mod_pow(f[i], mod_ - 2, mod_);
        }
        ModCulc {
            fact: f,
            fact_inv: f_i,
            mod_: mod_,
        }
    }

    fn nCr(&self, n: usize, r: usize) -> i64 {
        ((self.fact[n] * self.fact_inv[r]) % self.mod_ * self.fact_inv[n - r]) % self.mod_
    }
}

fn main() {
    let x: usize = read();
    let y: usize = read();

    if (x + y) % 3 != 0 {
        println!("0");
        return;
    } else {
        let turn = (x + y) / 3;
        if turn > x || turn > y {
            println!("0");
            return;
        }
        let dx = x - turn;
        let dy = y - turn;
        let mc = ModCulc::new(dx+dy+1, MOD);
        println!("{}", mc.nCr(dx+dy, dx));
    }
}

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


Measured memory_bytes: 16636
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct */
struct treasureBox {
    int price;
    int keys;
};
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<treasureBox> B(K);
    for (int i = 0; i < K; i++) {
        int p, m;
        cin >> p >> m;
        B[i].price = p;
        B[i].keys = 0;
        for (int j = 0; j < m; j++) {
            int k; cin >> k;
            k--;
            B[i].keys += (1 << k);
        }
    }

    // dp[s] : 状態sになるための最小円
    vector<int> dp(1<<N, INF);
    dp[0] = 0;
    for (int s = 0; s < 1<<N; s++) {
        for (int i = 0; i < K; i++) {
            int nextS = s | B[i].keys;
            int nextPrice = dp[s] + B[i].price;
            dp[nextS] = min(dp[nextS], nextPrice);
        }
    }
    int ans = dp[(1<<N)-1];
    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
}


Measured memory_bytes: 3652
var
	n,i:Longint;
	p:array[1..55]of Longint=(2,7,17,37,47,67,97,107,127,137,157,167,197,227,257,277,307,317,337,347,367,397,457,467,487,547,557,577,587,607,617,647,677,727,757,787,797,827,857,877,887,907,937,947,967,977,997,1087,1097,1117,1187,1217,1237,1277,1297);
begin
	read(n);
	for i:=1 to n do writeln(p[i]);
end.

Measured memory_bytes: 128
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a <= n - 1; ++a) {
    int bmax = (n - 1) / a;
    ans += bmax;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
typedef long int li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
#define Please return
#define AC 0


int main(){
  li h,w; cin >>h >> w;
  if(min(h,w)==1)cout << 1;
  else cout << (h*w+1)/2;
  
  Please AC;
}


Measured memory_bytes: 256
*,S = $<.read.split
X,Y,Z,t,a,b = [],[],[],0,S[0]
S.size.times {|i| if a == s=S[i]; X<<i elsif s == b||=s; Y<<i else Z<<i end }
[X,Y,Z].permutation {|x,y,z|
  b,ys,zs,s = 0,y.size,z.size,S[z[0]||0]
  x.each_with_index {|i,a|
    k = z[c=0]
    b += 1  until i < y[b]  rescue break
    b.upto(ys-1) {|b|
      l = (j=y[b])*2 - i
      k = z[c+=1]  until j < k  rescue break
      t += S[l]==s ? zs-c-1 : zs-c
    }
  }
}
p t

Measured memory_bytes: 14500
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d %d", &a,&b);

    int wa=a+b,sa=a-b,seki=a*b;
    int max=wa;
    if(sa>max){
        max=sa;
    }
    if(seki>max){
        max=seki;
    }
    printf("%d\n", max);
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;

#define MEM(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        cout << A[i] << " ";
    }
    cout << endl;
}

LL solve() {
    int n;
    cin >> n;

    LL res = 0;

    vector<int> A(n, 0);

    int cur = 0;

    FOR(i, 1, 101) {
        FOR(j, 1, 101) {
            FOR(k, 1, 101) {
                cur = i * i + j * j + k * k + i * j + i * k + j * k;
                if (cur > n) {
                    break;
                } else {
                    A[cur]++;
                }
            }
        }
    }

    FOR(i, 1, n+1) {
        cout << A[i] << endl;
    }

    return res;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();

    int t = 1;

    // cin >> t;

    for (int _ = t; _ > 0; _--) {
        solve();
        // cout << solve() << endl;
    }

    return 0;
}



Measured memory_bytes: 3596
// https://atcoder.jp/contests/abc157/submissions/10473664

object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start <= end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val n, m, k = sc.nextInt

	val friend, blocked = Array.fill(n+1)(0)
	val uf = UnionFind(1 to n)

	Seq.fill(m)((sc.nextInt, sc.nextInt)) foreach { case (a, b) =>
		uf.unite(a, b)
		friend(a) = friend(a) + 1
		friend(b) = friend(b) + 1
	}

	Seq.fill(k)((sc.nextInt, sc.nextInt)) foreach { case (c, d) =>
		if (uf.same(c,d)) {
			blocked(c) = blocked(c) + 1
			blocked(d) = blocked(d) + 1
		}
	}

	loop(1, n) { i =>
		pw.print( (uf.size(i) - 1 - friend(i) - blocked(i)).toString + " " )
	}
	pw.flush()
}

case class UnionFind[T](seq: Seq[T]) {
	import scala.collection.mutable.Map
	private[this] val par: Map[T, T] = Map[T,T](seq.map(elem => elem -> elem): _*)
	private[this] val sz: Map[T, Int] = Map[T, Int](seq.map(elem => elem -> 1): _*)

	@scala.annotation.tailrec
	private[this] def find(t: T, acc: Seq[T] = Nil): T = {
		val p = par(t)
		if (p == t) {acc foreach { par(_) = t }; t} else find(p, p +: acc)
	}

	def unite(a: T, b: T): Unit = {
		val pa = find(a)
		val pb = find(b)

		if (pa == pb) return

		if (sz(pa) <= sz(pb)) {
			par(pa) = pb
			sz(pb)  = sz(pa) + sz(pb)
		} else {
			par(pb) = pa
			sz(pa)  = sz(pa) + sz(pb)
		}
	}

	def same(a: T, b: T) = find(a) == find(b)

	def size(a: T) = sz(find(a))
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else { true }
  @inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte()
  }
  @inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else { -1 }

  def next(): String = {
    if(!hasNext()) ???
    val sb = new StringBuilder; var b = readByte()
    while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
    sb.toString
  }

  def nextInt(): Int = {
    val n = nextLong()
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }

  def nextLong(): Long = {
    if(!hasNext()) ???
    var minus = false; var b = readByte()
    if (b == '-') { minus = true; b = readByte() }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') { go(readByte(), n * 10 + b - '0') }
      else if (minus) { -n } else { n }
    go(b)
  }

  def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 137100
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll h, w;
ll a[501][501];
ll ans;
int main(){
    cin>>h>>w;
    REP(i, 0, h) REP(j, 0, w) cin>>a[i][j];

    REP(i, 0, h){
        REP(j, 0, w){
            if((i==0&&j==0) || (i==0&&j==w-1) || (i==h-1&&j==0) || (i==h-1&&j==w-1)){
                ans+=(a[i][j]*h*w);
            }
            else if(i==0 || i==h-1){
                ans+=(a[i][j]*(j+1)*(w-j)*h);
            }
            else if(j==0 || j==w-1){
                ans+=(a[i][j]*(i+1)*(h-i)*w);
            }
            else{
                ans+=(a[i][j]*(j+1)*(i+1)*(w-j)*(h-i));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  vsort(a);
  int ans=a[n-1]-a[0];
  cout(ans);
  return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = sorted([I() for _ in range(n)])
    b = sorted([I() for _ in range(n)])
    r = 1
    ai = 0
    bi = 0
    sa = 0
    while ai < n or bi < n:
        if ai >= n:
            if sa > 1:
                r *= sa
            sa -= 1
            bi += 1
        elif bi >= n:
            if sa < -1:
                r *= -sa
            sa += 1
            ai += 1
        elif a[ai] < b[bi]:
            if sa < -1:
                r *= -sa
            sa += 1
            ai += 1
        else:
            if sa > 1:
                r *= sa
            sa -= 1
            bi += 1
        r %= mod

    return r




print(main())



Measured memory_bytes: 14548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
const int maxn=404;
const ll modn=1e9+7;
const int inf=2e9+7;
const double PI = acos(-1.0);
const double eps=1e-8;
inline int lowbit(int x){return x&-x;}
inline ll lowbit(ll x) {return x&-x;}
inline int CountOneBinary(ll num){int ans=0;while(num){if(num&1) ans+=1;num>>=1;}return ans;}
inline void read(int &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline void read(ll &x){char c;x=0;for(c=getchar();c>'9'||c<'0';c=getchar());for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';}
inline ll qpow(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%modn;x=x*x%modn;y>>=1;}return ans;}
inline double qpow(double x,ll y){double ans=1;while(y){if(y&1) ans=ans*x;x=x*x;y>>=1;}return ans;}
ll n,c,a[maxn],b[maxn],x[maxn][maxn],dp[maxn][maxn],pre[maxn][maxn];
inline ll mod(const ll &tmp)
{
    return (tmp%modn+modn)%modn;
}
int main()
{
    for(ll i=1;i<maxn;i++)
    {
        x[i][0]=1;
        x[i][1]=i;
        for(ll j=2;j<maxn;j++) x[i][j]=x[i][j-1]*i%modn;
    }
    for(int i=1;i<maxn;i++)
    {
        for(int j=0;j<maxn;j++) pre[i][j]=(pre[i-1][j]+x[i][j])%modn;
    }
    while(scanf("%lld%lld",&n,&c)==2)
    {
        memset(dp,0,sizeof(dp));dp[0][0]=1;
        for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
        for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=c;j++)
            {
                for(int k=0;k<=j;k++)
                {
                    dp[i][j]=(dp[i][j]+dp[i-1][j-k]*mod(pre[b[i]][k]-pre[a[i]-1][k]))%modn;
                }
            }
        }
        printf("%lld\n",dp[n][c]);
    }
}//


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

int main()
{
  int a,b,c;
  cin >> a >> b;
  if(a > b){
    c = a;
    a = b;
    b = c;
  }

  for(int i=0; i<b; i++){
    cout << a;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

a, b, c = ril()
if a + b >= c:
    print(b + c)
else:
    print(a + 2 * b + 1)

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

using namespace std;

vector <int> prime;
bool isprime[300001];

void eratos(void)
{
	for(int i=2;i<=300000;i++)
	{
		if(isprime[i]==true)
		{
			if(i<=55555)
			{
				prime.push_back(i);
			}
			for(int j=2*i;j<=300000;j+=i)
			{
				isprime[j]=false;
			}
		}
	}
}
int main(void)
{
	int n;
	unordered_set <int> se;
	vector <int> res;
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> n;

	
	memset(isprime,true,sizeof(isprime));
	eratos();

	for(int i=0;i<prime.size();i++)
	{
		if(prime[i]%5==1)
		{
			res.push_back(prime[i]);
		}

		if(res.size()==n)
		{
			break;
		}
	}

	for(int i=0;i<res.size();i++)
	{
		cout << res[i] << ' ';
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <stdio.h>
#include <utility>
#include <map>
#include <set>
using namespace std;
#define LL long long;


int x, a;



int main() {

	cin >> x >> a;

	if (x < a) cout << "0" << endl;
	else cout << "10" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define sci(x) int x; scanf("%d", &x);
#define TC(x) sci(x); while(x--)
typedef long long ll;
using namespace std;
int main()
{
    int n;
    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        if(i%5!=0 && i%3!=0) sum+=i;
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long a, b, c;
	cin >> a >> b >> c;
	long long d = c - a - b;
	if (d < 0) {
		cout << "No" << endl;
		return 0;
	}
	if (4 * a * b < d * d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

unsigned long long str_to_int(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

void solve(){
	int n;
	cin >> n;
	int sum = 0,x = 0,y = 0;
	bool flag = true;
	rep(i,n){
		int a,b,c;
		cin >> a >> b >> c;
		if((abs(x-b)+abs(y-c))%2 != (a-sum)%2){
			flag = false;
		}
		if(a - sum < abs(x-b) + abs(y-c)){
			flag = false;
		}
		sum = a;
		x = b;
		y = c;
	}
	if(flag){
		P("Yes");
	}else{
		P("No");
	}
}

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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ExplodingFreeze
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define f(i,a,b) for(int i=(a);i<(b);i++)
const int MOD=1e9+7;
using pii=std::pair<int,int>;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

using namespace std;

int n,m;
class AACOrWA {
public:
	void solve(std::istream& in, std::ostream& out) {
		in >> n >>m;
		if(n==m)
			out << "Yes\n";
		else
			out << "No\n";
	}
};


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	AACOrWA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();

            return a.Max() - a.Min();
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int n;cin>>n;
  bool flag=false;
  int ans[5000][5000]={};
  int a,b;
  n*=2;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0&&(n/i==i+1)){
      a=n/i;b=i;
      flag=true;
      int num=n/i;
      int now=1;
      for(int j=0;j<i;j++){
	for(int k=j;k<i;k++){
	  ans[j][k]=now;
	  ans[k+1][j]=now;
	  now++;
	}
      }
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
    cout<<a<<endl;
    for(int i=0;i<a;i++){
      cout<<b<<" ";
      for(int j=0;j<b;j++){
	cout<<ans[i][j];
	if(j!=b-1)
	  cout<<" ";
      }
    cout<<endl;
  }

  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

int main() {
  int A;
  int B;
  int C;
  cin >> A >> B >> C;
  if (A == 7 ) {
    if(B == 5 && C == 5) {
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
  else if (A == 5 ) {
    if(B == 5 && C == 7) {
      cout << "YES" << endl;
    }
    else if(B == 7 && C == 5) {
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  }
   else{
     cout << " NO" << endl;
   }
 }

Measured memory_bytes: 256
def inv(x, ava):
    if x == 2:
        if 1 in ava:
            return 1
        else:
            return -1
    if x == 3:
        if 7 in ava:
            return 7
        else:
            return -1
    if x == 4:
        if 4 in ava:
            return 4
        else:
            return -1
    if x == 5:
        if 5 in ava:
            return 5
        if 3 in ava:
            return 3
        if 2 in ava:
            return 2
        else:
            return -1
    if x == 6:
        if 9 in ava:
            return 9
        if 6 in ava:
            return 6
        else:
            return -1
    if x == 7:
        if 8 in ava:
            return 8
        else:
            return -1
n, m = map(int, input().split())
ava = list(map(int, input().split()))
dp = [[] for _ in range(n+1)]
number = [inv(x,ava) for x in range(2,8)]
avapre = []
for i in range(6):
    if number[i] != -1:
        avapre.append(i+2)
avapresort = sorted(avapre,key = lambda x: number[x-2],reverse=True)
dp = [0 for _ in range(n+1)]
for i in range(1, n+1):
    if i < avapre[0]:
        dp[i] = -1
    else:
        dp[i] = -1
        for pre in avapre:
            if i - pre >= 0:
                dp[i] = max(dp[i], dp[i-pre]+1)
i = n
while(i > 0):
    for pre in avapresort:
        if i - pre >= 0 and dp[i] == dp[i-pre] + 1:
            print(number[pre-2], end='')
            i -= pre
            break
print()


Measured memory_bytes: 4340
import math
n, k = map(int, input().split())
a = [int(input()) for _ in [None]*n]

lb = max(a)
ub = lb * n

while True:
    mid = (ub+lb) // 2
    remain = k - 1
    cw = 0
    for w in a:
        cw += w
        if cw > mid:
            remain -= 1
            cw = w
        if remain < 0:
            break
    if remain < 0:
        if lb == mid:
            print(lb+1)
            break
        lb = mid
    else:
        if lb == mid:
            print(lb)
            break
        ub = mid

Measured memory_bytes: 12352
// Sun Apr 19 04:28:54 IST 2020          
#include <bits/stdc++.h>        
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- \n"
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define int64              long long    
#define MOD                998244353
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"  
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
#define precise(x)         cout << fixed << setprecision(12) << x << '\n'; 
using namespace std ;     
// using namespace __gnu_pbds;
// typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;   
int tests(){ 
  int n,d ;
  cin >> d ;
  int sum = 0 ;
  cin >> n ; 
  vector <int> a(n);
  for(auto &x :a)
  cin >> x,sum += x ;  
  if( d < sum )
    return cout << -1 << '\n',0;
  cout << d-sum << '\n';
  return  0; 
}
int32_t main(){
    I__O ;            
    int cases = 1 ; 
    // cin >> cases ;  
    for(int i = 1 ;i  <= cases ; i++ ){   
    // cout << "Case #" << i << ": ";
      tests(); 
    }
    return 0 ; 
}

// -Wall -Weptra -O2
// -pedantic -std=c++11
// -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
 
int main()
{
  string s;
  cin >> s;
  string ans = "Yes";
  map<char, int> mp;
  rep(i, s.size()) {
    mp[s[i]]++;
  }
  for (auto m: mp) {
    if (m.second%2==1) ans = "No";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <functional>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cctype>
using namespace std;
using node_t = function<int(int[3])>;
string S;
size_t cur = 0;

node_t parse() {
    char c = S[cur++];
    if (isdigit(c)) return [=](int[3]) { return c - '0'; };     // 定数関数
    if (isalpha(c)) return [=](int a[3]) { return a[c - 'P']; };
    node_t left = parse();
    if (c == '-') return [=](int a[3]) { return 2 - left(a); };             // NOT
    assert(c == '(');
    char op = S[cur++];
    node_t right = parse();
    ++cur;  // skip ')'
    if (op == '*') return [=](int a[3]) { return min(left(a), right(a)); }; // AND
    return [=](int a[3]) { return max(left(a), right(a)); };                // OR
}

int main() {
    while (cin >> S, S != ".") {
        int cnt = 0;
        cur = 0;
        auto tree = parse();
        for (int p : {0, 1, 2}) {
            for (int q : {0, 1, 2}) {
                for (int r : {0, 1, 2}) {
                    int a[] = {p, q, r};
                    if (tree(a) == 2) cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// }}} 1

int main() {

    char w[100];

    Scs(w);

    int cnt[256] = {};

    Rep( i , strlen(w)){
        cnt[w[i]]++;
    }

    bool a = true;

    Rep( i , 255 ){
        if( cnt[i] % 2 == 1 ) a = false;
    }

    a ? printf ("Yes\n") : printf("No\n");

    return 0;
}



Measured memory_bytes: 256
n,k = map(int,input().split())
a = [0] + list(map(int,input().split())) #1_indexed
tele = [1]
used = [False for i in range(n)]
while True:
    next_number = a[tele[len(tele)-1]]
    if not used[next_number-1]:
        tele.append(next_number)
        used[next_number-1] = True
    else:
        repeat = tele.index(next_number)
        tele_1 = tele[:repeat]
        tele_2 = tele[repeat:]
        break

if k < len(tele_1):
    print(tele_1[k])
else:
    k_new = (k-len(tele_1)+1) % len(tele_2)
    print(tele_2[k_new-1])

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

/*バーガーの構造*/
typedef struct {
  ll B = 0;  //バン
  ll P = 1;  //パティ
  ll A = 1;  //全部
} bur;

int N;
ll X;
bur Bur[51];  //バーガーレシピ

/*各レベルのバーガーレシピの作成*/
void make_Bur(int n){
  for(int i = 1; i <= n; i++) { 
    Bur[i].B = 2 * Bur[i-1].B + 2; 
    Bur[i].P = 2 * Bur[i-1].P + 1;
    Bur[i].A = Bur[i].B + Bur[i].P;
  }
  return ;
}

/*食った層の内訳(パティ)を返す*/
ll dsf(ll X, int l){
  if(X == 0) return 0;  //必要量食ったわ
  if(l == 0) return 1;  //食うとしても...どうあがいてもパティ
  if(X >= Bur[l].A/2+1) return Bur[l-1].P + 1 + dsf(X-Bur[l].A/2-1, l-1);  //半分以上食える
  if(X < Bur[l].A/2+1) return dsf(X-1, l-1);  //今のバーガーを半分も食えない
  return -1;
}

int main(){
  cin >> N >> X;
  make_Bur(N);
  cout << dsf(X, N) << endl;
  return 0;
}


Measured memory_bytes: 256
/***************************************************
 * Problem Name : D.cpp
 * Problem Link :
 * Contest Name :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2018-10-06
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cstring>
#include<string>
#include<sstream>
#include<cmath>
#include<vector>
#include<queue>
#include<cstdlib>
#include<deque>
#include<stack>
#include<map>
#include<set>
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define SET(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define pll pair <ll, ll>
#define debug cout <<"#########\n";
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define Pow2(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define Max3(a, b, c) max(a, max(b, c))
#define Min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
std::string NumberToString ( T Number ) {
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    ll n, m;
    cin >> n >> m;

    if (m % n == 0) {
        cout << m / n << "\n";

    } else {
        int x = m / n;
        int xx = m % n;

        if ( x % xx == 0) {
            cout << min (x, xx) << "\n";

        } else {
            ll mx = 0;

            for (ll i = 1; (i * n) <= m; i++) {
                if ( m % i == 0) {
                    mx = max (i, mx);
                }
            }

            cout << mx << "\n";
        }

        //~ int x = min (m / n, m % n);
        //~ cout << "1" << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#input
N = int(input())

#temp
while(1):
  #temp=N
  #2
  temp1 = N/1
  if(temp1<=9 and N%1==0):
    print('Yes')
    break
  temp2 = N/2
  if(temp2<=9 and N%2==0):
    print('Yes')
    break
  temp3 = N/3
  if(temp3<=9 and N%3==0):
    print('Yes')
    break
  temp4 = N/4
  if(temp4<=9 and N%4==0):
    print('Yes')
    break
  temp5 = N/5
  if(temp5<=9 and N%5==0):
    print('Yes')
    break
  temp6 = N/6
  if(temp6<=9 and N%6==0):
    print('Yes')
    break
  temp7 = N/7
  if(temp7<=9 and N%7==0):
    print('Yes')
    break
  temp8 = N/8
  if(temp8<=9 and N%8==0):
    print('Yes')
    break
  temp9 = N/9
  if(temp9<=9 and N%9==0):
    print('Yes')
    break
  
  print('No')
  break

#print('result')
#if answer 
#
#print(N)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define int64 long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    int A, B, C;
    cin >> A >> B >> C;
    if(A <= C && C <= B) cout << "Yes";
    else if (A >= C && C >= B) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << '\n';
    }

    return 0;
}

Measured memory_bytes: 888