akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    char A;
    cin>>A;
    cout<<char(A+1)<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long long max;
	long a, b, c, d;

	scanf("%ld%ld%ld%ld", &a, &b, &c, &d);

	max = a * c;
	max = (max < a * d) ? a * d : max;
	max = (max < b * c) ? b * c : max;
	max = (max < b * d) ? b * d : max;

	printf("%ld", max);

	return 0;
}

Measured memory_bytes: 3232
<?php
  $n = trim(fgets(STDIN));
  $a=[];
  for($i=0; $i<$n; $i++){
      $a[trim(fgets(STDIN))]++;
  }
  $count=0;
  foreach ($a as $d){
      if($d%2 == 1){
          $count++;
      }
  }
  echo $count;

Measured memory_bytes: 13048
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
//    make(int, n);
//    cout << fixed << setprecision(10) <<  2 * n * M_PI;

    make(int, n, k);
    int ans = 0;
    VI a(n + 1);
    iota(ALL(a), 0);
    int lsm = 0, l = 0;
    int rsm = 0, r = 0;
    for(int i = k; i <= n + 1; ++i){
        while(l < i){
            lsm += a[l++];
        }
        while(r < i){
            rsm += a[n - r++];
        }
//        cerr << lsm << ' ' << rsm << endl;
        ans = (ans + rsm - lsm + 1) % M7;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 4748
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = (0 until n).map { sc.next().toLong() }
    println(problem094c(n, x))
}

fun problem094c(n: Int, x: List<Long>): String {
    val sorted = x.sorted()
    val res = LongArray(n) { 0 }
    for (i in 0 until n) {
        val xi = x[i]
        res[i] = if (xi < sorted[(n + 1) / 2]) {
            sorted[n / 2]
        } else {
            sorted[(n - 1) / 2]
        }
    }
    return res.joinToString("\n")
}

Measured memory_bytes: 71472
n=gets.to_i
n.times.map{ gets.split.map(&:to_i) }.map do |xs|
  a = [0]*n
  unless xs[1] == 0
    xs[2..-1].each do |x|
      a[x-1] = 1
    end
  end
  a
end.each { |xs| puts xs.join(' ') }

Measured memory_bytes: 6168
#include <iostream>

using namespace std;
typedef long long ll;

ll m,a,r,c,h;

int main() {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        if(s[0]=='M') m++;
        if(s[0]=='A') a++;
        if(s[0]=='R') r++;
        if(s[0]=='C') c++;
        if(s[0]=='H') h++;
    }
    ll res = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
    cout << res << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef vector<long long> vll;

// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a/ gcd(a,b)*b;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,A[100010];
	vector<int> vec;
	ll ans = 0;
	scanf("%d", &N);
	REP(i, N) {
		cin >> A[i];
	}
	sort(A, A + N);
	int cnt = 1;
	REPL(i, 1, N) {
		if (A[i]== A[i - 1]) {
			cnt++;
			if (cnt % 2 == 0) {
				vec.push_back(A[i]);
			}
		}
		else {
			cnt = 1;
		}
	}
	if (vec.size() >= 2)ans = vec[vec.size() - 1] * vec[vec.size() - 2];
	cout << ans << endl;
	return 0;
}


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

template <typename T> void chmax(T &x,const T &y)
{
	if(x<y)x=y;
}
typedef long long ll;
typedef unsigned int ui;
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)

int a[3][105],dp[3][105];

