akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 3000000000000001 // 3e15
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 1000001;
const ll M = 1;

struct point
{
    ll x, y;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

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

vector<ll> p;
void SoE(ll n)
{
    bool Primes[n + 1];
    Primes[0] = Primes[1] = 0;
    for(ll i = 2; i < n + 1; i++)
        Primes[i] = 1;
    for(ll i = 2; i * i <= n; i++)
    {
       if(Primes[i] == 1)
       {
           for(ll j = i; i * j <= n; j++)
           {
               Primes[i * j] = 0;
           }
       }
    }
    for(ll i = 2; i < n + 1; i++)
    {
        if(Primes[i])
        {
            p.push_back(i);
        }
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x, y, ans = INF, k;
        cin >> n >> m >> x >> y;
        ans = max({n * x, m * y, m * x, n * y});
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3652
x = int(input()) # input:"7" intを忘れない
a = [int(i) for i in input().split()] # input:"1 2 3 4 5"
b = [int(i) for i in input().split()] # input:"1 2 3 4 5"
ans=0
tmp=0
for i in range(x):
  point = 0
  tmp = b[x-i-1]-a[x-i]
  if tmp>=0:
    point = a[x-i]
    if tmp - a[x-i-1]>=0:
      point += a[x-i-1]
      a[x-i-1] = 0
    else:
      point += tmp
      a[x-i-1] = a[x-i-1] - tmp
  else:
    point = b[x-i-1]
  ans += point
print(ans)

Measured memory_bytes: 19004
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
using namespace std;
using ll=long long;
using R=double;


int main(void){
	int X;
    cin >> X;

    if(X == 1){
        puts("1");
        return 0;
    }

    int m = 1;

    for(int i = 2; i < ceil(sqrt(X)); i++){
        //printf("i : %d\n", i);
        int num = i;
        for(int j = 1; j <= 10; j++){
            num = num * i;
            if(num <= X and num > m){
                m = num;
                //printf("m : %d\n", m);
            }
        }
    }



    cout << m << endl;

}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

typedef pair < ll, ll > pll;
typedef pair < int, ll > pil;
typedef pair < ll, int > pli;
typedef pair < int, int > pii;

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 100500;

int n, cnt;

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		cnt ^= (x & 1);
	}

	cout << (cnt ? "NO" : "YES");
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s, t;
  cin >> s >> t;
  ll ans = 0;
  rep(i,3)
    if (s[i] == t[i])
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 20010;
const int K = 30000;

int n, p[MAXN], a[MAXN], b[MAXN];

bool check() {
  REP(i, n - 1) {
    int x = a[p[i]] + b[p[i]];
    int y = a[p[i+1]] + b[p[i+1]];
    if (x > y) return false;
  }
  return true;
}

int main(void) {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%d",&p[i]);
    --p[i];
  }

  REP(i, n) a[i] = 1 + i * K;

  b[p[0]] = 0;
  FOR(i, 1, n) {
    int x = a[p[i]] - a[p[i-1]];
    b[p[i]] = b[p[i-1]] - (x - 1);
  }

  int lo = 0;
  REP(i, n) lo = min(lo, b[i]);
  REP(i, n) b[i] -= lo;

  REP(i, n) printf("%d ",a[i]);
  printf("\n");
  REP(i, n) printf("%d ",b[i]+1);
  printf("\n");
  assert(check());
  
  return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        int price = sn.nextInt();
        int cnt = 0;
        
        if((price / 500) != 0) {
            cnt += 1000 * (price / 500);
            price %= 500;
        } 
        
        if((price / 5) != 0) {
            cnt += 5 * (price / 5);
        }
        
        System.out.print(cnt);
        
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a = 0;
    cin >> a;
    cout << a * 800 - (a - a % 15) / 15 * 200;
    return 0;
}

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

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void) {
  ios::sync_with_stdio(false);
  int64_t X;
  cin >> X;
  vector<int64_t> div = divisor(X);
  int n = div.size();
  int64_t A = 0;
  while (true) {
    for (int i = 0; i < n; ++i) {
      // cout << "i = " << i << ": div[i]=" << div[i] << endl;
      int64_t B = A - div[i];
      int64_t AZ = A * A * A * A * A;
      int64_t BZ = B * B * B * B * B;
      if ((AZ - BZ) == X) {
        cout << A << " " << B << endl;
        return 0;
      }
    }
    ++A;
  }
  return 0;
}


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

