akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    ll ans =0;
    ll now=0;
     ll r=0;
    rep(l,N){
       
        while(r<N){
            //cout<<l<<" "<<r<<endl;
            if((now&A[r])==0){
                ans+=(r-l+1);
                //cout<<"a"<<ans<<endl;
                now += A[r];
                r++;
            }else{
                //r++;
                now -=A[l];
                break;
            }
        }
        if(r==N){
            break;
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4812
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#define N 100002
#define D 12
using namespace std;
struct edge 
{
	int nxt,point,v;
};

struct node 
{
	int v,c,d;	
};

edge e[N << 1];

node a[N];
int n,m,Q,f[N][D],cnt;

	void add(int u1,int v1)
	{
		e[++cnt].nxt = e[u1].point; e[u1].point = cnt; e[cnt].v = v1;
	}
	
	void insert(int u1,int v1)
	{
		add(u1,v1); add(v1,u1);
	}
void init()
{
	scanf("%d %d",&n,&m);
	cnt = 0;
	for (int i = 1;i <= m; ++i)
	{
		int u1,v1;
		scanf("%d %d",&u1,&v1);
		insert(u1,v1);	
	}
	memset(a,0,sizeof(a));
	scanf("%d",&Q);
	for (int i = 1;i <= Q; ++i)
	{
		scanf("%d %d %d",&a[i].v,&a[i].d,&a[i].c);
		f[a[i].v][a[i].d] = max(f[a[i].v][a[i].d],i);
	}
	//cout<<"ha"<<f[6][1]<<endl;
}

void DO_IT()
{
	for (int i = 9;i >= 0; --i)
		for (int j = 1;j <= n; ++j)
			for (int p = e[j].point;p;p = e[p].nxt)
				f[j][i] = max(f[j][i],f[e[p].v][i + 1]);		
	//for (int i = 1;i <= 9; ++i)
}

void print()
{
	for (int i = 1;i <= n; ++i)
	{
		int M = 0;
		for (int j = 0;j <= 10; ++j)
			M = max(M,f[i][j]);
		printf("%d\n",a[M].c); 
	}
}

int main()
{
	init();
	DO_IT();
	print();
	return 0;
}

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

bool solve();

int main()
{
	if (solve()) puts("YES");
	else puts("NO");

	return 0;
}

bool solve()
{
	int64_t R, C;
	int N;
	scanf("%lld%lld%d", &R, &C, &N);
	std::vector<std::pair<std::complex<long double>, int>> points;
	for (int i{}; i < N; i++)
	{
		int64_t r1, c1, r2, c2;
		scanf("%lld%lld%lld%lld", &r1, &c1, &r2, &c2);
		if (r1 != 0 && r1 != R && c1 != 0 && c1 != C) continue;
		if (r2 != 0 && r2 != R && c2 != 0 && c2 != C) continue;
		points.push_back({{(long double)c1, (long double)r1}, i});
		points.push_back({{(long double)c2, (long double)r2}, i});
	}
	std::complex<long double> center{C / 2.0, R / 2.0};
	std::sort(points.begin(), points.end(),
		[&](const auto& a, const auto& b)
		{
			return std::arg(a.first - center) < std::arg(b.first - center);
		}
	);
	std::stack<int> st;
	for (auto& e: points)
	{
		if (st.empty() || st.top() != e.second)
			st.push(e.second);
		else
			st.pop();
	}
	return st.empty();
}

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

int main(){
	int i,j,n;	cin>>n;
	
	ll f[n+1],b[n+1];
	f[0]=1;
	for(i=1;i<=n;i++){
		f[i]=(i*f[i-1])%mod;
	}
	b[n]=n;
	for(i=n;i>0;i--){
		b[i-1]=((i-1)*b[i])%mod;
	}
	
	ll temp[n+1];
	temp[1]=f[n];
	for(i=2;i<=n;i++){
		temp[i]=temp[i-1];
		ll t=f[i-1];
		if(i+1<=n)	t*=b[i+1];
		t%=mod;
		temp[i]+=t;	temp[i]%=mod;
	}
	ll ans=0,sum=0;
	ll a[n+1];
	for(i=1;i<=n;i++){
		scanf("%lld",a+i);
		sum+=a[i];	sum%=mod;
		ans+=a[i]*temp[i];	ans%=mod;
		ans+=a[i]*temp[n+1-i];	ans%=mod;
	}
	ans-=sum*f[n];	ans%=mod;
	ans+=mod;	ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define fr(i,n) for (int i = 0; i < n; i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<ll,ll>
#define vi vector<int>
#define vii vector<ii>
#define INF 1000000000
#define endl '\n'
#define ll long long int
using namespace std;
int main(){
	ll num=0,k;
	cin>>k;
	ll f=0;
  for(ll i=1;i<=(ll)1e7;i++){
  	num=(num*10+7)%k;
  	if(num==0)
  	{
  		cout<<i<<endl;
  		f=1;
  		break;
	  }
  }
  if(!f)
  cout<<"-1"<<endl;
}

Measured memory_bytes: 3612
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 2e5 + 100;





signed main() {
    speed;
    int n;
    cin >> n;
    cout << fixed << setprecision(10) << .0 +2*PI*n;
    return 0;
}


Measured memory_bytes: 3224
import java.util.Arrays;
import java.util.Scanner;

class Main {

	public void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int[][] d = new int[A][B];
		for (int i = 0; i < A; ++i) {
			for (int j = 0; j < B; ++j) {
				d[i][j] = sc.nextInt();
			}
		}

		//d[x][y]=min(c[i][j]+i*x+j*y);
		int[][] c = new int[101][101];
		for (int x = 0; x < A; ++x) {
			for (int y = 0; y < B; ++y) {
				for (int i = 0; i <= 100; ++i) {
					for (int j = 0; j <= 100; ++j) {
						c[i][j] = Math.max(c[i][j], d[x][y] - (x + 1) * i - (y + 1) * j);
					}
				}
			}
		}
		int[][] d_now = new int[A][B];
		for (int i = 0; i < A; ++i) {
			for (int j = 0; j < B; ++j) {
				d_now[i][j] = Integer.MAX_VALUE / 3;
			}
		}

		for (int i = 0; i <= 100; ++i) {
			for (int j = 0; j <= 100; ++j) {
				for (int x = 0; x < A; ++x) {
					for (int y = 0; y < B; ++y) {
						d_now[x][y] = Math.min(d_now[x][y], c[i][j] + (x + 1) * i + (y + 1) * j);
					}
				}
			}
		}
		for (int x = 0; x < A; ++x) {
			for (int y = 0; y < B; ++y) {
				if (d[x][y] != d_now[x][y]) {
					System.out.println("Impossible");
					return;
				}
			}
		}
		System.out.println("Possible");
		System.out.println(300 + " " + (100 + 100 + 101 * 101 + 2));
		for (int i = 1; i <= 100; ++i) {
			System.out.println(i + " " + (i + 1) + " X");
		}
		for (int i = 102; i <= 201; ++i) {
			System.out.println(i + " " + (i + 1) + " Y");
		}
		for (int i = 0; i <= 100; ++i) {
			for (int j = 0; j <= 100; ++j) {
				System.out.println((i + 1) + " " + (202 - j) + " " + c[i][j]);
			}
		}
		int s = 299;
		int t = 300;
		System.out.println(s + " " + 1 + " " + 0);
		System.out.println(202 + " " + t + " " + 0);
		System.out.println(s + " " + t);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 30244
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

int main(void){
	long n=nextplong();
	if(n==2){
		puts("1");
		return 0;
	}
	long ans=0;
	{
		int m=sqrt(n-1);
		for(int i=2; i<=m; i++){
			if((n-1)%i==0){ans+=2; /*printf("%d ", i);*/}
		}
		if((long)m*m==n-1) ans--;
		ans++; //n-1
		//putchar(10);
	}{
		long m=sqrt(n);
		for(int i=2; i<=m; i++){
			if(n%i==0){
			long s=n;
			while(s%i==0) s/=i;
			if(s%i==1){ans++; /*printf("%d ", i);*/}
			s=n;
			long j=n/i;
			if(j==i) continue;
			while(s%j==0) s/=j;
			if(s%j==1){ans++; /*printf("%ld ", j);*/}
			}
		}
		ans++; //n
		//putchar(10);
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 128
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 string s; cin >> s;
 string t; cin >> t;
 string q = t.substr(0, t.length()-1);
 if(s == q) cout << "Yes" << endl;
 else { cout << "No" << endl;}
return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int x = scanner.nextInt();
		String ans = x >= a && x <= a + b ? "YES" : "NO";
		System.out.println(ans);
	}

}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int inputDay = sc.nextInt();
      System.out.print("Christmas");
      for(int i = inputDay ; i<25; i++){
      	System.out.print(" Eve");
      }
    }
}

Measured memory_bytes: 22228
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll n,k;rd(n,k);
    ll a[n]; read(a,n);
    sort(a,a+n);
    ll left = n-k;
    ll s = 0;
    fo(i,0,left-1){
        s+=a[i];
    }
    pp(s);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 5164
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

void solve(){
    int n,temp;
    cin>>n;
    map<ll ,ll>m;
    for(int i=0; i<n; i++){
        cin>>temp;
        m[temp]++;
    }
    ll ans=0;
    for(auto it: m){
        if(it.first < it.second){
            ans += (it.second-it.first);
        }
        else if(it.first > it.second){
            ans += it.second;
        }
    }
    cout<<ans<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
}

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

int main(void)
{
    int r,c;
    cin >>r>>c;
    int a[r+1][c+1];
    int i,j, sum;
    for(i=0;i<r+1;i++){
        for(j=0;j<c+1;j++){
            a[i][j]=0;
        }
    }
    for(i=0;i<r;i++){
        sum = 0;
        for(j=0;j<c;j++){
            cin >>a[i][j];
            a[r][j] += a[i][j];
            sum += a[i][j];
        }
        a[i][c] = sum;
        a[r][c] += sum;
    }

    for(i=0;i<r+1;i++){
        for(j=0;j<c+1;j++){
            if(j==c) printf("%d\n", a[i][j]);
            else printf("%d ",a[i][j]);
        }
    }

}


Measured memory_bytes: 3216
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[100050];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
		cin>>n;
        for(int i=1;i<=n;++i)  cin>>a[i];
        int tmp=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[tmp]>0){
                   		G[i][j]=tmp;
                   		a[tmp]-=1;
				   } 
                   else if(a[tmp]==0){
                   		tmp++;
                   		G[i][j]=tmp;
                   		a[tmp]-=1;
				   } 
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[tmp]>0) {G[i][j]=tmp;--a[tmp];}
                    else if(a[tmp]==0) {++tmp;G[i][j]=tmp;--a[tmp];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) cout<<G[i][j]<<' ';
                else cout<<G[i][j]<<endl;
            }
        }
    }
    return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	long ans = 0;
	for(int i=0; i <= n; i++) {
		if(!(i % 3) || !(i % 5))
			continue;
		ans += i;
	}
	printf("%ld\n", ans);
}


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

