akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
using namespace std;
using VI = vector<long>;

int n, m;
int modulo[101010];
int pairs[101010];
map<int, map<int, int>> mp;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        modulo[x % m]++;
        if (mp[x % m].count(x) != 0) {
            pairs[x % m]++;
            mp[x % m].erase(x);
        } else {
            mp[x % m][x] = 1;
        }
    }
    
    long ans = 0;
    for (int i = 1; i < m; i++) {
        if (i >= m - i) {
            if (i == m - i) {
                ans += modulo[i] / 2;
                modulo[i] -= modulo[i] / 2 * 2;
//                cout << "modulo " << i << " has " << modulo[i] / 2 << " pairs" << endl;
            }
            break;
        }
        long p = min(modulo[i], modulo[m - i]);
//        cout << "modulo " << i << " and modulo " << m - i << " have " << p << " pairs" << endl;
        ans += p;
        modulo[i] -= p;
        modulo[m - i] -= p;
    }
    
    for (int i = 1; i < m; i++) {
        if (modulo[i] != 0) {
            ans += min(pairs[i], modulo[i] / 2);
//            cout << "modulo " << i << " has " << modulo[i] / 2 << " pairs" << endl;
        }
    }
    
//    cout << "modulo 0 has " << modulo[0] / 2 << " pairs" << endl;
    ans += modulo[0] / 2;
    cout << ans << endl;
}


Measured memory_bytes: 14720
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 2e5 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;
ll last[MAXN], dp[MAXN], a[MAXN];
int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    dp[0] = 1;
    for(ll i = 0;i < MAXN;i++)last[i] = -1;
    for(ll i = 1;i <= n;i++){
        cin >> a[i];
        dp[i] = dp[i - 1];
        if(last[a[i]] != -1 && last[a[i]] != i - 1){
            dp[i] = (dp[i] + dp[last[a[i]]]) % delta;
        }
        last[a[i]] = i;
    }
    cout << dp[n];
    return 0;
}
//Written by M_H_H_7


Measured memory_bytes: 4992
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;
int main (){
    string S,T;
    cin >> S >> T;

    cout << T << S;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <tuple>
#include <functional>
#include <limits>
#include <utility>
#include <string>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

// Print each element of a container.
template <typename Container>
void print(const Container& container)
{
    stringstream sstream;

    string delim("");
	for (const auto& element : container)
	{
		sstream << delim << element;
        delim = " ";
	}

    cout << sstream.str() << endl;
}

template <typename Container>
int bubbleSort(Container& container)
{
    int count(0);

    for(auto it(begin(container)); it != end(container); ++it)
    {
        for(auto jt(prev(end(container))); jt != it; --jt)
        {
            if(*jt < *prev(jt))
            {
                iter_swap(jt, prev(jt));
                ++count;
            }
        }
    }

    return count;
}

int main()
{
    vector<int> v;

    int n;
    cin >> n;

    for(size_t i(0); i < n; ++i)
    {
        int x;
        cin >> x;

        v.push_back(x);
    }

    int count(bubbleSort(v));

    print(v);

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3200
#!/usr/bin/env python
H, W = map(int, input().split())
A_raw = [[int(i) for i in input().split()] for j in range(H)]

c = 1
A = []
d = {}
for h in range(H):
    if h % 2 == 0:
        for a in A_raw[h]:
            A.append(a)
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)]))
    else:
        for a in A_raw[h][::-1]:
            A.append(a)
        d.update(zip(range(c, c + W), [(h+1, w) for w in range(1, W+1)[::-1]]))
    c += W

c = 0
ans = []
for i in range(len(A)-1):
    if A[i] % 2 == 1:
        A[i+1] += 1
        A[i] -= 1
        c += 1
        ans.append([d[i+1], d[i+2]])
print(c)
for x in ans:
    print(x[0][0], x[0][1], x[1][0], x[1][1])


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

int main() {
  
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for(int i=0; i<M; i++){ cin >> B[i]; }
  
  vector<int> A(M);
  int res=0;
  
  for(int i=0; i<N; i++){
    int sikii=0;
    for(int j=0; j<M; j++){
      cin >> A[j];
      sikii += A[j]*B[j];
    }
    sikii += C;
    if(sikii>0){ res+=1; }
  }
  cout << res << endl;


}



Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))


def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a%b)


g = a[0]
for x in a[1:]:
    g = gcd(g, x)

if g > 1:
    print('not coprime')
    exit()


exist = [False] * (10**6+1)
for x in a:
    if x % 2 == 0:
        if exist[2]:
            print('setwise coprime')
            exit()
        while x % 2 == 0:
            x //= 2
        exist[2] = True
    div = 3
    while div * div <= x:
        if x % div == 0:
            if exist[div]:
                print('setwise coprime')
                exit()
            while x % div == 0:
                x //= div
            exist[div] = True
        div += 2
    if x > 1:
        if exist[x]:
            print('setwise coprime')
            exit()
        exist[x] = True
