akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoderB
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        decimal ans = 0;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                ans += 1 / decimal.Parse(words[i]);
            }
        }
        ans = 1 / ans;

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int n; cin >> n;
    int ans = 0;
    for(int i = n; i <= 999; i++){
        if(i/100 == (i%100)/10 && (i%100)/10 == (i%100)%10){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  cin >> s;

  ll n = s.size();
  vll ans(n + 1);
  rep(i, n) if (s[i] == '<') ans[i + 1] = ans[i] + 1;
  rep(i, n) if (s[n - 1 - i] == '>') chmax(ans[n - i - 1], ans[n - i] + 1);

  //ll ansv = 0;
  //rep(i, n + 1) ansv += ans[i];
  cout << accumulate(ans.begin(), ans.end(), 0LL) << endl;

  return 0;
}


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

int main()
{
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int dx = x2 - x1, dy = y2 - y1;

	cout << x2 - dy << ' ' << y2 + dx << ' ' << x1 - dy << ' ' << y1 + dx << endl;

	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N, K;
  cin >> N >> K;
  cout << setprecision(32)<< K * pow(K-1, N-1) << endl;
  return 0;
}


Measured memory_bytes: 256
// AOJ 2152 Restrictive Filesystem
// 2018.2.24 bal4u

#include <stdio.h>
#include <string.h>

#define INF 1000000010

typedef struct { int id, f, e, nxt; } T;
T tbl[5000]; int sz;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, i, cmd, id, sno, from, end;

	while (n = in()) {
		tbl[0].id = -1, tbl[0].f = 0, tbl[0].e = INF, tbl[0].nxt = 0;
		sz = 1;

		while (n--) {
			cmd = getchar_unlocked(), getchar_unlocked();
			if (cmd == 'W') {
				id = in(), sno = in();
				for (i = 0; sno > 0; i = tbl[i].nxt) {
					if (tbl[i].id >= 0) continue;
					from = tbl[i].f, end = tbl[i].e;
					if (end-from+1 <= sno) {
						tbl[i].id = id;
						sno -= end-from+1;
					} else {
						tbl[i].id = id;
						tbl[i].f = from, tbl[i].e = from+sno-1;
						tbl[sz].nxt = tbl[i].nxt;
						tbl[i].nxt = sz;
						i = sz++;
						tbl[i].id = -1, tbl[i].f = from+sno, tbl[i].e = end;
						break;
					}
				}
			} else if (cmd == 'R') {
				sno = in();
				i = 0; while (sno < tbl[i].f || sno > tbl[i].e) i = tbl[i].nxt;
				printf("%d\n", tbl[i].id);
			} else {		// cmd == 'D'
				id = in();
				for (i = 0; tbl[i].nxt != 0; i = tbl[i].nxt)
					if (tbl[i].id == id) tbl[i].id = -1;
			}
		}
		putchar('\n');
	}
 	return 0;
}


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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N;cin>>N;
    int count=0;
    for(int i=1;i<N;i++){
        count+= (N-1)/i;
    }
    cout<<count<<endl;
    


    return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<char> s;
    for (size_t i = 0; i < n; i++)
    {
        char tmp;
        cin >> tmp;
        s.insert(tmp);
    }
    if (s.size() == 3)
    {
        cout << "Three" << endl;
    }
    else
    {
        cout << "Four" << endl;
    }

}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int a, b;
  cin >> a >> b;
  a--; b--;
  int k = 50;
  vcc ans(2*k, vc(2*k));
  rep(i,k)rep(j,2*k) ans[i][j] = '#';
  for(int i = k; i < 2*k; i++)rep(j,2*k) ans[i][j] = '.';
  for(int i = 0; i < k-1; i += 2) {
    for(int j = 0; j < 2*k; j += 2) {
      if(a > 0) {
        ans[i][j] = '.';
        a--;
      }
    }
    if(a < 0) break;
  }
  for(int i = k+1; i < k*2; i += 2) {
    for(int j = 0; j < 2*k; j += 2) {
      if(b > 0) {
        ans[i][j] = '#';
        b--;
      }
    }
    if(b < 0) break;
  }
  cout << 100 << ' ' << 100 << endl;
  rep(i,k*2) {
    rep(j,k*2) {
      cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
<?php
  
$S = trim(fgets(STDIN));
$N = strlen($S);
$answer = 'Yes';
 
$left = substr($S, 0, ($N - 1) / 2);
$right = substr($S, (($N + 3) / 2) - 1, ($N - 1) / 2);
 
if($left !== $right) {
  $answer = 'No';
}
 
if ($left !== strrev($left)) {
  $answer = 'No';
}
 
if ($right !== strrev($right)) {
  $answer = 'No';
}
 
echo $answer;

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    bool a[1000005];
    for(int i=0;i<=1000004;i++)
    {
        a[i]=true;
    }
    int in;
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>in;
        m[in]++;
    }
    for(auto j:m)
    {
        if(j.second>1) 
        {
            a[j.first]=false;
        }
        in=j.first;
        for(int j=2*in;j<=1000004;j+=in)
        {
            a[j]=false;
        }
    }
    int ans=0;
    for(auto j:m)
    {
        if(a[j.first]) ans++;
    }
    cout<<ans;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  cout << a.at(N-1)-a.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,k;
    string s;
    cin >> n >> k >> s;
    if(s.at(k-1)=='A'){
    s.at(k-1)='a';
    }
  else if(s.at(k-1)=='B'){
    s.at(k-1)='b';
  }
  else if(s.at(k-1)=='C'){
    s.at(k-1)='c';
  }
  cout<<s<<endl;  
}

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

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

