akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    
    int n; cin >> n;

    vector<pair<int, int>> town(n);
    rep(i, n){
        cin >> town[i].first >> town[i].second;
    }

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

    long double mean = 0;
    do{
        rep(i, n-1){
            long double tmp = 0;
            tmp += (town[i].first-town[i+1].first)*(town[i].first-town[i+1].first);
            tmp += (town[i].second-town[i+1].second)*(town[i].second-town[i+1].second);
            mean += sqrt(tmp);
        }
    }while(next_permutation(town.begin(), town.end()));

    for(int i = 1; i <= n; ++i){
        mean /= i;
    }
    cout << mean << '\n';
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	
	int ans = 0;
	char s[4];
	scanf("%s",&s);
	for(int i=0;i<4;i++){
		if( s[i] =='+'){
			ans++;
		}else{
			ans--;
		}
	}
	printf("%d",ans);
	return 0;
}
	

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int a[n];
		for(int i=0;i<n;i++)
			cin>>a[i];
		int ans=0;
		for(int i=0;i<n;i++){
			for(int j=0;j<n-1;j++){
				if(a[j]>a[j+1]){
					ans++;
					int temp=a[j];
					a[j]=a[j+1];
					a[j+1]=temp;
				}
			}
		}
		cout<<a[0];
		for(int i=1;i<n;i++)
			cout<<' '<<a[i];
		cout<<endl;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll n;
	cin>>n;
	if(n%2==0)
	{
		n/=2;
		ll ans=0;
		ll val=5ll;
		while(n/val)
		{
			ans+=n/val;
			val*=5;
		}
		cout<<ans<<'\n';
	}	
	else
	{
		ll val5=0;
		ll val2=0;
		ll val=5;
		while(n/val)
		{
			val5+=n/val;
			val*=5;
		}
		val=2;
		while(n/val)
		{
			val2+=n/val;
			val*=2;
		}
		val2-=(n/2);
		n/=2;
		val=5;
		while(n/val)
		{
			val5-=(n/val);
			val*=5;
		}
		val=2;
		while(n/val)
		{
			val2-=(n/val);
			val*=2;
		}
		ll ans=min(val5,val2);
		cout<<ans<<'\n';
	}
	return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



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

int N;
int l[100000],r[100000];         
int main() {
  cin >> N;
  for (int i=0 ; i<N ; ++i) cin >> l[i] >>r[i];
  int sum = 0;
  for (int i =0 ; i<N ; ++i)
    sum += r[i]-l[i]+1;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 0x3f3f3f3f

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    ll a = 0;
    for(auto&ch:s)a = (10*a + (ch-'0'))%3;

    cout<<(a ? "No" : "Yes");
}


Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

struct Edge{
	int to,time;
};

struct Node{
	int u,l,t;
	bool operator<(const Node &n)const{
		return t<n.t;
	}
	bool operator>(const Node &n)const{
		return t>n.t;
	}
};

int n,m,l,k,a,h,d[100][101];
bool flag[100];
vector<Edge> g[100];

void Djikstra(){
	fill_n((int*)d,100*101,INF);
	priority_queue<Node,vector<Node>,greater<Node>> q;
	q.push(Node{a,m,0});
	while(!q.empty()){
		Node v=q.top(); q.pop();
		if(d[v.u][v.l]<v.t) continue;
		d[v.u][v.l]=v.t;
		if(flag[v.u]){
			REP(i,0,m-v.l+1){
				if(d[v.u][v.l]+i<d[v.u][v.l+i]){
					d[v.u][v.l+i]=d[v.u][v.l]+i;
					q.push(Node{v.u,v.l+i,d[v.u][v.l+i]});
				}
			}
		}
		for(auto e:g[v.u]){
			if(v.l-e.time>=0&&d[v.u][v.l]+e.time<d[e.to][v.l-e.time]){
				d[e.to][v.l-e.time]=d[v.u][v.l]+e.time;
				q.push(Node{e.to,v.l-e.time,d[e.to][v.l-e.time]});
			}
		}
	}
}

