akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

vector<pair<int,int> > p;
int main () {
  int N;
  cin >> N;
  for (int i = 0;i<N;i++) {
    int a,b;
    cin >>a>>b;
    p.emplace_back(b,a);
  }
  
  sort(p.begin(), p.end());

  ll sum= 0;
  bool f = true;
  for (int i = 0;i<N;i++) {
    sum+=p[i].second;
    if (sum > p[i].first) {
      f = false;
      break;
    }

  }

  cout << (f ? "Yes":"No");
}


Measured memory_bytes: 2420
def sign(n):
    if 0 <= n:
        return 1
    return -1

sx, sy, tx, ty = map(int, input().split(" "))

w, h = tx-sx, ty-sy

text = ""
text += "_UD"[sign(h)] * abs(h)
text += "_RL"[sign(w)] * abs(w)
text += "_DU"[sign(h)] * abs(h)
text += "_LR"[sign(w)] * (abs(w)+1)
text += "_UD"[sign(h)] * (abs(h)+1)
text += "_RL"[sign(w)] * (abs(w)+1)
text += "_DU"[sign(h)]
text += "_RL"[sign(w)]
text += "_DU"[sign(h)] * (abs(h)+1)
text += "_LR"[sign(w)] * (abs(w)+1)
text += "_UD"[sign(h)]
print(text)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int a, b;
    cin >> a >> b;
    if (a >=10 or b >=10) cout << -1 << endl;
    else cout << a * b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

int a;

