akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n ; cin >> n ;
	if(65<=n&&n<=90) cout << 1 ;
	else if(97<=n&&n<=122) cout << 2 ;
	else cout << 0 ;
	cout << endl ;
}



Measured memory_bytes: 3132
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.LinkedList;

public class Main {

	
	

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		

		int n=scn.nextInt();
		int cost[]=new int[n];
		for(int i=0;i<n;i++){
			cost[i]=scn.nextInt();
		}
		int dp[]=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE/2);
		dp[0]=0;
		for(int i=0;i<n;i++){
			for(int j=i-1;j>=i-2 && j>=0;j--){
				dp[i]=Math.min(dp[i], Math.abs(cost[i]-cost[j])+dp[j]);
			}
		}
		
		
		
		
		System.out.println(dp[n-1]);

	}

}

Measured memory_bytes: 50904
a, b, c, x, y = map(int, input().split())
c *= 2
if a + b < c:
    price = a * x + b * y
elif x <= y:
    price = c * x
    if b < c:
        price += b * (y - x)
    else:
        price += c * (y - x)
else:
    price = c * y
    if a < c:
        price += a * (x - y)
    else:
        price += c * (x - y)
print(price)


Measured memory_bytes: 3060
s=input()
t=input()
if s[0]==t[0] and s[1]==t[1] and s[2]==t[2]:
    print("3")
elif (s[0]==t[0] and s[1]==t[1])or(s[1]==t[1] and s[2]==t[2])or(s[0]==t[0] and s[2]==t[2]):
    print("2")
elif s[0]==t[0] or s[1]==t[1] or s[2]==t[2]:
    print("1")
else:
    print("0")

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

#define DEBUG

#ifndef LOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define maxn 111
int b[maxn][maxn];
int a[maxn*maxn];
int n,h,w;

int main()
{
	cin>>h>>w;
	cin>>n;
	int px=1,py=1;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		while (x--)
		{
			b[px][py]=i;
			if (px%2==1)
			{
				if (py==w)
				{
					px++;
				}
				else
				{
					py++;
				}
			}
			else
			{
				if (py==1)
				{
					px++;
				}
				else
				{
					py--;
				}
			}
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cout<<b[i][j]<<' ';
		}
		cout<<endl;
	}
	return 0;
}


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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

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

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  vi num(4); rep(i, 4) num[i] = s[i] - '0';
  for (int op = 0; op < (1 << 3); op++) {
    int ans = num[0];
    rep(i, 3) {
      if ((op >> i) & 1) ans += num[i+1];
      else ans -= num[i+1];
    }
    if (ans == 7) {
      std::cout << num[0];
      rep(i, 3) std::cout << ((op>>i)&1 ? '+' : '-') << num[i+1];
      std::cout << "=7\n";
      return 0;
    }
  }
}


Measured memory_bytes: 256
n = int(input())
a = [int(xi) for xi in input().split()]

sum = 0
pm = 0
min = 10**10
for xi in range(n):
    if a[xi]<0: pm+=1
    sum += abs(a[xi])
    if abs(a[xi])<min :min=abs(a[xi])
    # print(a[xi], sum, min)

if pm%2 ==1: sum-=min*2

print(sum)


Measured memory_bytes: 20132
#include <stdio.h>

