akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n";

void Main()
{
	ll N;
	ll result=0;
	cin>>N;
	result=N/3;
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#ifdef LOCAL
#define cerr cout
#else
#endif

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 100005;
vector<int> con[N];
int deg[N];
int num_leaves[N];
int vis[N];
bool error = false;
vector<int> _internal;
bool found_path = false;
void dfs(int s, int p){
	if(error) return;
	_internal.push_back(s);
	found_path = true;
	bool done = false;
	for(int v :  con[s]){
		if(deg[v] != 1 && v != p){
			if(done){
				error = true;
				return;
			}
			dfs(v, s);
			done = true;
		}
	}
}

int perm[2][N];

void get_permutation(int perm[]){
	vector<int> orig = _internal;
	int _randomleaf = -1;
	for(auto it : con[_internal[0]]) if(deg[it] == 1) _randomleaf = it;
	reverse(_internal.begin(), _internal.end());
	_internal.push_back(_randomleaf);
	reverse(_internal.begin(), _internal.end());
	
	int now = 0;
	int cntr = 0;
	for(int i = 0; i < (int)_internal.size(); i++){
		int here = ++now;
		int node = _internal[i];
		int num_leaves = 0;
		for(int v : con[node]) if(v != _internal[0] && deg[v] == 1) num_leaves++;
		int is_end = i == ((int)_internal.size()) - 1;
		for(int j = 0; j < num_leaves - is_end; j++) perm[++cntr] = ++now;
		perm[++cntr] = here;
		if(is_end) perm[++cntr] = ++now; // last leaf
	}
	_internal = orig;
}

int main(){
	int n; sd(n);
	for(int i = 1; i < n; i++){
		int u, v;
		sd(u); sd(v);
		con[u].push_back(v);
		con[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	if(n == 2){
		printf("%d %d\n", 1, 2);
		return 0;
	}
	int num_leaves = 0;
	for(int i = 1; i <= n; i++){
		if(deg[i] != 1){
			int d = 0;
			for(int v : con[i]) if(deg[v] != 1) d++;
			if(d <= 1 && !found_path) dfs(i, -1);
		} else num_leaves++;
	}
	if(error || ((int)_internal.size()) != n - num_leaves){
		printf("-1\n");
		return 0;
	}
	for(int j = 0; j < 2; j++){
		get_permutation(perm[j]);
		reverse(_internal.begin(), _internal.end());
	}

	int lesser = 0;
	for(int i = 1; i <= n; i++){
		if(perm[0][i] < perm[1][i]){
			lesser = 0;
			break;
		} else if(perm[1][i] < perm[0][i]){
			lesser = 1;
			break;
		}
	}

	for(int i = 1; i <= n; i++) printf("%d ", perm[lesser][i]);
}

Measured memory_bytes: 12912
#カエル
#各足場の1つ前と2つ前を考える

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    inf = float('inf')
    dp = [inf]*(N)
    dp[0] = 0
    for i in range(1, N):
        for j in range(1,K+1):
            if i>=j:
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
            else:
                continue
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 55388
import copy

n, m = map(int, input().split())
G = [[] for i in range(n)] #G(i): 頂点iと隣接する頂点のlist
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
    G[a[i]-1].append(b[i]-1) #入力は 1-indexed とする
    G[b[i]-1].append(a[i]-1) #無向グラフの場合

seen = [0] * n #頂点iが訪問済みの場合 seen[i] = 1

def dfs(g, s, t): #頂点sを始点としたDFS
    seen = [0] * n
    todo = [s]
    while(todo != []):
        v = todo.pop(len(todo)-1) #FILO
        seen[v] = 1
        for i in g[v]:
            if seen[i] == 0:
                todo.append(i)
    return seen[t]

ans = 0
for i in range(m):
    H = copy.deepcopy(G)
    H[a[i]-1].remove(b[i]-1)
    H[b[i]-1].remove(a[i]-1)
    ans += 1-dfs(H, a[i]-1, b[i]-1)

print(ans)

Measured memory_bytes: 47068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N,ans=1;
  int c[26]={};
  string S;

  cin >> N >> S;

  for(int i=0; i<N; i++){
    c[S[i]-'a']++; 					//count
  }
  for(int i:c){
    ans *= i+1;
    ans %= 1000000007;
  }
    
  cout << ans-1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int mod = 998244353;
int ad(int x,int y){ x+=y; return x>=mod?x-mod:x; }
int sb(int x,int y){ x-=y; return x<0?x+mod:x; }
int mu(int x,int y) { return 1ll*x*y%mod; }
const int maxn = 5e5+5;
int ksm(int a,int b) {
	int ans = 1;
	for(;b;b>>=1,a=mu(a,a))
		if(b&1) ans = mu(ans,a);
	return ans;
}
int n,k;
int fac[maxn],inv[maxn];
int C(int a,int b) {
	if(a<b) return 0;
	return mu(fac[a],mu(inv[b],inv[a-b]));
}
int KAT(int r,int b,int c) {
	return sb(C(r+b,r),C(r+b,r+c));
}
int main() {
	scanf("%d%d",&n,&k);
	if(k<n) {
		puts("0");
		return 0;
	}
	fac[0] = fac[1] = 1;
	inv[0] = inv[1] = 1;
	for(int i=2;i<=k;i++) fac[i] = mu(fac[i-1],i),inv[i] = mu(inv[mod%i],mod-mod/i);
	for(int i=1;i<=k;i++) inv[i] = mu(inv[i-1],inv[i]);
	int ans = 0;
	for(int R=(k+1)/2;R<=k;R++) {
		int B = k-R;
		if(B==R) ans = ad(ans,KAT(R,B-1,R-n+1));
		else ans = ad(ans,KAT(R,B,R-n+1));
	}
	printf("%d",ans);
}

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

namespace practice001
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            Console.WriteLine("{0} {1} {2}", input[2], input[0], input[1]);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;




signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
    
    for(int i=1;i<=k;i++)
    {
        int pre[n+4]={0};
        for(int j=1;j<=n;j++)
        {
            pre[max(1LL,j-a[j])]++;
            pre[min(n+1,j+a[j]+1)]--;
        }
        bool flag=true;
        for(int j=1;j<=n;j++)
        {
            pre[j]+=pre[j-1];
            a[j]=pre[j];
            if(a[j]<n)
            {
                flag=false;
            }
        }
        if(flag)
            break;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";

} 

 

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

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

    for (int i = 1; i < n; i++) {

        for (int i = 0; i < n-1; i++) cout << a[i] << " ";
        cout << a[n-1] <<endl;

        int v = a[i];
        int j = i - 1;
        while ((j>= 0) && a[j] > v) {
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
    }
    for (int i = 0; i < n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
#include <iostream>
#include <functional>
#include <complex>
#include <stdlib.h>
#include <random>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> p3i;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<p3i> v3i;
typedef vector<vii> vvii;
typedef vector<p3i> vp3i;
typedef long double ld;
typedef vector<ld> vld;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define sz(v) (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define rv(v) reverse(all(v))
#define CL(v, val) memset((v), (val), sizeof((v)))
#define SORT(a) sort(all(a))
#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())
#define eps 1.0e-9
#define X first
#define Y second
#define bit(n) (1 << (n))
#define bit64(n) (ll(1) << (n))
#define sqr(x) ((x) * (x))

char s[100];

int main(void) {
	set<string> ss;
	int n;
	scanf("%d", &n);
	REP(i, n) {
		scanf("%s", &s);
		ss.insert((string)s);
	}

	printf("%d\n", sz(ss));
}

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


int main(){
    int N;
    cin >> N;
    std::vector<int> mochi(N);
    for(int i=0; i < N; i++){
        cin >> mochi.at(i);
    }
    sort(mochi.begin(), mochi.end());
    int shurui = 1;
    for(int i=1; i < N; i++){
        if(mochi.at(i-1) == mochi.at(i)){
            continue;
        }else{
            shurui ++;
        }
    }
    cout << shurui <<endl;
    return 0;
}


Measured memory_bytes: 256
N,x=map(int,input().split())
x=min(x,N-x)
rem=[N-x,x]
len=x
ans=N
i=1

while True:
  i=(i+1)%2
  ans+=2*(rem[i]//len)*len
  rem[i]=rem[i]%len
  if rem[i]!=0:
  	len=rem[i]
  else:
    break
  
print(ans-len)

Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=100005;
int n;
int a[N];
long long f[N],g[N];

int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++)
		scanf("%d",&a[i]);
	if(a[0]>1)
	{
		printf("-1");
		return 0;
	}
	g[n]=a[n];
	for(int i=n-1;i>=0;i--)
		g[i]=g[i+1]+a[i];
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=min((f[i-1]-a[i-1])*2,g[i]);
		if(a[i]>f[i])
		{
			printf("-1");
			return 0;
		}
	}
	long long ans=0;
	for(int i=0;i<=n;i++)
		ans+=f[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5748
#include <cstdio>

int main(){
	int n,a,v,ta = -1,tv = -1;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d%d",&a,&v);
		if(v > tv || (v == tv && a < ta)){
			tv = v;
			ta = a;
		}
	}
	printf("%d %d\n",ta,tv);
	return 0;
}

Measured memory_bytes: 2700
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

int n;
int a[200000]; //10^5

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  for (int i = n-1; i >= 0; i-= 2) {
    cout << a[i] << " ";
  }
  int from = n % 2 ? 1 : 0;
  for (int i = from; i < n; i+= 2) {
    cout << a[i] << " ";
  }

  return 0;
}



Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define N 2005
using namespace std;
inline int read(){
	char c=getchar();int x=0,f=1;
	while(c<'0'||c>'9'){ if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
vector<int> e[N];
int ans,n,k,dep[N],a[N],b[N],ban[N][N];
void dfs(int u,int f){
	dep[u]=dep[f]+1;
	for(int i=0;i<e[u].size();++i){
		if(ban[u][e[u][i]]) continue;
		if(dep[e[u][i]]) continue;
		dfs(e[u][i],u);
	}
}
int work(int rt){
	int res=0;
	memset(dep,0,sizeof(dep));
	if(k&1) dfs(a[rt],0),dfs(b[rt],0);
	else 
		dfs(rt,0);
	for(int i=1;i<=n;++i){
//		cout<<dep[i]<<' ';
		if(k%2==0&&dep[i]>(k/2+1)) ++res;
		if(k%2==1&&dep[i]>(k/2+1)) ++res;
	}
//	cout<<endl;//
	return res;
}
int main(){
	n=read();k=read();ans=2002;
	for(int i=1;i<n;++i){
		a[i]=read(),b[i]=read();
		e[a[i]].push_back(b[i]),e[b[i]].push_back(a[i]);
	}
	if(k%2==0){
		for(int i=1;i<=n;++i)
			ans=min(ans,work(i));
	}
	else{
		for(int i=1;i<n;++i){
	//		cout<<"hahah1"<<a[i]<<' '<<b[i]<<endl;
			ban[a[i-1]][b[i-1]]=ban[b[i-1]][a[i-1]]=0,
			ban[a[i]][b[i]]=ban[b[i]][a[i]]=1;
			ans=min(ans,work(i));
	//		cout<<"hahah2"<<i<<' '<<work(i)<<endl;
		}
	}
	printf("%d\n",ans);
	return 0;
}
/*
6 3
1 2
3 2
4 2
1 6
5 6

6 2
1 2
3 2
4 2
1 6
5 6
*/


Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define BS binary_search
#define mod 1000000007

const long long INF=1e18;

template <class A, class B> ostream& operator<<(ostream& os, const pair<A,B> p) {return os << "(" << p.first << "," << p.second << ")";} 

void dprint(string s) {cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w = s.find(','); cout << "[" << s.substr(0,w) << ": " << t << "] "; dprint(s.substr(w+1, (int)s.size()-w), u...);} 

#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...) "KEEP CALM" 
#endif

const int N=100005; // Don't forget to CHANGE this value ACC. TO Q.

int32_t main()
{
    IOS;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int T=1; 
    //cin>>T;
    while(T--)
    {
        int d,t,s;cin>>d>>t>>s;
        if(d>s*t)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    
    return 0;
}

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

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

ld dst(pair <ld, ld> a, pair <ld, ld> b) {
    return sqrt((a.fs - b.fs) * (a.fs - b.fs) + (a.sc - b.sc) * (a.sc - b.sc));
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    ld a, b, h, m;
    cin >> a >> b >> h >> m;
    const ld PI = atan2(0, -1);
    ld alpha = 2.0 * PI / 12.0, beta = 2.0 * PI / 60.0;
    /*ld phi = (alpha * h - beta * m);
    cout << alpha << " " << beta << " " << phi << "\n";
    cout << sqrt(a * a + b * b - 2 * a * b * cos(phi));*/
    pair <ld, ld> x = {a * cos(alpha * h + alpha * m / 60), a * sin(alpha * h + alpha * m / 60)},
                  y = {b * cos(beta * m), b * sin(beta * m)};
    //cout << x.fs << " " << x.sc << "\n" << y.fs << " "<< y.sc << "\n";
    cout << fixed << setprecision(10) << dst(x, y);  
    return 0;
}

Measured memory_bytes: 3812
#double underscore makes a class variable or a class method private
mod = 1000000007
ii = lambda :  int(input())
si = lambda :  input()
dgl = lambda : list(map(int, input()))
f = lambda :   map(int, input().split())
il = lambda :  list(map(int, input().split()))
it = lambda :  tuple(map(int, input().split()))
ls = lambda :  list(input())
n=ii()
print(((n)*(n-1))//2)

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

int main(){
    string arr[3] = { "Sunny" , "Cloudy" , "Rainy" };

    string s;
    cin >> s;

    for ( int i = 0; i < 3; ++i ){
        if ( s == arr[i] ){
            if ( i == 2 ){
                cout << arr[0];
            }
            else{
                cout << arr[i + 1];
            }
        }
    }
    return  0;
}


Measured memory_bytes: 256
// Aizu Vol0 0080: Third Root
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);


int main()
{
	char buf[150];
	int q;
	double x, err, t, x2;

	while (1) {
		gets(buf);
		q = atoi(buf);
		if (q < 0) break;

		x = (double)q / 2.0;
		err = 0.00001*(double)q;
		while (1) {
			x2 = x * x;
			t = x2 * x - q;
			if (-err < t && t < err) break;
			x = x - t / (3 * x2);
		}
		printf("%.8lf\n", x);
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
 
#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);
 
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;
 
constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;
 
template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int K,X; cin >> K >> X;
	Yn(K*500>=X);	

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

using P = pair<uint64_t, uint64_t>;

int main()
{
    auto byDate = [](const P &lh, const P &rh) {
        return lh.first > rh.first;
    };
    auto byReward = [](const P &lh, const P &rh) {
        return lh.second < rh.second;
    };
    priority_queue<P, vector<P>, decltype(byDate)> q0(byDate);

    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
    {
        uint64_t a, b;
        cin >> a >> b;
        q0.push(make_pair(a, b));
    }

    priority_queue<P, vector<P>, decltype(byReward)> q1(byReward);
    uint64_t result = 0;
    for (int i = 1; i <= m; i++)
    {
        while (!q0.empty() && q0.top().first <= (uint64_t)i)
        {
            auto p = q0.top();
            q1.push(p);
            q0.pop();
        }

        if (!q1.empty())
        {
            auto p = q1.top();
            //cout << "i=" << i << " " << p.first << ", " << p.second << endl;
            q1.pop();
            result += p.second;
        }
    }

    cout << result << endl;

    return 0;
}

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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        cout<<"x";
    }

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	D = defaultdict(int)
	table = [[0] * 100 for i in range(100)]
	tablesum = [[0] * 100 for i in range(100)]
	for i in range(N):
		A = input()
		num = ""
		mod5 = 0
		mod2 = 0
		for j in range(len(A)):
			if A[-1 - j] == ".":
				mod5 -= j
				mod2 -= j
			else:
				num += A[-1 - j]

		num = int(num[::-1])
		while True:
			if num % 2 == 0:
				mod2 += 1
				num = int(num // 2)
			else:
				break
		while True:
			if num % 5 == 0:
				mod5 += 1
				num = int(num // 5)
			else:
				break

		table[50 + mod2][50 + mod5] += 1
		tablesum[50 + mod2][50 + mod5] += 1
		# print(mod2, mod5)

	ans = 0
	# 累積
	for i in range(98, -1, -1):
		for j in range(98, -1, -1):
			tablesum[i][j] += tablesum[i + 1][j]

	for i in range(98, -1, -1):
		for j in range(98, -1, -1):
			tablesum[i][j] += tablesum[i][j + 1]

	for i in range(1, 100):
		for j in range(1, 100):
			if i >= 50 and j >= 50:
				ans += table[i][j] * (tablesum[100 - i][100 - j] - table[i][j])
			else:
				ans += table[i][j] * tablesum[100 - i][100 - j]
			# if table[i][j] * tablesum[100 - i][100 - j] > 0:
				# print(i, j)
				# print(table[i][j], tablesum[100 - i][100 - j])

	for i in range(50, 100):
		for j in range(50, 100):
			ans += (table[i][j] - 1) * table[i][j]

	# print(ans)
	ans = int(ans // 2)
	print(ans)


if __name__ == '__main__':
	main()

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    double ans = 0;
    ll N;
    cin >> N;
    rep(i, N) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += x * 380000.0;
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N;
    vector<ll> X(5);
    cin >> N;
    cin >> X;

    ll ans = 0;
    REP(i, 5) {
        chmax(ans, round_up(N, X[i]));
    }
    cout << ans + 4 << endl;
    return 0;
}

Measured memory_bytes: 256
class BIT1():
    """
    Binary Indexed Tree (1-indexed)
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)

    def build(self, data):
        pass

    def add(self, idx, x):
        # add x to idx-th element
        # idx: 1-indexed
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        # get sum of [1, idx]
        # idx: 1-indexed
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s

    def bisect_left(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) >= w
        if w <= 0:
            return 0
        idx = 0  # self.bit[idx] < w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] < w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1

    def bisect_right(self, w):
        # condition : always all element is not minus
        # return minimum idx where bit.sum(idx) > w
        if w < 0:
            return 0
        idx = 0  # self.bit[idx] <= w
        k = 1 << ((self.n).bit_length() - 1)
        while k > 0:
            if idx + k <= self.n and self.bit[idx + k] <= w:
                w -= self.bit[idx + k]
                idx += k
            k = k >> 1
        return idx + 1


n = int(input())
a = [0] + list(map(int, input().split()))

a2idx = [0] * (n + 1)
for i in range(1, n + 1):
    a2idx[a[i]] = i

ans = 0
bit = BIT1(n)
for x in range(1, n + 1):
    idx = a2idx[x]
    bit.add(idx, 1)
    idx_rank = bit.sum(idx)
    idx_l = bit.bisect_left(idx_rank - 1)
    idx_r = bit.bisect_left(idx_rank + 1)

    ans += x * (idx - idx_l) * (idx_r - idx)
    # print(x, idx, idx_l, idx_r, (idx - idx_l) * (idx_r - idx))

print(ans)


Measured memory_bytes: 82044
def main():
    N = int(input())
    points = [list(map(int, input().split())) for _ in range(N)]
    ks = [x + y for x, y in points]
    ls = [x - y for x, y in points]
    kk = max(ks) - min(ks)
    ll = max(ls) - min(ls)
    print(max(kk, ll))


if __name__ == '__main__':
    main()

Measured memory_bytes: 117524
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt, ans, d;
int main () {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>d;
	cout<<(n+2*d)/(2*d+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>s(n);
    rep(i,n)cin >> s[i];
    sort(all(s));
    int sum = 0;
    rep(i,n)sum += s[i];
    if(sum%10 != 0){
        cout << sum << endl;
        return 0;
    }
    rep(i,n){
        if(s[i]%10 != 0){
            cout << sum-s[i] << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int n;
	cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    int sum = -a[0] + a[n-1];
    for (int i = 1; i < n-1; i++) sum += abs(a[i]);
    cout << sum << endl;
    int x = a[0], y = a[n-1];
    for (int i = 1; i < n-1; i++) {
        if(a[i]>0) {
            cout << x << ' ' << a[i] << endl;
            x -= a[i];
        } else {
            cout << y << ' ' << a[i] << endl;
            y -= a[i];
        }
    }
    cout << y << ' ' << x << endl;
	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


class question {
public:
	int N, W;
	vector<ll> w;
	vector<int> v;
	int dp() {
		static vector <vector<ll>> memo(101, vector<ll>(100001, 100000000001));
		memo[0][0] = 0;
		int v_sum = 0;
		for (int i = 0;i < N;i++) {
			v_sum += v[i];
			memo[i + 1][0] = 0;
		}
		for (int i = 1;i <= N;i++) {
			for (int j = 1;j <= v_sum;j++) {
				if (j <= v[i - 1]) memo[i][j] = min(memo[i - 1][j], w[i - 1]);
				else memo[i][j] = min(memo[i - 1][j], memo[i - 1][j - v[i - 1]] + w[i - 1]);
			}
		}
		
		return upper_bound(memo[N].begin(), memo[N].end(), W) - memo[N].begin() - 1;
	}
	void ans() {
		cin >> N >> W;
		w.resize(N);
		v.resize(N);
		REP(i, N) cin >> w[i] >> v[i];
		cout << dp() << "\n";
	}
};

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

	question q;
	q.ans();

	return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 998244353;

const int MAX = 10010;

int DP[MAX][MAX];

char buf[MAX];
int A[MAX];
int B[MAX];

LL F[MAX];

LL bpow(LL a, LL b)
{
	LL res = 1;
	while(b)
	{
		if (b & 1) res = (res * a) % MOD;
		b /= 2;
		a = (a * a) % MOD;
	}

	return res;
}

LL inv(LL a)
{
	return bpow(a, MOD - 2);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	F[0] = 1;
	FOR (i, 1, MAX)
	{
		F[i] = (F[i-1] * (LL)i) % MOD;
	}

	scanf("%s", buf);
	int n = strlen(buf);
	FOR (i, 0, n)
	{
		A[i] = buf[i] - '0';
	}

	scanf("%s", buf);
	FOR (i, 0, n)
	{
		B[i] = buf[i] - '0';
	}

	int x, y;
	x = y = 0;
	FOR (i, 0, n)
	{
		if (A[i] == 1 && B[i] == 1) x++;
		if (A[i] == 0 && B[i] == 1) y++;
	}

	DP[0][0] = 1;
	FOR (i, 0, x+1)
	{
		FOR (j, 0, y+1)
		{
			if (i == 0 && j == 0) continue;
			LL cur = 0;
			if (j)
			{
				LL c = j * j;
				c *= DP[i][j-1];
				cur += c;
			}

			if (i && j)
			{
				LL c = i * j;
				c *= DP[i-1][j];
				cur += c;
			}

			DP[i][j] = cur % MOD;
		}
	}

	LL C = 1;
	LL C2 = 1;

	LL N = x + y;

	LL res = 0;
	FOR (i, 0, x+1)
	{
		LL cur = DP[x - i][y];
		cur *= F[i];
		cur %= MOD;
		cur *= F[i];
		cur %= MOD;
		cur *= C;
		cur %= MOD;
		cur *= C2;
		res = (res + cur) % MOD;

		C = (C * (N - i)) % MOD;
		C = (C * inv(i + 1)) % MOD;

		C2 = (C2 * (x - i)) % MOD;
		C2 = (C2 * inv(i+1)) % MOD;
	}

	cout<<res<<endl;


}


Measured memory_bytes: 389760
import java.util.Scanner;

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

        int W = sc.nextInt();
        int H = sc.nextInt();
        int N = sc.nextInt();

        int left = 0;
        int right = W;
        int top = H;
        int down = 0;

        for (int i = 0; i < N; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int a = sc.nextInt();

            if (a == 1 && left < x) {
                left = x;
            } else if (a == 2 && right > x) {
                right = x;
            } else if (a == 3 && down < y) {
                down = y;
            } else if (a == 4 && top > y) {
                top = y;
            }
        }

        if ((right - left) < 0 || (top - down) < 0) {
            System.out.println(0);
        } else {
            System.out.println((right - left) * (top - down));
        }
        sc.close();
    }
}

Measured memory_bytes: 22612
{-# OPTIONS_GHC -O3 #-}
{-# LANGUAGE ViewPatterns, ScopedTypeVariables #-}

import qualified Data.ByteString as B (getLine, getContents)
import qualified Data.ByteString.Char8 as C (readInt, lines, words, unpack, reverse, dropWhile)
import qualified Data.Maybe as M (fromJust)
import Data.Char as C (isSpace)
import qualified Data.IntSet as S

readInt = fst . M.fromJust . C.readInt
rstrip = C.reverse . C.dropWhile C.isSpace . C.reverse

run s (x:xs) | x `S.member` s = run (S.delete x s) xs | otherwise = run (S.insert x s) xs
run s [] = S.size s

main = do
    (map readInt . C.words -> [n]) <- B.getLine
    (map readInt . C.lines -> xs) <- B.getContents
    putStrLn $ show $ run S.empty xs


Measured memory_bytes: 17020
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N, X;
int L[MAX_N];

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

  cin >> N >> X;
  rep(i, N) cin >> L[i];

  int ans = 1;
  int sum = 0;
  rep(i, N) {
    sum += L[i];
    if (sum <= X) {
      ++ans;
    } else {
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] R = new int[n];

		for (int i = 0; i < n; i++) {
			R[i] = sc.nextInt();
		}

		int maxProfit = -2000000000;
		int minProfit = R[0];

		for (int i = 1; i < n; i++) {
			maxProfit = Math.max(maxProfit, R[i] - minProfit);
			minProfit = Math.min(minProfit, R[i]);
		}

		System.out.println(maxProfit);

		sc.close();
	}
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[202020];
ll p10[20];

int ok(int d,int c) {
	ll mo=p10[d+1];
	vector<pair<ll,ll>> V;
	V.push_back({c*p10[d],(c+1)*p10[d]-1});
	
	int i;
	FOR(i,N) {
		vector<pair<ll,ll>> V2=V;
		FORR(v,V) {
			ll a=((v.first-A[i])%mo+mo)%mo;
			ll b=((v.second-A[i])%mo+mo)%mo;
			if(a>b || a==0) return 1;
			V2.push_back({a,b});
		}
		sort(ALL(V2));
		V.clear();
		FORR(v,V2) {
			if(V.size() && v.first<=V.back().second+1) {
				V.back().second=max(V.back().second,v.second);
			}
			else {
				V.push_back(v);
			}
		}
	}
	
	return 0;
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	p10[0]=1;
	FOR(i,18) p10[i+1]=p10[i]*10;
	
	int ret=0;
	for(int d=0;d<=17;d++) {
		for(x=9;x>=0;x--) {
			if(ok(d,x)) {
				ret+=x;
				break;
			}
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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


void solve(long long A, long long B){
    printf("%lld\n", A * B);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;

LL inf = 1000000000000;
LL mod = 1000000007;

int main()
{
	LL h, w;
	cin >> h >> w;

	LL tr = w;
	LL ans = 0;

	if (min(h, w) == 1) {
		cout << 1 << "\n";
	}
	else {
		cout << (h/2)*tr + (h%2)*((w+1)/2) << "\n";

	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main()
{
  int n,l,m,ans;
  char s[500][500];
  ans=0;
  cin >> n;
  rep(i,n){
    rep(j,n){
      cin >> s[i][j];
    }
  }
  rep(k,n){
    rep(i,n){
      FOR(j,i,n){
        l=(i+k)%n;
        m=(j+k)%n;
        if(s[l][j]!=s[m][i])goto P;
      }
    }
    ans++;
    P:;
  }
  printf("%d",ans*n);
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    
    int N;
    cin >> N;
    
    if(N % 1000){
        cout << (1000 - N % 1000) << std::endl;
    }
    else{
        cout << N % 1000 << endl;
    }
    
    return 0;
    
}

Measured memory_bytes: 3604
def bisect(lst, isok, ok, ng):
    while(abs(ok-ng)>1):
        mid = (ok+ng)//2
        if isok(lst[mid]):
            ok = mid
        else:
            ng = mid
    return ok

n = int(input())
a = [int(input()) for i in range(n)]
inf = 10**10
dp = [inf] * (n+1)
dp[0] = -1
for i in a:
    ind = bisect(dp, lambda x:x < i, -1, n+1) #dpは単調増加列なのでbisectが使える
    dp[ind+1] = min(dp[ind+1], i)

for i in range(n+1):
    if dp[n-i]!=inf:
        print(n-i)
        break


Measured memory_bytes: 10444
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    //UnionFindのデータはparで構成されていて、[name].parでアクセスできる
    vector<int> rank; 
    vector<int> unsize;

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

    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(rank[x] < rank[y]){ //木の長さが低い方を高い方に繋げる
            par[rx] = ry;
            unsize[ry] += unsize[rx];
        }else if(rank[x] > rank[y]){
            par[ry] = rx;
            unsize[rx] += unsize[ry];
        }else{
            par[ry] = rx;
            if(rank[rx] == rank[ry]) rank[x]++;
            unsize[rx] += unsize[ry];
        }
    }

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

ll n,m;

int main(){
    cin >> n >> m;
    UnionFind tree(n);
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--; b--;
        tree.unite(a,b);
    }
    vector<ll> cnt(n,0);
    rep(i,n){
        cnt.at(tree.root(i))++;
    }
    ll ans = 0;
    rep(i,n){
        ans = max(ans,cnt.at(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7200
import java.util.Scanner;

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

        while (sc.hasNextInt()) {
            double a1 = sc.nextInt();
            double b1 = sc.nextInt();
            double c1 = sc.nextInt();
            double a2 = sc.nextInt();
            double b2 = sc.nextInt();
            double c2 = sc.nextInt();

            double a = (a1*b2 - a2*b1);
            double x = (c1*b2 - c2*b1) / a + 0;
            double y = (a1*c2 - a2*c1) / a + 0;
            System.out.printf("%.3f %.3f\n", x, y);
        }
    }
}

Measured memory_bytes: 26328
#include<stdio.h>

int main(void){
	int a, b, sum;
	int order;

	while(scanf("%d %d", &a, &b) != EOF){
		order = 0;
		sum = a+b;
		while(sum>0){
			sum = sum/10;
			order++;
		}
		printf("%d\n", order);
	}
	
	return 0;
}

Measured memory_bytes: 600