int main(){
    cin>>a;

    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3620
n=int(input())

monst=list(map(int,input().split()))
yusya=list(map(int,input().split()))
ans=0
for i in range(n):
  if(i==0):
    kill=min(yusya[0],monst[0])
    ans+=kill
    yusya[0]-=kill
    monst[0]-=kill
  else:
    kill=min(yusya[i-1],monst[i])
    ans+=kill
    yusya[i-1]-=kill
    monst[i]-=kill
    kill=min(yusya[i],monst[i])
    ans+=kill
    yusya[i]-=kill
    monst[i]-=kill
    
ans+=min(monst[-1],yusya[-1])

print(ans)



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

int main(){
  unsigned long long int h, w;
  cin >> h >> w;


  if(h==1 || w==1){
    cout << 1 << endl;
    return 0;
  }

  if(h%2 ==0) cout << (h/2)*w << endl;
  else if(w%2 ==0) cout << ((h+1)/2 + ((h+1)/2-1))*(w/2) << endl;
  else cout << ((h+1)/2 + ((h+1)/2-1))*(w/2) + (h+1)/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
/* mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x;}*/
ll powmod(ll a,ll b) {ll res=1;a%=mod;  for(;b>0;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
inline int read() {
    int s = 0, w = 1; char ch = getchar();
    while (ch < 48 || ch > 57) { if (ch == '-') w = -1; ch = getchar(); }
    while (ch >= 48 && ch <= 57) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return s * w;
}
const int N=100005;
int T,n,m,fl=0;

vector<int> v[N];
int vis[N];
void bfs(){
    queue<pair<int,int> > q;
    q.push({1,-1});
    while(!q.empty()){
        auto x=q.front();
        int u=x.first,fa=x.second;
        q.pop();
        rep(i,0,v[u].size() ){
            int son=v[u][i];
            if(son!=fa&&vis[son]==0){
                vis[son]=u;
                q.push({son,u});
            }
        }
    }
}

int main(){
    scanf("%d%d",&n,&m);
    rep(i,1,m+1){
        int a,b;
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    bfs();
    rep(i,2,n+1){
        if(vis[i]==0){
            fl=1;
            break;
        }
    }
    if(fl) puts("No");
    else{
        puts("Yes");
        rep(i,2,n+1){
            printf("%d\n",vis[i]);
        }
    }

}


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

int main()
{
  	string a;
  	cin>>a;
  	for(int i=0,j=a.length()-1 ; i<j ; ++i,--j)
    {
    	if(a[i]!=a[j])
        {
        	cout<<"No"<<endl;
          	return 0;
        }
    }
  	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;
typedef long long ll;
typedef vector<long> vl;
typedef vector<string> vs;

int main(){
  int a,b,c=0,d=0,e,n,m,x,y;
  string s,t,u;
  cin>>s>>t>>a>>b>>u;
  if(u==s) cout<<a-1<<" "<<b;
  else cout<<a<<" "<<b-1;
 
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int r, g, b;
    cin >> r >> g >> b;
    if((100*r+10*g+b)%4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<math.h>
#include<set>
#include<map>
#include<string.h>
#include<stack>
#define n 200000
#define loop(i, a, b) for(int i = a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
bool visit[n + 50];
int arr[n + 50], a, b, c, d, e;
string str1, str2;
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
	V[a].push_back(temp);
}


//////////////////////////////////////////


void solve()
{
	cin >> a;
	loop(i, 0, a - 1)
		cin >> arr[i];
	int max = 0;
	loop(i, 1, a - 1)
		if(arr[i] > arr[max]) max = i;
	int ans2 = -1;
	int temp = arr[max] / 2;
	loop(i, 0, a - 1)
	{
		if(i == max) continue;
		else if(ans2 == -1) ans2 = i;
		else
		{
			int t1 = abs(temp - arr[ans2]), t2 = abs(temp - arr[i]);
			if(t2 < t1) ans2 = i;
		}
	}
	cout << arr[max] << ' ' << arr[ans2] << '\n';
}
int main()
{
	int times = 1;
//	cin << times;
	loop(i, 1, times)
	{
		solve();
		printf("\n");
	}
	return 0;
}




Measured memory_bytes: 5376
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  int A;
  int memo;
  for(int i = 0; i < N; i++){
    cin >> A;
    if(A == 1) memo = i;
  }

  int Ans = 0;

  if(memo < K-1 || N-K < memo){
    if(K-1 > memo){
      memo = K-1, ++Ans;
      if(N!=K) Ans += (N-memo+K-2)/(K-1);
    }else{
      memo = N-K, ++Ans;
      if(N!=K) Ans += (memo+K-2)/(K-1);
    }
  }else{
    Ans += (N-memo-1+K-2)/(K-1);
    Ans += (memo+K-2)/(K-1);
    if((N-memo-1)%(K-1)+(memo)%(K-1)<K && (N-memo-1)%(K-1) > 0 && (memo)%(K-1) > 0){
      --Ans;
    }
  }

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

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    LLI a,b;

    scanf("%lld %lld", &a, &b);
    LLI gcd = __gcd( a, b);
    LLI ans = a*b/gcd;
    printf("%lld\n", ans);

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/   \/_________/\/__/   \/__/
//


Measured memory_bytes: 256
// https://ynucpc.github.io/blog/2018/04/15/cp_vscode/
// http://www.atmarkit.co.jp/ait/articles/1509/08/news019.html

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rep3(i,n,m) for(ll i=(n);i<(ll)(m);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
// #define max(a, b) ((a) > (b) ? (a) : (b))
// #define min(a, b) ((a) < (b) ? (a) : (b)) 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int _stoi(string s, int tmp=10){
	istringstream stm(s);
	int res;
	stm >> res;
	return res;
}
double _stod(string s, int tmp=10){
	istringstream stm(s);
	double res;
	stm >> res;
	return res;
}
template<typename T>string to_string(const T& n){
	std::ostringstream stm;
	stm << n;
	return stm.str();
}

// 降順ソート: sort(A, A+N, greater<>());
// min: *min_element(A, A+N)
// argmin: min_element(A, A+N)-A

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


int main(){	
	// ll A; cin >> A;
	// cout << "hello" << _stoi("14") << max({1,3}) << endl;
	ll A, B;
	cin >> A >> B;
	if (A!=B)cout << max(A, B) * 2 - 1 << endl; 
	else cout << A*2 << endl;
}








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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll Euclid(ll A, ll B){
    if(A<B) swap(A, B);
    ll C = B;
    while(C != 0){
        C = A%B;
        A = B;
        B = C;
    }
    return A;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    vector<ll> X(N), Y(N);
    ll tmp = A[0];
    REP(i, N){
    	tmp = Euclid(A[i], tmp);
    	X[i] = tmp;
    }
    tmp = A[N-1];
    REP(i, N){
    	tmp = Euclid(A[N-1-i], tmp);
    	Y[N-1-i] = tmp;
    }
    ll ma = -1;
    ma = max(ma, Y[1]);
    ma = max(ma, X[N-2]);
    for(int i=1;i<=N-2;i++){
    	ma = max(ma, Euclid(X[i-1], Y[i+1]));
    }
    //cout << X << endl;
    //cout << Y << endl;
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 2560
n = gets.to_i
ans = false
a = 0
for i in 1..Math.sqrt(2*n).ceil+1
  if n*2 == i*(i+1)
    ans = true
    a = i+1
    break
  end
end
if ans
  puts "Yes"
  puts a
  b = Array.new(a).map{[]}
  used = Array.new(n,true)
  f = 0
  (a-1).times do |i|
    for j in f..a-i+f-2
      b[i] << j+1
      b[i+j-f+1] << j+1
      used[j] = false
    end
    f += a-i-1
  end
  b.each do |arr|
    puts "#{a-1} #{arr.join(" ")}"
  end
else
  puts "No"
end

Measured memory_bytes: 6140
# 長さx=人数A*幅y+(人数A+1)*間z

# x = A*y + A*z + z
# x-z = A*y + A*z
# x-z = A*(y+z)
# A = (x-z)/(y+z)

x,y,z = gets.chomp.split.map(&:to_i)

puts (x-z)/(y+z)


Measured memory_bytes: 1788
N=gets.to_i
b = gets.chomp.split.map(&:to_i)

ans = []
while(!b.empty?) do 
  flag = 0
  (b.size-1).downto(0) do |i|
    if b[i] == i+1
      ans << b[i]
      b.slice!(i)
      flag = 1
      break
    end
  end
  if flag == 0
    puts -1
    exit
  end
end
ans.reverse!
ans.each {|v| puts v}

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

int main(void){
   int N;
   cin>>N;
   vector<long long> A(N);
   for(int i=0;i<N;i++){
      cin>>A[i];
   }
   long long result=0;
   for(int i=1;i<N;i++){
      if(A[i]<A[i-1]){
         result+=A[i-1]-A[i];
         A[i]=A[i-1];
      }
   }
   cout<<result<<endl;
   return 0;
}


Measured memory_bytes: 4820
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned int uint;

int main() {
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		uint num = n, sum = 0, p;
		for (int i=0; i<n; ++i) {
			cin >> p;
			sum += p;
		}
		vector<uint> J(n-1);
		for (int i=0; i<n-1; ++i) {
			cin >> J[i];
		}
		sort(J.rbegin(), J.rend());
		uint res = sum * n;
		for (int i=0; i<n-1; ++i) {
			sum += J[i];
			-- num;
			res = max(res, sum * num);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1464
# 2019-11-14 20:54:46(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    # ある１地点を経由してそれ以外の全てにいくのが最も多く
    # これは (n - 1) * (n - 2) // 2　通り
    # kがこれより大きいときには存在せず、それ以下の時は理論上存在する
    if k > (n - 1) * (n - 2) // 2:
        print(-1)
        sys.exit()
        
    all_uv = list(itertools.combinations(range(1, n+1), 2))

    m = n * (n - 1) // 2 - k
    print(m)
    # 1を中央として考えて、最低限1以外のn-1個の頂点は1とつながっている状態である必要がある
    for u, v in all_uv[:n*(n-1)//2-k]: # kの制約から、iの最大値は最小で(n-1)-1まで
        print(u, v)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3992
#! /usr/bin/python
# -*- coding: utf-8 -*-

n = int(raw_input())
ID=[]
for i in range(n):
    ID.append(raw_input())
m = int(raw_input())
door = 1
for i in range(m):
    per = raw_input()
    if per in ID:
        if door == 1:
            print "Opened by", per
        else:
            print "Closed by", per
        door *= -1
    else:
        print "Unknown", per 

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

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

    ll N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    unordered_set<ll> s;
    ll count = 0;
    rep(i, N){
        if(i>0 && A[i-1]==A[i]) continue;
        if(i<N-1 && A[i]==A[i+1]){
            for(ll n=A[i]; n<=1000000; n+=A[i]){
                s.insert(n);
            }
        }
        else{
            if(s.find(A[i])==s.end()) ++count;
            for(ll n=A[i]; n<=1000000; n+=A[i]){
                s.insert(n);
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 44224
n = int(input())
a = list(map(int,input().split()))

from itertools import product

li = [-1,0,1]
cnt = 0
for v in product(li,repeat = n):
    L = []
    for i in range(n):
        L.append(v[i]+a[i])
    if any(x%2==0 for x in L):
        cnt +=1

print(cnt)

Measured memory_bytes: 8704
import java.io.{InputStream, OutputStream, PrintStream}
import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val solver = new Solver(System.in, System.out)
    solver.solve()
  }

  class Solver(in: InputStream, out: OutputStream) {
    lazy val input = new Scanner(in)

    lazy val output = new PrintStream(out)

    def solve(): Unit = {
      val n = input.nextLine().toInt

      if (n == 1) {
        println("Hello World")
      }
      else {
        val a = input.nextLine().toInt
        val b = input.nextLine().toInt
        println(a + b)
      }
    }

  }

}


Measured memory_bytes: 25536
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

string rot(string a,int n) {
  string res="";
  srep(i,n,a.size()) {
    res.pb(a.at(i));
  }
  rep(i,n) res.pb(a.at(i));
  return res;
}

int main() {
  string s,t;
  cin >> s >> t;
  bool flag = false;
  rep(i,s.size()) {
    if(rot(s,i)==t) flag =true;
  }
  Yes(flag);

  return 0;
}


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

int main(){
  int n, i, j, k, f, r[4002];
  long long s[4002][2], id, uc, am;

  while(scanf("%d", &n) && n){
    j = f = 0;
    memset(r, 0, sizeof(r));
    memset(s, 0, sizeof(s));
    for(i = 0;i < n;i++){
      scanf("%lld%lld%lld", &id, &uc, &am);
      for(k = 0;k < j;k++)
	if(s[k][0] == id) break;
      if(k == j) s[j++][0] = id;
      s[k][1] += uc * am;
    }
    for(k = 0;k < n;k++)
      if(s[k][1] >= 1000000)
	r[f++] = s[k][0];

    //    for(i = 0;i < n;i++) printf("%lld %lld\n", s[i][0], s[i][1]);
    if(f == 0) puts("NA");
    else for(i = 0;i < f;i++) printf("%d\n", r[i]);
  }
  return 0;
}

Measured memory_bytes: 696
class AtCoder {
  // 入力系
  input=[];
  input_i=-1;
  n(){
    this.input_i++;
    return Number(this.input[this.input_i]);
  }
  nn(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.n());
    }
    return a;
  }
  s(){
    this.input_i++;
    return String(this.input[this.input_i]);
  }
  ss(n){
    const a=[];
    for(let i=0;i<n;i++){
      a.push(this.s());
    }
    return a;
  }
 
  // コンソール
  o(...a:any){
    console.log(...a);
  }
 
  // Math
  abs(a:number){
    return Math.abs(a);
  }
  min(...a:number[]){
    return Math.min(...a);
  }
  max(...a:number[]){
    return Math.max(...a);
  }
  floor(a:number){
    return Math.floor(a);
  }
  ceil(a:number){
    return Math.ceil(a);
  }
  round(a:number){
    return Math.round(a);
  }
 
  // ソート
  asc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return a-b});
  }
  desc(ar:number[]){
    const t=[...ar];
    ar.sort((a,b)=>{return b-a});
  }
 
  // 自作
  gcd(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=x;
    }
    return arr[arr.length-1];
  };
  lcm(...arr):number{
    for(let i=0;i<arr.length-1;i++){
      let [x,y]=[arr[i],arr[i+1]];
      while(y){
        [x,y]=[y,x%y];
      }
      arr[i+1]=arr[i]*arr[i+1]/x;
    }
    return arr[arr.length-1];
  };
  isPrime(n:number):boolean{
    if(n < 2) return false;
    const suq=Math.sqrt(n);
    for(let i=2;i<=suq;i++){
      if(n%i==0){
        return false;
      }
    }return true;
  };
  deduplicate(a:any[]):any[]{
    return Array.from(new Set(a));
  };
}
const o = new AtCoder()
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line',(line:any)=> {
  o.input.push(...line.split(/[\s]/));
});

process.stdin.on('end', ()=> {
  let n=o.n(),arr=o.nn(n)
  for(let i=0;i<n;i++){
    if(arr[i] % 2 == 0) {
      if(arr[i] % 3 != 0 && arr[i] % 5 != 0) {
        o.o('DENIED')
        return
      }
    }
  }
  o.o('APPROVED')
});


Measured memory_bytes: 11596
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == '?')
				System.out.print('D');
			else
				System.out.print(S.charAt(i));
		}
		
	}

}


