akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0521

int main() {
    int coins[] = {500, 100, 50, 10, 5, 1};

    while(true) {
        int price; cin >> price;
        if (price == 0) break;
        int change = 1000 - price;
        int ans = 0;
        for (int c : coins) {
            int n = change / c;
            ans += n;
            change -= c * n;
        }
        cout << ans << "\n";
    }

    return 0;
}



Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int n; int l;
	cin >> n>>l;
	string ans;
	vector<string>s(n);
	rep0(i, n - 1) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	rep0(j, n - 1) {
		ans += s[j];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int N, P;
    std::cin >> N >> P;

    bool odd = false;
    for (int i = 0; i < N; ++i) {
        int A;
        std::cin >> A;
        if (A & 1) odd = true;
    }
    std::cout << (odd ? 1LL << (N - 1) : (1LL << N) * (1 - P)) << std::endl;
    return 0;
}


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

using Graph = vector<vector<int>>;
struct LCA {
    vector<vector<int>> par;
    vector<int> dist;
    LCA(const Graph &G, int root = 0) { init(G, root); }

    void init(const Graph &G, int root = 0) {
        int V = G.size();
        int K = 1;
        while ((1 << K) < V) K++;
        par.assign(K, vector<int> (V, -1));
        dist.assign(V, -1);
        dfs(G, root, -1, 0);
        for (int k = 0; k + 1 < K; k++) {
            for (int v = 0; v < V; v++) {
                if (par[k][v] < 0) {
                    par[k + 1][v] = -1;
                } else {
                    par[k + 1][v] = par[k][par[k][v]];
                }
            }
        }
    }

    void dfs(const Graph &G, int v, int p, int d) {
        par[0][v] = p;
        dist[v] = d;
        for (auto to : G[v]) {
            if (to != p) {
                dfs(G, to, v, d + 1);
            }
        }
    }

    int query(int u, int v) {
        if (dist[u] < dist[v]) swap(u, v);
        int K = par.size();
        for (int k = 0; k < K; k++) {
            if ((dist[u] - dist[v]) >> k & 1) {
                u = par[k][u];
            }
        }

        if (u == v) return u;
        for (int k = K - 1; k >= 0; --k) {
            if (par[k][u] != par[k][v]) {
                u = par[k][u];
                v = par[k][v];
            }
        }
        return par[0][u];
    }
};

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n, vector<int>());
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++) {
            int in;
            cin >> in;
            g[i].push_back(in);
            g[in].push_back(i);
        }
    }
    int q;
    cin >> q;
    auto lca = LCA(g, 0);
    for (int i = 0; i < q; ++i) {
        int a, b;
        cin >> a >> b;
        cout << lca.query(a, b) << endl;
    }
}


Measured memory_bytes: 18220
n=gets.to_i
asum=0
bsum=0
n.times do
  a,b=gets.split
  if a>b
    asum=asum+3
  elsif a<b
    bsum=bsum+3
  else
    asum=asum+1
    bsum=bsum+1
  end
end
puts "#{asum} #{bsum}"



Measured memory_bytes: 6860
from collections import deque

N, M = [int(n) for n in input().split()]
P = deque([tuple(map(lambda n: int(n), input().split())) for _ in range(N)])
C = [tuple(map(lambda n: int(n), input().split())) for _ in range(M)]

def nearest(p, checkpoints):
    d = float('inf')
    x, y = p
    for i, c in enumerate(checkpoints):
        xi, yi = c
        dn = abs(x - xi) + abs(y - yi)
        if d > dn:
            d = dn
            idx = i
    return str(idx + 1)

