akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,a,b) for(ll i=a;i <= b;i++)
#define rep(i,n) for(ll i=0;i < n;i++)
#define fast_io ios_base::sync_with_stdio(0);
#define accuracy  ll precision = numeric_limits<double>::digits10;
#define double long double
#define eps 1e-6

bool check(double test) {
	ll integ = test;
	double frac = test - integ;
	if(frac < eps) {
		if(integ % 2 == 1) return true;
	}
	else if(frac > 1-eps) {
		if(integ % 2 == 0) return true;
	}
	return false;
}

ll myFn(ll a,ll b,ll c) {
	ll ans = 0;
	double temp1 = (a+b+c)*1.0/3;
	double temp2 = (b+c-2*a)*1.0/3;
	bool pos = false;
	while(ans < 100) {
		double temp;
		if(ans != 0) temp2 /= 2;
		if(ans % 2 == 0) temp = temp1 - temp2;
		else temp = temp1 + temp2;
		if(check(temp)) {
			pos = true;
			break;
		}
		ans++;
	}
	if(pos) return ans;
	else return LLONG_MAX;
}

int main() {
	fast_io; 
	accuracy;
	ll a,b,c; cin >> a >> b >> c;
	ll ans = LLONG_MAX; 
	ans = min(ans,myFn(a,b,c));
	ans = min(ans,myFn(b,c,a));
	ans = min(ans,myFn(c,a,b));
	if(ans != LLONG_MAX) cout << ans << endl;
	else cout << -1 << endl;
}

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

int power(int a, int n){
	if(n == 0){
		return 1;
	}
	else{
		return a * power(a, n - 1);
	}
}

int main(){
	int N, i, odd = 1;
	scanf("%d", &N);
	int *A = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	for(i = 0; i < N; i++){
		if(A[i] % 2 == 0){
			odd *= 2;
		}
	}
	printf("%d\n", power(3, N) - odd);
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n+1);
    vector<ll> b(n);

    rep(i,n+1){
        cin >> a.at(i);
    }
    rep(i, n){
        cin >> b.at(i);
    }
    ll ans=0;

    rep(i,n){
        ll minab = min(a.at(i), b.at(i));
        ans+=minab;
        b.at(i)-=minab;
        a.at(i)-=minab;

        minab= min(a.at(i+1), b.at(i));
        ans+=minab;
        b.at(i)-=minab;
        a.at(i+1)-=minab;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
static const int size = 33000;
bool IsPrime[size];
vector<int> Prime;

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	for(int i = 2; i < size; ++i)
	{
		if(IsPrime[i])
		{
			for(int j = 2 * i; j < size; j += i)
			{
				IsPrime[j] = false;
			}
			Prime.push_back(i);
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		int size1 = Prime.size();
		for(int i = 0; i < size1; ++i)
		{
			if(Prime[i] > n)
			{
				break;
			}
			for(int j = i; j < size1; ++j)
			{
				if(Prime[i] + Prime[j] == n)
				{
					count++;
				}
				if(Prime[i] + Prime[j] > n)
				{
					break;
				}
			}
		}
		cout << count << endl;
	}
}

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

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;


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

    REP(i, s.size()) {
        int tmp = s[i] - 'A';
        tmp += n;
        tmp %= 26;
        printf("%c", 'A'+tmp);
    }  
    cout << endl;  

    return 0;
}


Measured memory_bytes: 256
s=input()
a=[str(c) for c in s]
if len(a)%2!=0:
    print("No")
    exit()
for i in range(len(a)):
    if i%2==1:
        if a[i]!="i":
            print("No")
            exit()
    else:
        if a[i]!="h":
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 2940
a = 0
b = 0
k = 0
for i in range(6):
  t = int(input())
  if(i == 0):
    a = t
  elif(i == 4):
    b = t
  elif(i == 5):
    k = t

print(':(') if(b - a > k) else print('Yay!')

Measured memory_bytes: 3060
N, T = map(int, input().split())
Push = [int(i) for i in input().split()]
Total = T

if N >= 2:
    for i in range(1, N):
        if Push[i] >= Push[i-1] + T:
            Total += T
        else:
            Total += Push[i] - Push[i-1]

print(Total)

Measured memory_bytes: 25196
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

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

		if (A + B + C >= 22) {
			cout << "bust" << endl;
		}

		else {
			cout << "win" << endl;
		}

		
	}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;

