akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll a,b,c;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b>>c;
    a -= b;
    cout<<max(0LL, c - a);
    return 0;
}

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

int main(){
    int n;ll x; cin >> n >> x;
    vector<ll> a(n);
    ll sum1 = 0;
    rep(i,n) {
        cin >> a[i];
        sum1 += a[i];
    }
    rep(i,n-1){
        if(a[i+1]+a[i] <= x) continue;
        else if(a[i] >=x) {
            a[i] = x;
            a[i+1] = 0;
        }
        else a[i+1] = x-a[i];
    }
    ll sum2 = 0;
    rep(i,n) {
        sum2 += a[i];
    }
    cout << sum1-sum2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M, X;
  cin >> N >> M >> X;
  vector<long> sub(M);
  vector<vector<long>>data(N, vector<long> (M + 1));
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M + 1; j++){
      cin >> data.at(i).at(j);
    }
  }
  long a, cost, ans = INT_MAX, flag;
  for(int i = 0; i < pow(2, N); i++){
    a = i;
    cost = 0;
    flag = 1;
    for(int j = 0; j < M; j++)sub.at(j) = 0;
    for(int j = 0; j < N; j++){
      if(a % 2 == 1){
        cost += data.at(j).at(0);
        for(int k = 1; k < M + 1; k++){
          sub.at(k - 1) += data.at(j).at(k);
        }
      }
      a /= 2;
    }
    for(int j = 0; j < M; j++){
      if(sub.at(j) < X){
        flag = 0;
        break;
      }
    }
    if(flag == 1)ans = min(ans, cost);
  }
  cout << (ans != INT_MAX? ans: -1) << endl;
  return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) 
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u == NIL || k == u->key)
    return u;
  if(k < u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x->parent = y->parent;

  if(y->parent == NIL)
    root = x;
  else if(y == y->parent->left)
    y->parent->left = x;
  else y->parent->right = x;

  if(y != z)
    z->key = y->key;

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  y = NIL;
  x = root;
  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL)
      root = z;
    else if(z->key < y->key)
      y->left = z;
    else
      y->right = z;
}

void inorder(Node u){
  if(u == NIL)
    return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)
    return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20552
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a, b;
int cnt;
int ans[300010];

signed main() {
	cin >> n >> a >> b;
	if (n + 1 < a + b || a * b < n) {
		cout << -1 << endl;
		return 0;
	}
	cnt = b;
	for (int i = 1; i <= n; i++) {
		int x = min(a, n - i + 1 - cnt + 1);
		int s = (n - i + 1) * 2 - x + 1;
		for (int j = i; j < i + x; j++)ans[j] = s - (n - j + 1);
		i += x - 1;
		cnt--;
	}
	for (int i = 1; i <= n; i++)cout << ans[i] << " ";
	cout << endl;
}

Measured memory_bytes: 4480
#include<iostream>
#include <vector>
#include<string.h>
#include<cmath>
using namespace std;


