akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#define LL long long
#define maxn 200010
using namespace std;
int a[maxn],n,cnt[maxn],mx;
LL ans,out;
int main(){
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),cnt[a[i]]++,mx=max(mx,a[i]);
	for(i=1;i<=mx;i++)
		if(cnt[i]>=2)ans+=(LL)cnt[i]*(cnt[i]-1)/2;
	for(i=1;i<=n;i++){
		if(cnt[a[i]]>=2){
			out=ans-cnt[a[i]]*(cnt[a[i]]-1)/2;
			out+=(cnt[a[i]]-1)*(cnt[a[i]]-1-1)/2;
		}else out=ans;
		printf("%lld\n",out);
	}
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll s;
  cin >> s;
  ll power9 = (ll)1e+9;
  ll a = (s - 1 + power9) / power9;
  ll b = a * power9 - s;

  cout << 0 << " " << 0 << " " << (ll)1e+9 << " " << 1 << " " << b << " " << a
       << endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {

	char N[16];

	scanf("%s", &N);

	int s = 0, n = atoi(N);

	for (int i = 0; N[i] != '\0'; i++) {
		s += N[i] - '0';
	}

	printf("%s", (n%s) ? "No" : "Yes");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include <vector>
#include <queue>
#include <algorithm>
#include <time.h> 
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    //code goes here
    int A, B, T;
    cin >> A >> B >>T;
    int run = T/A;
    cout<<run*B;
}


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

int main() {
  char a, b;
  cin >> a >> b;
  if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
    cout << 'H' << endl;
  }
  else {
    cout << 'D' << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
long N;
//写経
void display(vector<long> c){
    for(int i = 0; i < c.size(); i++){
        cout << c.at(i) << " ";
    }
    cout << endl;
}
//ベクトル傾き
double coef(long x,long y,long X,long Y){
    return atan2(Y-y,X-x);
}
double arc(double a,double b){
    //角度の差を調べる
    if(b >= a){
        return b-a;
    }
    return 2*PI - a + b;
}
double angle(long i,long j,long k,vector<long> x,vector<long> y){
    ////i to j to kの反時計回りの角。0<=i,j,k<x.size()=y.size()
    return arc(coef(x.at(i),y.at(i),x.at(j),y.at(j)),coef(x.at(j),y.at(j),x.at(k),y.at(k)));
}
int main(){
    cin >> N;
    vector<long> x(N+1),y(N+1);
    for(int i = 1; i <= N; i++){
        cin >> x.at(i) >> y.at(i);
    }
    vector<long> c(2);
    c.at(0) = 0;
    c.at(1) = 1;
    long tmp = y.at(1); 
    for(int i = 2; i <= N; i++){
        if(tmp < y.at(i)){
            tmp = y.at(i);
            c.at(1) = i;
        }
    }
    x.at(0) = x.at(c.at(1)) + 1;
    y.at(0) = y.at(c.at(1));
    long last = 1;
    while(c.at(1) != c.at(last) || last == 1){
        double tmp = 3*PI; 
        long kouho;
        for(int i = 1; i <= N; i++){
            if(i != c.at(last)){
                if(angle(c.at(last-1),c.at(last),i,x,y) < tmp){
                    tmp = angle(c.at(last-1),c.at(last),i,x,y);
                    kouho = i;
                }
            }
        }
        c.push_back(kouho);
        last++;
    }
    c.at(0) = c.at(last-1);
    vector<double> ans(N+1);
    for(int i = 1; i < last; i++){
        ans.at(c.at(i)) = angle(c.at(i-1),c.at(i),c.at(i+1),x,y)/(2*PI);
    }
    for(int i = 1; i <= N; i++){
        cout << ans.at(i) << endl;
    }
}


Measured memory_bytes: 256
s = input()
t = input()

dp = [[0] * (len(t) + 1) for i in range(len(s) + 1)]

for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

nums = len(s)
numt = len(t)
d = dp[nums][numt]
ans = ""

while True:
    if d == 0:
        break
    if dp[nums - 1][numt] == d:
        nums -= 1
    elif dp[nums][numt - 1] == d:
        numt -= 1
    else:
        ans += s[nums - 1]
        nums -= 1
        numt -= 1
        d -= 1

print(ans[::-1])


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

typedef pair<int,int> PII;

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

	if(s=="keyence"){
		cout<<"YES"<<endl;
		return 0;
	}

	int n=s.size();
	for (int i = 0; i < n; ++i){
		for (int j = i; j < n; ++j){
			string str="";
			for (int k = 0; k < n; ++k){
				if(i<=k&&k<=j)
					continue;
				else
					str.push_back(s[k]);
			}
			if(str=="keyence"){
				cout<<"YES"<<endl;
				return 0;
			}
		}
	}

	cout<<"NO"<<endl;

}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn main() {
    loop {
        let mut buf1 = String::new();
        io::stdin().read_line(&mut buf1).ok();
        let n: usize = buf1.trim().parse().unwrap();
        if n == 0 {
            return;
        }

        let mut buf2 = String::new();
        io::stdin().read_line(&mut buf2).ok();
        let mut a: Vec<_> = buf2.split_whitespace().map(|n| u32::from_str(n).unwrap()).collect();

        a.sort();
        let mut ans = 1_000_001;
        for i in 0..a.len() - 1 {
            if a[i + 1] - a[i] < ans {
                ans = a[i + 1] - a[i];
            }
        }
        println!("{}", ans);
    }
}



