akhauriyash/Code-Regression huggingface dataset:
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

get_i_to_x_rbtree0(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 0, T2, T).

get_i_to_x_rbtree1(N, T) :-
    rb_empty(T2),
    get_i_to_x_rbtree(N, 1, T2, T).

get_i_to_x_rbtree(0, _, T, T).
get_i_to_x_rbtree(N, I, T2, T) :-
    get_number(X),
    rb_insert(T2, I, X, T3),    
    N2 is N - 1,
    I2 is I + 1,
    get_i_to_x_rbtree(N2, I2, T3, T).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f([X1,X2|Xs], T, U, S, Z) :- 
    X1 + 1 =:= X2, !, 
    rb_lookup(X1, V1, U),
    rb_lookup(X1, V2, T),
    S2 is S + V1 + V2,
    f([X2|Xs], T, U, S2, Z).
    
f([X|Xs], T, U, S, Z) :-
    rb_lookup(X, V, T),
    S2 is S + V,
    f(Xs, T, U, S2, Z).

f([], _, _, S, S).

main :-
    get_number(N),
    get_numbers(N, Xs),
    get_i_to_x_rbtree1(N, T),
    get_i_to_x_rbtree1(N-1, U),
    f(Xs, T, U, 0, Z),
    writeln(Z).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8276
<?php
  list($h,$w) = explode(" ", trim(fgets(STDIN)));
  $max_no = $h*$w-1;

  $masu = [];
  for($i=0; $i<$h; $i++){
    $p = str_split(trim(fgets(STDIN)));
    $masu = array_merge($masu, $p);
  }


  $ans = 0;
  for($i=0; $i<$h; $i++){
    for($j=0; $j<$w; $j++){
      $no = $i*$w+$j;
      $x = $masu[$no];
      if($x == '#'){
        continue;
      }
      $qe = new SplQueue();
      $qe->enqueue($no);
      $masu2 = [];
      $masu2[$no]=0;
      $max1 = 0;
      
      while($qe->count() > 0){
        $no = $qe->dequeue();
//        echo $no.PHP_EOL;
        for($k=0; $k<4; $k++){
          if($k==0){
            $right = $no - 1;
            if($right % $w > $no % $w){
              continue;
            }
          }else if($k==1){
            $right = $no + 1;
            if($right % $w < $no % $w){
              continue;
            }
          }else if($k==2){
            $right = $no - $w;
          }else if($k==3){
            $right = $no + $w;
          }
          
          if($right >= 0 && $right <= $max_no && $masu[$right]=='.'){
            if(isset($masu2[$right])){
              if($masu2[$right] > $masu2[$no]+1){
                $qe->enqueue($right);
//                echo ">".$right.PHP_EOL;
                $masu2[$right] = $masu2[$no]+1;
                $max1 = max($max1, $masu2[$no]+1);
              }
            }else{
              $qe->enqueue($right);
//                echo ">".$right.PHP_EOL;
              $masu2[$right] = $masu2[$no]+1;
              $max1 = max($max1, $masu2[$no]+1);
            }             
          }
        }
      }
      $ans = max($ans, $max1);
//      for($i=0; $i<=$max_no; $i++){
//        echo isset($masu2[$i]) ? $masu2[$i] : "-1";
//        echo " ";
//      }
//      echo $ans;
//      exit;
    }
  }
               
  echo $ans;

Measured memory_bytes: 4604
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val A = scanner.nextLong()
    val B = scanner.nextLong()
    val C = scanner.nextLong()
    val K = scanner.nextLong()
    val list = mutableListOf(A, B, C)
    val sortedList = list.sorted().toMutableList()
    //println(sortedList)//1,2,3
    sortedList[2] = Math.pow(2.0, K.toDouble()).toLong() * sortedList[2]
    println(sortedList.sum())
}