int main() {
  int a, b;
  while(cin >> a >> b) {
    cout << gcd(a,b) << endl;
  }
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) {
        if(i < k) continue;
        else {
            cout << ((a[i] > a[i-k])?"Yes":"No") << '\n';
        }
    }
}


Measured memory_bytes: 4396
S = input()
import sys

if S == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    sys.exit(0)

atoz = list(map(chr,range(97,123)))
charmap = dict()
for c in atoz:
    charmap[c] = 0

for s in S:
    charmap[s] += 1

flag = 0
for c in atoz:
    if charmap[c] == 0:
        flag = 1
        S = S + c
        break

if flag == 0:
    index = 0
    for i in range(len(S)-1):
        if S[-1-i] > S[-2-i]:
            index = -2-i
            break
    tmp = sorted(list(S[index+1:]))
    for t in tmp:
        if t > S[index]:
            S = S[:index]+t
            break

print(S)


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

ll f(ll n , ll b){
  ll res=0;
  while(n){
    res+=(n%b);
    n/=b;
  }
  return res;
}

int main(){
  ll n,s;
  cin>>n>>s;
  if(n<s)return cout<<"-1",0;
  if(n==s)return cout<<n+1,0;
  vector<ll> d;
  for(ll i=1;i*i<=n-s;i++)
  {
    if((n-s)%i==0){
      d.push_back(i+1);
      d.push_back((n-s)/i +1);
    }
  }
  sort(d.begin(),d.end());
  for(int i=0;i<d.size();i++)
  {
    if(f(n,d[i])==s)return cout<<d[i],0;
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[8][8] = {{}};
int row[8] = {};
int l[15] = {};
int r[15] = {};
int s[8] = {};

void print(){

  for(int i = 0;i < 8;i++){
    for(int j = 0;j < 8;j++){
      if(a[i][j] == 1){
        if(row[i] != j) {
          return;
        }
      }
    }
  }
  for(int i = 0;i < 8;i++){
    for(int j = 0;j < 8;j++){
      if(row[i] == j) cout << "Q";
      else cout << ".";
    }
    cout << endl;
  }

}

void backtrack(int i){

  if(i == 8){
    print();
    return;
  }

  for(int j = 0;j < 8;j++){
    if(s[j] == 1 || l[i + j] == 1 || r[i - j + 7] == 1) continue;

    row[i] = j;
    l[i + j] = r[i - j + 7] = s[j] = 1;

    backtrack(i + 1);

    row[i] = s[j] = l[i + j] = r[i - j + 7] = 0;

  }

}


int main(){

  int r,c,k;

  cin >> k;

  for(int i = 0;i < k;i++){
    cin >> r >> c;
    a[r][c] = 1;
  }
  backtrack(0);
}

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9+7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int L;
	cin >> L;
	LD a = (LD)L / 3;
	cout << setprecision(12) << a * a * a << "\n";
	return 0;
}


Measured memory_bytes: 3260
#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)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;

	int k = (A + B) / 2;

	if (abs(A - k) == abs(B - k)) cout << k << endl;
	else cout << "IMPOSSIBLE" << endl;
}







Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp {
    char name[100];
    int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue (P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue() {
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b) {
    return a < b ? a : b;
}
int main()
{
    int elaps = 0, c;
    int i, q;

    P u;
    scanf("%d %d", &n, &q);

    for ( i = 1; i <= n; i++ ) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1;
    tail = n+1;

    while ( head != tail ) {
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;

        if ( u.t > 0)
            enqueue(u);
        else
            printf("%s %d\n", u.name, elaps);
    }

    return 0;
}



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

int main(){
    long long X;
    cin >> X;
    long long ans = 100;
    long long count = 1;
    for(int i = 1;;i++){
        ans *= 1.01;
        if(ans >= X){
            count = i;
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> P(N, 0);
	for (int i = 0; i < N; i++)
	{
		cin >> P[i];
		P[i]--;
	}

	int result = 0;
	for (int i = 0; i < N - 1; i++)
	{
		if (P[i] == i && P[i + 1] == i + 1)
		{
			swap(P[i], P[i + 1]);
			result++;
		}
	}

	for (int i = 0; i < N - 1; i++)
	{
		if (P[i] == i)
		{
			swap(P[i], P[i + 1]);
			result++;
		}
	}

	if (P[N - 1] == N - 1)
	{
		result++;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int X = in.nextInt();
        int Y = in.nextInt();

        if (Y % 2 == 1) {
            out.println("No");
        } else {
            if (X * 2 <= Y && Y <= X * 4) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 32800
#include <bits/stdc++.h>
#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++)
using namespace std;
using P = pair<int, int>; 
using ll = long long;
using M = map<int, int>;

int main()
{
  ll a, b, x;
  cin >> a >> b >> x;
  b = b / x + 1;
  if(a != 0) a = (a - 1) / x + 1;
  cout << b - a << endl;

  return 0;
}

Measured memory_bytes: 3632
n, m = map(int, input().split())
a = [0for i in range(n)]

for i in range(n):
  a[i] = list(map(int, input().split()))

b = [0 for i in range(m)]
for i in range(m):
  b[i] = int(input())

for i in range(n):
  c = 0

  for j in range(m):
    c += a[i][j]*b[j]

  print(c)



Measured memory_bytes: 6012
#include<bits/stdc++.h>
#define ll long long
#define ii pair<ll,int>
using namespace std;

struct DSU {
    vector <int> P, R;
    DSU (int n) {
        P.resize(n), R.resize(n);
        for (int i = 0; i < n; i++) {
            P[i] = i, R[i] = 1;
        }
    }

    int find(int x) {return x == P[x] ? x : P[x] = find(P[x]);}

    bool unionS (int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;

        if (R[y] > R[x]) swap(x, y);
        R[x] += R[y];
        P[y] = x;
        return true;
    }
};
struct edge {
    int u, v;
    ll w;
    bool operator<(const edge & E) const {
        return w < E.w;
    }
};

int main(){
    int a,b;cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for (int i = 0; i < n; i++) {
			int[] lst = new int[3];
			for(int j = 0;j < 3; j++) {
				lst[j] = (int)Math.pow(s.nextInt(), 2);
			}
			Arrays.sort(lst);
			System.out.println(lst[0] + lst[1] == lst[2]?"YES":"NO");
		}
	}
}



Measured memory_bytes: 33604
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =1299709;
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N+1];//is_prime[i]がtrueならiは素数

//n以下の素数の数を返す
int sieve(int n){
	int p = 0;
	for(int i = 0;i <=n;i++){
		is_prime[i] =true;
	}
	is_prime[0] = false;
	is_prime[1] = false;
	for(int i = 2;i <=n;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i;j <=n;j +=i){
				is_prime[j] =false;
			}
		}
	}
	return p;
}
int main(){
	sieve(1299709);
	int N;
	int a1;
	int a2;
	while(cin>>N,N){
		a1 =N;
		a2 =N;
		for(int i = N;i >=0;i--){
			if(is_prime[i]){
				a1 =i;
				break;
			}
		}
		for(int i = N;i <=1299709;i++){
			if(is_prime[i]){
				a2 =i;
				break;
			}
		}
		cout <<a2-a1<<endl;
	}
	return 0;
}

Measured memory_bytes: 2820
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] point=new int[n];
		for(int i=0;i<n*(n-1)/2;i++){
			int s=sc.nextInt()-1,t=sc.nextInt()-1,sp=sc.nextInt(),tp=sc.nextInt();
			if(sp>tp)point[s]+=3;
			else if(tp>sp)point[t]+=3;
			else{
				point[s]++;
				point[t]++;
			}
		}
		int[] team=new int[n];
		for(int i=0;i<n;i++)team[i]=point[i];
		for(int i=0;i<point.length-1;i++){
            for(int j=0;j<point.length-i-1;j++){
            	if(point[j]<point[j+1]){
            		int a=point[j];
            		point[j]=point[j+1];
            		point[j+1]=a;
            	}
            }
        }
		int[] rnk=new int[n];
		int t=1;
		rnk[0]=1;
		for(int i=1;i<n;i++){	
			if(point[i]!=point[i-1])t=i+1;
			rnk[i]=t;			
		}
		int no=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(team[i]==point[j])no=rnk[j];
			}
			System.out.println(no);
		}
	}
}

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

