akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int d,g;cin >> d >> g;
	vector<int> p(d), c(d);
	rep(i,d) cin >> p.at(i) >> c.at(i);
	int ans = 1e9;
	rep(mask, (1 << d)){
		int sum = 0, cnt = 0;
		rep(i,d){
			if((1 << i) & mask){
				sum += c.at(i) + p.at(i) * (i + 1) * 100;
				cnt += p.at(i);
			}
		}
		if(sum >= g){
			ans = min(cnt, ans);
			continue;
		}
		for(int i = d - 1; i >= 0; i--){
			if(((1 << i) & mask) == 0){
				if((p.at(i) - 1) * (i + 1) * 100 + sum < g) break;
				int t = (g - sum + (i + 1) * 100 - 1) / ((i + 1) * 100);
				ans = min(ans, cnt + t);
				break;
			}
		}
	}
	cout << ans << endl;
}


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

int main(){
  int n;
  string s[30];

  while(cin >> n){
    for(int i=0;i<n;i++)cin >> s[i];

    int num[10];
    bool dual[10];
    for(int i=0;i<=6;i++){
      num[i] = 0;
      dual[i] = false;
    }

    for(int i=0;i<n;i++){
      if(s[i][0] == s[i][1])dual[s[i][0] - '0'] = true;
      num[s[i][0] - '0']++;
      num[s[i][1] - '0']++;
    }

    int odd = 0;
    bool f = true;
    for(int i=0;i<=6;i++){
      if(num[i]&1)odd++;
      else if(dual[i]){
	if(num[i]<=2 && n!=1)f = false;
      }
    }
    if(odd>2)f = false;

    if(f)cout << "Yes\n";
    else cout << "No\n";
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int D[9] = {0};

bool check(int target) {
  return D[target] == 1;
}

bool all_check(int target) {
  std::string tmp = std::to_string(target);
  bool result = true;
  for (auto it = tmp.begin(); it != tmp.end(); it++) {
    if (check(*it-'0')) result = false;
  }

  return result;
}

/*
std::string convert(int str) {
  if (check(str)) {
    str++;
  }
  return std::to_string(str);
}

int solve(int N) {
  std::stack<std::string> st;
  std::string str_N = std::to_string(N);
  
  for (auto it = str_N.begin(); it != str_N.end(); it++) {
    auto tmp = convert(*it - '0');
    st.push(tmp);
  }

  std::string result = "";
  while (st.size()) {
    result = st.top() + result;
    st.pop();
  }

  return std::stoi(result);
}
*/

int main() {
  int N, K;
  std::cin >> N >> K;
  
  REP(i, K) {
    int tmp;
    std::cin >> tmp;
    D[tmp] = 1;
  }

  while (1) {
    if (all_check(N)) break;
    N++;
  }

  std::cout << N << std::endl;
  return 0;
}



Measured memory_bytes: 764
#include <stdio.h>

int fen(int n)
{
    int s=0;
    while(n)
    {
        s+=n%10;
        n/=10;
    }
    return s;
}

int main()
{
    int n;
    scanf("%d",&n);
    int a,b;
    int ans=15654615;
    for(a=1;a<=n/2;a++)
    {
        b=n-a;
        int t=fen(a)+fen(b);
        if(ans>t)
        {
            ans=t;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  max(x,y)          ((x>y)?x:y)
#define  min(x,y)          ((x<y)?x:y)
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;


const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}



ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}





int main(){
ll n,d;cin>>n>>d;
ll ans = 0;
rep(i,n){
    ll x,y;cin>>x>>y;
    if(x*x + y*y <=d*d){ans++;}


}
cout<<ans;
}


Measured memory_bytes: 3576
S = list(input())
ans = 'AC'

if S[0] != 'A':
    ans = 'WA'
if S[2:len(S) - 1].count('C') != 1:
    ans = 'WA'

tmp = 0
for s in S:
    if ord('a') <= ord(s) <= ord('z'):
        tmp += 1


if tmp != (len(S) - 2):
    ans = 'WA'

print(ans)

Measured memory_bytes: 3064
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

const int MAX_N = 20;
const double EPS = 1e-9;
int x[MAX_N], y[MAX_N];
bool can_move[MAX_N][MAX_N][MAX_N];
double dist[MAX_N][MAX_N], dp[10001][MAX_N][MAX_N];

double turn(int ax, int ay, int bx, int by) {
	const double dot = ax * bx + ay * by, a_d = hypot(ax, ay), b_d = hypot(bx, by);
	return M_PI - fabs(acos(dot / (a_d * b_d)));
}

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

	int n;
	double r, theta;
	cin >> n >> r >> theta;
	theta = theta * M_PI / 180.0;

	for(int i = 0; i < n; ++i)
		cin >> x[i] >> y[i];

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

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

				const double a = turn(x[i] - x[j], y[i] - y[j], x[k] - x[j], y[k] - y[j]);
				if(a + EPS < theta)
					can_move[i][j][k] = can_move[k][j][i] = true;
			}
		}
	}

	for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j)
			dist[i][j] = dist[j][i] = hypot(x[i] - x[j], y[i] - y[j]);

	for(int i = 1; i <= 10000; ++i)
		for(int j = 0; j < n; ++j)
			for(int k = 0; k < n; ++k)
				dp[i][j][k] = INT_MAX;

	for(int i = 0; i < n; ++i)
		if(i != 0)
			dp[1][0][i] = dist[0][i];

	int ans = 0;
	for(int i = 1; i <= 10000; ++i) {
		for(int j = 0; j < n; ++j) {
			for(int k = 0; k < n; ++k) {
				if(dp[i][j][k] + EPS < r) {
					ans = i;
					for(int l = 0; l < n; ++l)
						if(can_move[j][k][l])
							chmin(dp[i + 1][k][l], dp[i][j][k] + dist[k][l]);
				}
			}
		}
	}

	cout << ans << endl;	

	return EXIT_SUCCESS;
}