int main() {
	char ch;
	int ans = 700;
	for (int i = 0; i < 3; i++) {
		cin >> ch;
		if (ch == 'o') ans += 100;
	}
	cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<ll, ll>> vpll;

//mt19937 random(566);
//uniform_int_distribution<ll> distr;
//ll rnd(ll a, ll b) {return a + distr(random) % (b - a + 1);}

const int N = 1e5;

int p[N], siz[N];

int find(int v) {
    if (p[v] == v) return v;
    else return p[v] = find(p[v]);
}

void unite(int u, int v) {
    u = find(u), v = find(v);
    if (u == v)
        return;
    siz[u] += siz[v];
    p[v] = u;
}

vi ban[N];
int deg[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    forn(i, n) p[i] = i, siz[i] = 1;
    int u, v;
    forn(i, m) {
        cin >> u >> v;
        u--, v--;
        deg[u]++, deg[v]++;
        unite(u, v);
    }
    forn(i, k) {
        cin >> u >> v;
        u--, v--;
        ban[u].pb(v);
        ban[v].pb(u);
    }
    forn(i, n) {
        int ans = siz[find(i)] - 1 - deg[i];
        for (int j : ban[i]) if (find(i) == find(j)) ans--;
        cout << ans << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 7808
<?php
fscanf(STDIN, "%d %d", $n, $k);
$line = fgets(STDIN);
$array = explode(" ", $line);
$count = 0;
sort($array, SORT_NUMERIC);
for ($i=0;$i<$k;$i++) { 
    $count += (int)$array[$i];
}
echo $count;
echo "\n";
?>


Measured memory_bytes: 16192
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
cur = 1e9
idx = 0
for i in range(n):
  if abs(a-(t-h[i]*0.006))<cur:
    cur = abs(a-(t-h[i]*0.006))
    idx = i+1
print(idx)

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  if(k<=a) ans = k;
  else if(a<k && k <= a+b) ans = a;
  else if(a+b < k) ans = a-(k-a-b);
  cout << ans << endl;
}


Measured memory_bytes: 3636
//I am so vegetable
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 105;
const int MOD = 998244353;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	FIO;
	string s; cin >> s;
	if (s[0] == s[1] && s[1] == s[2])cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.array;

void main(){
	auto s=readln.chomp;
	if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba")writeln("Yes");
	else writeln("No");
}

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


int main() {
  int n;
  cin >> n;
 
  int pre=-10, ans=0;
  rep(i, n-1){
    int b;
    cin >> b;
    if(i==0) ans+= 2*b;
    else if(pre > b) ans = ans-pre+(2 * b);
    else ans+= b;
    pre = b;
  }
  
  cout << ans << endl;  
  return 0;
  
}

Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input);

  let N = o.a();
  
  if (N === 1) {
    console.log("Hello World");
  }

  if (N===2) {
    let A = o.a();
    let B = o.a();
    console.log(A + B);
  }
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
X = [[int(i) for i in input().split()] for _ in range(n)]
ans = 0
for i in range(n):
    ab = [a*b for a,b in zip(X[i],B)]
    j = sum(ab) + c
    if j > 0:
        ans += 1
    else:
        ans += 0
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl color;  // color[v] : 0は白、1は黒、-1は未訪問

bool dfs(ll v, ll now = 0) {
    color[v] = now;
    for(auto u : G[v]) { 
        if(color[u] != -1) {
            if(color[u] == now) {
                return false;
            }
            continue;
        }
        if(!dfs(u, 1-now)) {
            return false;
        }
    }
    return true;
}

int main() {
    ll n, m;
    cin >> n >> m;    

    G.resize(n);
    rep(i, m) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    
    color.assign(n, -1);
    bool nibuGraph = true;
    rep(v, n) {
        if(color[v] != -1) {
            continue;
        }
        if(!dfs(v)) {
            nibuGraph = false;
        }
    }

    if(nibuGraph) {
        ll cntW = 0, cntB = 0;
        rep(v, n) {
            if(color[v]) {
                cntB++;
            }
            else {
                cntW++;
            }
        }
        out(cntW*cntB - m);
    }
    else {
        out(n*(n-1)/2 - m);
    }
    
    re0;
}

Measured memory_bytes: 7424
def xor_sum(a):
    sum = 0
    d = 10**9+7
    new_a = []
    for j in a:
        new_a.append(str(format(j, 'b')).zfill(60))
    for i in range(60):
        n_0 = 0
        n_1 = 0
        for j in new_a:
            if j[i] == '0':
                n_0 += 1
            else:
                n_1 += 1
        sum += (pow(2, 59-i)*(n_0*n_1))%d
    print(sum%d)

n = int(input())
a = [int(i) for i in input().split()]

xor_sum(a)

Measured memory_bytes: 129092
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=200005;
int n,b[N],B[N];
ll a[N],A[N],c[N];
double res[N];
pll q[N];
bool cmp(pll a,pll b,pll c){
	c.fi-=a.fi; c.se-=a.se;
	b.fi-=a.fi; b.se-=a.se;
	return 1ll*c.fi*b.se<=1ll*b.fi*c.se;
}
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%lld",&A[i]);
	For(i,1,n) scanf("%d",&B[i]);
	int p=max_element(A+1,A+n+1)-A;
	For(i,0,n) a[i]=A[(i+p-1)%n+1];
	For(i,0,n) b[i]=B[(i+p-1)%n+1];
	c[0]=c[1]=0;
	For(i,1,n-1) c[i+1]=2*c[i]+2*b[i]-c[i-1];
	int t=0;
	For(i,0,n){
		for (;t>1&&cmp(q[t-1],q[t],pll(i,a[i]-c[i]));--t);
		q[++t]=pll(i,a[i]-c[i]);
	}
	//For(i,1,t) cout<<q[i].fi<<' '<<q[i].se<<endl;
	For(i,1,t-1)
		For(j,q[i].fi,q[i+1].fi)
			res[j]=q[i].se+(q[i+1].se-q[i].se)/1.0/(q[i+1].fi-q[i].fi)*(j-q[i].fi);
	double sum=0;
	For(i,1,n){
		sum+=res[i]+c[i];
		//cout<<res[i]+c[i]<<' '<<b[i]<<' '<<a[i]<<endl;
	}
	printf("%.10lf\n",sum/n);
}
/*
c[i-1]-c[i]
*/

