akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> red(n), blue(n);
  for(int i = 0 ; i < n; i++){
    pair<int, int>temp_red;
    cin >> temp_red.second >> temp_red.first;
    red[i] = temp_red;
  }
  for(int i = 0 ; i < n; i++){
    pair<int, int>temp_blue;
    cin >> temp_blue.first >> temp_blue.second;
    blue[i] = temp_blue;
  }

  sort(red.begin(), red.end());
  reverse(red.begin(), red.end());
  sort(blue.begin(), blue.end());

  int ans = 0;
  //blue
  for(int i_blue = 0; i_blue < blue.size(); i_blue++){
    for(int i_red = 0; i_red < red.size(); i_red++){
      if(red[i_red].second < blue[i_blue].first && red[i_red].first < blue[i_blue].second){
        ans += 1;
        //cout << "red: "<<red[i_red].first<<" "<<red[i_red].second<<endl;
        //cout << "blue: "<<blue[i_blue].first<<" "<<blue[i_blue].second<<endl;
        red[i_red].first = 99999;
        red[i_red].second = 99999;
        blue[i_blue].first = -1;
        blue[i_blue].second = -1;
        break;
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

main {
  int h, w;
  cin >> h >> w;
  int c = INF;
  auto f = [&](int h, int w) -> void {
    for (int i = 1; i <= w; i++) {
      vi s(3);
      s[0] = i * h;
      s[1] = (w - i) * (h / 2);
      s[2] = w * h - s[0] - s[1];
      c = min(c, *max_element(all(s)) - *min_element(all(s)));
      s[1] = ((w - i) / 2) * h;
      s[2] = w * h - s[0] - s[1];
      c = min(c, *max_element(all(s)) - *min_element(all(s)));
    }
  };
  f(h, w);
  f(w, h);
  cout << c << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n][3];
  for(int i=0;i<n;i++){
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  }
  int dp[n+1][3];
//   memset(dp,sizeof(dp),0);
    for(int i=0;i<=n;i++) for(int j=0;j<3;j++) dp[i][j]=0;
//   dp[0][0]=dp[0][1]=dp[0][2]=0;
  dp[1][0]=a[0][0];dp[1][1]=a[0][1];dp[1][2]=a[0][2];
  
  for(int i=2;i<=n;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
      {
        if(k!=j)
          dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i-1][j]);
      }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;}
  

Measured memory_bytes: 5964
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>

#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,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL p=7+1e+9;

int main(){
  int Q, c, a, n;
  cin >> Q;
  REP(i,Q){
    int ans = 0;
    scanf("%d%d%d", &c, &a, &n);
    int t = min(c, min(a, n));
    ans += t;
    c -= t; a -= t; n -= t;
    t = min(c / 2, a);
    ans += t;
    c -= t * 2; a -= t;
    ans += c / 3;
    printf("%d\n", ans);
  }
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> p;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        p.emplace_back(b,a);
    }
    string c = "Yes";
    sort(p.begin(),p.end());
    long sum = 0;
    for(auto i:p){
        long x = i.first,y=i.second;
        sum += y;
        if(x<sum) c = "No";
    }
    cout << c << endl;
}

Measured memory_bytes: 5272
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 105;

int main()
{
	int arr[5];
	for(int i = 0 ; i <= 2 ; i++)
		cin >> arr[i];
	sort(arr,arr + 3);
	if(arr[0] + arr[1] == arr[2])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
	}

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

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N,M;
    cin >> N >> M;
    vector<pair<int,int>> move(M);
    REP(i,M)cin >> move[i].F >> move[i].S;
    REP(i,M){
        move[i].F--;
        move[i].S--;
    }
    vector<int> num(N,1);
    vector<bool> red(N);
    red[0] = 1;
    REP(i,M){
        num[move[i].F]--;
        num[move[i].S]++;
        if(red[move[i].F] == 1)red[move[i].S] = 1;
        if(num[move[i].F] == 0)red[move[i].F] = 0;
    }
    int sum = 0;
    REP(i,N){
        sum += red[i];
    }
    cout << sum << "\n";
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[200];
char t[200];

