akhauriyash/Code-Regression huggingface dataset:
label = {}
flow = {}
s, t = 'S', 'T'

def printpath(path):
    return
    for u, v in zip(path, path[1:]):
        print("%s -%d-> " % (label[u], flow[(u,v)]), end="")
    print("")

def printflow():
    return
    print("--flow--")
    for r in R:
        for b in edges[r]:
            print("  ", label[r], label[b], "s->r=%d"%flow[(s, r)], ", r->b=%d"%flow[(r, b)], ", b->t=%d"%flow[(b, t)])
            #print("  ", label[r], label[b], "r->s=%d"%flow[(r, s)], ", b->r=%d"%flow[(b, r)], ", t->b=%d"%flow[(t, b)])
        if edges[r]:
            print()

def findpath(v, t, edges, flow, visited):
    visited.add(v)
    #print(label[v], edges[v])
    for u in edges[v]:
        if u in visited:
            continue
        if flow[(v, u)] == 1:
            continue
        if u == t:
            return [v, t]
        path = findpath(u, t, edges, flow, visited)
        if path:
            return [v] + path
    return None

def max_match(R, B, edges):

    # init edge b - t
    for b in B:
        flow[(b, t)] = 0
        flow[(t, b)] = 1
        edges[b].append(t)

    edges[s] = []
    # init edge s - r
    for r in R:
        flow[(s, r)] = 0
        flow[(r, s)] = 1
        edges[s].append(r)

        # init flow r - b
        for b in edges[r]:
            flow[(r, b)] = 0
            flow[(b, r)] = 1

    change = True
    while change:
        printflow()
        change = False
        for r in R:
            if flow[(s, r)] == 1:
                continue
            path = findpath(r, t, edges, flow, set([s]))
            if not path:
                continue
            #printpath(path)
            path = [s] + path
            for u, v in zip(path, path[1:]):
                flow[(u, v)] = 1
                flow[(v, u)] = 0
            change = True
    printflow()
    return flow

def solve(R, B, edges):
    flow = max_match(R, B, edges)

    match = 0
    for r in R:
        for b in edges[r]:
            match += flow[(r, b)]
    return match
            

N = int(input())

R = [tuple([int(x) for x in input().split()]) for _ in range(N)]
B = [tuple([int(x) for x in input().split()]) for _ in range(N)]
for i, r in enumerate(R):
    label[r] = "R%d" % (i+1)
    #print(label[r], r)
for i, r in enumerate(B):
    label[r] = "B%d" % (i+1)
    #print(label[r], r)
label[s] = 'S'
label[t] = 'T'

edges = {}
for r in R:
    edges[r] = []
for b in B:
    edges[b] = []

for r in R:
    rx, ry = r
    for b in B:
        bx, by = b
        if rx < bx and ry < by:
            edges[r].append(b)
            edges[b].append(r)


print(solve(R, B, edges))




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

