akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    ll cnt = 0;
    ll ans;
    for(ll i = min(a,b); i >= 1; i--) {
        if (a % i == 0 && b % i == 0) cnt++;
        if (cnt == k) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> An(N);
	vector<int> x(N-1);
	vector<int> y(N-1);
 	int loop,count=0;
	for(loop=0;loop<N;loop++){
		cin >> An[loop];
	}
	sort(An.begin(),An.end());
	for(loop=1;An[loop]<0;loop++){
		x[count]=An[N-1];
		y[count]=An[loop];
		count++;
		An[N-1]-=An[loop];
	}
	for(;loop<N-1;loop++){
		x[count]=An[0];
		y[count]=An[loop];
		count++;
		An[0]-=An[loop];
	}
	x[count]=An[N-1];
	y[count]=An[0];
	An[N-1]-=An[0];
	cout << An[N-1] << endl;
	for(loop=0;loop<N-1;loop++){
		cout << x[loop] << " " << y[loop] << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    
    ll n,k,i,j;
    cin>>n>>k;
    ll a[n];
    ll count=0;
    in(i,n){
        cin>>a[i];
        if(a[i]>=k){
            count++;
        }
    }
    cout<<count;
}
 
 








 



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ar[50][50];
int main()
{
    ll ans=0;
    string s,t,str;
    cin >> s;
    for(int i=0;i<s.size();i++)cout << "x";
   cout << endl;
    return 0;
}



Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int n = 0;
        int sum = 0;
        while(input.hasNext()){
            n = input.nextInt();
            sum = input.nextInt();
            if(n == 0 && sum == 0)
                break;
            calculate(n, sum);
        }
    }
    
    public static void calculate(int n, int s){
        int cnt = 0;
        for (int i = 1; i < n; i ++)
            for (int j = i + 1; j < n; j ++)
                for (int k = j + 1; k <= n; k ++)
                    if ((i + j + k) == s)
                        cnt ++;
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26848
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <ios>

using namespace std;

//skip
void C111()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
}


void pyramid()
{
  int n;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  int x1, y1, h1;
  for (int i = 0; i < n; ++i)
  {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] >= 1)
    {
      x1 = x[i];
      y1 = y[i];
      h1 = h[i];
    }
  }

  for (int i = 0; i <= 100; ++i)
  {
    for (int j = 0; j <= 100; ++j)
    {
      int h_max = max(0, h1 + abs(i - x1) + abs(j - y1));
      int exist_ans = 1;
      for (int k = 0; k < n; ++k)
      {
        if (h[k] != max(0, h_max - abs(i - x[k]) - abs(j - y[k])))
        {
          exist_ans = 0;
          break;
        }
      }
      if (exist_ans)
      {
        cout << i << " " << j << " " << h_max << "\n";
        return;
      }
    }
  }
}


void id_113()
{
  int n, m;
  cin >> n >> m;
  
  vector<vector<pair<int, int>>> py(n);
  for (int i = 0; i < m; ++i)
  {
    int p, y;
    cin >> p >> y;

    py[p - 1].push_back(make_pair(y, i));
  }

  for (int i = 0; i < n; ++i) sort(py[i].begin(), py[i].end());

  map<int, pair<int, int>> ans;
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < py[i].size(); ++j)
    {
      ans[py[i][j].second] = make_pair(i + 1, j + 1);
    }
  }
  
  for (int i = 0; i < m; ++i)
  {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second << "\n";
  }
}


void C_755()
{
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i)
  {
    //string s = (string)n;
  }
}


void christmas_eve()
{
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  for (int i = 0; i < n; ++i) cin >> h[i];

  sort(h.begin(), h.end());

  int h_diff = 1000000000;
  for (int i = 0; i < n - k + 1; ++i)
  {
    h_diff = min(h_diff, h[i + k - 1] - h[i]);
  }

  cout << h_diff << "\n";
}


int main()
{
  //C111();
  //pyramid();
  //id_113();
  //C_755();
  christmas_eve();
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,k; cin >> a >> b >> k;
    if(a < k){
        OUT(0);
        if(b < k - a) OUT(0);
        else OUT(b - (k-a));
    }else{
        OUT(a-k);
        OUT(b);
    }

    return 0;
}

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

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int p, q, r;
	cin >> p >> q >> r;
	cout << p + q + r - max(p, max(q, r)) << endl;
}














Measured memory_bytes: 256
#include <stdio.h>

