akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    
    int ans=0;
    rep(i,0,3) ans+=(s[i]==t[i]);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin >> N;
string S;
cin >> S;
int x = 0;
int count = 0;
for(int i = 0; i<N; i++){
    if(S[i] == 'I'){
        count++;
    }
    else{
        count--;
    }
    x = max(x,count);
    
}
cout<<x<<endl;
return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

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

		// a、bの入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		// 積を計算
		int c = a * b;

		// 偶数なら'Even'、奇数なら'Odd'を出力
		if(isEven(c)){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
		}
	}

	static boolean isEven(int n){
		if(n%2 == 0){
			return true;
		}else{
			return false;
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;


signed main(){
    int c;
    cin >> n >> c;
    twovec(d,c,c);
    REP(i,c){
        REP(j,c){
            cin >> d[i][j];
        }
    }
    twovec(e,n,n);
    twovec(tmp,3,c);
    REP(i,n){
        REP(j,n){
            cin >> e[i][j];
            e[i][j]--;
            tmp[(i+j)%3][e[i][j]]++;
        }
    }
    int ans = max_int;
    REP(a,c){
        REP(b,c){
            REP(cc,c){
                if(a == b || b == cc || a == cc){
                    continue;
                }
                int cnt = 0;
                REP(i,3){
                    REP(j,c){
                        switch (i)
                        {
                        case 0:
                            cnt += d[j][a] * tmp[i][j];
                            break;
                        case 1:
                            cnt += d[j][b] * tmp[i][j];
                            break;
                        case 2:
                            cnt += d[j][cc] * tmp[i][j];
                            break;
                        default:
                            break;
                        }
                        
                    }
                }
                ans = min(ans,cnt);
            }
        }
    }
    print(ans);

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

class UnionFind {
public:
    explicit UnionFind(int N) : root(N, -1), size(N, 1) {}
    int getRoot(int u){ return root[u] == -1 ? u : root[u] = getRoot(root[u]); }
    int getSize(int u){ return size[getRoot(u)]; }
    bool same(int a, int b){
        return getRoot(a) == getRoot(b);
    }
    bool merge(int a, int b){
        int u = getRoot(a);
        int v = getRoot(b);
        if(u == v) return false;
        root[u] = v;
        size[v] += size[u];
        return true;
    }
private:
    vector<int> root;
    vector<int> size;
};

int main(){
    int N, Q; cin >> N >> Q;
    UnionFind uf(N);
    for(int i=0;i<Q;i++){
        int t, u, v; cin >> t >> u >> v;
        if(t == 0){
            uf.merge(u, v);
        } else {
            cout << (uf.same(u, v) ? 1 : 0) << endl;
        }
    }
}

Measured memory_bytes: 4692
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a<=0&&b>=0){
    cout<<"Zero"<<endl;
  }
  else if(a>0&&b>0){
    cout<<"Positive"<<endl;
  }
  else{
    if((b-a+1)%2==0){
      cout<<"Positive"<<endl;
    }
    else{
      cout<<"Negative"<<endl;
    }
  }
}


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int arr[n][3];
	for(int i = 0; i < n; ++i) {
	    for(int j = 0; j < 3; ++j) {
	        cin >> arr[i][j];
	    }
	}
	int dp[n][3];
	dp[0][0] = arr[0][0], dp[0][1] = arr[0][1], dp[0][2] = arr[0][2];
	for(int i = 1; i < n; ++i) {
	    dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
	    dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
	    dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0]);
	}
	cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  ll a[n+1];
  int temp;
  for(int i=0;i<n+1;i++){
    a[i]=-1;
  }
  for(int i=0;i<m;i++){
    cin >> temp;
    a[temp]=0;
  }
  a[0]=1;
  if(a[1]!=0)a[1]=1;
  // if(a[2]!=0)a[2]=a[1]+1;
  // for(int i=0;i<n+1;i++){
  //   cout << a[i] << endl;
  // }
  for(int i=0;i<n-1;i++){
    if(a[i+2]==-1)a[i+2]=(a[i+1]+a[i])%1000000007;
  }
  ll ans = a[n]%1000000007;
  cout << ans << endl;
  // for(int i=0;i<n+1;i++){
  //   cout << a[i] ;
  // }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#13359422の修正
using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i=0; i<(int)n; i++)
using vb = vector<bool>;


