akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,arr[200005];
     cin>>t;
     for(int i=0;i<t;i++)
        cin>>arr[i];
     ll mx=INT_MAX,cnt=0;
     for(int i=0;i<t;i++)
     {
         if(mx>=arr[i])
            cnt++,mx=arr[i];
     }
     cout<<cnt<<endl;
}


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

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

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
const int INF = 1001001001;
const ll mod = 1e9+7;


struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


struct Sieve {
  int n;
  vector<int> f, primes;
  //初期化、fの中にnまでの素数
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  //xが素数（fの中にある）かを判断
  bool isPrime(int x) { return f[x] == x;}
  //xを素因数分解
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  //素因数分解したものを、)vector<P> (値、数)にする
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  Sieve sieve(105);
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n+1,0);

  rep(i,n+1) a[i]=i;

//  map<int,int> mp;

  for( int i=2;i<=n;i++) {
  //  cout<<i<<' ';
    auto f = sieve.factor(a[i]);

    for (auto p : f) {
      b[p.first]+=p.second;
    //  cout<<p.second<<endl;
    }

  }
  ll c2=0;
  ll c4=0;
  ll c14=0;
  ll c24=0;
  ll c74=0;
//  vector<ll> c(5);
  rep(i,n+1){
    if (b[i]>=2) c2++;
    if (b[i]>=4) c4++;
    if (b[i]>=14) c14++;
    if (b[i]>=24) c24++;
    if (b[i]>=74) c74++;
  }
//  cout<<c2<<' '<<c4<<' '<<c14<<' '<<c24<<' '<<c74<<endl;
  ll ans=c4*(c4-1)*(c2-2)/2;
  ans+=c14*(c4-1);
  ans+=c24*(c2-1);
  ans+=c74;
  cout<<ans;


}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>

int count[1000010];
std::vector<int> V[100010];
std::vector<int> St;
int check[100010];
void func(int k, int prev)
{
	St.push_back(k);
	if(check[k]==1)
	{
		int i;
		for(i=0;i<St.size();i++) if(St[i]==k) break;
		for(;i<St.size()-1;i++)
		{
			int s = St[i], t = St[i+1];
			std::vector<int> ::iterator it;
			
			for(it = V[s].begin();it!=V[s].end();it++)
			{
				if((*it)==t)
				{
					V[s].erase(it);
					count[s]--;
					break;
				}
			}
			for(it = V[t].begin();it!=V[t].end();it++)
			{
				if((*it)==s)
				{
					V[t].erase(it);
					count[t]--;
					break;
				}
			}
		}
		return;
	}
	
	check[k] = 1;
	if(prev==V[k][0]) func(V[k][1],k);
	else func(V[k][0],k);
}

int check2[100010];
void func2(int k, int color)
{
	if(check2[k]) return;
	check2[k] = color;
	for(int i=0;i<V[k].size();i++) func2(V[k][i],color);
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=b;i++)
	{
		int c,d;
		scanf("%d%d",&c,&d);
		V[c].push_back(d);
		V[d].push_back(c);
		count[c]++, count[d]++;
	}
	
	for(int i=1;i<=a;i++)
	{
		if(count[i]%2==1)
		{
			printf("No");
			return 0;
		}
	}
	
	for(int i=1;i<=a;i++)
	{
		if(count[i]>=6)
		{
			printf("Yes");
			return 0;
		}
	}
	int ans = 0;
	for(int i=1;i<=a;i++) if(count[i]>=4) ans++;
	if(ans>=3)
	{
		printf("Yes");
		return 0;
	}
	if(ans<=1)
	{
		printf("No");
		return 0;
	}
	func(1,0);
	
	for(int i=1;i<=a;i++)
	{
		if(count[i]>=4)
		{
			printf("Yes");
			return 0;
		}
	}
	
	int color = 1;
	for(int i=1;i<=a;i++)
	{
		if(count[i]>0&&check2[i]==0)
		{
			func2(i,color++);
		}
	}
	if(color>=3) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 10876
local UnionFind={}

UnionFind.create=function(self,n)
    self.par={}
    self.rank={}
    self.size={}
    for i=1,n do
        self.par[i]=i
        self.rank[i]=1
        self.size[i]=1
    end
end

UnionFind.getroot=function(self,x)
    local nx=x
    while self.par[x]~=x do
        x=self.par[x]
    end
    while self.par[nx]~=x do
        self.par[nx],nx=x,self.par[nx]
    end
    return x
end

UnionFind.same=function(self,x,y)
    return self:getroot(x)==self:getroot(y)
end