Measured memory_bytes: 32576
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

ll dp[1100][1 << 12];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,m;
    cin >> n >> m;
    rep(i, 1100){
        rep(j, 1 << n){
            dp[i][j] = LLINF;
        }
    }
    dp[0][0] = 0;
    rep(i, m){
        ll a, b;
        cin >> a >> b;
        ll tre = 0;
        rep(j, b){
            int c;
            cin >> c;
            c--;
            tre |= 1 << c;
        }
        rep(j, 1 << n){
            chmin(dp[i + 1][j], dp[i][j]);
            chmin(dp[i + 1][j | tre], dp[i][j] + a);
        }
    }
    if(dp[m][(1 << n) - 1] == LLINF) print(-1);
    else print(dp[m][(1 << n) - 1]);
    

}


Measured memory_bytes: 35456
const main = (input) => {
  input = input.split('\n');
  const N = parseInt(input[0], 10);
  const S = input[1];
  const x = 0;
  const max = 0;
  for (const i = 0; i<N i++) {
    if (S[i] == 'I') {
      x++;
      max = Math.max(max, x);
    }else{
      x--;
    }
    max = Math.max(max, x);
  }
  console.log(max);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	answers := make([]int, n, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		tmp, _ := strconv.Atoi(sc.Text())
		answers[tmp - 1] = i + 1
	}

	for i := 0; i < n; i++ {
		fmt.Print(answers[i])
		fmt.Print(" ")
	}
	fmt.Print("\n")
}

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int N,t[1000];

int dp[2][1000];
int rec(int sec,int last){
  if(dp[sec][last]>=0)return dp[sec][last];
  int &ret=dp[sec][last];
  
  if(last<=1)return last==0||sec?t[0]:t[1];
  if(last==2&&sec)return t[2];
  
  ret=(int)1e9;
  if(sec==0){
    ret=min(ret,rec(1,last)+t[0]+t[1]);
  }
  else{
    if(last>2)ret=min(ret,rec(0,last-2)+t[last]+t[1]);
    ret=min(ret,rec(1,last-1)+t[last]+t[0]);
  }
  return ret;
}
int main(){
  scanf("%d",&N);
  rep(i,N)scanf("%d",t+i);
  sort(t,t+N);
  
  if(N<=2){
    printf("%d\n",N==1?t[0]:t[1]);
    return 0;
  }
  
  memset(dp,-1,sizeof(dp));
  printf("%d\n",rec(0,N-1));
  
  return 0;
}


Measured memory_bytes: 1260
N, K = map(int, input().split())
S = input()

left = 0
right = 0
ans = 0
remain = K
S += "?"
if S[0] == "0":
    remain -= 1

