akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	int A[20], B[20], C[20];
	cin >> n;
	rep(i, n)cin >> A[i];
	rep(i, n)cin >> B[i];
	rep(i, n - 1)cin >> C[i];

	int prev = -100;
	int ans = 0;
	rep(i,n) {
		int cur = A[i] - 1;
		ans += B[cur];
		if (prev + 1 == cur)ans += C[prev];

		prev = cur;
	}
	cout << ans << endl;



	return 0;
}

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


int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int A[M];
  for(int i = 0; i < M; i++) cin >> A[i];
  int sum0 = 0;
  int sumM = 0;
  if(X+1 == M || X-1 == 0){
    cout << 0 << endl;
    return 0;
  }
  for(int i = 0; i < M; i++){
    if(A[i]<X) sum0++;
    else sumM++;
  }
  cout << min(sum0, sumM) << endl; 
}


Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
void minimize(int * N, int digit, int min){
    int i;
    for(i = 0; i <= digit; i++){
        N[i] = min;
    }
}

void calc(int * N, int K, int * D, int digit, int digit_max, int * moveup, int min, int max){
    if(digit > 0 && N[digit] <= max) calc(N, K, D, digit-1, digit_max, moveup, min, max);
    N[digit] += *moveup;
    if(digit == digit_max && N[digit] == 0) return;
    *moveup = 0;
    if(N[digit] == 10){
        *moveup = 1;
        return;
    }

    while(1){
        int D_loop = 0;
        for(; D_loop < K; D_loop++){
            if(N[digit] == D[D_loop]) break;
        }
        if(D_loop == K) return;
        
        N[digit]++;
        minimize(N, digit-1, min);
        if(N[digit] == 10){
            *moveup = 1;
            N[digit] = min;
            return;
        }
    }
}


int main(void){
    int N_orig;
    int N_q = -1;
    int N[5] = {0, 0, 0, 0, 0};
    int K;
    int D[9] = {};
    int i;
    int min = 0;
    int max = 9;
    int N_ans = 0;
    
    scanf("%d %d", &N_orig, &K);
    for(i = 0; i < K; i++) scanf("%d", &D[i]);
    
    for(i = 0; i < K; i++){
        if(D[i] == min) min++;
        if(D[K-(i+1)] == max) max--;
    }
    
    N_q = N_orig;
    for(i = 0; N_q != 0; i++){
        N[i] = N_q % 10;
        N_q /= 10;
    }
    
    int moveup = 0;
    calc(N, K, D, i, i, &moveup, min, max);
    
    for(i = 4; i >= 0; i--){
        N_ans *= 10;
        N_ans += N[i];
    }
    printf("%d", N_ans);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0 && m == 0) {
				break;
			}

			int a[] = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}

			int max = -1;
			for (int i = 0; i < n; i++) {
				for (int j = i + 1; j < n; j++) {
					if (a[i] + a[j] <= m) {
						max = Math.max(max, a[i] + a[j]);
					}
				}
			}
			if (max == -1) {
				System.out.println("NONE");
			} else {
				System.out.println(max);
			}
		}

	}
}


Measured memory_bytes: 51168
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, a;

int main(){
	cin >> n;
	ll ans = 0;
	ll buf = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a;
		if(a > 0){
			ans += (a+buf)/2;
			buf = (a+buf)%2;
		}
		else{buf = 0;}
	}
	cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> p;
int N,R,L;
int d[1111111]={0};
int t[1111111]={0};
int x[1111111]={0};
int team[11111111]={0};
p rmq[1111111];
 
