akhauriyash/Code-Regression huggingface dataset:
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define ll                          long long
 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define fastio                      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   endl                      "\n"

int main()
{
	ll n;
	cin >> n;
	vector<ll> v;
	vector<ll> vv;
	forn(i,n){
		ll x,y;
		cin >> x >> y;
		v.pb(x + y);
		vv.pb(x - y);
	}
	sort(all(v));
	sort(all(vv));
	ll ans = v.back() - v[0];
	ll ans2 = vv.back() - vv[0];
	cout << max(ans,ans2) << endl;
}

Measured memory_bytes: 6624
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = n; i >= 0; --i) {
		if (s.substr(n - i) == t.substr(0, i)) {
			cout << 2 * n - i << endl;
			return 0;
		}
	}
	return 0;
}


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

int main(void) {
	int a = 0;
	char A[26];
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		A[i] = S[i];
	}
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < S.size(); j++) {
			if (i != j && A[i] == S[j]) a = 1;
		}
	}
	if (a == 0) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<int> idxs(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        idxs[i] = i;
    }
    sort(idxs.begin(), idxs.end(), [&](const int i1, const int i2){return a[i1] + b[i1] > a[i2] + b[i2];});

    ll ans = 0;
    for (int i = 0; i < n; i += 2) {
        ans += a[idxs[i]];
        int j = i + 1;
        if (j >= n) break;
        ans -= b[idxs[j]];
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

int levels[501][501];

void solve(int from, int to, int level) {
  if (from == to) return;
  int mid = (from+to)/2;
  for (int i = from; i <= mid; ++i) {
    for (int j = mid+1; j <= to; ++j) {
      levels[i][j] = level;
    }
  }
  if (to-from == 1) return;
  solve(from, mid, level+1);
  solve(mid+1, to, level+1);
}

int main() {
  int n;
  cin >> n;
  solve(0, n-1, 1);
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      cout << levels[i][j] << " ";
    }
    cout << endl;
  }
}