while left < N:
    while right < N and remain >= 0:
        if S[right] == "1" and S[right + 1] == "0":
            remain -= 1
        right += 1
    ans = max(ans, right - left)
    if left == right:
        right += 1
    else:
        if S[left] == "0" and S[left + 1] == "1":
            remain += 1
    left += 1
print(ans)


Measured memory_bytes: 3316
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Long N = sc.nextLong();
        Long[] cities = new Long[5];
        for(int i = 0 ; i < 5 ; i++){
            cities[i] = sc.nextLong();
        }
        sc.close();

        Arrays.sort(cities);
        long min = cities[0];

        long ans = 0 ;
        ans += N/min;

        if(N%min != 0){
            System.out.println(ans + 5);
        }
        else{
            System.out.println(ans + 4);
        }
    }
}

Measured memory_bytes: 21844
import numpy as np

N = input()
N = int(N)
a = []
for i in range(0,N):
    S, P = map(str,input().split())
    P = int(P)
    a.append([i,S,P])

b = sorted(a, key=lambda x:(x[1],-x[2]))
for j in range(0,N):
    print(b[j][0]+1)


Measured memory_bytes: 12500
using System;
using System.Collections.Generic;

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //long mx = 1000000000000001L;
            var c = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
            //var c = new char[] { '0','1','2','3','4','5','6','7','8','9' };

            var n = long.Parse(Console.ReadLine());
            var ca = new List<char>();
            for(; ; )
            {
                if (n == 0) break;
                var md = n % 26L;

                if (md > 0)
                {
                    ca.Add(c[md - 1]);
                }
                else { 
                    ca.Add('z');
                    n--;
                }
                n /= 26L;
            }

            ca.Reverse();
            string result = new string(ca.ToArray());

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27836
# coding: utf-8
memo={}
def fib(n):
    if n==0 or n==1:
        return 1
    else:
        if n-1 not in memo:
            memo[n-1]=fib(n-1)
        if n-2 not in memo:
            memo[n-2]=fib(n-2)
        return memo[n-1]+memo[n-2]

print(fib(int(input())))


Measured memory_bytes: 5604
import itertools
import fractions
def main():
  A = list(map(int,input().split()))
  A_ = sorted(A)
  dp = [0]*3
  dp[0] = 0
  for i in range(2):
    dp[i + 1] = dp[i] + (A_[i+1]-A_[i])
  print(dp[2])
if __name__ == '__main__':
  main()

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

int digit(int N){
  int cnt=0;
  while(N>0){
    N/=10;
    cnt++;
  }
  return cnt;
}

int main(){
  int N;
  cin >> N;
  int cnt=0;
  for(int i=1; i<=N; i++){
    if(digit(i)%2==1) cnt++;
  }
  cout << cnt <<endl;
}

Measured memory_bytes: 256
def dist(d1, d2):
    return abs(d1[0] - d2[0]) + abs(d1[1] - d2[1])


h, w, d = map(int, input().split())

table = {}

for i in range(h):
    a = list(map(int, input().split()))
    for j in range(w):
        table[a[j]] = (j + 1, i + 1)

cum = [0] * (h * w + 1)
for i in range(h * w + 1):
    if i > d:
        cum[i] = cum[i - d] + dist(table[i], table[i - d])


q = int(input())
for i in range(q):
    l, r = map(int, input().split())
    print(cum[r] - cum[l])



Measured memory_bytes: 84236
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<cmath>
#include<stack>
#include<algorithm>
#define rg register
#define ll long long
#define LDB long double
#define ull unsigned long long
#define view(i,x) for(rg int i=hd[x];i!=-1;i=e[i].nt)
#define go(i,x,a) for(rg int i=a;i<x;i++)
#define inf 0x3f3f3f3f
#define INF 0x7fffffff
using namespace std;

const int maxn=1e5+5;
int n,m;
ll a[maxn],ans=0,p[maxn],ss=0;
ll pre[maxn];

inline int rd(){
	int ret=0,af=1; char gc=getchar();
	while(gc < '0' || gc > '9'){ if(gc=='-') af=-af; gc=getchar(); }
	while(gc >= '0' && gc <= '9') ret=ret*10+gc-'0',gc=getchar();
	return ret*af;
}

