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

//#pragma GCC optimize("Ofast")
const int maxn = 1e6 + 1;
using namespace std;
using ld = long double;
using ll = int64_t;
const ld EPS = 1e-9;
string s[1001];
int color[1001];
int n;

void dfs(int v, int col) {
    color[v] = col;
    for (int i = 0; i < n; ++i) {
        if (s[i][v] != '0' && !color[i]) {
            dfs(i, 3 - col);
        }
    }
}

int main() {
#ifdef zxc
//    freopen("../farhod_output.txt", "w", stdout);
//    freopen("../kolya_input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    dfs(0, 1);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (s[i][j] == '1' && color[i] == color[j]) {
                cout << -1;
                return 0;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        queue<int> q;
        for (int j = 0; j < n; ++j) {
            color[j] = 0;
        }
        q.push(i);
        color[i] = 1;
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            for (int j = 0; j < n; ++j) {
                if (s[v][j] == '1' && !color[j]) {
                    color[j] = color[v] + 1;
                    q.push(j);
                }
            }
        }
        for (int j = 0; j < n; ++j) {
            ans = max(ans, color[j]);
        }
    }
    cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
 int main()
{	

	lli i,j,k,l,n,n1,a,b,m,q,count=0,flag=0;
	string s;
	cin >> n;
	for(i=1;i<=n;i++){
		if((i%3!=0) && (i%5!=0)) count=count+i;
	}
cout << count << '\n';
return 0;}


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

int main(){
  vector<long long> v;
  long long q, a, b;
  cin >> q;
    while(q--){
      cin >> a;
      if(a != 2){
        cin >> b;
        if(a == 0) v.push_back(b);
        else cout << v.at(b) << endl;
      }
      else v.pop_back();
    }
}


Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ll n,k;cin>>n>>k;
    string s;cin>>s;
    vector<int> v;
    int cnt=1;char cur=s[0];
    for(int i=1;i<n;i++){
        if(s[i]==cur)cnt++;
        else {
            cur=s[i];
            v.push_back(cnt);
            cnt=1;
        }
    }
    v.push_back(cnt);
    ll ans=0;
    for(int i=0;i<v.size();i++)if(v[i]>=2)ans+=v[i]-1ll;
    cout<<min(ans+min(k,ll(v.size()/2))*2,n-1);
}

Measured memory_bytes: 1020
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
int n,l,head,tail,a[500100];
double b[500100],sumt;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d",&n,&l);
    b[head=tail=1]=getint(),a[1]=getint(),sumt=a[1]*b[1];
    printf("%.10f\n",b[1]);
    while (--n)
    {
        double t=getint(); int v=getint(),w=v;
        for (; w>=a[head]; sumt-=b[head]*a[head],w-=a[head++]);
        sumt+=v*t-b[head]*w,a[head]-=w;
        for (; head<=tail && b[tail]>t; --tail)
            t=(v*t+a[tail]*b[tail])/(v+a[tail]),v+=a[tail];
        a[++tail]=v,b[tail]=t;
        printf("%.10f\n",sumt/l);
    }
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= (ll)a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T, class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<char c = ' ',class T> void write(T a){cout << setprecision(12) << a << endl;}
template<char c = ' ',class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << c; write<c>(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    REP(i,1,10)REP(j,1,10){
        cout<<i<<"x"<<j<<"="<<i*j<<endl;
    }
    return 0;
}

Measured memory_bytes: 3052
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>

using namespace std;
int main(){
	while(1){
		int d,e; cin >> d >> e;
		if (d + e == 0) break;
		double dis;
		double min = 10000;
		for (int i = 0; i <= d; i++){
			dis = sqrt(i*i + (d-i)*(d-i));
			if (min > abs(dis - e)){
				min = abs(dis - e);
			}
		}
		cout << abs(min) << endl;

	}
return 0;
}

Measured memory_bytes: 3200
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

N=ni()

def yaku(num):
  i = 0
  for j in range(num//2):
    if num%(j+1) ==0:
      i+=1
  return i+1

if N<105:
  print(0)
elif N==105:
  print(1)
else:
  ans = 1
  for i in range(107,N+1,2):
    if yaku(i) == 8:
      ans+=1
  print(ans)

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

int main()
{
  int n,ans;
  ans=1;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++)
  {
    cin>>s.at(i);
  }
  sort(s.begin(),s.end());
  for(int i=1;i<n;i++)
  {
    if(s.at(i)!=s.at(i-1))
      ans++;
  }
  cout<<ans<<endl;
}

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

