akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;

//-----------------------------------------------------------------------------

int n,m;
unordered_map<ll,vector<P> > g;
unordered_map<ll,int> d;

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

	cin>>n>>m;
	REP(i,m) {
		ll p,q,c;cin>>p>>q>>c;
		p--,q--;
		ll p_change=p|c<<30,q_change=q|c<<30;
		g[p].pb(P(p_change,1));
		g[p_change].pb(P(p,1));
		g[p_change].pb(P(q_change,0));
		g[q_change].pb(P(p_change,0));
		g[q_change].pb(P(q,1));
		g[q].pb(P(q_change,1));
	}
	priority_queue<P,vector<P>,greater<P> > pq;
	pq.push(P(0,0));
	while(!pq.empty()) {
		P p=pq.top();pq.pop();
		ll v=p.se;
		if(d[v]==0&&v!=0) d[v]=INF;
		if(d[v]<p.fi) continue;
		for(auto e:g[v]) {
			if(d[e.fi]==0&&e.fi!=0) d[e.fi]=INF;
			if(d[e.fi]<=d[v]+e.se) continue;
			d[e.fi]=d[v]+e.se;
			pq.push(P(d[e.fi],e.fi));
		}
	}

	cout<<(d[(ll)n-1LL]==INF||d[(ll)n-1LL]==0?-1LL:d[(ll)n-1]/2LL)<<endl;

	return 0;
}


Measured memory_bytes: 77172
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll mod = ll(1e9+7);

    string s;
    cin >> s;

    int num_digits = s.size();
    vector<vector<ll>> dp(num_digits, vector<ll>(13));

    for(int i=0; i<num_digits; i++) {
        char c = s[i];
        if(i==0) {
            if(c=='?') {
                for(int j=0; j<10; j++) dp[0][j] = ll(1);
            } else {
                dp[0][int(c-'0')] = ll(1);
            }
        } else {
            if(c=='?')
                for(int j=0; j<10; j++)
                    for(int k=0; k<13; k++)
                        dp[i][(10*k+j)%13] += dp[i-1][k] % mod;
            else
                for(int k=0; k<13; k++)
                    dp[i][(10*k+int(c-'0'))%13] += dp[i-1][k] % mod;
         }
    }

    ll ans = dp[num_digits-1][5] % mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13696
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

count = 0

for i in range(x+1, y+1):
    if max(X) < i and min(Y) >= i:
        count += 1
        break

if count == 1:
    print('No War')
else:
    print('War')

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

int main() {
	int w, h , n;
	cin >> w >> h >> n;
	int x[n];
	int y[n];
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}

	int sq[w][h] = {};
	for (int i = 0; i < n; i++) {
		if (a[i] == 1) {
			for (int j = 0; j < x[i]; j++) {
				for (int k = 0; k < h; k++) {
					sq[j][k] = 1;
				}
			}
		} else if (a[i] == 2) {
			for (int j = x[i]; j < w; j++) {
				for (int k = 0; k < h; k++) {
					sq[j][k] = 1;
				}
			}
		} else if (a[i] == 3) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < y[i]; k++) {
					sq[j][k] = 1;

				}
			}
		} else if (a[i] == 4) {
			for (int j = 0; j < w; j++) {
				for (int k = y[i]; k < h; k++) {
					sq[j][k] = 1;
				}
			}
		}
	}


	int ans = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++){ 
			if (sq[i][j] == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
#import numpy as np
#from collections import defaultdict
import math
#from collections import deque

input = sys.stdin.readline
#import numpy as n



def main():

    N = int(input())
    ans =0
    for i in range(1,N+1):
        num =  int(N/i)
        ans += int(num*(num+1)/2 *i)

    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 64460
r,c=map(int, input().split())
s=[0]*(c+1)

for i in range(r):
    k=list(map(int, input().split()))
    for j in range(c):
        print(k[j], end=" ")
        s[j]+=k[j]
    print(sum(k))
    s[c]+=sum(k)
    
for i in range(c+1):
    print(s[i], end="")
    if i<c:
        print(" ", end="")
print("")
    


Measured memory_bytes: 5648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
vector<ll> v;

int main() {
	cin >> n;
	rep(i, n) {
		ll l;
		cin >> l;
		v.push_back(l);
	}
	sort(ALL(v));
	reverse(ALL(v));
	ll now = 1;
	ll pre = -1;
	ll cnt = 0;
	rep(i, n) {
		if (pre == v[i]) {
			now *= pre;
			cnt++;
			pre = -1;
			if (cnt == 2)break;
		}
		else pre = v[i];
	}
	if (cnt == 2)cout << now << endl;
	else cout << 0 << endl;
}

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

int main() {
  int k,n;
  cin>>k>>n;
  vector<int> a(n+1);
  for (int i=0;i<n;++i) {
    cin>>a[i];
  }
  a[n]=k+a[0];
  int DL=0;
  for (int j=0;j<n;++j) {
    if ((a[j+1]-a[j])>DL) {
      DL=a[j+1]-a[j];
    }
  }
  cout<<k-DL<<endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
ifstream f("E.in");
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll a[n+3],sum=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        sum=sum^a[i];
    }
    for(int i=1;i<=n;i++) cout<<(a[i]^sum)<<' ';

    return 0;
}


Measured memory_bytes: 5204
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n;
    readf("%s", &n);
    readln;
    
    auto arr = readln.chomp.split.map!(to!int).array;
    
    int mn = n;
    int ans = 0;
    foreach (e; arr) {
        if (e <= mn) { ans += 1; }
        
        mn = min(mn, e);
    }
    ans.writeln;
}

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