int main(){
	//freopen("data.in","r",stdin);
	//freopen("1.out","w",stdout);
	n=rd(); m=rd();
	go(i,n+1,1) a[i]=rd(),ss+=a[i];
	sort(a+1,a+n+1);	
	go(i,n+1,1){
		p[i]=p[i-1]+a[i];
		pre[i]= i>=2?pre[i-2]+a[i]:a[i];
	}
	go(i,m+1,1){
		ans=0;
		ll x=rd(); int pos=lower_bound(a+1,a+n+1,x)-a-1;
		if(x >= a[n]){
			printf("%lld\n",pre[n]); continue;
		}
		int l=pos+1,r=n,p1,p2,mid=l,res=l;
		while(l <= r){
			mid=(l+r)/2;
			p1=lower_bound(a+1,a+n+1,x-(a[mid]-x))-a;
			p2=lower_bound(a+1,a+n+1,x-(a[mid-1]-x))-a;
			if(mid-p2 <= n-mid+1 && n-mid+1 <= mid-p1){
				res=mid; break;
			}
			if(mid-p2 > n-mid+1) r=mid-1;
			else l=mid+1,res=mid;
		}
		while(n-res+1 > res-p2 && p2 > 1) p2--;
		ans=p[n]-p[res-1]+pre[p2-1];
		printf("%lld\n",ans);
	}
	return 0;
}//Faze


Measured memory_bytes: 4096
#include <iostream>
#include <map>
#include <queue>
#include <vector>

#define N 100001

using namespace std;

