akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

ll gcd(ll x, ll y) {
    if (x > y) swap(x, y);
    ll m = 1;
    while (m != 0) {
        m = y % x;
        y = x;
        x = m;
    }
    return y;
}

int main() {
    int h, w, n, sy, sx;
    cin >> h >> w >> n >> sy >> sx;

    sy--;
    sx--;

    string s, t;
    cin >> s >> t;

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

    int l = 0, r = w - 1, u = 0, d = h - 1;

    rep(i, n) {
        if (i == 0) {
            char c = s[0];
            if (c == 'L') l++;
            else if (c == 'R') r--;
            else if (c == 'U') u++;
            else if (c == 'D') d--;
        } else {
            char tc = t[i], sc = s[i];
            if (tc == 'L') {
                r = min(w - 1, r + 1);
            } else if (tc == 'R') {
                l = max(0, l - 1);
            } else if (tc == 'U') {
                d = min(h - 1, d + 1);
            } else if (tc == 'D') {
                u = max(0, u - 1);
            }
            if (sc == 'L') {
                l++;
            } else if (sc == 'R') {
                r--;
            } else if (sc == 'U') {
                u++;
            } else if (sc == 'D') {
                d--;
            }
            if (l > r || u > d) {
                cout << "NO" << endl;
                ret();
            }
        }
    }
    if (l <= sx && sx <= r && u <= sy && sy <= d) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a,b;cin>>a>>b;
    int m=max(a-b,a+b);
    cout<<max(m,a*b)<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans = 1,r = 1;
    ll a;
    rep(i,n){
        r *= 3;
        cin >> a;
        if (a%2 == 0) ans *= 2;
    }
    PRINT(r-ans);
}


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

int a[3][3];
int main() {
    for(int i = 0; i < 3; i++)
        for(int j = 0; j < 3; j++)
            cin >> a[i][j];
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(a[j][k] == b)
                    a[j][k] = 0;
    }
    int r = 1;
    for(int i = 0; i < 3; i++) {
        r *= a[i][0] + a[i][1] + a[i][2], r *= a[0][i] + a[1][i] + a[2][i];
        r = !!r;
    }
    r *= a[0][0] + a[1][1] + a[2][2];
    r *= a[0][2] + a[1][1] + a[2][0];
    cout << (r ? "No" : "Yes") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M,W=0,R=0;
	cin >> N;
	vector<string> s(N);
	for (int i=0; i<N; i++){
		cin >> s.at(i);
	}
	cin >> M;
	vector<string> t(M);
	for (int i=0; i<M; i++){
		cin >> t.at(i);
	}
	
	for (int i=0; i<N; i++){
		W = 0;
		for (int j=i; j<N; j++){
			if (s.at(i) == s.at(j)){
				W++;
			}
		}
		for (int k=0; k<M; k++){
			if (s.at(i) == t.at(k)){
				W--;
			}
		}		
		if (W > R) {
			R = W;
		}
	}
	cout << R << endl;
}
	

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i,j;
  int z,z3;
  int max,tmp;

  while(1){
    scanf("%d",&z);
    if(!z)break;

    max = 0;
    z3 = z*z*z;
    for(i=z-1;i>0;i--){
      for(j=i;j>0;j--){
	tmp = i*i*i + j*j*j;
	if(tmp > max && tmp <= z3)max = tmp;
      }
    }

    printf("%d\n",z3 - max);

  }

  return 0;
}