print('pairwise coprime')

Measured memory_bytes: 189188
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

struct comb {
    ll cnt;
    ll cnt_A, cnt_B;
};

ll Q, A, B, C, D, i;
vector<comb> aux;
ll sm, bg, sz;
char s[111];

bool check(ll sacr) {
    ll rem_a = bg - sacr;
    ll grps_a = (rem_a + sz - 1) / sz;

    ll rem_b = sm - (grps_a - 1);
    ll grps_b = (rem_b + sz - 1) / sz;

    if (sacr >= grps_b - 1) return true;
    return false;
}

void build(int sacr) {
    ll rem_a = bg - sacr;
    ll grps_a = (rem_a + sz - 1) / sz;

    aux.clear();
    aux.pb({grps_a - 1, sz, 1});
    aux.pb({1, rem_a - (grps_a - 1) * sz, 0});

    ll rem_b = sm - (grps_a - 1);
    ll grps_b = (rem_b + sz - 1) / sz;

    if (rem_b == 0) return;
    aux.pb({1, 0, rem_b - (grps_b - 1) * sz});
    aux.pb({grps_b - 1, 1, sz});

    sacr -= max(0LL, grps_b - 1);
    if (sacr > 0) cerr << "Err";
}

char get(int pos) {
    for (auto e : aux) {
        if (e.cnt * (e.cnt_A + e.cnt_B) < pos) {
            pos -= e.cnt * (e.cnt_A + e.cnt_B);
            continue;
        }

        pos %= (e.cnt_A + e.cnt_B);
        if (pos == 0) pos = e.cnt_A + e.cnt_B;

        if (pos <= e.cnt_A) return 'A';
        return 'B';
    }
}

void solve() {
    ll i;

    sm = min(A, B);
    bg = max(A, B);

    sz = (bg + sm) / (sm + 1);

    ll ans = -1;
    for (ll step = 1LL << 30; step > 0; step >>= 1)
        if (ans + step <= bg)
            if (!check(ans + step))
                ans += step;

    ans++;
    build(ans);
    memset(s, 0, sizeof(s));

    if (A < B) {
        C = A + B - C + 1;
        D = A + B - D + 1;
        swap(C, D);
    }

    for (i = C; i <= D; i++) s[i - C] = get(i);

    if (A < B) {
        reverse(s, s + (D - C + 1));
        for (i = C; i <= D; i++) {
            if (s[i - C] == 'A')
                s[i - C] = 'B';
            else
                s[i - C] = 'A';
        }
    }

    printf("%s\n", s);
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%lld", &Q);
    for (i = 1; i <= Q; i++) {
        scanf("%lld%lld%lld%lld", &A, &B, &C, &D);
        solve();
    }


    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

int mt_num;
int maryoku[20000];
int S;

int qsort_comp(const void* x,const void* y) {
	int* a=(int*)x;
	int* b=(int*)y;
	if(*a>*b)return 1;
	if(*a<*b)return -1;
	return 0;
}

int nt(int start,int target) {
	int left,right,mid;
	left=start;right=mt_num-1;
	while(left<=right) {
		mid=(left+right)/2;
		if(maryoku[mid]>target)right=mid-1;
		else left=mid+1;
	}
	return mt_num-(right+1);
}

int main(void) {
	int i;
	int count;
	while(1) {
		scanf("%d%d",&mt_num,&S);
		if(mt_num==0 && S==0)break;
		for(i=0;i<mt_num;i++)scanf("%d",&maryoku[i]);
		qsort(maryoku,mt_num,sizeof(int),qsort_comp);
		count=0;
		for(i=0;i<mt_num;i++) {
			count+=nt(i+1,S-maryoku[i]);
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define N 50000
using namespace std;
typedef long long ll;
bool used[N];

ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}

bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=min((ll)N,n);i++)res&=!used[i],used[i]=1;
  return res;
}

int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);
  
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
	ll lcm=(p[i]/__gcd(p[i],p[j]))*p[j];
	if(!mark(lcm))continue;
	sum-=SumD(lcm,lcm,n/lcm);
	cnt-=(n/lcm);
      }
    }

    printf("%.8f\n",(1.0*SumD(1,1,n)-sum)/max(1LL,(n-cnt)));
  }
  return 0;
}

Measured memory_bytes: 3220
#include<iostream>
#include<vector>//可変長配列
#include<algorithm>//sort,二分探索,など
#include<map>//map(辞書)

using namespace std;

int main(void){
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2]<< endl;
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const string YES = "YES";
const string NO = "NO";

