akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n, C;
    cin >> n >> C;

    vector<ll> s(n), t(n), c(n);
    rep(i, n) cin >> s[i] >> t[i] >> c[i];
    
    vector<ll> S(n), T(n);
    rep(i, n) {
        S[i] = s[i] * 2 - 1;
        T[i] = t[i] * 2;
    }

    ll maxT = *max_element(all(T));
     
    vector<vector<ll>> d(C + 1, vector<ll>(maxT + 1));
    rep (i, n) {
        d[c[i]][S[i]]++;
        d[c[i]][T[i]]--;
    }

    rep (ch, C + 1) {
        repi(i, d[ch].size()) {
            d[ch][i] = d[ch][i-1] + d[ch][i];
        }
    }

    ll res = 0;
    rep(i, d[0].size()) {
        ll v = 0;
        rep (ch, C + 1) {
            if (d[ch][i] > 0) v++;
        }
        res = max(res, v);
    }

    put(res);
}
signed main(){ Main();return 0;}

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

#define INF 1234567890
#define ll long long

int N, M;

int main()
{
	scanf("%d %d", &N, &M);
	vector<ll> A(N), B(M), C;
	for(int i=0; i<N; i++)
		scanf("%lld", &A[i]);
	for(int i=0; i<M; i++)
		scanf("%lld", &B[i]);
	C = convolution(A, B);
	for(int i=0; i<C.size(); i++)
		printf("%lld ", C[i]);
	return 0;
}

Measured memory_bytes: 27256
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
    int n, m;
    
    scanf("%d %d", &n, &m);
    
    if (n > m) swap(n, m);
    
    if (n == 1) {
        if (m == 1) {
            puts("1");
        } else {
            printf("%d\n", m - 2);
        }
    } else {
        printf("%lld\n", (long long)(n - 2) * (m - 2));
    }
    
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)


n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))


for i in range(n):
    if a[i] % 2 == 1:
        print("first")
        exit()
print("second")


Measured memory_bytes: 51288
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Inf 0x3f3f3f3f


int main()
{
	ll a,b,c,k;//a:1;b:0;c:-1
	cin>>a>>b>>c>>k;
	ll count=0;
	if(k<=a)
	{
		count=k;
	}
	else
	{
		if(k<=a+b)
		  count=a;
		else
		count=a-1*(k-(a+b));
	}
    cout<<count<<endl;
	return 0;
}


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

int main(){
    int H, W; cin >> H >> W;
    //vector<string> pic(H);
    string s;
    for (int i=0; i<H; i++){
        //cin >> pic.at(i);
        cin >> s;
        for (int j=0; j<2; j++){
            cout << s << endl;
        }
    }
    return 0;
}

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

    {
        cout<<"Rainy";
    }
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

	private static long[] dp;
	private static long[] answer;
	private static List<Integer>[] g;
	private static int m;

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		m = sc.nextInt();

		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>();
		}

		for (int i = 0; i < n - 1; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			g[x].add(y);
			g[y].add(x);
		}

		dp = new long[n];
		answer = new long[n];
		dfs1(0, -1);
		dfs2(0, -1);

		StringBuilder sb = new StringBuilder();
		for (int v = 0; v < n; v++) {
			sb.append(answer[v]).append("\n");
		}

		System.out.print(sb.toString());
	}

	private static void dfs1(int v, int p) {
		dp[v] = 1;
		for (int to : g[v]) {
			if (to == p) continue;
			dfs1(to, v);
			dp[v] = (dp[v] * (dp[to] + 1)) % m;
		}
	}

	private static void dfs2(int v, int p) {
		List<Long> lm = new ArrayList<>();
		List<Long> rm = new ArrayList<>();
		lm.add(1L);
		rm.add(1L);
		for (int i = 0; i < g[v].size(); i++) {
			long last = lm.get(lm.size() - 1);
			lm.add(last * (1 + dp[g[v].get(i)]) % m);
		}

		for (int i = g[v].size() - 1; i >= 0; i--) {
			long last = rm.get((rm.size() - 1));
			rm.add(last * (1 + dp[g[v].get(i)]) % m);
		}

		answer[v] = rm.get(rm.size() - 1);
		for (int i = 0; i < g[v].size(); i++) {
			if (g[v].get(i) == p) continue;
			long t1 = dp[v];
			long t2 = dp[g[v].get(i)];
			long a = lm.get(i) * rm.get(rm.size() - 1 - i - 1) % m;
			dp[v] = a;
			dp[g[v].get(i)] = dp[g[v].get(i)] * (dp[v] + 1) % m;
			dfs2(g[v].get(i), v);
			dp[v] = t1;
			dp[g[v].get(i)] = t2;
		}
	}
}


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


