akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
int n;
long long v[20][20];
long long cost[1<<17];
long long dp[1<<17];
long long best;

inline long long max(long long a, long long b){
	return a>b?a:b;
}

int main(){

 	scanf("%d", &n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			scanf("%lld", &v[i][j]);
		}
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			for(int k=0;k<n;k++){
				if(i&(1<<j) && i&(1<<k))cost[i]+=v[j][k];
			}
		}
	}
	for(int i=1;i<(1<<n);i++){
		for(int j=i;j>0;j=(j-1)&i){
			dp[i] = max(dp[i], cost[j]/2+dp[i^j]);
			best = max(best, dp[i]);
		}
	}
	printf("%lld", best);
}


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

int main()
{
    while (1)
    {
        ll n;
        cin >> n;
        if (n == 0)
            return 0;
        vector<ll> a(n);
        rep(i, n) cin >> a[i];
        sort(a.begin(), a.end());
        ll sum = accumulate(a.begin(), a.end(), 0LL);
        rep(i, n) a[i] *= n;
        auto itr = upper_bound(a.begin(), a.end(), sum);
        cout << distance(a.begin(), itr) << endl;
    }

    return 0;
}


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

int main(){
	long long n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a%2==b%2){
		printf("%lld",abs(a-b)/2);
	}else{
		printf("%lld",min(((abs(a-b)+1)/2)+n-b,((abs(a-b)+1)/2)+a-1));
	}
}

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

namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            Iter it = new Iter();
            string line;
            while ((line = Console.In.ReadLine()) != "0 0")
            {
                int[] num = line.Split().Select(x => int.Parse(x)).ToArray();
                Console.Out.WriteLine(it.comb(num[0], num[1], 0));
            }
        }
    }
    internal class Iter
    {
        internal int comb(int n, int s, int rec)
        {
            int ans = 0;
            if (n == 0 && s == 0)
                return 1;
            for (int i = rec; i < 10; ++i)
            {
                ans += comb(n - 1, s - i, i + 1);
            }
            return ans;
        }
    }
}




Measured memory_bytes: 16396
n = int(input())
b = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i == 0:
        ans += b[0]
    elif i == n - 1:
        ans += b[n - 2]
    else:
        ans += min(b[i], b[i - 1])
print(ans)


Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
//NIL is NULL
#define NIL NULL
//Node structure
struct Node{
  int key;
  struct Node *parent;
  struct Node *leftc;
  struct Node *rightc;
};
//define Nodepointer
typedef struct Node * Nodepointer;

//root         
Nodepointer root;

//function insert
void insert(int k){
  Nodepointer x,y,z;
  y=NIL;
  x=root;
  //make memory
  z=new struct Node();

  z->key=k;
  z->leftc=NIL;
  z->rightc=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key) x=x->leftc;
    else x=x->rightc;
  }

  z->parent=y;

  if(y==NIL) root=z;

  else if(z->key<y->key) y->leftc=z;

  else y->rightc=z;


}

//function search
Nodepointer find(Nodepointer now,int data){
  if(now==NIL||data==now->key) return now;
  if(data<now->key) return find(now->leftc,data);
  else return find(now->rightc,data);
}

//function treeminimum
Nodepointer treeminimum(Nodepointer x){
  while(x->leftc!=NIL){
    x=x->leftc;
  }
  return x;
}
//function treesuccerssor
Nodepointer treesuccessor(Nodepointer x){
  Nodepointer y;
  if(x->rightc!=NIL) return treeminimum(x->rightc);
  y=x->parent;
  while(y!=NIL && x==x->rightc){
    x=y;
    y=y->parent;
  }
  return y;
}
//function treedelete
void treedelete(Nodepointer z){
  Nodepointer x,y;
  if(z->leftc==NIL ||z->rightc==NIL)y=z;
  else y=treesuccessor(z);

  if(y->leftc!=NIL)x=y->leftc;
  else x=y->rightc;
 
  if(x!=NIL)x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->leftc) y->parent->leftc=x;
  else y->parent->rightc=x;

  if(y!=z) z->key=y->key;
  //free memory
  delete z;
}

//print
void inorderprint(Nodepointer now){
  if(now!=NIL){
    inorderprint(now->leftc);
    printf(" %d",now->key);
    inorderprint(now->rightc);
  }
}

void preorderprint(Nodepointer now){
  if(now!=NIL){
    printf(" %d",now->key);
    preorderprint(now->leftc);
    preorderprint(now->rightc);
  }
}