char charElse(char c1, char c2) {
  set<char> chars;
  chars.insert('a');
  chars.insert('b');
  chars.insert('c');

  chars.erase(c1);
  chars.erase(c2);
  return *chars.begin();
}

bool solve_(char c1, char c2, map<char, ll> cnt) {
  char c3 = charElse(c1, c2);

  while (true) {
    if (cnt[c1] == 0) {
      break;
    }
    cnt[c1]--;

    if (cnt[c2] == 0) {
      break;
    }
    cnt[c2]--;

    if (cnt[c3] == 0) {
      break;
    }
    cnt[c3]--;
  }

  if (cnt[c1] == 0 && cnt[c2] == 0 && cnt[c3] == 0) {
    return true;
  }
  return false;
}

void solve(std::string S) {
  map<char, ll> cnt;
  rep(i, S.size()) { cnt[S[i]]++; }

  bool ans = false;
  for (char c1 = 'a'; c1 <= 'c'; c1++) {
    for (char c2 = 'a'; c2 <= 'c'; c2++) {
      if (c1 == c2) {
        continue;
      }
      ans = ans || solve_(c1, c2, cnt);
    }
  }

  if (ans) {
    print(YES);
  } else {
    print(NO);
  }
}

int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 512
//Author Name - Mohammad Shehar Yaar Tausif
#include <bits/stdc++.h>
#include <math.h>
using namespace std;

typedef long long int lld;

int main(){
	long i,n,arr[100000],DP[100000];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>arr[i];
	}
	DP[n-1] = 0;
	DP[n-2] = abs(arr[n-1] - arr[n-2]);
	for(i=n-3;i>=0;i--){
		DP[i] = min( (DP[i+1] + abs(arr[i+1] - arr[i]) ) , (DP[i+2] + abs( arr[i+2]- arr[i]) ) );
	}
	cout<<DP[0]<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define PI 3.141592653589
 
using namespace std;
 
int main()
{
   FAST/**/
   
   ld a,b,x;
   cin>>a>>b>>x;
   
   if(x<=(a*a*b)/2)
   {
       ld temp = (a*b*b)/2;
       temp/=x;
   temp = atan(temp);
   temp = temp*((ld)180/PI);
   
   /*ld temp1 = (2*a)/b - (2*x)/(a*b*b);
   temp1 = atan(temp1);
   temp1 = temp1*((ld)180/PI);
   
   //cout<<"temp1 = "<<temp1<<"\n";
   
   ld temp2 = (2*a)/a - (2*x)/(a*a*b);
   temp2 = atan(temp2);
   temp2 = temp2*((ld)180/PI);
   
   cout<<temp1<<" "<<temp2<<" "<<temp<<"\n";*/
   
   cout<<fixed<<setprecision(15)<<temp;
   return 0;
   }
   
   ld ans = 0;
   
   ld temp = (2*b)/a - (2*x)/(a*a*a);
   temp = atan(temp);
   temp = temp*((ld)180/PI);
   
   /*ld temp1 = (2*a)/b - (2*x)/(a*b*b);
   temp1 = atan(temp1);
   temp1 = temp1*((ld)180/PI);
   
   //cout<<"temp1 = "<<temp1<<"\n";
   
   ld temp2 = (2*a)/a - (2*x)/(a*a*b);
   temp2 = atan(temp2);
   temp2 = temp2*((ld)180/PI);
   
   cout<<temp1<<" "<<temp2<<" "<<temp<<"\n";*/
   
   cout<<fixed<<setprecision(15)<<temp;
   
   return 0;
}

Measured memory_bytes: 256
_=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)

min=a.min_by{|x|x.abs}

d=a.select{|x|x<0}.size

if(d%2==0)
    p a.map{|x|x.abs}.reduce(0,:+)
else
    p a.map{|x|x.abs}.reduce(0,:+) - 2*min.abs
end


Measured memory_bytes: 10116
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int[] array = new int[n + 1];
        IntStream.rangeClosed(2, n)
                .mapToObj(i -> scanner.nextInt())
                .forEach(i -> array[i]++);

        for (int i = 1; i <= n; i++) {
            System.out.println(array[i]);
        }
    }
}


Measured memory_bytes: 61176
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = INF; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
	cin >> N >> M;
	vl S(N), T(M);
	for (i = 0; i < N; i++) cin >> S[i];
	for (i = 0; i < M; i++) cin >> T[i];
	vll dp(N + 1, vl(M + 1));
	for (i = 0; i < N + 1; i++) dp[i][0] = 1;
	for (i = 0; i < M + 1; i++) dp[0][i] = 1;
	for (i = 0; i < N; i++) {
		for (j = 0; j < M; j++) {
			(dp[i+1][j+1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j]+MOD)%=MOD;
			if (S[i] == T[j]) (dp[i + 1][j + 1] += dp[i][j])%=MOD;
		}
	}
	cout << dp[N][M];
}

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