bool is_valid(vector<int> vis)
{
    for(auto it = vis.begin(); it != vis.end(); it++) {
        if(*it == -1) {
            return false;
        }
    }
    return true;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int a, b;
    map<int, vector<int>> path;
    for(int i = 0; i < m; i++) {
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    vector<int> vis(n+1, -1);
    vis[0] = 0;

    // bfs
    queue<pair<int,int>> que;
    que.push(make_pair(1, 0));

    while(!que.empty()) {
        pair<int, int> tmp = que.front();
        que.pop();
        int room = tmp.first;

        for(auto it = path[room].begin(); it != path[room].end(); it++) {
            if(vis[*it] == -1) {
                vis[*it] = room;
                que.push(make_pair(*it, tmp.second+1));
            }
        }
    }

    if(is_valid(vis)) {
        cout << "Yes" << endl;
        for(int i = 2; i <= n; i++) {
            cout << vis[i] << endl;
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 16200
import math
import bisect
def get_prime(number):
    prime_list = []
    search_list = list(range(2,number + 1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list

l = get_prime(100000)
l2 = []
for i in range(len(l)):
    x = l[i]
    y = (x+1)//2
    if y in l:
        l2.append(x)
        
Q = int(input())
for i in range(Q):
    a,b = map(int, input().split())
    x = bisect.bisect_left(l2, a)
    y = bisect.bisect_right(l2, b)
    print(y-x)


Measured memory_bytes: 13144
import math

a,b,x = map(int, input().split())

left = 0
right = (1/2)*math.pi
ret = left
eps = 10**(-7)
eeps = 10**(-9)

def calc_area(t):
    if t < math.atan(b/a):
        base_area = a*b
        upper = a*a*( math.tan(t) )/2
        area = base_area-upper
    else: 
        area = b*b*( math.tan(t)**(-1) )/2
    
    return area*a

ret = (right+left)/2

while True:
    diff = calc_area(ret)-x
    # print(ret*(180/math.pi), calc_area(ret),left, right, diff)
    if abs(diff) < eps: break
    
    if diff < 0:
        right = ret
    else:
        left = ret
        
    ret = (right+left)/2

print(ret*(180/math.pi))

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */
int main() {
	ll x,c;
	scanf("%lld", &x);
	if (0 < x % 11 && x % 11 < 7)c = 1;
	else c = 2;
	printf("%lld\n", (x - 1) / 11 * 2 + c);
	return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n)	 for(int i = 0; i < (n); i++)
#define all(a)		 begin(a), end(a)

typedef long long int		   ll;
typedef long long unsigned int llu;

void solve(ll A, ll B, ll C, ll D) {
	int x = 0;
	rep(i, 100) {
		if(i >= A && i <= B && i >= C && i <= D) {
			if(i + 1 >= A && i + 1 <= B && i + 1 >= C && i + 1 <= D) {
				x++;
			}
		}
	}
	printf("%d", x);
}

int main() {
	ll B;
	ll D;
	ll A;
	ll C;
	scanf("%lld", &A);
	scanf("%lld", &B);
	scanf("%lld", &C);
	scanf("%lld", &D);
	solve(A, B, C, D);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    string s;
    cin >> s;
    auto n = s.length();
    for (size_t i = 0 ; i < n; ++i) {
        cout << "x";
    }
    cout << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

class MyClass
{
    static void Main(string[] args)
    {
        int N, d, t, q;
        while ((N = int.Parse(Console.ReadLine())) != 0)
        {
            int[][] Q = new int[25][];
            for (int i = 0; i < 25; i++)
            {
                Q[i] = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            }
            for (int i = 0; i < N; i++)
            {
                string[] str = Console.ReadLine().Split(' ');
                d = int.Parse(str[0]);
                t = int.Parse(str[1]);
                for (int j = 0; j < d; j++)
                {
                    q = int.Parse(str[j + 2]);
                    Q[d][(j + d - t) % d] += q;
                }
            }
            const int L = 55440;
            int sum = 0;
            int[] T = new int[L];
            for (int i = 0; i < L; i++)
            {
                T[i] = 0;
            }
            for (int i = 1; i <= 24; i++)
            {
                if (i != 13 && i != 17 && i != 19 && i != 23)
                {
                    for (int j = 0; j < L; j++)
                    {
                        T[j] += Q[i][j % i];
                    }
                }
                else
                {
                    sum += Q[i].Max();
                }
            }
            Console.WriteLine(sum + T.Max());
        }
    }
}


Measured memory_bytes: 6944
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()



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

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

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

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res


def main():

    ide_ele =0

    def segfunc(x, y):
        return max(x, y)

    N,K =map(int,input().split())

    a = [0]*300002
    seg = SegTree(a,segfunc,ide_ele)

    for i in range(N):
        number =int(input())
        mma = seg.query(max(0,number-K), min(300001, number+K)+1)
        seg.update(number,mma+1)


    print(seg.query(0,300002))












if __name__ == "__main__":
    main()


Measured memory_bytes: 81412
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val Array(h, a) = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      (h / a) + (if (h % a == 0) 0 else 1)
    )
  }
}


Measured memory_bytes: 25540
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  int64_t ans = 0;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int k=1; k<=K; k++){
        int x = gcd(i,j);
        ans += gcd(x,k);
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        mut instructions: [(usize, usize); m],
    }
    
    let instructions: Vec<(usize, usize)> = instructions.iter().map(|inst| (inst.0-1, inst.1)).collect();
    let mut integer: Vec<Option<usize>> = vec![None; n];

    for instruction in &instructions {
        if n != 1 && instruction.0 == 0 && instruction.1 == 0 {
            println!("{}", -1);
            return;
        } 
        if let Some(num) = integer[instruction.0] {
            if num != instruction.1 {
                println!("{}", -1);
                return;
            }
        } else {
            integer[instruction.0] = Some(instruction.1)
        }
    }

    for (i, number) in integer.iter().enumerate() {
        match number {
            Some(num) => print!("{}", num),
            None => {
                if i == 0 && n != 1 {
                    print!("{}", 1);
                } else {
                    print!("{}", 0);
                }
            }
        }
    }

    println!();
}


Measured memory_bytes: 2188
import math

def comb(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)

def main():
    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())
    for i in range(1,K+1):
        if i > N - K + 1:
            print(0)
            continue
        blue = comb(N-K+1,i) % MOD
        red = comb(K-1,i-1) % MOD

        ans = blue * red % MOD

        print(ans)
            

main()

Measured memory_bytes: 69976
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

const int N = 10, M = N * N;

int h[N], e[M], ne[M], idx;
void add(int a, int b)
{
    e[idx] = b;
    ne[idx] = h[a];
    h[a] = idx ++;
}

int n, m, res;

void dfs(int u, int state)
{
    if(state == (1 << n) - 1)
    {
        res ++;
        return;
    }
    
    for(int i = h[u]; ~i; i = ne[i])
    {
        int j = e[i];
        if(!(state >> j & 1))
            dfs(j, state | (1 << j));
    }
}

int main()
{
    memset(h, -1, sizeof h);
    
    scanf("%d%d", &n, &m);
    while(m --)
    {
        int a, b;
        scanf("%d%d", &a, &b);
        a --, b --;
        add(a, b);
        add(b, a);
    }
    
    dfs(0, 1);
    
    printf("%d", res);
    return 0;
}

Measured memory_bytes: 760
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

class B121 {
public:
	void solve(std::istream& in, std::ostream& out) {
        string a,b;
        in>>a>>b;
        int n = stoi(a+b);
        double res = sqrt(n);
        if((int)res==res) out<<"Yes"<<endl;
        else out<<"No"<<endl;


	}
};


int main() {
	B121 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){swap(a,b);}
	if(b>c){swap(c,b);}
	if(a>b){swap(a,b);}
	cout<<a<<" "<<c<<endl;

	return 0;
}


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