int main() {
  string s;
  cin >> s;
  int max = 0;
  int cnt = 0;
  for(char x : s) {
    if (x == 'A' || x == 'C' || x == 'G' || x == 'T') {
      ++cnt;
      if (max < cnt) max = cnt;
    } else {
      cnt = 0;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S;
//---------------------------------------------------------------------------------------------------
string solve() {
    rep(msk, 0, 1 << 4) {
        string s = "";
        if (msk & (1 << 0)) s += "A";
        s += "KIH";
        if (msk & (1 << 1)) s += "A";
        s += "B";
        if (msk & (1 << 2)) s += "A";
        s += "R";
        if (msk & (1 << 3)) s += "A";

        if (S == s) return "YES";
    }
    return "NO";
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int bCount = 0;
        int studentCount = 0;

        for (int i = 0; i < n; i++) {
            boolean isPass = false;
            if (s[i] == 'a') {
                if (studentCount < a + b) {
                    studentCount++;
                    isPass = true;
                }
            }
            if (s[i] == 'b') {
                if (studentCount < a + b && bCount < b) {
                    studentCount++;
                    isPass = true;
                    bCount++;
                }
            }
            if (isPass) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 34604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int count = 0;

                for (int i = 5; i <= n; i += 5)
                {
                    int temp = i;

                    while (temp % 5 == 0)
                    {
                        temp /= 5;
                        count++;
                    }
                }
                sb.AppendLine(count.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     string s;
     cin>>s;
     if(s[2]==s[3] && s[4]==s[5])
     cout<<"Yes"<<endl;
     else
     cout<<"No"<<endl;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll GCD(ll a, ll b)
{
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}

ll lcm(ll a, ll b){
    return ((a * b) / GCD(a, b));
}

int main()
{
    Hello
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    // b/c b/d b/lcm(a, b)

    ll LCM = lcm(c, d);
    ll cntr = b - (b/c) - (b/d) + (b/LCM);
    a--;
    ll cntr2 = a - (a/c) - (a/d) + (a/LCM);

    cout << cntr - cntr2;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int cnt=0;
        int [] h, w;
        h = new int[300];
        w = new int[300];

        while(true){
            h[cnt] = sc.nextInt();
            w[cnt] = sc.nextInt();
            if(h[cnt] == 0 || w[cnt] == 0)
                break;
            cnt++;
        }

        for(int i=0; i<cnt; i++){
            for(int j=0; j<h[i]; j++){
                for(int k=0; k<w[i]; k++){
                    System.out.print("#");
                }
                System.out.print("\n");                
            }
            System.out.println("");
        }
    sc.close();
    }
}


Measured memory_bytes: 33332
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	while(cin>>a>>b>>c,a,b,c){
		int tool[301]={};
		for(int i=1;i<=a+b+c;i++)tool[i]=2;
		int n;
		cin>>n;
		int num[1001][4];
		for(int i=0;i<n;i++){
			for(int j=0;j<4;j++)cin>>num[i][j];
			if(num[i][3]==1)for(int j=0;j<3;j++)tool[num[i][j]]=1;
		}
		for(int i=0;i<n;i++){
			if(num[i][3]==0){
				int x=num[i][0],y=num[i][1],z=num[i][2];
				if(tool[x]==1&&tool[y]==1)tool[z]=0;
				else if(tool[x]==1&&tool[z]==1)tool[y]=0;
				else if(tool[y]==1&&tool[z]==1)tool[x]=0;
			}
		}
		for(int i=1;i<=a+b+c;i++)cout<<tool[i]<<endl;
	}
}

Measured memory_bytes: 1176
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	ll n,m;cin>>n>>m;cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);

    for (int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    string ans = "Yes";

    for (int i = 0; i < n-1; ++i) {
        if (count(w.begin()+i, w.end(), w[i]) > 1) ans = "No";
        if (w[i][w[i].size()-1] != w[i+1][0]) ans = "No";
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  int num[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;

  cout << num[K-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
def dfs(L):
    if len(L) == 0:
        return 0

    ret = min(L)
    L = [e - ret for e in L]
    L2 = []
    for e in L:
        if e == 0:
            ret += dfs(L2)
            L2 = []
        else:
            L2.append(e)

    ret += dfs(L2)
    return ret

def main():
    n = int(input())
    H = [int(e) for e in input().split()]

    print(dfs(H))

if __name__ == "__main__":
    main()


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

int A[100005];
int B[100005];
int C[100005];

int main()
{

    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int ans=0;
    ll s=0;
    ll d=0;
    for(int i=0;i<n;i++){
        cin>>B[i];
        C[i]=max(0,A[i]-B[i]);
        if(A[i]-B[i]<0)ans++;
        s+=A[i]-B[i];
        d+=max(0,B[i]-A[i]);
    }
    if(s<0){
        cout<<-1;
        return 0;
    }
   sort(C,C+n);
   reverse(C,C+n);
    int i=0;
    while(d>0){
        ++ans;
        d-=C[i];
        ++i;
    }
    cout<<ans;



}

Measured memory_bytes: 1408
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) { return a*b/gcd(a,b);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{},x{},t{},ans{};
	cin>>n>>x>>t;
	while(n)
	{
		if(x>=n)ans++,n=0;
		else ans++,n-=x;
	}
	cout<<ans*t<<'\n';
	//system("pause");
	return 0;	
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var N int
	fmt.Scanf("%d\n", &N)
	m := map[string]struct{}{}
	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		m[s] = struct{}{}
	}

	fmt.Println(len(m))

}


Measured memory_bytes: 20008
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <stdlib.h>

using namespace std;

long int A,B,C,K;

int main(){
    cin >> A >> B >> C >> K;
    int point = 0;

    if(K > A){
        K = K - A;
    }else{
        point = K;
        cout << point << endl;
        exit(0);
    }

    if(K > B){
        K = K - B;
    }else{
        point = A;
        cout << point << endl;
        exit(0);
    }

    point = A - K;

    cout << point << endl;

}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t[6000006][2], pr[6000005];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a;
  cin >> a;
  cout << a+(a*a)+(a*a*a);
  return 0;
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  vector<int> a(4);
  for(int i=0;i<4;i++) cin >> a[i];
  sort(all(a));
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

int main(){
    char s[4];
    for(int i=0; i<4; i++)
    cin >> s[i];
    if(s[0]==s[1] && s[1]==s[2])
    puts("Yes");
    else if(s[2]==s[3] && s[1]==s[2])
    puts("Yes");
    else
    puts("No");
    
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
    int k;
    cin>>k;
    int cnt=7;
    rep(i,10000000){
        if(cnt%k==0){
            cout<<i+1<<endl;
            return 0;
        }
        cnt *=10;
        cnt +=7;
        cnt %=k;
    }
    cout<<-1<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = m; i < n; i++)
const int INF = 1001001001;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  int h, w, ch, cw, dh, dw;
  cin >> h >> w >> ch >> cw >> dh >> dw;
  ch--;
  cw--;
  dh--;
  dw--;
  vector<string> s(h);
  for (string &i : s) cin >> i;
  vvi l(h, vi(w, INF));
  priority_queue<vi, vvi, greater<vi>> q;
  q.push({0, ch, cw});
  while (!q.empty()) {
    int gl = q.top().at(0);
    int gh = q.top().at(1);
    int gw = q.top().at(2);
    q.pop();
    if (gl >= l[gh][gw]) continue;
    l[gh][gw] = gl;
    FOR(mh, -2, 3) FOR(mw, -2, 3) {
      int nh = gh + mh, nw = gw + mw;
      if (mh == 0 and mw == 0) continue;
      if (nh < 0 or nh >= h) continue;
      if (nw < 0 or nw >= w) continue;
      if (s[nh][nw] == '#') continue;
      int magic = abs(mh) + abs(mw) == 1 ? 0 : 1;
      if (gl + magic < l[nh][nw]) q.push({gl + magic, nh, nw});
    }
  }
  if (l[dh][dw] != INF) cout << l[dh][dw] << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 12112
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL k,a,b;
    cin >> k >> a >> b;
    LL bi = 0;
    if (a > k || b - a < 2) {
        cout << k + 1 << endl;
        return;
    }
    bi = a;
    k -= a - 1;
    dump(bi);
    dump(k);
    bi += (b - a) * int(k / 2);
    cout << bi + k % 2 << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool cmp(int x,int y) {
    return x>y;
}
int n,a[1001],s1,s2;
int main()
{
	int i;
    cin>>n;
    for(i=1;i<=n;i++)
    cin>>a[i];
    sort(a+1,a+n+1,cmp);
    for(i=1;i<=n;i+=2)
    s1+=a[i];
    for(i=2;i<=n;i+=2)
    s2+=a[i];
    cout<<s1-s2<<endl;
    return 0;
}


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

namespace ABC088D
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Console.ReadLine().Split(' ');
            var H = int.Parse(HW[0]);
            var W = int.Parse(HW[1]);
            var grid = new List<string>();
            var dist = new List<List<int>>();
            var whiteCount = 0;
            for (var i = 0; i < H; i++)
            {
                var row = Console.ReadLine();
                grid.Add(row);
                whiteCount += row.Count(c => c == '.');
                dist.Add(new List<int>(Enumerable.Repeat(-1, W)));
            }

            dist[0][0] = 0;
            var queue = new Queue<(int x, int y)>();
            queue.Enqueue((0, 0));
            while (queue.Count > 0)
            {
                var current = queue.Dequeue();
                foreach (var next in GetNext(current))
                {
                    if (next.x >= 0 &&
                        next.x < W &&
                        next.y >= 0 &&
                        next.y < H &&
                        dist[next.y][next.x] == -1 &&
                        grid[next.y][next.x] == '.')
                    {
                        dist[next.y][next.x] = dist[current.y][current.x] + 1;
                        queue.Enqueue(next);
                    }
                }
            }

            var answer = -1;
            var goalDist = dist[H - 1][W - 1];
            if (goalDist != -1)
            {
                answer = whiteCount - goalDist - 1;
            }
            Console.WriteLine(answer);
        }

        static IEnumerable<(int x, int y)> GetNext((int x, int y) c)
        {
            yield return (c.x - 1, c.y);
            yield return (c.x + 1, c.y);
            yield return (c.x, c.y - 1);
            yield return (c.x, c.y + 1);
        }
    }
}


Measured memory_bytes: 28420
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)


const ll MOD = 1e9+7;

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    map<string,int>cnt,chk;
    vector<string>ans;
    set<string>inp;
    vector<string>s;
    int n;
    cin >> n;
    int ma=-1;
    for(int i=0;i<n;i++)
    {

        string str;
        cin >> str;
        cnt[str]++;
        ma=max(ma,cnt[str]);
        s.pb(str);
     }
     for(int i=0;i<n;i++)
     {
         if(!chk[s[i]] and cnt[s[i]]==ma)
         {
             ans.push_back(s[i]);
             chk[s[i]]=1;
         }
     }
     sort(ALL(ans));
     for(auto p:ans)cout<<p<<endl;

}





