akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] <= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) left = mid;
		else right = mid;
	}
	/* left は条件を満たす最大の値、right は条件を満たさない最小の値になっている */
	return left;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int x1, x2, x3, x4, x5;
	cin >> x1 >> x2 >> x3 >> x4 >> x5;
	if (x1 == 0) {
		cout << 1;
	}
	else if (x2 == 0) {
		cout << 2;
	}
	else if (x3 == 0) {
		cout << 3;
	}
	else if (x4 == 0) {
		cout << 4;
	}
	else if (x5 == 0) {
		cout << 5;
	}
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
int a[]={0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int s,t;cin>>s>>t;
		int cnt=0,i=0;
		while(a[i]!=s)i++;
		while(a[(i+cnt)%15]!=t)cnt++;
		int cnta=1e5,j=i+1;
		while(j<15&&a[j]!=s)j++;
		if(j<15)
		{
			cnta=0;
			while(a[(j+cnta)%15]!=t)cnta++;
		}
		if(cnt<cnta)
		{
			for(int k=0;k<=cnt;k++)cout<<a[(i+k)%15]<<(k==cnt?"\n":" ");
		}
		else
		{
			for(int k=0;k<=cnta;k++)cout<<a[(j+k)%15]<<(k==cnta?"\n":" ");
		}
	}
}



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

int main()
{
string s;
cin>>s;
int v=s.length();
v--;

int z;
if(v%2==1){
    v--;
}


z=v/2;
for(int r=0;r<z;r++){


   if(s.at(r)!=s.at(r+z)||v%2==1){
        v--;
        z=v/2;

        r=-1;
    }

}
cout<<v;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<math.h>
#include<string>
#include<cstdlib>
#include<sstream>

typedef long long ll;

using namespace std;

int main()
{
	ll n, count = 0;

	cin >> n;

	vector<ll>heights;

	for(ll i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		heights.push_back(x);
	}

	for(ll i = 0; i < n - 1; i++)
	{
		if(heights[i+1] < heights[i])
		{
			count = count + (heights[i] - heights[i+1]);
			heights[i+1] = heights[i];
		}
	}

	cout << count;
	
}



Measured memory_bytes: 5240
let buf = '';
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
  let s = process.stdin.read();
  if (s !== null) { buf += s.toString(); }
});
process.stdin.on('end', () => {
  let lines = buf.trim().split("\n");
  let getVals = (p) => lines[p].split(' ').map( (x) => parseInt(x) )
  let [n, m] = getVals(0);
  let graph: number[][] = [];
  let edges: [number, number][] = [];
  for (let i = 0; i <= n; i++) { graph[i] = []; }
  for (let i = 0; i < m; i++) {
    let [a, b] = getVals(i+1);
    edges[i] = [a, b];
    graph[a].push(b);
    graph[b].push(a);
  }
  let ans = 0;
  for (let i = 0; i < m; i++) {
    let [a, b] = edges[i];
  	let flag: boolean[] = [];
    let cnt = 1;
    let tmp: number[] = [];
    for (let j = 0; j <= n; j++) {
      flag[j] = false;
      if (j === 0) { continue; }
      if (j === a || j === b) { continue; }
      if (tmp.length > 0) { continue; }
      tmp.push(j);
      flag[j] = true;
    }
    while (tmp.length > 0) {
      let x = tmp.pop();
      let g = graph[x];
      for (let j = 0; j < g.length; j++) {
        let y = g[j];
        if (x === a && y === b) { continue; }
        if (x === b && y === a) { continue; }
        if (flag[y]) { continue; }
        flag[y] = true;
        tmp.push(y);
        cnt++;
      }
    }
    if (cnt !== n) {
      ans++;
    }
  }
  console.log(ans);
});

Measured memory_bytes: 7628
#define mod 1000000007
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=3e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
int st[4][2]={1,0,0,1,-1,0,0,-1};
//vector<int>vt[N];
//priority_queue<int>q;
int t,cas;
int n,m,k;
int main()
{
	map<char,int>q;
	char s[10];
	while(~scanf("%s",s))
	{
		q.clear();
		int cnt=0;
		for(int i=0;i<4;i++)
		{
			if(++q[s[i]]==2)cnt++;
		}
		if(cnt==2)printf("Yes\n");
		else printf("No\n");
	}
}


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