Measured memory_bytes: 14628
#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	cout<<a[n/2]-a[n/2-1];
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>


void selectionSort(void);

int A[100], n, count=0;

int main(){
  int i;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    scanf("%d", &A[i]);

  selectionSort();

  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i == n-1) break;
    printf(" ");
  }

  printf("\n%d\n", count);

  return 0;
}

void selectionSort(void){
  int i, j, a, minj;
  for(i = 0; i < n; i++){
    minj = i;
    for(j = i; j < n; j++){
      if(A[j] < A[minj])
	minj = j;
    }
    if(A[i] != A[minj]){
      a = A[i];
      A[i] = A[minj];
      A[minj] = a;
      count++;
    }
  }
}

Measured memory_bytes: 604
#include <iostream>

using namespace std;

int main(){
	int a, b, c;

	cin >> a >> b >> c;

	bool poor = false;

	if(a == b && a != c)
		poor = true;
	else if(a != b && a == c)
		poor = true;
	else if(b == c && a != c)
		poor = true;

	if(poor)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    cout << r * 2 * 3.141592 << endl;


    return 0;
}


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


int main()
{
    int n,AC=0,WA=0,TLE=0,RE=0;
    cin>>n;
    string s;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        if(s=="AC")
            AC++;
        else if (s=="WA")
            WA++;
        else if (s=="TLE")
            TLE++;
        else
            RE++;
    }

    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE;
}

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

