akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <iterator>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999LL;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}

// 出力
template<class T> ostream& operator << (ostream &s, vector<T> v){
    rep(i, v.size()) { if (i != 0) { s << " "; } s << v[i]; } return s;
}


int main(){
    vector<ll> v(3);
    rep(i, 3) cin >> v[i];

    sort(all(v));
    cout << v << endl;

    return 0;
}



Measured memory_bytes: 3144
N, M = map(int,input().split())
students = []
points = []
for _ in range(N):
    students.append(list(map(int,input().split())))
for _ in range(M):
    points.append(list(map(int,input().split())))
for i in range(N):
    ans = -1
    MIN = float('inf')
    for j in range(M):
        a, b = students[i]
        c, d = points[j]
        if MIN > abs(a-c) + abs(b-d):
            MIN = abs(a-c) + abs(b-d)
            ans = j + 1
    print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#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;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;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;}

const int maxn = 2e5 + 10; 

int h,w,k;
int mat[11][1005];
vector<int>p;

int get_sum(int x1, int y1, int x2, int y2)
{
	return mat[x2][y2] - mat[x1][y2] - mat[x2][y1] + mat[x1][y1];
}

bool check(int x, int y){
	for(int i = 1; i < (int)p.size(); ++i) {
		//cout << p[i - 1] << " " << x << " " << p[i] << " " << y << " " << get_sum(p[i - 1],x,p[i],y) << endl;
		if(get_sum(p[i - 1],x,p[i],y) > k) return true;
	}

	return false;
}