typedef long long ll;

const int maxn = 1e5 + 5, mod = 1e9 + 7;
int N;
vector<int> adj[maxn];
ll dp[maxn][2];

ll rec(int u, int p, int pcol) {
    ll& ret = dp[u][pcol];
    if (ret != -1) {
        return ret;
    }
    ll ways = 1, tot = 0;
    if (pcol == 0) {
        for (int v : adj[u]) {
            if (v == p) {
                continue;
            }
            ways = (ways * rec(v, u, 1)) % mod;
        }
        tot = ways;
    }
    ways = 1;
    for (int v : adj[u]) {
        if (v == p) {
            continue;
        }
        ways = (ways * rec(v, u, 0)) % mod;
    }
    tot = (tot + ways) % mod;
    return ret = tot;
}

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

    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    memset(dp, -1, sizeof(dp));
    ll answer = rec(0, -1, 0);
    cout << answer;

    return 0;
}

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

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

int main(void){
    int n, m, a, b, road[50];

    cin >> n >> m;
    REP(i, n) {
        road[i] = 0;
    }

    REP(i, m) {
        cin >> a >> b;
        road[a - 1]++;
        road[b - 1]++;
    }

    REP(i, n) {
        cout << road[i] << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;
using int32 = __uint32_t;

void solve() {
    int n, m;
    cin >> n >> m;

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

    map<int,int> mp;
    mp[0]++;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(i)
         v[i] += v[i - 1];
        ans += mp[v[i] % m];
        mp[v[i] % m]++;
    }
    cout << ans << endl;
}   

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int a[n];
    int first = 0, second = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        if(first < a[i])
            first = a[i];
        else if(second < a[i])
            second = a[i];
    }
    for(int i = 0; i < n; i++){
        if(a[i] == first)
            cout << second << endl;
        else
            cout << first << endl;
    }
    return 0;   
}

Measured memory_bytes: 2432
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @n, @k = gets.to_s.split.map { |v| v.to_i }
  end

  def solve
    eat(n, k)
  end

  def eat(n, k)
    x = length(n)
    case k
    when 0; 0
    when x; meat(n)
    when x + 1; meat(n) + 1
    when ->k { k < x }; eat(n - 1, k - 1)
    when ->k { k > x + 1 }; meat(n) + 1 + eat(n, k - x - 1)
    end
  end

  def show(ans)
    puts ans
  end

  def length(i); 2 ** (i + 2) - 3; end
  def meat(i); 2 ** (i + 1) - 1; end
end

Problem.new.instance_eval do
  show(solve)
end


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

int main(){
	string n;
	cin >> n ;
	if(n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3])
		cout  << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int change_num(char from, char to){
    if(from == to){
        return 0;
    }
    return int(to + 26 - from);
}

char after_alphabet(char from, int num){
    return (from - 'a' + num)% 26 + 'a';
}

int main(void) {
    string s;cin>>s;
    int k;cin>>k;
    int cur=0;
    int n = s.size();
    while(k>0&&cur<n){
        char alphabet = s.at(cur);
        if(cur==n-1){
            s.at(cur) = after_alphabet(s.at(cur), k);
        }else{
            int num = change_num(s.at(cur), 'a');
            if(num<=k){
                s.at(cur) = 'a';
                k -= num;
            }
        }
        cur++;
    }
    cout << s << endl;
    return 0;
}


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