int main(){
   char moji[11]={'\0'},moji2[21]={'\0'},moji3[11]={'\0'};
   int n,i=0,j,k,kai=0,t;

   scanf("%s",moji);
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%s",moji2);
      for(j=0;j<10;j++){
         moji3[j]=moji2[j];
      }
      moji3[10]='\0';
      for(k=0;moji3[k]!='\0';k++){
         moji2[k+10]=moji3[k];
      }
      moji2[20]='\0';
      for(j=0;j<10;j++){
          for(k=0;moji[k]==moji2[k+j];k++){
        if(moji[k+1]=='\0'){
             kai++;
             j=10;
             break;
        }
      }
      }
      }
   printf("%d\n",kai);

return 0;
}

Measured memory_bytes: 596
import math

PI = 4.0 * math.atan(1.0)
x = 0
y = 0
angle = 90.0 * PI / 180.0
while True:
  a,b = map(int, input().split(','))
  if a == 0 and b == 0:
    print(int(x))
    print(int(y))
    break
  x += a*math.cos(angle)
  y += a*math.sin(angle)
  angle -= b * PI / 180.0


Measured memory_bytes: 5740
from itertools import groupby
n = int(input())
A = list(map(int, input().split()))
B = A[:]
B.sort()
GB = {key: len(list(group)) for key, group in groupby(B)}
# print(GA)
# print(GA[1])
sums = 0
for i, v in GB.items():
  sums += v * (v - 1) // 2