int main()
{
	int n,t,i,j,k, W;
	long int w[102], v[102];
	cin>>n>>W;
	
	for(i=1;i<=n;i++)
	{
		scanf("%ld %ld", &w[i], &v[i]);
	}

	long int s[102][100002];
	
	for(i=0;i<=W;i++)
	{
		s[0][i] = 0;
	}

	for(j=0;j<=n;j++)
	{
		s[j][0] = 0;
	}
	
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=W;j++)
		{
			s[i][j] = s[i-1][j];

			if(w[i]<=j)
			{
				s[i][j] = max(s[i-1][j], v[i] + s[i-1][j-w[i]]);
			}
		}
	}
  
	cout<<s[n][W]<<endl;

	return 0;

}

Measured memory_bytes: 79744
import sys
if sys.platform=="ios":
	sys.stdin=open("input_file.txt")

n=int(input())
ans=""
print(end=" ")
for i in range(1,n+1):
	if i%3==0:
		ans+=str(i)+" "
		continue
	
	a=i//10000
	b=(i-10000*a)//1000
	c=(i-10000*a-1000*b)//100
	d=(i-10000*a-1000*b-100*c)//10
	e=(i-10000*a-1000*b-100*c-10*d)
	
	if a==3 or b==3 or c==3 or d==3 or e==3:
		ans+=str(i)+" "
		
