akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
LL A,B;
LL C,D;
int AA[61];
int BB[61];
int main(){
    cin>>A>>B;
    if(A==B){
       cout<<1<<endl;
       return 0;
    }
    int diff=1;
    REP(i,61){
        AA[i]=A%2;
        A/=2;
        BB[i]=B%2;
        B/=2;
        if(AA[i]!=BB[i]){
           diff=i;
        }
    }
    LL beki=1;
    REP(i,diff){
        beki*=2;
    }
    
    //CとDの再構成
    C=0;D=0;
    LL a=1;
    REP(i,diff){
        if(AA[i]==1){
           C+=a;
        }
        if(BB[i]==1){
           D+=a;
        }
        a*=2;
    }
    //D=0の場合の処理
    if(D==0){
    //cout<<"aaa"<<endl;
       if(C==0){
          cout<<2*(beki-C)<<endl;
       }else{
          cout<<2*(beki-C)+1<<endl;
       }
       return 0;
    }
    //Dの最上位ビットを取り出す
    LL D_max=0;
    LL temp=D;
    REP(i,diff){
        if(temp%2==1)D_max=i;
        temp/=2;
    }
    LL D_beki=1;
    REP(i,D_max+1){
        D_beki*=2;
    }
    /*
    LL C_min=1;
    REP(i,diff){
        if(BB[i]==1){
           break;
        }
        C_min*=2;
    }
    */
    LL ans_u=min(beki-C+D_beki,beki);
    /*if(C==0){
       ans_u++;
    }*/
    cout<<ans_u+(beki-C)<<endl;
    //cout<<C<<" "<<D<<" "<<D_beki<<" "<<beki<<endl;
    return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  string N;
  cin >> N;
  
  rep(i, 3) {
    if(N[i] == '7') {
      fin("Yes");
      return 0;
    }
  }
  
  fin("No");
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool b[229028];
int n, m;
vector<int>l;
int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++)b[i] = false;
	for (int i = 0; i < m; i++){
		int a; cin >> a;
		l.push_back(a);
	}
	for (int i = 1; i <= m; i++) {
		if (!b[l[m - i]])cout << l[m - i] << endl;
		b[l[m - i]] = true;
	}
	for (int i = 1; i <= n; i++)if (!b[i])cout << i << endl;
}

Measured memory_bytes: 3624
import itertools
def warshall_floyd(g):
    for k in range(len(g)):
        for i in range(len(g)):
            for j in range(len(g)):
                g[i][j] = min(g[i][j], g[i][k]+g[k][j])
    return g

n,m,r = map(int,input().split())
lst = list(map(int,input().split()))
graph = [[float('inf')]*n for _ in range(n)]
for _ in range(m):
    a,b,c = map(int,input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c
for i in range(n):
    graph[i][i] = 0
d = warshall_floyd(graph)

res = float('inf')
for l in itertools.permutations(lst):
    cnt = 0
    for i in range(1, len(l)):
        cnt += d[l[i-1]-1][l[i]-1]
    res = min(res, cnt)
print(res)

Measured memory_bytes: 59480
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M 998244353
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ull
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}



int power(int x,int k){
  int ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  map<int,int> mp;
  int maxd=0;
  int ans=1;
  rep(i,n){
    int d;
    cin>>d;
    if(i==0&&d!=0) ans=0;
    mp[d]++;
    maxd=max(d,maxd);
  }

  
  int p=1;
  if(mp[0]>1) ans=0;
  
  rep(i,maxd+1){
    if(mp[i]==0) ans=0;
    //cout<<mp[i]<<endl;
    ans*=power(p,mp[i]);
    ans%=M;
    p=mp[i];
  }

  cout<<ans<<endl;

}








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

#define SZ(a) (int)a.size()
#define PB push_back
//#define cerr if(false)cerr
#define print(x) cerr<<"\n" << (#x) << " is " << (x) << endl;

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

typedef vector<int> vi;
typedef vector<ll> vll;

const int MAXN = 1000007;
const int INF = 1000303;
const ll mod = 1e9+7;

ll power(ll a, ll b){
	ll tmp = 1LL;
	while(b){
		if(b & 1){tmp = (tmp * a); tmp %= mod;}
		a = (a * a) % mod;
		b /= 2;
	}
	return tmp;
}