void Solve(){
	while(true){
		cin >> n >> m >> l >> k >> a >> h;
		if(!n) break;
		REP(i,0,n) flag[i]=false;
		REP(i,0,l){
			int v;
			cin >> v;
			flag[v]=true;
		}

		REP(i,0,n) g[i].clear();
		REP(i,0,k){
			int x,y,t;
			cin >> x >> y >> t;
			g[x].push_back(Edge{y,t});
			g[y].push_back(Edge{x,t});
		}
		
		Djikstra();
		int ans=INF;
		REP(i,0,m+1) ans=min(ans,d[h][i]);
		if(ans==INF) cout << "Help!";
		else cout << ans;
		cout << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1492
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#define p(n) pow(n,2)
using namespace std;
int main(){
  int a,b,c,rhom=0,rect=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(p(a)+p(b)==p(c))rect++;
       if(a==b)rhom++;
  }
cout<<rect<<endl<<rhom<<endl;
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>
int main()
{
	char s[100005];
	scanf("%s",s);
	int n=strlen(s);
	int i;
	int ans=0;
	for(i=1;i<n;i++)
	    if(s[i-1]!=s[i])
	        ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd
k = int(input())
result = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        temp = gcd(i, j)
        work = temp
        for j in range(1, temp):
            work += gcd(j, temp)
        result += k//temp * work
        for j in range(1, k%temp+1):
            result += gcd(j, temp)
print(result)

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

int main(){
    char a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    int x=0;
    if (a==d) {
        x++;
    }
    if (b==e) {
        x++;
    }
    if (c==f) {
        x++;
    }
    cout << x << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = println(run {
    val n= readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    val q = readLine()!!.split(" ").map { it.toInt() }

    var count = 0
    var start = listOf(p,q).minBy { it.joinToString("") }!!
    val end = listOf(p,q).maxBy { it.joinToString("") }!!

    while (start != end) {
        start = start.nextPermutation()
        count++
    }
    count
})

fun List<Int>.nextPermutation() = run {
    val n = this.size
    try {
        val i = (0..n - 2).last { this[it] < this[it + 1] }
        val j = this.indexOfLast { it > this[i] }
        this.take(i) + this[j] + (this.drop(i) - this[j]).sorted()
    } catch (e: Exception) {
        this.reversed()
    }
}

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

typedef struct{
  int cnt;
  string str;
} Moji;

bool asc(const Moji& left,const Moji& right){
  return left.cnt == right.cnt ? left.str < right.str : left.cnt > right.cnt;
}


int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    string tmptmp;
    getline(cin,tmptmp);
    map<string,int> mp;
    Moji moji[26][5000];
    int mjp[26] = {};
    for(int i = 0;i < n;i++){
      string s,tmp;

      getline(cin,s);
      for(int i = 0;i < s.size();i++){
        if(s[i] == ' '){
          if(mp[tmp] == 0){
            moji[tmp[0]-'a'][mjp[tmp[0]-'a']].str = tmp;
            mjp[tmp[0]-'a']++;
          }
          mp[tmp]++;
          tmp.clear();
        }else{
          tmp.push_back(s[i]);
        }
      }
      if(mp[tmp] == 0){
        moji[tmp[0]-'a'][mjp[tmp[0]-'a']].str = tmp;
        mjp[tmp[0]-'a']++;
      }
      mp[tmp]++;
    }
    char search;
    cin >> search;
    search-='a';

    if(mjp[search] == 0){
      cout << "NA" << endl;
    }else{
      for(int i = 0;i < mjp[search];i++){
        moji[search][i].cnt = mp[moji[search][i].str];
      }
      sort(moji[search],moji[search]+mjp[search],asc);

      for(int i = 0;i < min(5,mjp[search]);i++){
        cout << moji[search][i].str; if(i != min(5,mjp[search])-1) cout << " "; else cout << endl;
      }
    }
  }

  return 0;
}








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

typedef long long ll;
ll INF = 1000000000000000;
using Graph = vector<vector<pair<ll,ll>>>;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
vector.erase(vector.begin() + index);
}

int main(){
 ll X;
 cin >> X;
 ll m = X % 11;
 ll memo = X / 11;
 ll ans = memo * 2;
 if(m > 6){
   ans += 2;
 }else if(m){
   ans++;
 }
 cout << ans << endl;
} 


Measured memory_bytes: 256
N_ = 8
FREE_ = -1
NOTFREE_ = 1
row = [FREE_ for i in range(N_)]
col = [FREE_ for i in range(N_)]
dpos = [FREE_ for i in range(2*N_-1)]
dneg = [FREE_ for i in range(2*N_-1)]
X = [[False for i in range(N_)] for j in range(N_)]

def output():
    for i in range(N_):
        for j in range(N_):
            if X[i][j]:
                if row[i] != j:
                    return

    for i in range(N_):
        for j in range(N_):
            if row[i] == j:
                print('Q', end='')
            else:
                print('.', end='')
        print()

def recursive(i):
    if i == N_:
        output()
        return

    for j in range(N_):
        if col[j] == NOTFREE_ or dpos[i + j] == NOTFREE_ or dneg[i - j + N_ - 1] == NOTFREE_:
            continue
        row[i] = j
        col[j] = dpos[i + j] = dneg[i - j + N_ - 1] = NOTFREE_
        recursive(i + 1)
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N_ - 1] = FREE_