int main () {

    int n;
    cin >> n;

    int max_n = 55555;
    bool prime[max_n + 1];
    for (int i = 0; i <= max_n; i++) {
        prime[i] = true;
    }
    for (int i = 2; i <= max_n; i++) {
        if (prime[i]) {
            for (int j = i + i; j <= max_n; j += i) {
                prime[j] = false;
            }
        }
    }

    vector<int> ans;
    for (int i = 11; i <= max_n; i++) {
        if (prime[i] && i % 5 == 1) {
            ans.push_back(i);
        }
    }

    for (int i = 0; i < n; i++) {
        cout << ans[i];
        
        if (i == n - 1) cout << endl;
        else cout << " ";
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>

int partition(int *A, int l, int r) {
    int p = A[r];
    int i = l - 1;
    for (int j = l; j < r; j++) {
        if (A[j] <= p) {
            i++;
            std::swap(A[i], A[j]);
        }
    }
    std::swap(A[i+1], A[r]);
    return i + 1;
}
int A[100000];

int main (int argc, char **argv) {
    int n;
    std::cin >> n;

    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int pi = partition(A, 0, n-1);
    for (int i = 0; i < n; i++ ) {
        if (i) std::cout << " ";
        if (i != pi) {
            std::cout << A[i];
        }else{
            std::cout << "[" << A[i] << "]";
        }
    }
std::cout << std::endl;
}


Measured memory_bytes: 3360
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ll Pow(ll a , ll b){
	if(b == 0) return 1 ;
	ll c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c)% mod )) % mod ;
	return (c * c) % mod ;
}
int verif(string s){
	int val = 0 ;
	bool b = true ;
	for(int i = 0 ; i < (int)s.size() ; i++){
		if(s[i] == '?'){
			b = false;
			for(int j = 0 ; j < 10 ; j++){
				s[i] = (char)(j + (int)'0') ;
				val += verif(s) ;
			}
			break ;
		}
	}
	if(b){
		ll x = atoll(s.c_str()) ;
		return (x % 13 == 5) ;
	}
	return val ;
}
ll Mod(ll x){
	while(x < 0) x += 13 ;
	return x % 13 ;
}
//check modulo
int main(){
	IOS;
	cout.precision(30) ;
	string s ; cin >> s ;
	//cout << verif(s) << endl ;
	int n = s.size() ;
	vector<vll> dp(n + 1 , vll(13 , 0)) ;
	dp[0][0] = 1 ;
	for(int i = 0 ; i < n ; i++){
		if(s[i] !='?'){
			int j = (int)s[i]  - (int)'0' ;
			for(int k = 0 ; k < 13 ; k++){
				add(dp[i + 1][Mod(k * 10 + j)] , dp[i][k]) ;
			}
		}
		else{
			for(int j = 0 ; j < 10 ; j++){
				for(int k = 0 ; k < 13 ; k++){
					add(dp[i + 1][Mod(k * 10 + j)] , dp[i][k]) ;
				}
			}
		}
	}
	cout << dp[n][5] << endl ;
			
	return 0;
}


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

int n , m , a[200] , sum , tot;