Measured memory_bytes: 1408
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	string s, x, y;
	bool xx[26], yy[26];
	cin >> s;
	REP1(i, n - 1){
		x = s.substr(0, i);
		y = s.substr(i, n - i);
		REP(i, 26){
			xx[i] = false;
			yy[i] = false;
		}
		REP(i, x.size()){
			xx[x[i] - 'a'] = true;
		}
		REP(i, y.size()){
			yy[y[i] - 'a'] = true;
		}
		tmp = 0;
		REP(i, 26){
			if(xx[i] && yy[i]) tmp++;
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
function Main(input) {
    nums = input.split("");
    var count = 0
    for (var i = 0; i < nums.length; i++) {
        if (nums[i] === "1") {
            count++
        }
    }
    console.log(count)
  
    }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k; cin >> n >> k;
    vec<ll> a(n); rep(i,n)cin >> a[i];
    rep(i,n-k)cout << (a[i] < a[i+k] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 4760
from collections import Counter
n,m,targets = map(int,input().split())
r,c = {},{}
rcnt,ccnt = Counter(),Counter()
done = set()
for _ in range(targets):
    i,j = map(int,input().split())
    done.add((i,j))
    rcnt[i] += 1
    ccnt[j] += 1
    if i in r:
        r[i].append(j)
    else:
        r[i] = [j]
    if j in c:c[j]+=1
    else:c[j]=1
#print(r,c)
rs,cs = [],[]
mx1 = max([len(r[k]) for k in r.keys()])
mx2 = max(c.values())
ans = mx1 + mx2 - 1
for k in r.keys():
    if len(r[k])==mx1:
        rs.append(k)
for k in c.keys():
    if c[k] == mx2:
        cs.append(k)
#print(mx1,mx2)
#print(rs,cs)
flag = False
for row in rs:
    for col in cs:
        if (row,col) not in done:
            flag = True
            ans += 1
            break
    if flag:
        break
print(ans)


# for key in r.keys():
#     arr = r[key]
#     l = len(arr)
#     for v in arr:
#         cand = l + c[v] - 1
#         mx = max(cand,mx)
# rcnt = [(k,v) for (k,v) in rcnt.items()]
# ccnt = [(k,v) for (k,v) in ccnt.items()]

# rcnt.sort(key = lambda x:x[1],reverse = True)
# ccnt.sort(key = lambda x:x[1],reverse = True)
# rcnt = rcnt[:500]
# ccnt = ccnt[:500]
# #print(rcnt,ccnt)
# #print(done)
# for row in rcnt:
#     for col in ccnt:
#         rowk,colk = row[0],col[0]
#         if rowk in r and colk in c and (rowk,colk) not in done:
#             cand = len(r[rowk]) + c[colk]
#         

Measured memory_bytes: 124868
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_B
 */
#include <iostream>
#include <vector>
#include <map>

using namespace std;

class Die
{
    enum fname {
        top, front, right, left, back, bottom,
    };

    vector<int> faces;
    map<fname, int> f2i;

    void
    turn_e() {
        int tmp = f2i[top];
        f2i[top] = f2i[left];
        f2i[left] = f2i[bottom];
        f2i[bottom] = f2i[right];
        f2i[right] = tmp;
    }

    void
    turn_n() {
        int tmp = f2i[top];
        f2i[top] = f2i[front];
        f2i[front] = f2i[bottom];
        f2i[bottom] = f2i[back];
        f2i[back] = tmp;
    }

    void
    turn_s() {
        int tmp = f2i[top];
        f2i[top] = f2i[back];
        f2i[back] = f2i[bottom];
        f2i[bottom] = f2i[front];
        f2i[front] = tmp;
    }

    void
    turn_w() {
        int tmp = f2i[top];
        f2i[top] = f2i[right];
        f2i[right] = f2i[bottom];
        f2i[bottom] = f2i[left];
        f2i[left] = tmp;
    }

public:
    Die()
    {
        faces.reserve(6);

        f2i.emplace(top, 0);
        f2i.emplace(front, 1);
        f2i.emplace(right, 2);
        f2i.emplace(left, 3);
        f2i.emplace(back, 4);
        f2i.emplace(bottom, 5);
    }

    ~Die()
    {
        faces.clear();
        f2i.clear();
    }

    void
    read_faces(istream &is) {
        for (int i = 0; i < 6; i++) {
            is >> faces[i]; is.ignore();
        }
    }

    void
    top_front(const int t, const int f) {
        const string aface = "NENEN";
        for (auto it = aface.cbegin(); it != aface.cend() && faces[f2i[top]] != f; it++) {
            turn(*it);
        }
        turn_s();
        const string roll = "EEE";
        for (auto it = roll.cbegin(); it != roll.cend() && faces[f2i[top]] != t; it++) {
            turn(*it);
        }
    }

    void
    turn(const char c) {
        switch (c) {
          case 'N':
            turn_n();
            break;
          case 'E':
            turn_e();
            break;
          case 'S':
            turn_s();
            break;
          case 'W':
            turn_w();
            break;
        }
    }

    int Top()    { return faces[f2i[top]   ]; }
    int Front()  { return faces[f2i[front] ]; }
    int Right()  { return faces[f2i[right] ]; }
    int Left()   { return faces[f2i[left]  ]; }
    int Back()   { return faces[f2i[back]  ]; }
    int Bottom() { return faces[f2i[bottom]]; }
};

int
main()
{
    ios::sync_with_stdio(false);

    Die d;
    d.read_faces(cin);

    int n;
    cin >> n; cin.ignore();

    for (int i = 0; i < n; i++) {
        int t, f;
        cin >> t >> f; cin.ignore();
        d.top_front(t, f);
        cout << d.Right() << endl;
    }

    return 0;
}

Measured memory_bytes: 3096
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(n,m,queries):
  redInBox   = [False] * (n+1)
  amountOfBalls = [1] * (n+1)
  redInBox[1] = True
  
  for query in queries:
    x,y = query
    if redInBox[x]:
      redInBox[y] = True
      amountOfBalls[x] -= 1
      amountOfBalls[y] += 1
      if amountOfBalls[x] == 0:
        redInBox[x] = False
    else:
      amountOfBalls[x] -= 1
      amountOfBalls[y] += 1
 
  return sum(redInBox)



def main():
  N,M = map(int,input().split())
  queries = [list(map(int,input().split())) for _ in range(M)]
  print(solve(N,M,queries))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 28464
//POJ 1979 穷竭搜索
#include<stdio.h>
#include<stack>
#include<string.h>
using namespace std;
const int maxn = 105;
char g[maxn][maxn];
bool flag = true;
int n,m;
int ans;
struct Node{
	int x;
	int y;
	Node(int xx,int yy):x(xx),y(yy){
	}
	Node(){
	}
	void set(int xx,int yy){
		x = xx;y=yy;
	}
};
stack<Node> s;
Node begin;
void init(){
	char tmp;
	memset(g,'a',sizeof(g));
	scanf("%d%d",&n,&m);
	if(n==0&&m==0){
		flag = false;
		return;
	}
			scanf("%c",&tmp);
	for(int i = 1;i<=n;++i){
		for(int j = 1;j<=m;++j){
			scanf("%c",&g[i][j]);
		}
			scanf("%c",&tmp);
	}
//	printf("init finished\n");
}
inline void push(Node w,char x){
	g[w.x][w.y] = 'a';
	if(g[w.x][w.y+1]==x){
		g[w.x][w.y+1] = 'a';
		s.push(Node(w.x,w.y+1));
	}
	if(g[w.x][w.y-1]==x){
		g[w.x][w.y-1] = 'a';
		s.push(Node(w.x,w.y-1));
	}
	if(g[w.x+1][w.y]==x){
		g[w.x+1][w.y] = 'a';
		s.push(Node(w.x+1,w.y));
	}
	if(g[w.x-1][w.y]==x){
		g[w.x-1][w.y] = 'a';
		s.push(Node(w.x-1,w.y));
	}
}
int solve(){
	ans = 0;
	s = stack<Node>();
	for(int i = 1;i<=n;++i){
		for(int j = 1;j<=m;++j){
		if(g[i][j]=='a')continue;
		begin.set(i,j);
		s.push(begin);
		char lp = g[i][j];
		while(!s.empty()){
			Node work = s.top();
			//printf("%d,%d:%c\n",work.x,work.y,g[work.x][work.y]);
	//	printf("now: %d , %d\n",work.x,work.y);
			s.pop();
			push(work,lp);		
	}
	++ans;
	}
	}
}
int main(){
	while(true){
	init();
	if(!flag)break;
	solve();
	printf("%d\n",ans);
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  cout << setprecision(10) << double(ceil(double(N)/2)) / N << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


/*
* Problem : abc 160 - B
* Acknowledgement : None
* Author : deathnaught_
* GitHub : www.github.com/DeathNaughT-GitHub
* Complexity : O()
*/

public class Main
{

    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();
        int N = sc.nextInt();
        int sum = (N / 500 * 1000);
        N = N % 500;
        sum += 5 * (N / 5);
        System.out.println(sum);
    }

    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

		boolean hasNext()
		{
		    return st == null ? false : true;
		}

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }
    } 

}

Measured memory_bytes: 22484
#include <stdio.h>
#define N 200
#define WHITE 0
#define BLACK 1
#define GRAY 2
void dfs(void);
void visit(int);
int time=0;
int d[N];
int f[N];
int color[N];
int n;
int array[N][N];
int main(){
  int i,j,u,k,vk;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      array[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
       scanf("%d",&vk);
       array[i][vk]=BLACK;
    }
  }
  dfs();
  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
    }
void dfs(void){
  int u;
  for(u=1;u<=n;u++){
    color[u]=WHITE;
  }
    time=0;
   for(u=1;u<=n;u++){
    if(color[u]==WHITE){
      visit(u);
    }
  }
}
void visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++time;
  for(v=1;v<=n;v++){
    if(color[v]==WHITE && array[u][v]==BLACK){
      visit(v);
    }
  }
    color[u]=BLACK;
    f[u]=++time;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    long long int a[n], b[n], c[m], d[m], ans[n];
    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) {
        long long int dist_min = 100000000000;
        for(int j = 0; j < m; ++j) {
            long long int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(dist < dist_min) {
                dist_min = dist;
                ans[i] = j+1;
            }
        }
    }
    for(int i = 0; i < n; ++i) cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string  dog;
	string pig;
	getline(cin, dog);
	getline(cin, pig);
	string cat = pig.substr(0, pig.size() - 1);
	//cout << cat;
	if (dog == cat)
		cout << "Yes";
	else
		cout << "No";

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>