int main() {
string s,t;
cin >> s >> t;
int count = 0;
for(int i = 0; i<s.size(); i++){
    if(s[i] != t[i]){
        count++;
    }
}
cout << count << endl;
}


Measured memory_bytes: 3912
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	ifstream fin("input.txt");
	long long N, A;
	cin >> N;
	cin >> A;
	N *= N;
	cout << N - A << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i;
    double a,sum;
    while(scanf("%lf",&a)!=EOF){
        sum=a;
        for(i=0;i<9;i++){
            if(i%2==0)a*=2;
            else a/=3;
            sum+=a;
        }
        printf("%f\n",sum);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const ll inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll H, W; cin >> H >> W;
    ll N; cin >> N;
    vector< vector<P> > v(W);
    REP(i, N) {
        ll y, x, a; cin >> y >> x >> a; --y, --x;
        v[x].pb({y, a});
    }
    vector< vector<P> > ev(H);
    REP(i, W) {
        sort( ALL(v[i]) );
        ll n = v[i].size();
        REP(j, n-1) {
            ll y1 = v[i][j].first;
            ll y2 = v[i][j+1].first;
            ll d = v[i][j+1].second - v[i][j].second;
            ev[y1].pb({y2, d});
            ev[y2].pb({y1, -d});
        }
    }
    vector<bool> used(H, false);
    vector<ll> pot(H, 0);
    bool ans = true;
    vector<ll> group(H, -1);
    vector<ll> pot0;
    int gid = 0;
    REP(q, H) {
        if (used[q]) continue;
        used[q] = true;
        group[q] = gid;
        pot0.pb(0);
        queue<ll> Q; Q.push(q);
        while ( !Q.empty() ) {
            int y = Q.front(); Q.pop();
            // cout << y << endl;
            EACH(p, ev[y]) {
                ll ny, d; tie(ny, d) = p;
                if (!used[ny]) {
                    used[ny] = true;
                    pot[ny] = pot[y]+d;
                    group[ny] = gid;
                    pot0[gid] = min(pot0[gid], pot[ny]);
                    Q.push(ny);
                    // cout << y << " " << ny << " " << d << endl;
                }
                else {
                    // cout << y << " " << ny << " " << d << endl;
                    // cout << pot << endl;
                    if (pot[ny] != pot[y]+d) {
                        ans = false;
                    }
                }
            }
        }
        ++gid;
    }
    REP(x, W) EACH(p, v[x]) {
        ll y, a; tie(y, a) = p;
        ll y0 = a - pot[y];
        if (y0 + pot0[group[y]] < 0) ans = false;
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 12792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

/*
Log order calcuration of power
*/
ll bi_pow(ll x, ll n){
  ll res = 1;
  while (n>0){
    if (n%2==1) {res = res * x % MOD;}
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

/*
Inverse element of MOD = 1e9+7
*/
ll inv_MOD(ll x){
  return bi_pow(x, MOD-2);
}


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

  ll H, W, A, B;
  cin >> H >> W >> A >> B;

  
  vector<ll> fact(H+W+1);
  fact[0] = 1;
  REP3(i,1,H+W+1){
    fact[i] = (fact[i-1] * i) % MOD;
  }

  // row A
  ll ans = 0;
  REP3(j,B,W){
     ll Aj = fact[H-A+j-1] * inv_MOD(fact[H-A-1]*fact[j]%MOD) % MOD;
     ll restAj = fact[A-1+W-j-1] * inv_MOD(fact[A-1]*fact[W-j-1]%MOD) % MOD;
     ans += Aj * restAj;
     ans %= MOD;
  }

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


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
char a[200020];
int main(void)
{
    int T,n,f,x,y,s,mn,xx,yy;
    string a,b,c;
    cin>>a>>b;
    scanf("%d %d",&x,&y);
    cin>>c;
    if(a==c)
        x--;
    else if(b==c)
        y--;
    printf("%d %d\n",x,y);
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int A[1000000], n;

int binarySearch(int key) {
    int left = 0;
    int right = n;
    int mid;
    while (left < right) {
        mid = (left + right) / 2;
        if (key == A[mid]) return 1;
        if (key > A[mid]) left = mid + 1;
        else if (key < A[mid]) right = mid;
    }
    return 0;
}

int main() {
    int i, q, k, sum = 0;

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

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d", &k);
        if (binarySearch(k)) sum++;
    }
    printf("%d\n", sum);

    return 0;

}


Measured memory_bytes: 3000
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		
		int n, m;
		n = int.Parse(s[0]);
		m = int.Parse(s[1]);
		int d = m/n;
		bool f = true;
		
		for(int i=d; i>0; i--){
			if(f){
				if(m%i==0){
					Console.WriteLine(i);
					f = false;
				}
			}
		}
	}
}


Measured memory_bytes: 13140
#include <cstdio>
#include <vector>
#include <algorithm>

using std::vector;

const int MaxK = 18, MaxN = 1 << MaxK, MaxS = 1 << 9;
const int MaxQ = 100005;

int n, q, W = 0;

struct item_t {
	int w, v;
	
	inline item_t add(const item_t &other) const {
		return {w + other.w, v + other.v};
	}
} items[MaxN];

struct query_t {
	int w, id;
};
vector<query_t> buk[MaxN];

int ans[MaxQ];

inline void append(vector<item_t> &f, const item_t &cur) {
	if (f.empty() || cur.v > f.back().v) f.push_back(cur);
}

vector<item_t> trans(const vector<item_t> &f, const item_t &item) {
	vector<item_t> res;
	auto it = f.begin();
	for (auto cur: f) {
		while (it != f.end() && it->w + item.w <= cur.w) append(res, it++->add(item)); 
		append(res, cur);
	}
	while (it != f.end() && it->w + item.w <= W) append(res, it++->add(item));
	return res;
}

inline bool cmp_w(const item_t &a, const item_t &b) {
	return a.w < b.w;
}

struct solve {
	const vector<item_t> &dp;
	vector<item_t> tmp;
	int res;
	
	solve(int u, int w, const vector<item_t> &f): dp(f), res(0) {
		for (; u >= MaxS; u >>= 1) tmp.push_back(items[u]);
		dfs(tmp.begin(), w, 0);
	}
	
	void dfs(vector<item_t>::iterator cur, int w, int v) {
		if (w < 0) return;
		if (w == 0 || cur == tmp.end()) {
			auto it = --std::upper_bound(dp.begin(), dp.end(), (item_t){w, 0}, cmp_w);
			res = std::max(res, v + it->v);
			return;
		}
		auto nxt = std::next(cur);
		dfs(nxt, w, v);
		dfs(nxt, w - cur->w, v + cur->v);
	}
};

void dfs(int u, const vector<item_t> &f) {
	if (u > n) return;
	const vector<item_t> &g = u < MaxS ? trans(f, items[u]) : f;
	for (auto q: buk[u]) ans[q.id] = solve(u, q.w, g).res;
	dfs(u << 1, g);
	dfs(u << 1 | 1, g);
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &items[i].v, &items[i].w);
	}
	scanf("%d", &q);
	for (int i = 0; i < q; ++i) {
		int u, w;
		scanf("%d%d", &u, &w);
		buk[u].push_back({w, i});
		W = std::max(W, w);
	}
	dfs(1, {{0, 0}});
	for (int i = 0; i < q; ++i) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 14972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

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

    int n=s.size();

    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout<<-1<<endl;
        return 0;
    }

    if(n==26){
        string t=s;
        next_permutation(all(s));
        string ans="";
        rep(i,n){
            ans+=s[i];
            if(s[i]>t[i]) break;
        }

        cout<<ans<<endl;
        return 0;
    }
    vector<int> cnt(26,0);
    rep(i,n){
        cnt[s[i]-'a']++;
    }

    rep(i,26){
        if(cnt[i]==0){
            string ans=s+char('a'+i);
            cout<<ans<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <numeric>//accumulate(v.begin(), v.end(), 0);
#include <algorithm>//sort(v.begin(),v.end());
#include <string>//
#include <cmath>
#include <iomanip> //setprecision(2)
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        string s,t;

        cin>> s;
        if(s.size()==2) {
                cout << s <<endl;
        }else{
                reverse(s.begin(), s.end());
                cout << s <<endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a1,a2,a3;

    scanf("%d %d %d", &a1, &a2, &a3);

    if((a1+a2+a3)>=22){
        printf("bust\n");
    }
    else{
        printf("win\n");
    }
}

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

int main() {
	string S, T = "CODEFESTIVAL2016";
	cin >> S;
	int ans = 0;
	for (int i = 0; i < 16; i++) {
		if (S.at(i) != T.at(i)) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  
  int r;
  
  scanf("%d",&r);
  if(r<1200){
    printf("ABC\n");
  }
    else if(r<2800){
      printf("ARC\n");
    }
  else {
    printf("AGC\n");
  }
  return 0;
}

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

int main()
{
    int num[10010]={0},map[110][110]={0};
    int n,h,w;
    while(cin>>h>>w>>n)
    {
        memset(num,0,sizeof(num));
        memset(map,0,sizeof(map));
        for(int i=1;i<=n;i++) cin>>num[i];
        int cnt=1,ans=0;
        for(int i=0;i<h;i++)
        {
            if(i%2==0){
            for(int j=0;j<w;j++)
            {
                map[i][j]=cnt;
                ans++;
                if(ans>=num[cnt])
                {cnt++; ans=0;}
            }
            }
            else{
            for(int j=w-1;j>=0;j--)
            {
                map[i][j]=cnt;
                ans++;
                if(ans>=num[cnt])
                {cnt++;ans=0;}
            }
            }
        }
        for(int i=0;i<h;i++)
        {
            for(int j=0;j<w;j++)
            {
                cout<<map[i][j];
                if(j!=w-1) cout<<' ';
            }
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int n,a,b,k,ca,cb,ans;
int gt[3000005],rgt[3000005];
int binpow(int x,int mu){
	if(mu==1) return x%mod;
	else{
		int tmp=binpow(x,mu/2);
		if(mu%2==1) return ((tmp*tmp%mod)*x)%mod;
		else return tmp*tmp%mod;
	}
}
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>a>>b>>k;
	gt[0]=1;
	for(int i=1;i<3000004;i++){
		gt[i]=(gt[i-1]%mod*(n-i+1)%mod)*(binpow(i,mod-2)%mod)%mod;
	}
	for(int ca=0;ca<=n;ca++){
		cb=(k-ca*a)/b;
		if(cb*b+ca*a!=k||cb<0) continue;
		ans=(gt[ca]*gt[cb]%mod+ans)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 24576
#include<iostream>
using namespace std;
void output(int Array[], char mark){
    for(int i=1;i<14;i++){
        if(Array[i]==0){
            cout<<mark<<" "<<i<<endl;
        }
    }
}

int main(){
    char mark[2];
    int n,S[14]={},H[14]={},C[14]={},D[14]={},tmp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>mark>>tmp;
        switch(mark[0]){
            case 'S':
            S[tmp]=1;
            break;
            case 'H':
            H[tmp]=1;
            break;
            case 'C':
            C[tmp]=1;
            break;
            case 'D':
            D[tmp]=1;
            break;
        }
    }
    output(S,'S');
    output(H,'H');
    output(C,'C');
    output(D,'D');
    return 0;
}


Measured memory_bytes: 3076
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=102;
int i,j,k,n,m,ch,x,y,ans;
int a[N][N],A[N][N],B[N][N];
char s[N];
short f[N][N][N][N];
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) {
		scanf("%s",s+1);
		for (j=1;j<=m;j++) {
			if (s[j]=='o') a[i][j]=1;
			if (s[j]=='E') x=i,y=j;
		}
	}
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) A[i][j]=a[i][j]+A[i][j-1];
	for (j=1;j<=m;j++)
		for (i=1;i<=n;i++) B[i][j]=a[i][j]+B[i-1][j];
	for (int u=0;u<=n;u++)
		for (int d=0;u+d<n;d++)
			for (int l=0;l<=m;l++)
				for (int r=0;l+r<m;r++) {
					if (x-d<=u+1 && u+1<=x+u) f[u+1][d][l][r]=max(f[u+1][d][l][r],(short) (f[u][d][l][r]+max(0,A[u+1][min(y+l,m-r)]-A[u+1][max(y-r,l+1)-1])));
					if (x-d<=n-d && n-d<=x+u) f[u][d+1][l][r]=max(f[u][d+1][l][r],(short) (f[u][d][l][r]+max(0,A[n-d][min(y+l,m-r)]-A[n-d][max(y-r,l+1)-1])));
					if (y-r<=l+1 && l+1<=y+l) f[u][d][l+1][r]=max(f[u][d][l+1][r],(short) (f[u][d][l][r]+max(0,B[min(x+u,n-d)][l+1]-B[max(x-d,u+1)-1][l+1])));
					if (y-r<=m-r && m-r<=y+l) f[u][d][l][r+1]=max(f[u][d][l][r+1],(short) (f[u][d][l][r]+max(0,B[min(x+u,n-d)][m-r]-B[max(x-d,u+1)-1][m-r])));
				}
	for (int u=0;u<=n;u++)
		for (int d=0;u+d<=n;d++)
			for (int l=0;l<=m;l++)
				for (int r=0;l+r<=m;r++) ans=max(ans,(int) f[u][d][l][r]);
	printf("%d\n",ans);
}

Measured memory_bytes: 209152
#include<iostream>

const int MAX_N = 100000;
int par[MAX_N];
int rank[MAX_N];
int dist2par[MAX_N];

void init(int n) {
	for(int i=0;i<n;i++) {
		par[i] = i;
		rank[i] = 0;
		dist2par[i] = 0;
	}
}

int find(int x) {
	if(par[x] == x) {
		return x;
	} else {
		int oldpar = par[x];
		int newpar = find(oldpar);
		par[x] = newpar;
		dist2par[x] += dist2par[oldpar];
		return newpar;
	}
}

bool unite(int l, int r, int d) {
	int rl = find(l);
	int dl = dist2par[l];
	int rr = find(r);
	int dr = dist2par[r];
	if (rl == rr) return d == dl - dr;

	if (rank[rl] < rank[rr]) {
		par[rl] = rr;
		dist2par[rl] = dr - dl + d;
	} else {
		par[rr] = rl;
		dist2par[rr] = -(dr - dl + d);
		if (rank[rl] == rank[rr]) rank[rl]++;
	}
	return true;
}

int main() {
	int n, m;
	std::cin >> n >> m;
	init(n);
	bool ok = true;
	for(int i=0;i<m;i++) {
		int l, r, d;
		std::cin >> l >> r >> d;
		if (ok) {
			ok = unite(l-1, r-1, d);
		}
	}
	std::cout << (ok ? "Yes" : "No") << std::endl;
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define inf 0


using namespace std;

int main(){
    //ll t; cin>> t; while(t--){
        ll n, m=3;
        cin>> n ;
        ll a[n][m], dp[n][m];
        for(ll i =0;i<n;i++){
            for(ll j =0;j<m;j++){
                cin >> a[i][j];
                dp[i][j] = inf;
            }

        }

        for(ll j =0;j<m;j++){
            dp[0][j] = a[0][j];
        }
        for(ll i =1;i<n;i++){
            for(ll j =0;j<m;j++){
                for(ll k =0;k<m;k++){
                    if(j != k) dp[i][k] = max(dp[i][k], dp[i-1][j]+a[i][k]);
                }
            }
        }

        ll ans = inf;
        for(ll j =0;j<m;j++){
            ans = max(ans, dp[n-1][j]);
        }
        cout << ans << endl;

}


Measured memory_bytes: 4992
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,m,c,b[20],a[20][20],x=0,y=0;
	cin>>n>>m>>c;
	for(int a1=0;a1<m;a1++){
		cin>>b[a1];
	}
	for(int a2=0;a2<n;a2++){
		for(int a3=0;a3<m;a3++){
			cin>>a[a2][a3];
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				x=x+b[j]*a[i][j];
				}
				x=x+c;
				if(x>0){
					y++;
					}
					x=0;
			}
			cout<<y<<endl;
			return 0;
}



Measured memory_bytes: 256
import sys
import pdb
input = sys.stdin.readline

S = input()
T = input()

# print(S, T)

# lcs[Sのi文字目まで][Tのj文字目まで]
# 求める答えはlcs[len(S)][len(T)]
lcs = [[0 for _ in range(len(T)+1)] for __ in range(len(S)+1)]

for i in range(len(S)):
  for j in range(len(T)):
    if S[i] == T[j]:
      lcs[i+1][j+1] = lcs[i][j] + 1
    else:
      # print(i,j)
      lcs[i+1][j+1] = max(lcs[i][j+1], lcs[i+1][j])

# print(lcs)
# print(lcs[len(S)][len(T)])

lcs_string = ""

i, j = len(S), len(T)

while i > 0 and j > 0:
  if lcs[i][j] == lcs[i-1][j]:
    i -= 1
  elif lcs[i][j] == lcs[i][j-1]:
    j -= 1
  else:# lcs[i][j] == lcs[i-1][j-1] + 1:
    lcs_string = S[i-1] + lcs_string
    i -= 1
    j -= 1

print(lcs_string)


Measured memory_bytes: 124508
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
int f[5010][5010],n,s[5010];
vector<int> e[5010];
ll cef[5010],fac[5010],ifac[5010];
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void upd(int&a,ll b){a=(a+b)%mod;}
void dp(int x,int dad){
	s[x]=1;f[x][1]=1;
	if(e[x].size()-(dad!=0)==0) return;
	int g[5010]={};
	for(int v:e[x]) if(v!=dad){
		dp(v,x);
		memset(g,0,sizeof(g));
		for(int i=0;i<=s[v];i++)
			for(int j=0;j<=s[x];j++){
				upd(g[i+j],1ll*f[x][j]*f[v][i]);
				if(i) upd(g[j],-1ll*f[x][j]*f[v][i]%mod*cef[i]);
			}
		memcpy(f[x],g,sizeof(g));
		s[x]+=s[v];
	}
}
int main(){
	read(n);
	for(int i=1;i<n;i++){
		int x,y;read(x);read(y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n]=fp(fac[n],mod-2);
	for(int i=n;i;i--) ifac[i-1]=ifac[i]*i%mod;
	cef[0]=1;
	for(int i=2;i<=n;i+=2) cef[i]=fac[i]*ifac[i/2]%mod*fp(fp(2,i/2),mod-2)%mod;
	dp(1,0);
	ll ans=0;
	for(int i=0;i<=n;i++)
		ans=(ans+cef[i]*f[1][i])%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 178944
#include<stdio.h>
#include<limits.h>

int main(void){
    int i,N;
    scanf("%d",&N);
    long long int L[100];
    L[0] = 2;
    L[1] = 1;

    for(i = 2;i < 100;i++) L[i] = L[i - 1] + L[i - 2];
    
    printf("%lld",L[N]);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a=sc.nextInt();
			int b=sc.nextInt();
			int x=a+b;
			String s=String.valueOf(x);
			System.out.println(s.length());
		}
	}
}

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

using namespace std;

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

  for(int i = 0;i < s.length();++i){
    char c = s[i];
    if(c >= 65 && c <= 90){
      c += 32;
    }else if(c >= 97 && c <= 122){
      c -= 32;
    }
    printf("%c", c);
  }
  printf("\n");

}



Measured memory_bytes: 3192
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, k;

ll bin_exp(ll b, ll e) {
    ll ret = 1;
    while (e > 0) {
        if (e & 1) {
            ret *= b;
        }
        b *= b;
        e >>= 1;
    }
    return ret;
}

int main() {
    fast_io; cout_precision;
    cin >> n >> k;
    cout << k * bin_exp(k - 1, n - 1);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N, M;
    cin >> N >> M;

    int p = 1;
    REP(i, M)p *= 2;
    int X = M * 1900 + (N - M) * 100;
    X *= p;
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val S = ns()
    var p = 0
    var ans = 0L
    REP(S.length) { i =>
      if (S(i) == 'W') {
        ans += i - p
        p += 1
      }
    }
    out.println(ans)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

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

signed main() {
    int N, M;
    scanf("%d %d", &N, &M);
    int A[N][M];
    int like[M+1]={};
    for(int i=0;i<N;i++){
        int K_i;
        scanf("%d", &K_i);
        for (int j=0;j<K_i;j++){
            int A_i_j;
            scanf("%d", &A_i_j);
            like[A_i_j] += 1;
        }
    }
    int count = 0;
    for (int i=1;i<M+1;i++){
        if (like[i] == N){
            count += 1;
        }
    }
    printf("%d\n", count);
}


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

int main() {
  
  int n;
  cin >> n;
  string s,t;
  cin >> s >> t;
  for(int i=0;i<n;i++){//i番目のs文字
    for(int j=i;j<i+1;j++){//i番目のt文字
    cout << s.at(i) << t.at(j);
    }
  }
}


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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

const ll p = 7LL + ll(1e9);
 
ll fac[500001];
ll inv_fac[500001];
 
ll mod_exp(ll a, ll b)
{
	if(b==0LL) return 1LL;
 
	ll ans = mod_exp(a,ll(b/2LL));
	ans*=ans;
	ans%=p;
 
	if(b%2LL==1LL) ans*=a;
	ans%=p;
 
	return ans;
}
 
ll C(int n, int k)
{
	if(k<0 || k>n) return 0;

	ll ans = fac[n]*inv_fac[k];
	ans%=p;
	return (ans*inv_fac[n-k])%p;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif
 
	fac[0]=1LL;
	inv_fac[0]=1LL;
 
	for(int i=1; i<=500000; i++)
	{
		fac[i] = ll(i)*fac[i-1];
		fac[i] %= p;
 
		inv_fac[i] = mod_exp(fac[i],p-2LL);
		// if(i<10) cout << i << " " << fac[i] << " " << inv_fac[i] << endl;
	}

	int n,m;
	cin>>n>>m;

	ll ans=C(m,n)*fac[n];
	ans %= p;

	for(int i=1; i<=n; i++)
	{
		ll cur = C(n,i);

		cur *= C(m-i,n-i);
		cur %= p;

		cur *= fac[n-i];
		cur %= p;

		if(i%2 == 1) cur = p-cur;

		ans += cur;
		ans %= p;
	}

	ans *= C(m,n);
	ans %= p;

	ans*=fac[n];

	cout << ans%p << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int main() {

    ll n, k;
    cin >> n >> k;

    priority_queue<ll> minus;
    priority_queue<ll, vector<ll>, greater<ll>> plus;
    priority_queue<ll> center;

    rep(i, n) {
        ll x;
        cin >> x;
        if (x < 0) {
            minus.push(x);
        } else if (x == 0) {
            center.push(x);
        } else {
            plus.push(x);
        }
    }


    ll plus_distance = 0;
    ll minus_distance = 0;
    ll ans = INF;
    for (ll i = 0; i < k; i++) {
        if (plus.empty()) {
            break;
        }
        ll plus_top = plus.top();
        center.push(plus_top);
        plus_distance = plus_top;
        plus.pop();
    }
    if (center.size() == k) {
        ans = plus_distance;
    }

    for (ll i = 0; i < k; i++) {
        if (minus.empty()) {
            break;
        }
        ll minus_top = minus.top();
        minus.pop();
        minus_distance = abs(minus_top);
        center.push(minus_top);

        if (center.size() > k) {
            center.pop();
            plus_distance = center.top();
        }

        if (center.size() == k) {
            if (plus_distance > 0 && minus_distance > 0) {
                ll now = min(plus_distance * 2 + minus_distance, minus_distance * 2 + plus_distance);
                ans = min(now, ans);
            } else {
                ll now = minus_distance;
                ans = min(ans, now);
            }
        }

    }

    cout << ans << endl;


}


Measured memory_bytes: 2548
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long x = long.Parse(Console.ReadLine());

            if(x >= 30)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }            
        }
    }
}