#define MAX_N 100
#define MAX_W 100000

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N, W, w[MAX_N], v[MAX_N];
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];
    long long dp[MAX_N + 1][MAX_W + 1];
    for (int i = 0; i <= W; ++i) dp[0][i] = 0;
    for (int i = 0; i <= N; ++i) dp[i][0] = 0;
    long long ans = 0; //
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= W; ++j) {
            long long t;
            if (j < w[i - 1]) t = 0;
            else t = v[i - 1] + dp[i - 1][j - w[i - 1]];
            dp[i][j] = max(dp[i - 1][j], t);
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 79232
fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map{it.toInt()}

    val a = (1..N).count {it % K == 0}.toLong()
    val b = (1..N).count {it % K != 0 && (it * 2) % K == 0}.toLong()
    println(a * a * a + b * b * b)
}


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

int main(){
  long long N;
  cin >> N;
  vector<pair<long long,long long>> A(N);
  for(int i=0;i<N;i++){
    long long a;
    cin >> a;
    A[i] = make_pair(a,i);
  }
  sort(A.rbegin(),A.rend());
  
  vector<vector<long long>> dp(N+1,vector<long long>(N+1,0));
  for(int i=0;i<N;i++){
    for(int j=0;j<=i;j++){
      dp[i+1][j+1] = max(dp[i+1][j+1], abs(A[i].second-j)*A[i].first + dp[i][j]);
      dp[i+1][j] = max(dp[i+1][j], abs(A[i].second-(N-(i+1-j)))*A[i].first + dp[i][j]);
    }
  }
  
  long long ans=0;
  for(int i=0;i<=N;i++) ans = max(ans,dp[N][i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 34676
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else {
			A[k]++;
		}
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		for (int j = kosuu; j >= 0; j--) {
			ll tmp = 0;
			for (int k = kosuu; k >= 0; k--) {
				dp[j][k] %= mod;
				tmp += dp[j][k];
				rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
				dp[j][k] = tmp;
			}
		}
		kosuu += A[i];
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}


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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n; cin >> n;
	rep(q, n){
		string s; cin >> s;
		if(s.substr(0, 2) == ">'"){
			s = s.substr(2);
			int c = 0;
			bool p = true;
			for(int i=0; i < s.size(); i++) if(s[i] == '='){c++;} else break;
			if(s[c] != '#' || c == 0)p = false;
			s = s.substr(c+1);
			if(c+1 != s.size() || s[s.size()-1] != '~')p = false;
			rep(i, c) if(s[i] != '=')p = false;
			cout << (p ? "A" : "NA") << endl;
		}else if(s.substr(0, 2) == ">^"){
			bool p = true;
			s = s.substr(2);
			if(s.substr(0, 2) != "Q=") p = false;
			while(s.substr(0, 2) == "Q=") s = s.substr(2);
			cout << (s == "~~" && p ? "B" : "NA") << endl;
		}else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 1216
#include<stdio.h>

int main(void) {
	int i, l,num = 0;
	char N[200001];
	scanf("%s", &N);

	l = strlen(N);
	for (i = 0; i < l; i++) {
		num += N[i] - '0';
	}
	
	if (num % 9 == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1812
using System;

namespace AOJ.Volume0
{
    public class Weight
    {
        public static void Main()
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                int weight = int.Parse(input);
                var binary = Convert.ToString(weight, 2);
                string output = "";
                for (int i = binary.Length - 1; i >= 0; i--)
                {
                    if (binary.Substring(i, 1) == "1")
                    {
                        output += Math.Pow(2, binary.Length - i - 1) + " ";
                    }
                }
                output = output.Trim();

                Console.WriteLine(output);
            }
        }
    }
}

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

int main(){
  long long i,N;
  string S;
  cin >> S;
  N = S.size();
  vector<long long> num(N);
  string tmpS;
  for(i=0; i<N; i++){
    tmpS = S[i];
	num.at(i) = stoi(tmpS);
  }
  vector<int> digit(N);
  long long tmp=1;
  for(i=0; i<N; i++){
    digit[i] = tmp;
    tmp = (tmp*10)%2019;
  }
  tmp = 0;
  vector<long long> ans(2019,0);
  for(i=N-1; i>=0; i--){
    tmp = (digit[N-i-1]*num[i]+tmp)%2019;
    ans.at(tmp)++;
  }
  long long An=0;
  for(i=0; i<2019; i++){
    An += (ans[i]*(ans[i]-1))/2;
  }
  cout << An + ans[0];
  return 0;
}

Measured memory_bytes: 5844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
string s[100005];
int y[100005];
pii order[100005];
string ans[100005];
map<string, int> id;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		cin >> s[i] >> y[i];
		order[i] = pii(y[i], i);
	}
	sort(order+1, order+1+m);
	for(int i=1;i<=m;i++){
		int idx = order[i].second;
		while(s[idx].length() < 6) s[idx] = "0" + s[idx];
		id[s[idx]]++;
		string add = to_string(id[s[idx]]);
		while(add.length() < 6) add = "0" + add;
		ans[idx] = s[idx] + add;
	}
	for(int i=1;i<=m;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 19840
#include<iostream>
using namespace std;
int main(){
	while(1){
		int m,n,N,ans=0,now,last=0,out;
		cin >> m >> n >> N;
		if(!m&&!n&&!N)	break;
		for(int i=1;i<=m;i++){
			cin >> now;
			if(n<i&&i<=N+1&&i!=1){
				if((last-now)>=ans){
					ans = last-now;
					out = i-1;
				}
			}
			last = now;	
		}
		cout << out << endl;
	}
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[100003];
    Scs(s);

    int n = strlen(s);
    Rep(i,n){
        printf ("%c", s[i++]);
    }

    printf ("\n");

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k; cin >> n >> k;
    int ans = 0;
    rep(i,n) {
        int x; cin >> x;
        ans += 2*min(k-x, x);
    }
    cout << ans << endl;
    return 0;
}

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

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

    ll H, W;
    cin >> H >> W;
    ll ans = (H*W+1)/2;
    if (H==1 || W==1) {
        ans = 1;
    }
    cout << ans << endl;
}

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

int check_lunlun(vector<int64_t>Lun, int keta, int nagasa){
  //keta:今調べている桁,nagasa:lunlun(K-1)の桁数
  //lunlun(K-1)を1の位から調べる
  //0を返すまで桁を増やし続ける（while)
  
  if(keta == nagasa-1){
    return 0;
  }
  if(Lun.at(keta)+1-Lun.at(keta+1)>=2 || Lun.at(keta) == 9){
    return 1;
  }
  else{
    return 0;
  }
}

int64_t lunlun(int K){
  if(K==1){
    return 1;
  }
  else{
    int64_t lunlun_old = lunlun(K-1);
    
    //lunlun(K-1)の桁数チェック
    string L_str = to_string(lunlun_old);
    int nagasa = L_str.length();
    
    //lunlun(K-1)が一桁の場合
    if(nagasa == 1){
      return lunlun_old + 1;
    }
    
    //99...99じゃないかチェック→桁が変わるので
    int check9 = 0;
    for(int i=0; i<nagasa; i++){
      if(L_str.at(i) == '9'){
        check9++;
      }
    }
    if(check9==nagasa){
      return lunlun_old+1;
    }
    
    vector<int64_t> Lun(nagasa);
    int64_t lunlun_old_judge=lunlun_old;
    for(int i=0; i<nagasa; i++){
      int64_t tmp=0;
      if(lunlun_old_judge/pow(10,i+1) >= 1){
        tmp = ((int64_t)lunlun_old_judge-(int64_t)pow(10,i+1)*((int64_t)lunlun_old_judge/(int64_t)pow(10,i+1)))/(int64_t)pow(10,i);
      }
      else{
        tmp = (int64_t)lunlun_old_judge/(int64_t)pow(10,i);
      }
      Lun.at(i) = tmp;
      lunlun_old_judge -= tmp*pow(10,i);
    }
    
    int keta = 0;
    
    while(check_lunlun(Lun, keta, nagasa)==1){
      keta++;
    }
    
    Lun.at(keta)++;
    for(int i=1; i<=keta; i++){
      if(Lun.at(keta)-i>=1){
        Lun.at(keta-i)=Lun.at(keta)-i;
      }
      else{
        Lun.at(keta-i)=0;
      }
    }
    
    
    int64_t ans = 0;
    for(int i=0; i<nagasa; i++){
      ans+=pow(10,i)*Lun.at(i);
    }
    return ans;
      
  }
  
}

int main() {
  int K;
  cin >> K;
  cout << lunlun(K) << endl;
  //for(int i=K-100; i<=K; i++){
    //cout << lunlun(i) << endl;
  //}
}





  

  //int nagasa = L_str.length();
  


// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;

int main(){
  ll h;
  cin >> h;
  ll r = log2(h) + 1;
  cout << setprecision(16)<<pow(2, r) - 1 << endl;
}


Measured memory_bytes: 512
object Main {
    def st(n: Double, i: Int): Stream[Double] =
        if (i % 2 == 0) n #:: st(n * 2, i + 1)
        else n #:: st(n / 3, i + 1)

    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.toDouble)
        in.foreach(d => println(st(d, 0).take(10).sum))
    }
}