#define ll long long
#define ar array

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

    int k, n;
    cin >> k >> n;
    int a[n];
    for(int i=0; i<n; ++i)
        cin >> a[i];
    int ans=a[n-1]-a[0];
    for(int i=1; i<n; ++i)
        ans=min(a[i-1]+k-a[i], ans);
    cout << ans;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXWH 30

vector<vector<int>> b(MAXWH, vector<int>(MAXWH));
int h,w,k;
ll result=0;
ll tmp_result=0;

void banish_with_point(int step, int x, int y){
  tmp_result += pow(2, step)*b[y][x];
  b[y][x]=0;
}

ll check(int step, int y){
  for(int cw=w; cw>=k; cw--){
    for(int cs=0; cs+cw<=w; cs++){
      if(b[y][cs]==0)continue;

      bool f=true;
      rep(i, cw)if(b[y][cs]!=b[y][cs+i])f=false;

      if(f) rep(i, cw)banish_with_point(step, cs+i, y);
    }
  }
}

void fall(){
  rep(y, h)rep(x, w)rep(k, h-y){
    if(b[y][x]!=0)continue;
    for(int i=y; i<h-1; i++) swap(b[i][x], b[i+1][x]);
  }
}

int main(){
  cin>>h>>w>>k;
  vector<string>o(MAXWH);
  rrep(i, h)cin>>o[i];
  vector<vector<int>> ob(MAXWH, vector<int>(MAXWH));
  rep(i, h)rep(j, w)ob[i][j]=o[i][j]-'0';

  rep(i, h)rep(j, w){
    tmp_result = 0;
    b=vector<vector<int>>(ob);
    b[i][j]=0;
    fall();
    ll pre = 0;
    rep(step, h){
      rep(y, h)check(step, y);
      fall();
      if(pre==tmp_result)break;
      pre=tmp_result;
    }

/*
if(tmp_result > result){
cout<<tmp_result<<'('<<i<<','<<j<<')'<<endl;
  rrep(i, h){rep(j, w)cout<<b[i][j]<<' ';cout<<endl;}
  cout<<endl;
}
*/

    result = max<ll>(result, tmp_result);
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	//freopen("input.txt", "r", stdin);
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	if(fabs(a-c)<=d){
		cout<<"Yes";
		return 0;
	}
	if(fabs(a-b)<=d&&fabs(b-c)<=d){
		cout<<"Yes";
		return 0;
	}
	else	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int num, rem;
    scanf("%d", &num);

    while(num>0)
    {
        rem = num % 10;

        if(rem == 7)
        {
            printf("Yes\n");
            return 0;
        }
        num = num/10;
    }
        printf("No\n");
  	return 0;
}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define SORT(A) std::sort(A.begin(), A.end())
#define RSORT(A) std::sort(A.begin(), A.end(), std::greater<>())
#define FR(A, e) for (auto& e : A)
#define SHOW(A) for (auto& e : A) {cout << e << " ";}; cout << endl;
#define within(x,_left,_right) (_left <= x && x <= _right)
#define rwithin(x, _l, _r) (_l < x && x < _r)
#define ALL(A) A.begin(),A.end()
#define RALL(A) (A).rbegin(),(A).rend()
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define sz(x) ((int)x.size())
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define bitcnt(x) (__builtin_popcountll(x))
#define fi first
#define se second
#define bg(A) A.begin()
#define ed(A) A.end()
#define rbg(A) A.rbegin()
#define red(A) A.rend()
using LL = long long;
using db = double;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
using VL = vector<LL>;
using VVL = vector<VL>;
const LL MOD = 1e9 + 7;
const LL LMAX = 0x7fffffffffffffff;
const LL LMIN = 0x8000000000000000;
typedef std::pair<int, int> PII;
typedef std::pair<LL, LL> PLL;
typedef std::pair<int, char> PIC;
// int dx[4] = {1, -1, 0, 0}; // 冯诺依曼型邻居
// int dy[4] = {0, 0, 1, -1};
// int dx[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; // 摩尔型邻居
// int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
// #include<iomanip> cout << fixed <<  setprecision(k) 输出k位精度
const int b = 1000;
int main(){
    int N;
    cin >> N;

    if (N % b)
        cout << b - (N % b) << endl;
    else 
        cout << 0 << endl;


    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cassert>

using namespace std;

int main(int argc, char* argv[]) {
    int N;
    std::cin >> N;

    auto v1 = new int[N/2];
    auto v2 = new int[N/2];
    for (int i = 0; i < N / 2; i++) {
        std::cin >> v1[i];
        std::cin >> v2[i];
    }

    auto bucket1 = new int[100002];
    auto bucket2 = new int[100002];
    for (int i = 0; i < 100002; i++) {
        bucket1[i] = 0;
        bucket2[i] = 0;
    }

    for (int i = 0; i < N / 2; i++) {
        bucket1[v1[i]]++;
        bucket2[v2[i]]++;
    }

    int max1 = 0;
    int max2 = 0;
    int index1 = 0;
    int index2 = 0;
    for (int i = 1; i < 100001; i++) {
        if (max1 < bucket1[i]) {
            max1 = bucket1[i];
            index1 = i;
        }
        if (max2 < bucket2[i]) {
            max2 = bucket2[i];
            index2 = i;
        }
    }
    //printf("%d %d", index1, index2);

    std::sort(bucket1, bucket1 + 100002, std::greater<int>());
    std::sort(bucket2, bucket2 + 100002, std::greater<int>());

    //assert(max1 == bucket1[0]);
    //assert(max2 == bucket2[0]);
    //printf("%d %d, %d %d \n", max1, bucket1[1], max2, bucket2[1]);

    int cnt = 0;
    if (index1 == index2) {
        int sum1, sum2, v;
        if (max1 > max2) {
            v = max1 + bucket2[1];
        } else if (max1 < max2) {
            v = bucket1[1] + max2;
        } else /* (max1 == max2) */ {
            sum1 = max1 + bucket2[1];
            sum2 = bucket1[1] + max2;
            v = std::max(sum1, sum2);
            //printf("%d %d %d \n", sum1, sum2, v);
        }
        //printf("%d \n", v);
        cnt = N - v;
    } else {
        cnt = N - max1 - max2;
    }

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
typedef std::pair<int,int> ipair;

int main()
{
    int x,y;
    cin >> x >> y;
    if (y >= 2*x && y <= 4*x && y%2==0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
vector<vector<int>> G(200001);
int point[200001];

void dfs(int from, int to, int p) {
    point[to] += p;
    rep(i, G[to].size()) {
        if (G[to][i] == from) continue;
        dfs(to, G[to][i], point[to]);
    }
}

int main()
{
    int N, Q;
    cin >> N >> Q;

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        point[p] += x;
    }

    dfs(-1, 0, 0);

    rep(i, N - 1) {
        cout << point[i] << " ";
    }
    cout << point[N - 1] << endl;
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	vector<vector<int>> A(3, vector<int> (3, 0));
	Rep0(i, 3)
		Rep0(j, 3)
			cin >>A.at(i).at(j);
	int N;
	cin >>N;
	vector<vector<bool>> B(3, vector<bool> (3, false));
	Rep0(i, N) {
		int BB;
		cin >>BB;
		Rep0(j, 3)
			Rep0(k, 3)
				if (BB==A.at(j).at(k))
					B.at(j).at(k)=true;
	}
	Rep0(i, 3)
		if ((B.at(i).at(0))&&(B.at(i).at(1))&&(B.at(i).at(2))) {
			cout <<"Yes" <<endl;
			return 0;
		}
	Rep0(i, 3)
		if ((B.at(0).at(i))&&(B.at(1).at(i))&&(B.at(2).at(i))) {
			cout <<"Yes" <<endl;
			return 0;
		}
	if ((B.at(0).at(0))&&(B.at(1).at(1))&&(B.at(2).at(2))) {
		cout <<"Yes" <<endl;
		return 0;
	}
	if ((B.at(0).at(2))&&(B.at(1).at(1))&&(B.at(2).at(0))) {
		cout <<"Yes" <<endl;
		return 0;
	}
	cout <<"No" <<endl;
	return 0;
}



Measured memory_bytes: 256
s = input()
q = int(input())
q1 = [list(map(str,input().split())) for i in range(q)]

ap = ["", ""]
revCount = 0

for j in q1:
  if j[0] == "1":
    revCount = (revCount+1) % 2

  else:
    if revCount == 0:
      ap[int(j[1]) - 1] = ap[int(j[1]) - 1] + j[2]
    else:
      ap[int(j[1]) - 2] = ap[int(j[1]) - 2] + j[2]
        

if revCount == 0:
  ap[0] = ap[0][::-1]
  print(ap[0] + s + ap[1])

else:
  aps = (s+ap[1])[::-1]
  print(aps + ap[0])

Measured memory_bytes: 40552
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>sc(N);
  int sm = 0;
  for (int i = 0; i < N; i ++) {
    cin >> sc[i];
    sm = sm ^ sc[i];
  }
  for (int i = 0; i < N; i ++) {
    cout << (sm ^ sc[i]) << endl;
  }
}



Measured memory_bytes: 4044
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

bool func(char x){
    if(x=='Y') return 1;
    else return 0;
}
bool check(ll int y){
    printf("? %lld\n",y);
  	fflush(stdout);
    char c;
    cin>>c;
    return func(c);
}
void ans(ll int z){
    printf("! %lld",z);
}

main(){
    if(check(1e11)){
        int l=0,r=10;
        while(l!=r){
            int mid=(l+r)/2;
            bool f=check(pow(10,mid)*2);
            if(f) r=mid;
            else l=mid+1;
        }
        ans(pow(10,l));
        return 0;
    }
    ll int l=0,r=10;
    while(l!=r){
        int mid=(l+r+1)/2;
        bool f=check(pow(10,mid));
        if(f) l=mid;
        else r=mid-1;
    }
    int dig=l;
    l=pow(10,dig);
    r=pow(10,dig+1);
    while(l!=r){
        ll int mid=(l+r)/2;
        bool f=check(mid*10);
        if(f) r=mid;
        else l=mid+1;
    }
    ans(l);
    return 0;

    
}


Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// const ll INF = 1e18;
//const ll MOD = 1e9+7;
//const double pi = 3.14159265358979;
using vl = vector<ll>;
# define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define all(x) (x).begin(), (x).end()

ll A, B, C, K;

int Main() {
    cin >> A >> B >> C >> K;
    ll sum = 0;
    // まずA枚取る
    ll minKA = min(K, A);
    K = K - minKA;
    sum += minKA;
    // まずB枚取る
    ll minKB = min(K, B);
    K = K - minKB;
    // なんもしない
    ll minKC = min(K, C);
    K = K - minKC;
    sum -= minKC;
    
    cout << sum << endl;
    
    return 0;
}

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


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1;}
    return 0;
}
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1;}
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> VS({"SAT","FRI","THU", "WED", "TUE", "MON","SUN"});

    string S;
    cin >> S;
    cout << distance(VS.begin(),find(ALL(VS),S)) + 1 << endl;
    return 0;
}