Measured memory_bytes: 40816
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
long long ci[3000];
char a[200010];
int main()
{
    scanf("%s",a+1);
   long long  l=strlen(a+1);
    for(int i=1;i<=l;++i)
        ci[(int)a[i]-96]++;
    long long ans;
    ans=l*(l-1)/2+1;
    for(int i=1;i<=26;++i)
        ans=ans-ci[i]*(ci[i]-1)/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int N_ = 200100;
vector<int> V[N_], G[N_], E[N_];
int N, Co[N_], Res[N_];
void Haku(int s, int e) {
	Co[s] = !Co[e];
	G[Co[s]].push_back(s);
	for (auto &u : V[s]) if (u != e) Haku(u, s);
}
int main() {
	int i, p = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; ++i) E[i % 3].push_back(i);
	for (i = 1; i + 1 <= N; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		V[a].push_back(b);
		V[b].push_back(a);
	}
	Haku(1, 1);
	if (G[1].size() < G[0].size()) p = !p;
	if (G[p].size() <= E[0].size()) {
		for (i = 1; i <= N; ++i) if (Co[i] == p) {
			Res[i] = E[0].back();
			E[0].pop_back();
		}
		for (i = 1; i <= N && E[1].size(); ++i) if (!Res[i]) {
			Res[i] = E[1].back();
			E[1].pop_back();
		}
		for (i = 1; i <= N && E[2].size(); ++i) if (!Res[i]) {
			Res[i] = E[2].back();
			E[2].pop_back();
		}
	} else {
		for (i = 1; i <= N && E[1].size(); ++i) if (Co[i]) {
			Res[i] = E[1].back();
			E[1].pop_back();
		}
		for (i = 1; i <= N && E[2].size(); ++i) if (!Co[i]) {
			Res[i] = E[2].back();
			E[2].pop_back();
		}
	}
	for (i = 1; i <= N; ++i) if (!Res[i]) {
		Res[i] = E[0].back();
		E[0].pop_back();
	}
	for (i = 1; i <= N; ++i) printf("%d ", Res[i]);
	puts("");
}


