akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
Vi a;
ll bx[100010];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    a.resize(n);
    rep(i,100010)bx[i]=0;
    rep(i,n){
        cin>>a[i];
        bx[a[i]]++;
    }
    ll tmp = 0,ct=0;
    rep(i,100010){
        if(bx[i]>=1){
            tmp += bx[i]-1;
            ct++;
        }
    }
    ct -= (tmp)%2;
    print(ct);
    return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#define ll long long
ll read()
{
    ll tmp=0; char c=getchar(),f=1;
    while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
    while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
    return tmp*f;
}
using namespace std;
int a[20]={0};
int main()
{
	int i;
	int n=read();
	for(i=1;i<=4;i++)a[i]=n%10,n/=10;
	if(a[1]==a[2]&&a[2]==a[3]){
		printf("Yes\n"); return 0;
	}
	else if(a[2]==a[3]&&a[3]==a[4]){
		printf("Yes\n"); return 0;
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
while(h,w=gets.split.map(&:to_i))!=[0,0]
	h.times do |i|
		w.times do |j|
			if(i==0 || i==h-1 || j==0 || j==w-1)
				print "#"
			else print "."
			end
		end
		puts
	end
	puts
end

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



int main(void){
    int n,m,a,b,c;
    cin>>a>>b;
    if(a==b){
        printf("Draw\n");
    }else if(b==1){
        printf("Bob\n");
    }else if(a==1){
        printf("Alice\n");
    }else if(a<b){
        printf("Bob\n");
    }else{
        printf("Alice\n");
    }
    return 0;
}


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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X, N; cin >> X >> N;
  vector<bool> vec(102);
  for (ll i = 0; i < N; i++) {
    ll p; cin >> p;
    vec.at(p) = true;
  }
  ll i = X;
  for ( ; vec.at(i); i++);
  ll j = X;
  for ( ; vec.at(j); j--);
  if (X - j <= i - X) {
    cout << j << endl;
  }else {
    cout << i << endl;
  }

  return 0;
}



Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
    /*
    {
       Md: Saroar Zahan Sojib
       Green University of Bangladesh
       https://web.facebook.com/sojib.bdb
    }
   */

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s,p;
    cin>>s>>p;
    int q=p.size();
    string a;
    for(int i=0;i<q-1;i++)
    {
        a=a+p[i];
    }
    if(s==a)cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;


    return 0;

}



Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;


int main() {
	vector<char> c = {'R','L','U','D'};

	string input;
	cin >> input;
	bool flg = true;
	rep(i, input.size()) {
		if ((i+1) % 2 == 0) {
			if (input[i] != c[1] && input[i] != c[2] && input[i] != c[3]) {
				//cout << i <<input[i] << endl;
				flg = false;
			}
		}
		else {
			if (input[i] != c[0] && input[i] != c[2] && input[i] != c[3]) {
				//cout << i << input[i] << endl;
				flg = false;
			}
		}
	}


	if (flg) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))

def check(ar):
    b = True
    for i in range(len(ar)):
        if ar[i] % 2 != 0:
            b = False
            break
    return b

answer = 0

for i in range(1000000000):
    if check(a) == True:
        for j in range(len(a)):
            a[j] = int(a[j]/2)
        answer += 1
    else:
        break;

