akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

//////////////////////////////////////////////////

int main(){
  COMinit();
  ll N,K;
  cin>>N>>K;
  
  RREP(i,K){
    if(i<=N-K+1){
      co(COM(K-1,i-1)*COM(N-K+1,i)%MOD);
    }
    else co(0);
  }
  return 0;
}

Measured memory_bytes: 123128
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    int MAX(int a,int b){
      if(a<b){
        int tmp = a;
        a = b;
        b = tmp;
      }
      int r = a%b;
      while(!r){
        a = b;
        b = r;
        r = a%b;
      }
      return r;
    }

    int main(){
      int n;
      cin>>n;
      auto a = vec(long,n);
      int cnt = 0;
      int cnt2 = 0;
      rep(i,n){
        cin>>a[i];
        a[i] %= 4;
        if(a[i] == 0)cnt++;
        if(a[i] == 2)cnt2++;
      }
      sort(a.begin(),a.end());
      if(a[0] == 2 && a[n-1] == 2){
        cout<<"Yes"<<endl;
        return 0;
      }
      if(cnt>=1 && cnt2>=2){
        n -= (1+cnt2);
        cnt--;
      }
      if(n/2 <= cnt)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }


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

int main() {
	int N; cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= (i + 1);
	}

	sort(A.begin(), A.end());
	ll b = A[N / 2];
	ll ret = 0;
	for (int i = 0; i < N; i++) {
		ret += abs(A[i] - b);
	}

	cout << ret << endl;
}

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

int main() {
  int a ;
  string s ;
  cin >> s ;
  if (s[0] == '1') {
  a = a + 1;
}
if (s[1] == '1') {
  a = a + 1;
}
  if (s[2] == '1') {
  a = a + 1;
  }
cout << a << endl;
    return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int main(){
    LL N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    N--;
    REP(i,N+1){
        LL ll=C*i+(-D)*(N-i);
        LL rr=D*i+(-C)*(N-i);
        //printf("[%lld,%lld\n]",ll,rr);
        if(B-A>=ll&&B-A<=rr)return 0*puts("YES");
    }
    return 0*puts("NO");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long s,f[1000005],a,b,n,k,q;
int main(){
	cin>>n;
	for(k=1;k<=n;k++){
		cin>>a;
		f[a]++;
		s+=a;
	}
	cin>>q;
	while(q--){
		cin>>a>>b;
		f[b]+=f[a];
		s=s-f[a]*a+f[a]*b;
		f[a]=0;
		cout<<s<<endl;
	}
}


Measured memory_bytes: 4408
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<vector>
#include<tuple>
using namespace std;

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

}


Measured memory_bytes: 256
l="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N=int(input())
S=list(input())
c=N%26

Sdash=[]
for e in S:
    if l.index(e)+c>=26:
        Sdash.append(l[c-(26-l.index(e))])
    else:
        Sdash.append(l[l.index(e)+c])
print("".join(Sdash))

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

const int INF = 1001001001;

// DAME:
// TIPS: bitDP
/*
    dp[集合s] = sを全て開けられる鍵の買い方の最小コスト
*/
int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<pair<int, int>> key;
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        int s = 0;
        for(int j=0; j<b; j++){
            int c;
            cin >> c;
            --c;
            // 1 << 3 → 1000
            s |= 1<<c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, INF); // 2^n
    dp[0] = 0;
    for(int s=0; s < 1<<n; s++){
        for(int i=0; i<m; i++){
            int t = s | key[i].first;
            int cost = dp[s]+key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == INF){
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::string s;
	std::cin >> s;
	std::vector<int> unhappy;
	if(s[0]=='L') unhappy.emplace_back(1);
	if(s[n-1]=='R') unhappy.emplace_back(1);
	rep(i,n-1) {
		if(s[i]=='R' && s[i+1]=='L') unhappy.emplace_back(2);
	}
	std::sort(all(unhappy),std::greater<int>());
	int sum = n;
	for(int i:unhappy) sum-=i;
	rep(i,k) if(i<unhappy.size()) sum+=unhappy[i];
	if(k>=unhappy.size()) sum = n-1;
	print(sum);

	return 0;
}


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

using namespace std;
#define ml 200005
#define ll long long
int n;
ll a[ml];
int main()
{
    ll tal=0;
    scanf("%d",&n);

    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);

    }
    if(a[1]!=0)
    {
        printf("-1");
        return 0;
    }
    for(int i=1;i<n;i++)
    {
        if(a[i+1]-a[i]>=2)
        {
            printf("-1");
            return 0;
        }
        if(a[i+1]-a[i]==1)
        {
            tal++;
        }
        else
        {
            tal+=a[i+1];
        }


    }
    printf("%lld",tal);

    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;
/*
int main(){
  long long a,b;
  cin >> a >> b;
  bool c[40] = {0};
  for(int i = 0; i < 32; i++){
    if(b >= (1 << i)){
      if((b-(1 << i)+1)%(1 << (i+1)) > (1 << i)) c[i] = 0;
      else c[i] = ((b-(1 << i)+1)%(1 << (i+1)))%2;
    }
    if(a >= (1 << i)){
      if((a-(1 << i))%(1 << (i+1)) > (1 << i)) c[i] += 0;
      else c[i] += ((a-(1 << i))%(1 << (i+1)))%2;
    }
  }
  for(int i = 0; i < 32; i++){
    cout << c[i] << endl;
  }
  long long ans = 0;
  cout << endl;
  for(int i = 0; i < 32; i++){
    ans += c[i] << i;
    cout << (c[i]<<i) << endl;
  }
  cout << ans << endl;
}*/


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


Measured memory_bytes: 256
using System;

class ITP1_7_B{
    static void Main(string[] args){
        int n,x;
        while(true){
            string[] str = Console.ReadLine().Split(' ');
            n = int.Parse(str[0]);
            x = int.Parse(str[1]);
            if(n+x == 0) break;
            int count = 0;
            for(int i=1; i<=n; i++){
                for(int j=1; j<=n; j++){
                    for(int k=1; k<=n; k++){
                        if((i!=j)&&(j!=k)&&(i!=k)){
                             int total = i + j + k;
                            if(total==x){
                                count++;
                            }
                        }
                    }
                }
            }
            Console.WriteLine(count/6);
        }
    }
}


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

bool cmp(char a,char b)
{
	return a>b;
}

int main(){
	string s,t;
	
	cin>>s;
	cin>>t;
	
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),cmp);
	
	if(s<t)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v)	((v).begin()), ((v).end())