k = int(input())
for i in range(k):
    r,c = map(int, input().split())
    X[r][c] = True

recursive(0)



Measured memory_bytes: 5620
#include <cstdio>

int W, H, N;
int rect[110][110];

int main()
{
	int i, j, k;
	scanf("%d%d%d", &W, &H, &N);
	for(i=0; i<=W; i++){
		for(j=0; j<=H; j++)
			rect[i][j] = 0;
	}
	int x, y, a;
	int x1=0, x2=W, y1=0, y2=H;
	for(i=0; i<N; i++){
		scanf("%d%d%d", &x, &y, &a);
		/*if(a==1){
			for(j=0; j<=x; j++){
				for(k=0; k<=H; k++)
					rect[j][k] = 1;
			}
		}
		else if(a==2){
			for(j=x; j<=W; j++){
				for(k=0; k<=H; k++)
					rect[j][k] = 1;
			}
		}
		else if(a==3){
			for(j=0; j<=W; j++){
				for(k=0; k<=y; k++)
					rect[j][k] = 1;
			}
		}
		else{
			for(j=0; j<=W; j++){
				for(k=y; k<=H; k++)
					rect[j][k] = 1;
			}
		}*/
		if(a==1){
			if(x > x1)
				x1 = x;
		}
		else if(a==2){
			if(x < x2)
				x2 = x;
		}
		else if(a==3){
			if(y > y1)
				y1 = y;
		}
		else{
			if(y < y2)
				y2 = y;
		}
	}
	int res = 0;
	/*for(i=0; i<=W; i++){
		for(j=0; j<=H; j++){
			if(rect[i][j] == 0)
				res ++;
		}
	}*/
	if(x2>x1 && y2>y1)
		res = (x2-x1) * (y2-y1);
	else
		res = 0;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [1]*n
for i in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    if h[x] >= h[y]: a[y] = 0
    if h[y] >= h[x]: a[x] = 0
print(sum(a))

Measured memory_bytes: 84856
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
int main()
{
    int n,sign=0;
    int a[100005];
    int m[100005]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]++;
    }
    if(n%2)
    {
        if(m[0]!=1){
            sign=1;
        }
        for(int i=2;i<n;i+=2)
        {
            if(m[i] != 2){
                sign = 1;
            }
        }
    }
    else
    {
        for(int i=1;i<n;i+=2)
        {
            if(m[i] != 2)
            {
                sign = 1;
            }
        }
    }
    ll s = 1;
    for(int i=0;i < floor(n/2);i++)
    {
        s = ((s%mod)*2)%mod;
    }
    if(sign)
    {
        cout<<"0\n";
    }
    else
    {
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int a, b;
int n;

bool ask(int a, int b){
	printf("? %d %d\n", a, b); fflush(stdout);
	char buf[5]; scanf("%s", buf);
	return buf[0] == 'Y';
}

char ans[4010];
int par[4010];
int r(int x){ return (x==par[x])?x:(par[x]=r(par[x])); }

bool df[4010][4010];

int main()
{
	read(a, b);
	if(a <= b){
		puts("Impossible");
		return 0;
	}
	n=a+b;
	
	for(int i=0; i<n; ++i) par[i]=i;
	
	int m=-1, c=0;
	for(int i=0; i<n; ++i){
		if(c == 0) m=i, c=1;
		else if(m == i) ++c;
		else {
			if(r(m) == r(i)) ++c;
			else if(ask(i, m)) ++c;
			else --c;
		}
	}
	
	for(int i=0; i<n; ++i){
		if(i == m) ans[i]='1';
		else ans[i]='0'+ask(m, i);
	}
	
	printf("! %s\n", ans);
	return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  string s, t; cin >> s >> t;
  int a = 0;
  rep(i, s.size()) if(s[i] != t[i]) ++a;
  cout << a << "\n";
  return 0;
}

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

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

    double ans = 0.0f;
    for (int i = 0; i < N; i++) {
        ans += 1.0/A.at(i);
    }
    
    cout << fixed << setprecision(10);
    cout << 1.0 / ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

int main(){

		int n,y,m,d;
		cin>>n;

			int cnt = 0;
			for(int j=1; j<1000; j++){
				if(j%3 != 0){
					for(int l=1; l<=10; l++){

						int t;
						if(l%2 == 1) t = 20;
						else t= 19;

						for(int k=1; k<=t; k++){
							cnt++;
						}
				    }
				}else{
					for(int l=1; l<=10; l++){
						for(int k=1; k<=20; k++){
							cnt++;
						}
				    }
				}
			}


		for(int i=0; i<n; i++){
			cin>>y>>m>>d;
			int c = 0;
			for(int j=1; j<1000; j++){
				if(j%3 != 0){
					for(int l=1; l<=10; l++){

						int t;
						if(l%2 == 1) t = 20;
						else t= 19;

						for(int k=1; k<=t; k++){
							c++;
							if(j==y && l == m && k == d){
								cout<<cnt - c + 1<<endl;
								break;
							}
						}
				    }
				}else{
					for(int l=1; l<=10; l++){
						for(int k=1; k<=20; k++){
							c++;
							if(j==y && l == m && k == d){
								cout<<cnt - c + 1<<endl;
								break;
							}
						}
				    }
				}
			}

		}		

	return 0;
}

Measured memory_bytes: 3052
import           Data.List                      ( sort
                                                , splitAt
                                                )

minimumVotes :: Float -> Float -> Float
minimumVotes allVotes m = allVotes / (4.0 * m)

main = do
    s <- getLine
    let (n : m : _) = map read $ words s :: [Int]
    let m'          = fromIntegral m :: Float

    votes' <- getLine
    let votes            = map read $ words votes' :: [Int]

    let sortedVotes      = reverse . sort $ votes
    let (targetVotes, _) = splitAt m sortedVotes

    let
        result' =
            flip map targetVotes
                $ (\vote ->
                      fromIntegral vote
                          >= minimumVotes (fromIntegral $ sum votes) m'
                  )
    let result = all id result'


    case result of
        True  -> putStrLn "Yes"
        False -> putStrLn "No"


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)