int n;
ll k,a[202020];
ll st=-2e18,en=2e18;

ll func(ll mid){
    ll cnt = 0;
    for(int i = 0;i < n;i++){
        if(a[i] < 0){
            int l = i,r = n;
            while(l+1 != r){
                int m = (l+r)/2;
                if(a[i]*a[m] <= mid)r = m;
                else l = m;
            }
            cnt += n - r;
        }else{
            int l = i,r = n;
            while(l+1 != r){
                int m = (l + r)/2;
                if(a[i]*a[m] <= mid)l = m;
                else r = m;
            }
            cnt += l - i;
        }

    }
    return cnt;
}
int main() {
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    while(st+1!=en) {
        ll mid = (st + en)/2;
        ll cnt = func(mid);
        if(cnt < k)st = mid;
        else en = mid;
    }
    cout << en << '\n';
    return 0;
}


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

class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		//一行目をインプット
		int n = scan.nextInt();
		int[] S = new int[n];
		for (int i=0; i<n; i++) {
			S[i] = scan.nextInt();
		}

		//二行目をインプット
		int q = scan.nextInt();
		int[] T = new int[q];
		for (int i=0; i<q; i++) {
			T[i] = scan.nextInt();
		}

		Arrays.sort(S);
		Arrays.sort(T);
		int count =0;

		if(n < q){

			for(int i = 0; i < n;i++){
				for(int j = 0;j < q;j++){
					if(S[i] == T[j]){
						count++;
						break;
					}
				}
			}
		}

		if(q < n){
			for(int i = 0; i < q;i++){
				for(int j = 0;j < n;j++){
					if(S[j] == T[i]){
						count++;
						break;
					}
				}
			}
		}

		System.out.println(count);
	}
}



Measured memory_bytes: 67700
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