Measured memory_bytes: 27472
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 2e5 + 5;
int ans[MAXN];
vector<int> G[MAXN];
vector<pii> tag___[MAXN];
vector<int> pool;
int VV[MAXN];

int bit[MAXN];
int Q(int x) {
    int ret = 0;
    while (x) {
        ret = max(ret, bit[x]);
        x -= x & (-x);
    }
    return ret;
}
void M(int x, int v, int u) {
    while (x <= (int)pool.size()) {
        tag___[u].push_back({x, bit[x]});
        bit[x] = max(bit[x], v);
        x += x & (-x);
    }
}

int magic(int x) {
    return lower_bound(pool.begin(), pool.end(), x) - pool.begin() + 1;
}
void dfs(int u, int p) {
    int x = magic(VV[u]);
    int nt = Q(x - 1) + 1;
    M(x, nt, u);
    ans[u] = Q(pool.size());
    for (auto &v : G[u]) {
        if (v == p)
            continue;
        dfs(v, u);
    }
    for (auto &p : tag___[u]) {
        bit[p.F] = p.S;
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 1 ; i <= n ; i++) {
        cin >> VV[i];
        pool.push_back(VV[i]);
    }
    sort(pool.begin(), pool.end());
    pool.erase(unique(pool.begin(), pool.end()), pool.end());
    for (int i = 0 ; i < n - 1 ; i++) {
        int u, v; cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1 ; i <= n ; i++)
        cout << ans[i] << '\n';
}

