akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define INF 100000000

int cost[101][101],d[101][101];

int min(int a,int b,int c){
  if(a<b)
    if(a<c)
      return a;
    else
      return c;
  else
    if(b<c)
      return b;
    else
      return c;
}

int sum(int a,int b,int c)
{
  if(a==INF || b==INF || c==INF)
    return INF;
  return a+b+c;
}

int main()
{
  while(1){
    int n,k,type;
    int g,h,i,j;
    scanf("%d %d",&n,&k);
    if(n==0&&k==0) break;

    for(i=1; i<=n; i++) 
      for(j=1; j<=n; j++){
	cost[i][j] = ((i==j)?0:INF);
	d[i][j] = ((i==j)?0:INF);
      }

    while(k--){
      scanf("%d",&type);
      if(type==0){
	scanf("%d %d",&i,&j);

	if(d[i][j]==INF)
	  puts("-1");
	else
	  printf("%d\n",d[i][j]);
      }else{
	scanf("%d %d %d",&g,&h,&i);
	cost[g][h] = min(i,cost[g][h],INF);
	cost[h][g] = cost[g][h];

	for(i=1;i<=n;i++)
	  for(j=1;j<=n;j++)
	    d[i][j] = min(d[i][j],sum(d[i][g],cost[g][h],d[h][j]),sum(d[i][h],cost[h][g],d[g][j]));
      }
    }
  }

  return 0;
}

