akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

Int dp[101][5];

int main() {
    string s;
    Int k;
    cin >> s >> k;
    dp[0][0] = 1;
    Int n = s.size();
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j <= 3; j++) {
            if (dp[i][j] == 0) continue;
            dp[i + 1][j] += dp[i][j];
            if (j == cnt) {
                dp[i + 1][j + 1] += (dp[i][j] - 1) * 9 + (s[i] - '0');
            }
            else {
               
                dp[i + 1][j + 1] += dp[i][j] * 9;
            }
        }
        if (s[i] != '0') {
            cnt++;
        }
    }
    // for (Int i = 0; i <= n; i++) {
    //     for (Int j = 0; j < 3; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    //}
    dump(dp[n][k]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int x,i=1;
	while(1)
	{
		cin>>x;
		if(x!=0)
		{
			cout<<"Case"<<" "<<i<<": "<<x<<endl;
			i++;
		} 
		else
		{
			return 0;
		}
	}
}
 


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

using namespace std;

const int mod = 1e9 + 7;

int main()
{
  string s;
  cin >> s;
  int size = s.size();
  vector<vector<long long>> dp(size + 1, vector<long long>(4, 0));
  dp[0][0] = 1;
  for (int i = 0; i < size; i++)
    for (int j = 0; j < 4; j++)
    {
      dp[i + 1][j] += dp[i][j] * (s[i] == '?' ? 3 : 1);
      if (j < 3 && (s[i] == '?' || s[i] == "ABC"[j]))
        dp[i + 1][j + 1] += dp[i][j];
      dp[i + 1][j] %= mod;
      dp[i + 1][j + 1] %= mod;
    }
  cout << dp[size][3] % mod << endl;

  return 0;
}


Measured memory_bytes: 7424
#include <stdio.h>
#include <stdlib.h>
 
#define CLEAN 0
#define DIRTY 1
#define SIZE  1401
#define INITIAL_STACK_SIZE 10
 
int table[SIZE][SIZE] = {};
int board[SIZE][SIZE] = {};
 
typedef struct Rectangle {
  int height;
  int pos;
} Rectangle;
 
typedef struct _stack {
  int size;
  int max;
  Rectangle *stack;
} *Stack;
 
Stack stack_init() {
  Stack stack = (Stack)malloc(sizeof(struct _stack));
  stack->size = 0;
  stack->max = INITIAL_STACK_SIZE;
  stack->stack = (Rectangle *)malloc(sizeof(Rectangle)*INITIAL_STACK_SIZE);
  return stack;
}
 
Rectangle empty_rectangle() {
  return (Rectangle) {
    .height = 0,
    .pos = 0
  };
}
 
Rectangle top(Stack stack) {
  if (stack->size <= 0) {
    return empty_rectangle();
  } else
    return stack->stack[stack->size-1];
}
 
Rectangle pop(Stack stack) {
  if (stack->size <= 0) {
    return empty_rectangle();
  } else
    return stack->stack[--(stack->size)];
}
 
Rectangle push(Rectangle item, Stack stack) {
  int i;
  if (stack->size < stack->max) {
    stack->stack[(stack->size)++] = item;
  } else {
    Rectangle *newStack = (Rectangle *)malloc(sizeof(int) * stack->max * 2);
 
    if (newStack == NULL) {
      perror("malloc failed.\n");
      exit(-1);
    }
      
    for (i=0; i<stack->size; i++)
      newStack[i] = stack->stack[i];
 
    newStack[stack->size++] = item;
    stack->max *= 2;
    free(stack->stack);
    stack->stack = newStack;
  }
 
  return item;
}
 
int empty(Stack stack) {
  return !stack->size;
}
 
void free_stack(Stack stack) {
  free(stack);
}
 
void create_table(int h, int w) {
  int i, j;
 
  for (i=0; i<w; i++)
    table[0][i] = (board[0][i] ? 0 : 1);
   
  for (i = 1; i < h; i++) {
    for (j = 0; j < w; j++) {
      if (board[i][j] == CLEAN)
    table[i][j] = table[i-1][j] + 1;
      else
    table[i][j] = 0;
    }
  }
}
 
int rectangleAreaMaxRow(int row[],int w) {
  Stack s = stack_init();
  int i, max = 0;
  row[w] = DIRTY;
 
  for (i=0; i<=w; i++) {
    Rectangle r;
    r.height = row[i];
    r.pos = i;
     
    if (empty(s) || top(s).height < r.height) {
      push(r, s);
    } else {
      int target = i;
      while (!empty(s) && top(s).height >= r.height) {
        Rectangle pre = pop(s);
        int area = pre.height * (i-pre.pos);
        max = (area > max ? area : max);
        target = pre.pos;
      }
    r.pos = target;
    push(r, s);
    }
  }
 
  free_stack(s);
  return max;
}
   
