akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
  
ll h;
cin>>h;
ll cnt=1;
ll ans=0;
while(h>0)
{
    ans=ans+cnt;
    cnt=cnt*2;
    h=h/2;
}
cout<<ans<<endl;
return 0;
}



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

long long int avd(long long int a, long long int b) {

	if (a < b)return b - a;
	else return a - b;

}
int main() {

	int N;
	int a[200010];
	long long int all_sum, sunuke, dif;

	all_sum = 0;
	sunuke = 0;
	dif = 2147483647;
	
	cin >> N;
	for (int i = 1; i <= N; i++) {

		cin >> a[i];

	}

	for (int i = 1; i <= N; i++) {

		all_sum += a[i];

	}
	for (int i = 1; i < N; i++) {

		sunuke += a[i];
		if (dif > avd(sunuke, all_sum - sunuke)) {

			dif = avd(sunuke, all_sum - sunuke);

		}

	}

	cout << dif << endl;
	
	return 0;
}

Measured memory_bytes: 1024
def searchyen(n, y):
	for i in range(0, n+1):
		for j in range(0, n+1-i):
			if 10000*i + 5000*j + 1000*(n-i-j) == y:
				return [i, j, n-i-j]
	return [-1, -1, -1]

inpt = map(int, raw_input().split())

ans = searchyen(inpt[0], inpt[1])
print str(ans[0]) + ' ' + str(ans[1]) + ' ' + str(ans[2])


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

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

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

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n; string s;
    cin >> n >> s;
    auto dp = make_v(n+1, 8, 0);
    dp[0][1] = 1;
    for (int i = 0; i < n; ++i) {
        int x = 0;
        if(s[i] == 'O') x = 1;
        if(s[i] == 'I') x = 2;
        for (int j = 0; j < 8; ++j) {
            for (int k = 0; k < 8; ++k) {
                if(!(k & (1 << x))) continue;
                if(!(j&k)) continue;
                (dp[i+1][k] += dp[i][j]) %= MOD;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 8; ++i) {
        (ans += dp[n][i]) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}



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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    int i;
    int n;
    cin>>n;
    //入力
    int l[n];
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    //処理
    sort(l,l+n,greater<>());
    int count=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(l[i]<l[j]+l[j+1]){
                for(int k=j+1;k<n;k++){
                    if(l[i]<l[j]+l[k])count++;
                    else break;
                }
            }else{
                break;
            }
        }
    }
    //出力
    cout<<count<<endl;

}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> c(n, 0);
    while (k--) {
        int d;
        cin >> d;
        while (d--) {
            int x;
            cin >> x;
            x--;
            c[x]++;
        }
    }
    int ans = 0;
    for (auto x : c) {
        if (x == 0) ans++;
    }
    cout << ans;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  string str;
  cin >> str;
  string result = "";

  REP(i, str.size()) {
    if(i % 2 == 0) {
      result.push_back(str[i]);
    }
  }
  cout << result;

  return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	string s;
	cin >> s;
	int i = 0;
	int lasti = -1;
	vector<int> res(s.size());
	while (1) {
		int numofR = 0, numofL = 0;
		while (s[i] == 'R') {
			numofR++;
			i++;
		}
		int left = i - 1;
		int right = i;
		while (s[i] == 'L') {
			numofL++;
			i++;
			if (i == s.size()) break;
		}
		res[right] = numofR / 2 + (numofL + 1) / 2;
		res[left] = numofR + numofL - res[right];
		if (i == s.size()) break;
	}
	FOR(i, 0, s.size()-1) {
		cout << res[i];
		if (i == s.size()) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return(0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int tcs;cin>>tcs;while(tcs--)
const int N=200007;
const int MOD=1e9+7;
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define printclock cerr<<"Time : "<<1000*(int)clock()/(int)CLOCKS_PER_SEC<<"ms\n"
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++)
{
	cin>>v[i];
}
sort(all(v),greater<int>());
int sum=0;
for(int i=0;i<n-1;i++)
{
	sum+=(v[(i+1)/2]);
}
cout<<sum<<endl;


cout<<endl;
printclock;
}


  


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,c;
    cin >> n >> c;
    int d[30][30];
    int color[500][500];
    for(int x = 0; x < c; x++)
        for(int y = 0; y < c; y++)
            cin >> d[x][y];
    for(int x = 0; x < n; x++)
        for(int y = 0; y < n; y++)
            cin >> color[x][y];

    ll v[3][30] {};
    for(int x = 0; x < n; x++){
        for(int y = 0; y < n; y++){
            for(int col = 0; col < c; col++){
                v[(x+y+2)%3][col] += d[color[x][y]-1][col];
            }
        }
    }

    ll ans = 1e+10;
    for(int x = 0; x < c; x++){
        for(int y = 0; y < c; y++){
            if(x == y) continue;
            for(int z = 0; z < c; z++){
                if(x == z || y == z) continue;
                ans = min(ans, v[0][x] + v[1][y] + v[2][z]);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1280
import java.util.*;
public 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 >= 10) {
    		System.out.println("error"); 
		}
		else {
		    System.out.println(a + b);
		}
	}
}

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

