akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {

    int N, M;
    int S[10][10] = {};
    int P[10];
    
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int index;
            cin >> index;
            index--;
            S[i][index] = 1;
        }
    }
    
    for(int i = 0; i < M; i++){
        cin >> P[i];
    }
    
    int ans = 0;
    
    for(int tmp = 0; tmp < (1 << N); tmp++){
        bitset<10> bit(tmp);
        bool true_f = true;
        
        for(int i = 0; i < M; i++){
            int on_switch_Count = 0;
            for(int j = 0; j < N; j++){
                if(bit[j]){
                    on_switch_Count += S[i][j];
                }
            }
            true_f &= (on_switch_Count % 2 == P[i]);
        }
        if(true_f){
            ans++;
        }

    }
    
    cout << ans << endl;    
    
    
}



Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
long a=sc.nextLong();
long b=sc.nextLong();

if(a==1 || b==1)
System.out.println(1);
else
System.out.println((long)Math.floor(((a*b)+1)/2));

}}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#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=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int A[3][3];
  int B[3][3] = {{0,0,0},{0,0,0},{0,0,0}};

  cin >> A[0][0] >> A[0][1] >> A[0][2];
  cin >> A[1][0] >> A[1][1] >> A[1][2];
  cin >> A[2][0] >> A[2][1] >> A[2][2];

  int i,tmp,N; cin >> N;

  rep(i,N){
      cin >> tmp;
      if(tmp == A[0][0]){B[0][0] = 1;}
      if(tmp == A[0][1]){B[0][1] = 1;}
      if(tmp == A[0][2]){B[0][2] = 1;}
      if(tmp == A[1][0]){B[1][0] = 1;}
      if(tmp == A[1][1]){B[1][1] = 1;}
      if(tmp == A[1][2]){B[1][2] = 1;}
      if(tmp == A[2][0]){B[2][0] = 1;}
      if(tmp == A[2][1]){B[2][1] = 1;}
      if(tmp == A[2][2]){B[2][2] = 1;}
  }

  if(B[0][0] == 1 && B[0][1] == 1 && B[0][2] == 1){cout << "Yes" << endl; return 0;}
  if(B[1][0] == 1 && B[1][1] == 1 && B[1][2] == 1){cout << "Yes" << endl; return 0;}
  if(B[2][0] == 1 && B[2][1] == 1 && B[2][2] == 1){cout << "Yes" << endl; return 0;}
  if(B[0][0] == 1 && B[1][0] == 1 && B[2][0] == 1){cout << "Yes" << endl; return 0;}
  if(B[0][1] == 1 && B[1][1] == 1 && B[2][1] == 1){cout << "Yes" << endl; return 0;}
  if(B[0][2] == 1 && B[1][2] == 1 && B[2][2] == 1){cout << "Yes" << endl; return 0;}
  if(B[0][0] == 1 && B[1][1] == 1 && B[2][2] == 1){cout << "Yes" << endl; return 0;}
  if(B[2][0] == 1 && B[1][1] == 1 && B[2][0] == 1){cout << "Yes" << endl; return 0;}
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3628
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int x; cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3592
n = int(input())
x = int(n / 1.08)

if int(x * 1.08) == n:
    print(x)
elif int((x-1) * 1.08) == n:
    print(x-1)
elif int((x+1) * 1.08) == n:
    print(x+1)
else:
    print(":(")


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
using namespace std;
typedef pair<double,double> pd;

pd D[100];
int A[100];
int n;

int side(pd p1, pd p2){
	double dy=p2.first-p1.first,dx=p2.second-p1.second;
	for(int i=0;i<n;i++){
		pd p3=D[i];
		if (p1==p3||p2==p3)continue;
		if ((p3.second-p1.second)*dy-dx*(p3.first-p1.first)<0) return 0;
	}
    return 1;
}

int main(){
	while (1){
		int i,s;
		pd p,p1,p2;
		char c;
		cin>>n;
		if (n==0) break;
		for (i=0;i<n;i++){
			cin>>D[i].first>>c>>D[i].second;
			A[i]=0;
		}
		sort(D,D+n);
		p=D[0];
		p1=p;
		s=0;
		while (1){
			for (i=0;i<n;i++){
				p2=D[i];
				if (A[i]==0 && p1!=p2 && side(p1,p2)) break;
			}
			p1=p2;
			A[i]=1;
			s++;
			if (p2==p) break;
		}
		cout<<n-s<<"\n";
		for (i=0;i<n;i++){
			D[i]=make_pair(0,0);
			A[i]=0;
		}
	}
}

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

signed main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (auto& e : x) {
		cin >> e;
	}

	if (m == 1) {
		cout << 0 << endl;
		return 0;
	}

	sort(x.begin(), x.end());
	vector<int> a;

	for (int i = 1; i < m; ++i) {
		a.push_back(x[i] - x[i - 1]);
	}
	
	sort(a.begin(), a.end());

	for (int i = 0; i < n - 1; ++i) {
		if (!a.empty()) {
			a.pop_back();
		}
	}

	if (a.empty()) a.push_back(0);
	cout << accumulate(a.begin(), a.end(), 0) << endl;
}


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

 
int main(){
  int n, i;
  cin >> n;
  
  vector<int> A(n);

  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  for(int i=0; i<n-1; i++){
    if(A[i] == A[i+1]){
      cout << "NO" << endl;
      break;
    }
    
    else if(i == n-2){
      cout << "YES" << endl;
    }
  }
  
}

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