ll h,w;
ll ban[10][10];

void in(){
	ll n=strlen(s);
	h=w=0;
	rep(i,0,10)rep(j,0,10)ban[i][j]=0;
	
	int i=0,j=0;
	rep(x,0,n){
		if(s[x]=='/'){
			w=j;
			i++;
			j=0;
		}else if(s[x]=='b'){
			ban[i][j]=1;
			j++;
		}else{
			j+=s[x]-'0';
		}
		h=i+1;
	}
}

void out(){
//	printf("%d %d\n",h,w);
	rep(i,0,h){
		int cnt=0;
		rep(j,0,w){
			if(ban[i][j]){
				if(cnt)printf("%d",cnt);
				printf("b");
				cnt=0;
			}else cnt++;
		}
		if(cnt)printf("%d",cnt);
		if(i!=h-1)printf("/");
	}
	puts("");
}

int main(){
	while(scanf(" %s",s),*s!='#'){
		in();
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		ban[a-1][b-1]=0;
		ban[c-1][d-1]=1;
		out();
	}
}


Measured memory_bytes: 2048
use List::Util qw(max min);
my $N = <STDIN>;
my @A = split(/ /, <STDIN>);
my $M = max(@A);
$M =~ s/(\r\n|\r|\n)$//g;
my $C = $M;
my $half = $M/2;
my $diff = $half;
foreach my $v (@A) {
        my $tmp = abs($half - $v);
        if ($tmp <= $diff){
                $diff = $tmp;
                $v =~ s/(\r\n|\r|\n)$//g;
                $C = $v;
        }
}
print $M." ".$C;

Measured memory_bytes: 18156
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstdlib>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct uftree{
private:
  int par[100005]={0},rank[100005]={0};
  ll sum[100005]={0};
public:
  uftree(int n){
    for(int i=1;i<=n;i++){
      par[i]=i;
      rank[i]=0;
      sum[i]=1;
    }
  }
  int find(int x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
  }
  ll unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b) return 0;
    ll ret=sum[a]*sum[b];
    if(rank[a]<rank[b]){
      par[a]=b;
      sum[b]+=sum[a];
    }
    else{
      par[b]=a;
      sum[a]+=sum[b];
      if(rank[a]==rank[b]) rank[a]++;
    }
    return ret;
  }
};
int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  for(int i=0;i<n;i++) {
    ll a;
    cin>>a;
    v.push_back(a);
  }
  sort(v.begin(),v.end());
  ll as=v[n-1],del=174417441744;
  int pos=0;
  for(int i=0;i<n-1;i++){
    if(abs(as-v[i]*2)<del){
      del=abs(as-v[i]*2);
      pos=i;
    }
  }
  cout<<as<<" "<<v[pos]<<endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#define MAXN 100005
#define mod 1000000007
typedef long long ll;
using namespace std;
//vector<ll> arr;
ll arr[MAXN];
ll book[MAXN];
ll dp[MAXN];
int main(){
    memset(dp,0,sizeof(dp));
    memset(book,0,sizeof(book));
    ll n;
    char x;
    ll y;
    cin >> n;
    for(ll i=1;i<=n;i++){
        cin >> x;
        y=x-'a'+1;
        arr[i]=y;
    }
    sort(arr+1,arr+n+1);
    for(ll i=1;i<=n;i++){
        if(!book[arr[i]]){
            dp[i]=(2*dp[i-1]+1)%mod;
        }
        else{
            int t=book[arr[i]];
            dp[i]=(dp[i-1]*2%mod+mod-dp[t-1]%mod)%mod;
        }
         book[arr[i]]=i;
    }
    printf("%lld\n",dp[n]%mod);
return 0;
}


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

int main(){   
    ll x;
    cin>>x;
 
    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            if(pow(i,5LL)-pow(j,5LL)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }   
        }
    }
}   


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

namespace AtCoder.Contests.ABC156
{
    /// <summary>
    /// 
    /// </summary>
    static class A
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            var r = NextInt();

