akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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;
}
ll mod= 998244353;

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 ans= 1;
  ll n;
  cin >> n;
  ll a[n]= {};
  ll b[n];
  ll ma=0;
  rep(i, n) {
    cin >> b[i];
    a[b[i]]++;
    chmax(ma,b[i]);
  }
  rep(i,ma+1)if(a[i]==0){cout<< 0 << endl; return 0;}
  if(a[0]!=1){cout << 0 <<endl;return 0;}
  if(b[0]!=0){cout << 0 <<endl;return 0;}
  
  for(int i=1;i<=ma;i++){
      ans=ans*RepeatSquaring(a[i-1],a[i],mod)%mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5212
#pragma warning(disable:4996)
#pragma warning(disable:6031)
#include <stdio.h>

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int a, b;
	a = (n * (n - 1)) / (2 * 1);
	b = (m * (m - 1)) / (2 * 1);
	printf("%d", a + b);
	return 0;
}

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

int main() {
  int N,W;
  cin >> N >> W;
  for (int k=0;k<W+2;k++){
  cout << "#" ;
  }
  cout << endl;
  for(int j=0;j<N;j++){
  vector <char> a(W);
  for(int i=0;i<W+2;i++){
  if (i == 0 || i ==W+1){
  cout << "#" ;
  }
  else {
    cin >> a.at(i-1);
  cout << a.at(i-1);
  }
  }
  cout << endl;
  }
  for (int k=0;k<W+2;k++){
  cout << "#" ;
  }
  cout << endl;
 }


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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