using namespace std;
const int _max = 1000;
typedef long long ll;
int dir[4][2] = {{1,  0},{-1, 0},{0,  1},{0,  -1}};
struct Node {
    int x;
    int y;
};

int main() {
/*    int _;
    _=5;*/

    int one,two;
    cin>>one>>two;
    int liang=(two-4*one)/2*(-1);
    int si=(two-2*one)/2;
    int jiao=2*liang+si*4;
    if(liang<0||si<0||jiao<=0){
        cout<<"No"<<endl;
        return 0;
    }
    if(jiao==two){
        cout<<"Yes"<<endl;

    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3648
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-03-06(Fri)
   note
**********************************************************************/

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  }
  else if (a <= 12) {
    cout << (b / 2) << endl;
  }
  else {
    cout << b << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[]$){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),x=sc.nextInt(),y=sc.nextInt();
		System.out.println(Math.min(a*x+b*y, Math.min(c*2*Math.max(x,y),c*2*Math.min(x,y)+(x>y?a*(x-y):b*(y-x) ))));
	}
}

Measured memory_bytes: 23252
#include<iostream>
using namespace std;
#include<vector>
struct SCC{
	int n;
	vector<int>comp,order;
	vector<bool>used;
	vector<vector<int> >G,RG;
	SCC(int _n=0):n(_n),comp(_n,-1),used(_n,false),G(_n),RG(_n){}
	void add_edge(int from,int to)
	{
		G[from].push_back(to);
		RG[to].push_back(from);
	}
	void copy(vector<vector<int> >&H)
	{
		for(int i=0;i<H.size();i++)
		{
			for(int j=0;j<H[i].size();j++)
			{
				G[i].push_back(H[i][j]);
				RG[H[i][j]].push_back(i);
			}
		}
	}
	int operator[](int u){return comp[u];}
	void dfs(int u)
	{
		used[u]=true;
		for(int i=0;i<G[u].size();i++)if(!used[G[u][i]])dfs(G[u][i]);
		order.push_back(u);
	}
	void rdfs(int u,int cnt)
	{
		comp[u]=cnt;
		for(int i=0;i<RG[u].size();i++)if(comp[RG[u][i]]==-1)rdfs(RG[u][i],cnt);
	}
	int build()
	{
		for(int i=0;i<n;i++)if(!used[i])dfs(i);
		int cnt=0;
		for(int i=n-1;i>=0;i--)if(comp[order[i]]==-1)rdfs(order[i],cnt++);
		return cnt;
	}
	int build(vector<vector<int> >&H)
	{
		int ret=build();
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<G[i].size();j++)
			{
				if(comp[i]!=comp[G[i][j]])
					H[comp[i]].push_back(comp[G[i][j]]);
			}
		}
		return ret;
	}
};
main()
{
	int n,m;cin>>n>>m;
	SCC scc(n);
	vector<vector<int> >G(n);
	for(int i=0;i<m;i++)
	{
		int a,b;cin>>a>>b;
		G[a].push_back(b);
	}
	scc.copy(G);
	scc.build();
	int q;cin>>q;
	for(int i=0;i<q;i++)
	{
		int a,b;cin>>a>>b;
		cout<<(scc[a]==scc[b])<<endl;
	}
}