int main(){
	scanf("%d %d" , &n , &m);
	for(int i = 1; i <= n; i++)
		scanf("%d" , &a[i]) , sum += a[i];
	double Lim = 1.0 * sum / 4 / m;
	for(int i = 1; i <= n; i++)
		if(a[i] >= Lim) tot++;
	tot >= m ? puts("Yes") : puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

const ll MAX = 1e15;

ll S(ll N){
    ll res = 0;
    while(N != 0){
        res += N%10;
        N /= 10;
    }
    return res;
}

ll pow2(ll x, ll n){
    if(n == 0) return 1;

    ll res = pow2(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

// let f(N) be the integer n>=N that minimizes the value of n/S(n) (in case of tie, chose the smallest one)
ll f(ll n){
    ll res = n;
    double val = (double)n/S(n);

    ll d = 0;
    ll x = pow2(10, d+1)*(n/pow2(10, d+1) + 1)-1;
    while(x <= MAX){
        double tmp = (double)x/S(x);
        if(tmp < val){
            val = tmp;
            res = x;
        }
        ++d;
        x = pow2(10, d+1)*(n/pow2(10, d+1) + 1)-1;
        
    }

    return res;
}


int main(){
    int K; cin >> K;
    vector<ll> ans;

    ll n = 1;
    for(int i=0; i<K; ++i){
        ll add = f(n);
        ans.push_back(add);
        n = add+1;
    }

    for(auto e:ans) cout << e << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n,k;
  cin >> n >> k;
  vector<ll>a(n);
  vector<ll>b(n);
  vector<ll>c(n);
  rep(i,n){
    c[i]=k+2*n+i;
  }
  if(2*k-1>n){
    cout<<-1<<endl;
    return 0;
  }
  else{
    if(n%2==1){
      rep(i,n/2+1){
        a[i]=k+2*i;
        b[i]=k+n+n/2-i;
      }
      rep(i,n/2){
        a[i+n/2+1]=k+1+2*i;
        b[i+n/2+1]=k+2*n-1-i;
      }
    }
    else{
      rep(i,n/2){
        a[i]=k+2*i;
        b[i]=k+n+n/2-1-i;
      }
      rep(i,n/2){
        a[i+n/2]=k+1+2*i;
        b[i+n/2]=k+2*n-1-i;
      }
    }
    rep(i,n){
      cout<<a[i]<<" "<<b[i]<<" "<<c[i]<<endl;
    }
  }
}


Measured memory_bytes: 4608
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    ll X, Y;
    cin >> X >> Y;

    if (A + B >= C * 2) {
        ll cNum = min(X, Y) * 2;
        ll aNum = 0;
        ll bNum = 0;
        if (X > Y) {
            bNum = 0;
            if (A <= C * 2) {
                aNum = X - cNum/2;
            } else {
                cNum = X * 2;
            }
        } else {
            aNum = 0;
            if (B <= C * 2) {
                bNum = Y - cNum/2;
            } else {
                cNum = Y * 2;
            }
        }

        cout << A * aNum + B * bNum + C * cNum << endl;
    } else {
        cout << A * X + B * Y << endl;
    }

    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	int a, b, c;
	int k;
	int p;
	int q;
	
	cin >> a >> b >> c;
	cin >> k;
	p = max(a, max(b, c));
	q = p;
	FOR(i, 1, k) {
		p *= 2;
	}
	p += a + b + c-q ;
	cout << p << endl;


	return 0;
}

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

int main() {
  string s; cin >> s;
  ll res = 0;
  rep(i, 4) {
    if (s.at(i) == '2') res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3524
#include <iostream>

using namespace std;

int main(){
	int N;
	int tri[200];
	static int ansA[1000000], ansB[1000000];
	for(int i=0;i<200;i++) tri[i] = i*(i+1)*(i+2)/6;
	ansA[0] = ansB[0] = 0;
	for(int i=1;i<1000000;i++){
		ansA[i] = ansB[i] = i;
		for(int j=0;i-tri[j]>=0;j++){
			ansA[i] = min(ansA[i], ansA[i-tri[j]]+1);
			if(tri[j]%2==1)
				ansB[i] = min(ansB[i], ansB[i-tri[j]]+1);
		}
	}
	while(cin >> N, N)
		cout << ansA[N] << " " << ansB[N] << endl;
}

Measured memory_bytes: 8556
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  if(N>=M){
    cout << 0 << endl;
    return 0;
  }
  vector<int> box(0,0);
  for(int i=0; i<M; i++){
    int x;
    cin >> x;
    box.push_back(x);
  }
  stable_sort(box.begin(), box.end());
  vector<int> dis(0,0);
  int ans=0;
  for(int i=0; i<box.size()-1; i++){
    int a= box[i+1]-box[i];
    dis.push_back(a);
    ans+=a;
  }
  stable_sort(dis.begin(), dis.end(), greater<int>());
  for(int i=0; i<N-1; i++){
    ans-=dis[i];    
  }
  cout << ans << endl;
}

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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(ll i = 0; i<n; i++)
#define rep_s(i, start, n) for(ll i= start;  i<n; i++)
#define rep_down(i, n) for(ll i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(ll i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()
#define print(ans) cout << ans << endl;
#define MOD 1000000007
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll keta_num(ll num){
  ll total = 0;
  while(num){
    num /= 10;
    total++;
  }
}


ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll fibonacchi(ll num){
  ll f0 = 0, f1 = 1, f2;
  ll count = 0;
  while(count<num){
    f2 = f0+f1;
    f0 = f1;
    f1 = f2;
    count++;
  }
  return f2;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, G, K,L, W, H, P, Q, R, V, X, Y;
  string S, T;
  cin >> N >> K;
  ll amari = N%K;
  ll ans = min(K-amari, amari);
  cout << ans << endl;
      
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      long mod = 1000000007;
      int N = int.Parse(Console.ReadLine());

      long result = pow(10, N) - pow(9, N) + pow(8, N) - pow(9, N);
      result %= mod;
      result = (result + mod) % mod;
      Console.WriteLine(result);
      Console.ReadLine();
    }

    static long pow(long b, int p)
    {
      long mod = 1000000007;
      long result = 1;
      for(int i = 0; i < p; i++)
      {
        result = (result * b) % mod;
      }
      return result;
    }
  }
}

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

using namespace std;

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

    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int vec[4] = {0,0,0,0};
      int i,kai=0,cv[6];
      for(i=0;i<6;i++)cin >> cv[i];
      
      for(i=0;i<6;i++){
       	 if(cv[i] == 1)vec[0]++;
     	 if(cv[i] == 2)vec[1]++;
     	 if(cv[i] == 3)vec[2]++;
     	 if(cv[i] == 4)vec[3]++;
      }
      for(i=0;i<4;i++){
        if(vec[i] <= 0 || vec[i] > 2)kai = 1; 
      }
      if(kai == 0)cout << "YES" << endl;
      else cout << "NO" << endl;
      
    }