int main()
{
	//freopen("1.in","r",stdin);
	int	n; 
	cin>>n;
	rep(j,1,2)
	rep(i,1,n)cin>>a[j][i];
	rep(j,1,2)
	rep(i,1,n)dp[j][i]=max(dp[j][i-1],dp[j-1][i])+a[j][i];
	cout<<dp[2][n];
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  D2(x)       { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  all(x)      (x).begin(), (x).end()
#define  mem(a)      memset(a , 0 ,sizeof a)
#define  deb(x)      cout << #x << " - " << x << "\n";
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)  __builtin_popcountll(x)
#define  deb2(x,y)   cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b)  for(int i=a ; i>=b ; --i)
 
#define PI 3.141592653589793
const ll p = 5;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

vi adj[MAX_N],vis(MAX_N),curr_t(MAX_N),nodes,in_tm(MAX_N),out_tm(MAX_N),idx(MAX_N);
int cntr = 1;

void dfs(int node){
    vis[node] = 1;
    nodes.pb(node);
    idx[node] = (int)nodes.size()-1;
    curr_t[cntr] = node;
    in_tm[node] = cntr++;
    
    for(auto x:adj[node]){
        if(!vis[x]) dfs(x);
    }
    out_tm[node] = cntr;
}

int main() {
    IOS;
    int n,q; cin >> n >> q;
    
    int na,nb; 
    rep(i,1,n){
        cin >> na >> nb;
        adj[na].pb(nb), adj[nb].pb(na);
    }
    
    dfs(1);
    
    vll d(n+1),a(n);
    d[0] = d[n] = 0;
    rep(i,1,n) d[i] = a[i] - a[i-1];
    
    while(q--){
        int vertex,x; cin >> vertex >> x;
        int id = idx[vertex],sz = abs(in_tm[vertex] - out_tm[vertex]);
        
        // deb(id);
        d[id] += x;
        d[id + sz] -= x;
    }
    
    a[0] = d[0]; 
    rep(i,1,n) a[i] = d[i] + a[i - 1]; 
    
    rep(i,1,n+1) cout << a[idx[i]] << ' ';
}

Measured memory_bytes: 31452
#pragma comment(linker, "/STACK:1073741824")

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<deque>
#include<unordered_set>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<fstream>
#include<iterator>
#include<functional>
#include<bitset>
#include<memory>
#include<sstream>
#include<new>
#include<cassert>
#include<iomanip>

using namespace std::placeholders;

typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<bool, bool> pbb;

const int inf = (int)2 * 1e9;
const ll linf = (ll) 1e18 * 8;
const ld eps = 1e-5;
const int mod = (int) 1e9 + 7;

#define it(v) begin(v), end(v)
#define pb push_back
#define eb emplace_back
#define mp std::make_pair
#define fst first
#define scn second
#define sgn(x) (x > 0 ? 1 : (x == 0 ? 0 : -1))

int main()
{
	std::ios_base::sync_with_stdio(false);
	std::string s;
	std::cin >> s;
	int n = s.size(), res = n;
	for (int i = 0; i < n - 1; i++)
	{
		if (s[i] != s[i + 1])
			res = std::min(res, std::max(i + 1, n - i - 1));
	}
	std::cout << res;
}

Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a: List<Int> = (0 until n).map { sc.nextInt() }
    var result = "APPROVED"
    for (index in a.indices) {
        if (a[index] % 2 == 0) {
            if (a[index] % 3 != 0 && a[index] % 5 != 0) {
                result = "DENIED"
                break
            }
        }
    }
    println(result)
}

Measured memory_bytes: 31264
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,q;
    cin>>n>>m>>q;
    int dp[505][505];
    //dp[i][j]:i~jを走る電車の本数
    for(int i=0;i<505;i++){
        for(int j=0;j<505;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        dp[l][r]++;
    }
    for(int i=0;i<505;i++){
        for(int j=1;j<505;j++){
            dp[i][j]+=dp[i][j-1];
        }
    }
    for(int i=1;i<505;i++){
        for(int j=0;j<505;j++){
            dp[i][j]+=dp[i-1][j];
        }
    }
    for(int i=0;i<q;i++){
        int p,q;
        cin>>p>>q;
        cout<<dp[503][q]-dp[p-1][q]<<endl;
    }
}

Measured memory_bytes: 2944
import java.util.*;
public class Main {
    static String[][] map;
    static boolean[][] al;
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        while(true) {
            int h = stdIn.nextInt();
            int w = stdIn.nextInt();
            if(w == 0 && h == 0) {
                break;
            }
            map = new String[h][w];
            al = new boolean[h][w];
            for(int i = 0; i < h; i++) {
                String tmp = stdIn.next();
                for(int j = 0; j < w; j++) {
                    map[i][j] = tmp.substring(j, j+1);
                }
            }
              
            int npx = 0;
            int npy = 0;
            boolean lp = false;
            while(true) {
                if(map[npy][npx].equals(".")) {
                    break;
                }
                if(al[npy][npx]) {
                    lp = true;
                    break;
                }
                al[npy][npx] = true;
                if(map[npy][npx].equals(">")) {
                    npx++;
                }
                if(map[npy][npx].equals("<")) {
                    npx--;
                }
                if(map[npy][npx].equals("v")) {
                    npy++;
                }
                if(map[npy][npx].equals("^")) {
                    npy--;
                }
            }
            if(lp) {
                System.out.println("LOOP");
            }
            else {
                System.out.println(npx + " " + npy);
            }
              
              
        }
    }
}


Measured memory_bytes: 29628
#include <stdio.h>

int main(){
  int i,j,c,r,sum1,sum2,sum3;
  int data[101][101];
  
  scanf("%d%d",&c,&r);
 
  for(i=1;i<c+1;i++){
    for(j=1;j<r+1;j++){
      scanf("%d",&data[i][j]);
    }
  }
  
  for(i=1;i<c+1;i++){
    sum1=0;
    for(j=1;j<r+1;j++){
      printf("%d ",data[i][j]);
      sum1 += data[i][j];
    }
    printf("%d\n",sum1);
  }
  for(j=1;j<r+1;j++){
    sum2=0;
    for(i=0;i<c+1;i++){
      sum2 += data[i][j];
    }
    printf("%d ",sum2);
  }
  sum3=0;
  for(i=1;i<c+1;i++){
    for(j=1;j<r+1;j++){
      sum3 += data[i][j];
    }
  }
  printf("%d\n",sum3);
  return 0;
}

Measured memory_bytes: 640
N,X,Y=map(int,input().split())
distance=[0]*N
for i in range(1,N):
    for j in range(i+1,N+1):
        k=min(j-i,abs(j-X)+abs(i-Y)+1,abs(j-Y)+abs(i-X)+1)
        distance[k]+=1