print(ans[:-1])
			
		



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

#define SKYLAGS UNSTOPPABLE
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define SKY ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long int

void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int dp[n];
    dp[1]=abs(a[1]-a[0]);
    dp[0]=0;
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1]<<"\n";
}

int32_t main()
{
    int T=1;
    //cin>>T;
    for(int i = 1 ; i <= T ; i++)
        solve();
    return 0;
}


Measured memory_bytes: 5128
import sys
inf = float('inf')
n, ma, mb = map(int, input().split())
t = [[inf] * 401 for _ in range(401)]
for _ in range(n):
  a, b, c = map(int, input().split())
  for aa in range(400, 0, -1):
    for bb in range(400, 0, -1):
      if t[aa][bb] == inf:
        continue
      if t[a + aa][b + bb] > c + t[aa][bb]:
        t[a + aa][b + bb] = c + t[aa][bb]
  if t[a][b] > c:
    t[a][b] = c
result = inf
for a in range(400, 0, -1):
  for b in range(400, 0, -1):
    if a * mb == b * ma and t[a][b] < result:
      result = t[a][b]
if result == inf:
  print(-1)
else:
  print(result)


Measured memory_bytes: 4844
using System;

class A{
	public static void Main(){




		for (int i=0; i<3000; i++) {

			string[] input = Console.ReadLine ().Split (' ');
			int a = int.Parse (input [0]);
			int b = int.Parse (input [1]);

			if (a == b && a == 0) {
				break;
			} else if (a > b) {				
				Console.WriteLine ("{0} {1}", b, a);
			}else{
				Console.WriteLine ("{0} {1}", a, b);
			}
		}
	}
}