int main() {
    double c, d;

    scanf("%lf%lf", &c, &d);

    if (c > d) {
        printf("GREATER\n");
    } else if (c < d) {
        printf("LESS\n");
    } else {
        printf("EQUAL\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n,m;cin>>n>>m;
    if(n==m){
        cout <<"Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }

}



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

using namespace std;

typedef long long ll;

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

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

const int MAX_N = 100000;

struct card {
    char mark;
    int value;
};

void merge_sort(const int N, int start, int end, struct card (*s)[MAX_N]) {
    static struct card tmp[MAX_N];

    assert(end - start >= 0);
    if (end - start == 0 || end - start == 1) {
        return;
    }

    int mid = (start + end) / 2;
    merge_sort(N, start, mid, s);
    merge_sort(N, mid, end, s);

    int ti = 0;
    int left = start;
    int right = mid;
    while (left < mid && right < end) {
        if ((*s)[left].value <= (*s)[right].value) {
            tmp[ti] = (*s)[left];
            left++;
            ti++;
        } else {
            tmp[ti] = (*s)[right];
            right++;
            ti++;
        }
    }
    while (left < mid) {
        tmp[ti] = (*s)[left];
        left++;
        ti++;
    }
    while (right < end) {
        tmp[ti] = (*s)[right];
        right++;
        ti++;
    }

    for (int i = 0; i < end - start; i++) {
        (*s)[start + i] = tmp[i];
    }
}

void quick_sort(const int N, int start, int end, struct card (*cards)[MAX_N]) {
    assert(end - start >= 0);
    if (end - start == 0 || end - start == 1) {
        return;
    }

    int pivot = end - 1;
    int border = start;
    for (int i = start; i < pivot; i++) {
        if ((*cards)[i].value <= (*cards)[pivot].value) {
            swap((*cards)[i], (*cards)[border]);
            border++;
        }
    }
    swap((*cards)[border], (*cards)[pivot]);

    quick_sort(N, start, border, cards);
    quick_sort(N, border + 1, end, cards);
}

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

    struct card cards1[MAX_N];
    struct card cards2[MAX_N];
    for (int i = 0; i < N; i++) {
        cin >> cards1[i].mark;
        cin >> cards1[i].value;
        cards2[i] = cards1[i];
    }

    quick_sort(N, 0, N, &cards1);
    merge_sort(N, 0, N, &cards2);

    bool is_stable = true;
    for (int i = 0; i < N; i++) {
        if (cards1[i].mark != cards2[i].mark || cards1[i].value != cards2[i].value) {
            is_stable = false;
            break;
        }
    }
    if (is_stable) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    cout << cards1[0].mark << " " << cards1[0].value << endl;
    for (int i = 1; i < N; i++) {
        cout << cards1[i].mark << " " << cards1[i].value << endl;
    }

    return 0;
}



Measured memory_bytes: 5380
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        List<String> list = new ArrayList<>();
        list.add("maerd");
        list.add("remaerd");
        list.add("esare");
        list.add("resare");

        StringBuilder sb = new StringBuilder(s);
        s = sb.reverse().toString();

        for (int i = 0; i < s.length(); ) {
            boolean flag = false;
            for (String str : list) {
                if (s.startsWith(str, i)) {
                    i += str.length();
                    flag = true;
                    break;
                }

            }
            if (!flag) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 26320
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
int n;
int fennec, snuke;

int dF[100010], dS[100010];
vector<vector<int>> G(100010);
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    cin >> n;

    for (int i = 0; i < n - 1; ++i)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    for (int i = 0; i < 100010; ++i)
    {
        dF[i] = -1;
        dS[i] = -1;
    }
    queue<int> q;
    q.push(0);

    dF[0] = 0;
    while (!q.empty())
    {
        int v = q.front();
        q.pop();

        for (int i = 0; i < (int)G[v].size(); ++i)
        {
            if (dF[G[v][i]] == -1)
            {
                dF[G[v][i]] = dF[v] + 1;
                q.push(G[v][i]);
            }
        }
    }

    q.push(n - 1);
    dS[n - 1] = 0;

    while (!q.empty())
    {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)G[v].size(); ++i)
        {
            if (dS[G[v][i]] == -1)
            {
                dS[G[v][i]] = dS[v] + 1;
                q.push(G[v][i]);
            }
        }
    }

    for (int i = 0; i < n; ++i)
    {
        if (dS[i] < dF[i])
            snuke++;
        else
            fennec++;
    }
    if (snuke >= fennec)
        cout << "Snuke" << endl;
    else
        cout << "Fennec" << endl;
    return 0;
}

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

int main(){
  int N;
  int64_t K;
  cin >> N >> K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int64_t x=0;
  bool flag;
  int64_t p=int64_t(pow(10,9));
  do{
    flag=false;
    for(int i=0;i<N-1;i++){
      if(A.at(i)>A.at(i+1)){
        swap(A.at(i),A.at(i+1));
        x++;
        flag=true;
      }
    }
  }while(flag);
  int64_t ans=(x*K);
  ans%=(p+7);
  int64_t y=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A.at(i)>A.at(j)){
        y++;
      }
    }
  }
  int64_t c=((K*(K-1))/2)%(p+7);
  ans+=(y*c);
  ans%=(p+7);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll k,a,b;
 sc(k);sc(a);sc(b);
 ll bis=1,money=0;
 ll cnt=0;
 if(b-a<=0){
  pr(1+k);return 0;
 }
 while(cnt!=k){
  if(cnt<k-1&&bis>=a){
   bis+=b-a;cnt+=2;
   //cout<<cnt<<" "<<bis<<" "<<money<<endl;
  }
  else {
   bis++;cnt++;
  // cout<<cnt<<" "<<bis<<" "<<money<<endl;
  }
 }
 pr(max(1+k,bis));
  








