akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	int grid[n][3];
	for(int i = 0; i < n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		grid[i][0] = a;
		grid[i][1] = b;
		grid[i][2] = c;
	}
	int dp[n][3];
	dp[0][0] = grid[0][0];
	dp[0][1] = grid[0][1];
	dp[0][2] = grid[0][2];
	for(int i = 1; i < n; i++){
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + grid[i][0];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + grid[i][1];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + grid[i][2];
	}
	
	cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

typedef long long ll;
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>A(n);
    for(int i=0;i<n;i++){
        cin>>A[i].first>>A[i].second;
    }
    sort(A.begin(),A.end());
    
    long long sum=0;
    
    for (int i = 0; i < n; i++) {
        if (m - A[i].second> 0) {
            sum += A[i].first*A[i].second;
            m -= A[i].second;
        } else {
            sum += A[i].first * m;
            break;
        }
        
    }
    cout<<sum;
}
    



Measured memory_bytes: 1792
import heapq

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

a = [[] for i in range(100000)]
d = []
heapq.heapify(d)

for _ in range(n):
    b,c = map(int,input().split())
    a[b-1].append(-1 * c)

#print(a)

ans = 0
for i in range(m):
    for j in range(len(a[i])):
        heapq.heappush(d,a[i][j])
    if d != []:
        ans -= heapq.heappop(d)

print(ans)

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    ll N, K, X, Y; cin >> N >> K >> X >> Y;
    
    ll sum = 0;
    
    if (N <= K) {
        sum += N * X;
    } else {
        sum += K * X;
        sum += (N - K) * Y;
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

m = defaultdict(int)
for a in A:
    m[a] += 1

total = 0

for k, v in m.items():
    if v >= 2:
        total += v * (v-1) // 2

for a in A:
    if m[a] >= 2:
        print(total - (m[a]-1))
    else:
        print(total)


Measured memory_bytes: 89932
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
//#include<boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

//namespace mp = boost::multiprecision;
//using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	vector<string> str(n);
	rep(i, n)
	{
		string s;
		cin >> s;
		sort(all(s));
		str[i] = s;
	}
	sort(all(str));
	ll cnt = 0;
	ll ans = 0;
	FOR(i, 1, n)
	{
		if (str[i] ==str[i - 1])
		{
			cnt++;
		}else{
			ans+=cnt*(cnt+1)/2;
			cnt=0;
		}
		//cout<<cnt<<endl;
	}
	ans+=cnt*(cnt+1)/2;
	cout << ans << endl;
}

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  string s;
  s = "NG";
  
  for(int i=a; i <= b; i++){
    if(i%k == 0){
      s = "OK";
      break;
    }
  }
  
  cout << s << endl;
  
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define int long long

typedef tree <
    int,
    null_type,
    less < int >,
    rb_tree_tag,
    tree_order_statistics_node_update >
ordered_set;

int const maxn = 2e5 + 5;
int mod = 998244353;
int st[maxn];

main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, y;
    cin >> n;
    st[0] = 1;
    vector < pair < int, int > > a;
    for (int i = 1; i <= n; ++i) {
        cin >> x >> y;
        st[i] = (st[i - 1] * 2) % mod;
        a.push_back({x, y});
    }
    sort(a.begin(), a.end());
    ordered_set lef, righ;
    for (auto key : a) {
        righ.insert(key.second);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        righ.erase(a[i].second);
        ans = (ans + st[n - 1]);
        if (ans >= mod) ans -= mod;
        int go1 = lef.order_of_key(a[i].second), go2 = (int)lef.size() - go1;
        int go3 = righ.order_of_key(a[i].second), go4 = (int)righ.size() - go3;
        ans = (ans + (st[go1] - 1) * (st[go4] - 1) % mod * (st[go2] + st[go3] - 1 + ((st[go2] - 1) * (st[go3] - 1)) % mod)) % mod;
        ans = (ans + (st[go2] - 1) * (st[go3] - 1) % mod * (st[go1] + st[go4] - 1)) % mod;
        lef.insert(a[i].second);
        //cout << a[i].first << " " << a[i].second << " " << ans << '\n';
    }
    cout << ans << '\n';
    return 0;
}


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

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