Measured memory_bytes: 4840
//https://atcoder.jp/contests/dp/tasks/dp_s
//S - Digit Sum
//typical_dpc_e.cppと同じか...
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
constexpr ll MOD=1e9+7;
int main() {
    string N; cin>>N;
    ll D; cin>>D;

    //[決めた桁][未満フラグ,未満のとき1][]
    const ll modd_max=D+1;
    vector<vector<vector<ll>>> dp(N.size()+1, vector<vector<ll>>(2,vector<ll>(modd_max)));

    dp[0][0][0]=1;
    FOR(k,0,N.size()){
        ll digit = N.at(k)-'0';
        FOR(f,0,modd_max){
            for(ll d=0;d<=9;++d){ //未満フラグ1
                ll mod_d = (f+d)%D;
                dp[k+1][1][mod_d] += dp[k][1][f];
                dp[k+1][1][mod_d] %= MOD;
            }
            for(ll d=0;d<=digit;++d){ //未満フラグ0
                ll mod_d = (f+d)%D;
                dp[k+1][(d<digit)][mod_d] += dp[k][0][f]; //未満フラグ0は桁数があっているとき
                dp[k+1][(d<digit)][mod_d] %= MOD;
            }
        }
    }
    ll ans = dp[N.size()][0][0]+dp[N.size()][1][0];
    ans %= MOD;
    ans -= 1; //0の分引く
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 17024
import sys
sys.setrecursionlimit(1000000)

n, m = map(int, input().split())
adlist = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(lambda x:int(x)-1, input().split())
  adlist[a] += [b]
  adlist[b] += [a]

ans = 0
used = [0] * n 
used[0] = 1
def dfs(u):
  global ans
  if sum(used) == n:
    ans += 1
    return 
  for v in adlist[u]:
    if used[v] == 0:
      used[v] = 1
      dfs(v)
      used[v] = 0

  return 

dfs(0)
print(ans)


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, m;
  cin >> n >> m;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b; cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  rep(i, n) {
    bool ok = true;
    for(auto next : g[i]) {
      if(h[next] >= h[i]) ok = false;
    }
    if(ok) ++ans;
  }
  cout << ans << endl;
}

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