Measured memory_bytes: 57868
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=INT_MAX;
    ll rcnt=0,wcnt=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='R')rcnt++;
        else wcnt++;
    }
    ll cnt=0;
    for(ll i=0;i<rcnt;i++){
        if(s[i]=='W')cnt++;
    }
    ans=min(ans,cnt);
    cnt=0;
    for(ll i=n-1;i>=n-1-wcnt;i--){
        if(s[i]=='R')cnt++;
    }
    ans=min(ans,cnt);
    ans=min(ans,min(wcnt,rcnt));
    cout<<ans;
    return 0;
}



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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

typedef long long ll;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


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

int main() {
    ios_base::sync_with_stdio(0);
    
    int n;
    cin >> n;
    
    VI p(n);
    FOR(i,0,n-1) {
        cin >> p[i]; p[i]--;
    }
    
    if (n == 1) {
        cout << 0;
        return 0;
    }
    
    VI pos(n);
    FOR(i,0,n-1) pos[p[i]] = i;
    
    VB good(n-1);
    FOR(i,0,n-2) {
        good[i] = pos[i] < pos[i+1];
    }
    
    int best = 0;
    for (int i = 0; i < n; ) {
        int j = i;
        while (j < n-1 && good[j]) j++;
        
        best = max(best, j - i + 1);
        i = j + 1;
    }
    
    cout << n - best;

    return 0;
}

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


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