using namespace std;

#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, s, n) for(int i = s; i < (int)(n); ++i)

int main() {
  int N;
  cin >> N;

  vector<int> A(N);
  Rep(n, N) cin >> A[n];

  vector<int> answers(N);
  Rep(i, 32) {
    int bit = 1 << i;

    int count = 0;
    for (auto a : A) {
      if (a & bit) {
        count++;
      }
    }

    if (count % 2 == 0) {
      Rep(n, N) {
        answers[n] |= A[n] & bit;
      }
    } else {
      Rep(n, N) {
        if (!(A[n] & bit)) {
          answers[n] |= bit;
        }
      }
    }
  }

  Rep(n, N) {
    cout << answers[n];
    if (n != N - 1) {
      cout << ' ';
    } else {
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4828
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)
#define int long long

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 1000003, M = N << 1;

int n, m;
int a[N];

signed main()
{
    //File("");
    n = gi();
    int sum = 0;
    for (int i = 1; i <= n; i+=1) a[i] = gi(), sum ^= a[i];
    for (int i = 1; i <= n; i+=1) cout << (sum ^ a[i]) << ' ';
    return 0;
}

Measured memory_bytes: 5124
#include<iostream>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<double> vd ;
  double num;
  while(cin >> num){
    vd.pb(num) ;
  }
  cout << vmax(vd) - vmin(vd) << endl;
  return 0;
}

Measured memory_bytes: 1304
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main()
{
	string str;
	int area = 0;
	char c;
	getline(cin, str);
	stack <int> stk;
	stack <pair<int, int>> stk2;
	stack <int> stk3;
	for (int i = 0; i < str.length(); i++)
	{
		if (str[i] == '\\')
		{
			stk.push(i);

		}
		else if (str[i] == '/')
		{
			if (stk.empty())continue;

			int temp = i - stk.top();
			area += temp;
			pair<int, int> p = make_pair(stk.top(), temp);
			if (stk2.empty())
			{
				stk2.push(p);
			}
			else
			{
				for (int l = i; l > p.first; l--)
				{
					if (stk2.empty())break;
					if (stk2.top().first == l)
					{
						p.second += stk2.top().second;
						stk2.pop();
					}
				}
				stk2.push(p);
			}
			stk.pop();
		}
	}

	cout << area << endl;
	int num = stk2.size();
	if (num != 0)
	{
		cout << num <<" ";
		for (int i = 0; i < num; i++)
		{
			pair <int, int> P = stk2.top();
			stk3.push(P.second);
			stk2.pop();
		}
		for (int i = 0; i < num; i++)
		{

			cout << stk3.top();
			if (i != num - 1)
			{
				cout << " ";
			}
			stk3.pop();
		}
	}
	else
	{
		cout << num;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 3276
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    s = ins()
    t = ins()
    ans = len(s)
    for i in range(len(s)):
        if i + len(t) > len(s):
            break
        count = 0
        for j in range(len(t)):
            if t[j] != s[i + j]:
                count += 1
        ans = min(ans, count)

    return ans


print(solve())


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define random_shuffle(...) shuffle(__VA_ARGS__, rng)
#define rand() rng()

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 111;
int a[N][N];

int main() {
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n = nxt();
	for (itn i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			a[i][j] = 1;
		}
	}

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

	int m = n - n % 2;
	for (int i = 0; i < m; ++i) {
		a[i][m - 1 - i] = 0;
	}

	vector<pair<int, int>> ans;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			if (a[j][i]) {
				ans.push_back({j, i});
			}
		}
	}

	cout << ans.size() << "\n";
	for (auto p : ans) {
		cout << p.first + 1 << " " << p.second + 1 << "\n";
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
const ll N = 1234567;

int n;
ll a[N];

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

    cin >> n;

    rep(i , 1 , n) cin >> a[i];

    rep(i , 1 , n) a[i] += a[i - 1];

    ll maxi = LLONG_MAX;
    rep(i , 1 , n - 1) {
        maxi = min(maxi , abs(a[i] - a[n] + a[i]));
    }
    cout << maxi << endl;
    return 0;
}


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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, k, n) for (int i = k; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

    int N, K;
    cin >> N >> K;
    vector<llong> X(N), Y(N);
    rep(i, N) {
        cin >> X[i] >> Y[i];
    }

    llong ans = INF;
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                rep(l, N) {
                    if (i == j || k == l) continue;

                    int cnt = 0;
                    llong left = X[i], right = X[j];
                    llong up = Y[k], down = Y[l];
                    if (right < left) swap(right, left);
                    if (up < down) swap(down, up);
                    rep(m, N) {
                        if ((left <= X[m] && X[m] <= right) && (down <= Y[m] && Y[m] <= up)) ++cnt;
                    }

                    llong s = (right - left) * (up - down);
                    if (cnt >= K) ans = min(ans, s);
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


int main(void){
    int X, A, B;
    cin >> X >> A >> B;
    cout << (X - A) % B << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <iterator>

int main()
{
    int N,M;
    std::cin >> N >> M;

    std::set<int> result;
    for (int i = 0; i < N; i++)
    {
        std::set<int> temp1, temp2;
        temp1 = result;
        result = std::set<int>();
        int k;
        std::cin >> k;
        for (int j = 0; j < k; j++)
        {
            int a_temp;
            std::cin >> a_temp;
            temp2.insert(a_temp);
        }
        if (i == 0) result = temp2;
        else
        {
            std::set_intersection(temp1.begin(),temp1.end(),
                    temp2.begin(),temp2.end(),std::inserter(result,result.end()));
        }
    }

    std::cout << result.size() << std::endl;
    return 0;
}




Measured memory_bytes: 256
w,a,b = map(int,input().split())

a1 = a
a2 = a+w
b1 = b
b2 = b+w

if a1==b1 and a2==b2 :
	print(0)
elif a1<=b2<=a2 :
	print(0)
elif a1<=b1<=a2 :
	print(0)
elif a2 < b1 :
	print(abs(b1 - a2))
elif a1 > b2 :
	print(abs(b2 - a1))
	



Measured memory_bytes: 3060
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        var t1 = check(a, n);
        Array.Reverse(a);
        var t2 = check(a, n);
        Console.WriteLine(t1 && t2 ? "yes":"no");
    }
    public static bool check (int [] a, int n)
    {
        var dmax = 0;
        for (int i = 0; i < n; i++)
        {
            if (i * 10 + a[i] > dmax) dmax = i * 10 + a[i];
            if (dmax >= (n - 1) * 10) return true;
            if (dmax < (i + 1) * 10) return false;
        }
        return false;
    }
}


Measured memory_bytes: 11512
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define int long long
#define MAX 1000000000000000000LL
int inf=100000000000007;
using namespace std;
typedef pair<int,int> P;
string alph="abcdefghijklmnopqrstuvwxyz";
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

signed main(){
    int q,h,s,d;
    cin>>q>>h>>s>>d;
    h=min(h,q*2);
    s=min(s,h*2);
    d=min(d,s*2);
    int n;cin>>n;
    int ma=n/2;
    int me=n%2;
    cout<<ma*d+me*s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	string S;
  	cin >> S;
  	int ans = 0;
  	rep(i, S.size()-1){
    	if(S[i] != S[i+1]){ans++;}
    }
  	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
  int  A[200003]={};
//  long long  A[100003]={};
//  long long  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d%", &a);

  printf("%d\n", 3*a*a);

  

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   

return 0;
}


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

namespace abc057_d
{
	class Program
	{
		static long[,] dp = new long[51, 51];
		static long comb(long n, long r)
		{
			if (r == 0) return 1;
			if (n < r) return 0;
			if (dp[n, r] == 0)
			{
				return dp[n, r] = comb(n - 1, r) + comb(n - 1, r - 1);
			}
			return dp[n, r];
		}
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			Array.Sort(a); Array.Reverse(a);
			long[] front = new long[x[1]];
			Array.Copy(a, front, x[1]);
			Console.WriteLine((double)front.Sum() / x[1]);

			if (front.Min() == front.Max())
			{
				int n = 0;
				foreach (var item in a) if (item == front[x[1] - 1]) n++;
				long ret = 0;
				for (int i = x[1]; i <= x[2]; i++)
				{
					ret += comb(n, i);
				}
				Console.WriteLine(ret);
			}
			else
			{
				int n = 0;
				foreach (var item in a) if (item == front[x[1] - 1]) n++;
				int r = 0;
				foreach (var item in front) if (item == front[x[1] - 1]) r++;
				Console.WriteLine(comb(n, r));
			}
		}
	}
}

