akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
char s[101];
int main() {
    int n;
    while(scanf("%d",&n),n) {
        vector<int> key;
        for(int i=0;i<n;i++) {
            int k;
            scanf("%d",&k);
            key.push_back(k);
        }
       scanf("%s",s);
       for(int i=0;s[i]!='\0';i++) {
            int code=0;
            if('a'<=s[i]&&s[i]<='z') code=s[i]-'a';
            if('A'<=s[i]&&s[i]<='Z') code=26+s[i]-'A';
            code-=key[i%key.size()];
            while(code<0) code+=52;
            code%=52;
            if(0<=code&&code<=25) putchar('a'+code);
            if(26<=code&&code<=51) putchar('A'+code-26);
       }
       putchar('\n');
    }
}

Measured memory_bytes: 3172
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray();
        int cnt = 0;
        StringBuilder sb = new StringBuilder();
        for(char c : s){
            if(c == 'T'){
                if(cnt == 0){
                    sb.append("T");
                }else{
                    cnt--;
                }
            }else{
                cnt++;
            }
        }
        System.out.println(sb.length()+cnt);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 24788
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200

//素因数分解をするアルゴリズム
template<typename T>
vector<T> prime_factorization(T n) 
{
	vector<T> res;
	T check = 2;

	while (check*check <= n) {
		if (n%check == 0) {
			n /= check;
			res.push_back(check);
		}
		else {
			check++;
		}
	}
	if (n != 1) res.push_back(n);
	sort(res.begin(), res.end());
	return res;
}

















//上に、ライブラリを作成していく。
//問題に応じて、以下を調整する。


//サブ関数
//入力
void input(int& n)
{
	cin >> n;
}


//出力
void output(int n)
{
	cout << n << ":";
	for (auto var : prime_factorization(n)) {
		cout << " " << var;
	}
	cout << endl;
}

//デバッグ
void debug(){
	int N;
	cin>>N;
}


//メイン関数
int main(){
	int n;
	input(n);
	output(n);
	debug();
	
	return 0;
}



Measured memory_bytes: 3136
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
import qualified Data.Vector.Unboxed as UV
main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    putStrLn $ if S.member k $ f k as then "First" else "Second"

f k as = UV.foldl' p S.empty $ UV.enumFromTo 0 k where
    p s i | S.member i s = s
          | otherwise = UV.foldl' (flip S.insert) s $ UV.map (+i) as