int main(){
   string s;
   cin>>s;
    int count=0;
    int len = s.length();
    for(int i = 0; i < len/2; i++){
            if(s[i] != s[len-1-i]){
               count++; 
            }
        }
    cout<< count <<endl;
    
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, x, y; cin >> n >> m >> x >> y;
  int up = -200; int down = 200;
  for (int i = 0; i < n; i++) {
    int k; cin >> k;
    up = max(k, up);
  }
  for (int i = 0; i < m; i++) {
    int k; cin >> k;
    down = min(k, down);
  }
  for (int i = x+1; i <= y; i++) {
    if (up < i && i <= down) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<complex>
#include<stack>
#include<queue>
#include<unordered_map>
#include<map>

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

using namespace std;

int main(void) {
  int n;
  cin >> n;
  long long int luca[86];
  luca[0] = 2;
  luca[1] = 1;
  for (int i = 2; i <= n; i++) {
    luca[i] = luca[i-1] + luca[i-2];
  }
  cout << luca[n] << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N - 1);
    for(int i = 0; i < N - 1; i++) cin >> B[i];

    A.back() = B.back();
    A[0] = B[0];
    for(int i = 1; i < N - 1; i++) A[i] = min(B[i - 1], B[i]);
    ll sum = 0;
    for(int i = 0; i < N; i++) sum += A[i];

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	int A[2][N];
	for(int i=0;i<N;i++)cin >> A[0][i];
	for(int i=0;i<N;i++)cin >> A[1][i];

	int dp[2][N];
	dp[0][0]=A[0][0];
	for(int i=1;i<N;i++){
		dp[0][i]=dp[0][i-1]+A[0][i];
	}
	dp[1][0]=dp[0][0]+A[1][0];
	for(int i=1;i<N;i++){
		int candyA=dp[1][i-1]+A[1][i];
		int candyB=dp[0][i]+A[1][i];
		if(candyA>candyB){
			dp[1][i]=candyA;
		}else{
			dp[1][i]=candyB;
		}
	}
	cout << dp[1][N-1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

public static void main(String args[]){

Scanner scan =new Scanner(System.in);

int a =scan.nextInt();

int b =scan.nextInt();

int c =scan.nextInt();

if(a<b && b<c){System.out.println("Yes");}

else {System.out.println("No");}

}}


Measured memory_bytes: 26276
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  ll n, k;
  cin >> n >> k;
  ll res = n*n;
  // cerr << res << endl;
  if(k > 0) {
    for(int b = 1; b <= n; ++b) {
      res -= n/b*min(k, (ll)b);
      int tmp = n%b;
      res -= k > tmp ? tmp : k-1;
      // cerr << res << endl;
    }
  }
  cout << res << endl;
  return 0;
}


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

using namespace::std;

long int N, a[100000],A,ans[2];
char S[6];

int min(int x, int y) {
	if (x > y)return y;
	return x;
}

int main() {
	cin >> S;
	ans[0] = 0;
	for (int i = 0; i < 6; i++) {
		if (S[i] == '1') {
			ans[0]++;

		}

	}
	cout <<ans[0]<<endl;
	return 0;
		}


	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 2000005

int n, k;
int a[MAX_N];
int b[MAX_N];
int deq[MAX_N];

void Sliding_Minimum_Element_init(){
    int s = 0;
    int t = 0;
    rep(i,n){
        while(s < t && a[deq[t - 1]] >= a[i]) t--;
        deq[t++] = i;

        if(i - k + 1 >= 0){
            b[i - k + 1] = a[deq[s]];

            if(deq[s] == i - k + 1){
                s++;
            }
        }
    }
}

int main() {
    cin >> n;
    cin >> k;
    rep(i,n) cin >> a[i];

    Sliding_Minimum_Element_init();

    rep(i, n - (k - 1)){
        cout << b[i];
        if(i < n - k){
            cout << ' ';
        }else{
            cout << endl;
        }
    }
    
    return 0;
}
 
 



Measured memory_bytes: 14820
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string s;
	int t;
	cin>>s;
	t=s.size();
	if(s[0]==s[t-1])
	{
	if(t%2==0)
	cout<<"First"<<endl;
	if(t%2!=0)
	cout<<"Second"<<endl;
	}
	else 
	{
		if(t%2==0) 
		cout<<"Second"<<endl;
		else
		cout<<"First"<<endl;
		}
		return 0;
	}