#define pb	push_back
#define mp	make_pair
#define mod 1000000007
#define debug(x)  cout<<#x<<" = "<<x<<" \n"
typedef long long ll;
void xin(){
	#ifndef ONLINE_JUDGE 
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}

// int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
// inline bool valid(int x, int y, int v) {
//     return x >= 0 && x < n && y >= 0 && y < m && !visited[x][y] && grid[x][y] == v;
// }

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

    int n,x,t;
    cin>>n>>x>>t;
    ll ans = ceil(float(n)/x)*t;
    cout<<ans<<endl;

   
}
    

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

int main()
{
  long A,B,C;
  long d=0;
  cin>>A>>B>>C;
  if(A<C) cout<<0<<" "<<max(d,A+B-C)<<endl;
  else cout<<A-C<<" "<<B<<endl;
}

Measured memory_bytes: 256
import bisect
n,m,v,p=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
kijun=a[p-1]
s=[0]*n
for i in range(n):
  s[i]+=s[i-1]+a[n-i-1]
if p>=v:
  print(n-bisect.bisect_left(a[::-1],kijun-m))
else:
  for i in range(n)[::-1]:
    rem=m*max(0,v-(n-i+p-1))
    if rem+(s[n-p]-s[n-1-i]) <= (a[i]+m)*(i-p+1) and a[i]+m >= kijun:
      print(i+1)
      break
    else:
      pass

Measured memory_bytes: 62784
# coding: utf-8

n, a, b = map(int,input().split())
s = input()