int rectangleAreaMax(int h, int w)
{
  int i, max = 0, temp;
  for (i=0; i<h; i++) {
    temp = rectangleAreaMaxRow(table[i], w);
    max = (temp > max ? temp : max);
  }
 
  return max;
}
 
int main() {
  int i, j, h, w;
 
  scanf("%d %d", &h, &w);
  for (i=0; i<h; i++)
    for (j=0; j<w; j++)
      scanf("%d", &board[i][j]);
 
  create_table(h, w);
   
  printf("%d\n", rectangleAreaMax(h, w));
   
  return 0;
}

Measured memory_bytes: 16056
#include <iostream>
#include <string>
using namespace std;
int main(){
  string S;
  cin >> S ;
  for(int i=0;i<S.size()-1;i++){
    if(S[i]=='A'&&S[i+1]=='C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int s;
	cin >> s;

	cout << !!(s & 1) + !!(s & 10) + !!(s & 100) << "\n";

	return 0;
}

Measured memory_bytes: 256
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 1000* 100 + 5;
int a[maxn];

int32_t main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
    }
    sort(a, a + n);
    for(int i = 1; i < n; i ++){
        a[i] += a[i - 1];
    }
    int pt = 0, ans = 0;
    for(int i = 0; i < n; i ++){
        xmax(pt, i);
        while(pt < n and (a[pt]* 2) >= (a[pt + 1] - a[pt]))
            pt ++;
        if(pt == n)
            ans ++;
    }
    cout <<ans <<endl;
    return false;
}


Measured memory_bytes: 1024
from collections import deque
N = int(input())
A = list(map(int, input().split()))
x = deque()
acc = 0
ans = 0
for a in A:
    while acc & a:
        acc ^= x.popleft()
    x.append(a)
    acc ^= a
    ans += len(x)
print(ans)


Measured memory_bytes: 25096
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
string s[114];
signed main() {
	int h, w;
	cin >> h >> w;
	rep(i, h)cin >> s[i];
		for (int i = 0; i < h; i++) {
			cout << s[i] << endl;
			cout << s[i] << endl;
		}
	getchar(); getchar(); return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll sumA = 0;
    ll opeA = 0;
    rep(i, n)
    {
        sumA += a[i];
        if (i % 2 == 0)
        {
            if (sumA <= 0)
            {
                opeA += abs(sumA) + 1;
                sumA += abs(sumA) + 1;
            }
        }
        else
        {
            if (sumA >= 0)
            {
                opeA += abs(sumA) + 1;
                sumA -= abs(sumA) + 1;
            }
        }
    }
    ll sumB = 0;
    ll opeB = 0;
    rep(i, n)
    {
        sumB += a[i];
        if (i % 2 == 0)
        {
            if (sumB >= 0)
            {
                opeB += abs(sumB) + 1;
                sumB -= abs(sumB) + 1;
            }
        }
        else
        {
            if (sumB <= 0)
            {
                opeB += abs(sumB) + 1;
                sumB += abs(sumB) + 1;
            }
        }
    }
    cout << min(opeA, opeB) << endl;
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

//const int INF = 1e9 + 7;

int main() {

	ll n, x;
	cin >> n >> x;
	vector<pll> a(ARRAY_MAX);
	vector<ll> b(ARRAY_MAX,0);

	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i].first;
		b[i] = a[i].first;
		a[i].second = i;
	}
	//番兵
	b[0] = 0;
	b[n + 1] = 0;

	sort(a.begin(), a.end(), greater<pll>());

	vector<ll> ans;

	for (ll i = 0; i < n; i++)
	{
		ll index = a[i].second;
		ll num = a[i].first;
		if (b[index] + b[index + 1] >= x)
		{
			for (ll j = index; j < n; j++)
			{
				ans.push_back(j);
			}
			for (ll j = index - 1; j >= 1; j--)
			{
				ans.push_back(j);
			}
			break;
		}
		else if (b[index] + b[index-1] >= x)
		{
			for (ll j = index - 1; j >= 1; j--)
			{
				ans.push_back(j);
			}
			for (ll j = index; j < n; j++)
			{
				ans.push_back(j);
			}
			break;
		}
	}
	
	if (ans.size() > 0)
	{
		cout << "Possible" << endl;
		for (ll i = ans.size()-1; i >= 0; i--)
		{
			cout << ans[i] << endl;
		}
	}
	else {
		cout << "Impossible" << endl;
	}


	return 0;
}