int main() 
{ 

     string s;
     int ans=0;
     getline(cin,s);
     if(s[0]=='R' && s[1]=='R' && s[2]=='R')ans=3;
     else if(s[1]=='R' && s[2]=='R')ans+=2;
     else if(s[0]=='R' && s[1]=='R')ans=2;
     else if(s[0]=='R' || s[1]=='R'|| s[2]=='R')ans+=1;
     cout<<ans<<endl;

    return 0; 
} 


Measured memory_bytes: 3612
#include<bits/stdc++.h>  
using namespace std;  
int WM(int k)
{  int m=sqrt(k);  
   for(int i=2;i<=m;i++)
   {  
     if(k%i==0) return 0;  
   }  
   return 1;  
}  
int main()  
{   int n,k=11;  
    cin>>n;  
    while(n>=1) 
	{  
      if(WM(k)==1)    
      {
	    n--;
	    cout<<k<<' ';
	  }
      k+=10;  
    }    
    return 0;  
}  

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cctype>
#include<string>
#include<cmath>
using namespace std;
int main(){
	char s[233]={0};
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I'){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n,q;
    cin>>n>>q;
    ll ans=(n-2)*(n-2),h=n,v=n;
    set<pair<ll,ll>> sh,sv;
    sh.insert({1,n});
    sv.insert({1,n});
    for(ll i=0;i<q;i++) 
    {
        ll x,y;
        cin>>x>>y;
        if(x==1)
        {
            ll h1=(*sh.begin()).second;
            if(h1>y)
            {
                sh.erase(sh.begin());
                sh.insert({1,y});
            }
            auto v1=(sv.ub({y,-1}));
            v1--;
            ans-=(*v1).second-2;
            sv.insert({y,(*v1).second});
        }
        else
        {
            ll v1=(*sv.begin()).second;
            if(v1>y)
            {
                sv.erase(sv.begin());
                sv.insert({1,y});
            }
            auto h1=(sh.ub({y,-1}));
            h1--;
            ans-=(*h1).second-2;
            sh.insert({y,(*h1).second});
        }
    }   
    cout<<ans;
    subt;
    return 0;
}


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

using namespace std;

int main(int argc, char *argv[]) {
    int64_t N;
    cin >> N;

    for (int h = 1; h <= 3500; h++) {
        for (int n = 1; n <= 3500; n++) {
            int64_t wone = N * n * h;
            int64_t wother = (4 * n * h - N * n - N * h);
            if (wother > 0 && wone % wother == 0 && wone / wother > 0) {
                int64_t w = wone / wother;
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int P = scan.nextInt();
        int Q = scan.nextInt();
        int R = scan.nextInt();
        int answer = P + Q;
        answer = Math.min(answer, Q + R);
        answer = Math.min(answer, R + P);
        System.out.println(answer);
    }
}


Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int L;
    cin >> L;
    int l = L;
    vector<int> digit;
    while (l) {
        digit.push_back(l%2);
        l >>= 1;
    }
    int size = digit.size();
    printf("%d ", size);
    vector<pair<pair<int, int>, int> > edges;
    int length = 1;
    for (int i = 1; i < size; i++) {
        edges.push_back(make_pair(make_pair(i, i+1), 0));
        edges.push_back(make_pair(make_pair(i, i+1), length));
        length *= 2;
    }
    for (int i = 1; i < size; i++) {
        if (digit[size-i-1] == 1) {
            edges.push_back(make_pair(make_pair(size-i, size), length));
            length += 1<<(size-i-1);
        }
    }
    printf("%d\n", (int)edges.size());
    for (const auto &edge : edges) {
        printf("%d %d %d\n", edge.first.first, edge.first.second, edge.second);
    }
    return 0;
}

Measured memory_bytes: 256
<?php
$n = int();
$A = ints();
echo count(array_unique($A)) - (count(array_unique($A)) % 2 == 0);

function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}

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