Measured memory_bytes: 29848
/*AOJ-ITP-4-3*/

/* 
 * ???????????´??° a, b ??¨?????????????????? op ?????????????????§???a op b ????¨??????????????????°?????????????????????????????????
 * ????????????????????? op ??????"+"(???)???"-"(???)???"*"(???)???"/"(???)???????????¨??????
 * ???????????§????????????????????´??????????°???°?????\??????????????¨????????????????¨????????????¨???????????? 
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
 
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String st[];
        String str;
        String op;
        int ans = 0;
        
        while(true){
        	str = br.readLine();
            st = str.split(" ");
        	int a = Integer.parseInt(st[0]);
        	op = st[1];
        	int b = Integer.parseInt(st[2]);
        	
        	if(op.equals("?")){break;}
        	
        	if(op.equals("+")){
        		ans = a + b;
        	}else if(op.equals("-")){
        		ans = a - b;
        	}else if(op.equals("*")){
        		ans = a * b;
        	}else if(op.equals("/")){
        		ans = a / b;
        	}
        	System.out.println(ans);
        }
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> C(M);
    for (int i = 0; i < M; ++i) cin >> C[i];
    vector<ll> dp(N+1, INF);
    dp[0] = 0;
    for (int i = 0; i < M; ++i) {
        for (int j = 0; j+C[i] <= N; ++j) {
            dp[j+C[i]] = min(dp[j+C[i]], dp[j]+1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = sc.nextInt();
		int mulFirst = (int) new Expression(s).value();
		int leftToRight = s.charAt(0) - '0';
		int length = (s.length() + 1) / 2;
		for(int i=1;i<length;i++) {
			int v = s.charAt(i*2) - '0';
			char c = s.charAt(i*2-1);
			leftToRight = c == '+' ? leftToRight + v : leftToRight * v;
		}

		//System.err.println(n + "," + mulFirst + "," + leftToRight);
		if (n == mulFirst) {
			if (n == leftToRight) {
				System.out.println("U");
			}else{
				System.out.println("M");
			}
		}else{
			if (n == leftToRight) {
				System.out.println("L");
			}else{
				System.out.println("I");
			}
		}

		sc.close();
	}
}
class Expression {
	private String expression;
	private int begin = 0;
	public Expression(String expression) {
		this.expression = expression;
	}
	public double value() {
		double num = term();
		while(begin<expression.length()) {
			char c = expression.charAt(begin);
			if (c=='+') {
				begin++;
				num+=term();
			}else if(c=='-') {
				begin++;
				num-=term();
			}else{
				break;
			}
		}
		return num;
	}
	private double term() {
		double num = factor();
		while(begin<expression.length()) {
			char c = expression.charAt(begin);
			if (c=='*') {
				begin++;
				num*=factor();
			}else if(c=='/') {
				begin++;
				num/=factor();
			}else{
				break;
			}
		}
		return num;
	}
	private double factor() {
		char c = expression.charAt(begin);
		if (c=='(') {
			begin++; //(
			double num = value();
			begin++; //)
			return num;
		}else{
			return number();
		}
	}
	private int number() {
		int num = 0;
		while(begin<expression.length()) {
			if (Character.isDigit(expression.charAt(begin))) {
				num*=10;
				num+=expression.charAt(begin)-'0';
				begin++;
			}else{
				break;
			}
		}
		return num;
	}
}

Measured memory_bytes: 17368
#include<bits/stdc++.h>
#define   ll  long long int
#define   sz  1000100

using namespace std;

map<string,ll>mp;

int main()
{


    ll n,i,j,k,a,b,x,y,p=8,d,c=0;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>a;

        if(a>=1 && a<=399)
        {
            mp["gray"]++;
        }
        else  if(a>=400 && a<=799)
        {
            mp["brown"]++;
        }
        else  if(a>=800 && a<=1199)
        {
            mp["green"]++;
        }
        else  if(a>=1200 && a<=1599)
        {
            mp["cyan"]++;
        }
         else  if(a>=1600 && a<=1999)
        {
            mp["blue"]++;
        }
        else  if(a>=2000 && a<=2399)
        {
            mp["yellow"]++;
        }
        else  if(a>=2400 && a<=2799)
        {
            mp["orange"]++;
        }
        else  if(a>=2800 && a<=3199)
        {
            mp["red"]++;
        }
        else
            c++;
    }

    x=mp.size();

    if(x==0)
    {

        cout<<1<<" "<<c<<endl;

        return 0;
    }


        d=x+c;

        cout<<x<<" "<<d<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a;
	int b[500][3];
	scanf("%d", &a);
	for (int i = 0; i < a-1; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			scanf("%d", b[i] + j);
		}
	}
	for (int i = 0; i < a-1; i++)
	{
		int time = 0;
		for (int j = i; j < a-1; j++)
		{
			if (time<b[j][1])
			{
				time = b[j][1];
			}
			if (time%b[j][2]!=0)
			{
				time++;
				j--;
				continue;
			}
			else
			{
				time += b[j][0];
			}
		}
		printf("%d\n", time);
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 128
//#include "bits/stdc++.h"

#include <iostream>
#include <iomanip>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	int a, b, d, r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = double(a) / b;
	cout << d << " " << r << " ";
	cout << fixed;
	cout << setprecision(5) << f << endl;
	return 0;
}



Measured memory_bytes: 3276
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    k,s = f()
    
    cnt = 0
    for i in range(k+1):
        for j in range(k+1):
            if s-i -j >=0 and s-i -j<= k:
                cnt += 1

    
    print(cnt)


solve()


Measured memory_bytes: 2940
#include <stdio.h>
int main(void)
{
  int R;
  scanf("%d\n",&R );

  if (R < 1200)
  {
    printf("ABC");
  }
  else if (R < 2800)
  {
    printf("ARC");
  }
  else
  {
    printf("AGC");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
static int cnt[100001];
int main()
{
  int N;
  cin >> N;
  long long sum = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    cnt[A]++;
    sum += (long long)A;
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int B, C;
    cin >> B >> C;

    sum = sum - (long long)B*cnt[B] + (long long)C*cnt[B];
    cout << sum << endl;
    cnt[C] += cnt[B];
    cnt[B] = 0;
  }
  return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<string>

#define MAX 1002
using namespace std;

int main(void){
	while( true ){
		int n;
		int maxSize = 0;
		int **map;
		int **sqsz;

		cin >> n;
		
		if( n == 0 ) break;

		map = new int*[n+2];
		sqsz = new int*[n+2];
		for(int i = 0; i < n+2; i++){
			map[i] = new int[n+2];
			sqsz[i] = new int[n+2];
			for(int j = 0; j < n+2; j++){
				map[i][j] = 0;
				sqsz[i][j] = 0;
			}
		}

		for(int i = 0; i < n; i++){
			string s;
			cin >> s;
			for(unsigned int j = 0; j < s.length(); j++){
				if( s[j] == '.' ) map[i+1][j+1] = 1;
			}
		}

		for(int i = n - 1; i >= 0; i--){
			for(int j = n - 1; j >= 0; j--){
				if( map[i+1][j+1] == 1 ){
					sqsz[i+1][j+1] = min(sqsz[i+2][j+1], min(sqsz[i+2][j+2], sqsz[i+1][j+2])) + 1;
					maxSize = max( maxSize, sqsz[i+1][j+1] );
				}
			}
		}
		cout << maxSize << '\n';

		for(int i = 0; i < n+2; i++){
			delete [] map[i];
			delete [] sqsz[i];
		}
		delete [] map;
		delete [] sqsz;

	}
	return 0;
}

Measured memory_bytes: 5672
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[][] lr = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
        Console.WriteLine(lr.Sum(x => x[1] - x[0] + 1));
    }
}

Measured memory_bytes: 13524
#include<iostream>
#include<cmath>
#include<string>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<<#X<<": "<<X<<" ";
#define ARDEB(i,X) cout<<#X<<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(X) {}
#define END {}
#endif
typedef long long int ll;
using namespace std;
ll m,a,r,c,h;
int main(){ 
	
	ll n,ans;
	string s[100000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i][0]=='M')m++;
		if(s[i][0]=='A')a++;
		if(s[i][0]=='R')r++;
		if(s[i][0]=='C')c++;
		if(s[i][0]=='H')h++;
	}
	ans=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int D,N;
  cin >> D >> N;
  if(N==100) cout << (((int)pow(100,D))*(N+1)) << endl;
  else cout << (((int)pow(100,D))*N) << endl;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int N;
ll dp[401][401];
vector<ll> a,S;

ll rec(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    else if(r-l < 2) return dp[l][r] = 0;
    else if(r-l == 2) return dp[l][r] = a[l] + a[r-1];

    ll res = LL_INF;
    REP(i,r-l-1){
        chmin(res, rec(l,l+i+1) + rec(l+i+1,r) + S[r] - S[l]);
    }
    return dp[l][r] = res;
}
int main(void){
    cin >> N;
    a.resize(N); REP(i,N) cin >> a[i];
    S.resize(N+1); S[0] = 0; REP(i,N) S[i+1] = S[i] + a[i];
    REP(i,N+1)REP(j,N+1) dp[i][j] = -1;
    ll ans = rec(0,N);
    cout << ans << en;
    return 0;
}

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

typedef unsigned long long ullong;

int main(void){
  int n;
  cin >> n;
  
  vector<ullong> a(n);
  for(int i=0; i<n; i++)
    cin >> a[i];

  vector< vector<ullong> > dp(n, vector<ullong>(n, 0));

  for(int i=0; i<n; i++)
    dp[i][i] = a[i];
  
  for(int k=1; k<n; k++){
    for(int i=0; i<n; i++){      
      if(k%2 == 0){
	dp[i][(i+k)%n] = max(dp[(i+1)%n][(i+k)%n] + a[i],
			     dp[i][(i+k-1)%n] + a[(i+k)%n]);
      }else{
	ullong temp1 = 0, temp2 = 0;
	if(max(a[i], a[(i+k+1)%n]) == a[i])
	  temp1 = dp[(i+1)%n][(i+k)%n];
	if(max(a[(n+i-1)%n], a[(i+k)%n]) == a[(i+k)%n])
	  temp2 = dp[i][(i+k-1)%n];
	dp[i][(i+k)%n] = max(temp1, temp2);
      }
    }
  }

  ullong outmax = 0;
  for(int i=0; i<n; i++){
    if(dp[i][(i+n-1)%n] > outmax)
      outmax = dp[i][(i+n-1)%n];
  }
  cout << outmax << endl;
  
  return 0;
}

Measured memory_bytes: 34220
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e9;
signed main() {
	int N;
    cin >> N;
    int ans = INF;
    for(int i = 1; i < N; i++) {
        int X = i;
        int Y = N-i;
        int cnt = 0;
        while(X != 0) {
            cnt+=X%10;
            X/=10;
        }
        while(Y != 0) {
            cnt+=Y%10;
            Y/=10;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

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

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

  if (a - a /2 == a / 2 || b - b /2 == b / 2) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


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

int main(void)
{
    int x[5];
    int n=5;
    rep(i, n){
        cin >> x[i];
    }
    rep(i, n){
        if(x[i]==0){
            cout << i+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  int N,M; cin>>N>>M;
  ll ans=N*(N-1)/2+M*(M-1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	private static final long MOD = 1000000007;
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {

			int n = sc.nextInt();

			long sum = 0;
			long powSum = 0;

			for(int i = 0 ; i < n ; i++ ) {

				long ai = sc.nextLong();
				sum += ai;
				sum = sum % MOD;

				powSum += (ai * ai) % MOD;
				powSum = powSum % MOD;

			}

			long ans = ((sum * sum) % MOD - powSum) % MOD;
			if ( ans < 0 ) {
				ans += MOD;
			}

			System.out.println(ans * modpow(2, MOD-2) % MOD);
			
//			System.out.println(modpow(2, MOD-2));
		}
	}

	public static long modpow(long a, long n) {
		long ans = 1;
		long ac = a;
		while ( n > 0 ) {
			if ( n % 2 == 1 ) {
				ans = ans * ac % MOD;
			}
			ac = ac * ac % MOD;
			n >>= 1;
		}
		return ans;
	}
}

Measured memory_bytes: 58220
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

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

  ll ans = 1;  
  bool skipf = false;
  for (size_t i = 1; i < str.size(); i++) {
    if(skipf){
      skipf = false;
      str[i] = '0';
      ans++;
    } else if (str[i] == str[i - 1]) {
      skipf = true;
    } else {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

string s;
int n;
bool d[4];

int main() {
	cin>>s;
	n = s.size();
	for(int i = 0; i < n; i++) {
		if(s[i] == 'N') d[0] = 1;
		if(s[i] == 'W') d[1] = 1;
		if(s[i] == 'S') d[2] = 1;
		if(s[i] == 'E') d[3] = 1; 
 	}
 	if(d[0] != d[2] || d[1] != d[3]) cout<<"No"<<endl;
 	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

ll mod = 1e9 + 7;

ll pow_mod(ll n, ll p)
{
    ll ret = 1;
    ll wk_n = n;
    ll wk_p = p;
    while (wk_p > 0)
    {
        if (wk_p % 2 == 0)
        {
            wk_n *= wk_n;
            wk_p /= 2;
            wk_n %= mod;
        }
        else
        {
            ret *= wk_n;
            wk_p--;
            ret %= mod;
        }
    }
    return ret;
}

ll cmb_mod(ll n, ll k)
{
    ll ret = 1;
    for (ll i = 1; i <= k; i++)
    {
        ret *= (n - i + 1);
        ret %= mod;
        ret *= pow_mod(i, mod - 2);
        ret %= mod;
    }
    return ret;
}

ll cmb_mod(ll n, ll k, ll prev)
{
    ll ret = prev;
    ret *= (n - k + 1);
    ret %= mod;
    ret *= pow_mod(k, mod - 2);
    ret %= mod;
    return ret;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll pat1 = cmb_mod(k - 1, 1 - 1);
    ll pat2 = cmb_mod(n - k + 1, 1);
    ll pat = (pat1 * pat2) % mod;
    cout << pat << endl;
    for (ll i = 2; i <= k; i++)
    {
        pat1 = cmb_mod(k - 1, i - 1, pat1);
        pat2 = cmb_mod(n - k + 1, i, pat2);
        pat = (pat1 * pat2) % mod;
        cout << pat << endl;
    }

    return 0;
}


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


void solve(long long K, long long N, std::vector<long long> A){
    // 差分配列を作成する
    vector<long long> B;
    for(int i = 0; i < A.size()-1; i++) {
        B.push_back(abs(A[i] - A[i+1]));
    }
    
    B.push_back(abs(K - A[A.size()-1]) + A[0]);

    long long max_f = -1;
    int max_idx;
    for(int i = 0; i < B.size(); i++) {
        if(max_f < B[i]) {
            max_f = B[i];
            max_idx = i;
        }
    }

    cout << K - max_f << endl;

    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 4980
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <queue>
#include <set>
#include <bitset>
#include <stack>

#define R register
#define ll long long
#define db double
#define sqr(_x) (_x) * (_x)
#define Cmax(_a, _b) ((_a) < (_b) ? (_a) = (_b), 1 : 0)
#define Cmin(_a, _b) ((_a) > (_b) ? (_a) = (_b), 1 : 0)
#define Max(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define Min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
#define Abs(_x) (_x < 0 ? (-(_x)) : (_x))

using namespace std;

namespace Dntcry
{
	inline int read()
	{
		R int a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	inline ll lread()
	{
		R ll a = 0, b = 1; R char c = getchar();
		for(; c < '0' || c > '9'; c = getchar()) (c == '-') ? b = -1 : 0;
		for(; c >= '0' && c <= '9'; c = getchar()) a = (a << 1) + (a << 3) + c - '0';
		return a * b;
	}
	const int Maxn = 1010;
	bitset<Maxn>S[Maxn];
	int n, m, Map[Maxn][Maxn];
	bool vis[Maxn];
	int A[Maxn], B[Maxn],tot;
	struct Edge
	{
		int v;
		Edge *next;
	}e[Maxn * Maxn], *last[Maxn], *c = e;
	void Add(R int u, R int v)
	{
		*++c = (Edge){v, last[u]}, last[u] = c;
		*++c = (Edge){u, last[v]}, last[v] = c;
	}
	void dfs(R int x, R int fa, R int col)
	{
		vis[x] = 1;
		if(!col) A[tot]++;
		else B[tot]++;
		for(R Edge *i = last[x]; i; i = i->next)
			if(i->v != fa && !vis[i->v]) dfs(i->v, x, col ^ 1); 
		return ;
	}
	bitset<Maxn> beibao;
	int mintuan;
	int Main()
	{
		n = read(), m = read();
		for(R int i = 1, u, v; i <= m; i++) u = read(), v = read(), Map[u][v] = Map[v][u] = 1;
		for(R int i = 1; i <= n; i++)
			for(R int j = 1; j <= n; j++)
				if(i != j) Map[i][j] ^= 1;
		for(R int i = 1; i <= n; i++)
			for(R int j = 1; j <= n; j++)
				S[i][j] = Map[i][j];
		/*for(R int i = 1; i <= n; i++, cout<<endl)
			for(R int j = 1; j <= n; j++)
				printf("%d ", Map[i][j]);*/
		for(R int i = 1; i <= n; i++)
			for(R int j = i + 1; j <= n; j++)
				if(Map[i][j] && ((S[i] & S[j]).count())) 
					return puts("-1"), 0;
		for(R int i = 1; i <= n; i++)
			for(R int j = i + 1; j <= n; j++)
				if(Map[i][j]) Add(i, j);
		for(R int i = 1; i <= n; i++)
			if(!vis[i]) tot++, dfs(i, 0, 0);
		//puts("down");
		beibao[0] = 1;
		for(R int i = 1; i <= tot; i++) beibao = beibao << A[i] | beibao << B[i];
		for(R int i = 1; i <= (n >> 1); i++) if(beibao[i]) Cmax(mintuan, i);
		printf("%d\n", mintuan * (mintuan - 1) / 2 + (n - mintuan) * (n - mintuan - 1) / 2);
		return 0;
	}
}
int main()
{
	return Dntcry :: Main();
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <functional>
//#include <array>
#include <bits/stdc++.h>
using namespace std;
//typedef unsigned long long ull;


int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;

}