int main()
{
  	ll N; cin >> N;
  	__int128 ans=1;
  	ll ub = pow(10,18);
  	loop(i,0,N)
    {
      	ll x; cin >> x;
      	if (x==0) ans=0;
      	if (ans*x > ub) {
          ans=-1;
        }
      	if (ans!=-1) ans*=x;
    }
  	cout << (ll)ans << "\n";
	return 0;  
}

Measured memory_bytes: 3616
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

const MOD: i64 = 1_000_000_007;
fn main() {
    input! {
       N:usize,mut K:usize,
       mut A:[i64;N]
    }
    let mut poslist = Vec::with_capacity(N);
    let mut neglist = Vec::with_capacity(N);
    let mut zerolen = 0;
    for i in 0..N {
        if A[i] == 0 {
            zerolen += 1;
        } else if A[i] > 0 {
            poslist.push(A[i]);
        } else {
            neglist.push(A[i]);
        }
    }
    let mut ans = 1;
    if N - zerolen < K {
        println!("0");
        return;
    }
    if N - zerolen == K && zerolen > 0 && neglist.len() % 2 != 0 {
        println!("0");
        return;
    }
    if poslist.len() == 0 {
        // この時 neglist.len() >= K
        neglist.sort();
        if K % 2 == 1 {
            if zerolen > 0 {
                println!("0");
                return;
            }
            neglist.reverse();
        }
        for i in 0..K {
            ans = ans * neglist[i] % MOD;
        }
    } else if N == K {
        for l in 0..N {
            ans = ans * A[l] % MOD;
        }
    } else {
        // poslist.len()>0のケース。
        neglist.sort();
        poslist.sort();
        poslist.reverse();
        let mut i = 0;
        let mut j = 0;
        if K % 2 == 1 {
            i = 1;
            K -= 1;
        }
        for k in 0..(K / 2) {
            if i + 1 >= poslist.len() {
                j += 2;
            } else if j + 1 >= neglist.len() {
                i += 2;
            } else if poslist[i] * poslist[i + 1] >= neglist[j] * neglist[j + 1] {
                i += 2;
            } else {
                j += 2;
            }
        }
        for l in 0..i {
            ans = ans * poslist[l] % MOD;
        }
        for l in 0..j {
            ans = ans * neglist[l] % MOD;
        }
    }
    println!("{}", (ans + MOD) % MOD);
}


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