            Console.WriteLine(n < 10 ? r + 100 * (10 - n) : r);
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	string s;
	cin >> s;
	vb cs(26, 0);
	vl cnts(26, 0);
	for (char c : s) {
		cs[c - 'A'] = true;
		cnts[c - 'A']++;
	}
	ll s1 = 0, s2 = 0;
	rep(i, 26) {
		s1 += cs[i];
	}
	if (s1 == 2) {
		bool dame = false;
		rep(i, 26) {
			if (cs[i] && cnts[i] != 2) {
				dame = true;
				break;
			}
		}
		if (dame == false) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


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

using namespace std;

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

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

    for(int i = 0; i < N; i++) {
        if(B[0] == A[i]) {
            cout << B[1] << endl;
        } else {
            cout << B[0] << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	if(a > b)
		swap(a, b);
	if(abs(a - b)&1){
		cout << min(1 + abs(a-b)/2 + min(a-1, n-b), min(b - 1, n - a));
	}
	else{
		cout << abs(a-b)/2 << '\n';
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
//#define no cout<<"NO"<<"\n"
#define INF (int)1e5+5
#define nax (int)1e6+3
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define MAX_N (int)1e6+2
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern
 
 


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

	int n;
	cin >> n;
	
	int out1=0, out2=0 ,out3=0 , out4=0;
	
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		if(s == "AC"){
			out1++;
		}
		else if(s == "WA"){
			out2++;
		}
		else if(s == "TLE"){
			out3++;
		}
		else
			out4++;
	}
	
	cout<<"AC x "<<out1<<"\n";
	cout<<"WA x "<<out2<<"\n";
	cout<<"TLE x "<<out3<<"\n";
	cout<<"RE x "<<out4<<"\n";
	
	
	return 0;
}


Measured memory_bytes: 3652
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    int minDistance(int k, int n, int* arr) {
        int maxDis = 0;
        sort(arr, arr + n);
        for(int i = 1; i < n; ++i) {
            maxDis = max(arr[i] - arr[i - 1], maxDis);
        }
        return k - max(maxDis, arr[0] + k - arr[n - 1]);
    }
};

int main() {
    Solution so;
    int k, n;
    cin >> k >> n;
    int arr[n];
    for(int i = 0; i < n; ++i) cin >> arr[i];
    cout << so.minDistance(k, n, arr) << endl;
    return 0;
}

Measured memory_bytes: 1024
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def is_ok(n, k):
    while n % k == 0:
        n //= k
    if n < k:
        return n == 1
    else:
        return n % k == 1


def prime_enumeration(n):
    div = []
    for i in range(1, int(sqrt(n))+1):
        if n % i == 0:
            if i != 1:
                div.append(i)
            if n // i != i:
                div.append(n // i)

    #div.sort()
    return div


def main():
    N = int(readline())

    div_n = prime_enumeration(N)
    div_n1 = prime_enumeration(N-1)
    #print(div_n)
    #print(div_n1)

    ans = 0
    for d in div_n:
        if is_ok(N, d):
            ans += 1
    
    for d in div_n1:
        if is_ok(N, d):
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3288
//
// Created by Myabu on 2020/01/12.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>

using namespace std;


int main(void){
    int N,M,X,Y;

    cin>>N>>M>>X>>Y;

    int x[110];
    int y[110];

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

    for (int i = 0; i < M; ++i) {
        cin>>y[i];
    }

    int x_max = x[0];
    for (int i = 0; i < N; ++i) {
        if(x_max < x[i]){
            x_max = x[i];
        }
    }

    int y_min = y[0];
    for (int i = 0; i < M; ++i) {
        if(y_min > y[i])y_min=y[i];
    }

    bool war=true;
    for (int i = -100; i < 101 ; ++i) {
        if(x_max < i && y_min >= i && X<i && Y>=i){
            war = false;
            break;
        }
    }

    if(war){
        cout<<"War"<<endl;
    }else{
        cout<<"No War"<<endl;
    }


    return 0;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	println(t + s);
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define graph vector<vi>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define T int t;cin>>t;rep(i,t)



void solve() {

	int n, m, k;
	cin >> n >> m >> k;
	
	int arr[n][m], cost[n];
	
	rep(i, n) {
		cin >> cost[i];
		
		rep(j, m)
			cin >> arr[i][j];
	}
	
	bool flag = false;
	int ans = INT_MAX;
	rep_a(i,1,1<<n) {
		
		int cal[m] = {0};
		bool temp = true;
		int curr = 0;
		rep(j, n) {
			
			if (i & 1<<j) {
				curr += cost[j];
				rep(z, m)
					cal[z] += arr[j][z];
			}
			
		}
		
		rep(j, m)
			if (cal[j] < k) {
				temp = false;
				break;
			}
		
		if (temp) {
			ans = min(ans, curr);
			flag = true;
		}
	}
	
	if(flag)
		cout << ans;
	else
		cout << -1;
}

int main()
{
    fastio;
//    T
    solve();
	//code
	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
	int n;
	while(cin>>n)
	{
		if(n<1200)
		{
			cout<<"ABC"<<endl;
		}
		else if(n<2800)
		{
			cout<<"ARC"<<endl;
		}
		else
		{
			cout<<"AGC"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
#define in2(N,s,t) rep(i,N){in(s[i] , t[i]);}
#define in3(N,s,t,u) rep(i,N){in(s[i] , t[i] , u[i]);}
using vd = V<double>; using vs = V<string>; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
//////////////////

void solve(){
  ini(N , K);
  vi a(N); in(a);
  double ans = -1.0 , cur = 0.0;
  rep(i , K){
    cur += 1.0 * (a[i] + 1.0) / 2;
  }
  amax(ans , cur);
  for(int i = 0 ; i < N - K ; i++){
    cur += 1.0 * (a[i + K] + 1.0) / 2;
    cur -= 1.0 * (a[i] + 1.0) / 2;
    amax(ans , cur);
  }
  out(ans);
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
main(){
  int N;
  cin >> N;  
  vector<int> num(N);
  for(int i=0;i<N;i++){
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  for(int i=0;i<N-1;i++){
    if(num.at(i)==num.at(i+1)){
      cout << "NO" << endl;
      exit(0);
    }
  }
  cout << "YES" << endl;
}

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

bool sq[300000];
int main(){
	int a;scanf("%d",&a);
	vector<int>v,u;
	for(int i=0;i*i<300000;i++)v.push_back(i*i);
	rep(i,v.size())rep(j,v.size()){
		if(v[i]+v[j]<300000)sq[v[i]+v[j]]=true;
	}
	sq[1]=false;
	rep(i,a){
		int p,q;scanf("%d%d",&p,&q);
		for(int i=1;i<=p*p+q*q;i++){
			if(!sq[i])continue;
			if((p*p+q*q)%i)continue;
			if(sq[(p*p+q*q)/i]){
				puts("C");goto g;
			}
		}
		puts("P");
		g:;
	}
}

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

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

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

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

int main(){
    int a, b;
    cin >> a >> b;
    rep(i, 1e6) {
        int x = (i * 0.08);
        int y = (i * 0.1);
        if(a == x && b == y) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int m, h;
    string s;
    while (true) {
        cin >> s;
        if (s == "-") break;
        cin >> m;
        for (int i = 0; i < m; ++i) {
            cin >> h;
            s = s.substr(h) + s.substr(0, h);
        }
        cout << s << endl;
    }
    return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s;
  cin >> s;
  int spe = 1;
  cin.ignore();
  for (int i = 1; i < n; i++){
    if(s[i] != s[i-1]) ++spe;
  }
  cout << spe << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int t[200005];
int main(){
  int n,T; cin >> n >> T;
  for(int i=0;i<n;++i) cin >> t[i];
  int ans=0;
  ans += T;
  for(int i=1;i<n;++i) ans += min(t[i]-t[i-1], T);
  cout << ans << endl;
  return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll L = TEN(9);

int main() {
	ll s; cin >> s;
	ll c = (s % L ? L - s % L : 0);
	printf("0 0 %lld 1 %lld %lld\n", L, c, (s + c) / L);
	return 0;
}

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
 
const int MAXN = 200200;
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;
 
template<typename T> inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}
 
template<typename T> inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}
 
template <typename T> inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}
 
int n, k;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
#define X first
#define Y second

int ans;
 
signed main() {
	read(n);
	for( ; n; n /= 10) ans += (n % 10 == 2);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from math import sqrt

def prime(ulim=10**5+10):
  cands = [2] + list(range(3, ulim, 2))
  primes = []
  while True:
    prime = cands.pop(0)
    primes.append(prime)
    if prime > sqrt(ulim):
      primes += cands
      break
    cands = [x for x in cands if x%prime != 0]
  return primes


if __name__=='__main__':
  x = int(input())
  for p in prime():
    if p >= x:
      print(p)
      break

Measured memory_bytes: 5364
from itertools import accumulate
HR_IN_DAY = 24; MIN_IN_HR = 60;  SEC_IN_MIN = 60

while True:
    n = int(input())
    if n == 0: break
    train = [0] * HR_IN_DAY * MIN_IN_HR * SEC_IN_MIN
    for i in range(n):
        depart, arrive = [t.split(':') for t in input().split(' ')]
        d_hr, d_min, d_sec = map(int, depart)
        a_hr, a_min, a_sec = map(int, arrive)
        train[d_hr * MIN_IN_HR * SEC_IN_MIN + d_min * SEC_IN_MIN + d_sec] += 1
        train[a_hr * MIN_IN_HR * SEC_IN_MIN + a_min * SEC_IN_MIN + a_sec] -= 1

    train = accumulate(train)
    print(max(train))


Measured memory_bytes: 6348
### constant

INF = 1 << 30
HP = 6

DXYS = [[1, 0], [0, -1], [-1, 0], [0, 1]]

### main

loop do
  w, h = gets.split.map(&:to_i)
  break if (w | h) == 0

  wh = w * h
  
  flds = wh.times.map{0}
  spt = gpt = nil
  pts = []
  
  for y in (0...h)
    line = gets.split.map(&:to_i)
    for x in (0...w)
      pt = y * w + x
      case line[x]
      when 0
        flds[pt] = -1
      when 2
        spt = pt
      when 3
        gpt = pt
      when 4
        pts << pt
      end
    end
  end
  pts.unshift(spt)
  pts << gpt

  pts.each_with_index{|pt, i| flds[pt] = i + 1}
  #p flds
  #p pts

  n = pts.length
  edges = n.times.map{n.times.map{nil}}
  nbrs = n.times.map{[]}
  
  pts.each_with_index do |pti, i|
    dists = wh.times.map{INF}
    dists[pti] = 0
    q = [pti]

    while ! q.empty?
      upt = q.shift

      ux = upt % w
      uy = upt / w
      nvd = dists[upt] + 1

      DXYS.each do |dx, dy|
        vx = ux + dx
        vy = uy + dy
        vpt = vy * w + vx
        if vx >= 0 && vx < w && vy >= 0 && vy < h && flds[vpt] >= 0
          vd = dists[vpt]
          if vd >= INF
            dists[vpt] = nvd
            if flds[vpt] > 0
              j = flds[vpt] - 1
              edges[i][j] = edges[j][i] = nvd
              nbrs[i] << j
              nbrs[j] << i
            end
            q << vpt if nvd < (HP - 1)
          end
        end
      end
    end
    #p dists
  end

  nbrs = (0...n).map{|i| nbrs[i].uniq.sort}
  #p edges
  #p nbrs

  times = n.times.map{INF}
  times[0] = 0
  q = [0]

  while ! q.empty?
    u = q.min{|a, b| times[a] <=> times[b]}
    q.delete(u)

    break if u == n - 1

    ut = times[u]
    
    for v in nbrs[u]
      nvt = ut + edges[u][v]
      vt = times[v]
      if vt > nvt
        q << v if vt >= INF
        times[v] = nvt
      end
    end
  end

  t = times[n - 1]
  puts (t >= INF) ? -1 : t
end

Measured memory_bytes: 6148
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define rfor(i,a,b)     for(ll i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

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

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

unordered_map<ll,ll> ma;
ll ans = 0;
void solve()
{
    int n; cin>>n;
    rep(i,1,n+1)
    {
        int x; cin>>x;
        if(ma.count(i-x)) ans+=ma[i-x];
        ma[i+x]++;
    }
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 11332
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

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

  int np = 0;
  for (char c : s) {
    if (c == 'p') np++;
  }
  cout << s.size() / 2 - np << endl;
}


Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10**6)

ans = []
while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    c = [list(map(int, input().split())) for _ in range(h)]
    s = [[0] * w for _ in range(h)]

    def dfs(x, y):
        s[y][x] = 1

        for dx in range(-1, 2, 1):
            for dy in range(-1, 2, 1):
                nx = x + dx
                ny = y + dy
                if 0 <= nx < w and 0 <= ny < h and c[ny][nx] == 1 and s[ny][nx] == 0:
                    dfs(nx, ny)

    res = 0
    for i in range(h):
        for j in range(w):
            if c[i][j] == 1 and s[i][j] == 0:
                dfs(j, i)
                res += 1
    ans.append(res)

for a in ans:
    print(a)



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

int main(){
    long long n,m,ans;
    cin >> n >> m;
    if(n*2 >= m){
        ans = (m - (m%2))/2;
    }
    else{
        ans = n + (m - n*2)/4;
    }

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

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    vector<ll> v;
    ll x;
    REP(i,3)cin>>x,v.pb(x);
    sort(ALL(v));
    cout<<abs(v[1] - v[0]) + abs(v[2] - v[1])<<endl;
}


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

int main() {
  int A,B;
  cin>>A;
  cin>>B;
  
  if(A==1&&B==2 || A==2&&B==1) {
    cout<<"3"<<endl;
  }
  
  else if(A==2&&B==3 ||A==3 && B==2) {
    cout<<"1"<<endl;
  }
  
  else {
    cout<<"2"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int n,A[20];

int solve(int p,int t){

  if(t-A[p]==0)return 1;
  else if(p<0||p>=n) return 0;
  else if(solve(p+1,t-A[p]))return 1;
  else if(solve(p+1,t)) return 1;

  return 0;
}


int main(){
  int i,q;
  int M;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M) == 1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


main(){
	double D;
	
	while(cin>>D){
		if(D==0)break;
		
		double px,py,vx,vy,d;
		
		cin>>px>>py>>vx>>vy;
		
		if(py*vx==vy*px){
			
			double nvx=sqrt(px*px+py*py)*vx/sqrt(vx*vx+vy*vy),nvy=sqrt(px*px+py*py)*vy/sqrt(vx*vx+vy*vy);
			
			if(abs(nvx-px)<EPS && abs(nvy-py)<EPS){
				d=2-sqrt(px*px+py*py);
			}else{
				d=sqrt(px*px+py*py);
			}
			
			
		}else{
			d=D+1;
		}
		
		if(d>D)puts("impossible");
		else printf("%.8lf\n",d);
	}
}

Measured memory_bytes: 0
// 2020 05 10
// B
#include <algorithm>
#include <complex>
#include <string>
#include <deque>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <queue>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    if(A >= K) {
        ans = K;
        cout << ans << endl;
        return 0;
    }
    if(A + B >= K) {
        ans = A;
        cout << ans << endl;
        return 0;
    }

    K = K - A - B;
    ans = A - K;
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

bool ask(int n) {
    cout << "? " << n << endl;
    char resp;
    cin >> resp;
    return resp == 'Y';
}
void answer(int n) {
    cout << "! " << n << endl;
}
signed main() {
    int num9 = 9999999999ll;
    int dig = 10;
    REP(i, 10) {
        if (!ask(num9)) {
            break;
        }
        dig--;
        num9 = num9 / 10;
    }
    dig++;

    int num1 = 1000000000ll;
    int dig2 = 10;
    REP(i, 10) {
        if (ask(num1)) {
            break;
        }
        dig2--;
        num1 /= 10;
    }
    
    dig = (dig2 == 10 ? dig : dig2);
    cerr << "dig = " << dig << endl;
 
    if (dig == 1) {
        REP(i, 9) {
          int tmp = (i + 1) * 10;
            if (ask(tmp)) {
                answer(i + 1);
                return 0;
            }
        }
    } else {
        int L = 1, R = 1;
        REP(i, dig - 1) R *= 10;
        L = R / 10;
        while (R - L > 1) {
            int M = (L + R) / 2;
            if (ask(M)) {
                L = M;
            } else {
                R = M;
            }
        }
        REP(i, 10) {
            int tmp = L * 100 + i * 10 + 0;
            if (ask(tmp)) {
                answer(tmp / 10);
                return 0;
            }
        }
        assert(false);
    }
    return (0^_^0);
}


Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0) ;
    cout.tie(0) ;
    int n ;
    cin >> n ;
    int flag = 0 ;
    while(n)
    {
        if(n % 10 == 7)
        {
            flag = 1 ;
            break ;
        }
        n = n / 10 ;
    }
    if(flag) cout << "Yes\n" ;
    else cout <<"No\n" ;

}


Measured memory_bytes: 3560
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a[3], k;
  cin >> a[0] >> a[1] >> a[2] >> k;
  sort(a, a + 3);
  for (int i = 0; i < k; i++) {
    a[2] *= 2;
  }
  cout << a[0] + a[1] + a[2] << endl;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int k;
		cin >> k;
		int n = (1 << k);
		vector<int> a(n, 0), b(n, 0);
		for(int i=0; i<n; i++)cin >> a[i];
		multiset<int> si(a.begin(), a.end());
		queue<pair<int, int>> q;
		q.push(make_pair(*prev(si.end()), k));
		si.erase(prev(si.end()));
		while(!q.empty()){
			auto f = q.front();
			q.pop();
			auto it = si.lower_bound(f.first);
			if(it == si.begin()){
				cout << "No\n";
				return;
			}
			it--;
			if(f.second != 1)q.push(make_pair(f.first, f.second-1));
			if(f.second != 1)q.push(make_pair(*it, f.second-1));
			si.erase(it);
		}
		cout << "Yes\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 15744
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;

using namespace std;

int main(){ 
    long long N;
    cin >> N;

    set<string> a;
    string S;

    for(int i = 0; i < N; ++i){
        cin >> S;
        a.insert(S);
    }

    cout << a.size();

}



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

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N),B(N),C(N);
  for(ll i=0;i<N;i++){
    cin >> A.at(i);
  }
  for(ll i=0;i<N;i++){
    cin >> B.at(i);
  }
  for(ll i=0;i<N;i++){
    cin >> C.at(i);
  }  
  
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  
  ll ans=0;
  /*
  for(ll i=0;i<N;i++){
    ll b = B.at(i);
    ans += (lower_bound(A.begin(),A.end(),b)-A.begin()) * (C.end() - upper_bound(C.begin(),C.end(),b));
  }
  */
  
  for(int i=0;i<N;i++){
    ans += (lower_bound(A.begin(), A.end(), B[i]) - A.begin())
        * (C.end() - upper_bound(C.begin(), C.end(), B[i]));
  }  

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
	string s; cin >> s;
	int n = s.size();
	bool f = true;
	if (s[0] == '0') f = false;
	if (s[n-1] == '1') f = false;
	for (int i = 0; i < n-1; ++i) {
		if (s[i] != s[n - 2 - i]) f = false;
	}

	if (!f) {
		cout << -1 << endl;
		return 0;
	}

	int now = 1;
	for (int i = 1; i < n; ++i) {
		cout << now << " " << i+1 << endl;
		if (s[i-1] == '1')now = i+1;
	}

	return 0;
}

Measured memory_bytes: 1664