def main():
    ans = []
    while P:
        p = P.popleft()
        ans.append(nearest(p, C))
    print('\n'.join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <random>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
#include <random>
using namespace std;
using LL = long long;

int main() {
	LL N;
	cin >> N;
	LL ans = 0;
	for (LL c = 1; c < N; c++) {
		LL a = 1;
		while (a * c < N) {
			a++;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    char s[6];
    scanf("%s" ,s);

    if( (s[2] == s[3]) && (s[4] == s[5]) ) {
        printf("Yes\n");
        return 0;
    }else{
        printf("No\n");
        return 0;
    }
}

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

using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int main() {
	int n;
	string s, t; cin >> n >> s >> t;
	string ans;
	for (int i = 0; i < n; ++i) {
		ans += s[i]; ans += t[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

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

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = pow(10, 9) + 7;

ll solve(vector<string> &s, ll start_h, ll start_w) {
    if (s[start_h][start_w] == '#') {
        return 0;
    }

    ll h = s.size(), w = s[0].size();

    ll distance[h][w];
    rep(i, h) {
        rep(j, w) { distance[i][j] = -1; }
    }

    distance[start_h][start_w] = 0;

    queue<pair<ll, ll>> q;
    q.push(make_pair(start_h, start_w));

    ll ans = 0;
    while (!q.empty()) {
        pair<ll, ll> p = q.front();
        q.pop();
        ll index0[4] = {-1, 0, 1, 0};
        ll index1[4] = {0, 1, 0, -1};
        rep(i, 4) {
            ll point_h = p.first + index0[i], point_w = p.second + index1[i];
            if ((point_h < 0 | h <= point_h) | (point_w < 0 | w <= point_w)) {
                continue;
            }
            if (s[point_h][point_w] == '#') {
                continue;
            }

            if (distance[point_h][point_w] >= 0) {
                continue;
            }

            ll num = distance[p.first][p.second];
            distance[point_h][point_w] = num + 1;
            ans = max(ans, num + 1);
            q.push(make_pair(point_h, point_w));
        }
    }

    /*
        cout << start_h << " " << start_w << endl;
        rep(i, h) {
            rep(j, w) { cout << distance[i][j]; }
            cout << endl;
        }
    */

    return ans;
}

int main() {
    // source
    ll h, w;
    cin >> h >> w;

    vector<string> s(h);
    rep(i, h) { cin >> s[i]; }

    ll ans = 0;
    rep(i, h) {
        rep(j, w) { ans = max(ans, solve(s, i, j)); }
    }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	cout << max(A * 10 + B + C, max(A + B * 10 + C, A + B + C * 10)) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    String str = scan.next();
    int max = 0;

    for (int i = 0; i < str.length();) {
      int cnt = 0;
      for (int j = i; j < str.length(); j++) {
        i = j + 1;
        if ((str.charAt(j) == 'A') || (str.charAt(j) == 'C') || (str.charAt(j) == 'G') || (str.charAt(j) == 'T')) {
          cnt++;
        } else {
          break;
        }
      }
      max = Math.max(max, cnt);
    }

    System.out.println(max);
  }

}

Measured memory_bytes: 20692
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n, m;
    scanf("%ld%ld", &n, &m);

    vector<vector<long> > zz(n);
    long i;
    for(i=0; i<m; i++) {
        long a, b;
        scanf("%ld%ld", &a, &b);
        zz[a-1].push_back(b-1);
        zz[b-1].push_back(a-1);
    }

    for(i=0; i<n; i++) {
        printf("%ld\n", (long)zz[i].size());
    }

    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)

N,M = map(int, input().split())
s = list(input())

'''
A
1 ~ N -> mod0
N+1 ~ 2N -> mod1

B
1 ~ N -> mod2
N+1 ~ 2N -> mod3
'''

lines = [[] for i in range(2*N)]
for _ in range(M):
    a,b = map(int, input().split())
    a-=1
    b-=1
    sa, sb = s[a], s[b]
    if sa == sb:
        lines[a].append(b+N)
        lines[b].append(a+N)
    else:
        lines[a+N].append(b)
        lines[b+N].append(a)

ed = [0]*(2*N)

def dfs(s):
    global ed
    ed[s] = 1
    for t in lines[s]:
        if ed[t] == 1: #今訪れている
            print('Yes')
            sys.exit()
        elif ed[t] == 0:
            dfs(t)
    ed[s] = 2

for s in range(N):
    if ed[s] == 0:
        dfs(s)

print('No')


Measured memory_bytes: 162700
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
long nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {
	int a, b;
	cin >> a >> b;
	cout << lcm(a, b) << endl;
}

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

int main(void) {
    int64_t N;
    int64_t mina;
    int mincnt;
    cin >> N;

    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];    
    }

    mina = *min_element(A.begin(), A.end());
    mincnt = 0;
    map<int,int> mpa;
    map<int,int> mpb;
    map<int,int>* cur;
    map<int,int>* tgt;
    map<int,int>* tmp;
    for(int i=0;i<N;i++) {
        if(mina == A[i]) {
            mpa[mina]++;
        } else {
            if(A[i]%mina == 0) continue;
            mpa[A[i]%mina]++;
        }
    }
        
    tgt = &mpa;
    cur = &mpb;
    while(tgt->size() > 1){
        mina = tgt->begin()->first;
        for(auto m: (*tgt)) {
            if(mina == m.first) {
                (*cur)[mina]++;
            } else {
                if(m.first % mina == 0) continue;
                (*cur)[m.first%mina]++;
            }
        }
        
        tmp = tgt;
        tgt = cur;
        cur = tmp;
        cur->clear();
    }

    cout << tgt->begin()->first << endl;
    return 0;
}


Measured memory_bytes: 1280
package main

import (
	"fmt"
	"io"
	"os"
	"strconv"
)

var pri = fmt.Println
var scan = fmt.Fscanln
var scanone = fmt.Fscan

func main() {
	solve(os.Stdin)
}

func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] {
			res = a[i]
		}
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

func mustint(a string) int {
	i, _ := strconv.Atoi(a)
	return int(i)
}

type P struct {
	x, y int
}

func (p *P) add(q *P) *P {
	return &P{p.x + q.x, p.y + q.y}
}

const huge = 1e10

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}
func solve(rd io.Reader) {
	var t1, t2, a1, a2, b1, b2 int
	scan(rd, &t1, &t2)
	scan(rd, &a1, &a2)
	scan(rd, &b1, &b2)
	d1 := (b1 - a1) * t1
	d2 := (b2 - a2) * t2
	if d1 > 0 && d2 > 0 {
		pri(0)
		return
	}
	if d1 < 0 && d2 < 0 {
		pri(0)
		return
	}
	if abs(d1) > abs(d2) {
		pri(0)
		return
	}
	d := abs(abs(d1) - abs(d2))
	if d == 0 {
		pri("infinity")
		return
	}
	n := abs(d1) / d
	if n*d != abs(d1) {
		n++
		pri(2*n - 1)
	} else {
		pri(2 * n)
	}
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

ll gcd(ll x, ll y)
{
    if(x < y)   swap(x, y);
    if(y == 0)  return x;
    return gcd(x % y, y);
}

ll lcm(ll x, ll y)
{
    return (x*y)/gcd(x, y);
}

ll f(ll x, int c, int d)
{
    return (x-(x/c)-(x/d)+(x/lcm(c, d)));
}

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b, c, d) - f(a-1, c, d);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();
    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    
    let mut ans = 100000;
    for i in 1..N{
        let mut i = i;
        let mut j = N-i;
        let mut tmp = 0;
        while i > 0{
            tmp += i%10;
            i /= 10;
        }
        while j > 0{
            tmp += j%10;
            j /= 10;
        }
        ans = min(ans,tmp);
    }

    println!("{}",ans);
}

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