using namespace std;

typedef long long ll;

ll w[105];
ll v[105];

vector<pair<ll, int> >vec[4];

int main() {

	int N,W;

	scanf("%d %d",&N,&W);

	int i, j, k, m, l;

	for (i = 0; i < N; i++) {
		scanf("%lld %lld",&w[i],&v[i]);
		vec[w[i] - w[0]].push_back(make_pair(v[i], i));
	}

	for (i = 0; i < 4; i++) {
		sort(vec[i].begin(),vec[i].end());
		reverse(vec[i].begin(),vec[i].end());
	}

	ll ans = 0ll;
	for (i = 0; i <= vec[0].size(); i++) {
		for (j = 0; j <= vec[1].size(); j++) {
			for (k = 0; k <= vec[2].size(); k++) {
				for (m = 0; m <= vec[3].size(); m++) {
					ll sum = 0ll;
					ll omosa = 0ll;
					for (l = 0; l < i; l++) {
						sum += vec[0][l].first;
						omosa += w[vec[0][l].second];
					}
					for (l = 0; l < j; l++) {
						sum += vec[1][l].first;
						omosa += w[vec[1][l].second];
					}
					for (l = 0; l < k; l++) {
						sum += vec[2][l].first;
						omosa += w[vec[2][l].second];
					}
					for (l = 0; l < m; l++) {
						sum += vec[3][l].first;
						omosa += w[vec[3][l].second];
					}
					if (omosa <= W) {
						if (ans < sum) {
							ans = sum;
						}
					}
				}
			}
		}
	}
	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(S.substr(i, 3) == "ABC") ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = 1e9 + 7;
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  ll n;
  cin >> n;
  vector<pair<string,ll>> A(n);
  for (auto& _a : A) cin >> _a.first >> _a.second;
  string x;
  cin >> x;
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += A[i].second;
  }
  
  for (int i = 0; i < n; ++i) {
    sum -= A[i].second;
    if (A[i].first == x) break;
  }
  cout << sum << endl;
  

}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(begin(a),end(a));
	int x=a[n/2-1],y=a[n/2];
	cout<<y-x<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader bf = new BufferedReader(is);
		int i = Integer.parseInt(bf.readLine());
		int s = i % 60;
		int m = (i / 60) % 60;
		int h = i / 3600;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 24336
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
using namespace std;

int main(){
    string a,b;
    cin >> a >> b;
    if((a=="H" && b=="H") || (a=="D" && b=="D")){
        cout << "H" << endl;
    }
    else{
        cout << "D" << endl;
    }
}

Measured memory_bytes: 256
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector as V

main :: IO ()
main = do
  [h, w] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    encode :: (Int, Int) -> Int
    encode (i, j) = i * w + j
    decode :: Int -> (Int, Int)
    decode ij = ij `divMod` w
  xs <- VU.fromList . map ('.' ==) . concat . lines <$> getContents :: IO (VU.Vector Bool)
  let
    ls = VU.constructN (h * w) rec
      where
        rec :: VU.Vector Int -> Int
        rec v | not (xs VU.! ij) = 0
              | 0 < j            = VU.last v + 1
              | otherwise        = 1
          where
            l = VU.length v :: Int
            ij = l :: Int
            (_, j) = decode ij
    rs = VU.constructrN (h * w) rec
      where
        rec :: VU.Vector Int -> Int
        rec v | not (xs VU.! ij) = 0
              | j < w - 1        = VU.head v + 1
              | otherwise        = 1
          where
            l = VU.length v :: Int
            ij = h * w - l - 1 :: Int
            (_, j) = decode ij
    us = VU.constructN (h * w) rec
      where
        rec :: VU.Vector Int -> Int
        rec v | not (xs VU.! ij) = 0
              | w <= l           = v VU.! (l - w) + 1
              | otherwise        = 1
          where
            l = VU.length v :: Int
            ij = l :: Int
    ds = VU.constructrN (h * w) rec
      where
        rec :: VU.Vector Int -> Int
        rec v | not (xs VU.! ij) = 0
              | w <= l           = v VU.! (w - 1) + 1
              | otherwise        = 1
          where
            l = VU.length v :: Int
            ij = h * w - l - 1 :: Int
    ys = VU.zipWith4 op ls rs us ds :: VU.Vector Int
      where
        op :: Int -> Int -> Int -> Int -> Int
        op l r u d = max 0 $ l + r + u + d - 3
  print . VU.maximum $ ys

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 138528
# https://atcoder.jp/contests/abc157/tasks/abc157_b

A_list = [[] for _ in range(3)]

for i in range(3):
    A1, A2, A3 = map(int, input().split())
    A_list[i] += [A1, A2, A3]

N = int(input())