int main(){
	char b;
	cin>>b;
	if(b=='A')cout<<'T'<<endl;
	else if(b=='T')cout<<'A'<<endl;
	else if(b=='C')cout<<'G'<<endl;
	else cout<<'C'<<endl;
		
	
	return 0;
}


Measured memory_bytes: 256
import bisect
N, M = map(int, input().split())
start_to_middle = []
middle_to_end = []
for i in range(M):
    a, b = map(int, input().split())
    if a == 1:
        start_to_middle.append(b)
    elif b == N:
        middle_to_end.append(a)
if not len(start_to_middle) or not len(middle_to_end):
    print('IMPOSSIBLE')
    exit()
middle_to_end.sort()
for middle in start_to_middle:
    idx = bisect.bisect_left(middle_to_end, middle)
    if idx < len(middle_to_end) and middle_to_end[idx] == middle:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')


Measured memory_bytes: 17236
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
	{
		cout<<"hon";
	}
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
	{
		cout<<"pon";
	}
	else if(n%10==3)
	{
		cout<<"bon";
	}
	return 0;
} 

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
ll a[100009];
void init()
{
    a[0]=1;
    for(int i=1;i<=100001;i++)
    {
        a[i]=a[i-1]*i;
        a[i]%=mod;
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    init();
    if(abs(n-m)>1)
    {
        cout<<0<<endl;
    }
    else
    {
        ll sum;
        if((n+m)%2==0)
        {
            sum=2*a[n]*a[n];
            sum%=mod;
        }
        else
        {
            sum=a[m]*a[n];
            sum%=mod;
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) {//最大公約数
    if(a<b){
        ll tmp = a;
        a = b;
        b = tmp; 
    }
    if (b==0) return a;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {//最小公倍数
    return a * b / gcd(a, b);
}

int main(){
    int n,x; cin >> n >> x;
    vector<int>D(n+1);
    D[0]=0;
    for(int i=0; i<n; i++){
        int l; cin >> l;
        D[i+1] = D[i]+l;
    }
    int ans = 0;
    for(int i=0; i<=n; i++){
        if(D[i]<=x){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function isDeivid(num) {
  let dnum = 10;
  for (let i = 1; i <= 9; i++) {
    if (num % i === 0) {
      dnum = num / i;
    }
  }
  if (dnum < 10) {
    return true;
  }
  return false;
}

function main(input) {
  input = parseInt(input.trim().split("\n")[0]);
  if (input <= 81 && isDeivid(input)) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}


Measured memory_bytes: 7620
a,b,c,x,y=map(int,input().split())
result=[]
if(x>y):
    result.append(a*x+b*y)
    result.append(a*(x-y)+2*c*y)
    result.append(2*c*x)
elif(x<y):
    result.append(a*x+b*y)
    result.append(b*(y-x)+2*c*x)
    result.append(2*c*y)
else:
    result.append(a*x+b*y)
    result.append(2*c*x)
print(min(result))

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

int main() {
int a,b,c,s;
cin>>a>>b>>c;
s=-1*b+c;
if(b>=c){
  cout  <<  "delicious"  <<  endl;
}
else if(s<=a){
cout <<"safe"<<endl;
}
else cout <<"dangerous"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007



int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);

  sort(all(a));

  int ans = 0;

  rep(i, N) {
    if (x >= a.at(i)) {
      x -= a.at(i);
      ans++;
    }
    else {
      break;
    }
  }

  if (x > 0 && ans == N) ans--;

  cout << ans << endl;

}


Measured memory_bytes: 256
e1,e2,e3,e4=map(int,input().split())
if (e1==e2 and e3==e4) or (e1==e3 and e2==e4) or (e1==e4 and e2==e3) or (e1==e2==e3==e4):
    print("yes")
else:
    print("no")


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A = 0;
  for ( int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if ( S == "Y" ) {
      cout << "Four" << endl;
      break;
    }
    else {
      A++;
    }
  }
  if ( A == N ) {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

bool ck(char c){
	if(c=='A')return true;
	if(c=='C')return true;
	if(c=='G')return true;
	if(c=='T')return true;
	else return false;
}

ll n,q;
string s;

vi l,r;
ll sum[10000000]={0};

void init(){
	rep(i,s.size()){
		if(i==0)continue;
		if(s[i-1]=='A'&&s[i]=='C'){
			sum[i]=sum[i-1]+1;
		}else{
			sum[i]=sum[i-1];
		}
	}
}

int main(){
	cin>>n>>q>>s;
	ll lll,rrr;
	rep(i,q){
		cin>>lll>>rrr;
		l.pb(lll-1);r.pb(rrr-1);
	}//input
	init();
	//rep(i,n)cout<<sum[i];
	//cout<<""<<endl;
	rep(i,q){
		cout<<sum[r[i]]-sum[l[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//issame:同じか判定
//unite:併合
//findroot:根の検索
//treesize:その木の要素数
struct UnionFind{
    vector<long long> size, par;
    UnionFind(long long n) {
        size.resize(n, 0);
        par.resize(n, 0);
        for (long long i = 0; i < n;i++){
            maketree(i);
        }
    }
    void maketree(long long x){
        par[x] = x;
        size[x] = 1;
    }
    long long findroot(long long x){
        if (x != par[x]) par[x] = findroot(par[x]);
        return par[x];
    }
    bool issame(long long x,long long y){
        return findroot(x) == findroot(y);
    }
    bool unite(long long x,long long y){
        x = findroot(x);
        y = findroot(y);
        if (x == y) return false;  //already united
        if(size[x]>size[y]){
            par[y] = x;
            size[x] += size[y];
        }
        else{
            par[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    long long treesize(long long x){
        return size[findroot(x)];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    for (ll i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    UnionFind uf(n);
    for (ll i = 0; i < m;i++){
        uf.unite(a[i], b[i]);
    }
    ll ans = 0;
    for (ll i = 0; i < n;i++){
        chmax(ans, uf.treesize(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 9588
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

#define fs first
#define sc second

const long long MOD = 1e9 + 7;

class Combination {
    //a^p%mod
    ll powmod(ll a, ll p) {
        ll ans = 1LL;
        ll mul = a;
        // p >>=1 <-> p=(p >> 1)
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod) {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }

        return ans;
    }
public:
    int N;
    ll mod;
    vector<ll> fact;
    vector<ll> revFact;

    Combination(int n, ll m) : N(n), mod(m), fact(n+1), revFact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= N; i++) {
            fact[i] = fact[i-1] * i;
            fact[i] %= mod;
        }

        // Fermat's little theorem
        revFact[N] = powmod(fact[N], mod - 2);

        for (int i = N-1; i >= 0; i--) {
            revFact[i] = revFact[i+1] * (i+1);
            revFact[i] %= mod;
        }
    }

    ll get(int a, int b) {
        if (a < 0 || b < 0) return 0;
        if (b > a) return 0;
        return (((fact[a] * revFact[b]) % mod) * revFact[a-b]) % mod;
    }
};

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

    Combination cm = Combination(2 * N + 5, MOD);

    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        if(K >= N - i) {
            ans += cm.get(N, i) * cm.get(N - 1, i - 1);
            ans %= MOD;
        }
    }

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

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstring>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int num = 100 * a + 10 * b + c;
	if (num % 4 ==0) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int X,Y;
  cin >> X >> Y;
  if (X*4 < Y )
  {
    cout << "No" << endl;
    return 0;
  }
  if ((X*4 - Y)%2 == 1 )
  {
    cout << "No" << endl;
    return 0;
  }
  if ( (X*2) > Y )
  {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}
  

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

int main(){
    int n,k;
    scanf(" %d %d",&n,&k);
    for(int i = 0; i < n;++i) scanf(" %lld",&nums[i]);
    for(int i = 1; i < n;++i){
        dp[i] = abs(nums[i]-nums[i-1]) + dp[i-1];
        for(int j = 0, q = i-1; q > -1 && j < k;++j,--q)
            dp[i] = min(dp[i],abs(nums[i]-nums[q])+dp[q]);
    }
    printf("%lld\n",dp[n-1]);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

//Aの中にBが含まれてればtrueを返す
bool image(string *A, int h, int w, string *B){
  for(int i=h; i<h+B[0].size(); i++)
    for(int j=w; j<w+B[0].size(); j++)
    //一致しない時点でfalse
    if(A[i][j] != B[i-h][j-w])
      return false;
  return true;
}

int main(){
  int N, M;
  cin >> N >> M;
  string A[N], B[M];
  rep(i, N)
    cin >> A[i];
  rep(i, M)
    cin >> B[i];
  //ここまで入力

  rep(i, N-M+1){
    rep(j, N-M+1){
      if(A[i][j] == B[0][0])
	//一致する時点で終了
	if(image(A, i, j, B) ){
	  cout << "Yes" << endl;
	  return 0;
	}
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
"""def power(x, y): 
    res = 1
    x=x
    while (y > 0): 
        if ((y & 1) == 1) : 
            res = (res * x) 
        y = y >> 1
        x = (x * x)
    return res""" 
"""def fact(n):
    if(n==0):
        return 1
    if(n==1):
        return 1
    return fact(n-1)+fact(n-2)"""

import math
#import combinations
#t=int(input())
#for _ in range(t):
n=int(input())
arr=list(map(int,input().split()))
#n,m=map(int,input().split())
#count=0
d={}
total=0
ans=0

for i in range(n):
    if arr[i] not in d:
        d[arr[i]]=1
    else:
        d[arr[i]]+=1
for i in d:
    total+=(d[i]*(d[i]-1))//2
for i in range(n):
    ans=total-(d[arr[i]]*(d[arr[i]]-1)//2) +((d[arr[i]]-1)*(d[arr[i]]-2)//2)
    print(ans)


Measured memory_bytes: 86476
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, w, weight[100100], value[100100];
ll dp[110][100100];

int main() {
    cin >> n >> w;
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i];
    for(int i = 0; i < 110; i++) for(int j = 0; j < 100100; j++) dp[i][j] = inf;

    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 100100; j++){
            if(j - value[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j - value[i]] + weight[i]);
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        }
    }

    ll res = 0;
    for(int i = 0; i < 100100; i++){
        if(dp[n][i] <= w) res = i;
    }

    cout << res << endl;
}


Measured memory_bytes: 86272
#include <iostream>
#include <string>
#include <list>
using namespace std;
    list <int> pl[3];
int main()
{
    string a,b,c;
    cin>>a>>b>>c;
    for(char& i: a)
        pl[0].push_back(i-'a');
    for(char& i: b)
        pl[1].push_back(i-'a');
    for(char& i: c)
        pl[2].push_back(i-'a');
    int idx=0;
    while(!pl[idx].empty())
    {
        int t=pl[idx].front();
        pl[idx].pop_front();
        idx=t;
    }
    if(idx==0)
        cout<<"A"<<endl;
    else if(idx==1)
        cout<<"B"<<endl;
    else if(idx==2)
        cout<<"C"<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

S = input()
Q = int(input())
s = deque(S)
reverse = True

for i in range(Q):
    tmp = list(input().split())
    if tmp[0] == '1':
        reverse = not reverse
    if tmp[0] == '2':
        F = tmp[1]
        C = tmp[2]
        if F == '1':
            if reverse:
                s.appendleft(C)
            else:
                s.append(C)
        else:
            if reverse:
                s.append(C)
            else:
                s.appendleft(C)
if reverse:
    print(''.join(s))
else:
    print(''.join(list(s)[::-1]))


Measured memory_bytes: 10100
package main

import "fmt"

const INF int = 1000000000

func bfs(graph [][]int, dist []int, start int) {
	q := make([]int, 0)

	push := func(x int) {
		q = append(q, x)
	}
	pop := func() int {
		res := q[0]
		q = q[1:]
		return res
	}

	push(start)
	dist[start] = 0

	for len(q) != 0 {
		u := pop()
		for _, v := range graph[u] {
			if dist[v] != INF {
				continue
			}
			dist[v] = dist[u] + 1
			push(v)
		}
	}
}
func main() {
	var n int
	fmt.Scan(&n)

	var graph = make([][]int, n)
	for i := 0; i < n - 1; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		a--
		b--
		graph[a] = append(graph[a], b)
		graph[b] = append(graph[b], a)
	}

	var distF = make([]int, n)
	var distS = make([]int, n)
	for i := 0; i < n; i++ {
		distS[i] = INF
		distF[i] = INF
	}

	bfs(graph, distF, 0)
	bfs(graph, distS, n - 1)

	var countF, countS int
	for i := 0; i < n; i++ {
		if distF[i] <= distS[i] {
			countF++
		} else {
			countS++
		}
	}

	if countF > countS {
		fmt.Printf("Fennec")
	} else {
		fmt.Println("Snuke")
	}
}

Measured memory_bytes: 14848
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50 * k == X:
                count += 1


print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int A,B,C;

int main(){
    cin>>A>>B>>C;

    cout<<min(B/A,C)<<endl;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
s=list(input())
ryo,kai=0,0
for i in range(len(s)):
    if s[i] == 'a' and ryo<(a+b):
        ryo+=1
        print('Yes')
    elif s[i] == 'b' and ryo<(a+b) and kai<b:
        ryo+=1
        kai+=1
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 56568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll n,k,ab,a[200005],b[200005];
int main(){
	n=read(),k=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	b[1]=k,ab=1;
	while(k){
		ll x=a[ab];
		if(b[x]==0){
			k--,ab=x,b[ab]=k;
			continue;
		}
		ll y=b[x]-k+1;
		k%=y;
		break;
	}
	while(k){
		k--,ab=a[ab];
	}
	cout << ab;
	return 0;
}

Measured memory_bytes: 6748
#define REP(i, s, e) for(register int i = s; i <= e ;i++)

#include <bits/stdc++.h>

using namespace std;
const int maxn = 100010;

int n, k, cnt[maxn], Max;

int main() {
	cin >> n;
	REP(i, 1, n) {
		scanf("%d", &k);
		k++;
		cnt[k]++;
		cnt[k+1]++;
		cnt[k-1]++;
	}
	REP(i, 1, 100000) Max = max(Max, cnt[i]);
	cout << Max;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef vector<long long int> vi;
typedef vector<vi> vvi;
typedef pair<long long int,long long int> ii;
typedef vector<ii> vii;
#define F first
#define S second

long long int n,a,b,ctr,ans,te,dff;
vi h;

bool works (long long int x){
    vi v = h;
    long long int te = 0;
    for (auto i: v){
        te += (x*b >= i) ? 0 : (i-x*b-1)/(a-b)+1;
    }
    return (x >= te);
}

int main(){
    cin >> n >> a >> b;
    dff = a-b;
    h.resize(n);
    for (auto &i: h) cin >> i;
    sort(h.begin(),h.end());
    int l = 0, r = 1e9, m;
    while (r >= l){
        m = (l+r)/2;
        if (works(m)) r = m;
        else l = m+1;
        if (l == r && l == m) break;
    }
    cout << m << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };


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

	llint ans = 0;
	if (k % 2 == 0) {
		llint s = k / 2;
		ans = n/s;
		ans -= n / k;
	}
	ans = (ans * ans * ans);
	llint z = n/ k;
	ans += z * z * z;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)


int main()
{
    long  k, x;
    cin >> k >> x;
    if (500 * k >= x) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
a = [list(input().split()) for i in range(m)]
ans = [0,0]
solved = [0]*(n+1)
penalty = [0]*(n+1)
for i in range(m):
  x = int(a[i][0])
  if a[i][1] == "AC":
    if solved[x] == 0:
      ans[1] += penalty[x]
    solved[x] = 1
  else:
    penalty[x] += 1
ans[0] = solved.count(1)
print(*ans)

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

int main() {
  
  int A=0, B=0;
  
  cin >> A >> B;
  
  int sum = A+B;
  
  if(10<=sum) {
    
    cout << "error" << endl;
    
  } else {
    
    cout << sum << endl;
    
  } 
  
  return 0;
  
}

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

int main()
{
    int r,g,b,n;cin>>r>>g>>b>>n;
    int ans = 0;
    for(int i = 0; i <= 3000; i++ ){
        int m = n - r*i;
        if(m < 0) continue;
        for(int j = 0; j <= 3000; j++){
            int l = m - g*j;
            if(l < 0)continue;
            if(l % b == 0) ans++;
        }
    
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> il1,iln;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    if(a==1)il1.push_back(b);
    if(b==1)il1.push_back(a);
    if(a==n)iln.push_back(b);
    if(b==n)iln.push_back(a);
  }
  if(il1.empty()||iln.empty()){
    cout<<"IMPOSSIBLE";
    return 0;
  }
  sort(iln.begin(),iln.end());  

  rep(i,il1.size()){
    //cout<<il1[i];
    auto iter = lower_bound(iln.begin(),iln.end(),il1[i]);  
    if(*iter==il1[i]){
      
      cout<<"POSSIBLE";
      return 0;
    }
  }
  cout<<"IMPOSSIBLE";
  return 0;
}

Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
map<long long int,int>mark;
long long int ar[100005];
int main(){
	int n;
	long long int m;
	cin>>n>>m;
	long long int tmp=0;
	for (int i=0;i<n;i++){
		scanf("%lld",&ar[i]);
		tmp+=ar[i];
		tmp%=m;
		mark[tmp]++;
	}
	tmp=0;
	long long int ans=0;
	for (int i=0;i<n;i++){
		ans+=mark[tmp%m];
		tmp=(tmp+ar[i])%m;
		mark[tmp]--;
	}
	printf ("%lld\n",ans);
}

Measured memory_bytes: 4992
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  VB used(3, false);
  REP(i, 3) {
    char c;
    cin >> c;
    if (used[c - 'a']) {
      cout << "No" << endl;
      return 0;
    } else {
      used[c - 'a'] = true;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.stdio;
import std.string;

void main()
{
	auto s = readln.strip;
	writeln( solve( s ) );
}

int solve( in string s )
{
	return 700 + s.map!( a => ( a == 'o' ) ? 100 : 0 ).sum;
}

unittest
{
	assert( solve( "oxo" ) == 900 );
	assert( solve( "ooo" ) == 1000 );
	assert( solve( "xxx" ) == 700 );
}


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

int v(string a){
	int sum=0;
	int t=0;
	for(int i=a.size()-1;i>=0;i--){
		int o=a[i]-'0';
		if(t!=0){
			for(int k=0;k<t;k++){
				o=o*10;
			}
		}
		sum+=o;
		t++;
	}
	return sum;
}

int main(){
	string a,b,c;
	cin>>a>>b;
	c=a+b;
	int x=v(c);
	for(int i=0;i<x;i++){
		if(i*i==x){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	nfs_mw;
	int i,j,n,k,v; ll pdp[lim] = {}, pdp2[lim] = {};
	cin>>n>>k;
	pdp[k] = 1;
	for(i=1; i<=n; i++){
		cin>>v;
		pdp2[0] = pdp[v];
		for(j=1; j<=k; j++) pdp2[j] = (((pdp[min(j+v,k)] + (mod - pdp[j-1])%mod)%mod) + pdp2[j-1])%mod;
		swap(pdp,pdp2);
	}
	cout<<pdp[0];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;

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

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n) - 1; i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

template<typename T, typename S>
istream& operator>> (istream& in, pair<S, T>& p) {
    in >> p.fs >> p.sn;
    return in;
}
template<typename T, typename S>
ostream& operator<< (ostream& out, pair<S, T>& p) {
    out << p.fs << ' ' << p.sn << ' ';
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& v) {
    for (T& x : v) in >> x;
    return in;
}
template<typename T>
ostream& operator<< (ostream& out, vector<T>& v) {
    for (T& x : v) out << x << ' ';
    return out;
}

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

namespace Kuhn {
    int n, k;
    vector<vector<int>> g;
    vector<int> mt;
    vector<char> used;


    bool try_kuhn (int v) {
        if (used[v])
            return false;
        used[v] = true;
        for (int i = 0; i < (int)g[v].size(); ++i) {
            int to = g[v][i];
            if (mt[to] == -1 || try_kuhn(mt[to])) {
                mt[to] = v;
                return true;
            }
        }
        return false;
    }

    void init(int _n, int _k) {
        n = _n, k = _k;
        g.resize(n);
        mt.assign(k, -1);
    }

    void add_edge(int i, int j) {
        g[i].push_back(j);
    }

    int run_kuhn() {
        int ans = 0;
        for (int v = 0; v < n; ++v) {
            used.assign(n, false);
            if (try_kuhn(v)) ++ans;
        }
        return ans;
    }

    void clear() {
        g.clear();
        mt.clear();
        used.clear();
    }
}
using Kuhn::add_edge;
using Kuhn::run_kuhn;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n), d(n);
    forn(i, 0, n) cin >> a[i] >> b[i];
    forn(i, 0, n) cin >> c[i] >> d[i];
    Kuhn::init(n, n);
    forn(i, 0, n)
        forn(j, 0, n)
            if (a[i] < c[j] && b[i] < d[j])
                add_edge(i, j);
    cout << run_kuhn() << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MOD int(1e9+7)
using namespace std;
int main(int argc, char const *argv[]) {
    //Parparosa
//     //Shawi Algorithm
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int n, k;
    cin >> n >> k;
    if(k == 1)cout << 0 << endl;
    else cout << n - (k - 1) - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

L = [1 if s == 'W' else 0 for s in S]
R = [1 if s == 'E' else 0 for s in S][::-1]

for i in range(1, N):
    L[i] += L[i-1]
    R[i] += R[i-1]

L = [0] + L[:-1]
R = R[:-1][::-1] + [0]

print(min([L[i] + R[i] for i in range(N)]))


Measured memory_bytes: 45908
#include<stdio.h>
#define KAISU 10
int main(void)
{
      int r=0;
      int D=0;
      int x2000=0;
      int xn=0;
      int i=0;

      scanf("%d%d%d",&r,&D,&x2000);

      xn=x2000;
      for(i=0;i<KAISU;i++){
            xn=r*xn-D;
            printf("%d\n",xn);
      }
      return 0;
}

Measured memory_bytes: 128
# returns : Nのd進数表記
def base_n_num(N, d):
    p = 1
    ans = []
    if N == 0:
        return [0]
    while N != 0:
        if N % (d**p) == 0:
            ans.append(0)
        else:
            ans.append(1)
            N -= (d**(p-1))
        p += 1
        if N == 0:
            break
    return reversed(ans)

def solve():
    n = int(input())

    # 下の桁から求める
    ans = base_n_num(n, -2)
    print(''.join(list(map(str, ans))))

solve()


Measured memory_bytes: 3064
fn print_vec(arr: &Vec<i32>) {
    for i in 0..arr.len() {
        print!("{}", arr[i]);

        if i < arr.len() - 1 {
            print!(" ");
        }
    }
}

const MAX_INPUT: usize = 2_000_000;

fn counting_sort(inputs: Vec<i32>) -> Vec<i32> {
    let n_inputs = inputs.len();
    let mut counter = vec![0 as i32; MAX_INPUT + 1];
    let mut outputs = vec![0_i32; n_inputs];

    for v in &inputs {
        counter[*v as usize] += 1;
    }

    let mut cumlative: Vec<i32> = counter
        .iter()
        .scan(0, |cumsum, &v| {
            *cumsum = *cumsum + v;
            Some(*cumsum)
        })
        .collect();

    // println!("{:?}", inputs);
    // println!("{:?}", cumlative);

    for v in inputs {
        let vu = v as usize;
        outputs[(cumlative[vu] - 1) as usize] = v;
        cumlative[vu] -= 1;
    }

    // println!("{:?}", outputs);

    outputs
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();

    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let inputs: Vec<i32> = line.split_whitespace()
        .map(|e| e.parse::<i32>().ok().unwrap())
        .collect();

    let sorted = counting_sort(inputs);
    print_vec(&sorted);
    println!();
}



Measured memory_bytes: 52544
a,b,k = map(int,input().split())
s1 = set(range(a,min(a+k,b+1)))
s2 = set(range(b,max(b-k,a-1),-1))
s0 = sorted(s1|s2)
[print(s0[i]) for i in range(len(s0))]

Measured memory_bytes: 3060
#include<stdio.h>
int main(){

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

  int x,y,cards[4][14];
  for ( x = 0 ; x < 4 ; x++ ){
    for ( y = 1 ; y <= 13 ; y++ ){
      cards[x][y] = 0;
    }
  }
  
  int i,number,suit;
  char c;
  
  for ( i = 0 ; i < n ; i++ ){

    scanf("%c %c %d", &c, &c, &number);

    if ( c == 'S' ) suit = 0;
    if ( c == 'H' ) suit = 1;
    if ( c == 'C' ) suit = 2;
    if ( c == 'D' ) suit = 3;
    
    cards[suit][number] = 1;
    
  }
  
  int j,k;
  for ( j = 0 ; j < 4 ; j++ ){
    for ( k = 1 ; k <= 13 ; k++ ){

      if ( cards[j][k] == 0 ){

	if ( j == 0 ) c = 'S';
	if ( j == 1 ) c = 'H';
	if ( j == 2 ) c = 'C';
	if ( j == 3 ) c = 'D';

	printf("%c %d\n", c, k);

      }

    }

  }

  return 0;

}

Measured memory_bytes: 596
#include<stdio.h>

int main() {
  int n;
  int s[100];
  int i;
  int min_not_zero = 1000;
  int sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &s[i]);
    sum += s[i];
    if (s[i] % 10 != 0 && s[i] < min_not_zero) {
      min_not_zero = s[i];
    }
  }
  /*printf("%d", min_not_zero);*/
  if (min_not_zero == 1000) {
    printf("%d\n", 0);
  } else {
    if (sum % 10 == 0) {
      printf("%d\n", sum - min_not_zero);
    } else {
      printf("%d\n", sum);
    }
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1E9+7;

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

int n;
ll a, b, h[100010], mem[100010];

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

    sort(h, h+n);

    ll r = h[n-1]/b+1, l = 0, mid, memmid;
    while(l < r){
        memmid = mid = (l+r)/2;

        for(int i = 0; i < n; i++){
            mem[i] = maxll(0, h[i]-mid*b);
        }
        for(int i = 0; i < n; i++){
            if(mem[i] != 0){
                memmid -= mem[i]/(a-b);
                if(mem[i] % (a-b) != 0) --memmid;
            }
        }
        if(memmid >= 0){
            r = mid;
        }
        else{
            l = mid+1;
        }
    }

    cout << r << endl;
}

Measured memory_bytes: 1792