akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int N;
    cin >> N;
    int X;
    reps(i,50000){
        X = (int)(i*1.08);
        if(X == N){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}


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


int main() {
	
	int N, M, x;
	cin >> N >> M >> x;
	int cntn = 0;
	int cnt0 = 0;
	for(int i=0; i<M; i++){
		int a;
		cin >> a;
		if(x<a) cntn++;
		else cnt0++;
	}
	cout << min(cntn, cnt0) << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
    exit(0)
# Nは1じゃない状態
elif N == 1:
    N, M = M, N
if M == 1:
    print(N - 2)
    exit(0)

corner = 4
edge = (N - 2) * 2 + (M - 2) * 2

print(N * M - corner - edge)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;
#define MX 200005
ll fact[MX];
ll invfact[MX];

ll mod_pow(ll x, ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if(n & 1) res = res * x % mod;
  return res;
}
ll mod_comb(ll n, ll k, ll p){
  if(n<0 || k<0 || n<k) return 0;
  return (((fact[n] * invfact[k]) % MOD) * invfact[n-k]) % MOD;
}
void comb_init(){
  fact[0] = fact[1] = 1;
  for(ll i=2; i<MX; i++) fact[i] = (fact[i-1] * i) % MOD;
  invfact[0] = invfact[1] = 1;
  for(ll i=2; i<MX; i++) invfact[i] = mod_pow(fact[i], MOD-2, MOD);
}
ll dp[3005];

ll calc(int r, int c){
  return mod_comb(r-1+c-1,c-1, MOD);
}

int main(){
  comb_init();
  int H, W, N;
  cin >> H >> W >> N;
  vector<vector<int>> v;
  rep(i,N){
    int r, c;
    cin >> r >> c;
    v.push_back({r,c});
  }
  v.push_back({H,W});
  sort(ALLOF(v));

  rep(i,v.size()){
    int r = v[i][0], c = v[i][1];
    ll ret = calc(r,c);
    rep(j,v.size()){
      if(i==j) continue;
      int tr = v[j][0], tc = v[j][1];
      if(r<tr || c<tc) continue;
      ll tmp = (dp[j] * calc(r-tr+1,c-tc+1)) % MOD;
      ret += MOD - tmp;
      ret %= MOD;
    }
    dp[i] = ret;
  }
  
  cout << dp[v.size()-1] << endl;
  
  return 0;
}


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

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

    int a[100] = {0,};

    for (int i=0; i<N; i++)
        cin >> a[i];

    int max = -1;
    int min = 1000;

    for (int i=0; i<N; i++) {
        max = std::max(max, a[i]);
        min = std::min(min, a[i]);
    }

    cout << max - min << endl;
}

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


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

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

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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

ll gcd(ll a, ll b) {
  ll greater = max(a, b), less = min(a, b);
  ll remainder = greater % less;

  if(remainder == 0) {
    return less;
  } else {
    return gcd(less, remainder);
  }
}

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

  ll ans = 1;
  rep(i, n) {
    ll t;
    cin >> t;
    ll g = gcd(ans, t);
    ans = ans / g * t;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力
const int MAX = 510000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

    ll M;
    cin >>M;
    vector<ll>d(M);
    vector<ll>c(M);

    rep(i,M)cin>>d[i]>>c[i];
    ll now = 0;
    ll ans = 0;
    rep(i,M){
        now+=d[i]*c[i];
        ans+=c[i];
    }
    ans--;
    /*ll tmp;
    while(now>9){
        tmp =0;
        while(now){
            tmp += now%10;
            now/=10;
            ans++;
        }
        ans--;
        now=tmp;
    }*/

    cout << ans+(now-1)/9 << endl;


    return 0;
    

}

Measured memory_bytes: 6320
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//
const int N = 200010;

vi adj[N], dp(N), ans(N), inp(N);

void dfs(int cur, int par)
{
    int val , pos;
    pos = lower_bound(dp.begin(), dp.end(), inp[cur]) - dp.begin();
    val = dp[pos];
    dp[pos] = min(dp[pos], inp[cur]);
    ans[cur] = lower_bound(dp.begin(), dp.end(), INT_MAX) - dp.begin() - 1;
    for(auto node: adj[cur])
        if(node != par)
            dfs(node, cur);
    dp[pos] = val;
}

int32_t main()
{
    io;
    int n;
    cin>>n;
    for(int i = 1; i<= n; i++)
        cin>>inp[i];
    for(int i = 1; i< n;i++)
    {
        int u, v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i = 1; i< N; i++)
        dp[i] = INT_MAX;
    dp[0] = INT_MIN;
    dfs(1, 1);
    for(int i = 1; i<= n; i++)
        cout<<ans[i] <<"\n";
    return 0;
}

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

using namespace std;
using ll = long long;

const int nax = 405;
const ll INF = 1e18L + 5; // 10^18+5
ll dp[nax][nax];
// dp[i][j] - the minimum total cost of combining interval [i,j] into one vertex

signed main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int& x : a) {
        scanf("%d", &x);
    }
    auto sum = [&](int L, int R) {
        ll s = 0;
        for (int i = L; i <= R; i++) {
            s += a[i];
        }
        return s;
    };
    for (int L = n - 1; L >= 0; L--) {
        for (int R = L; R < n; R++) {
            if (L == R) {
                dp[L][R] = 0;
            } else {
                dp[L][R] = INF;
                ll s = sum(L, R);
                for (int i = L; i <= R - 1; i++) {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s);
                }
            }
        }
    }    
    printf("%lld\n", dp[0][n - 1]);
    return false;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
 