int main()
{
	//fastIO;
	cin >> h >> w >> k;
	rep(i,1,h + 1) {
		rep(j,1,w + 1){
			scanf("%1d",&mat[i][j]);
		}
	}		
	rep(i,1,h + 1) {
		rep(j,1,w + 1){
			mat[i][j] += mat[i- 1][j] + mat[i][j - 1] - mat[i - 1][j - 1];
		}
	}
	int ans = INT_MAX;
	for(int i = 0; i < (1 << (h - 1)); ++i){
		p.clear(); p.pb(0);
		int now = 0;
		for(int j = 1; j <= h - 1; ++j){
			if(( 1 << (j - 1)) & i) p.pb(j), now++;
		}
		p.pb(h);
		//cout << i << " ";
		//rep(i,0,SZ(p)) cout << p[i] << " ";
		//cout << endl;
		int pre = 0;
		for(int j = 1; j <= w; ++j) {
			if(check(pre,j)) {
				if(j == pre + 1){
					now = INT_MAX;
					break;
				}
				pre = j - 1, now++;
			}
		}
		if(check(pre,w)) now = INT_MAX;
		ans = min(ans,now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a_list =[]
while True:
	try:
		a = input()
		a = a.lower()
		a_list += list(a)
	except EOFError:
		break
ch =["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
	print("{} : {}".format(ch[i],a_list.count(ch[i])))



Measured memory_bytes: 5580
n = int(input())
l = list(map(int, input().split()))

#ans = [0, abs(l[0]-l[1])]

ans = [0]+[float("inf")]*(n-1)
for i in range(0, n-2):
  ans[i+1] = min(abs(l[i]-l[i+1])+ans[i], ans[i+1])
  ans[i+2] = min(abs(l[i]-l[i+2])+ans[i], ans[i+2])

ans[n-1] = min(ans[n-1], abs(l[n-1]-l[n-2])+ans[n-2])
print(ans[n-1])

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

const int DIM = 2e5 + 5;

int arr[DIM], aux[DIM];

int main(void) {
    
    int n;
    cin >> n;
    
    long long s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        s += arr[i];
    }
    
    bool ok = true;
    if (s % (1LL * n * (n + 1) / 2))
        ok = false;
    
    long long v = s / (1LL * n * (n + 1) / 2);
    
    for (int i = 0; i < n; ++i) {
        aux[i] = arr[(i + 1) % n] - arr[i];
        
        if (v - aux[i] < 0 or (v - aux[i]) % n)
            ok = false;
    }
    
    if (ok)
        cout << "YES\n";
    else
        cout << "NO\n";
    
    return 0;
}

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

using namespace std;

int32_t main()
{
  string str;
  cin >> str;

  for(uint32_t i = 0; i < str.size(); i++){
    if((i % 2) == 0){
      cout << str[i];
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> listX = new ArrayList<Integer>();
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(sc.hasNext()) {
			int a = (int)sc.nextLong();
			int b = (int)sc.nextLong();
			int n = (int)sc.nextLong();
			
			double c = (double)a/b;
			c -= (int)c;
			
			String d = String.valueOf(c);
			int ans = 0;
			for(int i = 2; i < n+2; i++) {
				if(i >= d.length()){
					break;
				}
				ans += Integer.parseInt(String.valueOf(d.charAt(i)));
			}
			out.println(ans);
		}
		out.flush();
	}

	
	
	
	
}
	
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}

Measured memory_bytes: 16940
#include <stdio.h>

int main(void)


{
int W, H, x, y, r;

scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

if((x - r >= 0)&&(x + r <= W)&&(y - r >= 0)&&(y + r <= H))
{
printf("Yes\n");
}
else
{
printf("No\n");
}

return 0;

}



Measured memory_bytes: 2112
#include<iostream>
#include<vector>

using std::cin;
using std::cout;
using std::endl;

// Range Sum, Range Add
template<class T>
struct lazy_segment_tree{
  std::vector<T> data,lazy;
  T identity1,identity2;
  int n;
  lazy_segment_tree(){}
  lazy_segment_tree(int sz,T ide1,T ide2):identity1(ide1),identity2(ide2){
    n = 1;
    while(n<sz)n<<=1;
    data.resize(2*n-1,identity1);
    lazy.resize(2*n-1,identity2);
  }
  void eval(int k){
    if(lazy[k]==identity2)return;
    if(k<n-1){
      lazy[2*k+1] += lazy[k]/2;
      lazy[2*k+2] += lazy[k]/2;
    }
    data[k] += lazy[k];
    lazy[k] = identity2;
  }
  void add_impl(int a,int b,T x,int k,int l,int r){
    eval(k);
    if(a<=l&&r<=b){
      lazy[k] += x*(r-l);
      eval(k);
    }
    else if(a<r&&l<b){
      add_impl(a,b,x,2*k+1,l,(l+r)/2);
      add_impl(a,b,x,2*k+2,(l+r)/2,r);
      data[k] = data[2*k+1] + data[2*k+2];
    }
  }
  T query_impl(int a,int b,int k,int l,int r){
    eval(k);
    if(r<=a||b<=l){
      return identity1;
    }
    if(a<=l&&r<=b){
      return data[k];
    }
    else{
      T vl = query_impl(a,b,2*k+1,l,(l+r)/2);
      T vr = query_impl(a,b,2*k+2,(l+r)/2,r);
      return vl + vr;
    }
  }
  void add(int a,int b,T x){
    add_impl(a,b,x,0,0,n);
  }
  T query(int a,int b){
    return query_impl(a,b,0,0,n);
  }
  T operator[](int i){
    return query_impl(i,i+1,0,0,n);
  }
};
signed main(){
  int n,q;
  cin>>n>>q;
  lazy_segment_tree<int64_t> data(n,0,0);
  while(q--){
    int c;cin>>c;
    if(c==0){
      int64_t s,t,x;cin>>s>>t>>x;
      s--;t--;
      data.add(s,t+1,x);
    }else{
      int s,t;cin>>s>>t;
      s--;t--;
      cout<< data.query(s,t+1) <<endl;
    }
  }
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int tmp=b;
    b-=a;
    int cnt=1;
    while(b>0){
        b-=a-1;
        cnt++;
    }
    if(tmp==1)cout << 0 << endl;
    else cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 1;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

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

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,a,b,from,to,ans = 0;
    cin >> n >> a >> b >> from;
    rep0(i, n - 1){
        cin >> to;
        ans += min((to - from) * a,b);
        from = to;
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 384
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = set(list(range(1, M+1)))
  for _ in range(N):
    B = set(list(map(int, input().split()))[1:])
    A = A & B
  print(len(A))


if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	string s;
	cin >> s;
	ll cnt=0;
	for(char c:s)
	{
		cnt=cnt+c-'0';
	}
	if(cnt%9==0)
	cout << "Yes" << endl;
	else
	cout << "No" << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3748
a = int(input())
b = int(input())
c = int(input())
x = int(input())

rCnt = 0
ttla = 0
ttlb = 0

ia = 0

while ia <= a:
  ib = 0
  ic = 0
  ttla = 500 * ia
  ia = ia + 1
  while ib <= b:
    ic = 0
    ttlb = 100 * ib
    ib = ib + 1
    while ic <= c:
      if x == ttla + ttlb + 50 * ic:
        rCnt = rCnt + 1
      ic = ic + 1

print(rCnt)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define int long long
typedef vector<int> vec;


class AButtons {
public:
    void solve(std::istream &in, std::ostream &out) {
      int a, b;
      in >> a >> b;
      vec c = {
              a + a - 1,
              b + b - 1,
              a + b
      };
      out << *max_element(c.begin(), c.end()) << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  AButtons solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;
using LL = long long;

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

    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy\n";
    else if (s == "Cloudy") cout << "Rainy\n";
    else cout << "Sunny\n";
}

Measured memory_bytes: 256
from numpy import*
n,k,*v=int64(open(0).read().split())
m=0
for i in range(n):
 for j in range(min(k,n)-i+1):t=sort(v[:i]+v[:~j:-1]);m=max(m,sum(t)-sum(t[t<0][:k-i-j]))
print(m)

Measured memory_bytes: 12488
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n,m;
  cin>>n>>m;
  priority_queue<P> que1;
  priority_queue<int> que2;
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    que1.push(P(-a,b));
  }
  int ans=0;
  for(int i=0;i<=m;i++){
    int day=m-i;
    while(que1.size()&&-que1.top().first<=i){
      int b=que1.top().second;
      que1.pop();
      que2.push(b);
    }
    if(que2.size()){
      ans+=que2.top();
      que2.pop();
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include <stdio.h>
#include <math.h>
int main(void){
  int a,b,k,i;
  int s[10000],j=0;
  scanf("%d%d%d",&a,&b,&k);
  for(i=a;i<=fmin(b,a+k-1);i++){
    printf("%d\n",i);
  }
  for(i=fmax(b-k+1,a+k);i<=b;i++){
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std;
vector<long long> vv;
bool isPrime(long long  n)
{
  if (n == 1)
  {
    return false;
  }
  long i = 2;
  while (i*i <= n)
  {
      if (n % i == 0)
      {
          return false;
      }
      i += 1;
  }
  return true;
}
long long  gcd(long long a, long long b){
	if (a == 0)
		return b;
	return gcd(b%a, a);
} 
void commDiv(long long  a,long long  b) { 
	long long  n = gcd(a, b);
	long long  result = 0;
	for (int i=1; i<=sqrt(n); i++){
		if (n%i==0){
			if (n/i == i) 
				vv.push_back(i);
			else
				vv.push_back((n/i));
				vv.push_back(i);
		}
	}
}
int main(){ 
	
	long long a,b; cin>>a>>b;
	commDiv(a,b);
	long long co = 0;
	sort(vv.begin(),vv.end());
	//for(auto xx : vv) cout<<xx<<" "; cout<<"\n";
	for(int i = 0; i < vv.size(); i++){
		if(isPrime(vv[i])) co++; 
	}
	cout<<co+1<<"\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000LL;
constexpr long long MOD = 1000000007;

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


int main()
{
  int A, P;
  cin >> A >> P;
  P += 3*A;
  cout << P/2 << endl;
  return 0;
}


Measured memory_bytes: 256
inputList=input().split()
n = int(inputList[0])
q = int(inputList[1])


p=[]

for i in range(n):
    inputList=input().split()
    name = inputList[0]
    t = int(inputList[1])
    p.append([name,t])
    
over=0

while 1:
    
    if len(p) <= 0:
        break
    
    tp = p[0]
    p.pop(0)
    tp[1]-=q
    over+=q
    if tp[1] > 0:
        p.append(tp)
    else :
        over += tp[1]
        print(tp[0]+' ' + str(over))


Measured memory_bytes: 12876
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int r = sc.nextInt();
    if(r < 1200)
      System.out.println("ABC");
    else
      if(r < 2800)
        System.out.println("ARC");
      else
        System.out.println("AGC");
  }
}

Measured memory_bytes: 21716
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var S_ = lines[0].split("");
    var T = lines[1].split("");

    var ans = -1;

    for (var i = 0; i + T.length <= S_.length; i++) {
        var str_S = S_.concat().slice(i, i + T.length);

        for (var j = 0; j < T.length; j++) {
            if (T[j] !== str_S[j] && str_S[j] !== "?") { break; }
            if ((T[j] === str_S[j] || str_S[j] === "?") && j === T.length - 1) { ans = i; }
        }
    }

    if (ans === -1) { console.log("UNRESTORABLE") }
    else {
        for (var i = 0; i < S_.length; i++) {

            if (S_[i] === "?" && i !== ans) { S_[i] = "a" }
            if (i === ans) {
                for (var j = 0; j < T.length; j++) {
                    S_[i + j] = T[j];
                }
                i += T.length-1;
            }
        }

        console.log(S_.join(""));
    }
});

Measured memory_bytes: 7500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        var abt = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int A = abt[0];
        int B = abt[1];
        int T = abt[2];

        int n = T / A;

        Console.WriteLine(B * n);


    }
}

Measured memory_bytes: 13268
#include <stdio.h>

int main(void)
{
	int a=0,n,i;
	
	scanf("%d",&n);
	i=n;
	while(n>0){
		a+=n%10;
		n=n/10;
	}
	
	if((i%a)==0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;
	
int N, M;
pair<int,int> PD[10010];
int main(){
	while(cin >> N >> M && N){
		int d, p;
		for (int i=0; i<N; ++i){
			cin >> d >> p;
			PD[i] = make_pair(p,d);
		}
		sort(PD,PD+N,greater<pair<int,int>>());
		int S = 0;
		for (int i=0; i<N; ++i){
			S += PD[i].first * PD[i].second;
		}
		for (int i=0; i<N; ++i){
			if (M <= 0){
				break;
			}
			int guarded = min(M,PD[i].second);
			S -= PD[i].first * guarded;
			M -= guarded;
		}
		cout << S << endl;
	}
}
		
    


Measured memory_bytes: 3172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(f.readLine());


        int N = Integer.parseInt(st.nextToken());
        int W = Integer.parseInt(st.nextToken());

        long[][] items = new long[N][2];

        int sumValues = 0;
        for (int i = 0; i < N; i++) {
            st = new StringTokenizer(f.readLine());
            items[i][0] = Long.parseLong(st.nextToken());
            items[i][1] = Long.parseLong(st.nextToken());
            sumValues += items[i][1];
        }
        // System.out.println(sumValues);

        // long[][] dp = new long[N + 1][W + 1]; // default 0ed out

        long[] dp = new long[sumValues + 1];
        Arrays.fill(dp, Long.MAX_VALUE);
        dp[0] = 0;

        long curSubsetValueSum = 0;
        for (int i = 1; i < N + 1; i++) {
            curSubsetValueSum += items[i-1][1];
            for (int j = sumValues; j >= 1; j--) {
                if (curSubsetValueSum < j) {

                } else if (items[i-1][1] > j) {

                } else {
                    long previousMin = dp[(int) (j - items[i - 1][1])];
                    if (previousMin == Long.MAX_VALUE) {

                    } else {previousMin += items[i-1][0];}
                    dp[j] = Math.min(previousMin, dp[j]);
                    if (dp[j] <= W && i == N) {System.out.println(j); break;}
                }
            }
        }

        /*for (long l : dp){
            System.out.print(String.valueOf(l) + " ");
        }*/
        // System.out.println();

    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(ll i=0;i<(ll)n;++i)
const ll INF = 999999999999999;

vector<bool>  b(100001,true);
vector<ll> sum(100001);

void func(){
  b.at(0) = false;
  b.at(1) = false;
  
  for(ll i=2;i<=(ll)sqrt(100000)+1;++i){
    if( b.at(i) ){
      ll cnt = 2;
      while( i*cnt <= 100000 ){
        b.at(i*cnt) = false;
        ++cnt;
      }
    }
  }
  ll num=0;
  for(ll i=1;i<=100000;i+=2){
    if( b.at(i) && b.at((i+1)/2) ){
      sum.at(i-1) = num;
      ++num;
      sum.at(i) = num;
    }else{
      sum.at(i-1) = num;
      sum.at(i) = num;
    }
  }
}
int main(){
  ll q;
  cin >> q;
  func();
  for(ll i=0;i<q;++i){
    ll l,r;
    cin >> l >> r; 
    cout << sum.at(r) - sum.at(l-1) << "\n";
  }
  return 0;
}

Measured memory_bytes: 1408
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    N,=pin()
    A=list(pin())
    B=[(i+1,A[i]) for i in range(N)]
    B.sort(key=lambda x:x[1])
    ans=[]
    for b in B:
        ans.append(b[0])
    print(*ans)
resolve()

Measured memory_bytes: 67948
import math
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

X,Y = SL()
l = ["A","B","C","D","E","F"]

if l.index(X) < l.index(Y):
    print("<")
elif l.index(X) == l.index(Y):
    print("=")
else:
	print(">")

Measured memory_bytes: 12504
# coding: utf-8
import math
N = input()
ln = list(map(int, input().split()))
ans = 0
for i in range(0, len(ln) - 2):
    for j in range(i + 1, len(ln) - 1):
        for k in range(j + 1, len(ln)):
            l3 = [ln[i], ln[j], ln[k]]
            if ln[i] != ln[j] and ln[i] != ln[k] and ln[j] != ln[k] and \
                max(l3) < sum(l3) - max(l3):
                ans = ans + 1
print(ans)


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

static const int N = 100;

int main() {
	int n, p[N + 1], m[N + 1][N + 1];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i - 1] >> p[i];
	}

	for (int i = 1; i <= n; i++) m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	cout << m[1][n] << endl;


	return 0;
}

Measured memory_bytes: 3148
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        long N = cin.nextInt();
        long M = cin.nextInt();
        if (N > M) swap(ref N, ref M);

        if (N == 1)
        {
            if(M == 1) Console.WriteLine(1);
            else Console.WriteLine(M - 2);
            return;
        }
        else
        {
            Console.WriteLine((N - 2) * (M - 2));
        }


    }

    //swap
    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    } 

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
// #define int long long
struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
}IoSetup;

using Int = __int128_t;
using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T&b){if(a<b)return(a=b,1);return 0;}
template<class T>bool chmin(T &a, const T&b){if(b<a)return(a=b,1);return 0;}