int main(){

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

  long long n,m,ans;

  cin >> n >> m;

  if(n >= m/2){
    cout << m/2 << endl;
  }else{
    ans = n;
    m = m/2 - n;
    ans += m/2;
    cout << ans << endl;
  }
  return 0;
}


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

int n, k;
int f(int ind, bool r){
	return k + r * n + ind;
}

int32_t main(){
	cin >> n >> k;
	if(k > (n + 1) / 2){
		cout << -1;
		return 0;
	}
	bool state = 0;
	int stL = n / 2;
	int stR = n - 1;
	for(int i = 0; i < n / 2 - (n % 2 == 0); i++){
		cout << f(stR, 1) << ' ' << f(stL, 0) << ' ' << (k + 3 * n - i * 2 - 1) << endl;
		stL--;
		cout << f(stR, 0) << ' ' << f(stL, 1) << ' ' << (k + 3 * n - i * 2 - 2) << endl;
		stR--;
	}
	cout << f(stR, 1) << ' ' << f(stL, 0) << ' ' << (k + 2 * n + (n % 2 == 0)) << endl;
	if(n % 2 == 0){
		cout << f(0, 0) << ' ' << f(0, 1) << ' ' << (k + 2 * n) << endl;
	}
}

Measured memory_bytes: 2304
main :: IO()
main = do
    str <- getLine
    putStrLn $ if getsolve str == 1 then "First" else "Second"