int main(){
  int N,M,K;
  cin>>N>>M>>K;
  vvi fri(N);
  vvi blk(N);
  vi A(M), B(M), C(K), D(K);
  rep(i,M){
    cin>>A[i]>>B[i];
    A[i]--;B[i]--;
    fri[A[i]].pb(B[i]);
    fri[B[i]].pb(A[i]);
  }
  rep(i,K){
    cin>>C[i]>>D[i];
    C[i]--;D[i]--;
    blk[C[i]].pb(D[i]);
    blk[D[i]].pb(C[i]);
  }

  //連結成分調査
  vi where(N);
  vi renketusize(N, 0);
  int renketu = 0;
  vb checked(N, false);
  for(int i=0; i<N; i++){
    //iがどの連結成分にあるか
    if(checked[i])continue;
    queue<int> unchecked;
    unchecked.push(i);

    while(!unchecked.empty()){
      int current = unchecked.front();
      unchecked.pop();

      if(!checked[current]){
        //チェックしてない
        where[current] = renketu;
        checked[current] = true;
        renketusize[renketu]++;
        for(int next: fri[current]){
          unchecked.push(next);
        }
      }
    }
    //dfs終わったらrenketu++
    renketu++;
  }

  /*
  //どこの連結成分に入っているか
  rep(i,N){
    cout<<i<<" is in "<<where[i]<<endl;
  }

  //各連結成分の数は
  for(int x: renketusize){
    if(x==0)break;
    cout<<"size = "<<x<<endl;
  }
  */

  vi ans(N);
  rep(i,N){
    //連結成分の大きさ = 可能性あり
    //1引いとく
    ans[i] = renketusize[where[i]] -1;
  }

  rep(i,M){
    //友達リンクの両方で可能性が減る
    ans[A[i]]--;
    ans[B[i]]--;
  }

  rep(i,K){
    //同じ連結成分内でのブロックリンクの両方で可能性が減る
    if(where[C[i]]==where[D[i]]){
      ans[C[i]]--;
      ans[D[i]]--;
    }
  }

  rep(i,N){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}

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

int main() {
	// your code goes here
	int n = 0;
	cin >> n;
	vector <int> vect(n);
	int temp = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> temp;
		if (i == 0)
		{
			vect[i] = temp;
		}
		else
		{
			vect[i] = vect[i - 1] + temp;
		}
	}
	int t1 = vect[n - 1] - vect[0] - vect[0];
	if (t1 < 0)
	{
		t1 = t1 * -1;
	}
	int t2 = 0;
	for (int i = 1; i < n-1; i++)
	{
		t2 = vect[n - 1] - vect[i] - vect[i];
		if (t2 < 0)
		{
			t2 = t2 * -1;
		}
		if (t2 < t1)
		{
			t1 = t2;
		}
	}
	cout << t1 << endl;
	return 0;
}


Measured memory_bytes: 3160
#include<cstdio>
#include<algorithm>
int main(){
    int n,a[100];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    std::sort(a,a+n);
    printf("%d",a[n-1]-a[0]);
    return 0;
}

Measured memory_bytes: 128
n, m, x = map(int, input().split())

books = [0] * n
for _ in range(n):
    books[_] = list(map(int, input().split()))

ans = -1
ans_list = []
for i in range(1<<n):
    money = 0
    cleared = 0
    level = [0]*m
    for j in range(n):
        if i>>j & 1:
            money += books[j][0]
            for book in range(m):
                level[book] += books[j][book+1]

    level.sort()
    if level[0] >= x:
        ans_list.append(money)

if len(ans_list) > 0:
    ans = min(ans_list)

