akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

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

Node * find(Node *u, int k) {
  while( u != NIL && k != u->key) {
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x){
  if ( x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *y;
  Node *x;

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

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

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

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

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

  free(y);
}

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

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = NIL;

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

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

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

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

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

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

  return 0;
}


Measured memory_bytes: 22024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();	
		int[][] image = new int[N][N];
		int[][] template = new int[M][M];
		
		for(int y=0; y<N; y++){
			String line = sc.next();
			for(int x=0; x<N; x++)
				image[x][y] = line.charAt(x);
		}
		for(int y=0; y<M; y++){
			String line = sc.next();
			for(int x=0; x<M; x++)
				template[x][y] = line.charAt(x);
		}	
		sc.close();
		
		boolean match = false;
		for(int iy=0; iy< N-M+1 && !match ; iy++){
			for(int ix=0; ix<N-M+1 && !match ; ix++){
				match = true;
				for(int ty=0; ty<M; ty++){
					for(int tx=0; tx<M; tx++){
						if(image[ix+tx][iy+ty]!=template[tx][ty]){
							match = false;
							break;
						}
					}
					if(!match)
						break;
				}
			}
		}
		
		String ans = match ? "Yes":"No";
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 10184
n, l = map(int, input().split())
apples = []
min_val = l

for i in range(1, n + 1):
    apples.append(l + i - 1)
    if abs(l + i - 1) < abs(min_val):
        min_val = (l + i - 1)
apples.remove(min_val)

print(sum(apples))


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

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


typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	string A,B,C="";
	cin>>A>>B;
	for(int i=0;i<n;i++) 
	{C+=A.substr(i,1)+B.substr(i,1);}
	cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
cL = input()

ans = 0
s = 0
e = n - 1
while True:
    if s >= e:
        break
    if cL[s] == "R":
        s += 1
        continue
    else:
        if cL[e] == "W":
            e -= 1
            continue
        else:
            ans += 1
            s += 1
            e -= 1

print(ans)

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


std::string encode(char c){
    if(c == ' ') return "101";
    if(c == '\'') return "000000";
    if(c == ',') return "000011";
    if(c == '-') return "10010001";
    if(c == '.') return "010001";
    if(c == '?') return "000001";
    if(c == 'A') return "100101";
    if(c == 'B') return "10011010";
    if(c == 'C') return "0101";
    if(c == 'D') return "0001";
    if(c == 'E') return "110";
    if(c == 'F') return "01001";
    if(c == 'G') return "10011011";
    if(c == 'H') return "010000";
    if(c == 'I') return "0111";
    if(c == 'J') return "10011000";
    if(c == 'K') return "0110";
    if(c == 'L') return "00100";
    if(c == 'M') return "10011001";
    if(c == 'N') return "10011110";
    if(c == 'O') return "00101";
    if(c == 'P') return "111";
    if(c == 'Q') return "10011111";
    if(c == 'R') return "1000";
    if(c == 'S') return "00110";
    if(c == 'T') return "00111";
    if(c == 'U') return "10011100";
    if(c == 'V') return "10011101";
    if(c == 'W') return "000010";
    if(c == 'X') return "10010010";
    if(c == 'Y') return "10010011";
    if(c == 'Z') return "10010000";
    return "";
}

std::string encode2(std::string s){
    if(s == "00000") return "A";
    if(s == "00001") return "B";
    if(s == "00010") return "C";
    if(s == "00011") return "D";
    if(s == "00100") return "E";
    if(s == "00101") return "F";
    if(s == "00110") return "G";
    if(s == "00111") return "H";
    if(s == "01000") return "I";
    if(s == "01001") return "J";
    if(s == "01010") return "K";
    if(s == "01011") return "L";
    if(s == "01100") return "M";
    if(s == "01101") return "N";
    if(s == "01110") return "O";
    if(s == "01111") return "P";
    if(s == "10000") return "Q";
    if(s == "10001") return "R";
    if(s == "10010") return "S";
    if(s == "10011") return "T";
    if(s == "10100") return "U";
    if(s == "10101") return "V";
    if(s == "10110") return "W";
    if(s == "10111") return "X";
    if(s == "11000") return "Y";
    if(s == "11001") return "Z";
    if(s == "11010") return " ";
    if(s == "11011") return ".";
    if(s == "11100") return ",";
    if(s == "11101") return "-";
    if(s == "11110") return "'";
    if(s == "11111") return "?";
    return "";
}

int main(){
    std::string str, tmp, ans;
    while(getline(std::cin, str)){
        tmp = "", ans = "";
        for(int i = 0; i < str.size(); i++){
            tmp += encode(str[i]);
        }

        if(tmp.size() % 5 != 0){
            int n = 5 - (tmp.size() % 5);
            for(int i = 0; i < n; i++) tmp += "0";
        }

        for(int i = 0; i < tmp.size(); i += 5){
            ans += encode2(tmp.substr(i, 5));
        }

        std::cout << ans << std::endl;
    }

    return 0;
}

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

long long n,z[5005],ans,l,r;
string s;

int main(){

	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		for(int j=0;j<5005;j++)z[j]=0;
		l=r=i;
		z[i]=n-i;
		
		for(int j=i+1;j<n;j++){
			if(r<=j){
				l=r=j;
				while(r<n && s[r]==s[i+(r-l)])r++;
				z[j]=r-l;
			}
			else{
				if(z[i+j-l]<(r-j)){
					z[j]=z[i+j-l];
				}
				else{
					while(r<n && s[r]==s[i+(r-l)])r++;
					z[j]=r-j;
				}
			}
			ans=max(ans,min(z[j],(long long)j-i));
		}
		
		//for(int j=i;j<n;j++)cout<<z[j]<<" ";
		//cout<<endl;
	}
	
	
	
	for(int i=0;i<n;i++){
		for(int j=0;j<5005;j++)z[j]=0;
		l=r=i;
		z[i]=n-i;
		
		for(int j=i+1;j<n;j++){
			if(r<j){
				l=r=j;
				while(r<n && s[r]==s[i+(r-l)])r++;
				z[j]=r-l;
			}
			else{
				if(z[i+j-l]<(r-j)){
					z[j]=z[i+j-l];
				}
				else{
					while(r<n && s[r]==s[i+(r-l)])r++;
					z[j]=r-j;
				}
			}
			ans=max(ans,min(z[j],(long long)j-i));
		}
	}
	
	
	
	cout<<ans<<endl;

return 0;
}


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

