akhauriyash/Code-Regression huggingface dataset:
n, q, *S = open(0).read().split()
q = int(q)
J = list(zip(*[iter(S)]*2))
T = 0
while J:
    n, t = J.pop(0)
    t = int(t)
    if t <= q:
        T += t
        print(f'{n} {T}')
    else:
        T += q
        J.append((n, t-q))



Measured memory_bytes: 12928
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) {
	try {
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
			String input;
			input = buf.readLine();
			
			String[] strAry = input.split(" ");
		       int x = Integer.parseInt(strAry[0]);
		       int y = Integer.parseInt(strAry[1]);
		       int z = Integer.parseInt(strAry[2]);
		       
		     if(x > y){
		    	int a = x;
		    	int b = y;
		    	x = b;
		    	y = a; 
		     }
		     if(y > z){
			    	int b = y;
			    	int c = z;
			    	y = c;
			    	z = b;
		     }
		     if(x >  y){
		    	int a = x;
		    	int b = y;
		    	x = b;
		    	y = a; 
		     }  

		     System.out.println(x + " " + y + " " + z);
		     
	} catch (Exception e) {
		// TODO: handle exception
	}
}

}

Measured memory_bytes: 24392
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;
const int N=5e5+9;

ll to[N<<1],nxt[N<<1],beg[N],tot;
ll n,m,c[N],w[N<<1];
ll ans,f[4],flag;

inline void add(int u,int v,int c)
{
    to[++tot]=v;
    nxt[tot]=beg[u];
    w[tot]=c;
    beg[u]=tot;
}

inline void dfs(int u)
{
    f[c[u]]++;
    for(int i=beg[u];i;i=nxt[i])
    {
        if(w[i]==1)f[3]++;
        if(!(~c[to[i]]))
        {
            c[to[i]]=(c[u]+w[i])%3;
            dfs(to[i]);
        }
        else if (c[to[i]]!=(c[u]+w[i])%3)
            flag=1;
    }
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1,u,v;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        add(u,v,1);add(v,u,2);
    }

    memset(c,-1,sizeof(c));
    for(int i=1;i<=n;i++)
        if(!(~c[i]))
        {
            f[c[i]=0]=f[1]=f[2]=f[3]=flag=0;
            dfs(i);
            if(flag)
            {
                ll cnt=f[0]+f[1]+f[2];
                ans+=cnt*cnt;
                goto nxt;
            }
            if((!f[0]) || (!f[1]) || (!f[2]))
            {
                ans+=f[3];
                goto nxt;
            }

            ans+=f[0]*f[1];
            ans+=f[1]*f[2];
            ans+=f[2]*f[0];

            nxt:;
        }

    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 20096
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    S = readline().decode().rstrip()
    T = ['L' if i == 'R' else 'R' for i in S[::-1]]
    N = len(S)
    def calc(S):
        cnt = 0
        score = [0 for _ in range(N)]
        f = True
        for i in range(N):
            if S[i] == 'R':
                f = True
                cnt += 1
            else:
                if f:
                    score[i-1] = (cnt+1)//2
                    score[i] = cnt//2
                    cnt = 0
                f = False
        return score
    for i, j in zip(calc(S), calc(T)[::-1]):
        print(i+j, end=' ')
if __name__ == '__main__':
    main()

Measured memory_bytes: 6492
n, m = gets.split.map(&:to_i)
a = []
b = []
for i in 0...n do
  a[i], b[i] = gets.split.map(&:to_i)
end
c = []
d = []
for j in 0...m do
  c[j], d[j] = gets.split.map(&:to_i)
end
for i in 0...n do
  dist_min = 5 * (10 ** 8)
  dist_min_j = -1
  for j in 0...m do
    dist = (a[i] - c[j]).abs + (b[i] - d[j]).abs
    if dist_min > dist
      dist_min = dist
      dist_min_j = j
    end
  end
  puts dist_min_j + 1
end