namespace B.Palace
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var TA = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var Hn = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var min = double.MaxValue;
            int min_index = int.MaxValue;


            for (int i = 0; i < N; i++)
            {
                var diff = Math.Abs(TA[1] - (TA[0] - Hn[i] * 0.006));

                if (diff < min)
                {
                    min = diff;
                    min_index = i + 1;
                }
            }

            Console.WriteLine(min_index);

        }
    }
}

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

int main() {
  int N;
  cin>>N;
  int a[100001];
  int count=0;
  int ans=0;
  for(int i=1; i<=N; i++){
  	scanf("%d",&a[i]);
  	if(a[i]>a[i-1]){
  		count=0;
  	}else{
  		count++;
  	}
  	ans=max(ans,count);
  }
  cout <<ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
 int k,i,j,t,sum=0,x,y,z;
 (void)scanf("%d",&k);
for(i=1;i<=k;i++){
  for(j=1;j<=k;j++){
    for(t=1;t<=k;t++){
      x=0;
      y=i;
      if(y>j)
      y=j;
      if(y>t)
      y=t;
      for(z=1;z<=y;z++){
        if(i%z==0&&j%z==0&&t%z==0)
        x=z;
      }
      sum+=x;
    }
  }
}
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 1728
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int, int> P;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int H, W;
char s[55][55];
bool used[50][50];

signed main() {
  cin >> H >> W;
  for (int i = 0; i <= H + 1; i++) {
    for (int j = 0; j <= W + 1; j++) {
      s[i][j] = 'W';
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      if (s[i][j] != '#')
        continue;

      bool flag = false;
      for (int t = 0; t < 4; t++) {
        if (s[i + dy[t]][j + dx[t]] == '#') {
          flag = true;
          break;
        }
      }

      if (flag == false) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int a,b,c;
  cin >> a >> b >> c;
  
  int cnt = 0;
  while(a%2==0 && b%2==0 && c%2 == 0){
    if(a==b && b==c){
      cnt = -1;
      break;
    }
    int tmpa = a, tmpb = b, tmpc = c;
    a = (tmpb+tmpc)/2;
    b = (tmpa+tmpc)/2;
    c = (tmpa+tmpb)/2;
    cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main() {
    ll n;
    cin >> n;
    vector<ll> t(n);
    for (ll i=0;i<n;++i){
        cin >> t[i];
    }
    ll m;
    cin >> m;
    for (ll i=0;i<m;++i){
        ll p,x,ans=0;
        cin >> p >> x;
        for (ll i=0;i<n;++i){
            if (i+1==p){
                ans+=x;
                continue;
            }
            ans+=t[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
#入力
#a = int(input())
#b,c = map(int, input().split())
#s = input()

N = int(input())
s = input()
a = np.asarray(s.split(), dtype=int)

#処理

d = {}
for val  in a:
    if val in d.keys():
        d[val] += 1
    else:
        d[val] = 1

keyNum = len(d.keys())
num = len(a)
keys = list(d.keys())

#条件１
if len(d.keys()) == 1 and 0 in d.keys():
    print ("Yes")
elif len(a) % 3 != 0:
    print ("No")
elif keyNum == 2:
    keys.sort()
    if keys[0] != 0:
        print ("No")
    elif d[0] != num//3:
        print ("No")
    else:
        print ("Yes")
#        keys1 = format(keys[1],'b')
#        isAll1 = True
#        for x in keys1:
#            if x != '1':
#                isAll1 = False
#                break
#        if isAll1:
#            print ("Yes")
#        else:
#            print ("No")

elif keyNum != 3:
    print ("No")

else:
    if d[keys[0]] != num//3:
        print ("No")
    elif d[keys[1]] != num//3:
        print ("No")
    elif d[keys[2]] != num//3:
        print ("No")
    else:
        key1 = format(keys[0],'099b')
        key2 = format(keys[1],'099b')
        key3 = format(keys[2],'099b')
        isA = True
        for k1,k2,k3 in zip(key1,key2,key3):
            kk1 = int(k1)
            kk2 = int(k2)
            kk3 = int(k3)
            goukei = kk1 + kk2 + kk3
            if not (goukei == 0 or goukei == 2):
                isA = False
                break
        
        if isA:
            print ("Yes")
        else:
            print ("No")


Measured memory_bytes: 24792
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

var (
	d int
	g int
)

func main() {
	sc.Split(bufio.ScanWords)

	d = nextInt()
	g = nextInt()

	p := make([]int, d)
	c := make([]int, g)
	for i := 0; i < d; i++ {
		p[i] = nextInt()
		c[i] = nextInt()
	}

	res := 100000100000
	for bit := 0; bit < (1 << uint(d)); bit++ {
		sum := 0
		num := 0

		// p[i]をすべて解いた時の得点
		for i := 0; i < d; i++ {
			if bit&(1<<uint(i)) == 1<<uint(i) {
				sum += c[i] + p[i]*100*(int(i)+1)
				num += p[i]
			}
			// fmt.Println(res)

		}

		if sum >= g {
			res = min(res, num)
		} else {
			for i := d - 1; i >= 0; i-- {
				if bit&(1<<uint(i)) == 1<<uint(i) {
					continue
				}
				for j := 0; j < p[i]; j++ {
					if sum >= g {
						break
					}
					sum += 100 * (int(i) + 1)
					num++
				}
			}
			res = min(res, num)
		}

	}

	fmt.Println(res)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		System.out.println((A+B > C+D) ? "Left" : (A+B == C+D) ? "Balanced" : "Right");
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//F
//遠くにいく
//X,Yのabsの最大
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll x,a,b;
    cin >> x >> a >> b;

    ll res = 0;

    x -= a;

    res = x % b;

    cout << res << endl;


    return 0;    

}



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

int main()
{
  int n;
  long long K;
  scanf("%d%lld",&n,&K);
  vector<int> a(n);
  int mx=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    mx=max(mx,a[i]);
  }
  vector<int> b(mx+1,-1),nx(2*n);
  for(int i=2*n-1;i>=0;i--){
    if(b[a[i%n]]!=-1){
      nx[i]=b[a[i%n]];
    }
    b[a[i%n]]=i;
  }
  vector<int> V(n,-1);
  V[0]=0;
  int cur=0,t=0;
  K--;
  while(1){
    int next=nx[cur];
    //printf("%d %d %d\n",cur,next,t);
    if(nx[cur]>=n){
      if(K==0){
	break;
      }
      K--;
      t++;
      next-=n;
    }
    cur=next+1;
    if(cur==n){
      if(K==0){
	break;
      }
      cur=0;
      K--;
      t++;
    }
    if(V[cur]==-1){
      V[cur]=t;
    }
    else{
      K=K%(t-V[cur]);
    }
  }
  vector<int> ans;
  while(cur<n){
    if(nx[cur]>=n){
      ans.push_back(a[cur]);
      cur++;
    }
    else{
      cur=nx[cur]+1;
    }
  }
  for(int i=0;i<ans.size();i++){
    printf("%d%c",ans[i],i+1==ans.size()?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 6260
import scala.io.StdIn._

object Main extends App {
  val Array(n, k, q) = readLine.split(" ").map(_.toInt)
  val map = (1 to q).map(i => readLine.toInt).groupBy(identity).mapValues(_.size)
  val w = new java.io.PrintWriter(System.out)
  (1 to n).foreach { i => w.println(if (k - (q - map.getOrElse(i, 0)) > 0) "Yes" else "No")}
  w.flush
}

Measured memory_bytes: 86368
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
const db pi = acos(-1.0);
const int N = 22;
inline LL gcd(LL a, LL b) {return a % b == 0 ? b : gcd(b, a % b);}
inline LL read() {
    LL x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-')f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    return x * f;
}
int n, m, c, cnt, b[N];
int main() {
    n = read(); m = read(); c = read();
    for (int i = 1; i <= m; ++i) b[i] = read();
    for (int i = 1; i <= n; ++i) {
        int s = 0;
        for (int j = 1; j <= m; ++j) {
            int t = read();
            s += t * b[j];
        }
        s += c;
        if (s > 0) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    for (int i = B; i >= A; i--) {
        if (i % K == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
N = len(S)
S2 = S[:N//2]
S3 = S[(N+3)//2-1:]

if S == S[::-1] and S2 == S2[::-1] and S3 == S3[::-1]:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll k; cin>>k;
    ll a[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};
    cout<<a[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
int main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r<0 || x+r>W)
	{
		printf("No\n");
	}
	else if(y-r<0 || y+r>H)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int a[510][510];

typedef pair<int, int> P;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int H, W;
	cin >> H >> W;
	rep(i, H) rep(j, W) cin >> a[i][j];
	vector<P> v0;
	vector<P> v1;
	rep(i, H) {
		rep(j, W - 1) {
			if (a[i][j] % 2 == 1) {
				a[i][j]--;
				a[i][j + 1]++;
				v0.push_back({ i + 1, j + 1 });
				v1.push_back({ i + 1, j + 2 });
			}
		}
	}
	rep(i, H - 1) {
		if (a[i][W - 1] % 2 == 1) {
			a[i][W - 1]--;
			a[i + 1][W - 1]++;
			v0.push_back({ i + 1, W });
			v1.push_back({ i + 2, W });
		}
	}
	cout << v0.size() << endl;
	rep(i, v0.size()) {
		cout << v0[i].first << " " << v0[i].second << " " << v1[i].first << " " << v1[i].second << endl;
	}


    return 0;
}


Measured memory_bytes: 5356
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
s=input()
k=i1()
x=[-1,-1]
for i in range(len(s)):
 if s[i]!='1':
    x=[i,s[i]]
    break
if x[0]>=0 and k>=x[0]+1:
   print(x[1])
else:
   print(1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define double long double
#define N 20
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
const double g = 1.0;
int p[N],h[N];

double calcX(double radian,double v){
  double vix = v * cos(radian);
  double viy = v * sin(radian);
  double t = 2 * viy / g;
  return vix * t;
}

double calcV(double x,int n,int b,double radian){
  double L = 0, R = 1e10, cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcX(radian,M) > x) R = M;
    else L = M;
  }
    
  double v = L,pos = 0;
  for(int i=0;i<b;i++, pos += x){
    for(int j=0;j<n;j++){
      if(!(pos <= p[j] && p[j] <= pos+x)) continue;
      double vix = v * cos(radian);
      double viy = v * sin(radian);
      double t = (p[j] - pos)/vix;
      double y = -(g*t/2 - viy) * t;
      if(y-h[j]+EPS < 0) return INF;
    }
  }
  return v;  
}

double solve(double x,int n,int b){
  double L = PI/4,R = PI/2,cnt = 100;
  while(cnt--){
    double M = (L+R)/2;
    if(calcV(x,n,b,M) < INF) R = M; 
    else L = M;
  }
  return calcV(x,n,b,R);
}

signed main(){
  int D,n,B;
  cin>>D>>n>>B;
  for(int i=0;i<n;i++) cin>>p[i]>>h[i];
  double ans = INF;
  for(int i=1;i<=B+1;i++) Min(ans,solve(1.0*D/i,n,i));
  printf("%.5Lf\n",ans);
  return 0;
}

Measured memory_bytes: 3500
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
keta=len(str(n))
for i in range(3,keta):
    ans+=3**i-2**i*3+3
    # print(ans)
ite=list(itertools.product((3,5,7),repeat=keta))
ite.sort()
for ii in ite:
    bi=list(map(str,ii))
    ai = int(''.join(bi))
    if n>=ai:
        if (3 in ii) and (5 in ii) and  (7 in ii):
            ans+=1
    else:
        break

print(ans)

Measured memory_bytes: 43500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
const int mxN=1e5+10,M=1e9+7;
int n,k;
int mod(int a,int M){int ret=a%M;if(ret<0)ret+=M;return ret;}
int exp(int a,int b,int M){
    if(b==0LL)return 1LL;
    if(b==1LL)return mod(a,M);

    int t=exp(a,b/2,M);
    if(b&1)return mod(a*mod(t*t,M),M);
    return mod(t*t,M);
}
int v[mxN];
int resp;
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    
    for(int x=k;x>=1;x--){
        int temp=k/x;
        temp=exp(temp,n,M);
        for(int i=2*x;i<=k;i+=x){
            temp-=v[i];
        }
        v[x]=temp;
        resp=mod(resp+mod(x*temp,M),M);
    }

   
    cout<<resp;

}

Measured memory_bytes: 4320
N,D = [int(i) for i in input().split()]
lagd = []
for i in range(N):
    lagd.append([int(i) for i in input().split()])
lngs = D - 1
def kyoricac(daone,datwo,d):
    keka = []
    n = 0
    wa = 0
    while n <= d:
        wa = (daone[n] - datwo[n])**2
        keka += [wa]
        n += 1
    wa = sum(keka)
    kaesi = float(wa ** (1/2))
    return kaesi
ans = 0
fst = 1
for i in range(N):
    for n in range(fst,N):
        flag = float(kyoricac(lagd[i],lagd[n],lngs))
        if flag.is_integer() == True:
            ans += 1
    fst += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  set<int> s;
  s.insert(a);
  s.insert(b);
  s.insert(c);
  puts(s.size() == 3 || s.size() == 1 ? "No" : "Yes");
  return 0;
}

Measured memory_bytes: 256
n = int(input())
edge = [[] for _ in range(n)]
mod = 10**9 + 7
for i in range(n-1):
    x,y = map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
stack = [0]
parent = [-1]*n
deep = [[0,i] for i in range(n)]
while stack:
    p = stack.pop()
    for c in edge[p]:
        if c == parent[p]:continue
        parent[c] = p
        deep[c][0] = deep[p][0] + 1
        stack.append(c)
deep.sort(reverse = True)
ans = [[1,1] for _ in range(n)]
for d,i in deep[:-1]:
    p = parent[i]
    ans[p][0] *= ans[i][1]
    ans[p][0] %= mod
    ans[p][1] *= sum(ans[i])%mod
    ans[p][1] %= mod
print(sum(ans[0])%mod)


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

namespace ConsoleApp15
{
    class Class396
    {
        static void Main()
        {
            char a = Console.ReadLine()[0];
            if ('a' <= a && a <= 'z')
            {
                Console.WriteLine("a");
            }
            else
            {
                Console.WriteLine("A");
            }
        }
    }
}


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

int c[3][3];
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    set<int> st;
    for (int j = 0; j < 3; j++) {
      st.insert(c[i][j] - c[i + 1][j]);
    }
    if (st.size() > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i = 0; i < 2; i++) {
    set<int> st;
    for (int j = 0; j < 3; j++) {
      st.insert(c[j][i] - c[j][i + 1]);
    }
    if (st.size() > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = a * b;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3624
import collections
h,p = map(int, raw_input().split())
def f(mat, h, p):
	q = collections.deque([((0,0), 1)])
	vis = set([(0,0)])

	while(q):
		u,d = q.popleft()
		if u == (h-1, p-1): return collections.Counter(reduce(lambda x,y:x+y, mat))['.'] - d
			
		for v in [(u[0]+1,u[1]), (u[0]-1,u[1]), (u[0],u[1]+1),(u[0],u[1]-1)]:
			if 0 <= v[0] < len(mat) and 0 <= v[1] < len(mat[0]):
				if v not in vis and mat[v[0]][v[1]] == '.':
					vis.add(v)
					q.append((v, d+1))
	return -1
print f([list(raw_input()) for l in range(h)], h, p)

Measured memory_bytes: 74596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	if (n&1) printf("No\n");
	else
	{
		for (int i=0;i<n;i+=2)
			if (s[i]=='h' && s[i+1]=='i') continue;
			else
			{
				printf("No\n");
				return 0;
			}
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 210000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

ll fac[MAX],finv[MAX],inv[MAX];
//http://drken1215.hatenablog.com/entry/2018/06/08/210000
//テーブルを作る前処理　O(n)
//pが素数でなくてはならない
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
//二項係数計算
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main(){
    COMinit();
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    ll ans=0;
    for(int i=0;i<=H-A-1;i++){
        ll temp=COM(i+B-1,i)*COM(W-B-1+H-1-i,H-1-i);
        temp%=MOD;
        ans+=temp;
        ans%=MOD;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 5120
#include <stdio.h>
#include <string.h>
int main() {
	char s[100001];
	int n, a, b, pass = 0, fpass = 0;
	scanf("%d%d%d", &n, &a, &b);
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (s[i] == 'a') {
			if (pass < a + b) {
				printf("Yes\n");
				pass++;
			} else {
				printf("No\n");
			}
		} else if (s[i] == 'b') {
			if (pass < a + b && fpass < b) {
				printf("Yes\n");
				fpass++;
				pass++;
			} else {
				printf("No\n");
			}
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 640
N=int(input())
L=[]
for i in range(1,N+1):
    s,p=input().split()
    p=int(p)
    L.append((i,s,p))
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])
for l in L:
    print(l[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

string solve(string s)
{
    int S = s.size();
    string NG = "No", OK = "Yes";
    rep(i,S)
    {
        if(s[i]=='b' && s[S-1-i]!='d') return NG;
        if(s[i]=='d' && s[S-1-i]!='b') return NG;
        if(s[i]=='p' && s[S-1-i]!='q') return NG;
        if(s[i]=='q' && s[S-1-i]!='p') return NG;
    }
    return OK;
}

int main()
{
    string s;
    cin >>s;
    cout << solve(s) << endl;
    return 0;
}


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

int main() {
    const int inf = 1e+9;
    int n, m;
    cin >> n >> m;

    int a[1000], b[1000], c[1000], dist[100][100];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i==j) dist[i][j] = 0;
            else dist[i][j] = inf;
        }
    }

    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
        dist[a[i]][b[i]] = c[i];
        dist[b[i]][a[i]] = c[i];
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = m;
    for (int i = 0; i < m; i++) {
        bool shortest = false;
        for (int j = 0; j < n; j++) {
            if (dist[j][a[i]] + c[i] == dist[j][b[i]]) {
                shortest = true;
            }
        }
        if (shortest) {
            ans--;
        }
    }

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

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

ll ans;
ll d[100010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",d+i);
	rep(i,0,n)if(d[i]>=3){
		ans+=(d[i]-1)/2;
		d[i]-=(d[i]-1)/2*2;
	}
	rep(i,0,n){
		if(d[i]==2){
			ans++;
		}else if(d[i]&&d[i+1]){
			ans++;
			d[i+1]--;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int N = sc.nextInt();
            int ans = 0;

            for (int i = 0; i < N; i++) {
                int s = sc.nextInt();
                int f = sc.nextInt();

                if ( a < f && s < b ) {
                    ans = 1;
                }
            }
            System.out.println(ans);
        }
    }
}



Measured memory_bytes: 26488
n, d = gets.split.map(&:to_i)
points = []
n.times do
  points << gets.split.map(&:to_i)
end

count = 0
points.each_with_index do |y, i|
  points.each_with_index do |z, j|
    next if i >= j
    temp = 0
    d.times do |k|
      temp += (y[k] - z[k])**2
    end
    distance = temp ** (1/2.to_f)
    count += 1 if distance.to_i ** 2 == temp
  end
end
puts count


Measured memory_bytes: 1916
#include<iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[100000]={0};
    int tmp;
    for(int i(0);i<n;i++){
        cin>>tmp;
        a[tmp-1]++;
    }
    bool flag(true);
    for(int i(0);i<n;i++){
        if(n%2 == 0){
            if(i%2 == 0){
                if(a[i] != 2)flag = false;
            }
            else{
                if(a[i] != 0)flag = false;
            }
        }
        else{
            if(i%2 == 1){
                if(a[i] != 2)flag = false;
            }
            else{
                if(a[i] != 0)flag = false;
            }
        }
    }
    if(flag){
        int num = n/2;
        int ans(1);
        for(int i(0);i<num;i++){
            ans *= 2;
            if(ans >= 1000000007)ans %= 1000000007;
        }
        cout<<ans<<endl;
    }
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
int main()
{
	int l,r,a;
	cin>>a>>l>>r;
	int t=l/a*a;
	if(l<=t&&t<=r||l<=(t+a)&&(t+a)<=r)cout<<"OK";
	else cout<<"NG";
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main()
{
	int a, b;
	while(scanf("%d %d", &a, &b)!=EOF)
	{
		if((a + b) % 2 == 0)
		{
			printf("%d\n", (a + b) / 2);
		}
		else
		{
			printf("%d\n", (a + b) / 2 + 1);
		}
	}
	return 0;
}

Measured memory_bytes: 128
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897



int main() {

    get2(n,k);
    fill_nums(A,n);

    if(k>=n) {
        printf("0\n");
        return 0;
    }

    vector<vector<ll>> dp(n-k+1, vector<ll>(n+1,INF));
    dp[0][0] = 0;

    for(int i=1;i<=n-k;i++) {
        for(int j=1;j<=n;j++) {
            for(int k=0;k<j;k++) {
                dp[i][j] = min(dp[i][j], dp[i-1][k] + max((ll)0, (A[j-1]-(k-1>=0 ? A[k-1] : 0))));
            }
        }
    }

    ll res = INF;
    for(int j=1;j<=n;j++)
        res = min(res, dp[n-k][j]);
    printf("%lld\n", res);

    return 0;  
}

Measured memory_bytes: 1024