Measured memory_bytes: 3612
#include <iostream>
#include <cstdlib>
#include <list>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void)
{
    int N;
    int C[20];
    int V[20];

    cin >> N;
    for (auto i = 0; i < N; ++i)
    {
        cin >> V[i]; 
    }
    for (auto i = 0; i < N; ++i)
    {
        cin >> C[i]; 
    }

    int res = 0;
    for (auto i = 0; i < N; ++i)
    {
        if (V[i] - C[i] >= 0)
        {
            res += V[i] - C[i];
        }
    }
    
    cout << res << endl;

    return 0;
}


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

int main()
{
    int n, m, x;
	set<int> st;

	cin >> n >> m >> x;

	for (int i = 0; i < m; i++)
	{
		int tmp;
		cin >> tmp;
		st.insert(tmp);
	}

	if (0 == st.count(x))
	{
		st.insert(x);
	}

	auto ite = st.find(x);
	int distBegin = distance(st.begin(), ite);
	int distEnd = distance(ite, st.end());
	
	cout << min(distBegin, distEnd - 1) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define     ll long long int
#define     pb push_back
#define     inf 1000000009
#define     for0(i,a,n) for(ll i=a;i<=n;i++)


ll a[100002];
ll n;
ll dp[100005];

ll jump(ll i)
{
    if(i==n-1)
    return 0;
    
    if(i>=n)
    return inf;
    
    if(dp[i]!=-1)
    return dp[i];
    
    dp[i]=min( abs(a[i]-a[i+1])+jump(i+1),abs(a[i]-a[i+2])+jump(i+2) );
    
    return dp[i];
  
}
int main()
{
    cin>>n;
    
    for0(i,0,n)
    cin>>a[i];
    
    memset(dp,-1,sizeof(dp));
    ll res=jump(0);
    cout<<res<<endl;
}

Measured memory_bytes: 7472
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> v(n), u(n);
    rep(i, n) cin >> v[i];

    for(int i=1; i<n; i++){
        u[i] = v[i-1] - u[i-1];
    }

    int x = (v[n-1] - u[n-1]) / 2;

    vector<int> ans;
    rep(i, n){
        if(i%2 == 0) ans.push_back(u[i] + x );
        else ans.push_back(u[i] - x);
    }

    rep(i, n) cout << 2*ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 2680
#include <iostream>
  
using namespace std;
  
int main(void){
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >>r;
  
  if((x+r)<=w&&(x-r)>=0&&(y+r)<=h&&(y-r)>=0) cout << "Yes";
  else cout << "No";
  
  cout << endl;
  
  return 0;
  
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    int cnt[n] = {};
    for (int i = 0; i < n - 1; i++) {
        int t; cin >> t;
        ++cnt[t - 1];
    }
    for (int i : cnt) cout << i << "\n";
}


Measured memory_bytes: 4372
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long ll;

int N;
string s, t;
int pos[26][100000], head[26] = {0};

int main()
{
    cin >> s >> t;
    N = s.size();
    fill(&pos[0][0], &pos[25][100000], -1);

    // preprocess
    for (int i = 0; i < s.size(); i++)
    {
        int c = s[i] - 'a';
        while (head[c] <= i)
        {
            pos[c][head[c]++] = i;
        }
    }
    for (int i = 0; i < 26; i++)
    {
        while (head[i] < N)
        {
            pos[i][head[i]++] = pos[i][0];
        }
    }

    ll ans = -1;
    for (char ch : t)
    {
        int c = ch - 'a';
        if (pos[c][(ans + 1) % N] == -1)
        {
            ans = -1;
            break;
        }
        if (pos[c][(ans + 1) % N] <= ans % N)
        {
            ans = (ans / N + 1) * N + pos[c][(ans + 1) % N];
            // cout << ans << endl;
        }
        else
        {
            ans = ans / N * N + pos[c][(ans + 1) % N];
            // cout << ans << endl;
        }
    }
    cout << (ans == -1 ? -1 : ans + 1) << endl;

    // for (int i = 0; i < 26; i++)
    // {
    //     cout << (char)(i + 'a') << ": ";
    //     for (int j = 0; j < N; j++)
    //     {
    //         cout << pos[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    // system("pause");

}

Measured memory_bytes: 10752
#include<stdio.h>
#define N 500000

int cnt=0;

int a[N];

void merge(int left,int mid,int right){
	int L[N/2];
	int R[N/2];
	int i,j,idx;
	
	for(i=left;i<=mid;i++)
		L[i-left]=a[i];
	
	
	for(i=mid+1;i<=right;i++)
		R[i-mid-1]=a[i];

	i=0;  j=0;  idx=left;
	
	while(i<=(mid-left) && j<=(right-mid-1)){
		if(L[i] < R[j])
			a[idx++]=L[i++];
			
		else 
			a[idx++]=R[j++];
			
		cnt++;
	}
	
	while(i<=(mid-left)){
		a[idx++]=L[i++];
		cnt++;
	}
	
	while(j<=(right-mid-1)){
		a[idx++]=R[j++];
		cnt++;
	}
	
	return;
	
}

void mergeSort(int left,int right){
	int mid=(left+right)/2;
	
	if(left < right){
		mergeSort(left,mid);
		mergeSort(mid+1,right);
		merge(left,mid,right);
	}
	
	return;
	
}

int main(){
	int n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	mergeSort(0,n-1);
	
	for(i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n-1]);
	
	printf("%d\n",cnt);
	
	return 0;
	
}