using namespace std;

L n,start,ans=1,realans=1000000;
vector<L>v[100010];
L chk[100010];
L dwn[100010];
L bel[100010];

void dfs1(L x){
	L i;
	for(i=0;i<v[x].size();i++)
	{
		if(!chk[v[x][i]])
		{
			chk[v[x][i]]=1;
			dwn[x]++;
			dfs1(v[x][i]);
			bel[x]|=bel[v[x][i]];
		}
	}
	if(dwn[x]>=2) bel[x]=1;
}

void dfs2(L x,L bury){
	L i,passed=0;
	//printf("%lld %lld\n",x,bury);
	for(i=0;i<v[x].size();i++)
	{
		if(!chk[v[x][i]])
		{
			if(!bel[v[x][i]])
			{
				if(!passed)
				{
					passed=1;
				}
				else
				{
					//printf("*%lld*\n",x);
					ans++;
					bury=0;
				}
			}
			else
			{
				chk[v[x][i]]=1;
				dfs2(v[x][i],1);
				bury=0;
			}
		}
	}
	if(bury) ans++;
}

int main()
{
	srand((int)time(NULL));
	scanf("%lld",&n);
	L i;
	for(i=1;i<n;i++)
	{
		L s,e;
		scanf("%lld %lld",&s,&e);
		s++;
		e++;
		v[s].push_back(e);
		v[e].push_back(s);
	}
	vector<L>starts;
	for(i=1;i<=n;i++)
	{
		if(v[i].size()==1) starts.push_back(i);
	}
	L lop=3;
	while(lop--)
	{
		ans=1;
		for(i=1;i<=n;i++)
		{
			chk[i]=dwn[i]=bel[i]=0;
		}
		start=starts[rand()%starts.size()];
		chk[start]=1;
		dfs1(start);
		for(i=1;i<=n;i++)
		{
			chk[i]=0;
		}
		chk[start]=1;
		dfs2(start,0);
		realans=min(realans,ans);
	}
		printf("%lld",realans);
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define red(i,a,b) for(int i=(a);i>=(b);i--)
#define db double
#define ld long db
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=1e3+5;
int n,cnt;
ll x[N],y[N],len[N];
signed main(){
	//freopen("a","r",stdin);
	n=read();rep(i,1,n)x[i]=read(),y[i]=read();
	int re=abs(x[1]+y[1])&1;
	rep(i,2,n)if((abs(x[i]+y[i])&1)^re)return cout<<-1,signed();
	cout<<32-re<<'\n'<<1<<' ';len[++cnt]=1;
	if(re){rep(i,1,30)cout<<(len[++cnt]=(1<<i))<<' ';cout<<'\n';}
	else{rep(i,0,30)cout<<(len[++cnt]=(1<<i))<<' ';cout<<'\n';}
	rep(i,1,n){
		ll nx=0,ny=0;string s="";
		red(j,cnt,1){
			ll dx=x[i]-nx,dy=y[i]-ny;
			if(abs(dx)>abs(dy)){if(dx>0)nx+=len[j],s+='R';else nx-=len[j],s+='L';}
			else{if(dy>0)ny+=len[j],s+='U';else ny-=len[j],s+='D';}
		}reverse(s.begin(),s.end());cout<<s<<'\n';
	}return signed();
}

Measured memory_bytes: 3632
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
int main() {
  ll N, K;
  cin >> N >> K;

  map<ll, ll> mp;
  REP(i, N) {
    ll tmp;
    cin >> tmp;
    ++mp[tmp];
  }
  vector<ll> v;
  for (auto x = mp.begin(); x != mp.end(); x++) {
    v.push_back(x->second);
  }
  sort(ALL(v));

  ll ans = 0;
  if (v.size() > K) {
    REP(i, v.size() - K) { ans += v[i]; }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 14964
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        d: i64
    }
    match d {
        22 => println!("Christmas Eve Eve Eve"),
        23 => println!("Christmas Eve Eve"),
        24 => println!("Christmas Eve"),
        25 => println!("Christmas"),
        _ => unreachable!(),
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,i,j,k=1,cnt=0;
   cin >> n;
  
  vector<int> a(n);
  vector<int> b(n);
  
  for(i=0;i<n;i++){
    cin >> a.at(i);
  }
  
  for(i=0;i<n;i=j)
    for(j=i;j<n;j++){
      if(a.at(j)==k){
        b.at(k-1)=a.at(j);
        k++;
      }
      else cnt++;
    }
  
  if(b.at(0)==1)
    cout << cnt;
  
  else cout << -1;
}

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

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    String str = sc.next();
    System.out.println(str.equals("ABC") ? "ARC" : "ABC");
  }

}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte())
      return buffer[ptr++];
    else
      return -1;
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  public boolean hasNext() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr]))
      ptr++;
    return hasNextByte();
  }

  public String next() {
    if (!hasNext())
      throw new NoSuchElementException();
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public long nextLong() {
    if (!hasNext())
      throw new NoSuchElementException();
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public int nextInt() {
    long nl = nextLong();
    if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
      throw new NumberFormatException();
    return (int) nl;
  }

  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

Measured memory_bytes: 32264
S = str(input())
T = str(input())

S = list(S)
T = list(T)

A = S
for i in range(len(S)):
    AA = list(A[len(S) - 1])
    B = A[0:len(S) - 1]
    AA.extend(B)
    A = AA
    if A == T:
        p = 1
        break
    else:
        p = 0
        
if p == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0)break;
        for(i=0;i<H;i++){
            if(i==0||i==H-1){
                for(j=0;j<W;j++){
                    printf("#");
                }
                printf("\n");
            }
            else{
                for(j=0;j<W;j++){
                    if(j==0||j==W-1){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                }
                printf("\n");
            }
            
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1728
a,b,c=map(int,input().split())

A=[a]+[0]*10**5
B=[b]+[0]*10**5
C=[c]+[0]*10**5

i=0
while A[i]%2+B[i]%2+C[i]%2==0:
    i+=1
    A[i]=B[i-1]//2+C[i-1]//2
    B[i]=C[i-1]//2+A[i-1]//2
    C[i]=A[i-1]//2+B[i-1]//2
    if A[i]==B[i]==C[i]:
        i=-1
        break
print(i)

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

int main() {
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i, n) cin >> vec[i];
    
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int cnt = 0;
    int before = 101;
    
    rep(i, n){
        if(before != vec[i]){
            cnt++;
            before = vec[i];
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 3580
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main() {
	ll x;
	cin >> x;
	cout << 8 - (x - 400) / 200 << endl;
}

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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<ll>a(n);
    rep(i,n)cin>>a[i];

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    ll ans=a[0];

    rep2(i,2,n-1){
        ans+=a[i/2];
    }

    cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

#define rep(i,n) for(ll (i)=0;(i)<(n);++i)

#define rep1(i,n) for(ll (i)=1;(i)<=(n);++i)

#define rrep(i,n) for(ll (i)=(n)-1;(i)>=(0);--i)

#define rrep1(i,n) for(ll (i)=(n);(i)>=(1);--i)

#define pb push_back

#define fr first

#define sc second

const ll INF=0xfffffffffffff;
const ll inf=0xfffffff;
const ll SIZE=1<<17;
priority_queue<P> q;
ll N,HP;
ll D[100000],H[100000];
ll hp[SIZE];

ll ans=0;
ll l=0;
ll pos;
ll data[SIZE*2-1],datb[SIZE*2-1];
ll init(ll k){
	datb[k]=0;
	if(k>=SIZE-1) return data[k]=hp[k-SIZE+1];
	return data[k]=max(init(k*2+1),init(k*2+2));
}

ll update(ll a,ll b,ll val,ll k,ll l,ll r){
	if(a>b) swap(a,b);
	if(b<=l||r<=a) return data[k]+datb[k];
	if(a<=l&&r<=b){
		datb[k]+=val;
		return data[k]+datb[k];
	}
	else{
		data[k]=max(update(a,b,val,k*2+1,l,(l+r)/2),update(a,b,val,k*2+2,(l+r)/2,r));
		return data[k]+datb[k];
	}
}

ll query(ll a,ll b,ll k,ll l,ll r){
	if(r<=a||b<=l) return -INF;
	if(a<=l&&r<=b) return data[k]+datb[k];
	else return max(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r))+datb[k];
}


int main()

{
	ll ans=0;

	cin>>N>>HP;
	hp[0]=HP;
	rep(i,N-1){
		cin>>D[i]>>H[i];
		hp[i+1]=hp[i]-D[i];
	}
	init(0);
	pos=HP;
	ll want;
	ll z,zan;
	rep(i,N-1){
		q.push(P(H[i],i));
		while(pos-D[i]<1){
			want=D[i]-pos+1;
			P p=q.top();
			q.pop();
			zan = HP - query(p.sc,i+1,0,0,SIZE);
			if(zan<p.fr){
				q.push(P(zan,p.sc));
			}
			else if( (zan/p.fr)*p.fr<=want ){
				z=zan/p.fr;
				ans+=z;
				pos+=z*p.fr;
				update(p.sc,N,z*p.fr,0,0,SIZE);
				if(zan%p.fr!=0){
					q.push(P(zan%p.fr,p.sc));
				}
			}
			else{
				z=(want-1)/p.fr+1;
				ans+=z;
				pos+=z*p.fr;
				update(p.sc,N,z*p.fr,0,0,SIZE);
				q.push(p);
			}
		}
		pos-=D[i];
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 11356
/*
AOJ A2101
 */
#include <stdio.h>
#include <float.h>
#include <math.h>

int N;

main()
{
  int i,limit,sum;

  while(EOF!=scanf("%d",&N) && N)
    {
      limit=(int)sqrt((double)N);
      sum = 0;
      for(i=1;i<=limit;i++)
	if((N % i) == 0)
	  {
	    sum += i;
	    sum += (N/i);
	  }
      if(N == limit*limit)
	sum -= limit;

      //printf("s %d\n",sum);
      if(sum == 2*N)
	printf("perfect number\n");
      else if(sum <= 2*N)
	printf("deficient number\n");
      else
	printf("abundant number\n");
    }
  return(0);
}

Measured memory_bytes: 584
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var A = sc.ArrayLong(N);
        var ans = new long[N];
        var sum = 0L;
        for (int i = 1; i < N; i += 2) {
            sum += A[i] * 2;
        }
        ans[0] = A.Sum() - sum;

        for (int i = 1; i < N; i++) {
            ans[i] = (2 * A[i - 1]) - ans[i - 1];
        }

        WriteLine(string.Join(" ", ans));
    }


}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 33756
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m, l;
  cin >> n >> m >> l;
  ll one[n][m], two[m][l], ans[n][l];

  rep(i, 0, n) rep(j, 0, m) cin >> one[i][j];
  rep(i, 0, m) rep(j, 0, l) cin >> two[i][j];
  rep(i, 0, n) rep(j, 0, l) ans[i][j] = 0;

  rep(i, 0, n) {
    rep(j, 0, m) {
      rep(k, 0, l) { ans[i][k] += one[i][j] * two[j][k]; }
    }
  }

  rep(i, 0, n) {
    rep(j, 0, l) {
      if (j > 0)
        cout << " ";
      cout << ans[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n;
ll k;
int a[2020];
int app[2020];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		app[a[i]]++;
	}
	for(int i=1;i<=2000;i++)
		app[i]+=app[i-1];
	ll ans=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			if(a[j]<a[i])ans++;
	ans=ans*k%MOD;
	ll tmp=k*(k-1)/2ll%MOD;
	for(int i=0;i<n;i++)
		ans=(ans+tmp*1ll*app[a[i]-1]%MOD)%MOD;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FORB(i,s,e,st) for (int i = int(s); i < int(e); i+=(int(st)))
#define FOR(i,s,e) FORB(i,s,e,1)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

ll dp[51][2501];

int main(){
	int n,m,in;
	cin>>n>>m;
	CLR(dp);
	dp[0][0]=1;
	REP(i,n){
		cin>>in;
		for(int j=i;j>=0;j--){
			REP(k,2501-in){
				dp[j+1][k+in]+=dp[j][k];
			}
		}
	}
	ll ret=0;
	REP(i,n){
		ret+=dp[i+1][m*(i+1)];
	}
	cout<<ret<<"\n";
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/01  Problem: M-Solutions2019 B / Link: https://atcoder.jp/contests/m-solutions2019  ----- */


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

	string s;
	cin >> s;
	int ans = 0;
	for (auto cc : s) {
		if (cc == 'x')ans++;
	}
	auto print_yesno = [](LL yes, int mode = 0) {
		if (mode == 0) {
			cout << (yes ? "yes" : "no") << endl;
		}
		else if (mode == 1) {
			cout << (yes ? "Yes" : "No") << endl;
		}
		else if (mode == 2) {
			cout << (yes ? "YES" : "NO") << endl;
		}
		else assert(0);
	};
	DD(de(ans));
	LL yes = ans > 7;
	print_yesno(!yes, 2);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=0; (i)--)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))

typedef long long ll;

using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin>>N>>M;
  int a[M];
  REP(i,M)cin>>a[i];
  ll ans[N+1]={};
  int anow=0;
  ans[0]=1;
  if(a[0]!=1)ans[1]=1;
  else{
    ans[1]=0;
    anow++;
  }
  for(int i=2;i<N+1;i++){
    if(i==a[anow]){
      ans[i]=0;
      anow++;
    }else{
      ans[i]=(ans[i-1]%MOD+ans[i-2]%MOD)%MOD;
    }
  }
  cout<<ans[N];
  return 0;
}

Measured memory_bytes: 1408
use std;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_verical_vec<T: std::str::FromStr>(n: u32) -> Vec<T> {
    let mut vec = vec![];
    for _ in (0..n) {
        vec.push(read::<T>());
    }
    return vec;
}

fn read_matrix<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn b_judge_status_summary() {
    let n = read::<u32>();
    let s = read_verical_vec::<String>(n);
    ["AC", "WA", "TLE", "RE"].iter()
        .map(|e| {
            (e, s.iter().filter(|t| t == e).count())
        })
        .for_each(move |(e,t)| println!("{} x {}", e, t));
}

fn main() {
    b_judge_status_summary();
}


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

#define sz(x) int(x.size())
#define pii pair<int, int>
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define Debug(X) cout << #X << " = " << X << '\n'
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e6 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin);  freopen(Task".out", "w", stdout);
  int h, n;
  cin >> h >> n;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) cin >> a[i], sum += a[i];
  cout << (sum >= h ? "Yes" : "No");

}