print(*distance[1:],sep="\n")

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

int main() {
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<int> v;
    int d = 0;
    v.push_back(0);
    for (int i = 0; i < n; i++) {
        d += arr[i];
        v.push_back(d);
    }
    int ctr = 0;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] <= k)
            ctr++;
    }
    cout << ctr;
}

Measured memory_bytes: 256
ABCD = list(map(int, list(input())))
op_cnt = len(ABCD) -1
for i in range(2 ** op_cnt):
  ans_str = str(ABCD[0]) 
  ans = ABCD[0]
  op = ["-"]* op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt- j - 1] = "+"
  for i, f in enumerate(op):
    if f == "+":
      ans += ABCD[i+1]
      ans_str += "+" + str(ABCD[i+1])
    else:
      ans -= ABCD[i+1]
      ans_str += "-" + str(ABCD[i+1])
  if ans == 7:
    print(ans_str + "=7")
    break

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int arr[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
int main()
{
	int n, m;
	cin>>n>>m;
	unordered_map<int, int> mp;
	rep(i, 0, m)
	{
		int x;
		cin>>x;
		chmax(mp[arr[x-1]], x);
	}
	vector<int> dp(n+1);
	vector<int> track(n+1, -1);
	vector<int> label(n+1, 0);
	dp[0] = track[0] = 0;
	repn(i, 1, n)
	{
		for(auto x: mp)
		{
			int cost = x.f;
			int val = x.s;
			if(i - cost >= 0 && track[i - cost] != -1)
			{
				if(dp[i] < dp[i-cost] + 1)
				{
					dp[i] = dp[i-cost] + 1;
					track[i] = i-cost;
					label[i] = val;
				}
				if(dp[i] == dp[i-cost]+1)
				{
					if(label[i] < val)
					{
						label[i] = val;
						track[i] = i - cost;
					}
				}
			}
		}
	}
	int i = n;
	string ans = "";
	while(i != 0)
	{
		ans += to_string(label[i]);
		i = track[i];
	} 
	sort(ans.rbegin(), ans.rend());
	cout<<ans<<endl;

}


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

int main() {
    int n; cin >> n;

    vector<int> L(n);
    REP(i, n) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    REP(b, n) REP(a, b) {
        int ab = L[a] + L[b];
        int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
        int l = b + 1;
        ans += r - l;
    }

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


Measured memory_bytes: 256
k, s = map(int, input().split())

cnt = 0

for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            # print(x)
            # print(y)
            # print(s - x - y)
            # print("------------------")
            cnt += 1

print(cnt)

Measured memory_bytes: 42092
import sys
(n, m, l) = [int(i) for i in sys.stdin.readline().split()]

a = []
for i in range(n):
    a.append([int(i) for i in sys.stdin.readline().split()])
b = []
for i in range(m):
    b.append([int(j) for j in sys.stdin.readline().split()])

for i in range(n):
    row = []
    for j in range(l):
        c_ij = 0
        for k in range(m):
            c_ij += a[i][k] * b[k][j]
        row.append(str(c_ij))
    print(" ".join(row))

Measured memory_bytes: 7240
//
// Created by Huang,Zhiqiang on 2018/8/13.
//

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    if (N == 0) {
        cout << 0 << endl;
    } else {
        vector<int> ans;
        while (N != 0) {
            int k = N % -2;
            int t = N / -2;
            if (k < 0) {
                t++;
                k -= -2;
            }
            N = t;
            ans.push_back(k);
        }
        for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
        cout << endl;
    }
}

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


int main()
{
    ll n,w;
    cin>>n>>w;
    vector<ll> weight(n);
    vector<ll> value(n);
    for(ll i=0;i<n;i++)
    {
        cin>>weight[i];
        cin>>value[i];
    }
    vector<vector<ll> > ans(n,vector<ll> (w+1,0));
    for(ll i=weight[0];i<=w;i++)
    ans[0][i]=value[0];
    for(ll i=1;i<n;i++)
    {
        for(ll j=1;j<=w;j++)
        {
            if((j-weight[i]) >= 0)
            {
                ans[i][j]=max(ans[i-1][j],value[i]+ans[i-1][j-weight[i]]);
            }
            else
            ans[i][j]=ans[i-1][j];
        }
    }
    ll an=0;
    for(ll i=1;i<=w;i++)
    an = max(an,ans[n-1][i]);
    cout<<an;
    return 0;
}

Measured memory_bytes: 79360
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(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;
template <typename F,typename T>
struct DST{
  T identity;
  F merge;
  int size;
  vector<T> dat,delay;
  
  DST(F f,T id):merge(f),identity(id){}

  void eval(int k,int l,int r){
    if(delay[k] != -1){
      dat[k] = delay[k];
      if(k<size-1){
	delay[2*k+1] = delay[2*k+2] = delay[k];
      }
      delay[k]=-1;
    }
  }

  void init(int n){
    size = 1;
    while(size<=n) size *= 2;
    dat.resize(size*2-1,identity);
    delay.resize(size*2-1,-1);    
  }

  void build(vector<T> vec){
    rep(i,vec.size()) dat[size-1+i] = vec[i];
    dfs(0);
  }

  T dfs(int k){
    if(k>=size-1) return dat[k];
    else return dat[k] = merge(dfs(2*k+1),dfs(2*k+2));
  }

  void update(int a,int b,T x,int k,int l,int r){
    eval(k,l,r);

    if(r<=a||b<=l) return ;
    if(a<=l&&r<=b){
      delay[k] = x;
      eval(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = merge(dat[2*k+1],dat[2*k+2]);
    }
  }

  T query(int a,int b,int k,int l,int r){
    eval(k,l,r);
    if(r<=a||b<=l) return identity;

    if(a<=l&&r<=b) return dat[k];
    else return merge(query(a,b,2*k+1,l,(l+r)/2),query(a,b,2*k+2,(l+r)/2,r));
  }

  void all_eval(){
    rep(i,2*size-1){
      eval(i,0,0);
    }
  }

  T get(int k){ return dat[size-1+k];}
  
  void show(){
    int index = 0;
    int num = 1;
    while(index<size){
      rep(i,num){
	if(dat[i+index]==identity) cout << "e ";
	else cout << dat[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
    index = 0;
    num = 1;
    while(index<size){
      rep(i,num){
	cout << delay[i+index] << " ";
      }
      cout << "\n";
      num *= 2;
      index = index*2+1;
    }
  }
  

  
};
int main()
{
  int n,q;cin >> n >> q;
  vector<ll> c(q),s(q),t(q),x(q);
  rep(i,q){
    cin >> c[i];
    if(c[i]==0) cin >> s[i] >> t[i] >> x[i];
    else cin >> x[i];
  }

  auto f = [&](ll a,ll b){ return min(a,b);};
  ll id = (1LL<<31)-1;
  DST<decltype(f),ll> dst(f,id);
  dst.init(n);
  rep(i,q){
    if(c[i]==0) dst.update(s[i],t[i]+1,x[i],0,0,dst.size);
    else cout << dst.query(x[i],x[i]+1,0,0,dst.size) << "\n";
  }
  
  return 0;
}



Measured memory_bytes: 9940
#include<iostream>
#include<vector>
main(){
  int n;
  std::cin>>n;
  std::vector<int> a(n);
  for(auto& ai:a)std::cin>>ai;
  
  int allxor = 0;
  for(auto& ai:a)allxor ^= ai;
  
  for(auto& ai:a)std::cout<< (allxor^ai) <<std::endl;
}


Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<long long int> 
#define pb push_back
#define f(i,x,n) for (i=x;i<n;i++)


void solve(){
    int n;
    cin >> n;
    int a[n][2];
    for (int i=0;i<n;i++)cin >> a[i][0]>>a[i][1];
    for(int i=0;i<n;i++){
        if(a[i][0]==a[i][1]){
            if(i+1<n && (a[i+1][0]==a[i+1][1])){
                if(i+2<n && (a[i+2][0]==a[i+2][1])){
                    cout << "Yes"<<endl;
                    return;
                }
            
            }
            
        }
    }
    cout << "No"<<endl;
    
}
int main(){
	ios_base::sync_with_stdio(false); 
     	cin.tie(NULL);
	int t=1;;

	while(t--)
	solve();	
	
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    String S,T;
    int cnt = 0;
    std::cin >> S >> T;
    
    for(int i=0;i<S.length();i++){
        if(S[i]!=T[i]) cnt++;
    }

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 3916
import fractions
n=int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

count=0
for i in range(n):
  count+=(ans//a[i])
print(count%(10**9+7))
  


Measured memory_bytes: 6200
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  
	int n, q;

	cin >> n >> q;
	string s;
	cin >> s;
	vector<char> t(q);
	vector<char> d(q);
	for (int i = 0; i < q; ++i) {
		cin >> t[i] >> d[i];
	}

	reverse(t.begin(), t.end());
	reverse(d.begin(), d.end());

	int right_limit = -1;	// from left
	int left_limit = n;		// from right
	for (int i = 0; i < (int)t.size(); ++i) {
		if (right_limit >= n - 1) {
			break;
		}
		if (left_limit < 0) {
			break;
		}
		if (left_limit <=  right_limit) {
			break;
		}
		if (d[i] == 'L') {
			if (s[right_limit + 1] == t[i]) {
				++right_limit;
			}
			if (left_limit < n && s[left_limit] == t[i]) {
				++left_limit;
			}
		}
		if (d[i] == 'R') {
			if (right_limit >= 0 && s[right_limit] == t[i]) {
				--right_limit;
			}
			if (s[left_limit - 1] == t[i]) {
				--left_limit;
			}
		}
	}

	int alive = left_limit - right_limit - 1;
	alive = max(alive, 0);
	cout << alive << endl;

	return 0;
}

Measured memory_bytes: 900
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int n;
    cin>>n;
    cout<<24-n+24<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
		int D = sc.nextInt();
		
		int intArray[][] = new int[N][D];

		for(int i = 0 ;i < N;i++){
			for(int j = 0 ;j < D;j++){
				intArray[i][j] = sc.nextInt();
			}
		}

		int cnt = 0;
		for(int i = 0 ;i < N-1;i++){
			for(int i2 = i+1 ;i2 < N;i2++){
				int sum = 0;
				for(int j = 0 ;j < D;j++){
					sum += (int) Math.pow(Math.abs(intArray[i][j]-intArray[i2][j]),2);
				}
				int sumd = (int)Math.round(Math.sqrt(sum));
				if(sum == Math.pow(sumd, 2)) {
					cnt ++;
				}
//			String st = String.valueOf(sumd);
//			if(st.matches( "^(0|[-]?[1-9][0-9]*)$" )) {
//				cnt ++;
//			};
			}
		}

		System.out.println(cnt);

   		sc.close();
        return ;

    }
    
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,X;
  cin >> N >> X;
  vector<int> v(N);
  for (int i=0;i<N;i++){
    cin >> v[i];
  }
  sort(v.begin(),v.end());
  int ans=0;
  for (int i=0;i<N;i++){
    X-=v[i];
    ans++;
  }
  while (X>=v[0]){
    X-=v[0];
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M =[int(n) for n in input().split()]
p = {}
s = {}
for i in range(M):
    P, S = input().split()
    if S=='WA' and P not in p:
        c = s.setdefault(P, 0)
        c += 1
        s[P] = c
    else:
        if not p.setdefault(P, 0):
            p[P] = 1
for k in s:
    if k not in p:
        s[k] = 0 
print(sum(p.values()), sum(s.values()))


Measured memory_bytes: 17108
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

int main(){
    string n;
    cin >> n;

    if(n[0]=='1'){
        cout << '9';
    }else{
        cout << '1';
    }
    if(n[1]=='1'){
        cout << '9';
    }else{
        cout << '1';
    }
    if(n[2]=='1'){
        cout << '9';
    }else{
        cout << '1' ;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int diff_char(string s, int n){
	int cnt_l[26], cnt_r[26];
	for(int i=0; i<26; i++){
		cnt_l[i]=0;
		cnt_r[i]=0;
	}
	for(int i=0; i<n; i++){
		cnt_l[s[i]-'a']++;
	}
	for(int i=n; i<s.length(); i++){
		cnt_r[s[i]-'a']++;
	}
	int cnt=0;
	for(int i=0; i<26; i++){
		if(cnt_l[i]>0 && cnt_r[i]>0) cnt++;
	}
	return cnt;
}

int main(){
	int n;
	string s;
	cin >> n >> s;
	int max=0;
	for(int i=0; i<n; i++){
		int diff=diff_char(s,i);
		if(diff>max){
			max=diff;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <cassert>

int main()
{
  int n;
  scanf("%d",&n);
  std::vector<int> p3(n+1);
  p3[0]=1;
  for(int i=0;i<n;i++){
    p3[i+1]=3*p3[i];
  }
  static char T[200010];
  scanf("%s",T);
  int m=strlen(T);
  std::vector<bool> t(m);
  for(int i=0;i<m;i++){
    t[i]=(T[i]=='S');
  }
  std::vector<int> P(p3[n]),p(p3[n]);
  P[0]=0;
  std::vector<int> W(m,0);
  for(int r=0;r<n;r++){
    for(int i=0;i<p3[r+1];i++){
      p[i]=i/p3[r];
    }
    bool f=false;
    for(int j=0;j<m;j++){
      /*for(int i=0;i<p3[r+1];i++){
	printf("%d%c",p[i],i+1<p3[r+1]?' ':'\n');
	}*/
      if(t[j]){
	f=!f;
      }
      else if(!f){
	int X=-1;
	for(int x=0;x<3;x++){
	  int i=x*p3[r]+W[j];
	  if(p[i]==2){
	    X=x;
	  }
	  p[i]=(p[i]+1)%3;
	}
	assert(X!=-1);
	W[j]=X*p3[r]+W[j];
      }
      else{
	int X=-1;
	for(int x=0;x<3;x++){
	  int i=x*p3[r]+W[j];
	  if(p[i]==1){
	    X=x;
	  }
	  p[i]=(p[i]==0?2:p[i]==1?0:1);
	}
	assert(X!=-1);
	W[j]=X*p3[r]+W[j];
      }
    }
    for(int i=p3[r+1]-1;i>=0;i--){
      P[i]=P[i%p3[r]]+(f?(3-p[i])%3:p[i])*p3[r];
      //printf("%d%c",P[i],i==0?'\n':' ');
    }
  }
  for(int i=0;i<p3[n];i++){
    printf("%d%c",P[i],i+1<p3[n]?' ':'\n');
  }
  return 0;
}



Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <vector>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=200000000000005LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
struct edge{
	ll x;
	ll y;
	bool operator<(const edge& e)const{
		return x+y<e.x+e.y;
	}
	bool operator>(const edge& e)const{
		return x+y>e.x+e.y;
	}


};
struct road{ll cost;int to;};
ll l;
vector<ll> a;
ll t=0;
ll dp[5][200005]={};
int main() {
	cin>>l;
	a.resize(l+1);
	rep(i,1,l+1){
		cin>>a[i];
		t+=a[i];
	}
	rep(i,1,5){
		rep(j,0,l+1)dp[i][j]=-INF;
	}
	rep(i,1,5){
		rep(j,1,l+1){
			if(i==4){
				dp[i][j]=max(dp[i][j],dp[i][j-1]);
				dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
				dp[i][j]=max(dp[i][j],dp[i-2][j-1]);
				dp[i][j]=max(dp[i][j],dp[i-3][j-1]);
				continue;
			}
			if(i==1||i==3){
				if(a[j]==0){
					dp[i][j]=max(dp[i][j],dp[i][j-1]-2);
					dp[i][j]=max(dp[i][j],dp[i-1][j-1]-2);
					continue;
				}
				if(a[j]%2==1){
					dp[i][j]=max(dp[i][j],dp[i-1][j-1]+a[j]-1);
					dp[i][j]=max(dp[i][j],dp[i][j-1]+a[j]-1);
				}else{
					dp[i][j]=max(dp[i][j],dp[i-1][j-1]+a[j]);
					dp[i][j]=max(dp[i][j],dp[i][j-1]+a[j]);
				}
			}
			if(i==2){
				if(a[j]==0){
					dp[i][j]=max(dp[i][j],dp[i][j-1]-1);
					dp[i][j]=max(dp[i][j],dp[i-1][j-1]-1);
					continue;
				}
				if(a[j]%2==1){
					dp[i][j]=max(dp[i][j],dp[0][j-1]+a[j]);
					dp[i][j]=max(dp[i][j],dp[1][j-1]+a[j]);
					dp[i][j]=max(dp[i][j],dp[i][j-1]+a[j]);

				}else{
					dp[i][j]=max(dp[i][j],dp[0][j-1]+a[j]-1);
					dp[i][j]=max(dp[i][j],dp[1][j-1]+a[j]-1);
					dp[i][j]=max(dp[i][j],dp[i][j-1]+a[j]-1);
				}
			}

		}
	}
	ll ans=INF;
	rep(i,0,5){
		ans=min(ans,t-dp[i][l]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n;
	cin>>n;
	for(i=n;i<1000;i++){
//		cout<<i/100<<" "<<i/10%10<<" "<<i%10<<endl;
		if(i/100==i%10&&i/10%10==i%10){
			cout<<i<<endl;
			return 0;
		}
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
a, b, k = [int(_) for _ in input().split()]

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 0:
            a = a // 2
            b = b + a
        else:
            a = (a - 1) // 2
            b = b + a
    else:
        if b % 2 == 0:
            b = b // 2
            a = a + b
        else:
            b = (b - 1) // 2
            a = a + b

print(a, b)

Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
n,p=map(int,input().split())
s=input().rstrip()
if p==2:
    ans=0
    for i in range(n):
        if int(s[i])%2==0:
            ans+=i+1
elif p==5:
    ans=0
    for i in range(n):
        if int(s[i])==0 or int(s[i])==5:
            ans+=i+1
else:
    count=[0]*p
    x=0
    y=1
    count[0]=1
    for i in range(n-1,-1,-1):
        x=x+y*int(s[i])
        x=x%p
        count[x]+=1
        y=(y*10)%p
    ans=0
    for i in count:
        ans+=i*(i-1)//2
print(ans)



Measured memory_bytes: 41564
#include<stdio.h>

int a[10],b[10],x,y,i,j;

int main(){
	while(scanf("%d%d%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		x=y=0;
		for(i=0;i<4;i++){
			if(a[i]==b[i])x++;
			for(j=0;j<4;j++){
				if(i!=j && a[i]==b[j])y++;
			}
		}
		printf("%d %d\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 0
# import bisect
from collections import Counter, deque # https://note.nkmk.me/python-scipy-connected-components/
# from copy import copy, deepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())

    SS=Counter(S)

    ans=1
    for i in SS.values():
        ans*=(i+1)
    print((ans-1)%(10**9+7))

resolve()

Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (ll x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL printf("\n")
#define maxn 100007
ll n,k,q,d[maxn];
int main()
{
	IO;
	cin>>n>>k>>q;
	FOR(j,1,q)
      {
            ll x; cin>>x;
            d[x]++;
      }
      FOR(i,1,n){
      if(k+d[i]>q) cout<<"Yes";
      else cout<<"No";
      cout<<"\n";
      }
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define fs first
#define se second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int maxn=1e3+5;
const ll inf=0x3f3f3f3f;
const ll mod=1e9+7;

char s[maxn];

int main(){
	int n;
	scanf("%d",&n);
	printf("%d",3*n*n); 
	return 0;
}

Measured memory_bytes: 256
N = int(input())
kukan = [[] for _ in range(N)]
for i in range(N):
    X, Len = map(int, input().split())
    kukan[i] = [X - Len, X + Len]

kukan.sort(key=lambda x: x[1])
# kukan

p = -10 ** 9
ans = 0
for k in kukan:
    if p <= k[0]:
        # ok
        ans += 1
        p = k[1]
        pass
    else:
        # ng
        pass
print(ans)
        

Measured memory_bytes: 60320
n, m, x = [int(e) for e in input().split()]

import numpy as np
import itertools

all = np.zeros(n*(m+1)).reshape(n,m+1)

for i in range(n):
    all[i] += [int(e) for e in input().split()]

b = itertools.product([True,False],repeat=n)

dp=10**10

for i in b:
    i = np.array(i)
    if (all[i][:,1:].sum(axis = 0) >=x).all() :
        dp = min(dp,all[i][:,0].sum(axis = 0))

if dp ==10**10:
    dp = -1
print(int(dp))

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

int main(){
    
    int a, b, c;
    cin >> a >> b >> c;
    
    int n=0;
    
    for(int i = a; i <= b; ++i){
        if(c%i == 0){
            ++n;
        }
    }
    
    cout << n << endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int a[50];
int main(void){
    int n,kk,ans,rans=0;
    cin>>n>>kk;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=min(n,kk);i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=i-j;k++){
                ans=0;
                vector<int> v;
                for(int ii=0;ii<j;ii++){
                    v.push_back(a[ii]);
                    ans+=a[ii];
                }
                for(int ii=0;ii<k;ii++){
                    v.push_back(a[n-ii-1]);
                    ans+=a[n-ii-1];
                }
                sort(v.begin(),v.end());
                
                //cout<<kk<<j<<k<<endl;
                //cout<<ans;
                for(int ii=0;ii<min(j+k,kk-j-k);ii++){
                    
                    if(v[ii]<0)ans-=v[ii];
                }
                //cout<<ans<<endl;
                rans=max(rans,ans);
            }
        }
    }
    cout<<rans<<endl;
}


Measured memory_bytes: 384
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  return n**3

# main()
print(main())


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

int n, a[100009], maxn, m1 = (int)2.1e9, m2;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		maxn = max(maxn, a[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] == maxn) continue;
		int dst = abs(maxn - a[i] * 2);
		if (m1 > dst) { m1 = dst; m2 = a[i]; }
	}
	cout << maxn << " " << m2 << endl;
	return 0;
}

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

		int N = sc.nextInt();
		long[] T = new long[N];
		for( int i=0; i<N; i++ ){
			T[i] = sc.nextLong();
		}
		Arrays.sort(T);
		long ans = T[N-1];
		for( int i=0; i<N; i++ ){
			for( int j=1; j<=T[i]; j++ ){
				if( (ans*j)%T[i]==0 ){
					ans = ans*j;
					break;
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
    bool flag=false;
    cin >> S;
    for(int i = 0; i < S.length(); i++){
        for(int k = 0; k < S.length(); k++){
            if(i==k) continue;
            if(S[i]==S[k]) flag=true;
        }
    }
    if(flag){
        cout << "no" << "\n";
    }else{
        cout << "yes" << "\n";
    }
}


Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)

# キュー
queue = []

# 総合時間
t_time = 0

# 答えのハッシュ
ans = {}

n.times do
  queue << gets.split
end

# 配列の文字数字だけ数字に直す
queue = queue.map{|a,b|[a,b.to_i]}

# 名前の配列を作る
queue.each do |que|
  ans[que[0]] = 0
end

# キューが空になるまで無限ループ！！
while true
  
  # キューから先頭を取り出しクアンタム時間(q)を引く
  a = queue.shift
  a[1] -= q

  if a[1] > 0
    # 処理時間が残っていればキューの最後に追加、総合時間も追加
    t_time += q
    queue << a
  else
    # 処理時間が残っていなければクアンタム時間と処理時間を足して（-だと-２つになって+になるので×)総合時間に追加
    # 総合時間を作っておいたハッシュに追加
    t_time += q + a[1]
    ans[a[0]] = t_time
  end

  # キューが空ならループ終了
  break if queue.empty?
end

# ソートして出力
ans.sort_by{|a,b| b }.each{|an| puts an.join(" ")}


Measured memory_bytes: 26016
i = list(map(int, input().split()))
if i[1]%2 == 1 or i[1] == 0:
  print('No')
  exit()

x = 1/2*(i[1]-2*i[0])
y = i[0] - x

if 0 <= x <= i[0] and x.is_integer():
  if 0 <= y <= i[0] and y.is_integer():
    print('Yes')
else:
  print('No')

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  int a=s.size(),b=t.size();
  if(a>b){
    cout << "GREATER";
  }else if(a<b){
    cout << "LESS";
  }else{
    if(s>t){
      cout << "GREATER";
    }else if(s<t){
      cout << "LESS";
    }else{
      cout << "EQUAL";
    }
  }
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ull n,a,b;
    cin>>n>>a>>b;
    ull s=n%(a+b);
    ull r=((n-s)/(a+b))*a;
    r+=(s<=a?s:a);
    cout<<r<<'\n';
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
c = Counter(s)
m = 0
for v in c.values():
	m = max(m, v)
ans = []
for k, v in c.items():
	if v == m:
		ans.append(k)
ans.sort()
print(*ans, sep="\n")


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

int enc(char c){
    if('2' <= c && c <= '9')    return c-'0';
    if(c == 'T')    return 10;
    if(c == 'J')    return 11;
    if(c == 'Q')    return 12;
    if(c == 'K')    return 13;
    if(c == 'A')    return 14;
    return 0;   // unreachable
}

int main(){
    char c;
    while(cin >> c, c != '#'){
        int trick[2] = {};
        vector<vector<string>> v(4, vector<string>(13));
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 13; j++){
                cin >> v[i][j];
            }
        }
        int lead = 1;
        for(int j = 0; j < 13; j++){
            vector<pair<int,int>> game;
            for(int i = 0; i < 4; i++){
                int score = enc(v[i][j][0]);
                if(v[i][j][1] == v[lead][j][1]) score += 50;
                if(v[i][j][1] == c) score += 100;
                game.push_back({-score, i});
            }
            sort(game.begin(), game.end());
            trick[game[0].second%2]++;
            lead = game[0].second;
        }
        if(trick[0] > trick[1]){
            cout << "NS " << trick[0]-6 << endl;
        }else{
            cout << "EW " << trick[1]-6 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 

int compute(vector<int> &check,vector<int> &v)
{
  const int N = 1e6+10;
  int ans = 0;
  sort(v.begin(),v.end());
  vector<int> counter(N);
  set<int> done;
  for(int i=0;i<v.size();i++)
  {
    if(!counter[v[i]] && check[v[i]] == 1) 
    {
      ans++;
    }
    if(!done.count(v[i]))
    {
      done.insert(v[i]);
      for(int j=v[i];j<N;j+=v[i])
      {
        counter[j] += 1;
      }
    }
  }
  return ans;
}

int main()
{
  __;
  vector<int> check(1e6+10);
  int n;
  cin >> n;
  vector<int> v;
  for(int i=0;i<n;i++)
  {
    int a;
    cin >> a;
    v.pu(a);
    check[a]++;
  }
  
  cout << compute(check,v) << endl;
  return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI h(n);
	rep(i, n) cin >>h[i];
	rep2(i, 1, n){
		if(h[i-1] < h[i]) h[i]--;
	}
	bool ok=true;
	rep(i,  n-1){
		if(h[i] > h[i+1]) ok=false;
	}
	puts(ok? "Yes":"No");
	return 0;
	
}


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

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    for(int i = 0; i < s.length(); ++i){
        mp[s[i]]++;
    }
    for(auto x : mp){
        if(x.second % 2){
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long

string S;
int N, L, ans = 0;
int taste[220];
pair<int, int> tastea[220];

int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++) {
		taste[i] = L + i;
		ans += taste[i];
		tastea[i] = make_pair(abs(taste[i]), i);
	}
	sort(tastea, tastea + N);
	cout << ans - taste[tastea[0].second] << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int y=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		PriorityQueue<St> q=new PriorityQueue<>((t,r)->(r.var-t.var));
		for(int i=0; i<a; i++){
			q.add(new St(sc.nextInt(),0));
		}
		for(int i=0; i<b; i++){
			q.add(new St(sc.nextInt(),1));
		}
		for(int i=0; i<c; i++){
			q.add(new St(sc.nextInt(),2));
		}
		long ans=0;
		long sum=0;
		while(!q.isEmpty()){
			St s=q.poll();
			if(s.idx==0){
				if(x==0){
					continue;
				}
				x--;
			}else if(s.idx==1){
				if(y==0){
					continue;
				}
				y--;
			}else{
				if(sum==x+y){
					break;
				}
				sum++;
			}
			ans+=s.var;
			if(sum==x+y){
				break;
			}
		}
		System.out.println(ans);
	}
	static class St{
		int var,idx;
		St(int var,int idx){
			this.var=var;
			this.idx=idx;
		}
	}
}


Measured memory_bytes: 103400
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define BIG 1000000000
#define BIGNUM 100000
#define SIZE 1000
using namespace std;

int timer = 0;

typedef struct process {
	string name;
	int time;
	process(char* n, int t) { name = n; time = t; };
	void show();
};
void process::show() {
	cout << name << ' ' << timer<<'\n';
}

int main() {
	queue<process> queue;
	int n, q;
	scanf("%d %d", &n, &q);
	
	char name[15];
	int time;
	for (int i = 0; i < n; i++) {
		cin >> name >> time;
		process tmp(name, time);
		queue.push(tmp);
	}
	
	while (!queue.empty()) {
		process proc = queue.front();
		if (proc.time <= q) {
			timer += proc.time;
			proc.show();
			queue.pop();
		}
		else {
			proc.time -= q;
			timer += q;
			queue.pop();
			queue.push(proc);
		}
	}
}

Measured memory_bytes: 6372