Measured memory_bytes: 34256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n,k;
    cin>>n>>k;
    vector<ll>x(n),y(n);
    vector<ll>xary,yary;
    for (int i = 0; i < n; i++)
    {
        cin>>x[i]>>y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
   sort(begin(xary),end(xary));
   sort(begin(yary),end(yary));
    ll S=1LL*(xary[n-1]-xary[0])*(yary[n-1]-yary[0]);
    vector<ll>min_S;
    for (int xi = 0; xi < n; xi++)
    {
        for (int xj = xi+1; xj < n; xj++)
        {
            for (int yi = 0; yi < n; yi++)
            {
                for (int yj = yi+1; yj < n; yj++)
                {
                    ll x_min=xary[xi];
                    ll x_max=xary[xj];
                    ll y_min=yary[yi];
                    ll y_max=yary[yj];
                    ll cnt=0;
                    for (int i = 0; i < n; i++)
                    {
                        if(x_min<=x[i] && x[i]<=x_max && y_min<=y[i] && y[i]<=y_max) cnt++;
                    }
                    if(cnt>=k) {
                        S=min(S,1LL*(x_max-x_min)*(y_max-y_min));
                       
                    }
                    
                }
                
            }
    
        }
        
    }
    cout<<S<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

typedef pair<string,int> mypair;

struct pair_sort {
  bool operator()(const  mypair& x, const mypair& y) const {
	return x.first < y.first || x.first ==  y.first && x.second < y.second;
  }
};


int main(void){

int pg;
string gk;
vector<mypair> sss;
	while(cin >> gk >> pg ){
		if( cin.eof() ) break;
		sss.push_back(mypair(gk,pg));
	}
	sort(sss.begin(),sss.end()); //,pair_sort());
	string odwd="zzz999";
	rep(i, sss.size()){
		if(sss[i].first != odwd){
			if(odwd != "zzz999") cout << endl;
			cout << sss[i].first << endl;
			cout << sss[i].second;
		}else{
			cout << " " << sss[i].second;
		}
		odwd = sss[i].first;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1236
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
	int n;
  cin>>n;
  vector<ll>v,vec;
  rep(i,0,n-1)
  {
    ll x;
    cin>>x;
    v.pb(x);
    vec.pb(x);
  }
  repd(i,n-2,0)
  {
    v[i]+=v[i+1];
    v[i]%=MOD;
  }
  ll ans=0;
  rep(i,0,n-2)
  {
    ll prod=(vec[i]*v[i+1])%MOD;
    ans+=prod;
    ans%=MOD;
  }
  cout<<ans;
	
	
}
	

  


Measured memory_bytes: 6652
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
const int INF=2147483647;
const int mod=1e9+7;
char s[300005];
int vis[300005]= {0};

typedef long long ll;
ll gcd(ll a, ll b)
{
    if(a < b)
    {
        ll temp;
        temp = a;
        a = b;
        b = temp;
    }
    while(a % b)
    {
        ll r = a % b;
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main()
{
    ll x,y;
    scanf("%lld%lld",&x,&y);
    if(x == y || y == 1 ||x %y == 0)
    {
        printf("-1\n");

    }
    else if(x < y)
    {
        printf("%lld\n",x);
    }
    else
    {
        long long cnt = gcd(x,y)*x -x;
        while(cnt % y ==0)
        {
            cnt += x;
        }
        printf("%lld\n",cnt);
    }

    return 0;
}


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

int H, W;
int A[90][90], B[90][90];
bool dp[90][90][30001];

int main() {
    cin >> H >> W;
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) cin >> A[i][j];
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) cin >> B[i][j];
    for (int i=0; i<H; i++) for (int j=0; j<W; j++) for (int k=0; k<=30000; k++) dp[i][j][k] = false;
    dp[0][0][A[0][0]-B[0][0]+15000] = true;
    dp[0][0][B[0][0]-A[0][0]+15000] = true;
    
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (i>0) {
                for (int k=0; k<=30000; k++) {
                    if (dp[i-1][j][k]) {
                        if (0<=k+A[i][j]-B[i][j] && k+A[i][j]-B[i][j]<=30000) dp[i][j][k+A[i][j]-B[i][j]] = true;
                        if (0<=k+B[i][j]-A[i][j] && k+B[i][j]-A[i][j]<=30000) dp[i][j][k+B[i][j]-A[i][j]] = true;
                    }
                }
            }
            if (j>0) {
                for (int k=0; k<=30000; k++) {
                    if (dp[i][j-1][k]) {
                        if (0<=k+A[i][j]-B[i][j] && k+A[i][j]-B[i][j]<=30000) dp[i][j][k+A[i][j]-B[i][j]] = true;
                        if (0<=k+B[i][j]-A[i][j] && k+B[i][j]-A[i][j]<=30000) dp[i][j][k+B[i][j]-A[i][j]] = true;
                    }
                }
            }
        }
    }
    
    int ans = 1000000;
    
    for (int i=0; i<=30000; i++) {
        if (dp[H-1][W-1][i]) {
            ans = min(ans, abs(i-15000));
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 211200
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
ll A, B, C, X, Y;

int main(){
	cin >> A >> B >> C >> X >> Y;

	ll ans = 1e10;;
	for(ll z=0; z<=max(X,Y); z++){
		ans = min(ans, 2*z*C + max(0LL, X-z)*A + max(0LL, Y-z)*B);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define LEN 10

typedef struct{
  char name[LEN];
  int time;
}process;

void enq(process);
process deq();
int isFull(void);
int isEmpty(void);

process queue[MAX];
int head = 0;
int tail = 0;

int main(){
  process in[MAX];
  int n, q, ans = 0;
  int i;

  scanf("%d %d", &n, &q);

  for(i=0;i<n;i++){
    scanf(" %s %d", in[i].name, &in[i].time);
    enq(in[i]);
  }

  /*for(i=0;i<n;i++){
    printf("%s %d\n", queue[i].name, queue[i].time);
    }*/

  while(isEmpty() != 1){
    if(queue[head].time <= q){
      ans += queue[head].time;
      printf("%s %d\n", queue[head].name, ans);
      deq();
    }
    else{
      queue[head].time -= q;
      ans += q;
      enq(deq());
    }
  }
    
  return 0;
}

void enq(process x){
  if(isFull() == 1){
    printf("queue overflow!\n");
    exit(1);
  }
  queue[tail] = x;
  tail++;
  if(tail == MAX) tail = 0;
}

process deq(){
  if(isEmpty() == 1){
    printf("queue underflow!\n");
    exit(1);
  }
  head++;
  if(head == MAX){
    head = 0;
    return queue[MAX-1];
  }
  else return queue[head-1];
}

int isFull(){
  if(head == (tail + 1) % MAX) return 1;
  else return 0;
}

int isEmpty(){
  if(head == tail) return 1;
  else return 0;
}



Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
int32_t main()
{
   fastio
   int n,l;
   cin>>n>>l;
   int sum=n*l+((n-1)*n)/2;
   int mine=INT_MAX;
   int ans;
   int temp=l;
   repre(i,1,n)
   {
     temp=l+i-1;
     int rem=sum-temp;
     if(abs(sum-rem)<mine)
     {
       mine=abs(sum-rem);
       ans=rem;
     }
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

/************************************************/

ll fun(ll n)
{
    ll cnt=0;
    for(ll i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(i*i==n)
                cnt++;
            else
                cnt+=2;
        }
    }
    return cnt;
}

void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    // for(ll i=1;i<n;i++)
    // {
    //     ans+=fun(i);
    // }
    // cout<<ans;
    for(ll i=1;i<n;i++)
        ans+=((n-1)/i);
    cout<<ans;
}

int main()
{
    fast();
    int t;
    t=1;
    while(t--)
        solve();
   // time();
}

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

    int main() {
         long long  n , a , b;
        cin >>  a >> b >> n;
        if(a == 0 && b == 0)

        {
            cout <<a <<" " << b;
                return 0;
        }
        long long  a1 = (a - n);
        if(a1 < 0ll)
            a1 = 0ll;
        if(n - a < 0ll)
            cout << a1 << " " << b;
        else
       {

        b = b - (n - a);
        if(b < 0)
            b = 0;
        cout << a1 << " " << b;
       }

        return 0;
    }

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

int main(){
    int a,b;
    cin >> a>> b;
    int m;
    m = max(a+b,a-b);
    m = max(m,a*b);
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
vector<pair<int64_t,int64_t>>A(N);
  for(int64_t i=0;i<N;i++){
  int64_t a; cin>>a;
    pair<int64_t,int64_t>p(a,i);
    A.at(i)=p;
  
  }sort(A.begin(),A.end());
  int64_t dp[N][N];
  for(int64_t j=0;j<N;j++)
    dp[0][j]=A[0].first*abs(j-A[0].second);
  for(int64_t i=1;i<N;i++){
  for(int64_t j=0;j<N-i;j++){
  dp[i][j]=
 max(dp[i-1][j]+A[i].first*abs(A[i].second-i-j),A[i].first*abs(A[i].second-j)+dp[i-1][j+1]);
  
  }
  
  }cout<<dp[N-1][0]<<endl;
   return 0;
}

Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, T, A;
  cin >> N >> T >> A;
  float diff = INF;
  ll ans = INF;

  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    float temp = T - h * 0.006;
    if (abs(A - temp) < diff) {
      diff = abs(A - temp);
      ans = i;
    }
  }
  cout << ans + 1 << endl;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

// 1-indexed
template <class T, class Op, T unit>
struct Bit {
  int n;
  vector<T> dat;
  Op op;
  Bit(int n, Op op = Op()) : n(n), dat(n + 1, unit), op(op) {
  }
  Bit(const vector<T> &arr, Op op = Op()) : n(arr.size()), dat(arr.size() + 1), op(op) {
    copy(arr.begin(), arr.end(), dat.begin() + 1);
    for(int i=1; i<n; i++) {
      dat[i + (i & -i)] = op(dat[i + (i & -i)], dat[i]);
    }
  }
  void operate(int k, T a) {
    while(k <= n) {
      dat[k] = op(dat[k], a);
      k += k & -k;
    }
  }
  T accum(int k) {
    T sum = unit;
    while(k > 0) {
      sum = op(sum, dat[k]);
      k -= k & -k;
    }
    return sum;
  }
};

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll k;
  cin >> k;
  VL as(n);
  FOR(a,as) {
    cin >> a;
  }
  VL bs(n+1);
  bs[0] = 0;
  REP(i,0,n) {
    bs[i+1] = bs[i] + as[i] - k;
  }
  VL b_sort = bs;
  sort(b_sort.begin(), b_sort.end());
  Bit<ll, plus<ll>, 0> bit(n+1);
  ll ans = 0;
  FOR(b,bs) {
    int c = lower_bound(b_sort.begin(), b_sort.end(), b) - b_sort.begin() + 1;
    ans += bit.accum(c);
    bit.operate(c, 1);
  }
  cout << ans << endl;

  return 0;
}


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

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

    int i=0;
    int l=0;
    int a[n];
    
    while(std::cin >> l){
        a[i] = l;
        i++; 
        if(i>=n){
            break;
        }
    }

    int counter=0;
    std::sort(a,a+n);

    for(int j=0; j<n-2; j++){
        for(int k=j+1; k<n-1; k++){
            for(int m=k+1; m<n; m++){
                if(a[m]<a[j]+a[k]){
                    counter += 1;
                }
            }
        }
    }
    std::cout << counter <<std::endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int D, G;
	cin >> D >> G;
	int p[D], c[D];
	rep(i, D) {
		cin >> p[i] >> c[i];
	}
	int ans = 1000;
	rep(bit, 1 << D) {
		int d[D];
		rep(i, D) d[i] = p[i];
		int sum = 0;
		int cnt = 0;
		rep(i, D) {
			if (bit & (1 << i)) {
				sum += p[i] * (i + 1) * 100 + c[i];
				cnt += p[i];
				d[i] = 0;
			}
		}
		//cout << sum << " " << cnt << endl;
		if (sum >= G) {
			//cout << "*" << sum << " " << cnt << endl;
			ans = min(ans, cnt);
			continue;
		}
		int k = D;
		int f = true;
		while (true) {
			//cout << "->" << k << " " << d[k - 1] << endl;
			while (d[k - 1] <= 0 && f) k--;
			if (d[k - 1] <= 0 && f == false) break;
			f = false;
			sum += 100 * k;
			d[k - 1]--;
			cnt++;
			if (sum >= G) {
				//cout << "**" << sum << " " << cnt << endl;
				ans = min(ans, cnt);
				break;
			}
		}

	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
int a[26];
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
    
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int a , b , c , d;
	cin>>a>>b>>c>>d;
	long long int max1= max(a*c,a*d);
	long long int max2= max(b*c,b*d);
	cout<< max(max1,max2);
}

Measured memory_bytes: 3664
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	llint h,i,j,L;cin>>L;
	//0
	//0,1
	//0,1,2,3
	int kaz=0;
	for(i=0;i<18;i++){if(L&(1<<i)){kaz++;}}
	kaz+= L>>18;
	cout<<"20 "<<kaz+36<<endl;
	for(i=0;i<18;i++){
		cout<<i+1<<" "<<i+2<<" 0\n";
		cout<<i+1<<" "<<i+2<<" "<<(1<<i)<<endl;
	}
	for(i=0;i<18;i++){
		if(L&(1<<i)){
			cout<<i+1<<" 20 "<<(L&((1<<i)-1))<<endl;
		}
	}
	int num= L>>18;
	for(i=1;i<=num;i++){
		cout<<"19 20 "<<(i-1)*(1<<18)+(L&((1<<18)-1))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1016
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        if(str.startsWith("YAKI")){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }


    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> vec(n,0);
    rep(i,n){
        cin >> vec[i];
    }
    vector<int> ans;
    int nh=0,nw=0;
    rep(i,n){
        rep(j,vec[i]){
            ans.pb(i+1);
        }
    }
    vector<vector<int> > res(h,vector<int>(w,0));
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            if(i % 2 == 0){
                res[i][j] = ans[cnt];
            }else{
                res[i][w-1-j] = ans[cnt];
            }
            cnt++;
        }
    }
    rep(i,h){
        rep(j,w-1){
            cout << res[i][j] << " ";
        }
        cout << res[i][w-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 512
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

struct UnionFind
{
    vector<lint> data;
    UnionFind() {}

    // initialize
    UnionFind(lint size) : data(size, -1) {}

    void unite_set(lint x, lint y){
        x = root(x);
        y = root(y);
        bool is_unite = (x != y);
        
        if (is_unite){
            if (data[y] < data[x]){
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
    }

    bool is_same(lint x, lint y){
        return root(x) == root(y);
    }

    lint root(lint x){
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    lint size(lint x){
        return -data[root(x)];
    }
};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    lint n, m, a, b;
    lint ans;
    lint p, q;
    cin >> n >> m;
    struct UnionFind d(n);
    vector<pair<lint, lint>> query(m);
    for (lint i=1; i<=m; ++i){
        cin >> a >> b;
        a--;
        b--;
        query[m - i] = make_pair(a, b);
    }
    ans = (n * (n - 1)) / 2;
    vector<lint> answer(m);
    for (lint i=0; i<m; ++i){
        answer[m - i - 1] = ans;
        p = d.size(query[i].fst);
        q = d.size(query[i].snd);
        // cout << p << " " << q << endl;
        if(!d.is_same(query[i].fst, query[i].snd)){
            ans -= (p + q) * (p + q - 1) / 2 - p * (p - 1) / 2 - q * (q - 1) / 2;
        }
        d.unite_set(query[i].fst, query[i].snd);
    }
    for (lint i=0; i<m; ++i){
        if(answer[i] < 0){
            answer[i] = 0;
        }
        cout << answer[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4480
def solve():
    N = int(input())
    happiness = [[0] * 3 for i in range(N)]
    for i in range(N):
        tmpa, tmpb, tmpc = map(int, input().split())
        happiness[i][0] = tmpa
        happiness[i][1] = tmpb
        happiness[i][2] = tmpc

    dp = [[0] * 3 for i in range(N+1)]

    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][k] = max(dp[i][j] + happiness[i][k], dp[i+1][k])

    print(max(dp[-1][0], dp[-1][1], dp[-1][2]))
            

if __name__ == '__main__':
    solve()


Measured memory_bytes: 70764
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int turn = 0;
    while (a > 0 && c > 0) {
        if (!turn) {
            c -= b;
        }
        else {
            a -= d;
        }
        turn = 1-turn;
    }
    if (a <= 0) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 3648
import numpy as np

A = np.array([[1, 0, 0, 1, 0, 0], 
              [1, 0, 0, 0, 1, 0],
              [1, 0, 0, 0, 0, 1],
              [0, 1, 0, 1, 0, 0],
              [0, 1, 0, 0, 1, 0],
              [0, 1, 0, 0, 0, 1],
              [0, 0, 1, 1, 0, 0],
              [0, 0, 1, 0, 1, 0],
              [0, 0, 1, 0, 0, 1]])

b = np.array([], int)
for l in range(3):
    buf= list(map(int, input().strip().split()))
    b= np.concatenate((b, buf), axis=None)

b = np.reshape(b, (9,1))
Ab = np.concatenate((A, b), axis=1)

rA  = np.linalg.matrix_rank(A)
rAb = np.linalg.matrix_rank(Ab)

if rA==rAb:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15568
x,y = map(int,input().split())
mod = 10**9+7

if (x+y)%3 != 0:
    print(0)
    exit()

p = (x+y)//3
if min(x,y) < p:
    print(0)
    exit()

fact = [1]
fact_inv = [1]
for i in range(10**6+4):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

x = min(x,y)

print(mod_comb_k(p,x-p,mod))



Measured memory_bytes: 108156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) ll(i.size())
#define FOR(i, j, k, in) for (ll i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (ll i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll MAXN = 

ll k,n;
/********** Good Luck :) **********/
int main()
{
    IOS();
    cin >> n >> k;

    cout << (k == 1 ? 0 : n-k) << endl;
    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);
$total = 0;
for ($i = 9; $i <= $n; $i =$i+ 2) {
    $cnt = 0;
    for ($j = 1; $j <= $n; $j++) {
        if ($i % $j == 0) {
            $cnt ++;
        }
        if ($cnt > 8) {
            break;
        }
    }
    if ($cnt == 8) {
        $total++;
    }
}
echo $total;

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b - 1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    int N, A, B, C, cnt = 0;
    string S;
    cin >> S;
    bool flag = 1;
    for(int i =0; i < 3; i++){
        if(S[i] == S[i+1]){
            cout << "Bad\n";
            return 0;
        }
    }
    cout << "Good\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;


int main(){
string s;
    int a=1000;
    int flag = 0;
cin >> s;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'C'){
            a = i;
            break;
        }
            
    }
    if(a != 1000){
    for(int j=a;j<s.size();j++){
        if(s[j] == 'F'){
            cout <<"Yes"<<endl;
            flag = 1;
            break;
        }
    }
    }
    
    if (flag ==0)
        cout <<"No"<<endl;

   
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,M;
char s[110][110];
int num[50];

string solve(){
	if(N%2==0&&M%2==0){
		REP(i,26){
			if(num[i]%4!=0){
				return "No";
			}
		}
		return "Yes";
	}
	if(N%2==1&&M%2==1){
		int C[5]={};
		REP(i,26){
			C[num[i]%4]++;
		}
		if(C[3]>0){
			return "No";
		}
		if(C[1]!=1){
			return "No";
		}
		if(C[2]>(N-1)/2+(M-1)/2){
			return "No";
		}
		return "Yes";
	}
	if(M%2==1){
		swap(N,M);
	}
	int C[5]={};
	REP(i,26){
		C[num[i]%4]++;
	}
	if(C[1]>0||C[3]>0){
		return "No";
	}
	if(C[2]>M/2){
		return "No";
	}
	return "Yes";
}

signed main(){
	cin>>N>>M;
	REP(i,N){
		cin>>s[i];
	}
	REP(i,N){
		REP(j,M){
			num[s[i][j]-'a']++;
		}
	}
	cout<<solve()<<endl;
	return 0;
}


Measured memory_bytes: 256
def output(arr,s)
arr.each{|obj|
     printf("%s %d\n",s,obj)
}
end

arrs=Array[1,2,3,4,5,6,7,8,9,10,11,12,13]
arrh=Array.new(arrs)
arrc=Array.new(arrs)
arrd=Array.new(arrs)

n=gets.to_i
for i in 1..n do
s,m=gets.split(' ')
m=m.to_i
case s
when 'S' then
     arrs.delete(m)
when 'H' then
     arrh.delete(m)
when 'C' then
     arrc.delete(m)
when 'D' then
     arrd.delete(m)
end
end

output(arrs,'S')
output(arrh,'H')
output(arrc,'C')
output(arrd,'D')

Measured memory_bytes: 8588
n = input()
t = n[len(n) - 1]
if t == '3':
  print('bon')
elif t == '0' or  t == '1' or t == '6' or t == '8':
  print('pon')
elif t == '2' or t == '4' or t == '5' or t == '7' or t == '9':
  print('hon')

Measured memory_bytes: 8988
#include<cstdio>

using namespace std;

const int N=200020;
typedef long long ll;
ll s[N];
ll x;
int n, k;

ll num = 0;        //ÄæÐò¶Ô¸öÊý
void mergg(ll ar[],int low,int mid,int high)
{
    ll* b = new ll[high + 1];           //b[] ¸´ÖÆ ar[]
    for (int i = low;i <= high;++i)
    {
        b[i] = ar[i];
    }
    int i = low,j = mid + 1,k = low;
    while (i <= mid&&j <= high)
    {
        if (b[i] <= b[j])
        {
            ar[k++] = b[i++];
        }
        else
        {
            ar[k++] = b[j++];
            num += (ll)(mid - i + 1);       //·¢ÉúÄæÐò£¬´ËÊ±ÓÉÓÚ
            //a[i..m]ÊÇÒÑ¾­ÓÐÐòÁË£¬ÄÇÃ´a[i+1], a[i+2], ... a[m]¶¼ÊÇ´óÓÚa[j]µÄ£¬
            //¶¼¿ÉÒÔºÍa[j]×é³ÉÄæÐò¶Ô£¬Òò´Ënumber += m - i + 1
        }
    }
    while (i <= mid){ ar[k++] = b[i++]; }     //ÕâÁ½ÖÖÇé¿öÖ»»á·¢ÉúÒ»ÖÖ
    while (j <= high){ ar[k++] = b[j++]; }    //
    delete []b;
}
void merge_sort(ll ar[],int low,int high)  //¶þÂ·¹é²¢ÅÅÐò
{
    if (low < high)
    {
        int mid = low + (high - low)/2;
        merge_sort(ar,low,mid);
        merge_sort(ar,mid + 1,high);
        mergg(ar,low,mid,high);
    }
}

int main()
{
    int n;
    ll k, x;
    scanf("%d%lld", &n, &k);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &x);
        s[i] = s[i - 1] + x - k;
    }
    //for (int i = 1; i <= n; i++)
    //    printf("%d ", s[i]);
    merge_sort(s, 0, n);
    printf("%lld\n", ((ll)n * (ll)(n + 1) >> 1) - num);
    return 0;
}

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

int main() {
    long long n,ans = 0;
    cin >> n;
    vector<long long> a(n,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end(),greater<int>());
    vector<long long> b;
    for(int i = 0;i < n;i++){
        if(a[i-1] == a[i]){
            b.push_back(a[i]);
            i++;
        }
        if(b.size() == 2)break;
    }
    if(b.size() < 2)ans = 0;
    else ans = b[0]*b[1];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int> (C));
    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            cin >> D[i][j];
        }
    }

    int tmp;
    vector<vector<int>> c(3);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cin >> tmp;
            tmp--;
            c[(i+j) % 3].push_back(tmp);
        }
    }

    vector<vector<int>> cost(3, vector<int> (C));
    int S;
    for (int i = 0; i < 3; i++) {
        S = c[i].size();
        for (int j = 0; j < C; j++) {
            tmp = 0;
            for (int k = 0; k < S; k++) {
                tmp += D[c[i][k]][j];
            }
            cost[i][j] = tmp;
        }
    }

    int ans = inINF;

    for (int i = 0; i < C; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < C; k++) {
                if(i == j || j == k || k == i){
                    continue;
                }
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
            }
        }
    }

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

}


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