Measured memory_bytes: 3608
/**
 * B - 1%
 * https://atcoder.jp/contests/abc165/tasks/abc165_b
 */
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    // 高橋くんはAtCoder銀行に 100 円を預けています。
    // AtCoder銀行では、毎年預金額の 1%の利子がつきます(複利、小数点以下切り捨て)。
    // 利子以外の要因で預金額が変化することはないと仮定したとき、高橋くんの預金額が初めて X 円以上になるのは何年後でしょうか。
    long long X;
    cin >> X;

    long long  yen = 100;
    long long year = 0;
    while(yen < X) {
        yen *= 1.01;
        year++;
    }
    cout << year;
}
 

Measured memory_bytes: 3596
#include<stdio.h>
#define MAX 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF -1

int n, G[MAX][MAX], d[MAX], color[MAX];
int Q[MAX], head=0, tail=0;

void bfs(int );
void enqueue(int );
int dequeue(void);

int main()
{
  int i, j, u, k, v;

  scanf("%d", &n);
  for(i=0; i<=n; i++)
    {
      for(j=0; j<=n; j++)
        {
          G[i][j] = 0;
        }
    }
  for(i=1; i<=n; i++)
    {
      scanf("%d %d", &u, &k);
      for(j=1; j<=k; j++)
        {
          scanf("%d", &v);
          G[u][v] = 1;
        }
      color[u] = WHITE;
      d[u] = INF;
    }

  bfs(1);

  for(i=1; i<=n; i++) printf("%d %d\n", i, d[i]);

  return 0;
}