getsolve :: String -> Int
getsolve str
    | saisyo == saigo && mod len 2 == 0			= 1
    | saisyo /= saigo && mod len 2 == 1			= 1
    | otherwise									= 2
    where len 		= length str
          saisyo 	= head str
          saigo 	= last str




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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  rep(i, S.size()){
    if(S[i]=='1')cout << 9;
    else if(S[i]=='9')cout << 1;
    else cout << S[i];
  }
  return 0;
}


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

using namespace std;

long long n;
long long A[50][50],F[50][1<<21];
long long mat(int i,int used)
{

    if (i>n) return 1;
    if (F[i][used]!=-1) return F[i][used];
    long long res=0;

    for (int z=1; z<=n; ++z){
        if (A[i][z]==0 || ((used>>z)&1)) continue;
            res=(res + mat(i+1,used | (1<<z)))%1000000007;
    }

    return F[i][used]=res;

}


int main()
{
    //freopen("matching.inp", "r", stdin);
    //freopen("matching.out", "w", stdout);
    cin>>n;
    for (int i=1; i<=n; ++i){
        for (int j=1; j<=n; ++j){
            cin>>A[i][j];
        }
    }
    for (int i=1; i<=25; ++i)
        for (int j=1; j<=(1<<21);++j)
            F[i][j]=-1;
    cout<<mat(1,1);

    return 0;
}