Measured memory_bytes: 13652
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <numeric> 
#include <bits/stdc++.h>
typedef long long ll;
typedef std::pair<std::pair<int,int>,int>pi;
using namespace std;

int main() {
    int x,y,z; cin >> x  >> y >> z;
    
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z;
    
    return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int turn = 1;
    while(true) {
        if (turn == 1) {
            C -= B;
            if (C <= 0) {
                cout << "Yes" << endl;
                break;
            };
        }
        else {
            A -= D;
            if (A <= 0) {
                cout << "No" << endl;
                break;
            };
        }
        turn *= -1;
    }
}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;
//tokiomarine
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3652
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]

ans = []

i = 0
while i < n:
    j = k = n - i
    add = j
    times = n - i
    cnt = 0

    if j == 1:
        cnt = sum(b)
    else:
        while j <= n:
            cnt += b[j-1]
            j += add

    #print(k, a, cnt, b)
    if cnt % 2 != a[k-1]:
        b[k-1] = 1
        ans.append(k)
    else:
        b[k-1] = 0

    i += 1

print(len(ans))
if len(ans) > 0: print(*ans[::-1])


Measured memory_bytes: 14792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<12;
const ll INF=1LL<<50;

int bit[MAX+1][2005],N;
//1-indexed

int sum(int i,int j){
    int s=0;
    while(i>0){
        s+=bit[i][j];
        i-=i&-i;
    }
    return s;
}

