akhauriyash/Code-Regression huggingface dataset:
// 未解決

#include <bits/stdc++.h>

#include <iostream>
using namespace std;

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
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;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int x;
  cin >> x;

  REP(a, 100000) {
    int red = pow(a, 5) - x;
    // debug(red);
    int b_temp = 0;
    if (red >= 0) {
      b_temp = pow(red, 0.2);
      if (pow(a, 5) - pow(b_temp, 5) == x) {
        cout << a << " " << b_temp << endl;
        break;
      }
      // debug(b_temp);
    } else {
      b_temp = pow(-red, 0.2) * -1;
      if (pow(a, 5) - pow(b_temp, 5) == x) {
        cout << a << " " << b_temp << endl;
        break;
      }
      // debug(b_temp);
    }
  }

  // debug(pow(32, 0.2));
  return 0;
};


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  if ((b - a) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(L: int):
    return (L / 3) ** 3

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    print(solve(L))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

int main(){
string s;
int num=0;
cin>>s;
for (int i = 0; i < 3; i++)
{
    /* code */
    if (s[i]=='o')
    {
        /* code */
        num++;
    }
    
}
cout<<700+100*num<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
  
void ct(vector <long long int> v){  
  
    long long int n=v.size(); 
  
    sort(v.begin(), v.end());  
  
    long long int count = 0; 
      
    for( long long int i = n-1; i >= 1; i--){ 
        long long int l = 0, r = i-1; 
        while( l < r){ 
            if( v[l] + v[r] > v[i]){
                count += r - l ;  
                r--;   
            } 
            else {
                l++;}   
        } 
    } 
    cout<<count<<endl; 
} 
int main(){ 
  
  	long long int n,a,i;
  cin>>n;
    vector<long long int> v;  
   for(i=0;i<n;i++)
   {
     cin>>a;
     v.push_back(a);
   }
    ct(v); 
    return 0;
}     


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

    vector<ll> fivepow(1001);

    rep(i,1001){
        fivepow[i] = pow(i,5);
    }

    rep(i,1001){
        rep(j,1001){
            if(fivepow[i] + fivepow[j] == x){
                cout << i << " -" << j << endl;
                return 0;
            }else if(fivepow[i] - fivepow[j] == x){
                cout << i << ' ' << j << endl;
                return 0;
            }else if((-1)*fivepow[i] + fivepow[j] == x){
                cout << '-' << i  << " -" << j << endl;
                return 0;
            }else if((-1)*fivepow[i] - fivepow[j] == x){
                cout << '-' << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4116
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int h[100010];
    int dp[100010];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),dp[i-2] + abs(h[i]-h[i-2]));
    }
    cout << dp[n-1] << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define endl "\n"
#define loop(i,s,e) for(int i=s;i<e;i++)
#define int long long
#define mp make_pair
#define pii pair<int,int>
#define mset(a,f)  memset(a , f , sizeof(a))
#define pb push_back
const int N = 2e6 + 6;
const int M = 1e9 + 7;
int A[N];
int n , k , c;
string str;
int pre[N];
int suf[N];

void solve()
{
    int k;
    cin >> k;

    int ans = 0;

    map<int,int> m;

    for(int i = 2; i*i<= k; i++)
    {
        
        if(k%i == 1)
        {
            m[i]++;
            m[k/i]++;
        }
        else if(k%i == 0)
        {
            int r = k;
            while(r%i ==0)r /= i;
            if(r%i == 1)m[i]++;
        }
    }

    if(k > 2)
    {
        m[k]++,m[k-1]++;
    }
    if(k == 2)m[k]++;

    cout << m.size() << endl;

}
 
int32_t main()
{
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
  
     
     int t = 1;
     // cin >> t;
     while(t--)solve();
  
}


Measured memory_bytes: 2304
n = int(input())
a = [int(input()) for _ in range(n)]

a.sort()
a.append(0)
ans = 0
flag = True
for i in range(1,n+1):
    if a[i] == a[i-1]:
        flag = not flag
    else:
        if flag:
            ans += 1
        flag = True
    #print(flag)
    #print(a[i])
print(ans)

Measured memory_bytes: 50264
#include <iostream>
#include <string>
#include <queue>
using namespace std;

class Proc{
    public:
        string name;
        int time;

        Proc(){
            name = "";
            time = 0;
    }
};

int main(){
    queue<Proc> que;

    int n,Q;
    cin >> n >> Q;

    for(int i=0;i<n;i++){
        Proc p;
        cin >> p.name >> p.time;
        que.push(p);
    }

    int total_time(0);

    while(!que.empty()){
        Proc p(que.front());
        que.pop();

        if(p.time<=Q){
            total_time += p.time;
            cout << p.name << " " << total_time << endl;
        }else{
            total_time += Q;
            p.time -= Q;

            que.push(p);
        }
    }

    return 0;
}


Measured memory_bytes: 6228
N = int(input())

anss = set()
for X in range(1, int(N**0.5)+2):
    if (N-X) % X == 0:
        m = (N-X) // X
        if m <= 0: continue
        if N//m == N%m:
            anss.add(m)

for m in range(1, int(N**0.5)+2):
    if N//m == N%m:
        anss.add(m)

print(sum(anss))


Measured memory_bytes: 3188
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        double n = double.Parse(Console.ReadLine());
        while (true)
        {
            double ans = Math.Sqrt(n);
            if (ans - System.Math.Floor(ans) == 0) break;            
            n--;
        }
        Console.WriteLine(n);
    }
}

