akhauriyash/Code-Regression huggingface dataset:
x,n = map(int,input().split())
if n == 0:
  print(x)
else:
  p = list(map(int,input().split()))
  max_trial = 100
  for i in range(max_trial):
    if not x-i in p:
      print(x-i)
      break
    elif not x+i in p:
      print(x+i)
      break


Measured memory_bytes: 9172
/*
Mangal bhavan amangal haari
Drabahu su Dasharath achar Bihari
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hoi hai wohi jo Raam rachi raakha
Ko kari tarak badhave saakha
Raam Siya Raam Siya Raam jai jai Raam
Ho dheeraj dharam mitra aru naari
Aapad kaal parakhiye chaari
Ho jehike jehi par satya sanehu
So tehi milay na kachhu sandehu
Ho jaaki rahi bhawana jaisi
Prabhu murati dekhi tin taisi
Ho Raghukul reet sada chali aayi
Praan jaaye par vachan na jaayi
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Ho hari anant hari katha ananta
Kahahi sunahi bahuvidhi sab santa
Raam Siya Raam Siya Raam jai jai Raam, Raam
Raam Siya Raam Siya Raam jai jai Raam
Raam Siya Raam Siya Raam jai jai Raam
*/


#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
//auto->.
//map<int,int>::iterator i
vector<int> sieve(int n) 
{ 

    vector<bool> prime(n+1,true); 
       
    prime[0] = false; 
    prime[1] = false; 
    int m = sqrt(n); 
   vector<int> ans;

    for (int p=2; p<=m; p++) 
    { 
    
        if (prime[p]) 
        { 
         
            for (int i=p*2; i<=n; i += p) 
            prime[i] = false; 
        } 
    }  
    //vector<int> ans; 
    for (int i=0;i<n;i++) 
        if (prime[i]) 
            ans.push_back(i); 
    return ans; 
}

int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int mod = 1e9 + 7;
int power(int a , ll b)
{
	int res = 1;
	while(b)
	{
		if(b & 1)
			res = 1LL * res * a ;//% mod;
		a = 1LL * a * a ;//% mod;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
ll min(int a,ll b)
{
	if(a>b)
	return b;
	return a;
}
ll max(int a,ll b)
{
	if(a>b)
	return a;
	return b;
}
ll myXOR(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}
int conti(int x)
{
	if(x<1)
	return 0;
	if(x%4==0)
	return x;
	if(x%4==1)
	return 1;
	if(x%4==2)
	return x+1;
	if(x%4==3)
	return 0;
}
 
bool ispfsq(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is        an integer 
  return ((sr - floor(sr)) == 0); 
}
#define PI 3.141592653589793


vector<int > adj[200005];
bool visited[2005][2005];
int ch[100005],dep[100005];
void solve()
{
int n;
cin>>n;
vector<ll > arr;
for(int i=0;i<n;i++)
{
	int x;
	cin>>x;
	arr.pb(x);
	
}
sort(all(arr));
reverse(all(arr));
ll s=0;
n-=2;
s=arr[0];
for(int i=1;i<arr.size();i++)
{
	if(n<=0)
	{
		break;
	}
	if(n>=2)
	s+=2*arr[i];
	else if(n==1)
	s+=arr[i];
	n-=2;
}
cout<<s;

}

int main()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
int mul=0;
if(mul==1)
{
 int t;
    cin>>t;
   while(t--)
    {
		solve();
	cout<<"\n";
    }
    
}
else
{
//	fun();
	solve();
}
}

Measured memory_bytes: 9960
#include<stdio.h>
int main(){
	int n,m,l,i,j,k;
	long long int t,a[100][100],b[100][100],c[100][100];
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++)for(j=0;j<m;j++)scanf("%d",&a[i][j]);
	for(i=0;i<m;i++)for(j=0;j<l;j++)scanf("%d",&b[i][j]);
	for(i=0;i<100;i++)for(j=0;j<100;j++)c[i][j]=0;
	for(i=0;i<n;i++)for(j=0;j<l;j++){
		t=0;
		for(k=0;k<m;k++)t+=a[i][k]*b[k][j];
		c[i][j]=t;
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j!=l-1)printf("%lld ",c[i][j]);
			else printf("%lld\n",c[i][j]);
		}
	}
	return 0;
}

Measured memory_bytes: 832
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<double> a(n);
  vector<string> b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    cin>>b[i];
  }
  double sum=0.00000;
  for(int i=0;i<n;i++){
    if(b[i]=="JPY"){
      sum+=a[i];
    }
    else{
      sum+=a[i]*380000;
    }
  }
  cout<<sum<<setprecision(6)<<endl;
}

Measured memory_bytes: 256
S = gets.chomp.chars
fromL = [0]
fromR = [0]
S.each do |c|
    if c == "<"
        fromL << fromL[-1] + 1
    else
        fromL << 0
    end
end
S.reverse.each do |c|
    if c == ">"
        fromR << fromR[-1] + 1
    else
        fromR << 0
    end
end
p fromL.zip(fromR.reverse).map(&:max).inject(:+)