signed main() {
    string s;
    cin >> s;

    if(s.back() == 's') cout << s + "es\n";
    else cout << s + "s\n";
    

    return 0;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#define MAX_ARRAY_SIZE 2000001
#define MAX_NUMBER_SIZE 10002

void Counting_sort(int* array, int numbers) {
	int i, counting_array[MAX_NUMBER_SIZE];
	int* temp_array;
	temp_array = (int*)malloc(numbers * sizeof(int));

	//set all values in the counting array to 0
	for (i = 0; i != MAX_NUMBER_SIZE; i++) {
		counting_array[i] = 0;
	}

	//add the values from array to counting array and make temp array for reference
	for (i = 0; i != numbers; i++) {
		temp_array[i] = array[i];
		counting_array[array[i]]++;
	}

	//add from front to back
	for (i = 0; i != MAX_NUMBER_SIZE - 1; i++) {
		counting_array[i + 1] += counting_array[i];
	}

	//assign the ordered values
	for (i = 0; i != numbers; i++) {
		array[counting_array[temp_array[i]]] = temp_array[i];
		counting_array[temp_array[i]]--;
	}

}

int main() {
	int i, j, k, key;
	int array_num = 0;
	scanf("%d", &array_num);

	//dynamic scan
	int* array;
	array = (int*)malloc(array_num * sizeof(int));
	for (i = 0; i != array_num; i++) {
		scanf("%d", &array[i]);
	}

	Counting_sort(array, array_num);

	//printing
	for (i = 1; i < array_num; i++) {
		printf("%d ", array[i]);
	}
	printf("%d\n", array[array_num]);

	return 0;
}



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;
 //    #ifndef ONLINE_JUDGE
 //        freopen("in.txt",  "r",  stdin);
 //        freopen("out.txt", "w", stdout);
 //    #endif
   
   long int n;
   cin>>n;

   vector<pair<long int,long int>> edges;
   long int color = 0;
   vector<vector<long int>> v(n);
   for(long int i = 1; i < n; i++){
   	long int a,b;
   	cin>>a>>b;

   	v[a-1].push_back(b-1);
   	v[b-1].push_back(a-1);

   	edges.push_back({a-1,b-1});
   	color = max(color,(long int )v[a-1].size());
   	color = max(color,(long int )v[b-1].size());
   }	

   queue<long int> q;
   q.push(0);

   unordered_set<long int> visited;
   visited.insert(0);
   long int currentColor = 0;
   unordered_map<long int,long int> colors, umap;
   colors[0] = currentColor;

   while(!q.empty()){
   		auto e = q.front();
   		q.pop();

   		currentColor = colors[e];
   		for(auto ele : v[e]){
   			if(visited.find(ele) == visited.end()){
   				visited.insert(ele);
   				currentColor++;
   				colors[ele] = currentColor % color;
   				q.push(ele);
   			}
   		}
   }

   vector<long int> ans, sortColors;

   for(auto ele : edges){
   	ans.push_back(colors[max(ele.first,ele.second)]);
   	sortColors.push_back(ans.back());
   }

   sort(sortColors.begin(),sortColors.end());

   long int colorAssign = 0;
   for(long int i = 0; i < sortColors.size(); i++){
   		if(umap[sortColors[i]])
   			continue;
   		else
   			umap[sortColors[i]] = ++colorAssign;
   }

   cout<<color<<endl;
 	// cout<<edges.size()<<endl;

   // cout<<color<<endl;
   for(auto ele : ans){
   	cout<<umap[ele]<<endl;
   }

   return 0;
}

