akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> B(N - 1);
    rep(i, N - 1) cin >> B[i];
    vector<int> A(N);
    A[0] = B[0];
    rep(i, N - 1) {
        if (A[i] > B[i]) {
            A[i] = B[i];
        }
        A[i + 1] = B[i];
    }
    int sum = 0;
    rep(i, N) sum += A[i];
    cout << sum << endl;
}

Measured memory_bytes: 256
def sell(rate, kabu):
    return rate * kabu
    
def buy(rate, money):
    kabu = money//rate
    otsuri = money % rate
    return kabu, otsuri
    
N,*A = map(int, open(0).read().split())
money = 1000
have_kabu = 0
for i in range(N):
    #売る
    money += sell(A[i], have_kabu)
    have_kabu = 0
    #買う    
    if i != N-1 and A[i] < A[i+1]: 
        have_kabu, money = buy(A[i], money)
print(money)

Measured memory_bytes: 9204
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  int k,s;
  cin>>k>>s;
  int ret=0;
  rep(x,k+1) rep(y,k+1){
    if(x+y<=s && x+y+k>=s) ret++;
  }
  cout<<ret<<endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cctype>
#include <stdio.h>
using namespace std;

int main() {
    int N;cin>>N;
    int res = 0,x=N;
    while(N>0){
        res += N % 10;
        N/=10;
    }
    if (x%res==0){
        puts("Yes");
    } else {
        puts("No");
    }
}


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

vector<int> a(100000);

int gcd(int x,int y){
  if(y==0) return x;
  else return gcd(y,x%y);
}

int main(){
  int N;
  cin>>N;
  vector<int> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  
  vector<int> L(N+2),R(N+2);
  L[0]=0;
  for(int i=0;i<N;i++){
    L[i+1]=gcd(L[i],a[i]);
  }
  R[N]=0;
  for(int i=N;i>0;i--){
    R[i-1]=gcd(R[i],a[i-1]);
  }

  int ans=0;
  vector<int> M(N);
  for(int i=0;i<N;i++){
    ans=max(ans,gcd(L[i],R[i+1]));
  }

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

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

int main (void) {

    long long a, b, c, mod, N, ans;

    a = 1; b = 1; c = 1;

    scanf("%lld", &N);

    mod = pow(10, 9) + 7;

    for (int i = 0; i < N; i++) {
        a *= 10; a %= mod;
        b *= 9; b %= mod;
        c *= 8; c %= mod;
    }

    ans = (a - b - b + c);
    //printf("%lld\n", ans);

    ans %= mod;
    //printf("%lld\n", ans);

    ans = (ans + mod) % mod;
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
const int INF = 100000;
int main(){
  int a[3]; cin>>a[0]>>a[1]>>a[2];
  vector<int> v;
  for(int i=0; i<3; ++i) v.push_back(i);
  int min = INF;
  do{
    int sum = 0; 
    sum = 0*a[v[0]] + abs(a[v[0]]-a[v[1]]) + abs(a[v[1]]-a[v[2]]);
    if(min > sum) min = sum;
  }while( next_permutation(v.begin(),v.end()));
  cout << min <<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str = sc.next();
      int[] array = new int[str.length()+10];
      int min = 10000;
      for(int i = 0;i<str.length()-2;i++){
      	array[i] = Integer.parseInt( str.substring(i,i+3) );
        min = Math.min(min,Math.abs(array[i]-753));
      }
      System.out.println(min);
    }
}


Measured memory_bytes: 23764
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define int long long
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数定義や変数宣言







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



int x,money=100;
cin>>x;

int cnt=0;

while (money<x){
	money=money+(money/100);
	cnt++;
}


cout<<cnt<<endl;



return 0;

}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<string,int> mp;
    string s;
    ll ans = 0;
    for (int i = 0;i < n;i ++)
    {
        cin>>s;
        sort(s.begin(),s.end());
        if (!mp[s]) mp[s] = 1;
        else mp[s] ++;
    }
    map<string,int> :: iterator it;
    for (it = mp.begin();it != mp.end();it ++)
    {
        int n = it->second;
        ans += 1LL* n*(n-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define pb push_back
#define int long long
//#define M 1000000007
#define M 998244353
using namespace std;
const int inf=4e18;
const double pi=3.14159265358979;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;cin>>n;
	string s;cin>>s;
	if(n&1)
		cout<<"No\n";
	else
	{
		string s1(s,0,n/2);
		string s2(s,n/2,n/2);
		if(s1==s2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}

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

const ll oo = 1e18;

int main()
{
    ll n,w;
    cin>>n>>w;
    ll a[n][2];
    ll maxV = 0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]; // weight value
        maxV += a[i][1];
    }
    
    ll dp[n+1][maxV+1];
    
    for(ll i=0;i<=n;i++)
        dp[i][0] = 0;
    
    for(ll i=0;i<=maxV;i++)
        dp[0][i] = oo;
    
    dp[0][0] = 0;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=maxV;j++)
        {
            if(j < a[i-1][1])
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = min(dp[i-1][j-a[i-1][1]] + a[i-1][0], dp[i-1][j]);
        }
    }
    
    ll V = 0;
    for(ll i=1;i<=maxV;i++)
    {
        if(dp[n][i] <= w)
            V = max(V,i);
        //cout<<dp[n][i]<<" ";
    }
    cout<<V<<endl;

}

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

