akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=101000;
int n,u,v;
int dis[N],dis2[N];
VI e[N],br[N];

void dfs(int u,int f) {
	dis[u]=0;
	for (auto v:e[u]) {
		if (v==f) continue;
		dfs(v,u);
		dis[u]=max(dis[u],dis[v]+1);
		br[u].pb(dis[v]+1);
	}
}

void dfs2(int u,int f) {
	int mx=0,mx2=0;
	if (u!=1) br[u].pb(dis2[u]);
	mx=dis2[u];
	//printf("uu %d %d\n",u,dis2[u]);
	for (auto x:br[u]) {
		if (x>mx) mx2=mx,mx=x;
		else if (x>mx2) mx2=x;
	}
	for (auto v:e[u]) {
		if (v==f) continue;
		if (dis[v]+1==mx) dis2[v]=mx2+1;
		else dis2[v]=mx+1;
		dfs2(v,u);
	}
}
int main() {
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d%d",&u,&v);
		e[u].pb(v);
		e[v].pb(u);
	}
	dfs(1,0);
	dfs2(1,0);
	/*rep(i,1,n+1) {
		for (auto x:br[i]) printf("%d ",x);
		puts("");
	}*/
	int t=0;
	rep(i,1,n+1) if (SZ(br[i])>=3) {
		sort(all(br[i]));
		reverse(all(br[i]));
		t=max(t,br[i][0]+br[i][2]-(br[i][0]==br[i][2]));
	}
	rep(i,1,n+1) putchar((i<=2||i>t)?'1':'0');
	puts("");
}



Measured memory_bytes: 24372
fun main(args: Array<String>) {
  val N = readInt()
  val A = readInts()
  if (A.filter { it % 2 == 0 }.all { it % 3 == 0 || it % 5 == 0 }) {
    println("APPROVED")
  } else {
    println("DENIED")
  }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLong() = readString().toLong()
fun readLongs() = readStrings().map { it.toLong() }


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

int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) > abs(x - b))
		cout << "B" << endl;
	else
		cout << "A" << 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);
		int n = sc.nextInt();
		int[] a = new int[100000];
		for(int i = 0 ; i < n ; i++){
			a[i] = sc.nextInt();
		}
		
		int ans = 0;
		for(int i = 0 ; i < n ; i++){
			ans += a[i]*(1-2*(i%2));
		}
		System.out.printf(Integer.toString(ans));
		for(int i = 1 ; i < n ; i++){
			ans = ans*(-1)+2*a[i-1];
			System.out.printf(" "+Integer.toString(ans));
		}
	}
}

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

/*#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;*/

/*#include <ext/pb_ds/assoc_container.hpp>   // Policy_based_Data_Structure 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key*/


#define ll long long int
#define bigint int64_t
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define MOD 1000000007
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int main(){
    IOS;
    //io_set();
    ll a, b, c;
    cin >> a >> b >> c;
    if(a >= c){
       a -= c;
       cout << a << " " << b << endl;
    }
    else{
      c -= a;
      cout << 0 << " " << max(0ll, b-c) << endl;
    }
    return 0;
} 

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

int MOD, n, fac[3010], inv[3010], g[3010][3010], f[3010], pw[3010 * 3010];

int Kissme(int x, int y, int M) {
  int c = 1;
  while(y) {
    if(y & 1) c = (long long)c * x % M;
    x = (long long)x * x % M;
    y >>= 1;
  }
  return c;
}

int Dust(int x, int y) {
  return (long long)fac[x] * inv[y] % MOD * inv[x - y] % MOD;
}

void Ash(void) {
  fac[0] = 1;
  for(int i = 1; i <= n; i++)
    fac[i] = (long long)fac[i - 1] * i % MOD;
  inv[n] = Kissme(fac[n], MOD - 2, MOD);
  for(int i = n - 1; i >= 0; i--)
    inv[i] = (long long)inv[i + 1] * (i + 1) % MOD;
  pw[0] = 1;
  for(int i = 1; i <= n * n; i++)
    pw[i] = pw[i - 1] * 2 % MOD;
}

