akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
long mod = 998244353;
long factorials[200001];

int pre_factorials(int n){

    factorials[0] = 1;

    for (int i = 0; i < n; i++) {
        factorials[i + 1] = (long)(i + 1) * factorials[i] % mod;
    }
    
    return 0;
}

long modpow(long a, long p){
    
    if (p == 0) return 1;
    
    if (p % 2 == 0) {
        return modpow(a * a % mod, p / 2);
    
    } else
        return a * modpow(a, p - 1) % mod;
}

long Comb(long a, long b){

    long af = factorials[(int) a];
    long bf = factorials[(int) b];
    long abf = factorials[(int) (a - b)];
    long res = af * modpow(bf, mod - 2) % mod * modpow(abf, mod - 2) % mod;
    return res;
}


int main(){
    
    long n, m, k;
    cin >> n >> m >> k;
    
    long N = 200001;
    pre_factorials(N);
    
    vector<long> a(n, 0);
    
    a[0] = m;
    for(int i = 1; i < n; i++) a[i] = a[i - 1] * (m - 1) % mod;
    
    long ans = 0;
    rep(i, k + 1){
        ans += Comb(n - 1, i) * a[n - i - 1] % mod;
        ans %= mod;
    }
    
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 5940
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD;
#define INF 2*1e9
#define N 3100
using namespace std;

ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll modpow2(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow2(x*x%(MOD-1),n/2);
    if(n&1) res=res*x%(MOD-1);
    return res;
}
ll modpow3(ll x,ll n){
    return modpow(x,modpow2(x,n));
}
ll inv[4000],comb[4000];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(ll)(n+1-i)%MOD*inv[i]%MOD;
    }
    return;
}
void add(ll *x,ll y){
    *x=(*x+y%MOD+MOD)%MOD;return;
}
void subtract(ll *x,ll y){
    *x=(*x+MOD-(y%MOD))%MOD;
}
main(){
    ll n;
    cin>>n>>MOD;
    ll dp[N][N]={};
    dp[1][0]=1;
    dp[1][1]=1;
    rep2(i,1,n-1){
        rep2(j,0,i){
            add(&dp[i+1][j],dp[i][j]*(ll)(j+1));
            add(&dp[i+1][j+1],dp[i][j]);
        }
    }
    ll ans=0;
    calc_inv();calc_comb(n);
    ans=modpow3(2,n);
    ll s=-1;
    rep2(i,1,n){
        ll t=comb[i]*modpow3(2,n-i)%MOD*s;
        t=(t+MOD)%MOD;
        rep(j,i+1){
            add(&ans,t*dp[i][j]);
            t=t*modpow(2,n-i)%MOD;
        }
        s*=-1;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 75392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
const int N = 1e6 + 10, OO = 0x3f3f3f3f, mod = 1e9 + 7;

#define PI acos(-1)
#define clr(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, n) for (int i = 0; i < int(n); i++)
#define rloop(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define xloop(i, a, b) for (int i = int(a); i <= int(b); i++)
#define ALL(v) ((v).begin()), ((v).end())
#define SZ(v) ((int)((v).size()))
//int dx[] = {1, 0, -1, 0};
//int dy[] = {0, 1, 0, -1}; //4 Direction
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[] = {0, 1, 1, 1, 0, -1, -1, -1}; //8 direction
int dx[] = {2, 1, -1, -2, -2, -1, 1, 2};
int dy[] = {1, 2, 2, 1, -1, -2, -2, -1}; //Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction

//-- "كلٌّ من يسعى لابد يصل .. كلٌّ من يسعى مضمون له الوصول" --//

double d , t , s;

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

  cin >> d >> t >> s;
  double ans = d / s;
  if(ans <= t)
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll pw(ll x, ll y, ll mod) {
    if (y == 0) return 1;
    else if (y == 1) return x % mod;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2, mod);
        return p * p % mod;
    }
    else {
        ll p = pw(x, y / 2, mod);
        return p * p % mod * x % mod;
    }
}