Measured memory_bytes: 44220
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, M;
    char A[50][50], B[50][50];
    cin >> N >> M;
    REP(i, N) {
        REP(j, N) {
            cin >> A[i][j];
        }
    }
    REP(i, M) {
        REP(j, M) {
            cin >> B[i][j];
        }
    }
    REP(i, N) {
        REP(j, N) {
            if (i + M - 1 >= N || j + M - 1 >= N) {
                continue;
            }
            bool f = true;
            REP(p, M) {
                REP(q, M) {
                    if (A[i + p][j + q] != B[p][q]) {
                        f = false;
                    }
                }
            }
            if (f) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000

struct data{
	int v,d,c;
};

int main(){
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> E(N,vector<int>(0));
	
	for(int i=0;i<M;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	
	int Q;
	cin>>Q;
	
	vector<data> query(Q);
	for(int i=0;i<Q;i++){
		data D;
		scanf("%d %d %d",&D.v,&D.d,&D.c);
		D.v--;
		query[i] = D;
	}
	
	reverse(query.begin(),query.end());
	
	vector<vector<bool>> painted_flag(N,vector<bool>(11,false));
	
	vector<int> ans(N,0);
	
	for(int i=0;i<Q;i++){
		queue<int> q;
		q.push(query[i].v);
		int x = q.size();
		for(int j=0;j<=query[i].d;j++){
			int a = 0;
			while(a!=x){
				a++;
				int V = q.front();
				q.pop();
				if(painted_flag[V][query[i].d-j])continue;
				for(int k=query[i].d-j;k>=0;k--){
					painted_flag[V][k]=true;
				}
				if(ans[V]==0)ans[V]=query[i].c;
				for(int k=0;k<E[V].size();k++){
					q.push(E[V][k]);
				}
			}
			x=q.size();
		}
		
		
	}
	
	for(int i=0;i<N;i++){
		printf("%d\n",ans[i]);
	}
	
	
	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


const ll MOD = (ll)(1e9 + 7);

const int SZ = 412345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll two[SZ];
ll two_inv[SZ];

ll P[SZ];
ll Q[SZ];

int main2() {

  int B, W; cin >> B >> W;
  P[0] = 0;
  Q[0] = 0;
  for (int n = 1; n <= B+W; n++) {
    P[n] = P[n-1] + choose(n-1, B-1) * two_inv[n];
    Q[n] = Q[n-1] + choose(n-1, W-1) * two_inv[n];
    P[n] %= MOD;
    Q[n] %= MOD;
    ll ans = Q[n-1] + (1 + MOD - P[n-1] + MOD - Q[n-1]) * two_inv[1];
    ans = (ans % MOD + MOD) % MOD;
    printf("%d\n", (int)ans);
  }
  return 0;
}

int main() {
  {
    inv[1] = 1;
    for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
    fact[0] = 1;
    for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[0] = 1;
    for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;
  }

  {
    two[0] = 1;
    for (int i = 1; i < SZ; i++) two[i] = two[i-1] * 2 % MOD;
    two_inv[0] = 1;
    for (int i = 1; i < SZ; i++) two_inv[i] = two_inv[i-1] * inv[2] % MOD;
  }

  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 1e5+5; 

int main(){
	fast;
	ll n; cin >> n;
	ll ans = 0;
	
	if(n & 1){
	    cout << "0\n";
	    
	}
	else{
	
	ll d = 10;
	while(n >= d){
	    ans += n / d;
	    d *= 5;
	}
	
	cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 2000000000
#define MOD 2018012016
#define N 200005
#define M 1000005
#define LOG 1000000
#define KOK 32000
#define EPS 0.000000001
using namespace std;

int n;
int ata[N];
ll ans,a[N],b[N],pre[N],suf[N];

int bul(int node) {

	if(ata[node]==node) return node;

	return ata[node]=bul(ata[node]);

}

int main() {

//	freopen("input.txt","r",stdin);

	scanf("%d",&n);

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

		scanf("%lld",a+i);

		b[i]=a[i];

	}

	a[1]*=2;

	pre[1]=1;

	for(int i=1;i<=n;i++) ata[i]=i;

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

		ll cur=1;

		a[i]*=2;

		while(a[i-1]<a[i]) {

			ata[i]=bul(i-1);

			while(a[bul(i)]*4ll>a[bul(i)-1] && bul(i)>1) {

				ata[bul(i)]=bul(bul(i)-1);

			} 

			a[i-1]*=4ll;

			if(bul(i)!=i-1) a[bul(i)]*=4ll;

			cur+=2*(i-bul(i));

		}

		pre[i]=pre[i-1]+cur;

	}

	for(int i=1;i<=n;i++) ata[i]=i;

	suf[n]=0;

	for(int i=n-1;i>=1;i--) {

		ll cur=0;

		while(b[i+1]<b[i]) {

			ata[i]=bul(i+1);

			while(b[bul(i)]*4ll>b[bul(i)+1] && bul(i)<n) {

				ata[bul(i)]=bul(bul(i)+1);

			}

			b[i+1]*=4ll;

			if(bul(i)!=i+1) b[bul(i)]*=4ll;

			cur+=2*(bul(i)-i);

		}

		suf[i]=suf[i+1]+cur;

	}

	ans=pre[0]+suf[1];

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

		umin(ans,pre[i]+suf[i+1]);

	}

	printf("%lld",ans);

}

Measured memory_bytes: 7424
import collections
import math

N = int(input())
b =[]
for i in range(N):
    a = input()
    b.append([j for j in a])
    b[i].sort()
a = [''.join(j) for j in b]
b = [k for k in collections.Counter(a).values()]
c = 0
for x in range(len(b)):
    if b[x] > 1:
        c += math.factorial(b[x]) // (math.factorial(b[x] - 2) * math.factorial(2))
    else:
        None
print(c)

Measured memory_bytes: 40992
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <queue>
using namespace std;

int root(int a, int par[]){
  if(par[a] == a) return a ;
  return par[a] = root(par[a],par) ;
}

int main(){
  int N, M, ans = 0, roadA, roadB, rA, rB ;
  cin >> N >> M ;
  ans = N-1 ;
  int par[N+1] = {} ;
  for(int i=1;i<=N;i++) par[i] = i ;
  for(int i=0;i<M;i++){
    cin >> roadA >> roadB ;
    rA = root(roadA, par) ;
    rB = root(roadB, par) ;
    if(rA == rB) continue ;
    else{
      par[rA] = rB ;
      ans-- ;
    }
  }  
  cout << ans << endl ;
  return 0 ;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll k,a,b;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
    ans += b[a[i]-1]
    
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
        
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define all(n) n.begin(),b.end()
#define F first
#define S second
#define INF (1<<27)

using namespace std;

typedef pair<int, int> P;
typedef vector<P> VP;
int n;

bool cmp(const P& a, const P& b){
    if(a.S != b.S)
        return a.S < b.S;
    return false;
}

int closest_pair(vector<P>::iterator begin, vector<P>::iterator end){
    int len = end - begin;
    if(len <= 1) return INF;
    auto mid = begin + len / 2;
    int x = mid->F;
    int range = min(closest_pair(begin, mid), closest_pair(mid, end));
    inplace_merge(begin, mid, end, cmp);
    VP b;
    for(int i = 0; i < len; i++){
        if(abs(begin[i].F - x) >= range) continue;
        for(int j = b.size() - 1; j >= 0; j--) {
            int dx = begin[i].F - b[j].F;
            int dy = begin[i].S - b[j].S;
            if(dy >= range)
                break;
            range = min(range, dx*dx + dy*dy);
        }
        b.push_back(begin[i]);
    }
    return range;
}

int main(){
    cin >> n;
    vector<P> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i].F >> a[i].S;
    sort(a.begin(), a.end());
    cout << closest_pair(a.begin(), a.end()) << endl;
    return 0;
}

Measured memory_bytes: 10704
a,b = map(int,input().split())
s = input()
ans = ["0","1","2","3","4","5","6","7","8","9"]
ch1 = list(map(str,s[:a]))
ch2 = list(map(str,s[a+1:]))
count = 0
for i in range(len(ch1)):
    if ch1[i] not in ans:
        count +=1
for j in range(len(ch2)):
    if ch2[j] not in ans:
        count += 1
if count == 0 and s[a] == "-":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
SP = []
for i in range(N):
    s,p = input().split()
    SP.append((s, -int(p), i+1))

SP.sort()

for s,p,i in SP:
    print(i)

Measured memory_bytes: 3060
from sys import stdin
from collections import deque
def main():
    readline=stdin.readline
    S=readline().strip()
    d=deque(S)

    Q=int(readline())
    mode=1
    count=0
    for i in range(Q):
        li=readline().split()
        if li[0]=="1":
            mode+=1
            mode%=2
            count+=1
        else:
            o=li[1]
            c=li[2]
            if mode==1 and o=="1":
                d.appendleft(c)
            elif mode==0 and o=="1":
                d.append(c)
            elif mode==1 and o=="2":
                d.append(c)
            elif mode==0 and o=="2":
                d.appendleft(c)
    res=list(d)
    if count%2==1:
        res=res[::-1]
    print("".join(res))
if __name__=="__main__":
    main()

Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;
typedef pair<ll,ll>pll;

const int MAX_N = 40;

ll w[MAX_N];
ll v[MAX_N];
ll W;
int n;
pll ps[1<<(MAX_N/2)];

void solve()
{
	int n2 = n/2;
	rep(i,1<<n2){
		ll sw =0,sv=0;
		rep(j,n2){
			if(i&(1<<j)){
				sw += w[j];
				sv += v[j];
			}
		}
		ps[i] = pll(sw,sv);
	}
	sort(ps,ps+(1<<n2));
	int m=1;
	for(int i=1;i<(1<<n2);i++){
		if(ps[m-1].second < ps[i].second){
			ps[m++] = ps[i];
		}
	}
	ll res = 0;
	rep(i,1<<(n-n2)){
		ll sw=0,sv=0;
		rep(j,n-n2){
			if((i>>j)&1){
				sw += w[n2+j];
				sv += v[n2+j];
			}
		}
		if(sw <= W){
			ll tv = (lower_bound(ps,ps+m,pll(W-sw,INF))-1)->second;
			res = max(res,sv+tv);
		}
	}
	printf("%lld\n",res);
}

int main()
{
	cin >> n >> W;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	solve();
	return 0;
}

Measured memory_bytes: 19620
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> answer;
  answer.push_back(1);
  for(int i = 2; i <32; i++){
    int x = i;
    while(true){
      x = x*i;
      if(x <= 1000){        
        answer.push_back(x);
      }else{
       break; 
      }
    }
  }
  answer.push_back(1001);
  sort(answer.begin(),answer.end());
  for(int i = 0; i < answer.size();i++){
    if(answer[i] > n){
      cout << answer[i-1] << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,length=0,max=0,min=1000000;
            boolean first=true;
            Map<String,Integer> map=new HashMap<String,Integer>();
            LinkedHashSet<String> set=new LinkedHashSet<String>();
            while ((line = br.readLine()) != null) {
            	if(first){
            		length=Integer.parseInt(line);
            		first=false;
            	}else{
            		String[] tokens=line.split(" ");
            		if(!map.containsKey(tokens[0])){
            			map.put(tokens[0], Integer.parseInt(tokens[1]));
            		}else{
            			int a=map.get(tokens[0])+Integer.parseInt(tokens[1]);
            			map.put(tokens[0], a);
            		}
            		if(max<tokens[0].length()){
            			max=tokens[0].length();
            		}
            		if(min>tokens[0].length()){
            			min=tokens[0].length();
            		}
            		set.add(tokens[0]);
            		i++;
            		if(i==length){
            			break;
            		}
            	}
            }
            TreeSet<String> treeSet = new TreeSet<String>(set);
            Iterator<String> itr=treeSet.iterator();
            for(int k=1;k<=max;k++){
            	itr=treeSet.iterator();
            	while(itr.hasNext()){
            		String s=itr.next();
            		if(k==s.length()){
            			System.out.println(s+" "+map.get(s));
            		}
            	}
            }
        }
    }

}

Measured memory_bytes: 33800
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL N,KK;
    R(N,KK);
    LL an=0;
    FOR(K,KK,N+1){
        ADD(an,(N+N-K+1)*K/2-(K-1LL)*K/2+1);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

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

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

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

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

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

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

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

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


int main() {
    ll N, M;
    cin >> N >> M;

    vector<vector<ll>> A(N + 1, vector<ll>(M + 1));
    repn(i, N)repn(j, M)cin >> A[i][j];

    vector<ll> sp(M + 1, 1);

    ll ans = N;

    vector<ll> part(N + 1, 1);

    repn(k, M) {
        repn(j, N) {
            while (sp[A[j][part[j]]] == 0) { part[j]++; }
       }

        vector<ll> ninzu(M + 1,0);
        repn(j, N) { ninzu[A[j][part[j]]]++; }

        ll v = 0;
        ll id = 0;
        repn(j, M) {
            if (ninzu[j] > v) { v = ninzu[j]; id = j; }
        }

        ans = min(ans, v);
        sp[id] = 0;
    }

    cout << ans;
	system("PAUSE");
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define pi 3.1415926
using namespace std;
const double eps = 0.000001;
double a, b, x, t, ans;
int main() {
	scanf("%lf%lf%lf", &a, &b, &x);
	if(b * a * a >= x * 2) {
		t = (x * 2) / (a * b);
		t = t / b;
		ans = 90 - atan(t) * 180 / pi;
		printf("%lf", ans + eps);
	} else {
		t = (x * 2) / (a * a) - b;
		t = a / (b - t);
		ans = 90 - atan(t) * 180 / pi;
		printf("%lf", ans + eps);
	}
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
 
int main(void){
  char X[10];
  
  scanf("%s",X);
 
  X[4]=X[2];
  X[6]=X[3];
  X[2]=X[1];
  X[7]='=';
  X[8]='7';
  X[9]='\0';
  
  if(X[0]+X[2]+X[4]+X[6]-4*'0' == 7){
    X[1]='+';
    X[3]='+';
    X[5]='+';
  }else if(X[0]+X[2]+X[4]-X[6]-2*'0' == 7){
    X[1]='+';
    X[3]='+';
    X[5]='-';
  }else if(X[0]+X[2]-X[4]-X[6] == 7){
    X[1]='+';
    X[3]='-';
    X[5]='-';
  }else if(X[0]-X[2]-X[4]-X[6]+2*'0' == 7){
    X[1]='-';
    X[3]='-';
    X[5]='-';
  }else if(X[0]-X[2]-X[4]+X[6] == 7){
    X[1]='-';
    X[3]='-';
    X[5]='+';
  }else if(X[0]-X[2]+X[4]+X[6]-2*'0' == 7){
    X[1]='-';
    X[3]='+';
    X[5]='+';
  }else if(X[0]+X[2]-X[4]+X[6]-2*'0' == 7){
    X[1]='+';
    X[3]='-';
    X[5]='+';
  }else if(X[0]-X[2]+X[4]-X[6] == 7){
    X[1]='-';
    X[3]='+';
    X[5]='-';
  }
  
  printf("%s\n",X);
}

Measured memory_bytes: 128
#include <stdio.h>

int getMin(int data[], int n){
	int min = data[0];
	int i;
	for(i=0; i<n; i++){
		if(min > data[i]){
			min = data[i];
		}
	}
	return min;
}

int main(){
	int data[10];
	int n;
	int i;
	int min;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &data[i]);
	}
	min = getMin(data, n);
	i=1;
	while(i<=min){
		switch(n){
			case 2:
			if(data[0]%i==0&&data[1]%i==0){
				printf("%d\n", i);
			}
			break;
			
			case 3:
			if(data[0]%i==0&&data[1]%i==0&&data[2]%i==0){
				printf("%d\n", i);
			}
			break;
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i=0; i<h; i++) cin >> s[i];

    int ans = 0;
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            if (s[y][x] == '#') continue;
            vector<vector<bool>> checked(h, vector<bool>(w, false));
            queue<pair<int, int>> que;
            que.push(pair<int, int>(x, y));

            vector<vector<int>> cnt(h, vector<int>(w, 0));
            checked[y][x] = true;
            while (!que.empty()) {
                pair<int, int> point = que.front(); 
                que.pop();
                int xx = point.first;
                int yy = point.second;
                int cc = cnt[yy][xx];
                if (xx-1>=0 && s[yy][xx-1]=='.' && !checked[yy][xx-1]) {
                    que.push(pair<int, int>(xx-1, yy));
                    cnt[yy][xx-1] = cc+1;
                    checked[yy][xx-1] = true;
                }
                if (xx+1<=w-1 && s[yy][xx+1]=='.' && !checked[yy][xx+1]) {
                    que.push(pair<int, int>(xx+1, yy));
                    cnt[yy][xx+1] = cc+1;
                    checked[yy][xx+1] = true;
                }
                if (yy-1>=0 && s[yy-1][xx]=='.' && !checked[yy-1][xx]) {
                    que.push(pair<int, int>(xx, yy-1));
                    cnt[yy-1][xx] = cc+1;
                    checked[yy-1][xx] = true;
                }
                if (yy+1<=h-1 && s[yy+1][xx]=='.' && !checked[yy+1][xx]) {
                    que.push(pair<int, int>(xx, yy+1));
                    cnt[yy+1][xx] = cc+1;
                    checked[yy+1][xx] = true;
                }
                ans = max(ans, cc);
            }
        }
    }

    cout << ans << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int INF = TEN(9);
const int maxn = 2010;

V<int> g[maxn];
string S;
int cnt[maxn], smini[maxn], sum[maxn];

void dfs(int v, int p) {
	cnt[v] = (S[v] - '0');
	sum[v] = 0;

	pii maxi(-1, -1);

	for (int to : g[v]) if (to != p) {
		dfs(to, v);

		cnt[v] += cnt[to];
		sum[v] += sum[to] + cnt[to];
		smini[to] += cnt[to];
		chmax(maxi, mp(smini[to], to));
	}

	if (maxi.fi == -1) {
		smini[v] = 0;
		return ;
	}
	int to = maxi.se;
	if (maxi.fi > sum[v] - sum[to] - cnt[to]) {
		smini[v] = maxi.fi - (sum[v] - sum[to] - cnt[to]);
	} else {
		smini[v] = sum[v] % 2;
	}
}

int main() {
	int N;
	cin >> N >> S;
	rep(i, N-1) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].pb(b); g[b].pb(a);
	}

	int ans = INF;

	rep(i, N) {
		dfs(i, -1);
		if (smini[i] == 0) {
			chmin(ans, sum[i] / 2);
		}
	}

	if (ans == INF) ans = -1;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cctype>
#include<queue>
#include<algorithm>
#include<vector>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
using namespace std;
const  int N = 1e5 + 3;
int a[N];
int n;
vector <pii> G1,G2,G3;
inline int read(){
    int v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar(); 
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar(); 
    }
    return v * c;
}
int main(){
	n = read();
	for(int i = 1;i <= n;++i) a[i] = read();
	sort(a + 1,a + n + 1);
	int sum1 = a[n];
	for(int i = n - 1;i >= 1;--i){
		G1.push_back(mk(sum1,a[i]));
		sum1 -= a[i];
	}
	int sum2 = a[1];
	for(int i = 2;i < n;++i){
		G2.push_back(mk(sum2,a[i]));
		sum2 -= a[i];
	}G2.push_back(mk(a[n],sum2));
	sum2 = a[n] - sum2;
//	int k = 1;
	//while(a[k] < 0)
	int l = upper_bound(a + 1,a + n + 1,0) - a;
	if(a[1] < 0 && l + 1 <= n){
		int ans = a[1];
		for(int i = l;i < n;++i)
		G3.push_back(mk(ans,a[i])),ans -= a[i];
		G3.push_back(mk(a[n],ans));
		ans = a[n] - ans;
		for(int i = 2;i < l;++i)
		G3.push_back(mk(ans,a[i])),ans -= a[i];
		printf("%d\n",ans);
		for(int i = 0;i < (int)G3.size();++i){
			printf("%d %d\n",G3[i].first,G3[i].second);	
		}
		return 0;
	}
	else{
		if(sum1 > sum2){
			printf("%d\n",sum1);
			for(int i = 0;i < (int)G1.size();++i) printf("%d %d\n",G1[i].first,G1[i].second);
		}
		else{
			printf("%d\n",sum2);
			for(int i = 0;i < (int)G2.size();++i) printf("%d %d\n",G2[i].first,G2[i].second);	
		}	
	}
	
	return 0;
}

Measured memory_bytes: 4724
def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(b%a, a)

if __name__ == '__main__':
    N, Xini = map(int, input().split())
    X = list(map(int, input().split()))
    for i in range(N):
        X[i] = abs(X[i] - Xini)
    
    before = X[0]
    for i in range(1, N):
        before = gcd(X[i], before)
    
    print(before)

Measured memory_bytes: 14224
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N,K;
    int c=0;
    cin>>N>>K;
    int h[N];
    for(int i=0;i<N;i++){
        cin>>h[i];
        if(h[i]>=K){
            c++;
        }
    }
    cout<<c;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int p(long long u,long long v){
    if(u==1){
        if(v==1)return 1;
        else return 0;
    }
    else{
        long long ans = ((u-1)*(u))/2+u;
        if(ans>=v)return 1;
        else return 0;
    }
}
int main(){
	long long n;cin>>n;
	long long rem=n;
	while(rem!=0){
  	long long lo=1,hi=rem;
  	long long mid;
  	while(lo<hi){
  	    mid = lo+(hi-lo)/2;
  	    if(p(mid,rem)==1)hi = mid;
  	    else lo=mid+1;
  	    }
  	cout<<lo<<'\n';
  	rem -=lo;
	}
  
}

Measured memory_bytes: 3572
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<deque>
using namespace std;

int main(){
	long long n,k;
	cin >> n >> k;
	
	if(k>=n){
		cout << "0" << endl;
		return 0;
	}
	
	vector<long long> h(n,0);
	for(long long i=0;i<n;i++){
		cin >> h[i];
	}
	
	sort(h.begin(),h.end(),greater<long long>());
	
	long long sum=0;
	for(long long i=k;i<n;i++){
		sum+=h[i];
	}
	
	cout << sum << endl;
	return 0;
}


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

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

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D) {
    cout << "Right" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

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

  scanf("%d %d %d", &a, &b, &c);

  if((a == b && b != c) || (a == c && b != c) || (b == c && a != b)) printf("Yes\n");

  else printf("No\n");

  return 0;
}


Measured memory_bytes: 128