akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
mls = [0]*m
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(len(a)):
        if j == 0:continue
        mls[a[j]-1] += 1
ans = 0
for i in range(len(mls)):
    if mls[i] == n:ans+=1
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define min(a, b) ((a) < (b)? (a):(b))
#define max(a, b) ((a) > (b)? (a):(b))
#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back


int main() {
    int n, k;
    cin >> n >> k;
    
    string s;
    cin >> s;
    
    char now = '1';
    int cnt = 0;
    vector<int> nums;
    for(char c : s) {
        if(c == now) {
            cnt += 1;
        } else {
            nums.pb(cnt);
            now = c;
            cnt = 1;
        }
    }
    nums.pb(cnt);
    if(nums.size()%2 == 0) nums.pb(0);
    
    vector<int> sums(nums.size()+1);
    rep(i, nums.size()) sums[i+1] += sums[i] + nums[i];
    
    int w = 2 * k + 1;
    int ans = -1;
    for(int i=0; i<nums.size(); i+=2) {
        int left = i, right = min(i+w, nums.size());
        ans = max(ans, sums[right] - sums[left]);
    }
    
    cout << ans << endl;
}

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

const int mod = 1e9 + 7, maxn = 60;
string s[2];
int dp[3][3][maxn];

int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }

int main() {
    int n; cin >> n;
    cin >> s[0] >> s[1];
    s[0] = '.' + s[0]; s[1] = '.' + s[1];
    if (s[0][1] == s[1][1]) {
        dp[0][0][1] = dp[1][1][1] = dp[2][2][1] = 1;
        for (int j = 2; j <= n; ++j) {
            if (s[0][j] == s[1][j]) {
                for (int a = 0; a < 3; ++a) {
                    for (int b = 0; b < 3; ++b) for (int c = 0; c < 3; ++c) {
                        if (a != b && a != c) dp[a][a][j] = add(dp[a][a][j], dp[b][c][j - 1]);
                    }
                }
            } else {
                for (int a = 0; a < 3; ++a) {
                    for (int b = 0; b < 3; ++b) if (a != b) {
                        for (int c = 0; c < 3; ++c) for (int d = 0; d < 3; ++d) {
                            if (a != c && b != d) dp[a][b][j] = add(dp[a][b][j], dp[c][d][j - 2]);
                        }
                    }
                }
            }
        }
    } else {
        dp[0][1][2] = dp[1][0][2] = dp[0][2][2] = dp[2][0][2] = dp[1][2][2] = dp[2][1][2] = 1;
        for (int j = 3; j <= n; ++j) {
            if (s[0][j] == s[1][j]) {
                for (int a = 0; a < 3; ++a) {
                    for (int b = 0; b < 3; ++b) for (int c = 0; c < 3; ++c) {
                        if (a != b && a != c) dp[a][a][j] = add(dp[a][a][j], dp[b][c][j - 1]);
                    }
                }
            } else {
                for (int a = 0; a < 3; ++a) {
                    for (int b = 0; b < 3; ++b) if (a != b) {
                        for (int c = 0; c < 3; ++c) for (int d = 0; d < 3; ++d) {
                            if (a != c && b != d) dp[a][b][j] = add(dp[a][b][j], dp[c][d][j - 2]);
                        }
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) ans = add(ans, dp[i][j][n]);
    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7
cnt = 0
cnt2 = 0
for i in range(n):
  for j in range(n):
    if a[i] > a[j]:
      cnt2 += 1
      if i < j:
        cnt += 1
ans = (cnt*k + (k*(k-1)//2)*cnt2)%mod
print (ans)

Measured memory_bytes: 3188
# include <bits/stdc++.h>
using namespace std ;
int main () {
  int n; cin >> n ;
  int sum = 0 , maxL = 0;
  for ( int i = 0; i < n ; ++ i ) {
    int L ; cin >> L ;
    sum += L ;
    maxL = max ( maxL , L );
  }
  if ( maxL < sum - maxL ) {
    cout << " Yes " << endl ;
  }
  else {
    cout << "No" << endl ;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional> // std::function<void(int)>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 111111;
signed main(){
    int h,w,n;
    cin>>h>>w>>n;
    int res[100][100];
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int y=0,x=0;
    for(int i=0;i<n;i++){
        int cnt=a[i];
        while(cnt){
            cnt--;
            res[y][x]=i+1;
            if(y%2==0){
                x++;
                if(x==w){
                    x=w-1;
                    y++;
                }
            }
            else{
                x--;
                if(x==-1){
                    x=0;
                    y++;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<res[i][j]<<' ';
            if(j==w-1)cout<<endl;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a >= b && a >= c){
	cout << b + c;
  }else if(b >= a && b >= c){
	cout << a + c;
  }else{
	cout << a + b;
  }
}


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

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

void solve(long long N){
	int r[1111]={};
	for(int i = 1 ; i <= N ; i++){	
		auto t = pFactorize(i);
		for( auto j : t ) r[j]++;
	}
	long long ans = 1;
	for(int i = 0 ; i < 1111 ; i++){
		ans *= r[i] + 1;
		ans %=  1000000000+7;
	}
	cout << ans << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}


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

d = 0
e = 0
r = 0
f = 0

for i in range(N):
    a = str(input())
    if a == 'AC':
        d +=1
    elif a == 'WA':
        e += 1
    elif a == 'TLE':
        r += 1
    else:
        f += 1
        
print("AC x " +str(d))
print("WA x " + str(e))
print("TLE x " + str(r))
print("RE x " + str(f))

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, X;
        cin >> N >> X;
        vll x(N+1);
        x[0] = X;
        rep(i, 0, N) cin >> x[i+1];
        sort(all(x));
        vll diff(N);
        rep(i, 0, N) {
                diff[i] = abs(x[i] - x[i+1]);
        }

        ll g = g(diff[0], diff[1]);
        rep(i, 0, N) {
                g = g(g, diff[i]);
        }
        //print1d(diff);
        cout << g << endl;
}

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

// colours
#define RESET   "\033[0m"
#define BLACK   "\033[30m"
#define RED     "\033[31m"
#define GREEN   "\033[32m"
#define YELLOW  "\033[33m"
#define BLUE    "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN    "\033[36m"
#define WHITE   "\033[37m"

// debugging : values of variables
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << YELLOW << "debug statement : " << *it << " = " << a << RESET << endl;
    err(++it, args...);
} 

void testCase(){
    int n, m;
    cin>>n>>m;
    int evStart = m, oddStart = m;
    if(m%2 == 0) oddStart--;
    else evStart--;
    for(int i = evStart, j = 1; i >= 2; i-=2, j++){
        cout<<j<<" "<<j+i<<endl;
    }
    for(int i = oddStart, j = n; i >= 1; i-=2, j--){
        cout<<j<<" "<<j-i<<endl;
    }
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}

Measured memory_bytes: 3636
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v;
map<string, vector<LL>>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n >> m;
	rep(i, 1 << n) {
		vector<int>an;
		rep(j, n) {
			if (1 & (i >> j)) {
				an.push_back(j);
			}
		}
		if (an.size() == m) {
			cout << i << ":";
			rep(i, an.size()) {
				cout << " " << an[i];
			}
			cout << endl;
		}
		
	}
	return 0;
}


Measured memory_bytes: 7888
n,m = input().split()
n = int(n)
m = int(m)
l = [[] for i in range(n)]
for i in range(m):
    a,b = input().split()
    a = int(a)
    b = int(b)
    l[a-1].append(b-1)
    l[b-1].append(a-1)

f = False
for i in l[0]:
    for j in l[i]:
        if j == n-1:
            f = True
            break
if f:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 38352
main(void){
    
    int a,i,k,l;
    int x[100];
    
    scanf("%d",&a);
    l=a;
    for(i=0;i<a;i++){
        scanf("%d",&x[i]);
    }
    
    for(i=0;i<a/2;i++){
        l--;
        k=x[i];
        x[i]=x[l];
        x[l]=k;
    }
    for(i=0;i<a;i++){
        printf("%d",x[i]);
        if(i!=a-1){
            printf(" ");
        }
    }
    printf("\n");
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int x,y,hoge[300] = {300000,200000,100000};

signed main() {
    cin >> x >> y;--x,--y;
    if (x==0&&y==0) cout << 1000000 << endl;
    else {
        cout << hoge[x] + hoge[y] << endl;
    }
}




Measured memory_bytes: 764
#include <bits/stdc++.h>
int main(){
  int a;
  int x,y,z;
  std::cin >> a;

  x = a/100;
  y = (a - 100*x)/10;
  z = a - 100*x - 10*y;

  std::cout << x + y + z << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,s2;

  cin >> s >> s2;


  for(int i=0;i<s.size();i++)
    {
      string sa,sb,sc;

      sa = s.substr(0,i);
      sb = s.substr(i,s.size());
      sc = sb + sa;
      if(s2 == sc)
	{
	  cout <<"Yes" << endl;
	  return 0;
	}
    }
  cout <<"No"<< endl;
  return 0;
}


Measured memory_bytes: 256
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        ++$this->pointer;

        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int) $this->next();
    }

    public function nextDouble()
    {
        return (float) $this->next();
    }
}

$sc = new Scanner();
$N = $sc->nextInt();
$L = [];
for($i=0;$i<$N;$i++){
    $L[] = $sc->nextInt();
}
$ans = 0;

for($i=0;$i<$N;$i++){
    for($j=0;$j<$N;$j++){
        for($k=0;$k<$N;$k++){
            $a = $L[$i];
            $b = $L[$j];
            $c = $L[$k];
            $ab = $L[$i]+$L[$j];
            $bc = $L[$j]+$L[$k];
            $ca = $L[$k]+$L[$i];
            if(($a == $b) || ($b == $c) || ($c == $a)){
                continue;
            }
            if(($ab>$c) && ($bc>$a) && ($ca>$b)){
                $ans++;
            }
        }
    }
}

$ans = $ans/6;
echo $ans.PHP_EOL;


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int Q; cin >>Q;
    
    vector<bool> PN(100010, true);
    PN[0] = false;
    PN[1] = false;

    vector<int> sum(100010, 0);
    for(int i = 2; i < 100010; i++){
        for(int k = 2; k * k <= i; k++){
            if(i % k == 0){
                PN[i] = false;
                break;
            }
        }
    }

    for(int i = 1; i < 100010; i++){
        sum[i] = sum[i-1];
        if(i%2 == 1 && PN[i] && PN[(i+1)/2]) sum[i]++;
    }  

    for(int i = 0; i <Q; i++){
        int l, r; cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }

    return 0;
}


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

bool solve(vector<vector<int> > a, vector<int> b){
	int n = a.size();
	vector<vector<int> > B(n, vector<int>(n+1) );
	
	for(int i=0 ; i < n ; i++ ){
		for(int j=0 ; j < n ; j++ ){
			B[i][j] = a[i][j];
		}
	}
	for(int i=0 ; i < n ; i++ ){
		B[i][n] = b[i];
	}
	for(int i=0 ; i < n ; i++ ){
		int p = -1, val = -1;
		for(int j=i ; j < n ; j++ ){
			if( val < abs(B[j][i]) ){
				p = j;
				val = abs(B[j][i]);
			}
		}
		
		if( p == -1 || val <= 0 ) continue;
		
		swap(B[p], B[i]);
		for(int j=0 ; j < n ; j++ ){
			if( i == j ) continue;
			
			int m = B[j][i];
			if( m == 1 ){
				for(int k=i ; k <= n ; k++ ){
					B[j][k] = (B[j][k] + B[i][k]) % 2;
				}
			}
		}
	}
	vector<int> res(n);
	for(int i=0 ; i < n ; i++ ){
		res[i] = B[i][n];
		if( B[i][i] == 0 && B[i][n] == 1 ){
			return false;
		}
	}
	return true;
}

int main(){
	int w, h, d, s[25][25];
	while( cin >> w >> h >> d, w || h || d ){
		for(int y = 0 ; y < h ; y++ ){
			for(int x = 0 ; x < w ; x++ ){
				cin >> s[y][x];
			}
		}
		vector<vector<int> > a(w*h, vector<int>(w*h) );
		vector<int> b(w*h, 0);
		for(int y=0 ; y < h ; y++ ){
			for(int x=0 ; x < w ; x++ ){
				if( s[y][x] ){
					b[y*w+x] = 1;
				}
				
				for(int y_=0 ; y_ < h ; y_++ ){
					for(int x_=0 ; x_ < w ; x_++ ){
						int dist = abs(x - x_) + abs(y - y_);
						if( dist == d || dist == 0 ){
							a[y*w+x][y_*w+x_] = 1;
						}
					}
				}
			}
		}
		bool ans = solve(a, b);
		cout << ans << endl;
	}
}

Measured memory_bytes: 5828
import math
N, K = map(int,input().split())
MOD = 10**9 + 7
ans = 0
for k in range(K, N+2):
  min_part = (k-1)*k // 2
  max_part = (N*(N+1) - (N-k)*(N-k+1)) // 2
  # print(min_part, max_part)
  ans += max_part - min_part + 1
  ans %= MOD
print(ans)

Measured memory_bytes: 9192
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
using lint = long long;
template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }
template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }
inline int bitCount(int x) { return __builtin_popcount(x); }
inline int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//
const lint MOD = 1000003;

lint extgcd(lint a, lint b, lint &x, lint &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	lint d = extgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

lint invmod(lint a, lint m) {
    lint x, y;
    extgcd(a, m, x, y);
    return (x % m + m) % m;
}

lint powmod(lint x, lint k) {
	lint ret = 1;	
	while (k > 0) {
		if (k & 1) modMul(ret, x, MOD);
		modMul(x, x, MOD);
		k >>= 1;
	}
	return ret;
}

const int MAX_I = 1000005;
lint modfact[MAX_I];
lint invfact[MAX_I];

void solve(lint x, lint d, lint n) {
	if (d == 0) {
		cout << powmod(x, n) << endl;
		return;
	}
	lint base = (x * invmod(d, MOD)) % MOD;
	if (x % MOD == 0 || base == 0 || base + n - 1 >= MOD) {
		cout << 0 << endl;
		return;
	}
	lint ans = modfact[base + n - 1];
	modMul(ans, invfact[base - 1], MOD);
	modMul(ans, powmod(d, n), MOD);
	cout << ans << endl;
}

int main() {
	int Q;
	cin >> Q;
	modfact[0] = 1;
	for_(i,1,MAX_I) {
		modfact[i] = (modfact[i-1] * (lint)i) % MOD;
		invfact[i] = invmod(modfact[i], MOD);
	}
	for_(q,0,Q) {
		int x, d, n;
		cin >> x >> d >> n;
		solve(x, d, n);
	}
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 16512
N =int(input())
A =[]
B =[]
for i in range(N):
    a,b = input().split()
    A.append(a)
    B.append(int(b))
X =input()
n = A.index(X)
ans = 0
for i in range(n+1,N):
    ans += B[i]
print(ans)

Measured memory_bytes: 3064
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);

		while (true) {
			final int N = sc.nextInt();
			
			if(N == 0){
				break;
			}
			
			int[] count = new int[N];
			for (int i = 0; i < N; i++) {
				count[i] = sc.nextInt();
			}

			boolean has_over_two = false;
			int tring = 0;
			for (int i = 0; i < N; i++) {
				if (count[i] >= 1) {
					tring++;

					if (count[i] >= 2 && !has_over_two) {
						has_over_two = true;
					}
				}
			}

			System.out.println(has_over_two ? (tring + 1) + "" : "NA");
		}
	}

}

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll lon, squ, tri, lle, lri, zri, zle;
	cin >> lon >> squ >> tri >> lle >> lri >> zri >> zle;
	ll tot = squ * 2;
	int sm = (lon & 1) + (lle & 1) + (lri & 1);
	if(lon && lle && lri && sm >= 2) tot += 6, lon--, lle--, lri--;
	tot += 4 * (lle / 2);
	tot += 4 * (lri / 2);
	tot += (lon / 2) * 4;
	cout << tot / 2 << endl;
	return 0;
}


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

int main(){
    int a, b;
    cin>>a>>b;
    if(a*b%2==0){
        cout<<"Even"<<endl;
    }
    else{
        cout<<"Odd"<<endl;
    }
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
 
typedef long long i64;
typedef char str255[256];

#define BIG_PRIME 1'000'000'007
#define BP_remainder(x) ((x) % BIG_PRIME)

const int INF = 1 << 30;
const int INF_NEG = INF * -1;
const i64 INF_LONG = 1LL << 62;
const i64 INF_LONG_NEG = INF_LONG * -1;

int main()
{
    int L; cin >> L;
    double L3 = L / 3.0f;
    double ans = L3 * L3 * L3;
    printf("%.7f\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>

using namespace std;

int main(){

    string O;
    string E;

    cin >> O >> E;

    string ans = "";

    for(int i = 0;i < O.length();i++){
    	ans += O[i];
        if(i == O.length() - 1 && O.length() - 1 == E.length()){
        	break;
        }
    	ans += E[i];
    }

    cout << ans;

}


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

typedef long long ll;
const int N = 1e5 + 5;
vector<int> edge[N];
int col[N];
int a[3];
int n, m;
bool bp;

void DFS(int u) {
    for (int v: edge[u]) {
        if (col[v] != -1) {
            if ((col[v]^col[u]) != 1) bp = false;
        } else {
            col[v] = col[u]^1;
            DFS(v);
        }
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i=1; i<=m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    memset(col, -1, sizeof(col));
    for (int i=1; i<=n; ++i) {
        if (col[i] != -1) continue;
        if (edge[i].size() == 0) { col[i] = 0; a[0]++; }
        else {
            col[i] = 0;
            bp = true;
            DFS(i);
            if (bp) a[1]++;
            else a[2]++;
        }
    }
    ll ans = 0;
    for (int i=1; i<3; ++i) {
        for (int j=1; j<3; ++j) {
            if (i == 1 && j == 1) ans += (ll)a[i]*a[j]*2LL;
            else ans += (ll)a[i]*a[j];
        }
    }
    ans += (ll)a[0]*(n-a[0])*2LL+(ll)a[0]*a[0];
//    printf("%lld\n", ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int a[100],b[100],c[51];
int n;
bool f[51][51];
bool check(){
    memset(f,0,sizeof(f));
    for (int i=0;i<=50;i++)f[i][i]=1;
    for (int i=1;i<=50;i++)
        if (c[i]==0)
            for (int j=0;j<=50;j++)
                f[j][j%i]=1;
    for (int i=0;i<=50;i++)
        for (int j=0;j<=50;j++)
            if (f[j][i])
                for (int k=0;k<=50;k++)
                    if (f[i][k])
                        f[j][k]=1;
    for (int i=1;i<=n;i++)
        if (!f[a[i]][b[i]])return 0;
    return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++)cin>>a[i];
    for (int i=1;i<=n;i++)cin>>b[i];
    long long ans=0;
    if (!check()){
        cout<<-1;
        return 0;
    }
    for (int i=50;i>=1;i--){
        c[i]=1;
        if (!check())c[i]=0,ans+=(long long)1<<i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import sys

k = int(sys.stdin.readline().rstrip())

def main():
    n = 50
    print(n)
    q, r = divmod(k, n)
    lo = 49 - r + q
    hi = 50 + q

    a = [lo] * (50 - r) + [hi] * r
    return a

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Measured memory_bytes: 3060
N, Y = map(int, input().split())
Y /= 1000

def otoshidama():
    for x in range(N+1):
        resY = Y - 10*x
        if resY < 0:
            break
        for y in range(N-x+1):
            if  resY < 5*y:
                break
            if 5*y + (N-x-y) == resY:            
                return print(x, y, N-x-y)
    return  print('-1 -1 -1')

otoshidama()  

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MAX_N 200005

using namespace std;

int n;
int a[MAX_N];
int t[MAX_N];

void read()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),t[i]=a[i];
}

void work()
{
	int l,r;
	nth_element(t+1,t+(n>>1),t+1+n),l=t[(n>>1)];
	nth_element(t+1,t+(n>>1)+1,t+1+n),r=t[(n>>1)+1];
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=l) printf("%d\n",r);
		else printf("%d\n",l);
	}
}

int main()
{
	read();
	work();
}


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

using namespace std;

#define io freopen("test.txt", "r", stdin);
#define fast ios_base::sync_with_stdio(0);cin.tie(0);


#define ull unsigned long long int
#define lli long long int
#define li long int
#define ld long double

#define cout(x) cout<<x<<" "
#define coutn(x) cout<<x<<endl
#define newline cout<<endl

#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define ar array

#define pii pair<int,int>
#define pll pair<lli,lli>
#define pps pair<pair<int,int>, string>

const int MOD=1000000007;
const lli INF=1e18;
const int MX=100001;
const int N=1000000;


vector<int> g[N];
bool v[N];
int id[N],s[N];
int n,m,k,x,y,w;

int root(int i){
    while(id[i]!=i){
        id[i]=id[id[i]];
        i=id[i];
    }
    return i;
}

void uni(int x, int y){
    int rx=root(x), ry=root(y);
    if(rx==ry) return;
    if(s[rx]<s[ry]){
        id[rx]=ry;
        s[ry]+=s[rx];
        s[rx]=0;
    }else{
        id[ry]=rx;
        s[rx]+=s[ry];
        s[ry]=0;
    }
}

int main(){
    fast

    lli d,t,s;
    cin>>d>>t>>s;

    if(t*s>=d){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }

    
    return 0;
}

Measured memory_bytes: 27080
#include <cstdio>
int a, b;
int main()
{
	scanf("%d%d", &a, &b);
	if (a <= 0 && 0 <= b)
		puts("Zero");
	else if (b < 0 && (b - a + 1 & 1))
		puts("Negative");
	else
		puts("Positive");
	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<iostream>

using namespace std;

int dice[6] = { 1, 2, 3, 4, 5, 6 };


int main()
{
	int n, i, tmp, total;
	string order;
	while (1)
	{
		scanf("%d",&n);
		if (n == 0)break;
		total = 1;
		dice[0] = 1; dice[1] = 2; dice[2] = 3;
		dice[3] = 4; dice[4] = 5; dice[5] = 6;
		for (i = 0; i < n; i++)
		{
			cin >> order;
			if (order == "North")
			{
				tmp = dice[0];
				dice[0] = dice[1];
				dice[1] = dice[5];
				dice[5] = dice[4];
				dice[4] = tmp;
			}
			else if (order == "East")
			{
				tmp = dice[0];
				dice[0] = dice[3];
				dice[3] = dice[5];
				dice[5] = dice[2];
				dice[2] = tmp;
			}
			else if (order == "West")
			{
				tmp = dice[0];
				dice[0] = dice[2];
				dice[2] = dice[5];
				dice[5] = dice[3];
				dice[3] = tmp;
			}
			else if (order == "South")
			{
				tmp = dice[0];
				dice[0] = dice[4];
				dice[4] = dice[5];
				dice[5] = dice[1];
				dice[1] = tmp;
			}
			else if (order == "Right")
			{
				tmp = dice[1];
				dice[1] = dice[2];
				dice[2] = dice[4];
				dice[4] = dice[3];
				dice[3] = tmp;
			}
			else
			{
				tmp = dice[1];
				dice[1] = dice[3];
				dice[3] = dice[4];
				dice[4] = dice[2];
				dice[2] = tmp;
			}
			total += dice[0];
		}
		printf("%d\n", total);
	}
	return 0;
}

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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    int k, x;
    cin >> k >> x;

    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
max=-1000000
min=1000000
sum=0
for i in range(n):
    if max<x[i]:
        max=x[i]
    if min>x[i]:
        min=x[i]
    sum+=x[i]
print(min,max,sum)


Measured memory_bytes: 6592
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(dead_code)]
fn practice_1() {
    input! {
    n: i32,
    m: [i32; 2],
    s: chars,
    }
    let s: Vec<char> = s;
    let s: String = s.into_iter().collect();

    println!("{} {}", n + m[0] + m[1], s);
}

#[allow(dead_code)]
fn abc086_a() {
    input! {
    n: [i32; 2],
    }
//    let n: Vec<i32> = n;
    let res: i32 = n[0] * n[1];
    let res = if res % 2 == 0 {
        "Even"
    } else {
        "Odd"
    };
    println!("{}", res)
}

fn main() {
    abc086_a()
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> A)
{
    vector<ll> front(N);
    vector<ll> back(N);
    front[0] = A[0];
    for (int i = 1; i < N; i++)
    {
        front[i] = gcd(A[i], front[i - 1]);
    }

    back[N - 1] = A[N - 1];
    for (int i = N - 2; i >= 0; i--)
    {
        back[i] = gcd(A[i], back[i + 1]);
    }

    ll ans = -1;

    ans = max(ans, back[1]);
    ans = max(ans, front[N - 2]);
    for (int i = 1; i < N - 1; i++)
    {
        ans = max(ans, gcd(front[i-1],back[i+1]));
    }
    cout << ans << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var max = 0;

        var dic = new Dictionary<string, int>();
        for(int i=0; i<n; i++) {
            var s = input.ReadLine();
            var c = dic.ContainsKey(s) ? dic[s] : 0;
            c++;
            dic[s] = c;
            max = Math.Max(max, c);
        }

        var l = new List<string>();
        foreach(var s in dic.Keys) {
            if(dic[s] == max) {
                l.Add(s);
            }
        }

        l.Sort(StringComparer.OrdinalIgnoreCase);

        var buil = new StringBuilder();
        foreach(var i in l) {
            buil.AppendLine(i);
        }

        return buil.ToString();
    }
}


Measured memory_bytes: 49784
#include<bits/stdc++.h>
using namespace std;
int degit(int a);
int main(){
    int N;
    cin >> N;
    int sum = 0;
    for(int i = 1; i <= N; i++){
        if(degit(i)%2==1) sum++;
    }
    cout << sum << endl;
}
int degit(int a){
    int degit = 0;
    while(a != 0){
        degit++;
        a/=10;
    }
    return degit;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define maxn 1000010
using namespace std;
ll n,p;
ll prime[maxn],num=0;
bool vis[maxn];
int main()
{
	for(ll i=2;i<=maxn+5;++i)
	{
		if(!vis[i])
		{
			prime[++num]=i;
		}
		for(int j=1;j<=num&&prime[j]*i<maxn+5;++j)
		{
			vis[prime[j]*i]=1;
			if(i%prime[j]==0)break;
		}
	}
	scanf("%lld%lld",&n,&p);
	if(n==1)printf("%lld\n",p);
	else
	{
		ll ans=1;
		for(int i=1;i<=num&&prime[i]<=p/prime[i];++i)
		{
			ll now=0;
			while(p%prime[i]==0)
			{
				p/=prime[i];
				now++;
			}
			ans=ans*pow(prime[i],(now/n));
		}
		printf("%lld\n",ans);
	}
}

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



int N, L, T, X[101010], W[101010];
vector<pair<int, int>> St;
vector<int> En;
int ans[101010];
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> L >> T;

    int r = 0;
    rep(i, 0, N) {
        scanf("%d%d", &X[i], &W[i]);
        St.push_back({ X[i], i });
        int fin;
        if (W[i] == 2) {
            fin = (X[i] - T % L + L) % L;
            r -= (T + fin - X[i]) / L;
        } else {
            fin = (X[i] + T % L) % L;
            r += (T + X[i] - fin) / L;
        }
        En.push_back(fin);
        r = (r % N + N) % N;
    }

    sort(En.begin(), En.end());
    sort(St.begin(), St.end());

    for (int i = 0; i < St.size(); i++) ans[St[i].second] = En[(i + r) % N];
    rep(i, 0, N) printf("%d\n", ans[i]);
}

Measured memory_bytes: 4084
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  string s;
  map<char, int> m;
  m['J'] = 0;
  m['O'] = 1;
  m['I'] = 2;
  while(cin>>s){
    s = "I" + s;
    int N = s.size();
    int cnt[3]={};
    int ans = 0;
    for(int i = 1; i < N; i++){
      int n = m[s[i]];
      int b = m[s[i-1]];
      if(n < b){
        REP(i, 3) cnt[i] = 0;
        if(n == 0) cnt[0]++;
      }else{
        cnt[n]++;
        if(cnt[0]>=cnt[1]&&cnt[1]==cnt[2]) ans = max(ans, cnt[1]);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 605;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int n, a[MAXN][MAXN];

int main(){
	cin >> n;
	if(n <= 500){
		cout << n << endl;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				printf("%d ", (i + j) % n + 1);
			}
			puts("");
		}
		return 0;
	}
	else{
		int k = (n + 1) / 2;
		if(k % 2 == 1) k++;
		for(int i=0; i<k; i++){
			for(int j=0; j<k; j++){
				a[i][j] = (i + j) % k + 1;
				if(j % 2 == 1) a[i][j] += k;
				if(a[i][j] > n) a[i][j] -= k;
			}
		}
		cout << k << endl;
		for(int i=0; i<k; i++){
			for(int j=0; j<k; j++) printf("%d ", a[i][j]);
			puts("");
		}
	}
}


Measured memory_bytes: 2432
N = gets.to_i

MOD = 1000000007


res = {}

['a','c','g','t'].repeated_permutation(3).each do |a,b,c|
  k = a + b + c
  if ['agc' , 'acg' , 'gac'].include? k
    res[k] = 0
  else
    res[k] = 1
  end
end

(4..N).each do |_|
  n_res = Hash.new(0)
  ['a','c','g','t'].repeated_permutation(3).each do |a,b,c|
    k = a + b + c
    ['a','c','g','t'].each do |s|
      unless a + b + s == 'agc'
        unless a + c + s == 'agc'
          n_k = b + c + s
          unless ['agc', 'acg', 'gac'].include? n_k
            n_res[n_k] = (res[k] + n_res[n_k])%MOD
          end
        end
      end
    end
  end
  res = n_res
end

puts (res.reduce(0) do |re, (k,v)|
  re = (v + re)%MOD
end)


Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int n,m;

int main(){
  int ans=0;
  cin >> n >> m;
  vector<int> a(m+1),dp(n+1);
  int w=0;
  REP(i,m) cin>>a[i];
  dp[0]=1;
  dp[1]=1;
  if (a[0]==1){
    w=1;
    dp[1]=0;
  }
  
  for(int i=2;i<n+1;i++){
    if (i==a[w]){
      w++;
      continue;
    }
    dp[i]=(dp[i-1]+dp[i-2])%MOD;
  }
  
  

  cout<<dp[n]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

int main() {
    long long k;
    std::string s;
    std::cin >> s >> k;

    for (auto i = 0ll; i < s.length(); i++) {
        if (s[i] == 'a') continue;
        if (k >= 'z' - s[i] + 1) {
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }

    k = k % 26;

    s[s.length() - 1] = s[s.length() - 1] + k;

    std::cout << s << std::endl;

    return 0;
}

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

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n,m;
	cin >> n >> m;
	priority_queue<int> q;
	vector<vector<int>> v(m+1);
	for (int i=0; i<n; ++i){
		int a,b;
		cin >> a >> b;
		if (a <= m) v[a].emplace_back(b);
	}
	int ret=0;
	for (int i=1; i<=m; ++i){
		for (int k:v[i]){
			q.emplace(k);
		}
		if (!q.empty()){
			ret += q.top();
			q.pop();
		}
	}
	cout << ret;
	return 0;
}


Measured memory_bytes: 5632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var map = new long[n+1];
		for(int x = 1; x <= n; x++)
		{
			for(int y = 1; y <= n; y++)
			{
				if(x*x+y*y+x*y > n)
					break;
				for(int z = 1; z <= n; z++)
				{
					long q = x*x+y*y+z*z+x*y+y*z+z*x;
					//Console.WriteLine("{0}, {1}, {2}",x,y,z,q);
					if(q > n)
						break;
					if(q >= 0 && q <= n)
					{
						map[q]++;
					}
				}
			}
		}
		
		for(int i = 1; i <= n; i++)
		{
			Console.WriteLine(map[i]);
		}
		
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> intensity(n);
	
	for(int i = 0; i < n; i++){
		cin >> intensity[i];
	}
	for(int j=0;j<min(k,50);j++){
		vector<int> power(n+1);
		for(int i = 0; i < n; i++){
			int start = i - intensity[i];
			int end = i + intensity[i] + 1;
			if(start < 0) start = 0;
			if(end >= n) end = n;
			power[start] += 1;
			power[end] -=1;
		}
		
		long long current = 0;
		for(int i = 0; i<n; i++){
			current += power[i];
			intensity[i] = current;
		}
	}
	for(int x: intensity){
		cout << x << " ";
	}
	
}


Measured memory_bytes: 4812
#include<bits/stdc++.h>
using namespace std;
int DynamicProgramming(int dp[], int arr[], int n){

    if (n==1){
        return 0;
    }

    dp[1] = 0;
    dp[2] = abs(arr[2]-arr[1]);

    for (int i=3 ; i<=n ; i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }

    return dp[n];
}


using namespace std;
int main(){
    int n;
    cin >> n;
    int arr[n+1];
    for (int i=1 ; i<=n ; i++){
        cin >> arr[i];
    }
    
    int dp[n+1];

    cout << DynamicProgramming(dp,arr,n) << "\n";
   
    return 0;
}

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


int main()
{
    bool chk=true;
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;

        if(!(S.at(A)=='-'))
        {
            chk=false;
        }

    for(int i=0; i<A; i++)
    {
        if(S.at(i)=='-')
        {
            chk=false;
        }
    }
    for(int i=A+1; i<A+B+1; i++)
    {
        if(S.at(i)=='-')
        {
            chk=false;
        }
    }
    if(chk)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int arr[105];
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
    }
    sort(arr+1,arr+n+1);
    int mid = (arr[1] + arr[n]) / 2;
    int sum = arr[1] + arr[n];
    ll chaeng = 1e18;
    for(i=1;i<=100;i++)
    {
        ll sana = 0;
        for(j=1;j<=n;j++)
        {
            sana += 1LL*(arr[j]-i)*(arr[j]-i);
        }
        chaeng = min(chaeng, sana);
    }
    cout << chaeng << endl;
    return 0;
}


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

A = [None] * N
B = [None] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

result = 0
for i in range(N - 1, -1, -1):
    result += (B[i] - (A[i] + result) % B[i]) % B[i]
print(result)


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

ll expr(string s, int &p, int lev);
ll factor(string s, int &p);
ll number(string s, int &p);

string op[3];
vector<vector<string>> ops = {
  {"+-*", "", ""},
  {"+", "-*", ""}, {"-", "+*", ""}, {"*", "+-", ""},
  {"+-", "*", ""}, {"+*", "-", ""}, {"-*", "+", ""},
  {"+", "-", "*"}, {"+", "*", "-"}, {"-", "+", "*"}, {"-", "*", "+"}, {"*", "+", "-"}, {"*", "-", "+"}
};

ll expr(string s, int &p, int lev) {
  ll val1 = lev + 1 == 3 ? factor(s, p) : expr(s, p, lev + 1);
  while (op[lev].find(s[p]) != string::npos) {
    char op = s[p++];
    ll val2 = lev + 1 == 3 ? factor(s, p) : expr(s, p, lev + 1);
    switch (op) {
      case '+': val1 += val2; break;
      case '-': val1 -= val2; break;
      case '*': val1 *= val2; break;
    }
  }
  return val1;
}

ll factor(string s, int &p) {
  if (isdigit(s[p])) return number(s, p);
  p++;
  ll res = expr(s, p, 0);
  p++;
  return res;
}

ll number(string s, int &p) {
  ll res = 0;
  while (isdigit(s[p])) {
    res = res * 10 + (s[p++] - '0');
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  ll ans = LLONG_MIN;
  for (int i = 0; i < (int)ops.size(); i++) {
    for (int j = 0; j < 3; j++) {
      op[j] = ops[i][j];
    }
    int p = 0;
    ans = max(ans, expr(s, p, 0));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;


int main(){
    AC
    char c;
    cin>>c;
    if(c>='a'&&c<='z')
        cout<<'a'<<nl;
    else
        cout<<'A'<<nl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(void)
{
  int a, b;
  cin >> a >> b;
  int p = 1;
  int pa, pb;
  for (p = 1; p <= 1009; p++) {
    pa = p * 0.08;
    pb = p * 0.1;
    if (pa == a & pb == b) {
      cout << p << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main() {
		int N;
		cin >> N;
		if (N > 0 && N <= 9)
			cout << N;
		else if (N > 9 && N <=99)
			cout << 9;
		else if (N > 99 && N <= 999) {
			cout << 9 + (N - 99);
		}
		else if (N > 999 && N <= 9999) {
			cout << 909;
		}
		else if (N > 9999 && N <= 99999) {
			cout << 909 + (N - 9999);
		}
		else if (N == 100000) {
			cout << 90909;
		}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int A[2000001],B[2000001];

main(){
  int i,j,k,n,C[10001];
  k = 10000;

  scanf("%d",&n);
  i=1;
  while(i<n+1){
    scanf("%d",&A[i]);  
    i++;  
  }

  for(i=0;i<=k;i++){
    C[i] = 0;
  }
  for(j=1;j<n+1;j++){
    C[A[j]]++;
  }
  for(i=1;i<k+1;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i<n)printf(" ");
    else printf("\n");  
  }

 return 0;
}

Measured memory_bytes: 16268