akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

const int maxn = 3005;
int n, s;
int dp[maxn][maxn], a[maxn];

int f(int i, int k) {
  if(k > s) return 0;
  if(k == s) return n - i + 1;
  if(i == n) return 0;
  if(dp[i][k] != -1) return dp[i][k];
  return dp[i][k] = add(f(i + 1, k), f(i + 1, k + a[i]));
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof dp);
  f(0, 0);
  int res = 0;
  for(int l = 0; l < n; l++) {
    res = add(res, dp[l][0]);
  }
  cout << res;
}

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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n; cin >> n;
    ll ans = (a_n(10, n) + a_n(8, n))%MOD;
    ans = (ans - a_n(9, n) + MOD)%MOD;
    ans = (ans - a_n(9, n) + MOD)%MOD;
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        ret %= MOD;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count))%MOD;
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3564
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n; cin>>n; 
    int a[n+2],sum=0; 
    for (int i=1;i<=n;i++) cin >> a[i] ; 
    a[0]=0; a[n+1]=0;
    for (int i=1;i<=n+1;i++){
    	sum += abs(a[i]-a[i-1]);
    }
    for (int i=1;i<=n;i++){
    	int ans= sum - abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
    	cout << ans << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4372
#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 ll;
typedef unsigned long long int ull;
// PB-DS 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define ff first
#define ss second
#define pb push_back
#define Inf  1000000000000000000
#define inf -1000000000000000000
#define mod 1000000007

ll mulmod(ll x,ll y){
  return (x%mod*y%mod)%mod;
}
 
ll addmod(ll x,ll y){
  return (x%mod+y%mod)%mod;
}
 
long long  power(long long  x,long long  y) { 
    long long  res = 1;      
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x;  
        y = y>>1;  
        x = x*x;  
    } 
    return res; 
}


void testcases(int Case){
  string s;
  cin >> s;
  cout << s[0] << s[1] <<s[2] << endl;
}

  
int main()
{
 // sieve();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
    ll t;
    t = 1;
    //cin >> t;
    ll Case =1 ;
    while(t--)
    {
      testcases(Case++);
    }
}

Measured memory_bytes: 3616
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <bitset>
#include <map>
#include <queue>
 
using namespace std;

typedef long long ll;

void solve(){
	int k;
	string s;
	cin >> k >> s;
	if (s.size() <= k){
		cout << s << endl;
	} else {
		cout << s.substr(0, k) << "..." << endl;
	}
}

int main(){
    int t = 1;
	while (t--){
		solve();
	}
}



Measured memory_bytes: 3628
#include <stdio.h>

int main(){
    int m, f, r;
    while(1){
        scanf("%d %d %d ", &m, &f, &r);
        if(m==-1&&f==-1&&r==-1)break;
        if(m==-1||f==-1){
            printf("F\n");
        }else if(m+f>=80){
            printf("A\n");
        }else if(m+f>=65){
            printf("B\n");
        }else if(m+f>=50){
            printf("C\n");
        }else if(m+f>=30){
            if(r>=50){
                printf("C\n");
            }else{
                printf("D\n");
            }
        }else{
            printf("F\n");
        }
    }
    return 0;
}

Measured memory_bytes: 588
import sys
readline = sys.stdin.readline

n, k = map(int, readline().split())
P = 10**9 + 7

def mod_prod(a,b):
    return a * b % P

def mod_fact(a):
    ret = 1
    for i in range(a):
        ret = ret * (i + 1) % P
    return ret

def mod_pow(a, n):
    ret = 1
    while n > 0:
        if n % 2 == 1:
            ret = ret * a % P
        a = a * a % P
        n = n // 2
    return ret

def mod_div(a, b):
    b_inv = mod_pow(b, P - 2)
    return a * b_inv % P

def mod_comb(a,b):
    ret = 1
    b = min(b, a - b)
    for i in range(b):
        ret *= a - i
        ret %= P
    ret = mod_div(ret, mod_fact(b))
    return ret


if k >= n - 1:
    ans = mod_comb(n + n - 1, n - 1)
    print(ans)
else:
    ans = 0

    a = mod_comb(n, 0)
    b = mod_comb(n - 1, 0)
    ans = a * b % P
    for i in range(1, k + 1):
        a = mod_prod(a, (n - i + 1)) 
        a = mod_div(a, i)
        b = mod_prod(b, (n - 1 - i + 1))
        b = mod_div(b, i)
        ans += a * b % P
        ans %= P
    print(ans)