int main() {
    int64_t H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int64_t i = 0; i < H; i++) {
        cin >> s[i];
    }

    vector<vector<int64_t>> cost(H, vector<int64_t>(W, INT_MAX));
    struct Element {
        int64_t x, y, cost;
        bool operator<(const Element& rhs) const {
            return cost < rhs.cost;
        }
        bool operator>(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };
    priority_queue<Element, vector<Element>, greater<Element>> pq;
    pq.push({ 0, 0, cost[0][0] = (s[0][0] == '#')});

    while (!pq.empty()) {
        Element t = pq.top();
        pq.pop();
        if (t.cost > cost[t.y][t.x]) {
            continue;
        }

        int64_t dx[] = { 0, 1 };
        int64_t dy[] = { 1, 0 };
        for (int64_t k = 0; k < 2; k++) {
            int64_t nx = t.x + dx[k];
            int64_t ny = t.y + dy[k];
            if (nx < 0 || W <= nx || ny < 0 || H <= ny) {
                continue;
            }

            int64_t new_cost = t.cost + (s[t.y][t.x] == '.' && s[ny][nx] == '#');
            if (new_cost < cost[ny][nx]) {
                pq.push({ nx, ny, cost[ny][nx] = new_cost });
            }
        }
    }

    cout << cost[H - 1][W - 1] << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define int long long

using namespace std;

const int N = 300707;
int a, b, n;

signed main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("diameter.in", "r", stdin);
    //freopen("diameter.out", "w", stdout);
    cin >> n;
    cout << n * n << endl;



    return 0;
}


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

int main(){

    string a, b;
    cin >> a >> b;
    int numero = stoi(a+b);
    double resultado = sqrt(numero);
    if(resultado == int(resultado))
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = n-1;
        Set<Long> set = new HashSet<>();
        set.add(n);
        for (int i = 2; i < Math.sqrt(n)+1; i++) {
            if(n%i == 0){
                long b = n/i;
                while(b%i==0)b/=i;
                if(b%i == 1){
                    set.add((long)i);
                }
            }
        }
        for (int i = 1; i < Math.sqrt(a)+1; i++) {
            if(a%i == 0){
                long b = a/i;
                set.add((long)i);
                set.add(b);
            }
        }
        set.remove(Long.valueOf(1));
        System.out.println(set.size());
        sc.close();

    }

}


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



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

    ll n,m;
    cin>>n>>m;
    ll a[n];
    vector<ll> v;
    ll ans = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans += a[i];
        ll t = a[i];
        while(t){
            v.push_back(t-t/2);
            t/=2;
        }

    }
    sort(v.begin(),v.end(),greater<ll>());

    for(ll i=0;i<min(m,(ll)v.size());i++){
        ans -= v[i];
    }
    cout << ans << endl;
    return 0;
    

}

