akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int v[(1<<18)+13];
const int C = 9;
int w[(1<<18)+13];
int dp[(1<<C)+13][111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>v[i]>>w[i];
	}
	memset(dp,-1,sizeof(dp));
	const int L = 100000;
	for(int i=1;i<=min(n,(1<<C)-1);i++)
	{
		dp[i][0]=0;
		if(i>1)
		{
			for(int j=0;j<=L;j++)
			{
				dp[i][j]=max(dp[i][j],dp[i/2][j]);
			}
		}
		dp[i][w[i]]=max(dp[i][w[i]],v[i]);
		if(i>1)
		{
			for(int j=0;j<=L;j++)
			{
				if(j+w[i]<=L) dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i/2][j]+v[i]);
			}
		}
		for(int j=1;j<=L;j++)
		{
			dp[i][j]=max(dp[i][j],dp[i][j-1]);
		}
	}
	int q; cin>>q;
	while(q--)
	{
		int u; int tot;
		cin>>u>>tot;
		vector<ii> extras;
		while(u>(1<<C)-1)
		{
			extras.pb({v[u],w[u]});
			u>>=1;
		}
		int ans=0;
		for(int i=0;i<(1<<(extras.size()));i++)
		{
			int totw=0; int totv=0;
			for(int j=0;j<extras.size();j++)
			{
				if(i&(1<<j))
				{
					totw+=extras[j].se;
					totv+=extras[j].fi;
				}
			}
			if(totw<=tot)
			{
				ans=max(ans,totv+dp[u][tot-totw]);
			}
		}
		cout<<ans<<'\n';
	}
}	


Measured memory_bytes: 233564
N,M=map(int,input().split())

A=[]
array=input().split()
for i in array:
    A.append(int(i))

limit=(1/(4*M))*sum(A)
count=0

for i in range(N):
    if limit<=A[i]:
        count+=1

