akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

def main():
	n=II()
	x,y=1,1

	for _ in range(n):
		a,b=MI()
		k=max((x-1)//a,(y-1)//b)+1
		#print(k,x,y)
		x,y=k*a,k*b

	print(x+y)



if __name__ == "__main__":
	main()


Measured memory_bytes: 9280
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int w, d; cin >> w >> d;
		if (w == 0) break;
		vector<int> h(w), _h(d);
		for (int i = 0; i < w; i++) cin >> h[i];
		for (int j = 0; j < d; j++) cin >> _h[j];
		vector<int> a(21);
		int sum = 0;
		for (int i = 0; i < w; i++) {
			sum += h[i];
			a[h[i]]++;
		}
		for (int j = 0; j < d; j++)
			if (a[_h[j]] > 0) a[_h[j]]--;
			else sum += _h[j];
		cout << sum << endl;
	}
}

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

using ll = int64_t;

signed main(){

  int n,m;
  cin>>n>>m;
  vector<vector<pair<int,ll>>> adj(n);
  for(int i=0;i<m;++i){
    int l,r,d;
    cin>>l>>r>>d;
    l--;r--;
    adj[l].emplace_back(r,d);
    adj[r].emplace_back(l,-d);
  }

  vector<int> seen(n);
  for(int i=0;i<n;++i){
    if(seen[i])continue;
    queue<pair<int,ll>> que;
    map<int,ll> people;
    que.emplace(i,0);
    while(!que.empty()){
      ll pos;
      int v;
      tie(v,pos) = que.front();
      que.pop();
      if(people.count(v)&&people[v]!=pos){
        cout<<"No"<<endl;
        return 0;
      }
      if(seen[v])continue;
      seen[v]=1;
      people[v]=pos;
      for(auto nxt:adj[v]){
        que.emplace(nxt.first,nxt.second+pos);
      }
    }
  }
  cout<<"Yes"<<endl;

}

Measured memory_bytes: 23408
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    n, m = MI()

    B = [1] * n
    J = [False] * n
    J[0] = True

    for i in range(m):
        x, y = MI1()

        if J[x] == True:
            if B[x] == 1:
                J[x] = False
            B[x] -= 1
            J[y] = True
            B[y] += 1
        else:
            if B[x] > 0:
                B[x] -= 1
                B[y] += 1
    print(sum(J))





if __name__ == '__main__':
    solve()


Measured memory_bytes: 10424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


std::vector<std::string> split(std::string str, char del) {
	int first = 0;
	int last = str.find_first_of(del);

	std::vector<std::string> result;

	while (first < str.size()) {
		std::string subStr(str, first, last - first);

		result.push_back(subStr);

		first = last + 1;
		last = str.find_first_of(del, first);

		if (last == std::string::npos) {
			last = str.size();
		}
	}

	return result;
}
int main() {
	//int a, b, c,d; cin >> a>>b>>c>>d ;
	string s,t; cin >> s;
	vector<string>ss(3);
	
	char del = ',';
	int i = 0;
	for (const auto subStr : split(s, del)) {
		ss[i] = subStr;
		i++;
	}
	for (int i = 0; i < 3; i++) {
		cout << ss[i];
		if (i != 2)cout << " ";
	}

	cout << endl;
	return 0;
}


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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int GCD(int x,int y){
    int temp;
    if(x<y){
        temp=x,x=y,y=temp;
    }
    if(y<1){
        return -1;
    }
    if(x%y==0){
        return y;
    }
    return GCD(x,x%y);
}

