akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	ll N = T.size();
	ll ans = (N / 2) * (N / 2 + 1) / 2 + ((N + 1) / 2) * ((N + 1) / 2 + 1) / 2;
	
	vll one;

	rep(i, N) {
		if (T[i] == '0') { one.push_back({ (i + 1) % 2 }); }
	}

	ll M = one.size();
	if (M == 0) { cout << ans << endl; return 0; }

	//cout << M << endl;
	vll c(M, 0);
	c[0] = one[0];

	repn(i, M - 1) {
		if (one[i - 1] == 0 && one[i] == 1) { c[i] = c[i - 1] + 1; }
		else { c[i] = c[i - 1]; }
	}

	rep(i, M) ans -= c[i];
	cout << ans << endl;
	
}

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

int main(){
    int d;
    int n;
    cin>>d>>n;
    if(d==0 && n<100)cout<<n<<endl;
    else if(d==0 && n==100)cout<<101<<endl;
    else if(d==1 && n<100){
        cout<<100*n<<endl;
    }
    else if(d==2 && n<100){
        cout<<10000*n<<endl;

    }
    else if(d==1 & n==100){
        cout<<10100<<endl;
    }
    else if(d==2 && n==100){
        cout<<1010000<<endl;
    }
}

Measured memory_bytes: 256
import math
n,d = map(int,input().split())
a = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        hoge = 0
        for k in range(d):
            hoge += (a[i][k] - a[j][k])**2
        if math.sqrt(hoge) == int(math.sqrt(hoge)):
            count += 1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}

const int M=61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll K; cin >> N >> K;
    vector<int> A(N); cin >> A;
    vector<vector<int>> nxt(N,vector<int>(M));
    for (int i=0;i<N;++i) nxt[i][0]=A[i]-1;
    for (int j=0;j<M-1;++j){
        for (int i=0;i<N;++i){
            nxt[i][j+1]=nxt[nxt[i][j]][j];
        }
    }
    int ans=0;
    for (int j=M-1;j>=0;--j){
        if (K&1LL<<j) ans=nxt[ans][j];
    }
    cout << ans+1 << '\n';
}

Measured memory_bytes: 58636
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			boolean [] data = new boolean[11];
			data[a] = true;
			data[b] = true;
			data[c] = true;
			int sum = a + b;
			int count = 0;
			for(int i = 1; i <= 10; i++){
				if(data[i]) continue;
				if(sum + i <= 20){
					count++;
				}
			}
			double res = (double)count / 7;
			if(res >= 0.5){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
	}

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

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

int main()
{
    long long n,i,sum = 0;
    cin >> n;

    for (i = 1; i <= n; i++){
        if (i % 3 == 0 || i % 5 == 0){
            continue;
        }
        sum += i;
    }
    cout << sum;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)
n = int(input())
A = list(map(int,input().split()))
G = [[] for i in range(n)]
for i in range(n-1):
  u,v = map(int,input().split())
  u-=1;v-=1
  G[u].append(v)
  G[v].append(u)
dp = [inf] * (n+10)
dp[0] = A[0]
length = 1
fixed = [-1] * (n+10)
ans = [0] * n
def dfs(node,pre,length):
  if node != 0:
    if dp[length-1] < A[node]:
      dp[length] = A[node]
      length += 1
      fixed[node] = inf
    else:
      fixed[node] = dp[bisect.bisect_left(dp,A[node])]
      dp[bisect.bisect_left(dp,A[node])] = A[node]
  ans[node] = length
  for v in G[node]:
    if v == pre:continue
    dfs(v,node,length)
  dp[bisect.bisect_left(dp,A[node])] = fixed[node]

dfs(0,-1,1)
print(*ans,sep = "\n")
    

def LIS(seq):
    dp = [inf]*(n+10)
    dp[0] = seq[0]
    length = 1
    for i in range(1, n):
        if dp[length-1] < seq[i]:
            dp[length] = seq[i]
            length += 1
        else:
            dp[bisect.bisect_left(dp, seq[i])] = seq[i]
    return dp,length

Measured memory_bytes: 341356
N = int(input())
HP = [tuple(map(int,input().split())) for _ in range(N)]
HP.sort(key=lambda x: sum(x))

INF = float('inf')
dp = [0]
maxj = 0
for i,(h,p) in enumerate(HP):
	dp2 = [INF] * (maxj + 2)
	for j in range(maxj,-1,-1):
		dp2[j] = min(dp2[j], dp[j])
		if dp[j] <= h:
			dp2[j+1] = min(dp2[j+1], dp[j] + p)
			if j == maxj:
				maxj += 1
	dp = dp2
print(maxj)

Measured memory_bytes: 58584
#include <stdio.h>
int main(void){
    double r,l;
    int countal=0,countbl=0,countcl=0,countdl=0,countar=0,countbr=0,countcr=0,countdr=0;
    while(scanf("%lf %lf",&l,&r)!=EOF){
        if(r>=1.1)
        countar++;
        else if(r<1.1 && r>=0.6)
        countbr++;
        else if(r<0.6 && r>=0.2)
        countcr++;
        else if(r<0.2)
        countdr++;
        
        if(l>=1.1)
        countal++;
        else if(l<1.1 && l>=0.6)
        countbl++;
        else if(l<0.6 && l>=0.2)
        countcl++;
        else if(l<0.2)
        countdl++;
    }
    printf("%d %d\n%d %d\n%d %d\n%d %d\n",countal,countar,countbl,countbr,countcl,countcr,countdl,countdr);
    return 0;
}