set1 = {A_list[0][0], A_list[0][1], A_list[0][2]}
set2 = {A_list[1][0], A_list[1][1], A_list[1][2]}
set3 = {A_list[2][0], A_list[2][1], A_list[2][2]}
set4 = {A_list[0][0], A_list[1][0], A_list[2][0]}
set5 = {A_list[0][1], A_list[1][1], A_list[2][1]}
set6 = {A_list[0][2], A_list[1][2], A_list[2][2]}
set7 = {A_list[0][0], A_list[1][1], A_list[2][2]}
set8 = {A_list[0][2], A_list[1][1], A_list[2][0]}


b_set = set()

for n in range(N):
    b = int(input())
    b_set.add(b)

if (set1 <= b_set or 
    set2 <= b_set or
    set3 <= b_set or
    set4 <= b_set or
    set5 <= b_set or
    set6 <= b_set or
    set7 <= b_set or
    set8 <= b_set):

    print('Yes')
else:
    print('No')


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

using namespace std;

int main() {
    int N;
    long long val;
    cin >> N;
    vector<int> ans(N+1,0);
    for(int a=1; a<101; a++) {
        for(int b=1; b<101; b++) {
            for(int c=1;c<101; c++) {
                val = a*a + b*b + c*c + a*b + b*c + c*a;
                if(val <= N) {
                    ans[val]++;
                }
            }
        }
    }
    for(int i =1; i <=N; i++) {
        cout<< ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    int N;
    cin >> N;
    ll answer = 0;
    auto solver = [&](int x){
        ll count = N / x;
        ll ret = count * (x + x * count) / 2;
        return ret;
    };
    rep2(i, 1, N + 1){
        answer += solver(i); 
    }
    cout << answer << endl;
}


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

using namespace std;

int main(){
	int N, M, D[10005], P[10005];
	while( cin >> N >> M, N|M ){
		for(int i=0; i<N; i++){
			cin >> D[i] >> P[i];
		}
		for(int i=0; i<N; i++){
			for(int j=1; j<N; j++){
				if( P[j-1] < P[j] ){
					int tmp = P[j-1];
					P[j-1] = P[j];
					P[j] = tmp;
					tmp = D[j-1];
					D[j-1] = D[j];
					D[j] = tmp;
				}
			}
		}
		int ans=0;
		for(int i=0; i<N; i++){
			if( M>0 ){
				ans += max(0, D[i]-M) * P[i];
				M -= D[i];
			}else{
				ans += D[i] * P[i];
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> a, std::vector<long long> b){
    vll t(N);
    ll sumt = 0;
    rep(i, N){
        t[i] = b[i]-a[i];
        sumt += t[i];
    }
    ll x=0;
    rep(i, N){
        x += max(0LL, (t[i]+1)/2);
    }
    if(x <= sumt)
        cout << YES << endl;
    else
        cout << NO << endl;
    
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&b[i]);
    }
    solve(N, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,s,e) for(int i=s;i<e;i++)

int main(){
    int w;
    string s,ans;
    cin>>s;
    cin>>w;

    for(int i=0;i<s.length();i=i+w){
        ans+=s[i];
      
    }
    cout<<ans;
return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

class Program
{
    public void Slove()
    {
        int[] hist = new int[10];
        int[] inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
        foreach(int i in inputs)
        {
            hist[i]++;
        }
        int[] judgeNum = "1974".Select(x => int.Parse(x.ToString())).ToArray();
        foreach(int i in judgeNum)
        {
            hist[i]--;
        }
        //Console.WriteLine(string.Join(",", hist));
        Console.WriteLine(hist.All(x => x == 0) ? "YES" : "NO");
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys
from itertools import accumulate
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, a: "List[int]"):

    acc = [0]+list(accumulate(a))

    dp = [[-1]*N for _ in range(N)]

    def rec(l, r):
        if dp[l][r] > 0:
            return dp[l][r]
        if l == r:
            return 0

        wa = acc[r+1]-acc[l]
        ans = INF
        for k in range(l, r):
            ans = min(rec(l, k) + rec(k+1, r), ans)
        dp[l][r] = ans + wa
        return dp[l][r]

    print(rec(0, N-1))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45660
N,M = map(int,input().split())
A = [[] for n in range(N)]

for m in range(M):
    a,b = map(int,input().split())
    A[a-1].append(b-1)

for i in range(len(A[0])):
    if len(A[A[0][i]]) is not 0:
        if N-1 in A[A[0][i]]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')



Measured memory_bytes: 29092
#include<iostream>
using namespace std;
unsigned long long n,a[1010],b[1010];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i]>>b[i];
	unsigned long long x=a[0],y=b[0];	
	for(int i=1;i<n;i++)
	{
		long long l=0,r=0,w=0;
		l=x/a[i];
		if(x%a[i]!=0)
			l++;
		r=y/b[i];
		if(y%b[i]!=0)
			r++;
		w=max(l,r);	
		x=a[i]*w;
		y=b[i]*w;
	}	
	cout<<x+y<<endl;
} 


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int d1, d2;
	d1 = x2 - x1;
	d2 = y2 - y1;
	int x3, y3, x4, y4;
	x3 = x2 - d2;
	x4 = x1 - d2;
	y3 = y2 + d1;
	y4 = y1 + d1;
	cout << x3 << ' ';
	cout << y3 << ' ';
	cout << x4 << ' ';
	cout << y4 << endl;
}



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
cnt = 0

for i in range(100000000):
    tmp = 0
    for j in range(n):
        if a[j]%2==0:
            tmp+=1

    if tmp!=n:
        break
    else:
        cnt += 1
        for i in range(n):
            a.append(a[i]//2)
        del a[:n]

print(cnt)

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

int main(){
	int x,y;
	cin >> x >> y;
	for (int i = 0; i < 100; i++)
	{
		for (int j = 0; j < 100; j++)
		{
			if(i+j == x and i*2+j*4 == y){
				cout << "Yes" << endl;
				return 0;
			}
		}
		
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)
//計算量O(E)


//    Edges := 重み付き辺の集合
//    WeightedGraph := 重み付きグラフ
//    UnWeightedGraph := 重み無しグラフ
//    Matrix := 距離行列
template< typename T >
struct edge {
  ll src, to;
  T cost;

  edge(ll to, T cost) : src(-1), to(to), cost(cost) {}

  edge(ll src, ll to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator ll() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< ll > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
pair< T, int > dfs(const WeightedGraph< T > &g, int idx, int par)
{
  pair< T, int > ret(0, idx);
  for(auto &e : g[idx]) {
    if(e.to == par) continue;
    auto cost = dfs(g, e.to, idx);
    cost.first += e.cost;
    ret = max(ret, cost);
  }
  return ret;
}

template< typename T >
T tree_diameter(const WeightedGraph< T > &g)
{
  auto p = dfs(g, 0, -1);
  auto q = dfs(g, p.second, -1);
  return (q.first);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    WeightedGraph<ll> g(n);
    FOR(i,1,n){
      ll in1,in2;
      cin>>in1>>in2;
      in1--;
      in2--;
      g[in1].push_back(edge<ll>(in1,in2,1));
      g[in2].push_back(edge<ll>(in2,in1,1));
    }
    ll x = tree_diameter<ll>(g);

    if(x % 3 == 1 ) cout<<"Second"<<endl;
    else cout<<"First"<<endl;

}


Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
//解説動画解答写し
int g[15][15];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      g[i][j]=-1;
    }
  }
  for(int i=0;i<n;i++){
    int m=0;
    cin>>m;
    for(int j=0;j<m;++j){
      int a,x;
      cin>>a>>x;
      --a;
      g[i][a]=x;
    }
  }
  int ans=0;
  for(int i=0;i<(1<<n);++i){
    vector<int>d(n);
    for(int j=0;j<n;j++){
      if(i>>j&1)d[j]=1;
    }
    bool ok=true;
    for(int j=0;j<n;++j){
      if(d[j]){
        for(int k=0;k<n;++k){
          if(g[j][k]==-1)continue;
          if(g[j][k]!=d[k])ok=false;
        }
      }
    }
    if(ok)ans=max(ans,__builtin_popcount(i));
  }
  cout<<ans<<endl;
  return 0;
}
      

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define inf 1000000007
using namespace std;

typedef long long ll;

inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-f;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return f*x;
}

int ma1[500005], ma2[500005], dp[500005], k=0, k1;

int fun(int n)
{
    if(n==0)
    {
        return 0;
    }
    if(dp[n]!=0)
    {
        return dp[n];
    }
    int ji=1;
    int p=n, z=0;
    while(p)
    {
        if(p&1)
        {
            z++;
        }
        p=p/2;
    }
    dp[n]=ji+fun(n%z);
    return dp[n];
}

int main()
{
    memset(dp,0,sizeof(dp));
    int n;
    scanf("%d",&n);
    string s;
    cin >> s;
    for(int i=0; i<n; i++)
    {
        if(s[i]=='1')
        {
            k++;
        }
    }
    if(k==1)
    {
        k1=k+1;
        int z=0, y2;
        for(int i=0; i<n; i++)
        {
            z=z*2+s[i]-48;
            z=z%k1;
        }
        y2=z;
        z=1;
        for(int i=0; i<n; i++)
        {
            z=z%k1;
            ma2[i]=z;
            z=z*2;
        }
        for(int i=0; i<n; i++)
        {
            int p;
            int z;
            if(s[i]=='1')
            {
                printf("0\n");
                continue;
            }
            else
            {
                p=(y2+ma2[n-i-1]+3*k1)%k1;
            }
            z=fun(p)+1;
            printf("%d\n",z);
        }
        return 0;
    }
    else if(k==0)
    {
        for(int i=0; i<n; i++)
        {
            printf("1\n");
        }
        return 0;
    }
    k1=k+1;
    int z=0, y1, y2;
    k--;
    for(int i=0; i<n; i++)
    {
        z=z*2+s[i]-48;
        z=z%k;
    }
    y1=z;
    z=0;
    for(int i=0; i<n; i++)
    {
        z=z*2+s[i]-48;
        z=z%k1;
    }
    y2=z;
    z=1;
    for(int i=0; i<n; i++)
    {
        z=z%k;
        ma1[i]=z;
        z=z*2;
    }
    z=1;
    for(int i=0; i<n; i++)
    {
        z=z%k1;
        ma2[i]=z;
        z=z*2;
    }
    for(int i=0; i<n; i++)
    {
        int p;
        int z;
        if(s[i]=='1')
        {
            p=(y1-ma1[n-i-1]+3*k)%k;
        }
        else
        {
            p=(y2+ma2[n-i-1]+3*k1)%k1;
        }
        z=fun(p)+1;
        printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 7328
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int x[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += min((x[i + 1] - x[i]) * a, b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
typedef pair<xy_t, int> pci;
typedef vector<lint> poly;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

constexpr double eps=1e-9;

inline int sgn(double x){
    if(x<-eps) return -1;
    if(x>eps) return 1;
    return 0;
}

inline bool EQ(double x, double y){
    return sgn(x-y)==0;
}

inline bool GE(double x, double y){
    return sgn(x-y)==1;
}

inline bool LE(double x, double y){
    return sgn(x-y)==-1;
}

inline bool GEQ(double x, double y){
    return sgn(x-y)>=0;
}

inline bool LEQ(double x, double y){
    return sgn(x-y)<=0;
}

struct Point{
    double x, y;
    Point(double x, double y): x(x), y(y){}

    Point operator+(const Point &p){
        return {x+p.x, y+p.y};
    }

    Point operator-(const Point &p){
        return {x-p.x, y-p.y};
    }

    Point operator*(const double k){
        return {k*x, k*y};
    }

    Point operator/(const double k){
        return {x/k, y/k};
    }

    double operator*(const Point &p){
        return x*p.x+y*p.y;
    }

    double operator^(const Point &p){
        return x*p.y-y*p.x;
    }

    bool operator==(const Point &p){
        return EQ(x, p.x) && EQ(y, p.y);
    }
};

using Vec=Point;
using pdi=pair<double, int>;

double abs(Point p){
    return hypot(p.x, p.y);
}

double arg(Point p){
    return atan2(p.y, p.x);
}

constexpr int CCW_COUNTER_CLOCKWISE=1;
constexpr int CCW_CLOCKWISE=-1;
constexpr int CCW_ONLINE_BACK=-2;
constexpr int CCW_ONLINE_FRONT=2;
constexpr int CCW_ON_SEGMENT=0;

inline int ccw(Point a, Point b, Point c){
    Vec v=b-a, w=c-a;
    if(GE(v^w, 0)) return CCW_COUNTER_CLOCKWISE;
    if(LE(v^w, 0)) return CCW_CLOCKWISE;
    if(LE(v*w, 0)) return CCW_ONLINE_BACK;
    if(LE((a-b)*(c-b), 0)) return CCW_ONLINE_FRONT;
    return CCW_ON_SEGMENT;
}

bool intersectSS(Point a, Point b, Point c, Point d){
    return ccw(a, b, c)*ccw(a, b, d)<=0 && ccw(c, d, a)*ccw(c, d, b)<=0;
}

Point getCrossPointLL(Point p, Vec v, Point q, Vec w){
    double s=((q-p)^w)/(v^w);
    return p+v*s;
}

int main(){
    int q;
    scanf("%d", &q);
    while(q--){
        vector<Point> p;
        rep(i, 4){
            double x, y;
            scanf("%lf%lf", &x, &y);
            p.emplace_back(x, y);
        }
        printf("%d\n", intersectSS(p[0], p[1], p[2], p[3]));
    }
}


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

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int r, g;
	cin >> r >> g;
	cout << 2 * g - r << endl;
	return 0;
}

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

int main(){

    string b;
    cin >> b;
    if(b=="A"){
        cout << "T" << endl;
    }
    else if(b=="C"){
        cout << "G" << endl;
    }else if(b=="G"){
        cout << "C" << endl; 
    }else if(b=="T"){
        cout << "A" << endl;
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t v[100000];
int32_t length_l[100000];
int32_t length_r[100000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	for (;;) {
		in >> N;
		in >> N;
		if (N == 0) {
			return 0;
		}
		bool w = 0;
		for (int32_t i = 0; i < N; ++i)
		{
			in >> v[i];
			if (v[i] == 0) {
				--N;
				--i;
				w = true;
			}
			assert(v[i] > 0);
		}
		std::sort(v, v + N);
		if (N == 0) {
			out << 1 << endl;
			return 0;
		}
		length_l[0] = 1;
		for (int32_t i = 1; i < N; ++i)
		{
			length_l[i] = (v[i] == v[i - 1] + 1) ? (length_l[i - 1] + 1) : (1);
		}
		length_r[N - 1] = 1;
		for (int32_t i = N - 2; i >= 0; --i)
		{
			length_r[i] = (v[i] == v[i + 1] - 1) ? (length_r[i + 1] + 1) : (1);
		}
		if (w)
		{
			int32_t max = *std::max_element(length_l, length_l + N) + 1;
			for (int32_t i = 0; i < N - 1; ++i)
			{
				if (v[i] + 1 == v[i + 1] - 1) {
					max = std::max(length_l[i] + length_r[i + 1] + 1, max);
				}
			}
			out << max << endl;
		}
		else
		{
			out << *std::max_element(length_l, length_l + N) << endl;
		}
	}
	return 0;
}

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

using namespace std;

long long N,a,b;
long long ans,k,ball;

int main()
{
	cin>>N>>a>>b;
	
	k=N/(a+b);
	ball=N-k*(a+b);
	
	if (ball>a){
		ans=(k+1)*a;
		cout<<ans<<endl;
		return 0;
	}
	
	ans=k*a+ball;
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define INPUT_FROM_FILE (0)

#if INPUT_FROM_FILE
#include <fstream>
#endif

#if INPUT_FROM_FILE
#define IS ifs
#else
#define IS std::cin
#endif

class ListNode{
public:
	int key;
	ListNode *prev;
	ListNode *next;

	ListNode(int k, ListNode *p, ListNode *n) : key(k), prev(p), next(n){ return;}

	~ListNode(){ return; }
};

class List{
private:
	ListNode *head_;
public:

	List() : head_(NULL){
		head_ = new ListNode(-1, NULL, NULL);
		head_->prev = head_;
		head_->next = head_;
	}

	~List(){
		ListNode *cn = head_->next;

		while(cn != head_){
			ListNode *next = cn->next;
			delete cn;
			cn = next;
		}
		delete head_; head_ = NULL;
	}

	void insert(int key){
		ListNode *first = head_->next;
		ListNode *n = new ListNode(key, head_, first);

		first->prev = n;
		head_->next = n;
		return;
	}

	void delete_(int key){
		ListNode *cn = head_->next;
		while(cn != head_){
			if(cn->key == key){
				ListNode *prev = cn->prev;
				ListNode *next = cn->next;

				prev->next = next;
				next->prev = prev;
				delete cn; cn = NULL;
				break;
			}
			else{
				cn = cn->next;
			}
		}
		return;
	}

	void delete_first(){
		int key = head_->next->key;
		delete_(key);
		return;
	}

	void delete_last(){
		ListNode *last = head_->prev;
		ListNode *second_last = last->prev;

		second_last->next = head_;
		head_->prev = second_last;
		delete last; last = NULL;
		return;
	}

	void show_list(){
		ListNode *cn = head_->next;
		
		if(cn != head_){
			std::cout << cn->key;
			cn = cn->next;
			
			while(cn != head_){
				std::cout << " " << cn->key;
				cn = cn->next;
			}
		}
		std::cout << std::endl;
		return;
	}
};

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int n = 0;
	std::string command;
	int key = 0;
	List list = List();

	IS >> n;

	for(int i = 0; i < n; i++){
		IS >> command;

		if(command == "insert"){
			IS >> key;
			list.insert(key);
		}
		else if(command == "delete"){
			IS >> key;
			list.delete_(key);
		}
		else if(command == "deleteFirst"){
			list.delete_first();
		}
		else{
			list.delete_last();
		}
		//list.show_list();
	}

	list.show_list();
	return 0;
}

Measured memory_bytes: 34328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i * i < n; ++i)
	{
		if ((n - i) % i == 0)
		{
			ll m = (n - i) / i;
			if (n / m == n % m)
			{
				ans += m;
			}
		}
	}
	cout << ans << endl;
}

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

string S;
vector<vector<int>> v(200010);
int N,M,visited[200010] = {0};

int main(){
	cin  >> N >> M >> S;
	int a,b;
	int A[200010] = {0},B[200010] = {0};
	for(int i=0;i<M;i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	queue<int> Q;
	int count = 0;
	for(int i=1;i<=N;i++){
		for(int j=0;j<v[i].size();j++){
			if(S[v[i][j]-1]=='A') A[i]++;
			if(S[v[i][j]-1]=='B') B[i]++;
		}
		if(A[i]==0 || B[i]==0){
			Q.push(i);
			visited[i] = 1;
			count++;
		}
	}
	while(!Q.empty()){
		int t = Q.front();
		Q.pop();
		for(int i=0;i<v[t].size();i++){
			if(S[t-1]=='A') A[v[t][i]]--;
			if(S[t-1]=='B') B[v[t][i]]--;
			if((A[v[t][i]]==0 || B[v[t][i]]==0) && visited[v[t][i]]==0){
				Q.push(v[t][i]);
				count++;
				visited[v[t][i]] = 1;
			}
		}
	}
	cout << (count<N? "Yes":"No") << endl;
}

Measured memory_bytes: 13188
import java.util.Scanner;
class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
    int count = 0;
    for(int i = a; i <= b; i++)
      if(x%i == 0) count++;
    System.out.println(count);
	}
}


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

int main(){
  int n, q; cin >> n >> q;
  vector<vector<int>> con(n);
  for (int i = 0; i < n - 1; i++){
    int a, b; cin >> a >> b; a--; b--;
    con.at(a).push_back(b);
    con.at(b).push_back(a);
  }
  vector<int> cnt(n, 0);
  for (int i = 0; i < q; i++){
    int p, x; cin >> p >> x; p--;
    cnt.at(p) += x;
  }
  queue<int> que;
  que.push(0);
  vector<bool> checked(n, false);
  checked.at(0) = true;
  while (que.size()){
    int par = que.front();
    que.pop();
    for (int chd : con.at(par)){
      if (!checked.at(chd)){
        cnt.at(chd) += cnt.at(par);
        que.push(chd);
        checked.at(chd) = true;
      }
    }
  }
  for (int i = 0; i < n; i++){
    cout << cnt.at(i) << " ";
  }
  cout << endl;
}

Measured memory_bytes: 15604
import java.util.*;

public class Main{
  public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   String  s = sc.next();
   int w = sc.nextInt();
   int k = w;
   char[] leader = s.toCharArray();
   System.out.print(leader[0]);
   while(true){
     if(w >= leader.length){
       break;
     }
     System.out.print(leader[w]);
     w = w + k;
   }
 }
}


Measured memory_bytes: 21844
import math

n = int(raw_input())

for i in range(n):

  x1, y1, x2, y2, x3, y3 = map(float, raw_input().split())

  px = ((y2 - y3)*(x1*x1 + y1*y1) + (y3 - y1)*(x2*x2 + y2*y2) + (y1 - y2)*(x3*x3 + y3*y3))/(2*(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2)))
  py = ((x2 - x3)*(x1*x1 + y1*y1) + (x3 - x1)*(x2*x2 + y2*y2) + (x1 - x2)*(x3*x3 + y3*y3))/(2*(y1*(x2 - x3) + y2*(x3 - x1) + y3*(x1 - x2)))

  r = math.sqrt(pow((x1 - px), 2) + pow((y1 - py), 2))

  print "%.3f %.3f %.3f" % (px, py, r)

Measured memory_bytes: 6536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int ans = 1;
  cin >> N;
  vector<int> moti(N);
  for(int n = 0; n < N; n++){
    cin >> moti.at(n);
  }
  sort(moti.begin(), moti.end(), greater<int>());
  for(int n = 0; n < N; n++){
    if(n == N-1){
    }
    else{
      if(moti.at(n) != moti.at(n+1)){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> s(n);
  for (auto &e : s)
    cin >> e;

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

  int sum = accumulate(s.begin(), s.end(), 0);

  for (int i = 0; i < n && sum % 10 == 0; ++i)
  {
    if (s[i] % 10 != 0)
      sum -= s[i];
  }
  if (sum % 10 == 0)
    sum = 0;

  cout << sum << endl;

  return 0;
}


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

int main() {
    double minSpeed;
    while (cin >> minSpeed) {
        for (int i = 1; ; i++) {
            int y = 5 * i - 5;
            double t = sqrt(y / 4.9);
            double v = 9.8 * t;
            if (v >= minSpeed) {
                cout << i << endl;
                break;
            }
        }
    }
}

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

int main(void){
  vector<long long int> p, c;
  long long int D, G;
  cin >> D >> G;
  p.resize(D), c.resize(D);
  for(int i = 0; i < D; i++){
    cin >> p[i] >> c[i];
  }
  int minCnt = 1000;

  for(int bit = 0; bit < (1<<D); bit++){
    long long int tempSum = 0;
    int tempCnt = 0;
    for(int i = 0; i < D; i++){
      //Dでビットが立っているところをコンプリートしたとする。
      if(bit & (1<<i)){
        tempCnt += p[i];
        tempSum += p[i]*100*(i + 1) + c[i];
      }
    }
    //cout << bit << " " << tempCnt << " " << tempSum << endl;
    if(minCnt > tempCnt && tempSum >= G) minCnt = tempCnt;
    //達成できない場合1つ下の問題をp[i]-1問まで解いてみて達成するか判断
    else{
      for(int i = D - 1; i >=0; i--){
        bool flag = false;
        //cout << "else" << bit << " " << tempCnt << " " << tempSum << endl;
        //一番大きなbitが立っていない問題を解いてみる
        if(!(bit & (1<<i))){
          flag = true;
          for(int j = 0; j < p[i]; j++){
            //cout << "true" << bit << " " << tempCnt << " " << tempSum << endl;
            tempCnt ++;
            tempSum += 100*(i + 1);
            if(minCnt > tempCnt && tempSum >= G){
              minCnt = tempCnt;
              break;
            }
          }
        if(flag) break;
        }
      }
    }
  }
  cout << minCnt << endl;
  return 0;
}


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

int main(){
    vector<int>a(3);
    cin >> a[0] >> a[1] >> a[2];

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

    if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
from decimal import *

n , m = map(int, input().split())
arr = list(map(int, input().split()))
check = Decimal(1/(4*m)) * sum(arr)
count = 0
for i in arr:
	if i < check:
		continue
	else:
		count+=1
if count >= m:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 61420
#include "bits/stdc++.h"
using namespace std;

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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



signed main() {

    int N;
    cin >> N;
    vector<int> a(N);
    vector<P> S;
    rep(i, N) {
        cin >> a[i];
        S.push_back({ a[i],i+1 });
    }
    sort(S.begin(), S.end());
    rep(i, N)cout << S[i].second << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 3312
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != t[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3920
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func check(a, b uint64) {
	cnt := 0
	for a >= 2 || b >= 2 {
		if a > b {
			a = a - 2
			b++
		} else {
			b = b - 2
			a++
		}
		cnt++
		//out(cnt, ":", a, b)
	}
	out(cnt)
}

func calcN(n int) {
	N := 50
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = i
	}

	x := n / N
	m := n % N
	//	out(0, a)
	for i := 1; i <= m; i++ {
		min := 0
		for j := 0; j < N; j++ {
			if a[min] > a[j] {
				min = j
			}
			a[j]--
		}
		a[min] += N + 1
		/*	out(i, ":", a, (i-1)/N)
			if i%N == 0 {
				out("-----")
			}
		*/
	}
	for i := 0; i < N; i++ {
		a[i] += x
		fmt.Printf("%v ", a[i])
	}
	out()
	//	out(a)

}

func calc(n int) {
	N := 50
	a := make([]int, N)
	for i := 0; i < N; i++ {
		a[i] = i
	}
	out(0, a)
	for i := 1; i <= n; i++ {
		min := 0
		for j := 0; j < N; j++ {
			if a[min] > a[j] {
				min = j
			}
			a[j]--
		}
		a[min] += N + 1
		out(i, ":", a, (i-1)/N)
		if i%N == 0 {
			out("-----")
		}

	}
}

func main() {
	sc.Split(bufio.ScanWords)
	K := getInt()
	out(50)
	calcN(K)
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;


int main()
{
    long long int n, a, b;
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << (b - a) / 2 << endl;
    }
    else {
        cout << min(n - b, a - 1)+1+(b-a-1)/2 << endl;

    }


    return 0;

}

Measured memory_bytes: 256
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, c, s, t, yan, ans = 0;
	bool f[35][100010] = {};
	cin >> n >> c;
	for (int i = 1; i <= n; i++) {
		cin >> s >> t >> yan;
		for (int j = s; j <= t; j++)f[yan][j] = 1;
	}
	ll yojo = 0;
	for (int i = 1; i <= 100000; i++) {
		for (int j = 1; j <= c; j++) {
			if (f[j][i])yojo++;
		}
		ans = max(yojo, ans);
		yojo = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
using namespace std;
const int maxN = 2e3 + 7;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

int n, m, q;
char s[maxN][maxN];
int c[maxN][maxN], lf[maxN][maxN], up[maxN][maxN];
int A, B;

int calc(int cnt[][maxN], int x, int y, int u, int v) {
	return cnt[y][v] - cnt[x-1][v] - cnt[y][u-1] + cnt[x-1][u-1];
}

int main() {

	n = ri(), m = ri(), q = ri();
	rep (i, 1, n) scanf("%s", s[i]+1);
	
	rep (i, 1, n) rep (j, 1, m) c[i][j] = s[i][j] - '0';
	rep (i, 1, n) rep (j, 1, m) if (c[i][j] && c[i-1][j]) up[i][j] = 1;
	rep (i, 1, n) rep (j, 1, m) if (c[i][j] && c[i][j-1]) lf[i][j] = 1;
	rep (i, 1, n) rep (j, 1, m) {
		c[i][j] += c[i-1][j] + c[i][j-1] - c[i-1][j-1];
		lf[i][j] += lf[i-1][j] + lf[i][j-1] - lf[i-1][j-1];
		up[i][j] += up[i-1][j] + up[i][j-1] - up[i-1][j-1];
	}

	while (q--) {
		int x = ri(), u = ri(), y = ri(), v = ri();
		int a = calc(c, x, y, u, v);
		int b = calc(up, x+1, y, u, v) + calc(lf, x, y, u+1, v);
		printf("%d\n", a - b);
	}

	return 0;
}

Measured memory_bytes: 52864
#include <stdio.h>

char board[305][305];
int color[305][305];
int H, W, K;

int current_color;

int main()
{
	scanf("%d %d %d", &H, &W, &K);

	for (int i = 0; i < H; ++i)
	{
		scanf("%s", board[i]);

		bool met = false;

		for (int j = 0; board[i][j]; ++j)
		{
			if (board[i][j] == '#') color[i][j] = ++current_color;
		}
	}

	for (int i = 0; i < H;++i)
	{
		for (int j = 1; board[i][j]; ++j)
		{
			if (!color[i][j] && color[i][j - 1]) color[i][j] = color[i][j - 1];
		}
	}

	for (int i = 0; i < H; ++i)
	{
		for (int j = W - 2; j >= 0; --j)
		{
			if (!color[i][j] && color[i][j + 1]) color[i][j] = color[i][j + 1];
		}
	}

	for (int i = 1; i < H; ++i)
	{
		for (int j = 0; board[i][j]; ++j)
		{
			if (!color[i][j] && color[i - 1][j]) color[i][j] = color[i - 1][j];
		}
	}

	for (int i = H - 2; i >= 0; --i)
	{
		for (int j = 0; board[i][j]; ++j)
		{
			if (!color[i][j] && color[i + 1][j]) color[i][j] = color[i + 1][j];
		}
	}

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j) printf("%d ", color[i][j]);
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1152
A = int(input())
B = int(input())
if (A == 1 and B == 2):
    print(3)
elif (A == 1 and B == 3):
    print(2)
elif (A == 2 and B == 1):
    print(3)
elif (A == 2 and B == 3):
    print(1)
elif (A == 3 and B == 1):
    print(2)
elif (A == 3 and B == 2):
    print(1)

Measured memory_bytes: 38384