int k = 200007;
ll inv[200007];
ll fact[200007];
ll inv_fact[200007];
inline ll mul(ll a, ll b){
	return (ll)((a%mod) * (b%mod)) % mod;
}

inline ll add(ll a, ll b){
	return (ll)((a%mod) + (b%mod)) % mod;
}
ll calc(int n, int r){
	return mul(mul(fact[n], mul(inv_fact[r], inv_fact[n-r])), mul(fact[n-1], mul(inv_fact[r], inv_fact[n-1-r])));
}

ll n, s;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	
	inv[0] = 1, inv[1] = 1;
	for(int i=2; i<=k; i++){
		inv[i] = (mod - ((mod/i) * inv[mod%i]) % mod) % mod;
	}
	
	fact[1] = 1;fact[0] = 1;
	for(int i=2; i<k+1; i++){
		fact[i] = (fact[i-1]*i)%mod;
		fact[i]%=mod;
	}
	
	inv_fact[1] = 1;
	inv_fact[0] = 1;
	for(int i=2; i<=k; i++){
		inv_fact[i] = (inv_fact[i-1]*inv[i])%mod;
	}
	cin >> n >> s;
	ll ans = 0;
	s = min(s, n-1);
	for(int i=0; i<=s; i++){
		ans += calc(n, i);
		ans %= mod;
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 4992
'use strict'

const main = (input) => {
    input = input.split('\n').map(i => parseInt(i))
    const N = input[0]
    const A = input[1]
    const r = Math.floor(N % 500)
    if(A >= r){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
s = list(input())
t1 = []
t2 = []
t1 = s[0:int((len(s)-1)/2)]
t2 = s[int((len(s)-1)/2)+1:]

sr = list(reversed(s))
t1r = list(reversed(t1))
t2r = list(reversed(t2))

if s == sr and t1 == t1r and t2 == t2r:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long dp[100010];

int main()
{
	int N,K;
	int h[100015];

cin.tie(0);
ios::sync_with_stdio(false);
	cin>>N;

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

	for (int i = 0; i < 100010; ++i) dp[i] = INT_MAX;	
  
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for (int i = 2; i < N; ++i) {
		dp[i]=min(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
		dp[i]=min(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N-1] << endl;
}


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

int main() {
    string S;
    cin >> S;
    int ans = S.size();
    rep(i,2) {
        int cnt = 0;
        rep(j, S.size()) {
            if(j%2==0 && S[j] != (char)(i+'0')) cnt++;
            if(j%2==1 && S[j] == (char)(i+'0')) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
import java.lang.reflect.Array;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int k = sc.nextInt();

		if(b-a>k || c-a>k || d-a>k || e-a>k||
				c-b>k || d-b>k|| e-b>k||
				d-c>k || e-c>k || e-d>k  ) {
			System.out.println(":(");
		}else{
			System.out.println("Yay!");
		}

	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<map>
#include<cstdio>
#define ll long long
#define lson (rt<< 1)
#define rson (rt<< 1 | 1)
#define gmid ((l+r)>> 1 )
using namespace std;

const int maxn=200050;
int f[maxn];
int main()
{
	int n,k=0;
	ll ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(int i=1;i<=n;++i)
	  if(s[i-1]=='R') f[i]=1;
	    else  f[i]=0;
	for(int i=1;i<=n;++i)
	  k+=f[i];
	if(k<n/2)
	{
		for(int i=1;i<=k;++i)
		  if(f[i]==0) ans++;
		cout<<ans<<endl;  
	}      
	else
	{
		for(int i=n;i>=k+1;--i)
		  if(f[i]==1) ans++;
		cout<<ans<<endl;  
	}
}


Measured memory_bytes: 4068
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] strList = str.split("");
		int ans = 700;
		if(strList[0].equals("o")){
			ans += 100;
		}
		if(strList[1].equals("o")){
			ans += 100;
		}
		if(strList[2].equals("o")){
			ans += 100;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21972
#include<cctype>
#include<cstdio>

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

using namespace std;

typedef long long ll;

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

struct Stat{ int x,y,dir,t; };

int main(){
	char DIR[]="ENWS";
	int DIRR[128]; rep(k,4) DIRR[DIR[k]]=k;

	int h,w;
	for(ll l;scanf("%d%d%lld",&h,&w,&l),h;){
		static char B[100][101];
		int x,y,dir;
		rep(i,h){
			scanf("%s",B[i]);
			rep(j,w) if(isalpha(B[i][j])) x=j, y=i, dir=DIRR[B[i][j]];
		}

		int T[100][100][4];
		rep(i,h) rep(j,w) rep(k,4) T[i][j][k]=-1;

		ll t=0;
		while(l>0){
			if(~T[y][x][dir]){
				ll dif=t-T[y][x][dir];
				t+=(l-1)/dif*dif;
				l-=(l-1)/dif*dif;
			}
			T[y][x][dir]=t;

			int xx=x+dx[dir],yy=y+dy[dir];
			if(0<=yy && yy<h && 0<=xx && xx<w && B[yy][xx]!='#'){
				t++;
				l--;
				x=xx;
				y=yy;
			}
			else{
				dir=(dir+3)%4;
			}
		}

		printf("%d %d %c\n",y+1,x+1,DIR[dir]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a,b;
ll x[200001];

int main(void){
	scanf("%d%lld%lld",&n,&a,&b);
	for(int i=0;i<n;i++){
		scanf("%lld",&x[i]);
	}
	ll res=0;
	for(int i=0;i<n-1;i++){
		res+=min((x[i+1]-x[i])*a,b);
	}
	printf("%lld\n",res);
	return 0;
}


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

int prime(int);

int main(){

    int x;
    cin>>x;
    cout<<prime(x)<<endl;


    return 0;
}

int prime(int x){
    if(x==2) return 2;
    
    while(1){
        if(x%2==0){
            x++;
            continue;
        }
        bool primecheck=true;
        for(int i=3;i<x;i++){
            if(x%i==0){
                primecheck=false;
                break;
            }
        }
        if(primecheck) return x;

        x++;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vin p(n);
    map<int,int> num;
    rep(i,n){
        cin>>p[i];
        num[p[i]]=i+1;
    }
    set<int> r;
    rep(i,n+2)r.insert(i);//考えている数字より大きい数字の場所を残しておく
    ll tmp,sum,ans=(ll)0;
    ll l1,l2,r1,r2;//l1:iより小さいまだ残ってる数字の中でiに一番近い数字の場所 l2:iに二番目に近い r1,r2も同様
    rep2(i,1,n){
        tmp=num[i];
        r.erase(tmp);
        l1=*(--r.lower_bound(tmp));//upper is also ok
        l2=(l1!=0)?*(--r.lower_bound(l1)):0;
        r1=*(r.upper_bound(tmp));//lower is also ok
        r2=(r1!=n+1)?*(r.upper_bound(r1)):n+1;
        sum=(l1-l2)*(r1-tmp)+(tmp-l1)*(r2-r1);
        //cout<<i<<" "<<sum<<" "<<l1<<" "<<l2<<" "<<tmp<<" "<<r1<<" "<<r2<<endl;
        sum*=(ll)i;
        ans+=sum;
    }
    cout<<ans<<endl;
}

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

int main() {
  int q;
  cin>>q;
  multiset<int> s;
  int j,a,b;
  cin>>j>>a>>b;
  s.insert(a);
  ll cur=b;
  auto it=s.begin();
  ll now=0;
  
  rep(i,0,q-1){
    cin>>j;
    if(j==1){
      cin>>a>>b;
      cur+=b;
      if(s.size()%2==0){
        s.insert(a);
        if(a<*it){
          now+=*it-a;
        }
        else{
          it++;
          now+=a-*it;
        }
      }
      else{
        s.insert(a);
        if(a<*it){
          int old=*it;
          it--;
          now+=old-a;
        }
        else{
          now+=a-*it;
        }
      }
    }
    else{
      cout<<*it<<' '<<now+cur<<endl;
    }
  }
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef long long LL;
LL fun(LL x,LL n)
{
    LL res=1;
    while(n>0)
    {
        if(n & 1)
            res=(res*x);
        x=(x*x);
        n >>= 1;
    }
    return res;
}
ll a[]={0,2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67 ,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167 ,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227 ,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347 ,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401 ,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461 ,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523 ,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599 ,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653 ,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727 ,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797 ,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859 ,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937 ,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997 ,};
int main()
{
    ll dp[110000];
    ll a[110000];
    ll n,x,b;
    cin>>n>>x>>b;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    dp[1]=0;
    a[0]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+(a[i]-a[i-1])*x,dp[i-1]+b);
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,m,x;
   cin>>n>>m;
   long long int sum=0;
   for(int i=0;i<m;i++)
   {
     cin>>x;
     sum+=x;
     
   }
   
	if(sum<=n)
	cout<<n-sum<<endl;
	
	else
	cout<<-1<<endl;
	
	return 0;
  
}


Measured memory_bytes: 3628
n=int(input())
l=[]
tem=list(map(int,input().split()))
for i in range(n):
    l.append((tem[i],i+1))
l=sorted(l,key=lambda s: s[0])
for x in range(n):
    if x==0:
        print(l[x][1],end="")
    else:
        print(" %d"%l[x][1],end="")


Measured memory_bytes: 19964
n,x,y = map(int, input().split())
x -=1
y -=1

#edge = [[] for _ in range(n)]
cnt = [0] * n
#dist = [0] * n
#for i in range(1,n):
#    edge[i].append(i - 1)
#    edge[i - 1].append(i)

#edge[x].append(y)
#edge[y].append(x)

#def dfs(x, last = -1):
#    cnt[dist[x]] += 1
#    for nxt in edge[x]:
#        if nxt == last:continue
#        dist[nxt] = dist[i] + 1
#        dfs(nxt, x)

for i in range(n):
    for j in range(i + 1, n):
        dist = min(j - i,abs(j - x) + 1 + abs(i - y), abs(j - y) + 1 + abs(i - x))
        cnt[dist] += 1
#    dist[i] = 0
#    dfs(i)

for i in range(1,n):
    print(cnt[i])

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int n, r, p, c;
		int num[], tmp;
		int i, j, k;// loop counter
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			num = new int[n];
			for (i = 0; i < n; ++i) {
				num[i] = i + 1;
			}
			r = sc.nextInt();

			if (n == 0 && r == 0) {
				break;
			}
			for (i = 0; i < r; ++i) {
				p = sc.nextInt();
				c = sc.nextInt();

				for (j = 0; j < c; ++j) {
					for (k = 0; k < p - 1; ++k) {
						tmp = num[n - p - j + k + 1];
						num[n - p - j + k + 1] = num[n - p - j + k];
						num[n - p - j + k] = tmp;
					}
				}

			}
			System.out.println(num[n - 1]);
		}
		sc.close();
	}

}


Measured memory_bytes: 39528
K, A, B = map(int, input().split())

if B <= A + 2:
    print(1+K)
    exit(0)

move_left = K

bis = 1

if A - bis >= move_left:
    print(1 + K)
    exit(0)

move_left -= A - bis
bis = A

# print(move_left, move_left // 2)

bis += (B - A) * (move_left // 2)
move_left -= 2 * (move_left // 2)


# print(move_left, bis)

bis += move_left # 1 or 0

# while sousa < K:
#     if yen == 0:
#         if bis < A:
#             bis += 1
#             sousa += 1
#         elif sousa <= K - 2:
#             bis -= A
#             yen += 1
#             sousa += 1
#         else:
#             bis += 1
#             sousa += 1
#     else:
#         yen -= 1
#         bis += B
#         sousa += 1

print(bis)


Measured memory_bytes: 3060
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)


A, B, C, D = map(int, input().split())

N = B - A + 1

E = B//C - (A-1)//C
F = B//D - (A-1)//D
G = B//(lcm(D,C)) - (A-1)//(lcm(D,C))

ans = N - (E + F - G)

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    bool flag = false;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && (n / i) < 10) {
            flag = true;
        }
    }

    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,weight;
  scanf("%d%d",&n,&weight);
  int v[100];
  int w[100];
  int m[100];
  int i;
  for(i=0;i<n;i++) scanf("%d%d%d",v+i,w+i,m+i);
  int dp[10001];
  for(i=0;i<=weight;i++) dp[i]=0;
  for(i=0;i<n;i++){
    int k=1;
    int s=0;
    while(s<m[i]){
      if(s+k>=m[i]){
	k=m[i]-s;
      }
      int vv=k*v[i];
      int ww=k*w[i];
      int j;
      for(j=weight;j>=ww;j--){
	int index=j-ww;
	dp[j]=MAX(dp[j],dp[index]+vv);
      }
      s+=k;
      k*=2;
    }
  }
  int max=0;
  for(i=0;i<=weight;i++) max=MAX(max,dp[i]);
  printf("%d\n",max);
  return;
}

int main(void){
  run();
  return 0;
}



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

int main() {
  string S, T;
  cin >> S >> T;

  bool ok = true;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      ok = false;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x, a, b;
    cin >> x >> a >> b;
    string ans;
    if(b - a > x) ans = "dangerous";
    else if(b - a <= x && b-a > 0) ans = "safe";
    else ans = "delicious";
    cout << ans;
}

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


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);

	long long int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	cout<<abs(*max_element(a,a+n)-*min_element(a,a+n))<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
kun_list = [1] * n
for i in range(0, k):
    d = int(input())
    a_list = list(map(int, input().split()))
    for a in a_list:
        kun_list[a-1] = 0
print(sum(kun_list))


Measured memory_bytes: 9196
s = input()
t = input()
ls = len(s)
lt = len(t)
mx = 0
for i in range(ls -lt + 1):
#  print(s[i])
  c = 0
  for j in range(lt):
#    print(i,j,s[i+j], t[j])
    if s[i+j] == t[j]:
      c+= 1
  if c > mx:
    mx = c
print(lt - mx)


Measured memory_bytes: 9024
package main

import (
	"fmt"
	"sort"
)

func nC2(n int) int {
	return n * (n - 1) / 2
}

type RuneSlice []rune

func (r RuneSlice) Len() int {
	return len(r)
}

func (r RuneSlice) Less(i, j int) bool {
	return r[i] < r[j]
}

func (r RuneSlice) Swap(i, j int) {
	r[i], r[j] = r[j], r[i]
}

func sortChars(s string) string {
	r := []rune(s)
	sort.Sort(RuneSlice(r))
	return string(r)
}

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

	sum := 0
	cnt := 1
	for i := 1; i < N; i++ {
		if ss[i-1] == ss[i] {
			cnt++
			continue
		}
		sum += nC2(cnt)
		cnt = 1
	}
	sum += nC2(cnt)

	fmt.Println(sum)
}


Measured memory_bytes: 6272
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000
//cin.ignore (7777, '\n');

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll n,m,a,b;
ll massiv[MAXN];
ll massivv[MAXN];

int main(){
FAST_READ;
//cin.tie(0);
cin>>n>>m>>a>>b;
for(ll i=1;i<=n;i++)
{
  cin>>massiv[i];
}
for(ll i=1;i<=m;i++)
{
  cin>>massivv[i];
}
sort(massivv+1,massivv+(m+1));
sort(massiv+1,massiv+(n+1));
ll z=massiv[n]+1;
if(z>a && z<=b && z>massiv[n] && massivv[1]>=z)
{
  cout<<"No War"<<endl;
}
else cout<<"War"<<endl;



return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int N, D; cin >> N >> D;
 vector<vector<int>> X(N, vector<int>(D));
 for (int i = 0; i < N; ++i) {
for (int j = 0; j < D; ++j) {
 cin >> X[i][j];
 }
 }
 int ans = 0;
 for (int i = 0; i < N; ++i) {
 for (int j = i+1; j < N; ++j) {
 int norm = 0;
 for (int k = 0; k < D; ++k) {
 int diff = abs(X[i][k] - X[j][k]);
 norm += diff * diff;
 }
 // check whether norm = k for some k
 bool flag = false;
 for (int k = 0; k <= norm; ++k) {
 if (k * k == norm) {
 flag = true;
 }
}
 if (flag) ++ans;
 }
}
     cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

struct nt {
    ll time;
    ll node;
    ll money;
    nt(ll t, ll n, ll m) : time(t), node(n), money(m) {}
};

struct conNt {
    bool operator()(nt const &a, nt const &b) {
        return a.time > b.time;
    }
};


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,s;
    cin>>n>>m>>s;
    ll lim = 1LL<<60;
    vector<vector<ll>> mata(n,vector<ll>(n,lim));
    vector<vector<ll>> matb(n,vector<ll>(n,lim));
    vector<ll> exc(n), exctime(n);
    vector<vector<ll>> time(n,vector<ll>(2501, lim));
    rep(i,m) {
        ll u,v,a,b;
        cin>>u>>v>>a>>b;u--;v--; 
        mata[u][v] = mata[v][u] = a;
        matb[u][v] = matb[v][u] = b;
    }
    rep(i,n) {
        cin>>exc[i]>>exctime[i];
    }
    priority_queue<nt, vector<nt>, conNt> pq;
    pq.emplace(0,0,min(2500LL, s));
    ll nxt_time, remain;
    while (!pq.empty()) {
        nt now = pq.top();
        pq.pop();
        if (time[now.node][now.money] < now.time) {
            continue;
        }
        rep(i,n) {
            nxt_time = now.time + matb[now.node][i];
            remain = now.money - mata[now.node][i];
            if (remain >= 0 &&
            nxt_time < time[i][remain]) {
                time[i][remain] = nxt_time;
                pq.emplace(nxt_time, i, remain);
            }
        }
        nxt_time = now.time + exctime[now.node];
        remain = min(2500LL, now.money + exc[now.node]);
        if (time[now.node][remain] > nxt_time) {
            time[now.node][remain] = nxt_time;
            pq.emplace(nxt_time, now.node, remain);
        }
    }

    repr(i, 1, n) {
        ll res = lim;
        rep(j,2500) {
            chmin(res, time[i][j]);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 7268
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#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++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i+=2) {
        int cnt = 0;
        FOR(j,1,i)
            if (i % j == 0) cnt++;
        if (cnt == 8) res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
ai = lambda: list(map(int, input().split()))

h,w = ai()
d = [ai() for _ in range(10)]
a = [ai() for _  in range(h)]

from scipy.sparse import csgraph
d = csgraph.floyd_warshall(d)

ans = 0
from itertools import chain
for aa in chain.from_iterable(a):
    if aa != -1:
        ans += int(d[aa][1])
print(ans)


Measured memory_bytes: 27572
import random

def main():
    dir = ['W', 'N', 'S', 'E']
    dice = Dice([int(a) for a in input().split()])
    n = int(input())
    for _ in range(n):
        top, front = (int(x) for x in input().split())
        while True:
            if top == dice.getSuf(0) and front == dice.getSuf(1):
                print(dice.getSuf(2))
                break
            dice.move(random.choice(dir))


class Dice():
    def __init__(self, surface):
        self.l = surface
 
    def move(self, dir):
        if(dir == 'N'):
            self.l = [self.l[1], self.l[5], self.l[2], self.l[3], self.l[0], self.l[4]]
        elif(dir == 'W'):
            self.l = [self.l[2], self.l[1], self.l[5], self.l[0], self.l[4], self.l[3]]
        elif(dir == 'E'):
            self.l = [self.l[3], self.l[1], self.l[0], self.l[5], self.l[4], self.l[2]]
        elif(dir == 'S'):
            self.l = [self.l[4], self.l[0], self.l[2], self.l[3], self.l[5], self.l[1]]

    def show(self):
        print(self.l[0])
    
    def getSuf(self, surface):
        return self.l[surface]


main()


Measured memory_bytes: 8184
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define sz(a) ll(a.size())	
#define trace(c,x) for(auto &x:c)
#define F first
#define S second		
ll mod = 1e9 + 7;   //change acc to question
int memo[100005];
int a[103];
int n;
int dp(int i)
{
	if(i==0)
		return 0;//chal nhi paega....
	if(i<0)
		return 1;//pichle wale ka chalna is invaid here....
	if(memo[i]!=-1)
		return memo[i];
 
	int val = 0;
	memo[i] = 0;
	for(int j=0;j<n;j++)
	{
		val = dp(i-a[j]);
		if(val==0)
			memo[i] = 1;
	}
	return memo[i];
}
int main()
{
	ios::sync_with_stdio(false);
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<=k;i++)
		memo[i] = -1;
	if(dp(k)==1)
		cout<<"First"<<endl;
	else
		cout<<"Second"<<endl;
	return 0;
	}	

Measured memory_bytes: 5376
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

const double pi = 3.141592653589793;

int main() {
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double ans = sqrt(a*a + b*b - 2*a*b*cos(min(abs(pi*h/6 + pi*m/360 - pi*m/30),2*pi - abs(pi*h/6 + pi*m/360 - pi*m/30))));
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int x;
	cin>>x;
	if (x==0) cout<<1<<endl;
	else cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}


int main(){
	
	int a,b;
	cin>>a>>b;
	if((a+b)%2 == 1)cout<<(a+b)/2+1<<endl;
	else cout<<(a+b)/2<<endl;
}

Measured memory_bytes: 256
n, m = gets.split(" ").map(&:to_i)
hh = gets.split(" ").map(&:to_i)

edges = Array.new(n) { Array.new}

m.times do |_|
  a, b = gets.split(" ").map(&:to_i)
  a -= 1
  b -= 1
  edges[a] << b
  edges[b] << a
end

ans=0

n.times do |i|
  ans += 1 if edges[i].all? { |j| hh[i] > hh[j] }
end

puts ans

Measured memory_bytes: 26524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    for(ll a=-1000;a<=1000;a++) for(ll b=-1000;b<=1000;b++){
        if(a*a*a*a*a-b*b*b*b*b==X){
            cout << a << " " << b << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 3656
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	l := p.NextInts()
	_, _, X := l[0], l[1], l[2]
	A := p.NextInts()

	var left, r int
	for _, ai := range A {
		if ai < X {
			left++
		} else {
			r++
		}
	}
	p.PrintInt(min(left, r))
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 640
k, a, b = map(int, input().split())

ans = 0
if a >= b:
  ans = k+1
else:
  if b - a <= 2:
    ans = k+1
  else:
    if k < (a-1)+2:
      ans = k+1
    else:
      ans = b
      k -= (a-1)+2
      ans += (b-a)*(k//2)
      if k%2 == 1:
        ans += 1
print (ans)

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

int main() {

	std::vector<std::vector<int>> c(3, std::vector<int>(3, 0));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)std::cin >> c[i][j];
	}

	int res = 0;
	if (c[0][1] - c[0][0] == c[1][1] - c[1][0])res++;
	if (c[0][1] - c[0][0] == c[2][1] - c[2][0])res++;
	if (c[0][2] - c[0][1] == c[1][2] - c[1][1])res++;
	if (c[0][2] - c[0][1] == c[2][2] - c[2][1])res++;
	if (c[1][0] - c[0][0] == c[1][1] - c[0][1])res++;
	if (c[1][0] - c[0][0] == c[1][2] - c[0][2])res++;
	if (c[2][0] - c[1][0] == c[2][1] - c[1][1])res++;
	if (c[2][0] - c[1][0] == c[2][2] - c[1][2])res++;

	if (res == 8)std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin >>n >> m && (n || m)){
    vector<pii> v(m);
    rep(i,m){
      v[i].fi = 0;
      v[i].se = i+1;
    }
    ll a;
    rep(i,n){
      rep(j,m){
        cin >> a;
        v[j].fi -= a;
      }
    }
    sort(all(v));
    rep(i,m){
      if(i) cout << " ";
      cout << v[i].se;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>

#define SIZE 100
using namespace std;
using ll = long long int;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> light(m);
    vector<int> cond(m);

    for (size_t i = 0; i < m; i++)
    {
        int ki;
        cin >> ki;
        for (size_t _ = 0; _ < ki; _++)
        {
            int s;
            cin >> s;
            light[i].push_back(s);
        }
    }

    for (size_t i = 0; i < m; i++)
    {
        cin >> cond[i];
    }

    ll ans = 0;
    for (size_t i = 0; i < (1 << n); i++)
    {
        bitset<10> mask = i;
        vector<int> on(m);

        for (int j = 0; j < m; j++)
        {
            for (auto &&e : light[j])
            {
                if (mask[e-1])
                {
                    on[j]++;
                }
            }
        }
        bool ok = true;
        for (size_t j = 0; j < m; j++)
        {
            if (on[j] % 2 != cond[j])
            {
                ok = false;
            }
        }
        if (ok)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = long long;
#define int ll
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
using vi =vector<int>;
struct Edge{int to,cap,rev;};//ikisaki youryou gyakuhen
struct edge{int to,cap,rev;};//ikisaki youryou gyakuhen
#define inf INF
class MF{//max flow
public:
    int n;
    vector<vector<edge> >G;//[MAX];;
    vi level,iter;//[MAX];
    MF(int size){
        n=size;
        G=vector<vector<edge> >(n);
    }
    void add_edge(int from, int to, int cap){
        edge q={to,cap,int(G[to].size())};
        G[from].push_back(q);
        q={from,0,int(G[from].size()-1)};
        G[to].push_back(q);
    }
    void bfs(int s){
        level=vi(n,-1);
        queue<int>q;
        level[s]=0;
        q.push(s);
        while(!q.empty()){
            int v=q.front();q.pop();
            for(int i=0;i<G[v].size();i++){
                edge &e=G[v][i];
                if(e.cap>0&&level[e.to]<0){
                    level[e.to]=level[v]+1;
                    q.push(e.to);
                }
            }
        }
    }
    int dfs(int v,int t, int f) {
        if(v==t)return f;
        for(int &i=iter[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(level[v]>=level[e.to]||e.cap<=0) continue;
            int d =dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
        return 0;
    }
    int mf(int s,int t) {//from s to t,ford_fulkerson
        int flow=0;
        while(1){
            bfs(s);
            if(level[t]<0)return flow;
            iter=vi(n);
            int f;
            while((f=dfs(s,t,INF))>0)flow+=f;
        }
    }
};


signed main(){
    int N,M,s,t;
    cin >> N >> M >> s >> t;
    --s;--t;
    int wf[210][210];
    int cost[210][210];
    int dis[201][201];
    MF fl(N);
    // init
    rep(i,N)rep(j,N){
        wf[i][j] = INF; cost[i][j] = INF;
    }
    rep(i,N)wf[i][i] = 0;
    //

    rep(i,M){
        int u,v,d,c; cin >> u >> v >> d >> c;
        --u;
        --v;
        cost[u][v] = c;
        wf[u][v] = dis[u][v] = d;
    }
    rep(k,N)rep(i,N)rep(j,N){
        cmin( wf[i][j], wf[i][k] + wf[k][j] );
    }
    rep(i,N)rep(j,N){
        if(dis[i][j] != wf[i][j])continue;
            if(wf[s][i] + wf[i][j] + wf[j][t] == wf[s][t]){
                fl.add_edge(i, j, cost[i][j]);
        }
    }
    cout<< fl.mf(s, t) << endl;
}



Measured memory_bytes: 4012
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A;
		for(int i = 0;; i++) {
			A = i * i;
			if(A > N) {
				System.out.println((i - 1) * (i - 1)); 
				break;
			}
			A = 0;
		}
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;


int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int M;
    cin >> M;
    while(M--){
        string s;
        cin >> s;
        set<string> sset;
        for(int i=1; i<s.length(); i++){
            string a = s.substr(0, i);
            string b = s.substr(i);
            
            sset.insert(a+b);
            sset.insert(b+a);
            reverse(a.begin(), a.end());
            sset.insert(a+b);
            sset.insert(b+a);
            reverse(b.begin(), b.end());
            sset.insert(a+b);
            sset.insert(b+a);
            reverse(a.begin(), a.end());
            sset.insert(a+b);
            sset.insert(b+a);
        }
        
        cout << sset.size() << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <cmath>
#include <iomanip>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
using namespace std;

int main()
{
	const double pi = 3.141592653589;
	int aa, bb, hh, mm;
	cin >> aa >> bb >> hh >> mm;
	double xa, xb, ya, yb, tt, ll;
	tt = (double)hh + (double)mm / 60.0;
	xa = (double)aa * sin(2.0 / 12.0 * pi * (double)tt);
	ya = (double)aa * cos(2.0 / 12.0 * pi * (double)tt);
	xb = (double)bb * sin(2.0 * pi * (double)tt);
	yb = (double)bb * cos(2.0 * pi * (double)tt);
	ll = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
	ll = sqrt(ll);
	cout << fixed << setprecision(30);
	cout << ll << endl;
	return 0;
}

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


bool g[10][10];

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

  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    g[a][b] = true;
    g[b][a] = true;
  }

  std::vector<int> v(n);
  rep(i,n) v[i] = i;

  int ans = 0;
  do {
    if (v[0] != 0) break;

    bool ok = true;
    rep(i,n-1) {
      if (!g[v[i]][v[i+1]]) {
        ok = false;
      }
    }
    if (ok) ans++;
  } while (next_permutation(v.begin(), v.end()));

  cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve();
	}
	
	private void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] dp = new int[n+1];
		sc.close();
		
		dp[0] = 1;
		dp[1] = 1;
		
		for(int i = 2; i <= n; i++) {
			dp[i] = dp[i-1] + dp[i-2];
		}
		
		System.out.println( dp[n] );
	}
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,t,a;
	cin>>n>>t>>a;
	int ans=-1;
	double d=DBL_MAX;
	for(int i=1;i<=n;i++){
		double z;
		cin>>z;
		z=t-z*0.006;
		double temp=abs(z-a);
		if(temp<d){
			d=temp;
			ans=i;
		}
	}	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256