Measured memory_bytes: 2428
import java.util.Scanner;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
	while(true){
	int H = sc.nextInt();
	int W = sc.nextInt();
	if(H == 0 && W == 0){
	break;
	}
	for(int i = 0;i < H;i++){
	for(int j = 0;j < W;j++){
	System.out.print("#");
	}
	System.out.println("");
	}
	System.out.println("");
	}
}
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
int a[maxn];
bool vis[1000005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	rep(i,0,n) cin>>a[i];
	int ans=0;
	sort(a,a+n);
	rep(i,0,n)
	{
		if(vis[a[i]]==0&&(i==n-1||a[i]!=a[i+1]))
		{
			ans++;
		}
		if(!vis[a[i]])
		{
			for(int j=a[i];j<=1000000;j+=a[i]) vis[j]=1;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 5364
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
double dp[3005][3005];
bool have[3005][3005]={0};
double con[3005];
double F(int N,int now)
{
    if(N==0&&now==0) return 1.0;
    if(now<0||N==0) return 0.0;
    if(have[N][now]) return dp[N][now];
    have[N][now]=1;
    dp[N][now]=con[N]*F(N-1,now-1)+(1.0-con[N])*F(N-1,now);
    return dp[N][now];
}
int main()
{
    int N,i;
    double ans=0.0;
    scanf("%d",&N);
    for(i=1;i<=N;i++) scanf("%lf",&con[i]);
    for(i=0;i<=N;i++)
    {
        F(N,i);
        if(i>N-i) ans+=F(N,i);
    }
    printf("%.10lf\n",ans);
    return 0;
}


Measured memory_bytes: 79744
import sys
sys.setrecursionlimit(10**7)

n, m = list(map(int, input().split()))
par = list(range(n+1))
dist = [0 for _ in range(n+1)]

def root(x):
  if x == par[x]:
    return x
  r = root(par[x])
  dist[x] += dist[par[x]]
  par[x] = r
  return r

def direct_cost(x):
  if x == par[x]:
    return 0
  return dist[x] + direct_cost(par[x])

def diff(x, y):
  return direct_cost(x) - direct_cost(y)

def unite(x, y, w):
  rootx = root(x)
  rooty = root(y)
  if rootx != rooty:
    if y != rooty:
      # 直接yにつなげる
      dist[rootx] = w - direct_cost(x)
    else:
      # 根につなげる
      dist[rootx] = w - (dist[x] - dist[y])
    # ここで親を更新
    par[rootx] = y
  else:
    return w == diff(x, y)

flag = True
for _ in range(m):
  l, r, d = list(map(int, input().split()))
  # 根が異なってたらとりあえず併合、同じならdifを取って整合性を確かめる
  a = unite(l, r, d)
  if a is not None:
    if a == False:
      flag = False
  """
  rootx, rooty = root(l), root(r)
  if rootx != rooty:
    if r != rooty:
      # 直接yにつなげる
      dist[rootx] = d - direct_cost(l)
    else:
      # yの根につなげる
      dist[rootx] = d - (dist[l] - dist[r])
    par[rootx] = l
  else:
    if d != diff(l, r):
      flag = False
  """
"""
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(par)]
print()
[print("[{}]{}".format(idx, v), end=" ") for idx, v in enumerate(dist)]
print()
"""

print("Yes" if flag else "No")
  


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

long long ans[1<<13];
vector<tuple<int, int, long long>> Es;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int M, N, P; cin >> N >> M >> P;
  for (int i = 0; i < M; ++i) {
    int a, b, c; cin >> a >> b >> c;
    --a, --b;
    Es.emplace_back(a, b, P - c);
  }
  fill(ans, ans + N, 1ll << 60);
  ans[0] = 0;
  for (int i = 0; i < N; ++i) {
    for (auto T : Es) {
      int u, v, w; tie(u, v, w) = T;
      ans[v] = min(ans[v], ans[u] + w);
    }
  }
  long long cur = ans[N - 1];
  for (int i = 0; i < N; ++i) {
    for (auto T : Es) {
      int u, v, w; tie(u, v, w) = T;
      ans[v] = min(ans[v], ans[u] + w);
    }
  }
  if (cur > ans[N - 1]) {
    cout << -1 << '\n';
  }
  else cout << max(0ll, -cur) << '\n';
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (a, b, h, m) = getInts()

    val x = m * 6.0
    val y = h * 30 + m / 2.0
    val theta = (Math.max(x, y) - Math.min(x, y)) * Math.PI / 180.0
    println(len(a, b, theta))
}

fun len(a: Int, b: Int, theta: Double): Double {
    val c = b - a * Math.cos(theta)
    val d = a * Math.sin(theta)
    return Math.sqrt(c * c + d * d)
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

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

int main()
{
    long long x; cin >> x;
    
    long long tmpSum = 0;
    long long cnt = 1;
    while (true) {

        tmpSum += cnt;

        if (x <= tmpSum) {
            break;
        }

        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int ar[4]={0};
    int x;
    cin>>x;
    ar[x]=1;
    cin>>x;
    ar[x]=1;
    for(ll i=1;i<4;++i)
    {
        if(ar[i]==0){cout<<i;}
    }

    return (0);
}


Measured memory_bytes: 256
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e18;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

//Union-Find木
struct UnionFind{
  //メンバ変数 
  vector<long long>par; //par[i]:=頂点iの親
  vector<long long>s; //s[i]:=頂点iが属する集合の個数(iが根のとき)
  
  //コンストラクタ
  UnionFind(long long N):par(N),s(N){
    for(long long i=0;i<N;i++){
      par[i]=i; //最初はすべてが根として初期化
      s[i]=1;
    }
  }
  //メンバ関数
  //root(i):=頂点iの根
  long long root(long long i){
    if(par[i]==i) return i;
    par[i]=root(par[i]); //経路圧縮
    return root(par[i]); //再帰
  }
  //size[i]:=iが属する集合の個数
  long long size(long long i){
    return s[root(i)];
  }
  //same(x,y) xとyが同じ根を持つか(同じ集合に含まれるか)
  bool same(long long x, long long y){
    return root(x)==root(y);
  }
  //unite(x,y) xの根をyの根に繋げる(集合を合併)
  void unite(long long x, long long y){
    if(!same(x,y)){
      long long rx=root(x);
      long long ry=root(y);
      par[rx]=par[ry];
      s[ry]=s[rx]+s[ry];
    }
  }
};

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////
int dp[3005][3005][5];

//メイン関数
int main(){
  //doubleの桁数
  
  int N; cin >> N;

  ll a = 1, b = 2, c = 1;
  rep(i, N){
    a *= 10;
    b *= 9;
    c *= 8;
    a %= mod;
    b %= mod;
    c %= mod;
  }

  ll res = a + c - b;
  res += 1000 * mod;
  res %= mod;
  cout << res << endl;
}

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

int main() {
	// your code goes here
	int n,ac,wa,tle,re;
	ac=0;
	wa=tle=re=0;
	
	cin>>n;
	cin.ignore(256, '\n');
	for (int i=0;i<n;i++) {
	    string s;
	    getline(cin, s);
	    if (s=="AC") ac++;
	    if (s=="WA") wa++;
	    if (s=="TLE") tle++;
	    if (s=="RE") re++;
	    //out<<i<<s;
	}
	cout<<"AC x "<<ac<<'\n';
	cout<<"WA x "<<wa<<'\n';
	cout<<"TLE x "<<tle<<'\n';
	cout<<"RE x "<<re<<'\n';
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// 0 <= unsigned int <= 4.2e9

void find(int v, vector<vector<int>>& A, vector<vector<bool>>& Map)
{
    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            if (v == A[i][j]) Map[i][j] = true;
        }
    }
}

int main()
{
    vector<vector<bool> > Map(3, vector<bool>(3, false));
    vector<vector<int> > A(3, vector<int>(3, 0));

    for (size_t i=0; i<3; i++) {
        for (size_t j=0; j<3; j++) {
            cin >> A[i][j];
            Map[i][j] = false;
        }
    }
    size_t N; cin >> N;
    for (size_t i=0; i<N; i++) {
        int b; cin >> b;
        find(b, A, Map);
    }

    for (size_t i=0; i<3; i++) {
        bool judge = true;
        for (size_t j=0; j<3; j++) {
            if (Map[i][j] == false) {
                judge = false;
            }
        }
        if (judge == true) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for (size_t j=0; j<3; j++) {
        bool judge = true;
        for (size_t i=0; i<3; i++) {
            if (Map[i][j] == false) {
                judge = false;
            }
        }
        if (judge == true) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    bool judge = true;
    for (int i=0; i<3; i++) {
        if (Map[i][i] == false) {
            judge = false;
        }
    }
    if (judge == true) {
        cout << "Yes" << endl;
        return 0;
    }

    judge = true;
    for (int i=0; i<3; i++) {
        int k = 2 - i;
        if (Map[i][k] == false) {
            judge = false;
        }
    }
    if (judge == true) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 1000000007




int dp[2][1 << 16];


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, x, y, z;
	cin >> n >> x >> y >> z;

	long long ans = 1;
	rep(i, n)(ans *= 10) %= MOD;

	int(*cur)=dp[0], (*nxt)=dp[1];
	cur[0] = 1;
	rep(i,n) {
		memset(nxt, 0, sizeof(dp[0]));
		rep(j,1<<x+y+z-1) if(cur[j]){
			for (int a = 1; a <= 10;a++) {
				int b = j << a;
				b |= 1 << a - 1;
				if ((b & 1 << x - 1) == 0 || (b & 1 << x + y - 1) == 0 || (b & 1 << x + y + z - 1) == 0) {
					(nxt[b&((1 << x + y + z - 1) - 1)] += cur[j]) %= MOD;
				}
			}
		}
		swap(cur, nxt);
	}
	rep(i,1<<x+y+z-1) {
		ans -= cur[i];
	}
	ans %= MOD;
	ans += MOD;
	ans %= MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s,t;
    cin>>s>>t;
    int res = t.size();
    for(int i=0; i<=s.size()-t.size(); i++)
    {
        int c = 0;
        for(int j=0; j<t.size(); j++)
            c+=s[i+j]!=t[j];
        res=min(res,c);
    }
    cout<<res;
}


Measured memory_bytes: 3652
n = gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i).select {|x| x%2 == 0}
i = 0
switch = true
while i < arr.size
  if arr[i] % 3 != 0 && arr[i] % 5 != 0
    switch = false
    break
  end
  i += 1
end

if switch
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 14404
#include <iostream>
#include <vector>
using namespace std;
const int N = 2002;
int n,k;
vector<int> g[N];
int dep[N],ans,res;

void dfs(int u,int p){
    if(dep[u]<=k/2)ans++;
    for(auto v: g[u]) {
        if(p==v)continue;
        dep[v]=dep[u]+1;
        dfs(v,u);
    }
}

int main() {
    scanf("%d%d",&n,&k);
    for(int i=1;i<n;i++){
        int u,v; scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    if(k%2==0) {
        for(int i=1;i<=n;i++){
            ans=0; dep[i]=0; dfs(i,i); res=max(res,ans);
        }
    } else {
        for(int u=1;u<=n;u++){
            for(auto v: g[u]) {
                ans=0;
                dep[u]=0; dfs(u,v);
                dep[v]=0; dfs(v,u);
                res=max(res,ans);
            }
        }
    }
    printf("%d\n", n-res);
}

Measured memory_bytes: 512
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

n, m = map(int, raw_input().split())
A = map(int, raw_input().split())
dic = {}
dic[0] = 1
S = 0
for num in A:
    S += num
    S %= m
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
ans = 0
for key in dic:
    num = dic[key]
    ans += num * (num - 1) / 2
print ans

Measured memory_bytes: 11560
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

int main(){
  int n = in();
  int l = in();
  vector<string> strs(n);
  foreach(i,strs)in(i);
  sort(all(strs));
  foreach(i,strs)cout<<i;cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
D = len(bin(max(A))) - 2
O = max(len(bin(K)) - 2,D)
M = N / 2

L = [0] * D
C = [1] * O

for a in A:
  s = str(bin(a))[2:]
  l = list(s.zfill(D))
  L = [int(i) + j for i,j in zip(l,L)]
      
L = (O - D) * [0] + L

x = 0

for i in range(O):
  tmp = 0
  if L[i] < M:
    tmp = 2 ** abs(O - i - 1)
    if x + tmp <= K:
      x += tmp

ans = 0

for a in A:
  ans += x ^ a
  
print(ans)

Measured memory_bytes: 14620
import java.util.Scanner;

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

		int x = scan.nextInt();

		int[] array = new int[x];

		if (x == 1) {
			array[0] = scan.nextInt();
			System.out.println(array[0]);
		}

		else {
			for (int i = 0; i < x; i++) {
				array[i] = scan.nextInt();
			}

			System.out.print(array[x - 1] + " ");
			for (int i = x - 2; i > 0; i--) {
				System.out.print(array[i] + " ");
			}
			System.out.println(array[0]);
		}
	}
}

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

int main() {
  int  n, q;
  ll ans = 0;
  cin >> n;
  vector<int> a(n);
  vector<ll> tmp(100000, 0);
  rep(i, n) {
    cin >> a[i];
    tmp[a[i]]++;
    ans += a[i];
  }
  cin >> q;
  vector<int> b(q), c(q);
  rep(i, q) cin >> b[i] >> c[i];
  rep(i, q) {
    ans = ans + ((c[i] - b[i]) * tmp[b[i]]);
    tmp[c[i]] += tmp[b[i]];
    tmp[b[i]] = 0;
    cout << ans << endl;
  }
  return 0;
}

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



int main(void){
    int r;
    cin >> r;
    int ans = r*r;
    cout << ans <<endl;
    
    return 0;
}


























































Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
using namespace std;
const int MAX = 12;
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0};
void bfs(vector<string> &field,int x,int y){
  queue<pair<int,int> > que;
  que.push(pair<int,int>(x,y));
  while(!que.empty()){
    int cx,cy;
    pair<int,int> tmp = que.front();que.pop();
    cx = tmp.first;
    cy = tmp.second;
    field[cx][cy] = '0';
    for(int i = 0;i < 4;i++){
      int nx,ny;
      nx = dx[i]+cx;ny = dy[i]+cy;
      if(nx >= 0 && nx < MAX && ny >= 0 && ny < MAX && field[nx][ny] == '1'){
	que.push(pair<int,int>(nx,ny));
      }
    }
  }
}
int main(){
  string tmp;
  while(cin >> tmp){
    vector<string> field(MAX);
    field[0] = tmp;
    for(int i = 1;i < MAX;i++){
      cin >> tmp;
      field[i] = tmp;
    }    

    int ans = 0;
    for(int i = 0;i < MAX;i++){
      for(int j = 0;j < MAX;j++){
	if(field[i][j] == '1'){
	  ans++;
	  bfs(field,i,j);
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7080
/* **********************************JAI SAI RAM ************************************* */
//HELP IN CODEFORCES ROUND 641
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void  solve()
{
    ll n,i,j,k,l,m,o,q,r,t,x,y,a,b;
    ll ans=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        ans+=(n-i+1)*(i);
        if(i>=2)
        {
            cin>>j>>k;
            if(j>k)
            swap(j,k);
            ans-=(j*(n-k+1));
        }
    }
    cout<<ans<<endl;
}
int main()
{
    ll t;
    t=1;
        while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int a[N],n,d[N],sum;
void no(){
	puts("NO");
	exit(0);
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i],d[i]=a[i]-a[i-1];
	d[1]=a[1]-a[n];
	int tmp=n*(n+1)/2;
	if (sum%tmp)no();
	int k=sum/tmp,sum2=0;
	for (int i=1;i<=n;i++){
		int x=d[i]+k*(n-1);
		if (x%n!=0)no();
		x/=n;
		if (k-x<0||k-x>k)no();
		sum2+=k-x; 
	}
	printf("%s\n",sum2==k?"YES":"NO");
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c < 22)
		cout << "win" << endl;
	else
		cout << "bust" << endl;
	return 0;
}

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

const int maxn = 1e5 + 10;
int n, dp[2][maxn], pre[maxn], suf[maxn];
vector<int> adj[maxn], adj2[maxn];

void prep(int v, int p){
	for(int u : adj2[v]){
		if(u != p){
			prep(u, v);
			adj[v].push_back(u);
		}
	}
}

void dfs(int v){
	if(adj[v].size() == 0){
		dp[1][v] = true;
		dp[0][v] = false;
		return;
	}

	dfs(adj[v][0]);
	dp[1][v] = dp[0][adj[v][0]];
    for(int i = 1; i < adj[v].size(); i++){
		int u = adj[v][i];

		dfs(u);

		dp[1][v] &= dp[0][u];
    }

	pre[0] = dp[0][adj[v][0]];
    for(int i = 1; i < adj[v].size(); i++){
		int u = adj[v][i];

		pre[i] = dp[0][u] & pre[i - 1];
    }

    suf[adj[v].size()] = 1;
    for(int i = adj[v].size() - 1; i >= 0; i--){
		int u = adj[v][i];

		suf[i] = dp[0][u] & suf[i + 1];
    }

    dp[0][v] = dp[1][adj[v][0]] & suf[1];

    for(int i = 1; i < adj[v].size(); i++){
		dp[0][v] |= (pre[i - 1] & dp[1][adj[v][i]] & suf[i + 1]);
    }
}

int main(){
	ios_base::sync_with_stdio(false);

	cin >> n;

	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		adj2[a].push_back(b);
		adj2[b].push_back(a);
	}

	prep(1, 0);
	dfs(1);

	cout << (dp[0][1] ? "Second" : "First") << endl;

//	for(int i = 1; i <= n; i++){
//		cout << i << ' ' << dp[0][i] << ' ' << dp[1][i] << endl;
//	}
//
//	for(int i = 0; i <= 2; i++){
//		cout << pre[i];
//	}

	return 0;
}


Measured memory_bytes: 11776
import heapq
import copy

N, K = map(int, input().split())
*V, = map(int, input().split())

M = min(N, K)

ans = 0
a = 0
ah = []
for i in range(M + 1):
    if i > 0:
        v = V[i - 1]
        a += v
        if v < 0:
            heapq.heappush(ah, v)

    b = a
    bh = copy.copy(ah)
    for j in range(M + 1):
        if (i + j) > M:
            break
        if j > 0:
            v = V[N - j]
            b += v
            if v < 0:
                heapq.heappush(bh, v)

        c = b
        ch = copy.copy(bh)
        for n in range(min(K - i - j, len(ch))):
            c += -heapq.heappop(ch)
        if c > ans:
            ans = c

print(ans)

Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = x / 11;
		long ans = 0;
		long b = 0;
		if(a == 0) {
			ans = (x > 6 ? 2 : 1);
		} else {
			ans = a * 2;
			b = x % 11;
			if(b != 0) ans += (b > 6 ? 2 : 1);
		}
		System.out.println(ans);
	}
}


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

int main(void){
    int n,q;
    cin >> n >> q;

    stack<int> st[n]; // stackの配列だよ

    for(int i=0; i<q; i++){
        int cmd;
        cin >> cmd;
        if(cmd==0){
            int t,x;
            cin >> t >> x;
            st[t].push(x);
        }
        else if(cmd==1){
            int t;
            cin >> t;
            if(!st[t].empty()) cout << st[t].top() << "\n";
        }
        else if(cmd==2){
            int t;
            cin >> t;
            if(!st[t].empty()) st[t].pop();
        }
    }
    return 0;
}


Measured memory_bytes: 4364
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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


int main()
{
  int N, M;
  cin >> N >> M;
  int e = M / N;
  for (int i = e; i >= 1; i--) {
    if (M % i == 0 && M / i >= N) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 764
#include <iostream>
#include <cstring>
#include <cmath>

using namespace std;

const int maxn=1e2+10;
int a[maxn][maxn];
int dp[maxn][maxn];
int N;

void solve()
{
	dp[1][1]=a[1][1];
	
	int i,j;
	for(i=1;i<=2;i++)
		for(j=1;j<=N;j++)
		{
			if(i==1)
				dp[i][j]=dp[i][j-1]+a[i][j];
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
}

int main(int argc, char *argv[]) {
	while(cin>>N)
	{
		//cout<<"N="<<N<<endl;
		memset(a,0,sizeof(a));//初始化函数
		memset(dp,0,sizeof(a));
		
		int i,j;
		for(i=1;i<=2;i++)
		{
			//cout<<"i="<<i<<endl;
			for(j=1;j<=N;j++)
				cin>>a[i][j];	
		}
		solve();
		cout<<dp[2][N];
	}
	return 0;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		long[] A = new long[N];
		int cnt = 0;
		for (int i = 0; i < N; ++i) {
			A[i] = sc.nextLong();
			while (A[i] % 2 == 0) {
				A[i] /= 2;
				++cnt;
			}
		}
		System.out.println(cnt);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

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

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

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

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		int nextInt() {
			return (int) nextLong();
		}
	}

}


Measured memory_bytes: 23124
i= [int(i) for i in input().split()]
A = i[0]
B = i[1]
C = i[2]
K = i[3]
m = 0
if K>=A:
    m += A*1
    K -= A
else:
    m +=K*1
    K=0
if K>=B:
    m += B*0
    K -= B
else:
    m +=K*0
    K=0
if K>=C:
    m += C*-1
    K -= C
else:
    m +=K*-1
    K=0
print(m)

Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define ll          long long int
#define pb          push_back
#define mpp         make_pair
#define vll         vector<ll>
#define mll         unordered_map<ll,ll>
#define endl        "\n"
#define debug(x)    cout<< #x <<"="<<x<<"\n"
#define fo(i,a,x)   for(ll i=a;i<x;++i)
#define fastio      ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

ll n,m,k,cnt=0;
vector<bool>visited;
vector<vll>graph;
void dfs(ll i)
{
    cnt++;
    // cout<<"##"<<i;
    visited[i] = true;
    for(int j=0;j<graph[i].size();j++)
    {
        if(!visited[graph[i][j]])
        {
            dfs(graph[i][j]);
        }
    }
}

void solve()
{
    // cout<<"hi";
     cin>>n>>m;
     int u,v;
     
     graph.resize(n+1);
     set<ll>st[n+1];
     for(int i=0;i<m;i++)
     {
        cin>>u>>v;
        if(st[u].find(v)==st[u].end())
        {
            graph[u].push_back(v);
            st[u].insert(v);
        }
        if(st[v].find(u)==st[v].end())
        {
            graph[v].push_back(u);
            st[v].insert(u);
        }
     }

     visited.resize(n+1,false);
     ll ans=0;
     for(int i=1;i<=n;i++)
     {
        if(!visited[i])
        {
            cnt=0;
            dfs(i);
            // debug(cnt);
            ans = max(ans,cnt);
        }
     }
     cout<<ans<<endl;
}

int main()
{
    fastio;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ll t=1; 
    // cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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


int main(){
  int N;
  cin >> N;
  vector<int>W(N);
  for(int i=0;i<N;i++){
    cin >> W.at(i);
  }
  int ans=1e9;
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=W[i];
  }
  int sum2=0;
  for(int i=0;i<(N-1);i++){
    sum2+=W[i];
    int dif=abs(sum-sum2);
    ans = min(abs(dif-sum2),ans);
  }
  cout << ans << endl;
    
  
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum,min=10000000,max=-1,k;
	for(int i=0;i<5;i++)
	{
		cin>>n;
		if(min>n)
		min=n;
		if(max<n)
		max=n;
	}
	cin>>k;
	if(max-min<=k)
	cout<<"Yay!"<<endl;
	else
	cout<<":("<<endl;
	return 0;
}


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

bool sieve[1000000];

int nextPrime(int n){
	int i, p;
	memset(sieve, true, sizeof(sieve));
	sieve[0] = false, sieve[1] = false;
	for(i=0;i*i<=1000000;i++){
		if(sieve[i]){
			for(p=i*i;p<=1000000;p+=i)sieve[p]=false;
		}
	}
	//for(i=0;i<n;i++)cout << sieve[i] << " ";
	for(i=n;i<1000000;i++){
		if(sieve[i])return i;
	}
	return 0;
}

int main()
{
	int s;
	cin>>s;
	cout << nextPrime(s) << endl;
}

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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
    cout << intpow(in(),3) << endl;
}

Measured memory_bytes: 256
D = int(input())
C = [*map(int, input().split())]
S = [[*map(int, input().split())] for _ in range(D)]

# print(D)
# print(C)
# print(*S,sep='\n')

O = [[0]*26 for _ in range(D)]
A = [[0]*26 for _ in range(D)]

def last(d,t):
    for i in range(d,-1,-1):
        if O[i][t] > 0: return i
    return 0

score = 0
t = 0
for d in range(D):
    O[d][t] = 1
    dw = 0
    for i in range(26):
        dw += C[t]*(d - last(d,i))
    A[d][t] = S[d][t] - dw
    score += A[d][t]
    print(t+1)
    t = (t+1) % 26
# print(score)

# t = 0
# for d in range(D):
#     O[d][t] = 1
#     dw = 0
#     for i in range(26):
#         dw += C[t]*(d - last(d,i))
#     A[d][t] = S[d][t] - dw
#     print(t)
#     t = (t+1) % 26

# for d in range(D):
#     s = 0
#     for t in range(26):
#         s += C[t]*(d - last(d,t))
#     print(s)


Measured memory_bytes: 9664
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
//#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int cnt[4];
  rep(i,4) cnt[i]=0;
  rep(i,3) {
    int a,b;
    cin>>a>>b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  rep(i,4) {
    if(i==0||i==3) {
      if(cnt[i]==1) continue;
      else {
        cout<<"NO"<<endl;
        return 0;
      }
    }
    else if(i<3){
      if(cnt[i]==2) continue;
      else {
        cout<<"NO"<<endl;
        return 0;
      }
    }
  }
  cout<<"YES"<<endl;
}

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



int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> lines(n,0);
  for(int i = 0; i < n; i++){
    cin >> lines.at(i);
  }
  sort(lines.begin(), lines.end());
  reverse(lines.begin(), lines.end());
  int len = 0;
  for(int i = 1; i < n; i++){
    len += lines.at(i);
  }
  cout << (lines.at(0) < len ? "Yes" : "No") << endl;
  return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int a = scan.nextInt();
	int b = scan.nextInt();
	int c = scan.nextInt();

	if(a == b){
	    System.out.println(c);
	}else if(a == c){
	    System.out.println(b);
	}else{
	    System.out.println(a);
	}
    }
}


Measured memory_bytes: 22868
#include <iostream>
#include <map>
#include <vector>
#define int long long
typedef long long ll;
using namespace std;

ll n, count=0, A[200001];
map<int, int> S;
signed main(){
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> A[i];
        S[i+A[i]]++;
        count += S[i-A[i]];
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 27752
//============================================================================
// Name        : competitive_programing.cpp
// Author      : .Data_Nerd.
// Description : problem solving training
//============================================================================

#include <bits/stdc++.h>
#define Data_Nerd ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define files freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mod 1000000007
#define OO 0x3f3f3f3f
#define NIL -1
using namespace std;
typedef long long ll;

struct item {
	int weight;
	ll value;
};

vector <item> item_list;

int n, w;

ll memo[105][100005];

ll knapsack(int idx, int capacity){
	if(idx == n)
		return 0;
	if(memo[idx][capacity] != NIL)
		return memo[idx][capacity];
	memo[idx][capacity] = knapsack(idx + 1, capacity);
	if(capacity >= item_list[idx].weight)
		memo[idx][capacity] = max(item_list[idx].value + knapsack(idx + 1, capacity - item_list[idx].weight), memo[idx][capacity]);
	return memo[idx][capacity];
}

int main() {
	Data_Nerd

	memset(memo, NIL, sizeof(memo));

	scanf("%d%d", &n, &w);

	item_list.resize(n);

	for(int i = 0; i < n; ++i){
		scanf("%d%lld", &item_list[i].weight, &item_list[i].value);
	}

	printf("%lld", knapsack(0, w));

	return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n) {
        int a;
        cin >> a;
        if (a%2 == 1 && i%2 == 0) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a1, a2, a3, a4;
    int b1, b2, b3, b4;
    
    cin >> a1 >> a2 >> a3 >> a4;
    cin >> b1 >> b2 >> b3 >> b4;
    
    cout << max(a1+a2+a3+a4,b1+b2+b3+b4) << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>suuretsu(N);
  vector<int>ta(N);
  for (int i=0;i<N;i++){
    cin>>suuretsu.at(i);
  }
  ta=suuretsu;
  sort(ta.begin(), ta.end());
   for (int i=0;i<N;i++){
    if (suuretsu.at(i)<ta.at(N-1)){
      cout <<ta.at(N-1)<<endl;
    }
    if (suuretsu.at(i)==ta.at(N-1)){
      cout <<ta.at(N-2)<<endl;
    }
  }
}     
     
 

Measured memory_bytes: 3200
#include <iostream>
#include <string.h>

int road[52][52];
int n,m;

int find(int i)
{
	int res = 0;
	for(int j = 1; j <= n; ++j)
			res += road[i][j];
	return res;
}

int main()
{
	memset(road,0,sizeof(road));
	scanf("%d %d",&n,&m);
	int a, b;
	while(m--)
	{
		scanf("%d %d",&a,&b);
		road[a][b]++;
		road[b][a]++;
	}
	for(int j = 1; j <= n; j++)
		printf("%d\n",find(j));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int impossible(){
	cout << -1 << endl;
	return 0;
}

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	reverse( a.begin(), a.end() );
	ll ans = 0;
	for( int i = 0; i < n-1; ++i ){
		if( a[i] - a[i+1] > 1 ) return impossible();
		if( a[i] <= a[i+1] ) ans += a[i];
		else if( a[i] != 0 ) ++ans;
	}
	if( a[n-1] != 0 ) return impossible();
	cout << ans << endl;
	/*
	for( int i = 1; i < n; ++i ){
		if( i == 1 ){
			if( a[i-1] < a[i] ) ans += a[i-1];
			else if( a[i-1] != 0 ) ++ans;
		}
		if( ( i == n-1 and a[i] != 0 ) or a[i-1] - a[i] > 1 ) return impossible();
		else if( a[i-1] == a[i] ) ans += a[i];
		else if( a[i] != 0 ) ++ans;
	}
	*/
}



Measured memory_bytes: 1792
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s,s1,s2;
	getline(cin,s1);
	s=s1;
	reverse(s.begin(),s.end());
	for(int i=0;i<=s.length()-1;i++)
	{
		if(s[i]=='b') s[i]='d';
		else if(s[i]=='d') s[i]='b';
		else if(s[i]=='p') s[i]='q';
		else if(s[i]=='q') s[i]='p';
	} 
	s2=s;
	if(s2==s1)
	{
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
def f(n):
  if n%4 == 0:
    return n
  elif n%4 == 1:
    return n^(n-1)
  elif n%4 == 2:
    return n^(n-1)^(n-2)
  else:
    return 0
print(f(b)^f(a-1))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string s;
    cin >> s;
    if (s == "Sunny")
    {
        cout << "Cloudy";
    }else if(s == "Cloudy")
    {
        cout << "Rainy";
    }else{
        cout << "Sunny";
    }
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<pair<char, ll>> char_list;
  char now;
  ll cnt = 1;
  for (ll i = 0; i < N; ++i) {
    if (i == 0) {
      now = S[i];
      continue;
    }
    if (now == S[i]) {
      cnt += 1;
    }
    else {
      char_list.push_back({now, cnt});
      now = S[i];
      cnt = 1;
    }
  }
  char_list.push_back({now, cnt});
  ll ans = 0;
  for (ll i = 0; i < char_list.size(); ++i) {
    ans += char_list.at(i).second - 1;
  }
  ll r_cnt = 0, l_cnt = 0;
  for (ll i = 1; i < char_list.size() - 1; ++i) {
    if (char_list.at(i).first == 'L') {
      l_cnt += 1;
    }
    else {
      r_cnt += 1;
    }
  }
  char check;
  if (r_cnt > l_cnt) {
    check = 'R';
  }
  else {
    check = 'L';
  }
  if (max(r_cnt, l_cnt) >= K) {
    ans += 2 * K;
    cout << ans << endl;
    return 0;
  }
  else {
    ans += 2 * max(r_cnt, l_cnt);
    if (char_list.at(0).first == check) {
      ans += 1;
    }
    if (char_list.at(char_list.size() - 1).first == check) {
      ans += 1;
    }
    if (r_cnt == l_cnt && char_list.at(char_list.size() - 1).first == check && char_list.at(0).first == check) {
      ans -= 2;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 2548
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 4005;
const ll mod = 1e9+7;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
int power(long long a, long long b) {
    int c = 1;
    while (b) {
        if (b & 1) c = c * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return c;
}

int comb(int a,int b){
    long long x = 1, y = 1;
    for (int i = 0; i < b; i++) {
        x = x * (a - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int n,a,b;
    cin>>n>>a>>b;

    int res=1;
    int base=2;

    int n1=n;

    n1%=mod;

    while(n1>0){
        if(n1&1){
            res=(res*base)%mod;
        }
        base = (base * base)%mod;
        n1>>=1;
    }

    res%=mod;

    //cout<<res<<" "<<comb(n,a)<<" "<<comb(n,b)<<"\n";

    int ans = res-comb(n,a)-comb(n,b)-1;

    cout<<(ans%mod+mod)%mod<<"\n";
    return;
}
// how r u bro

Measured memory_bytes: 3612