Measured memory_bytes: 35684
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll H,W;
	scan(H>>W);
	if(H==1||W==1) prin(1);
	else if(H%2==1&&W%2==1) prin(H*W/2+1);
	else prin(H*W/2);
	return 0;
}


Measured memory_bytes: 256
def alp_num(alp):
    alp_lst = list('ABCDEF')

    num = alp_lst.index(alp)
    return num


def main():
    x, y = map(str, input().split())
    num1 = alp_num(x)
    num2 = alp_num(y)

    if num1 < num2:
        com_ope = '<'
    elif num1 == num2:
        com_ope = '='
    else:
        com_ope = '>'

    print(com_ope)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9064
#include <stdio.h>
int main(void)
 
{
 int a,b;
 scanf("%d %d",&a,&b);
 if(a > b){
 printf("a > b\n");
 }
 if(a < b){
 printf("a < b\n");
 }
 if(a == b){
 printf("a == b\n");
 }
 return 0;
}

Measured memory_bytes: 580
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max

object BMain{
    fun solve(){
        val n = next()
        var sum = 0
        n.forEach { sum += (it - '0'.toChar()).toInt() }

        if(sum % 9 == 0){
            println("Yes")
        }else{
            println("No")
        }
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun nextDouble() = next().toDouble()
}

fun main(){
    BMain.solve()
}



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n, a,b; cin >> n;
    vii tree(n);
    rep(i,n-1) {
        cin >> a >> b;
        --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vi distFrom0_(n, -1), distFromN_(n, -1);
    vi filled(n, -1);
    queue<int> q;
    q.push(0);
    distFrom0_[0] = 0;
    while(q.size()) {
        int v = q.front(); q.pop();
        for(int nv : tree[v]) {
            if(distFrom0_[nv]!=-1) continue;
            distFrom0_[nv] = distFrom0_[v]+1;
            q.push(nv);
        }
    }
    q.push(n-1);
    distFromN_[n-1] = 0;
    while(q.size()) {
        int v = q.front(); q.pop();
        for(int nv : tree[v]) {
            if(distFromN_[nv]!=-1) continue;
            distFromN_[nv] = distFromN_[v]+1;
            q.push(nv);
        }
    }

    rep(i,n) filled[i] = (distFrom0_[i] <= distFromN_[i] ? 1 : 0);

    int cnt_s = 0, cnt_f = 0;
    rep(i,n) {
        if(filled[i]) ++cnt_f;
        else ++cnt_s;
    }

    if(cnt_f <= cnt_s) cout << "Snuke" << '\n';
    else cout << "Fennec" << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 6912
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] a_b_c = str.split(" ", 0);

		int a = Integer.parseInt(a_b_c[0]);
		int b = Integer.parseInt(a_b_c[1]);
		int c = Integer.parseInt(a_b_c[2]);

		int divisor = 0;

		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				divisor++;
			}
		}
		System.out.println(divisor);
	}
}

Measured memory_bytes: 24228
#include <stdio.h>
#define NOT_FOUND 0
int binarySearch(int *p,int key,int n)
{
    int left = 0,right = n;
    int mid;
    while(left<=right)
    {
        mid = (left+right)/2;
        if(p[mid]==key)
            return 1;
        else if(p[mid]>key)
            right = mid - 1;
        else if(p[mid]<key)
            left = mid + 1;
    }
    return NOT_FOUND;
}
int main()
{
    int S[100000],T[50000];
    int n,m,i,count = 0;
    scanf("%d",&n);
    for(i = 0;i < n;i++)
    {
        scanf("%d",&S[i]);
    }
    scanf("%d",&m);
    for(i = 0;i < m;i++)
    {
        scanf("%d",&T[i]);
    }
    for(i = 0;i < m;i++)
    {
        if(binarySearch(S,T[i],n))
            count++;
    }
    printf("%d\n",count);
}




Measured memory_bytes: 2328
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