Measured memory_bytes: 413244
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

#define PB push_back

void Input(int*,vector<string>&);
void Bubblesort(int*,vector<string>);
void Selectionsort(int*,vector<string>);
void Output(int*,vector<string>);

int main(int argc,char* argv[]){

  int n;
  vector<string> vstr;

  Input(&n,vstr);
  Bubblesort(&n,vstr);
  Selectionsort(&n,vstr);

  return 0;
}

void Input(int* pn,vector<string>& vstr){
  string str;
  
  cin>>*pn;
  for(int i=0;i<*pn;i++){
    cin>>str;
    vstr.PB(str);
  }
}

void Bubblesort(int *pn,vector<string> vstr){
  
  for(int i=0;i<*pn;i++){
    for(int j=*pn-1;j>i;j--){
      if(vstr[j-1][1]>vstr[j][1]){
	swap(vstr[j-1],vstr[j]);
      }
    }
  }

  Output(pn,vstr);
  puts("Stable");
}

void Selectionsort(int*pn,vector<string> vstr){
  bool bflag=false;
  int iflag;

  for(int i=0;i<*pn;i++){
    int key=i;
    iflag=0;
    for(int j=i+1;j<*pn;j++){
      if(vstr[key][1]>=vstr[j][1]){
	if(vstr[key][1]==vstr[j][1]){
	  iflag=j;
	}
	else
	  key=j;
      }
    }
    if(i!=key){
      swap(vstr[i],vstr[key]);
      if(iflag!=0 && key!=iflag)
	bflag=true;
    }
      
  }

  Output(pn,vstr);
  if(bflag) puts("Not stable");
  else puts("Stable");
}

  void Output(int *pn,vector<string> vstr){

    cout<<vstr[0];
    for(int i=1;i<*pn;i++)
      cout<<" "<<vstr[i];
    puts("");
  }

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


//I am so fucking stupid
//Stupidity level :- 1/0




ll n;
vector<ll>v1;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    ll sum = 0 ;
    for(int i = 0 ;i<n;i+=1)
    {
        ll x;
        cin>>x;
        v1.push_back(x);
        sum+=x;
    }
    sort(v1.begin(),v1.end());
    if(sum%10)
    {
        cout<<sum<<endl;
    }
    else{
        for(int i = 0 ;i<n;i+=1)
        {
            if(v1[i]%10)
            {
                cout<<sum-v1[i];
                return 0;
            }
        }
        cout<<0<<endl;
    }
    
    return 0;
    
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'

int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  ll a1 = b*d;
  ll a2 = a*c;
  ll a3 = a*d;
  ll a4 = b*c;
  
  ll ans = max(a1,a2);
  ans = max(a3,ans);
  ans = max(a4,ans);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		long ct = 0;
		for(var i=0;i<s.Length;i++){
			ct += int.Parse(s.Substring(i,1));
		}
		if(ct%9==0){
			Console.WriteLine("Yes");
		} else {
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 21784
# include <bits/stdc++.h>
 
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
    ~debug() { cerr << endl; }
    eni(!=) cerr << boolalpha << i; ris; }
    eni(==) ris << range(begin(i), end(i)); }
    sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
    }
    sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
    }
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
# define forn(i, n) for (ll i = 0; i < int(n); i++)
# define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
# define all(V) V.begin(), V.end()
# define rall(V) V.rbegin(), V.rend()
# define len(V) (int)V.size()
# define ll long long
# define ld long double
# define ff first
# define ss second
# define pb push_back
# define mp make_pair
# define endl '\n'
# define M_PI 3.14159265358979323846
 
void solve()
{
        int n, x; cin >> n >> x;
        vector<ll> a(n);
        forn(i, n) cin >> a[i];
        sort(all(a));
        int cnt = 0, i = 0;
        while(cnt <= x && i < n)
        {
                cnt += a[i];
                i++;
        }
        if(cnt != x) i--;
        cout << max(0, i);
}
 