Measured memory_bytes: 13140
#include<stdio.h>

int main(void)
{
 int N;
 scanf("%d",&N);
 int num[N];
 int i;
 for(i=0;i<N;i++) scanf("%d", &num[i]);
  int maxv=-1000000000;
  int minv=num[0];
  for(i=1;i<N;i++){
    if(maxv<num[i]-minv) maxv=num[i]-minv;
    if(minv>num[i]) minv=num[i];
 }
 printf("%d\n",maxv);
 return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};

int main(){
  int n,k;cin>>n>>k;
  ll dp[2][k+10];
  ll sum[2][k+10];
  for(int i=0;i<k+10;i++)sum[1][i]=sum[0][i]=dp[0][i]=dp[1][i]=0;
  dp[0][0]=1;
  for(int i=1;i<=n;i++){
    // cout<<(i+1)%2<<endl;
    ll hoge;cin>>hoge;
    sum[(i+1)%2][0]=dp[(i+1)%2][0]%MOD;
    for(ll j=1;j<=k;j++){
      sum[(i+1)%2][j]=sum[(i+1)%2][j-1]+dp[(i+1)%2][j];
      sum[(i+1)%2][j]%=MOD;
      //cout<<sum[(i+1)%2][j]<<" ";
    }
    //sum[(i+1)%2][k+1]=sum[(i+1)%2][k]%MOD;
    // cout<<endl;
    for(ll j=0;j<=k;j++){
      if(j==min(j,hoge))dp[i%2][j]=sum[(i+1)%2][j]%MOD;
      else dp[i%2][j]=(MOD+sum[(i+1)%2][j]-sum[(i+1)%2][j-min(hoge,j)-1])%MOD;
      //cout<<dp[(i+1)%2][j]<<" ";
    }
    //cout<<endl;
  }
  cout<<(dp[n%2][k])%MOD<<endl;
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long n,ans=10;
	cin>>n;
	for(long long i=1;i*i<=n;i++)
		if(n%i==0)
			ans=min(ans,to_string(n/i).size()+0ll);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();

		if(a*b%2==1) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  int N;  cin>>N;
  vector<int> v(N);
  v[0] = 0;
  rep(i,1,N) cin>>v[i], v[i]--;
  vector<int> v2(N, 0);
  rep(i,1,N){
    v2[v[i]]++;
  }
  rep(i,0,N){
    cout<<v2[i]<<endl;
  }
  return 0;
}


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

int main() {
    int n, a[100];
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    int min = 1e9;
    for (int i = -100; i <= 100; ++i) {
        int sum = 0;
        for (int j = 0; j < n; ++j) {
            sum += (i - a[j]) * (i - a[j]);
        }
        if (sum < min) min = sum;
    }

    cout << min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    long long Luca[N+1];
    Luca[0] = 2;
    Luca[1] = 1;
    for(int i = 2; i <= N; i++){
        Luca[i] = Luca[i-1] + Luca[i-2];
    }

    cout << Luca[N] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#define sp system("pause");
using namespace std;
int main(){
	long long a,b;
	cin>>a>>b;
	if(b>=a)
		cout<<a;
	else
		cout<<a-1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

typedef vector<vector<ll> > Matrix;

const ll INF = 100000000;
Matrix d; // グラフの距離を格納した2次元配列（隣接行列）
          // d[u][v]は辺e=(u,v)のコスト（辺が存在しない場合はINF、ただしd[i][i]=0）

void warshall_floyd(int n) { // nは頂点数
    for (int i = 0; i < n; i++)      // 経由する頂点
        for (int j = 0; j < n; j++)    // 開始頂点
            for (int k = 0; k < n; k++)  // 終端
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

int N, M, R;
ll ans = INF;
int DEPTH;
vector<int> city;
void dfs(vector<int> &route, int depth, vector<bool> &used){
    if(depth == R){
        if(DEBAG){
            cout << "route is " ;
            for(int i = 0; i < R; i++) cout << route[i] << " ";
            cout << endl;
        }
        ll cost = 0;
        for(int i = 0; i < R - 1; i++){
            cost += d[route[i] ][ route[i+1] ] ;
            //if(DEBAG) cout << d[route[i] ][ route[i+1] ] << endl;
        }
        ans = min(ans, cost);
    }
    else{
        for(int i = 0; i < R; i++){
            if(used[i] == false){
                used[i] = true;
                route[depth] = city[i];
                dfs(route, depth + 1, used);
                used[i] = false;
            }
        }
    }
}

int main() {
    cin >> N >> M >> R;

    city.resize(R);
    for(int i = 0; i < R; i++){
        cin >> city[i];
        city[i] --;
    }

    //コストマップを初期化
    d = Matrix(N, vector<ll>(N, INF));
    for (int i = 0; i < N; i++){
        d[i][i] = 0;
    } 
    
    //コストマップに代入
    for (int i = 0; i < M; i++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        from --;
        to --;
        d[from][to] = cost;
        d[to][from] = cost;
    }
    
    //引数：頂点数
    warshall_floyd(N);

    if(DEBAG){
        cout <<"cost is " << endl;
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                cout << d[i][j] << " ";
            }
            cout << endl;
        }
        cout  << endl;

    }

    vector<bool> used(R);
    vector<int> route(R);
    dfs(route, 0, used);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
 for (int i = 0; i < n; i++){
   cin >> p.at(i);
 }
  int ans = 0;
  for (int i = 0; i < n-2; i++){
    if (p.at(i) < p.at(i+1) && p.at(i+1) < p.at(i+2) || p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2)){
      ans++;
    }
    else continue;
  }
  cout << ans << endl;
}

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