void bfs(int s)
{
  int i, empty=0, u;

  color[s] = GRAY;
  d[s] = 0;
  enqueue(s);
  empty++;

  while(empty != 0)
    {
      u= dequeue();
      empty--;
      for(i=1; i<=n; i++)
	{
	  if(color[i] == WHITE && G[u][i] == 1)
	    {
	      color[i] = GRAY;
	      d[i] = d[u] + 1;
	      enqueue(i);
	      empty++;
	    }
	}
      color[u] = BLACK;
    }
}

void enqueue(int s)
{
  if(tail == MAX) tail = 0;
  Q[tail] = s;
  tail++;
}

 int dequeue(void)
 {
   if(tail == MAX) tail = 0;
   return Q[head++];
 }

Measured memory_bytes: 636
#include <iostream>
using namespace std;
int main() {
 int n;
 while(cin >> n)
{
int a, b;
a = n % 10;
b = n /100;
if(a==b) {
 cout << "Yes" << endl;
 }
 else { 
     cout << "No" << endl;
}
}
 return 0;
 }


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

#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 rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

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

#pragma endregion

int main() {
  int n = in();
  vector<int> a(n);
  vector<bool> used(n, false);
  rep(i, n) { a[i] = in(); }
  int next = 0;
  int ans = 0;
  used[0] = true;
  while (true) {
    if (next == 1) {
      break;
    }
    next = a[next] - 1;
    if (used[next]) {
      ans = -1;
      break;
    } else {
      ans++;
      used[next] = true;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N;
	cin >> N;

	vector<int> W(N);
	int total = 0;
	for (int i = 0; i < N; i++) {
		cin >> W[i];
		total += W[i];
	}

	//分け目を全探索

	int S1 = 0, S2;
	int min_diff = INF;
	for (int i = 0; i < N - 1; i++) {
		//S1
		S1 += W[i];
		S2 = total - S1;
		if (min_diff > abs(S2 - S1)) {
			min_diff = abs(S2 - S1);
		}
	}
	cout << min_diff;
	return 0;
}

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

using namespace std;

const long long MOD=7+1e9;
int main(){
    long long n, k;
    cin>>n>>k;

    vector<long long> A(n);
    for(long long &x:A){
        cin>>x;
    }
    vector<vector<long long>> dp(2, vector<long long>(k+1));
    for(int i=0;i<=A[0];i++){
        dp[0][i]=1;
    }
    for(int i=1;i<n;i++){
        int curr=(i%2);
        int last=(!curr);
        long long temp=0;
        for(int j=0;j<=k;j++){
            if(j-A[i]-1>=0){
                temp-=dp[last][j-A[i]-1];
                temp=(temp+MOD)%MOD;
            }
            temp+=(dp[last][j]);
            temp%=MOD;
            dp[curr][j]=temp;
        }
    }

    int last=(n-1)%2;
    cout<<dp[last][k]<<endl;
}

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

int main(){
    double a, b, h, m; cin >> a >> b >> h >> m;
    h += m / 60;
    if(h == 0 && m < 30) h = 12;
    else if(m == 0 && h < 6) m = 60;
    double d = abs(h - m / 5);
    double theta = 30 * d;
    double l = sqrt(pow(a, 2)+pow(b, 2)-2*a*b*cos(theta/180*PI));
    cout << fixed << setprecision(10) << l << endl;
}

Measured memory_bytes: 4216
N=int(input())
H=list(map(int, input().split()))
h=H[::-1]
a=True
 
for i in range(N-1):
    if h[i] < h[i + 1]:
        if h[i+1]-h[i] <= 1:
            h[i+1] -=1
        else:
            a = False
            break
if a:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63856
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int n, bit[262200] = {};

/*
void init(int n_) {
    n = 1;
    while (n < n_) n *= 2;
    for (int i = 0; i < 2 * n - 1; i++) dat[i] = pow(2, 31) - 1;
}*/

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= (i & -i);
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += (i & -i);
    }
}