Measured memory_bytes: 640
#include <iostream>
#include <string.h>
using namespace std;

int memo[10][1000][20];
//3,2,1
int dfs(int c,int h,int m)//c:選んだ回数、h:残りの数字、m以下の数字から選ぶ
{
	if(c==0&&h==0)
		return 1;
	if(h<0||m<0||c<0)
		return 0;
	/*if(memo[c][h][m] != -1)
		return memo[c][h][m];*/
	int res = 0;
	for(int i=0;i<=m;++i){
		res += dfs(c-1,h-i,i-1);
	}
	//memo[c][h][m] = res;
	return res;
}

int main(void)
{
	while(1){
		int n,s;
		cin >> n >> s;
		if(n==0&&s==0)
			return 0;
		memset(memo,-1,sizeof(memo));
		cout << dfs(n,s,9) << endl;
	}
	return 0;
}

Measured memory_bytes: 1948
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(C < D){
        ll tmp = C;
        C = D;
        D = tmp;
    }
    ll r;
    r = C*D/__gcd(C,D);
    ll ans = 0;
    ll first = (A + (C - 1)) / C,second = (B - A) / C;
    if((first + second) * C > B)second--;
    ans += second + 1;
    first = (A + (D - 1)) / D;
    second = (B - A) / D;
    if((first + second) * D > B)second--;
    ans += second +  1;
    first = (A + (r - 1)) / r,second = (B - A) / r;
    if((first + second) * r > B)second--;
    ans -= second + 1;
    cout << B - A + 1 - ans <<  "\n";
}


