akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const



int main() {
  i64 N, Q;
  cin >> N >> Q;
  vector<vector<i64>> G(N);
  rep(i,0,N - 1) {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<i64> cnt(N);
  rep(i,0,Q) {
    i64 p, x;
    cin >> p >> x;
    p--;
    cnt[p] += x;
  }

  queue<int> que;
  que.push(0);
  vector<i64> vis(N);
  vis[0] = true;

  while(!que.empty()) {
    int v = que.front();
    que.pop();
    for(auto t: G[v]) {
      if(vis[t]) continue;
      vis[t] = true;
      cnt[t] += cnt[v];
      que.push(t);
    }
  }

  rep(i,0,N) {
    cout << cnt[i] << " \n"[i + 1 == N];
  }
}


Measured memory_bytes: 18672
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int count = 0;
		int countDummy = 0;
		for(int i = 0; i<s.length()-t.length()+1; i++) {
				String sDummy = s.substring(i, i+t.length());
				for(int j=0; j<t.length(); j++) {
					if(sDummy.charAt(j)==t.charAt(j)) {
						countDummy++;
					}
		}
				if(countDummy > count) {
					count = countDummy;
				}
				countDummy = 0;
			
			
		}

		
		System.out.println(t.length()-count);
		}

}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

vll h(string s){
	ll p1 = 1000000000 + 7, p2 = 1000000000 + 9, q = 31;

	ll n = s.size();
	vll res(n);

	res[0].ff = (s[0]-'a' + 1)%p1;
	res[0].ss = (s[0]-'a' + 1)%p1;
	for(int i = 1; i < n; ++i){
		res[i].ff = ((s[i]-'a' + 1)%p1 + (res[i-1].ff * q)%p1 )%p1;
		res[i].ss = ((s[i]-'a' + 1)%p2 + (res[i-1].ss * q)%p2 )%p2;
	}


	return res;
}

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

	ll n, res = 0;
	string s;
	cin >> n >> s;
	s = "0" + s;
	for(int i = 1; i <= n; ++i){
		if(s[i] != s[i-1]){
			res++;
		}
	}

	cout << res << endl;
	
	
	return 0;
}

Measured memory_bytes: 512
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
// use std::cmp::*;
//use std::collections::VecDeque;