#define ll long long
#define vl vector<ll>
#define vvl vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define vs vector<string>
#define vc vector<char>
#define vvc vector< vector<char> >

#define all(a) (a).begin(),(a).end()
using namespace std;

ll point(string s, vs &blue, vs &red){
	ll ret = 0;
	for (string ss : blue) if (ss == s) ret++;
	for (string ss : red) if (ss == s) ret--;
	return ret;
}

int main(){
	ll n; cin >> n;
	vs blue(n);
	for (ll i = 0; i < n; ++i) cin >> blue[i];
	ll m; cin >> m;
	vs red(m);
	for (ll i = 0; i < m; ++i) cin >> red[i];
	ll ans = 0;
	for (ll i = 0; i < n; ++i) ans = max(ans, point(blue[i], blue, red));
	for (ll i = 0; i < m; ++i) ans = max(ans, point(red[i], blue, red));
	cout << ans << endl;
	return 0;
}

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

int  a, b, c;
int main() {
	cin >> a;
	if (a==1){
		cout << "Hello World" << endl;
	} else if (a==2) {
		cin >> b >> c;
		cout << b+c << endl;
	} 
	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;
int m;

vector<vector<int>> A(303,vector<int>(303,0));

int ans;

int rec(vector<int>& ables){
    if(ables.size() == 0) return 0;
    vector<int> cou(m + 1,0);
    for(int i = 1;i <= n;i++){
        int MAX = -1;
        for(int s : ables){
            if(MAX == -1) MAX = s;
            else if(A[i][MAX] < A[i][s]) MAX = s;
        }
        cou[MAX]++;
    }
    int id = 0;
    for(int i = 1;i <= m;i++){
        if(cou[id] < cou[i]) id = i;
    }
    ans = min(ans,cou[id]);
    for(int i = 0;i < ables.size();i++){
        if(id == ables[i]){
            ables.erase(ables.begin() + i);
            break;
        }
    }

    rec(ables);
    return 0;
}

int main(){
   cin >> n >> m;
   ans = 1e9;
   for(int i = 1;i <= n;i++) {
       for(int j = 1;j <= m;j++){
           int t;
           cin >> t;
           A[i][t] = m - j + 1;
       }
   }
   vector<int> able;
   for(int i = 1;i <= m;i++) able.push_back(i);
   rec(able);
   cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
signed main(){
	int a,b;
  	map<int,bool> mp;
  	cin>>a>>b;
  	mp[a] = true;
  	mp[b] = true;
  
  	for(int i=1;i<=3;i++){
	 	if(mp[i] ==false)
          	cout<<i<<endl;
    }
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<int, int, int> ti;

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

    int H, W;
    cin >> H >> W;
    vector<string> map(H);
    for (int i = 0; i < H; i++)
    {
        string M;
        cin >> M;
        map.at(i) = M;
    }
    vector<int> dh = {-1, 1, 0, 0};
    vector<int> dw = {0, 0, -1, 1};
    queue<ti> moves;
    //全マスを起点で全探索
    int answer = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(map.at(i).at(j) == '#'){
                continue;
            }
            vector<vector<int>> moveCount(H, vector<int>(W, -1));
            moves.push(make_tuple(i, j, 0));
            moveCount.at(i).at(j) = 0;
            while(moves.size()){
                ti move = moves.front();
                moves.pop();
                int curH, curW, count;
                tie(curH, curW, count) = move;
                answer = max(answer, count);
                int nextH, nextW;
                for(int k = 0; k < 4; k++){
                    nextH = curH + dh.at(k);
                    nextW = curW + dw.at(k);
                    if(0 <= nextH && nextH < H
                    && 0 <= nextW && nextW < W                    
                    && map.at(nextH).at(nextW) == '.' 
                    && moveCount.at(nextH).at(nextW) == -1){
                        moves.push(make_tuple(nextH, nextW, count + 1));
                        moveCount.at(nextH).at(nextW) = count + 1;
                    }
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    if (y % 2 == 0 && y >= x * 2 && y <= x * 4) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int n, l, ans, N;
int dp[10][10];
string s;

int stt(int id, int mask)
{
    if(id == n)
        return mask == 7;

    if(dp[id][mask] != -1)
        return dp[id][mask];

    int ans = 0;
    ans += stt(id + 1, _set(mask, 0)) + stt(id + 1, _set(mask, 1)) + stt(id + 1, _set(mask, 2));

    return dp[id][mask] = ans;
}

void con(int id)
{
    if(id == l){
        int nn = n;
        int a = 0, b = 0, c = 0;
        while(nn){
            if(nn % 10 == 3)
                a++;
            if(nn % 10 == 5)
                b++;
            if(nn % 10 == 7)
                c++;
            nn /= 10;
        }
        if(!a || !b || !c)
            return;

        ans += (n <= N);
        return;
    }

    int x[] = {3, 5, 7};
    for(int i = 0; i < 3; i++){
        n *= 10, n += x[i];
        con(id + 1);
        n /= 10;
    }
}

int main()
{
    string s;
    cin >> s;

    l = s.size();
    for(int i = 0; i < l; i++)
        N *= 10, N += s[i] - '0';

    for(int i = 3; i < l; i++){
        mem(dp, -1);
        n = i, ans += stt(0, 0);
    }

    n = 0;
    con(0);

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


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const long long INF = 1LL << 58;
struct Edge
{
    ll s, t, d;
};
typedef vector<vector<Edge>> Graph;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int A = INF;
    int B = INF;
    int tmp;
    cin >> tmp;
    A = min(A, tmp * 4);
    cin >> tmp;
    A = min(A, tmp * 2);
    cin >> tmp;
    A = min(A, tmp * 1);
    cin >> tmp;
    B = min(A * 2, tmp);

    int N;
    cin >> N;
    cout << N % 2 * A + N / 2 * B << endl;
    // system("pause");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int W,int h){
	vvi vv(h+2,vi(W+2));
	vvb w(h+2,vb(W+2,true)),b(h+2,vb(W+2,true));
	queue<pii> bl,wh;
	char ch;
	rep(i,h)rep(j,W){
		b[i+1][j+1]=0;
		w[i+1][j+1]=0;
		w[i+1][j+1]=false;
		b[i+1][j+1]=false;
		cin>>ch;
		if(ch=='W'){
			vv[i+1][j+1]=1;
			w[i+1][j+1]=true;
			wh.push(pii(i+1,j+1));
		}
		if(ch=='B'){
			vv[i+1][j+1]=-1;
			b[i+1][j+1]=true;
			bl.push(pii(i+1,j+1));
		}
	}
	while(!wh.empty()){
		int x,y;
		tie(x,y)=wh.front();wh.pop();
		rep(i,4){
			int tx=x+dx[i];
			int ty=y+dy[i];
			if(!w[tx][ty]&&vv[tx][ty]!=-1){
				wh.push(pii(tx,ty));
				w[tx][ty]=true;
			}
		}
	}
	while(!bl.empty()){
		int x,y;
		tie(x,y)=bl.front();bl.pop();
		rep(i,4){
			int tx=x+dx[i];
			int ty=y+dy[i];
			if(!b[tx][ty]&&vv[tx][ty]!=1){
				bl.push(pii(tx,ty));
				b[tx][ty]=true;
			}
		}
	}
	int answ=0,ansb=0;
	rep(i,h){
		rep(j,W){
			if(!w[i+1][j+1]&&b[i+1][j+1])ansb++;
			if(vv[i+1][j+1]==-1)ansb--;
			if(!b[i+1][j+1]&&w[i+1][j+1])answ++;
			if(vv[i+1][j+1]==1)answ--;
		}
	}
	cout<<ansb<<" "<<answ<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	while(cin>>w>>h,h)solve(w,h);
}


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

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

int MOD=1e9+7;
ll INF=1e18;

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

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

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,i;
    double a,sum=0.0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&a);
        sum+=1.0/a;
    }
    sum=1.0/sum;
    printf("%f",sum);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <array>
#include <cmath>
#include <random>
#include <functional>
#include <climits>
using namespace std;
using lint=long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  cin>>a>>b;
  cout<<((a+b==15)?  '+' : (a*b==15)? '*' : 'x')<<endl;
  return 0;
}


Measured memory_bytes: 256
N, A, B, C = list(map(int, input().split()))
l = [int(input()) for x in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a + l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b + l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0,0,0,0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define sorted(a) sort(a.begin(), a.end());
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N, K;
  cin >> N >> K;
  vector<int> H(N, 0);
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }

  vector<ll> dp(N, INFINITY);
  dp[0] = 0;
  for (int i = 1; i < N; ++i) {
    int k = max(0, i - K);
    for (int j = k; j < i; ++j) {
      dp[i] = min(dp[i], abs(H[i] - H[j]) + dp[j]);
    }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
s = list(input())
k = int(input())
n = len(s)
s.append(' ')

l = []
cnt = 1
for i in range(1, n + 1):
    if s[i - 1] != s[i]:
        l.append(cnt)
        cnt = 1
    else:
        cnt += 1
m = sum(map(lambda li: li // 2, l))
if len(l) == 1:
    ans = k * n // 2
elif s[0] == s[-2] and l[0] % 2 == l[-1] % 2 == 1:
    ans = k * m + k - 1
else:
    ans = k * m
print(ans)

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
  int n; cin >> n;
  int ans = 999999;
  for(int i = 0; i < n; i++){
    int cnt = 0;
    int a; cin >> a;
    while(a % 2 == 0){
      a /=2;
      cnt++;
    }
    ans = min(ans, cnt);
    cnt = 0;
  }
  cout << ans;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S; cin >>S;
  int count=0;
  int h;
  int j=0;
  for(int i=0;i<S.size()/2;i++){
    h=S.size()-j-1;
    j++;
    if(S.at(i)!=S.at(h)){
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool l[180];
string str;
int main(){
	for(int i = 0;i < 11;i++){
		l["yuiophjklnm"[i]] = true;
	}
	while(cin >> str, str != "#"){
		bool pos = l[str[0]];
		int res = 0;
		for(int i = 1;i < str.size();i++){
			if(l[str[i]] ^ pos)res++;
			pos = l[str[i]];
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::vector<ll> vll;
typedef std::vector<vll> vvll;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int s;
  scan(s);
  vector<bool> ch(1000000+1, false);
  ch[s] = true;
  FOR (i, 2, 1000000+1) {
    if (s % 2 == 0) {
      s = s/2;
    } else {
      s = 3*s+1;
    }
    if (ch[s]) {
      print(i);
      return 0;
    }
    ch[s] = true;
  }
  assert(false);

  return 0;
}


Measured memory_bytes: 888
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    map<int, int> mp;
    ll ans = 0;
    rep(i, n) {
        mp[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        ans -= 1LL * mp[b] * b;
        ans += 1LL * mp[b] * c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << ans << endl;
    }
}


Measured memory_bytes: 8000
#include<stdio.h>
int sum,i;
int main()
{
    char s[5];
    scanf("%s",s);
    for(i=0;i<5;i++)
    {
        if(s[i]=='+')
           {
             sum++;
           }
        if(s[i]=='-')
           {
               sum--;
           }
    }
    printf("%d\n",sum);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define    fios ios_base::sync_with_stdio(false); cin.tie(0);
#define    sf(x) scanf("%d",&x)
#define    sfl(x) scanf("%lld",&x)
#define    pf(x) printf("%d\n",x)
#define    pfl(x) printf("%lld\n",x)
#define    ll long long
#define    nl "\n"
#define    PB(x) push_back(x)
#define    For(i,n) for(int i=0; i<n; i++)
#define    PI acos(-1)
using namespace std;


int main()
{
    int x,n,p;
    cin>>x>>n;

    int a[200]={0};

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

        cin>>p;

        a[p]=1;
    }

    int ans=1000,df=1000;


    for(int i=0; i<=101; i++)
    {
        if(a[i]==0 && abs(x-i)<df)
        {
            df=abs(x-i);
            ans=i;
        }

    }

    cout<<ans<<nl;





    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdint>

int64_t pars[100000], size[100000];
void init() {
	for (int i = 0; i < 100000; ++i)
		pars[i] = i;
	std::fill(size, std::end(size), 1);
}
int root(int x) {
	if (pars[x] == x)
		return x;

	pars[x] = root(pars[x]);
	size[pars[x]] += size[x];
	size[x] = 0;

	return pars[x];
}
int64_t unite(int a, int b) {
	a = root(a), b = root(b);
	if (a == b)
		return 0;

	pars[b] = a;
	size[a] += size[b];
	size[b] = 0;

	return size[a];
}
bool is_same(int a, int b) {
	a = root(a), b = root(b);
	return a == b;
}
int64_t get_size(int x) {
	return size[root(x)];
}

int main() {
	init();

	int64_t n, m;
	std::cin >> n >> m;

	std::vector<std::pair<int, int>> bridges(m);
	for (auto&& p : bridges) {
		std::cin >> p.first >> p.second;
		--p.first, --p.second;
	}

	std::reverse(bridges.begin(), bridges.end());

	std::vector<int64_t> ans(m);
	ans.front() = n * (n - 1) / 2;
	for (int i = 0; i < m - 1; ++i) {
		int a = bridges[i].first, b = bridges[i].second;

		ans[i + 1] = ans[i];
		if (!is_same(a, b))
			ans[i + 1] -= get_size(a) * get_size(b);

		unite(a, b);
	}

	for (int i = m - 1; i >= 0; --i)
		std::cout << ans[i] << std::endl;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    
    set<int>s;
    
    s.insert(a);
    s.insert(b);
    s.insert(c);
    
    if(s.size()==2) cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
    
    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cstdio>

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

using namespace std;

const int CAPA_INF=1<<29;
const int COST_INF=1<<29;

template<class T,class U>
struct Edge{
	int v,rev;
	T capa;
	U cost;
	T flow;
};

template<class T,class U>
struct AdjList:public vector< vector< Edge<T,U> > >{
	AdjList(int n):vector< vector< Edge<T,U> > >(n){}
};

template<class T,class U>
void add_edge(AdjList<T,U> &adj,int u,int v,T capa,U cost){
	adj[u].push_back((Edge<T,U>){v,adj[v].size()  ,capa, cost,0});
	adj[v].push_back((Edge<T,U>){u,adj[u].size()-1,   0,-cost,0});
}

template<class T,class U>
pair<T,U> augment(AdjList<T,U> &adj,int s,int t,vector<U> &pot,bool first){
	int n=adj.size();
	vector<int> pre(n);
	vector<U> d(n,COST_INF); d[s]=0;

	if(first){
		while(1){
			bool end=true;
			rep(u,n) rep(i,adj[u].size()) {
				Edge<T,U> &e=adj[u][i];
				U cost2=d[u]+e.cost;
				if(e.capa-e.flow>0 && cost2<d[e.v]){
					d[e.v]=cost2;
					pre[e.v]=e.rev;
					end=false;
				}
			}
			if(end) break;
		}
	}
	else{
		// Dijkstra
		bool ok=false;
		priority_queue< pair<U,int> > pq; pq.push(make_pair(0,s));
		while(!pq.empty()){
			int u=pq.top().second;
			U cost=-pq.top().first; pq.pop();

			if(cost<d[u]) continue;
			if(u==t) ok=true;

			rep(i,adj[u].size()){
				Edge<T,U> &e=adj[u][i];
				U cost2=cost+e.cost+pot[u]-pot[e.v];
				if(e.capa-e.flow>0 && cost2<d[e.v]){
					d[e.v]=cost2;
					pre[e.v]=e.rev;
					pq.push(make_pair(-cost2,e.v));
				}
			}
		}

		if(!ok) return make_pair(0,0);
	}

	T water=CAPA_INF;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		water=min(water,e2.capa-e2.flow);
		v=e1.v;
	}

	U cost=0;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		e1.flow-=water;
		e2.flow+=water;
		cost+=water*e2.cost;
		v=e1.v;
	}

	rep(u,n) pot[u]+=d[u];

	return make_pair(water,cost);
}

template<class T,class U>
pair<T,U> primal_dual(AdjList<T,U> &adj,int s,int t){
	T ans1=0;
	U ans2=0;
	vector<U> pot(adj.size());
	for(int i=0;;i++){
		pair<T,U> tmp=augment(adj,s,t,pot,i==0);
		if(tmp.first==0) break;
		ans1+=tmp.first;
		ans2+=tmp.second;
	}
	return make_pair(ans1,ans2);
}

int main(){
	int n; scanf("%d",&n);
	map<int,int> f;
	int a[1000],b[1000],m=0;
	rep(i,n){
		scanf("%d%d",a+i,b+i);
		if(f.count(a[i])==0) f[a[i]]=m++;
		if(f.count(b[i])==0) f[b[i]]=m++;
	}
	m++; // ツ環づィツ督鳴づづ按つ「ツブツδ債ッツクツつェツつアツつアツづ可猟ャツづェツづゥ

	AdjList<int,int> adj(n+m+2);
	int s=n+m,t=s+1;
	rep(i,n){
		add_edge(adj,s,i,1,0);
		add_edge(adj,i,n+f[a[i]],1,-b[i]);
		add_edge(adj,i,n+f[b[i]],1,-a[i]);
		add_edge(adj,i,n+m-1,1,0);
	}
	for(map<int,int>::iterator it=f.begin();it!=f.end();++it){
		add_edge(adj,n+it->second,t,1,0);
	}
	add_edge(adj,n+m-1,t,n,0);

	printf("%d\n",-primal_dual(adj,s,t).second);

	return 0;
}

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

using namespace std;

int N, M;
int DataA[100][100], DataB[100];
int Result[100];

void solve() {
	int sum;

	for (int i = 0; i < N; ++i) {
		sum = 0;
		for (int j = 0; j < M; ++j) {
			sum += DataA[i][j] * DataB[j];
		}
		Result[i] = sum;
	}

	for (int i = 0; i < N; ++i) {
		cout << Result[i] << endl;
	}
}

int main() {

	cin >> N >> M;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> DataA[i][j];
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> DataB[i];
	}
	solve();	

	return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#include<vector>
int max(int a, int b) { return (a > b)? a : b; } ;
int main(){
long long int N,W,a,b;
cin>>N>>W;
vector<int>v;
vector<int>wt;
for(int i=0;i<N;++i)
{
    cin>>a;
    wt.push_back(a);
    cin>>b;
    v.push_back(b);
}
long long int i, w;
long long int K[N+1][W+1];
for (i = 0; i <= N; i++)
{
	for (w = 0; w <= W; w++)
	{
		if (i==0 || w==0)
			K[i][w] = 0;
		else if (wt[i-1] <= w)
				K[i][w] = max(v[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]);
		else
				K[i][w] = K[i-1][w];
	}
}
cout<< K[N][W];
}

Measured memory_bytes: 79104
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

struct edge{
    int to;
    long long int cost;
};

#define MAX_V 110000
vector<edge> E[MAX_V];
long long int d1[MAX_V], d2[MAX_V];
 
void func(int u, int pre, int dist, long long int d[]){
    d[u] = dist;
    for(int i = 0; i < E[u].size(); i++){
        if(E[u][i].to != pre){
            func(E[u][i].to, u, dist + E[u][i].cost, d);
        }
    }
}

int main(){
     
    int N;
    cin >> N;
     
    for(int i = 0; i < N - 1; i++){
        int u, v, c;
        cin >> u >> v >> c;
        edge p;
        p.cost = c;
        p.to = v;
        E[u].push_back(p);
        p.to = u;
        E[v].push_back(p);
    }
     
    func(0, -1, 0, d1);
     
    int index = 0;
    int dmax = 0;
    for(int i = 0; i < N; i++){
        if(d1[i] > dmax){
            dmax = d1[i];
            index = i;
        }
    }
    func(index, -1, 0, d1);
     
    dmax = 0;
    for(int i = 0; i < N; i++){
        if(d1[i] > dmax){
            dmax = d1[i];
            index = i;
        }
    }
    func(index, -1, 0, d2);
	
    for(int i = 0; i < N; i++){
    	cout << max(d1[i], d2[i]) << endl;
    }
     
    return 0;
}


Measured memory_bytes: 6988
#pragma warning(disable:4996) 
 
#include<bits/stdc++.h> 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
//const long long MOD = 998244353;
long long MOD;
 
using namespace std;
 
char str[10][1005];
int s[12][12][1005];
int ne[12][12][1005];
 
void solve()
{
    int h, w, K;
    scanf("%d%d%d", &h, &w, &K);
    int i, j, k;
    for (i = 0; i < h; i++) {
        scanf("%s", str[i]);
        for (j = 0; j < w; j++) {
            s[i][i + 1][j + 1] = s[i][i + 1][j] + (str[i][j] == '1' ? 1 : 0);
        }
    }
 
    for (k = 0; k <= w; k++) {
        for (i = 0; i <= h; i++) {
            for (j = i + 2; j <= h; j++) {
                s[i][j][k] = s[i][j - 1][k] + s[j - 1][j][k];
            }
        }
    }
 
    for (i = 0; i <= h; i++) {
        for (j = i + 1; j <= h; j++) {
            for (k = 0; k < w; k++) {
                int off = lower_bound(&s[i][j][k], &s[i][j][w + 1], s[i][j][k] + K + 1) - &s[i][j][0];
                off--;
                ne[i][j][k] = off;
            }
        }
    }
    
    int ans = INF;
    for (k = 0; k < (1 << (h - 1)); k++) {
        int cnt0 = 0;
        for (i = 1; i < h; i++) {
            if (k & (1 << (i - 1))) {
                cnt0++;
            }
        }
 
        int cnt = 0;
        int stt = 0;
        while (stt < w) {
            int min = INF;
            int prev = 0;
            for (i = 1; i <= h; i++) {
                if (i==h || (k & (1 << (i - 1)))) {
                    int off = ne[prev][i][stt];
                    min = MIN(min, off);
                    prev = i;
                }
            }
            cnt++;
            if (min <= stt) {
                cnt = INF;
                break;
            }
            stt = min;
        }
        //printf("%d ", cnt+cnt0-1);
        ans = MIN(ans, cnt + cnt0 - 1);
    }
    printf("%d\n", ans);
 
    return;
}
 
int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}

Measured memory_bytes: 768
import math
Q = int(input())
ans = []

for i in range(Q):
    a,b = map(int,input().split())
    if a>b:
        a,b = b,a
    if a == b:
        ans.append((a-1)*2)
        continue
    c = math.ceil((a*b)**0.5-1)
    
    ans.append(c*2-2)
    if c*(c+1) < a*b and a != c+1 != b:
        ans[-1] +=1
for i in ans:
    print(i)


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

int main()
{
	int a;
	cin >> a;
	int b;
	cin >> b;
	if (a > b){
		cout << "a > b" << endl;
	}else if (a < b){
		cout << "a < b" << endl;
	}else{
		cout << "a == b" << endl;
	} 
}

Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	r.Scan(true)
	_, d := r.nextInt(), r.nextInt()
	ans := 0
	if d == 1 {
		ans = 1
	}
	fmt.Fprintln(stdout, ans)
}


Measured memory_bytes: 640
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, C, K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()

    first = T[0]
    cnt = 1
    ans = 0
    for i in range(1, N):
        if cnt == C:
            ans += 1
            first = T[i]
            cnt = 1
        elif first + K < T[i]:
            ans += 1
            first = T[i]
            cnt = 1
        else:
            cnt += 1
    ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 7504
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n;
  cin >> n;
  ll x = 1, y = 1;
  rep(i, n) {
    ll t, a;
    cin >> t >> a;

    ll f = max( x / t + (x % t ? 1 : 0),
		y / a + (y % a ? 1 : 0));
    x = f * t;
    y = f * a;
  }
  cout << x + y << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d" (fun abcd ->
    let a = abcd            / 1000 in
    let b = (abcd mod 1000) /  100 in
    let c = (abcd mod  100) /   10 in
    let d = (abcd mod   10)        in
    if a + b + c + d = 7 then Printf.printf "%d+%d+%d+%d=7\n" a b c d else
    if a + b + c - d = 7 then Printf.printf "%d+%d+%d-%d=7\n" a b c d else
    if a + b - c + d = 7 then Printf.printf "%d+%d-%d+%d=7\n" a b c d else
    if a + b - c - d = 7 then Printf.printf "%d+%d-%d-%d=7\n" a b c d else
    if a - b + c + d = 7 then Printf.printf "%d-%d+%d+%d=7\n" a b c d else
    if a - b + c - d = 7 then Printf.printf "%d-%d+%d-%d=7\n" a b c d else
    if a - b - c + d = 7 then Printf.printf "%d-%d-%d+%d=7\n" a b c d else
    if a - b - c - d = 7 then Printf.printf "%d-%d-%d-%d=7\n" a b c d else ()
)

Measured memory_bytes: 3856
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

vector<int> A;
int N;
int M;

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

    cin >> N >> M;

    int temp;
    rep(i, N)
    {
        cin >> temp;
        A.push_back(temp);
    }

    int m = 0;
    int j;
    while (m < M)
    {
        if (A.size() == 0)
        {
            break;
        }
        else
        {
            sort(A.begin(), A.end(), std::greater<int>());
            int half = A[0] / 2;
            j = 0;
            while (j < A.size() && half < A[j])
            {
                A[j] /= 2;
                if (A[j] == 0)
                {
                    A.erase(A.begin() + j);
                }
                ++j;
                ++m;
                if (m >= M) break;
            }
        }
    }

    u64 ret = 0;
    for (int i = 0; i < A.size(); ++i)
    {
        ret += A[i];
    }

    cout << ret << "\n";

    return 0;
}



Measured memory_bytes: 892
#include <iostream>

using namespace std;

int x[11][11];

int main(){
  int n, d;
  cin >> n >> d;
  for (int i=0;i<n;i++) {
    for (int j=0;j<d;j++) {
      int tmp;
      cin >> tmp;
      x[i][j] = tmp;
    }
  }
  int z_count = 0;
  for (int i=0;i<n;i++) {
    for (int k=i+1;k<n;k++) {
      int dist = 0;
      for (int j=0;j<d;j++) {
	dist += (x[i][j] - x[k][j])*(x[i][j] - x[k][j]);
      }
      for (int l=1;;l++) {
	if (dist == l*l) {
	  z_count++;
	  break;
	} else if (dist < l*l) {
	  break;
	}
      }
    }
  }
  cout << z_count << endl;
  return(0);
}


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

using namespace std;

int n, x[100005], ma = INT_MIN, mi = INT_MAX, sum;
bool z, ne[100005], sw;
vector<int> vp, vn;
vector<pair<int, int>> ans;

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int tmp;
		scanf("%d", &tmp);
		x[i] = tmp;
		sum += abs(tmp);
		if (tmp > 0)
			mi = min(mi, tmp);
		else if (tmp < 0) {
			ma = max(ma, tmp);
			ne[i] = 1;
		} else
			z = 1;
	}
	if (z) {
		if (ma == INT_MIN)
			for (int i = 0; i < n; i++)
				if (x[i] == 0) {
					ne[i] = 1;
					break;
				}
	} else
		if (ma == INT_MIN) {
			sum -= mi * 2;
			for (int i = 0; i < n; i++)
				if (x[i] == mi) {
					ne[i] = 1;
					break;
				}
		} else if (mi == INT_MAX) {
			sum += ma * 2;
			for (int i = 0; i < n; i++)
				if (x[i] == ma) {
					ne[i] = 0;
					break;
				}
		}
	printf("%d\n", sum);
	for (int i = 0; i < n; i++)
		if (ne[i])
			vn.push_back(x[i]);
		else
			vp.push_back(x[i]);
	while (vn.size() > 1 || vp.size() > 1)
		if (vn.size() > 1) {
			if (sw) {
				ans.emplace_back(vn.back(), INT_MAX);
				sw = 0;
			} else {
				ans.emplace_back(INT_MAX, vn.back());
				sw = 0;
			}
			vn.pop_back();
		} else {
			if (sw) {
				ans.emplace_back(INT_MAX, vp.back());
				sw = 1;
			} else {
				ans.emplace_back(vp.back(), INT_MAX);
				sw = 1;
			}
			vp.pop_back();
		}
	if (sw)
		ans.emplace_back(vn[0], vp[0]);
	else
		ans.emplace_back(vp[0], vn[0]);
	reverse(ans.begin(), ans.end());
	sum = 0;
	for (auto i : ans) {
		if (i.first == INT_MAX)
			i.first = sum;
		else if (i.second == INT_MAX)
			i.second = sum;
		printf("%d %d\n", i.first, i.second);
		sum = i.first - i.second;
	}
}


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

typedef long long LL;
typedef long double LD;
typedef string ST;


#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) for(auto (a): v )   cerr << a << endl
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl

void func() {
  LL N, K;
  cin >> N >> K;
  vector<LL> H(N);
  REP(i, N) cin >> H[i];
  sort(ALL(H));
  LL diff_min = LLONG_MAX;
  REP(i, N - K+1) {
    //cerr << H[i] << " " << H[i + 1] << " " << H[i + 2] << endl;
    //cerr << H[i + K - 1] - H[i] << endl;
    diff_min = min(H[i + K - 1] - H[i], diff_min);
  }
  cout << diff_min;
}







#ifdef CALC_TIME 
#include <windows.h>
int main()
{
  LARGE_INTEGER freq;
  QueryPerformanceFrequency(&freq);
  LARGE_INTEGER start, end;
  QueryPerformanceCounter(&start);
  // 何かの処理
  func();
  QueryPerformanceCounter(&end);
  double time = static_cast<double>(end.QuadPart - start.QuadPart) * 1000.0 / freq.QuadPart;
  fprintf(stderr, "\n%lf[ms]\n", time);
  return 0;
}
#else 
int main()
{
  func();
  return 0;
}
#endif





Measured memory_bytes: 1024