capacity = 0
foreigner = 0
for i in range(n):
    if s[i] == 'a':
        if capacity <= a+b-1:
            print('Yes')
            capacity += 1
        else:
            print('No')
    elif s[i] == 'b':
        if capacity <= a+b-1 and foreigner <= b-1:
            print('Yes')
            capacity += 1
            foreigner += 1
        else:
            print('No')
            foreigner += 1
    else:
        print('No')

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    vector<int> x(3);
    for(int i = 0; i < 3; ++i)  cin >> x[i];
    sort(x.begin(), x.end());
    int res = 0;
    if(x[1] < x[2] - 2){
        int hoge = x[2] - 2 - x[1];
        x[0] += hoge;
        x[1] += hoge;
        res += hoge;
    }

    int a = x[0], b = x[1], c = x[2];
    if(x[1] == x[2] - 1){
        ++res;
        ++a;
        if((c - a) % 2 == 0){
            res += (c - a) / 2;
        }
        else{
            ++res;
            ++c;
            res += (c - a) / 2;
        }
    }
    else if(x[1] == x[2] - 2){
        ++res;
        if((c - a) % 2 == 0){
            res += (c - a) / 2;
        }
        else{
            ++res;
            ++c;
            res += (c - a) / 2;
        }
    }
    else{
        if((c - a) % 2 == 0){
            res += (c - a) / 2;
        }
        else{
            ++res;
            ++c;
            res += (c - a) / 2;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;

int n;
char s[50];
bool vis[30];

bool check() {
	for(int i=0;i<26;i++) {
		if(s[i]!='z'-i) return 0;
	}
	return 1;
}

int main() {
	scanf("%s",s);
	n=strlen(s);
	if(n<26) {
		for(int i=0;i<n;i++) {
			vis[s[i]-'a']=1;
		}
		printf("%s",s);
		for(int i=0;i<26;i++) {
			if(!vis[i]) {
				printf("%c\n",'a'+i);
				break;
			}
		}
	}
	else {
		if(check()) {
			printf("-1\n");
		}
		else {
			int p=-1;
			for(int i=n-1;i>=0;i--) {
				vis[s[i]-'a']=1;
				if(s[i]>s[i-1]) {
					p=i;break;
				}
			}
			for(int i=0;i<p-1;i++) {
				printf("%c",s[i]);
			}
			for(int i=s[p-1]-'a'+1;i<26;i++) {
				if(vis[i]) {
					printf("%c\n",i+'a');
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    string str;
    while(cin>>str){
        int ans=0;
        for(int i=0;i<str.length();i++){
            if(str[i]=='+')ans++;
            else ans--;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
// template {{{

#include <bits/stdc++.h>

// #define int long long

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP2(i, n) REP3(i, 0, n)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += s)
#define RREP2(i, n) RREP(i, 0, n)
#define RREP3(i, a, b) for (int i = (b) - 1; i >= (int)(a); i--)

#define rep(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, RREP3, RREP2)(__VA_ARGS__)
#define eb emplace_back
#define ef emplace_front
#define pb pop_back
#define pf pop_front
#define all(c) std::begin(c), std::end(c)
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second
#define popcnt __builtin_popcountll

using uint = unsigned;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

template<typename T>
using maxpq = std::priority_queue<T, std::vector<T>, std::less<T>>;

template<typename T>
using minpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline bool chmax(T &x, U y){ if (x >= y) return false; x = y; return true; }

template<typename T, typename U>
inline bool chmin(T &x, U y){ if (x <= y) return false; x = y; return true; }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(std::begin(c), std::end(c)); c.erase(std::unique(all(c)), std::end(c)); }

using namespace std;

// }}}

set<string> st;

string gen(char c)
{
	while (true){
		string r;
		r += c;
		rep(i, 8) r += rand() % 26 + 'a';
		r += 'a';
		if (!st.count(r)) return r;
	}
}

int main()
{
	string a, b = "z";
	while (true){
		a = gen(b.back());
		cout << "?" << a << endl; st.insert(a);
		cin >> b;
		if (!st.insert(b).se || a.back() != b.front()){
			cout << "!OUT\n";
			return 0;
		}
	}
}

Measured memory_bytes: 3236
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>
bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>
bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int n; cin >> n;
    VD p(n);
    REP(i, n) cin >> p[i];
    vector<VD> dp(n+1, VD(n+1, 0.0));//i枚投げ j枚表
    dp[1][0] = 1 - p[0]; dp[1][1] = p[0];
    FORS(i, 2, n){
        REPS(j, i){
            if(!j) dp[i][j] = dp[i-1][j] * (1 - p[i-1]);
            else dp[i][j] = dp[i-1][j-1] * p[i-1] 
                          + dp[i-1][j] * (1 - p[i-1]);
        }
    }
    double ans = 0.0;
    FORS(i, n/2 + 1, n) ans += dp[n][i];
    cout << fixed << setprecision(10) << ans << "\n";
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  map<map<char,i64>,i64> MP;

  rep(i,N){
    string s;
    cin >> s;
    map<char,i64> mp;
    rep(j,s.size()){
      mp[s[j]] = mp[s[j]] + 1;
    }
    MP[mp] = MP[mp] + 1;
  }

  i64 ans = 0;
  for(auto &p:MP){
    ans += p.second * (p.second-1) / 2;
  }
  cout << ans << "\n";

}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 62336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N;
    cin >> N;
    vector<lli> x(N), y(N), h(N);
    auto mp = make_v(101, 101, -1);
    REP(i, 0, N) {
        cin >> x[i] >> y[i] >> h[i];
        mp[y[i]][x[i]] = h[i];
    }
    const int inf = 2000000000;
    REP(CX, 0, 101) {
        REP(CY, 0, 101) {
            lli candi = mp[CY][CX];
            lli uppr = inf;
            bool ok = true;
            REP(i, 0, N) {
                if (h[i] > 0) {
                    lli tmph = h[i] + abs(x[i] - CX) + abs(y[i] - CY);
                    if (candi != -1 && tmph != candi) {
                        ok = false;
                        break;
                    }
                    candi = tmph;
                } else {
                    uppr = min(uppr, h[i] + abs(x[i] - CX) + abs(y[i] - CY));
                }
            }
            if (candi == -1 && uppr == 1) {
                candi = 1;
            }
            if (ok && candi >= 0 && candi <= uppr) {
                cout << CX << ' ' << CY << ' ' << candi << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#####segfunc#####
def segfunc(x, y):
    return max(x, y)
#################

#####ide_ele#####
ide_ele = 0
#################

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res
# coding: utf-8
# Your code here!
a = input().split()
N = int(a[0])
M = int(a[1])
b = []
k = [int(input()) for i in range(N)]

temp = int(0)

for i in range(300001):
    b.append(0)
    
seg = SegTree(b, segfunc, ide_ele)

for i in range(N):
    temp = seg.query(max(0, k[i]-M), min(300001, k[i]+M+1))
    seg.update(k[i], temp+1)
    temp = 0
    
print(seg.query(0,300001))


Measured memory_bytes: 137388
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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 Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n;
	cin>>n;
	Array t(n,0), a(n,0);
	Array max(n,0), min(n,0);
	REP(i,n) cin>>t[i];
	REP(i,n) cin>>a[i];

	ll pre=-1;
	REP(i,n){
		if(pre<t[i]){
			max[i]=t[i];
			min[i]=t[i];
		}else{
			max[i]=pre;
			min[i]=1;
		}
		pre=t[i];
	}
	pre=-1;
	REP(i,n){
		//cerr<<max[n-1-i]<<" "<<min[n-1-i]<<endl;
		if(pre<a[n-1-i]){
			if(max[n-1-i]<a[n-1-i]||min[n-1-i]>a[n-1-i]){
				cout<<0<<endl;
				return 0;
			}else{
				max[n-1-i]=a[n-1-i];
				min[n-1-i]=a[n-1-i];
			}
		}else{
			if(max[n-1-i]==min[n-1-i]){
				if(pre<max[n-1-i]){
					cout<<0<<endl;
					return 0;
				}
			}else{
				chmin(max[n-1-i],pre);
			}
		}
		pre=a[n-1-i];
	}
	ll ans=1;

	REP(i,n){
		//cerr<<max[i]<<" "<<min[i]<<endl;;
		(ans*=max[i]-min[i]+1)%=MOD;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3456
Scanf.scanf "%d %d" (fun n m ->
    let state = Array.make n 10 in
    let sc = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun s c -> s, c)) in
    let rec loop i =
        if i < 0 then (
            match n with
            | 1 -> if state.(0) = 10 then 0 else
                   if state.(0) = -1 then -1 else state.(0)
            | 2 -> if state.(0) = -1 || state.(1) = -1 || state.(0) = 0 then (-1) else (
                if state.(0) = 10 then state.(0) <- 1;
                if state.(1) = 10 then state.(1) <- 0;
                state.(0) * 10 + state.(1)
            )
            | 3 -> if state.(0) = -1 || state.(1) = -1 || state.(2) = -1 || state.(0) = 0 then (-1) else (
                if state.(0) = 10 then state.(0) <- 1;
                if state.(1) = 10 then state.(1) <- 0;
                if state.(2) = 10 then state.(2) <- 0;
                state.(0) * 100 + state.(1) * 10 + state.(2)
            )
            | _ -> failwith "??"
        ) else (
            let s, c = sc.(i) in
            let s = s - 1 in
            let c = if state.(s) = 10 || state.(s) = c then c else (-1) in
            let () = state.(s) <- c in
            loop (i - 1)
        )
    in
    loop (m - 1) |> Printf.printf "%d\n"
)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define All(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
#define Graph vector<vector<int>>
using namespace std;

vl a,p;

long f(long n,long x)
{
        if(n==0)
        {
                if(x<=0)return 0;
                else return 1;
        }else if(x<=1+a[n-1])
        {
                return f(n-1,x-1);
        }else
        {
                return p[n-1]+1+f(n-1,x-2-a[n-1]);
        }
}


main()
{
        long n,x; cin>>n>>x;
        
        a.resize(n); p.resize(n);
        a[0]=1; p[0]=1;
        FOR(i,1,n-1)
        {
                a[i]=a[i-1]*2+3;
                p[i]=p[i-1]*2+1;
        }

        cout<<f(n,x)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,x,sum,ans=0;
  while(true){
    cin>>n>>x;
    if(n+x==0) break;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
	if(i!=j&&x-i-j<=n&&(x-i-j)!=i&&(x-i-j)!=j){
	  if(n!=i&&n!=j&&i<j&&j<x-i-j){
	    ans++;
	  }
	}
      }
    }
    cout<<ans<<"\n";
    ans=0;
  }
}



Measured memory_bytes: 3084
import random

X = int(input())


def is_prime(n):
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False

    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for k in range(100):
        a = random.randint(1, n - 1)
        t = d
        y = pow(a, t, n)

        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False

    return True


def solve(X):
    while True:
        if (is_prime(X)):
            return X
        X += 1


print(solve(X))


Measured memory_bytes: 4208
inf = 10 ** 18
mod = 10 ** 9 + 7
n = int(input())
t = [0] + list(map(int, input().split())) + [inf]
a = [inf] + list(map(int, input().split())) + [0]
ans = 1
for i in range(1, n + 1):
    if t[i - 1] < t[i]:
        ans *= 0 if t[i] > a[i] else 1
    if a[i + 1] < a[i]:
        ans *= 0 if t[i] < a[i] else 1
    if t[i - 1] == t[i] and a[i + 1] == a[i]:
        ans *= min(t[i], a[i])
        ans %= mod
print(ans)

Measured memory_bytes: 25304
#include<stdio.h>
int main(void)
{
  int S, h, m, s;
  scanf("%d", &S);
  h=S/3600;
  m=(S-h*3600)/60;
  s=(S-h*3600)%60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <stack>
#include <vector>
#include <cstdio>
#include <string>
#include <sstream>
using namespace std;

vector<string> split(const string &s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main()
{
	string s;

	getline(cin, s);
	vector<string> ss = split(s, ' ');
	stack<int> stack;

	for (int i = 0; i < ss.size(); i++)
	{
		int a, b;
		if (ss[i] == "+")
		{
			a = stack.top();
			stack.pop();
			b = stack.top();
			stack.pop();
			stack.push(b + a);
		}
		else if (ss[i] == "-")
		{
			a = stack.top();
			stack.pop();
			b = stack.top();
			stack.pop();
			stack.push(b - a);
		}
		else if (ss[i] == "*")
		{
			a = stack.top();
			stack.pop();
			b = stack.top();
			stack.pop();
			stack.push(b * a);
		}
		else
		{
			stack.push(atoi(ss[i].c_str()));
		}
	}
	cout << stack.top() << endl;
}


Measured memory_bytes: 3236
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265359

using namespace std;

/*ll powMod(ll a, ll y)
{
    ll ans = 1;
    
    while (y > 0) 
    { 
        if (y & 1) 
            ans = (ans*a) % MOD; 
  
        y = y>>1;
        a = (a*a) % MOD; 
    } 
    return ans;
}*/

/*ll modInv(ll a)
{
    return powMod(a, MOD-2);	
}*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(b*d, max(a*c, max(b*c, a*d))) << endl;
    return 0;
}




Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
vector<long long> oldpool,newpool;
long long a[1010],qzh[1010];
int n,k;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		qzh[i]=qzh[i-1]+a[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i;j<=n;j++){
			oldpool.push_back(qzh[j]-qzh[i-1]);
		}
	}
	long long ret=0;
	newpool.clear();
	for(int bit=60;bit>=0;bit--){
		newpool.clear();
		for(int i=0;i<oldpool.size();i++){
			if((oldpool[i]>>bit)&1){
				newpool.push_back(oldpool[i]);
			}
		}
		if(newpool.size()>=k){
			oldpool=newpool;
			ret+=(1LL<<(bit));
		}
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 6128
#include<cstdio>
#include<algorithm>
#include<cstring>

int fr[501];
int c[10001],d[10001];
using namespace std;
int main(void)
{
    int n,m;
    int a,b;
    while(scanf("%d%d",&n,&m))
    {
        if(n == 0 && m == 0) break;
        for(int i = 0;i < 501;i++) fr[i] = 0,c[i] = 0,d[i] = 0;

        int j = 0;
        for(int i = 0;i < m;i++)
        {
            scanf("%d%d",&a,&b);

            if(a == 1) fr[b] = 1;
            else if(b == 1)  fr[a] = 1;
            else
            {
                c[j] = a,d[j] = b;
                j++;
            }
        }

        for(int i = 0;i < j;i++)
        {
            if(fr[c[i]] == 1 && fr[d[i]] != 1) fr[d[i]] = 2;
            else if(fr[d[i]] == 1 && fr[c[i]] != 1) fr[c[i]] = 2;
        }

        int cnt = 0;
        for(int i = 0;i < 501;i++)
            if(fr[i] != 0) cnt++;

        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 1108
// problem: "https://atcoder.jp/contests/abc158/tasks/abc158_a"

#include<bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin>>s;

    if(s[0] != s[1] || s[1] != s[2] || s[2] != s[0])
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  //pattern 010101...
  int paint1 = 0;
  for (int i = 0; i < s.size(); ++i) {
    char c = s[i];
    if (i % 2 == 0 && c == '1') ++paint1;
    if (i % 2 == 1 && c == '0') ++paint1;
  }
  //pattern 101010...
  int paint2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    char c = s[i];
    if (i % 2 == 0 && c == '0') ++paint2;
    if (i % 2 == 1 && c == '1') ++paint2;
  }
  cout << min(paint1, paint2) << endl;
}


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

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

    ll ten = 1;
    for(ll i = 0; i < n; i++)
    {
        ten = ten * 10 % mod;
    }
    ll nine = 1;
    
    for(ll i = 0; i < n; i++)
    {
        nine = nine * 9 % mod;
    }

    ll eight = 1;
    for(ll i = 0; i < n; i++)
    {
        eight = eight * 8 % mod;
    }

    ll res = ten - (nine + nine) + eight;
    res %= mod;
    res = (res + mod) % mod; 
    
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>

long long inp_c, inp_n, i1;

long long inp_a[200005];

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld ", temp_func);
	return 0;
};

void dotesto() {
	
	for (long long i1f = 1; i1f <= inp_c; i1f++) {
		
		printNumber(i1f);
		
		printNumber(inp_c * 2 - i1f + 1);
		
		printf("\n");
		
	};
	
	return;
	
};

void doteste() {
	
	for (long long i1f = 1; i1f <= inp_c / 2; i1f++) {
		
		printNumber(i1f);
		
		printNumber(inp_n - i1f);
		
		printf("\n");
		
	};
	
	for (long long i1f = inp_c / 2 + 1; i1f <= inp_c; i1f++) {
		
		printNumber(i1f);
		
		printNumber(inp_c * 2 - i1f + 1);
		
		printf("\n");
		
	};
	
	return;
	
};

int main() {
	
	inp_n = readNumber();
	
	inp_c = readNumber();
	
	if (inp_n % 2 == 1) {
		
		dotesto();
		
	} else {
		
		doteste();
		
	};
	
}

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

typedef long long ll;

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

    int h,w;
    cin >> h >> w;
    vector<vector<string>> s(h,vector<string>(w));
    for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> s[i][j];
    string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=="snuke"){
                cout << alphabet[j] << i+1 << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

  char *o,*e,*pass;
  o = new char[50];
  e = new char[50];
  pass = new char[100];

  cin >> o >> e;
  for(int i=0; i<100; i=i+2)
  {
    pass[i] = o[i/2];
  }
  for(int i=1; i<100; i=i+2)
  {
    pass[i] = e[i/2];
  }
  cout << pass << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int n, p;
    cin >> n >> p;
    while(!(n == 0 && p == 0)){
        vector<int> st(n, 0);
        int rem = 0;
        bool game = true;
        while(game){
            REP(i, n){
                if(p > 0){
                    if(st[i]++ == 0) rem++;
                    if(--p == 0 && rem == 1){
                        game = false;
                        break;
                    }
                }else{      // p == 0
                    p = st[i];
                    if(st[i] > 0) rem--;
                    st[i] = 0;
                }
            }
        }
        REP(i, n){
            if(st[i] > 0){
                cout << i << "\n";
                break;
            }
        }
    
        cin >> n >> p;
    }
    return 0;
}


Measured memory_bytes: 3064
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    l = list(map(int, input().split()))
    len_l = len(l)
    len_set_l = len(set(l))
    if len_l != len_set_l:
        print("NO")
    else:
        print("YES")



if __name__=="__main__":
    main()


Measured memory_bytes: 127032
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

int mod(ll x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(ll x,ll m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    ll n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    vector<ll> v1(n,0);
    vector<ll> v2(n,0);

    REP(i,n) {
        REP(j,n) {
            if (v[i] > v[j]) {
                if (i < j) {
                    v1[j]++;
                }
                v2[j]++;
            }
        }
    }
    ll mul = mod(max(k * (k-1) / 2,0LL));
    ll ans = mod(modm(accumulate(ALL(v1),0LL),k) + modm(accumulate(ALL(v2),0LL),mul));
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main(){
     int a,b,c,d;
     cin >> a >> b >> c >>d;
     int T=0,A=0;
    T=(c+b-1)/b;
    A=(a+d-1)/d;
    cout<<(A>=T?"Yes":"No")<<endl;
 }

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <limits>

int main()
{
	unsigned int n = 0;
	int min = std::numeric_limits<int>::max();
	int max_gap = std::numeric_limits<int>::min();

	std::cin >> n;

	int R = 0;
	for (unsigned int i = 0; i < n; i++)
	{
		std::cin >> R;
		max_gap = std::max(max_gap, R - min);
		min = std::min(min, R);
	}

	std::cout << max_gap << std::endl;

	return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int prime[120001],num,cou=0,ans=0;
    for(int i=2;i<=120000;i++)prime[i]=0;
    for(int i=2;i<=(int)sqrt(120000);i++){
        for(int j=2;j*i<=120000;j++)prime[i*j]=1;
    }
    while(cin>>num&&num!=0){
        for(int i=2;cou<num;i++){
            if(prime[i]==0){
                    ans+=i;
                    cou++;
            }
        }
        cout<<ans<<endl;
        ans=0;cou=0;
    }
}

Measured memory_bytes: 1628
import math
a, b, h, m = map(int, input().split())

a_x = a * math.cos(math.radians(90 - 30 * h - 0.5 * m))
a_y = a * math.sin(math.radians(90 - 30 * h - 0.5 * m))

b_x = b * math.cos(math.radians(90 - 6 * m))
b_y = b * math.sin(math.radians(90 - 6 * m))
# print(a_x)
# print(a_y)
# print(b_x)
# print(b_y)

print(math.sqrt((a_x - b_x)**2 + (a_y - b_y)**2))

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

class node{
public:
  int key;
  int p;
};
vector<node> v(10000);
int findx(int x){
  while(1){
    if(x == v[x].p) break;
    x = v[x].p;
  }
  return x;
}

void solve(){
  int n, q; cin >> n >> q;
  for(int i = 0; i < n; i++){
    v[i].key = i;
    v[i].p = i;
  }
  vector<int> s(q), x(q), y(q);
  for(int i = 0; i < q; i++){
    cin >> s[i] >> x[i] >> y[i];
  }
  vector<int> rank(n, 0);
  for(int i = 0; i < q; i++){
    int a = findx(x[i]);
    int b = findx(y[i]);
    if(s[i] == 0){
      if(a == b) continue;
      if(rank[a] == rank[b]){
        v[b].p = a;
        rank[a]++;
      }
      else if(rank[a] < rank[b]){
        v[a].p = b;
      }
      else{
        v[b].p = a;
      }
    }
    else{
      if(a == b) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main(){
    int N, M, s, c;
    cin >> N >> M;
    vector<int> ans(N, 10);
    rep(i, M){
        cin >> s >> c;
        if(ans[s-1]!=10&&ans[s-1]!=c){
            cout << "-1" << endl; return 0;
        }
        ans[s-1] = c;
    }
    if(N==1&&c==0){
        cout << "0" << endl; return 0;
    }
    if(ans[0]==0){
        cout << "-1" << endl; return 0;
    }
    else if(ans[0]==10) ans[0] = 1;
    for(auto a: ans){
        if(a==10) a=0;
        cout << a;
    }
}


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

using namespace std;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  list<int> b;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (i & 1) {
        b.push_front(a[i]);
      } else {
        b.push_back(a[i]);
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i & 1) {
        b.push_back(a[i]);
      } else {
        b.push_front(a[i]);
      }
    }
  }

  for (list<int>::iterator it = b.begin(); it != b.end(); it++) {
    if (it != b.begin()) cout << " ";
    cout << *it;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int const MAXN=200100;
long long int n, v[MAXN], res=0;
int main(){
	cin>>n;
	for(int i=0;i<n;i++) cin>>v[i];
	int last=-1;
	long long int val=0;
	for(int i=0;i<n-1;i++){
		if(i>last) val+=v[i], last++;
		for(int j=last+1;j<n;j++){
			if((val&v[j])==0){
				val+=v[j];
				last=j;
			} else break;
		}
		res+=last-i;
		val-=v[i];
	}
	cout<<res+n;
}

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

int main()
{	
    long long n,W,i,j;
    cin>>n>>W;

    long long v[n],w[n];
    for(i=0;i<n;i++)
    {
      cin>>w[i];
      cin>>v[i];
    }

    long long dp[W+1][n+1];

    for(i=0;i<=W;i++)
      for(j=0;j<=n;j++)
        dp[i][j]=0;

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

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

	return 0;
}

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

int main() {
	int a[100] = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;
	cout << (a[x] == a[y] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256