Measured memory_bytes: 764
#include<iostream>
using namespace std;
void swap(int &a, int &b){
  a=a^b;
  b=a^b;
  a=a^b;
}
int main(){
  int n,cnt=0;
  cin >> n;
  int p[n];
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  for(int i=0;i<n;i++){
    if(p[i]==i+1){
      if(i!=n-1){
        swap(p[i],p[i+1]);
        cnt++;
      }else{
        swap(p[i],p[i-1]);
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }

vector<int> v;
int perm = 0;
bool used[10] = {};
void perm_dfs(int pos, int size)
{
   if (pos == size)
      v.push_back(perm);
   FOR(i, 0, size)
   {
      if (!used[i])
      {
         used[i] = true;
         perm = perm * 10 + (i + 1);
         perm_dfs(pos + 1, size);
         perm = (perm - i - 1) / 10;
         used[i] = false;
      }
   }
}

int main()
{
   int n, p = 0, q = 0, tmp, a, b;
   cin >> n;
   FOR(i, 0, n)
   {
      p *= 10;
      cin >> tmp;
      p += tmp;
   }
   FOR(i, 0, n)
   {
      q *= 10;
      cin >> tmp;
      q += tmp;
   }
   perm_dfs(0, n);
   FOR(i, 0, v.size())
   {
      if (p == v[i])
      {
         a = i;
      }
   }
   FOR(i, 0, v.size())
   {
      if (q == v[i])
      {
         b = i;
      }
   }

   cout << abs(a - b) << endl;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;

int main() {
	cin >> n;
	cout << "ABC" << n << endl;
}

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

using ll = long long;
const int N = 5e5+10;

int n, q;
char s[N];
set<int> idx[26];

int main () {
  scanf("%d %s %d", &n, s + 1, &q);
  for(int i = 1; i <= n; i++)
    idx[s[i] - 'a'].insert(i);
  while(q--) {
    int ty; scanf("%d", &ty);
    if(ty == 1) {
      int i; char x;
      scanf(" %d %c", &i, &x);

      idx[s[i] - 'a'].erase(i);
      s[i] = x;
      idx[s[i] - 'a'].insert(i);
    } else {
      int l, r; scanf(" %d %d", &l, &r);
      int ans = 0;
      for(int i = 0; i < 26; i++) {
        auto it = idx[i].lower_bound(l);
        if(it != idx[i].end() && *it <= r) ans++;
      }
      printf("%d\n", ans);
    }
  } return 0;
}

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

typedef long long ll;
using namespace std;

int N;
string S;

ll eval(int s){
    ll res = 0;
    int i = 0;
    while(i<N){
        ll tmp = 0;
        while(i<N && (s>>i)&1){
            tmp += S[i++]-'0';
            tmp *= 10;
        }
        tmp += S[i++]-'0';
        res += tmp;
    }
    return res;
}

int main(){
    cin >> S; N = S.size();
    
    ll ans = 0;
    for(int i=0; i<1<<(N-1); i++)
        ans += eval(i);
    
    cout << ans << endl;
    
    return 0;
}


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


int n;
int a[100001];
int b[100001];
int c[100001];


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

    for (int j = 0; j < n; j++)cin >> a[j];
    for (int j = 0; j < n; j++)cin >> b[j];
    for (int j = 0; j < n; j++)cin >> c[j];
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll A = lower_bound(a, a+n, b[i]) - a;
        ll B = n - (upper_bound(c, c+n, b[i])-c);
        ans += A*B;
    }
    cout << ans << endl;


    return 0;
}




Measured memory_bytes: 1408
#include <cstdio>
#include <utility>
#include <cmath>
using namespace std;

int gcd(int x,int y);
int max(int x,int y);


int main(){
    int ans;
    int N;
    scanf("%d",&N);

    int A[N];
    for(int i = 0;i<N;i++){
        scanf("%d",&A[i]);
    }
    if(N == 2){
        ans = max(A[0],A[1]);
        printf("%d",ans);
        return 0;
    }
    
    int gsum[N-1];
    gsum[0] = A[N-1];
    for(int i = 1;i<N-1;i++){
        gsum[i] = gcd(gsum[i-1],A[N-i-1]);
    }

    int lsum[N-1];
    lsum[0] = A[0];
    ans = max(gsum[N-2],gcd(A[0],gsum[N-3]));
    for(int i = 1;i < N-2;i++){
        lsum[i] = gcd(lsum[i-1],A[i]);
        int gci = gcd(lsum[i],gsum[N-3-i]);
        ans = max(ans,gci);
    }
    lsum[N-2] = gcd(lsum[N-3],A[N-2]);
    ans = max(ans,lsum[N-2]);
    printf("%d",ans);

    return 0;
}



int gcd(int x,int y){
    int tmp;

    if(x > y){
        tmp = x;
        x = y;
        y = tmp;
    }
    if(x == 1){
        return 1;
    }else if(x == 0){
        return y;
    }

    while(y%x != 0){
        tmp = y;
        y = x;
        x = tmp%x;
    }

    return x;

}
int max(int x,int y){
    if(x > y){
        return x;
    }else{
        return y;
    }
}


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

using namespace std;

typedef long long ll;

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

int main(){

    int N;

    cin >> N;

    int test;

    int res = 1;

    vector<int> A_n;

    rep(i,N) {
        
        cin >> test;
        if(test%2==0) A_n.push_back(test);
    }
    for(int x: A_n){
        if(x % 3 == 0) continue;

        else if (x % 5==0) continue;

        else {
            res = 0;
            break;
        }
    }
   
   if(res) cout << "APPROVED";
   else cout << "DENIED";

    return 0;

}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	double a, b;
	cin >> a >> b;
	print((int)ceil((a+b)/2));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
S=[input().strip() for i in range(N)]

PLUS=[]
MINUS=[]
ZERO=[0]
for br in S:
    NOW=0
    MIN=0
    for b in br:
        if b=="(":
            NOW+=1
        else:
            NOW-=1
            MIN=min(MIN,NOW)

    if NOW>0:
        PLUS.append((NOW,MIN))
    elif NOW<0:
        br2=br[::-1]

        NOW=0
        MIN=0
        for b in br2:
            if b==")":
                NOW+=1
            else:
                NOW-=1
                MIN=min(MIN,NOW)
        MINUS.append((NOW,MIN))
        
    else:
        ZERO.append(MIN)


from operator import itemgetter
PLUS.sort(key=itemgetter(1),reverse=True)

NOW0=0
for p,m in PLUS:
    if NOW0>=-m:
        NOW0+=p
    else:
        print("No")
        sys.exit()

MINUS.sort(key=itemgetter(1),reverse=True)

NOW1=0
for p,m in MINUS:
    if NOW1>=-m:
        NOW1+=p
    else:
        print("No")
        sys.exit()

if NOW0==NOW1 and NOW0>=-min(ZERO):
    print("Yes")
else:
    print("No")



        


Measured memory_bytes: 228528
#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
	
#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

using ll =long long ;
ll mod;

void solve(vector<vector<int>>&cango){
	int tt=cango.size();
	for(int i=0;i<tt;++i){
		for(int j=0;j<tt;++j){
			for(int k=0;k<tt;++k){
				cango[j][k]|=cango[j][i]&cango[i][k];
			}
		}
	}
}
vector<int> dfs(int now,int N,vector<pair<int,int>>&edges){
	vector<int>av{now};
	if(now*2+1<N){
		auto v=dfs(now*2+1,N,edges);
		av.insert(av.end(),v.begin(),v.end());
	}
	if(now*2+2<N){
		auto v=dfs(now*2+2,N,edges);
		for(auto e:v){
			edges.push_back(make_pair(now,e));
		}
		av.insert(av.end(),v.begin(),v.end());
	}
	return av;
}

int ask(int x){
	cout<<x+1<<endl;
	fflush(stdout);
	string st;cin>>st;
	if(st=="Yes")return -1;
	else if(st=="No")return 0;
	else return 1;
}
int main() {
	ios::sync_with_stdio(false);
	int N;cin>>N;
	int K;cin>>K;
	vector<pair<int,int>>edges;
	dfs(0,N,edges);
	sort(edges.begin(),edges.end());
	cout<<edges.size()<<endl;
	for(auto e:edges){
		cout<<e.first+1<<' '<<e.second+1<<endl;
	}

	while(K--){
		
		int now=0;
		while(true){
			int xx=ask(now);
			if(xx==-1)break;
			else{
				now=now*2+1+xx;
			}
		}
	}
	
	return 0;	
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  int ans = a+b;
  if(ans>9){
    cout << "error" << endl;
  }else{
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var hw = Console.ReadLine().Split(' ');
        var h = int.Parse(hw[0]);
        var w = int.Parse(hw[1]);

        var d = new string[h];
        for (int i = 0; i < h; i++)
        {
            d[i] = Console.ReadLine();
        }

        var dx = new[] { 1, 0, -1, 0 };
        var dy = new[] { 0, -1, 0, 1 };

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (d[i][j] == '#')
                {
                    var any = false;
                    for (int k = 0; k < 4; k++)
                    {
                        var sy = i + dy[k];
                        var sx = j + dx[k];

                        if (0 <= sy && sy < h &&
                            0 <= sx && sx < w &&
                            d[sy][sx] == '#')
                        {
                            any = true;
                            break;
                        }
                    }
                    if (!any)
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
            }
        }

        Console.WriteLine("Yes");
    }
}


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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 3e18 + 8;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9;

const int maxn = 1e5 + 7;

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int r;
    cin >> r;
    double ans = 2 * PI * r;
    cout << setprecision(10) << fixed;
    cout << ans;
    return 0;
}


