akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int hierarchy(int num);

int main(void) {
    int num, count, i, j, k;
    
    while(scanf("%d", &num) != EOF) {
        int ans = 0;
        switch(hierarchy(num)) {
            case 1:
                j = 6;
                k = 4;
                count = 0;
                for(i = 4; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 1) j += k++;
                    i += j;
                }
                break;
            case 2:
                j = 66;
                k = 1;
                count = 9;
                for(i = 282; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 10) {
                        j += k;
                        k -= 3;
                    }
                    i += j;
                }
                break;
            case 3:
                j = -41;
                k = -11;
                count = 19;
                for(i = 633; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 20) {
                        j += k;
                        k += 3;
                    }
                    i += j;
                }
                break;
            case 4:
                j = -28;
                k = 7;
                count = 29;
                for(i = 84; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 30) j += k--;
                    i += j;
                }
                break;
            default : break;
        }
        cout << ans << endl;
    }
    
    return(0);
}

int hierarchy(int num) {
    if(num >= 0 && num <= 9)
        return(1);
    else if(num >= 10 && num <= 19)
        return(2);
    else if(num >= 20 && num <= 29)
        return(3);
    else if(num >= 30 && num <= 36)
        return(4);
    else
        return(5);
}

Measured memory_bytes: 1208
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
 
auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;
 
int32_t N;
uint64_t M;
uint64_t A[100000];
 
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);
 
	in >> N >> M;
	uint64_t res = 0;
	for (int32_t i = 0; i < N; i++)
	{
		in >> A[i];
		A[i] %= M;
	}
 
	for (int32_t i = 0; i < N; i++)
	{
		A[i + 1] += A[i];
		A[i + 1] %= M;
	}
	std::unordered_map<int32_t, int32_t> num;
	for (int32_t i = 0; i < N; i++)
	{
		++num[A[i]];
	}
	++num[0];
 
 
	for (auto& c : num)
	{
		int64_t len = c.second;
		res += len * (len - 1) / 2;
	}
	out << res << endl;
 
	return 0;
}
#endif

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  if(A >= K){
  cout << A - K << ' ' << B << endl;
  }
  else if(A + B >= K){
    cout << 0 << ' ' << A + B - K << endl;
    }
  else{
    cout << 0 << ' ' << 0 << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            WriteLine(calc() ? "Yes" : "No");
        }

        static bool calc()
        {
            var S = ReadLine();
            var c = S.GroupBy(s => s);
            if (c.Count() != 2) return false;
            return !c.Any(s => s.Count() != 2);
        }
    }
}


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

int main()
{
        int N, K;
        string S;
        cin >> N;
        cin >> S;
        cin >> K;

        char C = S[K-1];

        for(int i = 0; i < N; ++i)
        {
                if(S[i] != C) S[i] = '*';
        }

        cout << S << endl;
        return 0;
}

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

using str = string;
using ss = stringstream;

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

    int h,w;cin>>h>>w;

    ss makeblank;
    for(int i=0;i<w;i++)makeblank<<'.';
    str blank=makeblank.str();

    vector<str> m;

    for(int i=0;i<h;i++)
    {
        str s;cin>>s;

        if(s!=blank)m.push_back(s);
    }

    vector<ss> mm(m.size());

    for(int i=0;i<w;i++)
    {
        bool c=true;
        for(auto im:m)if(im[i]=='#')c=false;
        if(!c)for(int j=0;j<m.size();j++)mm[j]<<m[j][i];
    }

    m.clear();

    for(int i=0;i<mm.size();i++)m.push_back(mm[i].str());

    for(auto im:m)cout<<im<<"\n";

    return 0;
}


Measured memory_bytes: 3756
#include <stdio.h>

