akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int C[100000000];
int A[100000000];
int count=0;
void merge(int a[],int left,int right);
int main(){
  int i,n;
 
  scanf("%d",&n);
  for(i=0; i < n ; i++){
    scanf("%d",&A[i]);
  }
  merge(A,0,n-1);
  for(i=0; i < n ; i++){
    if(i < n-1){
    printf("%d ",A[i]);
    }
    else{
      printf("%d",A[i]);
    }
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(int A[],int left,int right){
  int mid,i,j,p;
  if(right <=left)return;
  mid=(left+right)/2;
  merge(A,left,mid);
  merge(A,mid+1,right);

  for(i=left; i <= mid;i++){
    C[i]=A[i];
  }
  j=right;
  for(i=mid+1;i <=right;i++){
    C[i]=A[j];
    j--;
  }
  j=right;
  i=left;
  for(p=left;p<=right;p++){
    if(C[i]<=C[j]){
      A[p]=C[i++];
      count++;
    }
    else{
      A[p]=C[j--];
      count++;
    }
  }
}



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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  vector<vector<int>> g(n);
  for (int _ = n - 1; _--; ) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> res(n), dp(n + 1, inf<int>);
  dp[0] = 0;
  auto dfs = [&](auto&& self, int v, int p) -> void {
    res[v] = lower_bound(begin(dp), end(dp), inf<int>) - begin(dp) - 1;
    for (int u : g[v]) {
      if (u != p) {
        auto it = lower_bound(begin(dp), end(dp), a[u]);
        auto t = exchange(*it, a[u]);
        self(self, u, v);
        *it = t;
      }
    }
  };
  dp[1] = a[0];
  dfs(dfs, 0, -1);
  for (auto e : res) {
    cout << e << '\n';
  }
}


Measured memory_bytes: 30848
#include <bits/stdc++.h>
#include <boost/range.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>
#include <boost/math/constants/constants.hpp>
using namespace std;
namespace rng {
    using namespace boost::range;
    using namespace boost::adaptors;
}

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

using boost::irange;
using boost::math::double_constants::pi;
using i64 = int64_t;
constexpr char nl = '\n';
auto yesno(bool b) { return b ? "Yes" : "No"; }

template<class T> istream& operator>>(istream& in, vector<T>& vs) { for (T& v :vs) in >> v; return in; }
template<class T> ostream& operator<<(ostream& out, const vector<T>& vs) { for (size_t i = 0; i < vs.size(); ++i) { if(i) { out << ' '; } out << vs[i]; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const T& v) { cout << v; }
template<class T> void trace_(const vector<vector<T>>& m) { cout << nl; for (const auto& v : m) { trace_(v); cout << nl; } }
template<class T> void trace_(const char* s, const T& v) { cout << s << "="; trace_(v); cout << nl; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cout << *s; } cout << "="; trace_(v); trace_(s, vs...); }
#define TRACE(...) trace_(#__VA_ARGS__, __VA_ARGS__)
#else
#define TRACE(...)
#endif

int main() {
    int N;
    cin >> N;
    for (int a : irange(1, 10)) {
        for (int b : irange(1, 10)) {
            if (N == a * b) {
                cout << "Yes" << nl;
                return 0;
            }
        }
    }
    cout << "No" << nl;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(){
  int number;
  int h,m;

  cin >> number;

  h = number/3600;
  number %= 3600;

  m = number /60;
  number %= 60;
 
  cout << h << ":" << m << ":" << number << endl;
   

  return 0;
   
}

Measured memory_bytes: 3100
#include<stdio.h>

int main()
{
    int H, N, i, sum=0;

    scanf("%d %d", &H, &N);

    int A[N+2];

    for(i=1; i<=N; i++){///0.001+0.001
        scanf("%d", &A[i]);
    }

    for(i=1; i<=N; i++){
        sum += A[i];
        if(sum >= H){
            N=0;
            break;
        }

    }

    if(N==0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 2008
import java.util.Scanner;


	public class Main{
	  public static void main(String[] args) {
		  
		  Scanner scanner = new Scanner(System.in);
		  
		    String S = scanner.next();
	 		String T = scanner.next();
	 		
		  if (T.length() == S.length()+1 && T.indexOf(S) == 0) {
			  System.out.println("Yes");
		  }
		  else{
			  System.out.println("No");
		  }
		  scanner.close();
	}
}


Measured memory_bytes: 26932
// Aizu 2188: Unit Converter
// 2017.9.20 bal4u@uu

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

char *pre[20] = { 
	"yotta", "zetta", "exa", "peta", "tera",
	"giga", "mega", "kilo", "hecto", "deca",
	"deci", "centi", "milli", "micro", "nano",
	"pico", "femto", "ato", "zepto", "yocto" };
int idx[20] = {
	24, 21, 18, 15, 12,  9,   6,   3,   2,	 1,
	-1, -2, -3, -6, -9,-12, -15, -18, -21, -24 };
 
char buf[1105], ans[1105];

int main()
{
	int t, i, a, b, f;
	char *p, *q, *w;

	fgets(buf, 10, stdin); t = atoi(buf);
	while (t-- > 0) {
		fgets(buf, 1100, stdin); p = buf, q = ans;
		while (isspace(*p)) p++;
		while (*p == '0') p++;
		a = b = 0, f = 0;
		if (*p > '0') *q++ = *p++, f = 1;
		while (isdigit(*p)) {
			if (f == 1) *q++ = '.', f = 2;
			*q++ = *p++, a++;
		}
		if (*p == '.') { if (f == 1) *q++ = '.', f = 2; p++; }
		if (!f) a = -1;
		while (*p == '0') {
			if (f) *q++ = *p;
			else a--;
			p++;
		}
		if (isdigit(*p)) { if (!f) *q++ = *p++, f = 1; }
		while (isdigit(*p)) {
			if (f == 1) *q++ = '.', f = 2;
			*q++ = *p++;
		}
		while (isspace(*p)) p++;
		w = p; while (isalpha(*p)) p++;
		*p = 0;
		for (i = 0; i < 20; i++) if (!strcmp(w, pre[i])) { b = idx[i]; break; }
		if (i < 20) { p++; while (isspace(*p)) p++; w = p; }
		sprintf(q, " * 10^%d ", a + b);
		q += strlen(q);
		while (isalpha(*w)) *q++ = *w++;
		*q = 0;
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 1796
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans =0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3920
#include <iostream>
using namespace std;
int main(){
    char a[16];
    int n1,n2,n3,n4,ans;
    cin >> a ;
    n1 = a[0]-'0';
    n2 = a[1]-'0';
    n3 = a[2]-'0';
    n4 = a[3]-'0';
    for(int j=0;j<2;j++){
        if(j==1)n2=-1*n2;
        for(int x=0;x<2;x++){
            if(x==1)n3=-1*n3;
            for(int y=0;y<2;y++){
                if(y==1)n4=-1*n4;
                ans=n1+n2+n3+n4;
                if(ans==7){
                    cout<<n1;
                    if(n2>=0)cout<<"+";
                    cout<<n2;
                    if(n3>=0)cout<<"+";
                    cout<<n3;
                    if(n4>=0)cout<<"+";
                    cout<<n4;
                    cout<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    private static int Main() {
        var input = Console.ReadLine();
        var n = int.Parse( input );

        input = Console.ReadLine();
        var values = input.Split( ' ' );
        var x = values.Select<string, int>( _ => int.Parse( _ ) ).ToList();

        input = Console.ReadLine();
        values = input.Split( ' ' );
        var y = values.Select<string, int>( _ => int.Parse( _ ) ).ToList();

        var p1 = GetMinkowskiSpace( n, x, y, 1 );
        var p2 = GetMinkowskiSpace( n, x, y, 2 );
        var p3 = GetMinkowskiSpace( n, x, y, 3 );
        var pi = GetMinkowskiSpace( n, x, y, double.PositiveInfinity );

        Console.WriteLine( p1 );
        Console.WriteLine( p2 );
        Console.WriteLine( p3 );
        Console.WriteLine( pi );


        return 0;
    }

    /// <summary>
    /// ミンコフスキー距離を取得
    /// </summary>
    /// <param name="n">要素数</param>
    /// <param name="x">Xベクトル</param>
    /// <param name="y">Yベクトル</param>
    /// <param name="p">p</param>
    /// <returns></returns>
    private static double GetMinkowskiSpace( int n, System.Collections.Generic.List<int> x, System.Collections.Generic.List<int> y, double p ) {
        if( p == double.PositiveInfinity ) {
            var max = 0;
            for( int i = 0; i < n; ++i ) {
                var d = Math.Abs( x[ i ] - y[ i ] );
                if( max < d ) { max = d; }
            }

            return max;
        }

        double sum = 0;
        for( int i = 0; i < n; ++i ) {
            sum += Math.Pow( Math.Abs( x[ i ] - y[ i ] ), p );
        }

        return Math.Pow( sum, 1 / p );
    }


}

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


using namespace std;

int main(){
    long long N,A,B,C,D;
    long long ans=0;

    string S;

    cin>>N;

    vector<pair<long ,long>> v(N);

    for (auto &x : v)
    {
        cin>>x.second>>x.first;
    }
    

    sort(v.begin(),v.end());

    long long sum=0;

    for (auto &x : v)
    {

       // cout<<x.first<<" "<<sum<<endl;
        sum+=x.second;
        if(sum>x.first){
            cout<<"No"<<endl;
            return 0;
        }
    }
    
cout<<"Yes"<<endl;



}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	while(1){
		int n,m,l,k,a,h;
		cin >>n>>m>>l>>k>>a>>h;
		if(n==0) break;
		
		vector<int> freeze(l);
		for(int i=0; i<l; i++){
			cin >> freeze[i];
		}
		freeze.push_back(a);
		freeze.push_back(h);
		vector<vector<int> > dp(n, vector<int>(n,inf));
		for(int i=0; i<k; i++){
			int x,y,t;
			cin >> x >> y >> t;
			dp[x][y] = dp[y][x] = t;
		}
		
		for(int k=0; k<n; k++){
			for(int i=0; i<n; i++){
				for(int j=0;j<n; j++){
					if(dp[i][k]+dp[k][j] < dp[i][j]){
						dp[i][j] = dp[i][k]+dp[k][j];
					}
				}
			}
		}
		
		int numfrz = freeze.size();
		for(int i=0; i<numfrz; i++){
			for(int j=0; j<numfrz; j++){
				if(dp[freeze[i]][freeze[j]] > m){
					dp[freeze[i]][freeze[j]] = inf;
				}
			}
		}
		
		for(int k=0; k<numfrz; k++){
			for(int i=0; i<numfrz; i++){
				for(int j=0;j<numfrz; j++){
					int x=freeze[i];
					int y=freeze[j];
					int z=freeze[k];
					if(dp[x][z]+dp[z][y] < dp[x][y]){
						dp[x][y] = dp[x][z]+dp[z][y];
					}
				}
			}
		}
		
		if(dp[a][h]==inf){
			cout << "Help!" << endl;
		}else{
			cout << dp[a][h] +max(0, dp[a][h]-m) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3156
n=int(input())
s=[0]*n
l=[list(map(int,input().split())) for i in range(n-1)]
#print(l)
for i in range(n-1):
    s[i]=l[i][0]+l[i][1]
    #print(s)
    for j in range(i):
        if s[j]<=l[i][1]:
            s[j]=s[i]
        else:
            if s[j]%l[i][2]==0:
                s[j]=l[i][0]+l[i][2]*(s[j]//l[i][2])
            else:
                s[j]=l[i][0]+l[i][2]*(s[j]//l[i][2]+1)
for i in range(n):
    print(s[i])

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(M);
  vector<ll> dp(N+1);
  for(int i = 0; i < M; i++){
    cin >> a[i];
    a[i];
    dp[a[i]] = -1;
  }
  dp[0] = 1;
  for(int i = 1; i <= N; i++){
    if(dp[i] == -1){
      dp[i] = 0;
      continue;
    } 
    if(i != 1) dp[i] = dp[i-1] + dp[i-2];
    else dp[i] = 1;
    dp[i] = dp[i] % 1000000007;
  }
  cout << dp[N] << endl;
}


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

int main() {
  string a, b;
  cin >> a >> b;
  int ab = stoi(a + b);
  double sq = sqrt(ab);
  if(ceil(sq) == floor(sq)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    string a,b,c; 
    cin >> a >> b >> c;
    if (a[a.size()-1]==b[0] && b[b.size()-1]==c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    

    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int w = tx - sx;
    int h = ty - sy;

    for (int i = 0; i < h; i++)
        cout << "U";
    for (int i = 0; i < w; i++)
        cout << "R";
    for (int i = 0; i < h; i++)
        cout << "D";
    for (int i = 0; i < w + 1; i++)
        cout << "L";
    for (int i = 0; i < h + 1; i++)
        cout << "U";
    for (int i = 0; i < w + 1; i++)
        cout << "R";
    cout << "D";
    cout << "R";
    for (int i = 0; i < h + 1; i++)
        cout << "D";
    for (int i = 0; i < w + 1; i++)
        cout << "L";
    cout << "U";

    cout << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int s;
    cin >> s;

    int i = 1;
    vector<int> a;
    a.push_back(s);
    while (1)
    {
        if (a[i - 1] % 2 == 0)
        {
            a.push_back(a[i - 1] / 2);
        }
        else
        {
            a.push_back(3 * a[i - 1] + 1);
        }
        // cout << "i:" << i << "," << a[i] << endl;
        for (int j = 0; j < i; j++)
        {
            if (a[i] == a[j])
            {
                cout << i + 1 << endl;
                return 0;
            }
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 256
from math import atan2, pi


def solve(string):
    a, b, x = map(int, string.split())
    if x >= a**2 * b / 2:
        c, d = 2 * (a**2 * b - x), a**3
    else:
        c, d = a * b**2, 2 * x
    return str(atan2(c, d) * 180 / pi)


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 1610;

#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
int mod = 1000000007;
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (cin >> n)
		cout<<(24+24-n)<<endl;
   	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce
n = int(input())
a = list(map(int,input().split()))
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	ll n; cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];

	vector<ll> left(n+1,0), right(n+1,0);
	left[1]=v[0];	
	rep(i,n){
		left[i+1] = __gcd(left[i],v[i]);
	}
	right[n-2] = v[n-1];
	for(int i = n -3 ; i >= 0; i--){
		right [i] = __gcd(right[i+1],v[i+1]);
	}
//	right[n-2]=v[n-1];
//	rep(i,n-2){
//		right[n-3-i] = __gcd(right[n-2-i] ,v[n-2-i]);
//	}

//	for(auto x : left){
//		cout << x << " ";
//	}
//	cout << endl;
//	for(auto x : right){
//		cout << x << " ";
//	}
//	cout << endl;

	ll ans = 1 ;
	rep(i,n){
		ans = max(ans,__gcd(left[i],right[i]));
	}
	cout << ans << endl;
	}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

ll n, t, s, e;
ll weight[100010];
vector<pair<int, int>> G[100010];
vector<int> rt, last;
map<ll, ll> ed;
bool tk[100010] = {}, ans = 1, one_d[100010] = {};

void route(int k) {
    tk[k] = true;
    rt.push_back(k);
    if (k == e) last = rt; 
    for (int i = 0; i < G[k].size(); i++) {
        if (!tk[G[k][i].first]) route(G[k][i].first);
    }
    rt.pop_back();
}

void dfs(int k) {
    //cout << k << endl;
    vector<ll> l;
    ll lst = 1e9;
    tk[k] = true;
    for (int i = 0; i < G[k].size(); i++) {
        if (!tk[G[k][i].first]) {
            dfs(G[k][i].first);
            if (one_d[G[k][i].second]) lst = weight[G[k][i].second];
            else l.push_back(weight[G[k][i].second]);
        }
    }
    sort(l.begin(), l.end());
    //cout << k << ":";
    //for (int i = 0; i < l.size(); i++) cout << " " << l[i];
    //cout << endl;
    //cout << lst << endl;
    for (int i = 0; i < l.size(); i++) {
        if ((i + 1) * t >= l[i]) {
            ans = false;
            return ;
        }
    }
    if (k == s) {
        if (l.size() * t >= lst) {
            ans = false;
            return ;
        }
    }
    else {
        if ((l.size() + 1) * t >= lst) {
            ans = false;
            return ;
        }
    }
    
}

int main() {
    cin >> n >> t >> s >> e;
    s--;  e--;

    for (int i = 0; i < n - 1; i++) {
        ll a, b, w;
        cin >> a >> b >> w;
        a--;  b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
        if (a > b) {
            int tmp = a;
            a = b;  b = tmp;
        }
        weight[i] = w;
        ed[a * n + b] = i;
    }

    route(s);
    for (int i = 0; i < last.size() - 1; i++) {
        int x = last[i], y = last[i + 1];
        if (x > y) {
            int tmp = y;
            y = x;  x = tmp;
        }
        one_d[ed[x * n + y]] = true;
    }
    
    for (int i = 0; i < n; i++) tk[i] = false;
    dfs(s);

    cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 21200
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,y;
    cin>>n>>y;
    rep(i,n+1){
        rep(j,n+1){
            if(n-i-j<0) continue;
            if(10000*i+5000*j+1000*(n-i-j)==y){
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<' '<<-1<<' '<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;
int main() {
    string b;
    cin >> b;
    string c;
    if (b == "A") c = "T";
    if (b == "T") c = "A";
    if (b == "C") c = "G";
    if (b == "G") c = "C";
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn solve(n:i32) -> bool {
    for i in 0..26 {
        for j in 0..15 {
            if i*4 + j*7 == n {
                return true
            }
        }
    }
    false
}
fn main() {
    let n = read::<i32>();
    println!("{}", if solve(n) { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
object Main{
  def main(args:Array[String]){
    val sc=new java.util.Scanner(System.in)
    val n,m=sc.nextInt
    val a=Array.fill(n,m)(sc.nextInt)
    val b=Array.fill(m)(sc.nextInt)
    a.map(_.zip(b).map(x=>x._1*x._2).sum).map(println)
  }
}

Measured memory_bytes: 59384
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	ll plus = 0;
	for (ll i = n - 1;i >= 0;--i) {
		if ((a[i] + plus) % b[i] != 0) {
			ll res = b[i] - ((a[i] + plus) % b[i]);
			plus += res;
		}
	}
	cout << plus << endl;
	return 0;
}


Measured memory_bytes: 4784
#include <iostream>
using namespace std;
typedef long long ll;
const ll inf = 1LL << 60;

int n,W;
ll dp[110][100010] = {0};
ll w[110];
ll v[110];


int main(){
    cin >> n >> W;

    for(int i = 0; i < n; i++){
        cin >> w[i] >> v[i];
    }

    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j <= W; j++){
            if(j < w[i]) dp[i][j] = dp[i+1][j];
            else{
                dp[i][j] = max(dp[i+1][j],dp[i+1][j-w[i]] + v[i]);
            }
        }
    }
    
    cout << dp[0][W] << endl;

    return 0;
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=100005;
const LL K=1e18;
int n;
LL ans,a[maxn];
bool sol;
LL Mul(LL A,LL B)
{
	if (!sol) return 0;
	LL res=0;
	while (B)
	{
		if (B&1) res+=A;
		if (A>K || res>K) { sol=false; return 0; }
		A+=A;
		B>>=1;
	}
	return res;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	if (!a[1]) puts("0"); else
	{
		ans=a[1];
		sol=true;
		for (int i=2;i<=n;i++) ans=Mul(ans,a[i]);
		if (sol) printf("%lld\n",ans); else puts("-1");
	}
	return 0;
}


Measured memory_bytes: 4556
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int fc(int i){
  int co = 0;
  int j = i;
  while(j != 0){
    if(j % 2 == 1) co++;
    j /= 2;
  }
  int nx = i % co;
  if(nx == 0) return 1;
  return 1 + fc(nx);
}

int st(const string &x, int &co, int index){
  int n = x.size();
  co = 0;
  static vector<int> xtb(n, -1), xtp(n, -1), xtm(n, -1);
  if(xtp.at(index) != -1 || xtm.at(index) != -1){
    if(xtp.at(index) != -1) return xtp.at(index);
    return xtm.at(index);
  }
  vector<int> powerp(n), powerm(n);
  rep(i, n){
    if(x.at(i) == '1') co++;
  }
  int nowm = 0, nowp = 0;
  rrep(i, n){
    if(i == n-1){
      powerm.at(i) = powerp.at(i) = 1;
    }else{
      if(co > 1) powerm.at(i) = ((ll)powerm.at(i+1)*2) % (co-1);
      powerp.at(i) = ((ll)powerp.at(i+1)*2) % (co+1);
    }
  }
  rep(i, n){
    nowp *= 2;
    nowp += x.at(i) - '0';
    nowp %= co+1;
    if(co > 1){
      nowm *= 2;
      nowm += x.at(i) - '0';
      nowm %= co-1;
    }
  }
  rep(i, n){
    if(x.at(i) == '0'){
      int add = nowp;
      add += powerp.at(i);
      add %= (co+1);
      xtp.at(i) = add;
    }else{
      if(co <= 1) xtm.at(i) = -2;
      else{
        int add = nowm;
        add -= powerm.at(i);
        while(add < 0) add += (co-1);
        add %= (co-1);
        xtm.at(i) = add;
      }
    }
  }
  return -1;
}

int main(){
  int n;
  cin >> n;
  string x;
  cin >> x;
  int co;
  st(x, co, 0);
  rep(i, n){
    int r = st(x, co, i);
    if(r == 0){
      cout << 1 << endl;
      continue;
    }
    if(r == -2){
      cout << 0 << endl;
      continue;
    }
    int ans = 1 + fc(r);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7616
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    ll n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    s = "#" + s + "#";

    reps(i,a,c){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    reps(i,b,d){
        if(s[i] == '#' && s[i+1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }

    if(c < d){
        cout << "Yes" << endl;
        return 0;
    }else{
        reps(i,b,d+1){
            if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3916
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int n;cin>>n;
    vector<string> s(n);
    int t[n];
    for(int i=0;i<n;i++) cin>>s[i]>>t[i];
    string x;cin>>x;
    int ans=0;
    bool flag=false;
    for(int i=0;i<n;i++){
        if(s[i]==x){
            flag=true;
            continue;
        }
        if(flag) ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int x[30], y[30], r[30], c[30], n, ans;
bool memo[1<<24];
// d[i][j] i?????????j????????£?????????1
bool d[30][30];
void dfs(ll m) {
  if(memo[m]) return;
  //cout << bitset<24>(m) << endl;
  //???????????£?????????????????°???????????¨?????°??????
  VI cnt[6];
  REP(i, n) {
    //i????????¨??????????????£??????continue
    if(m>>i&1) continue;
    bool flag = true;
    REP(j, n) {
      //j????????¨??????????????£??????continue
      if(m>>j&1) continue;
      if(d[i][j]) flag = false;
    }
    if(flag) cnt[c[i]].PB(i);
  }

  bool g = false;
  FOR(i, 1, 5) if(cnt[i].size()>=2) g = true;
  //????????£????????????
  if(!g) {
    int sum=0;
    REP(i, n) {
      if(m>>i&1) sum++;
    }
    ans = max(ans, sum);
    memo[m] = true;
    return;
  }

  FOR(i, 1, 5) {
    //cout << "i:" << cnt[i].size() << endl;
    if(cnt[i].size()<=1) continue;
    REP(j, cnt[i].size()) REP(k, j) {
      //cout << j << ":" << k << endl;
      ll tmp = m;
      tmp |= 1<<cnt[i][j];
      tmp |= 1<<cnt[i][k];
      dfs(tmp);
    }
  }
  memo[m] = true;
  return;
}

signed main(void)
{
  while(true) {
    cin >> n;
    if(!n) break;
    REP(i, 30) REP(j, 30) d[i][j] = 0;
    bool h = true;
    REP(i, n) {
      cin >> x[i] >> y[i] >> r[i] >> c[i];
      for(int j=i-1; j>=0; --j) {
        // ??????i??¨??????j???????????£??????????????????i???????????????j????????¨????????????
        double dist = sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j])), rr = r[i] + r[j];
        //cout << dist << " " << rr << endl;
        if(dist < rr) d[i][j] = true, h = false;
      }
    }
    /*REP(i, n) {
      REP(j, n) {
        cout << d[i][j] << " ";
      }
      cout << endl;
    }*/
    ans = 0;
    memset(memo,false,sizeof(memo));
    dfs(0);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 19492
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<set>

using namespace std;

int main(){
  int  n;
  cin >>n;
  int a[3];
  cin >>a[0]>>a[1]>>a[2];
  int l[10];
  for(int i=0 ; i<n; i++ )
  cin >>l[i];

  int res= 1<<20;
  int bit[3];

  for(bit[0]=1;bit[0]<1<<n;bit[0]++){
    for(bit[1]=1;bit[1] < 1<<n; bit[1]++){
      if(bit[0] & bit[1]) continue;

      for(bit[2]=1;bit[2]<  1<<n;bit[2]++){

        if(bit[2] & bit[0]) continue;
        if(bit[2] & bit[1]) continue;

        int sum[3]={0};
        int num[3]={0};

        for(int i=0; i<n ; i++){
          for(int j=0; j<3 ; j++){
            if(bit[j] & 1<<i){
              sum[j]+=l[i];
              num[j]++;
            }
          }
        }

        int score=0;

        for(int i=0; i<3; i++){
          score +=abs(sum[i]-a[i]);
          score+=(num[i]-1)*10;
        }
        res=min(res,score);
      }
    }
  }

  cout<<res<<endl;







  }


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int w,b,a;
    cin>>w>>a>>b;
    if(b<a)
    swap(a,b);
    int x=b-(a+w);
    if(x<0)cout<<0<<endl;
    else cout<<x<<endl;
    return 0;
}


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

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

    int n, m, c;
    cin >> n >> m >> c;
    vector<int> B(m);
    for(int i = 0; i < m; i++){
        cin >> B[i];
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        int t = 0;
        for(int j = 0; j < m; j++){
            int a;
            cin >> a;
            t += B[j] * a;
        }
        if(t + c > 0) ans++;
    }
    cout << ans << 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();
    String[] abc = line.split(" ");
    int a = Integer.parseInt(abc[0]);
    int b = Integer.parseInt(abc[1]);
    int c = Integer.parseInt(abc[2]);
    int i = a;
    int count = 0;
    while (i <= b) {
      if(c % i == 0) {
        count++;
      }
      i++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 26344
#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	
	int f[50];
	
	f[0]=f[1]=1;
	
	int i;
	for(i=2;i<=n;i++)
	{
		f[i]=f[i-1]+f[i-2];
	}
	
	printf("%d\n",f[n]);
	
	return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<limits>
#include <bitset>      


#define LL long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define INF numeric_limits<int>::max()



using namespace std;


LL dp[102][100005];



int main(){

    int n, w;
    cin >> n >> w;

    int e[n+1], v[n+1];

    memset(dp, INF, sizeof dp);


    for(int i = 1; i <= n; i++){
        cin >> e[i] >> v[i];
      }

    
     for(int i = 0; i<= n; i++){
        for(int j = 0; j <= 100005; j++){
            dp[i][j] = INF;
        }
    }
    

    for(int i = 1; i <= n; i++){
        dp[i][v[i]] = e[i];
        for(int k = 1; k <= 100005; k++){
             dp[i][k] = min(dp[i][k], dp[i-1][k]);
             if(k >= v[i])
                dp[i][k] = min(dp[i][k], dp[i - 1][k - v[i]] + e[i]);
            }
        } 
    


    int ans = 0;

    for(int i = 100005; i >= 1 ; i--){
          if(dp[n][i] <= w){
                cout  << i;
                return 0;
            }
               
        }
    


    //cout << ans;


    return 0;
}






Measured memory_bytes: 80000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var N int
	fmt.Scan(&N)

	sum := 0.0
	for i := 0; i < N; i++ {
		str, _ := reader.ReadString('\n')
		str = strings.TrimSuffix(str, "\n")
		chars := strings.Split(str, " ")

		amount, _ := strconv.ParseFloat(chars[0], 32)
		currency := chars[1]

		if currency == "JPY" {
			sum += amount
		} else {
			sum += amount * 380000
		}

	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (c-a-b<=0) printf("No\n");
	else
	{
		long long v=(c-a-b);
		v=v*v;
		if (4LL*a*b<v) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define speed ios::sync_with_stdio(0); cin.tie(0);
int const N = 1e5+1;
vector<int> v;
int main(){
	speed 
	int x , time;
	cin >> x >> time;
	f(i,0,x){
		int c , t;
		cin >> c >> t;
		if (t <= time){
			v.push_back(c);
		} 
	}
	sort(v.begin(), v.end());
	if(v.size() == 0)cout << "TLE" << endl; else cout << v[0] << endl;
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
ll n;
cin>>n;
ll a[n+1];
ll fin[n+1];
rep(i, n){
	cin>>a[i];
	fin[i]=0;
}

ll x[n*n+1];
rep(i, n*n){
	x[i]=-1;
}

queue<ll> que{};
rep(i,n){
	x[a[i]]=i;
}

for(int i=n*n;i>=1;i--){
if(x[i]==-1)continue;
	ll v=x[i];
	rep(j,n-v){
		que.push(v);
	}
	if(n-v)
	que.push(v+(ll)1000000);
}



for(int i=n*n;i>=1;i--)
{
if(x[i]!=-1){
	ll v=x[i];
	rep(j,v-1){
		que.push(v);
	}
	fin[v]=1;
	continue;
}
if(que.size()==0){
	cout<<"No"<<endl;
	return 0;
}

ll t=que.front();

x[i]=t;
que.pop();

if(que.size()){
if(que.front()>=1000000){
ll va=que.front();
va-=1000000;
que.pop();
if(fin[va]){
	cout<<"No"<<endl;
	return 0;
}

}
}

}

cout<<"Yes"<<endl;
rep(i, n*n){
	if(i<n*n)cout<<x[i]<<" ";
else cout<<x[i]<<endl;
	}


return 0;
}




Measured memory_bytes: 4736
def f(d,x,y):n=int("9"*x+"0"*y);return d==0 if x<1 else sum(f(d+i*n,x-2,y+1)*(10-abs(i)-(y<1))for i in range(-9,10)if abs(d+i*n)<n)
D=input();print sum(f(D,i,0)*(10-i%2*9)for i in range(1,21))

Measured memory_bytes: 2568
n=int(input())
a=0
c=0
x=0
y=1
for i in range(1,n+1):
  c=0
  a=i
  while True:
    if a%2==0:
      a/=2
      c+=1
    else:
      if x<c:
        x=c
        y=i
      break
print(y)

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

const int M = 100005;

int n, m, a, b;
long long ans = 0;
vector<int> ve[M];
priority_queue<int> pq;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    while (n--)
    {
        cin >> a >> b;
        ve[a].push_back(b);
    }
    for (int i = 1; i <= m; i++)
    {
        for (int &v : ve[i])
            pq.push(v);
        if (!pq.empty())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans;
}


Measured memory_bytes: 5632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())

int main(void){
  string a,b;
  while(cin>>a>>b){
    if(a=="0")break;
    int hit=0;
    int blow=0;
    REP(i,4){
      REP(j,4){
        if(a[i]==b[j]){
          if(i==j)hit++;
          else blow++;
        }
      }
    }
    printf("%d %d\n",hit,blow);
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
using namespace std;

int main(){
	
	int N = 0;
	int K = 0;
	
	scanf("%d%d",&N,&K);
	
	int num = 1;
	
	for(int i=0;i<N;i++){
		if(num*2 < num+K){
			num = num*2;
		}else{
			num = num+K;
		}
	}
	
	printf("%d",num);
}


Measured memory_bytes: 128
N, K = map(int, input().split())

jou_list = [0 for _ in range(N)]
n_list = [i+1 for i in range(N)]

for i in range(N):
    m = 0
    ii = n_list[i]
    while ii < K:
        m += 1
        ii *= 2
    jou_list[i] = m

ans = 0
for i in range(N):
    ans += 1/(2**jou_list[i])

ans = ans/N

print(ans)

Measured memory_bytes: 7832
Imports System                      ' for System.Console.WriteLine
Imports System.Collections.Generic  ' for List

Module Module1

    Sub Main()

        Dim tmp As String() = Split(Console.ReadLine(), " ")
        Dim N As Integer = CInt(tmp(0))
        Dim K As Integer = CInt(tmp(1))
        Dim tmp2 As String() = Split(Console.ReadLine(), " ")
        Dim monster As New List(Of Integer)

        For i As Integer = 0 To N - 1
            monster.Add(CInt(tmp2(i)))
        Next

        monster.Sort()

        Dim cnt As Long = 0

        For Each m As Integer In monster
            If N - K > 0 Then
                cnt += m
            End If
            N -= 1
        Next

        Console.WriteLine(cnt)

    End Sub

End Module


Measured memory_bytes: 42628
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
int main () { 
	int x,y,z;
	y = 0;
	z = 0;
	string s;
	cin >> x;
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		if(y > z){
			z = y;
		}if(s[i] == 'I'){
			y = y + 1;
		}else if (s[i] == 'D'){
			y = y - 1;
		}
	}
	
		if (y > z){
			z = y;
		}
	cout << z << endl;	
} 			


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

struct PrimeNumbers {
    
    vector<bool> sieve;
    vector<long long> prime;
    
    PrimeNumbers (int n) : sieve(n+1,true) {
        sieve[0] = sieve[1] = false;
        for (long long i = 2; i < sieve.size(); i++) {
            if (sieve[i]) {
                prime.push_back(i);
                for (long long j = i * i; j < sieve.size(); j += i) {
                    sieve[j] = false;
                }
            }
        }
    }
    
    bool isPrime(long long n) {
        return sieve[n];
    }
    
    int size(void) {
        return (int) prime.size();
    }
    
    long long  operator [] (int n) {
        return  prime[n];
    }
    
};
/*
 O(N loglogN) ←早い!
 usage:
 PrimeNumbers prime(N); // Nまでの素数を列挙
 prime.size();  //素数の数
 prime[i]; //i番目の素数
 prime.isPrime(A); // bool, Aの素数判別
 */

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

    vector<bool> bad(1123456);
    
    ll N ; cin >> N ;

    vector<ll> A(N);

    map<ll, ll> cnt;
    rep(i, N){
        cin >> A[i];
        cnt[A[i]] ++;
    }
    
    rmsame(A);
    vector<ll> candi;
    
    rep(i, A.size()){
        if(!bad[A[i]]){
            candi.pb(A[i]);
            
            ll num = 1;
            while(A[i] * num <= 1000005){
                bad[A[i] * num] = true;
                num ++;
            }
        }
    }
    
    ll ans = candi.size();
    
    
    rep(i, candi.size()){
        if(cnt[candi[i]] >= 2) ans --;
    }
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int al = 0;
	int bo = 0;

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

	sort(a,a+n,greater<int>());

	for(int i=0; i<n; i++){
		if(i%2 == 0) al += a[i];
		else bo += a[i];		
	}

	cout << al-bo << endl;

}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  ll n, ans=0;
  cin >> n;
  vector<int> a(n+1), b(n);
  for(int i = 0; i < n+1; i++) cin >> a.at(i);
  for(int i = 0; i < n; i++) cin >> b.at(i);
  for(int i = 0; i < n; i++) {
    if(a.at(i) + a.at(i+1) <= b.at(i)) {
      ans += a.at(i) + a.at(i+1);
      a.at(i) = 0;
      a.at(i+1) = 0;
    }
    else if(a.at(i) <= b.at(i)) {
      ans += b.at(i);
      a.at(i+1) -= (b.at(i) - a.at(i));
      a.at(i) = 0;
    }
    else{
      ans += b.at(i);
      a.at(i) -= b.at(i);
    }
  }    
  cout << ans;
}
  

Measured memory_bytes: 1024
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_D&lang=jp
  * String - Transformation
  */
object Main {

  object Int {
    def unapply(v: String): Option[Int] = {
      Some(v.toInt)
    }
  }

  def main(args: Array[String]): Unit = {
    val initialStr = io.StdIn.readLine()
    val q = io.StdIn.readInt()
    val printPattern = """print (\d+) (\d+)""".r
    val reversePattern = """reverse (\d+) (\d+)""".r
    val replacePattern = """replace (\d+) (\d+) (\w+)""".r
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(q)
      .foldLeft(initialStr) { (str, command) =>
        command match {
          case printPattern(Int(a), Int(b)) =>
            println(str.slice(a, b + 1))
            str
          case reversePattern(Int(a), Int(b)) =>
            str.take(a) + str.slice(a, b + 1).reverse + str.drop(b + 1)
          case replacePattern(Int(a), Int(b), p) =>
            str.patch(a, p, b - a + 1)
        }
      }
  }
}

Measured memory_bytes: 45112
#include<stdio.h>

int main(void){
	char str[1050];
	int i;
	scanf("%[^\n]",str);
	while(str[i]!='\0'){
		if(str[i]=='a'&&str[i+1]=='p'&&str[i+2]=='p'&&str[i+3]=='l'&&str[i+4]=='e'){
			printf("peach");i=i+5;
		}
		else if(str[i]=='p'&&str[i+1]=='e'&&str[i+2]=='a'&&str[i+3]=='c'&&str[i+4]=='h'){
			printf("apple");i=i+5;
		}
		else {printf("%c",str[i++]);}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
#define endl '\n'
using namespace std;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 112345;
int main() {
    int n, k;
    scanf("%d", &n);
    int last = 0, x, ans = 0;
    while (n--) {
        scanf("%d", &x);
        if (x >= last) ++ans;
        last = max(last, x);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.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 ll long long

int main()
{
    int r,g;

    cin >> r >> g;

    cout << 2*g - r << endl;
}

Measured memory_bytes: 256