UnionFind.unite=function(self,x,y)
    x=self:getroot(x)
    y=self:getroot(y)
    if x==y then
        return
    end
    if self.rank[x]>self.rank[y] then
        x,y=y,x
    elseif self.rank[x]==self.rank[y] then
        self.rank[x]=self.rank[x]+1
    end
    self.par[x]=y
    self.size[y]=self.size[y]+self.size[x]
end

UnionFind.getsize=function(self,x)
    return self.size[self:getroot(x)]
end

UnionFind.new=function(self,n)
    local obj={}
    setmetatable(obj,{__index=UnionFind})
    obj:create(n)
    return obj
end

----------

local n,m=io.read("n","n")
local a,b={},{}
for i=1,m do
    a[i],b[i]=io.read("n","n")
end

local t={[m]=math.floor(n*(n-1)/2)}
local uf=UnionFind:new(n)
for i=m-1,1,-1 do
    if uf:same(a[i+1],b[i+1]) then
        t[i]=t[i+1]
    else
        local ua=uf:getsize(a[i+1])
        local ub=uf:getsize(b[i+1])
        uf:unite(a[i+1],b[i+1])
        t[i]=t[i+1]-ua*ub
    end
end

for i=1,m do
    print(t[i])
end

Measured memory_bytes: 9812
import numpy as np
X, Y, A, B, C = map(int,input().split())
Reds = list(map(int, input().split()))
Greens = list(map(int, input().split()))
Ns = list(map(int, input().split()))

Reds = np.array(Reds)
Greens = np.array(Greens)
Ns = np.array(Ns)

Reds = np.sort(Reds)[::-1]
Greens = np.sort(Greens)[::-1]
Ns = np.sort(Ns)[::-1]

Full = np.append(Reds[:X], Greens[:Y])
Full = np.append(Full, Ns)
Full = np.sort(Full)[::-1]

sum = 0

for i in range(X+Y):
    sum += Full[i]

print(sum)

Measured memory_bytes: 31320
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first < y.first;});
#define FRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.first > y.first;});
#define SSORT(c)     stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second < y.second;});
#define SRSORT(c)    stable_sort(ALL(c), [] (auto& x, auto& y) {return x.second > y.second;});
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define DEBUG true
#define $(x) {if (DEBUG) {cout << #x << " = " << (x) << endl;}}


