akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>

#define N 100000
typedef struct{
   char name[10];
   int time;
} Data;

typedef struct{
    int head,tail;
    Data data[N];
}Queue;


int empty(Queue *);
void push(Queue *,Data);
Data pop(Queue *);


int main(){
    int num,sec,sum=0;
    int i,j;
    Data data;
    Queue que;
   
   scanf("%d%d",&num,&sec);
   for(i=0;i<num;i++){
       scanf("%s %d",data.name,&data.time);
       push(&que,data);
    }

    while(empty(&que) != 1){
        data = pop(&que);
        data.time = data.time - sec;
        if(data.time > 0){
            sum += sec;
            push(&que,data);  
        }
        else{
            sum += data.time + sec;
            printf("%s %d\n",data.name,sum);
        }
        
     }
     return 0;
}



int empty(Queue *q){
    return (q->head == q->tail);
}

void push(Queue *q,Data d){
    q->data[(q->tail++)%N] = d; 
}

Data pop(Queue *q){

    return q->data[(q->head++)%N];
}
  



Measured memory_bytes: 3264
#include<iostream>
using namespace std;
int main(void){
int n;
int a=1,b=1,tmp=1;

cin>>n;

for(int i=2; i<n+1; i++){
  tmp = a + b;
  a = b;
  b = tmp;
}

cout<<tmp<<endl;

return 0;
}






Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define vi vector<int>
#define pii pair<int,int>
#define se second
using namespace std;
int t,a,b,c,x,y,k;
ll n;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin >> n;
	string s;
	while (n) {
	s += 'a' + ((n-1)%26);
	n=(n-1)/26;	
	}
	reverse(s.begin(),s.end());
	cout << s;
	
	
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    std::vector<int> c;
    cin >> n;
    int prev = -1;
    std::map<int, int> prevm;
    for (int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        if (prev == temp) {
            continue;
        }
        c.pb(temp);
        prev = temp;
    }
    int sum = 0;
    int l = c.size();
    std::vector<int> dp(l, 1);
    prevm[c[0]] = 0;
    for (int i = 1; i < l; i++) {
        if (prevm.count(c[i]) == 0) {
            dp[i] = dp[i - 1];
            prevm[c[i]] = i;
            continue;
        }

        dp[i] = (dp[prevm[c[i]]] + dp[i - 1]) % MOD;
        prevm[c[i]] = i;
    }
    cout << dp[l - 1] << endl;
    return 0;
}

Measured memory_bytes: 15856
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> data(N);
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
	}
	sort(data.begin(), data.end());

	cout << data[N - 1] - data[0] << endl;


	return 0;

}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc066/tasks/arc077_a

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 2*1e5;
const int A_I_MAX = 1e9;

int n;
int a[N_MAX];

void solve() {
  int i;

  printf("%d", a[n - 1]);
  for (i = n - 3; i >= 0; i -= 2) {
    printf(" %d", a[i]);
  }
  for (i = -1 - i; i < n; i += 2) {
    printf(" %d", a[i]);
  }
  printf("\n");
}

void input() {
  scanf("%d", &n);
  REP(i, n) scanf("%d", a + i);
}

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


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

int main() {
  long long n, k;
  cin >> n >> k;

  long long a = n % k;
  long long b = k - a;

  if (a < b) {
    cout << a << endl;
  }
  else {
    cout << b << endl;
  }
}

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

int main(){
  int N;
  cin>>N;
  vector<int> pre(N+1,0);
  
  for(int a=1;a<=N;++a){
  	for(int b=1;b<=N/a;++b){
    	++pre[a*b];
    }
  }
  
  int sum = 0;
  
  for(int i=1;i<N;++i)sum+=pre[i];
  
  cout<<sum;
return 0;
}