print(answer)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h)cin >> s[i];
    ll a[h][w], b[h][w], c[h][w], d[h][w];
    rep(i, h)rep(j, w){
        if(s[i][j] == '#')a[i][j] = -1;
        else if(i == 0)a[i][j] = 0;
        else a[i][j] = a[i-1][j] + 1;
        if(s[i][j] == '#')c[i][j] = -1;
        else if(j == 0)c[i][j] = 0;
        else c[i][j] = c[i][j-1] + 1;
    }
    for(int i = h-1; i >= 0; i--){
        for(int j = w-1; j >= 0; j--){
            if(s[i][j] == '#')b[i][j] = -1;
            else if(i == h-1)b[i][j] = 0;
            else b[i][j] = b[i+1][j] + 1;
            
            if(s[i][j] == '#')d[i][j] = -1;
            else if(j == w-1)d[i][j] = 0;
            else d[i][j] = d[i][j+1] + 1;
            
        }
    }
    ll ans = 1;
    rep(i, h)rep(j,w){
        ans = max(ans, 1+a[i][j]+b[i][j]+c[i][j]+d[i][j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 129408
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int b;
    cin >> b;
    if (b == 0){
      break;
    }
     b *= 2;
    vector<int> fact;
    for (int i = 1; i * i <= b; i++){
      if (b % i == 0){
        fact.push_back(i);
        if (i * i < b){
          fact.push_back(b / i);
        }
      }
    }
    int ans_a = 0;
    int ans_d = 0;
    for (int d : fact){
      if ((b / d - (d - 1)) % 2 == 0){
        int a = (b / d - (d - 1)) / 2;
        if (a >= 1 && d > ans_d){
          ans_a = a;
          ans_d = d;
        }
      }
    }
    cout << ans_a << ' ' << ans_d << endl;
  }
}


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

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

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	s = str(n)
	ans = 0
	for i in range(1,n+1):
		if(len(str(i))%2==1):
			ans+=1
	print(ans)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 64108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<int>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) { iota(par.begin(), par.end(), 0); }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return sz[find(x)]; }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

int n;

bool val(int x, int y) {
    if (x >= 0 && x < n && y >= 0 && y < n) return 1;
    return 0;
}

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

VVI v(505, VI(505, inf));
VVI used(505, VI(505, 1));

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    cin >> n;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            chmin(v[i][j], i);
            chmin(v[i][j], j);
            chmin(v[i][j], n - 1 - i);
            chmin(v[i][j], n - 1 - j);
        }
    }
    ll ans = 0;
    for (i = 0; i < n * n; i++) {
        int p;
        cin >> p;
        p--;
        int ox = p / n;
        int oy = p % n;
        ans += v[ox][oy];
        used[ox][oy] = 0;
        queue<P> q;
        q.push(P(ox, oy));
        while (q.size()) {
            int x = q.front().fi;
            int y = q.front().se;
            q.pop();
            for (j = 0; j < 4; j++) {
                int nx = x + dx[j];
                int ny = y + dy[j];
                if (!val(nx, ny)) continue;
                if (v[nx][ny] > v[x][y] + used[x][y]) {
                    q.push(P(nx, ny));
                    v[nx][ny] = v[x][y] + used[x][y];
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5696
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Main.run();
    }

    private static void run() {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        // カードリスト
        ArrayList<Integer> cardlist = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            cardlist.add(Integer.parseInt(sc.next()));
        }
        // カードリストを降順ソート
        Collections.sort(cardlist);
        Collections.reverse(cardlist);
        // アリスとボブの得点
        int alice = 0;
        int bob = 0;
        boolean aliceturn = true;
        // アリス→ボブの順で交互に高いカード引く
        for (int i = 0; i < n; i++) {
            if (aliceturn) {
                alice += cardlist.get(i);
                aliceturn = false;
            } else {
                bob += cardlist.get(i);
                aliceturn = true;
            }
        }
        out.println(alice - bob);
        out.close();
        sc.close();
    }

}


Measured memory_bytes: 35948
#include "bits/stdc++.h"
#include <set>

using namespace std;
#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 (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

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

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

int cnt2(int a)
{
	int count = 0;
	while (a % 2 == 0) {
		a /= 2;
		count++;
	}
	return count;
}

signed main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}

	int count = cnt2(a[0]);
	rep1(i, n) {
		if (count != cnt2(a[i])) {
			print(0);
			return 0;
		}
	}

	int ans = a[0]/2;
	rep1(i, n) {
		ans = lcm(ans, a[i] / 2);
	}
	
	if ((m / ans) % 2 == 0)print(m / (ans * 2));
	else print(m / (ans * 2)+1);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
    vector <ll> v(4);
    for(int i=0;i<4;i++)
        cin>>v[i];
        ll p=-(1e18);
    for(int i=0;i<=1;i++){
        for(int j=2;j<=3;j++){
            if(v[i]*v[j]>=p) p=v[i]*v[j];
           

        }
    }
    cout<<p<<endl;
}

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