int main()
{                         
	int n, l, r, x, ans = 1;
	scanf("%d", &n);
	l = -1, r = -1;
	while(n--){
		scanf("%d", &x);
		if(l == -1 && r == -1){
			l = x;
			r = x;
			continue;
		}
		if(l <= r && r <= x){
			r = x;
			continue;
		}
		if(l >= r && r >= x){
			r = x;
			continue;
		}
		l = r = x;
		ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define WHITE 0
#define BLACK 1
#define NIL -1
#define INF 2000000000

void prim(int, int );

int graph[101][101];
int d[101];
int pi[101];
int color[101];
int x = 0;

int main(){

  int sumnode,i,j;

  scanf("%d",&sumnode);

  for(i = 1; i <= sumnode; i++){

    for(j = 1; j <= sumnode; j++){

      scanf("%d",&graph[i][j]);

    }

  }

  prim(sumnode,1);



  for(i = 1; i <= sumnode; i++){

    x = x + d[i];

  }

  printf("%d\n",x);

  return 0;

}


void prim(int sumnode,int first){

  int i,mincost,v,u,j;
  mincost = INF;

  for(u = 1; u <= sumnode; u++){


    d[u] = INF;
    pi[u] = NIL;
    color[u] = WHITE;

  }


  d[first] = 0;

  while(1){

    mincost = INF;

    for(i =1; i<=sumnode;i++){

      if(color[i] != BLACK && d[i] < mincost){

	 mincost = d[i];

	 u = i;

      }
  
    }

    if(mincost == INF)  

      break;

    color[u] = BLACK;

      for(v=1 ; v <= sumnode;v++){

	if(graph[u][v] == -1){

	  continue;

	}

	if (color[v] != BLACK && graph[u][v] < d[v]){

	  pi[v] = u;

	  d[v] = graph[u][v];

	}
      }
  }

}

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

const int N = (int) 1e5 + 5;

struct TPair {
	int x, y;
	TPair() {}
	TPair(int x, int y) : x(x), y(y) {}
} s[N];

int n, m;
int p[N], par[N];

int cnt;
int mask[N];
vector <int> component[N];

int root(int u) {
	return u == par[u] ? u : par[u] = root(par[u]);
}

void join(int u, int v) {
	par[root(u)] = root(v);
}

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
	for (int i = 1; i <= m; i++) scanf("%d %d", &s[i].x, &s[i].y);
	for (int i = 1; i <= n; i++) par[i] = i;
	for (int i = 1; i <= m; i++) {
		int u = s[i].x, v = s[i].y;
		if (root(u) == root(v)) continue;
		join(u, v);
	}
	for (int i = 1; i <= n; i++) {
		int r = root(i);
		if (mask[r] == false) mask[r] = ++cnt;
		component[mask[r]].push_back(i);
	}
	int res = 0;
	fill(mask, mask + n + 1, 0);
	for (int i = 1; i <= cnt; i++) {
		for (int x = 0; x < component[i].size(); x++) mask[p[component[i][x]]] = 1;
		for (int x = 0; x < component[i].size(); x++) res += mask[component[i][x]];
		for (int x = 0; x < component[i].size(); x++) mask[p[component[i][x]]] = 0;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 7680
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
// HFUU-QerM  
// 00:09:24
ll CEIL(ll a,ll b)
{
	// 返回a/b并向上取整。
	ll res=a/b;
	if(a%b)
	{
		res++;
	}
	return res;
}
int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	ll a,b;
	ll n;
	cin>>n;
	cin>>a>>b;
	n--;
	ll x,y;
	repd(i,1,n)
	{
		cin>>x>>y;
		ll num=max(CEIL(a,x),CEIL(b,y));
		a=num*x;
		b=num*y;
	}
	cout<<a+b<<endl;
	
	
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 256
#!/usr/bin/env python3
#CODEFESTIVAL2017qualA B

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,k = LI()
for i in range(n+1):
    for j in range(m+1):
        if j*(n-i) + i*(m-j) == k:
            print('Yes')
            quit()
print('No')


Measured memory_bytes: 38896
import java.util.Scanner;
class Main{
public static void main(String[]args){
Scanner scan=new Scanner(System.in);
  int a=scan.nextInt();
  int min=1145141919;
  int max=0;
  for(int i=0;i<a;i++){
  int b=scan.nextInt();
    if(b>max){
    max=b;
    }
    if(b<min){min=b;}
  }
  System.out.println(max-min);
}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	rep(i, 0, 4){
		cout << s[i];
	}
	cout << " ";
	rep(i, 4, s.size()){
		cout << s[i];
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll A,B,C,D;
cin >> A >> B >> C >> D; 
for(int i = 0 ; i <= 105 ; i++){
  C-=B;
  if(C<=0){
    cout << "Yes" <<endl;
    break;
  }
 A-=D;
 if(A<=0){
   cout << "No" << endl;
   break;
 }
}
}


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

int main() {
  string s; cin>>s;
  if(s.size()==2) cout<<1<<endl;
  else{
    s=s.substr(0,s.size()-2);
    int size=s.size();
    int width=size;
    for(int i=0; i<size/2;i++){
      string s1,s2;
      s1=s.substr(0,width/2);
      s2=s.substr(width/2);
      if(s1==s2){
        cout<<width<<endl;
        break;
      }
      else{
        if(width==2) cout<<1<<endl;
        else{
          s=s.substr(0,s.size()-2);
          width=s.size();
        }
      }
    }
  }
}   
    


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long 
int main()
{
	ll n,k;
	cin>>n>>k;
	ll h[n];
	for(ll i=0;i<n;i++)
	{
		cin>>h[i];
	}
	ll dp[n];
	for(ll i=0;i<n;i++)
	{
		dp[i]=LLONG_MAX;
	}
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	//cout<<dp[0]<<endl<<dp[1]<<endl;
	for(ll i=2;i<n;i++)
	{
		if((i-k)<0)
		{
			for(ll j=0;j<i;j++)
			{
				dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
			}
		}
		else
		{
			for(ll j=i-k;j<i;j++)
			{
				dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
			}
		}
		//cout<<dp[i]<<endl;
	}
	cout<<dp[n-1]<<endl;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, M, K; cin >> N >> M >> K;
    Rep1(i, 0, N){
        Rep1(j, 0, M){
            if(i*j + (N-i)*(M-j) == K){
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (auto &it : A)
  {
    cin >> it;
  }
  vector<ll> ans = A;
  for (int k = 0; k < K; k++)
  {
    vector<ll> imos(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
      ll l = max(0LL, i - ans[i]);
      ll r = min((ll)(N - 1), i + ans[i]);
      imos[l]++;
      imos[r + 1]--;
    }
    bool ok = true;
    int MAX = N;
    if (ans[0] != MAX)
      ok = false;
    ans[0] = imos[0];
    for (int i = 1; i < N; i++)
    {
      imos[i] += imos[i - 1];
      ans[i] = imos[i];
      if (ans[i] != MAX)
        ok = false;
    }
    if (ok)
    {
      for (auto it : ans)
        cout << it << " ";
      cout << endl;
      return 0;
    }
  }
  for (auto it : ans)
    cout << it << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, D;
  cin >> N >> D;
  
  vector<vector<int>> point(N,vector<int>(D));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < D; j++){
    cin >> point.at(i).at(j);
    }
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < i; j++){
      int dist = 0;
      for(int k = 0;k < D; k++){
        dist += (point.at(i).at(k) - point.at(j).at(k)) * (point.at(i).at(k) - point.at(j).at(k));
      }
      int x = 0;
      while(x*x <= dist){
        if(x*x == dist){
          count += 1;
          break;
        }
        x++;
      } 
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,k,x,y;
int main()
{
	scanf("%lld%lld",&n,&k);
	n--;
	for(ll i=0;i<k;i++){
		scanf("%lld%lld",&x,&y);
		x--;
		y--;
		x=min(x,n-x);
		y=min(y,n-y);
		x=min(x,y);
		if(x%3==0){
			puts("1");
		}
		else if(x%3==1){
			puts("2");
		}
		else puts("3");
	}
}

Measured memory_bytes: 3112
module mod_quick_sort
  implicit none
  integer, private, parameter :: intkind = 4
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a, b
    res = a <= b
  end
  subroutine swap(a, b)
    integer(intkind), intent(inout) :: a, b
    a = xor(a, b)
    b = xor(a, b)
    a = xor(a, b)
  end
  recursive subroutine quick_sort(a)
    integer(intkind), intent(inout) :: a(:)
    integer(intkind) :: p
    integer :: n, l, r, m
    n = size(a)
    l = 1
    r = n
    m = (n + 1) / 2
    p = a(l) + a(m) + a(r) - min(a(l), a(m), a(r)) - max(a(l), a(m), a(r))
    do
      do while (.not.less(p, a(l)))
        l = l + 1
      end do
      do while (.not.less(a(r), p))
        r = r - 1
      end do
      if (l >= r) exit
      call swap(a(l), a(r))
      l = l + 1
      r = r - 1
    end do
    if (1 < l - 1) call quick_sort(a(1:l - 1))
    if (r + 1 < n) call quick_sort(a(r + 1:n))
  end
end module mod_quick_sort
program dist_max
  use mod_quick_sort
  implicit none
  integer :: n, x, y, i
  integer, dimension(200000) :: a = 0, b = 0
  read(*,*) n
  do i = 1, n
    read(*,*) x, y
    a(i) = x + y
    b(i) = x - y
  end do
  call quick_sort(a(1:n))
  call quick_sort(b(1:n))
  write(*,'(i0)') max(a(n) - a(1), b(n) - b(1))
end program dist_max

Measured memory_bytes: 4500
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>


using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int N;
    cin >> N;

    int T[N + 2];
    REP(i, N) cin >> T[i+1];
    T[0] = 0;
    T[N+1] = 0;

    double v[N+2];
    REP(i, N) cin >> v[i+1];
    v[0] = 0;
    v[N+1] = 0;

    double vt[200 * 1000];
    vt[0] = 0;

    int t = 0;
    double ans = 0;
    FOR(n, 1, N+2) {
        REP(_t, 2 * T[n]) {
            ++t;
            vt[t] = vt[t - 1] + 1;

            int ts = 0;
            REP(i, N+2) {
                vt[t] = min(vt[t], v[i] + abs(ts - double(t) / 2));
                if (i == n) vt[t] = min(vt[t], v[i]);

                ts += T[i];
                vt[t] = min(vt[t], v[i] + abs(ts - double(t) / 2));
                if (i == n) vt[t] = min(vt[t], v[i]);
            }

            ans += (vt[t] + vt[t-1]) / float(4);
        }
    }

    cout << fixed << setprecision(20);
    cout << ans << endl;

}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#define maxn 100010
using namespace std;
long long n,m,i,j,a[maxn],b[maxn],c[31],t,x,sum,ans;
int main()
{
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&a[i],&b[i]);
	for(j=1;j<=n;j++)
		if((a[j]&m)==a[j])ans+=b[j];
	while(m)
	{
		c[++t]=m&1;
		m>>=1;
	}
	x=(1<<t)-1;
	for(i=t;i;i--)
	{
		x-=1<<(i-1);
		if(c[i])
		{
			sum=0;
			for(j=1;j<=n;j++)
				if((a[j]&x)==a[j])sum+=b[j];
			ans=max(ans,sum);
		}
		if(c[i])x+=1<<(i-1);
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <bitset>
#include <functional>

using namespace std;

#define FOR(i,n) 		for(int(i)=0;(i)<(int)(n);(i)++)
#define FORN(i,a,b,c) 	for(int(i)=a;i<(int)(b);i+=(c))
#define RES(x,nilai)	memset(x,nilai,sizeof(x));
#define pb              push_back
#define mp              make_pair
#define INF				1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

inline string IS(int a){
    char x[100];
    sprintf(x,"%d",a); string s = x;
    return s;
}

inline int SI(string a){
    char x[100]; int res;
    strcpy(x,a.c_str()); sscanf(x,"%d",&res);
    return res;
}

//==============================================

bool cmp(int x,int y) {return x>y;}

int n,x;


int main() {
	//freopen("in.txt","r",stdin);
	//freopen("13.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	while (cin >> n) {
		if (n == 0) break;
		
		vector<int> v;
		map <int,int> ma;
		
		for(int i = 0;i < n; i++) {
			cin >> x;
			v.pb(x); ma[x]++;
		}
		
		int maks = -INF, indeks = -1;
		for(int i =0 ; i < v.size(); i++) {
			if (ma[v[i]] > maks) {maks = ma[v[i]]; indeks = v[i];}
		}
		
		if (maks > n/2) {cout << indeks << endl;}
		else cout << "NO COLOR" << endl;
	}
	
	
    return 0;
}

Measured memory_bytes: 11992
#include <iostream>
#include <string> 
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;

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

	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;

void main()
{
    real[] heits;
    while(true)
    {
        auto line = readln;
        if(!line)break;
        heits ~= line.chomp.to!real;
    }
    heits.sort;
    (heits[$ - 1] - heits[0]).writeln;
}

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

int main()
{
	int a,b,c,x,y,n;
	vector<int> ans;
	cin >> a >> b >> c >> x >> y;
	ans.push_back(a*x+b*y);
	ans.push_back(2*c*(x>=y?x:y));
	ans.push_back(2*c*(x<=y?x:y)+(x>=y?(x-y)*a:(y-x)*b));
	sort(ans.begin(),ans.end());
	cout << ans[0] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int x, y;
  cin >> x >> y;
  bool ok = false;
  REP(i, 100) {
    REP(j, 100) {
      if (i + j == x && 2 * i + 4 * j == y) {
        ok = true;
        break;
      }
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
  int i;
  char o[51],e[51];
  scanf("%s\n%s",o,e);
  for (i=0;1;i++){
    if (!o[i]) break;
    printf("%c",o[i]);
    if (!e[i]) break;
    printf("%c",e[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#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
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  char a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  if(c==d&&e==f)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    char c; std::cin >> c;
    switch (c)
    {
    case 'A':
        std::cout << 'T' << std::endl;
        break;
    case 'C':
        std::cout << 'G' << std::endl;
        break;
    case 'G':
        std::cout << 'C' << std::endl;
        break;
    case 'T':
        std::cout << 'A' << std::endl;
        break;
    default:
        break;
    }
    return 0;
}

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

int main() {
	int w,a,b;
	cin>>w>>a>>b;
	int a1 , b1;
	a1=a+w;
	b1=b+w;	
	if(b<=a1&&b>=a){
		cout<<0<<endl;
	}
	else if(a1>=b){
		cout<<min(a1-b,a-b1)<<endl;
	}
	else if(a1<=b){
		cout<<min(b-a1,b1-a)<<endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
def main():
    n,p = map(int,input().split())
    a = list(map(int,input().split()))
    D = {0:0, 1:0}
    for i in range(n):
        D[a[i]%2]+=1
    ans = 0

    nCr = {}
    def cmb(n, r):
        if r == 0 or r == n: return 1
        if r == 1: return n
        if (n,r) in nCr: return nCr[(n,r)]
        nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
        return nCr[(n,r)]
    if p==0:
        for i in range(D[1]//2+1):
            ans += cmb(D[1],2*i)
    else:
        for i in range(D[1]//2):
            ans += cmb(D[1],2*i+1)
    print(ans * pow(2,D[0]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9244
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, k;
    cin >> n >> k;
    vint p(n);
    rep(i, n) cin >> p[i];
    sort(all(p));

    int ans = 0;
    rep(i, k) ans += p[i];

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#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 pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

ll a[100001],b[100001];
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i]>>b[i];
    ll cnt=0;
    for(int i=n-1;i>=0;--i){
        cnt+=(b[i]-(a[i]+cnt)%b[i])%b[i];
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1792
def bblsrt(cards):
    cards1 = cards.copy()
    for i in range(len(cards1)):
        for j in range(len(cards1) - 1, i, -1):
            if cards1[j][1] < cards1[j - 1][1]:
                cards1[j], cards1[j - 1] = cards1[j - 1], cards1[j]
    return cards1


def slcsrt(cards):
    cards2 = cards.copy()
    for i in range(len(cards2)):
        minj = i
        for j in range(i, len(cards2)):
            if cards2[j][1] < cards2[minj][1]:
                minj = j
        cards2[i], cards2[minj] = cards2[minj], cards2[i]
    return cards2


n = int(input())
C = list(input().split())
print(' '.join(bblsrt(C)))
print('Stable')
print(' '.join(slcsrt(C)))
print('Stable' if slcsrt(C) == bblsrt(C) else 'Not stable')



Measured memory_bytes: 5608
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s,s1;
    cin >> s >> s1;
    rp(i,s.length()){
      if(s[i] != s1[s.length()-i-1]) {
        cout << "NO"<<endl;
        return 0;
      }
    }
    cout << "YES"<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

int n, a, s, g;
vector<string> labels[42][42];

string solve()
{
  bool valid[42] = {};
  valid[g] = true;
  vector<string> cur(n, "");
  /*
  vector<bool> arege(n, false);
  vector<int> next(n, -1);
  set<pair<pair<int, int>, int> > used;
  */
  // bool changed = true;
  // while (changed) {
  rep(superstep, 20 * n) {
    // changed = false;
    rep(j, n) {
      if (!valid[j]) continue;
      rep(i, n) {
	rep(k, (int) labels[i][j].size()) {
	  string tmp(all(labels[i][j][k]));
	  tmp.insert(tmp.end(), all(cur[j]));
	  if (!valid[i] || tmp < cur[i]) {
	    valid[i] = true;
	    cur[i] = tmp;
	    /*
	    if (used.find(mp(mp(i, j), k)) != used.end())
	      arege[i] = true;
	    else
	      changed = true;
	    next[i] = j;
	    used.insert(mp(mp(i, j), k));
	    */
	    if (i == s && superstep >= 10 * n)
	      return "NO";
	  }
	}
      }
    }
  }

  if (!valid[s])
    return "NO";
  /*
  int v = s;
  while (next[v] >= 0) {
    if (arege[v])
      return "NO";
    v = next[v];
  }
  */
  return cur[s];
}

int main() {
  while (cin >> n >> a >> s >> g && n) {
    rep(i, 42) rep(j, 42) labels[i][j].clear();
    rep(i, a) {
      int x, y; string lab;
      cin >> x >> y >> lab;
      labels[x][y].pb(lab);
    }

    cout << solve() << endl;
  }

  return 0;
}

Measured memory_bytes: 2704
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        n: usize,
    }

    if n == 1 {
        println!("1");
        return;
    }

    let mut a = 2;
    let mut b = 1;
    let mut l = 0i64;
    for _ in 2..=n {
        l = b + a;
        a = b;
        b = l;
    }
    println!("{}", l);
}


Measured memory_bytes: 2160
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;
using P = std::pair<ll, ll>;

ll S, W;

int main()
{
  std::cin >> S >> W;

  std::cout << (W >= S ? "unsafe" : "safe") << std::endl;

  return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, N) FOR(i, 0, N)
#define RREP(i, N) RFOR(i, N, 0)
#define FILL(A,value) memset(A,value,sizeof(A))
#define endl '\n'

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define Pi 3.14159265358979
#define A first
#define B second

typedef long long ll;
typedef vector <int> vi;
typedef vector<ll> vl;
typedef pair <int, int> pi;
typedef pair <ll, int> pl;
typedef pair <ll, ll> pll;
typedef pair <double, double> pd;

//change these according to prob constraints
const int INF = 0x3f3f3f3f;
const int MAX = 100005;
const int MAX1 = 1005;
const int MAX2 = 105;
const int LEN = 105;
const int BASE = 1000000000;
const double EPS = 1e-7;
const int MOD = 1000000007;
//g++ -std=c++11 your_file.cpp -o your_program

ll mypow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ifstream in("");
	ofstream out("");
	clock_t begin = clock();
	int n;
    cin >> n;
    vector<ll> tmp;
    set<ll> fin;
    REP(i, 9) {
        tmp.pb(i + 1);
        fin.insert(i + 1);
    }
    int dig = 9;
    while (dig--){
        vector<ll> tmp1;
        REP(i, SZ(tmp)){
            int tmpdig = tmp[i] % 10;
            if (tmpdig != 0) tmp1.pb((ll)10 * tmp[i] + (ll)tmpdig - 1);
            tmp1.pb((ll)10 * tmp[i] + (ll)tmpdig);
            if (tmpdig != 9) tmp1.pb((ll)10 * tmp[i] + (ll)tmpdig + 1);
        }
        for (auto x : tmp1) fin.insert(x);
        tmp.clear();
        REP(i, SZ(tmp1)) tmp.pb(tmp1[i]);
        tmp1.clear();
    }
    int ct = 1;
    for (auto x : fin) {
        //cout << x << endl;
        if (ct == n) {
            cout << x << endl;
            break;
        }
        ++ct;
    }
	clock_t end = clock();
    double esecs = double(end - begin) / CLOCKS_PER_SEC;
    //cout << esecs << " seconds" << endl;
	return 0;	
}

Measured memory_bytes: 11668
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;
using V = vector<int>;

void dfs(const int& u, const int& p, const bool& b, const vector<V>& g, V& bi, vector<V>& bipartite) {
    if (bi[u] >= 0) return;
    bi[u] = b;
    bipartite[b].push_back(u);

    for (auto v : g[u]) {
        if (v == p) continue;
        dfs(v, u, !b, g, bi, bipartite);
    }
}

void corner(vector<V>& mod, const vector<V>& bipartite) {
    int n = bipartite[0].size() + bipartite[1].size();

    V ans(n+1);
    for (auto b : bipartite[1]) {
        ans[b] = mod[0].back();
        mod[0].pop_back();
    }

    queue<int> q;
    for (int i=0; i<3; i++)
        for (auto m : mod[i]) q.emplace(m);

    for (auto b : bipartite[0]) {
        ans[b] = q.front();
        q.pop();
    }

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

int main() {
    int n;
    cin >> n;
    vector<V> g(n+1);
    vector<V> bipartite(2);
    for (int i=0; i<n-1; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> bi(n+1, -1);
    dfs(1, -1, false, g, bi, bipartite);

    if (bipartite[0].size() < bipartite[1].size()) swap(bipartite[0], bipartite[1]);

    vector<V> mod(3);
    for (int i=1; i<=n; i++) mod[i%3].push_back(i);

    if (bipartite[1].size() <= n/3) {
        corner(mod, bipartite);
        return 0;
    }

    V ans(n+1);
    for (int i=0; i<2; i++) {
        for (auto b : bipartite[i]) {
            if (!mod[i+1].empty()) {
                ans[b] = mod[i+1].back();
                mod[i+1].pop_back();
            }
            else {
                ans[b] = mod[0].back();
                mod[0].pop_back();
            }
        }
    }

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


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

int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    for(int i = tx - sx; i > 0; i--){
        cout << "R";
    }
    for(int i = ty - sy; i > 0; i--){
        cout << "U";
    }
    for(int i = tx - sx; i > 0; i--){
        cout << "L";
    }
    for(int i = ty - sy + 1; i > 0; i--){
        cout << "D";
    }
    for(int i = tx - sx + 1; i > 0; i--){
        cout << "R";
    }
    for(int i = ty - sy + 1; i > 0; i--){
        cout << "U";
    }
    cout << "L" << "U";
    for(int i = tx - sx + 1; i > 0; i--){
        cout << "L";
    }
    for(int i = ty - sy + 1; i > 0; i--){
        cout << "D";
    }
  	cout << "R";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
ll d[300][300],v, n, c, e, u, k, sum = 0,ans;
const  long long int INF = (1LL << 32);
void warshall_floyd(int n) { // nは頂点数
    rep(k, n) {  // 経由する頂点
        rep(i, n) {
            if (d[i][k] == INF) continue;// 開始頂点
            rep(j, n) {// 終端
                if (d[k][j] == INF) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
int main(void) {
    cin >> n >> e >> k;
    vector<int>r(k);
    rep(i, k) { 
        cin >> r[i];r[i]--;
    }
    sort(r.begin(), r.end());
    rep(i, n) {
        rep(j, n) {
            d[i][j] = ((i == j) ? 0 : INF);
        }
    }
    rep(i, e) {
        cin >> u >> v >> c;u--;v--;
        d[u][v] = c;
        d[v][u] = c;
    }
    warshall_floyd(n);ans = 9223372036854775800;
        do {
            sum = 0;
            rep(i, k - 1) {
                sum += d[r[i]][r[i + 1]];
            }
            ans = min(ans, sum);
        } while (next_permutation(r.begin(), r.end()));
    cout << ans << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
int n,f[100005][2];
char a[100005];
int add(int a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	return a;
}
signed main()
{
	cin>>a;
	n=strlen(a);
	f[0][0]=1;
	for(int i=0;i<n;i++)
	{
		if(a[i]=='0')
		{
			f[i+1][0]=add(f[i+1][0],f[i][0]);
			f[i+1][1]=add(f[i+1][1],f[i][1]);
		}
		else f[i+1][1]=add(f[i+1][1],add(f[i][0],f[i][1]));
		if(a[i]=='0')
		{
			f[i+1][1]=add(f[i+1][1],add(f[i][1],f[i][1]));
		}
		else{
			f[i+1][0]=add(f[i+1][0],add(f[i][0],f[i][0]));
			f[i+1][1]=add(f[i+1][1],add(f[i][1],f[i][1]));			
		}
	}
	cout<<add(f[n][0],f[n][1]);
}

Measured memory_bytes: 1920
#include <stdio.h>

int main()
{
  double h;
  while(scanf("%lf", &h) != EOF)
    {
      int n;
      
      n = (4.9*(h/9.8)*(h/9.8) + 5)/5 + 1;
      printf("%d\n", n);
    }

  return 0;
}
	  

Measured memory_bytes: 628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int a, b, h, m; cin >> a >> b >> h >> m;
  double theta = M_PI * 2 * abs((h + m / 60.0) / 12.0 - m / 60.0);
  if (abs(theta - M_PI) < EPS) {
    cout << a + b << '\n';
    return 0;
  }
  cout << sqrt(a * a + b * b - 2 * a * b * cos(min(theta, M_PI * 2 - theta))) << '\n';
  return 0;
}


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

int main() {
    long long x;
    cin >> x;

    auto y = 100LL;
    auto year = 0;
    while (y < x) {
        y += (y / 100);
        ++year;
    }

    cout << year << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#define rep(i,n) for(ll i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main()
{
    const ll INF = 1e9 + 7;
    ll n, sum = 0, ans = 0;
    cin >> n;
    vector<ll>a(n);
    rep(i,n){
        cin >> a[i];
        a[i] = a[i] % INF;
        sum += a[i];
    }
    rep(i,n){
        sum -= a[i];
        ans += ((a[i] % INF) * (sum % INF)) % INF; 
    }
    cout << ans % INF << endl;
    return 0;
}

Measured memory_bytes: 4788
INFTY = 10 ** 9
count = 0

def merge(A, left, mid, right):
    global count

    n1 = mid - left
    n2 = right - mid

    L = A[left:mid] + [INFTY]
    R = A[mid:right] + [INFTY]

    i = 0
    j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        
        count += 1


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)



n = int(input())
S = list(map(int, input().split()))

mergeSort(S, 0, len(S))
print(*S)
print(count)


Measured memory_bytes: 63688
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	vector< vector<int> > a(n, vector<int>(m, 0));
	vector<int> b(m);
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}

	for (int i = 0; i < n; i++)
	{
		int res_nth = 0;
		for (int j = 0; j < m; j++)
		{
			res_nth += (a[i][j] * b[j]);
		}
		cout << res_nth << endl;
	}
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    ll n;
    ll ans = 100000;
    auto f = [](ll x) {
        ll a = 0;
        while (x > 0)
        {
            x /= 10;
            a++;
        }
        return a;
    };
    cin >> n;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ll j = n / i;
            chmin(ans, max(f(i), f(j)));
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
	if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3])) cout<<"Yes";
	else cout<<"No";
}

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

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

  if(A==B){
    cout << "Draw" << endl;
  }
  else if(A==1){
    cout << "Alice" << endl;
  }
  else if(B==1){
    cout << "Bob" << endl;
  }
  else if(A<B){
    cout << "Bob" << endl;
  }
  else if(A>B){
    cout << "Alice" << endl;
  }

return 0;  
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
      	int n = Integer.parseInt(line);
      
      	int x = n % 1000;
      	int answer = 0;
      	if(x > 0){
          answer = 1000 - x;
        }
      System.out.println(String.valueOf(answer));
    }
}

Measured memory_bytes: 35644
N,M,X = gets.split.map(&:to_i)
CA = readlines.map {|s| s.split.map(&:to_i) }

if CA.each_with_object(Array.new(M,0)) {|(c,*a),r| M.times {|i| r[i] += a[i] } }.all? {|n| X <= n }
  ans = 2000000
  1.step(N) do |i|
    [*0...N].combination(i) do |a|
      ca = a.map {|j| CA[j] }
      if ca.each_with_object(Array.new(M,0)) {|(c,*a),r| M.times {|i| r[i] += a[i] } }.all? {|n| X <= n }
        sum = ca.sum {|c,*a| c }
        ans = sum if sum < ans
      end
    end
  end
else
  ans = -1
end
puts ans

Measured memory_bytes: 14808
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
constexpr int INF = (numeric_limits<int>::max() == INT_MAX ? (int)1e9 : (long long)1e18);
constexpr long double eps = 1e-6;
const string el = "\n";
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;using pii = pair<int,int>;using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void fast_io(){ios::sync_with_stdio(false); cin.tie(nullptr);}
int out(int a){cout << a << el; return 0;}
int out(string s = "NO"){cout << s << el; return 0;}
template <class T>
inline int out(vector<T>&v,string c = " "){
    for(int i = 0; i < v.size(); ++i){
        if(i) cout << c; cout << v[i];
    } cout << el;return 0;
}
signed main(){
    fast_io();
    int n,h,w; cin >> n >> h >> w;
    vector<pii>v(n);
    for(auto& p : v) cin >> p.first >> p.second;
    cout <<
    count_if(all(v),[&](pii p){
        return p.first >= h && p.second >= w;
    })
    << endl;
}


Measured memory_bytes: 256