Measured memory_bytes: 9396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int c = sc.nextInt();
		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < n; i++) {
			int sum = 0;
			for (int j = 0; j < m; j++) {
				sum += b[j] * sc.nextInt();
			}
			if (sum + c > 0) {
				ans++;
			}
		}
		sc.close();

		System.out.println(ans);
	}
}


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

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    for(int i = n-1; i >= 0; i--){
        if(i != n-1) cout << " ";
        cout << a[i];
    }
    cout << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int x[20][20];
int main()
{
    int n,d,i,j,k,sol,rez,z;
    scanf("%d%d",&n,&d);
    for(i=1; i<=n; i++)
        for(j=1; j<=d; j++)
            scanf("%d",&x[i][j]);
    sol=0;
    for(i=1; i<n; i++)
        for(j=i+1; j<=n; j++)
        {
            int rez=0;
            for(k=1; k<=d; k++)
                rez+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            int z=sqrt(rez);
            if(z*z==rez)
                sol++;
        }
    printf("%d",sol);

    return 0;
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld PI = acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
//const int mod = 998244353;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);

    int n; cin >> n;
    vi a(n), b(n), c(n); rep(i,n) cin >> a[i] >> b[i] >> c[i];

    vii dp(3, vi(112345, -inf));
    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for(int i = 1; i < n; ++i) {
        chmax(dp[0][i], max(dp[1][i-1]+a[i], dp[2][i-1]+a[i]));
        chmax(dp[1][i], max(dp[0][i-1]+b[i], dp[2][i-1]+b[i]));
        chmax(dp[2][i], max(dp[0][i-1]+c[i], dp[1][i-1]+c[i]));
    }
    cout << max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]) << '\n';
}

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

int main() {
    ll q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;

    ll ans = n / 2 * min({8 * q, 4 * h, 2 * s, d}) +
             (n % 2) * min({4 * q, 2 * h, s});

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


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

int main() {
	int N, buf;
	int table[100000] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> buf;
		table[buf]++;
	}

	int sum, max;
	sum = table[0] + table[1] + table[2];
	max = sum;
	for (int i = 3; i < 100000; i++) {
		sum = sum - table[i - 3] + table[i];
		if (max < sum) max = sum;
	}

	cout << max << endl;
}

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

int h,w;
string grid[20];
bool visit[20][20];

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

int rec(int y,int x){      //この場所から到達できるタイルの数を返す
  if(visit[y][x])return 0; //もう来たことがあるならカウントしない
  visit[y][x] = true;

  int res = 1;             //今いるタイルですでに1枚到達
  for(int i=0;i<4;i++){
    int ny = y+dy[i], nx = x+dx[i];

    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(grid[ny][nx] == '#')continue;
    res += rec(ny,nx);     //次の場所から到達できる枚数を足す
  }
  return res;
}

int main(){
  while(cin >> w >> h,h){
    for(int i=0;i<h;i++){
      cin >> grid[i];
      for(int j=0;j<w;j++)visit[i][j] = false;
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(grid[i][j] == '@')cout << rec(i,j) << endl;
      }
    }
  }
}

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

int main() {
    // a, b, cを入れる変数
    int a, b, c;
    // 答えの約数の数を入れる変数
    int sum = 0;

    cin >> a >> b >> c;

    // aからbまでの数を一つずつ見ていく
    for (int i = a; i <= b; ++i) {
        if(c % i == 0){
            ++sum;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

    private static int count = 0;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        double dp[][] = new double[n+1][n+1]; // dp[i][j]到第i个硬币时j个head的概率
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            double prob = scanner.nextDouble();
            dp[i][0] = dp[i-1][0] * (1-prob);
            for (int j = 1; j <= n; j++) {
                dp[i][j] = dp[i-1][j]*(1-prob) + dp[i-1][j-1]*prob;
            }
        }
        double sum = 0;
        for (int i = n/2 +1; i <= n; i++) {
            sum=sum + dp[n][i];
        }
        System.out.println(sum);
    }




}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n-1);
  rep(i, n-1) cin >> a[i];

  int ans[n+1] = {};

  rep(i, n-1) {
    ans[a[i]]++;
  }

  rep2(i, n) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4844