int main() {
    string a, b;
    cin >> a >> b;
    int N = stoi(a + b);
    string ans = "No";
    rep(i, 1100) {
        if (i*i == N) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<ld> x(n), y(n);
    vector<char> d(n);
    FOR(i, 0, n)cin >> x[i] >> y[i] >> d[i];

    map<char, ld> Xdir, Ydir;
    Xdir['R'] = 1, Xdir['L'] = -1;
    Ydir['U'] = 1, Ydir['D'] = -1;
    function<ld(ld)> f = [&](ld t) {
        ld Xmax = -LLINF, Xmin = LLINF;
        ld Ymax = -LLINF, Ymin = LLINF;
        FOR(i, 0, n) {
            ld nx = x[i] + t * Xdir[d[i]];
            ld ny = y[i] + t * Ydir[d[i]];
            chmax(Xmax, nx), chmin(Xmin, nx);
            chmax(Ymax, ny), chmin(Ymin, ny);
        }
        return (Xmax - Xmin) * (Ymax - Ymin);
    };

    ld l = 0, r = INF;
    FOR(i, 0, 500) {
        ld m1 = (l * 2 + r) / 3, m2 = (l + r * 2) / 3;
        if (f(m1) < f(m2))r = m2;
        else l = m1;
    }
    cout << f(l) << "\n";
}

Measured memory_bytes: 3456
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	rep(i, 10) {
		cout << a * c - b << endl;
		c = a * c - b;
	}
}


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

using namespace std;

typedef long long ll;

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

	int h, w, a, b;
	cin >> h >> w >> a >> b;

	int ans[h][w];
	rep(i, h) rep(j, w){
		if((i < b && j < a) || (i >= b && j >= a)){
			cout << 0;
		}else{
			cout << 1;
		}
		if(j == w-1) cout << endl;
	}
}


Measured memory_bytes: 1280
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		int c=Integer.parseInt(scan.next());
    		
    		System.out.print((b-a)==(c-b)?"YES":"NO");

    		
    	
  
    				
    	}
     
    }

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());
    int t = a[n / 2];
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += abs(a[i] - t);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using namespace std;