if count>=M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#ABC12３B
import math
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
lastOrder = min((A-0.5)%10,(B-0.5)%10,(C-0.5)%10,(D-0.5)%10,(E-0.5)%10)
print(math.ceil(A/10)*10 + math.ceil(B/10)*10 + math.ceil(C/10)*10 + math.ceil(D/10)*10 + math.ceil(E/10)*10 - 10 + int(lastOrder) + 1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char, int> mp;
    rep(i, n) mp[s[i]]++;
    ll ans = 1;
    int t=0;
    for(auto p : mp){
        ans*=p.second;
        t++;
    }
    if(t!=3) {
        cout<<0<<endl;
        return 0;
    }
    for(int i=1;i<=n;i++){
        rep(j, n){
            int a, b, c;
            a=j;
            b=j+i;
            c=j+2*i;
            if(c>=n) break;;
            if(s[a]!=s[b] && s[b]!=s[c] && s[a]!=s[c]) ans--;
        } 
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
H,W=list(map(int,input().split()))
img=[[0 for _ in range(W+2)] for _ in range(H+2)]
for y in range(H):
    for x,c in enumerate(input()):
        if c=='#':
            img[y+1][x+1]=1
ans='Yes'
for y in range(1,H+1):
    for x in range(1,W+1):
        if img[y+1][x+1]==1:
            if img[y][x+1]+img[y+2][x+1]+img[y+1][x+2]+img[y+1][x]==0:
                ans='No'
                break
    if ans=='No':
        break
print(ans)

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

typedef long long int ll;
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)

int main() {
	FASTIO;
	double D, T, S;
	cin >> D >> T >> S;
	if (D / S <= T)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 3736
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    K = int(input())
    A = read_list()[::-1]
    if A[0] != 2:
        print(-1)
        return

    minN = 2
    maxN = 2
    for a in A:
        minN = ((minN - 1) // a + 1) * a
        maxN = (maxN // a + 1) * a - 1
    if minN > maxN:
        print(-1)
    else:
        print(minN, maxN)


if __name__ == "__main__":
    main()


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

int main() {
  int a1,a2,a3,a4,a5;
  int sum = 0;
  cin >> a1 >> a2 >> a3 >> a4 >> a5;
  sum = a1 + a2 + a3 + a4 + a5;
  cout << (1+2+3+4+5) - sum << endl;
}

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

using ll = long long;
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

bool flag;
int a[10];

void dfs(int idx, int l, int r) {
   if (idx == 10) {
      flag = true;
      return;
   }

   int val = a[idx];
   if (l < val) dfs(idx+1, val, r);
   if (r < val) dfs(idx+1, l, val);
}

int main() {
   int N;
   cin >> N;
   while (N--) {
      for (int i = 0; i < 10; i++) cin >> a[i];
      flag = false;
      dfs(0, -1, -1);
      puts(flag ? "YES" : "NO");
   }
   return 0;
}


Measured memory_bytes: 3080
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let v = buffer
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .collect::<Vec<_>>();
    let n = v[0];
    let k = v[1];
    buffer.clear();
    stdin.read_line(&mut buffer).unwrap();
    let s = buffer.trim().chars().collect::<Vec<char>>();

    let mut nums = Vec::<u64>::new();
    let mut now = 1;
    let mut cnt = 0;
    for i in 0..n {
        if s[i] as u8 == now + '0' as u8 {
            cnt += 1;
        } else {
            nums.push(cnt);
            now = 1 - now;
            cnt = 1;
        }
    }
    if cnt > 0 {
        nums.push(cnt);
    }
    if nums.len() % 2 == 0 {
        nums.push(0);
    }

    let add = 2 * k + 1;
    let mut ans = 0;
    let mut sum = Vec::new();
    for i in 0..nums.len() + 1 {
        if i == 0 {
            sum.push(0);
        } else {
            let tmp = sum[i - 1] + nums[i - 1];
            sum.push(tmp);
        }
    }

    for i in 0..nums.len() {
        if i % 2 == 1 {
            continue;
        }

        let left = i;
        let right = std::cmp::min(i + add, nums.len());
        let tmp = sum[right] - sum[left];

        ans = std::cmp::max(ans, tmp);
    }

    write!(stdout, "{}\n", ans).unwrap();
}


Measured memory_bytes: 6396
#include <iostream>
#include <iomanip>

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

    double a;

    while (std::cin >> a) {
        double ans = a;
        a *= 2.;

        for (int i = 2; i <= 10; ++i) {
            ans += a;
            a = (i & 1) ? a * 2. : a / 3.;
        }
        std::cout << std::fixed << std::setprecision(6)
                  <<  ans << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1284
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let v: Vec<u16> =
        line.split_whitespace().map(|n| n.parse().unwrap()).collect();
    let n = v[0];
    let m = v[1];
    println!("{}", (n-1)*(m-1));
}

Measured memory_bytes: 4352
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:[(usize,usize);a]
    }
    let mut c=0;
    for i in 0..a {
        if b[i].0==b[i].1{c+=1}
        else {c=0}
        if c==3 {
            println!("Yes");
            exit(0)
        }
    }
    println!("No")
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;cin>>s>>t;
    cout<<t+s;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();
// const int N = 1e5 + 5 ;
const ll mod = 1e9 + 7 ;

ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
bool isBalanced(const string &exp)
{
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}

int gcd(int a, int b , int &x , int &y) {
	if (b == 0) {
		x = 1 ;
		y = 0 ;
		return a ;
	}
	int x1 , y1 ;
	int d = gcd(b , a % b , x1 , y1) ;
	x = y1 ;
	y = x1 - y1 * (a / b) ;
	return d ;

}







int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {
	int n ;
	cin >> n ;
	vector<int> a(10050) ;
	for (int i = 1 ; i < 105 ; i++) {
		for (int j = 1 ; j < 105 ; j++) {
			for (int k = 1 ; k < 105 ; k++) {
				int v = i * i + j * j + k * k + i * j + j * k + k * i ;
				if (v < 10050) a[v]++ ;
			}
		}
	}

	for (int i = 1 ; i <= n  ; i++) {
		cout << a[i] << "\n";
	}




	// }

	return 0 ;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int n;
vector<int> line;
ll factorial(ll x){
	static vector<ll> memo(1e5+5,-1);
	if(x<=1)return 1;
	if(memo[x]>=0)return memo[x];
	return memo[x] = x * factorial(x-1) % MOD;
}

ll func(int place,int x){
	if(place==n){
		return x;
	}
	static vector<map<int,ll>> memo(n);
	if(memo[place].count(x))return memo[place][x];
	ll res = 0;
	res += func(place+1,x%line[place]) * modinv(n-place);
	res += func(place+1,x) * (n-place-1) % MOD * modinv(n-place);
	return memo[place][x] = res % MOD;
}

int main(){
	cin >> n;
	ll x;
	cin >> x;
	rep(i,n){
		int d;
		cin >> d;
		line.push_back(d);
	}

	sort(all(line),greater<int>());

	cout << func(0,x) * factorial(n) % MOD << endl;

	return 0;
}


Measured memory_bytes: 58240
#include <bits/stdc++.h>
using namespace std;
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl;
#define print(v,r) f(i,0,r) cout<<v[i]<<" "; cout<<endl;
#define is_bit(x,y) (x%(1<<(y+1))>=(1<<y))
#define eror(x) cout<<#x<<'='<<(x)<<endl;
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define Gett(x,y) scanf("%d%d",&x,&y);
#define f(i,a,b) for(int i=a;i<b;i++)
#define get(x) scanf("%I64d",&x);
#define All(x) x.begin(),x.end()
#define gett(x) scanf("%d",&x);
#define Add(x,y) x=(x+y)%p
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first

const int N=1e5+9;

int n,frd,a[N];
ll sum;
string s[2]={"First","Second"};

void solve(int trn){
    int g=0,b=0;
    sum=0;
    f(i,0,n)
        if(a[i]!=1)
            b=1;
    if(!b){
        cout<<s[trn^1];
        return ;
    }
    f(i,0,n)
        sum+=a[i]-1;
    if(sum&1){
        cout<<s[trn]<<endl;
        return ;
    }
    f(i,0,n)
        if(a[i]==1){
            cout<<s[trn^1];
            return ;
        }
    f(i,0,n) 
        if(a[i]&1){
            a[i]--;
            break;
        }
    f(i,0,n)
        g=__gcd(g,a[i]);
    f(i,0,n)
        a[i]/=g;
    solve(trn^1);
}
int main(){
    cin>>n;
    f(i,0,n){ gett(a[i]); sum+=a[i]-1; frd++; }
    if(n==1) return cout<<s[1],0;
    solve(0);
        
}

Measured memory_bytes: 4048
#include "stdio.h"
int main(void)
{
	char ref[4];
	char real[4];
	int i;
	int cnt = 0;
	
	scanf("%s", ref);
	scanf("%s", real);
	
	for ( i = 0; i < 3; i++ ) {
		if (ref[i] == real[i]) {
			cnt++;
		}
	}
	
	printf("%d\n",cnt);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, c) for (int i = 0; i < c; i++)
#define MOD 1000000007
using namespace std;

int main() {
  int k, n;
  cin >> k >> n;
  int a[n];
  FOR(i, n) {
    cin >> a[i];
  }
  sort(a, a+n);
  int maxx = k-a[n-1]+a[0];
  FOR(i, n) {
    if (i) maxx = max(maxx, a[i]-a[i-1]);
  }
  cout << k-maxx << endl;
  return 0;
}



Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n;
ll a[21][21];
ll dp[22][(1<<21)];

int main() {
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    dp[0][0] = 1;
    rep(i,n) {
        rep(j,(1<<n)) {
            if (dp[i][j] == 0) continue;
            rep(k,n) {
                if (!(j&(1<<k)) && a[i][k]) dp[i+1][j^(1<<k)] = dp[i+1][j^(1<<k)]+dp[i][j];
            }
        }
        rep(j,(1<<n)) {
            dp[i+1][j] %= MOD;
        }
    }
    cout << dp[n][(1<<n)-1] << endl;
}



Measured memory_bytes: 344448
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;

LL tr[100005];

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

	for (int i = 0;i < m - 1;i++) {
		int b = a[i];
		int c = a[i + 1];
		tr[min(b, c) - 1]++;
		tr[max(b, c) - 1]--;
	}
	for (int i = 1;i <n;i++) {
		tr[i] += tr[i - 1];
	}
	long long ans = 0;

	for (int i = 0;i < n - 1;i++) {
		LL d, e, f;
		cin >> d >> e >> f;
		ans += min(d*tr[i], e*tr[i] + f);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4612
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long n = sc.nextLong();
		StringBuilder sb = new StringBuilder();
		while (n > 0) {
			n--;
			int t = (int) (n % 26);
			sb.insert(0, (char) ('a' + t));
			n = n / 26;
		}
		System.out.println(sb.toString());
	}
}








Measured memory_bytes: 35808
#include<bits/stdc++.h>
using namespace std;
void depth(vector<vector<vector<int>>> &g,vector<int64_t> &d,vector<bool> &c,int v,int64_t vd){
  d.at(v)=vd;
  c.at(v)=1;
  for(auto x:g.at(v)){
    int va=x.at(0);
    int vc=x.at(1);
    if(c.at(va))
      continue;
    depth(g,d,c,va,vd+vc);
  }
  return;
}
int main(){
  int n;
  cin>>n;
  vector<vector<vector<int>>> g(n);
  for(int _=0;_<n-1;_++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;
    b--;
    g.at(a).push_back({b,c});
    g.at(b).push_back({a,c});
  }
  int q,k;
  cin>>q>>k;
  k--;
  vector<int64_t> d(n);
  vector<bool> c(n,0);
  depth(g,d,c,k,0);
  for(int _=0;_<q;_++){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    cout<<d.at(x)+d.at(y)<<endl;
  }
}

Measured memory_bytes: 29848
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n,b_sum,a[100001],b[100001],c[100001],ans;
int main() 
{
   cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>a[i]>>b[i];
      c[i]=a[i]+b[i];
      b_sum+=b[i];
   }
   sort(c,c+n);
   reverse(c,c+n);
   for(int i=0;i<n;i++)
   {
		if(i%2==0)
		{
			ans+=c[i];
    	}
   }
   ans-=b_sum;
   cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N, K, S;
  cin >> N >> K >> S;
  vector<i64> ans(N);
  i64 P = 0;
  for(i64 i = 2;true;i++) {
    if(S % i != 0) {
      P = i;
      break;
    }
  }
  for(i64 i = 0;i < N; i++) {
    if(i < K)
      ans[N - 1 - i] = S;
    else {
      ans[N - 1 - i] = P;
    }
  }
  rep(i,0,N) {
    cout << ans[i] << " \n"[i + 1 == N];
  }
}


Measured memory_bytes: 2048
// --------------
// Tejas Pandey  |
// 19 - 01 - 20  |
// ABC #152      |
// --------------

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		map<pair<int,int>,ll> mp;
		ll ans = 0;
		for(int i = 1;i <= n;i++){
			int f = i;
			while(f >= 10) f/=10;
			mp[{f,i%10}]++;
		}
		for(int i = 1;i <= n;i++){
			int f = i;
			while(f >= 10) f/=10;
			ans += mp[{i%10,f}];
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  // ????????????????????????
  var inputs = chunk.toString().trim().split('\n');
  for (var i = 0; i < inputs.length; i++) {
    if (inputs[i] === '0 0') {
      break;
    }
    var cols = inputs[i].split(' ').map(Number);
    console.log(
      cols.sort(function(a,b) {
        return a - b;
      }).join(' ')
    );
  }
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 19408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define S(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;
int main()
{
   ll l,r,d;
   cin>>l>>r>>d;;
   ll ans = 0;
   loop(i,l,r+1){
      if(i%d == 0)ans++;
   }
   cout<<ans<<endl;  
}

Measured memory_bytes: 3632
#include <iostream>

int score_a, score_b;

int main(void)
{
    using namespace std;
    int n, data_a, data_b;

    while(1)
    {
        cin >> n;
        if (n == 0) break;
        score_a = 0;
        score_b = 0;
        for(; n > 0 ; n--) {
            cin >> data_a;
            cin >> data_b;
            if (data_a > data_b) {
                score_a += (data_a + data_b);
            } else if(data_a < data_b) {
                score_b += (data_a + data_b);
            } else {
                score_a += data_a;
                score_b += data_b;
            }
        }
        cout << score_a << " " << score_b << endl;
    }

    return 0;
}

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


int main() {
    int N,K;
    cin >> N >> K;
    vector<int> V(N);
    for(int i=0;i<N;i++){
        cin >> V.at(i);
    }
    sort(V.begin(),V.end());
    long long ans=0;
    N-=K;//最後の方はいらないからNを減らした
    for(int i=0;i<N;i++){
        ans+=V.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<map>
#define LL long long
#define LD long double
#define INF (1LL<<60)
using namespace std;
map<LL,LL> :: iterator it;
map<LL,LL> F,G;
int n,ans; LL a[100005],p[64],lp;
LL fpc(LL x,LL y,LL mo){ return ((x*y-(LL)((LD)x*y/mo)*mo)%mo+mo)%mo;}
LL fpm(LL x,LL y,LL mo){ LL s=1; while(y){ if(y&1) s=fpc(s,x,mo); y>>=1,x=fpc(x,x,mo);} return s;}
LL gcd(LL x,LL y){ return x ? gcd(y%x,x) : y;}
bool miller_rabin(LL p)
{
	LL a=rand()%(p-1)+1,q=p-1,x,y;
	if(p<=3) return 1;
	while(!a) a=rand()%p;
	for(;(q&1)^1;q>>=1);
	x=fpm(a,q,p);
	for(;q<p-1;q<<=1,x=y){
		y=fpc(x,x,p);
		if(y==1&&x!=1&&x!=p-1) return 0;
	  }
	return x==1;
}
bool test(LL x)
{
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	if(!miller_rabin(x)) return 0;
	return 1;
}
LL pollard_rho(LL n)
{
	LL d,c,x,y,a,b;
	for(c=2;;c++){
		y=1,b=a=rand()%n;
		for(x=1;x;x++){
			a=(fpc(a,a,n)+c)%n;
			if(b==a) break;
			d=gcd(abs(b-a),n);
			if(d!=1) return d;
			if(x==y) y<<=1,b=a;
		  }
	  }
	return 0;
}
void divide(LL x)
{
	LL d;
	if(x==1) return ;
	if(x==2){ p[++lp]=2; return ;}
	if(x==4){ p[++lp]=2,p[++lp]=2; return ;}
	if(test(x)){ p[++lp]=x; return ;}
	d=pollard_rho(x);
	divide(d);
	divide(x/d);
}
int main()
{
	int i,k,l,tag=0; LL y,z;
	srand(2222303);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	for(i=1;i<=n;i++){
		lp=0,divide(a[i]);
		sort(p+1,p+lp+1);
		y=z=1;
		for(k=1;k<=lp;k=l){
			for(l=k;l<=lp&&p[k]==p[l];l++);
			if((l-k)%3==2) y*=p[k]*p[k],z=z>0 ? z*p[k] : -1;
			if((l-k)%3==1){
				y*=p[k];
				if(z>0&&z<=INF/p[k]/p[k]) z*=p[k]*p[k];
				else z=-1;
			  }
		  }
		if(z==-1){ ans++; continue;}
		if(y==1){
			if(!tag) ans++,tag=1;
			continue;
		  }
		F[y]++,G[y]=z;
	  }
	for(it=F.begin();it!=F.end();it++){
		y=G[it->first],z=F[y];
		if(it->second>z||(it->second==z&&it->first>y))
			ans+=it->second;
	  }
	cout<<ans;
	return 0;
}


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

int N, M;
vector<vector<int>> G(100000, vector<int>(0));

int main()
{
  cin >> N >> M;
  vector<int> H(N);
  for (int i = 0; i < N; i++)
  {
    cin >> H.at(i);
  }
  for (int i = 0; i < M; i++)
  {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }

  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    int flag = true;
    for (int j = 0; j < G.at(i).size(); j++)
    {
      if (H.at(G.at(i).at(j)) >= H.at(i))
      {
        flag = false;
      }
    }
    if (flag)
    {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 8804
N = int(input())
a = list(map(int, input().split()))

tmp = [0] * (N+1)
ans = 0

for i in a:
    if i > N:
        ans += 1
    else:
        tmp[i] += 1

for i in range(N+1):
    if i > tmp[i]:
        ans += tmp[i]
    elif i < tmp[i]:
        ans += tmp[i] - i

print(ans)

Measured memory_bytes: 14268
#include <bits/stdc++.h>
     
    #define ll          long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        1000000007
    #define rep(i,a,b)  for(int i=a;i<b;i++)
    using namespace std;
    int q;
    string s;
    set<int> st[26];
    void solve(){
    	int n;
    	cin>>n;
        cin>>s;
        rep(i,0,sz(s)) st[s[i]-'a'].insert(i);
        cin>>q;
        
        while(q--){
            int type;
            cin>>type;
            if(type==1){
                int pos;
                char c;
                cin>>pos>>c;
                pos--;
                st[s[pos]-'a'].erase(pos);
                s[pos]=c;
                st[s[pos]-'a'].insert(pos);
            }
            else{
                int l,r;
                cin>>l>>r;
                l--,r--;
                int ans=0;
                rep(i,0,26){
                    auto d=st[i].lower_bound(l);
                    if(d!=st[i].end() and *d<=r) ans++;
                }
                cout<<ans<<endl;
            }
        }
    }
     
    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        // cin>>t;
        while(t--){
            solve();
        }
        return 0;
    }

Measured memory_bytes: 24220
#include<stdio.h>
int main(){
	long long h,n,k;
	scanf("%lld%lld",&h,&n);
	while(n--){
		scanf("%lld",&k);
		h-=k;
		if(h<=0){
			printf("Yes");
			return 0;
		}
	}
	if(h<=0) printf("Yes");
	else printf("No");
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 9999999999;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

int main()
{
	std::ios::sync_with_stdio(false);
	
	ll n,l;
	cin >> n >> l;
	ll sum = 0;
	vll v(n+2);
	for(int i = 1;i<=n;i++)
	{
		v[i] = l+i-1;
		sum+=v[i];
	}

	ll ans = LLONG_MAX;
	ll pri;
	for(int i = 1;i<=n;i++)
	{
		ll sum2 = sum-v[i];
		if(abs(sum-sum2)<ans)
		{
			ans = abs(sum-sum2);
			pri = sum2;
		}
	}
	cout << pri << endl;

	return 0;
}



Measured memory_bytes: 256
;; D - Lunlun Number

(defparameter *max-n-digits* 10) ; 最大桁数 (入力例4を参照)

(defun next-lunlun (lun &optional (i 0))
  "i桁目以降を次のルンルン数に更新. lunは最下位桁から順に格納."
  (cond ((null (aref lun i))
          (setf (aref lun i) 1))
        ((>= (aref lun i) (min (1+ (or (aref lun (1+ i)) 9)) 9))
          ; 桁上がり
          (next-lunlun lun (1+ i))
          (setf (aref lun i) (max 0 (1- (aref lun (1+ i))))))
        (t ; 桁上がりなし
          (incf (aref lun i)))))

(defun lunlun-to-int (lun)
  "配列lun (先頭が最下位桁) を整数に変換"
  (map 'string #'digit-char (nreverse (remove nil lun))))

(defun lunlun (k)
  "k番目のルンルン数"
  (loop with lun = (make-array (1+ *max-n-digits*) :initial-element nil)
             ; 各桁を格納する配列 (最下位桁が先頭)
        repeat k do (next-lunlun lun)
        finally (return (lunlun-to-int lun))))

(let ((k (read)))
  (princ (lunlun k)))


Measured memory_bytes: 7780
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,x[5];
    for(i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<5;i++){
        if(x[i]==0)
          printf("%d\n",i+1);
    }
    return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;
import java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int[][] dp = new int[s.length() + 1][t.length() + 1];

		for (int i = 0; i <= s.length(); i++) {
			dp[i][0] = 0;
		}
		for (int i = 0; i <= t.length(); i++) {
			dp[0][i] = 0;
		}
		for (int i = 1; i <= s.length(); i++) {
			for (int j = 1; j <= t.length(); j++) {
				if (s.charAt(i - 1) == t.charAt(j - 1)) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				} else {
					dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		int i = s.length();
		int j = t.length();
		String result = "";
		while (i > 0 && j > 0) {
			if (dp[i][j] == dp[i][j - 1]) {
				j--;
			}
			else if (dp[i][j] == dp[i - 1][j]) {
				i--;
			}
			else{
				result = s.charAt(i - 1) + result;
				i--;
				j--;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 86720
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////

int N;
char W[111][20];

int main(){
    cin>>N;
    fornum(i,0,N){
        cin>>W[i];
    }
    
    fornum(i,1,N){
        j=0;
        while(W[i-1][j]!='\0')j++;
        if(W[i][0]!=W[i-1][j-1]){
            cout<<"No";
            return 0;
        }
    }
    fornum(i,0,N){
        fornum(j,i+1,N){
            for(k=0;W[i][k]==W[j][k];k++){
                if(W[i][k]=='\0'){
                    cout<<"No";
                    return 0;
                }
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
using namespace std;

int main(void){
	int a,b;
	char op;
	
	while(1){
		cin>>a>>op>>b;
		if(op=='+')cout<<a+b<<endl;
		else if(op=='-')cout<<a-b<<endl;
		else if(op=='*')cout<<a*b<<endl;
		else if(op=='/')cout<<a/b<<endl;
		else if(op=='?')return 0;

	}
}


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

using namespace std;

#define ll long long
#define mod (ll)1000000007

const ll INF = 1e11;

void solve(){

    int a; cin >> a;
    cout << a + a*a + a*a*a;

    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    //int test; cin >> test;
    //for(int t = 1; t <= test; ++t){
        solve();    
    //}

	return 0;
}



Measured memory_bytes: 3604
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(max(a)+1)]
for x in a:
    b[x] += 1
c = sum([x*(x-1)//2 for x in b])
for i in range(n):
    print(c-b[a[i]]+1)

Measured memory_bytes: 90792
import sys
from fractions import gcd

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = int(read())
ans = 0

gcd_list = [[0]*210 for i in range(210)]
num_ct = [0]*210

for a in range(K):
    for b in range(K):
        tmp = gcd(a+1,b+1)
        gcd_list[a+1][b+1] = tmp
        num_ct[tmp] += 1

for c in range(K):
    for tmp in range(K):
        ans += gcd_list[c+1][tmp+1] * num_ct[tmp+1]

print(ans)

Measured memory_bytes: 75900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
 
public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int r = sc.nextInt() * 100;
		int g = sc.nextInt() * 10;
		int b = sc.nextInt();
		
		if ((r + g + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
  
    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;

    int n = s.size(), indexA = -1, indexZ = -1;
    rep(i, n)
    {
        if (s[i] == 'A')
        {
            indexA = i;
            break;
        }
    }
    rep(i, n)
    {
        if (s[n - i - 1] == 'Z')
        {
            indexZ = n - i - 1;
            break;
        }
    }

    cout << indexZ - indexA + 1 << "\n";

    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define ld long double
    #define MOD 1000000007
    #define mod9 1000000009
    #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    #define mp make_pair
    #define pb push_back
    #define ct ll t;cin>>t;while(t--)
    #define bi begin()
    #define ei end()
    #define fi first 
    #define se second  
    #define foe(i,a,b) for(ll i=a;i<b;i++)
    #define rfoe(i,a,b) for(ll i=a;i>=0;i--)
    #define sz(s) s.size() 
    #define mem(a,s) memset(a,s,sizeof(a)) 
    #define all(v) v.bi,v.ei
    #define MAX             8000000000000000064LL
    #define MIN            -8000000000000000064LL   

    typedef pair<ll,ll> pii;
    
    ll add(ll a, ll b){return (a%MOD + b%MOD + ((MAX)/MOD)*MOD)%MOD;}
    ll sub(ll a, ll b){return (a%MOD - b%MOD + ((MAX)/MOD)*MOD)%MOD;}
    ll mul(ll a, ll b){return ((a%MOD)*(b%MOD) + ((MAX)/MOD)*MOD)%MOD;}
    ll lcm(ll a,ll b){return(a*b)/__gcd(a,b);}
    ll fact[1000007 ]={0};
    ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
    y=y>>1;x=(1ll*x*x)%MOD;} return res;}
    void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
    ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
    ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
    int const N=2e5+9;
    ll const INF = 2e18+5;
    ll dx[8]={0,0,1,-1,1,1,-1,-1};
    ll dy[8]={1,-1,0,0,-1,1,-1,1};
    long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = mul(res,a);
        a = mul(a,a);
        b >>= 1;
    }
    return res%MOD;
}
    void solve()
    {  
          ll n;cin>>n;
        ll ans = binpow(10,n);
        ans-=2*(binpow(9,n))%MOD;
        ans%=MOD;
        ans+=MOD;
        ans%=MOD;
        ans+=binpow(8,n);
        ans+=MOD;
        ans%=MOD;
        ans+=MOD;
        ans%=MOD;
        cout<<ans<<endl;
    }
    int main()
    {
        fast
        // facto();
        // Sieve();
    //    ct    
        { 
            solve();
        }
    }


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String... args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        int[][] dp = new int[n][2];
        /*
        dp[i][0]: 増加(非減少)
        dp[i][1]: 減少
        dp[i][x]: iまで数列を見たときの，分割列の最小数
        */
        dp[0][0] = 1;
        dp[0][1] = 1;
        for(int i = 1; i < n; i++) {
            dp[i][0] = dp[i - 1][0] + 1;
            dp[i][1] = dp[i - 1][1] + 1;
            if(a[i] >= a[i - 1]) dp[i][0]--;
            if(a[i] <= a[i - 1]) dp[i][1]--;
            dp[i][0] = Math.min(dp[i][0], dp[i][1] + 1);
            dp[i][1] = Math.min(dp[i][0] + 1, dp[i][1]);
        }
        System.out.println(Math.min(dp[n - 1][0], dp[n - 1][1]));
    }
}


Measured memory_bytes: 50340
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools, bisect
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    N, K = LI()
    P = LI()

    cum = 0
    for i in range(K):
        cum += (P[i] + 1) / 2

    ans = cum
    for i in range(N - K):
        cum += (P[i + K] + 1) / 2 - (P[i] + 1) / 2
        ans = max(ans, cum)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 103436
#include<stdio.h>
int main(void){
  int a,b,k,n,f=0;
  
  scanf("%d",&k);
  scanf("%d %d",&a,&b);
  
  for(n=a;n<=b;n++){
    if(n%k == 0){
      f = 1;
      break;
    }
  }
  
  if(f == 1){printf("OK");}
  else{printf("NG");}
  
  return 0;
}


Measured memory_bytes: 1732
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
const int mod = 1000000007;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

ll st2(int n) {
  int c = 0;
  for (int mask = 0; mask < (1 << n); ++mask) {
    vi v(2 * n);
    for (int i = 0; i < n; ++i) if (mask & (1 << i)) v[i] = v[i+n] = 1;
    for (int i = 0; i < n; ++i) {
      bool ok = 1;
      for (int j = 0; j < n/2; ++j) if (v[i + j] != v[i + n - j - 1]) {
        ok = 0; break;
      }
      if (ok) {
        ++c;
        break;
      }
    }
  }
  return c;
}

int main() {
  ll n, k;
  cin >> n >> k;
//  if (k == 2 && n <= 20) cerr << st2(n) << endl;
//  if (n % 2) {
//    cout << (f(n, k) + mod) % mod << endl;
//  } else {
    vi d;
    for (int i = 1; i * i <= n; ++i) if (n % i == 0) {
      d.push_back(i);
      if (i * i != n) d.push_back(n / i);
    }
    sort(d.begin(), d.end());
    vl v(d.size());
    for (int i = 0; i < d.size(); ++i) {
      v[i] = mpow(k, (d[i] + 1) / 2);
      for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) v[i] = (v[i] - v[j]) % mod;
    }
    ll res = 0;
    for (int i = 0; i < d.size(); ++i) {
      if (d[i] % 2 == 0) res = (res + d[i] / 2 * v[i]) % mod;
      else res = (res + d[i] * v[i]) % mod;
    }
    cout << (res + mod) % mod << endl;
//  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


class UnionFind {
public:
	vector<int> s, p;

	UnionFind() {}
	UnionFind(int size) {
		s.resize(size, 0);
		p.resize(size, 0);
		rep(i, 0, size)makeSet(i);
	}

	void makeSet(int x) {
		p[x] = x;
		s[x] = 1;
	}

	bool same(int x, int y) {
		return findSet(x) == findSet(y);
	}

	void unite(int x, int y) {
		x = findSet(x);
		y = findSet(y);

		if (x == y)return;

		if (s[x] < s[y])swap(x, y);

		p[y] = x;
		s[x] += s[y];
	}


	int findSet(int x) {
		if (x == p[x]) {
			return x;
		}
		else {
			return p[x] = findSet(p[x]);
		}
	}

	int size(int x) {
		return s[findSet(x)];
	}
};

const ll MAX = 110000;
ll N;
vector<ll>x, y;

ll solve() {
	UnionFind un = UnionFind(2*MAX);
	x.resize(N); y.resize(N);
	rep(i, 0, N)cin >> x[i] >> y[i], un.unite(x[i],y[i]+MAX);
	map<int, ll>mx, my;
	rep(i, 0, MAX)mx[un.findSet(i)]++;
	rep(i, MAX, 2 * MAX)my[un.findSet(i)]++;
	ll res = 0;
	rep(i, 0, 2 * MAX)res += mx[i] * my[i];
	return res - N;
}

int main() {
	cin >> N;
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 30976
#include <iostream>
using namespace std;
int main(){
  int n,p,data[50],i,d,result;
  while(1){
    cin >> n >> p;
    d=p;
    if(n==0&&p==0) break;
    for(i=0;i<n;i++) data[i]=0;
    i=0;
    while(1){
      if(p>0){
    p--;
        data[i]++;
    if(data[i]==d){
      result=i;
      break;
    }
      }else if(p==0){
        p=data[i];
        data[i]=0;
      } 
      if(i+1==n) i=0;
      else i++;
    }
    cout << result << endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);
//const int INF=(1<<29);

int main(){
  int N;
  cin >> N;
  vector<ll> a(N),b(N);
  REP(i,N){
    cin >> a[i] >> b[i];
  }
  sort(ALL(a));
  sort(ALL(b));

  if(N%2==1){
    cout << b[N/2] - a[N/2] + 1 << endl;
  }else{
    cout << b[N/2] + b[N/2-1] - a[N/2] - a[N/2-1] + 1 << endl;
  }
}



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

int main(){
    int x;
    cin >> x;
   int factor[40];
   for(int i = 0; i < 40 ; i ++)factor[i] = 0;
  int  xx = x;

   int max = 1;
   int tmp = -1;
   for(int i = 2 ; i < 10;i++ ){
    for(int j = 2; j<x;j++){
      tmp = (int)pow(j,i);
      if( tmp<= x){
        if(tmp > max)max = tmp;
      }else{
        break;
      }
    }
   }
   cout<< max << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;


int n,s[200];

/*
input data
*/

void init(){
}

bool input(){
	cin>>n;
	if(n==0) return false;
	for(int i=0; i<n; i++) cin>>s[i];
	return true;
}


void swap(){
	int tmp;
	for(int i=0; i<n; i++){
		for(int j=n-1; j>i; j--){
			if(s[j-1]>s[j]){
				tmp=s[j-1];
				s[j-1]=s[j];
				s[j]=tmp;
			}
		}
	}
}



int solve(){
	int sum=0, ans=0;
	swap();
	for(int i=1; i<n-1; i++){
		sum+=s[i];
	}
	ans=sum/(n-2);
	return ans;
}


int main(){
  while(input()){
    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 1160
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAXN 100000
struct Point
{
    int t,x,y;
}A[MAXN+5],p;
int N;

bool cmp(Point a,Point b){return a.t<b.t;}
int dis(Point a,Point b){return abs(a.x-b.x)+abs(a.y-b.y);}

int main()
{
    scanf("%d",&N);
    for(int i=1;i<=N;i++)
        scanf("%d%d%d",&A[i].t,&A[i].x,&A[i].y);
    sort(A+1,A+N+1,cmp);
    for(int i=1;i<=N;i++)
        if(((A[i].t-p.t)%2!=dis(p,A[i])%2)||(A[i].t-p.t<dis(p,A[i])))
        {
            printf("No");
            return 0;
        }
        else p=A[i];
    printf("Yes");
}


Measured memory_bytes: 1280
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

int G[505][505];

int main() {

	boost;
	int n, m, q; cin>>n>>m>>q;
	for(int i=1; i<=m; i++) {
		int l, r; cin>>l>>r;
		G[l][r]++;
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			G[i][j] += G[i][j-1];
		}
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			G[i][j] += G[i-1][j];
		}
	}
	for(int i=1; i<=q; i++) {
		int l, r; cin>>l>>r;
		cout<<G[n][r] - G[l-1][r]<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int main(){
int N; 
string S; 
cin >> N >> S; 
int X = 0; 
int ans = 0; 
for (int i = 0; i < S.size(); ++i){
if(S.at(i) == 'I'){
X ++; 
}
else if(S.at(i) == 'D'){
X --; 
}
ans = max(ans, X); 
}
cout << ans << endl; 
}

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

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

  while(true) {
    int x, y, s;
    int sales;
    int max = -999999999;
    int hoz_i, hoz_j;
    cin >> x >> y >> s;
    if(x + y + s == 0) break;

    FOR(i, 1, s) {
      FOR(j, 1, s) {
        if((i * (100 + x) / 100) + (j * (100 + x) / 100) != s) continue;
        sales = (i * (100 + y) / 100) + (j * (100 + y) / 100);
        if(sales > max) {
          max = sales;
        }
      }
    }

    cout << max << endl;

  }
}



Measured memory_bytes: 3152
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var values = o.getArray(0);
    var A = values[0];
    var B = values[1];

    if (A > 9) {
        return -1;
    }

    if (B > 9) {
        return -1;
    }

    return A * B;
}

Measured memory_bytes: 7372
N=int(input())
L=list(map(int,input().split()))
count=0
for a in range(N):
    for b in range(N):
        for c in range(N):
            if L[a]<(L[b]+L[c]) and L[b]<(L[a]+L[c]) and L[c]<(L[b]+L[a]) and L[a]!=L[b] and L[a]!=L[c] and L[c]!=L[b] and a<b<c:
                count=count+1
            else:
                continue
print(count)

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

const int MAXN = 1e5+7;
int f[MAXN];

int main() {
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                f[x*x+y*y+z*z+x*y+y*z+z*x]++;
            }
        }
    }

    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) cout << f[i] << "\n";

    return 0;
}


Measured memory_bytes: 3828