return 0;}


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

#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define all(a) s.begin(), s.size()
#define file(s, w) freopen(s".in", "r", stdin); freopen(w".out", "w", stdout);

typedef long long ll;
typedef long double ld;

using namespace std;

const int N = 1e5 + 500;
const int mod = 1e9 + 7;
const int eps = 1e9 - 11;
const int inf = 2e9;
long long ans, cur, n;
int main()
{
        cin >> n;
       string s;
       cin >> s;
       for (int i = 0; i < s.size(); i ++){
        if (s[i] == 'I')
                cur ++;
        else
                cur --;
        ans = max(ans, cur);
       }
       cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
int q;
int a[100004];
bool sai[100004];
int pre(){
    memset(sai,0,sizeof(sai));
    sai[0]=1;sai[1]=1;
    for(int i=2;i<=100000;i++)
        if(!sai[i])for(int j=i+i;j<=100000;j+=i)sai[j]=1;
    for(int i=1;i<=100000;i+=2)
        if(!sai[i] && !sai[(i+1)/2])a[i]=1;
    for(int i=1;i<=100000;i++)a[i]+=a[i-1];
    return 0;
}
int LiangJiaJun(){
    pre();
    scanf("%d",&q);
    while(q--){
        int l,r;
        scanf("%d%d",&l,&r);
        printf("%d\n",a[r]-a[l-1]);
    }
    return 0;
}




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

int main(int argc, char const *argv[])
{
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];

  for(int i = 0; i < n; i++)
  {
    if(i != 0)
      cout << " " << flush;

    cout << a[n-1-i] << flush;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3028
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define int long long
#define mod 10007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
enum pqrs {
	j = 1,
	o = 2,
	i = 3,
	jo = 4,
	oi = 5,
	ij = 6,
	joi = 7,
	sum = 8
};
int dp[1010][10];
signed main() {
	int n; string s; cin >> n >> s;
	s = 'J' + s;
	for1(q, sum) dp[0][q] = 0;
	dp[0][j] = 1; dp[0][sum] = 1;
	for1(p, n) {
		if (s[p] == 'O' || s[p] == 'I')dp[p][j] = 0;
		else dp[p][j] = dp[p - 1][j] + dp[p - 1][jo] + dp[p - 1][ij] + dp[p - 1][joi];
		if (s[p] == 'I' || s[p] == 'J')dp[p][o] = 0;
		else dp[p][o] = dp[p - 1][o] + dp[p - 1][oi] + dp[p - 1][jo] + dp[p - 1][joi];
		if (s[p] == 'J' || s[p] == 'O')dp[p][i] = 0;
		else dp[p][i] = dp[p - 1][i] + dp[p - 1][ij] + dp[p - 1][oi] + dp[p - 1][joi];

		if (s[p] == 'I')dp[p][jo] = 0;
		else dp[p][jo] = dp[p - 1][sum] - dp[p - 1][i];
		if (s[p] == 'J')dp[p][oi] = 0;
		else dp[p][oi] = dp[p - 1][sum] - dp[p - 1][j];
		if (s[p] == 'O')dp[p][ij] = 0;
		else dp[p][ij] = dp[p - 1][sum] - dp[p - 1][o];

		dp[p][joi] = dp[p - 1][sum];

		for1(q, joi) { dp[p][q] %= mod; dp[p][sum] += dp[p][q]; }dp[p][sum] %= mod;
		if (dp[p][sum] < 0)dp[p][sum] += mod;
	}
	cout << dp[n][sum] << endl;
}


Measured memory_bytes: 3284
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n;

int main(){
	IOS
	cin >> n;
	n--;
	ll temp=(1+n);
	if(n%2==0){
		cout << n/2 * temp << '\n';
	}
	else{
		temp/=2;
		cout << n*temp << '\n';
	}
}		


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

int main() {
  ll int n; 
  cin >> n;
  
  map<int, int> div;
  
  ll int dai = n;
  int diviser = 2;
  while(diviser < sqrt(dai)+1) {
//    cout << "n:" << n << ", diviser:" << diviser;
    if(n % diviser == 0) {
//      cout << ":true" << endl;
      ++div[diviser];
      n /= diviser;
    } else {
//      cout << ":false" << endl;
      ++diviser;
    }
    if(n == 1) break;
  }
  if(n != 1) ++div[n];
  
  int ans = 0;
  for(auto x : div) {
//    cout << "bunkai:" << x.first << ":" << x.second << endl;
    int num = 1;
    while(true) {
      if(x.second >= num) {
//        cout << x.first << ":" << num << endl;
        x.second -= num;
        ++ans;
        ++num;
//        cout << x.second << endl;
      } else break;
    }
  }
  
  cout << ans << endl;
    
  
  
  return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string.h>
using namespace std;

int main()
{
  int N ;
  cin >> N ;
  string str[N] ;
  for(int i = 0;i < N;i++)
  {
    cin >> str[i];
  }
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for(int i = 0;i < N;i++)
  {
    if(str[i] == "AC" )
    {
      AC++;
    }
    if(str[i] == "WA" )
    {
      WA++;
    }
     if(str[i] == "TLE" )
    {
      TLE++;
    }
       if(str[i] == "RE" )
    {
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}


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

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

    vector<double> pos(20);
    pos[0] = 1.0;
    for (int i = 1; i < 20; ++i)
        pos[i] = pos[i - 1] / 2;

    const double p = 1.0 / n;

    double ans = 0;

    for (int i = 1; i <= n; ++i)
    {
        int t = 0;
        while (i * (1 << t) < k)
            ++t;

        ans += p * pos[t];
    }
    printf("%.12lf\n", ans);
}

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

int main() {
  int n, y;
  cin >> n >> y;
  bool judge = true;
  bool flag = false;
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      if (i + j  <= n) {
        if (10000 * i + 5000 * j + 1000 * (n - i - j) == y ) {
          judge = false;
          cout << i << " " << j << " " << n - i - j << endl;
          flag = true;
          break;
        }
      }
    }
    if (flag) {
      break;
    }
  }
  if (judge) {
    cout << "-1 -1 -1" << endl;
  }
}

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

using namespace std;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	bool needToMoveThreeTimes[1001];
	memset(needToMoveThreeTimes, 0, sizeof(needToMoveThreeTimes));
	int N, m;
	cin >> N >> m;
	for (int i = 0; i < m; ++i)
	{
		int c, d;
		cin >> c >> d;
		for (int j = c; j < d; ++j)
		{
			needToMoveThreeTimes[j] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i)
	{
		if (needToMoveThreeTimes[i])
		{
			ans += 2;
		}
	}
	cout << ans + N + 1 << endl;
}

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

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N, D; cin >> N >> D;
    int len = 2*D+1;

    cout << (N-1)/len + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, K; cin >> N >> K;
	int h[100001], dp[100001];
	for (int i = 0; i < N; i++) cin >> h[i];
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		dp[i] = 2e9;
		for (int k = 1; k <= min(i, K); k++)
			dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]));
	}
	cout << dp[N - 1] << '\n';
	return 0;
}

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

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl

int main(){
	
	ios::sync_with_stdio(false);
	int N,M,K;
	cin>>N>>M>>K;
	
	bool ans = false;

	REP(i,N+1){
		REP(j,M+1){
			
			int black_p =  j * N  + i * M - (2 * j * i);
			if(K == black_p){
				ans = true;
				break;
			}
		}
	}

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

	
	return 0;
}


Measured memory_bytes: 256
k = int(input())

ans = 0
import math
for i in range(1, k + 1):
    for j in range(1, k + 1):
        x = math.gcd(i, j)
        for l in range(1, k + 1):
            g = math.gcd(x, l)
            ans += g
            
print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }


struct UnionFind { // UnionFindTree
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(-d[x] < -d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};


int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        uf.unite(a,b);
    }
    
    int q;
    cin >> q;
    rep(i,q) {
        int a, b;
        cin >> a >> b;
        if(uf.same(a,b))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}




int main() {
	int r, D, X; cin >> r >> D >> X;
	for (int i = 1; i <= 10; i++) {
		X = r * X - D;
		cout << X << endl;
	}


	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (S.at(i) != S.at(i - 1)) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

bool solve(const string &s, const string &a, const int i = 0) {
  if (i >= a.size()) return a == s;
  if (a[i] == 'A') {
    string n = (i > 0 ? a.substr(0, i) : "") + a.substr(i+1);
    if (solve(s, n, i)) return true;
  }
  return solve(s, a, i+1);
}

int main() {
  string s;
  cin>>s;
  string a = "AKIHABARA";
  bool ok = solve(s, a);
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner t = new Scanner(System.in);
        
        int a = t.nextInt();
        int b = t.nextInt();
        int k = t.nextInt();
        int i;
        int s = 0, menor;
        if (a<=b){
            menor = a;
        } else {
            menor = b;
        }
        for (i = menor; i >= 1; i--) {
            if (a % i == 0 && b % i == 0){
                s++;
            }
            if (s == k){
                System.out.println(i);
                break;
            }
        }
    }   
}

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