int main(void){
	int a , b , n , sum;
	while(scanf("%d %d %d" , &a , &b , &n)!=EOF){
		a %= b;
		sum = 0;
		for(;n;n--){  
			a *= 10;  
			sum += a / b;  
			a %= b;  
		}
		printf("%d\n" , sum);
	}
	return 0;
}

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

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

    int cou = 0;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'R'){
            cou++;
        }
    }

    if(cou == 2){
        if(s == "RSR"){
            cou = 1;
        }
    }

    cout << cou << endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC023B {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string[,] map = new string[N, N];
            for (int i = 0; i < N; i++) {
                string str = Console.ReadLine();
                for (int j = 0; j < N; j++) {
                    map[i, j] = str.Substring(j, 1);
                }
            }
            int ans = 0;
            for (int i = 0; i < N; i++) {
                bool flag = true;
                for (int j = 0; j < N; j++) {
                    int num = i + j;
                    if (i + j >= N) {
                        num -= N;
                    }
                    for (int k = 0; k < N; k++) {
                        if (k > j) {
                            if (map[num, k] != map[(k + i) % N, j]) {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag) {
                    ans += N;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 15712
#include<stdio.h>

int main() {
	int a, b, c;
	int t;
	scanf("%d%d%d",&a,&b,&c);
	if (a > b) {
		t = a;
		a = b;
		b = t;
	}
	if (a > c) {
		t = a;
		a = c;
		c = t;
	}
	if (b > c) {
		t = b;
		b = c;
		c = t;
	}

	printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 1800
N = gets.to_i
c = [0,0,0,0]
N.times{|i|
  s = gets.chomp
  if s == "AC"
    c[0] = c[0] + 1
  elsif s == "WA"
    c[1] = c[1] + 1
  elsif s == "TLE"
    c[2] = c[2] + 1
  elsif s == "RE"
    c[3] = c[3] + 1
  end
}

puts "AC x " + c[0].to_s
puts "WA x " + c[1].to_s
puts "TLE x " + c[2].to_s
puts "RE x " + c[3].to_s

Measured memory_bytes: 14332
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    if(n<1200)
        printf("ABC\n");
    else
    if(n<2800)
        printf("ARC\n");
    else
        printf("AGC\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
using namespace std;
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define N 1005
lld grp[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
int main()
{
	
	lld n,m;
	cin>>n>>m;
	cout<<((grp[n]==grp[m])?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
//  -- ILSH -- //
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define viii vector < vii >
#define vlll vector < vll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=200000+6;
vii tree[N];
bool bo;
int u,v;
int val;
int arr[N];
int root;
int ma;
int odd;
void dfs( int pos, int par, int depth)
{
    if (pos==u){
        bo=false;
        val=depth;
        odd=depth%2;
    }
    for ( int i=0;i<tree[pos].sz();i++) 
        if ( bo&&tree[pos][i]!=par)
            dfs( tree[pos][i],pos, depth+1);
    if ( !bo&&(val+1)/2==depth)
        arr[pos]=1;
    if ( !bo&&(val+1)/2+1==depth)
        root=pos;
}
void dfs2(int pos, int depth)
{
    arr[pos]=1;
    for ( int i=0;i<tree[pos].sz();i++)
        if ( arr[tree[pos][i]]==0)
            dfs2(tree[pos][i],depth+1);
    ma=std::max( depth,ma);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    cin>>u>>v;
    for ( int i=0;i<n-1;i++) {
        int aa,bb;
        cin>>aa>>bb;
        tree[aa].pb( bb);
        tree[bb].pb( aa);
    }
    bo=true;
    if ( u==v){
        cout<<0<<'\n';
        return 0;
    }
    memset( arr,0,sizeof ( arr));
    odd=0;
    dfs(v,-1,1);
    ma=0;
    dfs2( root,0);
    cout<<val/2-1+odd+ma;
    cout<<'\n';
}

Measured memory_bytes: 14464
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
r,s,p = inm()
t = input().strip()
fail = [False]*n
acc = 0
for i in range(n):
    ddprint("i {}".format(i))
    if t[i]=='r':
        if not (i>=k and t[i-k]=='r') or fail[i-k]:
            acc += p
            ddprint("add {}".format(p))
        else:
            fail[i] = True
    elif t[i]=='s':
        if not (i>=k and t[i-k]=='s') or fail[i-k]:
            acc += r
            ddprint("add {}".format(r))
        else:
            fail[i] = True
    else:
        if not (i>=k and t[i-k]=='p') or fail[i-k]:
            acc += s
            ddprint("add {}".format(s))
        else:
            fail[i] = True
print(acc)


Measured memory_bytes: 45660
#include<stdio.h>


int main(void){
 int flag = 1;
int i,j,N,v,a[10000]; 
int c =0;

    scanf("%d", &N);
     for ( i = 0; i < N; i++ ){ 
scanf("%d", &a[i]);
}
 
 while ( flag ) {
        flag = 0;
        for ( j = N - 1; j >0; j-- ) {
            if ( a[j] < a[j - 1] ) {
                v = a[j];
                a[j] = a[j - 1];
                a[j - 1] = v;
                
                flag = 1;
c++;
            }
        }
    }

   
    for ( i = 0; i < N; i++ ) {
if(i>0){
printf(" ");
}

        printf("%d", a[i]);
}
printf("\n");
  
    

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

    return 0;
}
 

Measured memory_bytes: 1812
import heapq
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
ticket_num = m
heapq.heapify(a)

if n > 1:
    for i in range(m):
        MAX = heapq.heappop(a)
        MAX = math.ceil(MAX / 2)
        heapq.heappush(a,MAX)
        
else:
    MAX = heapq.heappop(a)
    MAX = math.ceil(MAX / (2**m))
    heapq.heappush(a,MAX)

print(sum(a)*(-1))

Measured memory_bytes: 20176
def main():
    a , b , c = map(str,(input().split(' ')))
    result = 3
    if a == b:
        result = result - 1
    if a == c:
        result = result -1
    if b == c:
        result = result - 1

    if result == 0:
        print("1")
    else:
        print(result)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  string t="ATGC";
  int ans=0,sum=0;
  rep(i,s.size()){
    bool is=false;
    rep(j,4){
      if(s.at(i)==t.at(j)){
        is=true;
      }
    }
    if(is){
      sum++;
    }else{
      sum=0;
    }
    ans=max(ans,sum);
  }
  cout << ans;
}
      
    
      

Measured memory_bytes: 3624
#include <iostream>
#include<cmath>
#include<vector>
#include<map>
#include<sstream>
#include<deque>
#include<iomanip>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#include<stack>
#include<unordered_set>
#include<cstring>
#include<list>
using namespace std;
//	int x=atoi(s.c_str()); s_to_in;
int dx[] = { -1,0,0,1 };
int dy[] = { 0,1,-1 ,0 };
#define endl '\n'
long long mo = 1e9;
const long double P = 3.141592653589793238L;
void trust_yourself()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
long long gcd(long long x, long long y)
{
	if (x == 0)
		return y;
	return gcd(y%x, x);
}
long long fast_power(long long x, long long y, long long mo)
{
	long long p = 1;
	while (y)
	{
		if (y & 1)
			p = (p*x) % mo;
		y = (y >> 1); //y/=2
		x = (x*x) % mo;
	}

	return p;
}


long long com(long long n, long long r) {
	long long p = 1, p1 = 1;
	for (long long i = r + 1; i <= n; i++) {
		p = p * i;
		p /= p1;
		p1++;
	}
	return p;
}


int main()
{
	trust_yourself();
	//freopen("hussien.in", "r", stdin);
	long long a[3], k, p = 0, s = 0;
	cin >> a[0] >> a[1] >> a[2] >> k;
	if (a[0] >= k) {
		s += k;
		k = 0;
	}
	else {
		s += a[0];
		k = k - a[0];
		if (a[1] < k) {
			k = k - a[1];
			if (a[2] >= k)
				s = s - k;
		}
		else
			k = 0;
	}
	cout << s;
	return 0;
}
	

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>


int main(void){
    int a;
    int b;
    scanf("%d %d", &a, &b);
    
    int num[3]={a+b,a-b, a*b};
    int max = num[0];
    int i;

    for(i=0;i<3;i++){
        if(num[i]>=max){
            max=num[i];
        }
    }

    printf("%d\n",max);
    return 0;
}

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

inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main() {
    int n; cin >> n;
    vector<long long> t(n);
    for (long long &ti: t) cin >> ti;
    long long ans = 1;
    for (long long ti: t) ans = lcm(ans, ti);
    cout << ans << endl;
    return 0;
}

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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

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

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

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

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

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

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

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

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


int main() {
	ll N, D, A;
	cin >> N >> D >> A;
	
	vector<pair<ll, ll>> B(N + 1);
	repn(i, N) cin >> B[i].first >> B[i].second;

	sort(++B.begin(), B.end());

	vector<ll> X(N + 1), H(N + 1);
	repn(i, N) {
		X[i] = B[i].first;
		H[i] = B[i].second;
	}

	vector<ll> F(N + 1);
	repn(i, N) {
		auto itr = upper_bound(++X.begin(), X.end(), X[i] + 2 * D);
		F[i] = distance(X.begin(), itr);
	}

	
	vector<ll> bf(N + 2, 0);
	ll  bomb = 0;
	ll ans = 0;

	repn(i, N) {
		bomb -= bf[i];

		ll T = (H[i] - 1) / A + 1;

		if (bomb < T) {
			ans += T - bomb;
			bf[F[i]] += T - bomb;
			bomb = T;
		}
	}
	cout << ans << endl;

	
	
	system("PAUSE");
}


Measured memory_bytes: 9848
#include <iostream>
#include <algorithm>
using namespace std;
int n,a[2100000],ans;
int main(void)
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        a[x]++;
    }
    for(int i=1;i<=1000000;i++)
    {
        if(a[i]==1)ans++;
        if(a[i]>0)
        {
            for(int j=i;j<=1000000;j+=i)
            {
                a[j]=0;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
#define all(v) v.begin(), v.end()
 
int main(){
  ll N,M,R,ans=1000000000;
  cin >> N >> M >> R;
  vector<ll> r(R);
  rep(i,R){
    cin >> r.at(i);
    r.at(i)--;
  }
  sort(all(r));
  vector<vector<ll>> d(N,vector<ll>(N,100000000));
  rep(i,N) d.at(i).at(i)=0;
  rep(i,M){
    ll a,b,c;
    cin >> a >> b >> c;
    d.at(a-1).at(b-1)=c;
    d.at(b-1).at(a-1)=c;
  }
  rep(k,N)rep(i,N)rep(j,N){
    d.at(i).at(j)=min(d.at(i).at(j),d.at(i).at(k)+d.at(k).at(j));
  }
  do{
    ll t=0;
    rep(i,R-1){
      t+=d.at(r.at(i)).at(r.at(i+1));
    }
    ans=min(ans,t);
  } while (next_permutation(all(r)));
  cout << ans << endl;
    
       
    
  
 
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int cnt = 0;
            for(int i = 1; i < 10; i++)
            {
                for(int j = 1; j < 10; j++)
                {
                    if(i * j == N)
                    {
                        cnt++;
                    }
                }
            }
            if(cnt > 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27116
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
            String[] s =  sc.next().split(",");
            double[] x = new double[6];
            double[] y = new double[6];
			for(int i=0;i<6;i++){
				if(i<4){
					x[i] = Double.valueOf(s[2*i]);
					y[i] = Double.valueOf(s[2*i+1]);
				}else{
					x[i] = x[i-4];
					y[i] = y[i-4];
				}
			}
			
			boolean flag = true;
            double x1, y1, x2, y2;
            double res = 0;
            for(int i=0;i<4;i++){
            	x1 = x[i+1]-x[i];
            	y1 = y[i+1]-y[i];
            	x2 = x[i+2]-x[i];
            	y2 = y[i+2]-y[i];
            	if(i==0){
            		res = x1*y2-x2*y1;
            	}else if(res*(x1*y2-x2*y1)<0){
            		flag = false;
            		break;
            	}
            }
			
            if(flag==true) System.out.println("YES");
            else System.out.println("NO");
		}
	}	
}

Measured memory_bytes: 17160
#include<stdio.h>


int main(void){
  int i,v,W,H;

  while(1){
    scanf("%d %d",&W,&H);

    if(W==0 && H==0){
      break;
    }else{
      for(i=1;i<=W;i++){
	for(v=1;v<=H;v++){
	  if(i==1 || v==1 || i==W || v==H){
	    printf("#");
	  }else{
	    printf(".");
	  }
	}
	printf("\n");
      }
      printf("\n");
    }
  }
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a;
    int ma = 0, mi = 101;
    for (int i = 0; i < 3; i++){cin >> a; ma = max(ma, a); mi = min(mi, a);}
    cout << ma-mi << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
int main() {
    int i, min = INT_MAX, tmp;
    char S[10];
    if (scanf("%s", S) == -1) return -1;
    for (i = 0; i < strlen(S)-2; i++) {
        tmp = abs(S[i] * 100 + S[i+1] * 10 + S[i+2] - '0' * 111 - 753);
        if (tmp < min) min = tmp;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h> 
#include<stdlib.h>



int main ()  {
	char s[50];
	int n ;
	scanf("%s",s) ;
	n=atoi(s) ;
	
	if (n%100 <=12 && n/100 <=12 && n%100 >0 && n/100 >0) {
		printf("AMBIGUOUS") ;
	}
	else if (n%100 <=12 && n%100 >0){
		printf("YYMM") ;
	}
	else if (n/100 <=12 && n/100 >0) {
		printf("MMYY") ;
	}
	else 
	printf("NA") ;
	
	return(0) ;
}

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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main() {
  string a,b;
  cin >> a;
  int ans = 7;
  vector<string> vec = {"MON","TUE","WED","THU","FRI","SAT"};
  REP(i,6)if(vec[i] == a) ans = 6-i;
  cout << ans << endl;
}

Measured memory_bytes: 3564
import java.util.Scanner;
import java.util.Arrays;
 
class Main {
  public static void main(String args[]) {
 
    Scanner scan = new Scanner(System.in);
    int h = scan.nextInt();
    int p = scan.nextInt();
 
    int count = 0;
 
    while(h > 0){
      count++;
      h = h - p;
    }
    System.out.println(count);
  }
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X;

    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        X.push_back(tmp);
    }

    // O(1 * N) -> 200 * N -> 200000 -> 2 * 10^5
    int64_t minHP = 2000000;
    for (int p = 1; p <= 200; p++) {
        int64_t sumHP = 0;
        for (int j = 0; j < N; j++) {
            int64_t tmp = pow(X.at(j) - p, 2);
            sumHP += tmp;
        }
        minHP = min(minHP, sumHP);
    }

    cout << minHP << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N):
    B[i] = A[i] - i
B.sort()

res = 0
x = B[N//2]

for i in range(N):
    res += abs(x - B[i])

print(res)

Measured memory_bytes: 26836
#include<stdio.h>
long long MAX(long long a,long long b){return a<b?b:a;}
int main(){
  long long max=0,mp=0,d[4][100010]={};
  int n,i;
  char s[100010];
  scanf("%d %s",&n,s);
  for(i=0;s[i];i++){
    d[0][i+1]=d[0][i];
    d[1][i+1]=d[1][i];
    if(s[i]=='J')d[0][i+1]+=1;
    if(s[i]=='O')d[1][i+1]+=d[0][i];
    if(s[i]=='I')max+=d[1][i];
  }
  for(i=n;i;i--){
    d[2][i-1]=d[2][i];
    d[3][i-1]=d[3][i];
    if(s[i-1]=='I')d[2][i-1]+=1;
    if(s[i-1]=='O')d[3][i-1]+=d[2][i];
  }
  for(i=0;i<=n;i++)mp=MAX(MAX(mp,d[0][i]*d[2][i]),MAX(d[1][i],d[3][i]));
  printf("%lld\n",max+mp);
  return 0;
}

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


double solve(double a){
  double ans=0;
  for(int i=0;i<10;i++){
    ans+=a;
    if(i%2==1){
      a/=3.0;
    }else{ 
      a*=2.0;
    }
  }
  return ans;
}

int main(){
  double a;
  while(cin>>a){
    printf("%.20lf\n",solve(a));
  }
}

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

int main() {
  int k; cin >> k;
  int odd,even;
  odd = k/2;
  even = k - odd;

  cout << odd*even << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
    int n,x;
    while(scanf("%d%d",&n,&x)){
    int a,b,c,cou = 0;
    if(n == 0 && x == 0) break;
     
    for(a = 1; n >= a; a++){
        for(b = 1; n >= b; b++){
            for(c = 1; n >= c; c++){
                if(a != b && a != c && b != c)
                    if(a+b+c == x) cou++;
            }   
        }   
    }
    printf("%d\n", cou/6);
    }
    return 0;
}


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

int main(){
  string S ;
  cin >> S ;
  string T = S ;
  int s = S.size();
  bool a = true; bool b = true ; bool c = true;
  reverse(S.begin(),S.end());

  
  if(S!=T) a = false;
  string s1 = S.substr(0,(s-1)/2);
  string t1 = s1;
  reverse(s1.begin(),s1.end());

  if(s1!=t1) b = false;
  string s2 = S.substr((s+1)/2,s-1);
  string t2 = s2;
  reverse(s2.begin(),s2.end());

  if(s2!=t2) c = false;
  
  if(a&&b&&c) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}





Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $k, $s);

$c = 0;
$min = max(0, $s - $k * 2);
for ($x = $min; $x <= $k; $x++) {
	$s1 = $s - $x;
	if ($s1 < 0) break;
	$c += $s1 - max(0, $s1 - $k) * 2 + 1;
}
echo $c;

Measured memory_bytes: 3832
S=input()
lens=len(S)
half=lens//2
if lens % 2 == 0:
    if S[:half]==S[half:][::-1] and S[:half]==S[half:]:
        print('Yes')
    else:
        print('No')
else:
    if S[:half]==S[half+1:][::-1] and S[:half]==S[half+1:]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
//12 13 26 => 26

int price(int tax, int without_tax)
{
    return without_tax * (100 + tax) / 100;
}

int main()
{
    int x, y, s;
    vector<int> answer;
    while (cin >> x >> y >> s && x != 0)
    {
        int max = 0;
        for (int i = 1; i < s; i++)
        {
            for (int j = 1; j < s - i + 1; j++)
            {
                if (price(x, i) + price(x, j) == s && price(y, i) + price(y, j) > max)
                {
                    //cout << i << " " << j << " " << price(y, i) + price(y, j) << endl;
                    max = price(y, i) + price(y, j);
                }
            }
        }
        answer.push_back(max);
        //cout << max << endl;
    }
    for (int i = 0; i < answer.size(); i++)
    {
        cout << answer.at(i) << endl;
    }
    return 0;
}



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

int main(){
  long long n, a[10000];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cout << *min_element( a, a + n) << " "
       << *max_element( a, a + n) << " "
       << accumulate( a, a + n, 0LL) << endl;
}



Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1<<30;
const ll  longinf = 1LL<<60;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

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




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));
    if (l[n-1] < accumulate(l.begin(), l.begin() + n-1, 0)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int data = Integer.parseInt(br.readLine());
		
		int debt = 100000;
		for(int i=0;i<data;i++) {
			debt = (int)Math.ceil(debt*1.05/1000)*1000;
		}
		
		System.out.println(debt); 
	}
}

Measured memory_bytes: 24136
#include <stdio.h>

int ans[100001];

int min(int a, int b) {
  return a < b ? a : b;
}

void build_table(int a) {
  for (int i = 1; i <= a; i++) {
    ans[i] = 1000000;
    for (int x = 1; x <= i; x *= 9) {
      ans[i] = min(ans[i], ans[i - x] + 1);
    }
    for (int x = 1; x <= i; x *= 6) {
      ans[i] = min(ans[i], ans[i - x] + 1);
    }
  }
}

int main() {
  int a;
  scanf("%d", &a);
  build_table(a);
  printf("%d\n", ans[a]);
  return 0;
}


Measured memory_bytes: 512
/*
 * h.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 50;
const int MAX_W = 50;

const int dxs[6] = {-1, 0, 1, 1, 0, -1};
const int dys[2][6] = {{0, -1, 0, 1, 1, 1}, {-1, -1, -1, 0, 1, 0}};

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef queue<pii> qpii;

/* global variables */

int h, w;
string flds[MAX_H];
bool used[MAX_H][MAX_W];

/* subroutines */

inline bool floating(int x, int y) {
  return
    (y > 0 && flds[y - 1][x] == '.' &&
     (x <= 0 || flds[y + dys[x & 1][0]][x - 1] == '.') &&
     (x >= w - 1 || flds[y + dys[x & 1][2]][x + 1] == '.'));
}

void fall_all() {
  for (int y = 1; y < h; y++) {
    for (int x = 1; x < w; x += 2)
      for (int y0 = y; flds[y0][x] != '.' && floating(x, y0); y0--)
	swap(flds[y0][x], flds[y0 - 1][x]);
    for (int x = 0; x < w; x += 2)
      for (int y0 = y; flds[y0][x] != '.' && floating(x, y0); y0--)
	swap(flds[y0][x], flds[y0 - 1][x]);
  }
}

bool vanish() {
  bool vnsh = false;
  memset(used, false, sizeof(used));

  for (int y0 = 0; y0 < h; y0++)
    for (int x0 = 0; x0 < w; x0++)
      if (flds[y0][x0] != '.' && ! used[y0][x0]) {
	vpii v;
	v.push_back(pii(x0, y0));
	qpii q;
	q.push(pii(x0, y0));
	char ch = flds[y0][x0];
	used[y0][x0] = true;

	while (! q.empty()) {
	  pii u = q.front(); q.pop();
	  int &ux = u.first, &uy = u.second;
	  for (int di = 0; di < 6; di++) {
	    int vx = ux + dxs[di], vy = uy + dys[ux & 1][di];
	    if (vx >= 0 && vx < w && vy >= 0 && vy < h &&
		! used[vy][vx] && flds[vy][vx] == ch) {
	      used[vy][vx] = true;
	      v.push_back(pii(vx, vy));
	      q.push(pii(vx, vy));
	    }
	  }
	}

	if (v.size() >= 3) {
	  for (vpii::iterator vit = v.begin(); vit != v.end(); vit++)
	    flds[vit->second][vit->first] = '.';
	  vnsh = true;
	}
      }

  return vnsh;
}

void do_proc() {
  do {
    fall_all();
  } while (vanish());
}

void print_flds() {
  for (int y = h - 1; y >= 0; y--) cout << flds[y] << endl;
}

/* main */

int main() {
  cin >> h >> w;
  for (int y = h - 1; y >= 0; y--) cin >> flds[y];

  do_proc();
  //print_flds();

  int q;
  cin >> q;
  while (q--) {
    int cx, cy;
    cin >> cx >> cy;
    if (cx <= 0 || cx >= w - 1 || cy <= 0 || cy >= h - 1) continue;

    char ctmp = flds[cy + dys[cx & 1][0]][cx + dxs[0]];
    for (int di = 1; di < 6; di++)
      flds[cy + dys[cx & 1][di - 1]][cx + dxs[di - 1]] =
	flds[cy + dys[cx & 1][di]][cx + dxs[di]];
    flds[cy + dys[cx & 1][5]][cx + dxs[5]] = ctmp;

    do_proc();
  }

  print_flds();
  return 0;
}


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

using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    if(t==1)
      cout<<0<<endl;
  else
    cout<<1<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    s=input()
    if s[2]==s[3] and s[4]==s[5]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n, m, ans = 0;
struct node{ll a, b, num, point;};
vector<node> query;
void dfs(vector<ll> v){
	if(v.size() == n){
		ll cnt = 0;
		for(auto& i: query){
			if(v[i.b] - v[i.a] == i.num) cnt += i.point;
		}
		ans = max(ans, cnt);
		return;
	}
	v.pb(v.back());
	while(v.back() <= m){
		dfs(v);
		v.back()++;
	}
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll q;
    cin >> n >> m >> q;
    ll u, v, c, d;
    for(int i=0;i<q;i++){
    	cin >> u >> v >> c >> d;
    	query.push_back({u-1,v-1, c, d});
    }
    dfs(vector<ll> (1,1));
    cout << ans << endl;
    return 0;
}


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

const double PI=3.14159265358979323846;
int main() {
    double r;
    cin >> r;
    cout << 2*r*PI<<endl;

    return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 100010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

ll as[MAX];

void solve(void){
    int N; ll x;
    cin >> N >> x;
    rep(N, i) {
        scanf("%lld\n", &as[i]);
    }
    ll ans = 0LL;
    rep(N-1, i) {
        if (as[i+1] + as[i] > x) {
            ll dif = as[i+1] + as[i] - x;
            ans += dif;
            as[i+1] = max(as[i+1]-dif, 0LL);
        }
    }
    printf("%lld\n", ans);
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 1024
/**************************************************************
	File name: a.cpp
	Author: huhao
	Email: 826538400@qq.com
	Create time: 2019/8/17 下午8:02:06
**************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=200010,inf=300000;
int f[N][10],n;
char s[N];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	f[1][2]=-inf;
	f[1][1]=f[2][2]=1;
	if(s[1]==s[2])
		f[2][1]=-inf;
	else
		f[2][1]=2;
	fr(i,3,n)
	{
		f[i][1]=f[i-1][2]+1;
		f[i][2]=f[i-2][1]+1;
		if(s[i]!=s[i-1])
			f[i][1]=max(f[i][1],f[i-1][1]+1);
		if(s[i]!=s[i-2]&&s[i-1]!=s[i-3])
			f[i][2]=max(f[i][2],f[i-2][2]+1);
	}
	printf("%d\n",max(f[n][1],f[n][2]));
	return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

class UnionFind{
    int n;
    vector<int> par;
    vector<int> rank;
    vector<int> sz;

public:
    UnionFind(int n) : n(n), rank(n, 0){
        par.resize(n);
        for(int i=0; i<n; i++)
            par[i] = i;
        sz.resize(n, 1);
    }
    int find(int x){
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        int x_root = find(x);
        int y_root = find(y);
        if(rank[x_root] > rank[y_root]){
            par[y_root] = x_root;
            sz[x_root] += sz[y_root];
        }else if (rank[x_root] < rank[y_root]){
            par[x_root] = y_root;
            sz[y_root] += sz[x_root];
        }else if (x_root != y_root){
            par[y_root] = x_root;
            sz[x_root] += sz[y_root];
            rank[x_root]++;
        }
    }
    int size(int x){ return sz[find(x)]; }
    bool same(int x, int y){ return find(x) == find(y); }
};

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

    UnionFind uf(N);
    for(int i=0; i<M; i++){
        int X, Y, Z;
        cin >> X >> Y >> Z;
        X--; Y--;
        uf.unite(X, Y);
    }
    int ans = 0;
    for(int i=0; i<N; i++)
        if(uf.find(i) == i)
            ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
int dep[N],fa[N],id[N],vis[N],n,k,top,res;
inline bool cmp(const int &x,const int &y){return dep[x]>dep[y];}
void dfs(int u){
	if(dep[u]>k)id[++top]=u;
	go(u)dep[v]=dep[u]+1,dfs(v);
}
void clr(int u){vis[u]=1;go(u)if(!vis[v])clr(v);}
inline void jump(R int u){fp(i,1,k-1)u=fa[u];clr(u);++res;}
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&fa[i]);
	fp(i,2,n)add(fa[i],i);
	dfs(1);
	sort(id+1,id+1+top,cmp);
	fp(i,1,top)if(!vis[id[i]])jump(id[i]);
	printf("%d\n",res+(fa[1]!=1));
	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif
 
int main(){
	std::vector<std::pair<int, int> > data;
	std::vector<int> rank;
	int r = 0;
	int pre_s = -1;
	int p, s, q;
	char tmp;


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> p >> tmp >> s){
#else
	while(std::cin >> p >> tmp >> s){
#endif
		if(p == 0 && s == 0){
			break;
		}
		data.push_back(std::pair<int, int>(s, p));
	}
 
	std::sort(data.begin(), data.end());
	std::reverse(data.begin(), data.end());

	rank.resize(data.size(), 0);
	for(int i = 0; i < data.size(); i++){
		if(pre_s != data[i].first){
			r++;
		}
		rank[i] = r;
		pre_s = data[i].first;
	}
 
#if INPUT_FROM_FILE
	while(ifs >> q){
#else
	while(std::cin >> q){
#endif
		for(int i = 0; i < data.size(); i++){
			if(data[i].second == q){
				std::cout << rank[i] << std::endl;
			}
		}
	}

#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=10000010,mod=998244353;

ll fac[maxn],inv[maxn],ans;
ll fpm(ll a,ll b){
    ll ret=1ll;
    for(;b;b>>=1,a=a*a%mod)
        if(b&1)ret=ret*a%mod;
    return ret;
}
ll C(ll n,ll m){
    if(n<0||m<0||n-m<0)return 0;
    return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int n;

void solve(){
    scanf("%d",&n);
    fac[0]=1;ans=fpm(3,n);
    for(int i=1;i<=n;++i)fac[i]=fac[i-1]*i%mod;
    inv[n]=fpm(fac[n],mod-2);
    for(int i=n;i;--i)inv[i-1]=inv[i]*i%mod;
    for(int i=(n>>1)+1;i<=n;++i)
        (ans-=C(n,i)*fpm(2,n-i+1)%mod)%=mod,(ans+=mod)%=mod;
    printf("%lld\n",ans);
}
int main(){
    solve();

    return 0;
}

Measured memory_bytes: 156544
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    
    int res = a*x+b*y;
    
    for(int i= 0 ; i<=max(x,y)*2; i+= 2){
        int pA = x-i/2;
        int pB = y-i/2;
        if(pA<0) pA = 0;
        if(pB<0) pB = 0;
        
        int price = a*pA + b*pB + c*i;
        res = min(res,price);
    }
    
    cout << res << endl;
}







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

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

const long long INF = 1LL << 60;

int main(){
  int N;
  cin >> N;
  int h[N];

  long long dp[100010];
  for(int i=0;i<100010;i++) dp[i] = INF;
  
  for(int i=0;i<N;++i)cin >> h[i];
  
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for(int i=2;i<N;i++){
    chmin(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
    chmin(dp[i],dp[i-2] + abs(h[i] - h[i-2]));
  }
  
  cout << dp[N-1] << endl;
}
  

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int a, b;
		int c, d;
		double e;
		Scanner scan = new Scanner(System.in);
		a = scan.nextInt();
		b = scan.nextInt();
		c = a / b;
		d = a % b;
		e = (double) a / b;

		System.out.printf("%d %d %.5f\n", c, d, e);

	}

}



Measured memory_bytes: 26584
object Main extends App {
  def gcd(a: Long,b: Long): Long = if(b ==0) a else gcd(b, a%b)
  
  val Array(a,b,c,d) = readLine.split(" ").map(_.toLong)
  val am = a-1
  val cd = c*d/gcd(c,d)
  println(b-am - (b/c-am/c) - (b/d-am/d) + (b/cd-am/cd))
}

Measured memory_bytes: 27204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	double xa, ya, xb, yb, xc, yc, xd, yd;
	

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	while(fscanf(fp, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
#else
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
#endif
		double calc0 = (xb - xa) * (yc - yb) - (xc - xb) * (yb - ya);
		double calc1 = (xc - xb) * (yd - yc) - (xd - xc) * (yc - yb);
		double calc2 = (xd - xc) * (ya - yd) - (xa - xd) * (yd - yc);
		double calc3 = (xa - xd) * (yb - ya) - (xb - xa) * (ya - yd);

		if((calc0 > 0 && calc1 > 0 && calc2 > 0 && calc3 > 0) ||
			(calc0 < 0 && calc1 < 0 && calc2 < 0 && calc3 < 0)){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a, b, c, d, mx1, mx2, mx3, mx4;
    cin >> a >> b >> c >> d;
    mx1 = a * c;
    mx2 = b * c;
    mx3 = a * d;
    mx4 = b * d;
    cout << max(mx1, max(mx2, max(mx3, mx4))) << endl;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using val = valarray<T>;

using pi = pair<int,int>;

#define rep(a,b) for(int a=0; a<b; ++a)
#define Rep(a,b,c) for(int a=b; a<c; ++a)
#define ran(a,b) for(auto &a:b)
#define all(v) v.begin(),v.end()

string smax(string a,string b){
	if(a.size()!=b.size()){
		return a.size()>b.size()?a:b;
	}
	rep(i,a.size()){
		if(a[i]!=b[i]){
			return a[i]>b[i]?a:b;
		}
	}
	return a;
}

string smin(string a,string b){
	if(a.size()!=b.size()){
		return a.size()<b.size()?a:b;
	}
	rep(i,a.size()){
		if(a[i]!=b[i]){
			return a[i]<b[i]?a:b;
		}
	}
	return a;
}

int ssub(string a,string b){
	//cout<<a<<" "<<b<<endl;
	int pnt;
	rep(i,a.size()){
		if(a[i]!=b[i]){
			pnt=i;
			break;
		}
	}
	if(a.size()-pnt-1>=2) return 37564;
	else{
		if(a.size()==1){
			return stoi(a)-stoi(b);
		}
		else{
			return stoi(a.substr(a.size()-2,2))-stoi(b.substr(b.size()-2,2));
		}
	}
}

int main(){
	string n; cin >> n;
	
	int ans = 10;
	
	string max1,min1;
	Rep(i,1,n.size()){
		//cout<<"Check"<<endl;
		if(n.size()%i!=0) continue;
		max1="0";
		min1=n;
		//cout<<"Check"<<endl;
		for(int j=0; j<n.size(); j+=i){
			string tmp=n.substr(j,i);
			//cout<<"Check"<<endl;
			max1=smax(max1,tmp);
			min1=smin(min1,tmp);
		}
		//cout<<"Case "<<i<<" : "<<max1<<" "<<min1<<endl;
		ans=min(ans,ssub(max1,min1));
		//cout<<"Check"<<endl;
	}
	//cout<<"Check"<<endl;
	
	int max2=0,min2=10;
	int pnt=0;
	while(pnt<n.size()){
		int tmp=n[pnt]-'0';
		if(n[pnt]=='1'&&pnt+1<n.size()){
			tmp*=10;
			tmp+=(n[pnt+1]-'0');
			++pnt;
		}
		++pnt;
		max2=max(max2,tmp);
		min2=min(min2,tmp);
	}
	//cout<<max2<<" "<<min2<<endl;
	ans=min(ans,max2-min2);
	cout<<ans<<endl;
}


Measured memory_bytes: 3464
#include <iostream>
#include <bitset>

using namespace std;

#define PRIME_MAX 1000000

bitset<PRIME_MAX> is_prime;

void make_cache() {
    is_prime.set(), is_prime.reset(0), is_prime.reset(1);
    for (int i = 2; i < PRIME_MAX; i++) {
        if (is_prime[i]) {
            for (int j = i + i; j < PRIME_MAX; j+=i) {
                is_prime.reset(j);
            }
        }
    }
}

int solve(int n) {
    int count = 0;
    int sum = 0;
    for (int i = 2; i < PRIME_MAX; i++) {
        if (is_prime[i]) {
            sum += i;
            count++;
            if (count == n) break;
        }
    }
    return sum;
}

int main() {
    make_cache();
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 0