Measured memory_bytes: 3804
n = int(input())
arr = [ int(x) for x in input().strip().split(' ') ]
isZ = False
for x in arr:
    if x == 0:
        isZ = True

if isZ:
    print ("0")
    exit(0)

res = 1
for x in arr:
    res *= x
    if res > 1000000000000000000:
        print ("-1")
        exit(0)
print (res)

Measured memory_bytes: 21660
while True:
    H, W = map(int, input().split())

    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if ((h == 0) or
                (h == H - 1) or
                (w == 0) or 
                (w == W - 1)):
                print("#", end="")
            else:
                print(".", end="")

        print()

    print()



Measured memory_bytes: 7008
#include<stdio.h>

int main(void){
    int n,b,f,r,v;
    int i,j,k;
    int rooms[4][3][10];

    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                rooms[i][j][k]=0;
            }
        }
    }

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        rooms[b-1][f-1][r-1]+=v;
    }

    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",rooms[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3) printf("####################\n");
    }

    return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
using namespace std;

int main() {
	stack<long long> ST;
	string S;
	while (cin >> S) {
		if (S == "+") {
			long long N = ST.top();
			ST.pop();
			N += ST.top();
			ST.pop();
			ST.push(N);
		}
		else if (S == "-") {
			long long N = ST.top();
			ST.pop();
			N = ST.top() - N;
			ST.pop();
			ST.push(N);
		}
		else if (S == "*") {
			long long N = ST.top();
			ST.pop();
			N *= ST.top();
			ST.pop();
			ST.push(N);
		}
		else {
			long long N = 0;
			for (int i = 0; i < S.size(); i++) {
				N *= 10;
				N += S[i] - '0';
			}
			ST.push(N);
		}
	}
	cout << ST.top() << endl;
}