Measured memory_bytes: 4084
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define BigInt      __int128
#define endl        '\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define sim         template < class c
#define ris         return * this
#define dor         > debug & operator <<
#define eni(x)      sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

using namespace std;

sim > struct rge {c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug 
{
	~debug() 
	{ 
		cerr<<endl; 
	}
	eni(!=) cerr << boolalpha << i; ris; }
	eni(==) ris << range(begin(i), end(i)); }
	sim, class b dor(pair < b, c > d) 
	{
		ris << "(" << d.first << ", " << d.second << ")";
	}
	sim dor(rge<c> d) 
	{
	  	*this << "[";
	  	for (auto it = d.b; it != d.e; ++it)
	    	*this << ", " + 2 * (it == d.b) << *it;
	  	ris << "]";
	}
};
#define fuck(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		string s;
		cin>>s;
		for(auto it:s)
		{
			if(it=='?')
			{
				cout<<"D";
			}
			else
			{
				cout<<it;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3740
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

int main(){
  ll N;
  cin >> N;
  if(N&1){
    cout << 0 << endl;
  }else{
    ll ni = 0 , go = 0;
    ll waruni = 2 , warugo = 10;
    while(waruni <= N){
      ni += N/waruni;
      waruni *= 2;
    }
    while(warugo <= N){
      go += N/warugo;
      warugo *= 5;
    }
    ll ans = ni;
    if(ans > go)ans = go;
    cout << ans << endl;


  }
}


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

int main() {
  int A, B, C, X, sum, count;
  cin >> A >> B >> C >> X;
  sum = 0;
  count = 0;
  
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        if (sum == X) count ++;
        sum = 500 * a + 100 * b + 50 * c;
      }
    }
  }
  cout << count << endl;
}

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

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

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

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

int main() {
  int n;
  cin >> n;
  ll total = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    total += i;
  }
  cout << total << endl;

  return 0;
}

Measured memory_bytes: 3624
A,B,K = map(int,input().split())
a,b = A,B
if(K <= A):
  a = A-K
  b = B
elif((A <= K)and(A+B >= K)):
  a = 0
  b = B-(K-A)
else:
  a = 0
  b = 0
print(a,b)

Measured memory_bytes: 3060
di = { chr(i):0 for i in range(97,97+26)}
try:
    while 1:
        l = [x for x in input().lower()]
        for i in range(len(l)):
            if l[i] in di:
                di[l[i]] += 1
except EOFError:
    pass
for a, b in di.items():
    print(a ,":" , b)


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;} 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 
// ========================================================
signed main(){
  #ifndef ONLINE_JUDGE
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  #endif
  fio;
    int n;
    cin>>n;
    if(n%1000 == 0){
        cout<<0<<endl;
    }
    else{
        cout<<(1000-(n%1000))<<endl;
    }
  rr;
}



Measured memory_bytes: 3628
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

//型宣言
typedef long long ll;
typedef unsigned long long ull;
typedef std::string string;
typedef ll answerType;

//変数宣言
ll N;
ll M;
std::vector<string> input;
std::vector<string> Ai;
std::vector<string> Bi;
answerType answer;

//関数のプロトタイプ宣言
//入力の取得
void getInput();
//答えを求める
answerType calcAnswer();

//メイン関数
int main() {
	//入力の取得
	getInput();

	//答え
	answerType answer = calcAnswer();

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}

//入力の取得
void getInput() {
	std::cin >> N >> M;
}

//答えを求める
answerType calcAnswer() {
	ll count = 0;
	ll loopStart = N;
	ll loopEnd = M;
	for(ll i=loopStart; i<=loopEnd; i++) {
		if(i % 10 == 0) {
			continue;
		}
		string temp = std::to_string(i);
		std::reverse(temp.begin(), temp.end());
		if(i == std::stoll(temp)) {
			count++;
		}
	}
	return count;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++){
			a[i] = sc.nextInt();
		}
		
		int nowon = 1;
		int count = 0;
		
		for(int i=0; i<n; i++){
			if (nowon == 2){
				break;
			}
			nowon = a[nowon-1];
			count++;
		}
		
		if (count == n){
			System.out.println(-1);
		}
		else{
			System.out.println(count);			
		}
		
		sc.close();
	}
}


Measured memory_bytes: 50488
h,w=map(int,input().split())
s=[]
for i in range(h):
    s.append(list(input()))