Measured memory_bytes: 5048
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string s,temp;
	int str[128][52];
	memset(str,-1,sizeof(str));
	int len = 0,cnt=0;
	while(cin >> s){
		temp = "";
		for(int i = 0,j = 0; i < s.size(); i++){
			if(s[i] == ','){
				j++;temp="";
			}
			else {
				temp += s[i];
				str[cnt][j] = atoi(temp.c_str());
			}
		}
		cnt++;
	}
	len = cnt/2+1;
	int dp[51][51] = {{0}};
	for(int i = 0; i < cnt; i++){
		int x = i+1;
		int y = i-len+2;
		for(int j = 0; j < len; j++){
			if(str[i][j] == -1){
				continue;
			}
			if(i < len){
				dp[x--][j+1] = str[i][j];
			}
			else{
				dp[len-j][y++] = str[i][j];
			}
		}
	}
	for(int i = 1; i <= len; i++){
		for(int j = 1; j <= len; j++){
			dp[i][j]+=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	cout << dp[len][len] << endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[5][30];
int main()
{
    ll N;
    cin >> N;
    REP(i, 3)
    {
        REP(j, N)
        {
            cin >> A[i][j];
        }
    }

    ll s = 0;
    REP(i, N)
    {
        s += A[1][i];
        if (i > 0)
        {
            if (A[0][i] == A[0][i - 1] + 1)
            {
                s += A[2][A[0][i - 1] - 1];
            }
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int maxn=1e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin >> a>> b >> c;
    if(a==b&&a==c&&b==c)
        cout << "No" << endl;
    else if(a!=b&&a!=c&&b!=c)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N, W, maxx = 0, kq;
long long f[109][100009];
struct item
{
    long long w;
    int v;
};
item a[109];
long tmp(item x, item y)
{
    return x.v < y.v;
}
void init()
{
    cin >> N >> W;
    for(int i = 1; i <= N; ++ i)
    {
        cin >> a[i].w >> a[i].v;
    }
}
void process()
{
    for (int i = 0; i <= 101; ++ i)
    {
        for (int j = 1;j <= 100001; ++ j)
        {
            f[i][j] = 1e17 + 9;
        }
    }
    for(int i = 1; i <= N; ++ i) f[i][0] = 0;
    for(int i = 1; i <= N; ++ i)
    {
        for(int j = 1; j <= 100001; ++ j)
        {
            f[i][j] = f[i - 1][j];
            if(a[i].v <= j)
            {
                f[i][j] = min(f[i - 1][j], f[i - 1][j - a[i].v] + a[i].w);
            }
        }
    }
    for(int i = 1; i <= 100001; ++ i)
    {
        if(f[N][i] <= W)
        {
            kq = i;
        }
    }
    cout << kq;
}
int main()
{
    init();
    process();
    return 0;
}


Measured memory_bytes: 80128
import sys
import itertools

N = int(input())
l = [x+1 for x in range(N)]
P = tuple(map(int, input().split(' ')))
Q = tuple(map(int, input().split(' ')))
if P == Q:
    print(0)
    sys.exit()

for i, v in enumerate(itertools.permutations(l, N)):
    if v == P:
        a = i+1
    elif v == Q:
        b = i+1
print(abs(a-b))

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int ans=0;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        ans+=2*min(a,abs(a-K));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			String[] before = new String[n];
			String[] after = new String[n];
			for(int i = 0; i < n; i++) {
				before[i] = stdIn.next();
				after[i] = stdIn.next();
			}
			
			int nm = stdIn.nextInt();
			for(int i = 0; i < nm; i++) {
				String tmp = stdIn.next();
				boolean cc = false;
				for(int j = 0; j < n; j++) {
					if(before[j].charAt(0) == tmp.charAt(0)) {
						System.out.print(after[j]);
						cc = true;
						break;
					}
				}
				if(!cc) {
					System.out.print(tmp);
				}
			}
			System.out.println();
			
			
			
		}
	}
}

Measured memory_bytes: 68280
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD2 = (long long)13; 
const long long MOD = (long long)1e9+7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	int con = 0;
	vector<int> c;
	
	cin>>s;
	
	c.resize(MOD2,0);
	
	for(int i = s.size()-1, j = 1; i >= 0; i--, j = (j*10)%MOD2){
		if(s[i] != '?'){
			con += (s[i] - '0')*j;
			con %= MOD2;
		}
	}
	c[con] = 1;
	
	for(int i = s.size()-1, j = 1; i >= 0; i--, j = (j*10)%MOD2){
		if(s[i] != '?'){
		} else {
			// cout<<"j = "<<j<<endl;
			int temp[MOD2] = {};
			for(int k = 0; k < MOD2; k++){
				if(!c[k]) continue;
				for(int l = 0; l <= 9; l++){
					temp[(l*j+k)%MOD2] += c[k];
					temp[(l*j+k)%MOD2] %= MOD;
					
					// cout<<"k = "<<k<<" l = "<<l<<" <><> "<<(l+j+k)%MOD2<<endl;
				}
			}
			for(int k = 0; k < MOD2; k++){
				c[k] = temp[k]%MOD;
			}

		
		}
		
	
	}
	// cout<<"con = "<<con<<endl;
	
	// cout<<"---"<<endl;
	// for(int y: c){
		// cout<<y<<endl;
	// }
	// for(int i = 0; i < 10; i++){
		// int xx = 700 + 4 + i*10;
		// cout<<xx<<" MOD 13 = "<<xx%13<<endl;
	// }
	cout<<c[5]<<endl;
	
	
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef	    long long       ll;
typedef	    vector<ll>      vll;
#define     pb              push_back
#define	    PB              pop_back
#define	    nn              "\n"
#define	    all(p)          p.begin(),p.end()
#define	    zz(v)           (ll)v.size()
#define	    mms(ar,a)       memset(ar,a,sizeof(ar))
#define	    ss              ' '
#define     S(a)            scanf("%lld",&a)
#define     SS(a,b)         scanf("%lld %lld",&a,&b)
#define     SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define     P(a)            printf("%lld\n",a)
#define     PP(a,b)         printf("%lld %lld\n",a,b)
#define	    gcd(a,b)        __gcd(a,b)
#define	    lcm(a,b)        (a*b)/gcd(a,b)
#define	    pi              acos(-1.0)
#define	    OO              1000000007

int main(){
//    freopen("input.txt","r",stdin);
    ll a,b,c=0,i,j,t,k,lie,m,n,o,x,y,z;
    string s;
    cin>>s;
    if(s[0]!=s[1] and s[2]!=s[1] and s[2]==s[3] and s[4]==s[5]) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
s = int(input())
last = str(input())
wordlist = [last]
ans = "Yes"

for i in range(s-1):
    word = str(input())

    if last[-1] != word[0]:
        ans = "No"
        break
    
    elif word in wordlist:
        ans = "No"
        break

    last = word
    wordlist.append(word)

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,r,cnt,yet,cc,c[5005],x[5005],f[5005][5005],num[2];
long long a[2][5005],fact[5005];
vector<int> g[5005];
inline long long P(long long a,int b){
	long long res=1;
	while(b){
		if(b&1){
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
inline void DFS(int u){
	c[u]=cc;
	cnt++;
	if(x[u]==-1){
		yet=1;
	}
	for(int v:g[u]){
		if(!c[v]){
			DFS(v);
		}
	}
}
int main(){
	cin>>n;
	fact[0]=1;
	for(int i=1;i<=n;++i){
		cin>>x[i];
		if(x[i]>0){
			g[i].push_back(x[i]);
			g[x[i]].push_back(i);
		}
		fact[i]=(fact[i-1]*i)%mod;
	}
	for(int i=1;i<=n;++i){
		if(!c[i]){
			cc++;
			cnt=yet=0;
			DFS(i);
			a[1-yet][num[1-yet]++]=cnt;
		}
	}
	f[0][0]=1;
	for(int i=0;i<num[0];++i){
		for(int j=0;j<=i;++j){
			if(f[i][j]){
				f[i+1][j]=(f[i+1][j]+f[i][j])%mod;
				f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*a[0][i])%mod; 
			}
		}
	}
	for(int i=0;i<num[0];++i){
		if(a[0][i]>1){
			r=(r+P(n-1,num[0]-1)*(a[0][i]-1))%mod;
		}
	}
	for(int i=0;i<num[1];++i){
		r=(r+P(n-1,num[0]))%mod;
	}
	for(int i=2;i<=num[0];++i){
		r=(r+(f[num[0]][i]*fact[i-1])%mod*P(n-1,num[0]-i))%mod;
	}
	cout<<((P(n-1,num[0])*n%mod+mod-r)%mod)<<'\n';
	return 0;
} 

Measured memory_bytes: 70660
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int p,o;
  string s;
  cin>>s;
  r(i,s.size())if(s[i]=='A'){p=i;break;}
  for(int i=s.size()-1;i>=0;i--)if(s[i]=='Z'){o=i;break;}
    cout<<o-p+1<<endl;
}

Measured memory_bytes: 768
fun main(args: Array<String>) {
    abc123b()
}

fun abc123b() {
    val menu = (1..5).map { readLine()!!.toInt() }.toMutableList()
    // 1の位が一番小さいものを一番最後に注文する(ただし0は一番大きいとする)
    val lastOrder = menu.minBy { (it - 1) % 10 }!!
    menu.remove(lastOrder)
    // ほかは10の位で繰り上げ(10分単位でしか注文できないので)
    val answer = menu.map { (((it - 1) / 10) + 1) * 10 }.sum() + lastOrder

    println(answer)
}


Measured memory_bytes: 31808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N, K;
  cin >> N >> K;
  int ans = N - K;
  if (K == 1)
    ans = 0;
  cout << ans << endl;
  return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
long long mod_div(long long a,long long b){
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}
 
#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
    if(n < r || n < 0 || r < 0)
        return 0;
	if(kaijo[0] != 1){
		kaijo[0] = 1;
		for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
	}
    long long ret = kaijo[n];
	long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
    return mod_div(ret,tmp);
}
 
ll dp[3333][2];
 
void modadd(ll &a, ll b){
	a += b;
	a %= MOD;
}
int main(){
  int h,w,n;cin>>h>>w>>n;
  dp[0][0]=1;
  vector<pair<int,int>>kabe(n);
  for(int i=0;i<n;i++){
    int a,b;
    scanf("%d %d",&a,&b);
    kabe[i]=mp(a,b);
  }
  kabe.pb(mp(1,1));
  kabe.pb(mp(h,w));
  sort(ALL(kabe));
  for(int i=0;i<kabe.size();i++){
    for(int k=0;k<2;k++){
      if(dp[i][k]){
	for(int j=i+1;j<kabe.size();j++){
	  if(kabe[i].F<=kabe[j].F&&kabe[i].S<=kabe[j].S){
	    modadd(dp[j][(k+1)%2],dp[i][k]*combination((kabe[j].F-kabe[i].F)+(kabe[j].S-kabe[i].S),min(kabe[j].S-kabe[i].S,kabe[j].F-kabe[i].F))%MOD);
	  }
	}
      }
    }
  }
  cout<<(dp[n+1][1]-dp[n+1][0]+MOD)%MOD<<endl;
  return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n;cin>>n;ll a[n];ll ans = 0;
for(int i = 0;i<n;i++){cin>>a[i];ll cnt = 0;while(a[i]%2==0){a[i]/=2;cnt++;}ans+=cnt;}
cout<<ans;
return 0;
}

Measured memory_bytes: 384
import numpy as np

n, l = [int(i) for i in input().split(" ")]

nl = np.array([i for i in range(n)]) + 1
ll = nl + l - 1

mini = np.where(np.absolute(ll) == np.min(np.absolute(ll)))
ll = list(ll)
del ll[mini[0][0]]

print(np.sum(ll))

Measured memory_bytes: 12408
#include<stdio.h>
#include<math.h>

int main()
{
	double a,b,c,C;
	double rad;
	double S,L,h;
	scanf("%lf %lf %lf",&a,&b,&C);
	rad = C * M_PI/180.0f;
	
	h=b*sin(rad);//a???????????¨??????????????????
	S=a*h*0.5f;//??¢???
	c=sqrt(a*a+b*b-2*a*b*cos(rad));
	L=a+b+c;
	
	printf("%lf\n%lf\n%lf\n",S,L,h);
	return 0;
}

Measured memory_bytes: 648
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.println((a < 9 && b < 9) ? "Yay!": ":(");
	}
}


Measured memory_bytes: 35824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5;
vector<pair<ll,ll> >v(N);
ll dp[N][N];
int n;
ll fun(int l,int r){
	if(l>r) return 0;
	if(dp[l][r]) return dp[l][r];
	int i=n-(r-l+1);
	return dp[l][r]=max(fun(l,r-1)+v[i].first*(r-v[i].second),fun(l+1,r)+v[i].first*(v[i].second-l));
}
int main(){
	scanf("%d",&n);
	for(int i=0,x;i<n;i++)
		scanf("%d",&x),v.push_back({x,i});
	sort(v.rbegin(),v.rend());
	fun(0,n-1);
	printf("%lld\n",dp[0][n-1]);
	return 0;
}

Measured memory_bytes: 26604
#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>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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 complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  ll A[100010];
  ll B[100010];
  
  rep(i,N+1){
    cin>>A[i];
  }
  rep(i,N){
    cin>>B[i];
  }
  
  ll count=0;
  
  rep(i,N){
    if((A[i]+A[i+1])>=B[i]&&B[i]>A[i]){
      count+=B[i];
      A[i+1]=A[i+1]+A[i]-B[i];
    }
    else if(B[i]>(A[i]+A[i+1])){
      count+=A[i]+A[i+1];
      A[i+1]=0;
    }
    else if(B[i]<=A[i]){
      count+=B[i];
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1792
S=input()
N=int(S)
keta=len(S)
ans=[[0]*10 for _ in range(10)]
fa=0
for A in range(1,N+1):
    ns=str(A)
    tailA=int(ns[-1])
    if tailA==0: continue
    headA=int(ns[0])
    if ans[headA][tailA]==0:
        dp=[[[0]*2 for __ in range(2)] for _ in range(keta+1)]
        dp[0][0][1]=1
        for i in range(keta):
            x=int(S[i])
            for j in range(2):
                for k in range(2):
                    for n in range(10):
                        ni=i+1
                        nj=1 if j==1 or n>0 else 0
                        nk=1 if k==1 and n==x else 0
                        if k==1 and n>x: continue
                        if j==0 and nj==1 and n!=tailA: continue
                        if ni==keta and n!=headA: continue
                        dp[ni][nj][nk]+=dp[i][j][k]
        for k in range(2):
            ans[headA][tailA]+=dp[keta][1][k]
    fa+=ans[headA][tailA]
print(fa)

Measured memory_bytes: 46188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
 
const double EPS = 1e-10;
 
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

set<ll> divisor(ll n){
    set<ll> s;
    for(ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            s.insert(i);
            s.insert(n/i);
        }
    }
    return s;
}

int main(){
    int N,K; cin >> N >> K;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int sum = 0;
    rep(i,N) sum += a[i];
    set<ll> div = divisor(sum);
    int ans = 0;
    for(int u : div){
        vector<int> b = a;
        rep(i,N) b[i] %= u;
        sort(b.begin(),b.end());
        vector<int> sum2(N+1);
        rep(i,N) sum2[i+1] = sum2[i]+u-b[i];
        int sum = 0;
        rep(i,N){
            sum += b[i];
            if(sum == sum2[N]-sum2[i+1] && sum <= K){
                ans = max(ans,u);
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

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

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	int n;
	cin >> n;
	vector<char> c(n);
	int rCount = 0;
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		if (c[i] == 'R') rCount++;
	}
	int ans = 0;
	for (int i = rCount; i < n; i++) {
		if (c[i] == 'R') ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc170_a.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vi a(5);
  REP(i, 5) { cin >> a[i]; }

  REP(i, 5) {
    if (a[i] == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;
vector<vector<ll>>adj(2001);
vector<ll>used(2001,0);
vector<ll>ans(2001,0);
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,y,r,k,d,m,t,a,b,n,x,temp;
	cin>>n>>m;
	ll arr[n+1]={0};
	for(i=1;i<=n;i++)
	{
	    cin>>arr[i];
	}
	vector<vector<ll>>adj(n+1),end(n+1);
	
	while(m--)
	{
	    cin>>a>>b;
	    adj[a].pb(b);
	    adj[b].pb(a);
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
	    if(adj[i].size()==0)
	    ans++;
	    else 
	    {
	        for(auto u:adj[i])
	        {
	            if(arr[u]>=arr[i])
	            {
	                ans--;
	                //cout<<i;
	                break;
	            }
	        }
	        ans++;
	    }
	}
	cout<<ans;
	return 0;
	
	
}

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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define print(x)				cout<<x<<endl
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
const long long MOD= 1000000007;


void solve(){
    int n; cin>>n;
    if(n % 1000 == 0)cout<<0<<endl;
    else{
        int k = n/1000;
        int ans = (1000*(k+1))-n;
        print(ans);
    }
}
int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

    int t =1 ;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define boostIO                   \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repn(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, b, a) for (int i = b; i >= a; i--)
#define sz(v) (int)(v.size())
#define all(v) v.begin(), v.end()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define trav(a, x) for (auto &a : x)
#define pb push_back
#define fi first
#define se second
#define int long long
#define mod 1000000007
#define rem 998244353
#define MAXN 1000005
const int INF = 1e18;
typedef pair<int, int> pii;

int sp[MAXN + 1];
bool vis[MAXN + 1];
void Seive() {
    rep(i, 1, MAXN) sp[i] = i;
    for (int i = 4; i <= MAXN; i += 2) sp[i] = 2, vis[i] = true;
    for (int i = 3; i * i <= MAXN; i += 2) {
        if (vis[i]) continue;
        sp[i] = i;
        for (int j = i * i; j <= MAXN; j += i) {
            if (vis[j]) continue;
            sp[j] = i;
            vis[j] = true;
        }
    }
}

signed main() {
    boostIO;
    Seive();
    map<int,int> is;
    bool ok = true;
    int n, hcf, x; 
    cin >> n >> hcf;
    x = hcf;
    while(x != 1){
        is[sp[x]] = 1;
        x /= sp[x];
    }
    for(int i = 1, x; i < n; i++){
        cin >> x;
        hcf = __gcd(hcf, x);
        int y = x;
        while(x != 1){
            if(is[sp[x]]) ok = false;
            x /= sp[x];
        }
        while(y != 1){
            is[sp[y]] = 1;
            y /= sp[y];
        }
    }
    if(ok){
        cout << "pairwise coprime\n";
    }
    else{
        if(hcf == 1){
            cout << "setwise coprime\n";
        }
        else{
            cout << "not coprime\n";
        }
    }
    return 0;
}
// XD

Measured memory_bytes: 17272
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, C, K, i;

    cin >> A >> B >> C;
    cin >> K;

    for(i=1; i<=K; i++){
        if(A>=B && A>=C){
            A *= 2;
        }
        else if(B>=A && B>=C){
            B *= 2;
        }
        else{
            C *= 2;
        }
    }

    cout << A+B+C << endl;
}

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


typedef long long int ll;

vector<ll> adj[1000001]; 


#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define rep(i,st,end) for( i=st;i<end;i++)
#define repv(i,st,end) for( i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST cin>>tc;while(tc--)

int main()
{
    string na;
    cin>>na;
    int f=0;
    for(int i=0;i<na.length();i++)
    {
        if(na[i]=='7')
        {
            f=1;
            break;
        }
    }
    if(f==0)
        cout<<"No";
    else
        cout<<"Yes";
}

Measured memory_bytes: 27060
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back


template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//











int main(){
        Int n,m;
        cin >> n >> m;

        m /= 2;

        Int ans = n + m;
        ans /= 2;
        ans = min(ans,m);

        cout << ans << endl;
                
}



















Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# 文字列の入力
S = str(input())

#入力文字列Sの文字数の半分の情報を取得
half = len(S) // 2

# 文字列Sの分割
T1, T2 = S[:half], S[half:]

ANS = 'No'

if(T1==T2):
    ANS='Yes'

print(ANS)

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

int main() {
	long int a, b, k;
	cin >> a >> b >> k;

	if (a >= k) cout << a - k << " " << b << endl;
	else if (a + b >= k) cout << 0 << " " << b - (k - a) << endl;
	else cout << 0 << " " << 0 << endl;

 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;

    vector<int> ans(n);
    for (int i=0; i<n; i++) {
        queue<pair<int, int>> q;
        q.push({i, 0});
        vector<bool> vis(n);
        
        while (!q.empty()) {
            auto cur = q.front();
            q.pop();
            if (vis[cur.first]) continue;
            if (cur.first > i)
                ans[cur.second]++;
            vis[cur.first] = true;
            if (cur.first != n-1) q.push({cur.first+1, cur.second+1});
            if (cur.first != 0) q.push({cur.first-1, cur.second+1});
            if (cur.first == x) q.push({y, cur.second+1});
        }
    }
    for (int i=1; i<n; i++) cout << ans[i] << "\n";
}


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

#include <atcoder/all>
typedef long long lint;
using namespace std;
using namespace atcoder;

int n, m;

int main() {
    cin >> n >> m;
    scc_graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto res = g.scc();
    cout << res.size() << endl;
    for (auto e : res) {
        cout << e.size() << ' ';
        for (auto v : e) {
            cout << v << ' ';
        }
        cout << endl;
    }
}

Measured memory_bytes: 40580
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;


int main(void) {

    ll N; cin>>N;
    int K; cin>>K;
    ll cnt=0;
    while(N>0){
        N/=K;
        cnt++;
    }

    cout<<cnt<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000ll
#define LLINF 2000000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 998244353ll // prime
// How to devide :
// ModInt a(6ll);
// ModInt b(2ll);
// a *= b.exp(MOD-2ll);  -> a/=b;  result: a = 3
struct ModInt{
	ll val;
	ModInt():val(0ll){}
	ModInt(ll v):val(((v%MOD)+MOD)%MOD){}
	ModInt exp(ll y)const{
		if(!y)return ModInt(1ll);
		ModInt a = exp(y/2ll);
		a *= a;
		if(y&1)a*=(*this);
		return a;
	}
	bool operator==(const ModInt& x)const{return val==x.val;}
	inline bool operator!=(const ModInt& x)const{return !(*this==x);}
	bool operator<(const ModInt& x)const{return val<x.val;}
	bool operator>(const ModInt& x)const{return val>x.val;}
	inline bool operator>=(const ModInt& x)const{return !(*this<x);}
	inline bool operator<=(const ModInt& x)const{return !(*this>x);}
	ModInt& operator+=(const ModInt& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator-=(const ModInt& x){if((val+=MOD-x.val)>=MOD)val-=MOD;return *this;}
	ModInt& operator*=(const ModInt& x){(val*=x.val)%=MOD;return *this;}
	ModInt operator+(const ModInt& x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt& x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt& x)const{return ModInt(*this)*=x;}
};
istream& operator>>(istream&i,ModInt&x){i>>x.val;return i;}
ostream& operator<<(ostream&o,const ModInt&x){o<<x.val;return o;}
string s;
set<string> se;
queue<string> q;
ModInt dp[200100][2][3][3];
int main(){
	cin >> s;
	bool al = true;
	for(int i=0;i<s.size();i++){
		if(s[i]!=s[0])al=false;
	}
	if(al){
		cout << 1 << endl;
		return 0;
	}
	if(s.size()<=3){
		q.push(s);
		se.insert(s);
		while(!q.empty()){
			string a = q.front();
			q.pop();
			for(int i=0;i+1<a.size();i++){
				if(a[i]!=a[i+1]){
					string b = a;
					for(char c='a';c<='c';c++){
						if(c!=a[i]&&c!=a[i+1]){
							b[i]=b[i+1]=c;
							break;
						}
					}
					if(se.find(b)==se.end()){
						q.push(b);
						se.insert(b);
					}
				}
			}
		}
		cout << se.size() << endl;
		return 0;
	}
	for(int i=0;i<3;i++)dp[0][0][i][i]=ModInt(1ll);
	for(int i=0;i+1<s.size();i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				for(int l=0;l<3;l++){
					if(j==l)dp[i+1][1][l][(k+l)%3]+=dp[i][0][j][k];
					else dp[i+1][0][l][(k+l)%3]+=dp[i][0][j][k];
					dp[i+1][1][l][(k+l)%3]+=dp[i][1][j][k];
				}
			}
		}
	}
	int sk = 0;
	for(int i=0;i<s.size();i++)sk = (sk+(s[i]-'a'))%3;
	bool check = false;
	for(int i=0;i+1<s.size();i++){
		if(s[i]==s[i+1])check = true;
	}
	ModInt ans;
	for(int i=0;i<3;i++)ans += dp[s.size()-1][1][i][sk];
	if(!check)ans += ModInt(1ll);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 28800
using System;
using System.Text;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        int[] a = sc.IntArray();

        var sb = new StringBuilder();
        for (int i = k; i < n; i++)
        {
            sb.AppendLine(a[i - k] < a[i] ? "Yes" : "No");
        }

        Console.Write(sb);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 49008
#include<stdio.h>

int main(){
int yama[10];
int temp;
int i,j;

for(i=0;i<10;i++){
scanf("%d",&yama[i]);
}

for(i=0;i<10;i++){
for(j=0;j<10;j++){
if(yama[i]>yama[j]){
temp=yama[i];
yama[i]=yama[j];
yama[j]=temp;
}
}
}
for(i=0;i<3;i++){
printf("%d\n",yama[i]);
}
return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
void call(int);

int main()
{
    int n;
    scanf("%d", &n);
    call(n);
    return 0;
}

void call(int n)
{
    int i, x;
    for (i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            printf(" %d", i);
        } else {
            x = i;
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    break;
                }
            } while (x /= 10);
        }
    }
    putchar('\n');
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 5e5 + 100;
using ll = long long;
const int M = 1e9 + 7;
vector<pair<int,int> >v1[maxn], v3[maxn], v2[maxn];
int tot = 0;
int vis[maxn];
void dij(int st,int en)
{
    static int dis[maxn];
    for(int i = 0;i <= tot; ++i) dis[i] = inf,vis[i] = 0;
    priority_queue<pair<int,int>, vector<pair<int,int> >, greater<pair<int,int>> >q;
    dis[st] = 0;
    q.push({0,st});
    while(!q.empty())
    {
        pair<int,int> tp = q.top();
        q.pop();
        vis[tp.second] = 0;
        for(auto &u:v3[tp.second])
        {
            if(dis[u.first] > dis[tp.second] + u.second)
            {
                dis[u.first] = dis[tp.second] + u.second;
                if(!vis[u.first]) 
                vis[u.first] = 1, q.push({dis[u.first],u.first});
            }
        }
    }
    int ans = dis[en];
    if(ans==inf) ans = -2;
    printf("%d\n",ans/2);
}
int main()
{
  //  freopen("1.in","r",stdin);
 //   freopen("1.out","w",stdout);
    int n, m;
  //  clock_t c1 = clock(),c2;int mx = 0;
    while (~scanf("%d%d",&n,&m))
    {
        tot = 0;
        for(int i = 1; i <= m; ++i){
            int x,y,c;
            scanf("%d %d %d",&x, &y, &c);
            v1[x].push_back({y,c});
            v2[x].push_back({c,0});
            v2[y].push_back({c,0});
        }
        tot = n;
        for(int i = 1;i <= n; ++i){
            sort(v2[i].begin(),v2[i].end());
            v2[i].erase(unique(v2[i].begin(),v2[i].end()),v2[i].end());
            for(auto &u:v2[i])
                u.second = ++tot;
        }
        for(int i = 1;i <= n; ++i){
            for(auto &u:v2[i]){
                v3[u.second].push_back({i,1});
                v3[i].push_back({u.second,1});
            }
            for(auto &u:v1[i]){
                int x = u.first,c = u.second;
                int p = lower_bound(v2[x].begin(),v2[x].end(),make_pair(c,0)) - v2[x].begin();
                p = v2[x][p].second;
                int p2 = lower_bound(v2[i].begin(),v2[i].end(),make_pair(c,0)) - v2[i].begin();
                p2 = v2[i][p2].second;
                v3[p].push_back({p2,0});
                v3[p2].push_back({p,0});
            }
        }
        dij(1,n);
        for(int i = 0;i <= tot; ++i) 
        {
            v1[i].clear();v2[i].clear();v3[i].clear();
        }
 //      mx = max(mx,tot);
    }
   // c2 = clock();
    //cout<<(c2-c1)/1000.0<<" "<<mx<<endl;
    return 0;
}

Measured memory_bytes: 68220