using namespace std;

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

   int x,y;
   x=(a+d-1)/d;
   y=(b+c-1)/b;

   if(x>=y)
    cout<<"Yes";
   else 
    cout<<"No";

}

int main()
{

   ios::sync_with_stdio(0);
   cin.tie(NULL);

   solve();

   return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

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

    vector<ll> culsum(n+2);
    culsum.push_back(0);
    for(int i=1; i<=n+1; i++){
        culsum[i] = culsum[i-1] + (i-1);
    }

    ll ans = 0;
    for(int ch=k; ch<=n+1; ch++){
        ll min = culsum[ch];
        ll max = culsum[n+1] - culsum[n+1-ch];
        // cout << ch << " : " << min << " " << max << endl;
        ans += (max - min + 1)%mod;
    }
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6340
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000

int H;
int A[MAX+1];

void insert(int);
void heapIncreaseKey(int *, int, int);
int heapExtractMax(int *);
void maxHeapify(int *, int);

int main(){
  int key;
  char k[10];

  while(1){
    scanf("%s",k);
    if(k[0] == 'e' && k[1] == 'n') break;
    if(k[0] == 'i'){
      scanf("%d",&key);
      insert(key);
    }
    else{
      printf("%d\n", heapExtractMax(A));
    }
  }

  return 0;
}

void insert(int key){
  H++;
  A[H]=-MAX;
  heapIncreaseKey(A, H, key);
}

void heapIncreaseKey(int *A, int i, int key){
  int tem;
  
  if(key < A[i]) return;
  A[i]=key;
  while(i > 1 && A[i/2] < A[i]){
    tem=A[i];
    A[i]=A[i/2];
    A[i/2]=tem;
    i=i/2;
  }
}

int heapExtractMax(int *A){
  int max;
  
  if(H < 1) return -MAX;
  max=A[1];
  A[1]=A[H];
  H--;
  maxHeapify(A, 1);

  return max;
}

void maxHeapify(int *A, int i){
  int l=2*i, r=2*i+1;
  int largest, tem;

  if(l <= H && A[l] > A[i]) largest=l;
  else largest=i;
  if(r <= H && A[r] > A[largest]) largest=r;

  if(largest != i){
    tem=A[i];
    A[i]=A[largest];
    A[largest]=tem;
    maxHeapify(A, largest);
  }
}
 



Measured memory_bytes: 5604
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main () {
    int n;
    cin >> n;
    cout << fixed << setprecision(8);

    while (n != 0) {
        double a[1000] = {0}, sum = 0;
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            sum += a[i];
        }
        double average = sum / n;
        sum = 0;

        for (int i = 0; i < n; i++)
            sum += (a[i] - average) * (a[i] - average);
        
        cout << sqrt(sum / n) << '\n';

        cin >> n;
    }
    
}


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

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    ll sum = 0;
    for(ll a : A){
        sum += a;
    }

    bitset<2000*2000+1> dp;
    dp[0] = 1;
    for(ll a : A){
        dp |= (dp<<a);
    }
    dp[0] = 0;

    vector<ll> V;
    FOR(i, 0, 2000*2000+1){
        if(dp[i]==1) V.push_back(i);
    }
    ll target = (sum+1)/2;

    // vprint(V);
    // pn(target);
    auto it = lower_bound(ALL(V), target);
    p(*it);
    
    return 0;
}