Measured memory_bytes: 256
N = int(input())
inputList = []
for count in range(1,N):
    C,S,F = map(int, input().split())
    tempList = [C,S,F]
    inputList.append(tempList)

for i in range(0,N):
    t = 0
    for j in range(i,N-1):
        C = inputList[j][0]
        S = inputList[j][1]
        F = inputList[j][2]
        if t < S:
            t = S
        elif t % F == 0:
            t = t
        else:
            t = t + F -t%F
        t += C
    print(t)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

struct edge_t {
  int other, delta;
};

bool ok;
vector<vector<edge_t>> adj;
vector<bool> marked;
vector<int> position;

void dfs(int v, int position_v) {
  if (marked[v]) {
    if (position[v] != position_v) {
      ok = false;
    }
    return;
  }
  marked[v] = true;
  position[v] = position_v;
  for (const edge_t &ed : adj[v])
    dfs(ed.other, position_v + ed.delta);
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  adj.resize(n);
  marked.resize(n);
  position.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b, delta;
    scanf("%d %d %d", &a, &b, &delta), --a, --b;
    adj[a].push_back({b, delta});
    adj[b].push_back({a, -delta});
  }
  ok = true;
  for (int i = 0; i < n; ++i)
    if (!marked[i])
      dfs(i, 0);
  if (ok) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
int main(void){
	
	int i=0,j=0;
	char n[10000]={0};
	int x[1001]={0};
	while(1){
		scanf("%c",&n[i]);
		if(n[i]=='0' && n[i-1]=='\n' || n[0]=='0')break;
		if(n[i]>='1' && n[i]<='9' && n[i]!='\n')x[j]+=n[i]-48;
		if(n[i]=='\n')j++;
		i++;
	}
	for(i=0;i<j;i++){
		printf("%d\n",x[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
 
int main (){
  int X, A, B;
  cin >> X >> A >> B;
  
  if(B<=A){
    cout << "delicious" << endl;
  }
  else if (-A+B<=X){
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256