print(ans)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rep1(i,n) for(int i=1; (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
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 long llINF = 1LL<<60;
const int INF = 1e9;

int main(){
    int n; cin >> n;
    vector<int> v(n); rep(i,n) cin >> v[i];
    //int k=0;
    sort(v.begin(), v.end());
    cout << v[n/2]-v[n/2-1];

    return 0;
}

Measured memory_bytes: 768
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n, ret;
vi a;
vpi ord;
set<int> fin;

signed main(){
    I(n);
    a.resize(n);
    REP(i,n) {
        I(a[i]);
        ord.eb(a[i],i);
    }
    sort(all(ord));
    fin.insert(-1);
    fin.insert(n);
    for (auto po: ord){
        int i = po.first;
        int od = po.second;
        auto lb = fin.lower_bound(od);
        int ue = *lb;
        lb--;
        int sita = *lb;
        ret += (od-sita) * (ue-od) * i;
        fin.insert(od);
    }
    cout << ret << endl;
}

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

int main(){

  int n, w; cin >> n >> w;
  vector< vector< ll > > v(4);
  int x, y;
  ll base = 0;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    if(i == 0){
      base = x;
      v[0].push_back(y);
    }
    else{
      v[x - base].push_back(y);
    }
  }
  sort(v[0].begin(),v[0].end(),greater<ll>());
  sort(v[1].begin(),v[1].end(),greater<ll>());
  sort(v[2].begin(),v[2].end(),greater<ll>());
  sort(v[3].begin(),v[3].end(),greater<ll>());
  v[0].insert(v[0].begin(),0);
  v[1].insert(v[1].begin(),0);
  v[2].insert(v[2].begin(),0);
  v[3].insert(v[3].begin(),0);
  for(int i = 1; i < (int)v[0].size(); ++i) v[0][i] = v[0][i - 1] + v[0][i];
  for(int i = 1; i < (int)v[1].size(); ++i) v[1][i] = v[1][i - 1] + v[1][i];
  for(int i = 1; i < (int)v[2].size(); ++i) v[2][i] = v[2][i - 1] + v[2][i];
  for(int i = 1; i < (int)v[3].size(); ++i) v[3][i] = v[3][i - 1] + v[3][i];
  
  ll finans = -1;
  rep(i,(int)v[0].size())rep(j,(int)v[1].size())rep(k,(int)v[2].size())rep(l,(int)v[3].size()){
    ll temp = (ll)((ll)base*(ll)i) + (ll)((ll)(base+1)*(ll)j) + (ll)((ll)(base + 2)*(ll)k) + (ll)((ll)(base +3)*(ll)l);
    if((ll)w < temp) continue;
      ll ans = (ll)v[0][i] + (ll)v[1][j] + (ll)v[2][k] + (ll)v[3][l];
      finans = max(finans,ans);
  }
  /*
  if(n == 4 && w == 10){
    cout << 400 << '\n';
    return 0;
  }*/
  cout << finans << '\n';
}


Measured memory_bytes: 3640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int,input().split())
XYZ = [list(map(int,input().split())) for _ in range(M)]
uf = UnionFind(N)
for i in range(M):
  uf.union(XYZ[i][0]-1,XYZ[i][1]-1)
#print(uf.parents)
#print(uf)
print(uf.group_count())


Measured memory_bytes: 32224
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


int main()
{
  finp;
  
  int n;
  map<int,int> my;
  cin>>n;
  afor(i,1,n)
  {
    int val;
    cin>>val;
    my[val]++;
  }

  if(my.size()==1 && (*my.begin()).first!=n-1)
  {
    my[(*my.begin()).first - 1] = 0;
  }

  
  if(my.size() == 1)
  {
    pp x = *(my.begin());
    if(x.first==n-1)cout<<"Yes\n";
    else cout<<"No\n";
  }
  else if(my.size()>2)
  {
    cout<<"No\n";
  }
  else
  {
    pp x1 = *(my.begin());
    my.erase(my.begin());
    pp x2 = *(my.begin());

    if(x1.first >= x2.first)swap(x1,x2);

    if(x2.first != x1.first+1)
    {
      cout<<"No\n";
    }
    else
    {
      ll num = x2.first;

      if(num <= x1.second)cout<<"No\n";
      else if(x2.second >= (2 * (num - x1.second)))cout<<"Yes\n";
      else cout<<"No\n";
    }
  }
return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d.size() << endl;
	return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a+b)%3 == 0){
        cout << "Possible\n"; 
    }
    else cout << "Impossible\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int len,a,b;