int main(int argc, char const *argv[])
{
    int D,G; cin >> D >> G;
    int ans = 1e9;
    int p[10];
    int c[10];
    REP(i, D){
        cin >> p[i] >> c[i];
    }

    for (int mask = 0; mask < (1 << D); mask++){
        int s = 0, num = 0, rest_max = -1;
        REP(i, D){
            if (mask >> i & 1){
                s += (i + 1) * 100 * p[i] + c[i];
                num += p[i];
            }
            else {
                rest_max = i;
            }
        }
        if (s < G){
            int s_m = 100 * (rest_max + 1);
            if (G - s <= s_m * (p[rest_max] - 1)) {
                num += (G - s)/ s_m + ((G - s) % s_m != 0);
            } 
            else continue;
        }
        ans = min(ans, num);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

if((D<=A)or(B<=C)):
  print(0)
elif((C<=A)and(A<D<=B)):
  print(D-A)
elif((A<C)and(A<D<=B)):
  print(D-C)
elif((A<=C<=B)and(B<D)):
  print(B-C)
else:
  print(B-A)

Measured memory_bytes: 3064
#ifdef LOCAL111
#else
	#define NDEBUG
#endif
#include <bits/stdc++.h>
const int INF = 1e8;
using namespace std;

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RBP(i,a) for(auto& i : a)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
#define rangej(a,b,c) ((a) <= (c) and (c) < (b))
#define rrangej(b,c) rangej(0,b,c)
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);	
}