Measured memory_bytes: 42088
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
using namespace std;
using ll = long long;
vector<vector<pair<ll,ll>>> v(100010);
vector<ll> dist(100010);
void dfs(ll cur, ll par,ll point=0){
    dist[cur] = point;
    // cout<<"cur:"<<cur<<", par:"<<par<<endl;
    for(ll i=0;i<v[cur].size();i++){
        ll next = v[cur][i].first;
        ll next_point = v[cur][i].second+point;
        // cout<<"next:"<<next<<endl;
        if(next!=par){
            dfs(next,cur,next_point);
        }
    }
    return;
}

int main(){
    long N;
    cin>>N;
    
    for(ll i=0;i<N-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back(make_pair(b,c));
        v[b].push_back(make_pair(a,c));
    }
    
    ll Q,K;
    cin>>Q>>K;
    K--;
    ll x[Q],y[Q];
    for(ll i=0;i<Q;i++){
        ll _x,_y;
        cin>>_x>>_y;
        _x--;_y--;
        x[i] = _x;
        y[i] = _y;
    }
    dfs(K,-1);
    for(ll i=0;i<Q;i++){
        cout<<dist[x[i]]+dist[y[i]]<<"\n";
    }




}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
  using namespace std;
 
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
   if(s.at(i)=='1'){
     s.at(i)='9';
   }else{
     s.at(i)='1';
   }
  }
  
  cout<<s<<endl;
}

Measured memory_bytes: 256
while True:
    N,X = map(int,input().split())
    if N == 0 and X == 0:
        break
    ans = 0
    for a in range(1,N+1):
        for b in range(1,N+1):
            if b <= a:
                continue
            c = X-(a+b)
            if c > b and c <= N:
                ans += 1
    print("%d"%(ans))