Measured memory_bytes: 408
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define LL inline ll
#define I inline int
#define V inline void
#define B inline bool
#define ll long long int
#define isnum(ch) ('0'<=ch&&ch<='9')
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define ROF(i,a,b) for(rnt i=a;i>=b;i--)
#define gc (_op==_ed&&(_ed=(_op=_buf)+fread(_buf,1,100000,stdin),_op==_ed)?EOF:*_op++)
char _buf[100000],*_op(_buf),*_ed(_buf);
I getint(){
	rnt _s=0;re char _ch=gc;
	while(!isnum(_ch))_ch=gc;
	while(isnum(_ch))_s=_s*10+_ch-48,_ch=gc;
	return _s;
}
const int N=1e5+1;
int n,m,rt,tot;
struct opt{
	int l,r,w;
	V input(){l=getint(),r=getint(),w=getint();}
	B operator<(const opt&u)const{return l<u.l;}
}q[N];
V input(){
	n=getint(),m=getint();
	FOR(i,1,m)q[i].input();
}
LL min(const ll&x,const ll&y){return x<y?x:y;}
struct ele{
	int ls,rs;ll tag,minn;
	V up(ll x){tag=min(tag,x),minn=min(minn,x);}
}t[N<<1];
#define lc t[p].ls
#define rc t[p].rs
#define lson lc,L,mid
#define rson rc,mid+1,R
V build(int&p,rnt L,rnt R){
	p=++tot,t[p].tag=t[p].minn=1ll<<60;
	if(L==R)return;
	rnt mid=L+R>>1;
	build(lson),build(rson);
}
V solve(rnt p){t[lc].up(t[p].tag),t[rc].up(t[p].tag);}
V modify(rnt p,rnt L,rnt R,rnt l,rnt r,ll w){
	t[p].minn=min(t[p].minn,w);
	if(L==l&&R==r)return t[p].up(w);
	solve(p);rnt mid=L+R>>1;
	if(r<=mid)modify(lson,l,r,w);
	else if(l>mid)modify(rson,l,r,w);
	else modify(lson,l,mid,w),modify(rson,mid+1,r,w);
}
LL ask(rnt p,rnt L,rnt R,rnt l,rnt r){
	if(L==l&&R==r)return t[p].minn;
	solve(p);rnt mid=L+R>>1;
	if(r<=mid)return ask(lson,l,r);
	if(l>mid)return ask(rson,l,r);
	return min(ask(lson,l,mid),ask(rson,mid+1,r));
}
V init(){build(rt,1,n),modify(rt,1,n,1,1,0),sort(q+1,q+1+m);}
V work(){
	FOR(i,1,m){
		ll x=ask(rt,1,n,q[i].l,q[i].r);
		modify(rt,1,n,q[i].l,q[i].r,x+q[i].w);
	}
	ll ans=ask(rt,1,n,n,n);
	if(ans>=(1ll<<60))
		cout<<"-1";
	else cout<<ans;
}
int main(){
	input();
	init();
	work();
	return 0;
}

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main() {
	int n,m,i,x,y,pd=0;
	cin>>n>>m;
	for (i=1; i<=m; i++) {
		cin>>x>>y;
		if(a[x]&&a[x]!=y || x==1&&y==0&&n!=1) {
			pd=1;
			cout<<"-1";
			break;
		}
		a[x]=y;
	}
	if (pd==0) {
		if (a[1]==0&&n!=1)
		    a[1]=1;
		for (i=1; i<=n; i++) {
			cout<<a[i];
		}
	}
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;

class Main{
	static final int nbits = 64;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String[] str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		BitSet bs = new BitSet(nbits);
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			if(op >= 0 && op <= 3){
				int pos = Integer.parseInt(str[1]);
				if(op == 0){
					pw.println(bs.get(pos) ? 1 : 0);
				}else if(op == 1){
					bs.set(pos);
				}else if(op == 2){
					bs.clear(pos);
				}else{
					bs.flip(pos);
				}
			}else{
				if(op == 4){
					boolean flag = true;
					for(int j = 0; j < nbits; j++) flag &= bs.get(j);
					pw.println(flag ? 1 : 0);
				}else if(op == 5){
					pw.println(!bs.isEmpty() ? 1 : 0);
				}else if(op == 6){
					pw.println(bs.isEmpty() ? 1 : 0);
				}else if(op == 7){
					int cnt = 0;
					for(int j = 0; j < nbits; j++){
						if(bs.get(j)) cnt++;
					}
					pw.println(cnt);
				}else{
					BigInteger sum = BigInteger.ZERO;
					BigInteger pow2 = BigInteger.ONE;
					BigInteger TWO = BigInteger.ONE.add(BigInteger.ONE);
					for(int j = 0; j < nbits; j++){
						if(bs.get(j)) sum = sum.add(pow2);
						pow2 = pow2.multiply(TWO);
					}
					pw.println(sum);
				}
			}
		}
		pw.close();
	}
}



Measured memory_bytes: 95692
using System;
using System.Collections.Generic;
using System.Globalization;

enum occupant
{
build, floor, room, number
}

class Program
 {



    static void Main(string[] args)
    {
        string nyuryoku;


        nyuryoku = Console.ReadLine();

        string word = nyuryoku;
        string text ="";
        while (true)
        {
            nyuryoku = Console.ReadLine();
            if (nyuryoku == "END_OF_TEXT")
                break;
            text = text + nyuryoku + "\n";

        }
        int result = 0,index = 0;
        while (true)
        {
            index = text.IndexOf(word, index, StringComparison.CurrentCultureIgnoreCase);
            if (index < 0)
                break;
            if (index == 0)
            {
                if (text[index + word.Length] == ' ' | text[index + word.Length] == '\n')
                    result++;
            }
            else
            {
                if (text[index - 1] == ' ' | text[index - 1] == '\n')
                    if (text[index + word.Length] == ' ' | text[index + word.Length] == '\n')
                        result++;
            }

            index = index + word.Length + 1;
            if (index >= text.Length)
                break;
        }
        Console.WriteLine("{0}", result);
    }

 }



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

