akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;
using P = pair<int, int>;

const int inf = 1e18;
int N,W;
int v[40],w[40];
vector<P> ps;
vector<P> qs;

signed main(void) {
  cin >> N >> W;
  rep(i,N) {
    cin >> v[i] >> w[i];
  }

  rep(i,(1<<N/2)) {
    int sw = 0, sv = 0;
    rep (j, N/2) {
      if ((i & (1ll << j)) != 0) {
        sw += w[j];
        sv -= v[j];
      }
    }
    if (sw <= W) ps.push_back(P(sw, sv));
  }

  sort(ps.begin(), ps.end());
  for(auto &v : ps) v.second *= -1;

  for (auto v : ps) {
    if (qs.empty() || qs.back().second < v.second) {
      qs.push_back(v);
    }
  }

  int ans = 0;
  rep(i,(1<<(N-N/2))) {
    int sw = 0, sv = 0;
    for (int j = N / 2; j < N; j++) {
      if ((i & (1ll << (j - N / 2))) != 0) {
        sw += w[j];
        sv += v[j];
      }
    }
    if (sw <= W) {
      ans = max(ans, (lower_bound(qs.begin(), qs.end(), P(W - sw, inf)) - 1)->second + sv);
    }
  }
  cout << ans << endl;
  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = llabs(a-b) / 2;
    if (abs((a-b)%2)==1) {
        ans += min(llabs(a-1), llabs(b-n)) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

	int x, y;
	while(sc.hasNext()){
	    x = sc.nextInt();
	    y = sc.nextInt();
	    
	    while(x!=0 && y!=0){
		int p, q;
		p = Math.min(x, y);
		q = Math.max(x, y);
		x = q-p;
		y = p;
	    }
	    
	    System.out.println(Math.max(x,y));
	}
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>

using namespace std;


int w,h;

int map[10001];
bool visited[10001];

int move(int pos) {

  if(visited[pos]==true) return -1;

  else {

    visited[pos]=true;

    switch(map[pos]) {

    case 0:
      return pos;

    case 1:
      return move(pos+1);

    case 2:
      return move(pos-w);

    case 3:
      return move(pos-1);

    case 4:
      return move(pos+w);

    }

  }

  return -1;

}

int main() {

  string buf;

  int res;
  

  while(cin >> h >> w) {

    if(w==0 && h==0) break;

    getline(cin,buf);

    for(int i=0;i<10001;i++) visited[i]=false;

    for(int i=0;i<h;i++) {

      getline(cin,buf);

      for(int j=0;j<w;j++) {

	switch(buf[j]) {

	case '.':
	  map[i*w+j]=0;
	  break;

	case '>':
	  map[i*w+j]=1;
	  break;

	case '^':
	  map[i*w+j]=2;
	  break;

	case '<':
	  map[i*w+j]=3;
	  break;

	case 'v':
	  map[i*w+j]=4;
	  break;

	}

      }

    }
    /*
    for(int i=0;i<h;i++) {

      for(int j=0;j<w;j++) {

	cout << map[i*w+j];

      }

      cout << endl;

    }
    */
    res=move(0);

    if(res==-1) cout << "LOOP" << endl;

    else cout << res%w << " " << res/w << endl;
    
  }

  return 0;

}
	  
 

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

int n,d,ans=0;
double x,y;

signed main()
{
	cin>>n>>d;
	for (int i=1;i<=n;i++)
	{
		cin>>x>>y;
		
		double len=sqrt(x*x+y*y);
		if (len<=d)  ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

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

int main() {
	vector<bool> std(31,false);
	for (int i=0; i<28; i++) {
		int a; cin >> a;
		std[a] = true;
	}
	for (int i=1; i<31; i++) {
		if (!std[i]) cout << i << endl;
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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 comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

void solve(){
  ll N, M;
  cin >> N >> M;
  if(500 * N >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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


Measured memory_bytes: 256
if __name__ == '__main__':

	while True:
		try:
			n = int(input())

			ans = []
			for i in range(9,-1,-1):
				if n >=  2**i:
					ans.append(2**i)
					n -= 2**i

			print(*sorted(ans))

		except EOFError:
			break




Measured memory_bytes: 5592
#include <stdio.h>

int fib (int);

int main () {
int n;

scanf("%d", &n);
printf("%d\n", fib(n));

return 0;
}

int fib (int n) {
int f[45], i;

f[0] = 1;
f[1] = 1;
for(i = 2 ; i < 45 ; i++) {
f[i] = f[i-2] + f[i-1];
}
return f[n];
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>


#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define prd(t) printf("%d",t)
#define prld(t) printf("%ld",t)
#define prlld(t) printf("%lld",t)
#define prc(t) printf("%c",t)
#define prs(t) printf("%s",t)
#define prf(t) printf("%f",t)
#define prsp() printf(" ")
#define prnl() printf("\n")
#define MOD 1000000007
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define fo(i,a,b) for(int i=a;i<b;i++)

// Merges two subarrays of arr[]. 
// First subarray is arr[l..m] 
// Second subarray is arr[m+1..r] 
void merge(int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    /* create temp arrays */
    int L[n1], R[n2]; 
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    /* Copy the remaining elements of L[], if there 
       are any */
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    /* Copy the remaining elements of R[], if there 
       are any */
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 
  
/* l is for left index and r is right index of the 
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        // Same as (l+r)/2, but avoids overflow for 
        // large l and h 
        int m = l+(r-l)/2; 
  
        // Sort first and second halves 
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
}

void solve(){
    int a,b,c,k;
    scd(a);
    scd(b);
    scd(c);
    scd(k);
    int x;
    if(k<=a) x=k;
    else if(k<=(a+b)) x=a;
    else if(k<=(a+b+c)) x=2*a-k+b;
    prd(x);
}


int main(){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
	solve();
	return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,num) FOR(i,0,num) {ll x; scanf("%lld",&x); a.pb(x); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> SET;
typedef map<ll, ll> MAP;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


ll a1, a2, a4;
int main(void) {
  cin >> n;
  FOR(i, 0, n) {
	cin >> tmp;
	if (tmp % 4 == 0) {
	  a4++;
	}
	else if (tmp % 2 == 0) {
	  a2++;
	}
	else {
	  a1++;
	}
  }

  n -= a2;

  if (a2 != 0) {
	if ((n + 1) >> 1 <= a4) {
	  cout << "Yes" << endl;
	}
	else {
	  cout << "No" << endl;
	}
  }
  else {
	if (n >> 1 <= a4) {
	  cout << "Yes" << endl;
	}
	else {
	  cout << "No" << endl;
	}
  }

  return 0;
}

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


int n;
int G[Max][Max];
char color[Max];
int d[Max];
int f[Max];
int time=0;

void visit(int );
void DFS(void );

int main(){
  int i,j;
  int id,num,adj;


  scanf("%d",&n);
  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++) G[i][j] = 0;
  }

  for(i=1 ; i<=n ; i++){
    scanf("%d",&id);
    scanf("%d",&num);
    for(j=0 ; j<num ; j++){
      scanf("%d",&adj);
      G[id][adj] = 1;
    }  
  }

  DFS();
    
  for(i=1 ; i<=n ; i++){
    printf("%d ",i);
    printf("%d ",d[i]);
    printf("%d\n",f[i]);
  }
  return 0;
}

void DFS(void){
  int i;
  for(i=1 ; i<=n ; i++){
    color[i] = 'W';
    time = 0;
  }
  for(i=1 ; i<=n ; i++) if(color[i] == 'W') visit(i);
}

void visit(int u){
  int i;
  color[u] = 'G';
  d[u] = ++time;
  for(i=1 ; i<=n ; i++) if(color[i] == 'W' && G[u][i]) visit(i);
  color[u] = 'B';
  f[u] = ++time;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, long long>;
const long long INF = 2e9;
struct edge { long long to; int cost; };
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  unordered_map<long long, vector<edge> > G;
  unordered_map<long long, int> d;
  for (int i = 0; i < m; i++) {
    int p, q, c; cin >> p >> q >> c;
    p--; q--;
    G[p * INF + 0].push_back(edge{p * INF + c, 1});
    G[p * INF + c].push_back(edge{p * INF + 0, 0});
    G[q * INF + 0].push_back(edge{q * INF + c, 1});
    G[q * INF + c].push_back(edge{q * INF + 0, 0});
    G[p * INF + c].push_back(edge{q * INF + c, 0});
    G[q * INF + c].push_back(edge{p * INF + c, 0});
    d[p * INF + c] = d[q * INF + c] = INF;
  }
  for (int i = 0; i < n; i++) d[i * INF + 0] = INF;
  priority_queue< P, vector<P>, greater<P> > pq;
  d[0 * INF + 0] = 0;
  pq.push(P(0, 0 * INF + 0));
  while (not pq.empty()) {
    P p = pq.top(); pq.pop();
    long long v = p.second;
    if (d[v] < p.first) continue;
    for (auto&& i : G[v]) {
      if (d[v] + i.cost >= d[i.to]) continue;
      d[i.to] = d[v] + i.cost;
      pq.push(P(d[i.to], i.to));
    }
  }
  cout << (d[(n - 1) * INF + 0] == INF ? -1 : d[(n - 1) * INF + 0]) << '\n';
  return 0;
}


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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, 0, N) cin >> A[i];

  set<ll> st;
  ll j = 0, ans = 0;
  REP(i, 0, N) {
    while(j < N) {
      bool ok = true;
      REP(k, 0, 24) {
        if(A[j] & (1LL << k)) {
          ok = ok && st.count(1LL << k) == 0;
        }
      }
      if(ok) {
        REP(k, 0, 24) {
          if(A[j] & (1LL << k)) {
            st.insert(1LL << k);
          }
        }
        j++;
      } else {
        break;
      }
    }

    ans += j - i;

    REP(k, 0, 24) {
      if(A[i] & (1LL << k)) {
        st.erase(1LL << k);
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <sstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

int main()
{
	int x;
	stack<int> S;
	while (cin >> x && x != EOF) {
		if (x == 0) {
			cout << S.top() << endl; S.pop();
		}
		else {
			S.push(x);
		}
	}
}



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

int main() {
  int N;
  cin>>N;
  int64_t x;
  cin>>x;
  vector<int64_t> p(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  vector<vector<int64_t>> dp(N,vector<int64_t>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      int64_t K=(i+N-j)%N;
      dp[i][K]=p[j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=1;j<N;j++){
      dp[i][j]=min(dp[i][j],dp[i][j-1]);
    }
  }
  int64_t Z=167167167167167167;
  for(int64_t i=0;i<N;i++){
    int64_t A=0;
    for(int j=0;j<N;j++){
      A+=dp[j][i];
    }
    Z=min(Z,A+i*x);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 34620
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	var ins []int

	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		var in int
		fmt.Scan(&in)
		ins = append(ins, in)
	}

	sort.Ints(ins)
	min := 1000 * 1000 * 1000 * 1000
	for i := 0; i+k-1 < n; i++ {
		diff := ins[i+k-1] - ins[i]
		if min > diff {
			min = diff
		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 7168
n = int(raw_input())                                           
GMatrix = [[0]*n for i in range(n)]                            
GList = {}                                                     
                                                               
for i in range(n):                                             
    input = map(int, raw_input().split())                      
    GList[i] = input[2:]                                       
    for j in input[2:]:                                        
        GMatrix[i][j-1] = 1                                    
                                                               
# Input                                                        
for i in range(n):                                             
    print ' '.join(map(str, GMatrix[i]))

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

int main() {
  int n;
  cin >> n;
  vector<double> a(n);
  double sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  double ave = sum/n;
  int ansid = 0;
  double ans = fabs(ave - a[0]);
  for (int i = 0; i < n; i++) {
    double tmp = fabs(ave - a[i]);
    if (tmp < ans) {
      ans = tmp;
      ansid = i;
    }
  }
  cout << ansid << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
int fun(int wts[], int vals[], int n, int w){
    int dp[n+1][w+1];
    for(int i = 0; i <= w; i++) dp[0][i] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= w; j++){
            if(j-wts[i] < 0) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j], dp[i-1][j-wts[i]] + vals[i]);
        }
    }
    return dp[n][w];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
       int n, w;
       cin >> n >> w;
       int vals[n+1], wts[n+1];
       FOR1(i, n){
           cin >> wts[i] >> vals[i];
       }
       cout << fun(wts, vals, n, w);
		cout<<'\n';
	}
	return 0;
}


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

// You want the "biggest power of 2 that doesn't exceed X"

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll h;
	cin >> h;
	ll b = 1;
	while(2 * b <= h) b *= 2;
	cout << 2 * b - 1 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

static const double EPS = 1e-12;
const double DTR = (2 * acos(-1)) / 360;


enum ans {
        ABC, ACD, ADB, BCD,
};

int solve() {
        string xy;
        cin >> xy;
        int d, l;
        scanf("%d%d", &d, &l);
        double base = 
                xy == "BC" ? -60 :
                xy == "CD" ? 0 :
                xy == "DB" ? 60:
                0;
        double theta = (base + d) * DTR;
        double y = l * sin(theta);
        double x = l * cos(theta);
        double z150 = -x + sqrt(3) / 3.0 * y;
        double z30 = x + sqrt(3) / 3.0 * y;
        y = fmod(fmod(y, 2.0 * sqrt(3)) + 2.0 * sqrt(3) + EPS, 2.0 * sqrt(3));
        z30 = fmod(fmod(z30, 2.0) + 2.0 + EPS, 2.0);
        z150 = fmod(fmod(z150, 2.0) + 2.0 + EPS, 2.0);
        y = (z30 + z150) * sqrt(3) / 2.0;
        if (z30 < 1.0) {
                if (z150 < 1.0) {
                        if (y < sqrt(3) / 2.0) {
                                return ADB;
                        } else {
                                return BCD;
                        }
                } else {
                        if (y < sqrt(3)) {
                                return ABC;
                        } else {
                                return ACD;
                        }
                } 
        } else {
                if (z150 < 1.0) {
                        if (y < sqrt(3)) {
                                return ACD;
                        } else {
                                return ABC;
                        }
                } else {
                        if (y < 3.0 * sqrt(3) / 2.0) {
                                return BCD;
                        } else {
                                return ADB;
                        }
                }
        }
}

int main() {
        int a = solve(), b = solve();
        puts(a == b ? "YES" : "NO");
        return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x;
    cin>>n>>m>>x;
    int a[n+2][m+2];
    int i,j,k;
    for(i=0;i<n;i++){
        for(j=0;j<=m;j++)
            cin>>a[i][j];
    }
    int ans = INT_MAX,t = 0;
    for(i=1;i<=4096;i++)
    {
        int b[m],cost = 0;
        memset(b,0,sizeof(b));
        for(j=14;j>=0;j--)
        {
            if((i>>j)&1)
            {
                // cout<<j<<" ";
                if(j>=n){
                    t = 1;
                    break;
                }
                cost+=a[j][0];
                for(k=0;k<m;k++)
                    b[k]+=a[j][k+1];
            }
        }
        if(t==1){
            t = 0;
            continue;
        }
        int f = 0;
        for(k=0;k<m;k++)
            if(b[k]<x)
                f = 1;
        if(f==0)
            ans=min(ans,cost);
    }
    // cout<<"\n";
    if(ans==INT_MAX)
        ans = -1;
    cout<<ans;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

int main() {

  int n;
  cin >> n;

  vector<vector<long long>> A(n, vector<long long>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> A[i][j];
    }
  }

  vector<vector<bool>> B(n, vector<bool>(n, false));

  for (int i = 0; i < n; ++i) {
    A[i][i] = INT_MAX;
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        if (i == j || i ==k || j == k)
          continue;

        if (A[i][j] == A[i][k] + A[k][j]) {
          B[i][j] = B[j][i] = true;
        }
        if (A[i][j] > A[i][k] + A[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
      }
    }
  }

  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (!B[i][j]) {
        sum += A[i][j];
      }
    }
  }

  cout << sum << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

char s[ 100 ] ;
int l ;

void init() {
  scanf( "%s" , s ) ;
  l = strlen( s ) ;
}

ll ans ;

void dfs( int nw , ll tmp , ll tt ) {
  if ( nw == l ) {
    ans += tmp + tt ;
    return ;
  }
  dfs( nw + 1 , tmp * 10 + s[ nw ] - '0' , tt ) ;
  dfs( nw + 1 , s[ nw ] - '0' , tmp + tt ) ;
}

void process() {
  ans = 0 ;
  dfs( 1 , s[ 0 ] - '0' , 0 ) ;
  printf( "%lld\n" , ans ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef unsigned long long ull;

using namespace std;

//制限
//
//1 &#8804; M &#8804; 1000    居住予定地の南北の長さ(km)
//1 &#8804; N &#8804; 1000    居住予定地の東西の長さ(km)
//1 &#8804; K &#8804; 100000    調査対象となる領域の個数
//
//4 7
//4
//JIOJOIJ
//IOJOIJO
//JOIJOOI
//OOJJIJO
//3 5 4 7
//2 2 3 6
//2 2 2 2
//1 1 4 7

//aj, bj, cj, dj は，1 &#8804; aj &#8804; cj &#8804; M, 1 &#8804; bj &#8804; dj &#8804; Nを満たす．

int f[1000][1000];
int dp[1000][1000][3];

int main() {
	int M, N;
	int k;

	cin >> M >> N >> k;
	REP(i,M) {
		REP(j,N) {
			char c;
			cin >> c;
			if (c == 'J') {
				f[i][j] = 0;
			}
			if (c == 'O') {
				f[i][j] = 1;
			}
			if (c == 'I') {
				f[i][j] = 2;
			}
		}
	}

	memset(dp, 0, sizeof dp);
	REP(i,M) {
		REP(j,N) {
			dp[i][j][f[i][j]]++;
			if (i - 1 >= 0) {
				REP(s,3) {
					dp[i][j][s] += dp[i - 1][j][s];
				}
			}
			if (j - 1 >= 0) {
				REP(s,3) {
					dp[i][j][s] += dp[i][j - 1][s];
				}
			}
			if (i - 1 >= 0 && j - 1 >= 0) {
				REP(s,3) {
					dp[i][j][s] -= dp[i - 1][j - 1][s];
				}
			}
		}
	}
//	REP(i,M) {
//		REP(j,N) {
//			REP(s,3) {
//				cout << dp[i][j][s];
//				if (s == 2)
//					cout << endl;
//				else
//					cout << " ";
//			}
//		}
//	}

	REP(j,k) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		a--;
		b--;
		c--;
		d--;
		int ans[3];
		memset(ans, 0, sizeof ans);
		REP(i,3) {
			ans[i] += dp[c][d][i];
			if (a - 1 >= 0 && b - 1 >= 0) {
				ans[i] += dp[a - 1][b - 1][i];
			}
			if (a - 1 >= 0) {
				ans[i] -= dp[a - 1][d][i];
			}
			if (b - 1 >= 0) {
				ans[i] -= dp[c][b - 1][i];
			}
		}
		REP(i,3) {
			cout << ans[i];
			cout << (i == 2 ? "\n" : " ");
		}
	}
	return 0;
}

Measured memory_bytes: 16752
w,h,n=map(int,input().split())
s=[[0 for _ in range(w)]]*h
#print(s)
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        for j in range(h):
            for k in range(0,x):
                s[j][k]=1
    elif a==2:
        for j in range(h):
            for k in range(x,w):
                s[j][k]=1
    elif a==3:
        for j in range(h-y,h):
            s[j]=[1]*w
    elif a==4:
        for j in range(h-y):
            s[j]=[1]*w
#print(s)
ans=0
for i in range(h):
    for j in range(w):
        if s[i][j]==0:
            ans+=1
print(ans)
        

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	long long A, B, C, K, ans, i;
	cin >> A; cin >> B; cin >> C; cin >> K;

	ans = A;
	if (ans < B)
		ans = B;
	if (ans < C)
		ans = C;

	if (ans == A) {
		for (i = 1; i <= K; i++)
			A = A*2;
	}

	else if (ans == B) {
		for (i = 1; i <= K; i++)
			B = B*2;
	}

	else if (ans == C) {
		for (i = 1; i <= K; i++)
			C = C*2;
	}
	
	ans = A + B + C;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
bool vis[220010];
char s[220010];
bool check(int x, int y, int len)
{
    vis[0]=x;
    vis[1]=y;
    for(int i=2; i<=len+1; i++)
    {
        if(vis[i-1])
        {
            if(s[i-1]=='o') 
                vis[i]=vis[i-2];
            else 
                vis[i]=!vis[i-2];
        }
        else
        {
            if(s[i-1]=='o') 
                vis[i]=!vis[i-2];
            else 
                vis[i]=vis[i-2];
        }
    }
    if(vis[len]==vis[0]&&vis[len+1]==vis[1])
    {
        for(int i=0;i<len;i++)
        {
            if(vis[i])
                printf("S");
            else
                printf("W");
        }
        puts("");
        return 1;
    }
    return 0;
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        scanf("%s",s);
        int len=n;
        s[len]=s[0];
        s[len+1]=s[1];
        s[len+2]='\0';
        bool fl=0;
        for(int i=0;i<2;i++)
        {
            for(int j=0;j<2;j++)
            {
                if(check(i,j,len))
                {
                    fl=1;
                    break;
                }
            }
            if(fl) 
                break;
        }
        if(!fl)
            puts("-1\n");
    }
    return 0;
}

Measured memory_bytes: 512
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N, T;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>T;
	int min = 10000000;
	for (size_t i = 0; i < N; i++)
	{
		int c, t;
		in >> c >> t;
		if (t <= T) {
			min = std::min(min, c);
		}
	}
	if (min < 10000000) {
		out << min << endl;
	}
	else {
		out << "TLE" << endl;
	}

	return 0;
}
#endif

#if 0
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	int last = 1;
	for (int i = 2; i*i <= M; ++i)
	{
		if (M%i!=0) {
			continue;
		}

		if (i >= N) {
			out << M / i << endl;
			return 0;
		}

		if (M / i < N) {
			out << last << endl;
			return 0;
		}
		last = i;
	}

	out << last << endl;
	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

const int N = 3e5;
bool seen[N];
vector<int> adj[N];
int dfs(int u) {
  if (seen[u]) return 0;
  seen[u] = 1;
  int r = 1;
  for (int v: adj[u]) {
    r += dfs(v);
  }
  return r;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, m; cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int ans = 0;
  for (int u = 1; u <= n; u++) {
    ans = max(ans, dfs(u));
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 23240
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,j,h,w;
  cin >> h >> w;
  int x[110][110];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      char s;
      cin >> s;
      if(s=='.'){
        x[i][j]=0;
      }
      else{
        x[i][j]=1;
      }
    }
  }
  for(i=0;i<h;i++){
    int res=0;
    for(j=0;j<w;j++){
      if(x[i][j]==1){
        res=1;
        break;
      }
    }
    if(res==0){
      for(j=0;j<w;j++){
        x[i][j]=-1;
      }
    }
  }
  for(i=0;i<w;i++){
    int res=0;
    for(j=0;j<h;j++){
      if(x[j][i]==1){
        res=1;
        break;
      }
    }
    if(res==0){
      for(j=0;j<h;j++){
        x[j][i]=-1;
      }
    }
  }
  for(i=0;i<h;i++){
    int res=0;
    for(j=0;j<w;j++){
      if(x[i][j]==0){
        cout << '.';
        res=1;
      }
      else if(x[i][j]==1){
        cout << '#';
        res=1;
      }
    }
    if(res==1){
      cout << endl;
    }
  }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define pp pair<ll,ll>
#define vi vector<pair<pp,pp> >
#define pq_min priority_queue<ll,vector<ll>,greater<ll>>
#define pq_max priority_queue<ll>
#define forx(i,a,b) for(ll i=0;i<a;i++)
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define ld long double
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef pair<pp,pp> ppll;
const ll mod=1e9+7;
 
 bool check(string s)
 {
 	string h=s;
 	reverse(h.begin(),h.end());
 	if(s==h)
 	{
 		return true;
    }
    return false;
 }
 int main()
 {
 	fast;
 	string s;
 	cin>>s;
 	if(check(s)==false)
	{
	   cout<<"No"; return 0;
    }
 	ll n=s.length();
 	string a=s.substr(0,n/2);
 	if(check(a)==false) {
	 cout<<"No"; return 0;}
 	a=s.substr(n/2 + 1);
 	if(check(a)==false) {
	 cout<<"No"; return 0;}
 	cout<<"Yes";
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>

#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[201];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    char c;
    string s,s1;
    //priority_queue<int> pq;
    map<string,int> mp;
    map<string,int>::iterator iter;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s;
        iter=mp.find(s);
        if(iter==mp.end())
            mp.insert(pair<string,int>(s,1));
        else
            iter->second+=1;
    }
    cin>>m;
    for(j=0;j<m;j++)
    {
        cin>>s;
        iter=mp.find(s);
        if(iter==mp.end())
            mp.insert(pair<string,int>(s,-1));
        else
            iter->second-=1;
    }
    sum=mp.begin()->second;
    for(iter=mp.begin();iter!=mp.end();iter++)
    {
        a=iter->second;
        sum=max(a,sum);
    }
    if(sum>=0) cout<<sum;
    else cout<<0;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a=0,b=0,c=0,d=0;
    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
            a++;
        else if(s=="WA")
            b++;
        else if(s=="TLE")
            c++;
        else
            d++;
    }
    cout<<"AC"<<" " <<"x"<<" "<<a<<endl;
    cout<<"WA"<<" " <<"x"<<" "<<b<<endl;
    cout<<"TLE"<<" " <<"x"<<" "<<c<<endl;
    cout<<"RE"<<" " <<"x"<<" "<<d<<endl;
}


Measured memory_bytes: 3636
program jihanki
  implicit none
  integer :: i, j, n
  integer :: a, b, k
  integer :: count
  integer, allocatable :: p(:)

  read(*,*)a,b,k
  n=min(a,b)
  allocate(p(n))

  i=n+1
  do while (i>0)
     i=i-1
     if (mod(a,i)==0 .and. mod(b,i)==0) then
        count=count+1
     end if
     if (count==k) then
        write(*,*)i
        exit
     end if
  end do
  
end program jihanki

Measured memory_bytes: 640
import sys

(x, y) = map(int, sys.stdin.readline().strip().split())

if y % 2 == 1:
    print('No')
    sys.exit()

b = -x + y/2
a = x - b

if a < 0 or b < 0:
    print('No')
else:
    print('Yes')

"""
a: 鶴の数、b: 亀の数
a + b = x -> 2a + 2b = 2x
2a + 4b = y

より
2b = -2x + y -> b = -x + 1/2y
"""

Measured memory_bytes: 61784
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main() {
  int N;
  string X;
  IN(N);
  IN(X);
  if(N>=3200) OUT(X);
  else OUT("red");
}

Measured memory_bytes: 256
import java.util.*;

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

		while(true){
			double x = sc.nextDouble();
			if(x == -1) break;

			int left = (int)x;
			String leftS = Integer.toString(left,2);

			if(leftS.length() > 8){
				System.out.println("NA");
				continue;
			}

			double right = x % 1;
			String rightS = "";
			int rem = 4;

			while(rem-- > 0 && right != 0){
				right *= 2;
				rightS += (int)right;
				right %= 1;
			}

			if(right != 0){
				System.out.println("NA");
				continue;
			}

			while(leftS.length() != 8) leftS = "0" + leftS;
			while(rightS.length() != 4) rightS += "0";

			System.out.println(leftS + "." + rightS);
		}
	}
}

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


int main()
{
    ll n; cin>>n;
    ll ax,bx; cin>>ax>>bx;
    n--;
    while(n--)
    {
        ll a,b; cin>>a>>b;
        ll xx=(ax+a-1)/a;
        xx=max(xx,(bx+b-1)/b);
        ax=xx*a;
        bx=xx*b;
    }
    cout<<ax+bx;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

n = 0
nmax = 0
for i in range(N - 1):
    if H[i + 1] <= H[i]:
        n += 1
        continue
    if nmax < n:
        nmax = n
    n = 0
if nmax < n:
    nmax = n
print(nmax)


Measured memory_bytes: 63984
def bubble_sort(l):
    N = len(l)
    isChange = True
    while isChange:
        isChange = False
        for i in range(N-1):
            if(l[i] > l[i+1]):
                l[i], l[i+1] = l[i+1], l[i]
                isChange = True
    return l

l = input().split()
out = bubble_sort(l)
print("{} {} {}".format(out[0], out[1], out[2]))

Measured memory_bytes: 5560
import java.util.Scanner;

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

		int A[] = new int[M];

		for (int i = 0; i < M; i++) {
			A[i] = sc.nextInt();
		}

		for (int i = 0; i < M; i++) {
			N -= A[i];
		}
		if (N >= 0) {
			System.out.println(N);
		} else {
			System.out.println(-1);
		}
	}
}


Measured memory_bytes: 46260
#include <stdio.h>
int main(void){
    int d;
    scanf("%d",&d);
    int a[30];
    for(int i=0;i<30;i++)a[i]=0;
    char c[100005];
    scanf("%s",c);
    for(int i=0;i<d;i++){
        a[c[i]-'a']++;
    }
    long long p=1000000007;
    long long ans=1;
    for(int i=0;i<26;i++){
        ans*=a[i]+1;
        ans%=p;
    }
    printf("%lld\n",(ans-1+p)%p);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  ll k;
  cin >> k;
  vector<ll> A(n), B(m), sumA(n+1), sumB(m+1);
  rep(i, n) {
    cin >> A[i];
    sumA[i+1] = sumA[i] + A[i];
  }
  rep(i, m) {
    cin >> B[i];
    sumB[i+1] = sumB[i] + B[i];
  }
  int ans = 0;
  rep(i, n+1) {
    if(sumA[i] > k) break;
    int j = upper_bound(all(sumB), k-sumA[i])-begin(sumB)-1;
    ans = max(i+j, ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
  
using namespace std;
const int inf = 1e9 + 7;
 
 
signed main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
 
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
 
    string s;
    cin >> s;
    int n = s.size();
    bool bad = false;
    for(int i = 0;i < (n - 1) / 2;i++) {
    	if (s[i] != s[(n - 1) / 2 - i - 1]) bad = true;
    	if (s[i + (n + 3) / 2 - 1] != s[n - i - 1]) bad = true;
    	if (s[i] != s[n - i - 1]) bad = true;
    }

    if (bad) cout << "No";
    else cout << "Yes";
 
}

Measured memory_bytes: 256
n=int(input())
A = []
for i in range(n):
  a = int(input())
  A.append([a,i])
A.sort()

i = A[-1][1]
for j in range(n):
  if j != i:
    print(A[-1][0])
  else:
    print(A[-2][0])
   

Measured memory_bytes: 37884
#include <iostream>
#include <utility>
#include <cstdlib>

const int MAXN = (int)1e5 + 3;
const int64_t INF = (int64_t)1e15;
int64_t s[MAXN];
int64_t t[MAXN];

int binary_search(int64_t a[], int n, int64_t x) {
  int l = 1, r = n;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (a[mid] <= x)
      l = mid;
    else
      r = mid;
  }
  return l;
}

std::pair<int64_t, int64_t> get(int64_t a[], int n, int64_t x) {
  std::pair<int64_t, int64_t> res(-INF, INF);
  if (x <= a[1]) 
    res = std::make_pair(-INF, a[1]);
  else if (x >= a[n])
    res = std::make_pair(a[n], INF);
  else {
    int index = binary_search(a, n, x);
    res = std::make_pair(a[index], a[index + 1]);
  }
  return res;
}

int64_t calc(int64_t x, std::pair<int64_t, int64_t> u, std::pair<int64_t, int64_t> v) {
  int64_t uf = u.first, us = u.second;
  int64_t vf = v.first, vs = v.second;
  int64_t res = abs(x - uf) + abs(uf - vf);
  res = std::min<int64_t>(res, abs(x - uf) + abs(uf - vs));
  res = std::min<int64_t>(res, abs(x - us) + abs(us - vf));
  res = std::min<int64_t>(res, abs(x - us) + abs(us - vs));
  return res;
}

int64_t solve(int n, int m, int64_t x) {
  std::pair<int64_t, int64_t> u = get(s, n, x);
  std::pair<int64_t, int64_t> v = get(t, m, x);
  return std::min(calc(x, u, v), calc(x, v, u));
}

int main() {
  int n, m, q;
  std::cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) 
    std::cin >> s[i];
  for (int i = 1; i <= m; ++i)
    std::cin >> t[i];
  for (int i = 1; i <= q; ++i) {
    int64_t x;
    std::cin >> x;
    std::cout << solve(n, m, x) << std::endl;
  }
  return 0;
}


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

int main(){
    int N;
    while(cin >> N, N){
        vector<int> vec(N);
        for(auto &v: vec)
            cin >> v;
        sort(vec.begin(), vec.end());
        int diff = 1e7;
        for(int i=1; i<N; i++){
            diff = min(diff, vec[i]-vec[i-1]);
        }
        cout << diff << endl;
    }
    return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int n , a, ans = 0 ;
  set<int> numbers ;
  scanf("%d",&n) ;

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

    if(numbers.find(a) == numbers.end()){
      ans++ ;
      numbers.insert(a) ;
    }
    else{
      ans-- ;
      numbers.erase(a) ;
    }
  }
  cout << ans << endl ;
	
  return 0 ;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    double r;
    cin>>r;
    printf("%.10f\n", r * 2 * PI);
}

Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
long long sum = 0;

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

int main() {
    cin >> N >> K;
    int v[50];
    rep(i, N) cin >> v[i];
    for(int i=0;i<=min(N, K);i++){
        for(int j=0;i+j<=min(N, K);j++){
            ll count = 0;
            vector<int> vec;
            rep(k, i){
                count += v[k];
                vec.push_back(v[k]);
            }
            for(int k=N-j;k<N;k++){
                count += v[k];
                vec.push_back(v[k]);
            }
            sort(vec.begin(), vec.end());
            for(int k=0;k<vec.size() && k<K-i-j && vec[k]<0;k++) count -= vec[k];
            max_value = max(max_value, count);
        }
    }
    cout << max_value;
}

Measured memory_bytes: 256
def lcs c1, c2, l, m
	dp = Array.new(m + 1){0}
	l.times do |i|
		tmp = dp.dup
		m.times do |j|
			jj = j + 1
			if c1[i] == c2[j]
				dp[jj] = tmp[jj - 1] + 1
			elsif  dp[jj] < dp[jj - 1] 
				dp[jj] = dp[jj - 1]
			end
		end
	end
	return dp[-1]
end

n = gets.to_i
n.times do
	c1 = gets.chomp.split("")
	c2 = gets.chomp.split("")
	puts lcs(c1, c2, c1.size, c2.size)
end

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int N; cin >> N;
    vector<bitset<10>> F(N);
    rep(i, N) {
        bitset<10> bs;
        rep(j, 10) {
            int f; cin >> f;
            bs.set(j, f);
        }
        F[i] = bs;
    }

    vector<vector<int>> P(N, vector<int>(11));
    cin >> P;

    vector<int> c(N, 0);
    int ans = INT_MIN;
    for (int i = 1; i < (1<<10); i++) {
        bitset<10> joisino(i);
        for (int j = 0; j < N; j++) {
            c[j] = (joisino & F[j]).count();
        }
        int profit = 0;
        for (int j = 0; j < N; j++) {
            profit += P[j][c[j]];
        }
        chmax(ans, profit);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256