akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const int MX = 100;
const LL INF = 1e9;

void print_a(VI v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    int l = min(n,MX), ans[n+1] = {0}, fn;
    loop(x,1,l+1)
    {
        loop(y,1,l+1)
        {
            loop(z,1,l+1)
            {
                fn = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
                if(fn <= n) ++ans[fn];
            }
        }
    }

    loop(i,1,n+1) cout<<ans[i]<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

int main( void )
{
    int N;
    float v[50];
    int i;
    int j;
    int temp;
    
    scanf( "%d", &N);
    if( N <= 100 )
    {
        for( i=0; i<N; i++ )
        {
            scanf( "%f", &v[i] );
        }
    }
    
    for( j=1; j<=N; j++ )
    {
        for( i=0; i<N-j; i++ )
        {
            temp = v[i];
            if( temp > v[i+1] )
            {
                v[i] = v[i+1];
                v[i+1] = temp;
            }
        }
    }
    
    for( i=0; i<N; i++ )
    {
        v[i+1] = ( v[i] + v[i+1] ) / 2;
    }
    
    printf( "%f", v[N-1] );
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define intt int64_t
#define all(vec) vec.begin(), vec.end()
#define INF 2000000000

int main() {
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> vec(n);
    rep(i,n) scanf("%d", &vec.at(i));
    sort(all(vec), greater<>());
    int ans = 0;
    rep(i,k) ans += vec.at(i);
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iomanip>

using namespace std;
// for loop
#define F(i, L, R) for(int i = L; i < R; i++)
#define FE(i, L, R) for(int i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(int i = L; i > R; i--)
#define FRE(i, L, R) for(int i = L; i >= R; i--)

// data types
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void draw(int h, int w) {
    if(h == 0 || w == 0) {cout << endl; return;}
    F(k, 0, h){
      string width = "";
      F(i, 0, w){
          if(k == 0 || k == h-1 || i == 0 || i == w-1)
              width += '#';
          else
              width += '.';
      }
      cout << width << endl;
    }
    cout << endl;
}

int main() {
    vvi data;
    while(1) {
        int h,w;
        vi vec;
        cin >> h >> w;
        if(h == 0 && w == 0)break;
        vec.push_back(h);
        vec.push_back(w);
        data.push_back(vec);
    }

    F(i, 0, data.size()){
        draw(data[i][0], data[i][1]);
    }

    return 0;
}



Measured memory_bytes: 3204
//21
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

char s[101];
int i,n;
char a;

void cat(string &a,const string &b){
  if(a.size()<=n){
    a+=b;
  }
}

string rs();
string prs();

string rs(){
  if(isalpha(s[i])){
    return string(1,s[i++]);
  }else{
    i++;
    string r=prs();
    i++;
    return r;
  }
} 

string prs(){
  string r;
  if(isalpha(s[i])){
    cat(r,string(1,s[i]));
    i++;
    cat(r,prs());
  }else if(isdigit(s[i])){
    int n=0;
    for(;isdigit(s[i]);i++){
      n=n*10+s[i]-'0';
    }
    string rst=rs();
    while(n--){
      cat(r,rst);
    }
    cat(r,prs());
  }
  return r;
}

int main(){
  for(;cin>>s>>n,s[0]!='0'||n;){
    i=0;
    string r;
    r=prs();
    cout<<((n<r.size())?r[n]:'0')<<endl;
  }
  return 0;
}
      

Measured memory_bytes: 6120
use std::io::*;
use std::str::FromStr;
use  std::collections::BTreeMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let l: f64 = read();
    let a = l / 3.0;
    println!("{:.6}", a * a * a);
}

// n (n - 1) - (n - 1) (n - 2) = 2 (n - 1)


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int X = scanner.nextInt();
        if (X >= A && (A + B) >= X) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () {
            s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 21204
#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

typedef long long int ll;

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


int main(){
  int a,b;
  cin >> a >> b;
  cout << max(max(a+b,a-b),a*b) << endl;
}



Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                    ans += 1

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
const int Maxn = 200005;
const ll Inf = 4000000000000000000ll;
 
int n;
ll sum[Maxn];
ll res = Inf;
 
void Get(int l, int r, ll &fir, ll &sec)
{
	ll res = Inf;
	int lef = l, rig = r - 1;
	while (lef <= rig) {
		int mid = lef + rig >> 1;
		ll a = sum[mid] - sum[l - 1];
		ll b = sum[r] - sum[mid];
		if (abs(a - b) < res) {
			res = abs(a - b);
			fir = a; sec = b;
		}
		if (a <= b) lef = mid + 1;
		else rig = mid - 1;
	}
}
 
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int a; scanf("%d", &a);
		sum[i] = a + sum[i - 1];
	}
	for (int i = 2; i <= n - 2; i++) {
		ll a, b; Get(1, i, a, b);
		ll c, d; Get(i + 1, n, c, d);
		ll cand = max(max(a, b), max(c, d)) - min(min(a, b), min(c, d));
		res = min(res, cand);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll N; cin >> N;
    vector<int> a(20,0);
    ll tmp = 26;
    int c=0;
    while(N>=1){
        int t = N%tmp;
        N /= tmp;
        if(t==0){
            t = 26;
            N--;
        }
        a[c++] = t-1;
        cerr << t << "\t" << (char)(t+'a') << "\t" << (char)(t+'a'-1) << endl;
    }
    cerr << c << endl;
    for(int i=c-1;i>=0;i--){
        cout << (char)(a[i]+'a');
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
    return a;
    else return gcd(b,a%b);
}
int main() {
    int n;
    cin>>n;
    long long int ans=0;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
    for(int k=1;k<=n;k++)
    ans+=gcd(gcd(i,j),k);
    cout<<ans;
	return 0;
}

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

int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;

  // speed [rad/sec]
  double Mspeed = 2.0*M_PI / 3600.0;
  double Hspeed = 2.0*M_PI / (3600.0*12.0);

  // time [sec]
  uint64_t time_sec = H * 3600 + M * 60;
  double Mangle = Mspeed * (double)time_sec;
  double Hangle = Hspeed * (double)time_sec;

  Mangle = fmod(Mangle, 2.0*M_PI);

  double theta = min( Hangle - Mangle, Mangle-Hangle );

  cout << fixed << setprecision(20) << sqrt( A*A + B*B - 2.0*A*B*cos(theta) ) << endl;
}

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

int main(){
  int N,T,A,minK=1e9+7,P=-1;
  cin >> N >> T >> A;
  for(int i=0;i<N;i++){
    int H;
    cin >> H;
    int K=abs(1000*A-1000*T+H*6);
    if(minK>=K){
      minK=K;
      P=i+1;
    }
  }
  cout << P << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	ll C0 = 0, C1 = 0, C3 = 0, C2 = 0;
	rep(i, N) {
		string S;
		cin >> S;
		if (S == "AC")C0++;
		else if (S == "WA")C1++;
		else if (S == "TLE")C2++;
		else if (S == "RE")C3++;
	}
	cout << "AC x " << C0 << endl;
	cout << "WA x " << C1 << endl;
	cout << "TLE x " << C2 << endl;
	cout << "RE x " << C3 << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
const int N = 1000064;
int A[N], B[4];
int main() {
	int m, x, *a = A, *b = B;
	scanf("%*d%d",&m);
	if (m == 1) {
		scanf("%d",&x);
		if (x == 1) puts("1\n1\n1");
		else printf("%d\n2\n1 %d",x,x-1);
		return 0;
	}
	while (m--) {
		scanf("%d",&x);
		*(x&1 ? b : a)++ = x;
		if (b > B+2) {puts("Impossible"); return 0;}
	}
	while (b != B+2) *b++ = *--a;
	printf("%d ",B[1]);
	for (int *i = a; i != A;) printf("%d ",*--i);
	printf("%d\n%d\n%d",*B,int(a-A)+1+(*B>1),B[1]+1);
	for (int *i = a; i != A;) printf(" %d",*--i);
	if (--*B) printf(" %d",*B);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int x = n%10;
  if(x==0 || x==1 || x==6 || x==8){
    cout << "pon\n";
  }else if(x==3){
    cout << "bon\n";
  }else{
    cout << "hon\n";
  }

  return 0;
}



Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <stdio.h>

struct Katana {
	int damage;
	bool isSingle;
};

Katana a[200000];

int main() {
	int N, H;
	scanf("%d %d", &N, &H);
	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &a[2 * i].damage, &a[2 * i + 1].damage);
		a[2 * i].isSingle = false;
		a[2 * i + 1].isSingle = true;
	}
	std::sort(a, a + 2 * N, [](const Katana &a, const Katana &b) {
		return a.damage > b.damage;
	});
	int ans = 0;
	int i = 0;
	while (H > 0) {
		if (a[i].isSingle) {
			H -= a[i++].damage;
			++ans;
		}
		else {
			int t = H / a[i].damage;
			ans += t;
			H -= a[i].damage * t;
			if (H > 0) {
				H -= a[i].damage;
				++ans;
			}
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll fac[5500];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans%mod;
}
ll inv(ll a)
{
    return pows(a,mod-2)%mod;
}
ll c(ll n,ll m)
{
    if(n==0||m==n)
		return 1;
	if(m<n)
		return 0;
    return fac[m]*inv(fac[m-n])%mod*inv(fac[n])%mod;
}
int main()
{
    fac[0]=1;
    for(ll i=1; i<3000; i++)
    {
        fac[i]=fac[i-1]*i%mod;
    }
    ll n,k;
    ll ans;
    cin>>n>>k;
    for(ll i=1; i<=k; i++)
    {
        ll a,b;
        a=c(i,n-k+1);
        b=c(i-1,k-1);
        ans=a*b%mod;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll tot = 0;
  if (n % 2 == 0) {
    REP(i, 0, n / 2 - 1) {
      tot -= 2 * a[i];
    }
    REP(i, n / 2 + 1, n) tot += 2 * a[i];
    tot -= a[n / 2 - 1];
    tot += a[n / 2];
  } else {
    REP(i, 0, n / 2 - 1) {
      tot -= 2 * a[i];
    }
    REP(i, n - (n / 2 - 1), n) {
      tot += 2 * a[i];
    }
    ll ma = - a[n / 2 - 1] - a[n / 2] + 2 * a[n / 2 + 1];
    ma = max(ma, -2 * a[n / 2 - 1] + a[n / 2] + a[n / 2 + 1]);
    tot += ma;
  }
  cout << tot << endl;
}


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

int main() {
  long long N; cin >> N;
  long long a[N + 1], b[N + 1], c[N + 1];
  for (long long i = 1; i <= N; i++) cin >> a[i] >> b[i] >> c[i];
  
  long long dp_a[N + 1], dp_b[N + 1], dp_c[N + 1];
  for (long long i = 0; i <= N; i++) dp_a[i] = dp_b[i] = dp_c[i] = 0;
  for (long long i = 1; i <= N; i++){
    dp_a[i] = max(dp_b[i - 1], dp_c[i - 1]) + a[i];
    dp_b[i] = max(dp_c[i - 1], dp_a[i - 1]) + b[i];
    dp_c[i] = max(dp_a[i - 1], dp_b[i - 1]) + c[i];
  }
  long long ans = max(dp_a[N], dp_b[N]);
  ans = max(ans, dp_c[N]);
  cout << ans << endl;
}

Measured memory_bytes: 8256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool prime(ll n) {
  if (n == 1) {
    return false;
  } else {
    for (ll i = 2; i <= (ll)pow(n, 0.5); i++) {
      if (n%i == 0) return false;
    }
  }
  return true;
}
ll RepeatSquaring(ll n, ll p, ll m) {
  if (p == 0) return 1;
  if (p%2 == 0) {
    ll t = RepeatSquaring(n, p/2, m);
    return (t*t)%m;
  }
  return (n*RepeatSquaring(n, p-1, m))%m;
}

int main() {
  ll n, m;
  cin >> n;
  set <ll> s;
  ll a;
  rep(i, n) {
    cin >> a;
    s.insert(a);
  }
  cin >> m;
  rep(i, m) {
    cin >> a;
    s.insert(a);
  }
  for (auto value : s) {
    cout << value << endl;
  }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
	int n, x, y, b, p, i, j, m[366], a;
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d %d %d %d", &x, &y, &b, &p);
		a =  x * b + y * p;
		if(b >= 5 && p >= 2){
			m[i] = a * 0.8;
		} else if(b < 5 && p >= 2){
			m[i] = (x * 5 + y * p) * 0.8;
			if(m[i] > a){
				m[i] = a;
			}
		} else if(b >= 5 && p < 2){
			m[i] = (x * b + y * 2) * 0.8;
			if(m[i] > a){
				m[i] = a;
			}
		} else {
			m[i] = a;
		}
	}
	for(i = 0; i < n; i++){
		printf("%d\n", m[i]);
	}
	return 0;
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	cin >> n;
	cout << (n / 2) + (n % 2) << endl;
}


Measured memory_bytes: 256
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


S=input()
T=input()

if T[0:len(S)]==S:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 9116
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define MAXN (1 << 20)

ll a[MAXN], b[MAXN], s[MAXN];
ll n, m, k;

int main() {
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	int ret = 0;
	s[0] = 0;
	for (int i = 1; i <= m; i++) {
		s[i] = s[i - 1] + b[i - 1];
	}
	ll used = 0;
	int pos = m;
	for (int i = 0; i <= n; i++) {
		while (pos && (s[pos] + used > k)) {
			pos--;
		}
		//cerr << i << " " << i + pos << endl;
		int cur;
		if (s[pos] + used <= k) {
			cur = i + pos;
		} else {
			cur = 0;
		}
		ret = max(ret, cur);	
		used += a[i];
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 8300
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>

class TaskB {
public:
    void solve(std::istream &in, std::ostream &out) {
        int N;
        in >> N;
        int res = 0;
        for (int i = 0; i < N; ++i) {
            int l, r;
            in >> l >> r;
            res += r - l + 1;
        }

        out << res << '\n';
    }
};


int main() {
    TaskB solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b;
  char op;

  while(scanf("%d %c %d",&a,&op,&b),op!='?'){
    switch(op){
    case '+':
      printf("%d\n",a+b);
      break;
    case '-':
      printf("%d\n",a-b);
      break;
    case '*':
      printf("%d\n",a*b);
      break;
    case '/':
      printf("%d\n",a/b);
      break;
    default:
      break;
    }
  }

  return 0;
}

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

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

using namespace std;

signed main()
{
    int H, W;
    cin >> H >> W;
    if (H == 1 || W == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (H * W + 1) / 2 << endl;
    }
}


Measured memory_bytes: 3620
// coding on smartphone
#include<iostream>
#include<map>
using namespace std;

typedef long long ll;

int main(){
  int n, m;
  ll ans = 0;
  map<int,ll> appear;
  
  cin >> n >> m;
  ll a[n+1];
  a[0] = 0;
  
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    a[i] += a[i-1];
    appear[a[i]%m]++;
  }
  
  for(pair<int,ll> x : appear){
    if(x.second < 2) continue;
    ans += (x.second) * (x.second - 1) / 2;
  }
  
  if(appear.count(0)) ans += appear[0];
  
  cout << ans << endl;
  
  return 0;
}


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

class Main{
  public static void main(String[] args) throws IOException{
    Scanner scan=new Scanner(System.in);
    int n=Integer.parseInt(scan.next());
    int[] array=new int[n];
    for(int i=0;i<array.length;i++){
      array[i]=Integer.parseInt(scan.next());
    }

    //選択ソート
    int count=0;
    for(int i=0;i<array.length-1;i++){
      int min=i;
      for(int j=i+1;j<array.length;j++){
        if(array[j]<array[min]){
          min=j;
        }
      }
      if(i==min){
        continue;
      }
      int tmp=array[i];
      array[i]=array[min];
      array[min]=tmp;
      count++;
    }
    for(int i=0;i<array.length;i++){
      System.out.print(array[i]);
      if(i<array.length-1){
        System.out.print(" ");
      }else {
        System.out.println();
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26076
#include<iostream>
#include<math.h>
#include<vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int a,b,result;
  cin >> a >> b;
  result = max({a,b});
  if(a>=b){
  	a--;
  }else{
  	b--;
  }
  result += max({a,b});
  cout << result;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
for h in range(max(1, N//4), 3501):
  for w in range(max(1, N//4, h), 3501):
    if 4*h*w-N*(h+w) > 0 and N*h*w%(4*h*w-N*(h+w)) == 0:
      n = N*h*w//(4*h*w-N*(h+w))
      print(h, n, w)
      exit()
print(-1, -1, -1)


Measured memory_bytes: 3064
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

prev = -100
total = 0
for i in a:
    total += b[i - 1]
    if prev == i - 1:
        total += c[i - 2]
    prev = i
print(total)


Measured memory_bytes: 38256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    vi v(n); 
    rep (i, 0, n-1) cin >> v[i];

    vector<ll> dp(n);
    dp[0] = (ll) 0;
    dp[1] = (ll) abs(v[0]-v[1]);

    rep (i, 2, n-1) {
    	dp[i] = min (dp[i-1] + abs(v[i-1]-v[i]), dp[i-2] + abs(v[i-2]-v[i]));
    }

    cout << dp[n-1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

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

public class Main {

    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        
        int N = in.nextInt();
        long[] a = new long[N];
        long[][] dp = new long[3005][3005];
        for(int i = 0; i < N; i++) {
            a[i] = in.nextLong();
        }
        
        for(int L = N-1; L >= 0; --L) {
            for(int R = L; R < N; ++R) {
                if(L == R) {
                    dp[L][R] = a[L];
                }
                else {
                    dp[L][R] = Math.max(a[L] - dp[L+1][R], a[R]-dp[L][R-1]);
                }
            }
        }
        
        System.out.println(dp[0][N-1]);
    }
    

        
}


Measured memory_bytes: 130408
a, b = map(int, input().split())

if a == 1 or b == 1:
  if a == b:
    print('Draw')
  elif a == 1:
    print('Alice')
  else:
    print('Bob')
else:
  if a > b:
    print('Alice')
  elif a < b:
    print('Bob')
  else:
    print('Draw')
  

Measured memory_bytes: 61364
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);







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

    ll a,b,c,k;
    cin >> a>> b >> c >> k;
    ll tot = a+b+c;
    if (k >= tot){
        cout << a-c << endl;
    }else if ((k < tot) &&(k>a+b)){
        cout << 2*a + b - k << endl;
    }else if ((k > a) && (k <= a+b)){
        cout << a << endl;
    }else{
        cout << k << endl;
    }
 
}
 
  




Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int N; cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    rep(i,N+1) cin >> A[i];
    rep(i,N) cin >> B[i];
    ll ans = 0;
    rep(i,N){
        if (B[i] > A[i] + A[i+1]){
            ans+=A[i] + A[i+1];
            A[i+1] = 0;
        }
        else if (B[i] <= A[i]){
            ans += B[i];
            A[i] = 0;
        }
        else{
            ans += B[i];
            A[i+1] -= (B[i]-A[i]);
        }
    }
    cout << ans;
    rn 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#define ll long long
int asc(const void *a,const void *b){return *(long long *)b-*(long long*)a;}
int main(){
    ll x,y,a,b,c,i,ans=0;
    scanf("%lld%lld%lld%lld%lld",&x,&y,&a,&b,&c);
    ll p[a],q[b],r[c],to[a+b+c];
    for(i=0;i<a;i++) scanf("%lld",&p[i]);
    for(i=0;i<b;i++) scanf("%lld",&q[i]);
    qsort(p,a,sizeof(long long),asc);
    qsort(q,b,sizeof(long long),asc);
    for(i=0;i<x;i++) to[i]=p[i];
    for(;i<x+y;i++) to[i]=q[i-x];
    for(;i<x+y+c;i++) scanf("%lld",&to[i]);
    qsort(to,i,sizeof(long long),asc);
    for(i=0;i<x+y;i++) ans+=to[i];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 7020
N = int(input())
A = list(map(int,input().split()))
cums = [0]
for a in A:
    cums.append(cums[-1] + a)

MOD = 10**9+7
ans = 0
for i in range(N-1):
    ans += A[i] * (cums[-1] - cums[i+1])
    ans %= MOD
print(ans)

Measured memory_bytes: 31372
N=5
A=list(int(input()) for _ in range(N))

mi=9
index=0
for i in range(N):
    if A[i]%10!=0:
        if mi>A[i]%10:
            mi=A[i]%10
            index=i

ans=0    
for i in range(N):
    if i==index:
        ans+=A[i]
    else:
        ans+=(A[i]//10)*10
        if A[i]%10:
            ans+=10
print(ans)

Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi; 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
map<int,int>mp;
int a[200010];
int n,ans;
bool cmp(int x,int y){
	return x>y;
}
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		mp[a[i]]++;
	}
	sort(a,a+n,cmp);
	for(int i=0;i<n;i++){
		int pw=1;
		if(mp[a[i]]==0)continue;
		mp[a[i]]--;
		for(int j=1;j<=31;j++){
			pw*=2;
			if(pw<a[i])continue;
			if(mp[pw-a[i]]>=1){
				mp[pw-a[i]]--;
				ans++;
				break;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 29824
#include<iostream>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef long long ll;
const ll mod = 1000000007;
/*
const int N = 2500;
fobOp
ll comb[N][N];
void precalc(){
  comb[0][0] = 1;
  REP(i,1,N){
    comb[i][0] = comb[i][i] = 1;
    REP(j,1,i){
      comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % mod;
    }
  }
}
*/

ll mypow(ll n,ll p){
  if (p == 1)return n;
  ll ret=mypow(n,p/2);
  ret=ret*ret%mod;
  if (p&1)ret=ret*n%mod;
  return ret;
}
ll getinv(ll a){
  return mypow(a,mod-2);
}

const int N = 300000;
ll fact[N];
void precalc(){
  fact[0] = 1;
  REP(i,1,N)fact[i] = (i * fact[i-1])%mod;
}

ll comb(int a,int b){
  ll ret = fact[a];
  ret = (ret * getinv(fact[b]))%mod;
  ret = (ret * getinv(fact[a-b]))%mod;
  return ret;
}

//nªãÉÚ®·éñ
//xªºÉÚ®·éñ
ll solve(int n,int x){
  if (x == 0)return 1;
  int u = n+x,d = x;
  ll all = comb(u + d,u);//·×ÄÌp^[Ì
  ll ng  = comb(u+1 + d-1,u+1);//_Èp^[ÌiÀWªÉÈép^[)
  assert(x-1 + n >= n);
  return (all - ng+mod)%mod;
}

main(){
  precalc();
  int n,m,k;
  while(cin>>n>>m>>k && n){
    ll ans = 0;
    /*
      kÊèÌñè¹ðA¶EÉÚ®·éñðÅèµÄSÊè·B
      eñè¹Ìp^[Ín+2*iñ®­±ÆÉÈéB
      ±êÅÀWª}CiXÉÈçÈ¢½ßÌû@ÍAwK[SªÉæÁÄ¢éû@ðg¤Æ¢¢B
      ÇSp^[ªn+2*i choose n ÆÈèA»±©çngÉÈép^[ n+1 + (2*i-1) choose n+1 ðø¢½àÌª¶EÖÌÚ®p^[ÆÈéB
      ãºÖÌÚ®p^[à¯lÉßçêéB
       ÆÍ±ÌQÂð©¯í¹ÄAãºÆ¶EÌÚ®ðÇÌ^C~OÅâé©ðRrl[VÅßêÎ¢¢B
     */
    rep(i,k+1){
      ll lr = solve(n,i)  ;//¶EÌÚ®
      ll ud = solve(m,k-i);//ãºÌÚ®
      ll tmp = (lr*ud)%mod;
      ll cm  = comb(n+2*i + m+2*(k-i),n+2*i);
      cm = (cm*tmp)%mod;
      ans = (ans + cm)%mod;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(void)
{
	int A, B,max;
	scanf("%d %d",&A ,&B);
	max = A - B;
	if(A + B > A - B)
	{
		max = A + B;
	}
	if (A * B > max)
	{
		max = A * B;
	}
	printf("%d", max);
}

Measured memory_bytes: 128
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, K = NMI()
    A = NLI()
    F = NLI()
    A.sort()
    F.sort(reverse=True)
    ok = 10**13
    ng = 0
    for i in range(100):
        mid = (ok+ng) // 2
        limits = [mid//f for f in F]
        ks = [max(a-l, 0) for a, l in zip(A, limits)]
        if sum(ks) <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

Measured memory_bytes: 243848
from copy import deepcopy


def puzzle(x,y,A):
    ans,point=0,0
    A[x][y]=0
    B=[[-1 for _ in range(w)] for _ in range(h)]
    for i in range(w):
        cnt=h-1
        for j in range(h)[::-1]:
            if A[j][i]!=0:
                B[j][i]=cnt
                cnt -=1
    C=[[0 for _ in range(w)] for _ in range(h)]
    for i in range(w):
        for j in range(h):
            if B[j][i]!=-1:
                C[B[j][i]][i]=A[j][i]
    A=C

    while 1:
        score=ans
        for i in range(h):
            cnt,num=0,A[i][0]
            for j in range(w):
                if A[i][j]==num:cnt +=1
                else:
                    if cnt>=k:
                        ans +=num*cnt*2**point
                        for l in range(cnt):
                            A[i][j-l-1]=0
                    num,cnt=A[i][j],1
                if j==w-1 and cnt>=k:
                    ans +=num*cnt*2**point
                    for l in range(cnt):
                        A[i][j-l]=0

        B=[[-1 for _ in range(w)] for _ in range(h)]
        for i in range(w):
            cnt=h-1
            for j in range(h)[::-1]:
                if A[j][i]!=0:
                    B[j][i]=cnt
                    cnt -=1
        C=[[0 for _ in range(w)] for _ in range(h)]
        for i in range(w):
            for j in range(h):
                if B[j][i]!=-1:
                    C[B[j][i]][i]=A[j][i]
        A=C
        if score==ans:break
        point +=1
    return ans


h,w,k=map(int,input().split())
D=[list(map(int,list(input()))) for _ in range(h)]

ans=0
for i in range(h):
    for j in range(w):
        A=deepcopy(D)
        ans=max(ans,puzzle(i,j,A))
print(ans)

Measured memory_bytes: 69212
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-8
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef complex<double>cp;
template<class T>inline void rread(T&num){
    num=0;T f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
    num*=f;
}
const ll inf = 1e18;
const int maxn = 2e5+10, mod = 1e9 + 7;
const int mod1 = 1e8+7,mod2 = 41;
const double pi = acos(-1);
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a, a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
cp power(cp a, int n)
{cp p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
unsigned long long power(unsigned long long a, unsigned long long n)
{unsigned long long p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
//head
int n,m;
char s[100];
int main()
{
    int kase=1;
    //freopen("data2.out","r",stdin);
    //freopen("ans2.out","w",stdout);


   while(~scanf("%s",s))
   {
       s[3] = '8';
       printf("%s",s);
   }

    return 0;
}


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

class Dice{
    public:
        void set(int num[6]);
        int top_number();
        void E(), N(), S(), W();
    private:
    int dice_number[6];
};

int Dice::top_number(){
    return dice_number[0];
}
void Dice::set(int num[6]){
    for(int i = 0; i < 6; i++) dice_number[i] = num[i];
}
void Dice::E(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[3];
    dice_number[3] = dice_number[5];
    dice_number[5] = dice_number[2];
    dice_number[2] = tmp;
}

void Dice::N(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[1];
    dice_number[1] = dice_number[5];
    dice_number[5] = dice_number[4];
    dice_number[4] = tmp;
}
void Dice::S(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[4];
    dice_number[4] = dice_number[5];
    dice_number[5] = dice_number[1];
    dice_number[1] = tmp;
}
void Dice::W(){
    int tmp = dice_number[0];
    dice_number[0] = dice_number[2];
    dice_number[2] = dice_number[5];
    dice_number[5] = dice_number[3];
    dice_number[3] = tmp;
}
int main(){
    Dice dice1;
    int dice_num[6];
    char order[100];
    for (int i = 0; i < 6; i++ ) cin >> dice_num[i];
    dice1.set( dice_num );
    cin >> order;
    int i = 0;
    while(order[i] != '\0'){
        if (order[i] == 'E') dice1.E();
        else if (order[i] == 'N') dice1.N();
        else if (order[i] == 'S') dice1.S();
        else dice1.W();
        i++;
    }
    cout << dice1.top_number() << endl;
    return 0;
}


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

using namespace std;

int f(int x, int y, int z) {
	return x*x + y*y + z*z + x*y + y*z + z*x;
}

int main() {
	int n;

	cin >> n;

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

	for (int x = 1; x <= n && f(x, 1, 1) <= n; x++) {
		for (int y = x; y <= n && f(x, y, 1) <= n; y++) {
			for (int z = y; z <= n && f(x, y, z) <= n; z++) {
				int w = f(x, y, z);

				// cout << x << " " << y << " " << z << " " << w << "\n";

				if (x == y && y == z)
					ans[w]++;
				else if (x == y || y == z || x == z)
					ans[w] += 3;
				else
					ans[w] += 6;
			}
		}
	}

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

	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct Rect {
  int l, t, r, b;
};

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

void dfs(int y, int x, int h, int w, vvi &field){
  field[y][x] = 2;
  REP(i, 4){
    int sx = x + dx[i];
    int sy = y + dy[i];
    if(sx < 0 || w <= sx || sy < 0 || h <= sy) continue;
    if(field[sy][sx] == 0) {
      dfs(sy, sx, h, w, field);
    }
  }
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<Rect> rect(n);
    vi hol, ver;
    map<int, int> hol_map, ver_map;
    REP(i, n){
      cin >> rect[i].l >> rect[i].t >> rect[i].r >> rect[i].b;
      hol.push_back(rect[i].l);
      hol.push_back(rect[i].r);
      ver.push_back(rect[i].t);
      ver.push_back(rect[i].b);
    }
    SORT(hol);
    SORT(ver);

    vvi field((ver.size()) * 2 + 1, vi((hol.size()) * 2 + 1, 0));

    REP(i, n){
      int l = (find(ALL(hol), rect[i].l) - hol.begin()) * 2 + 1;
      int r = (find(ALL(hol), rect[i].r) - hol.begin()) * 2 + 1;
      int t = (find(ALL(ver), rect[i].t) - ver.begin()) * 2 + 1;
      int b = (find(ALL(ver), rect[i].b) - ver.begin()) * 2 + 1;
      // LOG("%d %d %d %d\n", l, r, t, b);
      FOR(x, l, r + 1){
        field[t][x] = true;
        field[b][x] = true;
      }
      FOR(y, b, t + 1){
        field[y][l] = true;
        field[y][r] = true;
      }
    }

    int h = field.size(), w = field[0].size();
    int cnt = 0;
    REP(y, h){
      REP(x, w){
        if(field[y][x] == 0) {
          cnt++;
          dfs(y, x, h, w, field);
        }
      }
    }
    cout << cnt << endl;

    // REP(y, h){
    //   REP(x, w){
    //     LOG("%d", field[y][x] & 1);
    //   }
    //   LOG("\n");
    // }

  }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    bool check = false;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (N == i * j) check = true;
        }
    }
    cout << (check ? "Yes" : "No") << endl;
 }

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

using namespace std;

int main() {
  int A,B,C; cin>>A>>B>>C;

  int Arem = A - B;
  if (C - Arem >= 0) {
    cout << C - Arem << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// B - Touitsu
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	string A,B,C; cin>>A>>B>>C;
	int count = 0;
	rpz(i, N){
		char a = A[i], b = B[i], c = C[i];
		if(a==b && b==c) count += 0;
		else if(a==b || a==c || b==c) count += 1;
		else count += 2;
	}
	cout<< count <<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
        public static void main(String[] args){
                try(Scanner sc = new Scanner(System.in)){
                        int N = sc.nextInt();
                        int[] A = new int[N];
                        for(int i = 0; i < N; i++){
                                A[i] = sc.nextInt();
                        }
                        int ans = 0;
                        int index = 0;
                        while(index < N){
                                ans++;
                                int i = 1;
                                while(i + index < N && A[i+index] == A[index]){
                                        i++;
                                }
                                if(i+index == N){
                                        break;
                                }
                                boolean f = A[index] < A[i+index];
                                while(i+index<N&&(f&&A[i+index-1]<=A[i+index]||(!f&&A[i+index-1]>=A[i+index]))){
                                        i++;
                                }
                                index += i;
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 52172
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int i=0;
    double x,t=100.0;
    cin >> x;
    while(1){
        i++;
        t=floor(t*1.01);
        if(x <= t)break;
    }
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 3736