using namespace std;

using ll = long long;

int main() {

    string s, t;
    cin >> s >> t;

    int a = s.size();
    int b = t.size();

    int dp[a + 1][b + 1] = {};

    for (int i = 1; i <= a; ++i) {
        for (int j = 1; j <= b; ++j) {
            if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
//    cout << dp[a][b];

    int i = a , j = b;
    string ans;
    while(i>0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans += s[i-1];
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
}



Measured memory_bytes: 35456
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;


int main() {
    ll k, n, ans2 = 0, min = 10000000000;
    
    cin>>k>>n;
    vector<ll> a(n);
    rep(i, n) cin>>a[i];
    
    for(int i = 0; i<n;i++){
        if(i==0) ans2 = a[n-1] - a[0];
        
        else{
            if(a[i-1]==0) ans2 = k - a[i];
            else ans2 = k - a[i] + a[i-1];
        }
        if(min>= ans2) min = ans2;
        
    }
    
    cout<<min<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


#define N 200004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}



ll n;
vector<ll>v[N];
ll dp[N];
ll kaz[N];
void dfs1(ll id,ll par){
    kaz[id]=1;
    dp[id]=1;
    for(auto x:v[id]){
        if(x==par)continue;
        dfs1(x,id);
        kaz[id]+=kaz[x];
        dp[id]=mod(dp[id]*kai2[kaz[x]]);
        dp[id]=mod(dp[id]*dp[x]);
    }
    dp[id]=mod(dp[id]*kai[kaz[id]-1]);
}
void dfs2(ll id,ll par,ll d_par){
    dp[id]=mod(dp[id]*d_par);
    ll kazpar=n-kaz[id];
    dp[id]=mod(dp[id]*kai[n-1]);
    dp[id]=mod(dp[id]*kai2[kazpar]);
    dp[id]=mod(dp[id]*kai2[kaz[id]-1]);
    
    for(auto x:v[id]){
        if(x==par)continue;
        ll res=dp[id];
        res=mod(res*kai[kaz[x]]);
        res=mod(res*kai2[n-1]);
        res=mod(res*kai[n-1-kaz[x]]);
        res=mod(res*bunbo(dp[x]));
        dfs2(x,id,res);
    }
}

int main(){fastio
    calc();
    cin>>n;
    rep(i,1,n-1){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs1(1,-1);
    //rep(i,1,n)cout<<dp[i]<<" ";cout<<endl;
    dfs2(1,-1,1);
    rep(i,1,n)cout<<dp[i]<<endl;
    
    return 0;
}


Measured memory_bytes: 20976
-- alphametic '5' ["123","4X6","X79"] == True
alphametic :: Char -> [String] -> Bool
alphametic x ts = a + b == c && satisfiesPrefixRule x ts
  where [a,b,c] = map (read . map (replaceX x)) ts

satisfiesPrefixRule x = and . map (prefixRule x)
  where prefixRule x t = not (x == '0' && head t == 'X' && t /= "X")

replaceX x t | t == 'X'  = x
             | otherwise = t

main = do
  s <- getContents
  putStr . unlines . map eachLine . lines $ s

eachLine l = showResult $ filter (`alphametic` ts) ['0'..'9']
  where
    ts = words . map opToSpace $ l

showResult [] = "NA"
showResult (x:xs) = [x]

opToSpace '+' = ' '
opToSpace '=' = ' '
opToSpace  c  =  c

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


public class Test
{	
    public static void Main()
	{
	    int[] hasira = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	    Array.Sort(hasira);
	    if(hasira[1] - hasira[0] == hasira[2] - hasira[1])
	    {
	        Console.WriteLine("YES");
	    }
	    else
	    {
	        Console.WriteLine("NO");
	    }
	    
	} 
}

Measured memory_bytes: 13396
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def tami(hl, wl):
  cnt = 0
  for h in range(H):
    if h in hl:
      continue
    for w in range(W):
      if w in wl:
        continue
      if grid[h][w] == "#":
        cnt += 1
  if cnt == K:
    return True
  else:
    return False

H,W,K = IL()
grid = [list(S()) for i in range(H)]

ans = 0
for i in range(1<<H):
  a = []
  for ii in range(H):
    if (i >> ii) & 1 == 1:
      a.append(ii)
  for j in range(1<<W):
    b = []
    for jj in range(W):
      if (j >> jj) & 1 == 1:
        b.append(jj)
    if tami(a, b):
      ans += 1
print(ans)

Measured memory_bytes: 73736
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define M 1000000007
#define sz(c) c.size()
#define fr first
#define sc second
#define pb push_back
#define sz(c) c.size()
#define ppb  pop_back
#define mp make_pair
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,n)   for( int i=a ; i<n ; i++)
#define what_is(x)  cout << #x << " is " << x << endl;
#define U 1000000007
#define N 100005
using namespace std;
signed main()
{
  ios_base::sync_with_stdio(false);
 
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int b[n];
  b[n-1]=0;
  int z=0;
  for(int i=n-2;i>=0;i--)
  {
    if(a[i]>=a[i+1]) z++;
    else z=0;
    b[i]=z;
  }
  int ma=0;
  rep(i,0,n) ma=max(b[i],ma);
  cout<<ma;


}

Measured memory_bytes: 1792
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto S = readln.chomp;
    if (S == "RRR") {
        writeln(3);
    } else if (S == "SRR" || S == "RRS") {
        writeln(2);
    } else if (S == "SSS") {
        writeln(0);
    } else {
        writeln(1);
    }
}

Measured memory_bytes: 2592
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include <numeric>
    #include <array>
     
    #define INF 1e10
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
    const ll MOD = INF + 7;
     
  template <typename T>
struct PrimeFact {
    vector<T> spf;
    PrimeFact(T N) { init(N); }
    void init(T N) { // 前処理。spf を求める
        spf.assign(N + 1, 0);
        for (T i = 0; i <= N; i++) spf[i] = i;
        for (T i = 2; i * i <= N; i++) {
            if (spf[i] == i) {
                for (T j = i * i; j <= N; j += i) {
                    if (spf[j] == j) {
                        spf[j] = i;
                    }
                }
            }
        }
    }
    map<T, T> get(T n) { // nの素因数分解を求める
        map<T, T> m;
        while (n != 1) {
            m[spf[n]]++;
            n /= spf[n];
        }
        return m;
    }
};
     
    int main(){
       ll n;
       cin >> n;

       PrimeFact pf(n);
       ll res = 0;
       REP(i, 1, n){
          ll facnum = 1;
          //pf.get(i);
          for(auto m : pf.get(i)){
             facnum *= (m.second + 1);
          }
         res += facnum * i;
       }
      cout << res << endl;
    }

Measured memory_bytes: 80964
N, D = gets.split.map(&:to_i)
list = N.times.map { gets.split.map(&:to_i) }
count = 0
N.times do |i|
  ((i + 1)..(N - 1)).each do |j|
    n = list[i].zip(list[j]).map do |(a, b)|
      (a - b) ** 2
    end.reduce(&:+)
    m = Math.sqrt(n)
    count += 1 if m == m.to_i
  end
end
puts count


Measured memory_bytes: 1788
N=int(input())
alist=list(map(int,input().split()))
#print(alist)

blist=[]
for i in range(N):
  blist.append(alist[i]-(i+1))

blist.sort()
#print(blist)
b=blist[N//2]
#print(b)
answer=0
for i in range(N):
  answer+=abs(alist[i]-(b+i+1))
  
print(answer)

Measured memory_bytes: 25200
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#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 = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int s;
  cin >> s;
  vector<int> v;
  v.push_back(s);
  set<int> st;
  st.insert(s);
  int ans=1;
  while(1){
    if(s%2==0){
      s/=2;
      v.push_back(s);
      st.insert(s);
      ans++;
    }else{
      s=3*s+1;
      v.push_back(s);
      st.insert(s);
      ans++;
    }
    if(st.size()!=v.size()){
      cout << ans << endl;
      return 0;
    }
  }
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, K;
int pos;

int main() {
	cin >> N >> K;

	rep(i, N) {
		int x;
		cin >> x;
		if (x == 1) {
			pos = i;
		}
	}

	int ret = N;

	for (int i = 0; i <= N - K; ++i) {
		if (i <= pos && i + K > pos) { //fs
			int t = 1 + (i + K - 2) / (K - 1) + (N - i - K + K - 2) / (K - 1);
			ret = min(ret, t);
		}
	}

	cout << ret << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

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

ll prefixCount(ll until, ll c, ll d) {
//	printf("cf %lld\n", c / gcd(c, d) * d);
//	printf("pc %lld %lld %lld %lld %lld %lld\n", until, c, d, (until/c) , (until/d) ,  (until / (c / gcd(c, d) * d)));
	return (until / c) + (until / d) - (until / (c / gcd(c, d) * d));
}

int main() {
	ll a, b, c, d; scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	printf("%lld", (b - a + 1) - prefixCount(b, c, d) + prefixCount(a-1, c, d));	
	return 0;
}


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

int main(){
  int n,x=0,y=0;cin >>n;
  vector<int> a(n),b(n);
  rep(i,n){ cin >> a[i];y+=a[i];if((i+1)%2==0&&i<n)x+=a[i];}
  b[0]=y-2*x;
  b[n-1]=(a[n-1]-b[0]/2)*2;
  for(int i=1;i<n-1;i++){
    b[i]=2*a[i-1]-b[i-1];
}
  rep(i,n) cout << b[i] << endl;}

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

int main(){
    int a, b;
    while(cin >> a >> b, a+b){
        int n;
        cin >> n;
        int field[20][20];
        memset(field, 0, sizeof(field));
        for(int i=0; i < n; i++){int x, y; cin >> x >> y; field[y][x] = -1;}
        field[1][1] = 1;
        for(int i=1; i <= b; i++){
            for(int j=1; j <= a; j++){
                if(i == 1 && j == 1) continue;
                if(field[i][j] == -1) continue;
                else field[i][j] = (field[i][j-1]==-1?0:field[i][j-1]) + (field[i-1][j]==-1?0:field[i-1][j]);
            }
        }
        if(field[b][a] == -1) cout << 0 << endl;
        else cout << field[b][a] << endl;
    }
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N=int(input())
    a=N//10
    b=N%1000
    print(["No","Yes"][a%111==0 or b%111==0])
    
#%%submit!
resolve()




Measured memory_bytes: 38256
/*   Abhijith  */
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define	endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main()
{
     ios;
     lld n;
     cin>>n;
     vector<lld> v(n+1),dp(n+1);
     rep(i,1,n)
     {
         cin>>v[i];
     }
     dp[1]=0;
     dp[2]=abs(v[2]-v[1]);
     rep(i,3,n)
     {
         dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
     }
     cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

struct LazySegmentTree{
    int n, width;
    VL dat, lazy;
    const ll INF = 1e18;

    LazySegmentTree(VL v){
        int n = v.size();
        width = 1;
        while (width < n) width *= 2;
        dat.assign(2 * width - 1, -INF);
        lazy.assign(2 * width - 1, 0);
        REP(i,n) dat[i + width - 1] = v[i];
        FORR(i,width-2,0) dat[i] = max(dat[2 * i + 1], dat[2 * i + 2]);
    }

    void eval(int k, int l, int r){
        dat[k] += lazy[k];
        if (r - l > 1){
            lazy[2 * k + 1] += lazy[k];
            lazy[2 * k + 2] += lazy[k];
        }
        lazy[k] = 0;
    }

    void add(int a, int b, ll x, int k, int l, int r){
        eval(k, l, r);
        if (r <= a || b <= l) return;
        if (a <= l && r <= b){
            lazy[k] += x;
            eval(k, l, r);
        }else{
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }

    // [l, r) += x
    void add(int l, int r, ll x){
        add(l, r, x, 0, 0, width);
    }

    ll query(int a, int b, int k, int l, int r){
        eval(k, l, r);
        if (r <= a || b <= l) return -INF;
        if (a <= l && r <= b) return dat[k];
        ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return max(vl, vr);
    }

    ll query(int l, int r){
        return query(l, r, 0, 0, width);
    }
};

int main() {
    int n, m;
    cin >> n >> m;

    VL beg(n);
    vector<vector<PL>> end(n);
    REP(i,m){
        int l = in() - 1, r = in() - 1, a = in();
        beg[l] += a;
        end[r].push_back(PL(l, a));
    }

    ll INF = 1e16;
    VL dp(n + 1, -INF);
    dp[0] = 0;
    LazySegmentTree seg(dp);
    REP(i,n){
        seg.add(0, i + 1, beg[i]);
        dp[i + 1] = seg.query(0, i + 1);
        seg.add(i + 1, i + 2, INF + dp[i + 1]);
        for (PL p : end[i]){
            seg.add(0, p.first + 1, -p.second);
        }
    }

    ll ans = 0;
    REP(i,n+1) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 24064
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val Array(r,c) = readLine.split(" ").map(_.toInt)
  val matrix = ArrayBuffer.empty[Array[Int]]
  val row = Array.fill[Int](c+1)(0)

  for( i <- 0 until r) {
    val n = readLine.split(" ").map(_.toInt)
    val a = n :+ n.sum
    matrix += a
    (0 until c).foreach( j=> row(j) += n(j) );row(c) += n.sum
  }
  matrix += row
  matrix.toArray.foreach( row => println(row.mkString(" ")) )
}

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

int main()
{
    string s; cin>>s;
    int res=0, x=0;
    int n=s.size();
    for(int i=0; i<n; ++i) {
        res=max(x+s[i]-'1'+9*(n-1-i), res);
        x+=s[i]-'0';
    }
    res=max(res, x);
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

int main() {
	int i, a, ans=0;
	cin >> a;
	for (i = 1; i <=a; i++) {
		ans += i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

class SegTree:
    def __init__(self,arr,func,unit):
        self.func = func
        self.unit = unit
        n = 1
        while n < len(arr):
            n *= 2
        self.n = n
        nodes = [unit]*(2*n-1)
        nodes[n-1:n-1+len(arr)] = arr
        for i in range(n-2,-1,-1):
            nodes[i] = func(nodes[2*i+1],nodes[2*i+2])
        self.nodes = nodes

    def update(self,i,val):
        i += self.n-1
        self.nodes[i] = val
        while i >= 0:
            i = (i - 1) // 2
            self.nodes[i] = self.func(self.nodes[2*i+1], self.nodes[2*i+2])

    def query(self,l,r):
        l += self.n
        r += self.n
        s = self.unit
        while l < r:
            if r & 1:
                r -= 1
                s = self.func(s, self.nodes[r-1])
            if l & 1:
                s = self.func(s, self.nodes[l-1])
                l += 1
            l >>= 1
            r >>= 1
        return s

segt = SegTree(A, lambda x,y:gcd(x,y), 0)
ans = 0
for i in range(N):
    l = segt.query(0,i)
    r = segt.query(i+1,N)
    g = gcd(l,r)
    ans = max(ans, g)
print(ans)

Measured memory_bytes: 16140
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
	reg ll s = 0, t = 0; reg char ch = getchar();
	while (!isdigit(ch)) t |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
	return t ? -s : s;
}

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

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

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

    ll X;

    cin >> X;

    ll ans = 0;
    ll m = 100;
    while(true){
        ans++;
        m = ((double)m)*1.01;
        if( X <= m ){
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a==b && b==c){
		cout << "1" << endl;
	}
	else if(a==b && b!=c){
		cout << "2" << endl;
	}
	else if(a==c && a!=b){
		cout << "2" << endl;
	}
	else if(b==c && a!=b){
		cout << "2" << endl;
	}
	else{
		cout << "3" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
return true;}

void lok(){
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v*t>=abs(b-a)+(w*t))cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

const ll p=1000000007;
ll qp(ll a,ll b){if(!b)return 1;ll w=qp(a,b>>1);w=w*w%p;return b&1?w*a%p:w;}
ll a[100005];
int main()
{
	int n,k;
	cin>>n>>k;
	F(i,1,k) a[i]=qp(k/i,n)%p;
	ll ans=0;
	UF(i,k,1) {F(j,2,k/i) a[i]=(a[i]-a[i*j]+p)%p;ans+=a[i]*i%p;}
	cout<<ans%p<<endl;
	return 0;
}
////////////////////

Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  int n;
  cin>>n;

  ll t=1;
  ll a=1;
  ll x,y;
  rep(i,n){
    cin>>x>>y;
    t=((t+x-1)/x)*x;
    a=((a+y-1)/y)*y;
    if((t/x)*y>=a) a=(t/x)*y;
    else t=(a/y)*x;
  }

  cout << t+a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll com(ll n, ll k){
  ll u = 1;
  for(int i=0; i<k; i++){
    u *= n-i;
    u %=MOD;
  }
  ll v=1;
  for(int i=1; i<=k; i++){
    v *= i;
    v %=MOD;
  }
  ll x;
  x = u* modinv(v,MOD)%MOD;
  return x;
}
int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll p = modpow(2,n,MOD);
  ll A = com(n,a);
  ll B = com(n,b);
  ll Ans = p-A-B-1;
  while(Ans<0){
    Ans += MOD;
  }
  cout << Ans << endl;
  
}


Measured memory_bytes: 256
function prime(max){
   var arr=[];
   for(var i=0;i<=max;i++)arr[i]=i;
   arr[0]=false;
   arr[1]=false;
   var sqrt=Math.floor(Math.sqrt(max));
   for(var i=2;i<=sqrt;i++){
      if(arr[i]==false)continue;
         for(var j=i+i;j<=max;j+=i){
            arr[j]=false;
         }
   }
   var result=[];
   for(var i=0;i<=max;i++){
      if(arr[i]!==false)result.push(arr[i]);
   }
   return result;
}
var p=prime(999999);
 
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i++){
   var a=Arr[i];
   for(var j=0;j<p.length;j++){
      if(p[j]>a)break;
   }
   console.log(j);
}

Measured memory_bytes: 35780
s = []
while True:
    n, x = map(int, input().strip().split())
    if n == x == 0:break
    c = 0
    for i in range(1, x // 3):
        c += max(0, max(0,(x - 3 * i - 1) // 2) - max(0,(x - 2 * i - 1 - n)))
    s.append(str(c))
print('\n'.join(s))

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

int main(){
    long long N,K;
    cin >> N >> K;
    
    if(K == 0){
        cout << N * N << endl;
        return 0;
    }
    
    long long ans = 0;
    for(long long b = 1; b <= N; b++){
        long long d = N / b;
        ans += d * max(b - K, 0LL);
        if(N % b > 0){
            ans += max(0LL, N%b - K + 1);
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3600
import sys

from numba import njit

input = sys.stdin.readline


@njit("Tuple((i8,i8,i8))(i8)")
def solve(N):
    for h in range(1, 3501):
        for n in range(1, 3501):
            a = N * h * n
            b = 4 * h * n - (h + n) * N
            if b > 0 and a % b == 0:
                w = a // b
                return h, n, w
    return -1, -1, -1


def main():
    N = int(input())
    h, n, w = solve(N)
    print(h, n, w)


if __name__ == "__main__":
    main()


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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int K, X;
    cin >> K >> X;
    for (int i = max(-1000000, X - (K - 1)); i <= min(1000000, X + K -1); i++ ) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

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

int main(){
  cin.sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  long long s;
  s = 0;
  for(int i = 1; i <= N; i++){
    int a;
    int b;
    a = i;
    b = 0;

    bool flag = true;
    while(flag){
      b += a % 10;
      a =  a / 10;
      if(a == 0) flag = false;
    }

    if( A <= b && b <= B) s += i;
  }

  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10],x;
char c;
int main()
{
    while(cin>>c&&c!='\0')
    {
        if(c=='0') a[x++]=0;
        else if(c=='1') a[x++]=1;
        else if(x) x--;
    }
    if(x!=0)
    {
        for(int i=0;i<x;i++) 
        printf("%d",a[i]);
        printf("\n"); 
    }
}

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

int main(){
    string s;
    cin >> s;
    if(s == "SUN") {
        cout << 7;
    } else if(s == "MON") {
        cout << 6;
    } else if(s == "TUE") {
        cout << 5;
    } else if(s == "WED") {
        cout << 4;
    } else if(s == "THU") {
        cout << 3;
    } else if(s == "FRI") {
        cout << 2;
    } else if (s == "SAT") {
        cout << 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main(void){
    // Here your code !
    int n,m,a,b;
    cin>>n>>m;
    int g[n],s[n];
    memset(g,0,sizeof(int)*n);
    memset(s,0,sizeof(int)*n);
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(a==1||b==1)s[a+b-2]=1;
        if(a==n||b==n)g[a+b-n-1]=1;
    }
    
    bool flag=false;
    for(int i=0;i<n;i++){
        if(s[i]+g[i]==2)flag=true;
    }
    
    if(flag){
        cout<<"POSSIBLE";
    }
    else{
        cout<<"IMPOSSIBLE";
    }
}


Measured memory_bytes: 1792
#include <stdio.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
ll pom(ll a,ll n,int m){
  ll x=1;
  for(a%=m;n;n/=2) n&1?x=x*a%m:0,a=a*a%m;
  return x;
}
#define invp(a,p) pom(a,p-2,p)
#define MOD 998244353

ll n,a,b,k,ans;
ll fact[300010];
ll choose(ll n,ll r){
  return fact[n]*invp(fact[r]*fact[n-r],MOD)%MOD;
}
int main(){
  scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	fact[0]=1;
  rep(i,0,n)fact[i+1]=fact[i]*(i+1)%MOD;
  rep(i,0,n+1){
    ll j=(k-i*a)/b;
    if(0<=j&&j<=n&&i*a+j*b==k)ans=(ans+choose(n,i)*choose(n,j))%MOD;
  }
  printf("%lld",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

long long GCD(long long a, long long b) {
  return b != 0 ? GCD(b, a % b) : a;
}
long long LCM(long long a, long long b) {
  return a * b / GCD(a, b);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll E = LCM(C, D);
  ll x = B - B / C - B / D + B / E;
  ll y = (A - 1) - (A - 1) / C - (A - 1) / D + (A - 1) / E;
  cout << x - y << endl;
}


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

x = []
for i in range(1, 11):
    x.append(26 ** i)

count = 1

for i in x:
    if n > i:
        n = n - i
        count += 1

def base26(value): # 10 => 2
    x = 26
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    result = []
    tmp = int(value)
    while tmp >= x:
        result.append(str(tmp%x))
        tmp = int(tmp / x)
    result.append(str(tmp%x))
    return result

alp = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
    'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 
    'u', 'v', 'w', 'x', 'y', 'z'
]

ans = base26(n-1)
ans2 = ['a'] * count

for i in range(len(ans)):
    ans2[i] = alp[int(ans[i])]

ans2 = list(reversed(ans2))

print(''.join(ans2))

Measured memory_bytes: 9272