Measured memory_bytes: 5596
local ior = io.input()
local n, k = ior:read("*n", "*n")
local t = {}
local tidx = {}
for i = 1, n do
  local a, b = ior:read("*n", "*n")
  local idx = 0
  if(tidx[a] == nil) then
    local tmp = {}
    tmp.a = a
    tmp.b = 0
    table.insert(t, tmp)
    tidx[a] = #t
  end
  idx = tidx[a]
  t[idx].b = t[idx].b + b
end
table.sort(t, function(x, y)
  return x.a < y.a
end)
for i = 1, #t do
  if(k <= t[i].b) then
    print(t[i].a)
    break
  else
    k = k - t[i].b
  end
end


Measured memory_bytes: 7732
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)
//#define tr(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

//using namespace __gnu_pbds;

using namespace std;

//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s;

int ans, in;

int main()
{
	cin >> s;
	
	int n = s.length()-1;
	
	FOR (i, 0, n) {
		if (s[i] == 'A') {
			in = i;
			break;
		}	
	}
	
	FOR (i, 0, n)
		if (s[i] == 'Z' && i > in)
			ans = i-in+1;
	
	cout << ans;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
   int a,b,c;
   cin>>a>>b>>c;
   if(a<b && b<c){
       cout<<a<<" "<<b<<" "<<c<<endl;
   }
   else if(a<c && c<b){
       cout<<a<<" "<<c<<" "<<b<<endl;
   }
   else if(b<a && a<c){
       cout<<b<<" "<<a<<" "<<c<<endl;
   }
   else if(b<c && c<a){
       cout<<b<<" "<<c<<" "<<a<<endl;
   }
   else if(c<a && a<b){
       cout<<c<<" "<<a<<" "<<b<<endl;
   }
    else if(c<b && b<a){
       cout<<c<<" "<<b<<" "<<a<<endl;
   } 
    else if(a==b && b<c){
       cout<<a<<" "<<b<<" "<<c<<endl;
   }
    else if(a<b && b==c){
       cout<<a<<" "<<b<<" "<<c<<endl;
   } 
    else if(a==c && c<b){
       cout<<a<<" "<<c<<" "<<b<<endl;
   }
    else if(a<c && c==b){
       cout<<a<<" "<<c<<" "<<b<<endl;
   }
    else if(b==c && c<a){
       cout<<b<<" "<<c<<" "<<a<<endl;
   }
   else if(b<c && c==a){
       cout<<b<<" "<<c<<" "<<a<<endl;
   }
   else if(b==a && a<c){
       cout<<b<<" "<<a<<" "<<c<<endl;
   }
   else if(b<a && a==c){
       cout<<b<<" "<<a<<" "<<c<<endl;
   }
   else if(c==a && a<b){
       cout<<c<<" "<<a<<" "<<b<<endl;
   }
      else if(c<a && a==b){
       cout<<c<<" "<<a<<" "<<b<<endl;
   }
      else if(c==b && b<a){
       cout<<c<<" "<<b<<" "<<a<<endl;
   }
    else if(c<b && b==a){
       cout<<c<<" "<<b<<" "<<a<<endl;
   }
   return 0;
 
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
 
int main() {
  string s;
  int cnt = 0;
  
  cin >> s;
  for (int i=1;i<(int)s.size();i++) {
  	if (s[i-1]=='0' and s[i]=='0') { cnt++; s[i]='1';}
    else if (s[i-1]=='1' and s[i]=='1') { cnt++; s[i]='0';}
  }
  
  cout << cnt;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int s[10000]={0};
    int n;
    double avg,variance;

    cin >>n;

    while(n>0){
        avg = 0;
        variance = 0;
        for(int i=0;i<n;i++){
            cin >> s[i];
            avg +=s[i];
        }
        avg = avg/n;

        for(int i =0; i<n;i++){
            variance += (s[i]-avg)*(s[i]-avg);
        }
        variance = sqrt(variance/n);
        cout << fixed<<setprecision(4)<<variance <<endl;

        cin >>n;
    }
    
    cout << endl;


    return 0;
}



Measured memory_bytes: 3328
def string_palindrome(word):
	word_head = word[:(len(word)-1)//2]
	word_last = word[((len(word)+3)//2)-1:]
	if word != word[::-1]:
		return 'No'
	elif word_head == word_head[::-1] and word_last == word_last[::-1]:
		return 'Yes'
	else:
		return 'No'

print(string_palindrome(input()))

Measured memory_bytes: 3060
// ABC175E.cpp
//#include "pch.h"
#include <iostream>
#include <vector>
#include <algorithm> // max
using namespace std;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
ll v[3003][3003] = {};
ll dp[3003][3003][4] = {};
int main()
{
	int r, c, k;
	cin >> r >> c >> k;
	int pr, pc, pv;
	rep(i, k) {
		cin >> pr >> pc >> pv;
		v[pr][pc] = pv;
	}
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			ll up_max = max(max(dp[i - 1][j][0], dp[i - 1][j][1]), max(dp[i - 1][j][2], dp[i - 1][j][3]));
			dp[i][j][0] = up_max;
			dp[i][j][1] = max(max(dp[i][j - 1][1], dp[i][j - 1][0] + v[i][j]), up_max + v[i][j]);
			dp[i][j][2] = max(dp[i][j - 1][1] + v[i][j], dp[i][j - 1][2]);
			dp[i][j][3] = max(dp[i][j - 1][2] + v[i][j], dp[i][j - 1][3]);
		}
	}
	ll ans = max(max(dp[r][c][0], dp[r][c][1]), max(dp[r][c][2], dp[r][c][3]));
	cout << ans << endl;
}


Measured memory_bytes: 355052
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int k, x;
  cin >> k >> x;
  cout << (500 * k >= x ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    int n;
    cin>>n;
    cout<< !n;
}



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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

template<typename A, size_t N, typename T>
void array_fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    ll n;
    cin >> n;

    vector<map<ll, ll>> cnt(2);

    rep(i, n){
        ll v;
        cin >> v;
        ++ cnt[i % 2][v];
    }

    vector<vector<pair<ll, ll>>> cnt_vec(2);
    rep(i, 2){
        for(auto itr = cnt[i].begin(); itr != cnt[i].end(); ++ itr){
            cnt_vec[i].emplace_back(itr->second, itr->first);
        }
        sort(all(cnt_vec[i]));
        reverse(all(cnt_vec[i]));
    }


    int a = 0, b = 0;
    if(cnt_vec[0][0].second == cnt_vec[1][0].second){
        if(n / 2 - cnt_vec[0][1].first > n / 2 - cnt_vec[1][1].first){
            b = 1;
        }else{
            a = 1;
        }
    }

    cout << n - cnt_vec[0][a].first - cnt_vec[1][b].first << endl;
}

Measured memory_bytes: 8824
#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 REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int f[MAX_N]={};
int b[MAX_N]={};

int r[2002][2002]={};
int l[2002][2002]={};
int u[2002][2002]={};
int d[2002][2002]={};
bool s[2002][2002]={};

int main() {
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	int flg=0;
	if((x*2==w)&&(y*2==h))flg=1;
	printf("%.12f %d",(double)(w*h)/2.0,flg);

	return 0;
}


Measured memory_bytes: 256
// ABC118_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    ll N, M;
    cin >> N >> M;
//    vector<ll> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    if (M%N == 0) {
        cout << N+M << "\n";
    } else {
        cout << M - N << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 256
// Entrance Examination(入学試験)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1600&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		m, nMin, nMax := nextInt(sc), nextInt(sc), nextInt(sc)
		if m == 0 && nMin == 0 && nMax == 0 {
			break
		}

		points := []int{}
		for i := 0; i < m; i++ {
			points = append(points, nextInt(sc))
		}

		gapMax, pass := 0, 0
		for n := nMin; n <= nMax; n++ {
			gap := points[n-1] - points[n]
			if gap >= gapMax {
				gapMax, pass = gap, n
			}
		}

		fmt.Println(pass)
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1872
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(b) > sum(a):
  print(-1)
  exit()
d = []
minus = 0
minussum = 0
for i in range(n):
  k = a[i] - b[i]
  if k < 0:
    minus += 1
    minussum += k
  else:
    d.append(k)
d.sort(reverse=True)
for f in d:
  if minussum >= 0:
    print(minus)
    exit()
  minus += 1
  minussum += f
print(minus)

Measured memory_bytes: 18292
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,len;
	char s[100000];
	scanf("%s",s);
	len=strlen(s);
	printf("%c",s[0]);
	for(i=1;i<len;i++){
		if(i%2==0){
			printf("%c",s[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n, m;
    long long nans = 1, mans = 1, ans;
    const int surplus = pow(10, 9) + 7;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    for(long long i = 2; i <= n; i++){
        nans = (nans * i) % surplus;
    }
    for(long long i = 2; i <= m; i++){
        mans = (mans * i) % surplus;
    }
    ans = ((nans % surplus) * (mans % surplus)) % surplus;
    cout << (n == m ? (ans * 2) % surplus : ans) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"
import "strings"

func f(s string, n int) {
	for i := 0; i < n; i++ {
		fmt.Print(s)
	}
	fmt.Println()
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	f("#", w+2)
	for i := 0; i < h; i++ {
		var s string
		fmt.Scan(&s)
		s = strings.TrimSpace(s)
		fmt.Print("#")
		fmt.Print(s)
		fmt.Println("#")
	}
	f("#", w+2)
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  if(X<=100000&&X>=1&&Y<=100000&&Y>=1&&Z<=100000&&Z>=1&&Y+2*Z<=X){
    printf("%d\n",(X-Z)/(Y+Z));
  }
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  string S;
  int x, y;
  cin>>S>>x>>y;
  int n = S.size();
  bool dpx[2*n+1]={}, dpy[2*n+1]={}; //座標xはdpx[x+n]
  dpx[n]=true, dpy[n]=true;
  vector<int> vx;
  vector<int> vy;
  int work=0, xy=0; //xy=0はx向き，1はy向き
  REP(i, n){
    if(S[i]=='F') ++work;
    else if(work){
      if(!xy)vx.push_back(work);
      else vy.push_back(work);
      work=0;
      xy=1-xy;
    }
    else xy=1-xy;
  }
  if(S[n-1]=='F'){
      if(!xy)vx.push_back(work);
      else vy.push_back(work);
  }

  bool dpw[2*n+1];

  REP(i, vx.size()){
    if(i==0 && S[0]=='F'){
      dpx[n+vx[i]] = true;
      dpx[n] = false;
    }
    else{
      REP(j, 2*n+1){
        if(j-vx[i]>-1) dpw[j] = dpx[j-vx[i]];
        if(j+vx[i]<2*n+1 && !dpw[j]) dpw[j] = dpx[j+vx[i]];
      }
      REP(j, 2*n+1) dpx[j] = dpw[j];
    }
  }
  REP(i, vy.size()){
    REP(j, 2*n+1){
      if(j-vy[i]>-1) dpw[j] = dpy[j-vy[i]];
      if(j+vy[i]<2*n+1 && !dpw[j]) dpw[j] = dpy[j+vy[i]];
    }
    REP(j, 2*n+1) dpy[j] = dpw[j];
  }
  bool ans = dpx[n+x] & dpy[n+y];
  cout<<(ans?"Yes":"No")<<endl;


  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll; 
const int N = 2e5+5;

ll a[N],b[N];

int main()
{	
	ll n,m,x,k;
	scanf("%lld%lld%lld",&n,&m,&k);
	a[0] = b[0] = 0;
	
	for(int i = 1;i <= n;++i) scanf("%lld",&x),a[i] = a[i-1] + x;
	for(int i = 1;i <= m;++i) scanf("%lld",&x),b[i] = b[i-1] + x;
	
	ll res,num,ans = 0;
	for(int i = 1;i <= n;++i){
		if(a[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-a[i];
		}
		
		ll pos = lower_bound(b+1,b+m+1,res)-b;
		while((b[pos] > res && pos > 0) || pos > m) pos--;
		ans = max(ans,num+pos);
	}
	for(int i = 1;i <= m;++i){
		if(b[i] > k){
			num = 0;
			res = k;
		}
		else{
			num = i;
			res = k-b[i];
		}
		
		ll pos = lower_bound(a+1,a+n+1,res)-a;
		while((a[pos] > res && pos > 0) || pos > n) pos--;
		ans = max(ans,num+pos);
	}
	printf("%lld\n",ans);
	return 0;
}


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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MAX = 1e7 + 2;
ll a[MAX];

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		for(int i = 1; i <= n; i++)
		{
			for(int j = i; j <= n; j += i)
			{
				a[j] += 1;
			}
		}
		ll sum = 0;
		for(int i = 1; i <= n; ++i)
		{
			sum += i * a[i];
		}
		cout << sum;
	}
	return 0;
}


Measured memory_bytes: 81724
def resolve():
    N = int(input())
    H = list(map(int, input().split()))

    dp = [0 for _ in range(N+5)]
    
    #print(dp)

    dp[0] = 0
    dp[1] = abs(H[1] - H[0])

    for i in range(1, N-1):
        dp[i+1] = min(dp[i-1] + abs(H[i+1] - H[i-1]), dp[i] + abs(H[i+1] - H[i]))

    #print(dp)
    print(dp[N-1])

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    cin>>a>>b;
    if(a<=b){
        c=c+b;
        b--;
    }
    else{
        c=c+a;
        a--;
    }
        if(a<=b){
        c=c+b;
        b--;
    }
    else{
        c=c+a;
        a--;
    }
    cout<<c<<endl;
}

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

#define rep(i,f,n) for(int i = (f); i < (int)(n); i++)

#define re2(i,f,n) for(int i = (f); i <= (int)(n); i++)


int main(){


    int N,D; cin >> N >> D;
    int record[N][D];
    rep(i,0,N){
        rep(j,0,D){
            cin >> record[i][j];
        }
    }

    int ans=0;

    for(int i=0; i < N; i++){
    for(int j=i+1; j < N; j++){
        int euc=0;
        for(int k=0; k < D; k++){
            int point = record[i][k]-record[j][k];
            euc += point*point; 
        }
        re2(i,0,euc){
            if(i*i==euc){
                ans++;
            }
        }
    }
    }

    cout << ans << endl;

}



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

int main() {
int n, m;
  cin >> n >> m;
  vector<int> l(m);
  vector<int> r(m);
  for(int i = 0; i<m; ++i){
  cin >> l.at(i) >> r.at(i);  
}
int lmax = *max_element(l.begin(), l.end());
int rmin = *min_element(r.begin(), r.end());
  if(rmin - lmax >=0) cout << rmin-lmax+1 << endl;
  else cout << 0 << endl;


}


Measured memory_bytes: 1024
last = [0,0,0]
N = int(input())
flag = True
for i in range(N):
    now = list(map(int, input().split()))
    judge = (now[0]-last[0]) - (abs(now[1]-last[1])+abs(now[2]-last[2]))
    if not (judge >= 0 and judge % 2 == 0):
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>

using namespace std;

int a[2][100];
int dp[2][100];

int main() {
    int n, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < 2; i++) {
        for (j = 0; j < n; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    
    dp[0][0] = a[0][0];
    
    for (i = 0; i < 2; i++) {
        for (j = 0; j < n; j++) {
            if (i < 1) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
            if (j < n - 1) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j] + a[i][j + 1]);
        }
    }
    
    printf("%d\n", dp[1][n - 1]);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static int N;
    private static int K;
    private static int[] h;

    static {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        K = Integer.parseInt(sc.next());
        h = new int[N];
        for (int i = 0; i < N; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
    }

    public static void main(String[] args) {
        Arrays.sort(h);
        int res = Integer.MAX_VALUE;
        for (int i = 0; i <= N - K; i++) {
            res = Math.min(res, h[K + i - 1] - h[i]);
        }

        System.out.println(res);
    }
}


Measured memory_bytes: 49344
n=int(input())
A=[int(input()) for i in range(n)]
B=sorted(A)
if B[-1]==B[-2]:
  C=[B[-1] for i in range(n)]
  print(*C,sep='\n')
else:
  max_A=B[-1]
  max_A2=B[-2]
  for i in range(n):
    if A[i]==max_A:
      print(max_A2)
    else:
      print(max_A)

Measured memory_bytes: 19360
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

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

    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3556
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char c[3][3];
  for(int i = 0; i < 3; i++)scanf("%s", c[i]);
  
  for(int i = 0; i < 3; i++)printf("%c",c[i][i]);
  printf("\n");
  
  return 0;
}

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

int main(){
    ll X; cin >> X;
    ll n = X / 11;
    int t = X % 11;
    ll ans = 0;
    if(t > 6){
        ans = 2 * n + 2;
    }else if(t > 0){
        ans = 2 * n + 1;
    }else{
        ans = 2 * n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;
#define MAX 1000000007

int N, C, A[400], B[400];
ll dp[401][400] = {0};
ll pows[401][401] = {0};
ll culc(int c, int index){
	int ci, cs = 0;
	ll ret = 0, xi;
	if(index == N){ return 1; }
	if(dp[c][index]){ return dp[c][index]; }
	if(index+1 == N){ cs = c; }
	for(ci=cs; ci<=c; ci++){
		xi = (MAX + pows[B[index]][ci] - pows[A[index]-1][ci])%MAX;
		ret = (ret + (xi*culc(c-ci, index+1))%MAX)%MAX;
	}
	return dp[c][index] = ret;
}
int main(void){
	int i, j;
	scanf("%d%d", &N, &C);
	for(i=0;i<N;i++){ scanf("%d", &A[i]); }
	for(i=0;i<N;i++){ scanf("%d", &B[i]); }
	for(i=1;i<=400;i++){
		pows[i][0] = 1;
		for(j=1;j<=400;j++) pows[i][j] = (pows[i][j-1]*i)%MAX;
	}
	for(j=0;j<=400;j++){
		for(i=2;i<=400;i++){
			pows[i][j] = (pows[i][j]+pows[i-1][j])%MAX;
		}
	}
	printf("%lld\n", culc(C, 0));
	return 0;
}


Measured memory_bytes: 2688