int main()
{
	ios_init();
	int n;
	while(cin >> n){
		LL x;
		cin >> x;
		vector<LL> a(n);
		LL sum = 0;
		REP(i,n) cin >> a[i], sum += a[i];
		LL ans = sum;
		vector<LL> mm = a;
		REP(k,n){
			LL sum = 0;
			REP(i,n){
				mm[i] = min(mm[i],a[(i-k+n)%n]);
				sum += mm[i];
			}
			ans = min(ans,sum+k*x);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lop(i,n,a) for(int i=0;i<n;i+=a)
#define rep(i,n,a) for(int i=a;i<n;i++)
#define inarr(arr,n) lop(i,n,1)cin>>arr[i]
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define endl "\n"
#define eb emplace_back
#define fr first
#define sc second
#define pii pair<int,int>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ret return 0
#define pi 3.1415926536
#define hell 1000000007
using namespace std;
// syntax for min priority_queue of pairs
// priority_queue<pair<ll,ll>,vector<pair<ll,int>>,greater<pair<ll,int>>> q;
ll dp[101][100001];
ll pre[100001];
int solve(){
  int n,k;cin>>n>>k;
  dp[0][0]++;
  for(int i=1;i<=n;i++){
  	int a;cin>>a;
  	pre[0]=dp[i-1][0];
  	for(int j=0;j<=k;j++){
  		pre[j]=(pre[j-1]+dp[i-1][j])%hell;
  	}
  	for(int j=0;j<=k;j++){
  		dp[i][j]=(dp[i][j]+pre[j])%hell;
  		if(j>a)dp[i][j]=(dp[i][j]-pre[j-a-1]+hell)%hell;
  	}
  }
  cout<<dp[n][k]<<endl;
  ret;
}
int main(){
    IOS;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    ret;
}
 



Measured memory_bytes: 79232
S=input()
result = 0

for i in range(1 << len(S)-1):
    #先頭文字
    hoge=S[0]
    for j in range( len(S)-1 ):
        if i>>j&1 :
            hoge+="+"
        hoge+=S[j+1]
    result += eval(hoge)
print(result)

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

remind = [] 
for i in range(n): 
   remind.append(input()) 

egara = ["S ", "H ", "C ", "D "] 
for i in range(4): 
   for j in range(1, 14): 
      if egara[i] + str(j) not in remind: 
         print(egara[i] + str(j))


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

#define STRING_LEN 50

int main(void)
{
    char O[STRING_LEN + 1];
    char E[STRING_LEN + 1];

    scanf("%s\n%s", O, E);
   
    int i = 0;
    while (i < strlen(E))
    {
       printf("%c%c", O[i], E[i]);
       i++;
    }
    if (O[i] != '\0')
        printf("%c", O[i]); 


    return 0;
}




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

int main() {
  int a, b, d, h;
  cin >> a >> b;
  d = (b - a);
  h = d * (d + 1) / 2;
  cout << h - b << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = "APPROVED"

for n in range(N):
    if A[n] % 2 == 1:
        pass
    elif A[n] % 3 == 0:
        pass
    elif A[n] % 5 == 0:
        pass
    else:
        ans = "DENIED"
        break
print(ans)

Measured memory_bytes: 9156
import java.io.*;
import java.util.*;
 
 
public class Main{
static int mod = (int)(Math.pow(10, 9) + 7);
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      int n = sc.nextInt() % 10;
      if (n == 2 || n == 4 || n == 5 || n == 7 || n== 9){
        out.println("hon");
      }
      else if (n == 3){
        out.println("bon");
      }
      else out.println("pon");
      
      out.close();
   }
   
   static long pow(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a;
	   else {
		   long R = pow(a,N/2);
		   if (N % 2 == 0) {
			   return R*R;
		   }
		   else {
			   return R*R*a;
		   }
	   }
   }
   
   static long powMod(long a, long N) {
	   if (N == 0) return 1;
	   else if (N == 1) return a % mod;
	   else {
		   long R = powMod(a,N/2) % mod;
		   R *= R % mod;
		   if (N % 2 == 0) {
			   R *= a % mod;
		   }
			   return R % mod;
	   }
   }
static void mergeSort(int[] A){ // low to hi sort, single array only
      int n = A.length;
      if (n < 2) return;
      int[] l = new int[n/2];
      int[] r = new int[n - n/2];
 
      for (int i = 0; i < n/2; i++){
        l[i] = A[i];
      }
 
      for (int j = n/2; j < n; j++){
        r[j-n/2] = A[j];
      }
 
      mergeSort(l);
      mergeSort(r);
      merge(l, r, A);
    }
 
    static void merge(int[] l, int[] r, int[] a){
      int i = 0, j = 0, k = 0;
      while (i < l.length && j < r.length && k < a.length){
        if (l[i] < r[j]){
          a[k] = l[i];
          i++;
        }
        else{
          a[k] = r[j];
          j++;
        }
        k++;
      }
      while (i < l.length){
        a[k] = l[i];
        i++;
        k++;
      }
 
      while (j < r.length){
        a[k] = r[j];
        j++;
        k++;
      }
    }

   

   //-----------PrintWriter for faster output---------------------------------
   public static PrintWriter out;
      
   //-----------MyScanner class for faster input----------
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
 
      long nextLong() {
          return Long.parseLong(next());
      }
 
      double nextDouble() {
          return Double.parseDouble(next());
      }
 
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }

   }
   //--------------------------------------------------------
}







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

typedef long long LL;

LL li[200005];
LL ps[200005];
int n;

int cari(int l, int r)
{
	LL tmp = ps[r]-ps[l-1];
	int cl = l;
	int cr = r;
	int ret = cr;
	while(cl<=cr)
	{
		int mid = (cl+cr)/2;
		LL now = ps[mid] - ps[l-1];
		LL kan = tmp - now;
		if(now>=kan)
		{
			cr=mid-1;
			ret = mid;
		}
		else
		{
			cl=mid+1;
		}
	}
	return ret;
}

vector<LL> temp;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&li[i]);
		ps[i] = ps[i-1]+li[i];
	}
	LL ans = 1e16;
	for(int k=2;k<=n-2;k++)
	{
//		cout << k << endl;
		int idl = cari(1,k);
		int idr = cari(k+1,n);
		for(int i=-1;i<=1;i++)
		{
//			cout << i << "  aaa " << endl;
			if(idl-i<1 || idl-i>=k) continue;
			for(int j=-1;j<=1;j++)
			{
				if(idr-j<k+1 || idr-j>=n) continue;
				temp.clear();
				temp.push_back(ps[idl-i]);
				temp.push_back(ps[k] - ps[idl-i]);
				temp.push_back(ps[idr-j] - ps[k]);
				temp.push_back(ps[n] - ps[idr-j]);
				sort(temp.begin(),temp.end());
				ans = min(ans,abs(temp[3] - temp[0]));
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  REP(i, 10) REP(j, 10) {
    if (i * j == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  
  vector<string> S(N);
  for (int i = 0; i < N; ++i) cin >> S.at(i);

  sort(S.begin(), S.end());
  
  string sum = "";
  for (int i = 0; i < N; ++i) sum += S.at(i);
  
  cout << sum << endl;
}

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

class Program
{
    static void Main(string[] args) {
        int[] l = new int[5];
        l[0] = int.Parse(Console.ReadLine());
        l[1] = int.Parse(Console.ReadLine());
        l[2] = int.Parse(Console.ReadLine());
        l[3] = int.Parse(Console.ReadLine());
        l[4] = int.Parse(Console.ReadLine());
        int[] t = new int[5];
        for(int i = 0; i < 5; i ++) {
            t[i] = l[i];
            for (int j = 0; j < 5; j ++) {
                if (j != i) {
                    if (l[j]%10 == 0) t[i] += l[j];
                    else t[i] += l[j] + 10 - l[j]%10;
                }
            }
        }
        Console.WriteLine(t.Min());
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int z = scanner.nextInt();
		
		int ans = x/(y+z);
		
		if (x%(y+z)<z) {
			ans--;
		}
		System.out.println(ans);
		
		scanner.close();
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int N, M;
	int c = 0;
	cin >> N;
	cin >> M;
	vector<int>A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		c = c + A[i];
	}
	if (c > N)
		cout << -1;
	else {
		cout << N - c;
	}
	return 0;
}


Measured memory_bytes: 3660
//                             ¯\_(ツ)_/¯   
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mma,ava,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define ll long long
 
 
void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
 
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();

	int n,k;

	scanf("%d %d",&n,&k);
	std::vector<ll> a(n);
	for(int i = 0;i<n;i++){
		scanf("%lld",&a[i]);
		if(i>=k){
			if(a[i]>a[i-k])printf("Yes\n");
			else	printf("No\n");
		}
	}	
	
}

//CBA

Measured memory_bytes: 4844
#include <stdio.h>
#include <stdlib.h>
#define N 100
int bubbleSort(int *,int);

int main(){
  int i,num=0,num2[N],new;
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&num2[i]);
  }
  new=bubbleSort(num2,num);
  for(i=0;i<num;i++){
    if(i<num-1) printf("%d ",num2[i]);
    else printf("%d\n",num2[i]);
  }
  printf("%d\n",new);
  return 0;
}

int bubbleSort(int *num2,int num){
  int i,flag=1,j=0,temp=0,cnt=0;
  while(flag){
    flag=0;
    for(i=num-1;i>=j+1;i--){
      if(num2[i]<num2[i-1]){
	flag=1;
	temp=num2[i];
	num2[i]=num2[i-1];
	num2[i-1]=temp;
	cnt++;
      }
    }
    j++;
  }
  return cnt;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll n, k, r, s, p,sum=0;
	cin >> n >> k >> r >> s >> p;
	string t;
	cin >> t;
	string my=t;
	for (ll i = 0; i < my.size(); i++) {
		my[i] = 'o';
	}
	
	for (ll i = 0; i < t.size(); i++) {
		if (t[i] == 'r') {
			if (i<k) {
				sum += p;
				my[i] = 'p';
				//cout << sum << endl;
			}
			else if (i - k >= 0 && t[i - k] != 'r') {
				sum += p;
				my[i] = 'p';
				//cout << sum << endl;
				
			}
			else if (i - k >= 0 && t[i - k] == 'r'&&my[i-k]!='p') {
				my[i] = 'p';
				sum += p;
				
			}
			
		}
		else if (t[i] == 's') {
			if (i<k) {
				sum += r;
				my[i] = 'r';
				//cout << sum << endl;
			}
			else if (i - k >= 0 && t[i - k] != 's') {
				sum += r;
				my[i] = 'r';
				//cout << sum << endl;
			}
			else if (i - k >= 0 && t[i - k] == 's'&&my[i-k]!='r') {
				my[i] = 'r';
				sum += r;
			}
		}
		else {
			if (i<k) {
				sum += s;
				my[i] = 's';
				//cout << sum << endl;
			}
			else if (i - k >= 0 && t[i - k] != 'p') {
				sum += s;
				my[i] = 's';
				//cout << sum << endl;
			}
			else if (i - k >= 0 && t[i - k] == 'p'&&my[i-k]!='s') {
				my[i] = 's';
				sum += s;
			}
		}
	}
	cout << sum << endl;
}

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

int main(){
    ll n,d,x;
    cin>>n>>d>>x;
    ll a[n];
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;++i){
        for(ll j=0;j<=d;++j){
            if(a[i]*j+1 <= d){
                ans++;
            }
        }
    }
    cout<<ans+x<<endl;
}

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

