akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)
//by war
//2019.9.12
using namespace std;
int n,cnt,flag,t,ans;
int a[N];
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(n);
    For(i,1,n) in(a[i]);
    sort(a+1,a+n+1);
    For(i,2,n)
    	if(a[i]==a[i-1]) cnt++;
    if(cnt&1) cnt++;
    o(n-cnt);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, K, k = 0; cin >> A >> B >> K;
  for(int i = 100; i > 0; i--) {
    if((A % i == 0) && (B % i == 0)) k++;
    if(k == K) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (v[i] == v[j]) continue;
            for (int k = j + 1; k < n; k++) {
                if (v[j] == v[k]) continue;
                if (v[i] + v[j] > v[k]) res++;
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
//#include<cstdio>//"scanf("%lf",&(double型変数));printf("%f",(double型変数));"
//#include<iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include<string>//"reverse(s's it,s's it)"
//#include<functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include<cmath>//"abs" "sqrt"
//#include<numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include<algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
//#include<cassert>//"assert(cond);": error if cond doesn't hold.
using namespace std;
#define pb push_back//also for STRING
#define fi first
#define sc second
#define mp make_pair
#define is insert//also use as v.is(v's it,w's it,w's it);
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().
typedef long long ll;//not necessarily
typedef pair<int,int> pii;
typedef pair<pii,int> pt;

vector<int> par,rk;

void init(const int n){
	par.resize(n);
	rk.resize(n);
	for(int i=0;i<n;++i) par[i]=i;
	fill(rk.begin(),rk.end(),0);
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x,int y){
	x=find(x);
	y=find(y);
	if(x==y){
		return;
	}else if(rk[x]<rk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rk[x]==rk[y]){
			++rk[x];
		}
	}
}

bool same(int x,int y){
	return find(x)==find(y);
}

struct edge{
	int from,to,cost;
};

#define MAX_N 100000

vector<edge> es;
pt p[MAX_N];
int prv[MAX_N];

bool cmp_pt(pt p,pt q){
	if(p.fi.fi!=q.fi.fi) return p.fi.fi<q.fi.fi;
	else return p.fi.sc<q.fi.sc;
}

bool cmp_ed(edge e,edge f){
	return e.cost<f.cost;
}

int d(int i,int j){
	return min(abs(p[i].fi.fi-p[j].fi.fi),abs(p[i].fi.sc-p[j].fi.sc));
}

int main(){
	int n;
	scanf("%d\n",&n);
	for(int i=0;i<n;++i){
		cin>>p[i].fi.fi>>p[i].fi.sc;
		p[i].sc=i;
	}
	//printf("initializing points: fin\n");
	for(int k=0;k<2;++k){
		sort(p,p+n,cmp_pt);
		//printf("%d; sorting points: fin\n",k);
		for(int i=0;i<n;++i){
			if(i>0&&p[i].fi.fi==p[i-1].fi.fi){
				prv[i]=prv[i-1];
				es.pb((edge){p[i-1].sc,p[i].sc,0});
			}else prv[i]=i;
		}
		//printf("%d; spanning the 1st kind of edges: fin\n",k);
		for(int i=n-1;prv[i]>0;--i){
			int ub=prv[i]-1;
			if(p[ub].fi.sc<=p[i].fi.sc) es.pb((edge){p[ub].sc,p[i].sc,d(ub,i)});
			else{
				int lb=prv[ub];
				while(ub-lb>1){
					int mid=(ub+lb)/2;
					if(p[mid].fi.sc<=p[i].fi.sc) lb=mid;
					else ub=mid;
				}
				if(p[ub].fi.sc-p[i].fi.sc<p[i].fi.sc-p[lb].fi.sc) es.pb((edge){p[ub].sc,p[i].sc,d(ub,i)});
				else es.pb((edge){p[lb].sc,p[i].sc,d(lb,i)});
			}
		}
		//printf("%d; spanning the 2nd kind of edges: fin\n",k);
		for(int i=0;i<n;++i) swap(p[i].fi.fi,p[i].fi.sc);
		//printf("%d; fin\n",k);
	}
	sort(es.begin(),es.end(),cmp_ed);
	//printf("sorting edges: fin\n");
	init(n);
	//printf("initializing the unionfind: fin\n");
	int sc=0;
	//for(int j=0;j<es.size();++j){
	//	cout<<es[j].from<<" "<<es[j].to<<endl;
	//}
	for(int e=0,j=0;e<n-1;++j){
		int v=es[j].from,w=es[j].to;
		if(same(v,w)) continue;
		unite(v,w);
		sc+=es[j].cost;
		++e;
	}
	printf("%d\n",sc);
}

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

using namespace std;

int main(int argc, char const* argv[])
{
	bool flag[1000000];
	int p;

	for( int i = 0;i < 1000000;i++ ) flag[i] = true;

	for( int i = 2;i <= sqrt( 1000000 );i++ ){
		if( flag[i] != false ) for( int j = 2;j * i < 1000000;j++ ) flag[j * i] = false;
	}

	while( cin >> p ){
		int count = 0;
		for( int i = 2;i <= p;i++ ) if( flag[i] ) count++;
		cout << count << endl;
	}
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

vi adj[N];
int dp[N];

int dfs(int x){
	if(dp[x] != -1)
		return dp[x];
	if(adj[x].empty())
		return 0;
	int ans = 0;
	for(auto i:adj[x])
		ans = max(ans, 1 + dfs(i));
	return dp[x] = ans;
}

int main(){
	fastio;
	memset(dp, -1, sizeof(dp));
	int n,m;
	cin >> n >> m;
	while(m--){
		int x, y;
		cin >> x >> y;
		adj[x].pb(y);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(dp[i] == -1)
			ans = max(ans, dfs(i));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#define ll long long
#define oku7 1000000007
#define MAXN (int)1e+5 + 2
using namespace std;

char mapData[100][100];
int costData[100][100];
int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位

int main() {
	int H, W, whiteCount=0;
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char s;
			cin >> s;
			mapData[i][j] = s;
			costData[i][j] = -1;
			if (s == '.') whiteCount++;
		}
	}
	//bfs
	queue<pair<int, int>> q;
	pair<int, int> first = make_pair(1, 1);
	q.push(first);
	costData[1][1] = 1;

	while (!q.empty()) {
		pair<int, int> p = q.front(); q.pop();
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx<1 || ny<1 || nx>W || ny>H) continue;
			if (mapData[ny][nx] == '#') continue;
			if (costData[ny][nx] != -1) continue;
			costData[ny][nx] = costData[p.second][p.first] + 1;
			q.push(make_pair(nx, ny));
		}

	}
	if (costData[H][W] == -1) cout << -1 << "\n";
	else cout << whiteCount - costData[H][W] << "\n";



	return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Cake[] cakes = new Cake[n];
		for (int i = 0; i < n; i++) {
		    cakes[i] = new Cake(new long[]{sc.nextLong(), sc.nextLong(), sc.nextLong()});
		}
		Cake.sw = new int[]{1, 1, 1};
		Arrays.sort(cakes);
		long max = getMax(cakes, m);
		Cake.sw = new int[]{-1, 1, 1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		Cake.sw = new int[]{1, -1, 1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		Cake.sw = new int[]{1, 1, -1};
		Arrays.sort(cakes);
		max = Math.max(max, getMax(cakes, m));
		System.out.println(max);
    }
    
    static long getMax(Cake[] cakes, int count) {
        long fore = 0;
        long reer = 0;
        for (int i = 0; i < count; i++) {
            fore += cakes[i].getValue();
            reer += cakes[cakes.length - i - 1].getValue();
        }
        return Math.max(Math.abs(fore), Math.abs(reer));
    }
    
    static class Cake implements Comparable<Cake> {
        static int[] sw;
        long[] values;
        
        public Cake(long[] values) {
            this.values = values;
        }
        
        public long getValue() {
            long ans = 0;
            for (int i = 0; i < 3; i++) {
                ans += sw[i] * values[i];
            }
            return ans;
        }
        
        public int compareTo(Cake another) {
            long x = getValue();
            long y = another.getValue();
            if (x == y) {
                return 0;
            } else if (x < y) {
                return -1;
            } else {
                return 1;
            }
        }
    }
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const int64 mod = 1e9+7;

int main(void) {
	int64 N;
	cin >> N;
	vector<int64> a(N), b(N);
	REP(i, N) cin >> a[i];
	REP(i, N) cin >> b[i];
	int64 na = 0, nb = 0;
	REP(i, N) {
		if (a[i] < b[i]) {
			na += (b[i] - a[i] + 1) /2;
			if (b[i] % 2 != a[i] % 2)
				nb++;
		} else if (a[i] > b[i]) {
			nb += a[i] - b[i];
		}
	}
	if (nb > na) {
		cout << "No" << endl;
	} else if (nb < na) {
		cout << "Yes" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


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

int main() {
 	long long x, y, z;
  	cin >> x >> y >> z;
  	long long ans = y * z;
  	if(ans < x) {
     	 cout << "No\n";
    }
  	else {
     	cout << "Yes\n";
    }
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
char a;
int main()
{
	int n;
	scanf("%c",&a);
	if(a=='A')
	{
		printf("T");
	}
	if(a=='T')
	{
		printf("A");
	}
	
	if(a=='G')
	{
		printf("C");
	}
	if(a=='C')
	{
		printf("G");
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

const int mxN = 1e6 + 5; 
const int M = mod; 

ll fact[mxN];
ll ifact[mxN];

ll power(ll a,ll n) {
	a%=M;
	if(n==0) return 1;
	ll p = power(a,n/2) % M ;
	p = (p*p) % M ;
	return n%2 ? (p*a) % M : p;
}
ll invMod(ll a) {
	return power(a,M-2) % M ;
}
void pre() {
	fact[0] = 1 ;
	for(ll i = 1;i< mxN;++i) 
		fact[i] = ( i * fact[i-1] ) % M ;

	ifact[mxN-1] = invMod(fact[mxN-1]) ; 
	
	for(ll i = mxN-1 ; i>0 ;--i) 
		ifact[i-1] = ( ifact[i] * i ) % M ;
}

ll nCr(ll n, ll r) {
	if (n < r || r < 0 || n < 0) return 0;
	ll res = (ifact[r] * ifact[n-r]) % M ;
	res = ( res * fact[n]) % M ;
	return res ;
}
void solve() {
	pre() ;

	int n;cin >> n ;
	if(n < 2) cout << 0 << nl ;
	else {
		int ans = 0 ; 
		for(int i = 1 ; i < n ; ++i ) {
			ans = (ans + nCr(n,i) * (power(9,n-i)-power(8,n-i)+mod)%mod) % mod ;
		}
		cout << ans ;
	}
}

int32_t main() {

#ifndef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
  void add(int i, T x=1) {//0_index add(i,x) a_i+=x;
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
  T sum(int i) {//0_index sum(i):a_0~a_iの和
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) {//0_index sum(l,r):[a_l,a_r)の和
    return sum(r-1) - sum(l-1);
  }
  void print(){
    for(int i=0;i<n;i++){
      cout << sum(i,i+1);
    }
    cout << endl;
  }
};

int main(){
  int n,q;
  string s;
  cin >> n >> s >> q;
  vector<BIT<int>> bit(26,BIT<int>(n));
  rep(i,n){
    bit[s[i]-'a'].add(i,1);
  }
  //bit[0].print();
  rep(_,q){
    int id;
    cin >> id;
    if(id==1){
      int i;
      char c;
      cin >> i >> c;
      i--;
      bit[s[i]-'a'].add(i,-1);
      bit[c-'a'].add(i,1);
      s[i]=c;
    }else{
      int ans = 0;
      int l,r;
      cin >> l >> r;
      l--,r--;
      rep(j,26){
        if(bit[j].sum(l,r+1))ans++;
      }
      cout << ans << endl;
    }
  }
  return 0;
}


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

void display(int n, int* A) {
	for (int i = 0; i < n-1; i++) {
		cout << A[i] << " ";
	}
	cout << A[n-1] << endl;
}

int main() {
	int n;
	cin >> n;
	int* A=new int[n];
	int temp;

	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	display(n, A);

	for (int i = 1; i < n; i++) {
		temp = A[i];
		int j = i - 1;
		while (j >= 0 && temp < A[j]) {
			A[j + 1] = A[j];
			j--;
		}
		A[j+1] = temp;
		display(n, A);
	}

	
	return 0;
}



Measured memory_bytes: 3092
n = int(input())
a = [int(i) for i in input().split()]
a_dict = {}
for i in a:
  if i not in a_dict:
    a_dict[i] = 1
  else:
    a_dict[i] += 1

q = int(input())

replace = []
for _ in range(q):
  m, n = [int(i) for i in input().split()]
  replace.append((m,n))

res = sum([m*n for m,n in a_dict.items()])

for r in replace:
  if r[0] in a_dict:
    res += (r[1] - r[0])*a_dict[r[0]]
    
    if r[1] in a_dict:
      a_dict[r[1]] += a_dict[r[0]]
    else:
      a_dict[r[1]] = a_dict[r[0]]
    a_dict[r[0]] = 0

  print(res)

Measured memory_bytes: 31332
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	string S;
	cin >> S;
	string ans = "Yes";
	if (S[0] == S[1] && S[1] == S[2])
		ans = "No";


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

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int n;
char s[100005];
ll dp[100005][13];

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

	int a[100000];
	for(int i=0;i<n;i++){
		int t;
		cin >> t;
		a[t-1] = i+1;
	}

	for(int i=0;i<n;i++) cout << a[i] << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1152
#include<cstdio>

int main()
{
	int n,m,h,w;
	scanf("%d%d%d%d",&n,&m,&h,&w);
	if( n%h==0&&m%w==0 )
		return puts("No"),0;
	puts("Yes");

	long long c=(n/h)*(m/w)/((n%h)*m+(m%w)*n-(n%h)*(m%w))+1;
	long long s=(h*w-1)*c+1,t=0;int i,j;
	for(i=1;i<=n;i++,putchar(10))
		for(j=1;j<=m;j++)
			printf("%lld ",i%h==0&&j%w==0?-s:c),t+=i%h==0&&j%w==0?-s:c;
	if(t<=0)return 1;
}

Measured memory_bytes: 1280
#include <iostream>
#include <complex>
#include <cmath>
using namespace std;

typedef complex <double> P;
#define X real()
#define Y imag()

double func(P p1, P p2, P p3, P p4){
	return  ( (p1.X-p2.X)*(p3.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p3.X)) * ((p1.X-p2.X)*(p4.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p4.X));
}

int main(void)
{
	double x1, x2, x3, x4, y1, y2, y3, y4;
	char a;
	
	while (cin>>x1>>a>>y1>>a>>x2>>a>>y2>>a>>x3>>a>>y3>>a>>x4>>a>>y4){
		P a(x1, y1);
		P b(x2, y2);
		P c(x3, y3);
		P d(x4, y4);
		
		if (0.0 < func(a, c, b, d) || 0.0 < func(b, d, a, c)) cout << "NO" << endl;
		else cout << "YES" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
// 2014/08/30 Tazoe

#include <iostream>
using namespace std;

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

	for(int i=0; i<N; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;

		int f1 = x*b+y*p;		// 割引なし

		if(b<5){
			b = 5;
		}
		if(p<2){
			p = 2;
		}
		int f2 = (x*b+y*p)*4/5;		// 割引あり

		if(f1<f2){
			cout << f1 << endl;
		}
		else{
			cout << f2 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

int s[5];

int main()
{
    int n1, n2;
    while(cin >> n1 >> n2 && (n1 || n2))
    {
        s[0] = n1 + n2;
        REP(4){cin >> n1 >> n2; s[i+1] = n1 + n2;}
        int m = 0;

        REP(5)if(s[m] < s[i]) m = i;

        cout <<(char)('A' + m) << " " << s[m] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
 
		if(n == 1){
			System.out.println("Hello World");
		}else{
            int a = sc.nextInt();
		    int b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}



Measured memory_bytes: 22612
#[allow(unused_macros)]
macro_rules! input {
        (source = $s:expr, $($r:tt)*) => {
            let mut iter = $s.split_whitespace();
            let mut next = || { iter.next().unwrap() };
            input_inner!{next, $($r)*}
        };
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! input_inner {
        ($next:expr) => {};
        ($next:expr, ) => {};

        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };

        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }

#[allow(unused_macros)]
macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };

        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };

        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };

        ($next:expr, bytes) => {
            read_value!($next, String).into_bytes()
        };

        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };

        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }

fn main() {
    input! {
            a: u32,
            b: u32,
        }

    let diff = a as i32 - b  as i32;
    let diff = if 0 < diff { diff } else { -diff };

    if diff % 2 == 0 {
        let smaller: i32 = if a < b { a as i32 } else { b as i32 };
        let middle = smaller + (diff / 2);

        println!("{}", middle);
    } else {
        println!("IMPOSSIBLE");
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 100000008;

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int x, a, b;
	cin >> x >> a >> b;
	cout << (abs(x - a) <= abs(x - b) ? 'A' : 'B') << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int n = 0;
	static int[] x = null;
	static int[] y = null;
	static int[] h = null;
	
	public static void main(String[] args) {
		n = sc.nextInt();
		x = new int[n];
		y = new int[n];
		h = new int[n];
		int t = -1;
		for(int i = 0; i < n; ++i) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
			if(t < 0 && h[i] > 0) t = i;
		}
		
		int cx, cy, H;
		for(cx = 0; cx <= 100; ++cx) {
			for(cy = 0; cy <= 100; ++cy) {
				H = Math.abs(x[t] - cx) + Math.abs(y[t] - cy) + h[t];
				boolean isAppropriateH = true;
				for(int i = 0; i < n; ++i) {
					int height = H - Math.abs(x[i] - cx) - Math.abs(y[i] - cy);
					if(h[i] != Math.max(height, 0)) {
						isAppropriateH = false;
						break;
					}
				}
				
				if(isAppropriateH) {
					System.out.printf("%d %d %d\n", cx, cy, H);
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 23764
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll cnt_h[300010] = {}, cnt_w[300010] = {};
ll h[300010], w[300010];
map<lpair, bool> exists;

void solve(){
    ll H,W,M;
    cin >> H >> W >> M;
    rep(i,0,M){
        cin >> h[i] >> w[i];
    }
    ll ans = 0;
    rep(i,0,M){
        cnt_h[h[i]]++;
        cnt_w[w[i]]++;
    }
    ll max_h = 0, max_w = 0;
    rep(i,0,H+1){
        max_h = max(max_h, cnt_h[i]);
    }
    rep(i,0,W+1){
        max_w = max(max_w, cnt_w[i]);
    }
    rep(i,0,M){
        ans = max(ans, cnt_h[h[i]] + cnt_w[w[i]] - 1);
    }
    ll c1 = 0, c2 = 0;
    rep(i,0,H+1){
        if(max_h == cnt_h[i]) c1++;
    }
    rep(i,0,W+1){
        if(max_w == cnt_w[i]) c2++;
    }
    ll max_cnt = c1 * c2;
    ll cnt_exist = 0;
    rep(i,0,M){
        if(cnt_h[h[i]] == max_h && cnt_w[w[i]] == max_w) cnt_exist++;
    }
    if(max_cnt > cnt_exist){
        ans = max(ans, max_h + max_w);
    }else{
        ans = max(ans, max_h + max_w - 1);
    }
    print(ans);

    

}

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

Measured memory_bytes: 12992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n; cin>>n;
	ll a[n+1], b[n], tot =0;
	for(int i = 0 ; i <= n ; i++)cin>>a[i];
	for(int i = 0 ; i < n ; i++) cin>>b[i];
	for(int i = 0 ; i < n ; i++)
	{
		tot+=min(a[i]+a[i+1],b[i]);
		a[i+1] -= min(a[i+1],max(b[i]-a[i],(ll)0));
	}
	cout<<tot<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int r;
    r=a-b;
    r=(c-r);
    if(r<0){
        cout<<"0\n";
    }
    else{
       cout<<r<<"\n";
    }

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N,0);
    vector<ll> B(M,0);
    vector<ll> C(M,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    for(ll i=0;i<M;i++){
        cin>>B[i]>>C[i]
    ;}
    vector<P> deq;
    for(ll i=0;i<N;i++){
        deq.emplace_back(P(A[i],1LL))
    ;}
    for(ll i=0;i<M;i++){
        deq.emplace_back(P(C[i],B[i]))
    ;}
    sort(deq.begin(), deq.end());
    reverse(deq.begin(), deq.end());
    ll ans=0;
    ll point=0;
    for(ll i=0;i<N;i++){
        P T=deq[point];
        ans+=T.first;
        deq[point].second--;
        if(deq[point].second==0){point++;}
    ;}
    cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 8816
using System;

namespace rensyuu1
{

    class Program
    {
        static void Main(string[] args)
        {
            string ccc = Console.ReadLine();
            string[] vbs = ccc.Split(new char[] { ' ' });
            int a = int.Parse(vbs[0]);
            int b = int.Parse(vbs[1]);
            int c = int.Parse(vbs[2]);
            if (a < b && b < c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template <class S>S sum(vector<S>& a) {return accumulate(all(a), S());}
template <class S>S max(vector<S>& a) {return *max_element(all(a));}
template <class S>S min(vector<S>& a) {return *min_element(all(a));}
ll max(int a, ll b) { return max((ll)a, b); } ll max(ll a, int b) { return max(a, (ll)b); }
ll min(int a, ll b) { return min((ll)a, b); } ll min(ll a, int b) { return min(a, (ll)b); }

void eprint() { cerr << endl; }
template <class First, class... Rest>
void eprint(First& f, Rest&... r) {
  cerr << f << ' ';
  eprint(r...);
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  size_t output_num = v.size();
  bool is_omitted = false;
#ifdef OUTPUT_VECTOR_MAX
  if (OUTPUT_VECTOR_MAX < output_num) {
    output_num = OUTPUT_VECTOR_MAX;
    is_omitted = true;
  }
#endif
  os << "[";
  for (size_t i = 0; i < output_num - 1; i++) os << v[i] << ", ";
  os << v[output_num - 1];
  if (is_omitted) os << ", ...";
  return os << "]";
}

void Main();
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

void Main(){
  int n,m; cin >> n >> m;
  dsu d(n);
  Rep(m){
    int a,b; cin >> a >> b;
    a--; b--;
    d.merge(a,b);
  }
  cout << d.groups().size() - 1 << endl;
}

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
using namespace std;

int main() {
  int n;
  cin>>n;
  int ans = 0;
  fr(i,1,n+1) {
    if(i%2==0) continue;
    int f = 0;
    fr(j,1,sqrt(i)+1) {
      if(i%j==0) {
        f++;
        if(i/j!=j)f++;
      }
    }
    if(f == 8) {ans++;}
  }
  cout<<ans;nl;
}

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

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(const auto &buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	int x; cin >> x;
	Loop1(n, x) {
		int l = n * 100;
		int r = n * 105;
		if (l <= x && x <= r) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
int main(){
  long long n,a=1,b=1,x,y;
  cin>>n;
  while(n--){
    cin>>x>>y;
    if(a<=x&&b<=y){
        a=x;
        b=y;
    }
    else{
        a=x*max((a+x-1)/x,(b+y-1)/y);
        b=y*max((a+x-1)/x,(b+y-1)/y);
    }
  }
  cout << a+b << endl;
  return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    i64 cnt = 0;
    i64 p = 10;
    while (N >= p) {
        cnt += N / p;
        p *= 5;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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 ll INF=1e15;

int main(){
    ll x;
    cin >> x;
    vector<ll> p;
    for(ll i=1;i*i<=x;i++){
        if(x%i==0){
            if(i*i==x) p.push_back(i);
            else{
                p.push_back(i);
                p.push_back(x/i);
            }
        }
    }
    sort(p.begin(),p.end());
    for(auto a:p){
        ll i=-a/2-1;
        ll n=i+a;
        //cout <<  i << endl;
        while(n*n*n*n*n-i*i*i*i*i<=x || n+i<0){
            if(n*n*n*n*n-i*i*i*i*i==x){
                cout << n << " " << i << endl;
                return 0;
            }
            //cout << n << " " << i << endl;
            i++;
            n++;
        }
        /*ll y=x-a*a*a*a*a;
        cout << y << " ";
        if(y==0){
            cout << a << " " << 0 << endl;
            return 0;
        }
        for(ll i=5*a;i<=y;i+=5*a){
            if(y%5*i==i*i*i+a*a*a+2*i*a*(i+a)){
                cout << i+a << " " << a << endl;
                return 0;
            }
        }
        y=x+a*a*a*a*a;
        cout << y;
        if(y==0){
            cout << a << " " << 0 << endl;
            return 0;
        }
        for(ll i=5*a;i<=y;i+=5*a){
            ll t=i/5;
            if(y%5*i==(i*i*i-a*a*a-2*i*a*(i-a)){
                cout << i+a << " " << a << endl;
                return 0;
            }
        }
        */
    }
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
int main() {
	int n;
	while (cin >> n, n) {
		int d[16][17] = {};
		rep(i, n) {
			rep(j, n + 1) {
				cin >> d[i][j];
			}
		}
		int dp[1 << 16];
		fill(dp, dp + (1 << 16), (int)MOD);
		dp[(1 << n) - 1] = 0;
		for (int i = (1 << n) - 2; i >= 0; i--) {
			rep(j, n) {
				if (!(i >> j & 1)) {
					int mi = d[j][0];
					rep(k, n) {
						if (i >> k & 1) {
							mi = min(mi, d[j][k+1]);
						}
					}
					dp[i] = min(dp[i], dp[i | 1 << j] + mi);
				}
			}
		}
		cout << dp[0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3316
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {


			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var inputL = retreiveLongArray();

			var sortedArray = inputL.OrderBy(x => x).ToArray();

			long count = 0;

			//小さい辺から選んでいって、条件を満たす数を数える
			for (int i = 0; i < N-2; i++) {

				var a = sortedArray[i];

				for (int j = i+1; j < N-1; j++) {

					var b = sortedArray[j];
					//2分探索で、条件を満たすcの数を求める
					long min = j+1;
					long max = N-1;
					long mid = (min+max)/2;


					//最小のcも条件を満たさないとき、
					if (!((a + b) > sortedArray[min])) {
						continue;
					}

					//すべてのj+1が条件を満たす
					if ((a + b)>sortedArray[max]) {
						count += (N - 1) - (j);
						continue;
					}



					var ab = a + b;
					while (true) // 範囲内にある限り探し続ける
					{
						mid = min + (max - min) / 2;

						//midは条件を満たすけど、mid+1は満たさないというところを探す
						var hantei_mid = ab > sortedArray[mid];
						var hantei_mid_1 = ab > sortedArray[mid+1];


						if (hantei_mid && hantei_mid_1) {
							min = mid;
							continue;
						}

						if(!hantei_mid && !hantei_mid_1) {
							max = mid;
							continue;
						}

						count += mid-j;
						break;

					}



				}

			}

			//答えの出力
			var ans = count;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13396
n = int(input())

a = {}
l = []

for _ in range(n):
  s = input()
  
  if s not in a:
    a[s] = 1
  else:
    a[s] += 1

num = max(a.values())

for i in a:
  if a[i] == num:
    l.append(i)

l.sort()

for j in l:
  print(j)

Measured memory_bytes: 32096
//copy #1124820 

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
 
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int main (void) {
    int n;
    int a[100];
    while(cin>>n && n){
        rep(i,n)cin>>a[i];
        int f;
        cin>>f;
        int l=0; int r=n-1;
        int ans=0;
        while(l<=r) {
            ans++;
            int m=(l+r)/2;
            if(a[m] == f) break;
            else if(a[m]<f)l=m+1;
            else r=m-1;
            m=(l+r)/2;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
/*
 * AOJ 4
 * Simultaneous Equation (PCK 2003)
 *
 */
#include <iostream>
#include <cstdio>

using namespace std;

int main () {
	double a, b, c,
		d, e, f;
	while(cin >> a >> b >> c >> d >> e >> f) {
	double y = (c*d-f*a) / (b*d-e*a);
	double x = (c - b*y) / a;
	printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  int x;
  cin>>x;
  int p;
  for(int i=0;i<x;i++){
    cin>>p;
    n-=p;
  }
  if(n>=0){
    cout<<n<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    ll xi, yi;
    vector<ll> white(N, 1);
    vector<bool> red(N, false);
    red[0] = true;
    for(int i=0;i<M;i++){
        cin >> xi >> yi;
        xi--; yi--;
        if(red[xi]){
            if(white[xi]==0){
                red[xi] = false;
                red[yi] = true;
            }else{
                white[xi]--;
                white[yi]++;
                red[yi] = true;
                if(white[xi]==0) red[xi]=false;
            }
        }else{
            white[xi]--;
            white[yi]++;
        }
    }
    cout<<count(red.begin(), red.end(), true)<<endl;

    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#define MOD 1000000007
using namespace std;

char grid[1002][1002];

int numberOfWays(int n, int m) {
    int dp[n + 1][m + 1];
    dp[n][m] = 1; // Base Case
    for(int i = n; i >= 1; i--) {
        for(int j = m; j >= 1; j--) {
            if(i == n && j == m) continue;
            if(grid[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = ((((i == n) ? 0 : dp[i + 1][j]) + ((j == m) ? 0 : dp[i][j + 1])) % MOD);
        }
    }
    return dp[1][1];
}

int main() {
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) cin >> grid[i][j];
    }
    cout << numberOfWays(n, m) << endl;
    return 0;
}

Measured memory_bytes: 8412
import sys
N = int(input())
l = list(map(int,input().split()))
cnt = 0
while(1):
    for i in range(N):
        if l[i]%2 == 1:
            print(cnt)
            sys.exit()
        else:
            l[i] = l[i] // 2
    cnt += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int a , b , c , d;
    cin>>a>>b>>c>>d;
    
    for(int i =0 ; ; i++ ) {
        
        if(i%2 == 0 ) c -=b;
        else a -= d;
        
        if(a <= 0 ) {
            cout<<"No\n";
            break;
        }
        if(c <= 0)  {
            cout<<"Yes\n";
            break;
        }
    }
    return 0;
    
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    bool flag=true;
    int pre_t=0, pre_x=0, pre_y=0;
    for(int n=0; n<N; n++) {
        int t, x, y;
        cin >> t >> x >> y;
        
        int dis=abs(pre_x-x)+abs(pre_y-y);
        int tim=t-pre_t;
        if(tim>=dis && tim%2==dis%2) {
            pre_t=t;
            pre_x=x;
            pre_y=y;
        } else {
            flag=false;
        }
    }
    
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }



    return 0;
    
}

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

int main() {
    string s;
    cin >> s;

    int ans = 0;
    for (int i = 1; i < s.size(); i++) {
        if (s[i-1] == s[i]) {
            s[i] = (s[i] == '0') ? '1' : '0';
            ans++;
        }
    }

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


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

const int MAXV=100000;
const int MAXE=500000;
const long long INF=1e18;
//vector<int>G[MAXV]

struct edge {int from,to,cost;};

edge es[MAXE];
long long d[MAXV];
int V,E;

int main(){
    cin>>V>>E;int r;cin>>r;
    for(int i=0;i<E;i++){
        int s,t,dd;
        cin>>s>>t>>dd;
        es[i].from=s;
        es[i].to=t;
        es[i].cost=dd;
    }
    for(int i=0;i<V;i++)d[i]=INF;
    d[r]=0;
    while(true){
        bool update = false;
        for(int i=0;i<E;i++){
            edge e=es[i];
            if(d[e.from] != INF && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                update = true;
            }
        }
        if(!update)break;
    }
    
    for(int i=0;i<V;i++){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    
    return 0;
    
    
}
/*
2 1 0
0 1 7
*/


Measured memory_bytes: 9584
using System;
class test{
public static void Main(){
  var str = Console.ReadLine().Split(' ');
  if(int.Parse(str[0])>=10){
    Console.Write(str[1]);
  }else{
    Console.Write(int.Parse(str[1])+(100*(10-int.Parse(str[0]))));
  }
}
}

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

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

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll a, ll b) { cout << ceil((a + b) / 2.) << endl; }

int main() {
  ll a;
  cin >> a;
  ll b;
  cin >> b;
  solve(a, b);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;

ll COM(ll n, ll k) {
	if (k < 0 || n < k) return 0;
	int64_t ret = 1;
	for (int64_t i = 1; i <= k; ++i) {
		ret *= n--;
		ret /= i;
	}
	return ret;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll v[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v, v + n);
	reverse(v, v + n);
	ll sum = 0;
	for (int i = 0; i < a; i++) {
		sum += v[i];
	}
	map<ll, ll>mp1;
	map<ll, ll>mp2;
	printf("%lf\n", (double)sum / a);
	sum = 0;
	if (v[0] == v[a - 1]) {
		int num = 0;
		for (int i = 0; i < n; i++) {
			if (v[i] == v[0])num++;
		}
		for (int i = a; i <= b; i++) {
			sum += COM(num, i);
		}
		cout << sum << endl;
	}
	else {
		for (int i = 0; i < a; i++) {
			mp1[v[i]]++;
		}
		for (int i = 0; i < n; i++) {
			mp2[v[i]]++;
		}
		cout << COM(mp2[v[a - 1]], mp1[v[a - 1]]) << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long long int a,b,c;
  cin>>a>>b>>c;
  int Max = max(a, max(b,c));

  if( a%2==0 || b%2==0 || c%2==0){
    cout<<0<<endl;
  }else{
    if(Max == a){
      cout<<b * c<<endl;
    }else if(Max == b){
      cout<<a * c<<endl;
    }else if(Max == c){
      cout<<b * a<<endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        for (int i = x; i <= 1000000; i++) {
            boolean result = true;
            for (int j = 2; j < i; j++) {
                if (i % j == 0) {
                    result = false;
                }
            }
            if (result) {
                System.out.println(i);
                return;
            }

        }
    }
}

Measured memory_bytes: 23252
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    for (i in 1..N) {
        if ((i.toDouble() * 1.08).toInt() == N) {
            println(i)
            return
        }
    }

    println(":(")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 31660