ll dv(ll x, ll y, ll mod) {
    return x * pw(y, mod - 2, mod) % mod;
}
 
ll comb(ll cn, ll cr, ll mod) {
    ll v = 1;
    if (cn < cr || cn < 0 || cr < 0) return 0;
    for (int i = 1; i <= cr; i++) {
        v = v * (cn - i + 1) % mod;
        v = v * dv(1, i, mod) % mod;
    }
    return v;
}

int main() {
    ll n, m, k, mod = 1e9 + 7;
    cin >> n >> m >> k;

    ll s = 0, t = 0;
    for (int i = 1; i < n; i++) {
        s += pw(m, 2, mod) * (n - i) % mod * i % mod;
        s %= mod;
    }
    for (int i = 1; i < m; i++) {
        s += pw(n, 2, mod) * (m - i) % mod * i % mod;
        s %= mod;
    }
    cout << s * comb(n * m - 2, k - 2, mod) % mod << endl;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

ll gcd(ll a, ll b){if (b == 0) return a; return gcd(b, a % b);}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll a,b;
    ll c,d;
    ll ansA=0, ansB=0, ans=0;
    cin>>a>>b>>c>>d;

    ll lcm = (c*d)/gcd(c,d);
    a -= 1; //A以上B以下なのでAを引いてはいけない
    ansA= a - (a/c + a/d - a/lcm);
    ansB= b - (b/c + b/d - b/lcm);
    ans = ansB-ansA;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k,ans=0;
  cin>>h>>w>>k;
  vector<string> s(h);
  for(int i=0;i<h;i++) cin>>s[i];
  for(int i=0;i<(1<<h);i++)for(int j=0;j<(1<<w);j++){
       int cnt=0;
      for(int l=0;l<h;l++)for(int m=0;m<w;m++){
           if(i&(1<<l)) continue;
           if(j&(1<<m)) continue;
           if(s[l][m]=='#') cnt++;
      }
        if(cnt==k) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
    string s;
    getline(cin, s);

    string ans = "", t = "";
    for (int i=0; i<(int)s.size(); ++i) {
        if (s[i] == ' ' || s[i] == '.' || s[i] == ',') {
            if (3 <= (int)t.size() && (int)t.size() <= 6) {
                ans += " " + t;
            }
            t = "";
        } else {
            t += s[i];
        }
    }
    cout << ans.substr(1) << endl;
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
 
class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};
 
int main() {
    Radix r;
  	long long n;
  	int k;
  	std::cin >> n >> k;
    std::cout << r.to(n, k).length() << std::endl;
  
    return 0;
}

Measured memory_bytes: 888
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n;
		int[] dice;
		String str;
		int tmp, ans;
		while((n = sc.nextInt()) != 0){
			dice = new int[]{1, 2, 3, 4, 5, 6};
			ans = 1;
			for(int i = 0; i < n; i++){
				str = sc.next();
				if(str.equals("North")){
					tmp = dice[0];
					dice[0] = dice[1];
					dice[1] = dice[5];
					dice[5] = dice[4];
					dice[4] = tmp;
				}else if(str.equals("East")){
					tmp = dice[0];
					dice[0] = dice[3];
					dice[3] = dice[5];
					dice[5] = dice[2];
					dice[2] = tmp;	
				}else if(str.equals("West")){
					tmp = dice[0];
					dice[0] = dice[2];
					dice[2] = dice[5];
					dice[5] = dice[3];
					dice[3] = tmp;	
				}else if(str.equals("South")){
					tmp = dice[0];
					dice[0] = dice[4];
					dice[4] = dice[5];
					dice[5] = dice[1];
					dice[1] = tmp;	
				}else if(str.equals("Right")){
					tmp = dice[1];
					dice[1] = dice[2];
					dice[2] = dice[4];
					dice[4] = dice[3];
					dice[3] = tmp;	
				}else{
					tmp = dice[1];
					dice[1] = dice[3];
					dice[3] = dice[4];
					dice[4] = dice[2];
					dice[2] = tmp;	
				}
				ans += dice[0];
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>

long long max(long long a,long long b){
  if(a > b){
    return a;
  }
  return b;
}

int main(void){
  int N;
  scanf("%d", &N);

  long long A[N+1], B[N];
  for (int i = 0; i < N+1; i++) {
    scanf("%lld", &A[i]);
  }
  for (int i = 0; i < N; i++) {
    scanf("%lld", &B[i]);
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if(A[i] <= B[i]){
      ans += A[i];
      B[i] -= A[i];
      if(A[i+1] <= B[i]){
        ans += A[i+1];
        A[i+1] = 0;
      }else{
        ans += B[i];
        A[i+1] -= B[i];
      }
    }else{
      ans += B[i];
    }
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 1664
n = int(input())
p = list(map(float, input().split()))

dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    dp[i+1][0] = dp[i][0] * (1-p[i])
    for j in range(1, i+2):
        dp[i+1][j] = dp[i][j] * (1-p[i]) + dp[i][j-1] * p[i]

print(sum(dp[n][n // 2 + 1:]))


Measured memory_bytes: 263560
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0008
	Sum of 4 Integers
*/

#include <stdio.h>
int main(void)
{
	int n,a,b,c,d,sum,count;
	while (scanf("%d",&n) != EOF){
		count = 0;
	/* ??????????????????????????? */
		for (a = 0; a <= 9; ++a){
			b = 0;
			for (b = 0; b <= 9; ++b){
				c = 0;
				for (c = 0; c <= 9; ++c){
					d = 0;
					for (d = 0; d <= 9; ++d){
						sum = a + b + c + d;
						if(n == sum) count++;
						}
						d++;
					}
					c++;
				}
				b++;
			}
			a++;
		printf("%d\n",count);
		}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int score = count(S.cbegin() + 1, S.cend(), 'E');
    int ans = score;
    for (int i = 1; i < S.size(); i++)
    {
        if (S[i - 1] == 'W')
        {
            score++;
        }
        if (S[i] == 'E')
        {
            score--;
        }
        ans = min(ans, score);
    }
    cout << ans << endl;
}


Measured memory_bytes: 900
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n, k, x, s=0, c, i;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> x;
		c=k-x;
		if(c<0)
			c=-c;
		if(c>x)
			s+=2*x;
		else
			s+=2*c;
	}
	cout << s << endl;
	return 0;
}


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

#define i64 long long int
#define ran 101101

int n;
int a[ran], c[ran];
int q[ran], r = 0;

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	
	i64 need = 0;
	int ans = 0;
	for(int i=0;i<n;i++) {
		scanf("%d", &c[i]);
		if (c[i]>a[i]) {
			need += c[i] - a[i];
			ans++;
		}
		else q[r++] = a[i]-c[i];
	}
	
	sort(q, q+r);
	
	for(int i=r-1;need > 0 && i>=0;i--) {
		ans++;
		need -= q[i];
	}
	if (need>0) puts("-1");
	else printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#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;
}
const int INF=1e18;
const int MOD=1e9+7;

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

int modFAC(int x){
    if(x==1) return 1;
    return x*modFAC(x-1)%MOD;
}

int COM(int n,int r){
    int ret=1;
    REP(i,r){
        ret *= (n-i);
        ret %=MOD;
    }
    return ret*powMOD(modFAC(r),1e9+5)%MOD;
}

signed main(){
    int n,a,b;cin>>n>>a>>b;
    int ans=powMOD(2,n)-1;
    ans-=COM(n,a);
    ans-=COM(n,b);
    ans%=MOD;
    if(ans<0)ans+=MOD;
    cout<<ans;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<ld, ld> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[100005];
int L[100000],R[100000];
int ans[100000];
int main() {
	scanf("%s",s);
	int n=strlen(s);
	int t=-1;
	fdn(i,n-1,0,1)
	{
		if(s[i]=='L')t=i;
		L[i]=t;
	}
	t=-1;
	fup(i,0,n-1,1)
	{
		if(s[i]=='R')t=i;
		R[i]=t;
	}
	fup(i,0,n-1,1)
	{
		if(s[i]=='L')
		{
			int t=R[i];
			if((i-t)&1)ans[t+1]++;
			else ans[t]++;
		}
		else
		{
			int t=L[i];
			if((t-i)&1)ans[t-1]++;
			else ans[t]++;
		}
	}
	fup(i,0,n-1,1)printf("%d ",ans[i]);
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
  cout << setprecision(20) << fixed;
  long long w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << w*h/2.0 << " ";
  if ( (w % 2 == 0 && w/2 == x) && (h % 2 == 0 && h/2 == y) ) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

int g[110][110];

void solve() {
  int n, m;
  cin >> n >> m;
  using T = tuple<int, int, int>;
  vector<T> edges;
  rep(i, 110) rep(j, 110) g[i][j] = 1e9;
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    edges.emplace_back(a, b, c);
    g[a][b] = c;
    g[b][a] = c;
  }
  reps(k, n) reps(i, n) reps(j, n) {
    if (g[i][j] > g[i][k] + g[k][j]) g[i][j] = g[i][k] + g[k][j];
  }
  int ans = 0;
  rep(i, m) {
    int a, b, c;
    tie(a, b, c) = edges[i];
    if (g[a][b] != c) ans++;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll X; cin >> X;
    ll res=100, cnt=0;

    while(res<X){
        res = floor(double(res) * 1.01);
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--)        // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--)    // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define PB push_back

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

int h[100005];

int main(){
    int N, K; cin >> N >> K;
    rep(i, N) cin >> h[i];
    sort(h, h + N);
    int ans = INF;
    REP(i, K - 1, N){
        ans = min(ans, h[i] - h[i - K + 1]);
    }
    COUT(ans);
}

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

int main() {
  // 入力
  int N;
  int a,b,c,d;
  cin >> N;
  a=N/1000;
  d=N%10;
  c=(N/10)%10;
  b=(N/100)%10;
  if((a==b&b==c)||(b==c&&c==d)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int getDistance(int x,int y){
  return abs(x-y);
}
main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(getDistance(a,c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(getDistance(a,b)<=d&&getDistance(b,c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x ;i <= y; ++ i)
#define repd(i,x,y) for(register int i = x; i >= y; -- i)
using namespace std;
typedef long long ll;
template<typename T>inline bool chkmin(T&x,T y) { return x > y ? x = y , 1 : 0; }
template<typename T>inline bool chkmax(T&x,T y) { return x < y ? x = y , 1 : 0; }
template<typename T>inline void read(T&x)
{
    x = 0;char c;int sign = 1;
    do { c = getchar(); if(c  == '-') sign = -1; }while(!isdigit(c));
    do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
    x *= sign;
}

const int N = 6e5+500;
int tot,head[N],nxt[N],to[N],val[N];
int n,m,d[N];
bool vis[N];

inline void add(int x,int y,int w)
{
    val[tot] = w;
    to[tot] = y;
    nxt[tot] = head[x];
    head[x] = tot++;
}

bool dfs(int x)
{
    vis[x] = 1;
    for(register int i = head[x];~i ; i = nxt[i])
        if(chkmin(d[to[i]],d[x] + val[i]))
        {
            if(vis[to[i]]) return false;
            if(!dfs(to[i])) return false;
        }
    vis[x] = 0;
    return true;
}

int main()
{
    memset(d,0x3f,sizeof d);
    memset(head,-1,sizeof head);
    read(n); read(m);
    rep(i,1,m)
    {
        int a,b,c;
         read(a); read(b);read(c);
        add(a,b,c),add(b,a,-c);
    }

    rep(i,1,n)
        add(0,i,1);

    d[0] = 0;
    puts(dfs(0)?"Yes":"No");

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)
#define repit(it, t) for(__typeof((t).begin()) it = (t).begin(); it != (t).end(); it++)
#define endl "\n"
#define pb emplace_back
#define lb lower_bound
#define int long long
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second
#define DBG0(x) { cout << #x << ": " << x << "\t"; }
#define DBG(x) {DBG0(x); cout << endl;}
#define DBG2(x, y) {DBG0(x); DBG(y);}
#define DBG3(x, y, z) {DBG0(x); DBG2(y, z);}
#define DBG4(w, x, y, z) {DBG0(w); DBG3(x, y, z);}

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

signed main(void){
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans;
    if (b % a == 0) {
        ans = a + b;
    } else {
        ans = b - a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

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

    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }

    return 0;
}

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

using namespace std;

int X,N;
vector<int> p(100);

void input(){
  cin >> X >> N;
  int tmp;
  for(int i=0;i<N;i++){
    cin >> tmp;
    p[tmp]=1;
  }
}

int main(){
  input();
  for(int i=0;i<100;i++){
    //cout << p[i] << endl;
    if(p[X-i]==0 && (X-i)>=0 ){
      cout << X-i << endl;
      return 0;
    }
    if(p[X+i]==0 && (X+i)<=101){
      cout << X+i << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        ArrayList<Integer>list=new ArrayList<>();
        long sum=0;
        for(int i=0;i<n;i++){int po=sc.nextInt();sum+=po;list.add(po);}
        Collections.sort(list);
        if(sum%10==0){
            long sumcpy=sum;
            int count=0;
            while(sumcpy%10==0&&count<n){
                sumcpy=sum;
                sumcpy-=list.get(count);
                count++;
            }
            sum=sumcpy;
        }
        System.out.println((sum%10==0)?0:sum);
    }
}


Measured memory_bytes: 21844
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = [3,5,7];
  var count = 0;
  while(true){
    var tmp = list[count];
    var addlist = [3,5,7];
    var isOver = false;
    for(var i = 0; i < addlist.length; i++){
      var addValue = tmp * 10 + addlist[i];
      if(addValue > Math.pow(10,9)){
        isOver = true;
        break;
      }
      list.push(addValue);
    }
    if(isOver){
      break;
    }
    count++;
  }
  list.sort(function(a,b){
  	return a - b;
  });
  var output = 0;
  for(var i = 0; i < list.length; i++){
    var tmp = list[i].toString();
    if(N >= list[i] && tmp.indexOf("3") != -1 && tmp.indexOf("5") != -1 && tmp.indexOf("7") != -1){
      output++;
    }
  }
  myout(output);
}

Measured memory_bytes: 10160
def slove():
    import sys
    input = sys.stdin.readline
    n, d = list(map(int, input().rstrip('\n').split()))
    x = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    cnt = 0
    for i1, v1 in enumerate(x):
        for i2, v2 in enumerate(x):
            if i1 < i2:
                t = 0
                for i in range(d):
                    t += (abs(v1[i] - v2[i]) ** 2)
                if t ** 0.5 == int(t ** 0.5):
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  int a, b;
};
bool operator<(const ST& x, const ST& y){
  return x.b < y.b;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    ST x;
    cin >> x.a >> x.b;
    v.push_back(x);
  }

  sort(ALLOF(v));

  ll last = v[N-1].b;
  for(int i=N-1; i>=0; i--){
    if(last > v[i].b){
      last = v[i].b - v[i].a;
    }else{
      last = last - v[i].a;
    }
  }
  cerr << last << endl;
  if(last >= 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n";
#define ll long long

const ll MOD = 1e9 + 7;

int main() {
    int n,a,b,c,d;
    string s;
    cin >> n >> a >> b >> c >> d;
    cin >> s;
    s = '#' + s + '#';
    int tmp = 0, rockmax = 0;
    // 岩が連続してなければ移動可能
    for(int i=a; i<=c; i++) {
        if (s[i] == '#') {
            tmp++;
        } else {
            rockmax = max(tmp, rockmax);
            tmp = 0;
        }
    }
  	rockmax = max(tmp, rockmax);
    tmp = 0;
    for(int i=b; i<=d; i++) {
        if (s[i] == '#') {
            tmp++;
        } else {
            rockmax = max(tmp, rockmax);
            tmp = 0;
        }
    }
  	rockmax = max(tmp, rockmax);
    if (c < d) {
        // 追い抜かない場合
        if (rockmax <= 1) printf("Yes\n");
        else printf("No\n");
    } else {
        // 追い抜く場合（...が必要）
        int amax = 0;
        tmp = 0;
        for(int i=b-1; i<=d+1; i++) {
            if(s[i] == '.') {
                tmp++;
            } else {
                amax = max(tmp, amax);
                tmp = 0;
            }
        }
      	amax = max(tmp, amax);
        if (amax >= 3) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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

int main()
{
    int r, c;
    int *R;
    int i, j;
 
        cin >> r >> c;

         if ((r >= 1 && r <= 100) && (c >= 1 && c <= 100)) {
            try {
                R = new int[(r+1)*(c+1)];
        
                int n = 0;

                for (i = 0; i < r; i++) {
                    int sum = 0;
                    for (j = 0; j < c; j++) {
                        cin >> R[n];
                        sum += R[n];
                        n++;
                    }
                    R[n] = sum;
                    n++;
                }
 
                memset(&R[n], 0, sizeof(int)*(c+1));

                for (i = 0; i < r; i++) {
                    for (j = 0; j <= c; j++) {
                        R[n+j] += R[i*(c+1)+j];
                    }
                }

                n = 0;

                for (i = 0; i <= r; i++) {
                    for (j = 0; j <= c; j++) {
                        cout << R[n];
                        if (j == c) {
                            cout << endl;
                        } else {
                            cout << " ";
                        }
                        n++;
                    }
                }
            }
            catch (...) {
                return -1;
            }
        }

     return 0;
}


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

# 任意の偶数に関して、n ^ (n+1) = 1
# nが偶数の時最下位ビットのみが異なるので。

num = B - A + 1
ans = 0

if A % 2 == 0:
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
		
	if num % 2 == 1:
		ans = ans ^ B
		
if A % 2 == 1:
	num -= 1
	
	ones = num // 2
	
	if ones % 2 == 1:
		ans = 1
	else:
		ans = 0
	
	if num % 2 == 1:
		ans = ans ^ B
		
	ans = ans ^ A
	
print(ans)

Measured memory_bytes: 9212
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int i, j, n;
        int a[][];
        while(true){
            n = sc.nextInt();
            if(n == 0) break;
            a = new int [n + 1][n + 1];
            for(i = 0; i < n; i++){
                for(j = 0; j < n; j++){
                    a[i][j] = sc.nextInt();
                }
            }
            for(i = 0; i < n; i++){
                for(j = 0; j < n; j++){
                    a[i][n] += a[i][j];
                    a[n][i] += a[j][i];
                }
                a[n][n] = a[i][n] + a[n][j];
            }
            for(i = 0; i < n + 1; i++){
                for(j = 0; j < n + 1; j++){
                    System.out.print(String.format("%1$5s", a[i][j]));
                }
                System.out.println();
            }
        }
        sc.close();
    }
}



Measured memory_bytes: 32636
n,m=map(int,input().split())
X=sorted(list(map(int,input().split())))
if n>=m:
	print(0)
	exit()
x=[]
for i in range(len(X)-1):
	x.append(X[i+1]-X[i])
x.sort()
if n==1:print(sum(x))
else:print(sum(x[:-(n-1)]))

Measured memory_bytes: 13968
#include "bits/stdc++.h"
using namespace std;
signed main()
{
int n,m,x,y;
cin>>n>>m;
  int deg[n+1]={};
while(cin>>x>>y){deg[x]++;deg[y]++;}
for(int i=1;i<=n;i++)
  cout<<deg[i]<<"\n";
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,a[200040];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)cin>>a[i];
	sort(a,a+i);
	for(i=0;i++<n;)
	{
		for(j=i;j++<n;)
		{
			for(k=j;k++<n;)s+=a[i]+a[j]>a[k]&&a[i]<a[j]&&a[j]<a[k];
		}
	}
	cout<<s;
}

Measured memory_bytes: 3668
#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> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	//降順ソートし、evenとoddで分けて、合計を比較
	sort(a.begin(), a.end(), greater<int>());

	int alice = 0, bob = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>
#include<cmath>

using namespace std;

int count {0};

void insertionSort(vector<int> &A, int n, int g)
{
  for (int i = g; i < n; ++i) {
    int v = A[i];
    int j = i - g;
    while (j >= 0 and A[j] > v) {
      A[j+g] = A[j];
      j = j - g;
      count++;
    }
    A[j+g] = v;
  }
}

// Shell sort
int main()
{
  int n; cin >> n;
  vector<int> A(n);
  for (int i =0; i<n; ++i) cin >> A[i];

  vector<int> gs; int g;
  for (int k = 1; g = floor(n/pow(2, k)), g >= 1; ++k) {
    insertionSort(A, n, g);
    gs.push_back(g);
  }

  if (!gs.size())
    gs.push_back(1); // edge

  int m = gs.size();
  cout << m << endl; // m
  for (int i = 0; i < m; ++i) {
    if(i) cout << " ";
    cout << gs[i];
  }
  cout << endl << count << endl;
  for (int i = 0; i < n; ++i) cout << A[i] << endl;
}


Measured memory_bytes: 6784
n,k = map(int,input().split())
a = list(map(int,input().split()))
t,ans =2**40,0
while t:
    c = sum([(a[i]&t)//t for i in range(n)]) #a[i]のある桁における1の数
    if c>=n-c or k<t: ans += t*c
    else: ans += t*(n-c);k-=t
    t = t>>1
print(ans)

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

int main(){
	int k;
	cin >> k;
	if(k == 1){
		cout << 1 << endl;
		return 0;
	}
	
	vector<bool>r_flag(k+1,false);
	
	int r = 7%k;

	if(r == 0){
		cout << 1 << endl;
		return 0;
	}
	else{
		r_flag[r] = true;
	}

	int count = 1;
	while(1){
		r = (r*10+7) % k;
		count++;

		if(r == 0){
			cout << count << endl;
			return 0;
		}
		if(r_flag[r] == true){
			//cout << count << endl;
			cout << -1 << endl;
			return 0;
		}
		
		r_flag[r] = true;

	}

	return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)

 
void deal(){
	ll n , k;
	cin>>n;
	vector<vector<ll> > arr(n+1, vector<ll> (3));
	fori(n)
		forj(3)
			cin>>arr[i+1][j];
	vector<vector<ll> > dp(n+1, vector<ll> (3));
	for(ll i = 1; i<=n; i++){
		forj(3){
			dp[i][j] = max(dp[i-1][(j+1)%3] , dp[i-1][(j+2)%3]) + arr[i][j];
		}
	}
	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

int i1,i2;char ch;
inline int read()
{
	i1=i2=ch=0;
	while(!isdigit(ch))	i1|=ch=='-',ch=getchar();
	while(isdigit(ch))	i2=(i2<<1)+(i2<<3)+(ch^48),ch=getchar();
	return i1? -i2:i2;
}

int main()
{
	int x=read(),y=read();
	printf("%d\n",x+(y>>1));
	
	return 0;
}

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

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

	bool a = false, b = false, c = false;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'a') {
			a = true;
		}
		else if (s[i] == 'b') {
			b = true;
		}
		else if (s[i] == 'c') {
			c = true;
		}
	}

	if (a && b && c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

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

int main() {
  set<ll> s;
  for(ll i=0;i<3;i++) {
    ll temp;
    cin >> temp;
    s.insert(temp);
  }
  if(s.size()==2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dx[] = {1,0,0,1, 1,1, 1,0, 0,1, 1, 1,-1};
int dy[] = {0,1,0,1,-1,0, 0,1, 1,1,-1, 1, 1};
int dz[] = {0,0,1,0, 0,1,-1,1,-1,1, 1,-1, 1};

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

  int N, M, P;
  while(cin>>N>>M>>P,N){
	int res = 0, turn = 0;
	int bd[9][9][9];
	fill((int*)bd, (int*)bd+9*9*9, 0);
	REP(p,P){
	  int c = 1+p%2;
	  int x, y, z; cin >> x >> y;
	  if(res != 0) continue;

	  for(z=1;z<=7;++z)
		if(bd[x][y][z] == 0)
		  break;
	  bd[x][y][z] = c;
	  //	  cout<<x<<","<<y<<","<<z<<endl;
	  REP(i,13){
		int tx = x, ty = y, tz = z;
		int cnt = 0;
		while(bd[tx][ty][tz] == c)
		  tx += dx[i], ty += dy[i], tz += dz[i], ++cnt;
		tx = x, ty = y, tz = z;
		while(bd[tx][ty][tz] == c)
		  tx -= dx[i], ty -= dy[i], tz -= dz[i], ++cnt;
		--cnt;
		if(cnt >= M && res == 0){
		  res = c;
		  turn = p+1;
		}
	  }
	}
	if(res == 0)
	  cout << "Draw" << endl;
	else if(res == 1)
	  cout << "Black " << turn << endl;
	else
	  cout << "White " << turn << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  int cnta[2]={};
  int cntb[2]={};
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]!='1')cnta[i%2]++;
    if(s[i]!='0')cntb[i%2]++;
  }
  cout<<min(cnta[0]+cntb[1],cnta[1]+cntb[0])<<"\n";
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

mint pow(mint a, unsigned long long k) {
    mint r = 1;
    while (k) {
      if (k & 1) r *= a;
      a *= a;
      k >>= 1;
      }
      return r;
}

void solve(istream& cin, ostream& cout) {
  int n;
  int k;
  cin >> n >> k;
  // gcd(A1...AN)=Xとなる数列{Ai}が幾つ存在するか？
  //(K/X)^N個
  mint ans = 0;
  vector<mint> a(k + 1);
  RFOR(i, k, 1) {
    mint add = pow(mint(k / i), n);
    int m = 2;
    while (i * m <= k) {
      add -= a[i * m];
      m++;
    }
    a[i] = add;
    ans += mint(add * i);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3976
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long int n, m;
    cin>>n>>m;
    long int a[m], i, c=0, x;
    for(i=0; i<m; i++)
    {
      cin>>a[i];
      c=c+a[i];
    }
  	x = n-c;
    if(x>=0)
    {
      cout<<x<<endl;
    }
  	else
    {
	  cout<<"-1"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
  
};
typedef struct node * Node;
 
Node root;



Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else{
    if(z->key < y->key) y->left = z;
    else y->right = z;
  }
}
 
Node treeSearch(Node u, int k){
  while(u != NIL){
    if(u->key == k) return u;
    else if(u->key > k) u = u->left;
    else u = u->right;
  }
  return NIL;
}
 
void inorder(Node u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
 
Node treeSuccessor(Node x){
  Node y;
   
  if(x->right != NIL) return treeMinimum(x->right);
 
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node p;
  Node y; // node to be deleted
  Node x; // child of y
 
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
 
  if(y->left != NIL) x = y->left;
  else x = y->right;
 
  if(x != NIL) x->parent = y->parent;
 
  p = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == p->left) p->left = x;
  else p->right = x;
 
  if(y != z) z->key = y->key;
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } 
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
   
  return 0;
}



Measured memory_bytes: 20440
package main

import "fmt"

func main() {
	var h, c, sum int
	fmt.Scan(&h)
	for h > 0 {
		h = h / 2
		c++
	}
	sum = 1
	for c > 0 {
		sum *= 2
		c--
	}
	fmt.Println(sum - 1)

}


Measured memory_bytes: 512