Measured memory_bytes: 19688
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f,g,h,i;
int main()
{
    cin>>a>>b>>e;
    c=3*e-a-b;
    h=2*e-b;
    f=2*a-h;
    i=3*e-c-f;
    d=2*e-f;
    g=3*e-h-i;
    printf("%d %d %d\n%d %d %d\n%d %d %d",a,b,c,d,e,f,g,h,i);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        solve(new BufferedReader(new InputStreamReader(System.in)));
    }

    private static void solve(BufferedReader in) throws IOException {
        StringTokenizer st = new StringTokenizer(in.readLine());
        int N = Integer.parseInt(st.nextToken()), M = Integer.parseInt(st.nextToken());

        @SuppressWarnings("unchecked")
        List<LR>[] nByLen = new List[M + 1];
        for (int i = 1; i < M + 1; i++) {
            nByLen[i] = new ArrayList<>();
        }

        for (int n = 1; n < N + 1; n++) {
            st = new StringTokenizer(in.readLine());
            int l = Integer.parseInt(st.nextToken());// 1 <= l <= r <= M
            int r = Integer.parseInt(st.nextToken());
            LR lr = new LR(l, r);
            nByLen[lr.len].add(lr);
        }

        int accum = N;

        fenwick = new int[M + 1];
        for (int d = 1; d < M + 1; d++) {
            int sum = accum;
            for (int e = d; e < M + 1; e += d) {
                sum += faccum(e);
            }
            System.out.println(sum);
            accum -= nByLen[d].size();
            for (LR lr : nByLen[d]) {
                fadd(lr.l, 1);
                fadd(lr.r + 1, -1);
            }
        }
    }

    private static class LR {
        final int l, r, len;

        LR(int l, int r) {
            this.l = l;
            this.r = r;
            this.len = r - l + 1;
        }
    }

    private static int[] fenwick;

    private static int faccum(int i) {
        int sum = 0;
        for (; i > 0; i -= i & -i) {
            sum += fenwick[i];
        }
        return sum;
    }

    private static void fadd(int i, int a) {
        for (; i < fenwick.length; i += i & -i) {
            fenwick[i] += a;
        }
    }
}

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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

int main() {
  int N; string S;
  cin >> N >> S;
  S += S.substr(0,2);
  for (string s:{"SS","SW","WS","WW"}) {
    rep2(i,2,N+2) {
      if (s.substr(i-2,2)=="SS") {
        if (S[i-1]=='o') s+="S";
        else s+="W";
      }
      else if (s.substr(i-2,2)=="SW") {
        if (S[i-1]=='o') s+="W";
        else s+="S";
      }
      else if (s.substr(i-2,2)=="WS") {
        if (S[i-1]=='o') s+="W";
        else s+="S";
      }
      else {
        if (S[i-1]=='o') s+="S";
        else s+="W";
      }
    }
    if (s.substr(0,2)==s.substr(N,2)) {
      cout << s.substr(0,N) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
#define MAX_H 500000

int h;
int node[MAX_H + 1];

void maxHeapify(int i){
  int l = i * 2, r = i * 2 + 1;
  int largest;
  if(l <= h && node[l] > node[i]) largest = l;
  else largest = i;
  if(r <= h && node[r] > node[largest]) largest = r;

  if(largest != i){
    swap(node[largest], node[i]);
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i = h / 2; i >= 1; i--){
    maxHeapify(i);
  }
}

int main(void){
  cin >> h;
  for(int i = 1; i <= h; i++) cin >> node[i];
  buildMaxHeap();
  for(int i = 1; i <= h; i++){
    cout << " " << node[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3112
using System;
using System.Linq;

class prog{
  static void Main(){
    
    int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int[] num = new int[n[0] + 1];
    for(int i = 0; i <= n[0]; i++){
      num[i] = 0;
    }
    
    for(int i = 0; i < n[1]; i++){
      int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
      num[input[0]]++;
      num[input[1]]++;
    }
    
    for(int i = 1; i <= n[0]; i++){
      Console.WriteLine(num[i]);
    }
    
    
  }
}

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

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

    // char M[H+2][W+2];
    vector<vector<char>> M(H+2, vector<char>(W+2, '-'));

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            cin >> M[i][j];
        }
    }

    vector<vector<int>> N(H + 2, vector<int>(W + 2, 0));
    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (M[i][j] == '#')
                N[i][j] = -1;
            else
            {
                for (int k = -1; k <= 1; k++) {
                    for (int l = -1; l <= 1 ; l++)
                    {
                        if (M[i+k][j+l] == '#')
                            N[i][j]++;
                    }
                }
            }
            
        }
    }

    for (int i = 1; i <= H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            if (N[i][j] == -1)
                cout << '#';
            else
            {
                cout << N[i][j];
            }

            if (j == W)
                cout << endl;
        }
        }
    
}

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