ll mx = 3*3*3*3*3*3*3*3*3*3;
string s = "753";
set<string> st;
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < mx; i++) {
        int a[3] = {};
        int tmp = i;
        string ss = "";
        while (tmp > 0) {
            int k = tmp % 3;
            a[k]++;
            ss = s[k] + ss;
            tmp /= 3;
            if (ss.size() > 9) break;
            if (a[0] > 0 && a[1] > 0 && a[2] > 0) {
                if (stoi(ss) <= n) {
                    st.insert(ss);
                }
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aoj1
{
    class Program
    {
        static void Main()
        {
            int[] num;
            for (;;)
            {
                num = IntInput();
                Array.Sort(num);
                if (num[0] != 0 || num[1] != 0)
                {
                    Console.WriteLine("{0} {1}", num[0], num[1]);
                }
                else
                {
                    break;
                }
            }
        }

        static int[] IntInput()
        {
            string[] strs = Console.ReadLine().Split(' ');
            int[] numbers = new int[strs.Length];
            for (int i = 0; i < strs.Length; i++)
            {
                numbers[i] = int.Parse(strs[i]);
            }
            return numbers;
        }
    }
}

Measured memory_bytes: 5980
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
  int n,m,i,c,j,cnt=0;
  int b[10000];
  scanf("%d%d%d",&n,&m,&c);
  for(i=0;i<m;i++) scanf("%d",&b[i]);
  for(i=0;i<n;i++){
    int a[110]={0},sum=0;
    for(j=0;j<m;j++){
      scanf("%d",&a[j]);
      int total=a[j]*b[j];
      sum+=total;
    }
    sum+=c;
    if(sum>0) cnt++;
  }
  printf("%d",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

double averageTemp(double T, double x) {
    return T - (x * 0.006);
}


int main() {


    int N;

    cin >> N;

    double T, A;

    cin >> T >> A;

    vector<double> v;

    for (int i = 0; i < N; i++) {
        double a;
        cin >> a;
        v.push_back(a);
    }

    double minDiff = abs(A - averageTemp(T, v[0]));
    int pos = 0;
    for (int i = 1; i < N; i++) {

        double target = abs(A - averageTemp(T, v[i]));

        if (minDiff > target) {
            minDiff = target;
            pos = i;
        }

    }

    cout << (pos+1) << "\n";

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N,K,C=mi()
    S=list(input())
    ok,ng = "o","x"

    OK = []
    for i in range(N):
        if S[i] == ok:
            OK.append(i+1) # 1-index
    
    greeds = [OK[0]]
    for i in range(1,len(OK)):
        x = OK[i]
        if x - greeds[-1] > C:
            greeds.append(x)
            if len(greeds) > K:
                break

    inv_greeds = [OK[-1]]
    inv_OK = OK[::-1]
    for i in range(1,len(OK)):
        x = inv_OK[i]
        if -x + inv_greeds[-1] > C:
            inv_greeds.append(x)
            if len(inv_greeds) > K:
                break
    
    if len(greeds) < K or len(inv_greeds) < K:
        exit()

    greeds = greeds[:K]
    inv_greeds = inv_greeds[:K][::-1]

    # print(greeds,inv_greeds)
    for i in range(len(greeds)):
        if greeds[i] == inv_greeds[i]:
            print(greeds[i])



    
if __name__ == "__main__":
    main()

Measured memory_bytes: 128932
import java.io.*;

public class Main {

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

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));


        Long value = Long.parseLong(reader.readLine());
        if (value < 1200L)
            System.out.println("ABC");
        else
            System.out.println("ARC");
//        PrintWriter writer = new PrintWriter(System.out);
//
//        writer.close();


    }
}


Measured memory_bytes: 20564
#include <bits/stdc++.h>
#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 rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    ll a[2*n] = {};
    rep(i,2*n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+2*n);




    ll ans = 0;
    rep(i,n){
        ans+=a[i*2];
    }


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


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

int main(void){
  // input
  int n;
  cin >> n;
  map<string, int> mp; 
  for(int i=0; i<n ; ++i){
    string s;
    cin >> s;
    mp[s]++;
  }

  int mx = 0;
  for(auto p : mp){
    mx = max(mx, p.second);
  }
  for(auto p : mp){
    if(p.second != mx){
      continue;
    }  
    cout << p.first << endl;
  }

  return 0;
}


Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define mod 1000000007
#define pb push_back
void dora()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	dora(); fast;

	int t = 1; //cin >> t;
	while (t--)
	{
		int x; cin >> x;
		if (x >=  30)cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int dis[2010][2010];
int to[2010];
map<int, int> mp;

void bfs(int a)
{

}

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    x--; y--;
    
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<=n-1; j++) {
            int d = j - i;
            int now = abs(i-x) + 1 + abs(j-y);
            d = min(d, now);
            mp[d]++;
        }
    }
    for (int i=1; i<=n-1; i++) {
        cout << mp[i] << endl;
    }

    
    
    
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

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

    int ans = INF;
    for(int i = 1; i < N; i++) {
        int l = s[i] - s[0];
        int r = s[N] - s[i];
        ans = min(ans, abs(l - r));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
index_a = 0
index_z = -1
for i in range(len(s)):
  if s[i] == 'A':
    index_a = i
    break
    
for i in reversed(range(len(s))):
  if s[i] == 'Z':
    index_z = i
    break

print(index_z - index_a + 1)

Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
typedef double db;
const int maxn = 45000 + 5;
const int mod = 1e9 + 7;

int main(){
    db t, x;
    cin >> t >> x;
    cout << t / x << endl;
    return 0;
}


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
const long long MOD = 1e9 + 7 ;
const int MAXN = 1e6 + 10 ;
long long dp[MAXN] ;
long long cdp[MAXN] ;
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
      //  freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    long long n ;
    cin >> n ;
    dp[1] = n ;
    cdp[1] = dp[1] ;
    for(int i = 2 ; i <= n ; i++){
        dp[i] = dp[i-1] + ((n - 1)*(n - 1))%MOD + (n - max(i-1,2) + 1) ;
        dp[i] %= MOD ;
        if(i > 3){
            dp[i] = (dp[i] + cdp[i-3])%MOD ;
        }
        cdp[i] = (cdp[i-1] + dp[i])%MOD ;
    }
    cout << dp[n] << endl ;
    return 0 ; 
}

Measured memory_bytes: 15872
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n+1,0);
    rep(i,1,n+1) cin >> a[i];

    vector<int> visit(n+1,0);
    ll cur = 1;
    visit[cur] = 1;
    ll last = 0;
    vector<ll> V(n+1,0);
    V[1] = 1;

    if(k < 200000){
        int ans = 1;
        for(int i=1;i<=k;i++){
            ans = a[ans];
        }
        cout << ans << endl;
        return 0;
    }


    for(int i=2;i<=k;i++){
        cur = a[cur];
        V[i] = cur;
        if(visit[cur] != 0){
            last = i;
            break;
        }
        visit[cur] = i;
    }
    //cout << last << endl;
    //cout << k-visit[cur] << endl;
    //cout << (k-visit[cur]) % (last-visit[cur]) << endl;
    cout << V[visit[cur] + (k+1-visit[cur]) % (last-visit[cur])] << endl;
    //cout << visit[cur] + (k-visit[cur]) % (last-visit[cur]) << endl;


    return 0;
}