int main(void){
    int q;
    cin >> n >> q;
    
    //init(n);
    
    for (int i = 0; i < q; i++) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com) cout << sum(y) - sum(x - 1) << endl;
        else add(x, y);
    }
}



Measured memory_bytes: 3460
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let s: String = read();
    let ch: Vec<char> = s.chars().collect();
    let mm: u16 = (ch[5] as u16-'0' as u16)*10 as u16+(ch[6] as u16- '0' as u16) as u16;
    if mm <=4{
	println!("Heisei");
    }else{
	println!("TBD");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	
	if(a=='H' && b=='H'){
		printf("H\n");
	}else if(a=='H' && b=='D'){
		printf("D\n");
	}else if(a=='D' && b=='H'){
		printf("D\n");
	}else if(a=='D' && b=='D'){
		printf("H\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <list>
#include <map>
using namespace std;

#define repeat(n, i) for(int i = 0; i < (n); i++)

int main() {
    int n; cin >> n;
    repeat(n, i) {
        string s; cin >> s;
        list<char> train;
        bool which = false; // right: false, left: true
        map<char, bool> used;
        for (string::iterator si = s.begin(); si != s.end(); si++) {
            if (*si == '-') continue;
            if (*si == '<') {
                which = true;
            } else if (*si == '>') {
                which = false;
            } else if (!used[*si]) {
                used[*si] = true;
                if (which) {
                    train.push_front(*si);
                } else {
                    train.push_back(*si);
                }
            }
        }
        for (list<char>::iterator li = train.begin(); li != train.end(); li++) {
            cout << *li;
        }
        cout << endl;
    }
    return 0;
}
            
                    

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

int main(){
  
  int N,A[1010];
  int ans,bad;
  cin >> N;
  
  for(int i = 0;i < N;i ++) cin >> A[i];
  
  for(int i = 0;i < N;i ++){
    
    if(A[i] % 2 == 0){

      if(A[i] % 3 == 0 || A[i] % 5 == 0){
        ans ++;
      }else{
        bad ++;
    }
  }
  }
    
    if(ans > 0 && bad == 0){
      cout <<"APPROVED"<<endl;
    }else {
      cout <<"DENIED"<<endl;
    }
}
 
    
    





Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int n,x;
    int i,j,k;
    int count;
    
    while(1){
        count=0;
        scanf("%d %d",&n,&x);
        if(n==0 && x==0){
            break;
        }else{
            for(i=1;i<=n;i++){ //1??????n?????§
                for(j=1;j<i;j++){ //1??????i-1?????§
                    for(k=1;k<j;k++){ //1??????j-1?????§
                        //??????3???for???????????§??????????????¨?????????????????¨?????§??????
                        if(i+j+k==x){
                            count++;
                        }
                    }
                    
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "KharYusuf", 1 << 27);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastReader in = new FastReader(inputStream);
            PrintWriter out = new PrintWriter(outputStream);
            BCraneAndTurtle solver = new BCraneAndTurtle();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class BCraneAndTurtle {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int x = s.nextInt(), y = s.nextInt();
            for (int i = 0; i <= x; i++) {
                if (i * 2 + (x - i) * 4 == y) {
                    w.println("Yes");
                    return;
                }
            }
            w.println("No");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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


int main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    int sum[n+1];
    for(int i=0; i<n; i++)cin >> p[i];
    sum[0] = 0;
    for(int i=0; i<n; i++)sum[i+1] = sum[i]+p[i];
    int max = 0;
    for(int i=0; i<=n-k; i++){
        int val = sum[k+i] - sum[i];
        if (max < val) max = val;
    }
    double ans = ((max + k) / 2.0);
    cout << setprecision(11) << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

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

    string s;
    cin >> s;

    int max_len = 1;
    int last = n - 1, num_zero = (s.back() == '0');
    for (int first = n - 2; 0 <= first; --first) {
        if (s[first] == '1'
            || (s[first] == '0' && s[first + 1] == '0')) {
            max_len = max(max_len, last - first + 1);
        }
        else {
            ++num_zero;
            while (k < num_zero) {
                while (s[last] == '1') --last;
                while (s[last] == '0') --last;
                --num_zero;
            }
            max_len = max(max_len, last - first + 1);
        }
    }

    cout << max_len << endl;

    return 0;
}

Measured memory_bytes: 512
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isPrime(int n)
{
	for (int i = 2; i <= sqrt(n) + 1; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}
int32_t main()
{
	Raghav();
	char x;
	cin >> x;
	if (x >= 'a' && x <= 'z')
		cout << 'a';
	else
		cout << 'A';
	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String sin = sc.nextLine();
		int iin = Integer.parseInt(sin);
		int[][] iif = new int[iin][10];
		int[][] iip = new int[iin][11];
		int[] iipidx = new int[iin];
		int iret = 0;
		
		for(int i=0;i<iin;i++) {
			String sif = sc.nextLine();
			String[] ksif = new String[10];
			ksif = sif.split(" ");
			for(int j=0;j<10;j++) {
				iif[i][j] = Integer.parseInt(ksif[j]);
			}
		}
		for(int i=0;i<iin;i++) {
			String sip = sc.nextLine();
			String[] ksip = new String[11];
			ksip = sip.split(" ");
			for(int j=0;j<11;j++) {
				iip[i][j] = Integer.parseInt(ksip[j]);
			}
		}
		
		for(int i=1;i<1024;i++){
			for(int j=0;j<iin;j++){
				iipidx[j] = 0;
			}
			int ik=i;
			for(int kisu=512,k=0;k<10;kisu/=2,k++){
				if(ik/kisu==1){
					for(int j=0;j<iin;j++){
						if(iif[j][k]==1)
						iipidx[j] += 1;
					}
					ik -= kisu;
				}
			}
			int ikari = 0;
			for(int j=0;j<iin;j++){
				ikari += iip[j][iipidx[j]];
			}
			if(i==1 || iret<ikari){
				iret = ikari;
			}
		}
		System.out.println(iret);
    }
}

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

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    x--;
    y--;
    vector<int> k(n -1,0);
    //K = 1,2,3,4...nそれぞれの時点での最短距離を求める
    for(int i =0; i<n -1; i++){
        for(int j = i + 1; j < n;j++ ){
            //通常とxy経由のどちらか
            int dis = min( abs(i-j), abs(x-i) + abs(y-j) + 1);
            k[dis -1]++;  
           // printf("k:%d", dis);   
        } 
    }   
    rep(i,n -1) cout << k[i] << endl;
}

Measured memory_bytes: 256
## coding: UTF-8
X, Y = map(int,input().split())


ans = 'Yes'

if(Y % 2 != 0):
    ans = 'No'

a = 2*X
b = 4*X
if(Y < a):
    ans = 'No'
if(Y > b):
    ans = 'No'
print(ans)


Measured memory_bytes: 9176