Measured memory_bytes: 7132
function Main(input) {
  var input_splited = input.split(' ');
  var a = input_splited[0];
  var b = input_splited[1];
  var ab = a * b;
  if (ab % 2 == 0) {
    console.log('Even');
  } else {
    console.log('Odd');
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30740
import sys
input = sys.stdin.readline
xmax, ymax, N = [int(x) for x in input().split()]
X = []
for _ in range(N):
    X.append([int(x) for x in input().split()])
xmin = 0
ymin = 0
for i in X:
    x, y, a = i
    if a == 1:
        xmin = max(xmin, x)
    elif a == 2:
        xmax = min(xmax, x)
    elif a == 3:
        ymin = max(ymin, y)
    else:
        ymax = min(ymax, y)
if xmax <= xmin or ymax <= ymin:
    print(0)
else:
    print((xmax - xmin) * (ymax - ymin))


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
	int A, B, M;
	scanf("%d %d %d", &A, &B, &M);
	int ai[A],bi[B];
	int xi[M], yi[M], ci[M];
	int melhorA, melhorB, result=0;

	for(int i=0; i<A; i++){
		scanf("%d", &ai[i]);
		if(i==0)
			melhorA = ai[i];
		else{
			if(ai[i] < melhorA)
				melhorA = ai[i];
		}
	}
	for(int i=0; i<B; i++){
		scanf("%d", &bi[i]);
		if(i==0)
			melhorB = bi[i];
		else{
			if(bi[i] < melhorB)
				melhorB = bi[i];
		}
	}

	for(int i=0; i<M; i++){
		scanf("%d %d %d", &xi[i],&yi[i],&ci[i]);
		
		if(i==0){
			if((ai[xi[i]-1] + bi[yi[i]-1] - ci[i]) < (melhorA + melhorB))
				result = ai[xi[i]-1] + bi[yi[i]-1] - ci[i];
			else
				result = melhorA + melhorB;
		}

		if((ai[xi[i]-1] + bi[yi[i]-1] - ci[i]) < (melhorA + melhorB)){
			if((ai[xi[i]-1] + bi[yi[i]-1] - ci[i]) < result)
				result = ai[xi[i]-1] + bi[yi[i]-1] - ci[i];
		}else{
			if((melhorA + melhorB) < result)
				result = melhorA + melhorB;
		}
	}

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

	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;
void file(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}


int main(){//file();

    ll n , a  , pen = 0 , ac = 0 ;
    cin >> n >> n ;
    map < int , int > mp ;

    for(int i = 0 ; i < n ;i++){
        string s ;
        cin >>a >>  s ;
        if(s=="WA"&&mp[a]!=-1){
            mp[a]++;
        }
        else {
            if(mp[a]==-1)continue;
            pen += mp[a];
            ac++;
            mp[a]=-1;
        }
    }
    cout << ac << " " << pen << endl;
}


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

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

    int a, t, w, r;
    a = 0;
    t = 0;
    w = 0;
    r = 0;

    while (n--)
    {
        string s;
        cin >> s;

        if (s == "AC")
        {
            a++;
        }
        else if (s == "WA")
        {
            w++;
        }
        else if (s == "TLE")
        {
            t++;
        }
        else
        {
            r++;
        }
    }
    cout << "AC x " << a << endl
         << "WA x " << w << endl
         << "TLE x " << t << endl
         << "RE x " << r << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

constexpr int MOD = 1e9+7;

namespace math { namespace integer {

ll mod_pow(ll x, ll n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(x * x % mod, n / 2, mod); } else { return x * mod_pow(x, n - 1, mod) % mod; } }
template<class T> T extgcd(T a, T b, T& x, T& y) { T d = a; if(b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class T> T mod_inverse(T x, T mod) { return mod_pow(x, T(mod - 2), mod); /* use fermat */ }
template<class T> T mod_inverse_composite_num_mod(T a, ll mod) { T x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;

namespace math {

constexpr int MaxFact = 200010;

template<class T = int64_t>
struct FactRevFactList {
  array<T, MaxFact+1> fact_;
  array<T, MaxFact+1> rev_fact_;

  FactRevFactList() {
    fact_[0] = 1;
    for(int i=1; i<MaxFact; i++) {
      fact_[i] = fact_[i-1] * i;
      fact_[i] %= MOD;
    }

    rev_fact_[MaxFact-1] = mod_pow(fact_[MaxFact-1], (T)MOD-2, MOD);

    for(int i=MaxFact-2; i>=0; i--) {
      rev_fact_[i] = rev_fact_[i+1] * (i+1);
      rev_fact_[i] %= MOD;
    }
  }

  T fact(int x) const { return fact_[x]; }
  T fact_inv(int x) const { return rev_fact_[x]; }
};

template<class T = int64_t>
struct CombinationBig {
  math::FactRevFactList<> fr_;
  T comb(T n, T r) { return (fr_.fact(n) * fr_.fact_inv(r) % MOD) * fr_.fact_inv(n-r) % MOD; }
};

}

math::CombinationBig<> cbig;

int main() {
  int n, k; cin >> n >> k;
  ll ans = 0;
  rep(m, min(k + 1, n)) {
    ll pat = (cbig.comb(n, m) % MOD * cbig.comb(n - 1, m)) % MOD;
    (ans += pat) %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;

int main() {
	int N, X, ans = 1,k=0;
	cin >> N >> X;
	vector<int>L(N);
	for (int i = 1; i < N+1; i++)
	{
		cin >> L[i-1];
		k += L[i-1];
		if (k <= X)ans++;
	}
	cout << ans;
}

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

int main(){
	int n;
	cin>>n;
	int r[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>r[i];
	}
	int maxv=-1000000000;
	int minv=r[0];
	for (int i = 1; i < n; ++i)
	{
		maxv=max(maxv, r[i]-minv);
		minv=min(minv, r[i]);
	}
	cout<<maxv<<endl;
	

	
return 0;
}

Measured memory_bytes: 3788
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var A = new long[2, N];
            var l0 = ReadLongs();
            var l1 = ReadLongs();
            for (int i = 0; i < N; i++)
            {
                A[0, i] = l0[i];
                A[1, i] = l1[i];
            }

            var maxSum = 0L;
            for (int i = 0; i < N; i++)
            {
                var sum = 0L;
                var hIndex = 0;
                for (int j = 0; j < N; j++)
                {
                    sum += A[hIndex, j];
                    if (j == i)
                    {
                        hIndex = 1;
                        sum += A[hIndex, j];
                    }
                }
                maxSum = Math.Max(sum, maxSum);
            }

            return maxSum;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28208
#include<cstdio>
#include<algorithm>
using namespace std;
typedef pair<short,short> P;
short f[2005][20005];P a[2005][20005];
void dp(int x,int y)
{
	if(f[x][y]) return;f[x][y]=-1;
	if(x==1)
	{
		if(y==10) {a[x][y].first=1;f[x][y]=1;}
		if(y==5) {a[x][y].second=1;f[x][y]=1;}
		if(y==1) f[x][y]=1;return;
	}
	if(y>10) {dp(x-1,y-10);if(f[x-1][y-10]>0) {f[x][y]=1;a[x][y]=a[x-1][y-10];a[x][y].first++;return;}}
	if(y>5) {dp(x-1,y-5);if(f[x-1][y-5]>0) {f[x][y]=1;a[x][y]=a[x-1][y-5];a[x][y].second++;return;}}
	if(y>1) {dp(x-1,y-1);if(f[x-1][y-1]>0) {f[x][y]=1;a[x][y]=a[x-1][y-1];return;}}
}
int main()
{
	int n,m;scanf("%d%d",&n,&m);m/=1000;dp(n,m);
	if(f[n][m]<0) printf("-1 -1 -1\n");
	else printf("%d %d %d\n",a[n][m].first,a[n][m].second,n-a[n][m].first-a[n][m].second);
	return 0;
}

Measured memory_bytes: 231936
SA = input()
SB = input()
SC = input()
S = {'a' : SA, 'b' : SB, 'c' : SC}
card = S['a'][0]
while True:
    if S[card] == '':
        print(card.upper())
        break
    S[card], card = S[card][1:], S[card][0]

Measured memory_bytes: 9120
/* Harsh Pathak - pogba */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
int n;
int k;
const int N = 1e5;
int a[N];
int dp[N];

int main(int argc, char const *argv[])
{
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		dp[i] = 1e9;
		for (int j = i-1; j >= max(0, i-k); j--)
		{
			dp[i] = min(dp[i], dp[j] + abs(a[j] - a[i]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

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

int main() {
  int N,A;
  cin>>N>>A;
  if(A>=500){
    cout<<"Yes"<<endl;}
  int Q=N%500;
  if(A<500&&Q<=A){
    cout<<"Yes"<<endl;}
  if(A<500&&Q>A){
    cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  ll before = A.at(0);
  ll now = 1000;
  for (ll i = 0; i < N; ++i) {
    if (A.at(i) < before) {
      before = A.at(i);
    }
    else {
      now = (now % before) + (now / before) * A.at(i);
      before = A.at(i);
    }
  }
  cout << now << "\n";
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
long long n,a[1000000][10],F[1000000][10],maxx;
using namespace std;
int main()
{
    //freopen("VACATION.INP","r",stdin);
    cin>>n;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=3;j++)
            cin>>a[i][j];
    for (int i=1;i<=n;i++)
        for (int j=1;j<=3;j++)
        {
            if (j==1) F[i][j]=max(F[i-1][j+1]+a[i][j],F[i-1][j+2]+a[i][j]);
            else if (j==2) F[i][j]=max(F[i-1][j-1]+a[i][j],F[i-1][j+1]+a[i][j]);
            else F[i][j]=max(F[i-1][j-1]+a[i][j],F[i-1][j-2]+a[i][j]);
        }
    for (int i=1;i<=n;i++) maxx=max(maxx,F[n][i]);
    cout<<maxx;
    return 0;
}


Measured memory_bytes: 16640
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import math
import sys


def calc_p(a, b, c):
    u = {a, b, c}
    if len(u) == 3:
        return 6
    if len(u) == 2:
        return 3
    if len(u) == 1:
        return 1
    else:
        raise


def std_in():
    return sys.stdin.readline().strip()


def _main():
    N = int(std_in())
    fn = [0] * N
    if N == 1:
        x_max = 1
    else:
        x_max = int(math.sqrt(N - 2)) - 1

    n2 = [i**2 for i in range(1, x_max + 1)]

    ij = [[0 for _ in range(1, x_max + 1)] for _ in range(1, x_max + 1)]
    for i in range(x_max):
        for j in range(i, x_max):
            ij[i][j] = (i+1) * (j+1)

    for x in range(1, x_max + 1):
        y_min = x
        x2 = n2[x-1]
        for y in range(y_min, x_max + 1):
            z_min = y
            y2 = n2[y-1]
            xy = ij[x-1][y-1]
            tmp_n = x2 + xy + y2
            if tmp_n > N:
                break
            for z in range(z_min, x_max + 1):
                z2 = n2[z-1]
                yz = ij[y-1][z-1]
                zx = ij[x-1][z-1]
                n = tmp_n + z2 + yz + zx
                if n > N:
                    break
                fn[n-1] += calc_p(x, y, z)

    print(*fn, sep="\n")


if __name__ == "__main__":
    _main()


Measured memory_bytes: 9692
#include <cstdio>
#include <vector>
#include <algorithm>

class Point
{
public:
  int x, y;
  Point(int _x, int _y)
    :x(_x), y(_y) {}
};

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

int main()
{
  int N;
  while (~scanf("%d", &N)) {
    if (N == 0)
      break;

    std::vector<Point> fig(1, Point(0, 0));
    for (int i = 0; i < N-1; ++i) {
      int n, d;
      scanf("%d %d", &n, &d);
      fig.push_back(Point(fig[n].x+dx[d], fig[n].y+dy[d]));
    }

    Point min(INF, INF), max(-INF, -INF);
    for (unsigned int i = 0; i < fig.size(); ++i) {
      min.x = std::min(min.x, fig[i].x);
      min.y = std::min(min.y, fig[i].y);
      max.x = std::max(max.x, fig[i].x);
      max.y = std::max(max.y, fig[i].y);
    }

    printf("%d %d\n", max.x-min.x+1, max.y-min.y+1);
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		double area = (double) w * (double) h / 2.0;
		int way = w / 2.0 == x && h / 2.0 == y ? 1 : 0;
		System.out.println(area + " " + way);
	}

}


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

int main(){
    string a, b, c;
    cin >> a >> b >> c;
    if(a.at(a.size()-1) == b.at(0) && b.at(b.size()-1) == c.at(0)){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	double a;

	while (cin >> a) {
		if (a <= 48.0) {
			cout << "light fly" << endl;
		} else if (a <= 51.0) {
			cout << "fly" << endl;
		} else if (a <= 54.0) {
			cout << "bantam" << endl;
		} else if (a <= 57.0) {
			cout << "feather" << endl;
		} else if (a <= 60.0) {
			cout << "light" << endl;
		} else if (a <= 64.0) {
			cout << "light welter" << endl;
		} else if (a <= 69.0) {
			cout << "welter" << endl;
		} else if (a <= 75.0) {
			cout << "light middle" << endl;
		} else if (a <= 81.0) {
			cout << "middle" << endl;
		} else if (a <= 91.0) {
			cout << "light heavy" << endl;
		} else {
			cout << "heavy" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1220
n,k=gets.split.map(&:to_i)
x=gets.split.map(&:to_i)
kouho=Array.new
for i in 0..n-k
    y=x[i...i+k]
    if y[0]>=0
        kouho.push(y[k-1])
    elsif y[k-1]<=0
        kouho.push(y[0].abs)
    elsif y[0].abs<y[k-1]
        kouho.push(y[k-1]-2* y[0])
    else
        kouho.push(2*y[k-1]-y[0])
    end
end
p kouho.min

Measured memory_bytes: 11532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair <ll, ll>;
int main()
{
	ll n, x, d;
	cin >> n >> x >> d;
	if (d == 0)
	{
		cout << (x == 0 ? 1 : n + 1);
		return 0;
	}
	if (d < 0)
	{
		x = -x;
		d = -d;
	}
	unordered_map <int, vector <pi>> a;
	for (ll i = 0; i <= n; ++i)
	{
		ll l = x * i + d * (i - 1) * i / 2, r = x * i + d * (n - i + n - 1) * i / 2;
		a[x * i % d].emplace_back(make_pair(l, r));
	}
	ll ans = 0;
	for (auto &i : a)
	{
		auto &b = i.second;
		ll pre = LLONG_MIN / 2;
		sort(b.begin(), b.end());
		for (auto j : b)
			if (pre < j.second)
			{
				ans += (j.second - max(j.first, pre)) / d + (j.first > pre);
				pre = j.second;
			}
	}
	cout << ans;
}


Measured memory_bytes: 17864
import std.stdio, std.array, std.conv, std.string;

struct Card {
  string suit;
  int number;

  size_t toHash() {
    int a = 100;
    string[] suits = ["S", "H", "C", "D"];
    foreach (int i, s; suits) {
      if (s == suit) a = i;
    }

    return 13 * a + number;
  }
}

void main() {
  int n = to!int(chomp(readln()));
  bool[string][14] set;

  for (int i = 0; i < n; ++i) {
    string[] s = split(readln());
    set[to!int(s[1])][s[0]] = true;
  }

  string[] suits = ["S", "H", "C", "D"];
  foreach (i; suits) {
    for (int j = 1; j <= 13; ++j) {
      if (i in set[j]) continue;
      writef("%s %d\n", i, j);
    }
  }
}

// void main() {
//   int n = to!int(chomp(readln()));
//   bool[Card] set;
//
//   for (int i = 0; i < n; ++i) {
//     string[] s = split(readln());
//     set[Card(s[0], to!int(s[1]))] = true;
//   }
//
//   string[] suits = ["S", "H", "C", "D"];
//   foreach (i; suits) {
//     for (int j = 1; j <= 13; ++j) {
//       if (Card(i, j) in set) continue;
//       writef("%s %d\n", i, j);
//     }
//   }
// }

Measured memory_bytes: 2520
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var L = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var c = int.Parse(line[2]);
        Console.WriteLine((L - c) / (b + c));
    }
}



Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#define DIV 1000000007

using namespace std;

int main(void) {
	int N,M;
	cin >> N >> M;
	vector<int> dp(N+3,0);
	for (int i = 0; i < M; ++i) {
		int a;
		cin >> a;
		dp[a] = -1;
	}
	dp[0] = 1;
	for (int i = 0; i < N; ++i) {
		dp[i] %= DIV;
		if (dp[i] > 0) {
			if (dp[i+1] >= 0) {
				dp[i+1] += dp[i];
			}
			if (dp[i+2] >= 0) {
				dp[i+2] += dp[i];
			}
		}
	}
	cout << dp[N]%DIV << endl;
	return 0;
}




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

using namespace std;

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

int N;
int a[100010];

int main() {
  int i;
  set<int> s;

  scanf("%d", &N);
  REP(i,N) {
    scanf("%d", &a[i]);
    s.insert(a[i]);
  }

  set<int> t = s;
  while (t.size() > 1) {
    set<int> n;
    int mn = *(t.begin());
    for (const int& x : t) {
      int y = x % mn;
      if (y != 0) {
        n.insert(y);
      }
    }
    n.insert(mn);
    t = n;
  }

  cout << *(t.begin()) << endl;

  return 0;
}


Measured memory_bytes: 10240
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cassert>
#define ll long long
using namespace std;
inline ll read(){
	ll re=0;
	cin>>re;
	return re;
}
ll n;ll m=200000;
struct BIT{
	ll a[200010];
	void clear(){
		memset(a,0,sizeof(a));
	}
	ll lowbit(ll x){
		return x&(-x);
	}
	void add(ll x,ll val){
		for(;x<=m;x+=lowbit(x)) a[x]+=val;
	}
	ll sum(ll x){
		ll re=0;
//		cout<<"getsum "<<x<<' ';
		for(;x>0;x-=lowbit(x)) re+=a[x];
		//cout<<re<<'\n';
		return re;
	}
}T;
struct ele{
	ll val,num;
}a[100010];ll w[100010];
bool cmp1(ele l,ele r){
	return l.val<r.val;
}
bool cmp2(ele l,ele r){
	return l.num<r.num;
}
ll x[100010];ll lim;
bool check(ll val){
	ll i;ll sum=0,re=0;T.clear();
	for(i=1;i<=n;i++){
		if(a[i].val<val) x[i]=-1;
		else x[i]=1;
	}
	T.add(100000,1);
	for(i=1;i<=n;i++){
		sum+=x[i];
		re+=T.sum(sum+100000);
		T.add(sum+100000,1);
	}
//	cout<<"check "<<val<<' '<<re<<'\n';
	return re>=(lim/2+lim%2);
}
int main(){
	ll i;
	n=read();lim=n*(n+1)/2;
	for(i=1;i<=n;i++) a[i].val=read(),a[i].num=i;
	sort(a+1,a+n+1,cmp1);
	for(i=1;i<=n;i++) w[i]=a[i].val;
	sort(a+1,a+n+1,cmp2);
	ll l=1,r=n,mid;
	while(l<r){
		mid=(l+r)>>1;mid++;
		if(check(w[mid])) l=mid;
		else r=mid-1;
	}
	printf("%lld\n",w[l]);
} 

Measured memory_bytes: 4992
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

data class Segment(val from: Int, val to: Int, val id: Int)

fun solve(n: Int, segments: List<Segment>): Long {
  val segments1 = segments.sortedWith(java.util.Comparator { s1, s2 -> s2.from - s1.from })
  val segments2 = segments.sortedWith(java.util.Comparator { s1, s2 -> s1.to - s2.to })
//  println(segments1)
//  println(segments2)
  val visited = BooleanArray(n)
  var i1 = 0
  var i2 = 0
  var ans = 0L
  var x = 0
  while (true) {
    while (visited[segments1[i1].id]) {
      i1++
      if (i1 == n) break
    }
    if (i1 == n) break

    val s1 = segments1[i1]
    // if (s1.from < x) throw RuntimeException()
    if (x !in s1.from..s1.to) {
      ans += Math.abs(s1.from - x)
      x = s1.from
    }
    visited[s1.id] = true
//    println("i1: $i1 x: $x")
//    println(visited.asList())

    while (visited[segments2[i2].id]) {
      i2++
      if (i2 == n) break
    }
    if (i2 == n) break

    val s2 = segments2[i2]
    // if (s2.to > x) throw RuntimeException()
    if (x !in s2.from..s2.to) {
      ans += Math.abs(x - s2.to)
      x = s2.to
    }
    visited[s2.id] = true
//    println("i2:$i2 x: $x")
//    println(visited.asList())
  }
  ans += Math.abs(x)
  return ans
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val segments = Array(n, {
    val (from, to) = fastReadInts(2)
    Segment(from, to, it)
  }).asList()
  val rSegments = segments.map { Segment(-it.to, -it.from, it.id) }
  val ans = solve(n, segments)
  val rAns = solve(n, rSegments)
  println(Math.max(ans, rAns))
}


Measured memory_bytes: 49756
from math import sqrt


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    divisors.sort()
    return divisors


if __name__ == "__main__":
    N = int(input())

    div = Calc_Divisors(N)

    ans = N
    for d in div:
        a = d
        b = N // a
        c = a + b - 2
        if c < ans:
            ans = c

    print(ans)


Measured memory_bytes: 3288
import java.util.*;

/**
 * A
 */
public class Main{

    void run() {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[] array = new int[n];

        for(int i=0; i<n; i++) {
            array[i] = sc.nextInt();
        }

        sc.close();

        int cnt = partition(array, 0, n-1);

        System.out.print(array[0]);

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

            if( i == cnt) {
                System.out.print(" ["+array[i]+"]");
            } else {
                System.out.print(" "+array[i]);
            }

            if(i == n-1) {
                System.out.println();
            }
        }

    }

    int partition(int[] A, int p, int r) {

        int x = A[r];
        int i = p-1;
        int tmp;

        for(int j=p; j<r; j++) {
            
            if(A[j]<=x) {
                i = i+1;
                tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
            }

        }

        tmp = A[i+1];
        A[i+1] = A[r];
        A[r] = tmp;

        return i+1;
        
    }

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


Measured memory_bytes: 70500
#include<stdio.h>

int main(){

int n;
while(1){
scanf("%d",&n);if(n==0)break;
int c=0;
while(n!=1){
if(n%2==0)n=n/2;
else {n=3*n+1;}
c++;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

ll x;

int main(void){
    
    scanf("%lld", &x);
    
    ll ans = 0;
    if(x < 11) ans = x / 6 + ((x % 6) ? 1 : 0);
    else{
        if(x % 11 == 0) ans = x / 11 * 2;
        else ans = x / 11 * 2 + ((x % 11 <= 6) ? 1 : 2);
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {

		try (Scanner scan = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out);) {
			char[] s = scan.next().toCharArray();

			Set<Character> set = new HashSet<Character>();
			for (int i = 0; i < s.length; i++) {
				set.add(s[i]);
			}

			out.println(set.size() == 1 ? "No" : "Yes");
			out.flush();
		}
	}
}


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

int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  int at=0;
  for(int i=0;i<a;i++){
    if(!(s[i]>='0'&&s[i]<='9')){
      at++;
    }
  }
  for(int i=a+1;i<a+b+1;i++){
    if(!(s[i]>='0'&&s[i]<='9')){
      at++;
    }
  }
  if(s[a]!='-'){
    at++;
  }
  if(at>0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

int main() {
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
  
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b;
    cin>>a;
    map<ll,ll>m;
    multiset<ll>s;
    vector<ll>v,v2(a+1);
    set<ll>s1;
    for(int i=0; i<a; i++)
    {
        cin>>b;
        s.insert(b);
        s1.insert(b);
        v.push_back(b);
        m[b]++;
    }
    vector<ll>v1(s1.begin(),s1.end());
    ll sum=0;
    for(int i=0; i<v1.size(); i++)
    {
        if(s.count(v1[i])>=2)
        {
            sum=sum+((m[v1[i]])*(m[v1[i]]-1))/2;
            //cout<<sum<<endl;
        }

    }
    ll sum1=sum;
    for(int i=0; i<v.size(); i++)
    {
        sum1=sum;
        sum1-=(((m[v[i]])*(m[v[i]]-1))/2);
        sum1+=(((m[v[i]]-1)*(m[v[i]]-2))/2);
        printf("%lld\n",sum1);
    }
}


Measured memory_bytes: 30832
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
#define repi(i,a,b) for(lint i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) tsort(v); reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

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

    lint n, in, ans;cin>>n;
    cin>>ans;
    rep(i, n-1){
        cin>>in;
        ans=ans/__gcd(ans, in)*in;
        //ans=ans*in/gcd(ans, in);
    }
    co(ans);
}

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

int main(){
    double xs,ys,xt,yt;
    cin >> xs >> ys >> xt >> yt;
    double dx = xs -xt, dy = ys -yt;
    cout << fixed << setprecision(10);
    cout << sqrt(dx*dx +dy*dy) << endl;
    return 0;
}


Measured memory_bytes: 3300
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     pii             pair<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n, x)     (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     nshow(x,n)      for(int zz=0;zz<n;++zz)cout<<x[zz]<<" ";cout<<"\n";
#define     show2(x)        for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int k,n;
    cin>>k>>n;

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

    int sum=0,mx=0;
    for(int i=0;i<n;++i)
    {
        if(i==n-1)
        {
            sum+=k-v[i]+v[0];
            mx=max(mx,k-v[i]+v[0]);
            continue;
        }

        sum+=v[i+1]-v[i];
        mx=max(mx,v[i+1]-v[i]);
    }

    sum-=mx;
    cout<<sum;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <vector>
using namespace std;
vector<char> dict;
int n;
string s;
int cnt[2][26];
int main(){
 //   memset(cnt,false,sizeof(cnt));
    for(int i = 0; i < 26; i++)
        cnt[0][i] = 1e5;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < 26; j++)
            cnt[1][j] = 0;
        cin >> s;
        for(int j = 0; j < s.length(); j++)
        {
            cnt[1][s[j] - 'a']++;
        }
        for(int j = 0; j < 26; j++)
        {
            cnt[0][j] = min(cnt[1][j],cnt[0][j]);
        }
    }
    for(int j = 0; j < 26; j++)
    {
        if(cnt[0][j]!=0)
        {
            char ch = 'a' + j;
            while(cnt[0][j]--){
                dict.push_back(ch);
            }
        }
    }
    sort(dict.begin(), dict.end());
    for(int i = 0; i < dict.size(); i++)
        printf("%c", dict[i]);
    if(dict.size() == 0)
        printf("\n");
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		int H = 0;
		int W = 0;
		int h = 0;
		int w = 0;
		Scanner sc = new Scanner(System.in);
		ArrayList<String> ary = new ArrayList<String>();
		for (int i = 0; i < 2; i++) {
			String word = sc.next();
			ary.add(word);
			word = sc.next();
			ary.add(word);
			// ary.add(String.valueOf(word.charAt(0)));
			// ary.add(String.valueOf(word.charAt(2)));
		}
		H = Integer.parseInt(ary.get(0));
		W = Integer.parseInt(ary.get(1));
		h = Integer.parseInt(ary.get(2));
		w = Integer.parseInt(ary.get(3));
		if (H <= 0 || 20 < H) {
			throw new IllegalArgumentException("out of range");
		}
		if (W <= 0 || 20 < W) {
			throw new IllegalArgumentException("out of range");
		}
		if (h <= 0 || h > H) {
			throw new IllegalArgumentException("out of range");
		}
		if (w <= 0 || w > W) {
			throw new IllegalArgumentException("out of range");
		}

		Cal(H, W, h, w);
	}

	public static void Cal(int H, int W, int h, int w) {
		int cel = H * W;
		int x = h * W;
		int y = w * H;
		int over = h * w;
		System.out.println(cel - x - y + over);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;


int main(int argc, char **argv)
{
	string march{"MARCH"};
	ll N; cin >> N;
	map<char, ll> m;
	for (ll i = 0; i < N; ++i)
	{
		string s; cin >> s;
		char c = s[0];
		if (c == 'M' || c == 'A' || c == 'R' || c == 'C' || c == 'H')
			++m[c];
	}

	N = (ll)m.size();
	vector<ll> v;
	for (auto &e : m)
	{
		v.push_back(e.second);
	}
	// std::cout << "Pass"<< std::endl;

	ll res{0};
	for (ll i = 0; i < N-2; ++i)
	{
		for (ll j = i + 1; j < N-1; ++j)
		{
			for (ll k = j + 1; k < N; ++k)
			{
				res += v[i] * v[j] * v[k];
			}
		}
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n,a,b;cin>>n>>a>>b;
  pr(min(n*a,b));
  return 0;
}


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

using namespace std;


int main()
{
  int r,c;
  int data[100+1][100+1] = {};

  cin >> r >> c;

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  cin >> data[i][j];
	}
    }

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  data[r][c] += data[i][j];
	}
    }

  for(int i = 0;i < r;i++)
    {
      for(int j = 0;j < c;j++)
	{
	  data[i][c] += data[i][j];
	}
    }
  
  for(int j = 0;j < c;j++)
    {
      for(int i = 0;i < r;i++)
	{
	  data[r][j] += data[i][j];
	}
    }

  for(int i = 0;i <= r;i++)
    {
      for(int j = 0;j <= c;j++)
	{
	    if(j) cout << " ";
	  cout << data[i][j]; 
	}
      cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3124
n=int(input())

c=[[0]*10 for i in range(10)]

for i in range(1,n+1):
    t=str(i)
    c[int(t[0])][int(t[-1])]+=1
    
ans=0
for i in range(10):
    for j in range(10):
        ans+=c[i][j]*c[j][i]
        
print(ans)

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

int main() {
  int N = 0;
  cin >> N;
  vector<int> a(N);
  int b = N;
  for(int i = 0;i<N;i++){
    cin >> a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  for(int i = 0;i<N-1;i++){
    if(a.at(i) == a.at(i+1)){
      b--;
    }
  }
  
  cout << b << endl;
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using piii = pair<int, pii>;
using plll = pair<ll, pll>;
using pib = pair<int, bool>;
using pdi = pair<double, int>;
using pid = pair<int, double>;
using ld = long double;//__float128;
using piiii = pair<pii, pii>;

#define endl "\n"
#define inf 0x3f3f3f3f3f
#define f first
#define s second

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

int a, b, x, y, z, m, re[100001], mi[100001];

int main() {
    //freopen("deleg.in", "r", stdin);
    //freopen("deleg.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b >> m;
    int ans = inf;
    for (int i=1; i<=a; i++){
        cin >> re[i];
    }
    for (int i=1; i<=b; i++){
        cin >> mi[i];
    }
    for (int i=0; i<m; i++){
        cin >> x >> y >> z;
        ans = min(ans, re[x]+mi[y]-z);
    }
    sort(re+1, re+a+1); sort(mi+1, mi+b+1);
    ans = min(ans, re[1]+mi[1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
/** Nguyen Anh Tu **/
#include <bits/stdc++.h>
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x) memset(x,0,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)
using namespace std;

int n,m,ans, dd[maxn];
vector<int> a[maxn];

void dfs(int u){
    dd[u] = 1;
    for(auto v : a[u]) if(!dd[v]) {
        dfs(v);
    }
}

int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    cin >> n >> m;
    for(int i=1; i<=m; ++i){
        int u,v;
        cin >> u >> v;
        a[u].pb(v);
        a[v].pb(u);
    }
    for(int i=1; i<=n; ++i) if(!dd[i]) dfs(i), ++ans;
        cout << ans - 1;
    return  0;
}


Measured memory_bytes: 10004
package main
import(
  "fmt"
)
  func main(){
    var s string
    var i, j int
    fmt.Scan(&s)
    for i=0;i<len(s)-1;i++{
      for j=i+1;j<len(s);j++{
        if s[i]==s[j]{
          fmt.Println("no")
          return 
        }
      }
    }
   fmt.Println("yes")
 }

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


int n;
int h[100005];
int dp[100005];

void func(){

    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        
        int x=abs(h[i]-h[i-1])+dp[i-1];
        int y=abs(h[i]-h[i-2])+dp[i-2];
        dp[i]=min(x,y);
    }
    cout<<dp[n-1]<<endl;
}


int main(){



   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
   #endif
   cin>>n;
   for(int i=0;i<n;i++){
      cin>>h[i];
   }
   func();
}

Measured memory_bytes: 4388
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll n,m,k,d,q;
int a[maxn],level[maxn];
int main()
{
    cin>>n>>k>>q;
    level[0]=n;
    for(int i=0;i<q;i++)
    {
        int x;
        scanf("%d",&x);
        a[x]++;

    }
    for(int i=1;i<=n;i++)
    {
        if(a[i]>q-k)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }


    return 0;
}


Measured memory_bytes: 1024
#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 int INF = 1000000001;

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> g(h+2, vector<char>(w+2, '.'));
  for(int i = 1; i <= h; ++i){
    for(int j = 1; j <= w; ++j){
      cin >> g[i][j];
    }
  }

  for(int i = 1; i <= h; ++i){
    for(int j = 1; j <= w; ++j){
      if(g[i][j] != '#') continue;
      if( (g[i+1][j] == '#' && g[i][j+1] == '#') ||
          (g[i-1][j] == '#' && g[i][j-1] == '#') ){
        cout << "Impossible" << endl;
        return 0;
      }
    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
  'use strict';

  const temp = input.split(" ");

  const a = parseInt(temp[0], 10);
  const b = parseInt(temp[1], 10);

  const fragments = a * 3 + b;
  const pies = Math.floor(fragments / 2)

  console.log(pies);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
n = int(input())
ar = list(map(int,input().split()))
ans = 0
for i in range(0,n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			s = {ar[i],ar[j],ar[k]}
			if(len(s)!=3):
				continue;
			a , b, c = ar[i],ar[j],ar[k]
			if(a+b>c and b+c>a and c+a>b):
				#print(i,j,k)
				ans+=1
print(ans)					


Measured memory_bytes: 9196
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s;
    cin >> s;
    for (auto c : s) cout << 'x'; cout << endl;
    return 0;
}

Measured memory_bytes: 256