Measured memory_bytes: 7140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool used[100005];
vector<ll> node[100005];
ll T_dis[100005]={0},A_dis[100005]={0};
void dfs_T(ll pos,ll dis){
  T_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_T(to,dis+1);
    }
  }
}
void dfs_A(ll pos,ll dis){
  A_dis[pos]=dis;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs_A(to,dis+1);
    }
  }
}
int main(){
  ll n,u,v;
  cin>>n>>u>>v;
  for(int i=1;i<n;i++){
    ll a,b;
    cin>>a>>b;
    node[a].push_back(b);
    node[b].push_back(a);
  }
  for(int i=0;i<=n;i++) used[i]=false;
  used[u]=true;
  dfs_T(u,0);
  for(int i=0;i<=n;i++) used[i]=false;
  used[v]=true;
  dfs_A(v,0);
  ll ans=0;
  for(int i=1;i<=n;i++){
    if(T_dis[i]<A_dis[i]) ans=max(ans,A_dis[i]);
  }
  cout<<ans-1<<endl;
}


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

string s;

int main(){
  cin >> s;
  if(s == "abc" || s == "acb" || s == "bac" || 
     s == "bca" || s == "cab" || s == "cba"){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from math import sqrt

def is_prime(a):
    if a<2:return 0
    if a==2:return 1
    if a%2 == 0:return 0
    i = 3
    while i<=sqrt(a):
        if a%i==0:return 0
        i+=2
    return 1

def main():
    n = int(input())
    res = 0
    for _ in range(n):
        a = int(input())
        if is_prime(a):res+=1
    print(res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 5680
N = int(input())
H = [int(i) for i in input().split()]

dp = [0] * N
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(H[i] - H[i - 1]), dp[i - 2] + abs(H[i] - H[i - 2]))
print(dp[N - 1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
#define gc getchar
#define ull unsigned long long int
#define gcu getchar_unlocked
#define pc(x) putchar(x);
#define pcu(x) putchar_unlocked(x);
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007

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

//void readint(ll &x)
//    {
//        bool neg=false;
//        ll c;
//        x =0;
//        c=gc();
//        if(c=='-')
//        {
//            neg = true;
//            c=gc();
//        }
//        for(;(c>47 && c<58);c=gc())
//            x = (x<<1) + (x<<3) +c -48;
//        if(neg)
//            x *=-1;
//    }
//
//inline void input(ll *n)
//{
////    register char c=getchar_unlocked();
//    *n=0;
//    for(;(c<'0'||c>'9');c=getchar_unlocked());
//    for(;(c<='9'&&c>='0');c=getchar_unlocked())
//    {
//        *n=((*n)<<1) + ((*n)<<3) + c - 48;
//    }
//}

//inline void writeInt (ll n)
//{
//    ll N = n, rev, count = 0;
//    rev = N;
//    if (N == 0) { pc('0'); pc('\n'); return ;}
//    if (N*(-1)>0){pc('-');rev=rev*(-1);N=N*(-1);}
//    while ((rev % 10) == 0) { count++; rev /= 10;}
//    rev = 0;
//    while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;}
//    while (rev != 0) { pc(rev % 10 + '0'); rev /= 10;}
//    while (count--) pc('0');


//ll power(ll x, ll y,ll p)
//{
//    ll res = 1;
//    x = x % p;
//
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res*x) % p;
//
//        y = y>>1;
//        x = (x*x) % p;
//    }
//    return res;
//}

int main()
{
    SPEED
    ll n,i;
    cin>>n;
    long double a[n],s=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        //s=s+(1/a[i]);
    }
    sort(a,a+n);
    s=a[0];
    for(i=1;i<n;i++)
    {
        s=(s+a[i])/2;
    }
    cout<<fixed<<setprecision(6)<<s<<"\n";
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int a, b;
    std::cin >> a >> b;
    
    if(!((1 < a < 100) || (1 < b < 100))) return 0;
    std::cout << (a * b) << " " << 2 * (a + b) << std::endl;
    return 0 ;
}


Measured memory_bytes: 3100
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

    // メモ化(TLE)
    static int fibm(int n) {
        if (n == 0)
            return 1;
        if (n == 1)
            return 1;

        return fibm(n - 1) + fibm(n - 2);
    }

    // 動的計画法
    static boolean[] done;
    static int[] memo;

    static int fib(int n) {
        if (n == 0)
            return 1;
        if (n == 1)
            return 1;

        if (done[n]) {
            return memo[n];
        } else {
            int res = fib(n - 1) + fib(n - 2);
            done[n] = true;
            memo[n] = res;
            return res;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        done = new boolean[n + 1];
        memo = new int[n + 1];
        System.out.println(fib(n));
    }
}


Measured memory_bytes: 24284
lines = $stdin.read.lines.map(&:chomp)
N, M = lines.shift.split(/\s/).map(&:to_i)
cities = lines.map {|line| line.split(/\s/).map(&:to_i) }

pref_table = {}
lineno = 0
cities.each {|pref, year|
  pref_table[pref] = [] unless pref_table.key? pref
  pref_table[pref] << [lineno, year.to_i]
  lineno += 1
}

ret = []
pref_table.keys.each {|pref|
  pref_table[pref].sort! {|c0, c1| c0[1] <=> c1[1] }
  pref_table[pref].each.with_index {|c, i|
    ret << [c[0], "%06d%06d" % [pref, i + 1]]
  }
}

puts ret.sort {|c0, c1| c0[0] <=> c1[0] }.map {|c| c[1] }.join("\n")


Measured memory_bytes: 57648
#include <bits/stdc++.h>
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using namespace std;
typedef long long ll;
using vi   = vector<int>;
using vll  = vector<ll>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs  = vector<vector<string>>;

const static string el = "\n";

int main()
{
  int _min = INT_MAX;
  int n,k;cin>>n>>k;
  rep(bits,1,(1<<n)) {
    ll tmp=1;
    rep(i,0,n) {
      int mask = 1<<i;
      if (bits&mask) tmp*=2; // 1(true)なら2倍 0(false)なら+kする;
      else tmp+=k;
    }
    if(tmp<_min) _min=tmp;
  }
  print(_min);
  return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int x;
	cin >> x;
	cout << 1 + (1999 - x) / 200 << endl;
}

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

const int MAX = 6000;

string greedA(string S, int l) { // 先頭がaだった時の貪欲取得(abab…系)
	for (int i = 1, j, k;i < l;++ i) {
		if (S[i] == 'a') { // 連続した'a'を発見
			for (j = i + 1;S[j] == 'a';++ j); // 最初に出てくるb(消さない)
			for (k = j + 1;S[k] == 'a';++ k); // 次に出てくるb(消す)
			S.erase(S.begin() + k);
			S.erase(S.begin() + i);
			-- i;
		} else ++ i;
	}
	return S;
}

string greedB(string S, int l) { // 先頭がbだった時の探索(i決め打ち、i番目以降取る)
	string comp = S;
	for (int i = 0, ma = l >> 1, j;i < ma;i ++) {
		for (j = 1;comp[j] == comp[0];j ++);
		comp.erase(comp.begin() + j);
		comp.erase(comp.begin());
		S = S > comp ? S : comp;
	}
	return S;
}

int main() {
	int N;
	string S;
	cin >> N >> S;
	N = S.length();
	
	bool isA[MAX]; // isA[i] = S[i] == 'a'
	for (int i = 0;i < N;++ i) isA[i] = S[i] == 'a';
	
	int sum[MAX]; // 累積和、sum[i]は[0, i)までに出てきた'b'の数-出てきた'a'の数
	sum[0] = isA[0] ? -1 : 1;
	for (int i = 1;i < N;++ i) sum[i] = sum[i - 1] + (isA[i] ? -1 : 1);
	
	static string greed[MAX];
	int use = 0;
	
	string subst;
	for (int l = 0, r = 0;l < N;l = r, ++ r) {
		while(sum[r] != 0) ++ r; // ここまでで区間[l, r)の累積和は0、よって独立に解ける
		++ r;
		subst = S.substr(l, r - l);
		if (isA[l]) greed[use] = greedA(subst, r - l);
		else greed[use] = greedB(subst, r - l);
		use ++;
	}
	
	string ret = "";
	for (int i = use - 1;i >= 0;i --) { // 後は貪欲に構成
		ret = greed[i] + ret > ret ? greed[i] + ret : ret;
	}
	cout << ret;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説ACなので何も無いです、解説読んでね
*/

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;
#define INF 100000100LL

int main(){
    ll H; cin >> H;
    ll cnt = 0;
    ll ans = 0;
    if(H == 1){
        cout << 1 << endl;
        return 0;
    }
    while(H != 1){
        H = floor(H / 2);
        cnt++;
        ans += pow(2, cnt-1);
        if(H == 1){
            ans += pow(2, cnt);
        }
        //cout << H << " " << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef int64_t lint;
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> c(6);
	rep(i, H) {
		cin >> c.at(i);
	}

	int a=0, b=0;
	for (size_t i = 0; i < (1 << H); i++) {
		bitset<6> bh(i);
		for (size_t j = 0; j < (1 << W); j++) {
			bitset<6> bw(j);
			vector<string> t(6);
			rep(l, H) {
				t.at(l) = c.at(l);
			}
			rep(x, H) {
				rep(y, W) {
					if (bh.test(x) || bw.test(y)) {
						t.at(x).at(y) = '.';
					}
				}
			}
			rep(x, H) {
				rep(y, W) {
					if (t.at(x).at(y) == '#') {
						a++;
					}
				}
			}
			if (a == K) b++;
			a = 0;
		}
	}
	std::cout << b << '\n';
}


Measured memory_bytes: 3628
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)

int main()
{
	string s,ans="Yes";

	cin >> s;

	forll(i,0,s.size()/2)
	{
		if (s[i] != s[s.size() - i-1])
			ans = "No";
	}

	forll(i, 0, (s.size()-1)/ 2/2)
	{
		if (s[i] != s[s.size()/2 - i-1])
			ans = "No";
	}

	forll(i, (s.size()+1)/2, s.size())
	{
		if (s[i] != s[s.size()-i-1])
			ans = "No";
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  uint64_t N;
  string S;
  cin >> N;
  cin >> S;
  
  uint64_t left_count = 0;
  uint64_t right_count = 0;
  
  for (uint64_t i = 1; i < N; i++) {
    if (S.at(i) == 'E') {
      right_count++;
    }
  }
  uint64_t min_count = right_count;
  
  for (uint64_t i = 1; i < N; i++) {
    uint64_t count = 0;
    if (S.at(i) == 'E') {
      right_count--;
    }
    if (S.at(i - 1) == 'W') {
      left_count++;
    }
    count = left_count + right_count;
    if (count < min_count) {
      min_count = count;
    }
  }
  cout << min_count << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep0(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<string, int, int> TU;
typedef tuple<int, int, int> TI;

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


Measured memory_bytes: 3576
N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]
L=[K-Q]*N
for i in range(Q):
    L[A[i]-1]+=1
for j in range(N):
    if  L[j]<=0:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 81016
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
using namespace std;
typedef long int li;
typedef long long int lli;
typedef pair<lli, int> P;
const lli INF = 0xfffffffffff;
lli n, k, ans;
lli mod1, mod2;
int main(){
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		if (k % 2 == 0) {
			if (i%k == k / 2) mod2++;
		}
		if (i%k == 0) mod1++;
	}
	ans = pow(mod1,3);
	if (k % 2 == 0) ans += pow(mod2,3);
	cout << ans << endl;
}

Measured memory_bytes: 256