Measured memory_bytes: 19312
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define sec second
#define fir first
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
typedef vector<int> Vec;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s;
	int q;
	cin >> s >> q;
	int isr = 0;

	while(q--) {
		int a, b;
		string t;
		cin >> a;
		if(a == 1) {
			if(isr) isr = 0;
			else isr = 1;
		} else {
			cin >> b >> t;
			if(!isr) {
				if(b == 1) s.insert(0, t);
				else s.insert(s.size(), t);
			} else {
				if(b == 2) s.insert(0, t);
				else s.insert(s.size(), t);
			}
		}
	}
	if(isr) reverse(all(s));
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 912
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>

#include <map>
 
using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e10,flag;

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



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;


int main()
{
	double X;
	cin>>X;
	ll n;
	n = 100;
	for(int i = 1; i < 3800; i++){
		n = n * 1.01;
		if( n >= X){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 3720
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#define INF 10000000000000
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n,d,a,ans=0,dc=0,les,cnt;
  cin >> n >> d >> a;
  vector<ll> x(n),h(n),imo(n+1,0);
  vector<P> xh(n);
  for(int i=0;i<n;i++){
    cin >> xh[i].first >> xh[i].second;
  }
  sort(xh.begin(),xh.end());
  for(int i=0;i<n;i++){
    x[i] = xh[i].first;
    h[i] = xh[i].second;
  }
  x.push_back(INF);
  h.push_back(INF);
  for(int i=0;i<n;i++){
    dc += imo[i];
    les = h[i] - dc*a;
    if(les>0){
      cnt = (les+a-1)/a;
      dc += cnt;
      ans += cnt;
      auto itr = upper_bound(x.begin(),x.end(),x[i]+2*d);
      ll idx = distance(x.begin(),itr);
      imo[idx] -= cnt;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 11108
S=input()
a=set(S)
if len(a)==2:
  if S[0]==S[1] and S[2]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[2] and S[1]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[3] and S[2]==S[1]:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;

typedef long long int64;

int main()
{
	while(true) {
		
		int n, m;
		vector<pair<int, int> > score;
		
		scanf("%d%d", &n, &m);
		if(n == 0 && m == 0)
			break;
		
		score.resize(m);
		for(int i = 0; i < m; ++i)
			score[i].second = i;
		
		for(int i = 0; i < n; ++i) {
				
			for(int j = 0; j < m; ++j) {
				
				int t;
				
				scanf("%d", &t);
				
				if(t == 1)
					score[j].first -= 1;
			}
		}
		
		sort(score.begin(), score.end());
		
		for(int i = 0; i < m; ++i)
			printf("%d%s", score[i].second + 1, i != m - 1 ? " " : "\n");
	}
	
	return 0;
}

/* はやく人間になりたい */
/* 人権を得たい */
/* nullmineralが書きましたが */
/* 責任はまったくとりません */

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

void solve() 
{
    int n,p;string s;cin>>n>>p>>s;
    int64_t ans=0;
    if(p==2||p==5){
        REP(i,n)if(!((s[i]-'0')%p))ans+=i+1;
    }else{
        map<int,int>cnt;
        cnt[0]=1;
        int cur=0,ten=1;
        REP(i,n){
            (cur+=(s[n-1-i]-'0')*ten)%=p;
            ans+=cnt[cur]++;
            (ten*=10)%=p;
        }
    }
    cout<<ans<<endl;
}

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


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  map<char, int> dir;
  dir['U'] = 0;
  dir['R'] = 1;
  dir['D'] = 2;
  dir['L'] = 3;

  int h, w, n;
  cin >> h >> w >> n;
  int sr, sc;
  cin >> sr >> sc;
  string s, t;
  cin >> s >> t;

  vector<int> cnt(4, 0);
  int u = sr;
  int r = w - sc + 1;
  int d = h - sr + 1;
  int l = sc;
  // cout << u << ' ' << r << ' ' << d << ' ' << l << endl;
  rep(i, n) {
    cnt[dir[s[i]]]++;
    bool fin = false;
    if (cnt[0] == u) fin = true;
    if (cnt[1] == r) fin = true;
    if (cnt[2] == d) fin = true;
    if (cnt[3] == l) fin = true;

    if (fin) {
      cout << "NO" << endl;
      return 0;
    }

    cnt[(dir[t[i]] + 2) % 4]--;
    if (cnt[0] < 0 && (abs(cnt[0]) == d)) cnt[0]++;
    if (cnt[1] < 0 && (abs(cnt[1]) == l)) cnt[1]++;
    if (cnt[2] < 0 && (abs(cnt[2]) == u)) cnt[2]++;
    if (cnt[3] < 0 && (abs(cnt[3]) == r)) cnt[3]++;
  }

  cout << "YES" << endl;
}


Measured memory_bytes: 776
fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map { it.toInt() }
    val sum = a.reduce{ r1,r2 -> r1 + r2 }
    println(Math.max(-1, n - sum))
}


Measured memory_bytes: 39696
inputs = raw_input().replace("\n", "").split(" ")
N, M = map(int, inputs)

P_list = [[] for _ in xrange(N)]

PY_pairs = []
for _ in xrange(M):
    inputs = raw_input().replace("\n", "").split(" ")
    Pi, Yi = map(int, inputs)
    P_list[Pi-1].append(Yi)
    PY_pairs.append((Pi, Yi))

cvt_dict = {}
for Pi in xrange(N):
    for output_i, (input_i, Yi) in enumerate(sorted(enumerate(P_list[Pi]), key=lambda x: x[1])):
        address = "%06d" % (Pi + 1) + "%06d" % (output_i + 1) 
        cvt_dict[(Pi+1, Yi)] = address

for Pi, Yi in PY_pairs:
    print cvt_dict[(Pi, Yi)]

Measured memory_bytes: 56708
n = int(input())
a = input()
b = input()
c = input()
res = 0
for i in range(n):
    x,y,z = a[i], b[i], c[i]
    if x==y==z:
        res += 0
    elif x==y or y==z or z==x:
        res += 1
    else:
        res += 2
print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<int> dp(N, N + 1);
  vector<int> ind(26, N);
  vector<vector<int>> nxt(N); 
  for (int i = N - 1; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      if (ind[j] < N) {
        dp[i] = min(dp[i], 1 + dp[ind[j]]);
      } else {
        dp[i] = min(dp[i], 2);
      }
    }
    nxt[i] = ind;
    ind[S[i] - 'a'] = i;
  }
  string res = "";
  int len = N + 1, s = -1;
  for (int i = 0; i < 26; i++) {
    if (ind[i] >= N) {
      res = { char('a' + i) };
      len = 1;
      break;
    } else if (dp[ind[i]] < len) {
      res = { char('a' + i) };
      len = dp[ind[i]];
      s = ind[i];
    }
  }
  for (len--; len > 0; len--) {
    for (int i = 0; i < 26; i++) {
      if (nxt[s][i] >= N) {
        res += 'a' + i;
        break;
      } else if (dp[nxt[s][i]] == len) {
        res += 'a' + i;
        s = nxt[s][i];
        break;
      }
    }
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
   ll x,y,a,b,c;cin >>x>>y>>a>>b>>c;
   vector<P> app(a+b+c);
   rep(i,a){
    ll p;cin >>p;
    app[i]=make_pair(p,1);
    }
    rep(i,b){
    ll p;cin >>p;
    app[i+a]=make_pair(p,2);
    }
    rep(i,c){
    ll p;cin >>p;
    app[i+a+b]=make_pair(p,0);
    }
    sort(all(app));
    reverse(all(app));
    ll ans=0;
    ll get=0;
    ll red=0,green=0;ll i=0;
    while(get<x+y){
        ll col=app[i].second;
        ll val=app[i].first;
        if(col==0){
            ans+=val;
            get++;
        }
        if(col==1){
            if(red<x){
                ans+=val;
                get++;
                red++;
            }
        }
        if(col==2){
            if(green<y){
                ans+=val;
                get++;
                green++;
            }
        }
        i++;
    }

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


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

using namespace std;

int main() {
    string s;
    int nc, wc, sc, ec;
    nc = wc = sc = ec = 0;
    cin >> s;

    for (int i = 0; i < s.length(); ++i) {
        switch (s[i]) {
            case 'N':
                nc++;
                break;
            case 'W':
                wc++;
                break;
            case 'S':
                sc++;
                break;
            case 'E':
                ec++;
                break;
            default:
                break;
        }
    }
    // if ((nc > 0 && sc == 0) ||
    //     (nc == 0 && sc > 0) ||
    //     (wc > 0 && ec == 0) ||
    //     (wc == 0 && ec > 0)) {
    //     cout << "No" << endl;
    if (
            ((nc == 0 && sc == 0) || (nc > 0 && sc > 0)) &&
            ((wc == 0 && ec == 0) || (wc > 0 && ec > 0))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;

    };
    return 0;
}


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

int main()
{
   int sum , i;
    char k[1000];
      
    while(1){
        scanf("%s",k);
        if (k[0]=='0')break;
        for (sum=0,i=0; k[i]!='\0'; i++) {
            sum+=(k[i]-'0');
        }
        printf("%d\n",sum);
        }
  
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k;
	cin >> n >> k;
	cout << min(n%k,k-n%k) << endl;
	return 0;
}


Measured memory_bytes: 384
n,m=map(int,input().split());a,b=[list(map(int,input().split()))for i in range(m)],[float("INF")]*(n+1);b[1]=0
for i in range(1,n+1):
    for s,t,u in a:
        if b[t]>b[s]-u:
            b[t]=b[s]-u
            if i==n and t==n:print("inf");exit()
print(-b[-1])

Measured memory_bytes: 3444