int main()
{
    /*ABC144 B
    int x;
    cin>>x;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(x==i*j)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    */
    /*ABC150 B
    int n;
    string s;
    cin>>n>>s;
    int count = 0;
    for(int i=0;i<n-2;i++)
    {
        if(s[i]=='A')
        {
           if(s[i+1]=='B')
           {
               if(s[i+2]=='C')
               {
                   count++;
               }
           }
        }
    }
    cout<<count<<endl;
    */

    /*ABC136 B
    int n;
    cin>>n;
    int count = 0;
    for(int i=1;i<=n;i++)
    {
        int even=0;
        int num = i;
        while(num)
        {
            num/=10;
            even++;
        }
        if(even%2!=0)
        {
            count++;
        }
    }
    cout<<count<<endl;
    */
    /*ABC106 B
    int n;
    cin>>n;
    int count=0;
    for(int i=10;i<=n;i++)
    {
        int num = i;
        int yakusu=0;
        for(int j=1;j<=num;j++)
        {
            if(j%2==0)
            {
                continue;
            }
            if(num%j==0)
            {
                yakusu++;
            }    
        }
        if(yakusu==8)
        {
            count++;
        }
    }    
    cout<<count<<endl;
    */

    int a,b,k;
    cin>>a>>b>>k;
    int count=0;
    for(int i=100;i>=1;i--)
    {
        if(a%i==0 && b%i==0)
        {
           count++;
        }
        if(count==k)
        {
            cout<<i<<endl;
            return 0;
        }
    }

    

    return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

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

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

    if(a + b == 15) {
        cout << "+" << '\n';
    }
    else if(a * b == 15) {
        cout << "*" << '\n';
    }
    else {
        cout << "x" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend();
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

int N;//要素数
int M;
vi parent;
vi hight;
vi coodinate;

void init() {
	rep(N) {
		parent.push_back(i);
		hight.push_back(0);
		coodinate.push_back(0);
	}
}

int absolute_coodinate(int x) {
	if (parent[x] == x)return coodinate[x];
	else return coodinate[x] + absolute_coodinate(parent[x]);
}

int find_root(int x) {
	if (parent[x] == x)return x;
	else return find_root(parent[x]);
}

bool unite(int x, int y, int d) {
	int x_root = find_root(x);
	int y_root = find_root(y);
	int dif = absolute_coodinate(y) - absolute_coodinate(x);
	if (x_root == y_root) {
		if (dif != d)return true;
	}
	x = x_root;
	y = y_root;
	if (hight[x] < hight[y]) {
		parent[x] = y;
		coodinate[x] = dif - d;
	}
	else {
		parent[y] = x;
		coodinate[y] = d - dif;
		if (hight[x] == hight[y])++hight[x];
	}
	return false;
}

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

int main() {
	cin >> N >> M;
	init();
	int l, r, d;
	rep(M) {
		cin >> l >> r >> d;
		if (unite(l - 1, r - 1, d)) {
			say("No");
			re;
		}
	}
	say("Yes");
}

Measured memory_bytes: 1644
#include <iostream>
using namespace std;
long long a[10];
int main(){
	for(int i = 1;i <= 4;i++)
		cin >> a[i];
	long long res;
	res = a[1]*a[3];
	for(int i = 1;i <= 2;i++){
		for(int j = 3;j <= 4;j++){
			res = max(res,a[i]*a[j]);
		}
	}
	cout << res;
	return 0;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> v(N), c(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  for (int i = 0; i < N; i++) cin >> c[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (v[i] - c[i] > 0) {
      ans += v[i] - c[i];
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int N;
        string S;
        long long int initial[5];
        long long int Ans=0;
        int patern[10][3]={{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}};

        for(int i=0; i<5; i++)initial[i]=0;

        cin >> N ;

        for(int i=0; i<N; i++) {
                cin >> S;
                if(S[0]=='M') initial[0]++;
                if(S[0]=='A') initial[1]++;
                if(S[0]=='R') initial[2]++;
                if(S[0]=='C') initial[3]++;
                if(S[0]=='H') initial[4]++;
        }

        for(int i=0; i<10; i++) Ans+=initial[patern[i][0]]*initial[patern[i][1]]*initial[patern[i][2]];

        cout << Ans << endl;
        return 0;
}


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

using namespace std;
const int maxn = 310;

int n;
int niz[maxn];
double dp[maxn][maxn][maxn];
bool bio[maxn][maxn][maxn];

double rek(int a, int b, int c) {
	if (a < 0 || b < 0 || c < 0) return 0.0;
    if (a == 0 && b == 0 && c == 0) return 0.0;
    if (bio[a][b][c]) return dp[a][b][c];
    
    bio[a][b][c] = true;
    double ax = rek(a - 1, b, c);
    double bx = rek(a + 1, b - 1, c);
    double cx = rek(a, b + 1, c - 1);
    
    return dp[a][b][c] = (n + a * ax + b * bx + c * cx) / (a + b + c);
}

int main() {
    memset(bio, false, sizeof bio);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    int cnta = 0, cntb = 0, cntc = 0;
    for (int i = 0; i < n; i++) {
        cin >> niz[i];
        if (niz[i] == 1) cnta++;
        else if (niz[i] == 2) cntb++;
        else if (niz[i] == 3) cntc++;
    }
    
    cout << fixed << setprecision(15) << rek(cnta, cntb, cntc);
    return 0;
}


Measured memory_bytes: 256256
let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let ab_s = Array.init n @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let cds = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a, b
let f (x, y) (x2, y2) = abs (x - x2) + abs (y - y2)
let g ab =
  Array.fold_left (fun (mi, i) cd -> min mi (f ab cd, i), i + 1) ((max_int, -1), 1) cds
  |> fst |> snd |> Printf.printf "%d\n"
let _ = Array.iter g ab_s

Measured memory_bytes: 512
/* Stack (逆ポーランンド記法) */
/* 逆ポーランド記法で与えられた数式の計算結果を出力してください。 */
/* 入力: １つの数式が１行に与えられます。連続するシンボル（オペランドあるいは演算子）は１つの空白で区切られて与えられます。 */
/* 出力: 計算結果を１行に出力してください。 */


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

int top=0, abc[1000];

void push(int);
int pop();

int main()
{
  int x, y;
  
  top = 0;
  
  char aaa[100];
  
  while(scanf("%s", aaa) != EOF) {
    if (aaa[0] == '+') {
      x = pop();
      y = pop();
      push(x + y);
    }

    else if (aaa[0] == '-') {
      y = pop();
      x = pop();
      push(x - y);
    }

    else if (aaa[0] == '*') {
      x = pop();
      y = pop();
      push(x * y);
    }

    else push(atoi(aaa));
  }

  printf("%d\n", pop());
  
  return 0;
}

void push(int x)
{
  abc[++top] = x;
}

int pop()
{
  top--;
  return abc[top + 1];
}




Measured memory_bytes: 2076
var
	h,w,i,j,r,c:Longint;
	s:array of string;
	dx:array[1..8]of Longint=(1,0,-1,0,1,1,-1,-1);
	dy:array[1..8]of Longint=(0,1,0,-1,1,-1,1,-1);
begin
	readln(h,w);
	setlength(s,h+2);
	for i:=0 to h+1 do setlength(s[i],w+2);
	for i:=1 to h do readln(s[i]);
	for i:=1 to h do begin
		for j:=1 to w do begin
			if s[i][j]='.' then begin
				c:=48;
				for r:=1 to 8 do begin
					if s[i+dx[r]][j+dy[r]]='#' then inc(c);
				end;
				s[i][j]:=chr(c);
			end;
		end;
		writeln(s[i]);
	end;
end.

Measured memory_bytes: 128
/* **************************************************** */
/*                      Author : rakati                 */
/* **************************************************** */

#include <bits/stdc++.h>

using namespace std;

#define RP(i,a,b) for(int i = (a); i < (int)(b); i++)
#define RV(i,a,b) for(int i = (a); i > (int)(b); i--)
#define SHOW(v,d) {RP(i,0,v.size()) cout << v[i] << d;cout << '\n';}
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

const double EPS = 1e-9;
const double PI = 2 * acos(0.0);
const int INF = 1e9;

using ll    = long long;
using ull   = unsigned long long;
using vi    = vector<int>;
using vl    = vector<ll>;
using vb    = vector<bool> ;
using vc    = vector<char>;
using vii   = vector<vi>;
using vll   = vector<vl>;
using pii   = pair<int, int>;
using pll   = pair<ll, ll>;
using vpii  = vector<pii>;
using vpll  = vector<pll>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    vi arr(n);
    RP(i,0,n) cin >> arr[i];
    vi dp(n,0);
    dp[1] = abs(arr[1] - arr[0]);
    RP(i,2,n) dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2] + abs(arr[i] - arr[i-2]));
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    rep(i, 0, n) {
        vector<bool> tmp(n);
        tmp[i] = true;
        for (int j : g[i]) tmp[j] = true;
        g[i].clear();
        rep(j, 0, n) if (!tmp[j]) g[i].emplace_back(j);
    }
    vector<int> col(n), used;
    vector<pair<int, int>> p;
    function<void(int, int)> dfs = [&](int v, int p) {
        for (int u : g[v]) {
            if (u == p) continue;
            if (col[u] != 0) {
                if (col[v] == col[u]) col[u] = 2;  // output -1
            } else {
                col[u] = -col[v];
                dfs(u, v);
                used.emplace_back(u);
            }
        }
    };
    rep(i, 0, n) {
        if (col[i]) continue;
        used.clear();
        col[i] = 1;
        used.emplace_back(i);
        dfs(i, -1);
        pair<int, int> tmp;
        for (int j : used) {
            if (col[j] == 2) {
                cout << -1 << endl;
                return 0;
            }
            if (col[j] == 1)
                tmp.first++;
            else
                tmp.second++;
        }
        p.emplace_back(tmp);
    }
    vector<vector<bool>> sum(n + 1, vector<bool>(2));
    sum[0][0] = true;
    rep(j, 0, p.size()) {
        int s = p[j].first, t = p[j].second;
        for (int i = n; i >= 0; i--) {
            if (i + s <= n && sum[i][j % 2]) {
                sum[i + s][(j + 1) % 2] = true;
            }
            if (i + t <= n && sum[i][j % 2]) {
                sum[i + t][(j + 1) % 2] = true;
            }
            sum[i][j % 2] = false;
        }
    }
    int ans = 1e9;
    rep(i, 0, n) {
        if (sum[i][p.size() % 2] && sum[n - i][p.size() % 2]) {
            int j = n - i;
            ans = min(ans, i * (i - 1) / 2 + j * (j - 1) / 2);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
int n,t,z,d,tot,head[55000];
long long ans,f[1000010];
struct point{
	int v,w,num;
	friend bool operator <(point a,point b){
		return a.w*b.v>b.w*a.v;
	}
}a[55000];
struct node{
	int fr,to,nxt;	
}e[55000];
void add(int x,int y)
{
	e[++tot].fr=x;
	e[tot].to=y; e[tot].nxt=head[x];
	head[x]=tot;
}
void dfs(int x)
{
	a[x].w=1; 
	for(int i=head[x];i;i=e[i].nxt)
		dfs(e[i].to),a[x].v+=a[e[i].to].v,a[x].w+=a[e[i].to].w;
}
signed main()
{
	scanf("%lld%lld%lld",&n,&t,&d);
	scanf("%lld",&a[1].v); a[1].num=1;
	for(int i=2,x;i<=n;i++)
		scanf("%lld%lld",&a[i].v,&x),a[i].num=i,add(x,i);
	dfs(1);
	memset(f,0x3f,sizeof(f)); f[0]=0;
	for(int i=1;i<=n;i++)
	{
		int tmp=min(d,n);
		for(int j=0;(1<<j)<=tmp;j++) {
			for(int k=n*n*n;k>=0;k--)
				f[k+(1<<j)*a[i].w]=min(f[k+(1<<j)*a[i].w],f[k]+1ll*(1<<j)*a[i].v);
			tmp-=(1<<j);
		}
		if(tmp) for(int k=n*n*n;k>=0;k--)
			f[k+tmp*a[i].w]=min(f[k+tmp*a[i].w],f[k]+1ll*tmp*a[i].v);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++) 
		if(a[i].num==1) {z=i;break;}
	for(int i=0;i<=n*n*n;i++)
	{
		if(f[i]>t) continue;
		long long rst=t-f[i],ret=i;
		for(int j=1;j<z;j++)
		{
			int now=min(0ll+d-min(d,n),rst/a[j].v);
			ret+=1ll*now*a[j].w; rst-=1ll*now*a[j].v;
		}
		long long now=rst/a[z].v;
		ret+=1ll*now*a[z].w; ans=max(ans,ret);
	} 
	printf("%lld\n",ans);
}

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

int N, M;
vector<int> s, c;

bool ok(string str) {
    if (str.size() != N) return false;
    for (int i = 0; i < M; ++i) if (str[s[i]] != (char)(c[i] + '0')) return false;
    return true;
}

string solve() {
    for (int i = 0; i <= 999; ++i) {
        stringstream iss; iss << i;
        string str = iss.str();
        if (ok(str)) return str;
    }
    return "-1";
}

int main() {
    cin >> N >> M;
    s.resize(M); c.resize(M);
    for (int i = 0; i < M; ++i) cin >> s[i] >> c[i], --s[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
mod = 1000000007
n, a, b = [ int(v) for v in input().split() ]

def frac_with_mod(a,m):
    outlist = [ 1 for i in range(a+1) ]
    for i in range(1,a+1):
        outlist[i] = (outlist[i-1] * i)% m
    return outlist

frac_list = frac_with_mod(2*10**5+1,10**9+7)

total = (pow(2, n, mod) - 1)
ina = pow(frac_list[a],mod-2,mod)
for i in range(n, n-a, -1):
    ina *= i
    ina %= mod
inb = pow(frac_list[b],mod-2,mod)
for i in range(n, n-b, -1):
    inb *= i
    inb %= mod
print((total - ina - inb)%mod)

Measured memory_bytes: 52336
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define ll long long
const ll mod=1000000007;
inline int roundup(int a, int b) { return (((a + (b -1)) / b)); }
inline ll powmod(ll x, ll y) {ll res=1; for(ll i=0;i<y;i++){ res=res*x%mod; } return res;}
using namespace std;

signed main(void) {
    int n, d1[100], d2[100];
    cin >> n;
    rep(i,n) {
        cin >> d1[i] >> d2[i];
    }
    rep(i,n){
        if(i < n-2) {
            if(d1[i] == d2[i] && d1[i+1] == d2[i+1] && d1[i+2] == d2[i+2]) {
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No" ;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    cout << setprecision(10);
    int n,k;
    cin >> n >> k;
    double ans = 0;
    for(int i = 1; i <= n; i++){
        double calc = 1;
        calc /= n;
        int num = i;
        while(num < k){
            num *= 2;
            calc /= 2;
        }
        ans += calc;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	string x, y;
	cin >> x >> y;
	int x1, y1;
	if (x == "A") x1 = 10;
	if (x == "B") x1 = 11;
	if (x == "C") x1 = 12;
	if (x == "D") x1 = 13;
	if (x == "E") x1 = 14;
	if (x == "F") x1 = 15;
	if (y == "A") y1 = 10;
	if (y == "B") y1 = 11;
	if (y == "C") y1 = 12;
	if (y == "D") y1 = 13;
	if (y == "E") y1 = 14;
	if (y == "F") y1 = 15;
	if (x1 < y1)cout << "<" << endl;
	if (x1 > y1)cout << ">" << endl;
	if (x1 == y1)cout << "=" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <set>
#include <bitset>
#include <utility> 
using namespace std;

int main() {
   int N; cin >> N;
   vector<int> H(N);
   int ans=N;
   int tmpmax = 1;
   for (int i=0;i<N;i++){
       cin >> H[i];
   } 
   for (int i=0;i<N;i++){
       if (tmpmax>H[i]) {
           ans--;
       }
       else tmpmax = max(tmpmax,H[i]);
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
if A==1 and B==2:
  print(3)
elif A==2 and B==3:
  print(1)
elif A==3 and B==1:
  print(2)
elif A==1 and B==3:
  print(2)
elif A==3 and B==2:
  print(1)
else:
  print(3)

Measured memory_bytes: 3060
/*
    Author : Simanta Deb Turja
    Created On: 21/06/20
    Atcoder Beginner Contest 171
*/

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

#define Professor

using ll = long long;
using i64 = unsigned long long;
using ld = long double;

template <typename T> inline T Min (T a, T b, T c) { 
    return min(a, min(b, c)); 
}
template <typename T> inline T Min (T a, T b, T c, T d) { 
    return min(a, min(b, min(c, d))); 
}
template <typename T> inline T Max (T a, T b, T c) { 
    return max(a, max(b, c)); 
}
template <typename T> inline T Max (T a, T b, T c, T d) { 
    return max(a, max(b, max(c, d))); 
}

template <typename T> inline T Ceil(T a, T b) { 
    return ((a % b == 0) ? (a / b) : (a / b + 1)); 
} 
template <typename T> inline T Floor(T a, T b) { 
    return a / b; 
}

template <typename T> inline T Power (T a, T p) { 
    T res = 1, x = a; 
    while ( p ) { 
        if ( p & 1 ) res = ( res * x ); 
        x = ( x * x ); p >>= 1;
    }
    return res; 
}
template <typename T> inline T BigMod (T a,T p,T M) { 
    a %= M; T ret = (T)1; 
    while (p) { 
        if (p & 1) ret = (ret * a) % M; 
        a = (a * a) % M;  p = p >> 1;
    } 
    return ret;
}
template <typename T> inline T InverseMod (T a,T M) { 
    return BigMod (a, M - 2, M); 
}

template <typename T> inline T gcd ( T a, T b ) { 
    a = abs(a); b = abs(b); 
    while ( b ) { 
        a = a % b; swap ( a, b ); 
    } 
    return a;
}
template <typename T> inline T lcm(T x,T y) { 
    return (((x)/gcd((x),(y)))*(y)); 
}


template< typename T1, typename T2, typename T3 > struct Pair { 
    T1 first; T2 second; T3 third; 
};
template< typename T1, typename T2, typename T3, typename T4 > struct Pair4 { 
    T1 first; T2 second; T3 third; T4 fourth; 
};


using ii = pair <int, int>;
using iii = Pair <int, int, int>;
using iiii = Pair4 <int, int, int, int>;

#define endl '\n'

const double EPS = 1e-7;
const double PI = acos(-1.0);
const ll LLINF = (ll)1e18+1;
const int INF = (int)1e9+1;
const int MOD = (ll)1e9 + 7;
const int N = (int)4e5 + 10;


//++++++++++++++++++Template Ends Here++++++++++++++++++

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector <ll> arr(n);
    ll xor_total = 0LL;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        xor_total ^= arr[i];
    }   
    for (int i = 0; i < n; ++i) {
        cout << (xor_total ^ arr[i]) << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k, s;
    cin >> n >> k >> s;

    if (s < (int)1e9) {
        for (int i = 0; i < n; i++) {
            cout << (i < k ? s : s + 1) << " \n"[i == n - 1];
        }
    } else {
        for (int i = 0; i < n; i++) {
            cout << (i < k ? s : 1) << " \n"[i == n - 1];
        }
    }

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 9;
const int MAXN = 100005;

int n, l;
lint dp[55][2];

int main(){
	cin >> n >> l;
	dp[0][0] = 1;
	for(int i=1; i<=n; i++){
		int x;
		cin >> x;
		x %= 2;
		dp[i][0] = dp[i-1][0] + dp[i-1][0 ^ x];
		dp[i][1] = dp[i-1][1] + dp[i-1][1 ^ x];
	}
	cout << dp[n][l] << endl;
}


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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") cout << "Cloudy" << endl;
  if (S == "Cloudy") cout << "Rainy" << endl;
  if (S == "Rainy") cout << "Sunny" << endl;
}

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

            ll n,a,b;
            cin>>n>>a>>b;
            vector<ll>v;
            for(int i=1;i<=99999;i++)
            {
                v.push_back(i*n);
            }
            int f=0;
            for(int i=0;i<=99999;i++)
            {
                if(v[i]>=a&&v[i]<=b)
                {
                    f=1;
                }
            }

            if(f==1)
            {
                cout<<"OK"<<endl;
            }
            else
            {
                cout<<"NG"<<endl;
            }














        return 0;
    }


Measured memory_bytes: 4320