void updata(int k,int x){
  int no=k;
  k += N-2;
  rmq[k].first += x;
  rmq[k].second = no;
  while(k > 0){
    k = (k - 1) / 2;
    if(rmq[k*2+1].first > rmq[k*2+2].first){
      rmq[k] = rmq[k*2+1];
    }
    else if(rmq[k*2+1].first < rmq[k*2+2].first){
      rmq[k] = rmq[k*2+2];
    }
    else if(rmq[k*2+1].second < rmq[k*2+2].second){
      rmq[k] = rmq[k*2+1];
    }
    else{
      rmq[k] = rmq[k*2+2];
    }
  }
  return;
}
 
 
int main(){
  for(int i=0;i<1111111;i++){
    rmq[i].first = 0;
    rmq[i].second = 0;
  }
  int smp=0;
  int now=0;
  int now1=0;
  cin >> N >> R >> L;
  for(int i=0;i<R;i++){
    smp = rmq[0].second;
    cin >> d[i] >> t[i] >> x[i];
    //if(smp != rmq[0].second){
      team[smp] += t[i] - now;
      now = t[i];
      //}
    updata(d[i],x[i]);
    smp = rmq[0].second;
  }
  team[smp] += L - now;
  int a=0;
  int ans=1;
  for(int i=1;i<=N;i++){
    //cout<<team[i]<<endl;
    if(a < team[i]){
      ans = i;
      a = team[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 23684
#include <iostream>
using namespace std;
int main(){
  int R;
  cin >> R;
  if(R < 1200){
    cout << "ABC" << endl;
  } else if(1200 <= R && R < 2800) {
    cout << "ARC" << endl;
  } else if(2800 <= R || R <= 4208){
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int a,b,c;
   cin >> a >> b >> c;
   int ans = c-(a-b);
   if(ans < 0) ans = 0;
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
N = int(input())
S = []
for _ in range(N):
  S.append(input())

Ans = [0] * 4

for i in range(N):
  if S[i] == 'AC':
    Ans[0] = Ans[0] + 1
  elif S[i] == 'WA':
    Ans[1] = Ans[1] + 1
  elif S[i] == 'TLE':
    Ans[2] = Ans[2] + 1
  elif S[i] == 'RE':
    Ans[3] = Ans[3] + 1

print('AC x ' + str(Ans[0]))
print('WA x ' + str(Ans[1]))
print('TLE x ' + str(Ans[2]))
print('RE x ' + str(Ans[3]))

Measured memory_bytes: 16332
#include <bits/stdc++.h>
#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() {
  int64_t H, W;
  cin >> H >> W;
  if(H == 1 || W == 1){
    cout << 1 << endl;
    return 0;
  }

  int64_t ans = 0;
  if(W % 2 == 0){
    ans = ((H / 2) + (H % 2) + (H / 2)) * (W / 2);
  }
  else{
    ans = ((H / 2) + (H % 2) + (H / 2)) * (W / 2) + (H / 2) + (H % 2);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
    double h ;
    int n , x;
    cin >> h >> n ;
    for (int i=0 ; i<n ; ++i)
    {
         cin>>x ;
         h-=x ;
    }

    if (h<=0)
        cout<<"Yes" ;
    else
        cout<<"No" ;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()

string S;
int K, N;
int main(){
    cin >> S >> K;
    N = S.length();

    vector<string> s;
    for(int i=0;i<N;i++){
      for(int j=1;j<6;j++){
        s.push_back(S.substr(i, j));
      }
    }
    sort(all(s));
    s.erase( unique(all(s)), s.end());
    cout << s[K - 1] << endl;
    return 0;
}

Measured memory_bytes: 1660
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  priority_queue<ll> que;
  while(true){
    string s;cin>>s;
    if(s=="end") return 0;
    else if(s=="insert"){
      ll n;cin>>n;
      que.push(n);
    }else if(s=="extract"){
      cout<<que.top()<<endl;
      que.pop();
    }
  }
}


Measured memory_bytes: 11176
n,k=map(int,input().split())
a=list(map(int,input().split()))
dp=[False]*(k+1)
for i in range(1,k+1):
  for j in range(n):
    if i-a[j]>=0:
      dp[i] |= not(dp[i-a[j]])
#print(dp)
print("First" if dp[k] else "Second")

Measured memory_bytes: 74328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
 <url:https://beta.atcoder.jp/contests/arc087/tasks/arc087_b>
 問題文============================================================
 二次元平面の原点にロボットが置かれています。 最初、ロボットは x 軸の正の向きを向いています。
 
 このロボットに命令列s が与えられます。s は次の2 文字のみからなり、先頭から末尾まで順に実行されます。
 F : 今向いている向きに長さ1 だけ移動する。
 T : 時計回りまたは反時計回りの好きな方向に90 度だけ向きを変える。
 ロボットの目標は、命令列をすべて実行し終わった後に座標(x,y) にいることです。
 この目標が達成可能か判定してください。
 
 s  は F, T のみからなる。
 1≤|s|≤8 000
 x,y は整数である。
 |x|,|y|≤|s|
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
bool dp1[4050][16001];
bool dp2[4050][16001];
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    ll x,y; cin >> x >> y;
    vector<int> ax,ay;
    int t = 0;
    int cnt = 0;
    for(int i = 0; i < s.length();i++){
        if(s[i] == 'F'){
            cnt++;
        }else{
            if(t%2 == 0){
                ax.push_back(cnt);
            }else{
                ay.push_back(cnt);
            }
            t++; cnt = 0;
        }
    }
    if(cnt != 0){
        if(t%2 == 0){
            ax.push_back(cnt);
        }else{
            ay.push_back(cnt);
        }
    }
    dp1[0][8000] = true;
    for(int i = 0; i < (int)ax.size();i++){
        for(int j = 0; j <= 16000;j++){
            if(dp1[i][j]){
                dp1[i+1][j + ax[i]] = true;
                if(i == 0) continue;
                dp1[i+1][j - ax[i]] = true;
            }
        }
    }
    dp2[0][8000] = true;
    for(int i = 0; i < (int)ay.size();i++){
        for(int j = 0; j <= 16000;j++){
            if(dp2[i][j]){
                dp2[i+1][j + ay[i]] = true;
                dp2[i+1][j - ay[i]] = true;
            }
        }
    }
    if(dp1[ax.size()][8000+x] && dp2[ay.size()][8000+y]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 123776
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[300111];
int main()
{
	get1(n);
	for(int i=1;i<=3*n;i++)get1(a[i]);
	sort(a+1,a+3*n+1);
	LL ans=0;
	for(int i=0;i<n;i++)ans+=a[n+n+n-1-i*2];
	printendl(ans);
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h,w;
    cin>>h>>w;
    vector<vi> m(h, vi(w,0));
    REP(i,h) REP(j,w){
        cin>>m[i][j];
    }

    using P = tuple<int,int,int,int>;
    vector<P> route;

    REP(i,h) REP(j,w-1){
        if(m[i][j]%2==0) continue;

        route.emplace_back( P(i+1,j+1, i+1,j+2) );
        m[i][j]--;
        m[i][j+1]++;
    }

    REP(i,h-1){
        int j = w-1;
        if(m[i][j]%2==0) continue;

        route.emplace_back( P(i+1,j+1, i+2,j+1) );
        m[i][j]--;
        m[i+1][j]++;
    }

    //DEBUG(route.size());
    cout<<route.size()<<endl;
    REP(k,route.size()){
        int y1,y2,x1,x2;
        tie(y1,x1,y2,x2) = route[k];
        cout<<y1<<" "<<x1<<" "<<y2<<" "<<x2<<endl;
    }
    //cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[10001],i=1;
	for(a[0]=1;a[i-1]!=0;i++) cin>>a[i];
	i--;
	for(int j=1;j<i;j++) cout<<"Case "<<j<<": "<<a[j]<<endl;
	return 0;
}



Measured memory_bytes: 3036
S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

if a==b and c==d and b!=c:
    print("Yes")

elif a==c and b==d and a!=b:
    print("Yes")

elif a==d and b==c and a!=b:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int n=0;
	string s;
	string f="CODEFESTIVAL2016";
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]!=f[i]){
			n++;
		}
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
ll dp[110][80];
int main() {
	int N;
	cin >> N;
	map<int, int> p;
	for (int i = 2; i <= N; i++) {
		int n = i;
		for (int j = 2; j <= n; j++) {
			if (n%j) continue;
			int cnt = 0;
			while (n%j == 0) {
				cnt++;
				n /= j;
			}
			p[j] += cnt;
		}
	}
	int idx = 0;
	dp[0][1] = 1;
	for (auto x : p) {
		for (int i = 1; i <= 75; i++) {
			for (int j = 0; j <= x.second; j++) {
				if (i*(j + 1) <= 75) dp[idx + 1][i*(j + 1)] += dp[idx][i];
			}
		}
		idx++;
	}
	cout << dp[idx][75] << endl;
}


Measured memory_bytes: 256
import numpy as np
A = np.zeros((3,3), dtype=int)
for i in range(3):
    A[i,:] = list(map(int, input().split()))
N = int(input())
B = [int(input()) for _ in range(N)]

A = A.flatten()
for a in range(len(A)):

    for b in range(N):
        if A[a] == B[b]:
            A[a] = -1



if A[0] == -1 and A[1] == -1 and A[2] == -1:
    print('Yes')
elif A[3] == -1 and A[4] == -1 and A[5] == -1:
    print('Yes')
elif A[6] == -1 and A[7] == -1 and A[8] == -1:
    print('Yes')
elif A[0] == -1 and A[3] == -1 and A[6] == -1:
    print('Yes')
elif A[1] == -1 and A[4] == -1 and A[6] == -1:
    print('Yes')
elif A[2] == -1 and A[5] == -1 and A[8] == -1:
    print('Yes')
elif A[0] == -1 and A[4] == -1 and A[8] == -1:
    print('Yes')
elif A[2] == -1 and A[4] == -1 and A[6] == -1:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 12528
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N;
    scanf("%lld", &N);
    vector<ll> A(N);
    ll all = 0;
    for (ll i = 0; i < N; i++)
    {
        ll a;
        scanf("%lld", &a);
        A[i] = a;
        all ^= a;
    }

    for (ll i = 0; i < N; i++)
    {
        printf("%lld ", all ^ A[i]);
    }
}


Measured memory_bytes: 4824
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;
const int maxn=100005;

struct point{
	int x,y,id;
}p[maxn];

int f[maxn];

bool cmpx(point a, point b){return a.x<b.x;}
bool cmpy(point a, point b){return a.y<b.y;}
int G(int x){ return f[x]==x?x:f[x]=G(f[x]); }
void U(int x, int y){
	int fx=G(x), fy=G(y);
	if (fx!=fy){ f[fx]=fy;}
}
set<int> SX[maxn],SY[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) f[i]=i;
	for (int i=1;i<=n;i++)scanf("%d%d",&p[i].x,&p[i].y),p[i].id=i;
	sort(p+1,p+1+n,cmpx);
	for (int i=2;i<=n;i++){if (p[i].x==p[i-1].x) U(p[i].id,p[i-1].id); }
	sort(p+1,p+1+n,cmpy);
	for (int i=2;i<=n;i++){if (p[i].y==p[i-1].y) U(p[i].id,p[i-1].id); }
	for (int i=1;i<=n;i++){
		int fi=G(p[i].id);
		SX[fi].insert(p[i].x); SY[fi].insert(p[i].y);
	}
	long long  ans=0;
	for (int i=1;i<=n;i++){
		ans+=(SX[i].size() * SY[i].size());
	}
	printf("%lld",ans-n);
	return 0; 
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;


int uniq[2000100];
int score[2000100];
int bit[2000100];

int get(int x){
	int num = 0;
	for(int i = x ; i > 0 ; i -= i & -i ){
		num += bit[i];
	}
	return num;
}
int add(int x,int val){
	for(int i = x ; i < 2000100 ; i += i & -i ){
		bit[i] += val;
	}
}
vector<int> leader;
/*
3 5 7 8 10
  = = =
*/

int N,Q;
int U = 0;

int succ(int r){
	if( leader.size() == 0 ){
		return N;
	}
	//for(int i = 0 ; i < U ; i++) cout << uniq[i] << " "; cout << endl;
	vector< pair<int,int> > line;
	for(int i = 0 ; i < leader.size() ; i++){
		int prescore = uniq[score[leader[i]]];
		int pos1 = lower_bound(uniq,uniq+U,max(0,prescore-r)) - uniq;
		int pos2 = lower_bound(uniq,uniq+U,prescore) - uniq + 1;
		//cout << uniq[pos1] << " " << uniq[pos2] << "{" << r << "," << prescore << endl;
		line.push_back(make_pair(pos1,pos2));
	}
	sort(line.begin(),line.end());
	vector< pair<int,int> > merge;
	int s = line[0].first;
	int t = line[0].second;
	for(int i = 1 ; i < line.size() ; i++){
		if( line[i].first <= t ){
			t = max(t,line[i].second);
		}else{
			merge.push_back(make_pair(s,t));
			s = line[i].first;
			t = line[i].second;
		}
	}
	merge.push_back(make_pair(s,t));
	
	int dead = 0;
	for(int i = 0 ; i < merge.size() ; i++){
		int x = merge[i].first;
		int y = merge[i].second-1;
		dead += get(y) - get(x-1);
	}
	return N - dead;
}
int main(){
	cin >> N >> Q;
	for(int i = 0 ; i < N ; i++){
		scanf("%d",&score[i]);
		uniq[U++]=score[i]  ;
		uniq[U++]=score[i]-1;
	}
	uniq[U++] = -1;
	uniq[U++] = 0;
	
	sort(uniq,uniq+U);
	
	U = unique(uniq,uniq+U) - uniq;
	
	for(int i = 0 ; i < N ; i++){
		score[i] = lower_bound(uniq,uniq+U,score[i]) - uniq;
		add(score[i],1);
	}
	while(Q--){
		string s;
		int x;
		cin >> s >> x;
		if( s == "REMOVE" ){
			x--;
			leader.erase(remove(leader.begin(),leader.end(),x));
		}else if( s == "ADD"){
			x--;
			leader.push_back(x);
		}else{
			//cout << succ(0) << " < " << leader[0] << "(u" << uniq[1] << endl;
			//return 0;
			
			int l = 0 , r = 1000000000;
			while(l!=r){
				//cout << l << " " << r << endl;
				int m = (l+r)/2;
				if( succ(m) <= x ){
					r = m;
				}else{
					l = m+1;
				}
			}
			
			if( succ(l) > x ){
				cout << "NA" << endl;
			}else{
				cout << l << endl;
			}
		}
		
	}
	
}

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

#define int long long
struct Fast { Fast(){ std::cin.tie(0); std::cout.tie(0); ios::sync_with_stdio(false); }} fast;

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void) {
  
  int n; cin >> n;
  int k; cin >> k;
  vector<pair<int, int>> p(n);
  for (auto it = p.begin(); it != p.end(); ++it) {
    *it = make_pair(0, 0);
    cin >> (*it).first >> (*it).second;
  }
  sort(p.begin(), p.end());
  
  int m = 0;
  for (auto it = p.begin(); it != p.end(); ++it) {
    m += (*it).second;
    if (m >= k) {
      cout << (*it).first << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

        double r=sc.nextDouble();
        
        System.out.printf("%f.6 %f.6",r*r*3.141592653589,2*3.141592653589*r);
        }

    
}


Measured memory_bytes: 28060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::string S){
  ll ans=0;
  REP(N-2){
    if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C')
      ++ans;
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(){
  string str;
  cin >> str;
  int num(pow(2, str.size() - 1));
  long result(0);
  for(int i = 0; i < num; i++){
    long tmp(0);
    char *copy(&str[0]);
    for(int j = i; j; j >>= 1){
      if(j & 1){
        result += tmp + copy++[0] - 48;
        tmp = 0;
      }else tmp = (copy++[0] - 48 + tmp) * 10 ;
    }
    result += tmp + stol(copy);
  }
  cout << result << endl;
}


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

int main(){
    int n;
    cin >> n;
    long long int acc = 0;
    map<long long int, long long int> mp;
    mp[0]++;
    for(int i=0;i<n;++i){
        long long int a;
        cin >> a;
        acc += a;
        mp[acc]++;
    }

    long long int ans = 0;
    for(auto e : mp){
        ans += e.second * (e.second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
int n;
int y;
int num[50];
int numnum[50];
int dfs(int x,int sum);
int mem[50][15000];
main(){
  while(1){
    cin>>n;
    if(n==0)break;
    int cnt=0;
    int g;
    for(int i=0;i<n;i++){
      cin>>num[i]>>numnum[i];
    }
    cin>>g;
    for(int i=0;i<g;i++){
      memset(mem,-1,sizeof(mem));
      cin>>y;
      cnt=dfs(0,0);
      cout<<cnt<<endl;
    }
  }
}
int dfs(int x,int sum){
  if(sum==y){
    return 1;
  }
  if(x==n&&sum!=y){
    return 0;
  }
  if(mem[x][sum]!=-1){
    return mem[x][sum];
  }
  else{
    int cnt=0;
    for(int i=0;i<=numnum[x];i++){
      cnt+=dfs(x+1,sum+num[x]*i);
    }
    return mem[x][sum]=cnt;
  }
}

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

int main(){
    ll n; cin >> n;
    ll a[n], b[n], c[n];
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    ll da[n], db[n], dc[n];
    memset(da, -1, sizeof(da));
    memset(db, -1, sizeof(db));
    memset(dc, -1, sizeof(dc));
    da[0] = max(b[0], c[0]);
    db[0] = max(a[0], c[0]);
    dc[0] = max(a[0], b[0]);
    loop(i, 1, n){
        da[i] = a[i] + max(db[i-1], dc[i-1]);
        db[i] = b[i] + max(da[i-1], dc[i-1]);
        dc[i] = c[i] + max(da[i-1], db[i-1]);
    }

    cout << max(max(da[n-1], db[n-1]), dc[n-1]) << endl;

    return 0;
}

Measured memory_bytes: 4992
<?php
  while (true) {
    $a = trim(fgets(STDIN));
    if ($a == "0") {
      return;
    }
    $b = explode(" ", trim(fgets(STDIN)));
    $z = 0;
    foreach ($b as $val) {
      $z += pow(($val - array_sum($b) / $a), 2);
    }
    print(sqrt($z / $a) . "\n");
  }
?>

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

typedef long long ll;
using vi = vector<int>;
using vll = vector<ll>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, m;
    cin >> n >> m;
    vi p(m);
    vector<string> s(m);
    rep(i, m) {
        cin >> p[i] >> s[i];
    }

    ll sumAC = 0;
    bool isAC[100100];  //ACできたか
    int sumWA[100100];  //とりあえずWA数
    rep(i, 100100) {
        isAC[i] = false;
        sumWA[i] = 0;
    }

    rep(i, m) {
        if(isAC[p[i]]) continue;
        else {
            if(s[i] == "WA") sumWA[p[i]]++;
            else {
                isAC[p[i]] = true;
            }
        }
    }

    ll sum = 0;
    rep(i, 100100) {
        if(isAC[i]) {
            sumAC++;
            sum += sumWA[i];
        }
    }
    cout << sumAC << " " << sum << endl;

    return 0;
}

Measured memory_bytes: 6656
import itertools
N=int(input())
S=input()
cnt=0
for x in itertools.product(list(range(10)),repeat=3):
    li=list(x)
    zero=S.find(str(li[0]))
    one=S.find(str(li[1]),zero+1)
    two=S.find(str(li[2]),one+1)
    if(not(zero==-1 or one==-1 or two==-1)):
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int i;
    for(i=0;i<n;i++){
        if(a[i]%2) continue;
        if(a[i]%3==0 || a[i]%5==0) continue;
        break;
    }
    if(i==n){
        cout <<"APPROVED";
    }else
    cout << "DENIED";
    cout << endl;
    return 0;
}


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

int main() {
  int a,p,q,r;
  cin >> p >> q >> r;

  if(p>=q && p>=r)
  {
    a = q + r;
  }
   if(q>=p && q>=r)
  {
    a = p + r;
  }
     if(r>=p && r>=q)
  {
    a = p + q;
  }
  cout << a;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb  push_back
using namespace std;
typedef long long ll;
int ans[200005];
int main(){
    int n; cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    
    int l=0,r=n-1;
    bool f = 1;
    
    for(int i=n-1;i>-1;i--){
    	if(!f) ans[r--] = a[i];
    	else ans[l++] = a[i];
    	f^=1;
	}
	
	for(int i=0;i<n;i++) cout << ans[i] <<" ";
	
	return 0;
}

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

int main()
{
    int a,b;
    string s;
   while(cin>>a>>b)
   {
    if(a<b)
        s="<";
        else if(a==b)
        s="==";
        else 
        s=">";
   cout<<"a "<<s<<" b\n";
   } 
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int N; cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和と連想配列
    vector<long long> s(N+1, 0);
    map<long long, long long> nums;
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
    for (int i = 0; i < N+1; ++i) nums[s[i]]++;

    // 集計処理
    long long res = 0;
    for (auto it : nums) {
        long long num = it.second; // it.first が it.second 個ある
        res += num * (num - 1) / 2;
    }
    cout << res << endl;
}   

Measured memory_bytes: 18836
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <list>
#include <typeinfo>
using namespace std;
#define REP(a,b) for(long long a = 0;a < b;++a)
long long kouyaku(long long a,long long b) {
	if (a%b == 0) {
		return b;
	}
	else {
		return kouyaku(b, a%b);
	}
}
long long gcm(long long a,long long b) {
	return a*b / kouyaku(a, b);
}
int main() {
	int n;
	scanf("%d", &n);
	long long a;
	scanf("%I64d", &a);
	REP(i, n - 1) {
		long long b = 0;
		scanf("%I64d", &b);
		a = gcm(a, b);
	}
	printf("%d\n", a);
}
//thank you for reading my code!


Measured memory_bytes: 1204
# -*- coding: utf-8 -*-
h,n = list(map(int,input().split()))
ab = [list(map(int,input().split())) for i in range(n)]
a = [i[0] for i in ab]
b = [i[1] for i in ab]
 
from math import ceil
dp = [[0] * (h + 1) for _ in range(n)]
 
for j in range(h+1):
    dp[0][j] = ceil(j/a[0]) * b[0]
 
for i in range(1,n):
    for j in range(h+1):
        if j - a[i] > 0:
            dp[i][j] = min(dp[i][j-a[i]] + b[i],dp[i-1][j])
        else:
            dp[i][j] = min(b[i],dp[i-1][j])
 
print(dp[n-1][h])

Measured memory_bytes: 309640
#!/usr/bin/env ruby

nn, mm = gets.chomp.split.map(&:to_i)
ss = []
1.step(mm, 1) do |_i|
  k = gets.chomp.split.map(&:to_i)
  ss[_i - 1] = k[1..-1]
end
ps = gets.chomp.split.map(&:to_i)

ans = 0
0.step((2**nn) - 1, 1) do |bit2s|
  flag = true
  0.step(mm - 1, 1) do |ite_m|
    sum = 0
    ss[ite_m].each do |swi|
      next if bit2s[swi-1].to_i != 1
      sum += 1
    end
    if sum%2 != ps[ite_m]%2
      flag = false
      break
    end
  end
  ans += 1 if flag
end

p ans

=begin

# 一行に整数ひとつだけ
n = gets.chomp.to_i
p n

# 半角区切り整数を配列で受ける
# k1, k2 , ...
k = gets.chomp.split.map(&:to_i)

p k

# n
# a1, b1
# ...
# an, bn
# の形式

nn = gets.chomp.to_i
p nn
a = []
b = []
0.step(nn-1) do |i|
  k = gets.chomp.split(' ').map(&:to_i)
  a << k[0]
  b << k[1]
end

0.step(nn-1) { |i|
  puts "i: #{i} a:#{a[i]} b:#{b[i]}"
}

=end

Measured memory_bytes: 1788
require 'date'

def main
  if true then
    fh=STDIN
  else
    fh=open("in1_0125.txt")
  end

  while fh.gets do
    y1,m1,d1,y2,m2,d2 = $_.chomp.split.map{|x| x.to_i}
    break if y1<0 or m1<0 or d1<0 or y2<0 or m2<0 or d2<0

    d1=Date.new(y1,m1,d1)
    d2=Date.new(y2,m2,d2)
    puts (d2-d1).to_i
  end

end

if $0 == __FILE__ then
  main
end

Measured memory_bytes: 8956
k , n = map(int , input().split())

values = list(map(int , input().split()))

ans = values[n-1] - values[0]

answer = [0]*n
answer[0] = ans

for i in range(1,n):
	answer[i] = ans - (values[i] - values[i-1]) + (k-values[n-1]+values[0])
	
#print(answer)
	
print(min(answer))



Measured memory_bytes: 25840
S = input()
T = input()
ls = len(S)
lt = len(T)
cand = []
for i in range(ls-lt+1):
    frac =  S[i:i+lt]
    for j in range(lt):
        if frac[j] != T[j] and frac[j] != '?': break
    else:
        cand.append(S[0:i] + T + S[i+lt:ls])
if cand == []:
    print("UNRESTORABLE")
else:
    cand = list(map(lambda x:x.replace('?','a'), cand))
    cand.sort()
    print(cand[0])

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, j, n) for(int i = j; i < n; ++i)
using ll = long long;

ll n, m, a, b, c;
ll ans = 0;


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

	ll x = min(b - 1, n);
	cout << a * x / b - x / b * a;
	return 0;
}


Measured memory_bytes: 3596
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template <class T = usize> class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr rep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(f); }
	constexpr itr end() const noexcept { return itr(l); }
};
template <class T = usize> class revrep {
	const T f, l;

public:
	class itr {
		friend revrep;
		T i;
		constexpr itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		constexpr T operator*() const noexcept { return i; }
		constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	constexpr revrep(const T first, const T last) noexcept : f(first), l(last) {}
	constexpr itr begin() const noexcept { return itr(l - 1); }
	constexpr itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool amax(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool amin(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool asmax(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool asmin(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }
template <class T> constexpr T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

#include <algorithm>
#include <iostream>
#include <utility>
#include<array>

int main() {
	usize n;
	::std::cin >> n;
	::std::vector<u64> a(n);
	for (auto &e : a) {
		::std::cin >> e;
	}
	::std::vector<u64> dpl0(n + 1, 0), dpl1 = dpl0, dpr0 = dpl0, dpr1 = dpl0;
	const auto f = [&]() {
		u64 acl = 0;
		for (const auto i : rep<>(1, n + 1)) {
			const auto e = a[i - 1];
			acl += e;
			if (e) {
				dpl0[i] = ::std::min(dpl0[i - 1] + e % 2, acl);
				dpl1[i] = ::std::min(dpl1[i - 1] + (e - 1) % 2, dpl0[i]);
			}
			else {
				dpl0[i] = ::std::min(dpl0[i - 1] + 2, acl);
				dpl1[i] = ::std::min(dpl1[i - 1] + 1, dpl0[i]);
			}
		}
	};
	f();
	const auto dpl = dpl1;
	::std::reverse(a.begin(), a.end());
	f();
	const auto dpr = dpl1;
	u64 ans = ::std::numeric_limits<u64>::max();
	for (const auto i : rep<>(0, n + 1)) {
		asmin(ans, dpl[i] + dpr[n - i]);
	}
	::std::cout << ans << ::std::endl;
	return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<math.h>
double f(double a, double b,double ang){
    if(ang > M_PI/2.0){
        return 0.0;
    }
    double ans;
    if(a * tan(ang) <= b){
        ans = a * a * b - a * a * a * tan(ang) / 2.0;
    }else{
        ans = b * b / tan(ang)*a / 2.0;
    }
    return ans;
}

int main(){
    double a,b,x;
    scanf("%lf %lf %lf",&a,&b,&x);
    
    double ok = M_PI / 2.0;
    double ng = 0.0;
    for(int i = 0 ; i <= 1e+5 ; i++){
        double mid = ( ok + ng ) / 2.0;
        if( f( a , b , mid) < x ){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    printf("%f",ok / M_PI * 180);
    return 0;
    
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int a[3][3]={};
  int b[150]={};
  int i=0,j=0,k=0,n=0;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }
  }
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
  }
  for(k=0;k<n;k++){
   for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(a[i][j]==b[k]){
        a[i][j]=0;
      }
    }
   }
  }
  if(a[0][0]==0&&a[0][1]==0&&a[0][2]==0){
    printf("Yes");
    return 0;
  }
  if(a[1][0]==0&&a[1][1]==0&&a[1][2]==0){
    printf("Yes");
    return 0;
  }
  if(a[2][0]==0&&a[2][1]==0&&a[2][2]==0){
  printf("Yes");
  return 0;
  }
  if(a[0][0]==0&&a[1][0]==0&&a[2][0]==0){
    printf("Yes");
    return 0;
  }
   if(a[0][1]==0&&a[1][1]==0&&a[2][1]==0){
    printf("Yes");
    return 0;
  }
   if(a[0][2]==0&&a[1][2]==0&&a[2][2]==0){
    printf("Yes");
    return 0;
  }
   if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0){
    printf("Yes");
    return 0;
  }
   if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0){
    printf("Yes");
    return 0;
  }
  printf("No");
  
 return 0;
}

Measured memory_bytes: 1728
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <queue>
#include <cmath>
#include <map>

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

using namespace std;

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

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	priority_queue<int> q;

	reps( i, X )
	{
		for ( int j = 2; ; j++ )
		{
			int tmp = pow( i, j );
			if ( tmp < X )
			{
				q.emplace( tmp );
				if ( i == 1 ) { break; }
			}
			else if ( tmp == X )
			{
				cout << X << endl;
				return ( 0 );
			}
			else
			{
				break;
			}
		}
	}

	cout << q.top() << endl;

	return ( 0 );
}


Measured memory_bytes: 1016
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = do
  [h, _] <- getIntList
  a <- getIntList
  let as = sum a
  putStrLn $ if h-as <=0 then "Yes" else "No"
   


readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine


Measured memory_bytes: 2172
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, Q := sc.nextInt(), sc.nextInt()
	S := sc.nextStr()
	sum := make([]int, N)
	count := 0
	aFlag := false
	for i, r := range S {
		if aFlag && r == 'C' {
			count++
		}
		if r == 'A' {
			aFlag = true
		} else {
			aFlag = false
		}
		sum[i] = count
	}
	for i := 0; i < Q; i++ {
		l, r := sc.nextInt()-1, sc.nextInt()-1
		var ans int
		if l != 0 {
			ans = sum[r] - sum[l-1]
		} else {
			ans = sum[r]
		}
		if l != 0 && S[l-1] == 'A' && S[l] == 'C' {
			ans -= 1
		}
		fmt.Fprintln(wtr, ans)
	}
	wtr.Flush()
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 2e5 + 5;
 
int n, p;
string s;
int pref[N];
map<int, int> m;
 
int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
 
int32_t main()
{
	IOS;
	cin >> n >> p >> s;
	int ans = 0;
	int c2 = 0, c5 = 0;
	for(int i = 1; i <= n; i++)
	{
		if((s[i - 1] - '0') % 2 == 0)
			c2 += i;
		if((s[i - 1] - '0') % 5 == 0)
			c5 += i;
	}
	if(p == 2)
	{
		cout << c2;
		return 0;
	}
	if(p == 5)
	{
		cout << c5;
		return 0;
	}
	for(int i = n; i >= 1; i--)
	{
		pref[i] = pref[i + 1] + (s[i - 1] - '0') * pow(10, n - i, p);
		pref[i] %= p;
		m[pref[i]]++;
	}
	ans = m[0];
	int rem = 0;
	for(int i = n; i >= 2; i--)
	{
		m[pref[i]]--;
		rem += (s[i - 1] - '0') * pow(10, n - i, p);
		rem %= p;
		ans += m[rem];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 2580
#include<bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define nl cout<<"\n"
#define pb push_back
#define se second
#define fi first
#define int long long 
#define pi pair<int,int>
#define vpi vector<pi>
#define vvi vector<vpi>
#define pie =3.14159265358979323846264338327950;
const int mod= 1e9+7;

int32_t main(){
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
	int n,w;
	cin>>n>>w;
	vector<int> dp(w+1,-1);
	dp[0]=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		for(int j=w;j>=a;j--){
			if(dp[j-a]!=-1){
				dp[j]= max(dp[j], dp[j-a]+b);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=w;i++){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3936
def bakudanda (S,y,x):
  if y < 0 or y >= len(S):
    return 0
  if x < 0 or x >= len(S[y]):
    return 0
  if S[y][x] == '#':
    return 1
  else:
    return 0
H,W = map(int,input().split())
s=[]
for i in range(H):
  s.append(input())
  
for i in range(len(s)):
  a = s[i]
  fp = ''
  for j in range(len(a)):
    if a[j] == '.':
      c = 0
      ds = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0,1), (1, -1), (1, 0), (1, 1)]
      for (y, x) in ds:
        c+= bakudanda(s,i+y,j+x)
      fp += str(c)
    else:
      fp += '#'
  print(fp)
        

Measured memory_bytes: 9236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; ++i)
#define REP_R(i,n,m) for(int i=m; i<n; ++i)
#define NMAX 50
#define MMAX 1230

int N, M;
bool graph[NMAX+1][MMAX+1];
int p[MMAX+1];
int q[MMAX+1];
bool visited[NMAX];

void dfs(int v);

int main() {
  int a,b;
  cin >> N >> M;
  REP(i,M) {
    scanf("%d %d", &a, &b);
    p[i] = a-1; q[i] = b-1;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }

  int ans = 0;

  REP(number,M) {
    REP(i,N) visited[i] = false;

    graph[p[number]][q[number]] = graph[q[number]][p[number]] = false;

    dfs(0);

    bool judge = false;

    REP(i,N) {
      if (!visited[i]) {
        judge = true;
        break;
      }
    }

    if (judge) ans++;

    graph[p[number]][q[number]] = graph[q[number]][p[number]] = true;
  }

  cout << ans << endl;
}

void dfs(int v) {
  visited[v] = true;
  REP(i,N) {
    if (!graph[v][i]) continue;
    if (visited[i]) continue;

    dfs(i);
  }
}


Measured memory_bytes: 256