Measured memory_bytes: 5592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int h, w;
    cin >> h >> w;
    string s[60];
    imfor(i, h) {
        cin >> s[i];
    }
    imfor(i, h) {
        imfor(j, w) {
            if (s[i][j] == '#') {
                cout << "#";
                continue;
            }
            int tmp = 0;
            if (i != 0 && j != 0 && s[i - 1][j - 1] == '#') {
                tmp++;
            }
            if (i != 0 && s[i - 1][j] == '#') {
                tmp++;
            }
            if (i != 0 && j != w - 1 && s[i - 1][j + 1] == '#') {
                tmp++;
            }
            if (j != 0 && s[i][j - 1] == '#') {
                tmp++;
            }
            if (j != w - 1 && s[i][j + 1] == '#') {
                tmp++;
            }
            if (i != h - 1 && j != 0 && s[i + 1][j - 1] == '#') {
                tmp++;
            }
            if (i != h - 1 && s[i + 1][j] == '#') {
                tmp++;
            }
            if (i != h - 1 && j != w - 1 && s[i + 1][j + 1] == '#') {
                tmp++;
            }
            cout << tmp;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
for i in range(q):
    b_i, c_i = map(int, input().split())
    b.append(b_i)
    c.append(c_i)


res = {}
for a_i in a:
    if not a_i in res:
        res[a_i] = 0
    res[a_i] += 1

ans = 0
for key, val in res.items():
    ans += key * val

for b_i, c_i in zip(b, c):
    num = res[b_i] if b_i in res else 0
    res[b_i] = 0
    if not c_i in res:
        res[c_i] = 0
    res[c_i] += num

    ans += (c_i - b_i) * num

    print(ans)


Measured memory_bytes: 99336
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
using namespace std;

void print_vector(vector<int>& v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << "\n";
    return;
}

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int c1 = abs(a2 - a1) + abs(a3 - a2);
    int c2 = abs(a3 - a1) + abs(a2 - a3);
    int c3 = abs(a1 - a2) + abs(a3 - a1);
    int c4 = abs(a3 - a2) + abs(a1 - a3);
    int c5 = abs(a1 - a3) + abs(a2 - a1);
    int c6 = abs(a2 - a3) + abs(a1 - a2);
    int mc = min(c1, min(c2, min(c3, min(c4, min(c5, c6)))));
    cout << mc << "\n";

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
const double EPS=1e-9;
#define debug(c) (cerr<<#c<<": "<<c<<"\n")
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
ll a[1005][1005];
//ll dp[1005][1005];
ll dist[1005][1005];
ll vis[1005][1005];
ll dx[4]={-1,0,0,1};
ll dy[4]={0,-1,1,0};
ll mx[20]={-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
ll my[20]={-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
ll dh,dw,h,w;
bool safe(ll x,ll y)
{
	if(x>=1&&x<=h&&y>=1&&y<=w&&a[x][y])
		return true;
	else
		return false;
}
/*ll func(ll x,ll y)
{
	if(x==dh&&y==dw)
		return dp[x][y]=0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	vis[x][y]=2;
	ll min1=INT_MAX,i;
	for(i=0;i<=3;i++)
	{
		ll u=x+dx[i];
		ll v=y+dy[i];
		if(safe(u,v)&&vis[u][v]!=2)
			min1=min(min1,func(u,v));	
	}
	for(i=0;i<=19;i++)
	{
		ll u=x+mx[i];
		ll v=y+my[i];
		if(safe(u,v)&&vis[u][v]!=2)
			min1=min(min1,func(u,v)+1);	
	}
	vis[x][y]=1;
	dp[x][y]=min1;
	return min1;
}*/
void bfs(ll x,ll y)
{
	deque<pii> q;
	q.push_back({x,y});
	dist[x][y]=0;
	ll i;
	while(!q.empty())
	{
		pii d=q.front();
		q.pop_front();
		x=d.fi;y=d.se;
		if(vis[x][y]==1)
			continue;
		vis[x][y]=1;
		for(i=0;i<=3;i++)
		{
			ll u=x+dx[i];
			ll v=y+dy[i];
			if(safe(u,v)&&vis[u][v]==0)
			{
				dist[u][v]=min(dist[u][v],dist[x][y]);
				q.push_front({u,v});
			}
		}
		for(i=0;i<=19;i++)
		{
			ll u=x+mx[i];
			ll v=y+my[i];
			if(safe(u,v)&&vis[u][v]==0)
			{
				dist[u][v]=min(dist[x][y]+1,dist[u][v]);
				q.push_back({u,v});
			}	
		}
	}
}
int main()
{
	ios;
	//memset(dp,-1,sizeof(dp));
	memset(vis,0,sizeof(vis));
	string s;
	ll ch,cw,i,j,d;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
			dist[i][j]=INT_MAX;
	}
	for(i=1;i<=h;i++)
	{
		cin>>s;
		for(j=1;j<=w;j++)
			a[i][j]=(s[j-1]=='.')?1:0;
	}
	bfs(ch,cw);
	if(dist[dh][dw]==INT_MAX)
		dist[dh][dw]=-1;
	cout<<dist[dh][dw]<<endl;
	/*for(i=1;i<=h;i++)
	{
		for(j=1;j<=w;j++)
			cout<<dist[i][j]<<" ";
		cout<<endl;
	}*/

}


Measured memory_bytes: 28036
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
n  = int(input())
#  = int(input())
x  = list(map(int, input().split()))
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

xsort = sorted(x)
l = xsort[n // 2 - 1]
r = xsort[n // 2]

for x_ in x:
    print(r if x_ <= l else l)


Measured memory_bytes: 25476
import bisect
from itertools import accumulate

N, M, K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())

A_cumsum = list(accumulate(A))
B_cumsum = list(accumulate(B))

max_books = 0
for a, A_sum in enumerate([0] + A_cumsum):
    if A_sum > K:
        break
    else:
        b = bisect.bisect(B_cumsum, K - A_sum)
        max_books = max(a + b, max_books)

print(max_books)


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

s = 0
t = 0

ans = 10 ** 12

for i in range(N):
  t += A[i]

for n in range(N-1):
  s += A[n]
  t -= A[n]
  ans = min(ans, abs(s - t))

print(ans)

Measured memory_bytes: 23796
//
// Created by satcl on 2020-05-05.
//
#include <bits/stdc++.h>
#include <unordered_set>
#include <stdio.h>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define endl "\n"
#define PI 3.141592653589793
#define vi vector<int>
#define vll vector<long long>
#define p pair<int,int>
const int MOD = 1000000007;
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define rep(i,j,k,in) for (int i = j; i < k; i += in)


/*---END OF TEMPLATE---*/


ll n,w;
ll dp[1000000+2];
int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    //ifstream fin("data.in");
    //ofstream fout("data.out");

    //scan(n); scan(w);
	cin >> n >> w;
    memset(dp,0,sizeof(dp));
    for (ll i = 1; i < n+1; i++) {
        ll wei,val;
        cin >> wei >> val;
        for (ll j = w; j >= wei; j--) {
            dp[j] = max(dp[j-wei]+val,dp[j]);
        }
    }
    ll mx = -1;
  	for (ll i = 0; i <= w; i++) mx = max(dp[i],mx);
    cout << mx << endl;
}

Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
int k,x;
int main(){
    cin>>k>>x;
    if(k*500>=x){
        puts("Yes");
    }else{
        puts("No");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0; i<ll(n); i++)
#define FOR(i,m,n) for(int i=ll(m); i<ll(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = (1 << 30) - 1;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


void solve() {

	ll dp[15][15];

	REP(i, 15)REP(j, 15)dp[i][j] = 0;

	dp[1][1] = 1;
	REP(i, 15) {
		dp[i][1] = 1;
		dp[1][i] = 1;
	}

	FOR(i, 2, 10) {
		FOR(j, 2, 10) {
			dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j;
			dp[i][j] -= dp[i - 1][j - 1] * (i - 1)*(j - 1);
		}
	}



	REP(i, 10) {
		REP(j, 10) {
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}


}



ll dp[3005][3005];
int main() {

	

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	


	dp[a][b] = 1;

	FOR(i, b, d + 1) {
		dp[a][i + 1] = (dp[a][i] * a) % mod;
	}
	FOR(i, a, c + 1) {
		dp[i + 1][b] = (dp[i][b] * b) % mod;
	}

	FOR(i, a + 1, c + 1) {
		FOR(j, b + 1, d + 1) {

			dp[i][j] = dp[i][j - 1] * i + dp[i - 1][j] * j;
			dp[i][j] %= mod;
			dp[i][j] -= (dp[i - 1][j - 1] * (i - 1)*(j - 1)) % mod;
			dp[i][j] += mod;
			dp[i][j] %= mod;
		}
	}

	cout << dp[c][d] << endl;




}

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

int main() {
    string S;
    cin>>S;
    int N = S.size();
    string Winner; 
    if(S[0] == S[N-1]){
        if(N%2) Winner = "Second";
        else Winner = "First";
    }else{
        if(N%2) Winner = "First";
        else Winner = "Second";
    }
    cout << Winner << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>


int main(void)
{
	//変数の宣言
	int n;
	char s1[55];
	char s2[55];
	int i,j;
	int before=0;
	int now=0;
	long long int count;
	
	//データの読み込み
	scanf("%d",&n);
	scanf("%s\n",&s1);
	scanf("%s",&s2);
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	
	for(i=0;i<n;i++){
		if(i==0){
			if(s1[0]==s2[0]){
				count=3;
				i++;
				before=0;
			}else{
				count=6;
				i++;
				i++;
				before=1;
			}
			if(n==1){
				break;
			}
		}
		
		if(s1[i]==s2[i]){
			now=0;
		}else{
			now=1;
			i++;
		}
		
		if(before==0){
			count=count*2%1000000007;
		}else if(now==1){
			count=count*3%1000000007;
		}
		
		before=now;
//		printf("i=%d,count=%lld\n",i,count);
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%ld",count);
	
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
import sys

n, x = map(int, input().split())

a = list(map(int, input().split()))

a.sort()

# cnt_children = 0
# for i in range(n):
#     if x >= a[i]:
#         cnt_children += 1
#         x -= a[i]
#     else:
#         break

# if x > 0 and cnt_children == n:
#     cnt_children -= 1

# print("{}".format(cnt_children))

# cnt_candy = 0
# cnt_children = 0
# for item in a:
#     if cnt_candy < x:
#         cnt_candy += item
#         cnt_children += 1

# if cnt_candy != x:
#     cnt_children -= 1

# print("{}".format(cnt_children))

if x == sum(a):
    print("{}".format(n))
else:    
    cnt_candy = 0
    cnt_children = 0

    for index, item in enumerate(a):
        cnt_candy += item
        if x >= cnt_candy:
            cnt_children = index + 1

    if x > sum(a):
        print("{}".format(n-1))
    else:
        print("{}".format(cnt_children))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
    int x,out;
    cin >> x;
    out = 8;
    for (int i = 0; i < 8; i++)
    {
        x = x - 200;
        if(x<400)
            break;
        out = out - 1;
    }
    cout << out;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, m; cin >> n >> m;
  vector<int> box(n, 1);
  vector<bool> flag(n, false);

  flag[0] = true;

  rep(i, m) {
    int x, y; cin >> x >> y;
    --x; --y;
    flag[y] = flag[y] | flag[x];
    ++box[y];
    --box[x];

    if(box[x] == 0) flag[x] = false;
  }
  int ans = 0;
  rep(i, n) if(flag[i]) ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, m, dis[N], par[N];
vector<int> adj[N], ans;
int main(int argc, char const *argv[])
{
	scanf("%d %d\n", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		scanf("%d %d\n", &u, &v);
		adj[u].push_back(v);
	}
	for (int s = 1; s <= n; ++s)
	{
		queue<int> q;
		for (int i = 1; i <= n; ++i)
		{
			par[i] = dis[i] = -1;
		}
		q.push(s);
		dis[s] = 0;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int v: adj[u])
			{
				if (dis[v] == -1)
				{
					par[v] = u;
					dis[v] = 1 + dis[u];
					q.push(v);
				}
				else if (v == s)
				{
					int cur = u;
					vector<int> temp;
					while (cur != -1)
					{
						temp.push_back(cur);
						cur = par[cur];
					}
					if (temp.size() < ans.size() || ans.empty())
					{
						ans.clear();
						for (int node: temp)
							ans.push_back(node);
					}
				}
			}
		}
	}
	if (ans.empty())
		printf("%d\n", -1);
	else
	{
		printf("%d\n", (int)ans.size());
		for (int node: ans)
			printf("%d\n", node);
	}
	return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    cout<<fixed<<setprecision(6);
    double r;
    cin>>r;
    double PI=3.141592653589;
    double S=r*r*PI;
    double L=r*2*PI;
    cout<<S<<" "<<L<<endl;

    
    return 0;
    
}


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


def solve(N: str):
    if N[-1] == "3":
        print("bon")
    elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8":
        print("pon")
    else:
        print("hon")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61708
S=input()
b=S.replace("A","")=="KIHBR"
if b:
    L=list(map(len, "".join("*" if s!="A" else s for s in S).split("*")))
    X=[1,0,0,1,1,1,1]
    b&=all(L[i]<=X[i] for i in range(len(L)))
print("YNEOS"[not b::2])

Measured memory_bytes: 3064
def do():
    if n == 1:
        print(1)
        return 0
    x = (1+n) * n
    x -= 1
    #print(x) # なにもない時の和
    for i in range(2, (n // 2) + 1):
        num = n // i
        x += i * ( (1 + num) * num // 2)
        x -= i
        #for j in range(i+i, n + 1, i):
        #    x += j

    print(x)

res = 0
n = int(input())
do()


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

using namespace std;

int main()
{
	int n;
	cin>>n;
	int menor=0, cnt=0;
	for (int i=0; i<n; i++)
	{
		int x;
		cin>>x;
		if (x>=menor)
		{
			cnt++;
			menor=x;
		}
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}

int n;
vector<double> x,y;
double ave=0;
double m;

void f(vi v,bool b[10]){
  if(v.size()==n){
    double sum=0;
    FOR(i,1,n){
      sum+=sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
    }
    ave+=sum;
    m++;
  }

  rep(i,n){
    if(!b[i]){
      b[i]=true;
      v.PB(i);
      f(v,b);
      b[i]=false;
      v.erase(v.end()-1);
    }
  }
}



signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n;
  x=vector<double>(n);
  y=vector<double>(n);
  rep(i,n){
    cin>>x[i]>>y[i];
  }

  double sum=0;
  double m=1;
  FOR(i,1,n+1) m*=i;
  double k=1;
  FOR(i,1,n) k*=i;

  rep(i,n){
    FOR(j,i+1,n){
      double res=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
      res*=2*k;
      sum+=res;
    }
  }

  cout<<sum/m<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
int sum(int a){
	int b=0;
	while(a!=0){
		b+=a%10;
		a/=10;
	}
	return b;
}
int main(void){
int n,a,b;
ll ans=0;
cin>>n>>a>>b;
for(int i=1;i<=n;i++){
	int keta=sum(i);
	if(keta>=a&&keta<=b){
		ans+=i;
	}
}
cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
	const double pi = acos(-1);
	double a, b, x;
	cin >> a >> b >> x;

	double ans = 0;
	if (2*x < a*a*b) {
		ans = atan(a*b*b / (2.0*x)) * 180.0 / pi;
	} else {
		double a2 = a*a;
		ans = atan(2.0*(a2*b - x) / (a2*a)) * 180.0 / pi;
	}
	cout.precision(15);
	cout << fixed << ans << endl;

	return 0;
}


Measured memory_bytes: 512
pattern_list =[[0,1,2,3,4,5],[0,2,4,1,3,5],[0,4,3,2,1,5],[0,3,1,4,2,5],[1,2,0,5,3,4],[1,5,2,3,0,4],[1,3,5,0,2,4],[1,0,3,2,5,4],[2,0,1,4,5,3],[2,4,0,5,1,3],[2,5,4,1,0,3],[2,1,5,0,4,3],[3,0,4,1,5,2],[3,1,0,5,4,2],[3,5,1,4,0,2],[3,4,5,0,1,2],[4,2,5,0,3,1],[4,0,2,3,5,1],[4,3,0,5,2,1],[4,5,3,2,0,1],[5,1,3,2,4,0],[5,2,1,4,3,0],[5,4,2,3,1,0],[5,3,4,1,2,0]]

dice_a_list = list(map(int,input().split()))
dice_b_list = list(map(int,input().split()))

dice_c_list =[0,0,0,0,0,0]
cnt = 0
for i in range(24):
	for j in range(6):
		dice_c_list[j]=  dice_a_list[pattern_list[i][j]]
	if dice_c_list == dice_b_list:
		cnt =1
if cnt==0:
	print("No")
else:
	print("Yes")


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);

pair<int, vector<pair<int, int>>> node[100000];
int res[100000];

int main(){
  int n;
  int u,v,w;
  memset(res, -1, sizeof(res));
  cin >> n;
  REP(i, n-1){
    cin >> u >> v >> w;
    node[u-1].first=u-1;
    node[u-1].second.push_back(make_pair(v-1, w));
    node[v-1].first=v-1;
    node[v-1].second.push_back(make_pair(u-1, w));
  }
  stack<pair<int, vector<pair<int,int>>>> st;
  st.push(node[0]);
  res[0]=0;
  while(!st.empty()){
    auto target = st.top();
    st.pop();
    REP(i, target.second.size()){
      if(res[target.second[i].first]!=-1) continue;
      res[target.second[i].first] = (target.second[i].second%2 ? abs(res[target.first]-1) : res[target.first]);
      st.push(node[target.second[i].first]);
    }
  }
  REP(i, n) cout << res[i] << endl;
  return 0;
}

Measured memory_bytes: 11004
from pprint import pprint
m, n = map(int, raw_input().split())
k = int(raw_input())

psum = [[[0] * 3 for x in xrange(n + 1)] for y in xrange(m + 1)]

for y in xrange(m):
    line = raw_input()
    for x in xrange(n):
        for i in xrange(3):
            psum[y + 1][x + 1][i] = psum[y][x + 1][i] + psum[y + 1][x][i] - psum[y][x][i]
        psum[y + 1][x + 1][ { 'J':0, 'O':1, 'I':2 }[line[x]] ] += 1

for k_ in xrange(k):
    a, b, c, d = map(int, raw_input().split())
    j = psum[c][d][0] - psum[a - 1][d][0] - psum[c][b - 1][0] + psum[a - 1][b - 1][0]
    o = psum[c][d][1] - psum[a - 1][d][1] - psum[c][b - 1][1] + psum[a - 1][b - 1][1]
    i = psum[c][d][2] - psum[a - 1][d][2] - psum[c][b - 1][2] + psum[a - 1][b - 1][2]
    print j, o, i

Measured memory_bytes: 187128
n, k = gets.chomp.split.map(&:to_i)
num = Array.new(100001){0}
n.times do
    a, b = gets.chomp.split.map(&:to_i)
    num[a] += b
end
sum = 0
100001.times do |i|
    sum += num[i]
    if sum >= k
        puts i
        break
    end
end


Measured memory_bytes: 2556
#include <stdio.h>

int main(void) 
{
	int			student_id;
	double		weight, height, BMI;
	int			count = 0;

	while (scanf(" %d,%lf,%lf", &student_id, &weight, &height) != EOF) {
		BMI = weight / (height * height);

		if (BMI >= 25.0) {
			printf("%d\n", student_id);
			count++;
		}
	}

	if (!count)
		printf("該当なし\n");

	return 0;
}

Measured memory_bytes: 628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    int64_t Sum=0;
    rep(i,n){
        cin>>a.at(i);
        Sum+=a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    double ratio=Sum/(4.0*m);
    if(a.at(m-1)>=ratio){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

namespace Problem_C
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var upper = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var lower = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            var max = 0;
            for (var i = 0; i < n; i++)
            {
                var upperSum = upper.Take(i + 1).Sum();
                var lowerSum = lower.Skip(i).Take(n - i).Sum();
                max = Math.Max(max, upperSum + lowerSum);
            }
            Console.WriteLine($"{max}");
        }
    }
}


Measured memory_bytes: 13396
S = input()

is_palindrome = lambda S: S == ''.join(list(reversed(S)))
is_palindrome2 = lambda S: is_palindrome(S[0:int((len(S) - 1) / 2)])
is_palindrome3 = lambda S: is_palindrome(S[int((len(S) + 3) / 2):len(S) - 1])
is_strong_palindrome = lambda S: is_palindrome(S) and is_palindrome2(S) and is_palindrome3(S)

answer = 'Yes' if is_strong_palindrome(S) else 'No'

print(answer)


Measured memory_bytes: 3060
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  rep(i,S.size()){
    int s = int(S.at(i)) - int('A');
    s = (s+N)%26;
    s += int('A');
    char ans = char(s);
    S.at(i) = ans;
  }
  rep(i,S.size()){
    cout << S.at(i);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int n,l[45],L[45],a,d[5]={5,7,5,7,7};
string s;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=1;i<=n;i++){
      cin>>s,l[i]=s.size();
      L[i]=L[i-1]+l[i];
    }
    a=0;
    for(int i=1;i<=n;i++){
      int x=0,s=i;
      for(int j=i;j<=n;j++){
	if(L[j]-L[s-1]==d[x])x++,s=j+1;
	if(!a&&x==5)a=i,cout<<a<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdlib>
#include<iomanip>

using namespace std;

void Solution()
{
    double x, h;
    
    while (cin>>x>>h)
    {
        if (x == 0 && h == 0)
        {
            break;
        }
        
        cout<<fixed<<setprecision(6)<<(x * x) + 2 * x * sqrt(h * h + (x/2) * (x/2))<<endl; // 2xh = 4 * (1/2xh)
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
	int n, m; 
    cin >> n >> m;
    int sum = 0;
    vector<int> A(n);  
    for(int i = 0; i < n; i++){
    	cin >> A[i];
        sum += A[i];
    }
    double ref = (double)sum / (4.0 * m);
  int got = 0;  
  for(int i = 0; i < n; i++){
    	if((double)A[i] >= ref) got++;
        if(got == m) {
          cout << "Yes" << endl;
          return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
input = open(0).read

n, m, *l = map(int, input().split())

# abm は ai と bi の tuple を持つ list
*abm, = zip(l[::2], l[1::2])


def f(i):
    # 1 は tuple 1番目の要素 なので 2番目の要素
    # N は tuple 2番目の要素 なので 1番目の要素
    return set(abi[i < 2] for abi in abm if i in abi)


def main():
    print("POSSIBLE" if f(1) & f(n) else "IMPOSSIBLE")


main()


Measured memory_bytes: 48836
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from collections import deque

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    c = list(map(int,input().split()))
    c.sort(reverse = True)
    
    color = [-1] * n
    s = deque([0])
    i = 0
    while len(s):
        v = s.pop()
        color[v] = c[i]
        for e in G[v]:
            if color[e] != -1:
                continue
            s.append(e)
        i += 1
    
    print(sum(c) - c[0])
    print(*color)
if __name__ =='__main__':
    main()  

Measured memory_bytes: 6168
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 S              PIC X(100).
01 X              PIC X(100).
01 cur            PIC X(100).
01 pre            PIC X(100).
01 n              PIC 9(10).
01 m              PIC 9(10).
01 i              PIC 9(10).


PROCEDURE DIVISION.
  ACCEPT S.
  COMPUTE n = FUNCTION STORED-CHAR-LENGTH(S).
  MOVE n TO m.
  PERFORM REVERSESTR.
  IF S = cur
      MOVE ALL SPACE TO cur
      DIVIDE n BY 2 GIVING m
      MOVE S(1 : m) TO X
      PERFORM REVERSESTR
      IF X = cur
          DISPLAY "Yes"
      ELSE
          DISPLAY "No"
      END-IF
  ELSE
      DISPLAY "No"
  END-IF.
  STOP RUN.

REVERSESTR SECTION.
  PERFORM VARYING i FROM 1 BY 1 UNTIL m < i
      MOVE S(m - i + 1 : 1) TO cur(i : 1)
  END-PERFORM.


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

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

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> red(n), blue(n);
	for (int i = 0; i < n; i++)
		cin >> red[i].first >> red[i].second;
	for (int i = 0; i < n; i++)
		cin >> blue[i].first >> blue[i].second;

	sort(blue.begin(), blue.end());
	sort(red.begin(), red.end(), cmp);

	int count = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (red[j].first < blue[i].first && red[j].second < blue[i].second) {
				count++;
				red[j].second = 2 * n;
				break;
			}
		}
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int n,d,x,total=0,temp,cnt=1;
cin>>n>>d>>x;
int z=n;
while(z--){
    cin>>temp;
     while(cnt<=d){
        total++;
        cnt+=temp;

     }

     cnt=1;
}
cout<<total+x<<endl;
return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include <map>
#include <queue>
#include <stack>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }
void solve(){
    int n[3];
    int hoge[3] = {5,5,7};
    string ans = "YES";
    cin >> n[0] >> n[1] >> n[2];
    sort(n,n+3);
    for(int i=0;i<3;i++){
        if(n[i] != hoge[i]){
            ans = "NO";
        }
    }
    cout << ans;
}
signed main() {
    solve();
}



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n, x, y; cin >> n >> x >> y;
    --x; --y;

    vector<int> ans(n);

    for (int sv = 0; sv < n; ++sv) { //全点から調べる
        vector<int> dist(n, INF);
        queue<int> q;

        auto push = [&](int v, int d) {
            if (dist[v] != INF) return; //既に調べた点だったら
            dist[v] = d;
            q.push(v);
        };

        push(sv, 0);

        while (!q.empty()) {
            int v = q.front(); q.pop();

            int d = dist[v];
            //頂点iとi+1のつながりでの探索
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);

            //xとｙのつながりでの探索
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }

        for (int i = 0; i < n; ++i) {
            //距離の数を集計
            ans[dist[i]]++;
        }
    }

    for (int i = 0; i < n; ++i) {
        ans[i] /= 2; //(i, j)と(j, i)をダブルでカウントしているため
    }

    for (int i = 1; i <= n-1; ++i) {
        cout << ans[i] << endl;
    }
}

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

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

    int n, x, y, z;
    cin >> n;
    int dp[n][3];
    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
    for(int i=1; i<n; ++i){
        cin >> dp[i][0] >> dp[i][1] >> dp[i][2];
        dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] += max(dp[i-1][0], dp[i-1][1]);        
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});

    return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int C = Integer.parseInt(sc.next());
    long K = Long.parseLong(sc.next());
    if (K % 2 == 0) {
      System.out.println(A - B);
    } else {
      System.out.println(B - A);
    }
    
  }
}

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

Measured memory_bytes: 3096
import sys
from collections import deque
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
a = list(map(int, input().split()))

B=[0]*N
kazu = 0
for i in range(N, 0, -1):
	num = N//i
	total = 0
	for n in range(1, num + 1):
		total += B[i*n - 1]
	total = total % 2
	if total != a[i - 1]:
		B[i - 1] = 1
		kazu += 1

print(kazu)
for i in range(N):
	if B[i] == 1:
		print(i + 1, end="")
		print(" ", end="")

print("\n")

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

using namespace std;

int n,a[4];
int x[10];
int ans = 999999999;
int y[10][3] = {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}};
bool flag[4];
int cnt;

void dfs(int [],int,int);

int main(){
	scanf("%d%d%d%d",&n,&a[1],&a[2],&a[3]);
	for(int i = 1;i <= n; ++i){
		if(x[i] == a[1])flag[1] = true;
		if(x[i] == a[2]) flag[2] = true;
		if(x[i] == a[3]) flag[3] = true;
		scanf("%d",&x[i]);
	}
	if(flag[1] && flag[2] && flag[3]) {puts("0");return 0;}
	dfs(x,0,n);
	cout << ans << endl;
	return 0;
}

void dfs(int k[],int diss,int len){
	if(len < 3){return ;}
	int sum = 999999;
	for(int i = 1;i <= n; ++i){
		if(!k[i]) continue;
		for(int j = 1;j <= n; ++j){
			if(!k[j] || i == j) continue;
			for(int l = 1;l <= n; ++l){
				if(!k[i] || !k[j] || !k[l] || i == j || j == l || i == l) continue;
				sum = min(sum,abs(k[i] - a[1]) + abs(k[j] - a[2]) + abs(k[l] - a[3])); 
			}
		}
	}
	ans = min(ans,sum + diss);
	if(len == 3) return ;
//	puts("HHHHHHH");
	for(int i = 1;i <= n; ++i)
		for(int j = i + 1;j <= n; ++j){
			if(!k[i] || !k[j]) continue;
			int g = k[i],h = k[j];
			k[i] += k[j];k[j] = 0;
			dfs(k,diss + 10,len - 1);
			k[i] = g;k[j] = h;
		}
	return ;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a == 1) {
            a = 20;
        }
        if (b == 1) {
            b = 20;
        }
        if (a == b) {
            System.out.println("Draw");
        } else if (a < b) {
            System.out.println("Bob");
        } else {
            System.out.println("Alice");
        }
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <vector>
#include <algorithm>

int gcd(int a, int b) {
  while (b != 0) {
    int tmp = a % b;
    a = b;
    b = tmp;
  }
  return a;
}

int main() {
  int nI;
  scanf("%d", &nI);
  std::vector<int> its(nI);
  for (int i = 0; i < nI; ++i) {
    scanf("%d", &its[i]);
  }
  std::vector<int> pref(nI, 0);
  std::vector<int> suff(nI, 0);
  pref[0] = its[0];
  for (int i = 1; i < nI; ++i) {
    pref[i] = gcd(pref[i - 1], its[i]);
  }
  suff[nI - 1] = its[nI - 1];
  for (int i = nI - 2; i >= 0; --i) {
    suff[i] = gcd(suff[i + 1], its[i]);
  }
  int result = std::max(suff[1], pref[nI - 2]);
  for (int i = 1; i < nI - 1; ++i) {
    result = std::max(result, gcd(pref[i - 1], suff[i + 1]));
  }
  printf("%d\n", result);
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B){
    if(A <= 8 && B <= 8){
        cout << "Yay!" << endl;
    } else{
        cout << ":(" << endl;
    }
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int ans;

        static void Main(string[] args)
        {
            //[summary]A - DDCC Finals
            var line = ReadLine();
            var X = line[0];
            var Y = line[1];

            if (X == 1 && Y == 1)
            {
                ans = 1000000;
            }
            else
            {
                GetReward(X);
                GetReward(Y);
            }

            Console.WriteLine(ans);
        }

        static void GetReward(int order)
        {
            switch (order)
            {
                case 1:
                    ans += 300000;
                    break;
                case 2:
                    ans += 200000;
                    break;
                case 3:
                    ans += 100000;
                    break;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

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

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

    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) cnt++;
    }
    cout << cnt << endl;

    return 0;
}


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

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

int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    s.size()==N;
    int cr=0,cb=0;
    rep(i,N){
        if(s[i]=='R') cr++ ;
        else cb++ ;
    }
    if(cr>cb) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256