public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int n = in.nextInt();
        int l = in.nextInt();
        int [] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = l + i;
        }
        
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < a.length; i++) {
            if(Math.abs(a[i]) < Math.abs(min)) {
                min = a[i];
            }
        }
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            if(a[i]!=min) {
                sum+=a[i];
            }
        }
        out.println(sum);
        out.flush();
    }

    private static int [] mergeTwoArrays(int [] a, int [] b) {
        int [] res = new int[a.length + b.length];
        int i = 0;
        int j = 0;
        int index = 0;
        while (i<a.length && j<b.length) {
            if(a[i]<b[j]) {
                res[index++] = a[i++];
            }
            else {
                res[index++] = b[j++];
            }
        }
        System.out.println(i + " " + j);
        if(j == b.length - 1) {
            while (i<a.length) {
                res[index++] = a[i++];
            }
        }
        else {
            while (j<b.length) {
                res[index++] = b[j++];
            }
        }
        return res;
    }
}
class Point {
    private int value;
    private int index;
    public int getValue() {
        return value;
    }
    public int getIndex() {
        return index;
    }
    public Point(int value,int index) {
        this.value = value;
        this.index = index;
    }

}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt() {
        return Integer.valueOf(next());
    }
    public Long nextLong() {return  Long.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

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

int main() {
  int n,a = 0,b = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    string s,t;
    cin >> s >> t;
    if(s > t) a += 3;
    else if(s < t) b += 3;
    else{
      a++;
      b++;
    }
  }
  cout << a << " " << b << endl;
}



Measured memory_bytes: 3160
n = int(input())
a = list(map(int, input().split(' ')))

ali = 0
bo = 0

while len(a) > 0:
    ali += a.pop(a.index(max(a)))
    if len(a) == 0:
        break
    bo += a.pop(a.index(max(a)))

print(ali - bo)


Measured memory_bytes: 3060
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
	

int n, m; 

const int N = 2e5 + 100;
unordered_set<int> g[N];

int par[N], rnk[N];

int find_set(int v){
	if(v == par[v])return v;
	return par[v] = find_set(par[v]);
}

void union_set(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
		if(rnk[a] < rnk[b])swap(a, b);
		par[b] = a;
		if(rnk[a] == rnk[b])rnk[a]++;
	}
}

int main(){
   IOS

   cin>>n>>m;

   for(int i = 1; i <= n; i++){
	   par[i] = i;
	   rnk[i] = 0;
   }

   for(int i = 0; i < m; i++){
	   int u, v; cin>>u>>v;
		union_set(u, v);
   }

   unordered_map<int,int> mp;

   for(int i = 1; i <= n; i++){
	   mp[find_set(i)]++;
   }

   int mx = 0;
   for(auto it : mp){
	   mx = max(mx, it.second);
   }

   cout<<mx<<'\n';



	







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
	if(b&1) res = res * a % mod;
		a = a * a % mod;
	b >>= 1;
	}

	return res;
}



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