int main() {
    LL N;
    cin >> N;
    VI W(N);
    REP(i, N) cin >> W[i];

    LL ans = LLONG_MAX;
    REP(t, N) {
        LL left = 0;
        REP(i, t) left += W[i];
        LL right = 0;
        FOR(i, t, N) right += W[i];
        if (ans > abs(left - right)) {
            ans =  abs(left - right);
        }
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    auto getRadian = [](double x, double y) {
        return atan2(x, y);
    };

    double V = a * a * b;
    double rad;
    if (x * 2 > V) {
        double d = 2 * (V - x) / (a * a);
        rad = getRadian(a, d);
    } else if (x * 2 < V) {
        double d = 2 * x / (a * b);
        rad = getRadian(d, b);
    } else {
        rad = 45 * M_PI / 180;
    }
    cout.precision(10);
    cout << 90 - rad * 180 / M_PI;
    return 0;
}


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

int main()
{
	int H = 0, W = 0;
	cin >> H >> W;
	string s;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> s;
			if(s == "snuke"){
				char col = 'A' + j;
				string row = to_string(i + 1);
				string ans = col + row;
				cout << ans << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1;
	//cin>>q;
	while(q--){
		ll a,b,c,k;
		cin>>a>>b>>c>>k;

		ll ans=min(k,a);
		k-=a;
		if(k>0){
			k-=b;
			if(k>0){
				ans-=min(k,c);
			}
		}					
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3612
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s1 = input.ReadLine();
        var s2 = input.ReadLine();

        if(s1 == s2) return "EQUAL";
        if(s1.Length < s2.Length || s1.CompareTo(s2) < 0) return "LESS";
        else return "GREATER";
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

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

int main() {
  set<int> res;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    res.insert(a);
  }
  cout << res.size() << endl;

  return 0;
}

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

void solve(){
	
	int n ;
	cin>>n ;

	int arr[n] ;
	unordered_map<int,int> mp ;

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

	for(int i=0;i<n;i++){
		cout<<mp[i+1]<<" " ;
	}

}	

int main(){


	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 7768
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > 
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

map<char, ll> c;
ll t, o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll H , W;
  cin >> H >> W;

  rep(i, H){
    string inp; cin >> inp;
    rep(j, W){
      c[inp[j]]++;
    }
  }
  
  rep(i,26){
    ll num = c['a'+i];
    num%=4;
    t += num/2;
    num%=2;
    if(num != 0) o++;
  }

  cerr << t <<" "<<  o << endl;
  
  if(o==0){
    if((H%2) && (t<=W/2)) cout << "Yes" << endl;
    else if((W%2) && (t<=H/2)) cout << "Yes" << endl;
    else if((W%2 ==0) && (H%2==0) && (t==0)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else if(o ==1){
    if(H%2 && W%2 && t<=((H/2) + (W/2))) cout <<"Yes" << endl;
    else cout << "No"<< endl;
  }
  else cout <<"No" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
 
namespace workspace{
  class Test{
    static void Main(){
      var trg = "RRR";
      var trg2 = "RR";
      var trg3 = "R";
      
      var S = Console.ReadLine();
      
      if(S.Contains(trg)){
        Console.WriteLine(3);
      }else if(S.Contains(trg2)){
        Console.WriteLine(2);
      }else if(S.Contains(trg3)){
        Console.WriteLine(1);
      }else{
        Console.WriteLine(0);
      }
    }
  }
}

Measured memory_bytes: 25904
a=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
n=int(input())
s=input()
t=""
for u in s:
  t+=a[(a.index(u)+n)%26]

print(t)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define MOD 998244353
using namespace std;
int32_t main()
{
    int n,k;
    cin>>n;
    int m1,m2,m3;
    for(int i=0;i<n;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(i==0)
        {
            m1=a;
            m2=b;
            m3=c;
        }
        else
        {
            int x=m1,y=m2,z=m3;
            m1=a+max(y,z);
            m2=b+max(z,x);
            m3=c+max(x,y);
        }

    }
    cout<<max({m1,m2,m3});
}
    


Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include<utility>
using namespace std;
using ll = long long;

int main()
{
	ll n, a[200000], ans[2] = { 0,0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		ans[0] += abs(a[i] - a[n / 2 - 1]);
		ans[1] += abs(a[i] - a[n / 2]);
	}
	cout << min(ans[0], ans[1]) << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

	string ans = "Impossible";
	int a, b;

	cin >> a >> b;

	ans = (a % 3 == 0) ? "Possible" : ans;
	ans = (b % 3 == 0) ? "Possible" : ans;
	ans = ((a + b) % 3 == 0) ? "Possible" : ans;

	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = str(bin(a[i]))

ans = [0] * 65
for i in a:
    for j in reversed(range(len(i))):
        if i[j] == '1':
            ans[-len(i)+j] += 1
        elif i[j] == '0':
            continue
        elif i[j] == 'b':
            break

tmp = 0
for i in range(len(ans)):
    tmp += 2 ** abs(i - 64) * (n - ans[i]) * ans[i]
    #print(i,2 ** abs(i - 64) * (n - ans[i]) * ans[i])
    tmp %= 10**9+7

print(tmp)

Measured memory_bytes: 132996
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	char c=sc.next().charAt(0);
    if(Character.isUpperCase(c)){
      System.out.println('A');
    }else{
      System.out.println('a');
    }
  }
}


Measured memory_bytes: 35660
N = int(input())
A = [int(input()) for i in range(N)]

max1 = [A.index(max(A)), max(A)]
p = A.pop(A.index(max(A)))
max2 = max(A)
ans = [max2 if j == max1[0] else max1[1] for j in range(N)]
for k in range(N):
    print(ans[k])


Measured memory_bytes: 14100
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define endl    '\n' 
#define INF 2e9
#define int ll
#define vi          vector<int>
#define vii         vector<pii>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

typedef long long ll;

using namespace std;

signed main(){

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int N, X;

    cin >> N >> X;
    vi v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }

    int flag = 1;
    ll point = 0;
    for (int i = 0; i < N; i++)
    {
        point += v[i];
        if (point <= X)
        {
            flag += 1;
        }
    }

    cout << flag << endl;
}


Measured memory_bytes: 256
A,B=map(int,input().split())
S=input()
flag = True
for i in range(A):
    if S[i] == '-':
        flag = False
if S[A] != '-':
    flag = False
for i in range(A+1,A+B+1):
    if S[i] == '-':
        flag = False
if flag == True:
    print('Yes')
else:
    print('No')

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

using namespace std;
#define ll long long
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
const ll mod = 1e9 + 7;
typedef pair<int,int>           PI;
typedef pair<ll,ll>             PL;
typedef vector<PI>               vip; 
typedef vector<int>             vi;
typedef vector<vi>              vvi;
typedef vector<ll>              vl;
typedef vector<vl>              vvl;






int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    vl a(5);
    cin >> n;
    ll neck = 1e15+1;
    REP(i,5){
        cin >> a[i];
        neck = min(neck, a[i]);
    }  
    if(n % neck != 0) cout << n / neck + 5 << endl;
    else cout << n / neck + 4 << endl;

    

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
int main(){
    int Q;
    cin>>Q;
    for(int q=0;q<Q;q++){
        ll A,B;
        cin>>A>>B;
        ll C=0,D=INF;
        while(D-C>1){
            ll mid=(C+D)/2;
            if(mid*mid<A*B)
                C=mid;
            else
                D=mid;
        }
        if(A>B)
            swap(A,B);
        if(A==B){
            cout<<2*A-2<<endl;
            continue;
        }
        if(A+1==B){
            cout<<2*A-2<<endl;
            continue;
        }
        if(C*(C+1)>=A*B)
            cout<<2*C-2<<endl;
        else
            cout<<2*C-1<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>

using namespace std;

char s[200];
int ll[100] , rr[100] , n;

int solve(int x)
{
	int ttt = 0;
	memset(ll , 0 , sizeof(ll));
	memset(rr , 0 , sizeof(rr));
	for(int i = 0 ; i <= x ; i++){
		ll[s[i] - 'a']++;
	}
	for(int i = x + 1 ; i < n ; i++){
		rr[s[i] - 'a']++;
	}
	for(int i = 0 ; i < 26 ; i++){
		if(rr[i] != 0 && ll[i] != 0) ttt++;
	}
	return ttt;
}

int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	int Max = -1;
	for(int i = 0 ; i < n ; i++){
		Max = max(Max , solve(i));
	}
	printf("%d\n",Max);
}

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

#define lli long long int
#define pi pair<int,int>
#define mod 1000000007

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

	int n;
	cin>>n;
	vector<int> dp(3);
	for(int day=0;day<n;day++)
	{
		vector<int> new_dp(3,0);
		vector<int> c(3);
		for(int i=0;i<3;i++)
			cin>>c[i];
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
			{
				if(i!=j)
					new_dp[j]=max(new_dp[j],dp[i]+c[j]);
			}
		}
		dp=new_dp;
	}
	cout<<max(dp[0],max(dp[1],dp[2]))<<endl;
	return 0;
}

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

int main(){
	int n;
	int arr[59][59]={0};
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		for(int j=0;j<s.length();j++){
			int temp=s[j]-'a';
			arr[i][temp]++;
		}
	}
	int min[59];
	for(int j=0;j<26;j++){
		min[j]=arr[0][j];
		for(int i=0;i<n;i++){
			if(min[j]>arr[i][j]){
				min[j]=arr[i][j];
			}
		}
	}
	string ans;
	for(int i=0;i<26;i++){
		for(int j=0;j<min[i];j++){
			ans.push_back(char(i+'a'));
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int H, N;
    cin >> H >> N;
    vi A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    vl dp(H+1, INF);
    dp[0] = 0;
    rep(i, H) {
        rep(j, N) {
            int k = min(i + A[j], H);
            chmin(dp[k], dp[i] + B[j]);
        }
    }
    cout << dp[H] << endl;
    return 0;
}

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

int main() {

  string N;
  cin >> N;

  int tmp = 0;

  for(int i = 0; i < N.size(); i++){
    tmp += N[i] - '0';    
    tmp = tmp % 9;
  }
  if(tmp == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

vector<int> G[100000];

int calc(int v,int par){
	int g = 0;
	for(int to : G[v]){
		if(to != par) g ^= calc(to,v);
	}
	if(par != -1) g++;
	return g;
}

int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(calc(0,-1)) cout << "Alice" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 10368
def ABC_78_A():
    X,Y = map(str, input().split())
    list1 = ['A','B','C','D','E','F']
    list2 = [10,11,12,13,14,15]
    
    if list2[list1.index(X)] > list2[list1.index(Y)]:
        print('>')
    elif list2[list1.index(X)] < list2[list1.index(Y)]:
        print('<')
    else:
        print('=')



if __name__ == '__main__':

    ABC_78_A()

Measured memory_bytes: 3064
a = list(map(int, input().split()))

sum = 0

if a[0] >= a[3]:
    sum += 1 * a[3]
else:
    sum += 1 * a[0]

a[3] -= a[0]
a[3] -= a[1]

if a[3] > 0:
    if a[2] > a[3]:
        sum += -1 * a[3]
    else:
        sum += -1 * a[2]

print(sum)

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

using namespace std;

const long long MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;
    cin>>s;
    set<char> sc(s.begin(),s.end());
    cout<<(sc.size()==s.size()?"yes":"no");
    
    
    return 0;
}


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

using namespace std;

int main(){
    int A, B, K;
    cin >> A;
    cin >> B;
    cin >> K;
    
    //cout << K << endl;
    int i;
    for (int i=0;i<K;i++) {
        if (i%2==0) {
            if (A%2==0) {
                B += A/2;
                A -= A/2;
            }
            else {
                A -= 1;
                B += A/2;
                A -= A/2;
            }
        }
        
        else if (i%2==1) {
            if (B%2==0) {
                A += B/2;
                B -= B/2;
            }
            else {
                B -= 1;
                A += B/2;
                B -= B/2;
            }
        }
    }
    cout << A << " " << B << endl;
    
    return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
d=array(N)
N.times do|i|
    d[i]=get_i
end
is_via=array(N,false,N)
N.times do|k|
  d2=d[k]
  N.times do|i|
      next if i==k
      d1=d[i]
      (i+1).upto(N-1) do|j|
          next if k==j
          if d1[j]==d1[k]+d2[j]
            is_via[i][j]=true
            d1[j]=d1[k]+d2[j]
          elsif d1[j]>d1[k]+d2[j]
            puts "-1"
            exit
          end
      end
  end
end
ans=0
N.times do|i|
    (i+1).upto(N-1) do|j|
      unless is_via[i][j]
        ans+=d[i][j]
      end
    end
end
puts ans

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 500005

#define PI 3.14159265358979323846264338327950

#define F first
#define S second

#define ll  int

#define mod  1000000007



int main()
{
	FAST;
	ll n;
	cin >> n;
	ll a = n/100;
 	ll c = n % 10;
 	ll b = n/ 10   % 10;
 	
	if(a >= c && b <= a){
		cout << a << a << a;
		return 0;
	}
	a ++;
	cout <<a << a << a;
	return 0;
}

Measured memory_bytes: 3580
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <locale>
#define speed                     \
	ios_base::sync_with_stdio(0); \
	cin.tie(0);                   \
	cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf INT_MAX
#define mod 1000000007
using namespace std;

vector<double>v;
int n;
double ar[3000][3000];

double req(int p = 0, int c = 0) {
	if (p == n) {
		if (c > n / 2)
			return 1;
		return 0;
	}
	if (ar[p][c] >= 0)
		return ar[p][c];
	double res = (1 - v[p]) * req(p + 1, c) + v[p] * req(p + 1, c + 1);
	ar[p][c] = res;
	return res;
}

int main() {
	speed;
	for (int i = 0; i < 3000; ++i)
		for (int j = 0; j < 3000; ++j)
			ar[i][j] = -1;
	cin >> n;
	v.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	cout.precision(10);
	cout << fixed << req();
}

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


int main(){
    string S,T;
    cin >> S >> T;
    bool flag = false;
    for(int i=0;i<S.size();++i){
        if(S==T){
            flag = true;
            break;
        }
        S = S.back() + S.substr(0, S.size()-1);
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program{
  
 	static void Main(string[] args){
     	var line = System.Console.ReadLine();
      	var list = line.Split(' ').Select(x=>int.Parse(x)).ToList();
      
      	int a = list[0];
      	int b = list[1];
      
      	var calcList = new List<int>(){a+b,a-b,a*b};
      
      	System.Console.WriteLine(calcList.Max());
      
      
      
    }
  
}

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

#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b)  for(int i=(a);i<(b);++i)
#define rep(i,n)    FOR(i,0,n)
#define rrep(i,n)   for(int i=n-1;i<=0;--i)
#define loop        while(true)
typedef long long ll;
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const ll MAX = 10000000;
const ll MIN = 0;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using pint = pair<int, int>;
using pstring = pair<int, string>;

int main() {
    ll ans;
    ll N;
    cin >> N;
    if(N >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

int main()
{
    int d;
    cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));

    for (int i = 0; i < 26; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }
    vector<int> t(d);
    for (int i = 0; i < d; i++)
    {
        t[i] = 1;
    }
    
    int m = 150000;
    long long ans = 0;
    while(m--){
        vector<int> tt(d);
        for (int i = 0; i < d; i++)
        {
            tt[i] = t[i];
        }
        int dd = m % d,p = (m % 26 + 13) % 26 + 1;
        t[dd] = p;

        long long buf = 0;
        vector<int> last(26,0);
        for (int i = 0; i < d; i++)
        {
            buf += s[i][t[i] - 1];
            last[t[i] - 1] = i + 1;
            for (int j = 0; j < 26; j++)
            {
                buf -= c[j] * (i + 1 - last[j]);
            }
        }

        if(ans < buf)ans = buf;
        else
        {
            for (int i = 0; i < d; i++)
            {
                t[i] = tt[i];
            }
        }
    }
    //cout << ans << endl;
    for (int i = 0; i < d; i++)
    {
        cout << t[i] << endl;
    }
}


Measured memory_bytes: 3676
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
ans = 10000000000000000000000000000
for i in range(d):
    p[i], c[i] = map(int, input().split())

for i in range(2**d):
    sum = 0
    num = 0
    for j in range(d):
        if i & (1 << j):
            sum += c[j]+p[j]*100*(j+1)
            num += p[j]
    if sum >= g:
        ans = min(ans, num)
    else:
        for j in range(d-1, -1, -1):
            if i & (1 << j):
                continue
            for k in range(p[j]):
                if sum >= g:
                    break
                sum += 100*(j+1)
                num += 1
        ans = min(ans, num)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
using ll = long long;
ll mod = 2019;
int main(){
    ll a, b;
    cin >> a >> b;
    if(b - a >= 2019){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 2019;
    for(ll i = a; i <= b; i++){
        for(ll j = i + 1; j <= b; j++){
            ans = min(ans, i * j % mod);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
int main(void){
    int X; 
    long long int ans=0;
    scanf("%d",&X);
    ans+=X/500;
    ans*=1000;
    X=X%500;
    ans+=(X/5)*5;
    printf("%lld",ans);
    return 0;
}

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

int main() {
  string A;
  cin >> A;
  vector<ll> cs(26);
  ll n = A.size();

  for (char c : A)
    cs[c - 'a']++;

  ll res = n * (n - 1) / 2 + 1;

  for (ll x : cs) {
    res -= x * (x - 1) / 2;
  }

  cout << res << endl;
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
int main(){
	/*
	#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
	#endif
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int x;
	cin>>x;
	cout<<3*x*x;
}

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  char pre = ' ';
  for(auto x: s) {
    if(pre == x) cnt++; 
    else         cnt = 0;
    pre = x;
    if(cnt == 2) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Data{
  public:
  int a;
  int b;
  
  bool operator<(const Data &another) const{
    return b<another.b;
  };
};

int main(){
  int n,i,buf;
  cin>>n;
  vector<Data> A(n); 
  for(i=0;i<n;i++){
    cin>>buf;
    A[i].a=i+1;
    A[i].b=buf;
  }
  sort(A.begin(),A.end());
  for(i=0;i<n;i++){
    cout<<A[i].a;
    if(i==n-1) cout<<endl;
    else cout<<" ";
  }

  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	int n;
	cin >> n;
	string x;
	vector<pair<int,int>> v;
	int onlyOpen = 0, onlyClose = 0;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		int open = 0, close = 0;
		for (char c : x) {
			if (c == '(') open++;
			else {
				if (open) open--;
				else close++;
			}
		}
		if (close == 0) {
			onlyOpen += open;
		}else if (open == 0) {
			onlyClose += close;
		}else {
			v.push_back({open, close});
		}
	}
	sort(v.begin(), v.end(), [](auto a, auto b) {
		return a.first - a.second > b.first - b.second;
	});
	int open = onlyOpen;
	int ok = 1;
	for (auto a : v) {
		if (a.second > open) {
			ok = 0;
		}else {
			open -= a.second;
			open += a.first;
		}
	}
	if (ok && open == onlyClose) {
		cout << "Yes\n";
	}else {
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 5264
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int f(int x){
    if (x%2==1) return 0;
    return f(x/2) + 1;
}


int main(){
    int N; cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];

    ll ans = 0;
    rep(i,N){
        ans += f(a[i]);
    }

    cout << ans << endl;

}



Measured memory_bytes: 3696
def fib(n):
  a, b = 0, 1
  for i in range(n):
    a, b = b, a + b
    if b > 1000000007:
      b -= 1000000007
  return b

n,m=map(int,input().split())
if m==0:
  ans=fib(n)
else:
  a=[int(input()) for i in range(m)]
  ans = fib(a[0]-1)%1000000007
  for i in range(m-1):
    if a[i+1]-a[i]==1:
      ans=0
      break
    ans = ans*fib(a[i+1]-a[i]-2)%1000000007
  ans = ans*fib(n-a[m-1]-1)%1000000007
print(ans)

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

int main() {
    char ch;
  	cin>>ch;
   	map<int, char> mp;
    int limit =0;
  	for (char c = 'a'; c<='z'; c++) {
    	mp[limit++] = c;
    }
    int pos = (int)(ch-'a');
    cout << mp[(pos+1)%26];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, k, a, b;
  cin >> n;
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    if (a > n/2)
      a = n - a + 1;
    if (b > n/2)
      b = n - b + 1;
    int color = (a > b ? b : a) % 3;
    color = (color == 0 ? 3 : color);
    cout << color << endl;
  }
  return 0;
}

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

struct Dice{
	int num[6];
};

int move(struct Dice dice, string str){
	int store[6];

	for(int i=0;i<str.length();i++){
		for(int j=0;j<6;j++){
			store[j] = dice.num[j];
		}
		switch(str[i]){
		case 'N':
			dice.num[0] = store[1];
			dice.num[1] = store[5];
			dice.num[5] = store[4];
			dice.num[4] = store[0];
			break;
		case 'E':
			dice.num[0] = store[3];
			dice.num[3] = store[5];
			dice.num[5] = store[2];
			dice.num[2] = store[0];
			break;
		case 'S':
			dice.num[0] = store[4];
			dice.num[4] = store[5];
			dice.num[5] = store[1];
			dice.num[1] = store[0];
			break;
		case 'W':
			dice.num[0] = store[2];
			dice.num[2] = store[5];
			dice.num[5] = store[3];
			dice.num[3] = store[0];
			break;
		}
	}

	return dice.num[0];
}

int main(){
	struct Dice dice;
	string str;

	for(int i=0;i<6;i++){
		cin>>dice.num[i];
	}
	cin>>str;

	cout<<move(dice, str)<<endl;
	return 0;
}

Measured memory_bytes: 1208
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program {
    static void Main() {
        var N = NextInt();
        var sw = 0;
        foreach (var i in Enumerable.Range(0, N)) {
            var A = NextInt();
            sw = sw ^ A % 2;
        }
        if (sw == 0) {
            WriteLine("YES");
        } else {
            WriteLine("NO");
        }
    }

    static int NextInt() {
        return int.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 15400
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n,h,w;
    int a,b;
    cin>>n>>h>>w;
    int ans=0;
    for(int i=0; i<n; i++){
        cin>>a>>b;
        if(a>=h && b>=w){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3624
INF = 10**10
N,M,K = map(int,input().split())
A = [0]+list(map(int,input().split()))+[INF]
B = [0]+list(map(int,input().split()))+[INF]
tmp = 0
i = 0
j = 0
while tmp+A[i+1]<=K:
    tmp += A[i+1]
    i += 1
while tmp+B[j+1]<=K:
    tmp += B[j+1]
    j += 1
ans = i+j
while i>0:
    tmp -= A[i]
    i -= 1
    while tmp+B[j+1]<=K:
        tmp += B[j+1]
        j += 1
    ans = max(ans,i+j)
print(ans)

Measured memory_bytes: 42068
import std.stdio;
void main() {
	for (;;) {
		int n, x;
		"%d %d\n".readf(&n, &x);
		if (n == 0 && x == 0) break;
		int c = 0;
		foreach (i; 1..n-1)
			foreach (j; i+1..n)
				foreach (k; j+1..n+1)
					if (i+j+k == x) ++c;
		c.writeln;
	}
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
 using namespace std;
const int N=1e5+5;
int dp[N][3],a[N],b[N],c[N];

int main()
{
  
  int n,k;
  cin>>n;
  
  for(int i=1;i<=n;i++)
  {
    cin>>a[i]>>b[i]>>c[i];
  }

  dp[1][0]=a[1];
  dp[1][1]=b[1];
  dp[1][2]=c[1];

  for(int i=2;i<=n;i++)
  {
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
  }
  
  cout<<max({dp[n][0],dp[n][1],dp[n][2]});
  
  return 0;  
}   

Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<double> p(n+1);
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	vector<double> dp(n+1);
	dp[0]=1;
	for(int i=0;i<n;i++){
		for(int j=i+1;j>=0;j--){
		    dp[j] = (j==0?0:dp[j-1]*p[i]) + dp[j]*(1-p[i]) ;	
		}
	}
	double ans=0;
	for(int heads=0;heads<=n;heads++){
		int tails = n-heads;
		if(heads>tails)
		    ans+=dp[heads];
	}
	cout.precision(10);
	cout<<ans;
	return 0;
}


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

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

		//点数入力
		int *score = new int[judg];
		for(int i=0; i<judg; i++)
			cin >> score[i];
		
		//最高点最低点求める
		int max=0,min=0;
		for(int i=0; i<judg; i++){
			if( score[max]<score[i] ) max=i;
			if( score[min]>score[i] ) min=i;
		}
		
		//平均点求める
		int avg=0;
		for(int i=0; i<judg; i++){
			if(i!=max&&i!=min)
				avg+=score[i];
		}
		avg = avg/(judg-2);

		cout << avg << endl;
	}
}

Measured memory_bytes: 0
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    x, y = map(int, input().split())
    check = y // x
    n = 0
    while 2 ** n <= check:
        n += 1
    print(n)
    # print(int(math.log2(y / x)) + 1)




if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    char a,b;
    cin >>a>>b;
    if(a==b ) cout << 'H' << endl;
    else cout << 'D' << endl;



}


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

using namespace std;

int main() {
	int a[4];
	int b[2];
	int sum = 0;
	int minv = 0;
	int min1 = 120;
	for (int i = 0; i < 4; i++) {
		cin >> a[i];
		sum += a[i];
		min1 = min(min1, a[i]);
	}
	minv += min1;
	int min2 = 120;
	for (int i = 0; i < 2; i++) {
		cin >> b[i];
		sum += b[i];
		min2 = min(min2, b[i]);
	}
	minv += min2;
	cout << sum - minv << endl;
}


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

vector<int> adj[3000];
int visit[3000];
map<int,int> m;

void bfs(int s)
{
    memset(visit,-1,sizeof visit);
    queue<int> q;
    q.push(s);
    int k=0;
    while(1)
    {
        queue<int> tmp;
        while(q.size())
        {
            int x=q.front();
            q.pop();
        
		if(visit[x]==0)
		continue;
    visit[x]=0;
            for(int i=0;i<adj[x].size();++i)
            if(visit[adj[x][i]])
            tmp.push(adj[x][i]);
            ++m[k];
        }
        ++k;
        q=tmp;
        if(q.size()==0)
        break;
    }
}

int main() {
    int n;
    cin>>n;
    --n;
    for(int i=0;i<n;++i)
    adj[i].push_back(i+1),adj[i+1].push_back(i);
    
    int x,y;
    cin>>x>>y;
    --x;--y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    

    for(int i=0;i<=n;++i)
        bfs(i);

    
    
    for(int i=1;i<=n;++i)
    cout<<m[i]/2<<endl;
    
    return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, x, count int
	)

	fmt.Scan(&a, &b, &c, &x)
	for i := 0; i < a+1; i++ {
		for j := 0; j < b+1; j++ {
			for k := 0; k < c+1; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <stdio.h>

int main ()
{
	int n, i, j;
	char s [200];

	scanf ("%d", &n);
	getchar ();

	gets(s);

	if (n & 1) printf ("No");

	else {
		int flag = 0;
		for (i = 0, j = n / 2; i < n / 2; i ++, j ++) {
			if (s [i] != s [j]) flag = 1;
		}

		if (flag) printf ("No");
		else printf ("Yes");
	}

	return 0;
}


Measured memory_bytes: 1740
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;

const int NMAX = 510;
typedef long long i64;

i64 dp[NMAX][NMAX];
i64 sp[NMAX];

int main()
{
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; i++) {
        scanf("%d", sp + i);
        sp[i] += sp[i - 1];
    }

    for (int i = n; i >= 1; i--) {
        for (int j = i + 1; j <= n; j++) {
            dp[i][j] = 1e18;
            for (int k = i; k < j; k++)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);
            dp[i][j] += sp[j] - sp[i - 1];
        }
    }

    cout << dp[1][n] << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
using namespace std;

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

int main(){
    string in;
    while( getline(cin, in), !(in.length()==1 && in[0]=='.') ) {
        stack<int> brackets;
        bool judge = true;
        rep( i, in.length() ) {
            if( in[i] == '(' ) {
                brackets.push(0);
            } else if( in[i] == '[' ) {
                brackets.push(1);
            } else if( in[i] == ')' ) {
                if( !(brackets.size()>0 && brackets.top()==0) ) {
                    judge = false;
                } else {
                    brackets.pop();
                }
            } else if( in[i] == ']' ) {
                if( !(brackets.size()>0 && brackets.top()==1) ) {
                    judge = false;
                } else {
                    brackets.pop();
                }
            }
        }
        if( brackets.size() > 0 ) judge = false;
        cout << (judge ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int ans; 
string s; 
int main()
{
    cin>>s;
    for(int i=0;i<s.size();i++)
	{
        if(s[i]=='C') ans=1;
        if(s[i]=='F'&&ans==1)
		{
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> L(N);
    rep(i,N) cin>>L.at(i);
    ll ans=0;
    rep(i,N-1) ans+=min((L.at(i+1)-L.at(i))*A,B);
    cout<<ans<<endl;
    return 0;
}


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


int main()
{
    int N, M;
    std::cin >> N >> M;

    std::multiset<int> cost;

    for (int i = 0; i < N; ++i)
    {
        int n;
        std::cin >> n;
        cost.insert(n);
    }

    for (int i = 0; i < M; ++i)
    {
        // 先頭に割引券
        int p = *cost.rbegin();
        cost.erase(--cost.end());
        p /= 2;
        cost.insert(p);
    }

    int64_t sum = 0;
    for (int c : cost)
    {
        sum += c;
    }

    std::cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 4992