const int INF = 1001001001;
const ll mod = 1000000007;

int main(){
    int n; cin >> n;
    vector<pair<int, int>> blue(n), red(n);
    vector<bool> used(n, false);
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        red[i] = {b, a};
    }
    for(int i = 0; i < n; i++){
        int c, d; cin >> c >> d;
        blue[i] = {c, d};
    }
    sort(red.begin(), red.end());
    sort(blue.begin(), blue.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        int b_x = blue[i].first, b_y = blue[i].second;
        for(int j = n - 1; j >= 0; j--){
            int r_x = red[j].second, r_y = red[j].first;
            if(used[j]) continue;
            if(r_x >= b_x) continue;
            if(r_y < b_y){
                ans++;
                used[j] = true;
                break;
            }
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3632
function main(arg) {
    arg = arg.trim().split("\n")
    arg.shift()
    const MAX = arg.length
    
    var distinct = arg.filter(function(x, i, self){
        return self.indexOf(x) === i && i !== self.lastIndexOf(x);
    });
    
    if (distinct.length > 0) {
        console.log("No")
        return
    }
    var flag = true
    for (var i = 1; i< MAX;i++) {
        var text = arg[i]
        var last_text = arg[i - 1]
        if (last_text[last_text.length - 1] !== text[0]) {
            flag = false
            break;
        }
    }
    if (!flag) {
        console.log("No")
    } else {
        console.log("Yes")
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    const int MOD = 1e9 + 7;
    ll n, k;
    cin >> n >> k;

    ll ans = 1;
    for (int i = k; i <= n; i++) {
        ans = (ans + i * (n - i + 1) + 1) % MOD;
    }

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


Measured memory_bytes: 3600
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, i ,j;
	char c;
	int checked;
	int card[4][13] = { 0 };
	char s[4] = { 'S', 'H', 'C', 'D' };

	scanf("%d\n", &n);
	for (i = 0; i < n; i++) {
		scanf("%c %d\n", &c, &checked);
		for (j = 0; j < 4; j++) {
			if (s[j] == toupper(c)) {
				card[j][checked - 1] = 1;
			}
		}
	}

	//printf("\n\n");
	for (i = 0; i < 4; i++) {
		for (j = 1; j <=13; j++) {
			if (card[i][j-1] != 1) printf("%c %d\n", s[i], j);
		}
	}
	return 0;
}


Measured memory_bytes: 2096
<?php
const MOD = 10 ** 9 + 7;
list($n, $a, $b, $c) = ints();
init($n * 2);
// まず引き分けがないものとして期待値を計算
$sum = 0;
for ($i = 0; $i < $n; ++$i) {
    // Aがn回勝つ、Bはi回勝つ
    // pa = (n-1+i)Cn-1 * (a / 100)^n * (b/100)^i
    $pa = modProd(
        nCr2($n - 1 + $i, $n - 1),
        modPow(modDiv($a, $a + $b), $n),
        modPow(modDiv($b, $a + $b), $i)
    );
    // Bがn回勝つ、Aはi回勝つ
    $pb = modProd(
        nCr2($n - 1 + $i, $n - 1),
        modPow(modDiv($b, $a + $b), $n),
        modPow(modDiv($a, $a + $b), $i)
    );
    $sum = modAdd($sum, modProd($n + $i, modAdd($pa, $pb)));
}
// 引き分けを含んだ期待値を計算
$sum = modMul($sum, modDiv(100, 100 - $c));
echo $sum;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// SUM
function modSum(...$xs)
{
    $res = 0;
    foreach ($xs as $x) $res = modAdd($res, $x);
    return $res;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// PRODUCT
function modProd(...$xs)
{
    $res = 1;
    foreach ($xs as $x) $res = modMul($res, $x);
    return $res;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($n)
{
    global $fact, $ifact;
    $fact[0] = 1;
    for ($i = 1; $i <= $n; ++$i) $fact[$i] = modMul($fact[$i - 1], $i);
    $ifact[$n] = modDiv(1, $fact[$n]);
    for ($i = $n; $i >= 1; --$i)
        $ifact[$i - 1] = modMul($ifact[$i], $i);
}

// 順列（前処理）
function nPr2($n, $r)
{
    global $fact, $ifact;
    return modMul($fact[$n], $ifact[$n - $r]);
}

// 組み合わせ（前処理）
function nCr2($n, $r)
{
    global $fact, $ifact;
    return modMul(modMul($fact[$n], $ifact[$r]), $ifact[$n - $r]);
}


Measured memory_bytes: 34260
N = int(input())
n = input().split()
for i in range (N) :
    n[i] = int(n[i])

fl = True

for i in n :
    if (i % 2 == 0) :
        if (i % 3 != 0 and i % 5 != 0) :
            fl = False

print ('APPROVED' if fl else 'DENIED')

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


vector<int> G[100000];

int dfs(int cur){
	vector<int> v;
	rep(i,G[cur].size()) v.pb( dfs(G[cur][i]) );
	
	sort(all(v),greater<int>());

	int ret = 0;
	for(int i=1;i<v.size()+1;i++){
		ret = max(i+v[i-1],ret);
	}
	
	return max(ret,(int)G[cur].size());
}


int main(){
	int n;
	cin>>n;
	
	for(int i=1;i<n;i++){
		int a;
		cin>>a;
		a--;
		G[a].pb(i);
	}
	
	cout<<dfs(0)<<endl;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N, M, close[100001] = {0, }, a, b;
    map<int, vector<int> > mp;
    cin>>N>>M;
    REP(i,0,M) {
        cin>>a>>b;
        mp[a].push_back(b);
        ++close[b];
    }
    int ans=0;
    vector<int> open;
    REP(i,1,N+1) {
        if (close[i]>0) {
            for(int idx : open) {
                close[idx]--;
            }
            ans++;
            open.clear();
        }
        if(mp[i].size() > 0) {
            for(int idx : mp[i]) {
                open.push_back(idx);
            }
        }
    }
    cout<<ans;
    return 0;
}
// 1 2 3 4x5 6 7x8 9
// 1 8
// 2 7
// 3 5
// 4 6
// 7 9

Measured memory_bytes: 12032
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [n, m] <- readIntList
  s <- sum <$> readIntList
  print $ if n >= s then n - s else -1


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

int main() {
    int n;

    cin >> n;

    int sum = 0;
    for(int i = 1; i <= n; i++) {
        stringstream ss;
        ss << i;
        string s; ss >> s;
        if(s.size() % 2) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
const int MAXN=200005;
int n;
int d,k;
int tree[MAXN];
int ans=0;
struct node{
	int a,h;
}a[MAXN];

bool cmp(node x,node y){
	return x.a<y.a;
}

inline int lowbit(int x){
	return x&(-x);
}

inline void add(int x,int c){
	while (x<=n){
		tree[x]+=c;
		x+=lowbit(x);
	}
}

inline void change(int x,int y,int c){
	add(x,c);
	add(y+1,-c);
}

inline int query(int x){
	int ans=0;
	while (x>0){
		ans+=tree[x];
		x-=lowbit(x);
	}
	return ans;
}

inline int find(int x){
	int l=1,r=n;
	while (l<=r){
		int mid=l+r>>1;
		//cout<<l<<" "<<r<<" "<<mid<<endl;
		if (a[mid].a<=x) l=mid+1;
		else r=mid-1;
	}
	return r;
}
signed main()

{
	cin>>n>>d>>k;
	for (int i=1;i<=n;i++){
		cin>>a[i].a>>a[i].h;
		a[i].h=a[i].h/k+(a[i].h%k>0);
	}

	sort(a+1,a+1+n,cmp);
	
	for (int i=1;i<=n;i++){
		int tmp=query(i);
		if (tmp>=a[i].h) continue;
		a[i].h-=tmp;
		//cout<<a[i]<<" "<<a[i]+2*d<<' '<<a[i]+d<<endl;
		//cout<<i<<" "<<find(a[i]+2*d)<<endl;
		change(i,find(a[i].a+2*d),a[i].h);
		ans+=a[i].h;
	}

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

Measured memory_bytes: 4992
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<int> b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> b[i];
    }

    long long count = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] < b[i]) {
            count += (b[i] - a[i]) / 2;
        } else {
            count -= a[i] - b[i];
        }
    }

    std::cout << (count >= 0 ? "Yes" : "No") << std::endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

#ifdef DEBUG
#define dprintf      printf
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)    {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for((i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(1){}else
#define drep(i,n)    if(1){}else
#define dstop()      if(1){}else
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__);
#define array(T,id,n) T id[n]; rep(i,n)cin>>id[i];

//#define int long long;
#ifndef int
#define INF (0x7fffffff)
#else
#define INF (0x7fffffffffffffff)
#endif

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  char s[100]="Possible";
  char t[100]="Impossible";
  in(int,a,b);
  if(a%3==0)puts(s);
  else if(b%3==0)puts(s);
  else if((a+b)%3==0)puts(s);
  else puts(t);
  return 0;
}


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

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

    ll k = Y / 1000;
    if(k - N >= 0) {
        ll x, y, z;
        for(x = 0; x <= N; x++) {
            y = (k - N - 9*x) / 4;
            z = N - (x + y); 
            if((k - N - 9*x) % 4 == 0 && y >= 0 && z >= 0) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl; 
    
    return 0;
}

Measured memory_bytes: 3560
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;

namespace io {
#define File(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  const int SIZE = (1 << 21) + 1;
  char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;
  inline char getc () {return (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++);}
  inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}
  inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}
  template<class T>
  inline void read(T &x) {
    char ch; int f = 1;
    x = 0;
    while(isspace(ch = getc()));
    if(ch == '-') ch = getc(), f = -1;
    do x = x * 10 + ch - '0'; while(isdigit(ch = getc()));
    x *= f;
  }
  template<class T, class ...Args>
  inline void read(T &x, Args&... args) {read(x); read(args...);}
  template<class T>
  inline void write(T x) {
    static char stk[128];
    int top = 0;
    if(x == 0) {putc('0'); return;}
    if(x < 0) putc('-'), x = -x;
    while(x) stk[top++] = x % 10, x /= 10;
    while(top) putc(stk[--top] + '0');
  }
  template<class T, class ...Args>
  inline void write(T x, Args... args) {write(x); putc(' '); write(args...);}
  inline void space() {putc(' ');}
  inline void endl() {putc('\n');}
  struct _flush {~_flush() {flush();}} __flush;
};
using io::read; using io::write; using io::flush; using io::space; using io::endl; using io::getc; using io::putc;

const int M = 998244353;
inline int add(int x, int y) {return x+y>=M ? x+y-M : x+y;}
template<class ...Args> inline int add(int x, int y, Args... args) {return add(add(x, y), args...);}
inline int sub(int x, int y) {return x-y<0 ? x-y+M : x-y;}
inline int mul(int x, int y) {return 1LL * x * y % M;}
template<class ...Args> inline int mul(int x, int y, Args... args) {return mul(mul(x, y), args...);}
inline void inc(int &x, int y=1) {x += y; if(x >= M) x -= M;}
inline void dec(int &x, int y=1) {x -= y; if(x < 0) x += M;}
inline int power(int x, int y){
  int res = 1;
  for(; y; y>>=1, x = mul(x, x)) if(y & 1) res = mul(res, x);
  return res;
}
inline int inv(int x){return power(x, M - 2);}

const int N = 200005;
int l[N], r[N], s[N];

int main() {
  int n, k;
  read(n, k);
  --n;
  for (int i = 1; i <= k; ++i)
    read(l[i], r[i]);
  s[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= k; ++j) {
      int L = i - r[j], R = i - l[j];
      if (R < 0) continue;
      L = max(L, 0);
      if (L == 0) inc(s[i], s[R]);
      else inc(s[i], sub(s[R], s[L - 1]));
    }
    inc(s[i], s[i - 1]);
  }
  write(sub(s[n], s[n - 1]));
  return 0;
}

Measured memory_bytes: 3888
#include <iostream>
#include <vector>
#include <algorithm>
#include<stdio.h>
using namespace std;
typedef long long ll;
int main() {
    int A;
    int B;
    int C;
    cin >> A >> B >> C;
    int i_array[]={A,B,C};
    vector<int> v(i_array,i_array+sizeof(i_array));
    size_t n_count=std::count(v.begin(),v.end(),5);
    size_t n_count2=std::count(v.begin(),v.end(),7);
    if (n_count==2 && n_count2==1){
         printf("YES");
    }
    else{ printf("NO");
}
}


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

int solve(int[] a) {
  sort(a);

  int count = 0;
  count += (a[1] - a[0]) / 2;
  a[0] += (a[1] - a[0]) / 2 * 2;
  a[0] += a[2] - a[1];
  count += a[2] - a[1];
  a[1] += a[2] - a[1];

  if (a[0] == a[1] && a[1] == a[2]) {
    return count;
  }
  else {
    return count + 2;
  }
}

void main() {
  int[] a = readln.chomp.split.to!(int[]);

  writeln(solve(a));
}


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

int main(){
    string s; cin >> s;
    int g = 0, p = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'g'){
            g++;
        }else{
            p++;
        }
    }
    int ap = s.size() / 2;
    int ag = s.size() - ap;
    cout << min(g, ap) - min(p, ag) << endl;
}