using namespace std;

using ll = long long;
const int mod = 1000000007;
int N;
const int maxn = 21;

void add(int &a, int b) {
	a = (a+b)%mod;
}

int mult(int a, int b) {
	return a*1LL*b % mod;
}

bool ok[maxn][maxn];
vector<int> msk[maxn];
int dp[1 << 21];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> ok[i][j];
		}
	}
	dp[0] = 1;

	for (int i = 1; i < (1 << N); i++) {
		msk[__builtin_popcount(i)-1].push_back(i);
	}

	for (int i = 0; i < N; i++) {
		for (int cur : msk[i]) {
			for (int j = 0; j < N; j++) {
				if (ok[i][j] && (cur & (1 << j)) ) {
					add(dp[cur], dp[cur - (1 << j)]);
				}
			}
		}
	}

	cout << dp[(1 << N) - 1] << endl;

}

Measured memory_bytes: 17852
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
#define MOD 1000000007

ll m[200010],p[200010];
int mcnt,pcnt;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		if(t>=0)p[pcnt++]=t;
		else m[mcnt++]=-t;
	}
	sortup(m,mcnt);
	sortup(p,pcnt);
	
	//K==Nのとき
	if(k==n){
		ll ans=1;
		rep(i,0,mcnt)ans=ans*(MOD-m[i])%MOD;
		rep(i,0,pcnt)ans=ans*p[i]%MOD;
		printf("%lld",ans);
		return 0;
	}
	
	//Kが奇数かつ負のみのとき
	if(k%2==1&&mcnt==n){
		ll ans=1;
		rep(i,0,k)ans=ans*(MOD-m[i])%MOD;		
		printf("%lld",ans);
		return 0;
	}
	
	ll ans=1;
	while(k){
		if(k>=2 && mcnt>=2 &&(pcnt<=1 || (pcnt>=2 && m[mcnt-1]*m[mcnt-2]>=p[pcnt-1]*p[pcnt-2]))){
			ans=ans*m[--mcnt]%MOD;
			ans=ans*m[--mcnt]%MOD;
			k-=2;
		}else{
			ans=ans*p[--pcnt]%MOD;
			k--;
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4016
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

t = 0
now = 1
memo = [0]*(N+1)
memo[1]=1
jun = [1]
flag = 0
while t < K:
    t += 1
    next = A[now-1]
    if memo[next]>0:
        flag = 1
        break
    memo[next]=t+1
    jun.append(next)
    now = next
if flag ==0:
    print(now)
else:
    S = (t+1)-memo[next]
    for i in range(len(jun)):
        if jun[i]==next:
            start = i
            break
    K += -1*start
    amari = K%S
    print(jun[start+amari])

Measured memory_bytes: 94456
#include <stdio.h>
#include <math.h>
int main(void){
    int n, d;
    scanf("%d%d", &n, &d);
    int x[n][d];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < d; j++){
            scanf("%d", &x[i][j]);
        }
    }

    int ans = 0;
    int tmp, tmp2;
    for (int i = 0; i < n; i++){
        for (int j = i + 1; j < n; j++){
            tmp = 0;
            for (int k = 0; k < d; k++){
                tmp += pow(x[i][k] - x[j][k], 2);
            }
            tmp2 = pow(tmp, 0.5);
            if (pow(tmp, 0.5) == tmp2){
                ans += 1;
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

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

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

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

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

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

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

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

fn main() {
    input!{
        n:usize,
        a:[usize;n]
    }
    let mut dic = HashMap::new();
    for i in 0..n{
        let count = dic.entry(a[i]).or_insert(0);
        *count += 1;
    }
    let mut sum = 0u64;
    for (_key, value) in &dic{
        sum += value * (value-1) / 2;
    }

    for p_to_a in &a{
        let mut ans:u64 = sum;
        ans -= dic[p_to_a] * (dic[p_to_a] - 1) / 2;
        ans += (dic[p_to_a] - 1) * (dic[p_to_a] - 2) / 2;
        println!("{}", ans);
    }
    
}


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

using ll=long long;
const ll MOD=998244353;

const int SIZE=5000;
ll dp[SIZE][SIZE];
ll p2[SIZE];
ll comb(ll n,ll k){
    return dp[n][k];    
}
ll pow2(ll x){
    return p2[x];
}
ll g(int n,int k){
    if(n<0) return 0;
    if(n+k-1<n) return 0;
    return comb(n+k-1,n);
}
ll f(int n,int p,int k){
    // if(n<0 || p<0 || k<0) return 0;
    ll res=0;
    for(int i=0;i<=p;i++){
        res+=pow2(i)*comb(p,i)%MOD*g(n-i,k+i)%MOD;
        res%=MOD;
    }
    return res;
}
void init(){
    for(int i=0;i<SIZE;i++){
        dp[i][i]=1;
        dp[i][0]=1;
    }
    for(int i=2;i<SIZE;i++){
        for(int j=1;j<i;j++){
            dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%MOD;
        }
    }
    p2[0]=1;
    for(int i=0;i+1<SIZE;i++){
        p2[i+1]=p2[i]*2%MOD;
    }
}
int main(){
    init();
    int k,n;
    cin>>k>>n;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            int c=min(i/2-1,k-i/2);
            ll v0=f(n-1,c,k-1-2*c);
            ll v1=f(n,c,k-1-2*c);
            cout<<(v0+v1)%MOD<<endl;
        }
        else{
            int c=min((i-1)/2,k-(i-1)/2);
            ll v0=f(n,c,k-2*c);
            cout<<v0<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 193792
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n,k;
cin >> n >> k;
vector<int>a(n);
for(int i=0;i<n;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());
int ans = 10e8;
for(int i=k-1;i<n;i++){
    ans =min(ans,a.at(i)-a.at(i-k+1));
}
cout << ans << endl;
}
 


Measured memory_bytes: 640
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K=I()
    S=ST()
    if(len(S)<=K):
        print(S)
    else:
        print(S[:K]+"...")
if __name__ == '__main__':
    main()

Measured memory_bytes: 78064
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto &i : A) { std::cin >> i; }
  std::vector<int> last(30, -1);
  long long ans = 0;
  int max = -1;
  for (int i = 0; i < N; ++i) {
    int a = A[i];
    for (int j = 0; j < 30; ++j) {
      if (a % 2) {
        max = std::max(max, last[j]);
        last[j] = i;
      }
      a /= 2;
    }
    ans += i - max;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1024
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        m: usize,
        a: [usize;n]
    }

    let mut a = a;
    a.sort();
    a.reverse();

    let mut total = 0;
    for i in 0..n {
        total += a[i];
    }

    let mut ok = true;
    for i in 0..m {
        if a[i] * 4 * m < total {
            ok = false;
        }
    }

    if ok {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=2005;
int n;
vector <int> e[N];
int v[N],sz[N],mi[N],sm[N];
char s[N];
void dfs(int x,int pre){
	sz[x]=v[x],sm[x]=mi[x]=0;
	int my=0;
	for (auto y : e[x])
		if (y!=pre){
			dfs(y,x);
			sz[x]+=sz[y];
			sm[x]+=sm[y]+sz[y];
			if (my==0||mi[y]+sz[y]>mi[my]+sz[my])
				my=y;
		}
//	outval(x),outval(my),outval(sm[x]);
	if (my){
		if (mi[my]+sz[my]<=sm[x]-sm[my]-sz[my])
			mi[x]=sm[x]&1;
		else
			mi[x]=mi[my]+sz[my]-(sm[x]-sm[my]-sz[my]);
	}
}
int main(){
	n=read();
	cin>>s+1;
	For(i,1,n-1){
		int x=read(),y=read();
		e[x].pb(y),e[y].pb(x);
	}
	For(i,1,n)
		v[i]=s[i]-'0';
	int ans=1e9;
	For(i,1,n){
		dfs(i,0);
		if (mi[i]==0)
			ans=min(ans,sm[i]/2);
//		outval(i),outval(ans);
//		outarr(sz,1,n);outarr(sm,1,n);outarr(mi,1,n);
	}
	if (ans>8e8)
		puts("-1");
	else
		cout<<ans<<endl;
	return 0;
}

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

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

    if (a + b == c || a + c == b || b + c == a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

int a, b, c;
int main()
{
	int i, t1, t2, t3;
	cin >> a >> b >> c;
	if (a % 2 || b % 2 || c % 2) {cout << '0'; return 0;}
	if (a == b && a == c) {cout << "-1"; return 0;}
	for (i = 0; i < 2e9; i++) {
		if (a % 2 || b % 2 || c % 2) {cout << i; return 0;}
		t1 = a, t2 = b, t3 = c;
		a = (t2 + t3) / 2;
		b = (t1 + t3) / 2;
		c = (t1 + t2) / 2;
	}
    cout << "-1";
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main()
{
	int n;
	int a[10];
	int max = 0;

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (max < a[i]) {
			max = a[i];
		}
	}
	int j = 1;
	int x = max;
	while (1) {
		for (int i = 0; i < n; i++) {
			if (x % a[i] != 0) {
				break;
			}
			if (i == n - 1) {
				cout << x << endl;
				return 0;
			}
		}
		j++;
		x = max * j;
	} 

	return (0);
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> v(100005);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v.at(a).push_back(b);
    }
    ll ans = 0;
    priority_queue<int> q;
    for(int i = 1; i <= m;i++){
        for(int j = 0;j < v.at(i).size();j++) {
            q.push(v.at(i).at(j));
        }
        if(q.empty()) continue;
        ans += q.top();q.pop();
    }
    cout << ans << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9
 
int main() {

    int N;
    cin >> N;

    int ans =0;
    int count = 0;
    int max_count = 0;

    rep(i,N){
        int tmp = i+1;
        while(tmp%2 == 0){
            count++;
            tmp = tmp/2;
        }
        if(count > max_count){
            max_count = count;
            ans = i+1;
        }
        count = 0;
    }
    if(ans == 0){
        ans = 1;
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

#define MAX 100010
int n;
bool zaj[MAX];
int t[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  R(i,n)cin >> t[i];
  int res = t[0] - 1;
  int ak = 2;
  for(int i = 1;i<n;i++){
    if(t[i] == ak){
      ak++;
    }else{
      res += (t[i] - 1)/ak;
    }
  }
  cout << res << "\n";
}


Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b,k,t=0;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
		if(t==0){
			if(a%2==0){

			}else{
				a--;
			}
			a/=2;
			b+=a;
			t=1;
		}else{
			if(b%2==0){

			}else{
				b--;
			}
				b/=2;
				a+=b;
				t=0;
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}



Measured memory_bytes: 256
fun readIntArray(): List<Int> {
    return readLine()!!.split(" ").map{ it.toInt() }
}

fun main(args: Array<String>) {
    val c1 = readIntArray()
    val c2 = readIntArray()
    val c3 = readIntArray()

    val a1 = 0
    val b1 = c1[0] - a1
    val b2 = c1[1] - a1
    val b3 = c1[2] - a1
    val a2 = c2[1] - b2
    val a3 = c3[2] - b3

    val a = arrayOf(a1, a2, a3)
    val b = arrayOf(b1, b2, b3)
    val c = arrayOf(c1, c2, c3)

    for (i in 0..2) {
        for(j in 0..2) {
            if(a[i] + b[j] != c[i][j]) {
                println("No")
                return
            }
        }
    }

    print("Yes")
}


Measured memory_bytes: 36268
N, K = map(int, input().split())
*A, = map(int, input().split())
*F, = map(int, input().split())
A, F = sorted(A), sorted(F, reverse=True)

def cond(x):
    k = 0
    for a, f in zip(A, F): k += max(a - (x // f), 0)
    return True if k <= K else False 

MIN = -1
MAX = 10**12 + 1
left, right = MIN, MAX # search range
while right - left > 1:
    mid = (left + right) // 2
    if cond(mid): right = mid
    else: left = mid
print(right)

Measured memory_bytes: 121964
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <math.h>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(void){
    int n, h, w;
    cin >> n;
    cin >> h;
    cin >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include <string>
#include <sstream>
using namespace std;

int main()
{
    int a,b,c;
    
    cin >> a >> b >>c;
    bool ans=false;
    // for(int i=0;i<gcd(a,b);i++){
    for(int i=0;i<=100;i++){
        if (a*i %b ==c)ans=true;
    }


    
    cout <<(ans?"YES":"NO");
    
    return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> a[100002];
int n,m,q,ans[100002],maindis[100002],v[100002],d[100002],c[100002];
void dfs(int k,int cc,int to){
	if(k<0){
		return;
	}
	if(k<=maindis[to]){
		return;
	}
	if(ans[to]==0){
		ans[to]=cc;
	}
	maindis[to]=k;
	for(int i=0;i<a[to].size();i++){
		dfs(k-1,cc,a[to][i]);
	}
}
int main(){
	cin>>n>>m;
	fill(maindis,maindis+100000,-1);
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=m;i++){
		int t1,t2;
		cin>>t1>>t2;
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	cin>>q;
	for(int i=q;i>0;i--){
		cin>>v[i]>>d[i]>>c[i];
	}
	for(int i=1;i<=q;i++){
		dfs(d[i],c[i],v[i]);
	}
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<endl;
	}
//	for(int i=1;i<=n;i++){
//		cout<<maindis[i]<<" ";
//	}
	return 0;
}

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

int main()
{
	int k, x;

	cin >> k >> x;

	for (int i = 0; i < k * 2 - 1; i++) {
		cout << x - k + 1 + i;

		if (i == k * 2 - 2)
			cout << endl;
		else
			cout << " ";
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
int gcd(int a, int b)
{
    if(a < b){
        int c = a;
        a = b;
        b = c;
    }
    if(a % b == 0){
        return b;
    }
    else{
        return gcd(a - b * (a / b), b);
    }
}

int main()
{
    int a, b, c;
    std::cin >> a >> b >> c;
    int m = gcd(a, b);
    if(c % m == 0){
        std::cout << "YES" << std::endl;
    }
    else{
        std::cout << "NO" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout<<#x<<"="<<x<<endl
typedef long long ll;
using namespace std;
const int maxn = 109;
const int inf = 0x3f3f3f3f;

int first[maxn],mx[maxn],pre[maxn],arr[maxn];
bool vis[maxn];
struct line{int x,y;}a[maxn];
struct edg{int next,to;}e[maxn<<1];
int n,md,dd,t,e_sum,len;
ll ans;

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

void add_edg(int x,int y)
{
	e_sum++;
	e[e_sum].next=first[x];
	first[x]=e_sum;
	e[e_sum].to=y;
}

void dfs(int x,int fat,int dep)
{
	int cnt=0;dd=max(dd,dep);
	for(int i=first[x];i;i=e[i].next)
	{
		int w=e[i].to;
		if(w==fat||vis[w]) continue;
		cnt++;dfs(w,x,dep+1);
	}
	mx[dep]=max(mx[dep],cnt);
}

int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		a[i]=(line){x,y};
		add_edg(x,y);add_edg(y,x);
	}
	len=inf;ans=1e18;
	for(int i=1;i<=n;i++)
	{
		dd=0;memset(mx,0,sizeof mx);
		dfs(i,0,1);
		ll res=1;
		for(int j=1;j<=dd-1;j++) res=res*mx[j];
		if(dd<len||(dd==len&&res<ans)) len=dd,ans=res;
	}
	for(int i=1;i<n;i++)
	{
		int x=a[i].x,y=a[i].y;
		dd=0;memset(mx,0,sizeof mx);
		dfs(x,y,1);dfs(y,x,1);
		ll res=1;
		for(int j=1;j<=dd-1;j++) res=res*mx[j];
		res<<=1;
		if(dd<len||(dd==len&&res<ans)) len=dd,ans=res;
	}
	printf("%d %lld\n",len,ans);
	return 0;
}


Measured memory_bytes: 256
while (a,b = gets.split.map(&:to_i)) != [0,0] 
  for i in 0..(a-1)
    for j in 0..(b-1)
      if (i+j)%2 == 0
        print "#"
      else 
        print"."
      end
    end
    puts ""
  end
  puts ""
end



Measured memory_bytes: 6860
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include<queue>

using std::vector;

int main()
{
    int n,q,ope,t,x;
    std::cin>>n>>q;
    std::priority_queue<int> S[n];

    for(int i = 0; i < q; i++)
    {
        std::cin>>ope>>t;
        if(ope==0){std::cin>>x;S[t].push(x);}
        else if(ope==1){if(!S[t].empty()){std::cout<<S[t].top()<<std::endl;}}
        else{if (!S[t].empty()) S[t].pop();}
    }

    return 0;
}



Measured memory_bytes: 4080
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
bool v[802][802];
bool c[802][802];
void init() {
	rep(i, 802) {
		rep(j, 802) {
			c[i][j] = true;
		}
	}
}
int main() {
	init();
	int h, w; cin >> h >> w; int k; cin >> k;
	int sx, sy;
	rep1(i, h) {
		rep1(j, w) {
			char t; cin >> t;
			if (t == '.')c[i][j] = false;
			else if (t == 'S') {
				sx = i; sy = j;
			}
		}
	}
	c[sx][sy] = v[sx][sy]=true;
	queue<P> q; q.push({ sx,sy });
	rep(i, k) {
		int len = q.size();
		rep(j, len) {
			P nex = q.front(); q.pop();
			int x = nex.first; int y = nex.second;
			rep(k, 4) {
				int nx = x + dx[k]; int ny = y + dy[k];
				if (c[nx][ny])continue;
				c[nx][ny]=v[nx][ny] = true; q.push({ nx,ny });
			}
		}
	}
	int out = (int)mod;
	rep1(i, h) {
		rep1(j, w) {
			if (!v[i][j])continue;
			int mi = min({ i - 1,j - 1,h - i,w - j });
			out = min(out, (mi + k - 1) / k + 1);
		}
	}
	cout << out << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector <string> A(N);

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

  set<string> S;
  for(int i = 0; i < N; ++i){
    S.insert(A.at(i));
  }
  int ans = S.size();

  cout << ans << endl;
}


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

using namespace std;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout <<"Left"<< endl;
    }else if(a+b < c+d){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,cnt=0,sum=0,mini=9999999999,x;
    cin >> n;
    rep(i,n){
        cin >> x;
        sum+=abs(x);
        mini=min(mini,abs(x));
        if(x<=0) cnt++;
    }
    cout << (cnt%2?sum-2*mini:sum) << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=2e5+5;
const int MAX_E=2e5+5;
struct Edge{int to,nxt;}e[MAX_E<<1];
int head[MAX_N],tote;
void add_edge(int u,int v){e[++tote].to=v,e[tote].nxt=head[u];head[u]=tote;}
int root,fa[MAX_N];
bool vis[MAX_N],in_loop[MAX_N];
void find_root(int s)
{
	vis[s]=true;
	if(vis[fa[s]]) root=s;
	else find_root(fa[s]);
}
int loop[MAX_N],lpc=0;
void get_loop()
{
	find_root(1);
	loop[++lpc]=root,in_loop[root]=true;
	int now=fa[root];
	while(now!=root) loop[++lpc]=now,in_loop[now]=true,now=fa[now];
	loop[lpc+1]=root;
}
int val[MAX_N];
bool mex[MAX_N];
void dfs(int u)
{
	reps(u)if(!in_loop[v]) dfs(v);
	reps(u)if(!in_loop[v]) mex[val[v]]=true;
	while(mex[val[u]]) val[u]++;
	reps(u)if(!in_loop[v]) mex[val[v]]=false;
}
void init(int n)
{
	repi(i,0,n) head[i]=val[i]=mex[i]=0;
	tote=0;
}
int main()
{	
	int n; si(n);
	repi(i,1,n) si(fa[i]),add_edge(fa[i],i); 
	get_loop();
	repi(i,1,lpc) dfs(loop[i]);
	bool flag=false;
	repi(i,2,lpc)if(val[loop[i]]!=val[loop[i-1]]){ flag=true; break; }
	if(!flag&&(lpc&1)) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 8640
#include <iostream> 
#define A_SIZE 500001
using namespace std;

void MaxHeapify(int id, int H, int array[]) 
{
    int largest;
    int l = 2 * id;
    int r = 2 * id + 1;
    if (l <= H && array[l] > array[id]) largest = l;
    else largest = id;
    if (r <= H && array[r] > array[largest]) largest = r;

    if (largest != id)
    {
        swap(array[largest], array[id]);
        MaxHeapify(largest, H, array);
    }
}

int main() 
{
    int H, array[A_SIZE], value;
    scanf("%d", &H);
    for (int id = 1; id <= H; ++id) 
    {       
        scanf("%d", &value);
        array[id] = value;
    }

    for (int id = H/2; id >= 1; --id) MaxHeapify(id, H, array);

    for (int i = 1; i <= H; ++i) 
    {
        printf(" %d", array[i]);
    }
    printf("\n");
}


Measured memory_bytes: 5096
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
       long long  int n,k,a,b,c;
          cin>>n>>k;
          cin>>a>>b>>c;
        long long int w=0;
          string st,st1;
          cin>>st;
          for(int i=0;i<n;i++){
            if(st[i]=='r'){
                if(i<k||st1[i-k]!='p'){
                    w=w+c;
                    st1.push_back('p');
                }
                else if((i+k)<n&&st[i+k]!='s'){
                    st1.push_back('r');
                }
                else{
                    st1.push_back('s');
                }
            }
            else if(st[i]=='p'){
                    if(i<k||st1[i-k]!='s'){
                    w=w+b;
                    st1.push_back('s');
                    }
                    else if((i+k)<n&&st[i+k]!='r'){
                        st1.push_back('p');
                    }
                    else{
                        st1.push_back('s');
                    }
            }
            else if(st[i]=='s'){
               if(i<k||st1[i-k]!='r'){
                    w=w+a;
                    st1.push_back('r');
                    }
                    else if((i+k)<n&&st[i+k]!='p')
                    {
                        st1.push_back('s');
                    }
                    else{
                        st1.push_back('r');
                    }
            }
          }
          cout<<w<<endl;

    }


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    long long int n,m,num=0,i;
    cin>>n>>m;
    if(m%n==0)
        cout<<m/n<<endl;
    else
    {
        for(i=1;i<=(m/n);i++)
        {
            if(m%i==0&&(m/i>=n))
            {
                if(i>num)
                {
                    num=i;
                }
            }
        }
        cout<<num<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

const long long MOD = (long long)1e9 + 7;

ll dp[100010][13] = {0};
string s;

int main(){
    cin >> s;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < 13; j++){
            if(s[i] == '?'){
                for(int k = 0; k < 10; k++){
                    dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
                    dp[i + 1][(j * 10 + k) % 13] %= MOD;
                }
            }else{
                int t = s[i] - '0';
                dp[i + 1][(j * 10 + t) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + t) % 13] %= MOD;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
    return 0;
}


Measured memory_bytes: 10624
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
 int q,p,w[1000001],u[1000001],o;
 string a;
 int main()
 {
     cin>>a;//首先输入字符串
     for (int i=0;i<a.size();i++)//从0位开始循环
     {
         if (a[i]=='C') 
         {
             p++;
             u[p]=i+1;
         }//判断是否发现C这个东西，并统计其位置
         else if (a[i]=='F')
         {
            q++;
             w[q]=i+1;
         }
     }//判断是否发现F，同理 统计位置情况
     if (q>=1 && p>=1)
     {
     for (int i=1;i<=p;i++)
     {
         for (int j=1;j<=q;j++)
         {
             if (u[i]<w[j])
             {
                 o=1;
             }
         }
     }//循环，找到C是否在F的前面
     if (o==1) cout<<"Yes"<<endl;//在前面则Yes
     else cout<<"No"<<endl;//否则No   
     }
     else cout<<"No"<<endl;//不存在两个数，直接No
     //以上为全部过程，希望能理解。
 }

Measured memory_bytes: 2304
#include<iostream>
#include<cmath>
#include<string>
#define ll long long 
using namespace std;

int main()
{
    ll i,j,k,l,n,a,b;
    cin>>a>>b>>k;
    if((a+b)<=k)
    {
    	cout<<"0"<<" "<<"0";
    	return 0;
    }
    
    if(a<=k)  
    i=0;
    else
    {
    	 i= abs(k-a);
    l=b;
    cout<<i<<" "<<l;
    return 0;
    }
    l=abs(k-b-a);
    //j=abs(b-l);
    cout<<i<< " "<<l;
     
	return 0;
}

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

struct dat {
  long long a, b, c, d;
};

long long n, m, q, res = 0;
vector<dat> v;
vector<long long> now;

long long solve();
long long dfs(long long id);

int main() {
  cin >> n >> m >> q;
  v.resize(q);
  for (int i = 0; i < q; ++i) {
    cin >> v[i].a >> v[i].b >> v[i].c >> v[i].d;
    --v[i].a, --v[i].b;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  now.resize(n, 0);
  now[0] = 1;
  return dfs(1);
}

long long dfs(long long id) {
  if (id == n) {
    long long res = 0;
    for (int i = 0; i < q; ++i)
      if (now[v[i].b] - now[v[i].a] == v[i].c) res += v[i].d;
    return res;
  }
  long long res = 0;
  for (int i = now[id - 1]; i <= m; ++i) {
    now[id] = i;
    res = max(res, dfs(id + 1));
  }
  return res;
}

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


int main() {
    int n;
    cin >> n;
    cout << pow(n,3) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];

int main(){
  ll h,n;
  cin>>h>>n;
  if(h%n==0) cout<<h/n;
  else cout<<h/n+1;
  return 0;
}

Measured memory_bytes: 256
while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り



Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int q;
    cin >> q;
    int k;
    int ans = 1;
    while (q--) {
        cin >> k;
        if (!binary_search(ALL(a), k)) {
            ans = 0;
            break;
        }
    }
    cout << ans << endl;
}



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

int main() {
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << "3\n";
	}
	else if (S == "SSS") {
		cout << "0\n";
	}
	else if ((int)S.find("RR") >= 0) {
		cout << "2\n";
	}
	else {
		cout << "1\n";
	}
	return 0;
}

Measured memory_bytes: 3588