Measured memory_bytes: 3196
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))
#define all(v) v.begin(),v.end()

struct cmp {
    bool operator() (const ll& a, const ll& b){
        return a < b;
    }
};

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    string s; cin>>s;
    ll sum=0;
    for(ll i=0;i<s.length();i++)
        sum += (ll)(s[i]-'0');
    (sum%9)? cout<<"No" : cout<<"Yes";
    cout<<'\n';

    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


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

const string INF = "1111111111111111";
const int n = 32;

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

  int N; cin >> N;

  int n2 = n/2;
  vector<pair<int,string>> v;
  for(int i = 0; i < 1 << n2; i++){
    int res = 0;
    string s;
    for(int j = 0; j < n2; j++){
      if(i & (1 << j)){
        res += pow(-2,j);
        s = '1' + s;
      }
      else s = '0' + s;
    }
    v.push_back({res,s});
  }
  sort(v.begin(),v.end());

  for(int i = 0; i < 1 << n-n2; i++){
    int res = 0;
    string s;
    for(int j = 0; j < n-n2; j++){
      if(i & (1 << j)){
        res += pow(-2,n2+j);
        s = '1' + s;
      }
      else s = '0' + s;
    }
    auto p = lower_bound(v.begin(),v.end(),make_pair(N-res,INF));
    p--;
    if(N == res + p->first){
      string ans = s + p->second;
      for(int j = 0; j < ans.size(); j++){
        if(ans[j] == '1'){
          cout << ans.substr(j) << endl;
          return 0;
        }
      }
    }
  }
  cout << 0 << endl;

  return 0;
}


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