Measured memory_bytes: 512
a,b=map(int,input().split())
ans=2019
for i in range(b-a+1):
  for j in range(b-a+1):
    hoge=a+i
    huga=a+j
    if(hoge<huga and huga<=b):
      ans=min((hoge*huga)%2019,ans)
      if(ans==0):
        print(0)
        exit()
print(ans)

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

int main() {
    int a, b;
    cin >> a >> b;
    if(a == b) {
        cout << "Draw\n";
    } else if( ( a > b && b != 1 ) || a == 1) {
        cout << "Alice\n";
    } else cout << "Bob\n";

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)

typedef long long Int;
typedef pair<Int,Int> P;

const Int MOD = 1000000007;


Int modpow(Int a, Int n) {
    Int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

const Int MAX = 100010;

Int fac[MAX], finv[MAX], inv[MAX];

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

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


int main() {

    COMinit();


    Int N, K;
    cin >> N >> K;
    vector<Int> A(N);
    rep(i,N) cin >> A[i];

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

    Int sumMAX = 0, sumMIN = 0;

    rep(i,N) {
        if (i < K - 1) continue;
        if (A[i] >= 0) {
            sumMAX = (sumMAX + (A[i] * COM(i,K-1)) % MOD) % MOD;
        }
        else {
            sumMAX = (sumMAX - (((-A[i]) * COM(i,K-1)) % MOD) + MOD) % MOD;
        }
    }

    rep(i,N) {
        if (i < K - 1) continue;
        if (A[i] >= 0) {
            sumMIN = (sumMIN + (A[N-1-i] * COM(i,K-1)) % MOD) % MOD;
        }
        else {
            sumMIN = (sumMIN - (((-A[N-1-i]) * COM(i,K-1)) % MOD) + MOD) % MOD;
        }
    }

    Int ans;
    ans = (sumMAX - sumMIN + MOD) % MOD;

    cout << ans << endl;

    return 0;
}


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

int main()
{
	string str;
  cin >> str;
  if(str == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define Int long long
Int dp[2005];int main() {Int N,i,j;for (i=0;i<1001;i++) for (j=i;j<1001;j++) dp[i+j]++;while (scanf("%lld",&N)!=EOF) {for (j=0,i=0;i<2001;i++) if (N-i>=i && N-i<2001) j+=((i!=N-i)?2:1)*(2*dp[i]-((i&1)?0:1))*(2*dp[N-i]-(((N-i)&1)?0:1));printf("%lld\n",j);} return 0;}

Measured memory_bytes: 1040