Measured memory_bytes: 51224
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  int A,B;
  cin >> A >> B;
  B *= 2;
  if(A <= B){
    cout << 0 <<endl;
  }
  else{
    cout << A- B <<endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    char S[H + 2][W + 2];
    rep(i, W + 2){
        S[0][i] = '.';
        S[H + 1][i] = '.';
    }
    rep(i, H + 2){
        S[i][0] = '.';
        S[i][W + 1] = '.';
    }
    REP(i, H){
        REP(j, W){
            cin >> S[i][j];
        }
    }

    ll count = 0;
    REP(i, H){
        REP(j, W){
            if(S[i][j] == '.'){
                count = 0;
                for(ll p = i - 1; p <= i + 1; p++){
                    for(ll q = j - 1; q <= j + 1; q++){
                        if(S[p][q] == '#'){
                            count++;
                        }
                    }
                }
                cout << count;
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int[]a=new int[n];
		Arrays.setAll(a,i->s.nextInt());
		Arrays.parallelPrefix(a,Integer::sum);

		int r=Integer.MAX_VALUE;
		for(int i=0;i<n-1;++i) {
			r=Math.min(r,Math.abs(a[i]-(a[n-1]-a[i])));
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 31060
#include <bits/stdc++.h>
#define LL long long
#define PB push_back
#define MP make_pair
#define FI first
#define SC second
using namespace std;

typedef pair<LL,LL> ii;

LL n,m;
ii a[110],b[110];

LL dist(ii x, ii y){
	return abs(x.FI-y.FI) + abs(x.SC-y.SC);
}	

int main() {
	LL n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i].FI>>a[i].SC;
	}
	for(int i=0;i<m;i++){
		cin>>b[i].FI>>b[i].SC;
	}
	LL mn,idx;
	for(int i=0;i<n;i++){
		mn = 1e12;
		for(int j=0;j<m;j++){
			if(dist(a[i],b[j])<mn){
				mn = dist(a[i],b[j]);
				idx = j;
			}
		}
		cout<<idx+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
"""
SからN-3個取り除くのは制限的にしんどい。nCr(40000,3)とかになるので
3桁の数字を作ればいいので、000~999が作れるか試す。
"""
ans = 0
for i in range(0,1000):
    pin = str(i).zfill(3)

    idx = 0
    for s in S:
        if pin[idx] == s:
            idx += 1

        if idx == 3:
            ans += 1
            break

print(ans)


Measured memory_bytes: 41180
#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;
using ll=long long;

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;
  cin>>n>>m;
  vector<int> vec(n,0);
  int a,b;
  rep(i,0,m){
    cin>>a>>b;
    vec[a-1]++;
    vec[b-1]++;
  }
  rep(i,0,n) cout<<vec[i]<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

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

vector<pair<pair<string,int>,int>> d;
int N,M;
int k[12],s[12][12],p[12];

int main() {

	scanf("%d%d", &N,&M);
	rep(i, M) {
		scanf("%d", &k[i]);
		rep(j, k[i]) {
			scanf("%d", &s[i][j]);
		}
	}
	rep(i, M) scanf("%d", &p[i]);

	int T = 1 << N;
	int ans = 0;
	rep(t, T) {
		int of[12];
		rep(j, N) {
			of[j+1] = (t >> j) & 1;
		}
		bool f = true;
		rep(i, M) {
			int c = 0;
			rep(j, k[i]) {
				if (of[s[i][j]]) c++;
			}
			if (c % 2 != p[i]) {
				f = false;
				break;
			}
		}
		if (f) ans++;		
	}

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

	return 0;
}


Measured memory_bytes: 256
#define D double
D f(D n,D d,D x){return d+(n-1)*x/2+(n-2?f(n-2,d+2*d/n+5*x/n,x+4*x/n):0);}
n,d;main(x){scanf("%d%d%d",&n,&d,&x);printf("%.9f",f(2*n,d,x));}

Measured memory_bytes: 6400
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INF 999999999
using namespace std;

int main(){
          int n,k;
          cin >> n >> k;
          int l[n];
          REP(i,n) cin >> l[i];

          sort(l,l+n,greater<int>());

          int sum=0;
          REP(i,k) sum+=l[i];

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


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import deque
n = int(input())
edge = [[] for _ in range(n+1)]
for _ in range(n-1):
    a,b = map(int, input().split())
    edge[a].append(b)
    edge[b].append(a)

inf = 10**6


fvisited = [inf for _ in range(n+1)]
fvisited[1] = 0
q = deque([1])
while len(q)>0:
    s = q.popleft()
    for e in edge[s]:
        if fvisited[e]==inf:
            fvisited[e] = fvisited[s]+1
            q.append(e)

svisited = [inf for _ in range(n+1)]
svisited[n] = 0
q = deque([n])
while len(q)>0:
    s = q.popleft()
    for e in edge[s]:
        if svisited[e]==inf:
            svisited[e] = svisited[s]+1
            q.append(e)

# print(fvisited)
# print(svisited)
fcnt = 0
scnt = 0
for i in range(1,n+1):
    if fvisited[i]<=svisited[i]:
        fcnt += 1
    else:
        scnt += 1

if fcnt>scnt:
    print("Fennec")
else:
    print("Snuke")


Measured memory_bytes: 29500
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	ll a, b, c;
	cin >> a >> b >> c;
	ll k;
	cin >> k;

	while(k > 0 && a >= b) {
		b *= 2;
		--k;
	}
	while(k > 0 && b >= c) {
		c *= 2;
		--k;
	}
	if (a < b && b < c) cout << "Yes\n";
	else cout << "No\n";
}


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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if ( a == b ){
    cout << a + b << endl;
  }else if ( a > b ){
    cout << a + a-1 << endl;
  }else{
    cout << b + b - 1 << endl;
  }
  
  
  
}



Measured memory_bytes: 256
S = list(input())

C = []
C.append(S.count('a'))
C.append(S.count('b'))
C.append(S.count('c'))

C = sorted(C)

if C[0] == C[1] == C[2]:
    ans = 'YES'
elif C[0] + 1 == C[1] == C[2]:
    ans = 'YES'
elif C[0] == C[1] == C[2] - 1:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
int perimeter;
int n;
cin>>perimeter>>n;
vector<int> lengths(n, 0);
for (int i=0;i<n;i++){
  cin>>lengths[i];
}
int maxgap=min(lengths[0]-lengths[n-1]+perimeter, lengths[n-1]-lengths[0]);

for (int i=0;i<n-1;i++){
  if (min(lengths[i]-lengths[i+1]+perimeter, lengths[i+1]-lengths[i])>maxgap){
    maxgap=min(lengths[i]-lengths[i+1]+perimeter, lengths[i+1]-lengths[i]);
    }
}

cout<<perimeter-maxgap;
}

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

int main() {
    int D, G, p[11], c[11], ans = 1e9, sum, rest_max, cnt;
    cin >> D >> G;
    for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

    for (int i = 0; i < 1 << D; ++i) {
        sum = 0, rest_max = 0, cnt = 0;
        for (int j = 0; j < D; ++j) {
            if (i & 1 << j) {
                sum += 100 * (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
            else {
                rest_max = j;
            }
        }
        if (sum + 100 * (rest_max + 1) * p[rest_max] + c[rest_max] < G) {
            continue;
        }
        while (sum < G) {
            sum += 100 * (rest_max + 1);
            ++cnt;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    
    return 0;
}

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

const int maxn=100010,mod=1000000007;
typedef long long ll;
ll s[maxn],ans;
int n,k,a[maxn],inv[maxn],fac[maxn];

int c(int x,int y)
{
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main()
{
	int i,j;
	scanf("%d%d",&n,&k);
	if (k==1||n<k)
	{
		puts("0");
		return 0;
	}
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if (n==k)
	{
		printf("%d\n",(a[n]-a[1])%mod);
		return 0;
	}
	for (i=1;i<=n;i++)
		s[i]=s[i-1]+1ll*a[i];
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for (i=2;i<=n;i++)
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for (i=2;i<=n;i++)
	{
		inv[i]=1ll*inv[i-1]*inv[i]%mod;
		fac[i]=1ll*fac[i-1]*i%mod;
	}
	for (i=k-2;i<=n-2;i++)
	{
		ans=(ans+1ll*c(i,k-2)*(((s[n]-s[i+1]-s[n-i-1])%mod+mod)%mod)%mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2176