""" AtCoder """

N = int(input())
S = input()

w = "abcdefghijklmnopqrstuvwxyz"

count_max = 0

for i in range(N):
    count = 0
    for j in range(len(w)):
        if w[j] in S[:i] and w[j] in S[i:]:
            count += 1
    if count_max < count:
        count_max = count

print(count_max)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
const int mod=1e9+7;
const int N=1e5+9;
int fa[N],iv[N];
int f(int a,int n=mod-2){
	if(n==0)return 1;
	if(n==1)return a;
	int x=f(a,n/2);
	x=(x*x)%mod;
	if(n%2)x=(a*x)%mod;
	return x;
}
int c(int n,int k){
	return ((fa[n]*iv[k])%mod*iv[n-k])%mod;
}
int32_t main(){
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);

	int n,k;
	cin >> n >> k;
	int a[n];
	fa[0]=1;iv[0]=1;
	for(int i=1;i<N;i++){
		fa[i]=(fa[i-1]*i)%mod;
		iv[i]=f(fa[i]);
	}
	for(int i=0;i<n;i++)
		cin >> a[i];
	int sum=0;
	sort(a,a+n);
	for(int i=0;i<=n-k;i++){
		sum=(sum+mod-(a[i]*c(n-1-i,k-1))%mod)%mod;
	}
	for(int i=k-1;i<n;i++){
		sum=(sum+(a[i]*c(i,k-1))%mod)%mod;
	}
	cout << sum;
}