# print(sums)
for a in A:
  print(sums - (GB[a] * (GB[a] - 1) // 2) + ((GB[a] - 1) * (GB[a] - 2) // 2))
  

Measured memory_bytes: 26140
#include <iostream>

int main()
{
  int N;
  std::string S;
  std::cin >> N >> S;

  size_t i = 0;
  size_t ret = 0;
  while(i <= S.size() - 3) {
    if((S[i] == 'A' && S[i+1]  == 'B' && S[i+2] == 'C')) {
      ret++;
      i += 3;
    } else {
      i++;
    }
  }

  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3604
/*
    Created by Tejas Chaudhari
    link:
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef bool bl;
typedef vector<ll> vl;
typedef vector<bl> vb;
typedef string st;
typedef pair<ll,ll> pll;

#define INF LONG_LONG_MAX / 4;
#define SORT(x) sort(x.begin(), x.end());
#define Mod % 1000000007
#define HERE cout<<"HERE"<<endl;

void re_curse() {
    ll n;
    cin>>n;
    set <st> s;
    for (int i = 0; i < n; ++i) {
        st t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size()<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    for (int i = 1; i <= t; ++i) {
        re_curse();
    }
    return 0;
}

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

const int MAX = 3000;
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;
}

int main() {
  
  COMinit();
    // 前処理
    int s;
  scanf("%d",&s);
  
  int t=(s-s%3)/3,ans=0;
  
  for(int i=1;i<=t;i++){
    ans += COM(s-2*i-1,s-3*i);
    ans %= MOD;
  }
  
  printf("%d",ans);
  return 0;
  
}


Measured memory_bytes: 3888
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	long long N = 0;
	long long ans = 0;
	std::cin >> N;

	std::vector<long long> D(N);
	for (long long  i = 0; i < N; i++){
		std::cin >> D[i];
	}

	std::sort(D.begin(), D.end());
	ans = D[N / 2] - D[N / 2 - 1];

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

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



Measured memory_bytes: 256
N, M = map(int, input().split())
S = [0] * M
for i in range(M):
  S[i] =  list(map(int, input().split()))
P = list(map(int, input().split()))
#print(S, P)
ans = 0

for i in range(2 ** N):#bit全探索
  bin_i = bin(i)[2:].zfill(N)#zfillは0埋め
  #print(bin_i)
  m = 0
  for j in range(M):#各電球についてルーブ
    x = 0#ついてるスイッチの数
    for l in range(1,S[j][0] + 1):#各スイッチについてループ
      if bin_i[S[j][l] - 1] == "1":#スイッチがonなら
        x += 1
        
    if x % 2 != P[j]:
      m = 1
      #print(bin_i, j, l, x, P[j])
    
  if m == 0:
    ans += 1
    
print(ans)
    

        

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define LL long long
using namespace std;
const int N = 2e5 + 10;
LL a[N];
LL judge(LL x, LL n)
{
	LL cnt = 0;
	for(int i = 1; i <= n; i++)
		if(a[i] > x)
			cnt += a[i] / x;
	return cnt;
}
int main()
{
	LL n, k, L, R;
	LL maxa = 0;
	cin>>n>>k;
	for(int i = 1; i <= n; i++)
	{
		cin>>a[i];
		maxa = max(maxa, a[i]);
	}
	L = 0;
	R = maxa;
	while(R - L > 1)
	{
		int mid = (L + R) >> 1;
		if(judge(mid, n) <= k)
			R = mid;
		else
			L = mid;
	}
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  vector<int> v;
  int N; cin >> N;
  for (int i = 0; i < N; i++) {
    int p; cin >> p;
    if (p == 0) {
      int q; cin >>q;
      v.push_back(q);
    } else if (p == 1) {
      int q; cin >> q;
      cout << v[q] << endl;
    } else {
      v.pop_back();
    }
  }
}



Measured memory_bytes: 4964
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) a = b;
  return a > b;
}
template<class T> inline bool chmax(T&a, T b) {
  if (a < b) a = b;
  return a < b;
}

signed main() {
  int N; cin >> N;
  vector<int> h(N), dp(N, INF);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for (int i = 2; i < N; i++) {
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
  }
  cout << dp.back() << endl;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  int g, p, ans;
  g = p = ans = 0;
  rep(i, s.size()){
    if(s[i] == 'g'){
      if(p < g){
	ans ++;
	p ++;
      } else {
	g ++;
      }
    } else {
      if(p < g){
	p ++;
      } else {
	ans --;
	g ++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;


int main() {
	int N; cin >> N;
	if (N % 2 == 0) {
		cout << N / 2 - 1 << endl;
	}
	else {
		cout << N / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O2")
//#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
using vpi = vector<pi>;
const int maxn = 2e5 + 55;
const int mod = 1e9 + 7;
int n, cnt[11][11];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	string t;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		t = to_string(i);
		cnt[t[0] - '0'][t.back() - '0']++;
	}
	for (int i = 1; i <= n; i++) {
		t = to_string(i);
		ans += cnt[t.back() - '0'][t[0] - '0'];
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, n, a, b, c, aa, bb, cc;
	scanf("%d", &n);
	for(i=0;i<n;i++) {
		scanf("%d %d %d", &a, &b, &c);
		aa = a * a;
		bb = b * b;
		cc = c * c;
		
		if(aa+bb-cc==0 || bb+cc-aa==0 || cc+aa-bb==0) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int choose(int n,int k) {
    int ans = 1;
    rep(i,k) ans *= n-i;
    rep(i,k) ans /= i+1;
    return ans;
}
int pow(int n,int k) {
    int ans = 1;
    rep(i,k) ans*=n;
    return ans;
}
int main(){
    ios::sync_with_stdio(false);
    string n;
    int k;
    cin >> n >> k;
    int num = n.size();
    int ans = 0;
    ans += choose(num-1,k) * pow(9,k);
    ans += (n[0]-'0'-1)*choose(num-1,k-1) * pow(9,k-1);
    if(k == 1) ans++;
    if(k == 2) {
        for(int i = 1; i <= num-1; i++) {
            bool flag = false;
            for(int k = 1; k <= i-1; k++) {
                if (n[k] != '0') {
                    flag = true;
                    break;
                }
            }
            if(flag) ans += 9;
            else ans+=(n[i] - '0');
        }
    }
    if(k==3) {
        for(int i = 1; i <= num-2; i++) for(int j = i+1; j <= num-1; j++) {
            bool flag = false;
            for(int k = 1; k <= i-1; k++) {
                if (n[k] != '0') {
                    flag = true;
                    break;
                }
            }
            if(flag) ans += 9*9;
            else{
                flag = false;
                for(int k = i+1; k <= j-1; k++) {
                    if (n[k] != '0') {
                        flag = true;
                        break;
                    }
                }
                if(flag) {
                    ans += (n[i]-'0')*9;
                } else if(n[i] != '0') {
                    ans += (n[i]-'0'-1)*9 + n[j]-'0';
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
const int MAX_N =510000;

int par1[MAX_N], par2[MAX_N];
int depth1[MAX_N], depth2[MAX_N];
int size[MAX_N];

void init(int n, int par[], int depth[]){
    for(int i=0; i<n; i++){
        par[i]=i;
        depth[i]=0;
        size[i]=1;
    }
}

int find(int x, int par[], int depth[]){
    if(par[x]==x) return x;
    par[x] =find(par[x], par, depth);
    return par[x];
}

void unite(int x, int y, int par[], int depth[]){
    x = find(x,par,depth); y = find(y,par,depth);
    if(x==y) return;
    if(depth[x]<depth[y]) {par[x]=y; size[y]=size[y]+size[x]; return;}
    if(depth[x]>depth[y]) {par[y]=x; size[x]=size[x]+size[y]; return;}
    par[y]=x; depth[x]++; size[x]=size[x]+size[y];
    return;
}

bool same(int x,int y, int par[], int depth[]){
    return find(x, par, depth)==find(y, par, depth);
}

map<P,int> mp;

int main(){
    int N; cin >> N; init(N, par1, depth1);
    int K, L; cin >> K >> L;
    for(int i=0; i<K; i++){
        int p, q; cin >> p >> q; p--; q--;
        unite(p,q,par1,depth1);
    }
    init(N,par2,depth2);
    for(int i=0; i<L; i++){
        int r,s; cin >> r >> s; r--; s--;
        unite(r,s,par2,depth2);
    }
    for(int i=0; i<N; i++){
        mp[P(find(i,par1,depth1),find(i,par2,depth2))]++;
    }

    for(int i=0; i<N; i++){
        cout << mp[P(find(i,par1,depth1),find(i,par2,depth2))] << " ";
    }
    cout<< endl;
}

Measured memory_bytes: 19584
#include<cstdio>
#include<cstring>
#include<algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define fd(i,b,a) for(int i=(b);i>=(a);--i)
#define efo(i,v,u) for(int i=BB[v],u=B[BB[v]][1];i;u=B[i=B[i][0]][1])
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || ch>'9';ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=404,M=1e5+5;
int n,m;
bool bz[N][N],die[N];
int main()
{
	n=read(),m=read();
	mset(bz,1);
	fo(k,1,m)
	{
		int x=read(),y=read();
		if(!bz[x][y])
		{
			die[x]=die[y]=1;
			fo(i,1,n) bz[i][x]=bz[x][i]=bz[i][y]=bz[y][i]=0;
		}
		else bz[x][y]=bz[y][x]=0;
		fo(i,1,n)
		{
			if(!bz[i][x]) bz[i][y]=bz[y][i]=0;
			if(!bz[i][y]) bz[i][x]=bz[x][i]=0;
		}
	}
	int ans=0;
	fo(i,1,n-1) if(!die[i])
		fo(j,i+1,n) if(!die[j] && bz[i][j]) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define ll long long
using namespace std;


int min (ll x, ll y) {
    if(x>y) return y;
    else return x;
}

int val(ll *a, int left, int right){
    if(a[right] < 0) return -a[left];
    if(a[left] > 0) return a[right];
    if(-a[left] < a[right] ) return -2*a[left] +a[right];
    return -a[left] + 2*a[right];
}

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<ll> a(N);
    
    for(int i = 0; i < N; i++)
        cin >> a[i];
    
    ll ans = 10000000000000;
    for(int i = 0; i < N-K+1; i++){
        ans = min(ans, val(&a[0], i, i+K-1));
    }
    
    cout << ans << std::endl;
    
    return 0;
}




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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
string s;
void solve(){
    cin>>s;
    if(s[0]=='7' or s[1]=='7' or s[2]=='7') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m, f, r;
        while(true) {
            m = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
            if(m==-1 && f==-1 && r==-1) {
                break;
            }
            if(m==-1 || f==-1) {
                System.out.println("F");
                continue;
            }
            if(m+f < 30) {
                System.out.println("F");
            }
            else if(m+f < 50) {
                if(r >= 50) {
                    System.out.println("C");
                }
                else{
                    System.out.println("D");
                }
            }
            else if(m+f < 65) {
                System.out.println("C");
            }
            else if(m+f < 80) {
                System.out.println("B");
            }
            else {
                System.out.println("A");
            }
        }
    }
}


Measured memory_bytes: 26380
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////

int main(){
    int N,M;
    SCD2(N,M);
    int ans = 0;
    for (int p = M/N ; p >= 1; p--){
        if (M % p != 0) continue;
        PRINTD(p);
        return 0;
    }

    PRINTD(ans);
}

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

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=1000000007LL;
const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 510000LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

ll dp[3010][3010];
int main(){
  ll n;cin>>n;
  ll s;cin>>s;
  vl a(n);
  rep(i,n)cin>>a[i];
  dp[0][0]=1;
  for(ll i=1;i<=n;i++){
    rep(j,3010){
      dp[i][j]+=dp[i-1][j]*2;
      dp[i][j]%=MOD;
      if(j>=a[i-1])dp[i][j]+=dp[i-1][j-a[i-1]];
      dp[i][j]%=MOD;
    }
  }
  //rep(i,n+1){
    //rep(j,s+1)cout<<dp[i][j]<<" ";
    //cout<<endl;
  //}
  cout<<dp[n][s]%MOD<<endl;
}

Measured memory_bytes: 74176
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
	//declare the variables//
	int N, K;
	double pow(double a, double b);
	int NOC;

	//scan the number of the balls and colors//
	scanf("%d %d", &N, &K);

	//calculate the NOC//
	if (N == 1) {
		NOC = K;
		printf("%d\n", NOC);
	}

	else if(N != 1) {
		NOC = K*pow(K - 1, N - 1);
		printf("%d\n", NOC);
	}

	return(0);
}

Measured memory_bytes: 128
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
// #define int unsigned long long int
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int mul1 = 1003, mul2 = 5, mul3 = 8;
const int MOD3 = 179424673, MOD2 = 982451653, MOD1 = 1190494759;
const ld EPS = 1e-9;

ll N;
ll P = 1000000007;
vector<ll> A;

int main()
{
    cin >> N;
    ll all_sum = 0;
    ll s_sum = 0;
    for (int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
        all_sum += tmp;
        s_sum += (tmp * tmp) % P;
        all_sum %= P;
        s_sum %= P;
    }

    ll mul_sum = (all_sum * all_sum + P) % P;

    ll actual_sum = (mul_sum - s_sum + P) % P;

    if (actual_sum % 2 == 0)
    {
        cout << actual_sum / 2 << endl;
    }
    else
    {
        cout << P + ((actual_sum - P) / 2) << endl;
    }

    return 0;
    
}

Measured memory_bytes: 5272
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    bool ok = true;
    int countC = 0;
    if(s[0] != 'A') ok = false;
    for(int i = 0;i < s.size();i++) {
        if(i == 0 && s[i] != 'A') ok = false;
        if(i != 0) {
            if(tolower(s[i]) != s[i]) {
                if(s[i] == 'C' && i >= 2 && i < s.size()-1) countC++;
                else ok = false;
            }
        }
    }
    if(countC != 1) ok = false;
    
    if(ok)
        cout << "AC" << endl;
    else
        cout << "WA" << endl;
}




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

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CNuskeVsPhantomThnook {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    int N, M, Q;

    void solve(std::istream& cin, std::ostream& cout) {
        cin >> N >> M >> Q;

        vector<string> S(N);
        REP(i, N) {
            cin >> S[i];
        }

        vector<vector<int>> sumv(N + 1, vector<int>(M + 1));
        REP(i, N) {
            REP(j, M) {
                sumv[i + 1][j + 1] = sumv[i][j + 1] + sumv[i + 1][j] - sumv[i][j] + (S[i][j] == '1');
            }
        }
        vector<vector<int>> sumr(N + 1, vector<int>(M + 1));
        REP(i, N) {
            REP(j, M) {
                sumr[i + 1][j + 1] = sumr[i][j + 1] + sumr[i + 1][j] - sumr[i][j];
                if (i >= 1) sumr[i + 1][j + 1] += (S[i][j] == '1' && S[i - 1][j] == '1');
            }
        }
        vector<vector<int>> sumc(N + 1, vector<int>(M + 1));
        REP(i, N) {
            REP(j, M) {
                sumc[i + 1][j + 1] = sumc[i][j + 1] + sumc[i + 1][j] - sumc[i][j];
                if (j >= 1) sumc[i + 1][j + 1] += (S[i][j] == '1' && S[i][j - 1] == '1');
            }
        }

        while (Q--) {
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            int v = sumv[x2][y2] - sumv[x1 - 1][y2] - sumv[x2][y1 - 1] + sumv[x1 - 1][y1 - 1];

            int e = sumr[x2][y2] - sumr[x1][y2] - sumr[x2][y1 - 1] + sumr[x1][y1 - 1];
            e += sumc[x2][y2] - sumc[x1 - 1][y2] - sumc[x2][y1] + sumc[x1 - 1][y1];

            cout << v - e << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CNuskeVsPhantomThnook solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 100096
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;

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

  ll n = H;
  ll cnt = 0;
  for (ll i = 0;;i++) {
    cnt += pow(2, i);
    if (n == 1) break;
    n = ceil(n / 2);
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}
 
fn main() {
    let n: usize = read().unwrap();
    let mut a: Vec<usize> = Vec::new();
    for _i in 0..n {
        let x: usize = read().unwrap();
        a.push(x);
    }
    let mut touched: HashSet<usize> = HashSet::new();
    let mut counter: i64 = 0;
    let mut t: usize = 1;
    while {
        counter += 1;
        touched.insert(t);
        t = a[t - 1];
        t != 2 && !touched.contains(&t)
    } {}
    if t == 2 {
        println!("{}", counter);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 8444
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CIN(int, K);
    CIN(string, S);

    K--;
    char a = S[K];
    if ( a == 'A' ) {
        S[K] = 'a';
    } else if ( a == 'B') {
        S[K] = 'b';
    } else{
        S[K] = 'c';
    }

    cout << S << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int x;
  std::cin >> x;
  int x_100 = x/100;
  int x_less_100 = x%100;
  int k_min = 0;
  int k_max = 5*x_100;

  std::cout << (k_min <= x_less_100 && x_less_100 <= k_max ? 1 : 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n,m;cin>>n>>m;
    cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
   
    return 0;
}

Measured memory_bytes: 256
r,g,b,n=map(int,input().split())
cnt=0
for i in range(int(n//r)+1):
    for j in range(int(n//g)+1):
        if (n-i*r-j*g) %b ==0 and 0<=(n-i*r-j*g) // b <= 3000:
            # print(i,j,(n-i*r-j*g)//3)
            cnt+=1
print(cnt)

Measured memory_bytes: 67368
def ABC162C(a,b):#ユークリッドの互除法
    while b != 0:
        a %= b
        if a == 0:break
        b %= a
    return max(a,b)

a,b,c=map(int,input().split())
k=ABC162C(a,b)
print('YES' if k==ABC162C(ABC162C(b,c),k) else 'NO')

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int a,b; cin>>a>>b;
  for(int i=1;i<1001;i++){
    int k=i*8/100;
    int d=i/10;
    if(k==a&&d==b){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = [list(input()) for i in range(N)]
B = [list(input()) for i in range(M)]

for i in range(N - M + 1):
  for j in range(N - M + 1):
    for x in range(M):
      for y in range(M):
        if A[i + x][j + y] != B[x][y]:
          break
      else:
        continue
      break
    else:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct d{
  int id;
  char mark;
  int num;
}Data;

void quicksort(Data *, int, int);
int partition(Data *, int, int);
void stableJudge(Data *, int);

int main(){
  int i, n;
  Data *A;

  scanf("%d ",&n);
  A = (Data *)malloc(sizeof(Data) * n);
  for(i=0; i<n; i++){
    scanf("%c %d ", &A[i].mark, &A[i].num);
    A[i].id = i;
  }

  quicksort(A, 0, n);

  stableJudge(A, n);

  for(i=0; i<n; i++){
    printf("%c %d\n", A[i].mark, A[i].num);
  }

  return 0;
}

void quicksort(Data *A, int p, int r){
  int i,q;
  if(p < r){
    q = partition(A, p, r);
    
    quicksort(A, p, q);
    quicksort(A, q+1, r);
  }
}

int partition(Data *A, int p, int r){
  int i=p-1, j,  x=A[r-1].num;
  Data temp;

  for(j=p; j<r-1; j++){
    if(A[j].num <= x){
      i ++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i+1];
  A[i+1] = A[r-1];
  A[r-1] = temp;

  return i+1;
}

void stableJudge(Data *A, int n){
  int i;

  for(i=1; i<n; i++){
    if(A[i-1].num == A[i].num){
      if(A[i-1].id > A[i].id){
        puts("Not stable");
        return;
      }
    }
  }
  puts("Stable");
}



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

//Osa_k法
//arr[n] := nの最小の素因数を0からnまで
//素因数分解がO(ln(N))でできるっぽい
void Osa_k(int N, vector<int>& vect) {
	vect.resize(N + 1);
	for (int n = 0; n <= N; n++)vect[n] = n;
	for (int n = 2; n <= N; n++) {
		if (vect[n] != n)continue;   //素数じゃない場合
		int t = 2 * n;
		while (t <= N) {
			if (vect[t] == t)vect[t] = n;
			t += n;
		}
	}
	return;
}

int main() {
	ll N;
	cin >> N;
	vector<int> osak;
	Osa_k(55555, osak);
	vector<ll> primes[10];
	for (ll n = 0; n < 10; n++)primes[n] = vector<ll>();
	for (ll p = 2; p <= 55555; p++) {
		if (osak[p] != p)continue;
		primes[p % 10].push_back(p);
	}
	for (ll n = 0; n < N; n++) {
		cout << primes[1][n] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    CIN(M);
    if(M%N == 0){
        COUT(M/N);
        return 0;
    }
    long long h = M/N;
    long long hoge = M/N + M%N;
    while(true){
        if(hoge % h == 0){
            COUT(h);
            return 0;
        }
        h--;
        hoge+=N-1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
// -----------------------------------------------------------------------------

int main() {
#ifdef zerol
    freopen("a.in", "r", stdin);
#endif
    LL k, a, b; cin >> k >> a >> b;
    if (b - a <= 2 || a - 1 >= k) {
        cout << k + 1 << endl;
    } else {
        k -= a - 1; LL ans = a;
        ans += (k / 2) * (b - a);
        k %= 2;
        if (k) ans++;
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
A,B=map(int,input().split())
S=input()

ans="Yes"
for i in range(0,A):
  if S[i]=="-":
    ans="No"
if S[A]!="-":
  ans="No"
for j in range(A+1,A+B+1):
  if S[j]=="-":
    ans="No"
    
print(ans)

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  int H, W; cin >> H >> W;
  vector<string> field(H);
  rep(h, H) cin >> field[h];

  rep(w, W+2) cout << "#";
  cout << endl;
  rep(h, H){
    cout << "#";
    cout << field[h];
    cout << "#" << endl;
  }
  rep(w, W+2) cout << "#";
  cout << endl;

  return 0;
}


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


int main()
{
	long t;
	int h,m;
	

	cin >> t;

	h = t/3600;
	t -= h * 3600;
	m = t / 60;
	t -= m * 60;

	cout << h << ":" << m << ":" << t << endl;

	return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
ll N;
  cin>>N;
string C;
  cin>>C;
ll w=0;//白の数
ll r=0;//赤の数
ll wl=0;//赤の個数分より左にあった白の数
ll rl=0;//赤の個数分より左にあった赤の数
  
  
for(ll i=0;i<ll(C.size());i++){
if(C[i]=='W'){w++;}
if(C[i]=='R'){r++;}
}

for(ll i=0;i<r;i++){
if(C[i]=='W'){wl++;}
if(C[i]=='R'){rl++;}
}
  
  
ll ans=0;
ans=r-rl;
  
  
  cout<<ans<<endl;

  
     
  
}


Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

#if 1
#define DEBUG(x) do{cerr << #x << "=" << x << endl;}while(0);
#else
#define DEBUG
#endif


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

	vector<int> apple(n);
	for(int i=0; i<n;++i){
		apple[i] = l + i; // 1-based -> 0-based
	}

	// vector<int> abs_apple(n);
	vector<pair<int,int>> abs_apple(n);
	for(int i=0; i<n;++i){
		if( apple[i] > 0 ){
			abs_apple[i] = make_pair(apple[i], apple[i]);
		}
		else {
			abs_apple[i] = make_pair(-apple[i], apple[i]);
		}
	}

	sort(abs_apple.begin(), abs_apple.end());

	int sum = 0;
	for(int i=1; i<n;++i){
		sum += abs_apple[i].second;
	}

	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define pi 3.14159265358979323846
#define ll long long
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int n, m, sm = 0, c = 0;
  cin >> n >> m;
  int a[n];
  rep(i, 0, n){
    cin >> a[i];
    sm += a[i];
  }
  double s = (sm + 4 * m - 1) / (4 * m);
  
  rep(i, 0, n){
    if(a[i] >= s){
      c++;
    }
  }
  if(c >= m){
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
}

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

int main() {
	ll n,k,a[100010],ans=1<<30;
	cin>>n>>k;
	k--;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-k;i++){
		ll A=abs(a[i])+abs(a[i+k]-a[i]);
		ll B=abs(a[i+k])+abs(a[i+k]-a[i]);
		ans=min({ans,A,B});
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 1024