Measured memory_bytes: 1788
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(judge(A,B)){
            System.out.println("Possible");
        }else{
            System.out.println("Impossible");
        }
    }
    static boolean judge(int A, int B){
        if(A%3==0)return true;
        if(B%3==0)return true;
        if((A+B)%3==0)return true;
        return false;
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
int l[55];
int main(){
  int N, K;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    cin >> l[i];
  }
  sort(l, l + N, greater<int>());
  int sum = 0;
  for(int i =0; i < K; i++){
    sum += l[i];
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
def main():
    n = int(input())
    b = list(map(int, input().split()))

    ans = []
    while b:
        l = len(b)
        for i in range(l)[::-1]:
            if b[i] == i + 1:
                pp = b.pop(i)
                ans.append(pp)
                break

        else:
            ans = [-1]
            break

    print(*ans[::-1], sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m;
int cnt[100010];

signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 1; i <= n; i++) {
		if (cnt[i] % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define mp make_pair
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
const ll INF = 1e18;
int cnt[N];
int bit[N];
void update(int j,int x)
{
    for(;j<N;j+=j&(-j))
        bit[j]+=x;
}
int query(int j)
{
    int x=0;
    for(;j>0;j-=(j)&(-j))
        x+=bit[j];
    return x;
}
int B;
int main()
{
    int n,m,l,r,i,j,k,a,b;
    in2(n,m);
    vector<triple> vp(n);
    rep(i,n)
    {
        in2(l,r);
        vp[i]=mt(r-l+1,l-1,r);
    }
    sort(all(vp));
    cnt[1]=n,i=0;
    lp(j,2,m+1)
    {
        while(i<n && tf(vp[i])<j)
            update(ts(vp[i])+1,1),update(tt(vp[i])+1,-1),i++;
        a=0;
        for(k=j;k<=m;k+=j)
            a+=query(k);
        cnt[j]=a+(n-i);
    }
    lp(j,1,m+1)
        out(cnt[j]);
}





Measured memory_bytes: 5248
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  long long N,D;
  cin>>N>>D;
  int answer=0;
  for(int i=0;i<N;i++){
    long long X,Y;
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D) answer++;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> p;
int main(){
	int i=2,j,k=0,o;
	for(;i<70000;i++){o=1;
		for(j=0;j<p.size();j++)o=o&(i%p[j]>0);
		if(o)p.push_back(i);
	}cin>>i;
	while(i--){
		long long x;cin>>x;x=x*2+1;o=1;
		for(j=0;j<p.size();j++)o=x>p[j]?o&(x%p[j]>0):o;
		k+=o;
	}cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 3212
n = int(input())
_max = 0
out = 1
for i in range(1, n + 1):
    count = 0
    _i = i
    while _i > 0 and _i % 2 == 0:
        count += 1
        _i = _i // 2
    if count > _max:
        out = i
        _max = max(_max, count)
print(out)


Measured memory_bytes: 2940
import numpy as np
n = int(input())

factor_a = 0
for i in range(1, int(np.sqrt(n)) + 1):
    if n % i == 0:
       factor_a = i
       
factor_b = n // factor_a

#print(factor_a)
#print(num, factor_b)
print(factor_a - 1 + factor_b - 1)


Measured memory_bytes: 17984
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int 
#define pb push_back 
#define mp make_pair 
#define pii pair <int , int > 
#define pll pair < ll , ll >
int main(){
	ios_base::sync_with_stdio(false) ;
	cin.tie(NULL) ;
	int n , d ;
	cin >> n >> d ;
	int arr[n][d] ;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < d ; j++){
			cin >> arr[i][j] ;
		}
	}
	int ans = 0 ;
	for(int i = 0 ; i < n ; i++){
		for(int j = i + 1 ; j <n ; j++){
			int sum = 0 ;
			for(int k = 0 ; k < d ; k++){
				sum += (arr[i][k] - arr[j][k])*(arr[i][k] - arr[j][k]) ;
			}
			int a = sqrt(sum) ;
			if(a*a == sum) ans++ ;
		}
	}
	cout << ans ;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}
int dfs(int v, ll N, bool visited[nmax])
{
    bool all_visited = true;

    for (int i = 0; i < N; i++)
    {
        if (!visited[i])
        {
            all_visited = false;
        }
    }

    if (all_visited)
    {
        return 1;
    }
    int ret = 0;
    for (size_t i = 0; i < N; i++)
    {
        if (!graph[v][i])
        {
            continue;
        }
        if (visited[i])
        {
            continue;
        }

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

void solve(std::string c)
{
    if (c == "a" || c == "i" || c == "u" || c == "e" || c == "o")
    {
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
}

int main()
{
    std::string c;
    std::cin >> c;
    solve(c);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int h,w;
vector<int>x = {-1,0,1};
vector<int>y = {-1,0,1};
int cnt(int a,int b,vector<vector<char>>s){
    int ans = 0;
    rep(i,3){
        rep(j,3){
            if(a+x[i]<0||a+x[i]>h-1||b+y[j]<0||b+y[j]>w-1)continue;
            if(s[a+x[i]][b+y[j]]=='#')ans++;
        }
    }
    return ans;
}
int main(){
    
    cin >> h >> w;
    vector<vector<char>>s(h,vector<char>(w));
    rep(i,h){rep(j,w)cin >> s[i][j];}
    int ans = 0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')continue;
            char c = cnt(i,j,s)+'0';
            s[i][j] = c;
        }
    }
    rep(i,h){
        rep(j,w)cout << s[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[''.join(sorted(input())) for i in range(N)]
    C=Counter(S)
    print(sum([i*(i-1)//2 for i in C.values()]))






resolve()


Measured memory_bytes: 73816
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    vector<int> a(3);
    cin>>a[0]>>a[1]>>a[2];
    sort(a.begin(),a.end());
    cout<<a[0]+a[1]<<endl;
    return 0;


}


Measured memory_bytes: 3628
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int main(){
    string s;
    R(s);
    REP(i,SZ(s)){
        if(s[i]=='?')s[i]='D';
    }
    W(s);
    return 0;
}


Measured memory_bytes: 3752
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = sl()
    AB = ''
    BA = ''
    for _ in range(int(B)):
        AB += A
    for _ in range(int(A)):
        BA += B
    print(AB if AB < BA else BA)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      n: usize,
      xyp: [(i64, i64, i64); n]
   }

   let num = 1 << n;
   let mut tx = vec![vec![0i64; n]; num];
   let mut ty = vec![vec![0i64; n]; num];
   for s in 0..num {
      let mut xs = vec![];
      let mut ys = vec![];
      for i in 0..n {
         if (s >> i) & 1 == 1 {
            let (x, y, _) = xyp[i];
            xs.push(x);
            ys.push(y);
         }
      }
      for (i, (x, y, p)) in xyp.iter().enumerate() {
         let mut dx = x.abs();
         let mut dy = y.abs();
         for (xn, yn) in xs.iter().zip(ys.iter()) {
            dx = min(dx, (x - xn).abs());
            dy = min(dy, (y - yn).abs());
         }
         tx[s][i] = p * dx;
         ty[s][i] = p * dy;
      }
   }

   let mut ans = vec![std::i64::MAX; n + 1];
   let num: usize = (0..n).fold(1_usize, |acc, _| acc * 3);
   for _s in 0..num {
      let mut s1 = 0;
      let mut s2 = 0;
      let mut s = _s;
      let mut idx = vec![];
      for i in 0..n {
         if s % 3 == 1 {
            s1 += 1 << i;
         } else if s % 3 == 2 {
            s2 += 1 << i;
         } else {
            idx.push(i);
         }
         s /= 3;
      }
      let score = idx.iter().map(|&i| min(tx[s1][i], ty[s2][i])).sum();
      ans[n - idx.len()] = min(ans[n - idx.len()], score);
   }
   for a in ans {
      println!("{}", a);
   }
}


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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int q = sc.nextInt();
		PriorityQueue<Pair> pq = new PriorityQueue<Pair>();
		HashMap<Integer, Pair> map = new HashMap<Integer, Pair>();
		StringBuilder sb = new StringBuilder();
		while (q-- > 0) {
			int num = sc.nextInt();
			int get = sc.nextInt();
			if (!map.containsKey(num)) {
				Pair p = new Pair(num, get);
				map.put(num, p);
				pq.add(p);
			} else {
				Pair del = map.get(num);
				map.remove(num);
				pq.remove(del);
				del.cnt += get;
				map.put(num, del);
				pq.add(del);
			}
			Pair max = pq.peek();
			sb.append(max.num + " " + max.cnt + "\n");
		}
		System.out.print(sb);
	}

	class Pair implements Comparable<Pair> {
		int num;
		int cnt;

		public Pair(int num, int cnt) {
			super();
			this.num = num;
			this.cnt = cnt;
		}

		@Override
		public int compareTo(Pair arg0) {
			if (this.cnt == arg0.cnt) return this.num - arg0.num;
			return arg0.cnt - this.cnt;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 105020
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int A, B;
    cin >> A >> B;

    int m = A - 2 * B > 0 ? A - 2 * B : 0;

    cout << m << endl;

    return 0;
}

Measured memory_bytes: 256
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;

    string ns = to_string(n);
    ll nd = ns.size();
    ll nf = ns.front() - '0';
    ll nb = ns.back() - '0';
    

    ll pow10[18] = {1};
    REP(i, 17) pow10[i+1] = pow10[i] * 10;

    vector<vector<ll>> p(10, vector<ll>(10, 0));
    RANGE(i, 1, n) {
        string s = to_string(i);
        p[s.front() - '0'][s.back() - '0']++;
    }

    ll ans = 0;
    RANGE(i, 1, 9) RANGE(j, 1, 9) {
        ans += p[i][j] * p[j][i];
    }
    say(ans);
    
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b,c,d; 
  scanf("%d%d",&a,&b);
  if(a < b){
    d = a;
    a = b;
    b = d;  
  } 
 while(b != 0){
    c = a%b;
    a = b;
    b = c; 
 }
  printf("%d\n",a); 
  return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, MOD = 1e9 + 7;
vector<pair<int, int>> v;

int main() {
	cin >> n;
	inc(i, 2 * n) { int a; cin >> a; v.EB(a, (i < n ? +1 : -1)); }
	
	sort(ALL(v));
	
	LL ans = 1, c = 0;
	inc(i, 2 * n) {
		if(abs(c + v[i].SE) < abs(c)) { (ans *= abs(c)) %= MOD; }
		c += v[i].SE;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2420
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from math import gcd

S = list(map(int, list(read()[:-1])))
n = len(S)
F = [0] * (n + 1)  # [i,n)までを整数として見たときの余り
for i in ra(n, 0, -1):
    F[i - 1] = (F[i] + S[i - 1] * pow(10, n - (i - 1), 2019)) % 2019
cnt = Counter(F)
ans = 0
for v in cnt.values():
    ans += v * (v - 1) // 2
# print(F)
print(ans)


Measured memory_bytes: 89520
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
int N, M, K;
int main() {
	cin >> N >> M >> K;
	bool flag = false;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (M*i + N * j - 2 * i*j == K) {
				flag = true;
			}
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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


int main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
int32_t main() {
	int n,m;
	cin>>n>>m;
	if(n%3==0 or m%3==0){
		cout<<0;
		return 0;
	}
	int ans=100000000009;
	for(int i=1;i<=n;i++){
		int a1=i*m;
		int a2=(m/2)*(n-i);
		int a3=n*m-a2-a1;
		ans=min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
	}
	swap(n,m);
	for(int i=1;i<=n;i++){
		int a1=i*m;
		int a2=(m/2)*(n-i);
		int a3=n*m-a2-a1;
		ans=min(ans,max(a1,max(a2,a3))-min(a1,min(a2,a3)));
	}
	cout<<min(ans,min(n,m));
}


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

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to;
    int cost;
};

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

int main()
{
    int M;
    cin >> M;
    cout << 48 - M << endl;
    return 0;
}











Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=200001; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

int main(){
  cominit();
  ll n,m,k;
  cin >> n >> m >> k;
  ll afmul=com(n*m-2,k-2);
  ll ans=0;
  for(int d=1;d<n;d++){
    ans+=d*(n-d)%mod*m%mod*m%mod;
    ans%=mod;
  }
  for(int d=1;d<m;d++){
    ans+=d*(m-d)%mod*n%mod*n%mod;
    ans%=mod;
  }
  ans*=afmul;
  ans%=mod;
  cout << ans << endl;
  
}

Measured memory_bytes: 4992
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[set() for _ in range(N)] # 使用している色
d=[set() for _ in range(N)] # 隣接リスト
e=[ False for _ in range(N)] #訪問ずみかどうか
f=[0]*N  #答え
for i in range(N-1):
    a[i],b[i] = map(int,input().split())
    d[a[i]-1].add(b[i]-1)
    d[b[i]-1].add(a[i]-1)

maxi=max([len(d[i]) for i in range(N-1)])
print(maxi)
#print("c:",c)
#print("d",d)
#print("e",e)

#x=0としてBFSする

v=deque([0])
e[0]=True
color=1

while v:
  p = v.popleft()
  for q in d[p]:
    if e[q]==False:
      while color in c[p]:
        color +=1
        if color>maxi:
          color=1
      c[p].add(color)
      c[q].add(color)
      f[q]=color
      e[q]=True
      v.append(q)
      
for i in range(N-1):
  print( f[b[i]-1])

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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    ll n;
    vi v;
    cin>>n;
    ll ar[2*100000+1]={0};
    long double ma=0;
    rep(i,n){
        cin>>ar[i];
        ar[i]=ar[i]-i-1;
        v.pb(ar[i]);
        ma+=(long double)ar[i]/(long double)n;
    }
    sort(all(v));
    ll nya = v[n/2];
//    cout<<ma<<endl;

    ll ans = 0;
    ll ans2 = 0;
    ll ans3 = 0;
    ll ans4 = 0;
    rep(i,n){
        ans += abs(ar[i]-(ll)ma);
        ans4 += abs(ar[i]-(ll)nya);
        ans2 += abs(ar[i]-(ll)ma-1);
        ans3 += abs(ar[i]-(ll)ma+1);
    }
    cout<<min(ans4,min(ans3,min(ans,ans2)))<<endl;
//   cout<<ans<<" "<<ans2<<" "<<ans3<<" "<<ans4;
    return 0;
}


Measured memory_bytes: 2936
n,k = map(x -> parse(Int64, x), split(readline()))

d = map(x -> parse(Int64, x), split(readline()))

while n>=1
  m = map(x -> parse(Int64, x), split(string(n),""))
  p = 0
  for i in 1:k
  	if in(d[i] , m)
      p += 1
      break
    end
  end
  if p == 0
    print(n)
    global n=0
  else
  global n += 1
  end
end


Measured memory_bytes: 149388
n = int(input())
N_str = input()
N_str = N_str.split(" ")
N = [int(s) for s in N_str]

t = []
cnt = 0  
for i in range(n-1):
    t.append(N[i] - N[i+1])
    
l=[]
cnt = 0
for j in t:

    if j >= 0:
        cnt = cnt + 1
    else:
        l.append(cnt)
        cnt = 0
l.append(cnt)
print(max(l))

Measured memory_bytes: 18604
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"10
aabbbbaaca"# => r#"5"#,

r#"5
aaaaa"# => r#"1"#,

r#"20
xxzaffeeeeddfkkkkllq"# => r#"10"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        s: chars,
    }
    let mut ans = 1;

    for i in 1..n {
        if s[i - 1] != s[i] {
            ans += 1;
        }
    }

    ans.to_string()
}

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

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


int main(){
	int A, B, C;
	cin >> A >> B >> C;

	if(A + B >= C){
		cout << "Yes" << endl;
	} else{
		cout << "No" << endl;
	}
}



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

typedef long long ll;
using namespace std;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _repi(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _repi, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

int main(){
	ll r;	cin >> r;

	cout << r*r << endl;
	return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();
    for(int i=X-K+1; i<X+K; i++){
      if(i<X+K-1){
        System.out.print(i + " ");
      }else{
        System.out.print(i);
      }
    }
  }
}

Measured memory_bytes: 22228
using System;
class Program
{
    static void Main(string[] args)
    {


        // 整数の入力
        //int a = int.Parse(Console.ReadLine());
        // スペース区切りの整数の入力
        string input = Console.ReadLine();
        

        // 文字列の入力
        //string s = Console.ReadLine();

        //積が奇数なら Odd と、 偶数なら Even と出力せよ。
        //出力
        Console.WriteLine(CountChar(input,'1').ToString());
    }

    // 文字の出現回数をカウント
    public static int CountChar(string s, char c)
    {
        return s.Length - s.Replace(c.ToString(), "").Length;
    }
}


Measured memory_bytes: 11092
//52
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

typedef complex<double> P;

double cr(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

int main(){
  for(int n;cin>>n,n;){
    double x[50],y[50];
    double r[50],m[50];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>r[i]>>m[i];
    }
    int mc=0;
    for(int i=0;i<n;i++){
      for(int j=0;j<i;j++){
	double xx=x[j]-x[i];
	double yy=y[j]-y[i];
	for(int k=0;k<2;k++){
	  double r1=k?r[i]+m[i]:r[i];
	  for(int l=0;l<2;l++){
	    double r2=l?r[j]+m[j]:r[j];
	    P p[2];
	    for(int s=-1;s<=1;s+=2){
	      for(int rs=-1;rs<=1;rs+=2){
		double rts=r2*rs;
		double is=sqrt(xx*xx+yy*yy-(r1+rts)*(r1+rts)+1e-9);
		double xf=r1*(xx*(r1+rts)+s*yy*is)/(xx*xx+yy*yy);
		double yf=r1*(yy*(r1+rts)-s*xx*is)/(xx*xx+yy*yy);
		for(int v=0;v<2;v++){
		  if(fabs(yf)>fabs(xf)||1){
		    p[v]=P(v+x[i],(r1*r1-xf*v)/yf+y[i]);
		  }else{
		    p[v]=P((r1*r1-yf*v)/xf+x[i],v+y[i]);
		  }
		}
		int c=0;
		for(int i=0;i<n;i++){
		  P jw=P(x[i],y[i]);
		  double ds=fabs(cr(p[1]-p[0],jw-p[0]))/abs(p[1]-p[0]);
		  /*
		  cout<<xx*xx+yy*yy-(r1+r2)*(r1+r2)<<' '<<xf<<' '<<yf<<' ';
		  cout<<i<<':'<<r[i]<<' '<<ds<<' '<<r[i]+m[i]<<endl;
		  */
		  c+=r[i]-1e-5<ds&&ds<r[i]+m[i]+1e-5;
		}
		if(mc<c){
		  mc=c;
		}
	      }
	    }
	  }
	}
      }
    }
    cout<<(n>1?mc:1)<<endl;
  }
  return 0;
}
		     
	    

Measured memory_bytes: 1248
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

//vector<int> prod_perm(const vector<int>&a, const vector<int> &b) {
//	//bに置換aを実行して返す。
//	//すなわち、[0..N]→a になるような置換"→"によって、
//	//b→ansとなるようなansを求めて返す。
//
//	assert(a.size() == b.size());
//
//	vector<int>ans(b.size());
//	rep(i, b.size())ans[i] = b[a[i]];
//	return ans;
//}
//
//vector<int> pow_perm(const vector<int>&perm, const int K) {
//	//置換permのK乗を返す。
//
//	if (K == 0) {
//		vector<int>ans(K - 1);
//		rep(i, ans.size())ans[i] = i;
//		return ans;
//	}
//	if (K == 1)return perm;
//
//	vector<int>half = pow_perm(perm, K / 2);
//
//	if (K % 2 == 0)return prod_perm(half, half);
//	else return prod_perm(prod_perm(half, half), perm);
//}
vector<int64_t> prod_permutation(vector<int64_t> v, vector<int64_t> w) {//v○wの計算(先にwで置換、その後vで置換)
	if (v.size() != w.size()) {
		cout << "error" << endl;
		return v;
	}
	else {
		vector<int64_t> ret;
		for (int i = 0; i<v.size(); i++) {
			ret.push_back(v[w[i]]);
		}
		return ret;
	}
}
vector<int64_t> pow_permutation(vector<int64_t> v, int64_t N) {//置換vをN乗した結果を返す。
	if (N % 2 == 0) {
		if (N == 0) {
			vector<int64_t> ret;
			for (int i = 0; i<v.size(); i++) {
				ret.push_back(i);
			}
			return ret;
		}
		else {
			vector<int64_t> ret = pow_permutation(v, N / 2);
			return prod_permutation(ret, ret);
		}
	}
	else {
		if (N == 1) {
			return v;
		}
		else {
			vector<int64_t> ret = pow_permutation(v, (N - 1) / 2);
			return prod_permutation(prod_permutation(v, ret), ret);
		}
	}
}

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

	int N, M, K;
	cin >> N;
	vector<int>x(N);
	rep(i, N)cin >> x[i];
	cin >> M >> K;
	vector<int>a(M);
	rep(i, M)cin >> a[i];

	vector<int>perm(N - 1);
	rep(i, N - 1)perm[i] = i;
	rep(i, M)swap(perm[a[i] - 2], perm[a[i] - 1]);
	auto permK = pow_permutation(perm, K);

	vector<int>dx(N - 1);
	rep(i, N - 1)dx[i] = x[i + 1] - x[i];

	int ans = x[0];
	rep(i, N - 1) {
		cout << ans << endl;
		ans += dx[permK[i]];
	}
	cout << ans << endl;


	return 0;
}

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

int main(){
    long long ans = 0;
    int n, t0, t1 ,T;

    cin >> n >> T;
    cin >> t0;
    for (int i = 2; i <= n; i++)
    {
        scanf("%d", &t1);
        ans += min(T, t1 - t0);
        t0 = t1;
    }

    ans += T;
    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N;
    int[] A;
    void Solve() {
        //input
        N = io.Int;
        A = new int[N];
        for (int i = 0; i < N; ++i)
            A[i] = io.Int;
        //cal
        var dic = new Dictionary<int,int>();
        for (int i = 0; i < N;++i){
            if (!dic.ContainsKey(A[i]))dic[A[i]] = 0;
            dic[A[i]]++;
        }
        //res
        Console.WriteLine(dic.Where(kp => kp.Value % 2 != 0).Count());
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() {
        Solve();
        io.writeFlush();
    }
}
class SimpleIO {
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 20820
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int ans = 0;
	static ArrayList<ArrayList<Integer>> g;
	static int x;

	public static void main(String[] args) throws Exception {
		while (true) {
			x = sc.nextInt();
			int y = sc.nextInt();
			if (x == 0 && y == 0) break;
			g = new ArrayList<ArrayList<Integer>>();
			for (int i = 0; i < x; ++i) {
				g.add(new ArrayList<Integer>());
			}
			for (int i = 0; i < y; ++i) {
				int f = sc.nextInt();
				int t = sc.nextInt();
				g.get(f).add(t);
				g.get(t).add(f);
			}
			ans = x;
			int[] cover = new int[x];
			dfs(0, cover, 0);
			System.out.println(ans);
		}
	}

	static void dfs(int cur, int[] cover, int use) {
		if (use >= ans) return;
		if (cur == x) {
			for (int i = 0; i < x; ++i) {
				if (cover[i] == 0) return;
			}
			ans = use;
			return;
		}
		dfs(cur + 1, cover, use);
		for (int i = 0; i < g.get(cur).size(); ++i) {
			++cover[g.get(cur).get(i)];
		}
		++cover[cur];
		dfs(cur + 1, cover, use + 1);
		--cover[cur];
		for (int i = 0; i < g.get(cur).size(); ++i) {
			--cover[g.get(cur).get(i)];
		}
	}

}

Measured memory_bytes: 12000
def floor(n)
  n |= n >> 1
  n |= n >> 2
  n |= n >> 4
  n |= n >> 8
  n |= n >> 16
  (n + 1) >> 1
end

def f(a, b)
  mask = -floor(b - a)

  c = b & mask
  if b == c
    a, b = -b, -a 
    c = b & mask
  end
  b == c ? 1 : f(a, c) + f(c, b)
end

n = STDIN.gets.to_i
n.times do
  s, d = STDIN.gets.split.map(&:to_i)
  puts f(s, d)
end

Measured memory_bytes: 8572
#include <iostream>
using namespace std; 
int a, b, c, d, x, y, z;
int main()
{
	cin >> a >> b >> c >> d;
	x = a - b;
	y = a - c;
	z = b - c;
	if(x<0) x=-x;
	if(y<0) y=-y;
	if(z<0) z=-z;
	if(y <= d) cout << "Yes";
	else if(x <= d && z <= d) cout << "Yes";
	else cout << "No";
	
	return 0;
}

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

int main() {
    int n;
    vector<long long int> V;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        V.push_back(tmp);
    }
    sort(V.begin(), V.end());
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i == 0)
            ans -= V[i];
        else if (i == n - 1)
            ans += V[i];
        else
            ans += abs(V[i]);
    }
    cout << ans << "\n";
    for (int i = 1; i < n - 1; i++) {
        if (V[i] >= 0) {
            cout << V[0] << " " << V[i] << "\n";
            V[0] -= V[i];
        }
        else {
            cout << V[n - 1] << " " << V[i] << "\n";
            V[n - 1] -= V[i];
        }
    }
    cout << V[n - 1] << " " << V[0] << "\n";
}


Measured memory_bytes: 2804