int calc(int x,int y)
{
	return (max(x,y)-1)/(min(x,y)+1)+1;
}
bool check(int x)
{
	int alen=(x/(len+1)*len+x%(len+1)),blen=x/(len+1);
	if(x%(len+1)==0)--blen;
	if(alen>a)return false;
	if(calc(a-alen,b-blen)>len)return false;
	return true;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		len=calc(a,b);
		int l=0,r=a+b;
		while(l<r-1)
		{
			int m=(l+r)>>1;
			if(check(m))l=m;
			else r=m;
		}
		int mid;
		if(check(r))mid=r;
		else mid=l;
		if(d<=mid)
		{
			for(int i=c;i<=d;++i)
			{
				if(i%(len+1))printf("A");
				else printf("B");
			}
			printf("\n");
		}
		else if(c>mid)
		{
			int tot=a+b;
			for(int i=c;i<=d;++i)
			{
				int nowt=tot-i+1;
				if(nowt%(len+1))printf("B");
				else printf("A");
			}
			printf("\n");
		}
		else
		{
			for(int i=c;i<=mid;++i)
			{
				if(i%(len+1))printf("A");
				else printf("B");
			}
			int tot=a+b;
			for(int i=mid+1;i<=d;++i)
			{
				int nowt=tot-i+1;
				if(nowt%(len+1))printf("B");
				else printf("A");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int count = 0;
        if (n >= 1800) {
            count = 1;
        } else if (n >= 1600) {
            count = 2;
        } else if (n >= 1400) {
            count = 3;
        } else if (n >= 1200) {
            count = 4;
        } else if (n >= 1000) {
            count = 5;
        } else if (n >= 800) {
            count = 6;
        } else if (n >= 600) {
            count = 7;
        } else {
            count = 8;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 35616
#include <cstdio>

int len(int x){
	int ret(0);
	while(x) ++ret, x /= 10;
	return ret;
}

int main(){
	int n, ans(0); scanf("%d", &n);
	for(int i(1); i <= n; ++i) ans += (len(i) & 1);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n,N) for(ll i=n;i<(ll)N;i++)
#define RREP(i,n,N) for(ll i=N-1;i>=n;i--)
#define p(s) cout<<(s)<<endl
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

ll N;

int main() {
	cin>>N;

	REP(h,1,3501){
		REP(n,1,3501){
			if(4*n*h-N*(h+n)==0) continue;
			double check=(double) N*h*n/(4*n*h-N*(h+n));
			if( N*h*n/(4*n*h-N*(h+n))==check&&CK(N*h*n/(4*n*h-N*(h+n)),1,3501)){
				cout<<h<<" "<<n<<" "<<(int) check<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265

int n,m;
int a[1000000];

int main(){
  cin>>n>>m;
  rep(i,m){
    int b,c;
    cin>>b>>c;
    a[b]++;
    a[c]++;
  }

  rep(i,n+1){
    if(a[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }

  cout<<"YES"<<endl;

  return 0;
}

Measured memory_bytes: 640
// Problem : D - All Your Paths are Different Lengths
// Contest : AtCoder Regular Contest 102
// URL : https://atcoder.jp/contests/arc102/tasks/arc102_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

struct edge {
	int u, v, w;
};

int n, l;
vector<edge> v;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> l;
	l--;
	int x = __lg(l) + 1;
	n = x;
	if ((1 << x) - 1 == l) {
		n++;
	}
	for (int i = 2; i <= n; i++) {
		v.push_back({i - 1, i, 0});
		v.push_back({i - 1, i, 1 << (n - i)});
	}
	int cur = 0;
	if ((1 << x) - 1 != l) for (int i = x - 1; i >= 0; i--) {
		int bit = 1 << i;
		if (l & bit) {
			cur += bit;
			l -= bit;
			int j = l ? __lg(l) : 0;
			v.push_back({1, n - j, cur});
		}
	}
	cout << n << ' ' << size(v) << '\n';
	for (auto x : v) {
		cout << x.u << ' ' << x.v << ' ' << x.w << '\n';
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    int n;
    n = sc.nextInt();

    int a[] = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    func(a);

    sc.close();
  }

  private static void func(int a[]) {// バブルソート
    int times = 0, copy;

    // バブルソート
    for (int i = a.length; i > 0; i--) {
      for (int j = 0; j < i - 1; j++) {
        if (a[j] > a[j+1]) {
          copy = a[j+1];
          a[j+1] = a[j];
          a[j] = copy;
          times++;
        }
      }
    }

    // 回答
    for (int i = 0; i < a.length - 1; i++) {
      System.out.printf("%d ", a[i]);
    }
    System.out.printf("%d\n%d\n", a[a.length - 1], times);
  }
}



Measured memory_bytes: 26424
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var min, max, sum int = 1000000, -1000000, 0

	var t int
	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		if t < min {
			min = t
		}
		if t > max {
			max = t
		}
		sum += t
	}

	fmt.Println(min, max, sum)
}



Measured memory_bytes: 1692
#include <iostream>
#include <cmath>
#include <climits>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string.h>
#include <iomanip>
#include <ctype.h>

#define ll          long long int
#define ull         unsigned long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
//#define hell        1000000007
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.000000001
#define all(a)      (a).begin(),(a).end()
const long long INF = (long long) 1e7+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

using namespace std;
#include <stdio.h>
ll m;
ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;
    y=y/2;
  }
  return res;
}

ll modinv(ll x){
  return power(x,hell-2);
}

void solve();


void fastIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
   fastIO();
    solve();
}
//void sieve();
ll pw(ll k,ll x);
ll gcd(ll x,ll y);

/*
  For freq or prime factors

for(auto pri:prime){
  while(k%pri==0){
    pcnt[pri]++;
    k/=pri;
  }
}*/

void solve(){
  int test;
  //cin>>test;
  test=1;
  while(test--){
        int k,x;
        cin>>k>>x;
        if(500*k>=x)
        cout<<"Yes";
        else
        cout<<"No";   
  }    
}    




/*bool issafe(int x,int y){
  return (x>=0 && y>=0 && x<n && y<m);
}*/

///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1

ll gcd(ll x,ll y){
  if(x==0)
  return y;
  else
  return gcd(y%x,x);
}


ll pw(ll k,ll x){
  if(x==0)
  return 1;
  if(x&1)
  return ((pw(k,x-1))*k);
  else
  return ((pw(k,x/2))*(pw(k,x/2)));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
#define ll long long

ll N, X[1009], Y[1009], H[1009];
vector<tuple<ll, ll, ll>>vec;

int main() {
	cin >> N;
   tuple<ll, ll, ll>G = make_tuple(-1, -1, -1);

	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i] >> H[i];
		if (H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
	}

	for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			ll V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j);
      V = max(V, 0LL); bool flag = true;

      for (int k = 1; k <= N; k++) {
				ll VV = V - abs(X[k] - i) - abs(Y[k] - j); VV = max(VV, 0LL);
				if (H[k] != VV) flag = false;
			}
			if (flag == true) vec.push_back(make_tuple(i, j, V));
		}
	}
	if (vec.size() == 1) {
		cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
	}
	return 0;
}


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

int main(){
    int N,M;cin>>N>>M;
    vector<int>H(N);
    vector<int>seen(N,0);
    Graph G(N);
    rep(i,N){
        cin>>H.at(i);
    }
    rep(i,M){
        int a,b;cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int count=0;
    rep(i,N){
        if(G[i].size()==0){
            count++;
        }
        else{
            bool flag=true;
            for(auto next_v:G[i]){
                if(H.at(next_v)>=H.at(i)){
                    flag=false;
                    break;
                }
            }
            if(flag){
                count++;
            }
        }
    }
    cout<<count<<endl;
}

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

using namespace std;

int main (void) {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for ( int i = 0; i < N; i++ ) cin >> A.at(i);
    for ( int i = 0; i < N; i++ ) cin >> B.at(i);
    for ( int i = 0; i < N; i++ ) cin >> C.at(i);

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int i;
    int ci = 0;
    vector<long long> v(N);   /* 各中部パーツの上に載せられる上部パーツの数 */
    for ( int bi = 0; bi < N; bi++ ) {
        int b = B.at(bi);
        for ( i = ci; i < N && C.at(i) <= b; i++ ) {}
        if ( i == N ) i--;
        if ( C.at(i) <= b ) break;
        v.at(bi) = N - i;
        ci = i;
    }

    /* v を後ろからの累積和にする */
    for ( i = N-1; i >= 0; i-- ) {
        if ( i != N-1 ) v.at(i) += v.at(i+1);
    }

    long long ans = 0;
    int bi = 0;
    for ( int ai = 0; ai < N; ai++ ) {
        int a = A.at(ai);
        for ( i = bi; i < N && B.at(i) <= a; i++ ) {}
        if ( i == N ) i--;
        if ( B.at(i) <= a ) break;
        ans += v.at(i);
        bi = i;
    }

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



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

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

  int tmp = 1, a, b;
  rep(i,n){
    a = tmp*2;
    b = tmp + k;
    tmp = min(a, b);
  }
  cout<<tmp<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

    int X, Y, Z;
    int ans = 0;
    for (X = 0; X <= K; X++)
    {
        for (Y = 0; Y <= K; Y++)
        {
            Z = S - X - Y;
            if (Z >= 0 && Z <= K && X + Y + Z == S)
            {
                // printf("%d %d %d\n", X, Y, Z);
                ans++;
            }
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k=sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		
		boolean[] first = new boolean[k+1];
		for (int i=0;i<k;i++) {
			if (!first[i]) {
				for (int j=0;j<n;j++) {
					if(i+a[j]<=k) {
						first[i+a[j]]=true;
					}
				}
			}
		}

		
		System.out.println(first[k] ? "First" : "Second");
	}

}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

const int MOD = 1e9 + 7;
const int N = 3e6 + 6;
ll fat[N];

void init(){
    fat[0] = 1LL;
    for(ll i = 1; i < N; i++){
        fat[i] = fat[i-1] % MOD * (ll) i % MOD;
        fat[i] %= MOD;
    }
}

ll fast(ll a, ll p){
    if(p == 1) return a % MOD;
    if(p&1) return ((a % MOD) * (fast(a, p-1) % MOD)) % MOD;
    int x = p / 2;
    ll t = fast(a, x);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll nck(ll n, ll k){
    if(n < k) return 0;
    if(k == 0) return 1;
    ll up = fat[n];
    ll a = fast(fat[k], MOD - 2);
    ll b = fast(fat[n-k], MOD - 2);

    ll prod = up % MOD * a % MOD;
    prod %= MOD;
    prod *= b;

    return prod % MOD;
}

ll g(ll r1, ll r2, ll c){
    ll a = nck(r2 + c + 1, c + 1);
    ll b = nck(r1 + c, c + 1);
    return (a - b) % MOD;
}

int main(){
    fcin;

    init();

    ll i, j, i2, j2;
    cin >> i >> j >> i2 >> j2;

    ll ans = 0;
    for(ll c = j; c <= j2; c++){
        ans += g(i, i2, c);
        ans %= MOD;
    }

    cout << (ans + MOD) % MOD << endl;
    return 0;
}



Measured memory_bytes: 23680
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if L[i] != L[j] != L[k] != L[i] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]:
                ans += 1

print(ans)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,h[100001],cnt=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
		if(h[i]>=k) cnt++;
	}
	cout<<cnt<<endl;
	return 0;
} 


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>

using namespace std;

int main(void){
    int N=0;

    cin >> N;

    vector<long long int> ar(N);
    for(int i=0; i<N; i++)
        cin >> ar[i];
    cout << *min_element(ar.begin(), ar.end()) << " " << *max_element(ar.begin(), ar.end()) << " " << accumulate(ar.begin(), ar.end(), 0LL) << endl;
}


Measured memory_bytes: 3180
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using ll = long long int;
#define int ll

const int MOD = 1e9 + 7;
const int INF = 1e15 + 373;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> init_vector2(size_t n0, size_t n1, T e = T()) {
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> init_vector3(size_t n0, size_t n1, size_t n2, T e = T()) {
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int solve(int x, int y){
    if(x % y == 0){
        return -1;
    }
    return x;
}

signed main() {
    int x, y;
    cin >> x >> y;
    cout << solve(x, y) << endl;
    return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
inline void read (int &x) {
	char ch = getchar(); x = 0;
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch))  x = x * 10 + ch - 48, ch = getchar();
}
int n, l, r, mid, ans, a[200010];
inline bool check () {  
    for (int i = 0; i < n; ++i) {
    	if ((a[n-i] < mid and a[n-i-1] < mid) or (a[n+i] < mid and a[n+i+1] < mid))  
    	  return false;
    	if ((a[n-i] >= mid and a[n-i-1] >= mid) or (a[n+i] >= mid and a[n+i+1] >= mid))
    	  return true;
	}
	return a[n*2-1] >= mid;
}
int main() {
	read (n);
	for (int i = 1; i <= (n << 1) - 1; ++i)  read (a[i]);
	l = 1, r = (n << 1) - 1;
	while (l <= r) {
		mid = l + r >> 1;
		if (check())  ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef pair<LL, LL> PLL;

LL f(LL a, LL b) {
	return (LL)max(log10(a), log10(b))+1;
}

int main(void)
{
	LL n;
	sci(n);
	vector<LL> v;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0) {
			if (i*i == n) {
				v.push_back(i);
			}
			else {
				v.push_back(i);
				v.push_back(n / i);
			}
		}
	}

	sort(v.begin(), v.end());
	LL gb_min = 1e9;
	for (int i = 0; i < v.size(); i++) {
		gb_min = min(gb_min, f(v[i], v[v.size() - i - 1]));
	}
	printf("%lld", gb_min);
	return 0;
}

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

int main() {
  int N;
  int A[210];
  int count = 0;
  bool isLoop = true;

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

  while(isLoop) {
    bool isEven = true;

    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) isEven = false;
    }

    if (isEven) {
      for (int i = 0; i < N; ++i) A[i] /= 2;
      ++count;
    } else { isLoop = false; }
  }

  cout << count << endl;
}

Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {
	
	private static String judgeDists(int[] dists, int k) {
		// validate inputs
		if(k < 0 || k > 123) return ":(";
		for(int tmp : dists) {
			if (tmp < 0 || tmp > 123) return ":(";
		}
		
		// using 2 loops to judge the dists
		for(int i = 0; i < dists.length; i++){
			for(int j = i + 1; j < dists.length; j++){
				if(dists[j] - dists[i] > k) return ":(";
			}
		}
		
		return "Yay!";
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int[] dists = new int[5];
		// get values for 5 antennas and val for k
		dists[0] = sc.nextInt();
		dists[1] = sc.nextInt();
		dists[2] = sc.nextInt();
		dists[3] = sc.nextInt();
		dists[4] = sc.nextInt();
		
		int k = sc.nextInt();
		System.out.println(judgeDists(dists, k));
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(){
    int n;scanf("%d",&n);
    int ans=0;
    for(int i=105,c=0;i<=n;i+=2,c=0){
        for(int k=1;k<=i;k+=2){
            if(i%k==0)c++;
        }   
        if(c==8) ++ans;
    }   
    printf("%d",ans);
    return 0;
} 

Measured memory_bytes: 128
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = 10 ** 10
dp = [inf] * n
dp[0] = 0
for i in range(n - 1):

    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
print(dp[-1])

Measured memory_bytes: 52720
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int seconds(string t){
    int h = (t[0] - '0') * 10 + t[1] - '0';
    int m = (t[3] - '0') * 10 + t[4] - '0';
    int s = (t[6] - '0') * 10 + t[7] - '0';

    return h * 60 * 60 + m * 60 + s;
}

signed main(){
    while(true){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }

        vector<int> time(90000);
        rep(i, n){
            string s, t;
            cin >> s >> t;
            int begin = seconds(s);
            int end = seconds(t);

            time[begin] += 1;
            time[end] -= 1;
        }

        rep(i, 90000 - 1){
            time[i+1] += time[i];
        }

        int ans = 0;
        rep(i, 90000){
            if(time[i] > ans){
                ans = time[i];
            }
        }
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3672
import java.util.Map.Entry;
import java.util.*;

import org.w3c.dom.css.Counter;

public class Main {
//public class App {

    public static void main(String[] args){
     //スキャン
     Scanner s = new Scanner(System.in);
       // 入力
       int AH = Integer.parseInt(s.next());
       int AP =Integer.parseInt(s.next());
       int BH = Integer.parseInt(s.next());
       int BP =Integer.parseInt(s.next());

       int AL = AH / BP;
       if(AH % BP!= 0){
           AL++;
       }
       int BL = BH/ AP;
       if(BH % AP!= 0){
        BL++;
        }
        
        if(BL <= AL){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35700
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;
    //あらかじめ100をかけておき水の量を求めやすくする。
    A *= 100;
    B *= 100;

    int water; //水の量
    int suger, max_suger = 0; //砂糖の量
    int all, max_all = 0; //食塩水
    double dens, max_dens = -1.0; //濃度
    double limit_dens = E / (100.0 + E); //濃度の限界値
    
    
    //水の総量のパターンをたくさん出す。
    for(int a = 0; a <= F; a += A){
        for(int b = 0; a + b <= F; b += B){
            water = a + b;

            //対する塩の総量のパターンをたくさん出す。
            //上から順番に出していく。
            //最大値を初期値とする、その際に綺麗な値にする。
            for(int c = ((F - (water)) / C) * C; c >= 0; c -= C){
                for(int d = ((F - (water + c)) / D) * D; d >= 0; d -= D){
                    suger = c + d;

                    //食塩水の量を求める。
                    all = water + suger;
                    //砂糖の濃度を求める。
                    dens = suger * 1.0 / all;
                    //もし砂糖の濃度が限界値より超えていたらcontinue
                    if(dens > limit_dens) continue;
                    //現在の最大の濃度より濃かったらそれぞれ代入する。
                    if(max_dens < dens){
                        max_all = all;
                        max_suger = suger;
                        max_dens = dens;
                        break;
                    }
                }
            }
        }
    }

    cout << max_all << " " << max_suger << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main(int argc, char const* argv[])
{
	int x, y;
	int flag = 1;

	while(flag)
	{
		std::cin >> x >> y;
		if (x == 0 && y == 0)
			flag = 0;
		else
		{
			if (x > y)
				std::cout << y << " " << x << std::endl;
			else if (x <= y)
				std::cout << x << " " << y << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
N,M,C = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
count = 0
N.times do |i|
    source_code = gets.split.map(&:to_i)
    modified_source_code = []
    source_code.each_with_index do |num,j|
        modified_source_code << (num * B[j])
    end
    sum = 0
    modified_source_code.each {|num| sum += num}
    if sum + C > 0 
        count += 1
    end
end

puts count


Measured memory_bytes: 1788
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n;
    cin>>n;
    vi v(n);
    int ans=0;
    rep(i,n){
        cin>>v[i];
    }
    bool fl=1;
    while(1){
        rep(i,n){
            if(v[i]%2)fl=0;
        }
        if(!fl)break;
        rep(i,n)v[i]/=2;
        ans++;
    }
    cout<<ans<<enl;

    return 0;
}


Measured memory_bytes: 3624
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,x=INTM()
    m=[]
    for i in range(n):
        m.append(INT())
    ct=n
    x=x-sum(m)
    ct+=x//min(m)
    print(ct)
if __name__ == '__main__':
    do()

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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    sort(A.begin(), A.end(), greater<>());
    ll a1 = -1, a2 = -1;
    for ( int i = 0; i < N-1; i++ ) {
        if ( A[i] == A[i+1] ) {
            if ( a1 < 0 ) {
                a1 = A[i];
            } else if ( a2 < 0 ) {
                a2 = A[i];
                break;
            }
            i++;
        }
    }
    if ( a1 > 0 && a2 > 0 ) return a1 * a2;
    else return 0;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;

const long long MOD = 1000000007;

long check[51];

long root(long x){
    if(x == check[x]){
        return x;
    }
    return check[x] = root(check[x]);
}

void unite(long x, long y){
    long rx = root(x);
    long ry = root(y);
    if(rx == ry){
        return;
    }
    check[rx] = ry;
}

int main(){
    long n;
    cin >> n;
    vector< pair<long, long> > v;
    for(long i = 0; i < n; i++){
        long x, y;
        cin >> x >> y;
        v.push_back(make_pair(x, y));
    }

    long mi = 1 << 30;

    for(long i = 0; i < n; i++){
        for(long j = 0; j < n; j++){
            long p = v[i].first - v[j].first;
            long q = v[i].second - v[j].second;

            for(long k = 0; k < n; k++){
                check[k] = k;
            }
            for(long k = 0; k < n; k++){
                long pp = v[k].first + p;
                long qq = v[k].second + q;
                long ppp = v[k].first - p;
                long qqq = v[k].second - q;
                for(long l = 0; l < n; l++){
                    if(v[l].first == pp && v[l].second == qq){
                        unite(k, l);
                    }else if(v[l].first == ppp && v[l].second == qqq){
                        unite(k, l);
                    }
                }
            }
//            for(long k = 0; k < n; k++){
//                cerr << k << " " << check[k] << endl;
//            }
            long cou = 0;
            for(long k = 0; k < n; k++){
                if(check[k] == k){
                    cou++;
                }
            }
            mi = min(mi, cou);
        }
    }

    cout << mi << endl;

    
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		while(true) {
		int h = sc.nextInt();
		int w = sc.nextInt();
		if(h == 0 || w == 0) break;
		for(int i = 0; i < h; i++) {
			for(int j = 0; j <w; j++)
				System.out.print("#");
			System.out.println();
		}
		System.out.println();
		sc.nextLine();
		}
		sc.close();		
	}
}



Measured memory_bytes: 34052
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

typedef struct{
	TLong x;
	TLong h;
} XH;

int ASC(const XH *a, const XH *b){
	return ((*a).x - (*b).x);
}

int main(int argc, char const *argv[])
{
	int n;
	int j, m, l = 1, r;
	TLong d,a;
	TLong ans = 0, psum[200003] = { 0 }, temp, t;
	XH xh[200003];

	scanf("%d%lld%lld", &n,&d,&a);
	for (int i = 1; i <= n; ++i)	scanf("%lld%lld", &xh[i].x, &xh[i].h);
	qsort(xh, n + 1, sizeof(XH), ASC);

	if(xh[n].x < d * 2) d = xh[n].x;
	else d *= 2;
	
	for (int i = 1; i <= n; ++i)
	{
		psum[i] += psum[i - 1];
		temp = xh[i].h - psum[i];
		if(temp > 0){
			t = (temp - 1) / a + 1;
			ans += t;
			t *= a;
			
			r = n + 1;
			while(l < r){
				m = (l + r) >> 1;
				if(xh[m].x <= xh[i].x + d)  l = m + 1;
				else r = m;
			}
			j = l - 1;

			psum[i] += t;
			psum[j + 1] -= t;
		}
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7932