a=["+" for i in range(w)]
s.append(a)
s.insert(0,a)
for i in range(h+2):
    s[i].append("+")
    s[i].insert(0,"+")
for i in range(1,h+1):
    for j in range(1,w+1):
        if s[i][j]==".":
            m=0
            for x in range(3):
                for y in range(3):
                    if s[i-1+x][j-1+y]=="#":
                        m+=1
            s[i][j]=str(m)
for i in range(1,h+1):
    ans=s[i][1]
    for j in range(w-1):
        ans=ans+s[i][j+2]
    print(ans)


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  int dp[100] = {};
  dp[0] = 1;
  dp[1] = 1;

  for (int i = 2; i <= n; i++) {
    dp[i] = dp[i - 1] + dp[i - 2];
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
const int M = 1e5+10;
#define ll long long
#define F first
#define S second

int c[10][10];
int ans[10][10];
#define int ll
main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int h,w;cin>>h>>w;
	for(int i=0;i<=9;i++)
		for(int j=0;j<=9;j++)
			cin>>ans[i][j];
	for(int k=0;k<=9;k++)
		for(int i=0;i<=9;i++)
			for(int j=0;j<=9;j++)	
				ans[i][j]=min(ans[i][k]+ans[k][j],ans[i][j]);
	int tot=0;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			int x;cin>>x;
			if(x!=-1)
				tot+=ans[x][1];
		}
	cout<<tot;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int X, Y;
	int neko = 0;
	if (scanf("%d%d", &X, &Y) != 2) return 1;
	if (X <= 3) neko += 4 - X;
	if (Y <= 3) neko += 4 - Y;
	if (X == 1 && Y == 1) neko += 4;
	printf("%d%s\n", neko, "00000" + !neko * 5);
	return 0;
}


Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int V[N];
  int C[N];
  for(int i=0;i<N;i++){
    cin >> V[i];
  } 
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  int ans=0;
  for(int i =0;i<N;i++){
    if(V[i]>C[i]){
      ans += (V[i] - C[i]);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  string s; std::cin >> s;
  int x = 0, ans = 0;
  rep(i, s.size()) {
    if (s[i] == 'I') x++;
    else x--;
    chmax(ans, x);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
ll N, A[200010];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;

    ll t = 0;

    ll d[200010];

    REP(i,0,N){
        cin>>A[i];
        d[i] = (A[i] - (i+1));
    }
    sort(d, d+N);

    ll bb[3];

    bb[0] = d[max(0LL, N/2 - 1)];
    bb[1] = d[N/2];
    bb[2] = d[min(N-1LL, N/2 + 1)];

    ll ans = LLINF;
    REP(i,0,3){
        ll b = bb[i];
        ll tans = 0;
        REP(j,0,N){
            tans += abs(A[j] - (j+1) - b);
        }
        ans = min(ans, tans);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3328
#include <iostream>

typedef long long ll;

using namespace std;

int main()
{
    ll N, X, result = 0;
    cin >> N >> X;
    result += N;
    ll a, b, temp;
    a = X;
    b = N - X;
    while (b % a != 0)
    {
        temp = a * (b / a);
        result += 2 * temp;
        b -= temp;
        swap(a, b);
    }
    result+= 2 * a * (b / a) - a;
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, n, m) for(int i = n; i >= m; i--)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;

int main(){

  int N;
  cin >> N;
  ll hig=0;

  rep(i,N){

    ll H;
    cin>>H;
    if(H>hig){
      hig=H-1;
    }
    else if(H==hig){
      hig=H;
    }
    else{
      std::cout << "No" << '\n';
      return 0;
    }

  }
  cout << "Yes" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct compare
{
    bool operator()(const string& first, const string& second)
    {
        return first.size()>second.size();
    }
};
void solve()
{
    long long n;
    cin>>n;
    cout<<pow(n,3)<<endl;

}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb                 push_back
#define bug(x)             cerr<<#x<<" "<<x<<endl;
#define T int time;        scanf("%d", &time); while(time--)
    vector<ll>ar;
  bool check(ll i,ll n){
    if(abs(i-n)<=1)return true;
    for(ll ii=n-1; ii>i; ii--)if(ar[ii]<ar[ii-1])
      cout<<ar[ii]<<" ";
    cout<<endl;
    return true;
  }

   int main(){
        string s1,s2;
        cin>>s1>>s2;
        ll n,m;
        cin>>n>>m;
        string u;
        cin>>u;
        if(u==s1)n--;
        else m--;
        cout<<n<<" "<<m<<endl;
     }
   

Measured memory_bytes: 3496
def draw(i):
    global p,q,hd,wd
    B[p][q] = i
    if (q < W-1 and hd != -1):
        hd = 1
        wd = 0
    elif (hd == 1 and q == W-1) or (hd == -1 and q == 0):
        hd = 0
        wd = 1
    elif (q > 0 and hd != 1):
        hd = -1
        wd = 0
    p += wd
    q += hd

if __name__ == '__main__':
    p = 0
    q = 0
    hd = 1
    wd = 0
    H, W = list(map(int, input().split()))
    N = int(input())
    As = list(map(int, input().split()))
    B = [[0 for i in range(W)] for j in range(H)]

    for i in range(N):
        for j in range(As[i]):
            draw(i+1)

    for i in range(H):
        s = list(map(str, B[i]))
        print(' '.join(s))




Measured memory_bytes: 42096
#include <iostream>
#include <stdio.h>
int main(){

	int n,i,kane=100000,a,b;

	std::cin>>n;

	for(i=0;i<n;i++){
		kane=kane*1.05;
		if(kane%1000!=0){
			a=kane%1000;
			b=1000-a;
			kane=kane+b;
			}
		}
	
	std::cout<<kane<<std::endl;

		return 0;
		}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n,a,b,w;

vector<pair<int,int>> gr[N];
bool vis[N];
int dis[N];

void dfs(int node ,int par){
	vis[node] = true;
	for(auto i : gr[node]){
		if(!vis[i.first]){
			dis[i.first] = (i.second + dis[node])%2;
			dfs(i.first , node);
		}
	}
}

int32_t main(){
    boost;
    //code
    cin >> n;
    
    for(int i = 0 ; i < n ; ++i){
    	cin >> a >> b >> w;
    	gr[a].push_back({b,w});
    	gr[b].push_back({a,w});
    }

    dfs(1,0);

    for(int i = 1 ; i <= n ; ++i){
    	cout << dis[i] << "\n";
    }
    return 0;
}

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

using ll=long long;

ll d;
vector<ll> mypow10(22);
map<tuple<int,int,int>,ll> mp;
ll dfs(int id,int c,int k,vector<int>& num,ll sum){
    if(mp.count(make_tuple(k,id,sum))) return mp[make_tuple(k,id,sum)];
    if(id*2+1>k){
        return sum==d;
    }
    if(id*2+1==k){
        return (int)(sum==d)*10;
    }
    ll res=0;
    int x=d/mypow10[id]%10;
    int y=d/mypow10[k-id-1]%10;

    for(int i=0;i<10;i++){
        int j=(x+i+c)%10;
        if(id==0 && j==0) continue;
        int nexc=j-c<i;
        num[id]=i;
        num[k-id-1]=j;
        int tmp=(i+10-j)%10;
        
        if(tmp==y || tmp==(y+1)%10){
            ll nexsum=sum+(j-i)*mypow10[id]+(i-j)*mypow10[k-id-1];
            res+=dfs(id+1,nexc,k,num,nexsum);
        }
        num[id]=-1;
        num[k-id-1]=-1;
    }
    return mp[make_tuple(k,id,sum)]=res;
}
int main(){
    mypow10[0]=1;
    for(int i=1;i<mypow10.size();i++){
        mypow10[i]=mypow10[i-1]*10;
    }
    int tmp;
    cin>>tmp;
    d=tmp;
    ll res=0;
    for(int k=1;k<=19;k++){
        vector<int> num(k,-1);
        res+=dfs(0,0,k,num,0);
    }
    cout<<res<<endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int a[2][100];
  int n;
  cin>>n;
  rep(k,2){
  rep(i,n){
    cin>>a[k][i];
  }
}
int t=0;
int ans=0;
rep(k,n){
  int s=0;
rep(i,n){
  s+=a[t][i];
  if(k==i){
    t++;
    s+=a[t][i];
  }
}
t=0;
ans=max(s,ans);
}
cout<<ans<<endl;
return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  string s,t;
  cin >> s >> t;
  
  int same = 0;
  
  for(int i=1;i<=n;i++){
    if(s.substr(n - i,i) == t.substr(0,i))
      same = i;
  }
  
  cout << n * 2 - same << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
    while(1){
        int a,b; cin >> a>> b;
        if(a==0&&b==0)break;
        int k=b-a;
        cout << k%500/100 << " " << (k%1000>=500?1:0) << " " << k/1000 << endl;
    }
}


Measured memory_bytes: 3072
def counting_sort(array, max_val=10000):
    max_val = min(max(array), max_val)
    counting_array = [0] * (max_val+1)
    sorted_array = [0 for x in range(len(array))]

    for i in array:
        counting_array[i] += 1

    for i in range(1, max_val + 1):
        counting_array[i] += counting_array[i-1]

    for i in range(len(array))[::-1]:
        val = array[i]
        sorted_array[counting_array[val]-1] = val
        counting_array[val] -= 1

    return sorted_array


def main():
    n = int(input())
    array = [int(x) for x in input().split()]
    sorted_array = counting_sort(array)
    print(" ".join(map(str, sorted_array)))
    return

main()


Measured memory_bytes: 242196
//BUGSBUNNY
//IIT ROORKEE
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vl vector<long long>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vb vector<bool>
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (ll i = 0; i < n; i++)
#define repp(i,a,b) for(ll i = a ; i<b ; i++)
#define reppr(i,a,b) for(ll i = a-1 ; i>=b ; i--)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }


void solve();
signed main()
{
    //-------------------------------------------------------------------------------   
        ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        clock_t clk = clock();
    //-------------------------------------------------------------------------------   
        
    //-------------------------------------------------------------------------------
        int t = 1;
        // cin >> t;       
        rep(i,t)
        {
            // cout << "Case #" << i+1 << ": ";
            solve();
        }
    //-------------------------------------------------------------------------------
        clk = clock() - clk;
        cerr << fixed << setprecision(12) << "Time: " << ((double)clk)/CLOCKS_PER_SEC;
    //-------------------------------------------------------------------------------
}

void solve()
{
    int n , m ;
    cin >> n >> m ;
    int h[n];
    rep(i,n)
        cin >> h[i];
    int mx[n] = {};
    rep(i,m)
    {
        int u , v;
        cin >> u >> v;
        u-- , v--;
        mx[u] = max(mx[u],h[v]);
        mx[v] = max(mx[v],h[u]);
    }
    int ans = 0;
    rep(i,n)
        if(mx[i] < h[i])
            ans++;
    cout << ans << endl;
}   

Measured memory_bytes: 5392
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
A, B = MAP()
ind_A = X.index(A)
ind_B = X.index(B)
if ind_A > ind_B:
    print("Alice")
elif ind_A == ind_B:
    print("Draw")
else:
    print("Bob")


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	vector<int> health(n);
	for(int& x : health) cin >> x;
	sort(health.begin(), health.end());
	cout << accumulate(health.begin(), health.begin() + n - min(n, k), 0LL) << endl;
}


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

int main()
{
    int p[10]={},n,temp=-1,sel=-1;
    scanf("%d",&n);
    for (int i=0;i<n;i++) scanf("%d",&p[i]);
    for (int i=0;i<n;i++) if (p[i]>temp) {temp=p[i]; sel=i;}
    temp=p[sel]/2;
    for (int i=0;i<n;i++) if (i!=sel) temp+=p[i];
    printf("%d",temp);
    //system("PAUSE");
    return 0; 
}

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

int main(void) {
    string S = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    map<char, int> mp;
    for (int i = 0; i < S.size(); i++) mp[S[i]] = i;
    int N;
    cin>>N;
    string s;
    cin>>s;
    string result = "";
    for (int i = 0; i < s.size(); i++) {
        int index = (mp[s[i]] + N) % S.size();
        result += S[index];
    }
    cout << result << endl;
    return 0;
}

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

signed main(void) {
    int N, M;
    cin >> N >> M;
    int a[N], b[N], c[M], d[M];
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < M; i++) {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < N; i++) {
        int min_dist = 1000000000, check_point = 100;
        for (int j = 0; j < M; j++) {
            int dx = a[i] - c[j];
            int dy = b[i] - d[j];
            int tmp = abs(dx) + abs(dy);
            if (tmp < min_dist) {
                min_dist = tmp;
                check_point = j;
            } else if (tmp == min_dist) {
                if (j < check_point) {
                    check_point = j;
                }
            }
        }
        cout << check_point + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 100005
#define reg register
#define inl inline
using namespace std;
const int Mod=1e9+7;
int n,a[MAXN],deg[MAXN],cir[MAXN],len[MAXN],sum[MAXN],f[MAXN],ans=1,vis[MAXN];
inl int Add(reg int x,reg int y)
{
	return x+y>Mod?x+y-Mod:x+y;
}
inl int Mul(reg int x,reg int y)
{
	return 1ll*x*y-1ll*x*y/Mod*Mod;
}
inl void FindCir(reg int u)
{
	reg int num=0,st=0,pre=0,Len=0;
	while(cir[u])
	{
		num++;
		cir[u]=0;
		if(len[u])
		{
			if(!st)
			{
				st=num;
				pre=num;
				Len=len[u];
			}
			else
			{
				reg int val=0;
				if(len[u]<num-pre) val++;
				if(len[u]<=num-pre) val++;
				ans=Mul(ans,val);
				pre=num;
			}
		}
		u=a[u];
	}
	if(!st) sum[num]++;
	else
	{
		reg int val=0;
		if(Len<num-pre+st) val++;
		if(Len<=num-pre+st) val++;
		ans=Mul(ans,val);
	}
}
inl void Solve()
{
	for(reg int i=1;i<=n;i++)
	{
		if(deg[i]) continue;
		reg int u=i,Len=0;
		while(!cir[u])
		{
			u=a[u];
			Len++;
		}
		len[u]=Len;
	}
	for(reg int i=1;i<=n;i++) if(cir[i]) FindCir(i);
	for(reg int i=1;i<=n;i++)
	{
		if(!sum[i]) continue;
		f[0]=1;
		for(reg int j=1;j<=sum[i];j++)
		{
			if(i>1 && (i&1)) f[j]=Mul(f[j-1],2);
			else f[j]=f[j-1];
			if(j>1) f[j]=Add(f[j],Mul(f[j-2],Mul(j-1,i)));
		}
		ans=Mul(ans,f[sum[i]]);
	}
}
int main()
{
	scanf("%d",&n);
	for(reg int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		deg[a[i]]++;
	}
	for(reg int i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		reg int u=i;
		while(!vis[u])
		{
			vis[u]=i;
			u=a[u];
		}
		if(vis[u]!=i) continue;
		while(!cir[u])
		{
			cir[u]=1;
			u=a[u];
		}
	}
	for(reg int i=1;i<=n;i++) if((cir[i] && deg[i]>2) || (!cir[i] && deg[i]>1)) return puts("0"),0;
	Solve();
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  while (true) {
    int n, w, h, s, t, board[105][105] = {0};
    cin >> n;
    if (!n)
      break;
    cin >> w >> h;
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      board[y - 1][x - 1] = 1;
    }
    cin >> s >> t;

    /*REP(i, h) {
      REP(j, w) {
        cout << board[i][j] << " ";
      }
      cout << endl;
    }*/

    int maxret = -INF;
    REP(i, w - s + 1) REP(j, h - t + 1) {
      int ret = 0;
      REP(k, s) REP(l, t) {
        if (board[j+l][i+k] == 1) ret++;
        // cout << "(" << k << ", " << l << ") ";
      }
      // cout << endl;
      maxret = max(maxret, ret);
    }

    cout << maxret << endl;
  }
  return 0;
}

Measured memory_bytes: 3028
H, W = map(int, input().split())
MOD = 10 ** 9 + 7
A = ['#' * (W+1)]
for _ in range(H):
    A.append('#' + input())

dp = [[0 for _ in range(W+1)] for _ in range(H+1)]
dp[0][1] = 1

for y in range(1,H+1):
    for x in range(1,W+1):
        if A[y][x] == '#':
            dp[y][x] = 0
        else:
            dp[y][x] = dp[y-1][x] + dp[y][x-1]
            dp[y][x] %= MOD

print(dp[-1][-1])


Measured memory_bytes: 44640
#include <stdio.h>

int main()
{
	int i, N, D[51];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(D[i]));
	
	int count[13] = {}, flag[12] = {}, ex[25] = {}, ans = 0, min, tmp;
	for (i = 1; i <= N; i++) count[D[i]]++;
	if (count[0] == 0 && count[12] <= 1) {
		for (i = 1; i <= 11; i++) if (count[i] > 2) break;
		if (i == 12) {
			ex[0] = 1;
			ex[12] = count[12];
			ex[24] = 1;
			for (i = 1; i <= 11; i++) {
				if (count[i] == 2) {
					ex[i] = 1;
					ex[24-i] = 1;
				}
			}
			while (1) {
				for (i = 1; i <= 11; i++) {
					if (count[i] == 1) {
						ex[i] = (flag[i] == 0)? 1: 0;
						ex[24-i] = (flag[i] == 1)? 1: 0;
					}
				}
				for (i = 1, min = 12, tmp = 1; i < 25; i++) {
					if (ex[i] == 1) {
						if (tmp < min) min = tmp;
						tmp = 1;
					} else tmp++;
				}
				if (min > ans) ans = min;
			
				for (i = 11; flag[i] == 1; i--);
				for (flag[i++] = 1; i <= 11; flag[i++] = 0);
				if (flag[0] == 1) break;
			}
		}
	}
	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	string s;
	cin >> s;
	int f0=0,f1=0;
	int len = s.length();
	REP(i,len){
		int buf = s[i]-'0';
		if(i%2==0){ //偶数番目... f0 should be 0, f1 should be 1
			if(buf==0){
				f1++;
			}else{
				f0++;
			}
		}else{
			if(buf==0){
				f0++;
			}else{
				f1++;
			}
		}
	}
	println(min(f0,f1));

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int arr[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(long long int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";

}

Measured memory_bytes: 1792
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        String s=sc.next();
        int b=sc.nextInt();

        if (s.equals("+"))
        {
            System.out.println(a+b);
        }else
        {
            System.out.println(a-b);
        }
    }
}

Measured memory_bytes: 22740
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	ll n,k;
	cin>>n>>k;
	ll s=1;
	while(n--){
		s = min(2*s,s+k);
		}
	cout<<s<<nw;
	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    ll sum = 0;
    rep(i, N) {
        for (int j = i; j < N; j++) {
            if (i == j) continue;
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {
        n:usize,
        k:i64,
        ab:[(Usize1,Usize1);n-1],
    }
    let mut g = vec![Vec::new(); 101010];
    for (a, b) in ab {
        g[a].push(b);
        g[b].push(a);
    }
    // 頂点Ktoori
    let mut st = VecDeque::new();
    let mut ans = 1;
    let mut md = ModComb::new(MX, MOD);
    st.push_back((0usize, 0usize, 1));
    while let Some(s) = st.pop_front() {
        let (now, prev, cnt) = (s.0, s.1, s.2);
        if cnt == 1 {
            ans *= k;
            ans *= md.perm(k - 1, g[now].len() as i64);
        } else if cnt == 2 {
            ans *= md.perm(k - 2, g[now].len() as i64 - 1);
        } else {
            ans *= md.perm(k - 2, g[now].len() as i64 - 1);
        }
        for &nxt in g[now].iter() {
            if nxt == prev {
                continue;
            }
            st.push_back((nxt, now, cnt + 1));
        }
        ans %= MOD;
    }
    println!("{}", ans);
}
const MOD: i64 = 1000000007;
const MX: usize = 1010101;
/// x ^ n % m
pub fn mod_pow(x: i64, n: i64, m: i64) -> i64 {
    let mut res = 1;
    let mut x = x % m;
    let mut n = n;
    while n > 0 {
        if n & 1 == 1 {
            res = (res * x) % m;
        }
        x = (x * x) % m;
        n >>= 1;
    }
    res
}
struct ModComb {
    fact: Vec<i64>,
    fact_inv: Vec<i64>,
    n: usize,
    p: i64,
}
impl ModComb {
    fn initialize(&mut self) {
        let n = self.n;
        self.fact[0] = 1;
        for i in 1..n {
            self.fact[i] = (self.fact[i - 1] * i as i64) % self.p;
        }
        self.fact_inv[n - 1] = mod_pow(self.fact[n - 1], self.p - 2, self.p);
        for i in (0..n - 1).rev() {
            self.fact_inv[i] = (self.fact_inv[i + 1] * (i + 1) as i64) % self.p;
        }
    }
    fn new(max_n: usize, p: i64) -> ModComb {
        let mut ft = ModComb {
            fact: vec![0; max_n + 1],
            fact_inv: vec![0; max_n + 1],
            n: max_n + 1,
            p: p,
        };
        ModComb::initialize(&mut ft);
        ft
    }
    fn fact(&self, n: usize) -> i64 {
        self.fact[n]
    }
    fn comb(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        (self.perm(n, k) * self.fact_inv[k as usize]) % self.p
    }
    fn perm(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        self.fact[n as usize] * self.fact_inv[(n - k) as usize] % self.p
    }
    fn nsk(&self, n: i64, k: i64) -> i64 {
        if n < k {
            return 0;
        }
        let mut res = 0;
        for i in 0..k + 1 {
            let v = self.comb(k, i) * mod_pow(i, n, self.p) % self.p;
            if (k - i) % 2 == 1 {
                res = (res + self.p - v) % self.p;
            } else {
                res = (res + v) % self.p;
            }
        }
        return res * self.fact_inv[k as usize] % self.p;
    }
}


Measured memory_bytes: 29168