M = int(10**9)+7
n,k = [int(c) for c in input().split()]
nums = [0]*(k+1)
# nums = np.zeros((k+1), dtype=int)
for i in range(k, 0, -1):
    tmp = pow(k // i, n, M)
    tmp -= sum(nums[(2*i)::i])
    nums[i] += tmp
    
print(sum((i)*nums[i]%M for i in range(len(nums)))%M)
# print((np.arange(k+1) * nums).sum()%M)

Measured memory_bytes: 69952
a,b = map(int,input().split())
c = 0
if a == 1 and b == 1:
  c += 400000
if a == 3:
  c += 100000
if a == 2:
  c += 200000
if a == 1:
  c += 300000
if b == 3:
  c += 100000
if b == 2:
  c += 200000
if b == 1:
  c += 300000
print(c)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  char wed[7];
  scanf("%s", &wed[0]);
  if (wed[0] == 'S') {
    printf("Cloudy");
  } else {
    if (wed[0] == 'C') {
      printf("Rainy");
    } else {
      printf("Sunny");
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<deque>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
//#define __int64 long long
#define P pair<int,int>
int a,b,c,d;

int main(){
	cin>>a>>b>>c>>d;
	int ans=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+50*k==d)ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

#define forn(l, r) for(int i = l; i < (r); ++i)
#define forj(l, r) for(int j = l; j < (r); ++j)
#define TAM 1000100
#define SYNC ios::sync_with_stdio(0);
#define $ << ' ' <<
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 112345;
const ll mod = 1000000007;



int main() {
    //SYNC
    int a, p;
    cin >> a >> p;
    int ans = 3*a+p >> 1;
    cout << ans << endl;
    return 0;
}

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

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<n;i++)
#define REP1(i,n) for(long long i=1;i<=n;i++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();ite++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<a<<endl;
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

//---------------------
#define MAXN 5000
//---------------------

ll dp[4][MAXN+1];
ll **dp2=nullptr;
ll n,ga,gb,sa,sb,ba,bb;
ll v[4],w[4];
int main(){
	cin>>n>>ga>>sa>>ba>>gb>>sb>>bb;
	ZERO(dp);
	v[1]=ga,v[2]=sa,v[3]=ba;
	w[1]=gb-ga,w[2]=sb-sa,w[3]=bb-ba;
	REP1(i,3){
		if(w[i]<=0) v[i]=INF_LL;
	}
	REP1(i,3){
		REP(j,n+1){
		  	
		  	if(j-v[i]>=0)
			dp[i][j]=max(dp[i-1][j],dp[i][j-v[i]]+w[i]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	ll curdong=dp[3][n]+n;
	ZERO(v);ZERO(w);
	dp2=new ll*[4];
	REP(i,4) dp2[i] = new ll[curdong+1];
	v[1]=gb,v[2]=sb,v[3]=bb;
	w[1]=ga-gb,w[2]=sa-sb,w[3]=ba-bb;
	REP1(i,3){
		if(w[i]<=0){
			v[i]=INF_LL;
		}
	}
	
	REP1(i,3){
		REP(j,curdong+1){
		  	if(j-v[i]>=0)
			dp2[i][j]=max(dp2[i-1][j],dp2[i][j-v[i]]+w[i]);
			else dp2[i][j]=dp2[i-1][j];
		}
	}
	cout<<dp2[3][curdong]+curdong<<endl;
	REP(i,4) delete[] dp2[i];
	delete[] dp2;
	return 0;
}

Measured memory_bytes: 586368
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
	
	ll n, i, j, k, t = 0;
	cin >> n;
	vll st(n);
	for (i = 0; i < n; i++)
		cin >> st[i];
	
	sort(st.begin(), st.end());
	
	for (i = 0; i < n-2; i++) {
		for (j = i+1; j < n-1; j++) {
			for (k = j+1; k < n; k++) {
				if (st[k] > abs(st[i]-st[j]) and st[k] < st[i]+st[j] and
					st[i] != st[j] and st[j] != st[k] and st[i] != st[k])
					t++;
			}
		}
	}
	
	cout << t << "\n";
	
	return 0;
}


Measured memory_bytes: 3648
//Cookie Exchanges

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
using ll = long long;
#define range(a) (a).begin(),(a).end()


int main (){
    int A,B,C,Ans=0;cin>>A>>B>>C;
    for(Ans =0;A%2!=1&&B%2!=1&&C%2!=1;){
        if(A==B&&B==C){Ans = -1;break;}
        Ans++;
        int a=A, b=B, c=C;
        if((A+B)%2!=0)break;
        else C = (a+b) / 2;
        if((B+C)%2!=0)break;
        else A = (b+c) / 2;
        if((C+A)%2!=0)break;
        else B = (c+a) / 2;
    }
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

char A[101], B[101];
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B;

  int sa = strlen(A);
  int sb = strlen(B);

  if (sa > sb) {
    cout << "GREATER" << endl;
    return 0;
  } else if (sa < sb) {
    cout << "LESS" << endl;
    return 0;
  } else {
    for (int i = 0; i < sa; i++) {
      if (A[i] > B[i]) {
        cout << "GREATER" << endl;
        return 0;
      } else if (A[i] < B[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++)
#define rep_(d,a,n)  for(int d=a;d>=n;d--)
#define nl        "\n" 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;

void fun(){
    string a,s;
    cin>>a>>s;int len=a.length();int ans=0;
    rep(i,0,len-1){
        if(a[i]!=s[i]){
            ans++;
        }
    }
    cout<<ans;
}
int32_t main()
{
   
    fast_io;
    fun();
    
    return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n;
	cin >> n;
	int arr[n];
	REP(i, 0, n) cin >> arr[i];
	int ans = arr[0];
	REP(i, 1, n){
		if(arr[i] > arr[i-1]) ans+= arr[i]-arr[i-1];
	}
	cout << ans;

}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	if (s.length()<=n){
		cout << s << endl;
	}else{
	    for (int i=0; i<n; i++){
	    	cout << s[i];
	    }cout <<"..." << endl;
	}
}

Measured memory_bytes: 3624
N,M=map(int,input().split())
*H,=map(int,input().split())
J=[[0,0]]*M
i=0
while i<M:
    J[i]=list(map(int,input().split()))
    i+=1
ans=set(range(1,N+1))

for a,b in J:
    if H[a-1]>H[b-1]:
        ans-={b}
    elif H[a-1]<H[b-1]:
        ans-={a}
    else:
        ans-={a,b}

print(len(ans))

Measured memory_bytes: 40408
#include <bits/stdc++.h>
using namespace std;
int cnt[4]={};
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		cnt[s[i]-'a']++;
	}
	sort(cnt, cnt+3);
	if(cnt[2] - cnt[1] > 1 || cnt[1] - cnt[0] > 1 || cnt[2]-cnt[0] > 1)cout <<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

ll g[65536];
vector<int> B[65536];
ll a[16][16];
ll d[65536];
int n;

int main(){
    fio;
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int b = 0; b < (1<<n); b++){
        vector<int> V;
        for(int j = 0; j < n; j++){
            if(b >> j & 1){
                for(int u : V) g[b] += a[u][j];
                V.push_back(j);
                B[b].push_back(1<<j);
            }
        }
    }
    for(int b = 1; b < (1<<n); b++){
        d[b] = LLONG_MIN;
        int k = B[b].size();
        for(int c = 0; c < (1<<k)-1; c++){
            int mask = 0;
            for(int j = 0; j < k; j++){
                if(c >> j & 1) mask |= B[b][j];
            }
            d[b] = max(d[b], d[mask] + g[b^mask]);
        }
    }
    cout << d[(1<<n)-1] << '\n';
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 100010;
struct edge {
  int la,b;
} con[N << 1];
int tot, fir[N];
void add_edge(int from,int to) {
  con[++tot] = (edge) {fir[from], to};
  fir[from] = tot;
}
int n, m, deg[N], en, st, num;
void dfs(int pos,int fa) {
  if (pos == en) {
    ++ num;
    return;
  }
  for (int i = fir[pos]; i; i = con[i].la) {
    if (con[i].b == fa) continue;
    if (con[i].b == st) continue;
    dfs(con[i].b, pos);
  }
}
int main() {
  int x,y;
  read(n), read(m);
  rep (i, 1, m) {
    read(x), read(y);
    add_edge(x, y);
    add_edge(y, x);
    ++ deg[x], ++ deg[y];
  }
  rep (i, 1, n) if (deg[i] % 2 == 1) {
    puts("No");
    return 0;
  }
  rep (i, 1, n) if (deg[i] >= 6) {
    puts("Yes");
    return 0;
  }
  int num = 0;
  rep (i, 1, n) if (deg[i] >= 4) ++ num;
  if (num >= 3) return puts("Yes"), 0;
  if (num <= 1) return puts("No"), 0;
  int px = 0, py = 0;
  rep (i, 1, n) if (deg[i] == 4) {
    if (!px) px = i;
    else py = i;
  }
  en = py;
  st = px;
  dfs(px, 0);
  if (::num == 4) puts("No");
  else puts("Yes");
  return 0;
}


Measured memory_bytes: 3328
n = int(input())
A = [0] + [*map(int, input().split())] + [0]
dp_yen = [0]*(n+1)
dp_yen[1] = 1000
for day in range(1, n):
    stock = 0
    if A[day] > 0: stock = dp_yen[day] // A[day]
    remain = dp_yen[day] - stock*A[day]
    dp_yen[day+1] = max(dp_yen[day], remain + stock * A[day+1])
print(dp_yen[n])


Measured memory_bytes: 9108
class UnionFind
  def initialize(n)
    @root = Array.new(n)
    @rank = Array.new(n)
    @size = Array.new(n)
    (0...n).each do |i|
      @root[i] = i
      @rank[i] = 0
      @size[i] = 1
    end
  end

  def find(x)
    if @root[x] == x
      x
    else
      @root[x] = find(@root[x])
    end
  end

  def unite(x, y)
    x_root = find(x)
    y_root = find(y)
    return if x_root == y_root

    if @rank[x_root] < @rank[y_root]
      @root[x_root] = y_root
      @size[y_root] += @size[x_root]
    else
      @root[y_root] = x_root
      @size[x_root] += @size[y_root]
      if @rank[x_root] == @rank[y_root]
        @rank[x_root] += 1
      end
    end
    nil
  end

  def size(x)
    x_root = find(x)
    @size[x_root]
  end

  def same?(x, y)
    find(x) == find(y)
  end
end

N, K, L = gets.split.map(&:to_i)

P = K.times.map { gets.split.map(&:to_i) }
R = L.times.map { gets.split.map(&:to_i) }

uf1 = UnionFind.new(N)
P.each do |a, b|
  a -= 1
  b -= 1
  uf1.unite(a, b)
end
uf2 = UnionFind.new(N)
R.each do |a, b|
  a -= 1
  b -= 1
  uf2.unite(a, b)
end

count_table = Hash.new { 0 }
N.times do |n|
  a = uf1.find(n)
  b = uf2.find(n)
  count_table[[a, b]] += 1
end
ans = N.times.map do |n|
  a = uf1.find(n)
  b = uf2.find(n)
  count_table[[a, b]]
end.join(' ')
puts ans

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)	
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

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

	int x, y, z;

	cin >> x >> y >> z;

	int tmp = 0;

	tmp = x;
	x = y;
	y = tmp;

	tmp = x;
	x = z;
	z = tmp;

	cout << x << " " << y << " " << z << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  for(int i=0;i<n;i++) scanf("%d",&a[i]);
  int count=0;
  for(int i=0;i<n-1;i++){
    for(int j=0;j<n-i-1;j++){
      if(a[j]>a[j+1]){
	count++;
	int temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i+1==n) printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 3216
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
n = I()
S = LI()
q = I()
T = LI()
ans = 0
def is_ok(i):
    return x>=S[i]
def binarysearch(x):
    ok,ng = -1,n
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return S[max(ok,0)]
for x in T:
    if x==binarysearch(x):
        ans += 1
print(ans)


Measured memory_bytes: 16712
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>

using namespace std;


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

    vector<double> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    for (int i = 0; i < N-1; i++){
        //昇順ソート
        sort(v.begin(),v.end());

        //最初の２つを取得し要素削除
        double a = v[0];
        double b = v[1];
        v.erase(v.begin()+1);
        v.erase(v.begin());
        v.push_back( (a + b ) / 2 ); 
    }

    cout << v[0] << endl;

    return 0;
}


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

int main(){
    int A,B;
    cin >> A >> B;
    int socket=A;
    int ans;
    if(B==1){
        ans=0;
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<25;i++){
        if(socket>=B){
            ans=i+1;
            break;
        }
        socket+=(A-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res)
{
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			while (n % i == 0)
			{
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	int N, A, B;
	cin >> N >> A >> B;
	vector<int> X(N);

	int ans=0;

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

	for (int i = 1; i < N; i++) {
		ans += min(A * (X[i] - X[i - 1]), B);
	}

	cout << ans << endl;

	return 0;
}

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

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

long long lcm(long long a, long long b)  
{  
    return (a * b) / gcd(a, b);  
}  

int main()
{
    // input
    int A, B;
    cin >> A >> B;

    // the answer is LCM of A and B
    cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<complex>
#include<string>
#include<cstring>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 100000000
#define debug(x) cout<<#x<<": "<<x<<endl

#define all(x) x.begin(),x.end()
typedef pair<long long,long long> P;
typedef pair<long long,P> PP;
long long n,c,k;
long long input;
long long s;
long long ans;
long long flag;//s exist 1
vector<long long> hai;
int main()
{
	cin>>n>>c>>k;
	rep(i,n)
	{
		cin>>input;
		hai.push_back(input);
	}
	sort(all(hai));
	rep(i,n)
	{
		if(flag==0)
		{
			s=i;
			flag=1;
		}
		else
		{
			if(hai[s]+k<hai[i]||s+c<=i)
			{
				ans++;
				s=i;
			}
		}
	}
	cout<<ans+1<<endl;
	return 0;
}

Measured memory_bytes: 1400
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vl A(N);
    rep(i,N){
        cin >> A[i];
    }
    vector<bool> dp(K+1);
    dp[0]=0;
    rep(i,K){
        rep(j,N){
            if(i+1-A[j]>=0&&dp[i+1-A[j]]==0)dp[i+1]=1;
        }
    }
    cout << (dp[K]?"First":"Second") << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;

#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define vi vector<int>
#define pii pair<int,int>
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define MAX 500005
#define initialize(arr,elem) memset(arr,elem,sizeof(arr))

typedef long long ll;
// typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int memo[MAX], arr[MAX];
int k = 2;
int solve(int i){
	if (memo[i] !=-1) return memo[i];
	if (i==1) return memo[i] = 0;
	int dp = 100000000000000;
	for (int j =i-1; j>=i-k && j>0;j--){
		dp = min(dp,solve(j) + abs(arr[i]-arr[j]));
	}
	return memo[i] = dp;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
		
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int n;
	cin>>n;
	initialize(memo,-1);
	For(i,1,n+1) cin>>arr[i];
	cout<<solve(n)<<endl;
	// For(i,1,3) cout<<memo[i]<<" ";



	return 0;
}


Measured memory_bytes: 9984
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var MaxN int

func main() {
	sc := NewScanner()

	MaxN = Pow(10, 12)

	n := sc.ReadInt()

	ans := 0
	primeCounts := PrimeFactorize(n)
	for _, count := range primeCounts {
		ans += f(count)
	}

	fmt.Println(ans)
}

func f(n int) int {
	switch {
	case n < 1:
		return 0
	case n < 3:
		return 1
	case n < 6:
		return 2
	case n < 10:
		return 3
	case n < 15:
		return 4
	case n < 21:
		return 5
	case n < 28:
		return 6
	case n < 36:
		return 7
	case n < 45:
		return 8
	}
	return -1
}

func PrimeFactorize(n int) map[int]int {
	primeCounts := make(map[int]int)

	sqrtMax := int(math.Sqrt(float64(MaxN)))

	for n%2 == 0 {
		primeCounts[2]++
		n /= 2
	}
	for n%3 == 0 {
		primeCounts[3]++
		n /= 3
	}

	flag := true
	for i := 5; n > 1 && i <= sqrtMax; {
		for n%i == 0 {
			primeCounts[i]++
			n /= i
		}

		if flag {
			i += 2
		} else {
			i += 4
		}
		flag = !flag
	}

	if n > 1 {
		primeCounts[n]++
	}

	return primeCounts
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// *   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int d(int n)
{
    int res = 0;
    while (n > 0)
    {
        res += n % 10; 
        n /= 10;
    }
    return res;
}

void solve()
{
    int N, A, B; cin >> N >> A >> B;
    int ans = 0;
    REP1(i, N)
    {
        int e = d(i);
        if(A <= e && e <= B) ans += i;
    }
    cout << ans << endl;
}

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

    solve();

    return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define max_heap priority_queue <int> pq; // max heap 
#define min_heap priority_queue <int, vector<int>, greater<int> > pq;  //min heap
#define make_pairVector vector<pair<long long int,long long int> > pairVector // vector of pairs
#define hashmap unordered_map<long long int, long long int>hashmap;
#define pb push_back


//map<pair<ll,ll>, ll > hash;          // pair,value hashmap where key is a pair
//hash[make_pair(i,j)] = 0;
//if(hash.find(make_pair(i,j)) == hash.end())


//map<ll,ll>::iterator itr;           // iterating a map
//for (itr = hash.begin();itr != hash.end(); itr++)
//{
//   itr->first = key  
//   itr->second = value
//}


// vector<string> v; //to convert vector to a set
// set<string> s(v.begin(), v.end());


// set<string>s;     // to convert set to a vector
// vector<string> v(s.begin(),s.end());


// cin >> x >> y;
// pairVector.pb(mp(x,y));


// string size = str.size()


// stack <int> s; 


// queue <int> gquiz; 


// __gcd(m, n) 

// ll arr[10e5 + 5];


// char arr[10e5 + 5];


// printf ("%.9f\n",x);


bool sortbysec(const pair<long long int,long long int> &a, const pair<long long int,long long int> &b) 
{ 
    return (a.second < b.second); 
}
bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
int check_key(map<long long int, long long int> m, long long int key) 
{ 
    // Key is not present 
    if (m.find(key) == m.end()) 
        return 0; 
  
    return 1; 
} 

void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}

int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    ll arr[n+4] = {0};
    ll maxnum = -1;
    for(ll i = 1; i<=n; i++)
    {
        cin >> arr[i];
        maxnum = max(maxnum,arr[i]);
    }
    sort(arr,arr+n+1);
    ll prime[maxnum+5] = {0};
    ll mul;
    for(ll i = 1; i<=n; i++)
    {
        mul = 2;
        if(prime[arr[i]] == 0)
        {
            if(i != n)
            {
                if(arr[i] == arr[i+1])
                    mul = 1;
            }
            ll temp = arr[i];
            for(ll j = mul * temp; j <= maxnum; j += temp)
            {
                prime[j] = 1;
            }
        }
    }
    ll c = 0;
    for(ll i = 1; i<=n; i++)
    {
        if(prime[arr[i]] == 0)
        {
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}   

Measured memory_bytes: 12976
#include<bits/stdc++.h>
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

ll D;
ll p[30];
ll get1[400],get2[400];

ll dfs(int pos,int num,ll val){
    ll s=0;
    //if(num==4&&pos==3)cout<<val<<endl;
   // if(pos==2&&num==4)puts("who");
    for(int i=pos;i<=num/2;i++){
        s+=p[num-i]-p[i-1];
    }
    if(val+9*s<D||val-9*s>D)return 0;
    if(pos==num/2+1)return val==D;
    ll cnt=0;
    for(int i=-9;i<=9;i++){
        //if(pos==2&&num==4&&i==1)cout<<get1[20]<<endl;
        if(pos==1){
            cnt+=dfs(pos+1,num,val+i*(p[num-pos]-p[pos-1]))*get2[i+20];
        }
        else{
            //if(pos==2&&num==4)cout<<val+i*(p[num-pos]-p[pos-1])<<endl;
            cnt+=dfs(pos+1,num,val+i*(p[num-pos]-p[pos-1]))*get1[i+20];
        }
    }
    return cnt;
}

int main(){
    p[0]=1;FOR(i,1,19)p[i]=p[i-1]*10;
    cin>>D;
    ll ans=0;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            get1[i-j+20]++;
        }
    }
    for(int i=0;i<=9;i++){
        for(int j=1;j<=9;j++){
            get2[i-j+20]++;
        }
    }
    for(int i=2;i<=20;i++){
        if(i&1)ans+=dfs(1,i,0)*10;
        else ans+=dfs(1,i,0);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict


def main():
    H, W, N = map(int, input().split())
    cnt = defaultdict(lambda: defaultdict(lambda: 0))
    ans = [0] * 10
    ans[0] = (H-2)*(W-2)
    for _ in range(N):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        for i in range(a-1, a+2):
            for j in range(b-1, b+2):
                if i < 1 or H-1 <= i or j < 1 or W-1 <= j:
                    continue
                c = cnt[i][j]
                ans[c] -= 1
                ans[c+1] += 1
                cnt[i][j] = c+1
    for a in ans:
        print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 190444
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# N = int(readline())
# SP = [(x.split()[0].decode('utf8'), int(x.split()[1])) for x in readlines()]
# SPs = sorted((name, -pt, i + 1) for i, (name, pt) in enumerate(SP))
# print('\n'.join(str(a[2]) for a in SPs))

R, D, X = map(int, readline().split())
xl = []
for _ in range(10):
    X = R * X - D
    xl.append(X)

print('\n'.join(str(x) for x in xl))


Measured memory_bytes: 12500
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#define FOR(i, a, b) for (i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define For(i, N) for (i = 0; i < N; ++i)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define make(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << endl;
}

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = 2 * a[2] - a[0] - a[1];
	say(ans % 2 == 0 ? ans / 2 : (ans + 3) / 2);
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,q;
	while(cin>>n>>q,n){
		int ans=0,num=0,a,m,d[100]={};
		for(int i=0;i<n;i++){
			cin>>m;
			for(int j=0;j<m;j++){
				cin>>a;
				d[a]++;
			}
		}
		for(int i=0;i<100;i++){
			if(d[i]>=q && d[i]>num){
				ans=i;
				num=d[i];
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from collections import Counter

n=int(input())
INF = 10**20

d={}
for i in range(97,123):
  d[chr(i)] = INF

for i in range(n):
  s = input()
  c = Counter(s)
  for k in d.keys():
    if c.get(k):
      d[k] = min(c[k],d[k])
    else:
      d[k] = 0
    
keys=list(d.keys())
for k in keys:
  if d[k] == INF:
    del d[k]
    
ans = []
for k in d.keys():
  ans.extend([k]*d[k])
  
if len(ans)==0:
  print('')
  exit()
  
ans = sorted(ans)
print(''.join(ans))

Measured memory_bytes: 9440
#include <algorithm>
#include <iostream>
#include <utility>
#include <functional>
#include <map>
#include <vector>
#include <string>

using namespace std;

int
main() {
  int n,m;
  do {
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    vector<pair<int, int> > dp;
    for (int i=0;i<n; ++i) {
      int dx, px;
      cin >> dx >> px;
      dp.push_back(make_pair(dx, px) );
    }

    // calc
    sort(dp.begin(), dp.end(), [](pair<int,int> x, pair<int,int> y ) {
	return x.second > y.second;
      }
      );
    /*
    for (auto & x: dp) {
      cout << x.first << " " << x.second << endl;
    }
    cout << endl;
    */
    
    auto s { m };
    auto ans { 0 };
    {
      int i=0;
      for (; i<dp.size(); ++i) {
	auto dpeek = dp[i].first;
	if (s - dpeek <= 0) break;
      
	s -= dp[i].first;
      }
      
      int rest = s;
      dp[i].first -= rest;
      
      for (; i<dp.size(); ++i) {
	ans += dp[i].first * dp[i].second;
      }
    }
    
    // output
    cout << ans << endl;
  } while (true);
    
  return 0;
}

#if 0
Local Variables:
quickrun-option-cmd-alist: ((:command . "clang++")
			    (:exec    . ("%c -std=c++11 -o %n %s -Wall -D__MAIN__"
					 "%n "))
                            (:remove  . ("%n")))
  End:
#endif

Measured memory_bytes: 3100
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	if a < b && b < c {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}



Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    double s = (double)w * h / 2.0;
    cout << fixed << setprecision(15) << s << " " << (w % 2 == 0 && h % 2 == 0 && w/2 == x && h/2 == y) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ge(a, b) get<(b)>((a))
#define SZ(x) (x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
const int xd[4] = {0, 1, 0, -1}, yd[4] = {1, 0, -1, 0};
template <typename t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <typename t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}

int main() {
    ios_base::sync_with_stdio(0);
    cout.tie(0);

    double a;
    cin >> a;
    cout << fixed << setprecision(9) << 2.0 * a * M_PI << endl;

    return 0;
}


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

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

    char a[n][n];
    char b[m][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
            cin >> b[i][j];
        }
    }

    int ans = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(j + m - 1 >= n || i + m - 1 >= n){
                continue;
            }

            int flag = 0;

            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(a[i + k][j + l] != b[k][l]){
                        flag = 1;
                    }
                }
            }

            if(flag == 0){
                ans = 1;
            }
        }
    }

    if(ans == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int n,m;
	cin>>n;
	string s;
	set<string>u;
	for(int i=0;i<n;i++){
		cin>>s;
		u.insert(s);
	}
	cin>>m;
	int parity=0;
	for(int i=0;i<m;i++){
		cin>>s;
		if(u.count(s)==0)cout<<"Unknown"<<" "<<s<<endl;
		else{
			if(parity==0){
				cout<<"Opened by"<<" "<<s<<endl;
				parity=1;
			}
			else{
				cout<<"Closed by"<<" "<<s<<endl;
				parity=0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 3244
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    vector<int> solve(int m, int k) {
        int N = 1 << (m + 1);
        int M = 1 << m;
        if (k >= M) {
            return {};
        }

        vector<int> res;
        if (k == 0) {
            for (int i = 0; i < M; ++i) {
                res.push_back(i);
                res.push_back(i);
            }
            return res;
        }

        int a = 0, b = 0;
        for (int i = 1; i < M; ++i) {
            if (i == k) {
                continue;
            }
            if ((i ^ k) < M && (i ^ k) > 0) {
                a = i;
                b = i ^ k;
                break;
            }
        }

        if (a == 0 || b == 0) {
            return {};
        }

        vector<bool> used(M, false);

        used[a] = used[b] = used[k] = true;
        deque<int> que;
        for (auto x : {a, b}) {
            que.push_back(x);
        }

        for (int i = 0; i < M; ++i) {
            if (!used[i]) {
                que.push_back(i);
                que.push_front(i);
            }
        }
        que.push_back(k);
        que.push_front(k);
        que.push_back(b);
        que.push_back(a);

        for (auto x : que) {
            res.push_back(x);
        }
        return res;
    }
};

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

    int m, k;
    cin >> m >> k;
    Solution sol;
    auto res = sol.solve(m, k);
    if (res.empty()) {
        cout << -1 << '\n';
    } else {
        int n = res.size();
        for (int i = 0; i < n; ++i) {
            cout << res[i] << (i == n - 1 ? '\n' : ' ');
        }
    }

    return 0;
}

Measured memory_bytes: 3008