//sからtの和=sum(t)-sum(s-1)

void add(int i,int j,int x){
    while(i<=N){
        bit[i][j]+=x;
        i+=i&-i;
    }
}

int main(){
  
    cin>>N;
    N*=2;
    vector<char> C(N);
    vector<int> A(N),wdoko(N/2),bdoko(N/2);
    for(int i=0;i<N;i++){
        cin>>C[i]>>A[i];
        if(C[i]=='W') wdoko[A[i]-1]=i;
        else bdoko[A[i]-1]=i;
    }
    
    vector<vector<ll>> dp(N/2+1,vector<ll>(N/2+1,INF));
    dp[0][0]=0;
    
    for(int i=0;i<N;i++){
        if(C[i]=='B'){
            for(int j=0;j<A[i];j++){
                add(i+1,j,1);
            }
        }else{
            for(int j=0;j<2005;j++){
                add(i+1,j,1);
            }
        }
    }
    
    for(int k=0;k<N;k++){
        for(int i=0;i<=k;i++){
            int j=k-i;
            
            if(i<N/2&&j<=N/2) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+sum(wdoko[i],j));
            
            if(i<=N/2&&j<N/2) dp[i][j+1]=min(dp[i][j+1],dp[i][j]+sum(bdoko[j],j));
            
            if(i<N/2&&j<=N/2) add(wdoko[i]+1,j,-1);
        }
    }
    
    /*for(int i=0;i<=N/2;i++){
        for(int j=0;j<=N/2;j++){
            cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
        //cout<<endl;
    }*/
    
    cout<<dp[N/2][N/2]<<endl;
}