int main()
{
	int x,y,z;
	cin >> x >> y >> z;
	cout << z << " " << x << " " << y << endl;
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint ret = 0;
    for (int i = 1; i < n; ++i) {
        ret += i;
    }
    cout << ret << "\n";
    return 0;
}

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

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

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}


int main() {
  int N,X;
  cin>>N>>X;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  vector<int> S(N);
  for(int i=0;i<N;i++){
    S.at(i)=abs(vec.at(i)-X);
  }
  if(N==1) cout<<S.at(0)<<endl;
  else{
    int a=gcd(S.at(0),S.at(1));
    for(int i=2;i<N;i++){
      a=gcd(a,S.at(i));
    }
    cout<<a<<endl;
  }
            
    
  
    
  
}


Measured memory_bytes: 3984
import sys
import numpy as np

ri = lambda: int(sys.stdin.readline())
rl = lambda: list(map(int, sys.stdin.readline().split()))

D = ri()
c = np.array(rl())
s = np.array([np.array(rl()) for _ in range(D)])
li = np.zeros(26)
li_one = np.ones(26)
c_sum = sum(c)
for lis in s:
  tmp_list = lis ** 2 / c**0.01
  idx_list = np.argsort(tmp_list)[::-1]
  li += li_one
  max_idx = 0
  max_score = -10**10
  for i in idx_list:
    tmp = li
    li[i] = 0
    sum_c_li = np.sum(c*li)
    score = lis[i] - sum_c_li
    if score > max_score:
      max_idx = i
      max_score = score
    li = tmp
  print(max_idx + 1)


  

Measured memory_bytes: 27284
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;

bool prime(int x){
  if(x == 2) return true;
  if(!(x & 1)) return false;
  for(int i = 3; i * i <= x; i += 2) if(!(x % i)) return false;
  return true;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int k; cin>>k;
  while(!prime(k)) k++;
  cout<<k<<endl;		    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }
#define INF           1e9
#define INFL          static_cast<lint>(INF)
#define REP(i,n)      for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)     for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)     for(lint i=n-1;i>=0;--i)
#define REPR1(i,n)    for(lint i=n;i>0;--i)
#define REPI(i,ini,n) for(lint i=(ini),i##_len=(n);i<i##_len;++i)
#define REPC(i,obj)   for(auto i:obj)
#define R_UP(a,b)     (((a)+(b)-1)/(b))
#define ALL(obj)      (obj).begin(),(obj).end()
int main()
{
	int n = in();
	vector<int>a(n);
	REPC(&i, a) i = in();
	REP(i, n)
	{
		if (i != 0)cout << ' ';
		cout << a[i];
	}
	cout << endl;
	REP1(i, n - 1)
	{
		int foo = a[i];
		int j;
		for (j = i - 1; j >= 0 && a[j] > foo; j--)
		{
			a[j + 1] = a[j];
		}
		a[j + 1] = foo;
		REP(j, n)
		{
			if (j != 0)cout << ' ';
			cout << a[j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3092
#include<stdio.h>

int main(void){
    
    int n,x;
    int i,j,k;
    int c;
    
    while(1){
        c=0;
        scanf("%d %d",&n,&x);
        if(n==0 && x==0)
            break;
        for(i=1;i<=n;i++){
            for(j=i+1;j<=n;j++){
                for(k=j+1;k<=n;k++){
                    if(i+j+k==x){
                        c++;
                    }
                }
            }
        }printf("%d\n",c);
    }

    return 0;
        
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();

		int sum = 0;

		for(int i = 0; i < k; i++) {
			if(a > 0) {
				sum++;
				a--;
			}else if(b > 0) {
				b--;
			}else if(c > 0) {
				sum--;
				c--;
			}
		}

		System.out.println(sum);

		sc.close();
	}
}


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

using namespace std;

int64_t f(int64_t n, int64_t k) {
    return n/k;
}

int64_t g(int64_t x) {
    return x*x*x;
}

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

    if(K%2) {
        cout << g(f(N, K)) << endl;
    } else {
        cout << g(f(N, K)) + g(f(N, K/2) - f(N, K)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int a[200010],sum;
int main(){
	int n,i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),sum^=a[i];
	for(i=1;i<=n;i++)printf("%d ",sum^a[i]);
	return 0;
}

Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define MAX (ll)(1e5 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;
using ld = long double;

vector<pair<int, int>> gr[MAX];
int cl[MAX];

void dfs (int node, int par, int col) {
	int cc = 1;
	for (auto x : gr[node]) {
		if (x.first != par) {
			if (cc == col) {
				cc++;
			}
			cl[x.second] = cc;
			dfs (x.first, node, cc++);
		}
	}
}
			

int main () {
	int n;
	cin >> n;
	int ma = 0;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		gr[a].push_back (make_pair (b, i));
		gr[b].push_back (make_pair (a, i));
		ma = max (ma, (int)gr[b].size ());
		ma = max (ma, (int)gr[a].size ());
	}
	dfs (1, 0, 0);
	cout << ma << "\n";
	for (int i = 0; i < n - 1; i++) {
		cout << cl[i] << "\n";
	}
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
//ワーシャルフロイゼ法(隣接行列を受け取り、それぞれの最短を受け取る、size:10^2-)
vector<vector<long long>> WarshallFloyd(vector<vector<long long>> &pathmatrix){
    int index=pathmatrix.size();
    vector<vector<long long >>res=pathmatrix;
    for (int a = 0; a < index; a++){
        for (int b = 0; b < index; b++){
            for (int c = 0; c < index; c++){ 
                chmin(res[b][c], res[b][a] + res[a][c]);
            }
        }
    }
    return (res);
}
int main(){
    int h,w;
    ll ans=0;
    cin >>h>>w;
    VV a(h,V(w,-1));
    VV map(12,V(12,INF));
    rep(i,10){
        rep(j,10){
            cin>>map[i][j];
        }
    }
    map=WarshallFloyd(map);
    rep(i,h){
        rep(j,w){
            cin>>a[i][j];
            if(a[i][j]!=-1 and a[i][j]!=1){
                ans+=map[a[i][j]][1];
            }
        }
    }
    cout<<ans<<endl;
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int n,l;
    cin>>n>>l;
    vector<string> a(n);
    FOR(i,0,n) cin>>a[i];
    sort(a.begin(),a.end());
    FOR(i,0,n) cout<<a[i];
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		sc.close();
		out.println(n+n*n+n*n*n);
	}
}


Measured memory_bytes: 26828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    string s;
    int k;
    cin >> s >> k;
    map<string,ll> mp;

    for (int i = 0;i < s.size();i++){
        for (int j = 1;j <= k;j++){
            string tmp;
            for (int l = 0;l < j;l++){
                if (i + l >= s.size()) break;

                tmp.push_back(s[i+l]);
            }
            mp[tmp]++;
        }
    }

    int count = 0;
    for (auto out : mp){
        count++;
        if (count == k){
            cout << out.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
vector<pair<long long,long long> > i;
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0;
  cin >>a>>b;
  for(long long n=0;n<a;n++){
    cin>>c>>d;
    i.push_back(make_pair(c,d));
  }
  sort(i.begin(),i.end());
  for(long long n=0;n<a;n++){
    if(b>=i[n].second) e+=i[n].first*i[n].second,b-=i[n].second;
    else{
      e+=i[n].first*b,b=0;
    }
    if(b==0){
      cout <<e<<'\n';
      return 0;
    }
  }
  return (0);
}


Measured memory_bytes: 2548
AV = list(map(int, input().split()))
BW = list(map(int, input().split()))
T=int(input())

diff = abs(AV[0] - BW[0])
vdiff = AV[1] - BW[1]

if (vdiff <= 0):
    print("NO")
else:
    if (vdiff * T >= diff):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9196
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0] + a[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define pp pair<ll,ll>
#define maxn 100005
#define db double
#define mod 998244353
using namespace std;
void solve()
{
	ll n,m;
	cin >> n >> m;
	ll ans=0;
		ans += (n*(n-1))/2;
		ans+=(m*(m-1))/2;
		cout << ans ;
}
int main()
{
	ll t=1,i=1;
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
    std::cout.precision(10);
    std::cout.setf( std::ios::fixed, std:: ios::floatfield ); 
	//cin >> t;
	//cin >> n;
	while(i<=t)
	{
		solve();
		i++;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
	int N,count=0;
	bool flag;
	int m[1000001]={0};
	cin>>N;
	int A[N];
	for(int i=0;i<N;i++){
		cin>>A[i];
		m[A[i]]++;
	}
	for(int i=0;i<N;i++){
		flag=true;
		for(int j=1;j*j<=A[i];j++){
			if(A[i]!=j && m[j]>0 && A[i]%j==0)flag=false;
			else if(A[i]%j==0 && j!=1 &&m[A[i]/j]>0)flag=false;

		}
		if(m[A[i]]>=2)flag=false;
		if(flag)count++;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 8312
#include <stdio.h>

int main () {
	int n, ctr = 0, i = 0;
	scanf("%d", &n);
	char str[n];
	scanf("%s", str);
	
	for (int j = n / 2 ; j < n ; j++) {
		if (n % 2 != 0) {
			ctr++;
			break;
		} 
		else if (str[i] == str[j]) {
			i++;
		} else {
			ctr++;
			break;
		} 
	}
	ctr != 0 ? puts("No") : puts("Yes");
	
	return 0;
}

Measured memory_bytes: 1640
use text_io::*;
use std::process::exit;
use im_rc::HashMap;
use std::cmp::min;

fn main() {
    let mut n: usize = read!();
    let mut v = Vec::new();
    for i in 0..n {
        let mut a: String = read!();
        v.push(a);
    }
    let mut cnt = vec![vec![0; 19]; 19];
    let mut p2 = vec![0; n];
    let mut p5 = vec![0; n];
    for i in 0..n {
        let s = v[i].clone();
        let mut ip:usize = 0;
        let mut dp:usize = 0;
        if let Some(i) = s.find('.') {
            // 入力値が小数の場合
            ip = s[0..i].parse().unwrap();
            let ss:String = s[(i + 1)..].to_string() + "0000000000";
            dp = ss[0..9].parse::<usize>().unwrap()
        } else {
            // 入力値が整数の場合
            ip = s.parse::<usize>().unwrap();
        }
        let mut x = ip * 1_000_000_000 + dp;
        while x % 2 == 0 {
            x /= 2;
            p2[i] += 1;
        }
        while x % 5 == 0 {
            x /= 5;
            p5[i] += 1;
        }
        p2[i] = min(p2[i], 18);
        p5[i] = min(p5[i], 18);
        cnt[p2[i]][p5[i]] += 1;
    }

    let mut ans = 0usize;
    for i in 0..n {
        let remain2 = 18 - p2[i];
        let remain5 = 18 - p5[i];
        for j in remain2..19 {
            for k in remain5..19 {
                ans += cnt[j][k];
            }
        }
        if p2[i] >= remain2 && p5[i] >= remain5 {
            ans -= 1;
        }
    }
    println!("{}", ans / 2);
}

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

int n, a, b, c, d;

int main()
{
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	b *= ((n / a) + ((n % a)?(1):(0)));
	d *= ((n / c) + ((n % c)?(1):(0)));
	printf("%d\n", min(b, d));
}


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

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

int main()
{
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    int ans = 0;
    int tmp = 0;
    rep(i,n-1){
        if(a[i+1] <= a[i]){
            tmp++;
            ans = max(ans,tmp);
        }else{
            tmp = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
#include <fstream>
using namespace std;
typedef pair<int, int>p;
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
vector<long long> divisor(long long n) {
	vector< long long> ret;
	for (long long i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return (ret);
}
struct LazySegmentTree {
private:
	int n;
	vector<int> node, lazy;
	vector<bool> lazyFlag;

public:
	LazySegmentTree(vector<int> v) {
		int sz = (int)v.size();
		n = 1; while (n < sz) n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1, INT_MAX);
		lazyFlag.resize(2 * n - 1, false);

		for (int i = 0; i<sz; i++) node[i + n - 1] = v[i];
		for (int i = n - 2; i >= 0; i--) node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}

	void lazyEvaluate(int k, int l, int r) {
		if (lazyFlag[k]) {
			node[k] = lazy[k];
			if (r - l > 1) {
				lazy[k * 2 + 1] = lazy[k * 2 + 2] = lazy[k];
				lazyFlag[k * 2 + 1] = lazyFlag[k * 2 + 2] = true;
			}
			lazyFlag[k] = false;
		}
	}

	void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			lazyFlag[k] = true;
			lazyEvaluate(k, l, r);
		}
		else {
			update(a, b, x, 2 * k + 1, l, (l + r) / 2);
			update(a, b, x, 2 * k + 2, (l + r) / 2, r);
			node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		}
	}

	int find(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		lazyEvaluate(k, l, r);
		if (b <= l || r <= a) return INT_MAX;
		if (a <= l && r <= b) return node[k];
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};
long long mod = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(16);
	int x, a;
	cin >> x >> a;
	if (x < a)cout << 0;
	else cout << 10;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

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

int main()
{
  int h,w,k;
  cin>>h>>w>>k;
  pair<int,int> start,goal;
  cin>>start.first>>start.second;
  start.first--;start.second--;
  cin>>goal.first>>goal.second;
  goal.first--;goal.second--;
  vector<string> field(h);
  for (int i = 0; i < h; ++i)
  {
    cin>>field[i];
  }
  vector<vector<ll>> distance(h,vector<ll>(w,-1));
  vector<vector<bool>> seen(h,vector<bool>(w,false));
  distance[start.first][start.second]=0;
  queue<pair<int,int>> next;
  next.push(start);
  seen[start.first][start.second]=true;
  while(!next.empty())
  {
    int x=next.front().first;
    int y=next.front().second;
    next.pop();
    for (int i = 0; i < 4; ++i)
    {
      for (int j = 1; j <= k; ++j)
      {
        int nx=x+j*dx[i],ny=y+j*dy[i];
        if(nx<0||nx>=h||ny<0||ny>=w) break;
        if(field[nx][ny]=='@') break;
        if(seen[nx][ny]) 
        {
          if(distance[nx][ny]<distance[x][y]+1) break;
          distance[nx][ny]=min(distance[nx][ny],distance[x][y]+1);
          continue;
        }
        else distance[nx][ny]=distance[x][y]+1;
        seen[nx][ny]=true;
        next.push({nx,ny});
      }
    }
  }

  cout<<distance[goal.first][goal.second]<<endl;
}

Measured memory_bytes: 19996
import java.util.Scanner;

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

		// 入力値の取得
		long H = sc.nextLong();
		
		int count = 0;
		long hp = H;
		while (hp > 1) {
			count++;
			hp = hp / 2;
		}
		
		// 結果の出力
		long nodes = (long) Math.pow(2, count);
		long sum = 0;
		while (nodes >= 1) {
			sum += nodes;
			nodes = nodes / 2;
		}
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
enum{AKI,RED,GREEN,BLUE,YELLOW,PURPLE,JAMA};

int recmap[6][12];
vector<int> map[6];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
typedef pair<int,int> P;

int rec(int fillv,int x,int y,int col){
     if( x<0 || x>5 || y<0 || y > 11) return 0;
     if(recmap[x][y]>-1||map[x][y]!=col) return 0;
     recmap[x][y]=fillv;
     int sum=0;
     for(int i=0;i<4;i++)sum+=rec(fillv,x+dx[i],y+dy[i],col);
     ++sum;
     return sum;
}
void recclear(){
     for(int i=0;i<12;i++){
	  for(int j=0;j<6;j++){
	       recmap[j][i]=-1;
	  }
     }
}

int main(){
     int T;
     cin>>T;
     for(int time=0;time<T;time++){
	  for(int i=0;i<6;i++){
	       map[i].resize(12,0);
	  }
	  for(int i=11;i>-1;i--){
	       for(int j=0;j<6;j++){
		    char a;
		    cin>>a;
		    switch(a){
		    case 'R':
			 map[j][i]=RED;
			 break;
		    case 'G':
			 map[j][i]=GREEN;
			 break;
		    case 'B':
			 map[j][i]=BLUE;
			 break;
		    case 'Y':
			 map[j][i]=YELLOW;
			 break;
		    case 'P':
			 map[j][i]=PURPLE;
			 break;
		    case 'O':
			 map[j][i]=JAMA;
			 break;
		    case '.':
			 map[j][i]=AKI;
		    }
	       }
	  }
	  int count=0;
	  while(1){
	       vector<int> dels;
	       recclear();
	       for(int i=0;i<6;i++){
		    for(int j=0;j<12;j++){
			 if(map[i][j]==AKI||map[i][j]==JAMA)continue;
			 if(rec(i+j*6,i,j,map[i][j])>3){
			      dels.push_back(i+j*6);
			 }
		    }
	       }
	       if(dels.empty())break;
	       count++;
	       bool isdel[6][12]={};
	       for(int i=0;i<6;i++){
		    for(int j=0;j<12;j++){
			 for(int k=0;k<dels.size();k++){
			      if(recmap[i][j]==dels[k])isdel[i][j]=true;
			 }
		    }
	       }
	       for(int i=0;i<6;i++){
		    for(int j=0;j<12;j++){
			 if(map[i][j]==JAMA){
			      bool flag=false;
			      for(int k=0;k<4;k++){
				   if(i+dx[k]<0||i+dx[k]>5||j+dy[k]<0||j+dy[k]>11)continue;
				   if(isdel[i+dx[k]][j+dy[k]]&&map[i+dx[k]][j+dy[k]]!=JAMA){
					flag=true;
					break;
				   }
			      }
			      if(flag)isdel[i][j]=true;
			 }
		    }
	       }
	       for(int i=0;i<6;i++){
		    for(int j=0;j<12;j++){
			 if(isdel[i][j]){
			      map[i][j]=AKI;
			 }
		    }
	       }
	       for(int i=0;i<6;i++){
		    vector<int>::iterator endit=remove(map[i].begin(),map[i].end(),0);
		    map[i].resize(12,0);
		    fill(endit,map[i].end(),0);
	       }
	       /*for(int i=0;i<6;i++){
		 vector<int>::iterator itr=map[i].begin();
		 while(itr!=map[i].end()){
		 cout<<*itr;
		 itr++;
		 }
		 cout<<endl;
		 }
		 cout<<endl;*/
	  }
	  cout<<count<<endl;
     }
}

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

int main(){
	int n;
	cin >> n;
	string s[n];
	for(int i = 0; i < n; i++){
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	string ans = s[0];
	for(int i = 1; i < n; i++){
		string dp[ans.size() + 1][s[i].size() + 1]{};
		for(int j = 0; j < ans.size(); j++){
			for(int k = 0; k < s[i].size(); k++){
				if(ans[j] == s[i][k]){
					dp[j + 1][k + 1] = dp[j][k] + ans[j];
				}else{
					dp[j + 1][k + 1] = max(dp[j][k + 1], dp[j + 1][k]);
				}
			}
		}
		ans = dp[ans.size()][s[i].size()];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
program name
    implicit none
    integer(4):: d,g
    integer(4),allocatable:: p(:),c(:)
    integer(4):: i,scr,slv,ans = 1000000000

    read*, d,g
    allocate(p(d),c(d))

    do i=1,d
        read*,p(i),c(i)
    end do


    do i= 0,2**d-1
        call calc_point(i,scr,slv)
        if (scr < g) cycle
        ans = min(ans,slv)
    end do

    print*, ans

    contains
    subroutine calc_point(num,score,solve)
        integer(4),intent(in):: num
        integer(4),intent(out):: score, solve
        integer(4):: i, max_not_solve, max_limit
        score=0
        solve=0
        max_not_solve = 0
        max_limit = 0

        do i=1,d
            if (and(rshift(num,i-1),1) == 1) then
                score=score + 100*i*p(i) + c(i)
                solve=solve + p(i)
            else
                max_not_solve = max(max_not_solve, 100*i)
                max_limit = p(i)
            end if
        end do

        if (score < g) then
            do i=1,max_limit-1
                score = score + max_not_solve
                solve = solve + 1
                if (score >= g) exit
            end do
        end if
    end subroutine
end program name

Measured memory_bytes: 384
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        boolean flag = true;
        for(int i=0;i<n;i++) flag &= (a[i]%2==0);
        String ans = flag?"second":"first";
        System.out.println(ans);
    }
}

Measured memory_bytes: 53016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree< pair<int,int>, null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update>Order_Set;

Order_Set X;

const int mxn = 1e5+100;
const int mod = 1e9+7;

long long arr[mxn];
int bitOn[55];
map<int,int>Mp;
vector<pair<long long,int> >Pi;
vector<int>v;
set<int>seet;

bool cmp(pair<long long, int>a, pair<long long, int>b)
{
    if(a.first < b.first) return true;
    else if(a.first == b.first and a.second > b.second) return true;
    return false;
}

int main()
{
    ios::sync_with_stdio(false);

      long long n, k;
      cin>>n>>k;

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

       int cnt;
       long long x = 0;

       for(int i=50 ; i>=0 ; i--){
            cnt = 0;
            for(int j=0 ; j<n ; j++){
                if((arr[j]>>i) & 1) cnt++;
            }
            if(cnt < n-cnt and (x+(1LL<<i)) <= k) x+=(1LL<<i);
       }

        long long Ans = 0;
        for(int i=0 ; i<n ; i++) Ans+=(x ^ arr[i]);
        cout<<Ans<<endl;

       return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int ans = -1, count = 1, a = data.at(0);
  while(true) {
    if (a == 2) {
      ans = count;
      break;
    }
    a = data.at(a - 1);
    count++;
    if(count == N + 1) break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n, d = map(int, input().split())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i], y[i] = map(int, input().split())
ans = 0
for i in range (n):
  direct = (x[i]**2 + y[i]**2)**(1/2)
  if direct <= d:
    ans = ans +1
print(ans)

Measured memory_bytes: 24608
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
#include <bits/stdc++.h>
using namespace std;
int main(){
  char c;
  std::cin >> c;
  std::cout << char(c+1) << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
map<pair<int,int> , int>mp;
set<pair<int,int> >st;
int ans[11];
int dx[] = {0,0,0,1,1,1,-1,-1,-1};
int dy[] = {0,1,-1,0,1,-1,0,1,-1};
int n,m;
void solve(int i , int j)
{
    if(st.count({i,j})) return;
    st.insert({i,j});
    int sum = 0;
    for(int k = 0 ; k<9 ; ++k)
    {
        int x = i + dx[k];
        int y = j + dy[k];
        if(x <= 0 || x>n || y<=0 || y>m) return;
            sum += mp.count({x,y});
    }
    ans[sum]++;
}
void tr(int i , int j)
{
    for(int k = 0 ; k<9 ; ++k)
    {
        int x = i + dx[k];
        int y = j + dy[k];
        if(x > 0 && x<=n && y>0 && y<m) solve(x,y);
    }
}
pair<int,int>pr[100100];
int main()
{
    int cnt;
    cin>>n>>m>>cnt;
    for(int i = 0 ; i<cnt ; ++i)
    {
        int x,y;
        scanf("%d%d" , &x ,  &y);
        mp[{x,y}] = 1;
        pr[i] = {x,y};
    }
    for(int i = 0 ; i<cnt ; ++i) tr(pr[i].first ,pr[i].second );
    long long sum = 0;
    for(int i = 1 ; i<10 ; ++i) sum += ans[i];
    sum = 1ll*(n-2)*(m-2) - sum;
    cout<<sum<<endl;
    for(int i = 1 ; i<10 ; ++i) printf("%d\n" , ans[i]);
    return 0;
}


Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,cnt[80][40],ans;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n){
        string s,a="",b="";
        cin>>s;
        bool flag=false;
        for(char c:s){
            if(!flag){
                if(c=='.')flag=true;
                else a+=c;
            }
            else{
                b+=c;
            }
        }
        string c=a+b;
        int q=1,p=stoll(c);
        rep(_,b.size())q*=10;
        int g=gcd(p,q);
        p/=g,q/=g;
        P x={0,0};
        if(p%2==0){
            while(p%2==0){
                p/=2;
                x.fi++;
            }
        }
        else{
            while(q%2==0){
                q/=2;
                x.fi--;
            }
        }
        if(p%5==0){
            while(p%5==0){
                p/=5;
                x.se++;
            }
        }
        else{
            while(q%5==0){
                q/=5;
                x.se--;
            }
        }
        for(int k=30-x.fi;k<=73;k++){
            for(int l=15-x.se;l<=33;l++){
                ans+=cnt[k][l];
            }
        }
        cnt[30+x.fi][15+x.se]++;
    }
    cout<<ans<<endl;
    return 0;
}

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


int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int>>A(r,vector<int>(c));
    vector<int>ans(c);
    int sum=0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> A[i][j];
            cout << A[i][j] << ' ';
            sum+=A[i][j];
            ans[j]+=A[i][j];
        }
        cout << sum << endl;
        sum=0;

    }
    for(int i=0; i<c; i++){
        cout << ans[i] << ' ';
        sum+=ans[i];
    }
    cout << sum << endl;



}


Measured memory_bytes: 3140
#define N 100000

int partition(int*,int,int);

int main(){
  int n,i,A[N],q;

  scanf("%d",&n);
  for(i = 0; i < n; i++)
    scanf("%d",&A[i]);
  q = partition(A,0,n-1);
  for(i = 0; i < n; i++) {
    if(i>0) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");
  return 0;
}

int partition(int A[],int p,int r){
  int x,i,j,a,b;

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

  for(j = p; j <= r-1; j++){
    if(A[j] <= x){
      i = i + 1;
      a = A[j];
      A[j] = A[i];
      A[i] = a;
    }
  }
  b = A[r];
  A[r] = A[i+1];
  A[i+1] = b;

  return i+1;
  
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    int cnt=0,ans=0;
    rep(i,n){
        cin>>a[i]>>b[i];
        if(a[i]==b[i]) cnt++;
        else{
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    ans=max(ans,cnt);
    if(ans>=3) cout<<"Yes";
    else cout<<"No";
}

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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };


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

	ll n, w, m, k, h, ans = 0;

	cin >> n;
	vector<double> p(n);
	rep(i, n) cin >> p[i];
	double dp[3010][3010];
	memset(dp, 0.0, sizeof dp);

	dp[0][0] = 1.0;
	rep(i, n) {
		rep(j, i + 1) {
			dp[i + 1][j + 1] += dp[i][j] * p[i];
			dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
		}
	}

	/*rep(i, n) {
		rep(j, n) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/

	double res = 0.0;
	REP(i, (n + 1) / 2, n+1) res += dp[n][i];
	cout << fixed << setprecision(10) << res << endl;
	return 0;
}


Measured memory_bytes: 71040
h,w=map(int, input().split())
t=[["."]*(w+2)]+[["."]+list(input())+["."] for _ in range(h)]+[["."]*(w+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if t[i][j]==".":continue
        if t[i-1][j]=="." and t[i+1][j]=="." and t[i][j-1]=="." and t[i][j+1]==".":
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
	char c;
	//int w = 0;
	int b = 0;
	long long  ans = 0;
 
	while (cin >> c) {
		if (c == 'W'){
		//	w++;
			ans += b;
		}
		else
		{
			b++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#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, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vvl G = VVL(N, N, llINF);
  vvl A = VVL(N, N, 0);
  vl as(M, 0), bs(M, 0);

  REP(i, M) {
    ll c;
    cin >> as[i] >> bs[i] >> c;
    as[i]--;
    bs[i]--;
    G[as[i]][bs[i]] = c;
    G[bs[i]][as[i]] = c;
  }
  REP(i, N) G[i][i] = 0;
  REP(k, N) {
    REP(i, N) {
      REP(j, N) {
        if (G[i][j] > G[i][k] + G[k][j]) {
          A[i][j] = 1;
          A[j][i] = 1;
        }
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  ll ans = 0;
  REP(i, M) {
    if (A[as[i]][bs[i]] == 1)
      ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

int main()
{
  ios::sync_with_stdio(false);
  int n ,m;
  cin>>n>>m;
  vector<int>a(m+1);
  for(int i=0;i<n;i++)
  {
    int k;
    cin>>k;
    for(int j=0;j<k;j++)
    {
      int tmp;
      cin>>tmp;
      a[tmp]+=1;
    }
  }
  int res=0;
  for(int i=0;i<m+1;i++)
  {
    res+=a[i]==n;
  }
  cout<<res;
  return 0;
}

Measured memory_bytes: 256