vector<int> tpsort(const vector<vector<int>>& g) {
	int V = g.size();
	vector<int> indeg(V, 0);
	stack<int> S;

	for (int i = 0; i < V; ++i) {
		for (int j = 0; j < g[i].size(); ++j) {
			++indeg[g[i][j]];
		}
	}
	for (int i = 0; i < V; ++i) {
		if (indeg[i] == 0) { S.push(i); }
	}

	vector<int> ret;
	while (S.size() > 0) {
		int u = S.top(); S.pop();
		ret.push_back(u);
		for (int i = 0; i < g[u].size(); ++i) {
			--indeg[g[u][i]];
			if (indeg[g[u][i]] == 0) {
				S.push(g[u][i]);
			}
		}
	}
	return ret;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g(N);
	for (int i = 0; i < M; ++i) {
		int x, y;
		cin >> x >> y;
		g[x - 1].emplace_back(y - 1);
	}

	vector<int> v = tpsort(g);
	vector<int> d(N, 0);
	int ans = 0;
	for (int s : v) {
		for (int t : g[s]) {
			d[t] = max(d[t], d[s] + 1);
			ans = max(ans, d[t]);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6780
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			 
			Scanner sc = new Scanner(System.in);
			// 整数の入力
			// スペース区切りの整数の入力
			int N = sc.nextInt();

			ArrayList<Integer> stateList = new ArrayList<Integer>();

			stateList.add(N);
					
			for (int i = 1; i <= N;i ++ ){
				stateList.add(sc.nextInt());
			}
			
            int ai= 1;		
            int j = 0;
			for(int i=1;i <= stateList.size();i++){
				ai = stateList.get(ai);
				j ++;
				if(ai == 2){
		       		// 出力
		        	System.out.println(j);
		        	return ;
				}
    		 }

    		 // 出力
			System.out.println("-1");
		}
}


Measured memory_bytes: 62288
mod = 1000000007
n, k = map(int, input().split())

d = [0] * (k + 1)

for i in range(1, k + 1):
    d[i] = pow(k//i, n, mod)

for i in range(k, 0, -1):
    for j in range(2*i, k + 1, i):
        d[i] -= d[j]
        d[i] %= mod

ans = 0
for i in range(i, k+1):
    ans += d[i] * i

ans %= mod
print (ans)

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

int dp[1000+1];

void solve(int idx, int sum, const vector<pair<int, int> >& cards)
{
  if (sum > 1000)
    return;

  if (idx >= cards.size()) {
    ++dp[sum];
    return;
  }

  for (int i = 0; i <= cards[idx].second; ++i)
    solve(idx+1, sum+cards[idx].first*i, cards);
}

int main()
{
  int m;
  while (cin >> m) {
    if (m == 0)
      break;

    vector<pair<int, int> > cards(m);
    for (int i = 0; i < m; ++i)
      cin >> cards[i].first >> cards[i].second;

    for (int i = 0; i <= 1000; ++i)
      dp[i] = 0;
    solve(0, 0, cards);

    int g;
    cin >> g;
    for (int i = 0; i < g; ++i) {
      int n;
      cin >> n;
      cout << dp[n] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin >> n;
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<=i;j++){
      sum+=a[j];
    }
    for(int j=i;j<n;j++){
      sum+=b[j];
    }
    ans=max(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
	string S, T;
	cin >> S >> T;
	ll answer = 0;
	rep(i, S.size()) if (S.at(i) != T.at(i)) answer++;
	cout << answer;
}

Measured memory_bytes: 3900
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", long, "cost");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto k = lread();
    long s;
    foreach (i; iota(1, k + 1))
    {
        foreach (j; iota(1, k + 1))
        {
            auto tmp = gcd(i, j);
            foreach (l; iota(1, k + 1))
            {
                s += gcd(tmp, l);
            }
        }
    }
    s.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2704
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	int t, a; cin >> t >> a;

	vector<int> h(n);

	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int ans = INF;
	int num = -1;
	for (int i = 0; i < n; i++) {
		int temp = 1000 * t - 6 * h[i];

		int diff = abs(1000 * a - temp);

		if (ans > diff) {
			ans = diff;
			num = i;
		}
	}

	cout << num + 1 << endl;
}

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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n),dp(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans = 0;
	for(int i=0;i<n;i++){
		if(i<k)
			dp[i] = (i==0 ? a[i] : dp[i-1] + a[i]);
		else dp[i] = dp[i-1] + a[i] - a[i-k];	
		//ctrl + /cout<<dp[i]<<" "; 
		ans = max(ans,dp[i]);
	}
	cout<<setprecision(14)<<0.5*ans + 0.5*k;
	

	return 0;
}
	
	
	
	
	
	
	
	
	
	
	

























Measured memory_bytes: 3328
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = Hash.new(0)
n.times do |i|
  b[a[i]] += 1
end
b = b.select{|k,v|v >= 2}
c = b.keys.sort.unshift([0,0]).flatten
if !(b.empty?) && b[c[-1]] >= 4
  puts c[-1]**2
else
  puts c[-1]*c[-2]
end

Measured memory_bytes: 16004
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

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

int N, A, B;

int firstdiff(int a, int b)
{
    a = a^b;
    b = 0;
    while((a&1) == 0) {
        ++b;
        a >>= 1;
    }
    return b+1;
}

int delps(int a, int ps)
{
    int ae = (a >> (ps-1)) << (ps-1);
    ae = ae ^ a;
    ae += (a >> ps) << (ps-1);
    return ae;
}

int addps(int a, int ps, int bit)
{
    int b = (a >> (ps-1)) << (ps-1);
    b = b^a;
    int c = (a >> (ps-1)) << 1;
    c += bit;
    c <<= (ps-1);
    c += b;
    return c;
}

vector<int> solve(int a, int b, int n)
{
    if(n == 1) {
        vector<int> ans = {a, b};
        return ans;
    }
    int ps = firstdiff(a, b);
    //cout << a << " " << b << " " << ps << endl;
    int ae = delps(a, ps);
    int be = delps(b, ps);
    int c = ae^1;
    vector<int> vl = solve(ae, c, n-1);
    vector<int> vr = solve(c, be, n-1);
    for(auto &x: vl) {
        x = addps(x, ps, (a>>(ps-1))&1);
    }
    for(auto x: vr) {
        x = addps(x, ps, (b>>(ps-1))&1);
        vl.push_back(x);
    }
    return vl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> A >> B;
    int m = A^B;
    int d = 0;
    while(m) {
        if(m&1) ++d;
        m >>= 1;
    }
    if(d%2 == 0) {
        cout << "NO" << endl;
        return 0;
    }
    vector<int> ans = solve(A, B, N);
    cout << "YES" << endl;
    for(auto x: ans) {
        cout << x << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1648
#include<iostream>
#include<algorithm>
using namespace std;
int x[105];
int main(){
  int a,b;
  cin>>a>>b;
  x[0]=a+b;
  x[1]=a-b;
  x[2]=a*b;
  sort(x,x+3);
  cout<<x[2]<<'\n';
  return(0);
}


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

using namespace std;

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

int main( void )
{
	int n, m[17][17];
	bool t[17][17][17][17];
	cin >> n;
	while(n--) {
		int gx, gy; cin >> gx >> gy;
		memset(m, 0, sizeof(m));
		memset(t, false, sizeof(t));

		int p; cin >> p;
		for(int i=0; i < p; ++i) {
			int x1, y1, x2, y2;
			cin >> x1 >> y1 >> x2 >> y2;
			t[x1][y1][x2][y2] = t[x2][y2][x1][y1] = true;
		}

		m[0][0] = 1;
		for(int y=0; y <= gy; ++y)
			for(int x=0; x <= gx; ++x) {
				if(m[y][x]) {
					for(int d=0; d < 2; ++d) {
						int mx = x + dx[d];
						int my = y + dy[d];
						if(!t[x][y][mx][my]) {
							m[my][mx] += m[y][x];
						}
					}
				}
			}
		if(!m[gy][gx])
			cout << "Miserable Hokusai!" << endl;
		else
			cout << m[gy][gx] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
# # -*- coding: utf-8 -*-
X, Y, A, B, C = map(int, input().split(' '))
P = list(map(int, input().split(' ')))
Q = list(map(int, input().split(' ')))
R = list(map(int, input().split(' ')))

apples = []
apples.extend([(p, 0) for p in P])
apples.extend([(q, 1) for q in Q])
apples.extend([(r, 2) for r in R])
apples.sort(key=lambda x: x[0], reverse=True)

ans = 0
num = X + Y
thresholds = [X, Y, C]
for v, category in apples:
    # もうその色のリンゴを取れない
    if not thresholds[category]:
        continue

    num -= 1
    thresholds[category] -= 1
    ans += v

    if num == 0:
        break

print(ans)




Measured memory_bytes: 123816
N,A,B=[int(i) for i in input().split()]

sum_list=[]
for x in range(1,N+1):
    #万の位
    a=x//10000
    #千の位
    b=(x%10000)//1000
    #百の位
    c=((x%10000)%1000)//100
    #10の位
    d=(((x%10000)%1000)%100)//10
    #1の位
    e=(((x%10000)%1000)%100)%10
    
    
    if A<=(a+b+c+d+e)<=B:
        sum_list.append(x)
        
print(sum(sum_list))
        

Measured memory_bytes: 9244
#include<iostream>]
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	int a[200000],b[200000];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n, greater<int>());
	for(int i=0;i<n;i++){
		if (a[0] == b[i])cout << a[1] << endl;
		else cout << a[0] << endl;
	}
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	s = " " + s;
	bool easy = true;
	for (int i = 1;i < s.length();++i)
	{
		if ((i % 2) == 1 && s[i] == 'L')
			easy = false;
		if ((i % 2) == 0 && s[i] == 'R')
			easy = false;
	}
	if (easy)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 888
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    a = iread()
    print(3 * a * a)

Measured memory_bytes: 2940
n,a,b = map(int,input().split())
mod = 10**9 + 7

ans = pow(2,n,mod)
p = 1
for i in range(n,n-a,-1):
    p *=i
    p %= mod
p_inv = 1
for i in range(1,a+1):
    p_inv *= i
    p_inv %= mod
p *= pow(p_inv,mod-2,mod)

q = 1
for i in range(n,n-b,-1):
    q *=i
    q %= mod
q_inv = 1
for i in range(1,b+1):
    q_inv *= i
    q_inv %= mod
q *= pow(q_inv,mod-2,mod)

ans -= p
ans -= q
ans %= mod
print(ans-1)

Measured memory_bytes: 39152
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M = map(int, readline().split())
    AB = [list(map(int, readline().split())) for _ in range(N)]
    CD = [list(map(int, readline().split())) for _ in range(M)]

    ans = [0] * N
    for i, (a, b) in enumerate(AB):
        dist = INF
        for j, (c, d) in enumerate(CD):
            if dist > abs(a - c) + abs(b - d):
                dist = abs(a - c) + abs(b - d)
                res = j
        ans[i] = res + 1

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9036
from heapq import heapify, heappop, heappush

def resolve():
  N, M = map(int, input().split(" "))
  A = [int(x) for x in input().split(" ")]
  sortedA = sorted(A)
  integraA = [0, sortedA[0]]

  # O[N]
  for i in range(1, N):
    integraA.append(integraA[-1] + sortedA[i])
  # print(integraA)
  # O[M]
  heap_tasks = []
  heapify(heap_tasks)
  for _ in range(M):
    B, C = map(int, input().split(" "))
    heappush(heap_tasks, ((-1)*C, B))
  

  # O[M]
  start_index = 0
  result = integraA[-1]
  for _ in range(M):
    task = heappop(heap_tasks)
    C = (-1) * task[0]
    B = task[1]
    # B が残りよりも多かった場合、残りに合わせる。
    if start_index + B > N:
      B = N - start_index

    if B == 0:
      break

    # print("task =", B, C)
    if sortedA[start_index + B - 1] <= C:
      # 対象範囲の全てが C より小さかったら全て置き換える。
      # print("diff", (integraA[start_index + B] - integraA[start_index]))
      result += B*C - (integraA[start_index + B] - integraA[start_index])
      start_index += B
      if start_index >= N:
        break
    elif sortedA[start_index] >= C:
      # 対象範囲の全てが C 以上だったら置き換えせずに終了。
      break
    else:
      # 対象範囲の一部が C 未満だったらその部分だけ置き換えて終了 (残りは全て C 以上になることが保証されているので)
      while sortedA[start_index + B - 1] > C:
        B -= 1
      result += B*C - (integraA[start_index + B] - integraA[start_index])
      break
  print(result)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 93904
//# define FLAG
///delet....................................
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <cstdio>
# include <string>
# include <cmath>
# include <ctime>
# include <set>
# include <map>
# include <queue>
# include <stack>
# include <bitset>
# include <vector>
# include <fstream>
# include <algorithm>
using namespace std;
# define eps 1e-8
# define pb push_back
# define pi acos(-1.0)
# define bug puts("H");
# define mem(a,b) memset(a,b,sizeof(a))
# define IOS ios::sync_with_stdio(false);
# define FO(i,n,a) for(int i=n; i>=a; --i)
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define INF 0x3f3f3f3f
# define MOD 1000000007
///           123456789
//# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef unsigned long long ULL;
typedef long long LL;
inline int Scan(){
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
///coding...................................

int main()
{
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif /// FLAG
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b<=c||d<=a)cout<<0<<endl;
    else if(a<=c&&d<=b)cout<<d-c<<endl;
    else if(a<=c&&b<=d)cout<<b-c<<endl;
    else if(c<=a&&b<=d)cout<<b-a<<endl;
    else if(c<=a&&d<=b)cout<<d-a<<endl;
    return 0;
}








Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define pos position<int>
#define at_(p) at(p.x).at(p.y)

#define GCD(v) gcd(ALL(v), 0l)

template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;



int main(){
  long long x;
  cin>>x;
  int c=0;
  long long y=100;
  while(y<x){
    c++;
    y*=1.01;
  }
  cout<<c;
}



/* きょむ〜 */


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

int main()
{
    int n,l,i,j;
    cin>>n>>l;
    string temp,s[n];
    for(i=0;i<n;i++)cin>>s[i];
    for(i=0;i<n;i++)
    {
        for(j=i;j<n;j++)
          {
              if(s[i].compare(s[j])>0)
              {
                  temp=s[i];
                  s[i]=s[j];
                  s[j]=temp;
              }
          }
          cout<<s[i];
    }
    cout<<endl;
}



Measured memory_bytes: 3580
N, K, Q = [int(v) for v in raw_input().split()]
points = [0] * N
for n in range(Q):
    A = int(raw_input()) -1
    points[A] += 1
for n in range(N):
    res = K + points[n] - Q
    if res > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6996
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);

	if(a<b){
	printf("a < b\n");	
	}else if(a>b){
	printf("a > b\n");
	}else if(a==b){
	printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <ctype.h>
#include <fstream>
#include <unordered_map>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
int n;
LL a[100005],dp[100005];
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%lld", a + i);

	for (int i = 0; i <= n + 2; i++)
		dp[i] = mod * mod;
	dp[0] = 0;
	for (int i = 0; i < n-1; i++)
	{
		dp[i + 1] = min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}

	cout << dp[n - 1] << endl;

	return 0;
}

/*



*/

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
#define int long long

constexpr int M = 200000 + 10;
constexpr int MOD = 1000000000 + 7;
vector<int> inv;

constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}

vector<int> listModinv(int n)
{
    vector<int> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    return inv;
}

int naiveSolution(int n, int a, int b)
{
    int ans = 0;
    int c = 1;
    for (int i = 1; i <= n; i++)
    {
        c = c * (n - i + 1) / i;

        if (i == a || i == b)
            continue;

        (ans += c) %= MOD;
    }
    return ans;
}

int modCombi(int n, int k)
{
    int ans = 1;
    for (int i = 1; i <= k; i++)
    {
        ans *= ((n - i + 1) * inv[i]) % MOD;
        ans %= MOD;
    }
    return ans;
}

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

    inv = listModinv(M);

    int n, a, b;
    cin >> n >> a >> b;

    int ans = 0;

    int rown1 = modpow(2, n);
    ans = rown1;
    (ans = ans + MOD - modCombi(n, 0)) %= MOD;
    (ans = ans + MOD - modCombi(n, a)) %= MOD;
    (ans = ans + MOD - modCombi(n, b)) %= MOD;

    cout << ans << endl;
    // cout << naiveSolution(n, a, b) << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;


ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll le[MAX], ri[MAX], a[MAX];

ll gcd(ll x, ll y) {
  if (x < y) swap(x, y);
  return y ? gcd(y, x%y) : x;
}


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


  cin >> n;
  FOR(i, 1, n + 1) cin >> a[i];
  le[1] = a[1];
  FOR(i, 2, n + 1) le[i] = gcd(le[i - 1], a[i]);
  ri[n] = a[n];
  RFOR(i, 1, n) ri[i] = gcd(ri[i + 1], a[i]);
  ans = 1;
  FOR(i, 1, n + 1) {
    if (i == 1) tmp = ri[i+1];
    else if (i == n) tmp = le[n - 1];
    else tmp = gcd(le[i - 1], ri[i + 1]);
    ans = max(ans, tmp);
  }
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> v(n);
    for (int i = 0; i < n-1; ++i) {
        if(s[i] == 'A' && s[i+1] == 'C') v[i+1]++;
        v[i+1] += v[i];
    }
    for (int i = 0; i < q; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        cout << v[b] - v[a] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long lli;
void solve();
int main()
{
	int t = 1;
//	cin >> t;
	for(int i=1; i <= t; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

void solve()
{
	string a, b; cin >> a >> b;
	int cnt = 0;
	for(int i=0; i<a.size(); i++)
	{
		if(a[i] != b[i]) cnt ++;
	}
	cout << cnt;
}

Measured memory_bytes: 3844
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	int a[1001] = {};
	int b[1001] = {};
	for (string s; getline(cin, s) && s != "";) {
		stringstream ss(s);
		int p, q; char c;
		ss >> p >> c >> q;
		a[p]++;
	}
	for (string s; getline(cin, s) && s != "$";) {
		stringstream ss(s);
		int p, q; char c;
		ss >> p >> c >> q;
		b[p]++;
	}
	for (int i = 0; i < 1001; i++) {
		if (a[i] > 0 && b[i] > 0)
			cout << i << " " << a[i] + b[i] << endl;
	}

	return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<ld> Point;
typedef vector<vector<int>> Graph;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    ll n, k, s;
    cin >> n >> k >> s;
    vector<ll> ans;
    ll compliment;
    if (s == 1) {
        compliment = 1e9;
    } else {
        compliment = s - 1;
    }
    rep(i, n) {
        if (i < k)
            ans.push_back(s);
        else
            ans.push_back(compliment);
    }
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2292
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

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

	vector<int> a;
	for (int i = 0; i < w; i++)
	{
		a.push_back(i + 1);
	}

	int n;
	cin >> n;

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

		string s;
		cin >> s;

		stringstream ss;
		ss << s;

		ss >> x;
		ss.ignore();
		ss >> y;

		swap(a.at(x - 1), a.at(y - 1));
	}

	for (int i = 0; i < w; i++)
	{
		cout << a.at(i) << endl;
	}
}


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

int n, m;
char es[50][50];
char used[50];

void f(int v){
	used[v]=1;
	int i;
	for(i=0; i<n; i++){
		if(used[i]==0 && es[v][i]!=0){
			f(i);
		}
	}
}

int main(void){
	char p[50][2], P=0;
	int i, j;
	scanf("%d%d", &n, &m);
	for(i=0; i<m; i++){
		int a, b;
		scanf("%d%d", &a, &b); a--; b--;
		es[a][b]=1; es[b][a]=1;
		p[P][0]=a; p[P][1]=b; P++;
	}
	int ans=0;
	for(i=0; i<m; i++){
		es[p[i][0]][p[i][1]]=0;
		es[p[i][1]][p[i][0]]=0;
		memset(used, 0, sizeof(used));
		f(0);
		char k=1;
		for(j=0; j<n; j++){
			if(used[j]==0){k=0; break;}
		}
		if(k==0) ans++;
		es[p[i][0]][p[i][1]]=1;
		es[p[i][1]][p[i][0]]=1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256