Measured memory_bytes: 62976
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int k, n;
	int *a;
	int max_length = 0;
	scanf("%d", &k);
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	if(a[n-1] - a[0] <= k/2){
		printf("%d\n", a[n-1] - a[0]);
	}
	else{
		max_length = k - (a[n-1] - a[0]);
		for(int i=0; i<n-1; i++){
			if(a[i+1]-a[i] > max_length){
				max_length = a[i+1]-a[i];
			}
		}
		printf("%d\n", k - max_length);
	}
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S,T;
    cin >> S >> T;
    int ans = S.size();
    for(int i=0;i+T.size() - 1<S.size();i++){
        int count = 0;
        for(int j=0;j<T.size();j++){
            if(S[i+j] != T[j]){
                count++;
            }
        }
        ans = min(ans,count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3172
s=list(input())
count=0
count1=0
for i in range(len(s)-2):
    if s[i:i+3]==['A','B','C']:
        count+=1
        s[i]='B'
        s[i+1]='C'
        s[i+2]='A'

            
        for j in range(1,len(s)):
            if i-j<0:
                count+=count1
                break
            if s[i-j]=='A':
                count1+=1
            else:
                count+=count1
                break
            
    if s[i:i+3]==['A','A','A'] or s[i:i+3]==['A','A','B'] or s[i:i+3]==['C','A','A'] or s[i:i+3]==['C','A','B'] or s[i:i+3]==['B','C','A']:
        continue
    else:
        count1=0


print(count)


        
    
        

        
    


Measured memory_bytes: 63944
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;

int mark[MAX];

vector<int>prm ;

void seive() {
    for(ll i = 2 ; i*i < MAX ; i++) {
        if(mark[i]) continue;
        for(ll j = i*i ; j < MAX ; j += i) {
            mark[j] = 1;
        }
    }    
    for(int i = 2 ; i < MAX ; i++ ) {
        if(mark[i]) continue;
        prm.push_back(i);
    }
}


int main()
{
    fastRead;
    seive();
    ll n;
    cin>>n;
    vector<ll>vec;
    
    for(auto x : prm) {
        if(n%x) continue;
        
        int cnt = 0;
        while(n%x ==0) {
            n/=x;
            cnt++;
        }
        vec.push_back(cnt);
    }
    
    if(n != 1) vec.push_back(1);
    
    vector<ll>rec;
    for(ll i = 0 ; i < MAX ; i++ ) {
        rec.push_back(i*(i+1)/2);
    }
    
    ll ans = 0;
    for(auto x : vec) {
        
        int id = upper_bound(rec.begin() , rec.end() , x) - rec.begin() - 1;
        ans += id;

//        cout<<x<<'\n';
    }
    
    cout<<ans<<'\n';
    return 0;
    
}

Measured memory_bytes: 15824
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    int N, K;
    while (cin >> N) {
        cin >> K;
        vector<int> a(N + 1, 0);
        for (int i = 0; i < N; ++i) {
            int p;
            cin >> p;
            ++a[p];
        }
        vector<pair<int, int>> b;
        for (int i = 1; i <= N; ++i) {
            if (a[i])
                b.emplace_back(a[i], i);
        }
        sort(b.begin(), b.end());
        reverse(b.begin(), b.end());
        int ct = 0;
        while ((int)b.size() > K) {
            ct += b.back().first;
            b.pop_back();
        }
        cout << ct << endl;
    }
    return 0;
}


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

int main(){
  int i,j,cnt=0;
  int n,a,b;
  cin>>n;
  cin>>a>>b;
  int p[n];
  for(i=0;i<n;i++)cin>>p[i];
  int p1=0,p2=0,p3=0;
  for(i=0;i<n;i++){
    if(p[i]<=a)p1++;
    else if(a<p[i] && p[i]<=b)p2++;
    else p3++;
  }
  cout<<min(p1,min(p2,p3));
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
struct edge{int to;ll cap;int rev;};
typedef pair<ll, ll> P;
int main(){
    int n;
    cin>>n;
    vector< vector<int> > a(n, vector<int>(n-1));
    rep(i,n){
        rep(j,n-1){
        cin>>a[i][j];
        a[i][j]--;
        }
        reverse(a[i].begin(), a[i].end());
    }
    vector<P> q;
    auto check = [&](int i){
        if(a[i].size() == 0) return;
        int j = a[i].back();
        if(a[j].size() == 0) return;
        if(a[j].back() == i) {
            P p(i,j);
            if(p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };
    rep(i,n) check(i);
    int day = 0;
    while(q.size() > 0){
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()) ,q.end());
        vector<P> prevQ;
        swap(prevQ,q);
        // rep(i,prevQ.size()) cout<<prevQ[i].first<<" "<<prevQ[i].second<<endl;
        for(P p : prevQ){
            int i = p.first, j = p.second;
            a[i].pop_back();
            a[j].pop_back();
        }
        for(P p : prevQ){
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i,n){
        if(a[i].size() != 0){
            puts("-1");
            return 0;
        }
    }
    cout<<day<<endl;
    
    return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(){
    int n, x, i, j, k, c;
    
    while (1) {
        scanf("%d %d", &n, &x);
        if (n == 0 && x == 0) break;
        c = 0;
        for (i = 1; i < n ; i++) {
            for (j = i + 1; j < n; j++) {
                for (k = j + 1; k <= n; k++) {
                    if ((i + j + k) == x )
                        c++;
                }
            }
        }
        printf("%d\n", c);
    }
    return 0;
}

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

int main()
{
    ll X, Y;
    cin >> X >> Y;
    ll A = (Y - X * 2), B = (4 * X - Y);
    ll a = (Y - X * 2) / 2, b = (4 * X - Y) / 2;
    if ((A == a * 2) && (B == b * 2) && A >= 0 && B >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(n-1):
  if a[i]+1 == a[i+1]:
    ans += c[a[i]-1]
    
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
#define lli long long int
#include <limits.h>
#include <fstream>

using namespace std;

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i,j,tt=1;
    //cin>>tt;
    while(tt--)
    {
        lli n,ans=0,temp;
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>temp;
            if(i%2==0 && temp%2)
                ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3632
s = input()
l = []
for i in range(len(s)):
	if s[i] == 'A':
		l.append(i)
		break
for i in range(len(s)-1, 0, -1):
	if s[i] == 'Z':
		l.append(i)
		break
print(l[1]-l[0]+1)

Measured memory_bytes: 3512
import itertools
n, k = map(int,input().split())
d = []
a = []


for i in range(k):
    tmpd = int(input())
    d.append(tmpd)
    a.append(list(map(int,input().split())))

a = list(itertools.chain.from_iterable(a))
a = list(set(a))

print(n - len(a))

Measured memory_bytes: 9360
#include "bits/stdc++.h"

using namespace std;

int n;
int ans[512][512];

void f(int l = 0, int r = n, int dep = 1)
{
    if (l + 1 == r)
        return;
    int m = (l + r) / 2;
    for (int i = l; i < m; i++)
    {
        for (int j = m; j < r; j++)
        {
            ans[i][j] = dep;
        }
    }
    f(l, m, dep + 1);
    f(m, r, dep + 1);
}

void solve()
{
    cin >> n;
    f();
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            cout << ans[i][j] << ' ';
        }
        cout << "\n";
    }
}

int main()
{
    solve();
    cerr << "\"努力不足ですね！\"" << endl;
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    int h;
    int w;
    int k;
    String[][] grid;

    private void run() {
        h = sc.nextInt();
        w = sc.nextInt();
        k = sc.nextInt();
        grid = new String[h][w];

        for (int i = 0; i < h; i++) {
            grid[i] = sc.next().split("");
        }

        // 全探索
        int ans = 0;
        for (int rows = 0; rows < 1 << h; rows++) {
            for (int cols = 0; cols < 1 << w; cols++) {
                int black = 0;
                for (int i = 0; i < h; i++) {
                    if ((1 & rows >> i) == 1) continue;
                    for (int j = 0; j < w; j++) {
                        if ((1 & cols >> j) == 1) continue;
                        if (grid[i][j].equals("#")) black++;
                    }
                }
                if (black == k) ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 36376
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] v = new int[N];
		for(int i = 0; i < N; i++) {
			v[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(v);
		double p = v[0];
		for(int i = 0; i < N; i++) {
			p = (p + v[i]) / 2;
		}
		System.out.println(p);
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <array>
#include <cmath>
using namespace std;
using ll = long long;

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

	if (a >= b * 2)
		cout << a - b - b << endl;
	else
		cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(string &a){reverse(a.begin(),a.end()) ;}



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

	ll n,m ;
	cin >> n >> m ;
	vector<pll> a(n) ;
	for(int i=0;i<n;i++) cin >> a.at(i).first >> a.at(i).second ;
	sort(a.begin(),a.end()) ;
	priority_queue<ll> pq ;
	ll ans = 0 ;
	ll pos = 0 ;
	for(int i=1;i<=m;i++){
		while(pos!=n&&a.at(pos).first<=i){
			pq.push(a.at(pos).second) ;
			pos++ ;
		}
		if(pq.empty()) continue ;
		ans += pq.top() ;
		pq.pop() ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;

int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        int n; cin >> n;
        if(n <= 1000) cout << 1000 - n << endl;
        else{
                while(1){
                        n-=1000;
                        if(n <= 1000) break;
                } 
                cout << 1000 - n << endl;
        } 

        return 0;
}


Measured memory_bytes: 3664