Measured memory_bytes: 2560
# -*- coding: utf-8 -*-
n = int(input())
pair = (1,n)
#sqrt(n)(切り下げ)から1までを探索する。
from math import sqrt
mid = int(sqrt(n))
for i in range(mid,0,-1):
    if n % i==0:
        pair = (i,n//i)
        break
print(sum(pair)-2)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
void mmin(int &a, int b) {
	a = min(a, b);
}
void mmax(int &a, int b) {
	a = max(a, b);
}
int nibl(vel &v, int tan) {
	int up = v.size() - 1;
	int lo = 0;
	if (v[up] <= tan) return up;
	while (up - lo > 1) {
		int mi = (up + lo) / 2;
		if (v[mi] <= tan) lo = mi;
		if (tan < v[mi]) up = mi;
	}
	return lo;
}
signed main() {
	int h, w, n;
	cin >> n >> h >> w;
	cout << (n - w + 1)*(n - h + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int a, b;
  scanf("%d",&a);
    scanf("%d",&b);
  if ( a < b )
  {
   printf ("a < b\n");
    }
   if (a > b)
   {
    printf ("a > b\n");
    }
    if (a == b)
    {
    printf ("a == b\n");
    }
    return 0;
    }
    

Measured memory_bytes: 580
# -*- coding: utf-8 -*-
import collections

n = int(raw_input())
a = map(int, raw_input().split())

a_col = collections.Counter(a)
remove_count = 0

for k in a_col:
	if k > a_col[k]:
		remove_count += a_col[k]
	elif k < a_col[k]:
		remove_count += a_col[k] - k

print remove_count


Measured memory_bytes: 16292
#include <stdio.h>
#include <algorithm>

using namespace std;

int H;

void maxHeapify(long long array[],int i){
	int left = 2*i;
	int right = 2*i + 1;
	if(left > H) return;
	int largest = i;
	if(right <= H){
		if((array[right] > array[left]) && (array[right] > array[i])){
			largest = right;
		}else if((array[left] > array[right]) && (array[left] > array[i])){
			largest = left;
		}
	}else{
		if(array[i] < array[left]){
			largest = left;
		}
	}
	if(largest != i){
		swap(array[i],array[largest]);
		maxHeapify(array, largest);
	}
}

void buildMaxHeap(long long array[]){
	for(int i = H/2; i >=1; i--) maxHeapify(array,i);
}

int main(){
	scanf("%d",&H);
	long long array[H+1];

	for(int i = 1; i <= H; i++) scanf("%lld",&array[i]);

	buildMaxHeap(array);

	for(int i = 1; i <= H; i++) printf(" %lld",array[i]);
	printf("\n");
}

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

/*long long a,b,q,c,aa,ab,ia,ib,ch,maxm,ans=0,co;
int main(){
  int i,j;
  maxm = pow(10,9);
  cin >> q;
  for(i=0;i<q;i++){

    ans = 0;
    cin >> a >> b;
    aa = a-1;
    ab = b-1;
    ia = 1;
    ib =1;
    c=a*b;

    while(aa>=1){
      ch = c/aa;
      if(c%aa==0)ch--;
      if(ch>b&&ch<=maxm)break;
      aa--;
    }
    while(ab>=1){
      ch = c/ab;
      if(c%ab==0)ch--;
      if(ch>a&&ch<=maxm)break;
      ab--;
    }
    while(1){
      ch = c/ia;
      if(c%ia==0)ch--;
      if(ch>b)break;
      ia++;
      if(ia==a+1)break;
    }
    while(1){
      ch = c/ib;
      if(c%ib==0)ch--;
      if(ch>a)break;
      ib++;
      if(ib==a+1)break;
    }
    //  cout << ab << ' ' << ib << ' ' << aa << ' ' << ia << endl;
    if(ab>=ib)ans += ab-ib+1;
    if(aa>=ia)ans += aa -ia+1;
    ch = max(ab,aa);
    co = min(ia,ib);
    j=co;
    while(j<ch){
      if(j-1!=0&&c/j == c/(j+1)){
	ans--;
	if(j>=max(ia,ib)&&j<=min(ab,aa))ans--;
      }
      // else  break;
      j++;
    }
    cout << ans <<endl;
      

    
  }
  

  return 0;
}
*/


long long a,b,c;

int main(){
  int q;
  cin >> q;
  for(int i=0;i<q;i++){
  cin >> a >> b;
  if(a>b)swap(a,b);

  if(a==b)cout<< 2*a-2 ;
  else if(a+1==b) cout << 2*a-2;
  else{
    c = sqrt(a*b);
    if(c*c==a*b)c--;
    if(c*(c+1)>=a*b)cout << 2*c-2;
    else cout << 2*c-1;
  }
  cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int a, b;

  std::cin >> a >> b;
  
  std::cout << (a + b + 1) / 2  << std::endl;

  return 0;
}


Measured memory_bytes: 888
using System;
class Program
{
    static int n;
    static int m;
    static int q;
    static int max;

    static void DFS(int d, int[] X, int cnt, int[,] L)
    {
        if(cnt==n)
        {//正常終了
            //for(int i=0; i<n; i++)
            //{
            //    Console.Write(" " + X[i]);
            //}
            //Console.WriteLine();
            Cir(X, L);
            return;
        }
        if(d == m + 1)
        {//不正終了
            return;
        }
        //dをとらない
        DFS(d + 1, X, cnt, L);
        //dをとる
        X[cnt] = d;
        //重複許す
        DFS(d, X, cnt + 1, L);
        DFS(d + 1, X, cnt + 1, L);
    }
    static void Cir(int[] X, int[,] L)
    {
        int tmp = 0;
        for (int i=0; i<q; i++)
        {            
            if(X[L[i,1]-1]- X[L[i, 0] - 1]== L[i, 2])
            {
                tmp += L[i, 3];
            }
        }
        
        if (tmp > max) max = tmp;
    }
    static void Main()
    {
        string[] In1 = Console.ReadLine().Split(' ');
        n = int.Parse(In1[0]);
        m = int.Parse(In1[1]);
        q = int.Parse(In1[2]);
        string[] In2;
        int[,] L = new int[q, 4];
        for (int i=0; i<q; i++)
        {
            In2 = Console.ReadLine().Split(' ');
            for(int j=0; j < 4; j++)
            {
                L[i, j] = int.Parse(In2[j]);
            }
        }
        int[] X = new int[n];
        DFS(1, X, 0 ,L);
        Console.WriteLine(max);
    }
}

Measured memory_bytes: 27532
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [[] for i in range(N)]

for i in range(N):

    A[i] = list(map(int,input().split()))

answer = 0

for i in range(N):

    checkrank = 0

    for j in range(M):

        checkrank += A[i][j] * B[j]

    if checkrank+C  > 0:

        answer += 1

print(answer) 


Measured memory_bytes: 3064