fn main() {
    input! {
       S:Chars
    }
    let T = "CODEFESTIVAL2016".chars().collect::<Vec<char>>();
    let mut ans = 0;
    for i in 0..S.len() {
        if S[i] != T[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
  string s; char c;
  long long a=0,b=0,i=0,j=0;
  cin >> s;
  for(i=0; i<s.size(); i++){
    c=s[i];
    if(c=='W'){
      j++;
      b+=j; a+=i+1;
    }
  }
  cout << a-b;
}  

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

using namespace std;

int main(int argc, const char * argv[]) {
    double a, b, c, degree, S;
    scanf("%lf %lf %lf", &a, &b, &degree);
    S = (0.5) * a * b * sin(M_PI * degree / 180);
    c = sqrt(a * a + b * b - 2 * a * b *cos(M_PI * degree / 180));
    printf("%.8lf\n", S);
    printf("%.8lf\n", a+b+c);
    printf("%.8lf\n", 2*S/a);
    return 0;
}



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

int main() {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cout << "Case " << i + 1 << ':' << endl;
    int s;
    cin >> s;
    for(int j = 0; j < 10; ++j) {
      s = pow(s, 2) / 100;
      if(s >= 10000) s -= s / 10000 * 10000;
      cout << s << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  rep(i, a){
    cin >> p[i];
  }
  rep(i, b){
    cin >> q[i];
  }
  rep(i, c){
    cin >> r[i];
  }
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());
  priority_queue<int, vector<int>, greater<int> > red;
  priority_queue<int, vector<int>, greater<int> > green;
  rep(i, x){
    red.push(p[i]);
  }
  rep(i, y){
    green.push(q[i]);
  }
  rep(i, c){
    if(red.top()>=r[i] && green.top()>=r[i])break;
    if(red.top()>=green.top()){
      green.pop();
      green.push(r[i]);
    } else {
      red.pop();
      red.push(r[i]);
    }
  }
  ll ans=0;
  while(!red.empty()){
    ans+=red.top();
    red.pop();
  }
  while(!green.empty()){
    ans+=green.top();
    green.pop();
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> box(n, 1);
  vector<bool> pos(n, false);
  pos[0] = true;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    box[x]--;
    box[y]++;
    if (pos[x]) pos[y] = true;
    if (pos[x] && box[x] == 0) pos[x] = false;
  }

  int ans = 0;
  rep(i, n) if (pos[i]) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{

	ll N;
	cin >> N;
	vec A(N);
	vec presum(N + 1, 0);
	REP(i, N) {
		cin >> A[i];
		presum[i + 1] = presum[i] + A[i];
	}


	vec rsep(N);
	vec lsep(N);
	rsep[1] = 2;
	lsep[1] = 1;
	ll ans = INF;
	FOR(i, 2, N - 1) {
		ll P = 0, Q = 0, R = 0, S = 0;
		rsep[i] = rsep[i - 1];
		lsep[i] = lsep[i - 1];
		if (rsep[i] - i < 1) rsep[i] = i + 1;
		if (rsep[i] > N - 1) break;
		if (i - lsep[i] < 1) continue;

		bool rsearch = true, lsearch = true;
		P = presum[lsep[i]] - presum[0];
		Q = presum[i] - presum[lsep[i]];
		R = presum[rsep[i]] - presum[i];
		S = presum[N] - presum[rsep[i]];
		while (lsearch) {
			if (abs(P - Q) > abs(P - Q + 2 * A[lsep[i]])) {
				lsep[i]++;
				P = presum[lsep[i]] - presum[0];
				Q = presum[i] - presum[lsep[i]];
			}
			else lsearch = false;
		}
		while (rsearch) {
			if (abs(R - S) > abs(R - S + 2 * A[rsep[i]])) {
				rsep[i]++;
				R = presum[rsep[i]] - presum[i];
				S = presum[N] - presum[rsep[i]];
			}
			else rsearch = false;
		}
		ll maxval = max(max(P, Q), max(R, S));
		ll minval = min(min(P, Q), min(R, S));
		ans = min(ans, abs(maxval - minval));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a * b % 2 == 0) {
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}
}

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

int ans;
ll N;

void dfs(ll n, int b){
	if(n > N) return;
	if(b == 7){
		ans++;
		//cout << n << endl;
	}
	dfs(n * 10 + 7, b | 1);
	dfs(n * 10 + 5, b | 2);
	dfs(n * 10 + 3, b | 4);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N;
	dfs(0, 0);
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool isneed(vector<int>& a,int it,int n,int k){
	vector<bool> dp(k+5,false);
	dp[0]=true;
	for(int i=0;i<n;i++){
		if(i==it) continue;
		for(int j=k;j>=a[i];j--){
			if(dp[j-a[i]]) dp[j]=true;
		}
	}
	for(int i=max(0,k-a[it]);i<k;i++) if(dp[i]) return true;
	return false;
}

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a.begin(),a.end(),greater<int>());
	int left=-1,right=n;
	while(right-left>1){
		int mid=(right+left)/2;
		if(isneed(a,mid,n,k)) left=mid;
		else right=mid;
	}
	int ans=n-(left+1);
	cout << ans << endl;
	return 0;
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 550;
const long long Q = 10100;
const long long mod = 998244353;
const long long MAGIC = 30;

using namespace std;

int n;

void solve()
{
        cin >> n;
        long long a = 1, b = 1;
        for(int i = 1; i <= n; i++){
                long long x, y;
                cin >> x >> y;
                long long k = max((a - 1) / x + 1, (b - 1) / y + 1);
                a = x * k;
                b = y * k;
        }
        cout << a + b << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("island.in");
        //fout("island.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    char s[5];
    // ll n;
    ll ans=0;
    scanf("%s",s);
    // ll [n];
    if(s[0]=='S'){
        if(s[1]=='U'){
            ans=7;
        }else{
            ans=1;
        }
    }else if(s[2]=='E'){
        ans=5;
    }else if(s[0]=='T'){
        ans=3;
    }else if(s[0]=='W'){
        ans = 4;
    }else{
        ans=2;
    }
    if(s[0]=='M') ans=6;
    // if()

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[655][322][322];
int stt[655];
int main()
{
	int num;
	scanf("%d", &num);
	int c0 = 0;
	for (int i = 0; i < num; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		za--, zb--;
		if (za > zb)swap(za, zb);
		if (za != -2)stt[za] = stt[zb] = -1;
		else if (zb != -2)stt[zb] = 1;
		else c0++;
	}
	dp[num + num][0][0] = 1;
	for (int i = num + num; i >= 1; i--)
	{
		if (stt[i - 1] == -1)for (int j = 0; j <= num; j++)for (int k = 0; k <= num; k++)dp[i - 1][j][k] = dp[i][j][k];
		else if (stt[i - 1] == 0)
		{
			for (int j = 0; j <= num; j++)
			{
				for (int k = 0; k <= num; k++)
				{
					if (dp[i][j][k] == 0)continue;
					dp[i - 1][j + 1][k] = (dp[i - 1][j + 1][k] + dp[i][j][k]) % mod;
					if (j > 0)dp[i - 1][j - 1][k] = (dp[i - 1][j - 1][k] + dp[i][j][k]) % mod;
					if (k > 0)dp[i - 1][j][k - 1] = (dp[i - 1][j][k - 1] + dp[i][j][k] * k) % mod;
				}
			}
		}
		else
		{
			for (int j = 0; j <= num; j++)
			{
				for (int k = 0; k <= num; k++)
				{
					if (dp[i][j][k] == 0)continue;
					dp[i - 1][j][k + 1] = (dp[i - 1][j][k + 1] + dp[i][j][k]) % mod;
					if (j > 0)dp[i - 1][j - 1][k] = (dp[i - 1][j - 1][k] + dp[i][j][k]) % mod;
				}
			}
		}
	}
	ll ans = dp[0][0][0];
	for (int i = 1; i <= c0; i++)ans = ans*i%mod;
	printf("%lld\n", ans);
}


Measured memory_bytes: 487424
# frozen_string_literal: true

n, m = gets.split.map(&:to_i)
s = Hash.new(0)
t = Hash.new(0)

m.times do
  a, b = gets.split.map(&:to_i)
  s[b] += 1 if a == 1
  t[a] += 1 if b == n
end
k = s.keys
cnt = 0
k.each do |i|
  cnt += 1 if t[i] != 0
end
puts (cnt == 0 ? 'IMPOSSIBLE' : 'POSSIBLE')


Measured memory_bytes: 15612
#include<iostream>
#include<algorithm>

using namespace std;


int main(){
	
	int A[5];
	
	for(int i=0;i<5;i++)
	cin >> A[i];
	
	sort(A, A+5);
	
	for(int i=4;i>0;i--)
	cout << A[i] << " ";
	cout << A[0] << "\n";
	
    return 0;
}


Measured memory_bytes: 3040
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char gen;
  char c[1000];
  int n;
  while(cin>>c){
    if(c[0]=='#') break;
    gen = 'A';
    for(int i=0;i<strlen(c);i++){
      if(gen=='A'){
	if(c[i]=='0') gen = 'X';
	else  gen = 'Y';
      }
      else if(gen=='X'){
	if(c[i]=='0') break;
	else  gen = 'Z';
      }
      else if(gen=='Y'){
	if(c[i]=='0') gen = 'X';
	else break;
      }
      else if(gen=='Z'){
	if(c[i]=='0') gen = 'W';
	else gen = 'B';
      }
      else if(gen=='W'){
	if(c[i]=='0') gen = 'B';
	else gen = 'Y';
      }
      else if(gen=='B'){
	if(c[i]=='0') gen = 'Y';
	else gen = 'X';
      }
      //cout << gen << endl;
    }
    if(gen=='B') cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

using namespace std;

const int INF = 1e9 + 5;

int main()
{
	int n;
	cin >> n;
	vector <int> h(n);
	for (auto i = 0; i < h.size(); i++)
	{
		cin >> h[i];
	}
	vector <int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j : {i + 1, i + 2}) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp[n - 1]);
	cin.get();
	return 0;
}

Measured memory_bytes: 4004
import sys

input = sys.stdin.readline


def main():
    N, M = [int(x) for x in input().split()]
    S = input().strip()

    if S.count("1" * M) > 0:
        print(-1)
        return

    ans = []
    r = N
    while r > 0:
        li = N - 1
        for diff in range(1, M + 1):
            if r - diff < 0:
                break
            if S[r - diff] == "0":
                li = r - diff
        ans.append(r - li)
        r = li
        if r == 0:
            break

    ans.reverse()
    print(*ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 6384
x,k,d = map(int,input().split(" "))
if k * d <= abs(x):
    print(abs(x) - k * d)
else:
    x = abs(x)
    k -= x // d
    x %= d 
    if min(x,abs(x-d)) != x:
        k -= 1
    x = min(x,abs(x-d))
    if k % 2 == 0:
        print(x)
    else:
        print(d - x)

Measured memory_bytes: 9204
N = int(input())
A = [int(x) for x in input().split()]
buf = True

for i in range(N) :
    if A[i] % 2 == 0 :
        if (A[i] % 3 == 0) or (A[i] % 5 == 0) :
            pass
        else :
            buf = False
            break

if buf == True :
    print('APPROVED')
else :
    print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,i,j,a,b;
    cin>>n>>k;
    long long arr[n];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(i=k;i<n;i++)
    {
        a=arr[i];
        b=arr[i-k];
        if(a>b)cout<<"Yes\n";
        else cout<<"No\n";
    }
    
}

Measured memory_bytes: 5164
#include<stdio.h>
int main(void){
int n,kai[12][10],a,b,c,d,e;
for(a=0;a<12;a++)for(b=0;b<10;b++)kai[a][b]=0;
scanf("%d",&n);
for(e=0;e<n;e++){

scanf("%d %d %d %d",&a,&b,&c,&d);
if(a>0&&a<=4&&b>0&&b<=12&&c>0&&c<=10){
kai[(a-1)*3+(b-1)][c-1]+=d;
if(kai[(a-1)*3+(b-1)][c]<0)kai[(a-1)*3+(b-1)][c-1]=0;
if(kai[(a-1)*3+(b-1)][c]>9)kai[(a-1)*3+(b-1)][c-1]=9;
}

}
for(a=0;a<12;a++){
for(b=0;b<10;b++)printf(" %d",kai[a][b]);
printf("\n");
if(a==2||a==5||a==8)printf("####################\n");
}
return 0;
}


Measured memory_bytes: 1972
#include<iostream>
using namespace std;
typedef double d;
d cross(d x1,d y1,d x2,d y2){
	return (x1 * y2) - (y1 * x2);
}

int main(){
  d x[3],y[3],xp,yp;
  while(cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> xp >> yp){
    d ret[3];
    for(int i = 0;i<3;i++){
      int nx =(i + 1) % 3;
      ret[i]=cross(xp- x[i],yp - y[i], x[nx] - x[i] ,y[nx] - y[i]);
    }
    if((ret[0] < 0 && ret[1] < 0 && ret[2] < 0) ||  
       (ret[0] > 0 && ret[1] > 0 && ret[2] > 0) ){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
/*Infor {{{
    > File Name: a.cpp
    > Author: samcompu
    > Mail: a1592710567@126.com
    > Website: https://www.samcompu.com
    > Created Time: 2018年08月25日 星期六 20时01分19秒
}}}*/
#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for (int i = (int)(a); i >= (int)(b); i--)
#define FORLINE(i, t) for (int i = fi[t]; i; i = ne[i])
typedef long long ll;
typedef unsigned long long int ull;
/*}}}*/

/*Constant {{{*/
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  ios::sync_with_stdio(false);
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
import "dart:io";
import 'dart:async';
import 'dart:convert';
import 'dart:math' as Math;

void main() async {
  int N = int.parse(stdin.readLineSync());
  var lines = stdin.transform(utf8.decoder).transform(LineSplitter());
  List<int> A = [];
  await for(var line in lines) {
   A = line.split(' ').map((x) => int.parse(x)).toList();
  }
  for (int i=0; i<N;i++) {
  	if (A[i]==0) {
    	print(0);
        return;
    }
  }
  final M = Math.pow(10, 18);
  int r = 1;
  for (int i=0; i<N;i++) {
    if (A[i]<=M/r && r*A[i]<=M) {
    	r*=A[i];
    } else {
     	print(-1);
      	return;
    }
  }
  print(r);
}

Measured memory_bytes: 28632
n = int(input())
b = list(map(int,input().split()))
a = [b[n-2]]
if n != 2:
  for i in range(2,n):
    if b[-i] >= b[-i+1]:
      a.append(b[-i+1])
    else:
      a.append(b[-i])
a.append(b[0])
print(sum(a))

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,m,i,j,k,a[210],b[210],c[210],t[210],d[210][210]={0};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&t[i]);
  for(i=0;i<m;i++)scanf("%d %d %d",&a[i],&b[i],&c[i]);
  for(i=1;i<n;i++){
    for(j=0;j<m;j++){
      if(t[i-1]<a[j]||b[j]<t[i-1])continue;
      for(k=0;k<m;k++)d[i][k]=MAX(d[i][k],d[i-1][j]+abs(c[j]-c[k]));
    }
  }
  for(i=j=0;i<m;i++){
    if(a[i]<=t[n-1]&&t[n-1]<=b[i])j=MAX(j,d[n-1][i]);
  }
  printf("%d\n",j);
  return 0;
}

Measured memory_bytes: 784
#include <iostream>

using namespace std;

int main() {
  char c;
  cin >> c;
  if (c == 'A')
    cout << 'T' << endl;
  else if (c == 'C')
    cout << 'G' << endl;
  else if (c == 'G')
    cout << 'C' << endl;
  else if (c == 'T')
    cout << 'A' << endl;
  return 0;
}


Measured memory_bytes: 256
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define endl '\n'
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define bit(s,i) (((s)>>(i))&1LL)
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
const int MAXN    = 2e5+9;
/*-----------------------------------------------------------------------------------------------------*/

ll mpow(ll a, ll b) {
	ll x = a, ans=1;
	while(b) {
		if(b&1) ans=(ans*x)%MOD;
		x=(x*x)%MOD;
		b>>=1;
	}
	return ans;
}

ll cal(ll a, ll b) {
	ll ans = 1;
	for(int i = max(b, a-b)+1; i <= a; i++) {
		ans=(ans*i)%MOD;
	}
	for(int i = 2; i <= min(b, a-b); i++) {
		ans=(ans*mpow(i, MOD-2))%MOD;
	}
	return ans;
}

signed main() {
	EmiliaMyWife

	ll n, a, b;
	cin >> n >> a >> b;
	ll base = mpow(2, n)-1;
	base=(base+2*MOD-cal(n, a)-cal(n, b))%MOD;
	cout << base;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  ll sum=0;
  rep(i,N) sum+=A[i];
  sum/=2;
  rep(i,N) if(i%2) sum-=A[i];
  cout<<sum*2<<" ";
  ll tmp=sum;
  rep(i,N-1){
    tmp=A[i]-tmp;
    cout<<tmp*2<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
    queue<int> q;
    q.push(s);
    V[s] = true;
    while ( !q.empty() ) {
        int u = q.front(); q.pop();
        out.push_back(u);
        for ( int i = 0; i < G[u].size(); i++ ) {
            int v = G[u][i];
            indeg[v]--;
            if ( indeg[v] == 0 && !V[v] ) {
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort() {
    for ( int i = 0; i < N; i++ ) {
        indeg[i] = 0;
    }
    
    for ( int u = 0; u < N; u++ ) {
        for ( int i = 0; i < G[u].size(); i++ ) {
            int v = G[u][i];
            indeg[v]++;
        }
    }
    
    for ( int u = 0; u < N; u++ )
        if ( indeg[u] == 0 && !V[u] ) bfs(u);
        
    for ( list<int>::iterator it = out.begin(); it != out.end(); it++ ) {
        cout << *it << endl;
    }
}

int main() {
    int s, t, M;
    
    cin >> N >> M;
    
    for ( int i = 0; i < N; i++ ) V[i] = false;
    
    for ( int i = 0; i < M; i++ ) {
        cin >> s >> t;
        G[s].push_back(t);
    }
    
    tsort();
    
    return 0;
}


Measured memory_bytes: 6188
import collections
dic = collections.defaultdict(int)
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
  dic[a[i]] += 1
ans = 0
for key in dic.keys():
    if dic[key] >= key:
      ans += (dic[key] - key)
    else:
        ans += dic[key]
print(ans)


Measured memory_bytes: 101524
import bisect
import numpy

n, m, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

cost_a = numpy.insert(numpy.cumsum(a), 0, 0)
cost_b = numpy.insert(numpy.cumsum(b), 0, 0)

ans = 0
j =  len(cost_b) -1
for i in range(len(cost_a)):
    for j in range(j, -1, -1):
        if cost_a[i] + cost_b[j] <= k:
            ans  = i + j if ans < i + j else ans
            break
print(ans)

Measured memory_bytes: 58388
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const int mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
int pow(int a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    int res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
int modpow(int a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    int res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
int com(int n, int a){
  int x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  int res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
int modcom(int n, int a){
  int x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  int ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
int ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
int nlcm(vector<int> a) {
  int res;
  res = a[0];
  for (int i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int ans = 1001001001;
  for(int i = 0; i <= max(x, y) * 2; i += 2){
    int A = max((int)0, x - i/2) * a;
    int B = max((int)0, y - i/2) * b;
    int AB = i * c;
    ans = min(ans, A+B+AB);
  }
  cout << ans << endl;
}






Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long

int main()
{
	int a,b;
	scanf("%i %i",&a,&b);
	if(a>8 || b>8) printf(":(\n");
	else printf("Yay!\n");
	return 0;
}

Measured memory_bytes: 128
import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    """
    「中間の値に関してうんぬん　→　その値の左右の区間から計算」
    は定石と思っていい気がする。

    言われてみればA[i]を除いたGCDはgcd(A[:i])とgcd(A[i+1:])から求まるわなあ
    素因数分解してとか考える以前の話だった。。。
    """

    L = [0] * (N + 1)    # L[i] = gcd(A[:i])
    R = [0] * (N + 1)    # R[i] = gcd(A[i:])
    L[1] = A[0]
    R[N - 1] = A[N - 1]
    for i in range(2, N + 1):
        L[i] = gcd(L[i - 1], A[i - 1])
    for i in range(N - 2, -1, -1):
        R[i] = gcd(R[i + 1], A[i])

    ans = R[1]
    for i in range(1, N - 1):
        ans = max(ans, gcd(L[i], R[i + 1]))
    ans = max(ans, L[N - 1])
    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
	int d,n;
	cin >> d >> n;
	int ans;
	
		int k = 1;
		for(int i = 0;i<d;i++)k*=100;
	if(n==100)
	{
		ans=101*k;
	}
	else
	{
		ans = k*n;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  string S,T;
  cin >> S >> T;
  int count = 0;
  
  for (int i=0 ; i < 3 ; i++) {
     if( S.at(i) == T.at(i) ){
        count++ ;
      }
    }
    cout << count << endl;
}


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

int main() {
  int n, m = 0, nm, t;
  cin >> n;
  vector<int> st(n), a(n);
  vector<vector<pair<int, int>>> x(n, vector<pair<int, int>>());
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    int tx, ty;
    for(int j = 0; j < a.at(i); j++) {
      cin >> tx >> ty;
      x.at(i).push_back({tx - 1, ty});
    }
  }
  for(int i = 0; i < (1 << n); i++) {
    nm = 0;
    t = 1;
    for(int j = 0; j < n; j++) {
      st.at(j) = (i >> j) & 1;
      nm += st.at(j);
    }
    for(int j = 0; j < n; j++)
      if(st.at(j))
        for(int k = 0; k < a.at(j); k++)
          if(st.at(x.at(j).at(k).first) != x.at(j).at(k).second)
            t = 0;
    if(t)
      m = max(m, nm);
  }
  cout << m << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    int num[26] = {};
    rep(i, s.size()) { num[(int)s[i] - 'a'] += 1; }
    bool flag = true;
    rep(i, 26) {
        if (num[i] >= 2) {
            flag = false;
        }
    }

    if (flag) {
        cout << "yes" << endl;
    } else {
        cout << "no" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K;
vector<int> u, v;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    string s;
    cin >> s;
    ll a = 0, k = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'W')
            a += i - k, k++;
    }
    cout << a << endl;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll n, d;
	cin >> n >> d;
	d = d * d;
	int ans = 0;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		ll z = x * x + y * y;
		if (z <= d) ans++;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=998244353;
const int MAX = 510000;
const int INF = 1e9;
const double pi=acos(-1);

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main(){
  int n;
  cin >> n;
  int sum=0;
  map<string,int>mp;
  rep(i,n){
    string s;
    int t;
    cin >> s >> t;
    sum+=t;
    mp[s]=sum;
  }
  string x;
  cin >> x;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    if(x==itr->first){
      cout << sum-mp[x] << endl;
      return 0;
    }
  }
  
  
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  [a, b, c] <- readIntList
  putStrLn $ if a == b + c || b == c + a || c == a + b then "Yes" else "No"



Measured memory_bytes: 380
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		//?????±?????°n????¨??????????
		int n = (Integer.parseInt(br.readLine()));
		
		//n??¶????????±????????????
		ArrayList<String> list = new ArrayList<String>();
		for (int i = 0; i < n; i++) {
			list.add(br.readLine());
		}

		
		//?????????????????±???int??????????????????2?¬?????????????????´???????
		int[][] data = new int[n][4];
		for(int i = 0; i < n; i++) {
			String s = list.get(i);
			String [] ary = s.split(" ", 0);
		
			
			for(int j = 0; j < 4; j++) {	
				data[i][j] = Integer.parseInt(ary[j]);
			}
		}
		
		//?????±????????¨?????¨?±??????±????¨??????????
		int[][] building1 = new int[3][10];
		int[][] building2 = new int[3][10];
		int[][] building3 = new int[3][10];
		int[][] building4 = new int[3][10];
		for(int i = 0; i < n; i++) {
			int floor = data[i][1];
			int number = data[i][2];
			if(data[i][0] == 1) {
				building1[floor - 1][number -1] = building1[floor - 1][number -1] + data[i][3];
			}
			if(data[i][0] == 2) {
				building2[floor - 1][number -1] = building2[floor - 1][number -1] + data[i][3];
			}
			if(data[i][0] == 3) {
				building3[floor - 1][number -1] = building3[floor - 1][number -1] + data[i][3];
			}
			if(data[i][0] == 4) {
				building4[floor - 1][number -1] = building4[floor - 1][number -1] + data[i][3];
			}
		}
		
		//?????????????????????
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 10; j++) {
				System.out.print(" " + building1[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 10; j++) {
				System.out.print(" " + building2[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 10; j++) {
				System.out.print(" " + building3[i][j]);
			}
			System.out.println();
		}
		System.out.println("####################");
		
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 10; j++) {
				System.out.print(" " + building4[i][j]);
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 24932
#include <bits/stdc++.h>
#define int long long
 
using namespace std;
 
inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}
 
const int mod=1e9+7;
int n,m,bin[1000005],inv[1000005];
 
inline int ksm(int x,int y)
{
	int ret=1ll;
	while(y)
	{
		if(y&1) ret=ret*x%mod;
		x=x*x%mod;
		y>>=1ll;
	}
	return ret;
}
 
inline int C(int x,int y)
{
	return bin[x]%mod*inv[x-y]%mod*inv[y]%mod;
}
 
signed main()
{
	n=read();
	m=read();
	bin[0]=1,inv[0]=1;
	for ( int i=1;i<=n;i++ ) bin[i]=bin[i-1]*i%mod;
	for ( int i=1;i<=n;i++ ) inv[i]=ksm(bin[i],mod-2)%mod;
	int ans=1;
	for ( int i=1;i<n;i++ ) 
		if(n-i<=m)
			ans=(ans+C(n,i)*C(n-1,i-1)%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

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

int main()
{
    string str;
    cin >> str;
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] == '7')
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    N = len(S)

    if N == 3:
        if S == S[::-1]:
            print(YES)
            exit()
        else:
            print(NO)
            exit()

    s1 = S[:(N-1)//2]
    s1r = s1[::-1]
    s2 = S[(N+3)//2]
    s2r = s2[::-1]
    # print(s1, s1r, s2, s2r)
    if S == S[::-1] and s1 == s1r and s2 == s2r:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,ans;
int s[20][20];
bool vis[20];
int cnt[20];
void dfs(int x,int tot)
{
	if(x==n+1)
	{
//		for(int i=1; i<=n; i++)
//			printf("%d ",vis[i]);
//		printf("\n");
		bool flag=1;
		for(int i=1; i<=n; i++)
			if(vis[i])
				for(int j=1; j<=n; j++)
					if( (s[i][j]==1&&!vis[j]) || (s[i][j]==0&&vis[j])) 
						flag=0;
		if(flag)
			ans=max(ans,tot);
		return;
	}
	vis[x]=1;
	dfs(x+1,tot+1);
	vis[x]=0;
	dfs(x+1,tot);
}

int main()
{
	scanf("%d",&n);
	for(int i=1; i<=15; i++)
		for(int j=1; j<=15; j++)
			s[i][j]=-1;
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&m);
		for(int j=1; j<=m; j++)
		{
			int a,b;
			scanf("%d%d",&a,&b);
			s[i][a]=b;
		}
	}
	dfs(1,0);
	printf("%d",ans);
	return 0;
} 

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int n,m;


int main(){
  int ans=0;
  cin>>n>>m;
  vector<int> k(m),p(m);
  vector<vector<int>> s = vector<vector<int>>(m, vector<int>(n, 0));
  REP(i,m){
    cin>>k[i];
    REP(j,k[i]){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  REP(i,m){
    cin>>p[i];
  }


  int sikou=1<<n;
  vector<int> ss(n);
  REP(i,sikou){

    REP(j,n){
      if (((i>>j)%2)!=0){
        ss[j]=1;
      }else{
        ss[j]=0;
      }
    }
    //状態完了
    int flg=0;
    int g;
    REP(ii,m){//各電球をチェック
      g=0;
      REP(j,k[ii]){
        g+=ss[s[ii][j]];
      }
      if ((g%2)==p[ii])flg++;
    }
    if  (flg==m)ans++;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())

p = [[] for _ in range(n)]

for i in range(n):
    a = int(input())
    for _ in range(a):
        x,y = map(int,input().split())
        p[i].append((x-1,y))

ans = 0

for i in range(2 ** n):
    a = [0]*n
    for j in range(n):
        if ((i>>j) & 1):
            a[j] = 1
    chk = 0
    for j in range(n):
        if a[j] != 1:
            continue
        else:
            if not all(a[s[0]] == s[1] for s in p[j]):
                chk = 1
    if chk != 1:
        ans = max(ans,sum(a))

print(ans)
    

Measured memory_bytes: 47196
n = int(input())
list = list(map(int, input().split()))
list1 = sorted(list)
median_candidate1, median_candidate2 = list1[n//2-1], list1[n//2]
for i in list:
    if i <= median_candidate1:
        print(median_candidate2)
    else:
        print(median_candidate1)


Measured memory_bytes: 25556
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
#define nl <<"/n"                  // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>> 
#define vll vector <pair<ll,ll>> 
#define vi vector <int> 
#define vl vector <ll> 
#define mp(a,b) nake_pair(a,b)
#define F first
#define S second
using namespace std;



int main()
{ 

	int n;
	cin>>n;
    
    vector <string> v(n);

	f0(i,n){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        v[i]=s;
    } 
    
    sort(v.begin(),v.end());
   // f0(i,n) cout<<v[i]<<endl;
    ll c=1;
     ll ans=0;
    f1(i,n-1){
            if(v[i]==v[i-1]) c++;
            else{
            	ans+=(c*(c-1))/2;
            	c=1;
            }
    }
    
    ans+=(c*(c-1))/2;

    cout<<ans;
    return 0;
    }	


Measured memory_bytes: 5760
MOD=10**9+7
s=input()[::-1]
l=len(s)
dp=[[0 for j in range(13)] for i in range(l)]
if s[0] == "?":
    for j in range(10):dp[0][j]=1
else:
    dp[0][int(s[0])]=1
m=1
for i in range(1,l):
    m=10*m%13
    if s[i] == "?":
        for j in range(10):
            for k in range(13):dp[i][(k+j*m)%13]+=dp[i-1][k]%MOD
    else:
        for k in range(13):
            dp[i][(k+int(s[i])*m)%13]+=dp[i-1][k]%MOD
print(dp[-1][5]%(10**9+7))

Measured memory_bytes: 65756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  ll n,a,b; cin >> n >> a >> b;
  ll ans = 0;
  if((b-a) % 2 == 0){
    ans = (b-a) / 2;
  }else{
    ans = min((a-1),(n-b)) + 1 + ((b-a) / 2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int ans=0,s,l,r,h[100100],n,k,INF=999999999,g;
bool no=true;
void now(int x,int y)
{
	k=INF;
	if(y-x<0)
		return ;
	for(int i=x;i<=y;i++)
		k=min(k,h[i]);
	for(int i=x;i<=y;i++)
		h[i]-=k;
	ans+=k;
	if(x==y && h[x]==0)
		return ;
	for(int i=x;i<=y;i++)
	{
		if(h[i]!=0 && i==x)
		{
			s=1;
			l=i;
		}
		else if(h[i]==0)
		{
	  		if(s==1)
	  		{
	  			r=i-1;
	  			now(l,r);
	  			s=0;
			}
			if(s==0 && i!=y)
			{
				l=i+1;
	  			s=1;
			}
		}
		else if(h[i]!=0 && i==y)
		{
			if(s==1)
			{
				r=i;
	  			now(l,r);
	  			s=0;
			}
			else
				now(y,y);
		}
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	now(1,n);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b
char c[12] = "w kstnhmyr";
char v[6] = "aiueo";
int main() {
	char s[1001];
	S(s, s);
	int i;
	for (i = 0; s[i]; i += 2) {
		int a = s[i + 1] == 'T' ? 0 : s[i + 1] == 'L' ? 1 : s[i + 1] == 'U' ? 2 : s[i + 1] == 'R' ? 3 : 4;
		if (s[i] == '0'&&s[i+1] == 'U') printf("nn");
		else if (s[i]=='1') printf("%c", v[a]);
		else {
			printf("%c%c", c[s[i] - '0'], v[a]);
		}
	}
	puts("");
	return 0;
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int a,b;
  string S1,S2;
  S1 = S.substr(0,2);
  S2 = S.substr(2,2);
  a = atoi(S1.c_str());
  b = atoi(S2.c_str());
  int judge1 = 0;
  int judge2 = 0;
  if(a >= 1 && a <= 12){
    judge1 = 1;
  }
  if(b >= 1 && b <= 12){
    judge2 = 1;
  }
  if(judge1 == 1 && judge2 == 1){
    cout << "AMBIGUOUS" << endl;
  }
  else if(judge1 == 1 && judge2 == 0){
    cout << "MMYY" << endl;
  }
  else if(judge1 == 0 && judge2 == 1){
    cout << "YYMM" << endl;
  }
  else{
    cout << "NA" << endl;
  }
}

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

for i in range(n):

  diff = min(a[i], b[i])
  cnt += diff
  a[i] -= diff
  b[i] -= diff

  diff = min(a[i+1], b[i])
  cnt += diff
  a[i+1] -= diff
  b[i] -= diff

print(cnt)

Measured memory_bytes: 19156
MOD = 1000000007#い　つ　も　の
n,k = map(int,input().split())

nCk = 1#nC0
ans = 1

if k > n-1:
    k = n-1

for i in range(1,k+1,1):
    nCk = (((nCk*(n-i+1))%MOD)*pow(i,1000000005,1000000007))%MOD
    ans = (ans%MOD + ((((nCk*nCk)%MOD)*(n-i)%MOD)*pow(n,1000000005,1000000007)%MOD)%MOD)%MOD

print(ans)


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

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

int mod(int a, int b){
	int z;
	z = a % b;
	return z;
}

int main() {
    int A, B;
    int f_mod;
    int out;

    cin >> A >> B;
    f_mod = mod(B, A);
    
    if(f_mod==0){ 
        out = A + B;    
    }else{   
        out = B - A; 
    }

    cout << out << endl;
}

Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var i, n int
  var sum, m, count float64
  sum=0
  count=0
  fmt.Scan(&n, &m)
  a:=make([]float64, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    sum+=a[i]
  }
  sum*=1/(4*m)
  for i=0;i<n;i++{
    if sum<=a[i]{
      count++
    }
  }
  if count<m{
    fmt.Println("No")
  }else{
    fmt.Println("Yes")
  }
}


Measured memory_bytes: 512