int main() {
	int A,B,N;
	cin >> N >> A >> B;
	if ( N*A < B ){
		cout << N*A << endl;
	}
	else if ( N*A == B ){
		cout << B << endl;
	}
	else if ( N*A > B ) {
		cout << B << endl;
	}
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N)
    cin >> X[i];
  
  long long ret = -1;
  rep(i, 100) {
    long long tmp = 0;
    rep(j, N) {
      tmp += (i - X[j]) * (i - X[j]);
    }
    if(ret == -1 || tmp < ret)
      ret = tmp;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

typedef enum {false, true} bool;


bool trace(long long xy[][2], long long basis, long long xor_basis, int N, int num, int ctr, int index)
{
    int i, j;
    static int record[15];
    static bool flag;
    static long long temp;
    
    
    if(num == ctr)
    {
        flag = true;
        temp = xor_basis ^ basis;
        
        for(i=0; i<num; i++)
        {
            if(((xy[record[i]][1] & basis) != basis) || (((xy[record[i]][0] ^ xor_basis) & temp) != temp))
            {
                flag = false;
                
                break;
            }
        }
    }
    else
    {
        for(j=index; j<=N-(num-ctr); j++)
        {
            if(ctr == 0)
                basis = 0;
            
            record[ctr] = j;
            
            if(trace(xy, basis | 1<<(N-j-1), xor_basis, N, num, ctr+1, j+1))
                return true;
        }
    }
    
    if(flag)
        return true;
    else
        return false;
}

int main(void)
{
    char c;
    int N;
    int A, x, y;
    
    long long xy[15][2], temp, temp2;
    
    int i, j;
    
    
    scanf("%d%c", &N, &c);
    
    
    for(i=0; i<N; i++)
    {
        scanf("%d%c", &A, &c);
        
        xy[i][0] = 1<<(N-i-1);
        
        xy[i][1] = 1;
        for(j=1; j<N; j++)
            xy[i][1] = xy[i][1]<<1 | 1;
        
        temp = xy[i][1];
        
        for(j=0; j<A; j++)
        {
            scanf("%d%c%d%c", &x, &c, &y, &c);
            
            if(y == 0)
            {
                temp2 = temp ^ 1<<(N-x);
                xy[i][1] &= temp2;
            }
            if(y == 1)
                xy[i][0] |= 1<<(N-x);
        }
    }
    
    for(i=N; i>0; i--)
    {
        if(trace(xy, 0, temp, N, i, 0, 0))
            break;
    }
    
    
    printf("%d\n", i);
    
    
    //system("pause");
    
    return 0;
}


Measured memory_bytes: 256
import std.stdio: writefln, readf, readln;
import std.array: split;
import std.string: chomp;

void main() {
	string[] balls = readln.split;
	int a, b;
	readf("%s %s\n", &a, &b);
	string u = readln.chomp;
	if (u == balls[0])
		a--;
	else
		b--;
	writefln("%s %s", a, b);
}


Measured memory_bytes: 256
S =str(input())
top = int(S[:2])
bot = int(S[-2:])

if 1<= top <= 12:
    if 1 <= bot <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if 1 <= bot <= 12:
        print("YYMM")
    else:
        print("NA")
        

Measured memory_bytes: 2940
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

int A[101];

int main()
{
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&A[i]);
	sort(A,A+n,greater<int>());
	int sum=0;
	for(i=0;i<n;i++)
		if(i%2)sum-=A[i];
		else sum+=A[i];
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int a, b, c, d, e, f = 0, g = 0, h = 0;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);
	if (a>0) {
		g = b - a;
		g = g * e;
		printf("%d\n", g);
	}
	else  {
		f = 0 - a;
		f = f * c;
		g = b * e;
		f = f + d + g;
		printf("%d\n", f);
	}

	return 0;
}

Measured memory_bytes: 1820
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 03 21:23:15 2018

@author: ashida
"""

N = input()

if N == 10 or N == 100 or N == 1000 or N == 10000 or N == 100000:
    print(10)
else:
    ans = 0
    a = N
    while(a > 0):
        ans = ans + a - (a/10)*10
        a = a/10
    print(ans)

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

long long cnt[26];
char str[200005];
int main(){
    scanf("%s",str);
    int n = (int)strlen(str);
    long long ans = n; ans *= (n-1); ans /= 2; ans++;
    for(int i=0;str[i];i++) cnt[str[i]-'a']++;
    for(int i=0;i<26;i++){
        cnt[i] = (cnt[i] * (cnt[i]-1)) / 2;
        ans -= cnt[i];
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 384
/**
 *  author: mahfuzz
 *  created: 13.06.2020
**/
 
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define trace(x) cout << #x << ':' << x << "\n"
typedef long long ll;


int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    string n; cin >> n;
    char c = n[n.size()-1];
    if(c == '0' || c == '1' || c == '6' || c == '8')
        cout << "pon\n";
    else if(c == '3')
        cout << "bon\n";
    else
        cout << "hon\n";

        
    return 0;
}



Measured memory_bytes: 3624
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

int main() {
  size_t n;
  string str;
  cin >> n >> str;
  
  size_t bs = str.find("#");
  if (bs == string::npos) {
    cout << 0 << endl;
    return 0;
  }
  ll state = 1; // black
  ll bc = 0;
  ll wc = 0;
  ll ansb = 0;
  ll answ = 0;
  for (size_t i = bs; i < n; i++) {
    if(state == 0){
      if(str[i] == '.') {
        state = 1;
        wc = 1;
      } else {
        bc++;
      }
    } else {
      if(str[i] == '#') {
        tie(ansb, answ) = P(wc + min(ansb, answ), bc + answ);
        bc = 1;
        wc = 0;
        state = 0;
      } else {
        wc++;
      }
    }
  }
  if(str[n-1] == '.')
    tie(ansb, answ) = P(wc + min(ansb, answ), bc + answ);

  cout << min(answ, ansb) << endl;
  return 0;
}


Measured memory_bytes: 644