Measured memory_bytes: 384
import math


def m():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = [0] * n
    b[0] = a[0]
    ans = 0
    for i in range(1, n):
        b[i] = b[i-1] + a[i]
    d = dict()
    d[0] = 1
    for i in range(n):
        t = d.get(b[i]%m, 0)
        d[b[i]%m] = t+1
    for v in d.values():
        if v < 2:
            continue
        ans += math.factorial(v) // (math.factorial(v-2) * 2)
    return ans

print(m())

Measured memory_bytes: 17240
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(false)
#define For(i, x, y) for(int i = x; i <= y; i++)
#define For_(i, x, y) for(int i = x; i >= y; i--)
const int inf = 0x3f3f3f3f;
const ll Inf = 1e18;

int main(void)
{
	int n;
	cin >> n;
	int ans = 0;
	ans += n / 500 * 1000;
	n %= 500;
	ans += n / 5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(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 fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
class Eratosthenes{
  public:
    int n, sqlim;
    vector<bool> prime;
    Eratosthenes(int N):n(N+1){
        sqlim=(int)ceil(sqrt(n));
        prime=vector<bool>(n,1); prime[0]=prime[1]=0;
        for(int i=2;i<=sqlim;i++) if(prime[i]) for(int j=i*i;j<=n;j+=i) prime[j]=0;}
    vector<int> primeArray(int s=0, int l=10000){vi ret; for(int i=s;ret.size()!=l;i++) if(prime[i]) ret.push_back(i); return ret;}
};


int main(){
	int n;
	cin>>n;
	Eratosthenes e(100001);
	vi is(100000,0);
    for(int i=1;i<=99999;i+=2){
	    if(e.prime[i] && e.prime[(i+1)/2]){
	        is[i]=1;
	    }
	}
	partial_sum(all(is),is.begin());
	rep(i,n){
	    int l,r;cin>>l>>r;
	    cout<<is[r]-is[max(l-2,0)]<<endl;
	}
	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int w=sc.nextInt();
	int h=sc.nextInt();
	int x=sc.nextInt();
	int y=sc.nextInt();
	int r=sc.nextInt();
	String ans="Yes";
	if(x-r<0||x+r>w||y-r<0||y+r>h)ans="No";
	System.out.println(ans);
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26208
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n & 1) return (a * powmod(a, n - 1, mod)) % mod;
	return powmod((a * a) % mod, n / 2, mod);
}

int mod = 1000000007;
int n;
int fact[1000010];
int factInv[1000010];
int f[1000010];

void initFact() {
	fact[0] = 1;
	factInv[0] = 1;
	for (int i = 1; i < 1000010; i++) {
		fact[i] = (fact[i - 1] * i) % mod;
		factInv[i] = powmod(fact[i], mod - 2, mod);
	}
}

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

signed main() {
	int i;
	
	cin >> n;
	
	initFact();
	
	/*dp[1][1] = 1;
	for (i = 1; i <= n - 2; i++) {
		for (j = 1; j <= i; j++) {
			dp[i + 1][j + 1] += dp[i][j] * (j + 1); dp[i + 1][j + 1] %= mod;
			dp[i + 2][j + 1] += dp[i][j] * (j + 1); dp[i + 2][j + 1] %= mod;
		}
	}*/
	
	//f[j] = dp[n - 1][j] = fact[j] * comb[j - 1][n - 1 - j]. (1 <= j <= n - 1)
	for (i = 1; i < n; i++) {
		f[i] = fact[i] * comb(i - 1, n - 1 - i) % mod;
		//cout << i - 1 << " " << n - 1 - i << " " << comb(i - 1, n - 1 - i) << endl;
		//cout << "f[" << i << "] = " << f[i] << endl;
	}
	
	int ans = 0;
	for (i = 1; i <= n - 1; i++) {
		int cnt = (f[i] - (f[i - 1] * (n - i)) % mod + mod) % mod;
		cnt *= fact[n - 1 - i];
		cnt %= mod;
		//cout << "i = " << i << ", dp = " << dp[n - 1][i] << endl;
		//cout << i << " " << cnt << endl;
		ans += cnt * i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const ll MOD = 1e9+7;
int main()
{
    she_told_me_dont_worry
    ll n, k;
    cin>>n>>k;
    ll pos[n+5] = {}, pre[n+5] = {};
    ll i;
    FOR0(i, n+1)
    {
        pos[i] = i;
        pre[i] = i;
    }
    FOR(i, 1, n+1)
    {
        pre[i] += pre[i-1];
        pre[i] %= MOD;
    }
    FORD(i, n-1, 0)
    {
        pos[i] += pos[i+1];
        pos[i] %= MOD;
    }
    ll ans = 0;
    FOR(i, k, n+2)
    {
        ll cur = pos[n-i+1];
        cur -= pre[i-1];
        cur += MOD;
        cur %= MOD;
        cur++;
        cur %= MOD;
        ans += cur;
        ans %= MOD;
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 6868
import copy
N=int(input())
X=list(map(int,input().split()))

Y=copy.copy(X)
Y.sort()
center = N//2
right = Y[center]
left = Y[center-1]
center_line = (right+left)/2

for i in range(N):
  if X[i] > center_line:
    print(left)
  else:
    print(right)

Measured memory_bytes: 27156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string ans = "Yes";
  cin >> N;
  vector<string> W(N);
  for(int i=0;i<N;i++){
      cin >> W[i];
  }

  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
          if(W[i]==W[j]&&i!=j){
              ans = "No";
              break;
          }
      }

  }

  for(int i=0;i<N-1;i++){
      if(W[i].substr(W[i].size()-1,1)!=W[i+1].substr(0,1)){
          ans = "No";
          break;
      }
  }
    cout << ans << endl;
  
}


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

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

    vector<tuple<int, int, int> > v(n);
    int m = n / 2 + 1;
    for(int i=0; i<n; ++i){
        int a = k + i;
        int b;
        if(i < m)
            b = k + 2 * n - m + i;
        else
            b = k + n - m + i;
        v[i] = make_tuple(a + b, a, b);
    }
    sort(v.begin(), v.end());

    for(int i=0; i<n; ++i){
        int a, b, c;
        tie(c, a, b) = v[i];
        c = k + 2 * n + i;
        if(c < a + b){
            cout << -1 << endl;
            return 0;
        }
        v[i] = make_tuple(c, a, b);
    }

    for(int i=0; i<n; ++i){
        int a, b, c;
        tie(c, a, b) = v[i];
        cout << a << ' ' << b << ' ' << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
using namespace std;
 
int n, m, r, c;
int main()
{
	int i, j;
	cin >> n >> m >> r >> c;
	if (m % c > 0) {
		cout << "Yes" << endl;
		for (j = 0; j < n; j++) {
			for (i = 0; i < m; i++) {
				if (i % c == 0) printf("%d ", 1000 * (c - 1) - 1);
				else printf("-1000 ");
			}
			printf("\n");
		}
	} else if (n % r > 0) {
		cout << "Yes" << endl;
		for (j = 0; j < n; j++) {
			for (i = 0; i < m; i++) {
				if (j % r == 0) printf("%d ", 1000 * (r - 1) - 1);
				else printf("-1000 ");
			}
			printf("\n");
		}
	} else {
		cout << "No";
	}
    return 0;
}

Measured memory_bytes: 1664
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        
        int xx = Integer.parseInt(s.substring(0,2));
        int yy = Integer.parseInt(s.substring(2,4));
        String ret = "";
        boolean xIsMonth = 1 <= xx && xx <= 12;
        boolean yIsMonth = 1 <= yy && yy <= 12;
        if(xIsMonth && yIsMonth) {
            ret = "AMBIGUOUS";
        } else if(xIsMonth && !yIsMonth) {
            ret = "MMYY";
        } else if(!xIsMonth && yIsMonth) {
            ret = "YYMM";
        } else {
            ret = "NA";
        }
        System.out.println(ret);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main()
{
        int n;
        scanf("%d\n", &n);
        while(n--){
                double x1,y1,x2,y2,x3,y3,x4,y4;
                scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
                printf("%s\n",((y1-y2)/(x1-x2))==((y3-y4)/(x3-x4))?"YES":"NO");
        }
        return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    long long int n,a,b;
    cin>>n>>a>>b;
    cout<<(n/(a+b))*a+min(a,n%(a+b))<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	string s;
	cin >> s;
	if (s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes" << endl;
	else cout << "No" << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
const int mod = 1000000007;

void Main(){
  int n;
  cin>>n;
  vl a(n);
  cin>>a;
  ll sum = accumulate(rng(a),0ll);
  ll es = 0;
  rep(i,n){
    if(i%2==1){
      es+=a[i];
    }
  }
  es*=2;
  ll x = sum-es;
  cout<<x<<" ";
  rep(i,n-1){
    x = 2*a[i]-x;
    cout<<x<<" ";
  }
  cout<<endl;
} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

bool is_war (const vi &x, const vi &y) {
  return *max_element(all(x)) >= *min_element(all(y));
}

int main() {
  int N, M; cin >> N >> M;
  vi x(N+1), y(M+1);
  cin >> x.at(0) >> y.at(0);
  rep(i,N) cin >> x.at(i+1);
  rep(i,M) cin >> y.at(i+1);
  
  if (is_war(x,y))
    cout << "War" << endl;
  else
    cout << "No War" << endl;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
T=[a for a in T]
answer=0
takahashi=[]
if N%K==0:
    number=(N/K-1)*K
else:
    number=(N//K)*K
for a in range(K):
    if T[a]=='r':
        answer+=P
        takahashi.append('p')
    elif T[a]=='s':
        answer+=R
        takahashi.append('r')
    else:
        answer+=S
        takahashi.append('s')
for a in range(K,int(number)):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            if a+K<N:
                if T[a + K] == 's':
                    takahashi.append('s')
                else:
                    takahashi.append('r')
            else:
                pass
        else:
            answer+=P
            takahashi.append('p')
    elif T[a]=='s':
        if takahashi[a-K]=='r':
            if a+K<N:
                if T[a + K] == 'p':
                    takahashi.append('p')
                else:
                    takahashi.append('s')
            else:
                pass
        else:
            answer+=R
            takahashi.append('r')
    else:
        if takahashi[a-K]=='s':
            if a+K<N:
                if T[a + K] == 'r':
                    takahashi.append('r')
                else:
                    takahashi.append('p')
            else:
                pass
        else:
            answer+=S
            takahashi.append('s')
for a in range(int(number),N):
    if T[a]=='r':
        if takahashi[a-K]=='p':
            pass
        else:
            answer+=P
    elif T[a]=='s':
        if takahashi[a-K]=='r':
           pass
        else:
            answer+=R
    else:
        if takahashi[a-K]=='s':
            pass
        else:
            answer+=S
print(answer)


Measured memory_bytes: 4920
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int main(){
	char S[27];
	char c, s;
	int l, i, j, b = 0, k, p = -1;

	scanf("%s", S);
	l = strlen(S);
	S[l] = 'a'-1;
	for (i = l; i >= 0; i--){
		for (c = S[i]+1; c <= 'z'; c++){
			b = 0;
			for (j = 0; j < i; j++){
				if (c == S[j]){
					b = -1;
				}
			}
			if (b != -1){
				k = i;
				s = c;
				p = 0;
				break;
			}
		}
		if (b != -1){
			break;
		}
	}

	if (p == -1){
		printf("-1\n");
	}
	else{
		for (i = 0; i < k; i++){
				printf("%c", S[i]);
		}
		if (k != 26){
			printf("%c\n", s);
		}
	}

	return 0;
}

Measured memory_bytes: 128
a, b = map(int, input().split())
s = str(input())

s1 = s[:a]
s2 = s[a:a+1]
s3 = s[a+1:]

if s2 == '-':
    if str.isdigit(s1) and len(s1) == a and str.isdigit(s3):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 9048
#include <iostream>

#define REP(i, n) for(int i=0; i<n; i++) 
#define MOD 1000000007

typedef long long ll;
using namespace std;

int main() {
	string S;
	ll dp[4] = { 0 }, dp_next[4];
	int m;

	cin >> S;
	dp[0] = 1;

	for (const char& s : S) {
		if (s == '?') m = 3;
		else m = 1;

		REP(i, 4) dp_next[i] = m * dp[i];

		if (s == '?' or s == 'A') dp_next[1] += dp[0];
		if (s == '?' or s == 'B') dp_next[2] += dp[1];
		if (s == '?' or s == 'C') dp_next[3] += dp[2];

		REP(i, 4) dp[i] = dp_next[i] % MOD;
	}

	cout << dp[3] << endl;

	return 0;
}

Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))

a.sort()
a.reverse()
b = []
c = []
for i in range(N):
    if i % 2 == 0:
        b.append(a[i])
    else:
        c.append(a[i])
b_sum = 0
c_sum = 0
for i in b:
    b_sum += i
for i in c:
    c_sum += i

print(b_sum - c_sum)

Measured memory_bytes: 3064