Measured memory_bytes: 500
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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 ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    if(s.size()%2 == 1){
        cout << "No" << endl;
        return 0;
    }
    
    bool ok = true;
    rep(i, s.size()-1){
        if(s[i] == 'h' && s[i+1] == 'i') i++;
        else ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main() {
  // ここにプログラムを追記
  string S ,T;
  cin>>S>>T;
 int N = T.size() - 1;
  char A=T.at(  N );
    string B =S + A;
    if(T ==B )
    {cout << "Yes"<<endl;
    }
  else{
    cout<< "No"<<endl;
  }
}


Measured memory_bytes: 3628
MOD = 10**9+7
N,M,K = map(int,input().split())

U = N*M
fact = [1]*(U+1)
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD

def comb(n,k):
    x = fact[n]
    x *= pow(fact[n-k],MOD-2,MOD)
    x %= MOD
    x *= pow(fact[k],MOD-2,MOD)
    return x

res = 0

for i in range(1,N):
    res += i*M*M*(N-i)%MOD
    res %= MOD

for i in range(1,M):
    res += i*N*N*(M-i)%MOD
    res %= MOD

res *= comb(N*M-2,K-2)
res %= MOD
print(res)

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

public class PaizaPj
{
    

    public static void Main()
    {
        // 読込
        string[] strs = Console.ReadLine().Trim().Split(' ');

        int K = int.Parse(strs[0]);
        int X = int.Parse(strs[1]);

        string ans = "No";
        if (500*K >= X)
        {
            ans = "Yes";
        }
        Console.WriteLine(ans);
    }



}


Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var (
		n      int
		s1, s2 string
	)
	fmt.Scan(&n, &s1, &s2)

	const mod = 1000000007
	ans := 0
	i := 0
	if s1[0] == s2[0] {
		ans += 3
		i++
	} else {
		ans += 6
		i += 2
	}
	for i < n {
		if s1[i] == s2[i] {
			if s1[i-1] == s2[i-1] {
				ans *= 2
				ans %= mod
			}
			i++
		} else {
			if s1[i-1] == s2[i-1] {
				ans *= 2
				ans %= mod
			} else {
				ans *= 3
				ans %= mod
			}
			i += 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s;
    cin >> s;
    int s1, s2, s3, s4;

    s1 = s[0] - '0';
    s2 = s[1] - '0';
    s3 = s[2] - '0';
    s4 = s[3] - '0';
    int n = 1000 * s1 + 100 * s2 + 10 * s3 + s4;

    int n1 = n / 100, n2 = n % 100;

    if ((n1 > 12 && n2 > 12) || (n1 == 0 && n2 == 0) || (n1 > 12 && n2 == 0) || (n1 == 0 && n2 > 12)) {
        cout << "NA" << endl;
        exit(0);
    }
    else if (n1 > 0 && n2 > 0 && n1 <= 12 && n2 <= 12) {
        cout << "AMBIGUOUS" << endl;
        exit(0);
    }
    else if (n1 > 0 && n1 <= 12) {
        cout << "MMYY" << endl;
    }
    else if (n2 > 0 && n2 <= 12) {
        cout << "YYMM" << endl;
    }
    else {
        cout << "NA" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long x;
	cin>>x;
	for(long long i=1;i<=x;i++){
		if(i*(i+1)/2==x){
			cout<<i<<endl;
			break;
		}else if(x>i*(i-1)/2 && x<i*(i+1)/2){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int p, q, r;
    cin >> p >> q >> r;

    cout << min(p + q, min(q + r, r + p)) << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
using namespace std;
    
ll min1[1000001], min2[1000001], adds[1000001],n,q,pre;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
il void down(int nw) 
{
    if (!adds[nw])return;
    adds[ls(nw)] += adds[nw];
    adds[rs(nw)] += adds[nw];
    min1[ls(nw)] += adds[nw];
    min2[ls(nw)] += adds[nw];
    min1[rs(nw)] += adds[nw];
    min2[rs(nw)] += adds[nw];
    adds[nw] = 0;
}
void setpt(int l, int r, int nw, int pt, ll num) 
{
    if (l == r) 
	{
        min1[nw] = min(min1[nw], num - l);
        min2[nw] = min(min2[nw], num + l);
        return;
    }
    int mid = (l + r) >> 1;down(nw);
    if (pt <= mid)setpt(l, mid, ls(nw), pt, num);
    else setpt(mid + 1, r, rs(nw), pt, num);
    min1[nw] = min(min1[ls(nw)], min1[rs(nw)]);
    min2[nw] = min(min2[ls(nw)], min2[rs(nw)]);
}
ll query1(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (min1[nw]);
    int mid = (l + r) >> 1;down(nw);
    if (rl > mid)return (query1(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query1(rl, rr, l, mid, ls(nw)));
    return (min(query1(rl, mid, l, mid, ls(nw)), query1(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query2(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (min2[nw]);
    int mid = (l + r) >> 1;down(nw);
    if (rl > mid)return (query2(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query2(rl, rr, l, mid, ls(nw)));
    return (min(query2(rl, mid, l, mid, ls(nw)), query2(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query(int l, int r, int nw) 
{
    if (l == r)return (min1[nw] + l);
    int mid = (l + r) >> 1;down(nw);return (min(query(l, mid, ls(nw)), query(mid + 1, r, rs(nw))));
}
signed main() 
{
//	freopen("2558.in","r",stdin);
    n = read(), q = read(), pre = read();memset(min1, 63, sizeof(min1));memset(min2, 63, sizeof(min2));setpt(1, n, 1, read(), 0);
    for (register int i = 1; i <= q; i++) 
	{
        int nw = read();
        ll cjr = min(query1(1, nw, 1, n, 1) + nw, query2(nw, n, 1, n, 1) - nw);
        adds[1] += abs(nw - pre);
        min1[1] += abs(nw - pre);
        min2[1] += abs(nw - pre);
        setpt(1, n, 1, pre, cjr);
        pre=nw;
    }
    printf("%lld\n",query(1,n,1));
    return (0);
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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 P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint res(1e4+1,0);

    for(int x=1; x*x<n; x++){
        for(int y=1; y*y<n; y++){
            for(int z=1; z*z<n; z++){
                if(x*x+y*y+z*z+x*y+y*z+z*x<=n) res[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }
    range(i,1,n+1) cout<<res[i]<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s1, s2, s3;

int main() {
    cin >> s1 >> s2 >> s3;
    cout << char(toupper(s1[0])) << char(toupper(s2[0])) << char(toupper(s3[0])) << endl;
    return 0;
}


Measured memory_bytes: 3660
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
using namespace std;
typedef long long int ll; typedef pair <double, double> P;
const int INF = 1000000000; const double EPS = 10e-9;
const double g = 9.8;
int n, v, X, Y;
struct block {
	int l, b, r, t;
	block(int L, int B, int R, int T)
	{
		l = L; b = B; r = R; t = T;
	}
	block() {};
};
block bl[50];
double calc(double vy, double t)
{
	return vy * t - g * t * t / 2;
}
int comp(double lb, double rb, double a)
{
	return lb + EPS > a ? -1 : rb - EPS < a ? 1 : 0;
}
bool check(int x, int y)
{
	double a = g * g / 4, b = g * y - v * v, c = x * x + y * y;
	double D = b * b - 4 * a * c;
	if (D > -EPS && D < 0) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2)
	{
		double t2 = (-b + d * sqrt(D)) / (2 * a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = x / t;
		double vy = sqrt(v * v - vx * vx);
		double loc = calc(vy, X / vx);
		if (loc < Y - EPS) continue;
		bool res = true;
		for (int i = 0; i < n; i++)
		{
			if (bl[i].l >= X) continue;
			if( X == bl[i].r && loc >= bl[i].b  && bl[i].t  >= Y) res = false;
			//if (!(bl[i].l <= X && X <= bl[i].r && loc >= bl[i].b - EPS && bl[i].t + EPS >= Y)) res = false;
			int lh = comp(bl[i].b, bl[i].t, calc(vy, bl[i].l / vx));
			int rh = comp(bl[i].b, bl[i].t, calc(vy, bl[i].r / vx));
			int mw = comp(bl[i].l, bl[i].r, vx* vy / g);
			int mh = comp(bl[i].b, bl[i].t, calc(vy, vy / g));
			if (lh * rh <= 0) res = false;
			if (mw == 0 && lh < 0 && mh >= 0) res = false;
		}
		if (res) return res;
	}
	return false;
}
int main() 
{
	cin >> n >> v >> X >> Y;
	for (int i = 0; i < n; i++)
	{
		int l, b, r, t; cin >> l >> b >> r >> t;
		r = min(r, X);
		bl[i] = block(l, b, r, t);
	}
	bool res = check(X, Y);
	for (int i = 0; i < n; i++)
	{
		res |= check(bl[i].l, bl[i].t);
		res |= check(bl[i].r, bl[i].t);
	}
	puts(res ? "Yes" : "No");
	return 0;
}

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

const int MAX_N = 2e5+10;
int N;
int a[MAX_N];

void solve()
{
	map<int,int> cnt;
	for(int i=1;i<=N;++i) cnt[a[i]]++;
	ll tot = 0;
	for(auto p : cnt) tot += 1LL*(p.second)*(p.second-1)/2;
	for(int i=1;i<=N;++i){
		cout<<tot-(cnt[a[i]]-1)<<'\n';
	}
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i) cin >> a[i];
	solve();
	return 0;
}

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

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int H = 0;
        int W = 0;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            while (st.hasMoreTokens()) {
                H = Integer.parseInt(st.nextToken());
                W = Integer.parseInt(st.nextToken());
                for (int i = 1; i <= H; i++) {
                    for (int j = 1; j <= W; j++) {
                        if ((i+j) % 2== 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    }
                    System.out.println();
                }
                if (H == 0 && W == 0) {
                    break;
                }
                System.out.println("");

            }
            if (H == 0 && W == 0) {
                break;
            }
        }
    }

}



Measured memory_bytes: 33540
//Created Time:Tue 03 Dec 2019 03:49:01 PM CST
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#define N 100005

using namespace std;

int n;
int f[N];

vector < int > G[N];

void dfs(int);
bool cmp(int ,int);

int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; ++i){
		int x; scanf("%d", &x);
		G[x].push_back(i);
	}
	dfs(1); cout << f[1] << endl;
	return 0;
}

bool cmp(int x, int y){
	return f[x] < f[y];
}

void dfs(int u){
	int sz = G[u].size();
	for(int i = 0; i < sz; ++i)
		dfs(G[u][i]);
	sort(G[u].begin(), G[u].end(), cmp);
	for(int i = 0; i < sz; ++i)
		f[u] = max(f[u], f[G[u][i]]) + 1;
	return ;
}


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



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n;
    cin>>n;
    ll a[n];
    ll ans =0 ;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(i && a[i] <= a[i-1]) ans++;
    }
    ans++;
    cout << ans << endl;
    cout << n << endl;
}



Measured memory_bytes: 3924
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = Counter(A)
    # print(l)
    Q = int(input())
    ans = sum(A)
    
    for i in range(Q):
        B, C = map(int, input().split())
        tmp = l[B]
        l[C]+=tmp
        l[B] = 0
        ans += (C-B)*tmp
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23988
import sys
input = sys.stdin.buffer.readline

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 10 ** 9 + 7
INF = 10 ** 18


A, B, N = map(int, input().split())

def f(x):
    return (A * x) // B - A * (x // B)
    
#for x in range(1, N + 1):
#    print(f(x))
    
if N >= B - 1:
    print(f(B - 1))
else:
    print(f(N))

Measured memory_bytes: 65264
N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
def fp(i):
    global Parent
    if Parent[i] == i:
        return i
    else:
        Parent[i] = fp(Parent[i])
        return Parent[i]

for _ in range(M):
    a, b = (int(x) for x in input().split())
    par_a, par_b = fp(a-1), fp(b-1)
    if par_a < par_b:
        Parent[par_b] = par_a
    else:
        Parent[par_a] = par_b

Groupsize = collections.defaultdict(lambda:0)
for i in range(N):
    i = fp(i)
    Groupsize[i] +=1
ans = max(gs for gs in Groupsize.values())
print(ans)

Measured memory_bytes: 38036
import itertools
from itertools import accumulate

q=int(input())
x=[list(map(int, input().split())) for i in range(q)]
s=[0]*(1+10**5)
#素数のリスト
n = 10**5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

primes.sort()
for i in range(len(primes)):
    if primes[i]>5*10**4:
        break
    primes.append(2*primes[i])

primes.sort()
count=0
for i in range(len(primes)-1):
    if primes[i+1]-primes[i]==1 and primes[i+1]%2==0:
        s[primes[i]]=1
s=itertools.accumulate(s)
s=list(s)
a=0
b=0
for i in range(q):
    print(s[x[i][1]]-s[x[i][0]-1])
    
            
        
        
    
    
    
    
    
    
    
    
    
        


    

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=998244353;
ll INF=100000000000001;
vector<ll> value; // ノードの値を持つ配列
ll N;             // 葉の数
 
void update(ll i, ll x) {
    // i 番目の葉の値を x に変える
    i += N - 1; // i 番目の葉のノード番号
    value[i] = x;
    while (i > 0) {
        i = (i - 1) / 2; // ノード i の親ノードの番号に変える
        value[i] = min(value[i * 2 + 1],
                       value[i * 2 + 2]); // 左右の子の min を計算しなおす
    }
}
 
ll query(ll a, ll b, ll k, ll l, ll r) {
    // [a, b) の区間に対するクエリについて
    // ノード k （区間 [l, r) 担当）が答える
    if (r <= a || b <= l) return INF; // 区間が被らない場合は INF を返す
    if (a <= l && r <= b)
        return value[k]; // ノード k の担当範囲がクエリ区間 [a, b)
                         // に完全に含まれる
    else {
        ll c1 = query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子に値を聞く
        ll c2 = query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子に値を聞く
        return min(c1, c2); // 左右の子の値の min を取る
    }
}
signed main(){
    llin(n);
    FOR(i,1,n){
        if((i*108)/100==n){
            sal(i);
            return 0;
        }
    }
    sal(":(");
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N)
    cin >> L[i];
  //

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

  long long ans = 0;
  for(int i=0; i<N-2; i++){
    for(int j=i+1; j<N-1; j++){
      int sum = L[i] + L[j];
      int right = upper_bound(L.begin()+j, L.end(), sum-1) - L.begin();
      ans += (right-1 - j);
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  string S;
  cin >> S;
  int a,b;
  for(int i=0;i<S.size();i++){
    a=(int)S.at(i)+N;
    
  if(a>=91){
    cout<<(char)(a-26);}
    else{cout <<(char)a;}
  }cout << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int N; cin >> N;
  int X[N], M[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &X[i]); M[i] = X[i];
  }
  sort(M, M + N);
  int m1 = M[N / 2 - 1], m2 = M[N / 2];
  for (int i = 0; i < N; i++){
    if (X[i] <= m1) printf("%d\n", m2);
    else printf("%d\n", m1);
  }

  return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long n, b, sumNum = 0, maxNum = -100000000, minNum = 1000000000;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> b;
        sumNum += b;
        if (b > maxNum) maxNum = b;
        if (minNum > b) minNum = b;
    }
    cout << minNum << " " << maxNum << " " << sumNum << endl;
}


Measured memory_bytes: 3088
#include <iostream>
using namespace std;
int main() {
    int i,j,k;
    long n, s=1, M=1e9+7, a[1001]={0};
	cin>>n;
	for(i=2;i<=n;i++){
	    k=i;
	    for(j=2;k>1;){
	        if(k%j==0){
	            a[j]++;
	            k/=j;
	        }
	        else
	            j++;
	    }
	}
	for(auto x:a)
	    s = s*(x+1)%M;
	cout<<s;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, v, m, x, y, p, q, k, W;
string s, t, s0, s1, s2;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	cout<<(ll)(n + n*n + n*n*n);
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int amari = N % 10;
  if(amari == 2 || amari == 4 || amari == 5 || amari == 7 || amari == 9){
    cout << "hon" << endl;    
  } else if (amari == 0 || amari == 1 || amari == 6 || amari == 8){
    cout << "pon" << endl;
  } else if (amari == 3){
    cout << "bon" << endl;
  }  
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	cin >> N;

	vector<Int> H(N);
	for (Int i = 0; i < N; i++) {
		cin >> H[i];
	}

	Int temp = H[0];
	Int cnt=0;
	vector<Int> ans;
	for (Int i = 1; i < N; i++) {
		if (H[i] <= temp) {
			temp = H[i];
			cnt++;
		}
		else {
			ans.push_back(cnt);
			cnt = 0;
			temp = H[i];
		}
	}
	ans.push_back(cnt);

	Int a = *max_element(ans.begin(), ans.end());

	cout << a << endl;


}

Measured memory_bytes: 2168
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [x1, x2, y1, y2] = input[0].split(' ').map(x => parseInt(x))
  const x = y1 - x1
  const y = y2 - x2

  console.log(y1 - y, y2 + x, x1 - y, x2 + x)
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29876
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

ll combination(ll n,ll k){//組み合わせ
  ll ans = 1;
  if (k == 1){
    return n / k;
  }
  ans = n * combination(n-1, k-1) / k;
  return ans;
}

int main(){
  int n;
  cin >> n;
  map<int, int> m;
  vi vec(n);
  rep(i,n){
    int j;
    cin >> j;
    m[j]++;
    vec.at(i) = j;
  }
  // for (auto p : m){
  //   if (p.second == 1){
  //     m.erase(p.first);
  //   }
  // }
  // for (auto p : m){
  //   printf("%d %d\n", p.first, p.second);
  // }

  ll cnt = 0;
  for (auto p : m){
    cnt += combination(p.second, 2);
  }
  // cout << cnt << endl;

  rep(i,n){
    ll ans = cnt + (combination(m[vec.at(i)]-1, 2) - combination(m[vec.at(i)], 2));
    cout << ans << endl;
  }
  return 0;
}


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

int maxDistance(int *a,size_t n){
  int min,i,d;
  min=a[0];
  d=a[1]-a[0];
  for (i=1;i<n;i++){
    if (a[i]<min)min=a[i];
    else if (a[i]-min>d)d=a[i]-min;
  }
  return d;
}

int main(){
  int a[5],k,i,d;
  for (i=0;i<5;i++)cin>>a[i];
  cin>>k;
  d=maxDistance(a,5);
  cout<<(d>k?":(":"Yay!")<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int p[51];
    rep(i, N) cin >> p[i];
    int cnt = 0;
    rep(i, N) if(p[i] == i + 1) cnt++;
    if(cnt >= N - 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
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;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int n, m;
        map<char, int> dx={{'N', 0}, {'E', 1}, {'W', -1}, {'S', 0}};
        map<char, int> dy={{'N', 1}, {'E', 0}, {'W', 0}, {'S', -1}};
        while(scanf("%d", &n) && n){
                set<pii> S;
                rep(i, n){
                        int x, y;
                        scanf("%d%d", &x, &y);
                        S.emplace(x, y);
                }
                int tx=10, ty=10;
                scanf("%d", &m);
                rep(i, m){
                        char c;
                        int d;
                        scanf(" %c %d", &c, &d);
                        rep(j, d){
                                tx+=dx[c];
                                ty+=dy[c];
                                S.erase({tx, ty});
                        }
                }
                printf(S.empty() ? "Yes\n" : "No\n");
        }
}


Measured memory_bytes: 3228
/*
  AtCoder Beginner Contest 106
  D - AtCoder Express 2

  方針
    クエリが大量に出る問題は全探索では無理であることが多い。
    このような場合、短時間で探索できるようなメモを生成する方法が多く取られる。
    
    今回はNxNの二次元のメモを考える。
    区間L~Rを走る各列車があった場合、座標(L, R)に1を足す。
    この操作をすべての列車に行うことでメモが完成する。

    次にクエリ(p, q)が与えられたとき、
    (p, p), (p, q), (q, p), (q, q)で作られる正方形に囲まれる列車の数が解となる。

    このとき1つのクエリに対して最大でNxNだけ探索する必要がある。
    したがって、
      メモを作る計算量はO(N^2)であり、
      各クエリに対して解を得る計算量はO(QN^2)である。

  実装
    各クエリに対して解を得る際に
      1次元累積和を用いると、計算量がO(N)
      2次元累積和を用いると、計算量がO(1)
    に減らすことができます。

    今回は2次元累積和を用いた実装をします。 
*/

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

template <typename T>
class CumulativeSum2D {
public:
  CumulativeSum2D(int N): N(N), memo(vector<vector<T>>(N+1, vector<T>(N+1, 0))) {}
  
  T operator()(int l, int r) {
    return memo[l][r];
  }

  void add(int l, int r) {
    memo[l][r] += 1;
  }

  void build() {
    for (int k = 1; k <= N; ++k) {
      for (int i = 1; k + i <= N; ++i) {
        int j = i + k;
        memo[i][j] += memo[i + 1][j] + memo[i][j - 1] - memo[i + 1][j - 1];
      }
    }
  }

private:
  int N;
  vector<vector<T>> memo;
};

int N, M, Q;
int L, R;
int p, q;

int main() {
  scanf("%d%d%d", &N, &M, &Q);
  
  CumulativeSum2D<int> cs(N);
  for (int i = 0; i < M; ++i) {
    scanf("%d%d", &L, &R);
    cs.add(L, R);
  }
  cs.build();

  for (int i = 0; i < Q; ++i) {
    scanf("%d%d", &p, &q);
    printf("%d\n", cs(p, q));
  }

  return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

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


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

int main() {
  long a,b;
  cin >> a>>b;
  
  int c=1;
  for (int i = 1; i <= 100000; i++) {
    if(a%i==0&&b%i==0){
      c=i;
    }
  }
  
  cout <<a*b/c<< endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int N;
  while (cin >> N && N){
    vector<int> L(N), T(N), R(N), B(N), X, Y;
    REP(i, N){
      cin >> L[i] >> T[i] >> R[i] >> B[i];

      for (int j = -1; j <= 1; j++){
        X.push_back(L[i] + j);
        X.push_back(R[i] + j);
        Y.push_back(T[i] + j);
        Y.push_back(B[i] + j);
      }
    }
    
    sort(ALL(X));
    X.erase(unique(ALL(X)), X.end());

    sort(ALL(Y));
    Y.erase(unique(ALL(Y)), Y.end());
    
    REP(i, N){
      L[i] = lower_bound(ALL(X), L[i]) - X.begin();
      R[i] = lower_bound(ALL(X), R[i]) - X.begin();
      
      T[i] = lower_bound(ALL(Y), T[i]) - Y.begin();
      B[i] = lower_bound(ALL(Y), B[i]) - Y.begin();
    }

    ll board[X.size()][Y.size()];
    memset(board, 0, sizeof(board));

    REP(i, N) REP2(x, L[i], R[i]) REP2(y, B[i], T[i]){
      board[x][y] |= (1LL << i);
    }

    int res = 0;
    REP(x, X.size()) REP(y, Y.size()) if (board[x][y] >= 0){
      res++;
        
      ll mask = board[x][y];
      
      typedef pair<int, int> P;

      int dx[] = {0, 1, 0, -1};
      int dy[] = {1, 0, -1, 0};
        
      queue<P> que;
      que.push(P(x, y));
        
      while (!que.empty()){
        int cx = que.front().first;
        int cy = que.front().second;
        que.pop();

        for (int i = 0; i < 4; i++){
          int nx = cx + dx[i];
          int ny = cy + dy[i];
          if (nx < 0 || (int)X.size() <= nx) continue;
          if (ny < 0 || (int)Y.size() <= ny) continue;

          if (board[nx][ny] == mask){
            board[nx][ny] = -1;
            que.push(P(nx, ny));
          }
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1944
k = int(input())

num=[1,2,3,4,5,6,7,8,9]

if k<10:
    print(num[k-1])
    exit()

ans=9

def hantei():
    global ans
    ans+=1
    if ans==k:
        print(num[-1])
        exit()

for i in range(10**10):

    hitoketa=num[0]%10

    if hitoketa==0:
        num.append(10*num[0]+0)
        hantei()
        num.append(10*num[0]+1)
        hantei()
        num.pop(0)

    elif hitoketa==9:
        num.append(10*num[0]+8)
        hantei()
        num.append(10*num[0]+9)
        hantei()
        num.pop(0)

    else:
        num.append(10*num[0]+(hitoketa-1))
        hantei()
        num.append(10*num[0]+(hitoketa))
        hantei()
        num.append(10*num[0]+(hitoketa+1))
        hantei()
        num.pop(0)

Measured memory_bytes: 73980
def main():
    N = int(input())
    ans = [0] * (N + 2)
    A = list(map(int, input().split()))
    for i in range(len(A)):
        ans[A[i] - 1] += 1
    for i in range(len(A) + 1):
        print(ans[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 33876
import Control.Monad

import Data.Ord
import Data.List
import Data.Function
import Data.Maybe

import qualified Data.ByteString.Char8 as BS

import Debug.Trace

tuplify2 :: [a] -> (a, a)
tuplify2 (x:y:_) = (x, y)
tuplify2 _ = undefined

--Input functions by ByteString
readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
  [a,p] <- getIntList
  print $ f a p

f a p = allP `div` 2
  where
    allP = p + a * 3


Measured memory_bytes: 380
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 10001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define P pair<int,int>
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
/*chrono::system_clock::time_point  start;
void timerstart(){start = chrono::system_clock::now();}
void timerend(){
	auto end = chrono::system_clock::now();
	int elapsed = chrono::duration_cast<chrono::milliseconds>(end-start).count();
	printf("%d[ms]\n", elapsed);
}*/

string s, t;
int dp[2003][2003][3];
int main(){
	int n, m;
	cin >> n >> m >> s >> t;
	s = ' ' + s +  'x';t = ' ' + t + 'x';
	
	int ans = 0;
	for(int i = 0;i <= n;i++){
		for(int j = 0;j <= m;j++){
			if(s[i+1] == 'I'){
				dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][2]+1);
			}
			if(t[j+1] == 'I'){
				dp[i][j+1][1] = max(dp[i][j+1][1], dp[i][j][2]+1);
			}
			if(s[i+1] == 'O'){
				if(dp[i][j][1] != 0)
				dp[i+1][j][2] = max(dp[i+1][j][2], dp[i][j][1]+1);
			}
			if(t[j+1] == 'O'){
				if(dp[i][j][1] != 0)
				dp[i][j+1][2] = max(dp[i][j+1][2], dp[i][j][1]+1);
			}
			ans = max(ans, dp[i][j][1]);
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 50276
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
//Global 
int n, s;
const int MAX_N = 1000;
int a[10] = { 0,1,2,3,4,5,6,7,8,9 };
int counter;


void solve(int i, int SUM, int use)
{
	if (i == 10) {
		if (SUM == s && use == n) {
			counter++;
		}
	}
	if (i <= 9) {
		solve(i + 1, SUM, use);
		solve(i + 1, SUM + a[i], use + 1);
	}
}


int main()
{
	while (true) {
		cin >> n >> s;
		if (n == 0 && s == 0) {
			break;
		}
		counter = 0;
		solve(0, 0, 0);
		cout << counter << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    if (n == 1) cout << 1 << endl;
    else {
        map<int, int> pf;
        for (int i = 2; i <= n; ++i) {
            int m = i;
            for (int j = 2; j * j <= i; ++j) {
                if (m % j != 0) continue;
                int cnt = 0;
                while (m % j == 0) { ++cnt; m /= j; }
                pf[j] += cnt;
            }
            if (1 < m) pf[m] += 1;
        }

        constexpr ll MOD = 1e9 + 7;
        ll res = 1;
        for (auto it : pf) res = (res * (it.second + 1)) % MOD;
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 256
/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
Do not pray for an easy life, pray for the strength to endure a difficult one.
When something is important enough, you do it even if the odds are not in your favor.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.
No matter how hard it gets, NEVER GIVE UP*/

#include <bits/stdc++.h>

#define pb push_back
#define MP make_pair
#define ALL(r) (r).begin(),(r).end()

typedef long long int ll;

#define FOR(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; ++i )
#define FORN(i,m,n) for(ll i=(ll)(m-1) ; i >= (ll) (n) ; --i )

#define RUN_FAST ios::sync_with_stdio(false);

using namespace std;



void solve()
{
    ll a,b,c,d,m,n,p,q,r,x,y,z,aa,bb,cc,dd; //variable
    ll i,j,k,l; //pointer
    ll cnt=0,cnt1=0,cnt2=0,cnt3=0,sum=0,mx=LLONG_MIN,mn=LLONG_MAX; //counter
    ll flag=0,flag2=0; //flag
    vector <ll> vec1,vec2,vec3;
    string s1,s2,s3;

    //PULOK SAHA
    //BMO

    cin >> n;
    s1=to_string(n);
    m=s1.size();

    FOR(i,0,m)
    {
        x=s1[i]-'0';
        sum+=x;
    }
   // cout << sum << endl;

    if(n%sum==0)
        cout << "Yes\n";
    else
        cout << "No\n";

}

int main()
{
    RUN_FAST
    //PULOK SAHA
    //BMO

    ll t=1;//test case

    //cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}






//PULOK SAHA


Measured memory_bytes: 3664
#include <stdio.h>

int main(void){
	int h,w,i,j,k,save=0,ari=0;
	scanf("%d %d",&h,&w);
	char a[h][w+1];
	int ans[h][w];
	for(i=0;i<h;i++){
		scanf("%s",a[i]);
	}
	
//	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			ans[i][j]=-1;
		}
	}
//
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='c'){
				ans[i][j]=0;
				save=0;
				ari=1;
			}
			else{
				if(ari==1){
					ans[i][j]=++save;
				}
			}
		}
		save=0;
		ari=0;
	}
	
	
	
	for(i=0;i<h;i++){
		for(j=0;j<w-1;j++){
			printf("%d ",ans[i][j]);
		}
		printf("%d\n",ans[i][j]);
	}
	return 0;
}	

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

LL cnt[10005] = {};

void prime_factorize(long long n) {
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        //res.push_back(make_pair(p, num));
        cnt[p] += num;

    }
    if (n != 1)
    {
        //res.push_back(make_pair(n, 1));
        cnt[n]++;
    }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N; cin >> N;
    for(LL i = N; i > 1; i--)
    {
        prime_factorize(i);
    }
    LL ans = 1;
    FOR(i,2,10005)
    //FOR(i,2,10)
    {
        //dump(i)
        //dump(cnt[i])
        ans = ans * (cnt[i]+1) % MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10010];
void init(){
	int n=sqrt(10000)+1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				int now=i*i+j*j+k*k+i*j+j*k+k*i;
				if(now>10000) break;
				a[now]++;
			}
		}
	}
}
int main(){
    init();
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
    	cout << a[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 3620