int main(void) {
  scanf("%d%d", &n, &MOD);
  Ash();
  g[0][0] = f[0] = 1;
  for(int i = 1, op; i <= n; i++) {
    for(int j = 0; j <= i; j++)
      g[i][j] = ((long long)(j + 1) * g[i - 1][j] + g[i - 1][j - 1]) % MOD;
    for(int j = 0; j <= i; j++)
      f[i] = (f[i] + (long long)g[i][j] * pw[(n - i) * j]) % MOD;
  }
  for(int i = 0; i <= n; i++)
    f[i] = (long long)f[i] * Kissme(2, Kissme(2, n - i, MOD - 1), MOD) % MOD;
  int ans = 0;
  for(int i = 0, op = 1; i <= n; i++, op = -op)
    ans = (ans + (long long)op * Dust(n, i) * f[i] % MOD + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}



Measured memory_bytes: 70912
#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--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    int h,a;
    cin >> h >> a;
    if(h % a == 0) cout << h/a << endl;
    else cout << h/a + 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int main(){
	ll N,x[110],y[110],h[110],H,p=0;
	cin>>N;
	REP(i,N){
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0){
			p=i;
		}
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			H=h[p]+abs(i-x[p])+abs(j-y[p]);
			int count=0;
			for(int k=0;k<N;k++){
				if(k==p)continue;
				if(std::max(H-abs(i-x[k])-abs(j-y[k]),0LL)==h[k]){
					count++;
				}
			}
			if(count==N-1){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
			if(i==100&&j==0){DEB(H)END}
		}
	}
	return 0;
}
//h[i]=H-abs(Cx-x[i])+abs(Cy-y[i])
//H=h[i]+abs(Cx-x[i])+abs(Cy-y[i])

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

int main(){
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    if(H % h == 0 && W % w == 0){
        cout << "No" << endl;
        return 0;
    }

    long long int minus = (H / h) * (W / w);
    long long int plus  = H * W - minus;
    long long int x = plus - minus * (h*w - 1);

    if(x < 0){
        cout << "No" << endl;
        return 0;
    }

    long long int p = (minus + x) / x;
    long long int m = - p * (h * w - 1) - 1;

    if(p > 1e9 || m < -1e9){
        cout << "No" << endl;
        return 0;
    }

    vector<vector<long long int>> a(H, vector<long long int>(W));
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            a[i][j] = p;
            if((i+1) % h == 0 && (j+1) % w == 0) a[i][j] = m;
        }
    }

    cout << "Yes" << endl;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << a[i][j];
            if(j == W-1) break;
            cout << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string S;
    cin >> S;
    int n = S.size();
    int count = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(S[i]==S[j])count++;
            if(count==1)goto RESULT;
        }
    }

RESULT:
    if(count==1)cout << "no";
    else cout <<"yes";
}


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

using namespace std;

#define MAX 1010
const bool debug = 0;

const long long mod = 1000000007;
int N,M,A[MAX],B[MAX];

void compute() {
  long long ans = 1;
  map<int,int> mp_A, mp_B;
  set<int> put_A, put_B;
  for(int i=0;i<N;++i) mp_A[A[i]] = i;
  for(int i=0;i<M;++i) mp_B[B[i]] = i;
  
  for(int i=N*M;i>=1;--i) {

    bool exist_A = ( mp_A.count(i) != 0 );
    bool exist_B = ( mp_B.count(i) != 0 );

    if( exist_A  && exist_B ) {
      put_A.insert( mp_A[i] );
      put_B.insert( mp_B[i] );
      
    } else if( exist_A ) {
      ans *= (long long)put_B.size();
      ans %= mod;
      put_A.insert( mp_A[i] );
      
    } else if( exist_B ) {
      ans *= (long long)put_A.size();
      ans %= mod;
      put_B.insert( mp_B[i] );
      
    } else {
      long long coef = ( (long long)put_A.size() * (long long)put_B.size() );
      coef %= mod;
      coef -= ( N * M - i );
      if( coef < 0LL ) coef += mod;
      ans *= coef;
      ans %= mod;
    }
    
  }
  
  cout << ans << endl;
}

int main() {
  cin >> N >> M;
  for(int i=0;i<N;++i) cin >> A[i];
  for(int i=0;i<M;++i) cin >> B[i];
  compute();
  return 0;
}


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


int main() {
  int a = 0;
  int b = 0;
  cin >> a ;
  cin >> b ;

  if ( (a+b)%2 != 0 ) {
    puts("IMPOSSIBLE") ;
    return 0 ;
  }

  cout << (a+b)/2 << endl ;
  
 
  return 0 ;
}



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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
int mod = 1000000007;