Measured memory_bytes: 2036
#include<stdio.h>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
	int i,j,n,a[5][105]={0};
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[1][i]);
	for(i=1;i<=n;i++)
	scanf("%d",&a[2][i]);
	int maxx=0;
	for(i=1;i<=n;i++){
		int sum=0;
		for(j=1;j<=i;j++)
			sum+=a[1][j];
		for(j=i;j<=n;j++)
			sum+=a[2][j];
		if(sum>maxx)
			maxx=sum;
	}
	printf("%d\n",maxx);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=5000+10;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
/*
f[x][y]=num of bar=x sum of length=y,last bar's length=0

      o
      o
  ooooo
_oooooo
|<-x->|  sum of o = y
ans= \sum_{i=0}^{n-1} f[n/2+1][i],2|n
     
*/
int n,mod,f[2][N];
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}

int main()
{
	n=rd(),mod=rd();
	int nw=1,la=0;
	f[la][0]=1;
	for(int i=1;i<=n/2;++i)
	{
		for(int j=0;j<n;++j)
		{
			if(!f[la][j]) continue;
			for(int k=j,l=1;k<n;k+=i,++l) ad(f[nw][k],1ll*f[la][j]*l%mod);
			f[la][j]=0;
		}
		nw^=1,la^=1;
	}
	int ans=0;
	if(n&1)
	{
		for(int i=0;i<n;++i) ad(ans,1ll*f[la][i]*((n-1-i)/(n/2+1)+1)%mod);
	}
	else
	{
		for(int i=0;i<n;++i) ad(ans,f[la][i]);
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main(){
	int x,a;
	cin>>x>>a;
	if(x<a?print(0):print(10));
}	

Measured memory_bytes: 256
num =[0,0,0]

for a in range(10):
    x = int(input().rstrip())
    if x > num[0]:
        num[2] = num[1]
        num[1] = num[0]
        num[0] = x
        continue 
    elif x > num[1]:
        num[2] = num[1]
        num[1] = x
        continue 
    elif x > num[2]:
        num[2] = x
for a in range(3):
    print(num[a])
    

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

int edge[100000];
vector <int> g[100000];
int D[100000];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		x--;y--;
		g[x].push_back(y);
		edge[y]++;
	}
	int Q[100000];
	int start=0,end=0;
	for(int i=0;i<n;i++) if(edge[i]==0) Q[end++]=i;
	int ans=0;
	while(start<end){
		int x=Q[start++];
		ans=max(ans,D[x]);
		for(int i=0;i<g[x].size();i++){
			int a=g[x][i];
			edge[a]--;
			if(edge[a]==0) Q[end++]=a;
			D[a]=max(D[a],D[x]+1);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6912
N,K = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
kitaiti = Array.new(1000)

(1..1000).each do |i|
  kitaiti[i] = (1..i).inject(:+) / i.to_f
end

sum = 0
left = 0
right = K
max = 0
(0..(K-1)).each do |i|
  max += kitaiti[p[i]]
end
sum = max

#(1..p[i]).inject(:+) / p[i].to_f

(1..(N - K)).each do |i|
  	next_sum = sum - kitaiti[p[i-1]] + kitaiti[p[i + K - 1]]
	if next_sum > max
      max = next_sum
      left = i
      right = i + K
    end
  	sum = next_sum
end

sum = 0
(left..(right - 1)).each do |i|
  sum += kitaiti[p[i]]
end
puts sum



Measured memory_bytes: 16932
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

int const SIZ = 10001;

bitset<SIZ> sieve;
vector<int> primes;

void prepare() {
    primes.push_back(2);
    sieve.set();
    sieve.set(0, 0);
    sieve.set(1, 0);
    for (int i=4; i<SIZ; i+=2) {
        sieve.set(i, 0);
    }
    for (int i=3; i<SIZ; i+=2) {
        if ( ! sieve[i]) continue;
        primes.push_back(i);
        for (int j=2; i*j<SIZ; ++j) {
            sieve.set(i*j, 0);
        }
    }
}

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

    int n;
    cin >> n;

    prepare();

    unordered_map<int,int> checked;
    int m, ans = 0;
    for (int i=0; i<n; ++i) {
        cin >> m;
        if (checked[m]) continue;
        if (m < SIZ && sieve[m]) {
            ++ ans;
            checked[m] = 1;
            continue;
        }
        bool isprime = true;
        for (int i=0; i<(int)primes.size(); ++i) {
            if (m % primes[i] == 0) {
                isprime = false;
                break;
            }
        }
        if (isprime) {
            ++ ans;
            checked[m] = 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>

int		main()
{
	int		A, B, C,D;
	int		t, a;

	scanf("%d %d %d %d\n", &A, &B, &C,&D);
	t = A / D;
	if (A % D)
		t++;
	a = C / B;
	if (C % B)
		a++;
	if (t >= a)
		printf("Yes\n");
	else
		printf("No\n");
	return (0);
}


Measured memory_bytes: 1644
#include<iostream>
#include<climits>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;

using namespace std;

ll n, k;
ll W[100000];

bool check(ll M) {
	ll cost = 0, cnt = 0, i;
	rep(i,n) {
		cost += W[i];
		while (cost > M) {
			cost = W[i];
			cnt++;
			if (cnt==k) return false;
		}
	}
	return true;
}

int main() {
	// input
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll L=0, R=INT_MAX, M, x, i;
	cin >> n >> k;
	rep(i,n) cin >> W[i];

	while(L < R) {
		M = (L + R) / 2;
		if (check(M)) R = M;
		else L = M + 1;
	}
	cout << L << endl;
	return 0;
}

Measured memory_bytes: 1972
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib> 
#include <algorithm>
#include <cmath>
#include <stack>

#define Bigger(a,b) (a <= b)?b:a                   //大きい方を返す
#define Rep(i, n) for(int i = 0; i < n; i++)    //i=0 → i=nまでループ
#define Repr(i,n) for(int i = n; i <=0; i--)    //i=n → i=0までループ　
#define For(i, m, n) for(int i = m;i < n;i++)   //i=m → i=nまでループ
#define All(x) (x).begin(),().end()             //xの最初と最後のイテレータを返す 
#define Out(n) cout << n << endl


using namespace std;



int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(((a < c ) && (b > c)) || ((b < c) && (a > c))){
        Out("Yes");
    } else {
        Out("No");
    }




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  string s, t; cin >> s >> t;
  long long m = s.size();
  long long n = t.size();
  
  long long cnt = -1;
  long long num = m - 1;
  for(int i = 0; i < n; i++){
    long long tmp;
    num++;
    if(num == m){
      cnt++;
      num = 0;
    }
    tmp = num;
    num = s.substr(num, m - num).find(t[i]);
    if(num != string::npos) num += tmp;
    if(num == string::npos){
      cnt++;
      num = 0;
      num = s.substr(num, m - num).find(t[i]);
      if(num == string::npos){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << m * cnt + num + 1 << endl;
}


Measured memory_bytes: 640
#include<iostream>

using namespace std;

int main(){
	unsigned long long a,b,c,ans,res;
	cin>>a>>b>>c;
	if(a>c||b>c||(a==c&&b==c)) cout<<"No"<<endl;
	else{
	ans = (c-a-b)*(c-a-b);
	res = 4*a*b;
	if(ans > 1000000000&&res>1000000000){
		ans -= 1000000000;
		res -= 1000000000;
	}
	if(ans > res)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int>a(n+3);
    vector<int>b(n+3);
    for(int i = 0; i < n; i++){
      cin >> a.at(i);
      b.at(a.at(i)) = i+1;
    }

    for(int i = 1; i <= n; i++){
      cout << b.at(i) << " ";
    }
}





Measured memory_bytes: 1536
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

# --------------------------------------------

dp = None

def main():
    N, Z, W = list(map(int, input().split()))
    A = list(map(int, input().split()))

    if N == 1:
        print(abs(A[0] - W))
    else:
        print(max(
            abs(A[-1] - W),
            abs(A[-1] - A[-2])
        ))

main()


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

#define rep(j,n) for(int j=0;j<n;j++)
#define ll long long
#define MX 100005

#define pb .push_back

using namespace std;

int main(){
    ll n;
    cin>>n;
    ll ans=(n*(n-1))/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N,M;
vector<int> children[100000];

int dp[100000];
int solve(int now){
	if(dp[now] != -1) return dp[now];
	dp[now] = 0;
	for(int i=0; i<children[now].size(); i++) dp[now] = max(dp[now], solve(children[now][i])+1);
	return dp[now];
}

int main(){
	
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int x,y;
		cin >> x >> y;
		children[x-1].push_back(y-1);
	}
	for(int i=0; i<N; i++) dp[i] = -1;
	int ans = 0;
	for(int i=0; i<N; i++) ans = max(ans, solve(i));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int dp1[100010],dp2[100010],dp[100010];

int main()
{
	vector<pair<int,int> > v;
	int n;cin >> n;
	REP(i,n)
	{
		int a,b;
		cin >> a >> b;
		dp1[a]++;dp2[b]++;
		dp[a]++;dp[b]--;
		v.PB(MP(a,b));
	}
	
	REP(i,100009)
	{
		dp[i+1] += dp[i];dp1[i+1] += dp1[i];dp2[i+1] += dp2[i];
	}
	
	int ans = 0;
	for(int i = 0;i < n;i++)
	{
		ans = max(ans,dp1[v[i].SE-1]-dp2[v[i].FI]);
	}
	cout << ans << ' ';
	
	ans = 0;
	REP(i,100010)
	{
		ans = max(ans,dp[i]);
	}
	
	cout << ans << endl;		
	
	return 0;
}

Measured memory_bytes: 6092
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	ll a,b,n;
	cin>>a>>b>>n;
	ll x=min(n,b-1ll);
	cout<<a*x/b;



return 0;
}



Measured memory_bytes: 3616
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
const int MAXN=2e5+10;
//vector<int> G[2][MAXN];
int Fa[2][MAXN],cnt[MAXN];
map<pair<int,int>,int> MP;
pair<int,int> A[MAXN];
int n;
void Init()
{
	for(int k=0;k<2;k++)
		for(int i=0;i<n;i++)
		{
			//G[k][i].clear();
			//G[k][i].push_back(i);
			Fa[k][i]=i;
		}
}
int Getfa(int x,int z)
{
	return (Fa[z][x]==x?x:Fa[z][x]=Getfa(Fa[z][x],z));
}
void Union(int x,int y,int z)
{
	//cout<<0<<" "<<x<<" "<<y<<endl;
	//cout<<Fa[z][y]<<" ";
	x=Getfa(x,z);
	y=Getfa(y,z);
	//cout<<1<<" "<<x<<" "<<y<<endl;
	//system("pause");
	if(x==y)return;
	//if(G[z][x].size()>G[z][y].size())
	//{
		Fa[z][y]=x;
		//for(int i=0;i<G[z][y].size();i++)
		//	G[z][x].push_back(G[z][y][i]);
		//G[z][y].clear();
	//}
	//else
	//{
	//	Fa[z][x]=y;
		//for(int i=0;i<G[z][x].size();i++)
		//	G[z][y].push_back(G[z][x][i]);
		//G[z][x].clear();
//	}
}
int main()
{
	int kl[2];
	cin>>n>>kl[0]>>kl[1];
	Init();
	for(int tc=0;tc<2;tc++)
	{
		for(int i=0;i<kl[tc];i++)
		{
			int x,y;
			cin>>x>>y;
			x--,y--;
			Union(x,y,tc);
			//cout<<1<<endl;
		}
		//for(int i=0;i<n;i++)
		//{
		//if(Fa[tc][i]==i)sort(G[tc][i].begin(),G[tc][i].end());
		//}
		//system("pause");
	}
	for(int i=0;i<n;i++)
	{
		int ii=Getfa(i,0);
		int iii=Getfa(i,1);
		A[i]=make_pair(ii,iii);
		MP[A[i]]++;
		//vector<int> v(G[0][ii]);
		//v.insert(v.end(),G[1][iii].begin(),G[1][iii].end());
		//sort(v.begin(),v.end());
		//v.erase(unique(v.begin(),v.end()),v.end());
		//int cnt=G[0][ii].size()+G[1][iii].size()-v.size();
		//cout<<cnt<<" ";
		/*cur.clear();
		int cnt=0;
		int ii=Getfa(i,0);
		int iii=Getfa(i,1);
		if(ii<iii)
		{//cout<<i<<" "<<ii<<" "<<iii<<endl;
		//system("pause");
		for(int j=0;j<G[0][ii].size();j++)
			cur.insert(G[0][ii][j]);
		//cout<<cur.size()<<endl;
		//system("pause");
		//system("pause");
		for(int j=0;j<G[1][iii].size();j++)
		{
		int a=G[1][iii][j];
		if(cur.find(a)!=cur.end())cnt++;
	}
		}
		else
		{
		for(int j=0;j<G[1][iii].size();j++)
			cur.insert(G[1][iii][j]);
		//cout<<cur.size()<<endl;
		//system("pause");
		//system("pause");
		for(int j=0;j<G[0][ii].size();j++)
		{
			int a=G[0][ii][j];
			if(cur.find(a)!=cur.end())cnt++;	
		}*/
	}
	for(int i=0;i<n;i++)
		cout<<MP[A[i]]<<" ";
		//cout<<cnt<<" ";
	cout<<endl;
	return 0;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int n;

// cur: 現在の値、counter: 一致した数の総数、useFlag: 7,5,3の使用状況フラグ
void dfs(ll cur, ll &counter, unsigned int useFlag) {
  if (cur > n) {
    return;
  }
  if (useFlag == 0b111) {
    counter++;
  }
  vector<int> d = {7, 5, 3};
  vector<unsigned int> flags = {0b001, 0b010, 0b100};
  for (int i = 0; i < 3; i++) {
    int dd = d[i];
    unsigned int flag = flags[i];
    dfs(cur * 10 + dd, counter, useFlag | flag);
  }
}

int main() {
  cin >> n;
  ll res = 0;
  dfs(0, res, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
K = int(input())

A = []
for s in S:
    t = (ord('z') - ord(s) + 1) % 26
    if t <= K:
        K -= t
        A.append('a')
    else:
        A.append(s)

A[-1] = chr((ord(A[-1]) + K - ord('a')) % 26 + ord('a'))
print("".join(A))

Measured memory_bytes: 4212
N = int(input())
d = {}
for i in range(N):
    S = input()
    if S in d.keys():
        d[S] += 1
    else:
        d[S] = 1
max_val = max(d.values())
key_list = [kv[0] for kv in d.items() if kv[1] == max_val]
for k in sorted(key_list):
    print(k)

Measured memory_bytes: 35652
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
long long mod=998244353;
struct segtree{
	int size=1;
	vector<int> node;
	segtree(vector<int> v){
		while(size<v.size()){
			size<<=1;
		}
		node.resize(size*2-1);
		for(int i=0;i<v.size();i++){
			node[i+size-1]=v[i];
		}
		for(int i=size-2;i>=0;i--){
			node[i]=min(node[i*2+1],node[i*2+2]);
		}
	}
	//k番目の値をaに変更
	void update(int k,int a){
		k+=size-1;
		node[k]=a;
		while(k){
			k=(k-1)/2;
			node[k]=min(node[k*2+1],node[k*2+2]);
		}
	}
	//[a,b)の範囲内で最小値を求める
	int query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=size;
		}
		if(r<=a||b<=l){
			return 2147483647;
		}else if(a<=l&&r<=b){
			return node[k];
		}else{
			int va=query(a,b,k*2+1,l,(l+r)/2);
			int vb=query(a,b,k*2+2,(l+r)/2,r);
			return min(va,vb);
		}
	}
};
int main(){
	long long n,q;
	cin>>n>>q;
	long long now=(n-2)*(n-2);
	vector<int> nul(n,n);
	segtree ue(nul);
	segtree hidari(nul);
	for(int i=0;i<q;i++){
		int a,x;
		cin>>a>>x;
		if(a==1){
			int mem=ue.query(x-1,n);
			now-=mem-2;
			if(hidari.query(mem-1,mem)>x){
				hidari.update(mem-1,x);
			}
		}else{
			int mem=hidari.query(x-1,n);
			now-=mem-2;
			if(ue.query(mem-1,mem)>x){
				ue.update(mem-1,x);
			}
		}
	}
	cout<<now<<endl;
	return 0;
}


Measured memory_bytes: 8308
import sys
sys.setrecursionlimit(10**7)
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7


# max_n = 100000
# max_k = 2

# factorial = [1,]  # 0! = 1
# tmp_fac = 1
# for i in range(1,max(max_n+1, max_k+1)):
#     tmp_fac *= i
#     factorial.append(tmp_fac)  # O(1)

from scipy.misc import comb  # must write exact=True to use

# def combinations(n, k):
#     return factorial[n] // factorial[k] // factorial[n-k]

def main(): 
    N = II()
    S = []
    for _ in range(N):
        s = tuple(sorted(list(SI())))
        S.append(s)

    S.sort()

    prev = None
    ans = 0
    same_count = 0
    for i in S:
        if prev == i:
            same_count += 1
            # prev = i
        else:
            # ans += combinations(same_count, 2)
            ans += comb(same_count, 2, exact=True)
            same_count = 1
            prev = i
    ans += comb(same_count, 2, exact=True)
    # ans += combinations(same_count, 2)


    print(ans)

main()

Measured memory_bytes: 27492
import sys
from io import StringIO
import unittest
import os
import heapq

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 検索用タグ、優先度付きキュー、値の大きい物から取得

# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())
    a_s = list(map(int, input().split()))

    a_s.sort(reverse=True)

    # 優先度付きキューの作成
    que = []
    heapq.heapify(que)

    ans = 0
    # 大きい値から順番に処理していく
    for cnt, a in enumerate(a_s):
        # 大きい値から順番に処理していくため、値を反転(優先度付きキュー利用時の注意)
        a = -a
        if cnt == 0:
            # ループ一回目の時だけ、こっちを通過。
            heapq.heappush(que, a)
            continue

        # キューから値の取り出し
        target = heapq.heappop(que)
        ans += -target
        # 現在の値を追加できるパターンが2つできるので、それをキューに追加
        heapq.heappush(que, a)
        heapq.heappush(que, a)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
2 2 1 3"""
        output = """7"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """7
1 1 1 1 1 1 1"""
        output = """6"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def test_1original_1(self):
        test_input = """4
2 2 3 3"""
        output = """9"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

int main() {
	ll n;
	cin >> n;
	map<ll, ll>a;
	for (int i = 0; i < n; i++) {
		ll x;
		cin >> x;
		if (a.count(x))a.at(x)++;
		else a[x] = 1;
	}
	ll ans = 0;
	for (auto b : a) {
		if (b.first < b.second)ans += b.second - b.first;
		else if (b.first > b.second)ans += b.second;
	}
	cout << ans << endl;
}

Measured memory_bytes: 6272
H, W = map(int, input().split())
A = [[s for s in input()] for _ in range(H)]

flag = True

prev = 0
for a in A:
    if prev > 0:
        if '#' in a[:prev]:
            flag *= False
    prev = max([n for n, v in enumerate(a) if v == '#'])
if flag:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 1e5 + 5, L = 20;
int a[N], b[N][L];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, q;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    cin >> m >> q;

    for (int i = n - 1; i >= 0; i--) {
        b[i][0] = upper_bound(a, a + n, a[i] + m) - a - 1;
        for (int j = 1; j < L; j++) {
            b[i][j] = b[b[i][j - 1]][j - 1];
        }
    }

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (x > y)
            swap(x, y);

        int ans = 0;
        for (int j = L - 1; j >= 0; j--) {
            if (b[x][j] < y) {
                ans += (1 << j);
                x = b[x][j];
            }
        }

        ans++;

        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan

    long long int n,k; cin >> n >> k;
    vector< int > v(n);
    vector< int > visited(n,0);
    vector< int > seq;
    vector< int > second_seq;

    for(int i=0;i<n;i++)
    {
        cin >> v[i];
        v[i]-=1;
    }

    map< int , int > index;

    int x = 0;
    seq.push_back(0);
    index[x]=0;

    while(true)
    {
        visited[x]=1;
        x=v[x];

        if(visited[x])
            break;
        else
        {
            seq.push_back(x);
            index[x]=seq.size()-1;
        }
    }


    if(k<index[x])
        cout << seq[k]+1 << endl;
    else
    {

        cout << seq[index[x]+((k-index[x])%(seq.size()-index[x]))]+1 << endl;

        //cout << index[x] << endl;
    }



    /*for(int c : seq)
            cout << c << " ";
        cout << endl;*/

    return 0;


}


Measured memory_bytes: 14796
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> d(N);
	for (int ii = 0; ii < N; ++ii){
		cin >> d[ii];
	}

	ll sum = 0;
	for (int ii = 0; ii < N-1; ++ii){
		for (int jj = ii + 1; jj < N; ++jj){
			sum += d[ii]*d[jj];
		}
	}


		cout << sum << "\n";		

	return 0;
}


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

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

    vector<string>s(n);
    rep(i,0,n){
        cin>>s[i];
    }

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

    rep(i,0,n){
        cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}	
	}
	return true;
}
int main()
{
   ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);	
    string s;
    cin>>s;
    ll sum=0;
    for(int i=0;i<s.size();i++)
    {
    	sum=sum+s[i]-'0';
	}
	if(sum%9==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}
 
 
 

 


Measured memory_bytes: 3748
#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() {
    vector<vector<int>> data(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> data.at(i).at(j);
        }
    }
    
    int n;
    cin >> n;
    
    int b;
    rep(i, n) {
        cin >> b;
        rep(j, 3) {
            rep(k, 3) {
                if (b == data.at(j).at(k)) data.at(j).at(k) = 0;
            }
        }
    }
    
    string bingo = "No";
    if ((data.at(0).at(0) == 0) && (data.at(0).at(1) == 0) && (data.at(0).at(2) == 0)) bingo = "Yes";
    else if ((data.at(1).at(0) == 0) && (data.at(1).at(1) == 0) && (data.at(1).at(2) == 0)) bingo = "Yes";
    else if ((data.at(2).at(0) == 0) && (data.at(2).at(1) == 0) && (data.at(2).at(2) == 0)) bingo = "Yes";
    else if ((data.at(0).at(0) == 0) && (data.at(1).at(0) == 0) && (data.at(2).at(0) == 0)) bingo = "Yes";
    else if ((data.at(0).at(1) == 0) && (data.at(1).at(1) == 0) && (data.at(2).at(1) == 0)) bingo = "Yes";
    else if ((data.at(0).at(2) == 0) && (data.at(1).at(2) == 0) && (data.at(2).at(2) == 0)) bingo = "Yes";
    else if ((data.at(0).at(0) == 0) && (data.at(1).at(1) == 0) && (data.at(2).at(2) == 0)) bingo = "Yes";
    else if ((data.at(0).at(2) == 0) && (data.at(1).at(1) == 0) && (data.at(2).at(0) == 0)) bingo = "Yes";

    cout << bingo << endl;
}

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

const int MAXN = 3000;

int fact[MAXN], fact_inv[MAXN], mod;
int memo[MAXN][MAXN];

int mul(int a, int b) {
	int ans = 1LL * a * b % mod;
	while(ans < 0) ans += mod;
	while(ans >= mod) ans -= mod;
	return ans;
}

void add_self(int& a, int b) { 
	a += b; 
	while(a < 0) a += mod;
	while(a >= mod) a -= mod;
}

void fix(int& a) {
	a %= mod;
	while(a < 0) a += mod;
	while(a >= mod) a -= mod;
}

int mpow(int a, int n) {
	fix(a);
	if(memo[a][n] != -1) return memo[a][n];
	if(n == 0) return 1;
	int x = mpow(a, n/2);
	x = mul(x, x);
	if(n % 2 == 1) x = mul(x, a);
	return memo[a][n] = x;

}

int binomial(int n, int k) {
	return mul(fact[n], mul(fact_inv[k], fact_inv[n-k]));
}

vector<int> g(int i) {
	vector<int> ans(mod);
	
	for(int k = 0; k < mod; k++) {
		ans[k] = mul(binomial(mod-1, k), mpow(i, mod-1-k));
		if((mod-1-k) % 2 == 1) {
			ans[k] = mul(ans[k], -1);
		}
	}
	
	for(int k = 0; k < mod; k++) {
		ans[k] = mul(ans[k], -1);
	}
	
	add_self(ans[0], 1);
	
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> mod;
	
	memset(memo, -1, sizeof memo);
	fact[0] = fact_inv[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		fact[i] = mul(fact[i-1], i);
		fact_inv[i] = mpow(fact[i], mod-2);
	}

	vector<int> arr(mod);
	for(int& x : arr) cin >> x;
	vector<int> ans(mod);
	
	for(int i = 0; i < mod; i++) {
		int a = arr[i];
		vector<int> gi = g(i);
		for(int j = 0; j < mod; j++) {
			add_self(ans[j], mul(a, gi[j]));
		}
	}
	
	for(int i = 0; i < mod; i++) {
		cout << ans[i] << " \n"[i==mod-1];
	}
}


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


char buf[5];
bool query(long long int val){
	printf("? %lld\n", val);
	fflush(stdout);
	scanf("%s", buf);
	return buf[0] == 'Y';
}
void outt(long long int val){
	printf("! %lld\n", val);
	fflush(stdout);
	exit(0);
}
int main(){
	long long int ten = 1;
	long long int ten2 = 10;
	for (int i = 1; i <= 11; i++){
		bool A1 = query(ten);
		bool A2 = query(ten2 - 1);
		if (A1 == A2&&A1==true){
			if (i != 1){
				long long int mint = ten;
				long long int maxt = ten2 - 1LL;
				while (mint + 1LL < maxt){
					long long int mid = (mint + maxt) >> 1LL;
					if (query(mid * 10LL)){
						maxt = mid;
					}
					else{
						mint = mid + 1LL;
					}
				}
				if (query(mint * 10LL)){
					outt(mint);
				}
				else{
					outt(maxt);
				}
			}
			else{
				break;
			}
		}
		ten *= 10;
		ten2 *= 10;
	}
	ten = 1;
	ten2 = 10;
	for (int i = 2; i <= 11; i++){
		ten *= 10LL;
		ten2 *= 10LL;
	}
	for (int i = 11; i >= 1; i--){
		bool A1 = query(ten);
		bool A2 = query(ten2 - 1);
		if (A1 == A2&&A1 == true){
			if (i == 11){
				outt(1);
				return 0;
			}
			if (1){
				long long int mint = ten;
				long long int maxt = ten2 - 1LL;
				while (mint + 1LL < maxt){
					long long int mid = (mint + maxt) >> 1LL;
					if (query(mid * 10LL)){
						maxt = mid;
					}
					else{
						mint = mid + 1LL;
					}
				}
				if (query(mint * 10LL)){
					outt(mint);
				}
				else{
					outt(maxt);
				}
			}
		}
		ten /= 10LL;
		ten2 /= 10LL;
	}
	return 0;
}

Measured memory_bytes: 684
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef unsigned long long ull;

struct Item {
  int v;
  int w;
  char t;
  ull d;
  char s[25];
};

bool comp(const Item &x, const Item &y) {
  if (x.v < y.v) return true;
  else if (x.v == y.v) {
    if (x.w < y.w) return true;
    else if (x.w == y.w) {
      if (x.t < y.t) return true;
      else if (x.t == y.t) {
        if (x.d < y.d) return true;
        else if (x.d == y.d) {
          if (strcmp(x.s,y.s) < 0) return true;
        }
      }
    }
  }
  return false;
}

int main() {
  int N;
  Item items[100100];

  scanf("%d",&N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d %c %llu %s",
          &items[i].v,&items[i].w,&items[i].t,&items[i].d,&items[i].s);
  }

  sort(items,items + N, comp);

  for (int i = 0; i < N; ++i) {
    printf("%d %d %c %llu %s\n",
           items[i].v,items[i].w,items[i].t,items[i].d,items[i].s);
  }

  return 0;
}



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

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        int y = 0;
        if (i%2 != 1) continue;
        rep(j, i){
            if (i%j == 0){
                // printf("%d %d \n", i, j);
                y++;
            }
        }
        if (y == 8) cnt ++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque

#キューを使った幅優先探索を使うのが正解らしい

#グラフを隣接リストで表現するときに使う関数
def make_list(i, j):
    global c
    global h
    global w

    l = []
    a = [-1, 0, 1]
    b = [-1, 0, 1]

    for y in a:
        for x in b:
            if i+y < 0 or j+x < 0 or i+y >= h or j+x >= w:
                continue
            if (x == 0 and y == 0) or (abs(x) == 1 and abs(y) == 1):
                continue
            if c[i][j] == 1:
                continue
            if c[i + y][j + x] == 0:
                l.append((i+y)*w + (j+x))

    return l

hw = list(map(int, input().split()))
h = hw[0]
w = hw[1]

c = [[0] * w for i in range(h)]

for i in range(h):
    line = input()
    for j in range(w):
        if line[j] == '.':
            c[i][j] = 0
        else:
            c[i][j] = 1

rlist = []
for i in range(h):
    for j in range(w):
        rlist.append(make_list(i, j))

def bfs(u):
    color[u] = 'gray'
    d[u] = 0
    queue.append(u)

    while(len(queue) > 0):
        u = queue.popleft()
        for rl in rlist[u]:
            if color[rl] == 'white':
                queue.append(rl)
                color[rl] = 'gray'
                d[rl] = d[u] + 1
        color[u] = 'black'

result = 0
for i in range(len(rlist)):
    color = ['white'] * len(rlist)
    queue = deque([])
    d = [-1] * len(rlist)
    if len(rlist[i]) > 0:
        bfs(i)
        if result < max(d):
            result = max(d)

print(result)

Measured memory_bytes: 3316
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int x, y;
    cin >> x >> y;

    bool res = false;

    for (int i = 0; i <= x; ++i) {
        int cnt = i * 2 + (x - i) * 4;
        if (cnt == y) {
            res = true;
            break;
        }
    }

    if (res) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }


    return 0;
}

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

int main() {
  string s; cin >> s;
  ll res = 0;
  for (ll i = 0; i < s.size(); i++) {
    if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
      ll j = i;
      while (j+1 < s.size() && (s[j+1] == 'A' || s[j+1] == 'G' || s[j+1] == 'C' || s[j+1] == 'T')) {
        j++;
      }
      res = max(res, j-i+1);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int N = S.size();
    
    string ans = "AC";
    int C = 0;
    int capital = 0;
    for(int i = 0; i < N; i++) {
        if(2<=i && i<=N-2 && S.at(i)=='C') C++;
        if(S.at(i)<97) capital++;
    }
    if(S.at(0)!='A' || C!=1 || capital!=2) ans = "WA";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == ',') {
			cout << " ";
		}
		else {
			cout << s[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] #i=ワンフロアの部屋の数, j=階の数 ,k=棟の数
for i in range(0, n):
  b, f, r, v = map(int, input().split()) #b棟f階のr番目の部屋にv人が追加で入居したことを示す
  count[b-1][f-1][r-1] = count[b-1][f-1][r-1] + v

for k in range(0,4):
  for j in range(0, 3):
    for i in range(0, 10):
      print("",count[k][j][i], end=''"")
      if i == 9:
        print("")
  if k < 3:
    for l in range(0, 20):
      print("#", end="")
    print("")


Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> p;


int main(){
    int N, M; cin >> N >> M;
    vector<Int> H(N);
    rep(i,N) cin >> H[i];

    vector<vector<int>> G(N);
    rep(i,M){
        int A, B; cin >> A >> B; A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }

    int ans = 0;
    rep(i,N){
        bool flag = true;
        for(int to: G[i]){
            if(H[to] >= H[i]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }

    cout << ans << endl;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>a(N),b(N);
  ll suma=0,sumb=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    suma+=a[i];
  }
  for(int i=0;i<N;i++){
    cin>>b[i];
    sumb+=b[i];
  }

  if(suma>sumb){
    cout<<"No"<<endl;
    return 0;
  }

  ll m=0;
  ll p=0;
  for(int i=0;i<N;i++){
    if(b[i]<a[i]){
      m+=a[i]-b[i];
    }
    else{
      p+=(b[i]-a[i])/2;
    }
  }

  if(m<=p)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  /*
  int N,A,B;
  cin>>N>>A>>B;
  vector<int>h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  sort(rng(h));
  reverse(rng(h));
  */
  return 0;
}


Measured memory_bytes: 384
use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Ordering};
use std::io::Read;

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let N = buf_it.next().unwrap().parse::<usize>().unwrap();
    let mut A = (0..N).map(|_| buf_it.next().unwrap().parse::<isize>().unwrap()).collect::<Vec<_>>();

    let mut ans = 0;
    let mut flag = true;

    while flag{
        flag = false;
        for j in 1..N{
            let j = N-j;
            if A[j] < A[j-1]{
                let tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = true;
                ans += 1;
            }
        }
    }

    println!("{}",A.iter().map(|&a| format!("{}",a)).collect::<Vec<_>>().join(" "));
    println!("{}",ans);

}


Measured memory_bytes: 5044
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
ll mod_pow(ll x, ll n, ll mod) {
    if(n == 0) return 1;
    ll res = mod_pow((x * x) % mod, n / 2 , mod);
    if(n & 1) res = (res * x) % mod;
    return res;
}
int main(){
	//%MOD下での階乗
	ll ex[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		ex[i]=ex[i-1]*i%MOD;
	}
	//%MOD下での階乗の逆数
	ll inv[SIZE]={1,0};
	for(int i=1;i<SIZE;i++){
		inv[i]=mod_pow(i,MOD-2,MOD);
	}
	for(int i=1;i<SIZE;i++){
		inv[i]=inv[i-1]*inv[i]%MOD;
	}

	int N,M;
	cin>>N>>M;
	int L=M;
	map<int,int> pam={};
	for(int i=2;i*i<=M;i++){
		while(L%i==0){
			pam[i]++;
			L/=i;
		}
	}
	if(L!=1)
		pam[L]++;
	ll ans=1;
	for(pint P:pam){
		int n=P.second;
		(ans*=ex[n+N-1]*inv[n]%MOD*inv[N-1]%MOD)%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;
int main() {
	int x;
	string res = "";

	cin >> x;

	if (x <= 599) res = "8";
	else if (x <= 799) res = "7";
	else if (x <= 999) res = "6";
	else if (x <= 1199) res = "5";
	else if (x <= 1399) res = "4";
	else if (x <= 1599) res = "3";
	else if (x <= 1799) res = "2";
	else if (x <= 1999) res = "1";

	cout << res << endl;
}

Measured memory_bytes: 3624