int main(){

  int n,i,j,data;
  Nodepointer del;
  char str[10];
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    //insert
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      insert(data);
    }
    //find
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    //delete
    else if(strcmp(str,"delete")==0){
      scanf("%d",&data);
      del=find(root,data);
      treedelete(del);
    }
    //print
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long K;
	cin >> K;
	
	queue<long long > q;
	for (int i = 1; i <= 9; i++) q.push(i);
	while (!q.empty()) {
		long long x = q.front(); q.pop();
		K--;
		if (K == 0) { cout << x << endl; break; }
		
		for (int y = (x % 10) - 1; y <= (x % 10) + 1; y++) {
			if (y < 0 || y >= 10) continue;
			q.push(x * 10 + (long long)y);
		}
	}
	return 0;
}

Measured memory_bytes: 1792
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i32 = read();
    let a: i32 = read();
    let b: i32 = read();

    let rest = x - a;
    println!("{}", rest - ((rest / b) * b));
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
H,W = map(int,input().split())
grid = [[-float("inf")]*W for _ in range(H)]
for i in range(H):
  s = input()
  for j in range(W):
    if s[j]==".":
      grid[i][j]=0
dire = [[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]]
for r in range(H):
  for c in range(W):
    if grid[r][c] == -float("inf"):
      for d in dire:
        if 0 <= r+d[0] and r+d[0] < H and 0 <= c+d[1] and c+d[1] < W:
          grid[r+d[0]][c+d[1]] += 1