Measured memory_bytes: 100540
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 18;
int invs[(1 << maxN) + 2][maxN];
int dp[(1 << maxN) + 2][maxN];
int a[maxN], b[maxN];
const int INF = (int)1e9 + 10;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int lst = 0; lst < n; lst++) {
            if (mask & (1 << lst)) {
                for (int who = 0; who < n; who++) {
                    if (who == lst) continue;
                    if (who > lst && (mask & (1 << who))) invs[mask][lst]++;
                    if (who < lst && !(mask & (1 << who))) invs[mask][lst]++;
                }
            }
        }
    }
    for (int i = 0; i < (1 << n); i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] = INF;
        }
    }
    for (int i = 0; i < n; i++) {
        dp[(1 << i)][i] = invs[(1 << i)][i];
    }
    for (int mask = 1; mask < (1 << n); mask++) {
        for (int was = 0; was < n; was++) {
            if (!(mask & (1 << was))) continue;
            if (dp[mask][was] == INF) continue;
            int val1 = (invs[mask][was] % 2) ? b[was] : a[was];
            for (int new_was = 0; new_was < n; new_was++) {
                if (mask & (1 << new_was)) continue;
                int val2 = (invs[mask | (1 << new_was)][new_was] % 2) ? b[new_was] : a[new_was];
                if (val2 < val1) continue;
                dp[mask | (1 << new_was)][new_was] = min(dp[mask | (1 << new_was)][new_was], dp[mask][was] + invs[mask | (1 << new_was)][new_was]);
            }
        }
    }
    int best = INF;
    for (int i = 0; i < n; i++) best = min(best, dp[(1 << n) - 1][i]);
    if (best == INF) cout << -1 << '\n';
    else cout << best / 2;
    return 0;
}

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


int main(){

	int a,b,sum;

	while(cin>>a){
		cin>>b;

		sum = a+b;

		int count=1;

		while( (sum/=10) > 0){
			count++;
		}

		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i, n) FOR(i,0,n)

using namespace std;
typedef long long ll;
const int INF = 1e9;

ll N,A,B;
int x[100001];
int gap[100000];

void solve(){
    ll res = 0;
    REP(i,N-1){
//        res += (A*gap[i]<B) ? A*gap[i] : B;
//        cout << gap[i] <<"\n";
        res += min(A*gap[i] , B);
    }
    cout << res << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> A >> B;
    REP(i,N){
        cin >> x[i];
        if(i!=0) gap[i-1] = x[i] - x[i-1];
    }
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
signed main(){
  char a[100];
  cin>>a;
  if(a[5]=='0'){
    if(a[6]<='3')
      cout<<"Heisei"<<endl;
    else if(a[6]=='4'){
      if(a[8]=='3' && a[9]=='0'){
    cout<<"Heisei"<<endl;
      }

      else if(a[5]<='2'){
      cout<<"Heisei"<<endl;
      }
    }
    else
      cout<<"TBD"<<endl;
  }
  else
    cout<<"TBD"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int b,r,g,c,s,t;
	
	while(1)
	{
		scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t);
		if(b==0&&r==0&&g==0&&c==0&&s==0&&t==0)
		{
			break;
		}
		printf("%d\n",(80*b+54*r+7*g+2*c+s*3)-(t-5*b-3*r)*3+100);
	}
	
	return 0;
}

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

    int n,m,s=0;
    cin >> n >> m;

    vector<int> a(n);

    rep(i, n)
    {
        cin >> a.at(i);
        s += a.at(i);
    }

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

    double t = (double)s / 4.0 / (double)m;

    rep(i, m)
    {
        if (a.at(i) < t)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define pb push_back
#define mp make_pair
bool isPrime(ll n) 
{ 
    
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
   
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
int minthis(int a, int b){
if(a < b){
return a;
}
return b;
}
int maxthis(int a, int b){
if(a > b){
return a;
}
return b;
}
int gcd(int a, int b){
    if( a<0 ) a = -a;
    if( b<0 ) b = -b;
    while( b!=0 ){
        a %= b;
        if( a==0 ) return b;
        b %= a;
    }
    return a;
}
 
int findLargestDivisor(int n) 
{ 
	int max = 1;
    for (int i = 2; i < n; i++) {        
        if(n %(i) == 0) { 
            max = i;
        } 
    }
    return max;     
} 
 
 
ll power(ll x, ll y)  
{  
    ll temp;  
    if(y == 0)  
        return 1;  
    temp = power(x, y / 2);  
    if (y % 2 == 0)  
        return temp * temp;  
    else
    {  
        if(y > 0)  
            return x * temp * temp;  
        else
            return (temp * temp) / x;  
    }  
}  


void solve(){	
	ll n;
	cin >> n;
	ll arr[n];
	ll total = 0;
	for(int i = 0 ; i < n ;i++){
		cin >> arr[i];
		total ^= arr[i];
	}
	for(int i = 0 ; i < n ; i++){
		ll thi = total^arr[i];
		cout << thi << " ";
	}
}
  
int main(){ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;    
    //cin >> t;
    while(t--){
		solve();
	}
    return 0; 
}


Measured memory_bytes: 5228
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
int main(){
	LL a,b,c,d;
	cin >> a >> b >> c >> d;
	if(a*b>c*d)cout << a*b <<endl;
	else cout << c*d <<endl;
	return 0;
	}

Measured memory_bytes: 256
n,u,v = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n-1)]

graph = [[] for _ in range(n+1)]

for a,b in lis:
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [-1] * (n+1)
    stack = [v]
    dist[v] = 0
    while stack:
        v = stack.pop()
        dw = dist[v] + 1
        for w in graph[v]:
            if dist[w] >= 0:
                continue
            dist[w] = dw
            stack.append(w)
    return dist

takahashi = dfs(u)
aoki = dfs(v)

ans = 0

for i in range(1,n+1):
    if takahashi[i] < aoki[i]:
        ans = max(ans,aoki[i]-1)

print(ans)

Measured memory_bytes: 41952
#include <stdio.h>
 
int main(void){
 
	int in[2]={0};
	
	int i;
	int count=0;
	int rev=0,num=0;
	scanf("%d %d",&in[0],&in[1]);
	
	
	for(i=in[0];i<=in[1];i++){
		
		num=i;
		rev=0;
		while(num>0){
			rev=rev*10+num%10;
			num/=10;
		}
		
		if(i==rev){
			count++;
		}
	}
	
	printf("%d",count);	
	
	return 0;
}

Measured memory_bytes: 128
function main(input) {
    N = parseInt(input.split('\n')[0], 10);
    A = input.split('\n')[1].split(' ');

    L = []
    for (var i = 0; i < N; i++) {
        L.push(parseInt(A[i], 10));
    }
    
    var res = 0
    var flag = false
    while (true) {
        for (var i = 0; i < N; i++) {
            if (L[i]%2 !== 0) {
                flag = true;
            } else {
                L[i] = L[i] / 2
            }
        }
        if (flag) {
            break
        }
        res++
    }

    console.log(res)
}

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

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }

const int MAXN = 212345;

int n, m, k;

int mrk[MAXN], tempo;
int d[MAXN];
int cnt[MAXN];

int main (){
    int x, y;
	scanf("%d%d%d", &n, &x, &y);
    for(int ini=1;ini<=n;ini++){
        queue<int> q; 
        q.push(ini);
        d[ini] = 0;
        tempo++;
        mrk[ini] = tempo;
        while(!q.empty()){
            int u = q.front();
            q.pop();
            cnt[d[u]]++;
            if(u+1 <= n && mrk[u+1] != tempo){
                q.push(u+1);
                d[u+1] = d[u] + 1;
                mrk[u+1] = tempo;
            }
            if(u-1 >= 1 && mrk[u-1] != tempo){
                q.push(u-1);
                d[u-1] = d[u] + 1;
                mrk[u-1] = tempo;
            }
            int nxt = -1;
            if(u == x)
                nxt = y;
            if(u == y)
                nxt = x;
            if(nxt != -1 && mrk[nxt] != tempo){
                q.push(nxt);
                mrk[nxt]  = tempo;
                d[nxt] = d[u] + 1;
            }
        }
    }
    for(int a=1;a<n;a++){
        printf("%d\n", cnt[a]/2);
    }
}



Measured memory_bytes: 384
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C, K = il()
    print(min(A,K)-max(0, K-(A+B)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
#include<bits/stdc++.h>
// five elements

#define ll long long
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rev(i, s, n) for (int i = s; i > n; i = i - 1)
using namespace std;
#define fr first
#define se second
#define pb push_back
#define mp make_pair
#define mv vector<ll>
#define vii vector<pair<ll, ll>>
// akane_psycho
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define c1(a) cout << a << endl;
#define c2(a, b) cout << a << " " << b << endl;
#define inf 1e18
#define mod 1000000007
#define ii pair<ll,ll>
#define sw(v)      cout << endl;                                                                \
  for(auto u:v) {cout << u << " ";}                                     \
  cout << endl;
  
  /*
  ll ml(ll a, ll b){
  	return ( (a%mod)*(b%mod) )%mod;
  }
ll fp(ll num,ll g)
{
    if(g==0)return 1;
    if(g%2==1)return ml(num,fp(ml(num,num) ,g/2) );
    return fp( ml(num,num),g/2);
}
ll d(ll a, ll b) {//a/b
	return a*fp(b, mod - 2) % mod;
}
ll pm(ll f[] , ll n, ll r){
	return d(  f[n] , f[n-r] );
}
ll cm(ll f[] , ll n , ll r ){
		return d( f[n] , ml( f[r],f[n-r] ) );
	}
*/
int main(){
	ll n;cin>>n;
	ll a[n+1];
	rep(i,1,n+1)cin>>a[i];
	
	
	
	map<ll,ll> w,mp;
	rep(i,1,n+1)w[-a[i]-i ]++;
	ll s=0;
	for(int i=n;i>=1;i--){
		w.erase( -a[i]-i );
		if( w.find( a[i]-i )!=w.end()  )s+=w[ a[i]-i ];
	}
	c1(s)

}


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

int main() {
	int n;
	cin >> n;
	vector<int> nums(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> nums[i];
	}
	vector<int> res(n, 0);
	int index = 0;
	for (int i = n - 1; i >= 0; i -= 2) {
		res[index] = nums[i];
		if (i >= 1) {
			res[n - 1 - index] = nums[i - 1];
		}
		index++;
	}
	for (int i = 0; i < n; i++) {
		cout << res[i] << " ";
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
typedef long long int LL;
LL c[110000],p[110000];
int main(void){
    LL n,i,j;
    LL ans=0,x,m;
    bool u=false;
    for(i=0;i<110000;i++){
        c[i]=0;
        p[i]=-1;
    }
    cin>>n>>x>>m;
    for(i=0;i<n;i++){
        ans+=x;
        if(p[x]==-1||u){
            c[x]=ans;//答え保管
            p[x]=i;//場所保管
            x=x*x%m;
        }else{
            u=true;
            j=(n-i-1)/(i-p[x]);//高速ループ回数
            ans+=(ans-c[x])*j;
            i+=j*(i-p[x]);//*/
            x=x*x%m;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5324
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	string s, t;
	scans(s);
	scans(t);
	reverse(all(t));
	printYN(s == t);
	
	Please AC;
}


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

typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;	

ll gcd(ll a,ll b){
	if (b==0){
		return a;
	}
	return gcd(b,a%b);
}

int main(){
	int T;
	cin>>T;
	REP(t,T){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if (a<b){
			cout<<"No"<<endl;
		}else if (d<b){
			cout<<"No"<<endl;
		}else if (c>=b-1){
			cout<<"Yes"<<endl;
		}else{
			d%=b;
			a%=b;
			ll g=gcd(b,d);
			if (g==0){
				g=b;
			}
			if (c>=a+(b-1-a)/g*g){
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * 3.cpp
 * Copyright (C) 2020 itachi <itachi@itachi-Z510>
 *
 * Distributed under terms of the MIT license.
 */

#include <bits/stdc++.h>

using namespace std;

int main() {
   int h,n;
   cin >> h >> n;
   vector<int> a(n),b(n);
   for (int i=0;i<n;i++) {
       cin >> a[i] >> b[i];
   }
   vector<vector<int>> dp(n+1,vector<int>(h+1));
   /* for (auto v:dp) { */
   /*     for (auto val:v) cout << val << ' ';cout << endl; */
   /* } */
   for (int j=1;j<=h;j++) {
       dp[0][j] = INT_MAX;
   }
   for (int i=1;i<=n;i++) {
       for (int j=0;j<=h;j++) {
           dp[i][j] = min(dp[i-1][j], dp[i][max(0,j-a[i-1])] + b[i-1]);
       }
   }
   cout << dp[n][h] << endl;
}


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

int func(int n){
  if(n%2==0){
    return n/2;
  }else{
    return 3*n + 1;
  }
}

int main(){
  int s;
  cin>>s;
  
  int M = 1000000;
  int a[M];
  a[0]=s;
  for(int i=1;i<M;i++){
    a[i]=func(a[i-1]);
    for(int j=0;j<i;j++){
      if(a[j]==a[i]){
        cout<<i+1<<endl;
        return 0;
      }
    }
  }
  
  return 0;
}
    

Measured memory_bytes: 256
/*
 * AtCode Beginner Contest 137 : A.-+x
 * Author : anaksoleh
 * 18 August 2019
 *
 */


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

int A,B;
vector<int> v;

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

	cin>>A>>B;

	v.push_back(A+B);
	v.push_back(A-B);
	v.push_back(A*B);

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

	cout << v[2] << '\n';
		
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

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

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b);
    return 0;
}


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

int main(){
  int W,H,N;
  cin >> W >> H >> N;
  int xs=0,xe=W,ys=0,ye=H;
  for(int i = 0; i < N; i++){
    int x,y,a;
    cin >> x >> y >> a;
    if(a == 1) xs = max(xs,x);
    else if(a == 2) xe = min(xe,x);
    else if(a == 3) ys = max(ys,y);
    else if(a == 4) ye = min(ye,y);
  }
  if((xe - xs < 0) || (ye - ys < 0))cout << 0 << endl;
  else cout << (xe - xs) * (ye - ys) << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Complex

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    [a,b,h,m] <- map fromIntegral <$> r'

    let h' = (60 * h + m) / 60 / 12
        m' = m / 60

    print $ magnitude ((a :+ 0) -  rotate (m' - h') (b :+ 0))

rotate :: Double -> Complex Double -> Complex Double
rotate ofFullCirc = (* (0 :+ 1) ** (4 * ofFullCirc :+ 0))

Measured memory_bytes: 4440
H, W, d = map(int, input().split())
G = [[None]*W for _ in range(H)]
Col = ['R', 'G', 'B', 'Y']
for i in range(H):
    for j in range(W):
        a, b = ((i+j)//d)%2, ((i-j)//d)%2
        G[i][j] = Col[2*a+b]
for g in G:
    print(''.join(g))

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

#define ran 101101

int n, k, q;
int s[ran];

int main() {
	scanf("%d%d%d", &n, &k, &q);
	for(int i=0;i<q;i++) {
		int x;
		scanf("%d", &x);
		s[x]++;
	}
	for(int i=1;i<=n;i++)
		if(q-s[i]<k) puts("Yes");
		else puts("No");
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for(int i=0;i<N;i++){
		cin >> A.at(i);
		B.at(i)=0;
	}
	for(int i=0;i<N;i++){
		B.at(0)+=A.at(i)*pow(-1,i);
	}
	cout << B.at(0);
	for(int i=1;i<N;i++){
		B.at(i)=A.at(i-1)*2-B.at(i-1);
		cout <<" "<< B.at(i);
	}
	cout << endl;
}

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


Measured memory_bytes: 128
//#include<boost/multiprecision/cpp_int.hpp>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;
//using namespace boost::multiprecision;

constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    vector<pair<ll,ll>> v;
    int azero=0;
    int bzero=0;
    int ex=0;
    map<pair<ll,ll>,ll> mp;
    map<pair<ll,ll>,ll> mpp;
    map<pair<ll,ll>,int> used;
    for(int i=0;i<n;i++){
        if(b[i]<0){
            a[i]*=(-1);
            b[i]*=(-1);
        }
        if(b[i]==0){
            if(a[i]==0){
                ex++;
                continue;
            }
            bzero++;
        }
        else{
            if(a[i]==0){
                azero++;
            }
            else{
                ll g=__gcd(abs(a[i]),b[i]);
                a[i]/=g;
                b[i]/=g;
                v.push_back(make_pair(a[i],b[i]));
                mpp[make_pair(a[i],b[i])]++;
                if(a[i]<0){
                    a[i]*=(-1);
                    b[i]*=(-1);
                }
                mp[make_pair(-b[i],a[i])]++;
            }
        }
    }
    vector<pair<ll,ll>> vv;
    vv.push_back(make_pair(azero,bzero));
    for(int i=0;i<v.size();i++){
        if(used[v[i]])continue;
        used[v[i]]=1;
        ll aa=v[i].first,bb=v[i].second;
        if(aa<0){
            aa*=-1;
            bb*=-1;
        }
        used[make_pair(-bb,aa)]=1;
        vv.push_back(make_pair(mpp[v[i]],mp[v[i]]));
    }
    ll res=1;
    for(auto p:vv){
        ll pp=(mod_pow(2,p.first)+mod_pow(2,p.second)-1+mod)%mod;
        (res*=pp)%=mod;
    }
    res+=ex;
    res--;
    res+=mod;
    res%=mod;
    cout << res << endl;
}


Measured memory_bytes: 75028
#include <stdio.h>

int main(void)
{
	int x,y;
	
	scanf("%d %d",&x,&y);
	
	if(y>x){
		int temp = y;
		y = x;
		x = temp;
	}
	int r = x % y;
	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}
	
	printf("%d\n",y);
	
	return 0;
}
		
		


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

int main() {
    int n, m, sum = 0;
    cin >> n;
    vector<int> t(n);
    rep(i, n) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    cin >> m;
    int problem, x;
    rep(i, m) {
        cin >> problem >> x;
        cout << sum - t.at(problem - 1) + x << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final int MOD = (int) (1e9+7);

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h= scanner.nextInt();
        int w = scanner.nextInt();
        char[][] grid = new char[h][w];
        for(int i = 0 ; i < h ; ++i){
            grid[i] = scanner.next().toCharArray();
        }
        int[][] dp = new int[h+1][w+1];
        for(int i = h-1 ; i>=0 ; --i){
            for(int j = w-1 ; j>=0 ; --j){
                if(i==h-1&&j==w-1){
                    dp[i][j] =1;
                }else if(grid[i][j]=='#'){
                    dp[i][j] = 0;
                }else{
                    dp[i][j] = (dp[i+1][j] + dp[i][j+1])%MOD;
                }
            }
        }
        System.out.println(dp[0][0]);
    }
}

Measured memory_bytes: 49576
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool solve(){
  int n;
  cin>>n;
  vector<vector<int>> tree(n);
  vector<int> rev(n), cnt(n), a(n, -1);

  rep(i,n){
    int p; cin>>p; p--;
    tree[p].pb(i);
    rev[i] = p;
  }
  rep(i,n) cnt[i] = tree[i].size();

  auto mex = [&](int v, vector<int> &num){
    vector<int> vv;
    for(auto d : tree[v]) vv.pb(num[d]);
    uniq(vv);
    int x = 0;
    while(x < vv.size() && vv[x]==x) x++;
    return x;
  };

  auto bfs = [&](queue<int> &q, vector<int> &num, vector<int> &c){
    int last = -1;
    while(!q.empty()){
      int v = q.front(); q.pop();
      num[v] = mex(v, num);
      c[rev[v]]--;
      if(c[rev[v]]==0 && num[rev[v]]==-1) q.push(rev[v]);
      last = v;
    }
    return last;
  };

  {
    queue<int> q;
    rep(i,n) if(cnt[i]==0) q.push(i);
    bfs(q,a,cnt);
  }

  int s = -1;
  rep(i,n) if(a[i]==-1) s=i;

  if(s==-1) return true;

  vector<int> vv;
  for(auto d : tree[s]) if(a[d]!=-1) vv.pb(a[d]);
  uniq(vv);
  int c1=0;
  while(c1 < vv.size() && vv[c1]==c1) c1++;
  int c2 = c1+1;
  while(c2-1 < vv.size() && vv[c2-1]==c2) c2++;

  // dbg(s,c1,c2,vv,a);

  rep(_,2){
    // try c1
    vector<int> b(a);
    vector<int> cc(cnt);
    cc[s] = 0;
    b[s] = c1;
    queue<int> q;
    q.push(rev[s]);

    int last = bfs(q,b,cc);
// dbg(b);
    if(b[last]!=b[s] && b[last] == mex(last, b) && b[s]==mex(s,b)) return true;

    swap(c1,c2);
  }

  return false;
}

int main(){
  if(solve()) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int s, w; cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3640
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = list(read_func().strip().split())
    count_even = 0
    count_odd = 0
    count_4adj = 0
    for i in range(N):
        a = int(input_raw[i])
        if (a % 4) == 0:
            count_4adj += 1
        elif (a % 2) == 0:
            count_even += 1
        else:
            count_odd += 1

    is_yes = False
    if count_even == 0:
        if count_4adj >= count_odd - 1:
            is_yes = True
    else:
        if count_4adj >= count_odd:
            is_yes = True

    if is_yes:
        print "Yes"
    else:
        print "No"



if __name__ == '__main__':
    main()


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

using namespace std;
queue< pair< int , pair<int,int> > >q;
#define pii pair< int,pair<int,int> >
char arr[1005][1005];
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};
int n,m;
long long m1=0;
int vis[1005][1005];

void bfs()
{

	while(!q.empty())
	{
		pii top=q.front(); q.pop();
		for(int k=0;k<4;k++)
		{
		    int p=top.first;
			int tx=top.second.first+fx[k];
			int ty=top.second.second+fy[k];
			if(tx>=0 and tx<n and ty>=0 and ty<m and arr[tx][ty]!='#' and vis[tx][ty]==0)
			{
				vis[tx][ty]=1;
				m1=p+1;
				q.push({m1,{tx,ty}});
			}
		}
	}
}

int main()
{

    cin>>n>>m;
    memset(vis,0,sizeof vis);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>arr[i][j];
            if(arr[i][j]=='#')
            {
                q.push({0,{i,j}});
                vis[i][j]=1;

            }
       }
    }
    bfs();
    cout<<m1<<endl;
}


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

using namespace std;
const double PI=3.14159265358979323846;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))


int main() {

	int A, B, C, D;

	cin >> A >> B >> C >> D;

	int TKn, AOn;
	TKn = A / D;
	if(A % D > 0) TKn += 1;
	AOn = C / B;
	if(C % B > 0) AOn += 1;

	string ans = "No";
	if (TKn + 1 > AOn) ans = "Yes";
	cout << ans << endl;
}

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

int main(){
	ll n, m, i, w, v, j, k;
	string s, t;
	cin >> s >> t;
	int s1 = s.size();
	int s2 = t.size();
	int dp[s1+1][s2+1];
	for(i = 0; i <= s1; i++) dp[i][0] = 0;
	for(i = 0; i <= s2; i++) dp[0][i] = 0;
	
	for(i = 1; i <= s1; i++){
		for(j = 1; j <= s2; j++){
			if(s[i-1] != t[j-1]){
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
			else{
				dp[i][j] = 1 + dp[i-1][j-1];
			}
		}
	}
	
	// for(i = 0; i<=s1; i++){
	// 	for(j= 0 ; j<=s2; j++){
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	
	i = s1;
	j = s2;
	string ans = "";
	while(i > 0 && j > 0){
		if(dp[i][j] != dp[i-1][j] && dp[i][j] != dp[i][j-1]){
			ans += s[i-1];
			i--;
			j--;
		}
		else if(dp[i-1][j] > dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans;
	
}

Measured memory_bytes: 35456
#include<iostream>
using namespace std;
int main(){
    int tbl[] = {111,222,333,444,555,666,777,888,999};
    int N;
    cin >> N;

    for (int i=0; i<9; i++) {
        if (N > tbl[i]) {
            continue;
        } else {
            cout << tbl[i] << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second

ll comb(int n, int r=2) {
  if (n == 1) return 0;
  ll si = 1;
  ll bo = 1;
  for (int i = 0; i < r; i++) {
    bo = (bo * (i + 1));
    si = (si * (n - i));
  }
  return si / bo;
}

int main(void){
    int n;
    cin >> n;
    map<int, int> a;
    vector<int> b;
    rep(_, n) {
      int tmp;
      cin >> tmp;
      b.push_back(tmp);
      a[tmp]++;
    }
    ll s = 0;
    map<int, ll> c;
    for(auto p: a){
      c[p.fs] = comb(p.sc);
      s += c[p.fs];
      //cout << p.fs << p.sc << c[p.fs]<< endl;
    }
    //cout << s << endl;
    rep(i, n) { cout << s - c[b[i]] * 2 / a[b[i]] << endl; }
}


Measured memory_bytes: 16244
#include<bits/stdc++.h>
using namespace std;
long long find2(long long W,long long w[],long long v[],long long i,long long** dp)
{
    if(i<0)
    return 0;
    if(dp[i][W]!=-1)
    return dp[i][W];
    if(w[i]>W)
    {
        dp[i][W]=find2(W,w,v,i-1,dp);
        return dp[i][W];
    }
    else
    {
        dp[i][W]=max(v[i]+find2(W-w[i],w,v,i-1,dp),find2(W,w,v,i-1,dp));
        return dp[i][W];
        
    }
}
long long find1(long long n,long long w[],long long v[],long long W)
{
    long long** dp;
    dp=new long long*[n];
    for(long long i=0;i<n;i++)
    dp[i]=new long long[W+1];
    for(long long i=0;i<n;i++)
    for(long long j=0;j<W+1;j++)
    dp[i][j]=-1;
    return find2(W,w,v,n-1,dp);
}
int main()
{
    long long n,W;
    cin>>n>>W;
    long long v[n],w[n];
    for(long long i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<find1(n,w,v,W)<<endl;
}

Measured memory_bytes: 78592
#include <bits/stdc++.h>
int D, N;
int dp[101][101];
int A[100], E[100], R[100];
using namespace std;

int main(){
    while(scanf("%d %d", &D, &N), D || N){
        for(int i=0;i<N;i++){
            scanf("%d %d %d", A+i, E+i, R+i);
        }

        for(int i=0;i<=D;i++){
            for(int j=0;j<=100;j++){
                dp[i][j] = 1001001001;
            }
        }
// dp[i][j] :=
//?¨?????????????????????????i????????????????¨???????j?????¨?????????????????§?¨???????????????????
        dp[D][0] = 0;
        for(int i=D;i>=0;i--){
            for(int j=0;j<=100;j++){
                for(int k=0;k<N;k++){
                    if(j >= R[k]){
                        int ni = max(i-A[k],0),
                            nj = min(j+E[k],100);
                        dp[ni][nj] = min(dp[ni][nj], dp[i][j] + 1);
                    }
                }
            }
        }

        int res = 9999999;
        for(int i=0;i<=100;i++){
            res = min(res, dp[0][i]);
        }

        if(res != 9999999){cout<<res<<endl;}
        else{cout<<"NA"<<endl;}
    }
    return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	int a,b,k;
	cin>>a>>b>>k;
	if(a+k-1>=b-k+1){
		for(int i=a;i<=b;i++){
			cout<<i<<endl;
		}
	}
	else{
		for(int i=a;i<a+k;i++){
			cout<<i<<endl;
		}
		for(int i=b+1-k;i<=b;i++){
			cout<<i<<endl;
		}
	}
	return(0);
}

Measured memory_bytes: 3576
N,M,V,P = map(int, input().split())
A = [int(a) for a in input().split()]

A.sort(reverse=True)

S = [0]*N
t = 0
for i in range(N):
    t += A[i]
    S[i] = t

s = M*(N-V)
l = P
r = N
if P == 1:
    a = 0
else:
    a = S[P-2]
while l < r:
    m = (r-l)//2 + l
    if A[P-1]-M > A[m]:
        r = m
        continue
    if S[m-1]-a-(m-P+1)*A[m] > s:
        r = m
        continue
    l = m+1
    
print(l)

Measured memory_bytes: 14484
public class Main {
    public static void main(String[] args){
    	int i,j;
    	for(i=0;i<9;i++){
    		for(j=0;j<9;j++){
    			System.out.println((i+1)+"x"+(j+1)+"="+(i+1)*(j+1));
    		}
    	}
    }
}


Measured memory_bytes: 24160
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
#define endl             "\n"
// -----------------<Container manipulation / traversal macros>------------------
#define mp                 make_pair
#define pb                 push_back
#define ff                 first
#define ss                 second
#define sz(x)             ((int)((x).size()))
#define all(x)             (x).begin(),(x).end()
#define rep(i,n)         for(ll (i)=0;(i)<(n);(i)++)
#define forn(i,a,b)     for(ll (i)=(a);(i)<=(b);(i)++)
#define fill(l,a)        memset((l) , (a) , sizeof(l))
// -----------------<Some common useful functions>------------------
#define maX(a,b)        ( (a) > (b) ? (a) : (b))
#define miN(a,b)        ( (a) < (b) ? (a) : (b))
#define checkbit(n,b)   ( (n >> b) & 1)
#define INDEX(arr,i)      ( lower_bound(all(arr),i)-arr.begin())
#define in(b,a)         ( (b).find(a) != (b).end())
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector< std::vector<ll> > matrix;
typedef map<ll,ll> mii;
typedef vector<pii> vpii;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}
ll lcm(ll a,ll b)
{
    return(a/gcd(a,b)*b);
}
/*ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}*/
/*ll b_search(ll arr[],ll n,ll s)
{
    ll l=0,r=n-1;
    while(l<=r)
    {
        ll mid=l+(r-l)/2;
        if(arr[mid]==s)
        return(mid);
        if(arr[mid]<s)
        l=mid+1;
        else
        r=mid-1;
    }
    return(-1);
}*/

void solve()
{
    ll n;
    cin>>n;
    double pi=3.141592653589793238;
    cout<<fixed<<setprecision(16)<<double(2*pi*n)<<endl;
}

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


Measured memory_bytes: 3800
from itertools import product
N = int(input())
M = int(N**0.5)
ans = [0] * N
for x, y, z in product(range(1, M+1), repeat=3):
    i = x*x + y*y + z*z + x*y + y*z + z*x
    if i <= N:
        ans[i-1] += 1
for i in range(N):
    print(ans[i])

Measured memory_bytes: 69108
#include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>
using namespace std;
int ball[10];
bool dfs(int i,int b,int c);
int main(void){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int s=0;s<10;s++){
            cin>>ball[s];
        }
        if(dfs(0,0,0))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
bool dfs(int i,int b,int c){
    if(i==10)return true;
    if(b<ball[i]){
        if(dfs(i+1,ball[i],c))return true;
    }
    if(c<ball[i]){
        if(dfs(i+1,b,ball[i]))return true;
    }
    return false;
}

Measured memory_bytes: 1152
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, l int
	fmt.Scan(&n, &l)
	s := make([]string, n)
	for i := 0; i< n; i++{
		fmt.Scan(&s[i])
	}
	sort.Strings(s)

	var ans string
	for _, key := range	 s{
		ans += key
	}
	fmt.Print(ans)
}


Measured memory_bytes: 2480
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

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

int main() {
	int n;
	cin >> n;
	cout << (n + 2 - 1) / 2 << endl;
}

Measured memory_bytes: 3640
/*
 * N
 * A1
 * x11 y11
 * x12 y12
 * ...
*/

#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

bool check(vector< vector< pair<int, int> > > v, long long i) {
  // printf("%d\n", i);
  for (int j = 0; j < v.size(); j++) {
    // printf("  %d\n", j);
    vector< pair<int, int> > pairs = v.at(j);

    // 自分が不親切なとき
    if (!((i >> j) & 1)) continue;

    for (const auto &pair : pairs) {
      int honest = (i >> (pair.first - 1)) & 1;

      // printf("%d, %d\n", honest, pair.second);

      if (honest != pair.second) {
        return false;
      }
    }
  }

  return true;
}


int count_bit(long long i) {
  int ret = 0;

  while (i > 0) {
    if (i & 1) ret++;
    i = i >> 1;
  }

  return ret;
}

int main() {
  long long n;
  cin >> n;
  vector< vector< pair<int, int> > > v(n);

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      v.at(i).push_back(make_pair(x, y));
    }
  }

  int answer = 0;

  for (long long i = 0; i < pow(2, n); i++) {
    if (check(v, i)) {
      answer = max(count_bit(i), answer);
      // printf("answer %d\n", answer);
    }
  }

  cout << answer << endl;
}



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

int n;

char ipt[15];

int getcol (int I) {
	printf("%d\n",I);
	fflush(stdout);
	scanf("%s",ipt);
	if(ipt[0] == 'V') exit(0);
	return (ipt[0] == 'M') ^ (I%2);
}

int main()
{
	scanf("%d",&n);
	int S = 0, E = n-1, C = getcol(0);
	while(S<E) {
		int M = (S+E)/2;
		getcol(M) != C ? E = M : S = M+1;
	}
	printf("%d\n", S);
}


Measured memory_bytes: 852
/*input
1000000000
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define ld long double
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define F first
#define S second
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

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


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll x;
	ll ans=0;
	cin>>x;
	ans=(x/500)*1000;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans<<endl;
	return 0;
}




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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

const ll INF = 1e15;

int main() {
  int n;
  cin >> n;
  vector<P> to[n];
  rep(i, n - 1) {
    int a, b, w;
    cin >> a >> b >> w;
    --a, --b;
    to[a].push_back({b, w});
    to[b].push_back({a, w});
  }

  vector<int> g(n, -1);
  vector<ll> d(n, INF);
  queue<int> q;
  g[0] = 0;
  d[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto p : to[u]) {
      if (d[p.first] != INF) continue;
      d[p.first] = d[u] + p.second;
      g[p.first] = ((p.second % 2 == 0) ? g[u] : (1 - g[u]));
      q.push(p.first);
    }
  }

  rep(i, n) cout << g[i] << endl;
  return 0;
}


Measured memory_bytes: 10368
#include <iostream>

using namespace std;

int main(void) {
	int k;
	cin >> k;
	int even= 0;
	int odd = 0;
	for(int i = 1; i <= k; i++)
		if(i % 2 == 0)even++;
		else odd++;
	cout << even*odd << "\n";
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc109/tasks/abc109_d

# 各マスにおいて、上下左右でいけるところに移動させる。
# と思ったけど、奇数同士が離れていた場合もあるな。
# ということで、まず奇数の枚数をカウントする。その割る2（繰り下げ）が
# 最大の枚数になる。
# その後は、コインが奇数枚のマスから、同じくコインが奇数枚のマスへの
# 最短経路を記録しておく。
# 一度選んだマスは、もう使えない。
# 提示された例に引きずられるとだめなやつだった。
# 一筆書きに、全部をなめるようにする。奇数だったら移動させて、偶数だったら無視する。
h, w = map(int, input().split())

matrix = []
for _ in range(h):
    matrix.append([int(i) for i in input().split()])


ans_move = []
for i in range(h):
    if i % 2 == 0: # 右に行く
        for j in range(w):
            if matrix[i][j] % 2 == 1:
                if j == w - 1 and i != h - 1: # 最右端
                    matrix[i][j] -= 1
                    matrix[i + 1][j] += 1
                    ans_move.append([i + 1, j + 1, i + 1 + 1, j + 1])
                elif j != w - 1:
                    matrix[i][j] -= 1
                    matrix[i][j + 1] += 1
                    ans_move.append([i + 1, j + 1, i + 1, j + 1 + 1])
    else: # 左に行く
        for j in range(w)[::-1]:
            if matrix[i][j] % 2 == 1:
                if j == 0 and i != h - 1: # 最左端
                    matrix[i][j] -= 1
                    matrix[i + 1][j] += 1
                    ans_move.append([i + 1, j + 1, i + 1 + 1, j + 1])
                elif j != 0:
                    matrix[i][j] -= 1
                    matrix[i][j - 1] += 1
                    ans_move.append([i + 1, j + 1, i + 1, j - 1 + 1])
ans = len(ans_move)
print(ans)
for m in ans_move:
    print(*m)


Measured memory_bytes: 94272