int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        solve();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int N,Arr[1500],i,count=0,cnt=0;
    cin>>N;
    for(i=1;i<=N;i++)
    {
        cin>>Arr[i];
    }
    for(i=1;i<=N;i++)
    {
        if(Arr[i]%2==0)
        {
            count++;
            if(Arr[i]%3==0 || Arr[i]%5==0)
            {
                cnt++;
            }
        }
    }
    if(cnt==count)
    {
         cout<<"APPROVED\n";
    }
    else
    {
        cout<<"DENIED\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i);

map<llong, llong> M;

template<typename T> void factorization(T p) {
    llong i = 2;
    while (i * i <= p) {
        if (p % i == 0) {
            ++M[i];
            p /= i;
        } else {
            ++i;
        }
    }

    if (p != 1) ++M[p];
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    llong n, p;
    cin >> n >> p;

    factorization(p);

    llong ans = 1;
    for (map<llong, llong>::iterator itr = M.begin(); itr != M.end(); ++itr) {
        ans *= pow(itr->first, itr->second / n);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int A(vector<int>& x) {
    for (int i = 0; i < x.size(); i++)
        if (x[i] == 0)
            return i + 1;
    return -1;
}

int main() {
    vector<int> x(5);
    for (int i = 0; i < x.size(); i++)
        cin >> x[i];
    cout << A(x);
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pair<int,int> > pipii;
typedef priority_queue<pii,vector<pii>,greater<pii>> minpq;
typedef priority_queue<pii> maxpq;
//const double PI = acos(-1);
const int mod = 1000000007;
int cnt =0;

void show_vect(vector<int>v){
    tr(it,v){
        cout<<*it<<" ";
    }
    cout<<endl;
}
bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    // This is checked so that we can skip 
    // middle five numbers in below loop 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int cpy = n;
    vi rep;
    while(n){
        rep.pb(n%26);
        n/=26;
    }
    for(int i =0;i<(int)rep.size()-1;i++){
        if(rep[i]<=0){
            rep[i]+=26;
            rep[i+1]--;
        }  
    }
    string ans="";

    for(int i =0;i < (int)rep.size();i++){
        if(rep[i]>0)
        ans+= char('a' +  rep[i]-1);
    }
    
    reverse(all(ans));
    cout<<ans<<endl;



   


       
        







  


    
    
}

Measured memory_bytes: 3656
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    std::map<ll, ll> m;
    ll n;
    cin>>n;
    std::vector<ll> v(n);
    for(auto &x:v)
    {
    	cin>>x;
    }
    for(auto x:v)
    {
    	ll p = 0;
    	while(x%2==0)
    	{
    		p++;
    		x/=2;
    	}
    	if(p)m[2]=max(m[2],p);
    	for(ll i=3;i*i<=x;i+=2)
    	{
    		p = 0;
    		while(x%i==0)
    		{
    			p++;
    			x=x/i;
    		}
    		if(p)m[i] = max(m[i],p);
    	}
    	if(x>1)
    	{
    		m[x]=max(m[x],1ll);
    	}
    }
    ll lcm = 1;
    for(auto &x:m)
    {
    	ll z = powmod(x.fi,x.se,M);
    	lcm = (lcm*z)%M;
    }
    ll ans = 0;
    for(auto x:v)
    {
    	ll temp = powmod(x,M-2,M);
    	temp = (temp*lcm)%M;
    	ans = (ans+temp)%M;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int n,i;
	ll x,y,a=-INFLL,b=INFLL,c=-INFLL,d=INFLL;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> x >> y;
		a = std::max(a,x+y);
		b = std::min(b,x+y);
		c = std::max(c,x-y);
		d = std::min(d,x-y);
	}
	std::cout << (std::max(a-b,c-d)) << std::endl;
	return 0;
}


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

int main(){

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];

    long long ans = 0;
    vector<long long> bmod(N);
    for(int bit = 0; bit < 31; bit++){
        long long mod = 1 << (bit + 1);
        for(int i = 0; i < N; i++) bmod[i] = b[i] % mod;
        sort(bmod.begin(), bmod.end());

        long long count = 0;
        for(int i = 0; i < N; i++){
            long long amod = a[i] % mod;
            auto t1 = lower_bound(bmod.begin(), bmod.end(), 1 * (1 << bit) - amod);
            auto t2 = lower_bound(bmod.begin(), bmod.end(), 2 * (1 << bit) - amod);
            auto t3 = lower_bound(bmod.begin(), bmod.end(), 3 * (1 << bit) - amod);
            auto t4 = lower_bound(bmod.begin(), bmod.end(), 4 * (1 << bit) - amod);
            count += t2 - t1 + t4 - t3;
        }
        if(count % 2 == 1) ans += (1 << bit);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
/**
 * @see https://practice.contest.atcoder.jp/tasks/practice_1
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    return input.split("").filter(x => x === "1").length;
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    string S;
    cin >> S;
    ll sn = S.size();

    ll l = 0, r = sn - 1, cnt = 0;
    while(l<r){
        if(S[l]==S[r]){
            l++, r--;
        }
        else if(S[l]=='x'){
            l++, cnt++;
        }
        else if(S[r]=='x'){
            r--, cnt++;
        }
        else{
            // err(l, r);
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    xy = sorted([LI() for _ in range(n)])
    if n == 1:
        return 1
    d = collections.defaultdict(int)
    for i in range(n):
        x,y = xy[i]
        for j in range(i+1,n):
            x2,y2 = xy[j]
            d[(x-x2,y-y2)] += 1

    return n - max(d.values())


print(main())



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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> cl = {a,b,c};
    sort(cl.begin(),cl.end());
    int ans = 3;
    rep(i,2){
        if(cl[i]==cl[i+1]) ans--;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n; cin >> n;
    Vl buc(100000, 0);
    while(n--){
        ll b;
        cin >> b;
        buc[b]++;
    }
    ll ans = 0;
    Rep(i, 1, 99998){
        ll an = buc[i-1] + buc[i] + buc[i+1];
        ans = max(ans, an);
    }
    cout << ans << "\n";
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int h1 , m1 , h2 , m2 , k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  cout << (h2 * 60 + m2) - (h1 * 60 + m1) - k;
}

Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define MAX 2000000
#define INFTY (1 << 30)

int H,A[MAX +1];

void maxHeapify(int i)
{
    int l,r,largest;

    l = 2*i;
    r = 2*i + 1;

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

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

int extract()
{
    int maxv;
    if(H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);

    return maxv;
}

void increaseKey(int i, int key)
{
    if(key < A[i]) return;
    A[i] = key;

    while(i > 1 && A[i/2] < A[i])
    {
        swap(A[i],A[i/2]);
        i = i/2;
    }

}

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

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

    while(1)
    {
        scanf("%s",com);

        if(com[0] == 'e' && com[1] == 'n') break;

        if(com[0] == 'i')
        {
            cin >> key;
            insert(key);
        }
        else
        {
            cout << extract() << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d,flag;
    cin >>a>>b;
    for(int i=0; i<10000; i++){
        d = i/10;
        c = (i*2)/25;
        if(c == a){
            if(d == b){
                flag = 1;
                cout<<i<<endl;
                break;
            }
        }
        flag = 2;
    }
    if (flag == 2)cout <<"-1"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=int(1e5+5);
int n,m;
string f[MAXN];
int g[10]={0,2,5,5,4,5,6,3,7,6};
char t[100][100];
string Max(string a,string b) {
	if(a.length()==b.length())
		return max(a,b);
	else return (a.length()>b.length())?a:b;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%s",t[i]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(i>=g[t[j][0]-'0']) {
				if(f[i-(g[t[j][0]-'0'])]==""&&i-g[t[j][0]-'0']!=0)
					continue;
				f[i]=Max(f[i],t[j][0]+f[i-g[t[j][0]-'0']]);
			}
	cout<<f[n];
}

Measured memory_bytes: 33152
#include <stdio.h>

int main(void) {
  int i[10], v1, v2, j, sum, sum2;
  double point;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&i[0],&i[1],&i[2],&i[3],&i[4],&i[5],&i[6],&i[7],&i[8],&i[9],&v1,&v2)!=EOF) {
    sum = 0; sum2 = 0;
    for (j = 0; j < 10; j++)
      sum += i[j];

    point = ((double)(v1 * sum) / (double)(v1 + v2));

    for (j = 0; j < 10; j++) {
      sum2 += i[j];
      if ((double)sum2 >= point) break;
    }
    printf("%d\n", j + 1);
  }
  return 0;
}

Measured memory_bytes: 596
string = input()
n = int(string.split()[0])
a = int(string.split()[1])
b = int(string.split()[2])

if (n % (a + b)) > a:
    print(((n // (a + b)) + 1) * a)
else:
    print((n // (a + b)) * a + (n % (a + b)))


Measured memory_bytes: 2940