akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable inf = 10^^9;

void main() {
    int N, M, R;
    int[] r;

    scan(N, M, R);
    r = readln.split.to!(int[]);
    r[] -= 1;

    int[][] c = new int[][](N, N);
    fillAll(c, inf);
    foreach (i ; 0 .. N) c[i][i] = 0;

    foreach (i ; 0 .. M) {
        int ai, bi, ci;
        scan(ai, bi, ci);
        ai--; bi--;
        c[ai][bi] = ci;
        c[bi][ai] = ci;
    }

    foreach (k ; 0 .. N) {
        foreach (i ; 0 .. N) {
            foreach (j ; 0 .. N) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    debug {
        writefln("%(%(%s %)\n%)", c);
    }

    int ans = 10^^9;

    foreach (rs ; r.permutations) {
        debug {
            writeln(rs);
        }
        int tmp;
        foreach (i ; 0 .. R - 1) {
            tmp += c[rs[i]][rs[i + 1]];
        }

        ans = min(ans, tmp);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;





int main() {
  int a,b;
  char p;
  cin>>a>>p>>b;
  if(p=='+') cout<<a+b;
  else cout<<a-b;
  cout<<endl;

  return 0;
}

Measured memory_bytes: 256
let change a = 
	let rec change a n = 
    	if a land 1 == 0 then change (a lsr 1) (n + 1) else n
    in change a 0
let calc n = 
	let rec calc n ans = 
    	if n = 0 then print_int ans
        else calc (n - 1) (ans + Scanf.scanf " %d" change)
    in calc n 0
let main = Scanf.scanf "%d" calc

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a,b,c,d,e,k;
int main(void){
    cin>>a>>b>>c>>d>>e>>k;
    if(e-a>k){
        cout<<":("<<endl;
    }else{
        cout<<"Yay!"<<endl;
    }
    
}


Measured memory_bytes: 3504
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ll N, x, i;
	cin >> N >> x;
	ll a[N];
	for (i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	ll sum = 0;
	ll cnt = 0;
	for (i = 0; i < N; i++) {
		sum += a[i];
		if (sum == x) {
			cnt++;
			break;
		}
		else if(sum > x || i==N-1){
			break;
		}
		cnt++;
	}

	cout << cnt <<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int K=stdIn.nextInt();
		int X=stdIn.nextInt();
		if(K*500>=X)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#include <random>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pll pair<ll,ll>
#define ld double
#define pld pair<ld,ld>
#define pii pair<int,int>
#define sqr(a) ((a)*(a))
#define all(v) v.begin(),v.end()

using namespace std;
//using namespace __gnu_pbds;

ll MOD = 998244353;
const ll INF = 1e18;
const ld E = 1e-18;
const ld PI=acos(-1);
mt19937_64 rnd(time(0));
ll p1 = 31, p2 = 37, p3 = 7, p4 = rnd() % 100 + 1, md1 = MOD, md2 = 998244353, md3 = 998244357, md4 = rnd() % 1000000000;

//using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

ll n, m, T;
vector<ll> c[100001];
bool tt[100001];
vector<ll> v;

ll binpow(ll h, ll r, ll md = MOD)
{
    ll l = 1;
    while (r)
    {
        if (r & 1) l *= h;
        h *= h;
        //h %= md;
        r /= 2;
    }
    return l;
}

ll gcd(ll x, ll y)
{
    if (x < y) swap(x, y);
    while (x && y)
    {
        x %= y;
        swap(x, y);
    }
    return x + y;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen("capitals.in","r",stdin);
    //freopen("capitals.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    ll ans=0;
    for (int i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        ans+=(i&1 && x&1);
    }
    cout << ans;
    return 0;
}

/*
3
4 2
1 1
1 0
3 2
2 2

3 1
1 1
1 0
3 2

3 2
1 1
1 0
3 2
*/


Measured memory_bytes: 5988
#include<stdio.h>
int main(){
	int H,W;
	for(int i=0;i<300;i++){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				if(i%2==0){
					if(j%2!=0)printf(".");
					else printf("#");
				}
				else{
					if(j%2==0){
						printf(".");
					}
					else printf("#");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2616
/* author   : mpily :-()
title : Competing.cpp
time :Sun Oct 27 15:03:30 2019

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	unordered_map<int,int>umap;
	for(int i = 1; i < 10; i++){
		for(int j = 1; j < 10; j++){
			umap[i*j]+=1;
		}
	}
	int n;
	cin>>n;
	if(umap[n])cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] B = new int[N];
        int[] A = new int[N];
        for(int i = 0; i < N-1; i++) {
            B[i] = scanner.nextInt();
        }
        int ans = 0;
        ans = A[0] = B[0];
        for(int i = 1; i < N-1; i++) {
            ans += A[i] = Math.min(B[i], B[i-1]);
        }
        ans += A[N-1] = B[N-2];

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
ll dp[100001];
int main() {
    ll n,m;
    cin>>n>>m;
    vector<ll> bm(m);
    rep(i,m){
        cin>>bm[i];
        dp[bm[i]]=INF;
    }
    dp[0]=1;
    for(int i=0;i<n;i++){
        if(dp[i]!=INF){
            if(dp[i+1]!=INF){
                dp[i+1]+=dp[i];
                dp[i+1]%=MOD;
            }
            if(dp[i+2]!=INF){
                dp[i+2]+=dp[i];
                dp[i+1]%=MOD;
            }
        }
    }
//    rep(i,n){
//        cout<<dp[i]<<endl;
//    }
cout<<dp[n]<<endl;



    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	int a, b;

	a = N / 10;
	b = N % 1000;

	if (a%111==0 || b%111==0)
	{

		cout << "Yes" << endl;

	}
	else {

		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1e9 + 7;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*ll fact_[200000];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1;
		for (int i = 1; i < 200000; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
		}
	}
	if (x < y) return 0;
	return mod_pow(fact_[x], mod, mod) *
		mod_pow(fact_[x - y], mod - 2, mod) % mod *
		mod_pow(fact_[y], mod - 2, mod) % mod;
}//xCy*/
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
signed main() {
	cin >> n;
	if (n % 2 == 0) cout << 0.5 << endl;
	else printf("%.20LF\n", (ld)(n - (n / 2)) / n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using lb=long double;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll loop;
ll start;
ll last;
vll a;
ll dist[220000];

void f(ll now){
 ll next=a[now];
  if(dist[next]==-1){
    dist[next]=dist[now]+1;
    f(next);
  }
  else{
    start=dist[next];
    last=dist[now];
    loop=dist[now]-dist[next]+1;
  }
}

int main(){cout<<fixed<<setprecision(20);
		   ll n,k;
           cin>>n>>k;
           a.resize(n);
           rep(i,0,n){
             cin>>a[i];
             a[i]--;
           }
           rep(i,0,n)dist[i]=-1;
           dist[0]=0;
           f(0);
           if(last>=k){
            rep(i,0,n){
             if(dist[i]==k){
              cout<<i+1<<endl;
               return 0;
             }
            }
           }
           else{
            // cout<<start<<" "<<loop<<" "<<last<<endl;
             k-=start-1;
             k%=loop;
             k=(k+loop-1)%loop;
             //cout<<k<<endl;
             k+=start;
             rep(i,0,n){
              if(dist[i]==k){
               cout<<i+1<<endl;
                return 0;
              }
             }
           }
}

Measured memory_bytes: 6384
#include <iostream>
#include <cmath>
int main() {
  int n, t, a, h, i, r=0;
  double m=1001001;
  std::cin>>n>>t>>a;
  for(i=1;i!=n+1;++i) {
    std::cin>>h;
    if(std::fabs(a-t+0.006*h)<m) {
      m = std::fabs(a-t+0.006*h);
      r = i;
    }
  }
  std::cout<<r<<"\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> a(n);
    for(Int i=0;i<n;i++) cin>>a[i];
    Int s=0;
    for(Int i=0;i<n;i++) s+=a[i];
    Int cnt=0;
    for(Int i=0;i<n;i++){
      if(a[i]*n<=s) cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}



Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100010,MOD=1000000007;
int x[MAXN],c[2*MAXN];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
		c[x[i]]++;
	}
	bool nemoguce=false;
	if(n%2==0){
		for(int i=1;i<=n;i+=2){
			if(c[i]!=2){
				nemoguce=true;
				break;
			}
		}	
	}
	if(n%2==1){
		if(c[0]>1)	nemoguce=true;
		if(!nemoguce){
			for(int i=2;i<=n;i+=2){
				if(c[i]!=2){
					nemoguce=true;
					break;
				}
			}	
		}
	}
	long long int r;
	if(nemoguce) r=0;
	else{
		r=1;
		for(int i=0;i<n/2;i++){
			r*=2;
			r%=MOD;
		}
	}
	cout<<r;
	return 0;
}

Measured memory_bytes: 1024
import java.lang.StringBuilder

fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val cnt = mutableMapOf<String,Int>()
    var maxCount = 0
    for(i in (0 until itemCount)) {
        val s = readLine()!!
        if(cnt.containsKey(s)) {
            cnt[s] = cnt[s]!! + 1
        } else {
            cnt[s] = 1
        }
        maxCount = Math.max(maxCount, cnt[s]!!)
    }
    val ans = StringBuilder()
    cnt.filter { it.value == maxCount }.keys.sorted().forEach { ans.appendln(it) }
    print(ans.toString())

}


Measured memory_bytes: 105900
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n;
int main(){
	n=read();
	printf("%d\n",180*(n-2));
	return 0;
}



Measured memory_bytes: 3756
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#ifndef LOCAL
#define cerr if(0)cout
#endif
typedef long long ll;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it, len;
	fastio() {it=len=0;}
	inline char get()
	{
		if (it<len) return s[it++]; it=0;
		len=fread(s, 1, 100000, stdin);
		if (len==0) return EOF; else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while (c==' '||c=='\n') c=get();
		if (it>0) it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0; bool ng=0; char c; c=_buff.get();
	while (c!='-'&&(c<'0'||c>'9')) c=_buff.get();
	if (c=='-') ng=1, c=_buff.get();
	while (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();
	return ng?-r:r;
}
template <class T> inline void putnum(T x)
{
	if (x<0) putchar('-'), x=-x;
	register short a[20]={}, sz=0;
	while (x) a[sz++]=x%10, x/=10;
	if(sz==0) putchar('0');
	for (int i=sz-1; i>=0; i--) putchar('0'+a[i]);
}
inline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}
ll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
const int maxn = 1000111;
ll n, fac[maxn], ifac[maxn], inv[maxn];
ll C(int x, int y) {return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}
int main()
{
	cin>>n;
	if (n==2)
	{
		puts("1");
		return 0;
	}
	fac[0] = 1;
	for (int i=1; i<=n; i++) fac[i] = fac[i-1]*i%mod;
	inv[1] = 1;
	for (int i=2; i<=n; i++) inv[i] = mod-1ll*(mod/i)*inv[mod%i]%mod;
	ifac[0] = 1;
	for (int i=1; i<=n; i++) ifac[i] = ifac[i-1]*inv[i]%mod;
	ll ans = fac[n-1]*(n-1);
	for (int i=1; i+1<n; i++)
	{
		if (i*2<n) continue;
		ans += -C(i-1, n-2-(i-1))*fac[i]%mod*fac[n-1-i]%mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}


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

int main()
{
  int X, N;

  cin >> X >> N;

  vector<int> p(N);

  for (int i = 0; i < N; i++)
  {
    cin >> p.at(i);
  }

  int sub = 10000;
  int ans;
  int flag = true;

  for (int i = 0; i <= 101; i++)
  {
    for (int j = 0; j < N; j++)
    {
      if (i == p.at(j))
      {
        flag = false;
      }
    }

    if (flag)
    {
      if (sub > abs(X - i))
      {
        sub = abs(X - i);
        ans = i;
      }
    }
    flag = true;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int a[n];
  int max=0;
  int max_=0;
  for (int i=0;i<n;i++) {
    cin >> a[i];
    if (a[i]>=max){
      max_=max;
      max=a[i];
    }else if(a[i]>=max_){
      max_=a[i];
    }
  }
  for (int i=0;i<n;i++){
    if (a[i]==max && a[i]==max_){
      cout << a[i] << endl;
    } else if (a[i]==max){
      cout << max_ << endl;
    } else {
      cout << max << endl;
    }
  }
}


Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)

int main(){
    int n, m;
    while(cin >>n >>m && n){
        int anst = -1, ansh = -1, sum = 1000000000;
        vector<int> t(n), h(m);
        REP(i, n) cin >>t[i];
        REP(i, m) cin >>h[i];
        REP(i, n){
            REP(j, m){
                swap(t[i], h[j]);
                int a = accumulate(t.begin(), t.end(), 0), b = accumulate(h.begin(), h.end(), 0);
                if(a == b && a + b < sum){
                    anst = h[j];
                    ansh = t[i];
                    sum = a + b;
                }
                swap(t[i], h[j]);
            }
        }
        if(anst == -1) cout <<-1 <<endl;
        else cout <<anst <<" " <<ansh <<endl;
    }
    return 0;
}

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

namespace B___Great_Ocean_View
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Hn = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var max = 0;
            var cnt = 0;

            for (int i = 0; i < N; i++)
            {
                if (Hn[i] >= max)
                {
                    max = Hn[i];
                    cnt++;
                }
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13268
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

res = 0

(0..a).each do |a_cnt|
  (0..b).each do |b_cnt|
    (0..c).each do |c_cnt|
      total = a_cnt * 500 + b_cnt * 100 + c_cnt * 50
      res += 1 if total == x
    end
  end
end

puts "#{res}"


Measured memory_bytes: 3836
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)
#define L ((ll)(1e9+7))

vector<ll> v;

int main(void){
	ll h,w,a,b,ans[10],d,j,k,t,p,q;
	int n,i,tmp;
	cin >> h >> w >> n;
	fill(ans,ans+10,0ll);
	for(i=0; i<n; ++i){
		cin >> a >> b;
		--a; --b;
		v.push_back(a*L+b);
	}
	sort(v.begin(),v.end());
	for(i=0; i<n; ++i){
		p = v[i] / L;
		q = v[i] % L;
		for(j=0ll; j<3ll; ++j){
			if(p-j < 0ll || p-j+3 > h){
				continue;
			}
			for(k=0; k<3; ++k){
				if(q-k < 0ll || q-k+3 > w){
					continue;
				}
				tmp = 0;
				for(t=0; t<3; ++t){
					tmp += (int)(lower_bound(v.begin(),v.end(),(p-j+t)*L+q-k+3)-lower_bound(v.begin(),v.end(),(p-j+t)*L+q-k));
				}
				if(tmp){
					++ans[tmp];
				}
			}
		}
	}
	ans[0] = (h-2)*(w-2);
	for(i=1; i<10; ++i){
		ans[i] /= i;
		ans[0] -= ans[i];
	}
	for(i=0; i<10; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


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

const long long MOD = 1000000007;

long long D, N, X;

long long mtr[2002], tmp[2002], vec[2002];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N >> D >> X && (N||D||X)){
        fill(mtr,   mtr+X,   1LL);
        fill(mtr+X, mtr+2001, 0LL);
        fill(vec+1, vec+N+1, 0LL);
        vec[0] = 1LL;
        for(;D; D /= 2){
            if(D & 1){
                for(int i = 0; i <= N; i++){
                    tmp[i] = 0LL;
                    for(int j = 0; j <= i; j++){
                        tmp[i] += mtr[i-j] * vec[j];
                        tmp[i] %= MOD;
                    }
                }
                for(int i = 0; i <= N; i++){
                    vec[i] = tmp[i];
                }
            }
            for(int i = 0; i <= N; i++){
                tmp[i] = 0LL;
                for(int j = 0; j <= i; j++){
                    tmp[i] += mtr[i-j] * mtr[j];
                    tmp[i] %= MOD;
                }
            }
            for(int i = 0; i <= N; i++){
                mtr[i] = tmp[i];
            }
        }
        cout << vec[N] << endl;
    }
    return 0;
}

Measured memory_bytes: 1236
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    vector<ll> a(3);
    rep(0, i, 3)
    {
        cin >> a.at(i);
    }
    sort(all(a));
    cout << a.at(0) + a.at(1) << endl;
}

Measured memory_bytes: 3576
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
        int[] a = new int[num];
  	 	for(int i=0; i<num; i++){
            a[i] = sc.nextInt();
        }
        int count = 0;
        for(int j=1; j<num; j++){
        	for(int i=0; i<j; i++){
             if(a[i] > a[j]) break;
             if(i+1 == j) count++;       
        	}
        }
		System.out.println(count+1);
	}
}

Measured memory_bytes: 22740
<?php

function input() {
    return trim(fgets(STDIN));
}

$n = (int)input();
$f[0] = $f[1] = 1;
for ($i = 2; $i <= $n; $i++) {
    $f[$i] = $f[$i - 1] + $f[$i - 2];
}

echo $f[$n] . "\n";


Measured memory_bytes: 9224
N = int(input())
pos = [0, 0]
time = 0
p = "Yes"
for i in range(N):
  A = list(map(int, input().split()))
  dt = A[0] - time
  dx = A[1] - pos[0]
  dy = A[2] - pos[1]
  if dt < dx + dy or dt % 2 != (dx + dy) % 2:
    p = "No"
  pos[:] = [A[1], A[2]]
  time = A[0]
print(p)

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

using namespace std;

const int INF = 1e9;

int n,m,i,j,k,cnt[305],a[305][305];
bool used[305];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++)
		scanf("%d", &a[i][j]);
	}
	
	int res = INF;
	
	for(i = 0; i < m; i++){
		int mx = 0;
		memset(cnt, 0, sizeof(cnt));
		
		for(j = 0; j < n; j++){
			for(k = 0; k < m; k++){
				if(used[a[j][k]]) continue;
				cnt[a[j][k]]++;
				if(cnt[a[j][k]] > cnt[mx])
				mx = a[j][k];
				break;
			}
		}
		
		res = min(res, cnt[mx]);
		used[mx] = 1;
	}
	
	printf("%d\n", res);
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>

using namespace std;

int main(){
 int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int m;
  m=max(a,max(b,c));
  
  for(int i=0;i<k;i++) m*=2;
  
  cout << m+a+b+c-max(a,max(b,c)) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
map<int,int>m; 
int n,b,sum;
int main(){
	scanf("%d",&n);
	F(i,1,n){
		scanf("%d",&b);
		++m[b];
	}
	for(map<int,int>::iterator it=m.begin();it!=m.end();++it){
		int x=it->first,y=it->second;
		if(y>=x)sum+=y-x;
		else sum+=y;
	}
	printf("%d",sum);
	return 0;
}


Measured memory_bytes: 4736
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl v(n);
	REP(i, n)cin >> v[i];
	ll u = INF*INF, l = -1;

	vl w = v;
	ll mid = (u + l) / 2;
	ll cnt = 0;
	while (1) {
		ll tmp = 0;
		vl c(n, 0);
		REP(i, n) {
			tmp += w[i] / n;
			c[i] = w[i] / n;
			w[i] %= n;
			
		}
		if (tmp == 0)break;
		cnt += tmp;
		REP(i, n) {
			w[i] += tmp - c[i];
		}
	}
	cout << cnt << endl;



}



Measured memory_bytes: 256
from math import ceil
D, G = map(int,input().split())
ps, cs = [], []
for _ in range(D):
    p, c = map(int,input().split())
    ps.append(p)
    cs.append(c)
ans = float("inf")
for i in range(2**D):
    cnt = 0
    point = 0
    for j in range(D):
        if (i>>j)&1:
            cnt += ps[j]
            point += ps[j]*100*(j+1)+cs[j]
    if point >= G:
        ans = min(ans, cnt)
        continue
    for j in range(D-1, -1, -1):
        if (i>>j)&1 == 0:
            if (ps[j]-1)*100*(j+1)+point >= G:
                cnt += ceil((G-point)/100/(j+1))
                point += ceil((G-point)/100/(j+1))*100*(j+1)
                break
            else:
                cnt += (ps[j]-1)
                point += (ps[j]-1)*100*(j+1)
    if point >= G:
        ans = min(ans, cnt)
print(ans)

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x / a;
  double rad;
  if (s >= a * b / 2) {
    double h = (a * b - s) * 2 / a;
    rad = atan2(h, a);
  } else {
    double w = s * 2 / b;
    rad = atan2(b, w);
  }

  double deg = rad * 180 / M_PI;
  printf("%.10f\n", deg);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
vector<ll>graph[100005];
ll dp[100005],n,m;
ll func(ll src)
{
    ll mx=0;
    for(auto it:graph[src])
    {
        if(dp[it]==-1)
        {
            mx=max(mx,func(it)+1);
        }
        else
            mx=max(mx,dp[it]+1);
    }
    return dp[src]=mx;
}
int main()
{
// #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        memset(dp,-1,sizeof(dp));
        for(ll i=1;i<=m;i++)
        {
            ll a,b;
            cin>>a>>b;
            graph[a].push_back(b);
        }
        ll mx=0;
        for(ll i=1;i<=n;i++)
        {
            if(dp[i]==-1)
                mx=max(mx,func(i));
            else
                mx=max(mx,dp[i]);
        }
        cout<<mx;
    }
    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll K, N, MDIST = 0; cin >> K >> N;
  vecll AS(N);
  REP(i, N) cin >> AS[i];
  REP(i, N-1) MDIST = max(MDIST, AS[i+1] - AS[i]);
  MDIST = max(MDIST, AS[0]+(K-AS[N-1]));
  cout << K - MDIST << endl;
  return 0;
}


Measured memory_bytes: 2300
def solve():
    from itertools import combinations
    from sys import stdin
    f_i = stdin
    
    def dfs(base, stones):
        key = tuple(stones)
        if key in rec:
            return set((base + l, base + r) for l, r in rec[key])
        
        edges = set()
        positions = set()
        for i in range(1, len(stones)):
            for tpl in combinations(stones, i):
                s1 = list(tpl)
                s2 = stones[:]
                for s in s1:
                    s2.remove(s)
                
                w1 = sum(s1)
                w2 = sum(s2)
                w = w1 + w2
                
                b1 = base - w2 / w
                b2 = base + w1 / w
                
                left_tree_ends = dfs(b1, s1)
                right_tree_ends = dfs(b2, s2)
                
                for ll, lr in left_tree_ends:
                    for rl, rr in right_tree_ends:
                        if ll < rl:
                            l = ll
                        else:
                            l = rl
                        if lr < rr:
                            r = rr
                        else:
                            r = lr
                        edges.add((l - base, r - base))
                        positions.add((l, r))
        
        rec[key] = edges
        return positions
    
    num = int(f_i.readline())
    
    rec = dict()
    for i in range(num):
        r = float(f_i.readline())
        s = int(f_i.readline())
        
        stones = sorted(int(f_i.readline()) for i in range(s))
        
        for stone in stones:
            rec[(stone,)] = {(0, 0)}
        
        edge_set = dfs(0, stones)
        try:
            ans = max(b - a for a, b in edge_set if b - a < r)
            print(ans)
        except ValueError:
            print(-1)

solve()


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

int main() {

    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
string a, b, c;
int main() {
	cin >> a >> b >> c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	int turn = 0;
	while(a.size() && b.size() && c.size()) {
		char z;
		if(turn == 0) z = a.back(), a.pop_back();
		if(turn == 1) z = b.back(), b.pop_back();
		if(turn == 2) z = c.back(), c.pop_back();
		if(z == 'a') turn = 0;
		if(z == 'b') turn = 1;
		if(z == 'c') turn = 2;
	}
	if(!a.size()) puts("A");
	if(!b.size()) puts("B");
	if(!c.size()) puts("C");
	return 0;
}

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

using namespace std;

typedef long long ll;

ll n;
ll a[200005];
vector<ll> ve[200005], x;
ll ans[200005];

void dfs(ll p)
{
    ll t = a[p];
    ll t2 = lower_bound(x.begin(), x.end(), t) - x.begin();
    if(x.size() <= t2)
    {
        x.push_back(t);
        ans[p] = (ll)x.size();
        for(ll i = 0; i < ve[p].size(); i++)
        {
            if(ans[ve[p][i]] == 0) dfs(ve[p][i]);
        }
        x.pop_back();
    }
    else
    {
        ll y = x[t2];
        x[t2] = t;
        ans[p] = (ll)x.size();
        for(ll i = 0; i < ve[p].size(); i++)
        {
            if(ans[ve[p][i]] == 0) dfs(ve[p][i]);
        }
        x[t2] = y;
    }
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 1; i < n; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    dfs(1);
    for(ll i = 1; i <= n; i++)
    {
        printf("%lld\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 29368
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let s: Vec<char> = s.chars().collect();

    let ans = format!("{}{}{}", s[0], s.len()-2, s[s.len()-1]);

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

int A[100000], ocurrences[100001];


int main()
{
    int N, i, Q, B, C;
    long long sum;

    scanf("%d", &N);
    memset(ocurrences, 0, sizeof ocurrences);
    sum = 0;
    for(i = 0; i < N; ++i){
        scanf("%d", &A[i]);
        ++ocurrences[A[i]];
        sum += A[i];
    }
    scanf("%d", &Q);
    while(Q--){
        scanf("%d%d", &B, &C);
        ocurrences[C] += ocurrences[B];
        sum += ocurrences[B] * 1LL * (C - B);
        ocurrences[B] = 0;
        printf("%lld\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2504
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define TEST(...)                                                              \
    { printf("! "), printf(__VA_ARGS__); }
#else
#define TEST(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        int n, m;
        cin >> n >> m;
        vector<int> a(n);
        int sum = 0;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
            sum += a[i];
        }
        int b = 0;
        for (int i = 0; i < n; ++i) {
            if (a[i] * 4 * m < sum)
                continue;
            b++;
        }
        if (b >= m)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t A,B;
  cin>>A>>B;
  for(int i=1;i<=B;i++){
    if((A*i)%B==0){
      cout<<A*i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

using namespace std;
int main() {
  std::cout << std::fixed << std::setprecision(10);
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  rep(i, N) {
    cin >> p[i];
  }

  int max_num = 0;
  int max_idx = 0;
  // first k
  for(int i=0; i<K; ++i) {
    max_num += p[i];
  }
  int prev = p[0];
  int current = max_num;

  for(int i=K; i<N; ++i) {
    current = current - prev + p[i];
    if (current > max_num) {
      max_num = current;
      max_idx = i - K + 1;
    }
    prev = p[i-K+1];
  }

  double ret = 0;
  for(int i=max_idx; i<max_idx+K; ++i) {
    double prob = (p[i] + 1.0) / 2.0;
    ret += prob;
  }

  cout << ret << endl;
  return 0;
}

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

int main() {
  int N,P,i;
  cin >> N;
  i = 0;
  P = 0;
  while ( i < N ) {
    P += i + 1;
    i ++;
  }
  cout << P << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
        #define REP(i, n) for(int i = 0;i < n;i++)
        #define REPR(i, n) for(int i = n;i >= 0;i--)
        #define FOR(i, m, n) for(int i = m;i < n;i++)
        #define FORR(i, m, n) for(int i = m;i >= n;i--)
        #define SORT(v, n) sort(v, v+n);
        #define VSORT(v) sort(v.begin(), v.end());
        #define llong long long
        #define pb(a) push_back(a)
        #define INF 1000000000000000000LL
        #define MOD 1000000007
        using namespace std;
        typedef pair<int, int> P;
        typedef pair<llong, llong> LP;
        typedef pair<int, P> PP;
        typedef pair<llong, LP> LPP;
        //vector<tuple<long long, long long, long long>>vec;

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

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


        int main()
        {
            int n;
            cin>>n;
            vector<int> a(n,0);
            for(int i=0; i<n; i++) {cin>>a[i];}
            sort(a.begin(),a.end());

            vector<int> sum(a[n-1]+1,0);
            for(int i=0; i<n; i++)
            {
                sum[a[i]]++;
            }
            int ans=0;
            if(a[n-1]==0) ans=sum[0];
            else if(a[n-1]==1) ans=sum[0]+sum[1];
            else
                {
                for(int i=0; i<a[n-1]-1; i++)
                {
                    int cnt;
                    cnt=sum[i]+sum[i+2]+sum[i+1];
                    ans=max(cnt,ans);
                }
                }
            cout<<ans<<endl;
        }



Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long ll;
#define dbg(x) cout<<#x<<" = "<<x<<endl
#define dbg2(x,y) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<endl
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<endl
#define dbg4(x,y,z,q) cout<<#x<<" = "<<x<<", "<<#y<<" = "<<y<<", "<<#z<<" = "<<z<<", "<<#q<<" = "<<q<<endl
#define dbg_array(x,sz) for (int i = 0; i < sz; ++i) cout << x[i] << " \n"[i==sz-1]
using namespace std;

const ll N = 100 + 9, M = 400 - 9, Max_ans = 1LL * (1e16);
int vis[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
#ifdef ECLIPSE
	freopen("input.in", "rt", stdin);
	//freopen("output.out", "wt", stdout);
#endif
	int n;
	cin >> n;
	string s;
	while (n--) {
		cin >> s;
		++vis[s[0] - 'A'];
	}
	printf("AC x %d\n", vis['A' - 'A']);
	printf("WA x %d\n", vis['W' - 'A']);
	printf("TLE x %d\n", vis['T' - 'A']);
	printf("RE x %d\n", vis['R' - 'A']);
	return 0;
}



Measured memory_bytes: 3728
open System

let readNumbers (str:string) =
    let mutable buf = 0
    seq {
        for c in str do
            match c with
            | ' ' ->
                yield buf
                buf <- 0
            | x ->
                buf <- buf * 10 + (int x) - 0x30
        yield buf
    }

do
    Console.ReadLine()
    let odds =
        Console.ReadLine()
        |> readNumbers
        |> Seq.filter (fun x -> x % 2 = 1)
        |> Seq.length
    printf "%s" <| if odds % 2 = 0 then "YES" else "NO"

[<EntryPoint>]
let main _ =
    0

Measured memory_bytes: 7764
use std::io::*;
use std::str::FromStr;

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

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let n = parse_line::<usize>();
    let w = parse_line_vec::<i32>();

    let total_weight: i32 = w.iter().sum();

    let min_abs_difference = (1..n)
        .map(|i| {
            let former_part_weight: i32 = w[0..i].into_iter().sum();
            let latter_part_weight: i32 = total_weight - former_part_weight;
            (former_part_weight - latter_part_weight).abs()
        })
        .min()
        .unwrap();

    println(min_abs_difference);
}


Measured memory_bytes: 4352
def main():
    a, b = map(int, input().split())
    if a < 0 and b > 0:
        print('Zero')
    elif a > 0 and b > 0:
        print('Positive')
    elif a == 0 or b == 0:
        print('Zero')
    else:
        if (abs(a) - abs(b) + 1) % 2 == 1:
            print('Negative')
        else:
            print('Positive')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var n, k, q, i int
	fmt.Scan(&n, &k, &q)
	scores := make(map[int]int)
	// create scores map
	for i = 1; i <= n; i++ {
		scores[i] = 0
	}
	for index := 0; index < q; index++ {
		fmt.Scan(&i)
		scores[i]++
	}
	for i = 1; i <= n; i++ {
		score := scores[i]
		score = k - q + score
		if score > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

typedef pair<int, int> P;

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


int solve(int a[100][100],int w,int h){
	int d[100][100]={0};
	d[1][1]=1;

	P sp(1,1);
	queue<P> q;
	q.push(sp);

	while(!q.empty()){
		P p=q.front();
		q.pop();
		int x=p.first;
		int y=p.second;
		int cnt=d[y][x];

		if(x==w*2-1 && y==h*2-1){
			break;
		}

		for(int i=0;i<4;i++){
			int mx=x+dx[i];
			int my=y+dy[i];
			int nx=mx+dx[i];
			int ny=my+dy[i];

			if(nx<0 || ny<0 || nx>w*2 || ny>h*2){
				continue;
			}

			if(a[my][mx]==0 && d[ny][nx]==0){
				P np(nx,ny);
				q.push(np);
				d[ny][nx]=cnt+1;
			}
		}
	}
	return d[h*2-1][w*2-1];
}


int main(){
	int x,y;

	while(cin>>x>>y,x||y){
		
		int MazeWall[100][100]={0};
		
		for(int xr=0;xr<=x*2;xr++){
			MazeWall[0][xr]=MazeWall[y*2][xr]=1;
		}

		for(int yr=0;yr<=y*2;yr++){
			MazeWall[yr][0]=MazeWall[yr][x*2]=1;
		}
		
		
		for(int yr=0;yr<(y*2-1);yr++){
			if(yr%2==0){
				for(int xr=0;xr<x-1;xr++){
					//(x,y)=>(2xr+2,yr+1);
					cin>>MazeWall[yr+1][xr*2+2];
				}
			}
			else{
				for(int xr=0;xr<x;xr++){
					//(x,y)=>(2xr+1,yr+1);
					cin>>MazeWall[yr+1][xr*2+1];
				}
			}
		}
		cout<<solve(MazeWall,x,y)<<endl;
	}
}

Measured memory_bytes: 1300
from fractions import gcd

def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a, b = map(int, input().split())
print(len(set(pf(gcd(a, b)))) + 1)

Measured memory_bytes: 5432
s = input()
q = int(input())

add_s = ['', ''] #pre, post
rev_flag = 0

for i in range(q):
    query = input()
    if query == '1':
        rev_flag = (rev_flag+1)%2
    else:
        _, f, c = query.split()
        if f == '1':
            add_s[rev_flag] += c
        else:
            add_s[(rev_flag+1)%2] += c

if rev_flag == 1:
    s = s[::-1]

print(add_s[rev_flag][::-1]+s+add_s[(rev_flag+1)%2])

Measured memory_bytes: 4504
#include <iostream>
#include <cstdlib>
using std::cout;
using std::cin;
using std::endl;
using std::calloc;

int main()
{
	int i, num, *list;
	cin >> num;
	list = (int *) calloc(num, sizeof(int));
	if (list == NULL) return 1;
	for (i = 0; i < num; i++) cin >> list[i];
	for (i = num - 1; i > 0; i--) cout << list[i] << " ";
	cout << list[0] << endl;
	return 0;	
}

Measured memory_bytes: 1200
import math

abC = [int(x) for x in input().split()]
S = abC[0] * abC[1] * math.sin(math.radians(abC[2])) / 2
L = abC[0] + abC[1] + ((abC[0] ** 2 + abC[1] ** 2 - 2 * abC[0] * abC[1] * math.cos(math.radians(abC[2]))) ** 0.5)
h = 2 * S / abC[0]
print(" %.8f" % S)
print(" %.8f" % L)
print(" %.8f" % h)


Measured memory_bytes: 5728
#include "bits/stdc++.h"

using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;

    int win = 0, lose = 0;
    int p = 0, g = 0;
    for (auto &elem : s) {
        if (elem == 'g') {
            if (p + 1 <= g) {
                p++, win++;
            } else {
                g++;
            }
        } else {
            if (p + 1 <= g) {
                p++;
            } else {
                g++, lose++;
            }
        }
    }

    cout << win - lose << "\n";

    return 0;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int A=a*b, B=c*d;

    if(A>=B){
        cout << A << endl;
    } else {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 3676