#define REP( i, n )     for( int (i) = 0; (i) < (n); (i)++ )
#define ALL( a )        (a).begin(), (a).end()

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

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int gcd( int a, int b ){
    if( b == 0 ){
        return a;
    }else{
        return gcd( b, a % b );
    }
}

int main(){
    int N, X; cin >> N >> X;
    vector<int> xd( N );
    REP( i, N ){
        int x; cin >> x;
        xd[i] = abs( x - X );
    }

    REP( i, N - 1 ){
        xd[i + 1] = gcd( xd[i], xd[i + 1] );

    }

    cout << xd[N - 1] << endl;
}


Measured memory_bytes: 640
import math
s = list(input())
kaha = math.ceil(len(s) / 2)
t = "10" * kaha
t1 = list(t)
n = 0
for i in range(len(s)):
	if(s[i]!=t1[i]):
		n = n + 1
if(n >= kaha):
	n= len(s)-n
print(n)

Measured memory_bytes: 4648
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int a[110];
int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	int n;
	cin>>n;
	int mn=999,mx=0;
	for(int i=1; i<=n; ++i) {
		int t;
		cin>>t;
		a[t]++;
		mn=min(mn,t);
		mx=max(mx,t);
	}
	if (mn<(mx+1)/2) {
		puts("Impossible");
		return 0;
	}
	if (a[mn]>(mx%2==0?1:2)) {
		puts("Impossible");
		return 0;
	}
	for(int i=mn; i<=mx; ++i) {
		if (a[i]==0) {
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	return 0;
}

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

#define REP(i, N) for(int i = 0; i < (int)(N); i++)
bool dp[32][1 << 12];

int main() {
	for(int N, M; cin >> N >> M, (N || M); ) {
		string str;
		string word[12];
		REP(i, N) cin >> word[i];
		REP(i, M) {
			string s;
			cin >> s;
			str += s;
		}
		int len = str.size();

		memset(dp, 0, sizeof(dp));
		REP(j, 32) dp[j][0] = true;
		
		int mask = (1 << N) - 1;
		int sum = 0;
		REP(pos, len + 1) {
			int j = pos & 31;
			REP(i, N) if( word[i] == str.substr(pos, word[i].size()) ) {
				int am = (pos + word[i].size()) & 31;
				REP(state, mask) if( (state & (1 << i) ) == 0){
					dp[am][state | (1 << i)] |= dp[j][state];
				}
			}
			sum += dp[j][mask];
			for(int state = 1; state < 1 << N; state++)
				dp[j][state] = 0; 
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 1068
fn main() {
    let n = read::<usize>();
    let mut v = read_vec::<usize>();
    v.sort();
    let mut ret = v[0] as f64;
    for i in 1..n {
        let tmp = (ret + v[i] as f64) / 2.0;
        ret = tmp;
    }
    println!("{}", ret);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352