int main(int argc, char const *argv[]) {
	int x, a; cin >> x >> a;
	if (x < a) printf("%d\n", 0);
	else printf("%d\n", 10);
	return 0;
}

Measured memory_bytes: 256
// CPP program to demonstrate use of std::map 
#include<iostream>
#include<stdio.h>
#include<string>
#include<stack>
#include<string.h>
using namespace std;
int main(){ 
    string N;
    cin >> N;
    long long int sum=0;
    for(int i=0;i<N.size();i++){
        sum+=N[i]-'0';
    }
    if(sum % 9 == 0)
        cout << "Yes" << endl; 
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3356
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int a,b;
cin>>a>>b;
ol(2*b-a);

return 0;
}



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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n;
    cin >> n;
    vi v(n);

    fo(i, n) cin >> v[i];
    sort(all(v));

    long double med = v[0];
    fo(i, n - 1) {
        med = (med + v[i + 1]) / 2;
    }

    cout << fixed << setprecision(10) << med << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

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

    cin >> n;
    int a;
    set<int> s;
    s.insert(1000000001);
    rep(i, n){
        cin >> a;
        if(s.find(a) == s.end()){
            s.insert(a);
        }else{
            s.erase(a);
        }
    }
    cout << s.size() - 1 << endl;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

char word[15];
int n;

void backtrack(int n, int w, char c) {
    if (w == n) {
        printf("%s\n", word);
        return;
    }
    
    for (char z = 'a'; z <= c; z++) {
        word[w] = z;
        backtrack(n, w + 1, c);
    }
    if (w > 0) {
        word[w] = c + 1;
        backtrack(n, w + 1, c + 1);
    }
}

int main() {
    scanf("%d", &n);
    backtrack(n, 0, 'a');
    return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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 LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    int n,a,b;cin >> n >> a >> b;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int t;cin >> t;
        if(t < a || b <= t) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		System.out.println(Math.min(c, a+b+1)+b);
	}

}

Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
       try{ 
        String line1 = reader.readLine();
        int N = Integer.parseInt(line1);
        String line2 = reader.readLine();
        String[] split = line2.split(" ");
        int[] A = new int[N];
        for(int i = 0; i < N ; i ++){
            A[i] = Integer.parseInt(split[i]);
        }
        int count = 0;
        for(int i = 0; i < N-1; i++){
            int minid = i;
            for(int j = i + 1; j < N; j++){
                if(A[j] < A[minid]){
                    minid = j;
                }
            }
            if(minid != i){
                int temp = A[i];
                A[i] = A[minid];
                A[minid] = temp;
                count ++;
            }
        }
        for(int i = 0; i < N; i++){
            if(i < N-1){
                System.out.print(A[i] + " ");
            }else{
                System.out.println(A[i]);
            }
        }
        System.out.println(count);
       }catch(IOException e){

       }
    }
}


Measured memory_bytes: 24500
#include <stdio.h>
#include <math.h>

int main(void){

    long int num, i, temp;
    long int boss_num[200005] = {};
    long int counter[200005] = {};

    scanf("%ld", &num);

    for(i = 0; i < num-1; i++){
        scanf("%ld", &boss_num[i]);
        temp = boss_num[i];
        counter[temp] += 1;
    }

    for(i = 1; i < num + 1; i++){
        printf("%ld\n", counter[i]);
    }

    return 0;

}

Measured memory_bytes: 4860
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