for r in range(H):
  for c in range(W):   
    if grid[r][c] == -float("inf"):
      grid[r][c] = "#"
    else:
      grid[r][c] = str(grid[r][c])
  print("".join(grid[r]))

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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n){
        cin >> p[i];
    }
    int cnt = 0;
    rep(i, n - 2){
        if(p[i] < p[i + 1] && p[i + 1] < p[i + 2]){
            cnt++;
        }else if(p[i + 2] < p[i + 1] && p[i + 1] < p[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}

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

int n;
int x[200000], y[200000], t[200000];
string res = "Yes";

int main(){
  cin >> n;
  x[0] = 0, y[0] = 0, t[0] = 0;
  for(int i = 1; i <= n; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i = 0; i < n; i++){
    int dx = abs(x[i] - x[i + 1]);
    int dy = abs(y[i] - y[i + 1]);
    int dt = abs(t[i] - t[i + 1]);
    
    if(dt % 2 != (dx + dy) % 2){
      res = "No";
      break;
    }
    if((dx + dy) > dt){
      res = "No";
      break;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

const long long MOD = 1e9 + 7;
int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> v(n + 1);
    rep(i, 0, n + 1) v[i] = i;
    vector<ll> c(n + 1, 2);
    ll ans = 0;
    rep(i, 1, n + 1)
    {
        ans += i * (n / i) * (n / i + 1) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 159460
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define M 1046527
#define NIT (-1)
#define L 14

char H[M][L];

int getchar(char ch)
{
    if(ch=='A')return 1;
    else if(ch=='C')return 2;
    else if(ch=='G')return 3;
    else if(ch=='T')return 4;
    else return 0;
}

long long getkey(char str[])
{
    long long sum=0,p=1,i;
    for(i=0;i<strlen(str);i++)
    {
        sum+=p*(getchar(str[i]));
        p*=5;
    }
    return sum;
}

int h1(int key){return key%M;}
int h2(int key){return 1+(key%(M-1));}

int find(char str[])
{
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++)
    {
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0)return 0;
    }
    return 0;
}

int insert(char str[])
{
    long long key,i,h;
    key=getkey(str);
    for(i=0;;i++)
    {
         h=(h1(key)+i*h2(key))%M;
         if(strcmp(H[h],str)==0)return 1;
         else if(strlen(H[h])==0)
         {
             strcpy(H[h],str);
             return 0;
         }
    }
    return 0;
}

int main()
{
    int h,i,n;
    char str[L],com[9];
    for(int i=0;i<M;i++)H[i][0]='\0';
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s %s",com,str);
        if(com[0]=='i')
        {
            insert(str);
        }else
        {
            if(find(str))
            {
                printf("yes\n");
            }else
            {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 17432
#include <stdio.h>

int main(void){


	int h, w, a, b, cnt;
	cnt = 0;
	
	while(1){

		scanf("%d %d", &h, &w);

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

		for(a = 0; a < h; a++){


			for(b = 0; b < w; b++){

				if(cnt % 2 == 0){
					printf("#");
					cnt++;
				}
				else{
					printf(".");
					cnt++;
				}
			}
			printf("\n");
		if(w % 2 == 0){
			if(cnt % 2 == 0){
				cnt = 1;
			}
			else{
				cnt = 0;
			}
		}
		}
		printf("\n");
		cnt = 0;
	}

	return 0;

}

Measured memory_bytes: 572
from math import log2


def cntOnes(n, N):
    ret = [0] * N
    i = 0
    while (n >> i) > 0:
        t = 2 ** i
        quot = n // t
        rem = n % t
        if quot % 2 == 1:
            ret[i] = (quot // 2) * t + (rem + 1)
        else:
            ret[i] = (quot // 2) * t
        i += 1
    return ret


A, B = map(int, input().split())

if B == 0:
    print(0)
    exit()
dig = int(log2(B)) + 1
cntA = cntOnes(A - 1, dig) if A != 0 else [0] * dig
cntB = cntOnes(B, dig)

ans = 0
for i, (a, b) in enumerate(zip(cntA, cntB)):
    if (a - b) % 2 == 1:
        ans += (1 << i)

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double memo = ((T - A) * 1000 + 0.0) / 6;
  int ans;
  double best = 1000000000000;
  for (int i = 0; i < N; i++) {
    int H;
    double memo2;
    cin >> H;
    if (H > memo) {
      memo2 = H - memo;
    }
    else {
      memo2 = memo - H;
    }
    if (best > memo2) {
      best = memo2;
      ans = i + 1;
    }
  }
  cout << ans << endl;   
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}


int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n;
		cin>>n;
		vector<pair<int,int>> v;
		for(int i=0;i<n;i++){
			int p,q;
			cin>>p>>q;
			v.push_back({p,q});
		}
		double z=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				z+=sqrt(((v[i].first-v[j].first)*(v[i].first-v[j].first))+ ((v[i].second-v[j].second)*(v[i].second-v[j].second)));
			}
		}
		z*=2;
		z/=float(n);
		cout<<fixed<<setprecision(7)<<z;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ld a, b, c;
  cin >> a >> b >> c;
  
  ld ab, cab;
  ab = sqrtl(a*b);
  cab = c - a - b;
  
  //cout << "ab=" << a*b << ", rutoab=" << ab <<endl;
  //cout << "2ab=" << 2.0*ab <<", cab=" << cab <<endl;
  if(2.0*ab < cab)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}





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

int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        vector<int> v(n);
        rep(i, n) {
                scanf("%d", &v[i]);
        }
        long long ans = -1e9 + 10;
        rep(a, k + 1) {
                rep(b, k + 1) {
                        rep(c, k + 1) {
                                rep(d, k + 1) {
                                        if (a + b + c + d > k) continue;
                                        if (c + d > n) continue;
                                        if (a + b > n) continue;
                                        if (a < c) continue;
                                        if (b < d) continue;
                                        vector<int> took;
                                        for (int i = 0; i < a; i ++) {
                                                took.push_back(v[i]);
                                        }
                                        for (int i = n - 1; i > n - 1 - b; i --) {
                                                took.push_back(v[i]);
                                        }
                                        sort(took.rbegin(), took.rend());
                                        long long res = 0;
                                        rep(i, a + b - c - d) {
                                                res += took[i];
                                        }
                                        ans = max(ans, res);
                                }
                        }
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>


using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if ( a != 1 && b != 1 ) cout << 1; 
  if ( a != 2 && b != 2 ) cout << 2 ;
  if ( a != 3 && b != 3 ) cout << 3 ;
  return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n;
	cin >>n;
	rep2(i, n, 1112){
		string s=to_string(i);
		if(count(all(s),s[0])==sz(s)){
			cout << i <<"\n";
			return 0;
		}
	}
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

using complex_t = complex<double>;
vector<complex_t> koch(complex_t a, complex_t b, int n) {
    if (n == 0) { return {a}; }
    complex_t c0 = (a * 2.0 + b) / 3.0, c2 = (a + b * 2.0) / 3.0;
    complex_t c1 = c0 + (c2 - c0) * polar(1.0, PI / 3);
    vector<complex_t> v0 = koch(a, c0, n - 1), v1 = koch(c0, c1, n - 1),
        v2 = koch(c1, c2, n - 1), v3 = koch(c2, b, n - 1);
    v0.insert(v0.end(), all(v1)), v0.insert(v0.end(), all(v2)), v0.insert(v0.end(), all(v3));
    return v0;
}
int n;
signed main() {
    cin >> n;
    complex_t a = 0, b = 100;
    vector<complex_t> ans = koch(a, b, n);
    ans.push_back(b);
    rep(i, ans.size()) { cout << ans[i].real() << " " << ans[i].imag() << endl; }
}


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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var H = input[0];
            var W = input[1];
            var board = new int[H, W];
            for (int i = 0; i < H; i++)
            {
                input = ReadArrayInt();
                for (int j = 0; j < W; j++)
                {
                    board[i, j] = input[j];
                }
            }
            var ans = new List<int[]>();
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if (i == H - 1 && j == W - 1) break;
                    if (j != W - 1)
                    {
                        if (board[i, j] % 2 != 0)
                        {
                            board[i, j]--;
                            board[i, j + 1]++;
                            ans.Add(new int[] { i + 1, j + 1, i + 1, j + 2 });
                        }
                    }
                    else
                    {
                        if (board[i, j] % 2 != 0)
                        {
                            board[i, j]--;
                            board[i + 1, j]++;
                            ans.Add(new int[] { i + 1, j + 1, i + 2, j + 1 });
                        }
                    }
                }
            }

            Console.WriteLine(ans.Count);
            foreach(var a in ans)
            {
                Console.WriteLine(a[0] + " " + a[1] + " " + a[2] + " " + a[3]);
            }

            Console.WriteLine();
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;

string s;
string res;
ll K;

bool dfs(int l,int r){
  bool is_str=true;
  repl(i,l,r){
      if(s[i]=='('||s[i]==')'||isdigit(s[i]))is_str=false;
  }
  if(is_str){
    res+=s.substr(l,r-l);
    return res.length()>K;
  }

  if(isdigit(s[l])){
    int i=l;
    while(i<r&&isdigit(s[i]))i++;
    int cnt=stoi(s.substr(l,i-l));
    if(s[i]=='('){
      int j=i+1;
      int level=1;
      while(j<r&&level!=0){
        if(s[j]=='(')level++;
        if(s[j]==')')level--;
        j++;
      }
      rep(c,cnt){
        if(dfs(i+1,j-1))return true;
      }
      if(dfs(j,r))return true;
    }else{
      rep(c,cnt){
        if(dfs(i,i+1))return true;
      }
      if(dfs(i+1,r))return true;
    }
  }else{
    if(dfs(l,l+1))return true;
    if(dfs(l+1,r))return true;
  }
  return false;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>s>>K;
    if(s=="0")break;
    res="";
    int n=s.length();
    if(!dfs(0,n))cout<<0<<endl;
    else cout<<res[K]<<endl;
  }
	return 0;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e8;
int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int>w(n),e(n);
    rep(i,n-1){
        if(s[i]=='W'){
            w[i]++;
        }
        if(i==n-1)continue;
        w[i+1]=w[i];
    }
    for(int i = n-1;i>=0;i--){
        if(s[i]=='E'){
            e[i]++;
        }
        if(i==0)continue;
        e[i-1]=e[i];
    }
    int M = INF;
    w[-1]=0;
    e[n]=0;
    rep(i,n){
        int now = w[i-1]+e[i+1];
        M = min(M,now);
    }
    cout<<M<<endl;
    return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string>S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(),S.end());
  for (int i = 0; i < N; i++) {
    cout << S.at(i);
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b >= c - 1) {
        cout << b + c << endl;
        return 0;
    } else {
        cout << a + b + 1 + b << endl;
        return 0;
    }

    return 0;
}


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

int A[1000000];
vector<int> G;
long long cnt;

void insertionSort(int n,int g)
{
  for(int i=g;i<n;i++)
  {
    int v=A[i];
    int j = i-g;
    while(j>=0 && A[j]>v)
    {
      A[j+g] = A[j];
      j -= g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void ShellSort(int n)
{
  int h=1;
  while(h<=n)
  {
    G.push_back(h);
    h = 3*h + 1;
  }
  for(int i=G.size()-1;i>=0;i--)
  {
    insertionSort(n,G[i]);
  }
}

int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++) cin >> A[i];
  cnt = 0;

  ShellSort(n);
  printf("%d\n",G.size());
  for(int i=G.size()-1;i>=0;i--)
  {
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(int i=0;i<n;i++)
  {
    printf("%d\n",A[i]);
  }
}



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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

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

const int MOD = 998244353;

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

	int n; cin >> n;
	int cnt = 0;
	bool ok = false;
	FOR(i, n){
		int a, b; cin >> a >> b;
		if(a == b) cnt ++;
		else cnt = 0;

		if(cnt == 3){
			ok = true;
		}
	}

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

	return 0;
}


Measured memory_bytes: 3664
def main():
    from bisect import bisect_left as bl
    a, b, q, *stx = map(int, open(0).read().split())
    s = [-float('Inf')] + stx[:a] + [float('Inf')]
    t = [-float('Inf')] + stx[a:a + b] + [float('Inf')]
    x = stx[a + b:]
    tmp = []
    for i in x:
        f, g = bl(s, i), bl(t, i)

        sr, sl = s[f - 1], s[f]
        tr, tl = t[g - 1], t[g]

        d = min([max(sl, tl) - i, i - min(sr, tr), 2 * (tl - sr) - max(i - sr, tl - i), 2 * (sl - tr) - max(sl - i, i - tr)])
        tmp.append(d)

    ans = '\n'.join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;


int main() {
    int N;
    cin >> N;
    int ans = N;
    int cnt;
    for (int i = 0; i <= N; ++i) {
        cnt = 0;
        int t = i;
        while (t) cnt += t % 6, t /= 6;
        t = N - i;
        while (t) cnt += t % 9, t /= 9;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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






int main() {
  string a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=0;i<3;i++){
    if(a.at(i)==b.at(i)){ans++;}
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, M;
int a[1010], b[1010], c[1010][20];

int main() {
    cin >> N >> M;
    for (int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }

    // 1次元DP
    vector<int> dp(5000, INT_INF);
    dp[0] = 0;

    for (int item = 1; item <= M; item++) {
        int now = 0;
        // 宝箱の組み合わせのbit表現を得る
        for (int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }

        // DPテーブルの更新
        for (int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }

    if (dp[(1 << N) - 1] == INT_INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
using namespace std;
#define INF 0x3f3f3f3f3f3f3f3f;
typedef long long LL;
const int maxn=100005;
LL p1[maxn], p2[maxn];
LL n,res[maxn*3];
LL c1, c2, ans;
 
priority_queue<int, vector<int>, greater<int> > Q1;
priority_queue<int>Q2;
 
int main()
{
cin.sync_with_stdio(false);
cin.tie(0);
    cin>>n;
    c1=c2=0;
    for(int i=1;i<=3*n;i++){
        cin>>res[i];
        if(i<=n){
            Q1.push(res[i]);
            c1+=res[i];
        }
        else if(i>2*n){
            Q2.push(res[i]);
            c2+=res[i];
        }
    }
    p1[0]=c1;
    p2[0]=c2;
    for(int i=1;i<=n;i++){
        c1+=res[n+i];
        Q1.push(res[n+i]);
        c1-=Q1.top();
        Q1.pop();
        p1[i]=c1;
        c2+=res[2*n+1-i];
        Q2.push(res[2*n+1-i]);
        c2-=Q2.top();
        Q2.pop();
        p2[i]=c2;
    }
    ans=-INF;
    for(int i=0;i<=n;i++){
        ans=max(ans, p1[i]-p2[n-i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int n,m;
    ll k;
    cin>>n>>m>>k;
    vector<ll>a(n);
    vector<ll>b(m);
    FOR(i,n) cin>>a[i];
    FOR(i,m) cin>>b[i];

    ll  t=0;
    FOR(i,m) t+=b[i];
    ll ans=0;
    int j=m;

    FOR(i,n+1)
    {
        while(j>0&&t>k)
        {
            j--;
            t-=b[j];
        }
        if(t>k) break;
        ans=max(ans,(ll)i+j);
        if(i==n) break;
        t+=a[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6360
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
// 1000000
// 100000

int main() {
  int X;
  cin >> X;
  int y = X % 100;
  int N = X/100;
  VEC<int> v = {1, 2, 3, 4, 5};
  reverse(ALL(v));
  int cnt = 0;
  REP(i, 0, v.size()) {
    // DUMP(y, v[i]);
    if (y / v[i] > 0) {
      cnt += y / v[i];
      y -= (y / v[i]) * v[i];
    }
  }
  if(cnt<=N){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  // DUMP(cnt);

  return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    int h, w, k;
    cin >> h >> w >> k;

    vvc c(h, vc(w));
    rep(i, h) rep(j, w) {
        cin >> c[i][j];
    }

    int ans = 0;
    rep(i, pow2(h)) {
        rep(j, pow2(w)) {
            int cnt = 0;
            rep(k, h) {
                rep(l, w) {
                    if (bit(i, k) == 0 && bit(j, l) == 0 && c[k][l] == '#') {
                        cnt++;
                    }
                }
            }
            if (cnt == k) ans++;
        }
    }

    prt(ans);

    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	static int w, h;
	static int a[][];

	public static void f(int x, int y, int c) {
		if (x < 0 || w <= x || y < 0 || h <= y) {
			return ;
		}
		if (a[y][x] != c) {
			return ;
		}
		a[y][x] = -1;
		f(x + 1, y, c);
		f(x - 1, y, c);
		f(x, y + 1, c);
		f(x, y - 1, c);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int sx, sy;
		int gx, gy;
		int dx0[] = {0, 0, 1, 1, 2, 2, 3, 3};
		int dy0[] = {0, 1, 0, 1, 0, 1, 0, 1};
		int dx1[] = {0, 0, 0, 0, 1, 1, 1, 1};
		int dy1[] = {0, 1, 2, 3, 0, 1, 2, 3};

		while (true) {
			w = sc.nextInt();
			h = sc.nextInt();
			if ((w | h) == 0) {
				break;
			}
			sx = sc.nextInt() - 1;
			sy = sc.nextInt() - 1;
			gx = sc.nextInt() - 1;
			gy = sc.nextInt() - 1;
			n = sc.nextInt();
			a = new int[h][w];
			while (n-- != 0) {
				int c = sc.nextInt();
				int d = sc.nextInt();
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				if (d == 0) {
					for (int i = 0; i < 8; i++) {
						a[y + dy0[i]][x + dx0[i]] = c;
					}
				} else {
					for (int i = 0; i < 8; i++) {
						a[y + dy1[i]][x + dx1[i]] = c;
					}
				}
			}

			f(sx, sy, a[sy][sx]);
			if (a[sy][sx] == 0 || a[gy][gx] == 0) {
				System.out.println("NG");
			} else if (0 <= a[gy][gx]) {
				System.out.println("NG");
			} else {
				System.out.println("OK");
			}
		}
	}
}

Measured memory_bytes: 24028
#include<bits/stdc++.h>
#define f(i,s,n)for(register int i=s;i<=n;++i)
#define f2(i,s,n)for(register int i=n;i>=s;--i)
#define N 110
using namespace std;
string s[N];
int main(){
	ios::sync_with_stdio(false);
	int n,l;
	cin>>n>>l;
	f(i,1,n){
		cin>>s[i];
	}
	sort(s+1,s+n+1);
	f(i,1,n){
		cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int a[1010];
int t[10],b[10],top;
bool ok(int t)
{
	for(int i=1;i<=top;i++)
		if(a[t+i-1]!=b[i])
			return false;
	return true;
}
int main()
{
	int N;
	cin>>N;
	for(int i=1;i<=N;i++)
		cin>>a[i];
	for(int i=0;;i++)
	{
		top=0;
		int x=i;
		do
		{
			t[++top]=x%10;
			x/=10;
		}while(x);
		for(int j=1;j<=top;j++)
			b[j]=t[top-j+1];
		bool f=false;
		for(int j=1;j<=N-top+1&&!f;j++) f=ok(j);
		if(!f)
		{
			cout<<i<<endl;
			break;
		}
	}
}

Measured memory_bytes: 1168
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	int n;
	cin>>n;

	vector<int>a(n),b(n);

	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}

	for(i=0;i<n;i++)
	{
		cin>>b[i];
	}

	// for(i=0;i<n;i++)
	// {
	// 	if()
	// }

	if(a==b)
	{
		cout<<0<<endl;
	}
	else
	{
		vector<int>v(a);


		sort(all(v));

		d(v);

		int cnt=0,first=-1,second=-1;

		do
		{
			cnt++;
			if(v==a||v==b)
			{
				if(first==-1)
				{
					first=cnt;
				}
				else
				{
					second=cnt;
				}
			}

		}
		while(next_permutation(all(v)));

		cout<<abs(first-second)<<endl;
	}



}

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

#define int long long int
#define pb push_back
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 19
#define mod 1000000007

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int d, t, s;
  cin >> d >> t >> s;
  double ans = (double)d / s;
  (ans <= (double)t) ? cout << "Yes\n" : cout << "No\n";
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<string>
#include<iostream>
using namespace std;

void dfs(string s, int k, int n) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }

    for(int i = 0; i < k; i++) {
        char c = 'a' + i;
        dfs(s + c, k, n);
    }

    char c = 'a' + k;
    dfs(s + c, k + 1, n);
}

int main() {
    int n;
    cin >> n;
    dfs("", 0, n);
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n,t;
int main(){
      ios_base::sync_with_stdio(false); cin.tie(NULL);
      cin>>n;
      string s;
      ll cnt=1;
      cin>>s;
      for(int i=1;i<n;i++){
        if(s[i]!=s[i-1])cnt++;
      }
      cout<<cnt;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  string board[60];
  int dx[] = {1, 0,-1, 0};
  int dy[] = {0, 1, 0,-1};
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> board[i];
  }
  //cout << "--------" << endl;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      // まわりの爆弾を数える
      if (board[i][j] == '#') {
        //cout << "#:" << i << "," << j << "_______" << endl;
        bool is_ok = false;
        for (int k = 0; k < 4; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          //cout << x << "," << y << ":"<< board[i][j] << endl;
          if (x >= 0 && x < h && y >= 0 && y < w){

            if (board[x][y] == '#') {
              //cout << "got----" << endl;
              is_ok = true;
              break;
            } else {
            }
          }
        }
        if (!is_ok) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
// 差が最小になるとき、すなわち A - B = 1において、1変化しただけで10^9を超えてしまうような場合がコーナーケースに該当する
// それはA = 120, B = 119, またA = -199, B = -200 のとき
// (双方に-がつくと符号反転してB - Aになる)
// つまりAは-199 ~ 120, Bは-200 ~ 119までの値しか取れないので、この範囲で総当り検索すれば求められる
// 計算量は10^4くらいで余裕
#include <bits/stdc++.h>
using namespace std;

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<long long> vecll;
typedef vector<unsigned long long> vecull;

ll X;

int main(void) {
    cin >> X;

    ll ans_a, ans_b;
    for (ll a = -199; a <= 120; ++a) {
        for (ll b = -200; b <= 199; ++b) {
            if (powl(a, 5) - powl(b, 5) == X) {
                ans_a = a;
                ans_b = b;
                break;
            }
        }
    }

    cout << ans_a << ' ' << ans_b << ' ' << endl;

    return 0;
}


Measured memory_bytes: 3688
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
int num[207];
int main(){
	scanf("%d",&n);
	for(int i=0;i<2*n;i++)
		scanf("%d",&num[i]);
	sort(num,num+2*n);
	long long tot=0;
	for(int i=0;i<n;i++)
		tot+=num[i*2];
	printf("%lld\n",tot);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, mx1[105], fr1[105], mx2[105], fr2[105];
vector<int> G[105];
int frr;
int find_dia(int u, int lst) {
	mx1[u] = 0, mx2[u] = 0;
	for (int v : G[u]) if (v != lst) {
		int cur = find_dia(v, u) + 1;
		if (mx1[u] < cur) {
			mx2[u] = mx1[u];
			fr2[u] = fr1[u];
			mx1[u] = cur;
			fr1[u] = v;
		} else if (mx2[u] < cur) {
			mx2[u] = cur;
			fr2[u] = v;
		}
	}
	if (!frr || mx1[u] + mx2[u] > mx1[frr] + mx2[frr]) frr = u;
	return mx1[u];
}
int F[105];
void dfs(int u, int lst, int depth) {
	int deg = 0;
	for (int v : G[u]) if (v != lst) {
		deg++;
		dfs(v, u, depth + 1);
	}
	F[depth] = max(F[depth], deg);
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	find_dia(1, 0);
	vector<int> dia;
	for (int u = frr; u; u = fr1[u]) {
		dia.push_back(u);
	}
	reverse(dia.begin(), dia.end());
	for (int u = fr2[frr]; u; u = fr1[u]) {
		dia.push_back(u);
	}
	if ((int)dia.size() % 2 == 0) {
		int rt1 = dia[dia.size() / 2 - 1], rt2 = dia[dia.size() / 2];
		memset(F, 0, sizeof(F));
		dfs(rt1, rt2, 0);
		dfs(rt2, rt1, 0);
		long long ans = 2;
		for (int i = 0; i < (int)dia.size() / 2 - 1; i++) {
			ans *= F[i];
		}
		printf("%d %lld\n", (int)dia.size() / 2, ans);
	} else {
		int rt = dia[dia.size() / 2];
		memset(F, 0, sizeof(F));
		dfs(rt, 0, 0);
		long long cur = 1;
		for (int i = 0; i < (int)dia.size() / 2; i++) {
			cur *= F[i];
		}
		long long ans = cur;
		for (int v : G[rt]) {
			memset(F, 0, sizeof(F));
			dfs(rt, v, 0);
			dfs(v, rt, 0);
			cur = 2;
			for (int i = 0; i < (int)dia.size() / 2; i++) {
				cur *= F[i];
			}
			ans = min(ans, cur);
		}
		printf("%d %lld\n", (int)dia.size() / 2 + 1, ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main()
{
	int a, b;
	cin >> a >> b;
	if(a<b)
	{
		cout << "a < b\n";
	}
	else if(a > b)
	{
		cout << "a > b\n";
	}
	else
	{
		cout << "a == b\n";
	}
	
	return 0;
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main()
    {
        string[] s = Console.ReadLine().Split();
        int n, m;
        n = int.Parse(s[0]);
        m = int.Parse(s[1]);
        List<int> l = new List<int>();
        for (int i = 0; i < m; i++)
        {
            s = Console.ReadLine().Split();
            int a, b;
            a = int.Parse(s[0]);
            b = int.Parse(s[1]);
            l.Add(a);
            l.Add(b);
        }
        int[] count = new int[l.Max() + 1];
        foreach (var i in l)
            count[i]++;
        bool f = true;
        foreach (var i in count)
            f = f && i % 2 == 0;
        C.WriteLine(f ? "YES" : "NO");
    }
}
//以下標準出力用のクラス
static class C
{
    [System.Runtime.InteropServices.DllImport("msvcrt.dll")]
    private static extern void printf(string s);
    public static void Write(string s) { printf(s); }
    public static void Write(char c) { printf(c.ToString()); }
    public static void Write(long n) { printf(n.ToString()); }
    public static void Write(int n) { printf(n.ToString()); }
    public static void Write(double d) { printf(d.ToString()); }
    public static void WriteLine() { printf("\n"); }
    public static void WriteLine(string s) { printf(s + "\n"); }
    public static void WriteLine(char c) { WriteLine(c.ToString()); }
    public static void WriteLine(long n) { WriteLine(n.ToString()); }
    public static void WriteLine(int n) { WriteLine(n.ToString()); }
    public static void WriteLine(double d) { WriteLine(d.ToString()); }
    public static void WriteLines(string[] s) { foreach (var i in s) WriteLine(i); }
    public static void WriteLines(char[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(long[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(int[] c) { foreach (var i in c) WriteLine(i); }
    public static void WriteLines(double[] d) { foreach (var i in d) WriteLine(i); }
}

Measured memory_bytes: 19404
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n, m, p;
	cin >> n >> m >> p;
	int d[m];
	for(int i = 0; i < m; i++) cin >> d[i];
	for(int i = 0; i < m; i++){	
		d[i] -= p;
		if(d[i] < 0) d[i] += n;
	}
	sort(d, d + m);
	int mn = d[m - 1] * 100;
	for(int i = 0; i < m - 1; i++){
		int cost = d[i] * 100 * 2 + (n - d[i + 1]) * 100;
		mn = min(mn, cost);
	}
	mn = min(mn, (n - d[0]) * 100);
	for(int i = m - 1; i >= 1; i--){
		int cost = (n - d[i]) * 100 * 2 + d[i - 1] * 100;
		mn = min(mn, cost);
	}
	cout << mn << endl;
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M) vector<vector<L>> K(N, vector<L>(M))
#define mod 1000000007
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
lli gcd(lli num1, lli num2){
    return num2 != 0 ? gcd(num2, num1 % num2) : num1;
}
lli lcm(lli num1, lli num2){
    return num1 / gcd(num1, num2) * num2;
}
int toD(char s){
  s=s-' ';
  return s;
}
int toK(char s){
  s=s+' ';
  return s;
}
int main(){
  lli A=1,B,D,E,N,M,K,sum=0,num=0,ans=0;
  cin >> N >> A >> B;
  N-=2;
  M=A+B+A*N;
  K=A+B+B*N;
  if(B<A||(K-M+1)<0)Out(0);
  else Out(K-M+1);
}

Measured memory_bytes: 256