int main(){
    int n;
	cin >> n;
	double ans=0.0;
	for(int i=0; i<n; i++){
		double tmp;
		cin >> tmp;
		ans += 1.0/tmp;
	}
	ans = 1/ans;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

n, = I()
l = []
for i in range(n):
    l.append(I()[0])
l.sort()
print(sum(l) - l[-1]//2)

Measured memory_bytes: 3064
while(True):
    # n:#ofShelf, m:#ofBook
    n, m = map(int, input().split(' '))
    if n == 0:
        break
    widths = [int(input()) for i in range(m)]
    minwid = max(widths)
    maxwid = sum(widths)

    def packable():
        bookQ = widths.copy()
        nShelf = 1
        sumBook = 0
        while len(bookQ) != 0 and nShelf <= n:
            if sumBook + bookQ[0] <= guess:
                sumBook += bookQ.pop(0)
            else:
                nShelf += 1
                sumBook = bookQ.pop(0)
        return len(bookQ) == 0 and nShelf <= n

    # Try packing
    while minwid != maxwid:
        guess = (maxwid+minwid)//2
        if packable():
            maxwid = guess
        else:
            minwid = guess + 1
    print(minwid)


Measured memory_bytes: 5604
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    que=deque()
    for _ in range(n):
        oa=input().split()
        o=oa[0]
        if o=="insert":
            que.appendleft(oa[1])
        elif o=="delete":
            a=oa[1]
            if a in que:
                que.remove(a)
        elif o=="deleteFirst":
            que.popleft()
        else:
            que.pop()
    print(*que)

main()



Measured memory_bytes: 69744
# ABC134-C

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()
  l1=[I() for _ in range(n)]

  l2=copy.deepcopy(l1)
  l2.sort(reverse=True)

  a=l2[0]
  b=l2[1]

  for x in l1:
    if x==a:
      print(b)
    else:
      print(a)

main()
# print(main())


Measured memory_bytes: 16692
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
string L;
ll ans;

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

int main(void)
{
	cin >> L;
	ll num = 0;
	for (int i = 0; i < L.length(); i++)
	{
		if (L[i] == '1')
		{
			(ans += po(3, L.length() - i - 1) * po(2, num) % mod) %= mod;
			num++;
		}
	}
	(ans += po(2, num)) %= mod;
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int e;
    cin>>e;
    if(!e)break;
    int m=1000000;
    for(int z=0;z*z*z <= e;++z)
      for(int y=0;y*y+z*z*z<=e;++y){
        int x = e-y*y-z*z*z;
        m=min(m,x+y+z);
      }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    long[] a = new long[n];
    long sum = 1;
    long lastSum = 1;
    boolean over = false;
    String[] str = in.readLine().split(" ");
    for(int i = 0; i < n; i++){
      a[i] = Long.parseLong(str[i]);
      if(a[i]==0) {
        System.out.println(0);
        return;
      }
      sum *= a[i];
      if(lastSum > sum || sum > 1000000000000000000L) {
        over = true;
      }
      lastSum = sum;
    }
    System.out.println(over?-1:sum);
  }
}

Measured memory_bytes: 50236
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define sll set<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define fo(i,n) for(i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define sc(n) scanf(" %lld",&n)
#define sci(n) scanf(" %d",&n)
#define srt(v) sort(v.begin().v.end())
using namespace std;

ll a[301][301],d[315][315],p[5005];
map<pair<ll,ll>,ll> ma;

ll findS(ll i)
{
    if(p[i]==i)
        return i;
    return p[i]=findS(p[i]);
}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0);
    #ifdef UJJWAL_HOME
        freopen("000.txt","r",stdin);
    #endif // UJJWAL_HOME

    ll i,j,k,n,t;

    cin>>n;

    priority_queue<pair<ll,pair<ll,ll> >,vector<pair<ll,pair<ll,ll> > >,greater<pair<ll,pair<ll,ll> > > > pq;

    fo(i,n)
    {
        fo(j,n)
        {
            cin>>a[i][j];
            if(i<j)
                pq.push(mp(a[i][j],mp(i,j)));
        }
    }

    fo(i,n+5)
    {
        fo(j,n+5)
            d[i][j]=1000000000000000000;
        d[i][i]=0;
    }

    ll a1,a2,a3,ia1,ia2;

    vll v[505];
    fo(i,505)
    {
        p[i]=i;
    }
    while(!pq.empty())
    {
        a1=pq.top().first;
        a2=pq.top().second.first;
        a3=pq.top().second.second;
        pq.pop();

        //cout<<a2<<" "<<a3<<" "<<d[a2][a3]<<endl;
        if(d[a2][a3]<a1)
        {
            cout<<-1;
            return 0;
        }
        else if(d[a2][a3]>a1)
        {
            d[a2][a3]=a1;
            d[a3][a2]=a1;
            v[a2].pb(a3);
            v[a3].pb(a2);
            fo(j,n)
            {
                fo(k,n)
                {
                    if(d[j][k]>a1+d[j][a2]+d[k][a3])
                        d[j][k]=d[k][j]=a1+d[j][a2]+d[k][a3];
                }
            }
        }
    }

    ll ans=0;
    fo(i,n)
    {
        fo(j,v[i].size())
        {
            //cout<<i<<" "<<v[i][j]<<" "<<d[v[i][j]][i]<<endl;
            ans+=d[v[i][j]][i];
        }
    }

    cout<<ans/2;

    return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main()
{
	int n,pre,cnt=0;
	cin >> n >> pre;

	REP(i,n-1) {
		int target;
		cin >> target;
		if (pre == target) {
			cnt++;
			pre = n + 1;
		} else {
			pre = target;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) ((a) < (b) CSS ? (b) : (a))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;



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

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



int main() {
	int i, j, k;
	//ll N, M, K;
	int N, M, K;
	cin >> N >> M;
	int A[3] = { -1,-1,-1 };
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--;
		if (A[a] != -1 && A[a] != b) {
			cout << -1;
			return 0;
		}
		A[a] = b;
	}
	if (A[0] == 0 && N!=1) {
		cout << -1;
		return 0;
	}
	
	if (A[0] == -1) {
		if (N == 1) {
			cout << 0;
			return 0;
		}

		A[0] = 1;
    }
		cout << A[0];

	rep(i, 1, N) {
		if (A[i] == -1) {
			A[i] = 0;
		}
		cout << A[i];
	}
	return 0;


}


Measured memory_bytes: 256
def II(): return int(input())
def LI(): return list(map(int, input().split()))
N=II()
A=LI()
A.sort(reverse=True)
start=A[0]
if N%2==0:
  mid=sum(A[1:(N+1)//2])*2
else:
  mid=sum(A[1:(N-1)//2]*2)+A[(N-1)//2]
ans=start+mid
#print(start,mid)
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    int A, B;
    cin >> A >> B;
    int k = A + B;
    if(k % 2 == 0){
        cout << abs(k / 2)<< endl;
        k /= 2;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    long long int a,b,c,d,i,j,k,l;
    cin>>a;
    int a1[a+1];
    int a2[a+1];
    for(i=1;i<=a;i++)
    {

     cin>>a1[i];
     a2[a1[i]]=i;
    }
    for(i=1;i<=a;i++)
        cout<<a2[i]<<" ";
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int n, k; cin >> n >> k;
    vector<ll> V(n, 0);
    for(int i = 0; i < n; ++i) cin >> V.at(i);

    ll ans = 0;
    for(int left = 0; left <= min(n, k); ++left) {
        // cout << left << endl;
        // 左からleft個取得する
        priority_queue< ll, vector<ll>, greater<ll> > ansque;
        for(int i = 0; i < left; ++i) ansque.push(V.at(i));
        // cout << "ok" << endl;

        for(int right = 0; right+left <= min(n, k); ++right) {
            // cout << right << endl;
            priority_queue< ll, vector<ll>, greater<ll> > rightque;
            rightque = ansque;
            for(int j = 0; j < right; ++j) rightque.push(V.at(n-1-j));
            
            int gomi = k-(right+left);
            for(int j = 0; j < min(right+left, gomi); ++j) {
                ll now = rightque.top();
                if(now < 0) rightque.pop();
                else break;
            }

            ll sum = 0;
            while(!rightque.empty()) {
                sum += rightque.top();
                rightque.pop();
            }
            chmax(ans, sum);
        }
    }
    cout << ans << endl;
}

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


int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  int x=a*b,i=a;
  string ans="NO";
  while(i<=x){
    if(i%b==c){ans="YES";break;}
    i+=a;
  }
  cout<<ans<<endl;





  return 0;
}


Measured memory_bytes: 256
import math
monsterNum, centerDamage, otherDamage = map(int, input().split())
monsterHitpoint = [0] * monsterNum
maxHitpoint = 0

def enough(times):
  result = True
  damageCount = 0
  hitpoint = [monsterHitpoint[i] - otherDamage * times for i in range(monsterNum)]
  for i in range(monsterNum):
    if hitpoint[i] > 0:
      damageCount += math.ceil(hitpoint[i] / (centerDamage - otherDamage))
    if damageCount > times:
      result = False
      break
  return result
  
for i in range(monsterNum):
  monsterHitpoint[i] = int(input())
  if maxHitpoint < monsterHitpoint[i]:
    maxHitpoint = monsterHitpoint[i]
#2分探索
low, high = 0, math.ceil(maxHitpoint / otherDamage)
while low <= high:
  minTimes = (low + high) // 2
  checkEnough = enough(minTimes)
  if checkEnough and not(enough(minTimes - 1)):
    break
  elif checkEnough:
    high = minTimes - 1
  elif not checkEnough and (enough(minTimes + 1)):
    minTimes += 1
    break
  elif not checkEnough:
    low = minTimes + 1
print(minTimes)

Measured memory_bytes: 12688
"""
lazyseg使う方法とかもあるが、imos法使うのが簡単そう。
座標圧縮は必須。
"""
from math import ceil
N,D,A = map(int,input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort()

coordinates = set()
for x,h in XH:
    coordinates.add(x)
    coordinates.add(x+2*D+1)

compress = {x:i for i,x in enumerate(sorted(coordinates))}

imos = [0]*(len(compress))
damage = 0
cur = 0
ans = 0
for x,h in XH:
    compX = compress[x]
    while cur <= compX:
        damage += imos[cur]
        cur += 1
    rest = h-damage
    if rest > 0:
        add = A*ceil(rest/A)
        ans += int(ceil(rest/A))
        imos[cur] += add
        right = compress[x+2*D+1]
        imos[right] -= add
print(ans)

Measured memory_bytes: 224032
#include<stdio.h>
#include<math.h>

int prime(int a){
	int i,flag=1;
	
	if(a==2 ) return 1;
	if(a%2 == 0) return 0;
	for(i=3;i<=sqrt(a);i+=2){
		if(a%i==0) flag=0;
		
		if(flag==0) break;
	}
	return (flag);
}

int main (void){
	
	int i,j,count=0,n;
	
	for(;;){
	scanf("%d",&n);
	
	if(n==0) break;
	
	count=0;
	for(i=2;i<=n/2;i++){
		if(prime(i)==1 && prime(n-i)==1){
			count++;
		}
	}
	
	printf("%d\n",count);
	}

return 0;
}

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

using P = pair<int, int>;

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

int H, W;
char grid[55][55];
bool used[55][55];
int dist[55][55];
int cnt = 0;

int bfs() {
    queue<P> next;
    next.push(P(1, 1));
    used[1][1] = true;
    dist[0][0] = 0;

    while (!next.empty()) {
        P cur = next.front();
        next.pop();

        for (int i = 0; i < 4; i++) {
            int ny = cur.first + dy[i];
            int nx = cur.second + dx[i];
            if (!used[ny][nx] && grid[ny][nx] == '.') {
                next.push(P(ny, nx));
                used[ny][nx] = true;
                dist[ny][nx] = dist[cur.first][cur.second] + 1;
            }
            if (ny == H && nx == W) {
                return cnt - dist[cur.first][cur.second] - 2;
            }
        }
    }
    return -1;
}

int main() {
    cin >> H >> W;
    fill(grid[0], grid[54], '#');
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            cin >> grid[i][j];
        }
    }

    // 白マスの数を数える
    for (int i = 1; i < H + 1; i++) {
        for (int j = 1; j < W + 1; j++) {
            if (grid[i][j] == '.') cnt++;
        }
    }

    cout << bfs() << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > vp;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    vp.push_back(make_pair(A, 1));
  }
  for (int i = 0; i < M; ++i) {
    int B, C;
    cin >> B >> C;
    vp.push_back(make_pair(C, B));
  }
  sort(vp.begin(), vp.end());
  reverse(vp.begin(), vp.end());

  long long total = 0;
  int count = 0;
  for (size_t i = 0; i < vp.size(); ++i) {
    pair<int, int> p = vp[i];
    int v = p.first;
    int c = p.second;
    if (count + c <= N) {
      total += (long long)(v) * (long long)(c);
      count += c;
    }
    else {
      total += (long long)(v) * (long long)(N - count);
      break;
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <map>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <cmath>
#include <queue>
#include <ctime>
#include <utility> // std::pair
#include <functional> // std::greater <int> ()
#define int long long
#define inf 1000000000000000001
#define BASE 29 // hashings mod, can be rand'd
#define mod 998244353 // can be 1000000007
#define pi 3.1415926535897
#define pii pair <int, int>
#define fii first
#define see second

typedef long long ll;
typedef long double ld;
using namespace std;

int n;
int h[100005];
int ans=0, cur, cnt=0;

// functions
void input(){
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> h[i];
	}
	return;
}

void solve(){
	cur=h[1];
	for(int i=2; i<=n; i++){
		if(h[i]>cur){
			ans=max(ans, cnt);
			cnt=0;
		}
		else{
			cnt++;
		}
		cur=h[i];
	}
	ans=max(ans, cnt);
	cout << ans;
	return;
}

void output(){
	return;
}

signed main(){
/*
//  REMEMBER TO TURN OFF IFDEF IN PROBLEMS WITH FILE I/O
*/
//#ifdef sheeep
//	freopen("forces.inp", "r", stdin);
//	freopen("forces.out", "w", stdout);
//#endif
	ios_base::sync_with_stdio(false);
//	int t;
//	cin >> t;
//	for(int i=1; i<=t; i++){
		input();
		solve();
		output();
//	}
	return 0;
}
// Author: NamSPro

Measured memory_bytes: 1024
/*
[abc133] F - Colorful Tree
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MAX_Q = 1e5;

const int MAX_V = MAX_N;
const int MAX_LOG_V = 18;

struct edge {
    int d;
    int c;
    int to;
};

int N, Q;
vector<edge> g[MAX_N];
vector<int> req[MAX_N];
int X[MAX_Q], Y[MAX_Q], U[MAX_Q], V[MAX_Q];
int W[MAX_Q];
int dist[MAX_N];
int cur_num[MAX_N], cur_sum[MAX_N];
unordered_map<int, int> num[MAX_N], sum[MAX_N];

int par[MAX_LOG_V][MAX_V];
int dep[MAX_V];

void dfs(int v, int p = -1, int d = 0) {
    par[0][v] = p;
    dep[v] = d;
    for (auto& e : g[v]) {
        if (e.to == p) {
            continue;
        }
        dfs(e.to, v, d + 1);
    }
}

int lca(int u, int v) {
    if (dep[u] > dep[v]) {
        swap(u, v);
    }
    for (int k = 0; k < MAX_LOG_V; k++) {
        if (((dep[v] - dep[u]) >> k) & 1) {
            v = par[k][v];
        }
    }
    if (u == v) {
        return u;
    }
    for (int k = MAX_LOG_V - 1; k >= 0; k--) {
        if (par[k][u] != par[k][v]) {
            u = par[k][u];
            v = par[k][v];
        }
    }
    return par[0][u];
}

void init() {
    dfs(0);
    for (int k = 1; k < MAX_LOG_V; k++) {
        for (int v = 0; v < N; v++) {
            par[k][v] = (par[k - 1][v] < 0) ? -1 : par[k - 1][par[k - 1][v]];
        }
    }
}

void dfs2(int v, int par = -1) {
    for (int c : req[v]) {
        num[v][c] = cur_num[c];
        sum[v][c] = cur_sum[c];
    }

    for (auto& e : g[v]) {
        if (e.to == par) {
            continue;
        }
        dist[e.to] = dist[v] + e.d;
        cur_num[e.c]++;
        cur_sum[e.c] += e.d;
        dfs2(e.to, v);
        cur_num[e.c]--;
        cur_sum[e.c] -= e.d;
    }
}

int calc(int v, int x, int y) { return dist[v] - sum[v][x] + y * num[v][x]; }

void solve() {
    init();
    for (int i = 0; i < Q; i++) {
        W[i] = lca(U[i], V[i]);
        req[U[i]].push_back(X[i]);
        req[V[i]].push_back(X[i]);
        req[W[i]].push_back(X[i]);
    }

    dfs2(0);

    for (int i = 0; i < Q; i++) {
        int ans = calc(U[i], X[i], Y[i]) + calc(V[i], X[i], Y[i]) -
                  2 * calc(W[i], X[i], Y[i]);
        cout << ans << endl;
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 0; i < N - 1; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--;
        g[a].push_back((edge){d, c, b});
        g[b].push_back((edge){d, c, a});
    }
    for (int i = 0; i < Q; i++) {
        cin >> X[i] >> Y[i] >> U[i] >> V[i];
        X[i]--, U[i]--, V[i]--;
    }

    solve();

    return 0;
}


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

int main(){

    int x,y,z,ans;
    cin >> x >> y >> z;
    int n = 1;
    ans = 0;
    while(ans <= x){
        ans = y*n+z*(n+1);
        if(ans > x){
            break;
        }
        n++;
    }

    cout << n-1 << endl;
    
    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> x(n);
  int sum = 0;
  rep(i, n) {
    cin >> x[i];
    sum += x[i];
  }
  int ans = 0, ans2 = 0;
  rep(i, n) {
    int a = abs(sum / n - x[i]);
    int b = abs(sum / n - x[i] + 1);
    ans += a * a;
    ans2 += b * b;
  }
  cout << min(ans, ans2);
  return 0;
}

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

#define NIL -1000000000

struct xyz {
  int x,y,z;
  bool operator<(const xyz& a) const {
    return z > a.z;
  }
};

int G[51][51];
bool F[51][51],used[51][51];
int w,d,n;
int dx[]={1,0,0,-1},dy[]={0,1,-1,0};

bool bfs(xyz s) {
  G[s.x][s.y]=s.z;
  queue<xyz> q;
  q.push(s);
  while(!q.empty()) {
    xyz v=q.front(); q.pop();
    used[v.x][v.y]=true;
    for(int i=0;i<4;++i) {
      int nx=v.x+dx[i],ny=v.y+dy[i];
      if(nx<=0||ny<=0||nx>w||ny>d) continue;
      if(used[nx][ny]) continue;
      if(F[nx][ny]) {
        if(abs(G[nx][ny]-v.z)>=2) return false;
        else continue;
      }
      if(G[nx][ny]>v.z+1) return false;
      else if(G[nx][ny]>=v.z-1) continue;
      else G[nx][ny]=v.z-1;
      q.push({nx,ny,G[nx][ny]});
      //cout << G[nx][ny] << endl;
    }
  }
  return true;
}

signed main() {
  cin >> w >> d >> n;
  for(int i=1;i<=w;++i)
    for(int j=1;j<=d;++j)
      G[i][j]=NIL;
  vector<xyz> in(n);
  for(auto&a:in) cin >> a.x >> a.y >> a.z;
  sort(in.begin(),in.end());
  for(int i=0;i<n;++i) {
    memset(used,false,sizeof(used));
    F[in[i].x][in[i].y]=true;
    if(!bfs(in[i])) {
      cout << "No" << endl;
      //break;
      return 0;
    }
  }

  int ans=0;
  for(int i=1;i<=w;++i)
    for(int j=1;j<=d;++j)
      ans+=G[i][j];
  cout << ans << endl;

  /*
  cout << endl;
  for(int j=1;j<=d;++j) {
    for(int i=1;i<=w;++i) {
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
  */


  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define REPR(i, m, n) for (int i = (int)(m); i >= (int)(n); i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
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;

int q;
int dp[1100][1100];

int main(){
  cin >> q;
  rep(k, q){
    string x, y;
    cin >> x >> y;
    int n = x.size();
    int m = y.size();

    memset(dp, 0, sizeof(dp));
    rep(i, n){
      rep(j, m){
        if(x[i] == y[j]) chmax(dp[i+1][j+1], dp[i][j]+1);
        else{
          chmax(dp[i+1][j+1], dp[i][j+1]);
          chmax(dp[i+1][j+1], dp[i+1][j]);
        }
      }
    }

    cout << dp[n][m] << endl;
  }

  return 0;
}





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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  ll n,m;cin>>n>>m;
  ll minx=llINF,maxx=-llINF,miny=llINF,maxy=-llINF;
  ll x[n+10]={};
  ll y[m+10]={};
  ll rui[m+10]={};
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<m;i++){
    cin>>y[i];
    if(i!=0)
      rui[i]=rui[i-1]+y[i]-y[i-1];
  }
  ll ans=0;
  ll sum=0;
 
  int now=m-1;
  int kake=m-2;
  for(int i=1;i<=m/2;i++){
    sum=(sum+(((y[i]-y[i-1])%MOD)*(m-i)%MOD)*i%MOD)%MOD;
    now=(now+kake)%MOD;
    kake--;
  }
  for(int i=m-1;i>m/2;i--){
    sum=(sum+(((y[i]-y[i-1])%MOD)*i%MOD)*(m-i)%MOD)%MOD;
   now=(now+kake)%MOD;
    kake--;
  }
  now=n-1;
  kake=n-2;
  for(int i=1;i<=n/2;i++){
    ans=(ans+((((x[i]-x[i-1])*sum%MOD)*(n-i)%MOD)*i%MOD)%MOD)%MOD;
   now=(now+kake)%MOD;
    kake--;
  }
  now=n-1;
  kake=n-2;
  for(int i=n-1;i>n/2;i--){
    ans=(ans+((((x[i]-x[i-1])*sum%MOD)*i%MOD)*(n-i)%MOD)%MOD)%MOD;
   now=(now+kake)%MOD;
    kake--;
  }
  cout<<ans<<endl;
  return 0;
}


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


int main(){
int N;
cin >> N;
vector<ll>a(N);
REP(i, N) cin >> a.at(i);
 
ll four = 0, odd = 0;
// ll two = 0;
 
REP(i, N){
	if(a.at(i) % 4 == 0 ) four++;
	// else if(a.at(i) % 4 != 0 && a.at(i) % 2 == 0) two++;
	else if(a.at(i) % 2 == 1) odd++;
}
// print(odd);
// print(four);
 
if(odd == 0) yes;
else if(four >= odd) yes;
else if(a.size() % 2 == 1 && four >= odd - 1) yes;
else no;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin>>N>>K;
  vector<int> vec(N, 0);
  for(int i=0; i<N; i++){
    cin>>vec.at(i);
  }
  int ans=0;
  for(int i=0; i<N; i++){
    if(vec.at(i)<K-vec.at(i)){
      ans+=2*vec.at(i);
    }
    else{
      ans+=2*(K-vec.at(i));
    }

  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    rep(_,k){
        if(*min_element(ALL(a))==n){
            rep(i,n) cout<<n<<(i+1==n?"\n":" ");
            return 0;
        }

        vector<int> imos(n+1,0),b(n);

        rep(i,n){
            imos[max(0,i-a[i])]++;
            imos[min(n,i+a[i]+1)]--;
        }

        int p=0;
        rep(i,n){
            p+=imos[i];
            b[i]=p;
        }
        swap(a,b);
    }
    rep(i,n) cout<<a[i]<<(i+1==n?"\n":" ");
    return 0;
}


Measured memory_bytes: 5576
# -*- coding: utf-8 -*-

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]

    def same(self, x, y):
        return self.root(x)==self.root(y)

    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x==y:
            return

        if self.par[x]>self.par[y]:
            x,y = y,x

        self.par[x] += self.par[y]
        self.par[y] = x

    def size(self,x):
        return -self.par[self.root(x)]

n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ab.reverse()
uf = UnionFind(n)
res = []
cur = n*(n-1)//2
for a,b in ab:
    res.append(cur)
    a -= 1
    b -= 1
    if uf.same(a,b):
        continue

    sa = uf.size(a)
    sb = uf.size(b)
    cur -= sa*sb
    uf.unite(a,b)

res.reverse()
for r in res:
    print(r)


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  ll Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  ll ans = 0;
  vector<ll> v = {8*Q,4*H,2*S,D};
  ll mi2 = 1000000000000;//2リットルあたりの値段が最も低いもの
  rep(i,4){
    mi2 = min(mi2,v[i]);
  }
  
  vector<ll> v2 = {4*Q,2*H,S};
  ll mi1 =1000000000000;//1リットルあたり最も安いもの
  rep(i,3){
    mi1 = min(mi1,v2[i]);
  }
//cout << mi2 << " " << mi1 << endl;
  if(N%2){
    //N-1リットルを2リットルあたりの値段が最も低いもので買う
    ans += (N-1)/2 * mi2;
    //残り1リットルを1リットルあたり最も安いもので買う
    ans += mi1;
  }
  else{
    //Nリットルを2リットルあたりの値段が最も低いもので買う
    ans = N/2 * mi2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;
const string d="dream";
const string e="erase";

int main() {
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i!=3) cout<<s[i];
    else cout<<"8";
  }
  cout<<endl;
}


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

int main(){
  
  int i,j,k,A[N],v,n;
  
  scanf("%d",&n);
  if(n<1 || n>100){
    exit(1);
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]<0 || A[i]>1000){
      exit(1);
    }
  }

  for(i=0;i<n;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    
    A[j+1]=v;

    for(k=0;k<n;k++){
      printf("%d",A[k]);
      if(k==n-1) break;
      printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
// https://atcoder.jp/contests/agc025/tasks/agc025_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

const int MOD = 998244353;

template <int N, typename T, T M> struct factorial_mod {
    T mod[N + 1];
    T inv_mod[N + 1];

    constexpr factorial_mod() : mod(), inv_mod() {
        mod[0] = 1;
        for (int i = 0; i < N; ++i) {
            mod[i + 1] = (mod[i] * (i + 1)) % M;
        }
        inv_mod[N] = power(mod[N], M - 2);
        for (int i = N - 1; i >= 0; --i) {
            inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
        }
    }

    constexpr T power(T a, T b) {
        T r = 1;
        while (b > 0) {
            if ((b & 1) != 0)
                r = (r * a) % M;
            a = (a * a) % M;
            b >>= 1;
        }
        return r;
    }

    constexpr T comb(T n, T r) {
        return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
    }
};
factorial_mod<300000, long long, MOD> facmod;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b, k, ans = 0;
    cin >> n >> a >> b >> k;
    for (int i = 0, j = n; i <= n && i * a <= k; i++) {
        while (i * a + j * b > k)
            j--;
        if (i * a + j * b == k)
            ans = (ans + facmod.comb(n, i) * facmod.comb(n, j)) % MOD;
    }
    cout << ans << endl;

    return 0;
}


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

std::string replace_with_str (std::string str, std::string str_from, std::string str_to) {
    std::string::size_type pos = 0;
    while (pos = str.find(str_from, pos), pos != std::string::npos) {
        str.replace(pos, str_from.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(void) {
    std::string T;
    std::cin >> T;

    std::string T2 = replace_with_str(T, "?", "D");
    
    std::cout << T2 << std::endl;
    // CGTCAACGTAACCTGC
    
    return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  string a = "CODEFESTIVAL2016";
  int ans = 0;
  rep(i,sz(s)) {
    if(a[i] != s[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<math.h>

using namespace std;

using ll = long long;

#define rep(i, n) for (ll i = 0; i < n; i++)

const ll INF = 1LL << 60;

typedef pair<ll, double> P;

bool pairCompare(const P & firstElof, const P & secondElof)
{
	return firstElof.second < secondElof.second;
}


signed main() {

	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;

	if (u == s)a--;
	if (u == t)b--;
	cout << a << endl << b;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		HashMap<Integer, Integer> kamikire = new HashMap<Integer, Integer>();

		for (int i = 0; i < N; i++) {
			Integer A = sc.nextInt();
			if (!kamikire.containsKey(A)) {
				kamikire.put(A, 1);
			} else {
				Integer value = kamikire.get(A);

				kamikire.put(A, ++value);
			}
		}
		int counter = 0;
		for (Integer key : kamikire.keySet()) {
			Integer value = kamikire.get(key);
			if (value % 2 != 0) {
				counter++;
			}
		}
		System.out.println(counter);
	}
}


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

typedef long long int ll;
ll a, b, c, d;

int main() {
    cin >> a >> b >> c >> d;
    while(a > 0 && c > 0) {
        a -= d;
        c -= b;
    }

    if(a <= 0 && c <= 0) cout << "Yes" << endl;
    else if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<n[k-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n;
  int min = 1000000, max = -1000000;
  long sum = 0;
  int i;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    int temp;
    scanf("%d", &temp);
    if(temp < min){
      min = temp;
    }
    if(temp > max){
      max = temp;
    }
    sum += temp;
  }

  printf("%d %d %ld\n", min, max, sum);

  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	int con = 0;
	
	cin>>N;
	
	for(int i = 2; i * i <= N; i++){
		if(N%i == 0) {
			if(i * i == N) {
				{
					int n = N, j = i;
					
					while(n%j == 0){
						n /= j;
					}
					if(n%j == 1) con++;
				}
			} else {
				{
					int n = N, j = i;
					
					while(n%j == 0){
						n /= j;
					}
					if(n%j == 1) con++;
				}
				
				{
					int n = N, j = N/i;
					
					while(n%j == 0){
						n /= j;
					}
					if(n%j == 1) con++;
				}
			}
		}
		
		
	}
	
	
	for(int i = 1; i * i <= N-1; i++){
		if((N-1)%i == 0) {
			con++;
			if(i * i != N-1) con++;
		}
	}
	cout<<con<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    string n;
    cin >> n;
    rep(i, 0, (sz(n))/2)
        if (n[i] != n[sz(n) - i - 1])
        {
            cout << "No" << endl;
            return 0;
        }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256