int main() {
    int n, k;
    int min = mod, max = -mod;
    ll sum = 0;
    cin >> n;
    rep(i, n) {
        cin >> k;
        sum += k;
        if(min > k)
            min = k;
        if(max < k)
            max = k;
    }
    cout << min << " " << max << " " << sum << endl;
}



Measured memory_bytes: 3124
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let n:usize = get_input().parse().unwrap();
    let mut h:Vec<u64> = get_input().split_whitespace().map(|x| x.parse().unwrap()).collect();

    let mut ans = "Yes";

    for i in (0..n-1).rev() {
        if h[i + 1] < h[i] {
            h[i] -= 1;
        }
        if h[i + 1] < h[i] {
            ans = "No";
            break;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 8444
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <assert.h>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

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

char from[11][22];
int fromlen[11];
char to[11][22];
int tolen[11];

char source[22];
char dest[22];

set<int> failed[11];
int limit = 0;
int n = 0;
int srclen = 0;
int dstlen = 0;

inline int thash(char* str,int len)
{
	int hash = 0;
	for(int i = 0;i < len;i++) hash = hash * 233 + str[i];
	return hash;
}

int dfs(char* cur, int x, int clen)
{
	if(x > limit) return 0;
	if(strcmp(cur,dest) == 0) return 1;
	if(clen == dstlen) return 0;
	int h = thash(cur,clen);
	if(failed[x].find(h) != failed[x].end()) return 0;

	for(int i = 0;i < n;i++)
	{
		// transform
		bool pos[11] = {0};
		int cnt = 0;
		for(int j = 0;j < clen;)
		{
			if(strncmp(from[i],cur+j,fromlen[i]) == 0)
			{
				pos[j] = true;
				j += fromlen[i];
				cnt++;
			}
			else j++;
		}
		if(!cnt || clen + (tolen[i]-fromlen[i])*cnt > dstlen) continue;
		char nstr[13] = {0};
		int nlen = 0;
		for(int j = 0;j < clen;)
		{
			if(pos[j])
			{
				strcpy(nstr+nlen,to[i]);
				nlen += tolen[i];
				j += fromlen[i];
			}
			else nstr[nlen++] = cur[j++]; 
		}
		if(dfs(nstr,x+1,nlen)) return 1;
	}
	failed[x].insert(h);
	return 0;
}

int main(void)
{
	while (scanf("%d",&n) != EOF && n)
	{
		for(int i = 0;i < n;i++)
		{
			scanf("%s %s",from[i],to[i]);
			fromlen[i] = strlen(from[i]);
			tolen[i] = strlen(to[i]);
		}
		scanf("%s %s",source,dest);

		if(strcmp(source,dest) == 0)
		{
			puts("0");
			continue;
		}

		srclen = strlen(source);
		dstlen = strlen(dest);
		int ans = -1;
		for(limit = 1;limit <= dstlen-srclen;limit++)
		{
			for(int i = 0;i < 11;i++) failed[i].clear();
			if(dfs(source,0,srclen))
			{
				ans = limit;
				break;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1092
N=int(input())
a=list(map(int,input().split()))
a_sum=sum(a)
ans_list=[]
sunuke=a[0]
araiguma=a_sum-a[0]
for i in range (1,N):
    ans_list.append(abs(sunuke-araiguma))
    sunuke+=a[i]
    araiguma-=a[i]
print(min(ans_list))

Measured memory_bytes: 24812
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_d"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func chmax(x *int, v int) {
	if *x < v {
		*x = v
	}
}

func solve(N, W int, wvs [][]int) int {
	t := make([][]int, N+1, N+1) // t[item_index][weight]
	for i := range t {
		t[i] = make([]int, W+1, W+1)
	}
	for i, wv := range wvs {
		w, v := wv[0], wv[1]
		for sumWeight := 0; sumWeight <= W; sumWeight++ {
			if sumWeight-w >= 0 {
				chmax(&t[i+1][sumWeight], t[i][sumWeight-w]+v)
			}
			chmax(&t[i+1][sumWeight], t[i][sumWeight])
		}
	}
	return t[N][W]
}

func main() {
	scan := newScanner(os.Stdin)
	N, W := scan.Int(), scan.Int()
	wvs := make([][]int, N, N)
	for i := 0; i < N; i++ {
		wvs[i] = []int{scan.Int(), scan.Int()}
	}
	fmt.Println(solve(N, W, wvs))
}


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

int main(){
  constexpr int64_t Nalp= 26;
  int64_t bufN;
  cin >> bufN;
  int64_t N= bufN;

  string ans;
  while(N > 0){
    int64_t tail= (N-1)%Nalp;
    char c= ('a'+ tail);
    ans= c+ ans;

    N-= (tail+1);
    N/= Nalp;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans;
    if(k<=a) ans=k;
    else if(k<=a+b) ans=a;
    else if(k>a+b) ans=a-(k-a-b);
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3656
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      val n = readLine().split(" ").map(_.toInt).sorted
      val (a,b,c) = (n(0),n(1),n(2))
      println(a + " " + b + " " + c)
  }
}

Measured memory_bytes: 43820
#include<bits/stdc++.h>
using namespace std;
int main(){
	int l,r;
	scanf("%d%d",&l,&r);
	if(l%2019==0||(r/2019)-(l/2019)){printf("0");return 0;}
	r%=2019,l%=2019;int ans=2019;
	for(int i=l;i<=r;i++)for(int j=i+1;j<=r;j++)ans=min(ans,i*j%2019);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

MOD = 10**9 + 7

N = int(input())
ball = [tuple(int(x) for x in input().split()) for _ in range(N+N)]

# x座標を1,2,...,N
# y座標をN+1,N+2,...,N+N

graph = [set() for _ in range(N+N+1)]
for x,y in ball:
    graph[x].add(y+N)
    graph[y+N].add(x)

visited = set()
components = []
for x in range(1,N+N+1):
    if x in visited:
        continue
    V = set([x])
    q = [x]
    while q:
        y = q.pop()
        for z in graph[y]:
            if z in V:
                continue
            V.add(z)
            q.append(z)
    visited |= V
    components.append(V)

def make_get_patterns(V):
    deg1 = [x for x in V if len(graph[x]) == 1]
    get = {},{}
    while deg1:
        x = deg1.pop()
        if not graph[x]:
            continue
        y = graph[x].pop()
        se = graph[y]; se.remove(x)
        if len(se) == 1: deg1.append(y)
        if x < y:
            get[0][(x,y)] = 0; get[1][(x,y)] = 0
        else:
            pass
            get[0][(y,x)] = 1; get[1][(y,x)] = 1
    for x in V:
        if graph[x]:
            y = graph[x].pop()
            break
    # 残りはサイクル
    graph[y].remove(x)
    if x > y: x,y = y,x
    get[0][(x,y)] = 0; get[1][(x,y)] = 1
    while True:
        if not graph[x]:
            break
        y = graph[x].pop()
        graph[y].remove(x)
        if x < y:
            get[0][(x,y)] = 1; get[1][(x,y)] = 0
        else:
            get[0][(y,x)] = 0; get[1][(y,x)] = 1
        x = y
    return get

def F(V):
    # V is connected
    E = sorted((x,y) for x in V if x <= N for y in graph[x])
    if len(E) != len(V):
        return 0
    ret = 0
    for get in make_get_patterns(V):
        den = 1
        dp = {x:0 for x in V}
        for x,y in E:
            if get[(x,y)] == 0:
                k = dp[x] + 1
            else:
                k = dp[y] + 1
            dp[x] += k
            dp[y] += k
            den *= k
            den %= MOD
        ret += pow(den,MOD-2,MOD)
    return ret % MOD

prob = 1
for c in components:
    prob *= F(c)
    prob %= MOD

answer = prob
for n in range(1,N+N+1):
    answer *= n
    answer %= MOD
print(answer)


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, ans=0;
	cin>>N;
	for(int i=1;i<=N;i++) {
		int a;
		cin>>a;
		ans+=i&1&a&1;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3612