int mymod(int num){
  if (num< 0){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

double eps = .0000000001;

int main ()
{
  prep ();
  int n;
  cin >> n;
  int minn = 1000000000;
  int sums[n];
  int arr[n];
  for (int i=0; i<n; i++){
      cin >>arr[i];
      sums[i] = arr[i];
  }
  for (int i=1; i<n; i++){
      
      sums[i] = sums[i]+sums[i-1];
  }
  for (int i=0; i<n-1; i++){
      minn = min(minn, abs(sums[i]-(sums[n-1]-sums[i])));
  }
  cout << minn;
  return 0;
  
}
// in dp problems think: up until here, intervals, or "what if there's 1, 2, 3..."
// in math problems write out equations
// also in math problems to change multiplication/division to addition/subtraction use logs, add/subtract something to make the multiplication easier (like if it's 3*f(x)+2, change it to 3*(f(x)+1)-1)
// if printint pow function, put an (int) or (long long) next to it
// if checked everything check for bugs (like sorting wrong way or not putting a break in a loop)
// if n is 10^7 try brute force if the operations are simple
// if can't do dp do brute force/greedy
// to save time don't copy maps/vectors into variables if it already exists
// only use long long if need to
// if wrong on decimal problem, check if program rounds or if you can round to a certain amt of decimals
// if decimals too, if can subtract instead of divide
// in grid traversal problems check if doing sideways or not
// if TLE try to take away loop
// in recursion looking math problems look at things from the point of view of both sides (the start and the end sections of the recursion)
// think about how many possible answers there are to the problem
// try to set the answer to the problem and see if it's possible (like w/ binary search)
// if it makes it easier use +1 indexing
// think twice when writing things down that you're going to use later
// for conversions think if you can compute them w/ only one conversion 
// if the problem involves two things moving at the same time, see if you can generalise it to just one thing moving (590/B) (1117/C)
// if nt think primes
// see if you can do a pattern of steps to achieve something (1148/C) (1119/C)
// for problems where you're searching for like a pair that requires something, if it's a yes/no prob, don't focus on individual elements if it's too long (593/B)
// if sub-interval requirements, try to reduce problem into prefix array problem (pairwise numbers) (1174/D)
// think from the end of the problem (if this is the result, what is an attribute of it?)
// if repeating action, if good for debugging use function
// if you know you can do bin search to make it easier but can also solve it shorter way, just do bin search

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

right = 0
xor = 0
S = 0
ans = 0
for left, a in enumerate(A):
    while right < N and (xor ^ A[right]) == (S + A[right]):
        xor ^= A[right]
        S += A[right]
        right += 1
    S -= a
    xor ^= a
    ans += right - left

print(ans)


Measured memory_bytes: 23560
n, m = map(int, input().split(' '))
A = [[None for i in range(m)] for j in range(n)]
for i in range(n):
    table = list(map(int, input().split(' ')))
    for j in range(m):
        A[i][j] = table[j]

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

c = [None] * n
for i in range(n):
    for j in range(m):
        if c[i] is None:
            c[i] = A[i][j] * b[j]
        else:
            c[i] += A[i][j] * b[j]

for item in c:
    print(item)
            


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

using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int Q;
  int maxN = 50000+10;
  cin >> Q;
  vector<vector<int>> lr(Q, vector<int>(2));
  for(int i=0;i<Q;++i){
    cin >> lr[i][0] >> lr[i][1];
  }
  
  vector<int> sum(maxN);
  for(int i=0;i<maxN;++i){
    if(i==0){
      sum[i] = 0;
    }else{
      if(IsPrime(2*i-1) && IsPrime(i)){
        sum[i] = sum[i-1] + 1;
      }else{
        sum[i] = sum[i-1];
      }
    }
  }
  
  for(int i=0;i<Q;++i){
      cout << sum[(lr[i][1]+1)/2]-sum[(lr[i][0]+1)/2-1] <<endl;
  }
}

Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll N, M;
	cin >> N >> M;
	bool flag = false;
	map<ll, ll>mp;
	for (ll i = 0; i < M; i++) {
		ll a, b;
		cin >> a >> b;
		if (a == 1) mp[b]++;
		if (b == N) mp[a]++;
	}
	for (auto p : mp) {
		if (p.second >= 2)
			flag = true;
	}
	cout << ((flag) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


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


int main(){
  int x,a,b;
  cin >> x >> a >> b;
  
  if(b >= x+a+1) cout << "dangerous" << endl;
  if(x+a >= b && b > a) cout << "safe" << endl;
  if(a >= b) cout << "delicious" << endl;
}

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



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

    long long count_0 = 0;
    long long count_1 = 0;

    for(long long i = 0; i < s.size(); i++){
        if(s[i] == '0'){
            count_0++;
        }
        else{
            count_1++;
        }
    }

    if(count_0 == 0 || count_1 == 0){
        printf("0\n");
    }
    else{
        printf("%lld\n", 2*min(count_0, count_1));
    }

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define reps(i,j,k) for(int i=j;i<k;i++)
#define rep(i,j) reps(i,0,j)
#define InumF 1<<30
#define fr first
#define sc second
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
typedef pair<int,int> Pii;

int main(){
	string str;
	int n;
	while(true){
		cin >> str;
		scanf("%d",&n);
		if(str == "0" && n == 0)break;
		int len = str.size();
		string numew="";
		numew += str[0];
		reps(i,1,len){
			if(isdigit(str[i-1]) && isalpha(str[i])){
				numew += "(";
				numew += str[i];
				numew += ")";
			}
			else{
				numew += str[i];
			}
		}
		str = numew;
		stack < int > S;
		vector<int> par(1280,-1);
		vector<int> num(1280,-1);
		rep(i,str.size()){
			if(isdigit(str[i])){
				string tmp = "";
				int j;
				for(j = i; str[j] != '(' ;j++){
					tmp += str[j];
				}
				num[i] = atoi(tmp.c_str());
				i = j;
			}
		}

		rep(i,str.size()){
			if(str[i] == '('){
				for(int j = i-1; j >= 0; j--){
					if(num[j] != -1){
						S.push(j);
						break;
					}
				}
			}
			if(str[i] == ')'){
				par[i] = S.top();
				S.pop();
			}
			//cout << num[i] << " ";
		}


		int now = 0;
		int cnt = 0;
		vector<int> nex = num;
		
		while(true){
			//cout<<now<<"("<<cnt<<")"<<" ";
			if(isalpha(str[now])){
				//cout<<str[now];
				if(cnt == n){
					cout<<str[now]<<endl;
					break;
				}
				now++,cnt++;
			}
			else if(isdigit(str[now])){
				nex[now]--;
				if(nex[now] == 0)nex[now] = num[now];
				int j = now;
				while(true){
					if(str[j] == '(')break;
					j++;
				}
				j++;
				now = j;
			}
			else if(str[now] == '(')now++;
			else if(str[now] == ')'){
				if(nex[par[now]] == num[par[now]])now++;
				else now = par[now];
			}
			if(now == str.size()){
				cout<<0<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
#define ul unsigned long long
#define ll long long
#define ld long double

int main() {
  int N;
  cin>>N;
  int ans=N%1000;
  ans=(1000-ans)%1000;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>  
using namespace std;
#define rep(i,k,n) for(int i=(int)(k); i<(int)(n); i++)

int main() {
  int n,x,y; cin>>n>>x>>y;
  x--;y--;
  vector<int> v(n-1,0);
  rep(i,0,n-1){
    rep(j,i+1,n){
      int k=j-i-1;
      if(i<=x && y<=j){
        k+=x-y+1;      
      }
      k=min(k,abs(x-i)+abs(y-j));
      v[k]++;
    }
  }
  rep(i,0,n-1){cout<<v[i]<<endl;}
}

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

using namespace std;
using ll = long long;

int main() {
    int n,m;
    cin>>n>>m;
    vector<int> h(n);
    for(int i = 0;i < n;++i) {
        cin>>h[i];
    }
    vector<bool> yoi(n,true);
    for(int i = 0;i < m;++i) {
        int a,b;
        cin>>a>>b;
        --a;--b;
        if(h[a]<=h[b])yoi[a]=false;
        if(h[b]<=h[a])yoi[b]=false;
    }
    int ans=0;
    for(int i = 0;i < n;++i) {
        if(yoi[i])++ans;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int t = 1;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != s[s.size() - 1 - i])
            t = 0;
    }

    if(t == 1){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef long double ld;

const ll MOD=1e9+7;
ll modpow(ll b, ll i){
  ll s=1;
  while(i){
    if(i%2) s=(s*b)%MOD;
    b=(b*b)%MOD; i/=2;
  }
  return s;
}
ll nCr(ll n, ll r){
  ll m1=1,m2=1;
  for(int i=0; i<r; i++){
    m1=(m1*(n-i))%MOD; m2=(m2*(r-i))%MOD;
  }
  return (m1*modpow(m2,MOD-2))%MOD;
}
int main(){
  int n,a,b; cin >>n >>a >>b;  
  cout <<(modpow(2,n)-nCr(n,a)-nCr(n,b)-1+2*MOD)%MOD;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct dictionary{
  struct dictionary *A, *C, *G, *T;
  int a, c, g, t;
} dictionary;
void Insert(void);
void Find(void);
dictionary *Tree;
int main(){
  int i, n;
  char func[6];
  Tree = (dictionary *)malloc(sizeof(dictionary) * 1);
  Tree->A = Tree->C = Tree->G = Tree->T = NULL;
  Tree->a = Tree->c = Tree->g = Tree->t = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",func);
    if(strcmp(func,"insert") == 0) Insert();
    else if(strcmp(func,"find") == 0) Find();
  }
  return 0;
}
void Insert(void){
  int i;
  char in[12];
  dictionary *n, *temp=Tree;
  scanf("%s",in);
  for(i=0; in[i]!='\0' ; i++){
    switch(in[i]){
      printf("%c\n",in[i]);
      case 'A':
      if(temp->A == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->A = n;
      }
      if(in[i+1] == '\0') temp->a = 1;
      temp = temp->A;
      break;
      case 'C':
      if(temp->C == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->C = n;
      }
      if(in[i+1] == '\0') temp->c = 1;
      temp = temp->C;
      break;
      case 'G':
      if(temp->G == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->G = n;
      }
      if(in[i+1] == '\0') temp->g = 1;
      temp = temp->G;
      break;
      case 'T':
      if(temp->T == NULL){
        n = (dictionary *)malloc(sizeof(dictionary) * 1);
        n->A = n->C = n->G = n->T = NULL;
        n->a = n->c = n->g = n->t = 0;
        temp->T = n;
      }
      if(in[i+1] == '\0') temp->t = 1;
      temp = temp->T;
      break;
      default:
      break;
    }
  }
}
void Find(void){
  int i;
  char in[12];
  dictionary *temp=Tree;
  scanf("%s",in);
  // printf("%s\n",in);
  for(i=0; in[i]!='\0' ; i++){
    switch(in[i]){
      case 'A':
      if(temp->A == NULL || (in[i+1] == '\0' && !temp->a)){
        printf("no\n");
        return;
      }
      temp = temp->A;
      break;
      case 'C':
      if(temp->C == NULL || (in[i+1] == '\0' && !temp->c)){
        printf("no\n");
        return;
      }
      temp = temp->C;
      break;
      case 'G':
      if(temp->G == NULL || (in[i+1] == '\0' && !temp->g)){
        printf("no\n");
        return;
      }
      temp = temp->G;
      break;
      case 'T':
      if(temp->T == NULL || (in[i+1] == '\0' && !temp->t)){
        printf("no\n");
        return;
      }
      temp = temp->T;
      break;
      default:
      break;
    }
  }
  printf("yes\n");
}

Measured memory_bytes: 22324
fn main() {
    proconio::input! {
        n: usize, m: usize,
        mut a: [i32; m],
    }
    let total: i32 = a.iter().sum();
    let ans = n as i32 - total;
    if ans >= 0 {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

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

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=0,temp=i;
        while(temp)
            cnt++,temp/=10;
        if(cnt%2)
            ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int N, A, B;
    cin >> N >> A >> B;
    if ((A - B) % 2 == 0)
        cout << "Alice" << endl;
    else
        cout << "Borys" << endl;
    //system("pause");
}

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

using namespace std;

const int N=100005;
int n,cnt[N],mx,mn,x;

void chk(bool f){if(f)puts("Yes");else puts("No");}

int main(){
	scanf("%d",&n);mn=n;
	for(int i=1;i<=n;i++)scanf("%d",&x),cnt[x]++,mx=max(mx,x),mn=min(mn,x);
	if(mn==mx)chk(mn==n-1||mn<=n/2);
	else if(mx-mn==1)chk(cnt[mn]<=mn&&mn<=cnt[mn]+cnt[mx]/2-(cnt[mx]?1:0));
	else puts("No");
	return 0;
}

Measured memory_bytes: 640
/**********************************************************
* @Author: 			   Kirito
* @Date:   			   2020-04-12 20:07:46
* @Last Modified by:   Kirito
* @Last Modified time: 2020-04-12 20:09:07
* @Remark: 
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111111;


int main()
{
	int n;
	while(cin >> n)
	{
		ll ans = 0;
		for(int i = 1; i <= n; i++)
		{
			if(i % 3 != 0 && i % 5 != 0)
			{
				ans += i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

const int pos[4] = {0, 4, 6, 8};

int main(){

  string s = stin();

  REP( i , 4 ){
    if( SZ(s) >= pos[i] + 1 ){
      if( s[pos[i]] != 'A' ){
      s = s.substr(0, pos[i]) + "A" + s.substr(pos[i]);
      }
    } else {
      s = s + "A";
    }
  }
  // cout << s << endl;
  
  if( s == "AKIHABARA" ){
    puts( "YES" );
  } else {
    puts( "NO" );
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    char before[27] = "abcdefghijklmnopqrstuvwxyz";
    char after[27] =  "bcdefghijklmnopqrstuvwxyza";
    int index = 0;
    char s[2];
    cin >> s;
    for(int i = 0;i < 27;i++)
    {
        if(before[i] ==s[0])
        {
            index = i;
        }
    }
    cout << after[index];

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;
	cin>>n;
	cout<<(n-2)*180;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
 
using namespace std;
 
 int dx[4] = {1,0,-1,0};
 int dy[4] = {0,1,0,-1};

void dfs(vector<string> &map,vector<vector<bool> > &move,int x,int y,int h, int w){
  
    if(x < 0 || x >=w || y < 0 || y >=h){
      return ;
    }

    if(map[y][x] == '#'){
      return;
    }

    if(move[y][x]){
      return;
    }

    move[y][x] = true;

    for(int i=0;i<4;i++){
      dfs(map,move,x+dx[i],y+dy[i],h,w);
    }

    return;
}


int main()
{

  while(true){

    int w,h;
    cin >> w >> h;

    if(w==0&&h==0){
      break;
    }

    vector<string> map(h);    
    vector<vector<bool> > move(h,vector<bool>(w,false));
    int x=0,y=0;
    int count=0;

    for(int i=0;i<h;i++){
      cin >> map[i];
      //cout << map[i] << endl;
    }

    for(int i=0;i<w;i++){
      for(int k=0;k<h;k++){
        if(map[k][i]=='@'){
          x=i;
          y=k;
       
        //  cout << w << "," << h << endl;
        // cout << x << "," << y << endl; 
        }
        
     }
    
    }


    dfs(map,move,x,y,h,w);

   for(int i=0;i<w;i++){
    for(int k=0;k<h;k++){
      if(move[k][i]){
        count++;
      }
    }
   }
  
    cout << count << endl;

  }

    return 0;
}

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

const int mod=1000000007;
typedef long long ll;

struct mat{
	int a[3][3];
	mat(){memset(a,0,sizeof a);}
	mat(int A,int B,int C,int D,int E,int F,int G,int H,int I){
		a[0][0]=A;a[0][1]=B;a[0][2]=C;
		a[1][0]=D;a[1][1]=E;a[1][2]=F;
		a[2][0]=G;a[2][1]=H;a[2][2]=I;
	}
	mat operator * (const mat&b)const{
		mat c;
		for(int i=0;i<3;++i)
			for(int j=0;j<3;++j)
				for(int k=0;k<3;++k)
					c.a[i][k]=(c.a[i][k]+(ll)a[i][j]*b.a[j][k])%mod;
		return c;
	}
}A(1,0,0,0,0,0,0,0,0),p(2,1,1,2,1,2,1,0,1),q(1,1,1,0,1,2,0,0,1);

mat ksm(mat a,int b,mat c){
	for(;b;b/=2,a=a*a)
		if(b&1)c=c*a;
	return c;
}
int n,m;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m;
	int l=0;
	for(int i=1;i<=m;++i){
		int x;cin>>x;
		A=ksm(p,x-l-1,A)*q;l=x;
	}
	A=ksm(p,n-l,A);
	cout<<A.a[0][2]<<'\n';
	return 0;
}


Measured memory_bytes: 256
/**
*    created: 07.07.2020 21:58:38
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    rep(i,w+2) cout << '#';
    cout << endl;
    rep(i,h) {
        string s; cin >> s;
        cout << '#' << s << '#' << endl;
    }
    rep(i,w+2) cout << '#';
    cout << endl;
    return 0;
}

Measured memory_bytes: 3540
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define WALL 999999

int H, W;
int maze[21][21];

int bfs(int sh, int sw)
{
	int log[20*20] = {0};
	int queue[20*20] = {0};
	int qidx, qptr = 0;
	int dh[4] = {1, -1, 0,  0};
	int dw[4] = {0,  0, 1, -1};

	queue[0] = sh * W + sw;
	log[queue[0]] = 1;
	qidx = 1;
	int max = 0;
	while (qidx > qptr) {
		int pop = queue[qptr];
		++qptr;
		int n = log[pop];
		int h = pop / W;
		int w = pop % W;
		for (int i = 0; i < 4; i++) {
			int hh = h + dh[i];
			int ww = w + dw[i];
			if (hh < 0 || hh >= H)
				continue;
			if (ww < 0 || ww >= W)
				continue;
			if (maze[hh][ww] == WALL)
				continue;
			int pp = hh * W + ww;
			if (log[pp])
				continue;
			queue[qidx++] = pp;
			log[pp] = n + 1;
		}
		if (n > max)
			max = n;
	}
	return max;
}

int main(int argc, char **argv)
{
	scanf("%d%d", &H, &W);
	int sh, sw;
	for (int h = 0; h < H; h++) {
		char line[21];
		scanf("%s", line);
		for (int w = 0; w < W; w++) {
			char ch = line[w];
			if (ch == '#')
				maze[h][w] = WALL;
		}
	}
	//
	int max = 0;
	for (int h = 0; h < H; h++) {
		for (int w = 0; w < W; w++) {
			if (maze[h][w] == WALL)
				continue;
			int dis = bfs(h, w);
			if (dis > max)
				max = dis;
		}
	}
	printf("%d\n", max-1);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

vi get_num(string str){
	str.pb('.');
	string s = "";
	vector<int> vec;
	rep(i,str.size()){
		if(str[i] == '.'){
			vec.pb(atoll(s.c_str()));
			s = "";continue;
		}
		s.pb(str[i]);
	}
	return vec;
}

int length_of_year(int y){ // 1-indexed
  if(y%400 == 0 || ((y%100 != 0) && (y%4 == 0)))return 366;
  return 365;
}

int length_of_month(int y, int m){ // 1-indexed
  int monthes[12] = {31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if(m != 2)return monthes[m-1];
    if(length_of_year(y) == 366)return 29;
    return 28;
}

int date_to_int(string date){ //ex) 2018.08.05
	vector<int> vec = get_num(date);
	int ans = 0;
	int y = vec[0], m = vec[1], d = vec[2];
	repi(i,1,y)ans += length_of_year(i);
	repi(i,1,m)ans += length_of_month(y, i);
	return ans + d;
}

int maya_to_int(string date){
	vector<int> vec = get_num(date);
	int ans = 0, tmp = 1;
	int mask[] = {13, 20, 20, 18, 20};
	drep(i,5-1,0){
		ans += vec[i]*tmp;
		tmp *= mask[i];
	}
	return ans;
}

string to_str(int num){
	//return to_string(num);
	if(num == 0)return "0";
	string s = "";
	while(num > 0){
		s += ((num%10)+'0');
		num /= 10;
	}
	reverse(all(s));
	return s;
}

string anno_to_str(int date){
	int y = 1, m = 1;
	for(int i = 1;length_of_year(i) < date;i++){date -= length_of_year(i);y++;}
	for(int i = 1;length_of_month(y, i) < date;i++){date -= length_of_month(y, i);m++;}
	string ans;
	ans += to_str(y) + ".";
	ans += to_str(m) + ".";
	ans += to_str(date);
	return ans;
}

string maya_to_str(int date){
	int mark2[] = {13, 20, 20, 18, 20};
	int mark[5] = {}, ans[5] = {};
	int tmp = 20;
	drep(i,3,0){mark[i] = tmp;tmp *= mark2[i];}
	rep(i,4){
		ans[i] = date/mark[i];
		date -= mark[i]*(date/mark[i]);
	}ans[4] = date;
	string str = "";
	rep(i,4){
		str += to_str(ans[i]%mark2[i]) + ".";
	}
	return str+to_str(ans[4]);
}

signed main(){
	int B = date_to_int("2012.12.21");
	while(1){
		string str;
		cin >> str;
		if(str == "#")break;
		if(get_num(str).size() == 3){
			int num = date_to_int(str)-B;
			cout << maya_to_str(num) << endl;
		}else{
			int num = maya_to_int(str)+B;
			cout << anno_to_str(num) << endl;
		}
	}
	return 0;
}





Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int a,b; cin>>a>>b;
	if(a<=9 && b<=9) cout<<a*b;
	else cout<<-1;
	
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  ll total = 0;
  for (int a : A) total += a;
  vector<int> xs;
  for (int x = 1; x <= sqrt(total); x++) {
    if (total % x == 0) {
      xs.push_back(x);
      xs.push_back(total / x);
    }
  }
  sort(xs.begin(), xs.end(), greater<int>());

  for (int x : xs) {
    if (total % x != 0) continue;
    ll lsum = 0, rsum = 0;
    vector<int> B(N);
    for (int i = 0; i < N; i++) {
      B[i] = A[i] % x;
      rsum += x - A[i] % x;
    }
    sort(B.begin(), B.end());
    for (int i = 0; i < N; i++) {
      lsum += B[i];
      rsum -= x - B[i];
      if (max(lsum, rsum) <= K) {
        cout << x << endl;
        return 0;
      }
    }
  }
}

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

int a[102];
int main(){
	int n,p,x,m;
	long long ans = 0;
	
	cin >> n;
	for(int i = 1;i<=n;i++){
		cin >> a[i];
		ans+=a[i];
	}
	cin >> m;
	while(m--){
		cin >> p >> x;
		cout << ans-a[p]+x << endl;
	}
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


bool cmp(const pair<int,ll> &a,const pair<int,ll> &b) {
	if(a.second!=b.second)return a.second>b.second;
	else return a.first>b.first;
}

int main(void){
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    vector<P>p(m);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>p[i].first>>p[i].second;
    sort(a.begin(),a.end());
    sort(p.begin(),p.end(),cmp);
    ll num=0,index=0;
    for(int i=0;i<m;i++){
        if(num==n)break;
        bool flag=false;
        while(true){
            if(p[i].first==0)break;
            if(p[i].second>a[num]){
                a[num]=p[i].second;
                //cout<<num<<" "<<a[num]<<endl;
                p[i].first--;
                flag=true;
                num++;
            }
            else break;
        }
        if(!flag)break;
    }
    ll ans=0;
    for(ll i=0;i<n;i++)ans+=a[i];
    cout<<ans<<endl;
    return 0;
}

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



signed main(){
   int n,w,a,b;
   cin >>n>>w;
   vector<int> kati[n];
   kati[0].push_back(0);
   for(int i=1;i<=w;i++)kati[0].push_back(-1);
   for(int j=1;j<n;j++)for(int i=0;i<=w;i++)kati[j].push_back(-1);
    cin >> a>>b;
    kati[0][a]=b;
   for(int j=1;j<n;j++){
       cin >> a>>b;
       for(int i=0;i<a;i++) kati[j][i]=kati[j-1][i];;
       for(int i=a;i<w+1;i++){
       if(kati[j-1][i-a]!=-1)kati[j][i]=max(kati[j-1][i],b+kati[j-1][i-a]);
       else kati[j][i]=kati[j-1][i];
       }
   }
   int ans=0;
   for(int i=0;i<=w;i++)ans=max(ans,kati[n-1][i]);
   cout <<ans;
    return 0;
}

Measured memory_bytes: 80212
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }



int main() {
	int N, X;
	scanf("%d%d", &N, &X);
	int *A = (int *)malloc(sizeof(int)*N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	qsort(A, N, sizeof(int), cmp);
	ll sum = 0;
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (X >= A[i]) {
			cnt++;
			X -= A[i];
		}
	}

	if (cnt == N && X != 0) {
		cnt--;
	}

	ll ans = cnt;
	printf("%lld\n", ans);





#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){

 int i;
 int j;
 int n;
 int m;
 int ma[100][100] = { 0 };
 int mb[100] = { 0 };
 int mc[100] = { 0 };

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

 for(i = 0; i < n; i++){
	for(j = 0; j < m; j++){
		scanf("%d ",&ma[i][j]);
	}
 }
 
 for(j = 0; j < m; j++){
	scanf("%d",&mb[j]);
 }

 for(i = 0; i < n; i++){
	for(j = 0; j < m; j++){
		mc[i] = mc[i] + ma[i][j] * mb[j];
	}
 }

 for(i = 0; i < n; i++){
 	printf("%d\n",mc[i]);
 }

 return 0;
}

Measured memory_bytes: 1900
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N];
  int y[M];
  for(int i=0; i<N;i++) cin >> x[i];
  for(int i=0; i<M;i++) cin >> y[i];
  sort(x, x+N);
  sort(y, y+M);
  string ans = "War";
  if(X < Y){
    for(int i=X+1; i<=Y; i++){
      if(x[N-1] < i && y[0] >= i){
        ans = "No War";
        break;
      }
    }
  }

  cout << ans << endl;

}

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

int n, m, a[1005], b[1005];
constexpr long long mod = 1000000007;
int ua[1000005], ub[1000005];

int main() {
	std::cin >> n >> m;
	bool check = false;
	for (int i = 0; i < n; ++i) {
		std::cin >> a[i];
		if (ua[a[i]] != 0)
			check = true;
		++ua[a[i]];
	}
	for (int i = 0; i < m; ++i) {
		std::cin >> b[i];
		if (ub[b[i]] != 0)
			check = true;
		++ub[b[i]];
	}

	if (check) {
		std::cout << 0 << std::endl;
		return 0;
	}

	for (int i = 1; i <= n * m; ++i) {
		ua[i] += ua[i - 1];
		ub[i] += ub[i - 1];
	}

	long long ans = 1;
	for (int x = n * m; x > 0; --x) {
		if (ua[x] - ua[x - 1] != 0 && ub[x] - ub[x - 1] != 0)
			continue;
		else if (ua[x] - ua[x - 1] != 0)
			ans = ans * (ub[n*m] - ub[x - 1]) % mod;
		else if (ub[x] - ub[x - 1] != 0)
			ans = ans * (ua[n*m] - ua[x - 1]) % mod;
		else
			ans = ans * ((ua[n*m] - ua[x - 1])*(ub[n*m] - ub[x - 1]) - (n*m - x)) % mod;
	}

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


Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define pb 			push_back
#define mp 			make_pair
#define max(a,b) 	(a>b?a:b)
#define min(a,b) 	(a<b?a:b)
const int sz = 1e5 + 5;

int cnt[105], cnt2[105];

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

	char a[sz];
	scanf("%s", a);
	int w;
	scanf("%d", &w);
	int l = strlen(a);
	for(int i = 0; i < l; i+=w){
		printf("%c", a[i]);
	}
	puts("");
	
	return 0;
}

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

int main(){
  int n;
  while(cin >> n, n){
    vector<int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    
    long long ans = 0;
    for(int i=0;i<n;i++)ans += a[i]*(n-i-1);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1248