int main(){
    int A,B;
    cin >> A >> B;
    if(A<10&&B<10){
        cout << A*B << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n;
    cin >> n;
    int ans = INT_MAX;
    for(int i = 1; i < n; i++) {
        int a = i;
        int b = n-i;
        int a2 = 0, b2 = 0;
        while(a) {
            a2 += (a%10);
            a /= 10;
        }
        
        while(b) {
            b2 += (b%10);
            b /= 10;
        }
        
        ans = min(ans, a2+b2);
    }
    
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll N, K;
ll A[112345];

int main() {
	cin >> N >> K;
	REP(i, N) scanf("%lld", A + i);
	
	int cnt[64] = {};
	REP(i, N) {
		for (int k = 0; k < 62; k++) if (A[i] >> k & 1) cnt[k]++;
	}
	
	ll X = 0;
	for (int i = 61; i >= 0; i--) {
		if (X + (1ll<<i) > K) continue;
		if (N & 1) {
			if (cnt[i] <= N / 2) X |= 1ll<<i;
		}
		else {
			if (cnt[i] < N / 2) X |= 1ll<<i;
		}
	}
	
	ll ans = 0;
	REP(i, N) ans += X ^ A[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n;
    ll d,a;cin>>n>>d>>a;
    vector<pair<ll,ll>> p(n);
    rep(i,n)cin>>p[i].first>>p[i].second;
    sort(p.begin(),p.end());
    d*=2;
    ll tot=0;
    queue<pair<ll,ll>> q;
    ll ans=0;
    rep(i,n){
        ll x=p[i].first;
        ll h=p[i].second;
        while(q.size()&&q.front().first<x){
            tot-=q.front().second;
            q.pop();
        }
        h-=tot;
        if(h<=0)continue;
        ll num=(h+a-1)/a;
        ans+=num;
        ll damage=num*a;
        tot+=damage;
        q.emplace(x+d,damage);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int spf[1000001];

long long power(long long a,long long b){
    
    if( b == 0)
        return 1;
        
    if(b&1)
        return (a*power((a*a)%mod,b/2))%mod;
    
    return power((a*a)%mod,b/2);
    
}

void sieve(){
    
    
    for(int i = 1;i<=1000000;i++)
        spf[i] = i;
    
    for(int i=2;i*i<=1000000;i++){
        if(spf[i] == i){
            for(int j=2*i;j<=1000000;j+=i){
                spf[j] = i;
            }
           
        }
    }
    
}

int main(){
  sieve();
  
  int n;
  cin>>n;
  
  long long a[n];
  
  long long gcd = 0;
  long long prod = 1;
  
  int maxipower[1000001];
  memset(maxipower,0,sizeof maxipower);
  
  for(int i=0;i<n;i++){
      cin>>a[i];
     
     long long z = a[i];
     
     while(z>1){
        
        long long pp = spf[z];
        int cnt = 0;
        
        while(z%pp == 0){
            z/=pp;
            cnt++;
        }
        
        maxipower[pp] = max(maxipower[pp],cnt);
     }
    
  }

  long long lcm = 1;
  
  for(int i=2;i<=1000000;i++){
      if(spf[i] == i)
        lcm = (lcm*power(i,maxipower[i]))%mod;
  }
  
  long long ans = 0;
  
  for(int i=0;i<n;i++){
      ans = (ans + (lcm*power(a[i],mod-2))%mod)%mod;
  }
  
  cout<<ans;
  
}


Measured memory_bytes: 8192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n, m;
vector<int> s[10];
int p[10];

signed main() {
	int i, j, k;
	
	cin >> n >> m;
	rep(i, m) {
		int x;
		cin >> x;
		rep(j, x) {
			int xx;
			cin >> xx;
			s[i].push_back(xx - 1);
		}
	}
	rep(i, m) cin >> p[i];
	
	int ans = 0;
	rep(i, (1 << n)) {
		rep(j, m) {
			int cnt = 0;
			rep(k, s[j].size()) {
				if ((i >> s[j][k]) % 2) cnt++;
			}
			if (cnt % 2 != p[j]) break;
		}
		if (j == m) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables **************/
int n;
vector<int> t, x, y;
/**********************************************/

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

    cin >> n;
    t.resize(n+1);
    x.resize(n+1);
    y.resize(n+1);

    FOR(i, 1, n+1) cin >> t[i] >> x[i] >> y[i];
    t[0] = 0; x[0] = 0; y[0] = 0;

    FOR(i, 1, n+1){
        int dis = abs(x[i-1] - x[i]) + abs(y[i-1] - y[i]);
        int time = t[i] - t[i-1];
        if(dis > time || (dis <= time && (time-dis) % 2 == 1)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
cin >> n;
ll a[n];
ll cum[n + 1];
cum[0] = 0;
for (ll i = 0; i < n; i++){
    cin >> a[i];
    cum[i + 1] = cum[i] + a[i];
}
ll ans = INF;
for (ll i = 1; i < n; i++) {
    ll tmp = abs(2*cum[i]-cum[n]);
    chmin(ans, tmp);
}
cout << ans << endl;
}

Measured memory_bytes: 3328
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int v[100005];

long long modpow(long long m, int n) {
    if (n == 0) return 1;
    long long ret = modpow(m * m % MOD, n / 2);
    if (n % 2) ret *= m;
    return ret % MOD;
}

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

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

    for(int i = 1; i <= n; i++){
        int cnt = 0;
        ll score = i;
        while(score < k){
            score *= 2;
            cnt++;
        }
        v[i] = cnt;
    }

    double ans = 0;
    for(int i = 1; i <= n; i++){
        double div = modpow(2, v[i]);
        ans += ( (double)1/(double)n ) * (double)1.0/div;
    }

    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {

	// 読み込み数取得
	var n, m int
	fmt.Scan(&n, &m)

	answer := 0
	penalty := 0
	a := make([]int, n+1)

	for i := 1; i <= m; i++ {

		id := 0
		result := ""
		fmt.Scan(&id, &result)

		if result == "WA" {
			if a[id] != -1 {
				a[id] = a[id] + 1
			}
		} else {
			if a[id] != -1 {
				answer++
				penalty += a[id]
				a[id] = -1
			}
		}

	}

	fmt.Printf("%d %d", answer, penalty)

}


Measured memory_bytes: 5504
//AUTHOR - NAVEEN KUMAR(@naveen19991124)
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#inlcude<boost/multiprecision/cpp_dec_float.hpp>
#define ll long long
#define pb push_back
#define f(a) for(ll i = 0;i<a;i++)
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define rrep(i,a,b) for(ll i = a;i>b;i--)
#define v vector<ll>
#define mp make_pair
#define fir first
#define sec second
#define _fast_ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
//using boost :: multiprecision :: cpp_int;
//using boost :: multiprecision :: cpp_dec_float_50;
//using boost :: multiprecision :: cpp_dec_float_100;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1;
a *= a; a %= mod;} return p % mod;}
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 check(string s)
{
    string x = s;
    reverse(s.begin(),s.end());
    if(x == s)
    {
        return true;
    }
    return false;
}
int main()
{
    _fast_
    ll t = 1;
   // cin>>t;
    while(t--){
    string s;
    cin>>s;
    if(check(s))
    {
    ll len = s.length();
    if(len == 1 || len == 3)
    {
        cout<<"Yes\n";
    }
    else
    {ll len1 = (len-1)/2;
    ll len2 = (len+3)/2;
    string x1,x2;
    x1 = s.substr(0,len1);
    x2 = s.substr(len2-1,len1);
    if(check(x1) && check(x2))
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    }
    }
    else
    {
        cout<<"No\n";
    }
    
    

    }
    return 0;
}

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

using namespace std;

int main()
{
    char s[7];
    for (int i = 0;i<6;i++)
    {
      cin >> s[i];
    }

    if (s[2] == s[3])
    {
        if (s[4] == s[5])
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }else
    {
      cout << "No";
    }

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll arr[3];
	for (ll i=0;i<3;i++) {
		cin>>arr[i];
	}
	sort(arr,arr+3);
	for (ll i=0;i<3;i++) {
		if (i!=2) {
			cout<<arr[i]<<' ';
		}
		else {
			cout<<arr[i]<<endl;
		}
	}
}
	




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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  if ((b - a) % 2 == 1) {
    cout << "Borys" << endl;
  } else {
    cout << "Alice" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n,m;
  cin >> n >> m;
  vector<int> s(m),c(m);
  rep(i,m) cin >> s[i] >> c[i];
  int ans=-1;

  for(int i=1000; i>=0; i--){
    string S=to_string(i);
    bool ok=true;
    if(sz(S)!=n) ok=false;
    for(int j=0; j<m; j++){
      if(S[s[j]-1]!=(char)(c[j]+'0')) ok=false;
    }
    if(ok) ans=i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int t_score = 0, h_score = 0;
        String t, h;
        int n = scanner.nextInt();
        for(int i = 0; i < n; i++){
            t = scanner.next();
            h = scanner.next();
            if(t.compareTo(h) > 0)t_score+=3;
            else if(t.compareTo(h) < 0)h_score+=3;
            else {
                t_score++;
                h_score++;
            }
        }
        System.out.println(t_score + " " + h_score);


    }
}



Measured memory_bytes: 30460
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;

struct Process{
    string name;
    int time;
};

int top, bottom, t;
Process P[1000000];

void enqueue(Process p){
    P[++top] = p;
}

Process dequeue(int q){
    if (P[bottom].time - q > 0){
        t += q;
        P[bottom].time -= q;
    }
    else {
        t += P[bottom].time;
        P[bottom].time = 0;
    }
    bottom++;
    return P[bottom-1];
}

bool isEmpty(){
    return top - bottom == -1;
}

int main() {
    top = 0;
    bottom = 1;

    int n, q;
    cin >> n >> q;
    Process p;

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

    t = 0;
    while (not isEmpty()){
        p = dequeue(q);

        if (p.time > 0){
            enqueue(p);
        }

        else if (p.time == 0){
            cout << p.name << " " << t << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 21084
x, y = map(int, input().split())

min, max = 0, 0
kq, kmod = divmod(y, 4)
tq, tmod = divmod(kmod, 2)
if tmod != 0:
        print('No')
        exit()
else:
        min = kq + tq

t2q, t2mod = divmod(y, 2)
if t2mod != 0:
        print('No')
        exit()
else:
        max = t2q

if x <= max and x >= min:
        print('Yes')
else:
        print('No')
        exit()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << (ele) << endl
#define print10(ele) cout << fixed << setprecision(10) << (ele) << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  string s;
  cin >> s;
  bool ok = s != "AAA" && s != "BBB";

  print(ok ? "Yes" : "No");
  return 0;
}

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

def counter(N, K):
    if K % 2 == 1:
        return (int(N/K))**3
    if K % 2 == 0:
        A = (int(N/K))**3
        B = (int(2*N/K)-int(N/K))**3
        return A+B
            
print(counter(N,K))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> X(N), Y(N);
    for(int i=0; i<N; i++){
        cin >> X[i] >> Y[i];
    }

    map<pair<int,int>,int> mp;
    for(int i=0; i<N; i++)for(int j=0; j<N; j++){
        if(i==j) continue;
        int p = X[i]-X[j];
        int q = Y[i]-Y[j];
        mp[{p,q}]++;
    }

    int cost = 0;
    int p=0, q=0;
    for(auto m:mp){
        if(cost < m.second){
            cost = m.second;
            p = m.first.first;
            q = m.first.second;
        }
    }
    cout << N - cost << endl;
}


Measured memory_bytes: 384
import sys; readline = sys.stdin.readline
from collections import deque

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

j = 1

for i in range(len(a)):
    if j == a[i]:
        j += 1

if j == 1:
    print(-1)
else:
    print(len(a) - (j - 1))


Measured memory_bytes: 72012
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }

 #define pi 3.14159265
 
void solve()
{  
  int n,m;
  cin>>n>>m;
  int a[m];
  int ans=0;
  rep(i,0,m)
    {cin>>a[i];ans+=a[i];}
    if(n-ans>=0)
    	 cout<<n-ans;
    	else
    		cout<<-1;
 
}
signed main()
{fast
    int t;
 t=1;
  //cin>>t;
  while(t--)
     {
      solve();
     }
 
 
 
}

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

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int pos[1000];
    rep(i, 1000) pos[i] = 0;

    int ans = 0;

    rep(s, (int)S.size())
    {
        int num = S[s] - '0';

        rep(n, 1000)
        {
            if (pos[n] == 3)
                continue;
            else if (pos[n] == 2)
            {
                int d10 = n / 10;
                int tmp = n - d10 * 10;
                if (tmp == num)
                {
                    pos[n] = 3;
                    ++ans;
                }
            }
            else if (pos[n] == 1)
            {
                int d10 = n / 100;
                int tmp = (n - d10 * 100) / 10;

                if (tmp == num)
                    pos[n] = 2;
            }
            else if (pos[n] == 0)
            {
                int tmp = n / 100;

                if (tmp == num)
                    pos[n] = 1;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int k,a,b;
cin>>k>>a>>b;
int flag=0;
for(int i=a;i<=b;i++)
    if(!(i%k))
    flag=1;
    if(flag)
        cout<<"OK";
    else
        cout<<"NG";
}


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

int top,S[1000];

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

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

int main(){
    char s[1000];
    int a,b;
    int top=0;
    
    while(cin>>s){
        if(s[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }else if(s[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }else if(s[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    cout<<pop()<<endl;
    return 0;
}




Measured memory_bytes: 3108
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
NUM = 10000



N,W = map(int,input().split())

dp = [W+1]*(NUM+1)
dp[0] = 0

for loop in range(N):
    value,weight = map(int,input().split())
    for v in range(NUM,0,-1):
        if v-value < 0:
            break
        dp[v] = min(dp[v],dp[v-value]+weight) #価値あたりの最小の重さを求める

ans = 0
for i in range(NUM,0,-1):
    if dp[i] <= W:
        ans = i
        break

print("%d"%(ans))


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 2000
#define MAX_X 2000
#define MAX_Y 2000
i64 N, X, Y;

i64 calcd(i64 i, i64 j) {
    i64 d;
    if (i <= X && Y <= j) {
        d = (X - i) + 1 + (j - Y);
    } else if (i <= X && j < Y) {
        d = min((X - i) + (j - X), (X - i) + 1 + (Y - j));
    } else if (X < i && Y <= j) {
        d = min(j - i, (i - X) + 1 + (j - Y));
    } else if (X <= i && j <= Y) {
        d = min(j - i, (i - X) + 1 + (Y - j));
    } else {
        d = j - i;
    }
    return d;
}

int main() {
    cin >> N >> X >> Y;

    unordered_map<i64, i64> dist;
    for (i64 i = 1; i <= N - 1; i++) {
        for (i64 j = i + 1; j <= N; j++) {
            dist[calcd(i, j)]++;
        }
    }

    REPS(i, N - 1) {
        cout << dist[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 998244353;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct meow
{
    int a, b;
    bool operator< (meow x)
    {
        if (b >= 0)
        {
            if (x.b < 0) return true;
            return a < x.a;
        }
        
        else
        {
            if (x.b >= 0) return false;
            return a + b > x.a + x.b;
        }
    }
};

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	int sum = 0;
	meow arr[n + 1];
	
	FOR (i, 1, n)
	{
	    string s;
	    cin >> s;
	    int b = 0, a = inf;
	    
	    for (auto c: s)
	    {
	        if (c == '(') b++;
	        else b--;
	        a = min(b, a);
	    }
	    
	    sum += b;
	    arr[i] = {-a, b};
	}
	
	sort(arr + 1, arr + n + 1);
	if (sum) {cout << "No"; return 0;}
	
	int s = 0;
	FOR (i, 1, n)
	{
	    int a = arr[i].a, b = arr[i].b;
	    if (s - a < 0) {cout << "No"; return 0;}
	    s += b;
	}
	
	cout << "Yes";
}





















Measured memory_bytes: 19216
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    set<char> ss;
    for (int i = 0; i < s.size(); i++)
        ss.insert(s[i]);
    if (ss.size() > 1)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

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

int n, u, v, m;
int a[510][510], b[510][510];
int c[100010];
int f[510][510], g[510][510];
pii posa[1000010], posb[1000010];

template <size_t N, size_t M>
bool check(int cnt, int (&used)[N][M]) {
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!used[i][j]) break;
      if (j + 1 == n) res++;
    }
  }
  if (n > 1) {
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < n; i++) {
        if (!used[i][j]) break;
        if (i + 1 == n) res++;
      }
    }
    for (int i = 0; i < n; i++) {
      if (!used[i][i]) break;
      if (i + 1 == n) res++;
    }
    for (int i = 0; i < n; i++) {
      if (!used[i][n - i - 1]) break;
      if (i + 1 == n) res++;
    }
  }
  return res >= cnt;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  fill_n((pii*)posa, 1000010, pii(-1, -1));
  fill_n((pii*)posb, 1000010, pii(-1, -1));
  cin >> n >> u >> v >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
      posa[a[i][j]] = pii(i, j);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> b[i][j];
      posb[b[i][j]] = pii(i, j);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  for (int i = 0; i < m; i++) {
    pii p = posa[c[i]], q = posb[c[i]];
    if (p.first >= 0) f[p.first][p.second] = true;
    if (q.first >= 0) g[q.first][q.second] = true;
    bool oka = check(u, f);
    bool okb = check(v, g);
    if (oka || okb) {
      if (oka ^ okb) {
        cout << (oka ? "USAGI" : "NEKO") << endl;
      } else {
        cout << "DRAW" << endl;
      }
      return 0;
    }
  }
  cout << "DRAW" << endl;


  return 0;
}


Measured memory_bytes: 21912
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

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

    ll N;
    cin >> N;
    vec a(N);
    ll tmp = 0;
    Rep (i, N) {
        cin >> a[i];
        tmp = tmp ^ a[i];
    }

    Rep (i, N) {
        cout << (tmp ^ a[i]) << " \n"[i==N-1];
    }


}

Measured memory_bytes: 4776
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstring>

using namespace std;

typedef long long LL;
const int N = 100000 + 5;

int n;
LL a[N];
LL b[N];

void solve()
{
    ios::sync_with_stdio(false);
    cin >> n;
    LL sum = 0;
    for(int i = 0; i < n; ++ i) {
        cin >> a[i];
        sum += a[i];
    }
    LL d = (LL)n * (n + 1) / 2;
    if (sum % d) {
        cout << "NO" << endl;
        return;
    }
    LL x = sum / d;

    for(int i = 0; i < n; ++ i) {
        b[i] = a[i] - a[(i + n - 1) % n];
        if (x - b[i] < 0 || (x - b[i]) % n) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

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


Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<cstring>
#include<math.h>
using namespace std;

int main(){

    int d,g, i,j;
    int *p, *c, *p_cp;
    int sum = 0;
    int probNum = 0;
    int minProbNum = 0;

    scanf("%d", &d);
    scanf("%d", &g);
    p = new int[d];
    p_cp = new int[d];
    c = new int[d];
    for(i = 0; i < d; i++){
        scanf("%d", &p[i]);
        scanf("%d", &c[i]);
        p_cp[i] = p[i];
        minProbNum += p[i];
    }

    for(i = 0; i < (int)pow(2, d); i++){

        sum = 0;
        probNum = 0;
        for(j = 0; j < d; j++){
            p_cp[j] = p[j];
        }

        for(j = 0; j < d; j++){
            if((1&(i>>j))==1){
                sum += (100*p_cp[j]*(j+1) + c[j]);
                probNum += p_cp[j];
                p_cp[j] = 0;
            }
        }


        for(j = d-1; j >= 0; j--){
            while((p_cp[j] > 1) && (sum < g)){
                sum += 100*(j+1);
                p_cp[j]--;
                probNum++;
            }
        }

        if(sum >= g){
            if(probNum < minProbNum){
                minProbNum = probNum;
            }
        }

    }

    printf("%d\n", minProbNum);

    return 0;
}

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

using namespace std;

map<string,int> res;   //first -> string, second -> step
string x = "01234567";
struct node{

    string x;
    int step,id;    //id -> 0 index
    node(string x="",int step=0,int id=0):x(x),step(step),id(id){}
};

inline void work(const node &tmp,queue<node> &que,int ct){

    x = tmp.x;
    swap(x[tmp.id],x[tmp.id+ct]);
    if(!res.count(x)){
        que.push(node(x,tmp.step+1,tmp.id+ct));
        res[x] = tmp.step+1;
    }
}
void ini(){

    res[x] = 0;
    queue<node> que;
    que.push(node(x,0,0));

    node tmp;
    while(!que.empty()){
        tmp = que.front(); que.pop();
        if(tmp.step == 40320) return;   //8! = 40320
        if(tmp.id != 3 and tmp.id < 7) work(tmp,que,1);
        if(tmp.id != 4 and tmp.id > 0) work(tmp,que,-1);
        if(tmp.id < 4) work(tmp,que,4);
        if(tmp.id > 3) work(tmp,que,-4);
    }
}
int main(){

    ini();
    string tmp;
    int x;
    while(cin >> x){
        tmp.clear();
        tmp += char(x + '0');
        for(int i = 0; i < 7; i++){
            cin >> x;
            tmp += char(x + '0');
        }
        cout << res[tmp] << endl;
    }

//    system("pause");
    return 0;
}






Measured memory_bytes: 5344
# import numpy as np
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    ans = x
    for i in range(-1, 102):
        if i in p:
            continue

        if i <= x:
            ans = i
        else:
            if x - ans > i - x:
                ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	int a, p;
	cin >> a >> p;
	cout << (3 * a + p) / 2;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[ ]:





# In[1]:


import heapq


# In[2]:


N, M = map(int, input().split())


# In[9]:


ab = []
for _ in range(M):
    a, b = map(int, input().split())
    heapq.heappush(ab, (a, b))


# In[14]:


# temp = ab.copy()
# temp
# ab = temp.copy()
# ab


# In[15]:


R = -1
count = 0
for i in range(M):
    (abl, abr) = heapq.heappop(ab)
    if R <= abl:
        # next
        count += 1
        R = abr
    elif abr < R:
        # R更新
        R = abr


# In[16]:


print(count)


# In[ ]:





# In[ ]:






Measured memory_bytes: 64600
def s(n):
    if n<10:
        return n
    else:
        return n%10+s(n//10)
n=0
for _ in [0]*int(input()):
    n +=1    
    minn = n
    d = 1
    while n>=d:
        d *= 10    
        m = (n//d+1)*d-1
        if minn*s(m)>m*s(minn):
            minn = m
    n = minn
    print(n)

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	var N int
	if scanner.Scan() {
		str := scanner.Text()
		N, _ = strconv.Atoi(str)
	}
	s := fmt.Sprintf("%b", N)
	//fmt.Printf("%b\n", N)
	ans := len(s) - 1
	p := math.Pow(2, float64(ans))
	fmt.Fprintln(wtr, int(p))
	_ = wtr.Flush()
}

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}


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

signed main(void)
{
	int n;
	long long ans;
	cin >> n;
	ans = 0;
	rep(i, n)
	{
		if (i % 3 != 0 && i % 5 != 0)
			ans += i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


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

    vector<pair<string, ll>> st(n);

    map<string, ll> p, q;
    ll w = 0;

    string s;
    ll t;
    for0(i, n){
        cin >> s >> t;

        st[i].first = s;
        st[i].second = t;
        p[s] = t;
        w += t;
        q[s] = w;

    }

    string x;
    cin >> x;

    cout << w - q[x];

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define rap(i,j,k) for(int i=j;i>=k;--i)
#define ser(i,j)   for(int i=e[j].y;i;i=e[i].n)
#define ll         long long
using namespace std;
int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<1)+(num<<3)+c-48;
	return num*f;
}
const int mn=100010;
int n,m,t,len,ans,a[mn];
void fre()
{
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
}
void init()
{
	ans=0x3f3f3f3f;
	n=read();t=read();
	rep(i,1,n)
	{
		int a=read(),b=read();
		if(b<=t)
		{
			ans=min(ans,a);
		}
	}
}
void bf_work()
{
	if(ans==0x3f3f3f3f)
	{
		printf("TLE");
	}
	else
	{
		printf("%d",ans);
	}
}
void work()
{
	
}
void re_zero()
{
	
}
int main()
{
	//fre();
		init();
		bf_work();
		work();
		re_zero();
	return 0;
}

Measured memory_bytes: 256
n=int(input())
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

x=factorize(n)
L=[str(a) for a in x]
L=" ".join(L)
print(f'{n}: {L}')



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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL(x) memset(x,0,sizeof(x))


using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y << endl;


  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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

int main(){
  int w,d;
  while(cin>>w>>d,w){
    vector<int> hw(w);
    for(int i=0;i<w;i++){
      cin>>hw[i];
    }
    vector<int> hd(d);
    for(int i=0;i<d;i++){
      cin>>hd[i];
    }
    int res=accumulate(hw.begin(),hw.end(),0)+accumulate(hd.begin(),hd.end(),0);
    for(int i=0;i<w;i++){
      for(int j=0;j<d;j++){
	if(hw[i]==hd[j]){
	  hd[j]=-1;
	  res-=hw[i];
	  break;
	}
      }
    }

    cout<<res<<endl;

  }



}

Measured memory_bytes: 2992
import sys
import os

def file_input():
    f = open('ARC091/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,M=map(int, input().split())

    if N==1 and M==1:
        print(1)
    elif N==1 or M==1:
        print(N*M-2)
    else:
        print(N*M-4-(N+M-4)*2)

if __name__ == '__main__':
    main()


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

bool check_pairwize(long long N, std::vector<long long> &A, multiset<int> &s)
{
    // pairwize coprimeの確認
    for (ll i = 2; i <= A[N - 1] / 2; i++)
    {
        if (i == 2 or i % 2 == 1)
        {
            ll cnt = 0;
            for (ll j = 1; i * j <= A[N - 1]; j++)
            {
                cnt += s.count(i * j);
            }
            if (cnt > 1)
            {
                return false;
            }
        }
    }
    return true;
}

bool check_setwize(long long N, std::vector<long long> &A, multiset<int> &s)
{
    // setwize coprimeの確認
    ll res = A[0];
    for (ll i = 1; i < N; i++)
    {
        res = gcd(res, A[i]);
    }
    if (res != 1)
    {
        return false;
    }
    return true;
}

void solve(long long N, std::vector<long long> A)
{

    multiset<int> s;
    sort(A.begin(), A.end());
    for (auto &&e : A)
    {
        s.insert(e);
    }
    assert(A.size() == s.size());

    string ans;
    if (check_pairwize(N, A, s))
    {
        ans = "pairwise coprime";
    }
    else if (check_setwize(N, A, s))
    {
        ans = "setwise coprime";
    }
    else
    {
        ans = "not coprime";
    }
    cout << ans << endl;
}

signed 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: 57900
#include <bits/stdc++.h>
using namespace std;
int n; string a, b;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
cin >> a >> b;
for (int i=0; i<n; i++) cout << a[i] << b[i];
return 0;
}


Measured memory_bytes: 256