void chmin(int& a, int b){
    a = min(a, b);
}

int main(){
    string S;
    cin >> S;
    int N = S.size();
    
    vector<vector<int>> dp(N+2, vector<int>(27, N+1));
    for(int i=0; i<N; i++) dp[i][S[i]-'a'] = i+1;
    for(int i=N-1; i>=0; i--){
        for(int j=0; j<26; j++) chmin(dp[i][j+1], dp[dp[i][j]][j]);
        for(int j=0; j<26; j++) chmin(dp[i][j], dp[dp[i][26]][j]);
    }

    vector<vector<int>> doub(N+2, vector<int>(19, N+1));
    for(int i=0; i<N; i++) if(dp[i][26] != N+1) doub[i][0] = dp[i][26];
    for(int k=0; k<18; k++) for(int i=0; i<N; i++) doub[i][k+1] = doub[doub[i][k]][k];

    int Q;
    cin >> Q;
    while(Q--){
        int l, r;
        cin >> l >> r;
        l--;
        for(int k=18; k>=0; k--) if(doub[l][k] <= r) l = doub[l][k];
        cout << (l==r ? "Yes" : "No") << endl;
    }

    return 0;
}


Measured memory_bytes: 134020
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,sum_a=0,p_tmp,n_tmp;
  cin >> n>>k;
  vector<ll> vals;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum_a+=a[i];
  }
  for(ll i=1;i*i<=sum_a;i++){
    if(sum_a%i==0){
      vals.push_back(i);
      if(sum_a!=i){
        vals.push_back(sum_a/i);
      }
    }
  }
  sort(vals.begin(),vals.end(),greater<ll>());
  for(auto i:vals){
    if(i==1){
      cout << 1<<endl;
      return 0;
    }
    vector<ll> divs;
    ll sum0[n],tn,en;
    fill(sum0,sum0+n,0);
    for(int j=0;j<n;j++){
      if(a[j]%i!=0){
        divs.push_back(a[j]%i);
      }
    }
    sort(divs.begin(),divs.end());
    tn = divs.size();
    sum0[0]=divs[0];
    sum0[0]=i-divs[0];
    for(int j=1;j<tn;j++){
      sum0[j]+=(i-divs[j])+sum0[j-1];
    }
    en = sum0[tn-1];
    if(en==0){
      cout <<i<<endl;
      return 0;
    }
    p_tmp = en;
    n_tmp = 0;
    for(int j=0;j<tn;j++){
      n_tmp += divs[j];
      p_tmp -= (i-divs[j]);
//      cout << i <<" "<< j << " "<<n_tmp<<" "<<p_tmp<<endl;
      if(p_tmp == n_tmp&&p_tmp<=k){
        cout << i << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
import math

#a, b, h, m = 3, 4, 10, 40
a, b, h, m = map(int, input().split())

pi = math.pi

theta1 = -2*(h/12+m/60/12)*pi + pi/2
theta2 = -2*m/60*pi + pi/2

x1 = a * math.cos(theta1)
y1 = a * math.sin(theta1)

x2 = b * math.cos(theta2)
y2 = b * math.sin(theta2)

d = ((x1-x2)**2 + (y1-y2)**2)**0.5

print(d)


Measured memory_bytes: 9464
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int H, W; cin >> H >> W;

    char A[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }

    bool row[H] = {false};
    for (int i = 0; i < H; i++) {
        bool flg = true;
        for (int j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                flg = false;
            }
        }
        if (flg) {
            row[i] = true;
        }
    }

    bool col[W] = {false};
    for (int i = 0; i < W; i++) {
        bool flg = true;
        for (int j = 0; j < H; j++) {
            if (A[j][i] == '#') {
                flg = false;
            }
        }
        if (flg) {
            col[i] = true;
        }
    }

    for (int i = 0; i < H; i++) {
        if (!row[i]) {
            for (int j = 0; j < W; j++) {
                if (!col[j]) {
                    cout << A[i][j];
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 10000

int main() {
  int x[SIZE], i, j;

  i = 0;
  while (i++ <= SIZE) {
    scanf("%d", &x[i]);
    if (x[i] == 0)
      break;
  }
  for (j = 1; j < i; j++)
    printf("Case %d: %d\n", j, x[j]);

  return 0;
}

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

int main(int argc, char const *argv[])
{
	int i, j;
	char str[8][9];
	char temp[100];

	/* データ入力 */
	for(i = 0 ;i < 8; ++i) {
		// 一度tempに入力
		scanf("%s", temp);
		for(j = 0; j < 8; ++j) {
			// tempを一文字ずつ探索,\0か\nならループ脱出
			if((temp[j]=='\0')||(temp[j]=='\n')) break;
			// 配列strにtempのj文字目を格納
			str[i][j]=temp[j];
		}
		// 8文字に満たない場合,入力をもう一度行なう
		if(j<8){
			i--;
		}
	}
	/* データ入力終了 */

	printf("90\n");
	for(i = 0; i < 8; ++i) {
		for(j = 0; j < 8; ++j)
			printf("%c", str[7 - j][i]);
		printf("\n");
	}

	printf("180\n");
	for(i = 0; i < 8; ++i) {
		for(j = 0; j < 8; ++j)
			printf("%c", str[7 - i][7 - j]);
		printf("\n");
	}

	printf("270\n");
	for(i = 0; i < 8; ++i) {
		for(j = 0; j < 8; ++j)
			printf("%c", str[j][7 - i]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main()
{
    long int n,a[100005],b[100005];

    scanf("%ld",&n);
   long  int i;
    for(i=0;i<n+1;i++)
        scanf("%ld",&a[i]);

    for(i=0;i<n;i++)
        scanf("%ld",&b[i]);

    long int ans=0;

    for(i=0;i<n;i++)
    {
        if(a[i] >= b[i])
        {
            ans += b[i];
            continue;
        }
        else/*a[i] <= b[i] */
        {
            ans += a[i];
            b[i] -= a[i];

            if(a[i+1] >= b[i])
            {
                ans += b[i];
                a[i+1] -= b[i];
            }
            else
            {
                ans += a[i+1];
                a[i+1] -= b[i];

                if(a[i+1] < 0)
                a[i+1] = 0;
            }
            
        }
    }

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

    return 0;
}

Measured memory_bytes: 1664
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	static final int INF = (int)1e9 + 7;
	int N,Ma,Mb;
	int[] A,B,C;

	public void solve() {
		N = nextInt();
		Ma = nextInt();
		Mb = nextInt();

		A = new int[N];
		B = new int[N];
		C = new int[N];

		for(int i = 0;i < N;i++){
			A[i] = nextInt();
			B[i] = nextInt();
			C[i] = nextInt();
		}

		int[][][] dp = new int[N+1][444][444];
		for(int i = 0;i < N + 1;i++){
			for(int j = 0;j < 444;j++){
				for(int k = 0;k < 444;k++){
					dp[i][j][k] = INF;
				}
			}
		}

		dp[0][0][0] = 0;
		for(int i = 0;i < N;i++){
			for(int j = 0;j < 444 - A[i];j++){
				for(int k = 0;k < 444 - B[i];k++){
					int a = j + A[i];
					int b = k + B[i];
					dp[i+1][j][k] = Math.min(dp[i+1][j][k], dp[i][j][k]);
					dp[i+1][a][b] = Math.min(dp[i+1][a][b],dp[i][j][k]+C[i]);
				}
			}
		}

		int ans = INF;
		int max = Math.max(Ma,Mb);

		for(int i = 1;i * max < 444;i++){
			ans = Math.min(ans,dp[N][i*Ma][i*Mb]);
		}
		if(ans == INF){
			out.println(-1);
		}else{
			out.println(ans);
		}
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 63136
N = int(input())
l = []
A = []
for i in range(N):
  A.append(int(input()))
  l.append([])
  for j in range(A[-1]):
    x, y = map(int, input().split())
    x -= 1
    l[-1].append([x, y])

mem = []
for i in range(2 ** N):
  mem.append(("{:0=15}".format(int(bin(i)[2:])))[15-N:])

ans = 0
for m in mem:
  f = True
  for i in range(N):
    if m[i] == "1":
      for li in l[i]:
        if str(li[1]) != m[li[0]]:
          f = False
          break
  if f:
    ans = max(ans, m.count("1"))
print(ans)

Measured memory_bytes: 5480
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

string s, t;
int a, b;
string u;
int main() {
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s) {
		--a;
	}
	else {
		--b;
	}
	cout << a << ' ' << b << endl;
	return 0;
}

Measured memory_bytes: 256
import sys


def resolve(in_):
    x = int(in_.read())
    c = 9
    if 400 <= x <= 599:
        c = 8
    elif 600 <= x <= 799:
        c = 7
    elif 800 <= x <= 999:
        c = 6
    elif 1000 <= x <= 1199:
        c = 5
    elif 1200 <= x <= 1399:
        c = 4
    elif 1400 <= x <= 1599:
        c = 3
    elif 1600 <= x <= 1799:
        c = 2
    elif 1800 <= x <= 1999:
        c = 1
    return c


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

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

int main(){
    string s;
    cin >> s;
    int a,b;
    a=(s[0]-'0')*10+s[1]-'0';
    b=(s[2]-'0')*10+s[3]-'0';

    bool yymm = (b<=12)&&(b>0);    //YYMMになる必要条件
    bool mmyy = (a<=12)&&(a>0);    //MMYYになる必要条件

    if(yymm && mmyy) {
        cout << "AMBIGUOUS" << endl;
    }else if(yymm) {
        cout << "YYMM" << endl;
    }else if(mmyy) {
        cout << "MMYY" << endl;
    }else cout << "NA" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    while (true)
    {
        c -= b;
        if (c <= 0)
            break;
        a -= d;
        if (a <= 0)
            break;
    }
    if (a <= 0)
    {
        puts("No");
    }
    else
    {
        puts("Yes");
    }
}

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

#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 ALL(v) v.begin(), v.end()


const int MOD = 1000000007;

int64_t modpow(int64_t x, int64_t n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int64_t comb(int64_t n, int64_t k) {
    int64_t x = 1;
    for(int i=n-k+1; i<=n; i++) {
        x = x*i%MOD;
    }

    int64_t y = 1;
    for(int i=1; i<=k; i++) {
        y = y*i%MOD;
    }
    y = modpow(y, MOD-2);

    return x*y%MOD;
}

int main() {
  //std::cout << std::fixed << std::setprecision(20);

  int64_t n, a, b;
  cin >> n >> a >> b;
 

  int64_t ans = 0;
  int64_t all = modpow(2,n) - 1;
  ans = all - comb(n,a) - comb(n,b);
  while(ans < 0) ans += MOD;


  
  cout << ans << endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt(), m = in.nextInt() , x = in.nextInt();
        int r[] = new int[n+1];
        int c[] = new int[m+1];
        long maxr = 0, maxc = 0;int mr = 0, mc = 0;
        HashSet<Long> set = new HashSet<>(); 
        for(int i=0;i<x;i++) {
        	int a = in.nextInt(), b = in.nextInt();
        	set.add(a*1000000000L+b);
        	r[a]++;c[b]++;
        	maxr = Math.max(maxr, r[a]);
        	maxc = Math.max(maxc, c[b]);
        }
        long pans = maxr + maxc;
        ArrayList<Integer> rr = new ArrayList<>();
        ArrayList<Integer> cc = new ArrayList<>();
        for(int i=1;i<=n;i++) {
        	if(r[i]==maxr)
        		rr.add(i);
        }
        for(int i=1;i<=m;i++) {
        	if(c[i]==maxc)
        		cc.add(i);
        }
        boolean verdict = Boolean.FALSE;
        for(int i : rr) {
        	for(int j : cc) {
        		if(!set.contains(i*1000000000L+j)) {
        			verdict = Boolean.TRUE;break;
        		}
        	}
        }
        if(!verdict) pans--;
        out.println(pans);
        out.flush();
	}
	
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int a[] = new int[n];
			for(int i=0;i<n;i++) a[i] = nextInt();
			return a;
		}
		
		long[] readArray(int n,long x) {
			long a[] = new long[n];
			for(int i=0;i<n;i++) a[i] = nextLong();
			return a;
		}
		
	}
}











Measured memory_bytes: 83116
s = input()
n = len(s)
for k in range(1,n):
    if s[k-1] == s[k]:
        print(k,k+1)
        exit(0)
if n >= 3:
    for k in range(1,n-1):
        if s[k-1] == s[k+1]:
            print(k,k+2)
            exit(0)
print(-1,-1)


Measured memory_bytes: 39536
from collections import Counter

n, x, y = list(map(int, input().split()))
counter = Counter()

for i in range(1, n):
    for j in range(i+1, n+1):
        k = min(j - i, abs(i-x) + abs(j-y) + 1)
        counter[k] += 1

for cnt in range(1, n):
    print(counter[cnt])


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

int main() {
    int N;
    cin >> N;
    double sum = 0;
    for(int i=0; i<N; ++i) {
        int a;
        cin >> a;
        sum += 1.0 / a;
    }
    cout << fixed << setprecision(6) << 1.0 / sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,sum=0;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    int xi;
    cin>>xi;
    sum+=(xi<abs(K-xi)? xi*2 : abs(K-xi)*2);
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
using namespace std;

bool is_target(char c){
  if(c == 'A' || c == 'C' || c == 'G' || c == 'T') return true;
  return false;

}

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


  int i = 0, len = 0, max_len = 0;
  while(i < s.size()){
    while(!is_target(s[i]) && i < s.size()) i++;

    int len = 0;
    while(is_target(s[i]) && i < s.size()) {
      len++;
      i++;
    }

    if(len > max_len){
      max_len = len;
    }
  }

  cout << max_len << endl;


  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,l,ans=0,Min=114514;
int Main(void){
    cin>>n>>l;
    For(i,1,n+1){
        ans+=l+i-1;
        if(abs(Min)>abs(l+i-1)) Min=l+i-1;
    }
    cout<<ans-Min<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m; cin >> n >> m;
  vector<int> num(n, 1);
  vector<bool> red(n, false);
  red[0] = true;
  REP(i,m){
    int x,y; cin >> x >> y;
    x--, y--;
    num[x]--;
    num[y]++;
    if(red[x]) red[y] = true;
    if(num[x]==0) red[x] = false;
  }
  int cnt = 0;
  REP(i,n) if(red[i]) cnt++;
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000000;
const long long MOD = 1000000007;

long long f(long long N){
  string s = to_string(N);
  long long ret = 0;
  for (int i = 0; i < s.length();i++){
    ret += s[i] - '0';
  }
  return ret;
}

int main()
{
  string a, b;
  cin >> a >> b;
  long long d = stoi(a + b);
  if (d == (long long)((long long)sqrt(d) * (long long)sqrt(d)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;

typedef long long ll;

ll MOD = 1000000007LL;

int n, m;
int a[2002], b[2002];

ll dp[2002][2002];

void solve() {
  memset(dp, 0, sizeof(dp));
  for (int j = 0; j <= m; j++) {
    dp[0][j] = 1;
  }

  for (int i = 0; i < n; i++) {
    ll sum = 0;
    for (int j = 0; j <= m; j++) {
      if (dp[i][j] == 0) {
        continue;
      }
      sum += dp[i][j];
      if (i < n) {
        dp[i + 1][j] += dp[i][j];
        dp[i + 1][j] %= MOD;
      }
      if (i < n && j < m && a[i] == b[j]) {
        dp[i + 1][j + 1] += sum - j;
        dp[i + 1][j + 1] %= MOD;
      }
    }
  }
  
  ll ans = 0;
  for (int j = 0; j <= m; j++) {
    ans += dp[n][j];
    ans %= MOD;
  }
  cout << ans - m << endl;
}

int main() {
  while (cin >> n >> m) {
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < m; i++) {
      cin >> b[i];
    }

    if (n < m) {
      swap(n, m);
      for (int i = 0; i < n; i++) {
        swap(a[i], b[i]);
      }
    }

    solve();

    /*
    if (n == 4 && m==4) {
      for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
          printf("%3lld", dp[i][j]);
        }
        cout<<endl;
      }
    }
    */

    
  }
}


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


_beki = [None] * 50
def ni_beki(n):
    return 2 ** n


# １-nのそれぞれの2進数で下からn桁目(n=0,1,...)の中の1の個数を返す関数
def f(x, n):
     a, b = divmod(x, ni_beki(n+1))
     p = ni_beki(n)
     return a * p + max(b - (p - 1), 0)

# 2進数での桁数を求める
def g(n):
    c = 0
    while True:
        if ni_beki(c) >= n + 1:
            return c
        c += 1

keta = g(B)
# 下から数えていく
d = []
for i in range(keta):
    p = f(B, i)
    q = f(A-1, i)
    d.append(p - q)

# 表示順に
d.reverse()

# 01文字に
e = list(map(lambda x: str(x % 2), d))

# 文字列に
e = ''.join(e)

if e == '':
    e = "0"
print(int(e, 2))

Measured memory_bytes: 3064