int main(int argc, char const *argv[])
{
    int n, b, f, r, v;
    cin >> n;
    int rooms[4][3][10]{};
    rep(i, n) {
        cin >> b >> f >> r >> v;
        rooms[b-1][f-1][r-1] +=v;
    }

    rep(i, 4) {
        rep(j, 3) {
            rep(k, 10) {
                cout << ' ' << rooms[i][j][k];
            }
            cout << endl;
        }
        if(i!=3) cout << "####################" << endl;
    }

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

Graph g;
vector<int> dp;

int		rec(int node)
{
	if (g[node].size() == 0)
		return (0);
	vector<int> tmp;
	for (auto it = g[node].begin(); it != g[node].end(); it++)
	{
		if (dp[*it] == -1)
			dp[*it] = rec(*it);
		tmp.push_back(dp[*it]);
	}
	return (*max_element(tmp.begin(), tmp.end()) + 1);
}

int     main()
{
	int n, m;
	cin >> n >> m;
	g.resize(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[--a].push_back(--b);
	}
	dp = vector<int>(n, -1);
	for (int i = 0; i < n; i++) {
		if (dp[i] == -1)
			dp[i] = rec(i);
	}
	int ans = *max_element(dp.begin(), dp.end());
	cout << ans << endl;
}




Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int a[101];
int main()
{
    int n,i,j,m,s;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    m=1000000000;
    for(j=a[0];j<=100;j++)
    {
        s=0;
        for(i=0;i<n;i++)
        {
            s+=(a[i]-j)*(a[i]-j);
        }
        if(s<m)m=s;
    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;

using ipair = pair<int, int>;

ll INF = 1e16+7;
ll mod = 998244353;

bool operator>(const ipair a,const ipair b){return a.first > b.first;}

int main(){
  ll N, M;
  deque<ipair> vect;

  cin >> N >> M;

  rep(i, N){
    int a, b;
    cin >> a >> b;
    vect.push_back(make_pair(a, b));
  }

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

  ll ans = 0;
  while(1){
    if(vect.front().second >= M){
      ans += (ll)vect.front().first * M;
      break;
    }

    ans += ((ll)vect.front().first) * ((ll)vect.front().second);
    M -= vect.front().second;

    vect.pop_front();
  }

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


Measured memory_bytes: 4388
#include<iostream>
#include<vector>
#include <set>
#include <algorithm>
#include <iterator>

using namespace std;

int main(void) {

    int n, m;
    int a[50][50];

    cin >> n >> m;

    // store

    for (int i = 0; i < n ; i++) {
        int k;
        cin >> k;
        a[i][0] = k;
        for(int j=0; j<k;j++){
            cin >> a[i][1+j];
        }
    }

    // create as set
    vector<set<int>> values;
    for(int x = 0; x < n; x++){
        set<int> t;
        for(int y = 1; y < a[x][0] + 1; y++) {
            t.insert(a[x][y]);
            // cout << a[x][y] << " ";
        }
        values.push_back(t);
        // cout << endl;
    }

    // get intersection
    set<int> res = values[0];
    for(auto s : values) {

        set<int> temp;

        // cout << "--a--" << endl;
        // for (auto i : s) {
        //     cout << i << " ";
        // }

        // cout << endl;

        // cout << "--b--" << endl;
        // for (auto i : res) {
        //     cout << i << " ";
        // }

        // cout << endl;

        set_intersection(s.begin(), s.end(), res.begin(), res.end(), inserter(temp, temp.end()));

        res = temp;

        // cout << "---result---" << endl;
        // for (auto i : res) {
        //     cout << i << " ";
        // }
        // cout << endl << "--end--" << endl;
    }

    cout << res.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N;
    cin >> N;
    int j;
    for(int i = 0; i * i <= N; i++) {
        j = i;
    }
    cout << j * j << endl;
    return 0;
}

Measured memory_bytes: 256
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("filed 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 n:usize = read();
    let d:usize = read();
    let x:usize = read();
    let mut ans = n + x;
    for _ in 0..n {
        let y:usize = read();
        ans += (d-1) / y;
    }
    println!("{}", ans);
}


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

#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 1005;

int n, k;
int dat[N];

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++) scanf("%d", &dat[i]);
	sort(dat, dat+n);
	int ans = 0;
	for (int i = 0; i < k; i++) ans += dat[i];
	printf("%d\n", ans);
	return 0;
}

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

int main(void){
    int n,y,a = -1,b = -1,c = -1;
    cin >> n >> y;
    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= n;j++){
            int k = n - i - j;
            if(i+j+k == n &&10000*i + 5000*j + 1000*k == y && k >= 0){
                a = i,b = j,c = k;
                break;
            }
        }
    }
    cout << a << " " << b << " " << c <<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int A, B, C;
  cin>>A>>B>>C;
  if(A==B && A!=C){
    cout<<"Yes";
    return 0;
  }
  if(B==C && B!=A){
    cout<<"Yes";
    return 0;
  }
  if(C==A && C!=B){
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
  return 0;

}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a = inp()
b = inp()
if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e4 + 5;
//head
int a[256];
set<int> S{'A', 'T', 'G', 'C'};
int main() {
    string s;
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); ++i) {
        for(int j = i + 1; j <= s.size(); ++j) {
            bool ok = true;
            for(int k = i; k < j; ++k) {
                if(!S.count(s[k])) {
                    ok = false;
                    break;
                }
            }
            if(ok) ans = max(ans, j - i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from subprocess import call
call (('pypy3', '-c', """
from collections import deque
 
def main():
    h, w = map(int, input().split())
    A = [list(input()) for _ in range(h)]
    d = [[10**9] * w for _ in range(h)]
    que = deque([])
    
    for i in range(h):
        for j in range(w):
           if A[i][j] == "#":
               que.append([i, j])
               d[i][j] = 0
           else:
               d[i][j] = 10 ** 9
            
    while que:
        x, y = que.popleft()
        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4): 
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 10**9:
                d[nx][ny] = d[x][y] + 1
                que.append([nx, ny])
    ans = 0
    for i in range(h):
        for j in range(w):
            ans = max(ans, d[i][j])
    print(ans)
    
    return
    
main()
 
"""))

Measured memory_bytes: 180932
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    if(n % 2 == 0){
      System.out.println(1/2.0);
    }else{
      System.out.println(((n+1)/2.0)/n);
    }
  }
}

Measured memory_bytes: 22740
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2401

#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
using namespace std;

string S;
int cur;

bool a[11];

bool formula() {
  if (islower(S[cur])) {
    return a[S[cur++] - 'a'];
  }
  switch(S[cur]) {
  case 'T':
    cur++;
    return true;
  case 'F':
    cur++;
    return false;
  case '-':
    cur++;
    return !(formula());
  default:
    assert(S[cur++] == '(');
    bool x = formula();
    char p = S[cur++];
    if (p == '-') cur++;
    bool y = formula();
    assert(S[cur++] == ')');
    switch (p) {
    case '*':
      return x && y;
    case '+':
      return x || y;
    default:
      assert(p == '-');
      return !(x && !y);
    }
  }
}

bool equation() {
  bool l = formula();
  assert(S[cur++] == '=');
  bool r = formula();
  return l == r;
}

int main() {
  while (cin >> S && S != "#") {
    for (auto i=0; i < (1 << 11); i++) {
      cur = 0;
      for (auto j=0; j<11; j++) {
	a[j] = (i >> j) & 1;
      }
      if (!equation()) {
	cout << "NO" << endl;
	goto EXIT;
      }
    }
    cout << "YES" << endl;
  EXIT: continue;
  }
}

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

int enum_div(int n) {
  vector<int> ret;
  for(int i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      ret.push_back(i);
      if(i != 1 && i*i != n) {
        ret.push_back(n/i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret.size();
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(i%2 == 1 && enum_div(i) == 7) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import Counter
def solve():
    ans = 0
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    cum = [0]*(N+1)
    for i in range(N):
        cum[i+1] = (cum[i]+A[i])%K
    for i in range(N):
        cum[i+1] = (i+1-cum[i+1])%K
    if N<K:
        c = Counter(cum)
        for v in c.values():
            ans += v*(v-1)//2
    else:
        c = Counter(cum[:K-1])
        for i in range(N):
            c[cum[i]] -= 1
            if i+K-1<=N:
                c[cum[i+K-1]] += 1
            ans += c[cum[i]]
    return ans
print(solve())

Measured memory_bytes: 42720
<?php
$n = 0;
$m = 0;
fscanf(STDIN, '%u %u', $n, $m);
$input = fgets(STDIN);

$votes = explode(' ', trim($input));
$total_votes = array_sum($votes);
$min_votes = (float)$total_votes / (float)(4 * $m);
$popular = 0;
foreach ($votes as $vote) {
	if ($vote >= $min_votes) {
		$popular++;
	}
	if ($popular >= $m) {
		echo "Yes";
		exit;
	}
}
echo 'No';


Measured memory_bytes: 4728
main(n,x,j,s,c){for(;;){scanf("%d%d",&n,&x);if(n+x==0)exit(0);for(c=0;n>2;n--)for(s=x-n,j=1;j<--s&j<n;j++)if(0<s&s<n)c++;printf("%d\n",c);}}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

string S;

bool C(string s){
    int a=0;
    reps(i,1,12){
        int q=i+1;
        if(i>=7)q-=6;
        a+=(s[i]-'0')*q;
    }
    if(a%11<=1)a=0;
    else a=11-a%11;
    return s[0]-'0'==a;
}

signed main(){
    cin>>S;
    reverse(all(S));

    int idx=find(all(S),'?')-S.begin();
    int ans,cnt=0;
    rep(i,10){
        string s=S;
        s[idx]='0'+i;
        if(C(s)){
            cnt++;
            ans=i;
        }
    }

    if(cnt==1)cout<<ans<<endl;
    else cout<<"MULTIPLE"<<endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    string t, h;
    int tpoint=0, hpoint=0;
    for(int i=0; i<n; i++){
        cin >> t >> h;
        if(t<h){
            hpoint+=3;
        }
        else if(t>h){
            tpoint+=3;
        }
        else{
            tpoint+=1;
            hpoint+=1;
        }
    }
    cout << tpoint << " " << hpoint << endl;
    return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<vector>
#define VAL 55
using namespace std;
using lli = long long int;
lli dp[VAL][VAL][VAL][VAL]; // 曲，サイリウム数，状態1，状態2

int main(){
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < VAL*VAL*VAL*VAL; i++) {
    const int x = VAL*VAL*VAL, y = VAL*VAL, z = VAL;
    dp[i/x][(i/y)%z][(i/z)%z][i%z] = -1e17;
  }
  vector<vector<lli> > music(n, vector<lli>(3));
  for (int i = 0; i < n; i++) {
    int x, y, z;
    std::cin >> x >> y >> z;
    music[i][0] = x;
    music[i][1] = y;
    music[i][2] = z;
  }
  dp[0][m][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= m; j++) {
      for (int k = 0; k <= min(8, j); k++) {
        for (int a = 0; a <= 8; a++) {//状態1
          for (int b = 0; b <= 8; b++) {//状態2
            if(dp[i][j][a][b] == -1e17)continue;
            lli cost = -1e17;
            if(min(k, 8)*music[i][0] + min(a, 8 - min(k, 8))*music[i][1] > 0)
              cost = max(cost, min(k, 8)*music[i][0] + min(a, 8 - min(k, 8))*music[i][1]);
            if(min(k, 8 - min(a, 8))*music[i][0] + min(a, 8)*music[i][1] > 0)
              cost = max(cost, min(k, 8 - min(a, 8))*music[i][0] + min(a, 8)*music[i][1]);
            if(k > 0)cost = max(cost, music[i][0]);
            if(a > 0)cost = max(cost, music[i][1]);
            cost = max(cost, music[i][2]);
            dp[i + 1][j - k][k][a] =
              max(dp[i + 1][j - k][k][a], dp[i][j][a][b] + cost);
          }
        }
      }
    }
  }
  lli ans = -1e17;
  for (int i = 0; i <= 50; i++) {
    for (int j = 0; j <= 50; j++) {
      for (int k = 0; k <= 50; k++) {
        ans = max(ans, dp[n][i][j][k]);        
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}




Measured memory_bytes: 74640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int n,fac[200005],inv[200005],f[200005],g[200005],root,siz[200005],ans[200005];
vector<int> v[200005];
int qpow(int x,int y){
    int res = 1;
    while(y){
        if(y&1) res = (ll)res * x % mod;
        x = (ll)x*x%mod;
        y>>=1;
    }
    return res;
}
int getinv(int x){
    return qpow(x, mod - 2);
}
int dfs1(int x,int fa){
    siz[x]++;
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        siz[x] += dfs1(to,x);
    }
    return siz[x];
}
int C(int x,int y){
    if(x < y || x < 0 || y < 0) return 0;
    return (ll)fac[x] * inv[y] % mod * inv[x - y] % mod;
}
map<ll,int> vals[200005];
void dfs(int x,int fa){
    int cur = 1,rest = siz[x] - 1;
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        dfs(to,x);
        cur = (ll)cur * f[to] % mod * C(rest,siz[to]) % mod;
        rest -= siz[to];
    }
    f[x] = cur;
}
void dfs2(int x,int fa){
    ans[x] = (ll) f[x] * g[x] % mod * C(n - 1,siz[x] - 1) % mod;
    ll product = 1;
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        product = product * f[to] % mod;
    }
    rap(i,0,v[x].size()){
        int to = v[x][i];
        if(to == fa) continue;
        g[to] = (ll)g[x] * C(n - siz[to] - 1,n - siz[x]) % mod;
        g[to] = (ll)g[to] * product % mod * getinv(f[to]) % mod;
        if(vals[x].find(siz[to]) != vals[x].end()) g[to] = (ll)g[to] * vals[x][siz[to]] % mod;
        else {
            int rest = siz[x] - 1 - siz[to];ll calcing = 1;
            rap(j,0,v[x].size()) if(i != j){
                int to2 = v[x][j];
                if(to2 == fa) continue;
                calcing = (ll) calcing * C(rest, siz[to2]) % mod;
                rest -= siz[to2];
            }
            g[to] = (ll)g[to] * calcing % mod;
            vals[x][siz[to]] = calcing;
        }
        dfs2(to,x);
    }
}
int main()
{
    scanf("%d",&n);
    rep(i,2,n){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        v[t1].pb(t2);
        v[t2].pb(t1);
    }
    fac[0] = 1;rep(i,1,n) fac[i] = (ll)fac[i-1] * i % mod;
    rep(i,0,n) inv[i] = getinv(fac[i]);
    rep(i,1,n) if(v[i].size() == 1) {root = i;break;}
    g[root] = 1;
    dfs1(root,0);
    dfs(root,0);
    dfs2(root,0);
    rep(i,1,n) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 39040
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int i;
  int abc[3],ans=3;
  rep(i,0,3)cin>>abc[i];
  rep(i,0,2)
    rep(j,i+1,3)
      if(abc[i]==abc[j])
        --ans;
  if(ans==0)ans=1;
  cout<<ans<<endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define pi 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define inf -1
int main()
{
    FIO;

    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    n = n%10;
    if(n==2||n==4||n==5||n==7||n==9)
        return cout<<"hon"<<endl, 0;
    if( n== 0||n==1||n==6||n==8)
        return cout<<"pon"<<endl, 0;
    else cout<<"bon"<<endl;
}


Measured memory_bytes: 3612