akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};
typedef long long ll;

int ans;

signed main(){

    int a,b,c;
    cin>>a>>b>>c;
    cout<<min({a+b,b+c,c+a})<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  int N;
  cin >> N;
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
	  for (int j = 1; j <= 9; j++) {
		  if (i * j == N) {
			  flag = true;
			}
		}
	}
  if (flag) {
	  cout << "Yes" << endl;
	}
  else {
	  cout << "No" << endl;
	}
  return 0;
}

Measured memory_bytes: 256
n = 12
data = [0 for i in range(n + 1)]
data[1] = 1
data[3] = 1
data[5] = 1
data[7] = 1
data[8] = 1
data[10] = 1
data[12] = 1
data[4] = 2
data[6] = 2
data[9] = 2
data[11] = 2
data[2] = 3
a, b = map(int,input().split())
if data[a] == data[b]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int date[1000000];
//#define int long long
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    if(b!=0){
      date[i]=c;
      b--;
    }
    else if(c!=1) date[i]=c-1;
    else if(c==1) date[i]=c+1;
  }
  for(int i=0;i<a;i++){
    cout<<date[i];
    if(i!=a-1) cout<<" ";
  }
  cout<<"\n";
}


Measured memory_bytes: 1664
#abc166c
n,m=map(int,input().split())
h=list(map(int,input().split()))
res=[1]*n
for i in range(m):
 a,b=map(int,input().split())
 if h[a-1]<=h[b-1]:
  res[a-1]=0
 if h[b-1]<=h[a-1]:
  res[b-1]=0
print(res.count(1))


Measured memory_bytes: 20108
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[10000];
	a[0]=m;
	for(int i=1;i<n+1;i++){
		int b,c;
		cin>>b>>c;
		a[i]=a[i-1]+b-c;
		if(a[i]<0){
			cout<<0<<endl;
			goto loop;
		}
	}
	sort(a,a+n+1);
	cout<<a[n]<<endl;
	loop:;
	return 0;
}			


Measured memory_bytes: 3136
#include <iostream>
using namespace std;
typedef long long int LLI;
int main()
{
	string s;
	cin >> s;
	int g = 0, p = 0;
	for(int i = 0; i < s.size(); i++)
	{
		if( s[i] == 'g' )
			g++;
		else
			p++;
	}
	cout << ( g - p ) / 2;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
  ll N;
  cin >> N;
  ll D;
  cin >> D;
  vector<vector<ll>> X(N, vector<ll>(D, 0));
  for(ll i=0;i<N;i++){
   for(ll j=0;j<D;j++){
     cin>>X[i][j]
   ;}
  ;}
  ll counter=0;
  for(ll i=0;i<N-1;i++){
   for(ll j=i+1;j<N;j++){
     ll sum=0;
     for(ll k=0;k<D;k++){
       sum+=pow(X[i][k]-X[j][k],2)
     ;}
     ll r=sqrt(sum);
     if(r*r==sum)counter++;
   ;}
  ;}
  cout<<counter<<endl;
  

return 0;
}


Measured memory_bytes: 256
private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val (n, k) = readLongs()
    var r = n % k
    println(Math.min(r, Math.abs(r - k)))
}


Measured memory_bytes: 37776
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;



int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	int ans = 0;
	ans = (t / a)*b;

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()



int main(void) {
	int a, b, c, x; cin >> a >> b >> c >> x;
	ll ans = 0;
	for (ll i = 0; i <= a; i++) {
		for (ll ii = 0; ii <= b; ii++) {
			for (ll iii = 0; iii <= c; iii++) {
				if (x == i * 500 + ii * 100 + iii * 50)ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define sz size()
#define mp make_pair
#define pb push_back
#define rep(p, a, b) for (ll p = a; p < b; p++)
#define F first
#define S second
using namespace std;

typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<ld> vld;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;

int main()
{
    ll t, i, j, k, ans, n, m, sum = 0, x;

    //cin>>t;
    t = 1;
    while (t--)
    {
        cin>>n;
        ll mi = LLONG_MAX;
        ans=1;

        cin>>x;mi = x;
        rep(p,1,n)
        {
            cin>>x;
            if(x<=mi)
            {
                mi = x;
                ans++;
            }
        }
        cout<<ans;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

int main(){
	ios::sync_with_stdio(false);
	LL a,b,c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b << endl;
	return 0;
}
//

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,b) for(i=0;i<b;++i)
#define repp(i,a,b) for(i=a;i<b;++i)
#define endl "\n"
//#define LLONG_MAX 99999999999999
typedef long long int lli;
int main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    lli n,i,j,k,b,a,q,m;
    lli t=1;
    cin>>k>>n;
    vector<lli> v(n);
    rep(i,n)cin>>v[i];
    set<lli> st;
    rep(i,n)st.insert(v[i]);
    lli ans=10000;
    lli fans=-1;
    rep(i,102){
			if(st.find(i)==st.end()){
				if(abs(k-i)<ans){
					ans=abs(k-i);
					fans=i;
				}
			}
    }
    cout<<fans<<endl;



}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<P, ll> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
using namespace std;
#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < (N); ++i)
int main()
{
  int N;
  cin >> N;
  int A = 0;
  int C = 1;
  int G = 2;
  long dp[101][5][5][5] = {};
  dp[0][4][4][4] = 1;
  REP(i, N)
  REP(j, 5)
  REP(k, 5)
  REP(l, 5)
  REP(m, 4)
  {
    if (k == A && l == G && m == C)
      continue;
    if (k == A && l == C && m == G)
      continue;
    if (k == G && l == A && m == C)
      continue;
    if (j == A && l == G && m == C)
      continue;
    if (j == A && k == G && m == C)
      continue;
    dp[i + 1][k][l][m] += dp[i][j][k][l];
    dp[i + 1][k][l][m] %= MOD;
  }

  long ans = 0;
  REP(j, 4)
  REP(k, 4)
  REP(l, 4)
  {
    ans += dp[N][j][k][l];
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
 
int main() {
int N,X;
cin >> N >> X;
vector<int> L(N);
vector<int> D(N+1);
D.at(0) = 0;
for (int i = 0;i < N;i++) {
    cin >> L.at(i);
    D.at(i+1) = D.at(i) + L.at(i); 
    
}
int cnt = 0;
for (int i = 0;i < N+1;i++) {
    if (X >= D.at(i)) cnt++;
}
cout << cnt << endl;
 
 
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int pat[4][50][50];
int scen[100][100];

void rote(int s, int e, int m)
{
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			pat[e][j][i] = pat[s][i][(m - 1) - j];
		}
	}
}


int main(void)
{
	int n, m;
	int patx, paty;
	bool end;
	
	while (1){
		scanf("%d%d", &n, &m);
		
		if (n == 0 || m == 0){
			break;
		}
		
		for (int y = 0; y < n; y++){
			for (int x = 0; x < n; x++){
				scanf("%d", &scen[x][y]);
			}
		}
		for (int y = 0; y < m; y++){
			for (int x = 0; x < m; x++){
				scanf("%d", &pat[0][x][y]);
			}
		}
		for (int i = 0; i < 3; i++){
			rote(i, i + 1, m);
		}
		
		end = false;
		for (int y = 0; (y + m) <= n; y++){
			for (int x = 0; (x + m) <= n; x++){
				int dx, dy;
				for (int i = 0; i < 4; i++){
					bool flag;
					flag = true;
					for (dy = 0; dy < m; dy++){
						for (dx = 0; dx < m; dx++){
							if (pat[i][dx][dy] != -1 && scen[x + dx][y + dy] != pat[i][dx][dy]){
								flag = false;
								break;
							}
						}
						if (!flag){
							break;
						}
					}
					if (flag){
						int px, py;
						
						px = py = -1;
						for (dy = 0; dy < m; dy++){
							for (dx = 0; dx < m; dx++){
								if (pat[i][dx][dy] != -1){
									px = dx;
									py = dy;
									break;
								}
							}
							if (px != -1) break;
						}
						end = true;
						printf("%d %d\n", x + px + 1, y + py + 1, i);
						break;
					}
				}
				if (end) break;
			}
			if (end) break;
		}
		
		if (!end){
			printf("NA\n");
		}
	}
	
	return (0);
}

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

using namespace std;

int main(){
    int n,k; //すぬけ人数n, k種類のおかし
    cin >> n >> k;

    int d; //iのおかしをd人に配る
    int sunuke[n+1]={0};
    //int a[k + 1][d + 1] = {0};
    int count = 0, s = 0;

    for(int i=0;i<k;i++){
        cin >> d;
        for (int j=0;j<d;j++)
        {
            cin >> s; //a[i][j];
            sunuke[s-1]+= 1;
        }
    }
    
    for (int i=0;i<n;i++)
    {
        if(sunuke[i] == 0){
            count++;
        }    
    }

    cout << count<< endl;
    return 0;

}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Sparsh Sanchorawala
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALphabet solver = new ALphabet();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALphabet {
        public void solve(int testNumber, InputReader s, PrintWriter w) {
            char c = s.next().charAt(0);
            if ('A' <= c && c <= 'Z')
                w.println("A");
            else
                w.println("a");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                if (Character.isValidCodePoint(c)) {
                    res.appendCodePoint(c);
                }
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return nextString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> odd(1e5 + 1, 0);
    vector<ll> even(1e5 + 1, 0);
    for (ll i = 0; i < n;i++){
        ll t;
        cin >> t;
        if (i % 2 == 0) even[t]++;
        else
            odd[t]++;
    }
    ll oddmax = 0;
    ll oddmaxkey = 0;
    ll oddsecond = 0;
    ll oddsecondkey = 0;
    ll evenmax = 0;
    ll evenmaxkey = 0;
    ll evensecond = 0;
    ll evensecondkey = 0;
    ll ans = 0;
    for (ll i = 0; i < 1e5 + 1; i++) {
        if (chmax(oddmax, odd[i])) oddmaxkey = i;
        if (chmax(evenmax, even[i])) evenmaxkey = i;
    }
    for (ll i = 0; i < 1e5+1;i++){
        if (i == oddmaxkey) continue;
        else if(chmax(oddsecond,odd[i]))
            oddsecondkey = i;
    }
    for (ll i = 0; i < 1e5+1;i++){
        if (i == evenmaxkey) continue;
        else if(chmax(evensecond,even[i]))
            evensecondkey = i;
    }
    if (oddmaxkey != evenmaxkey) ans = n - oddmax - evenmax;
    else
        ans = min(n - oddmax - evensecond, n - oddsecond - evenmax);
    cout << ans << endl;
}

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

ll a,b,N,K,cunt;                                                 
int main(){
    cin>>N>>K;

    if(K){
        for(b=K+1;b<=N;b++)
            cunt+=(N/b)*max(0ll,b-K)+max(0ll,N%b+1-K);
    }
    else
        cunt=N*N;
    cout<<cunt<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
vector<int> adj[mex];

int main(){
	int n,t;
	cin>>n;
	vector<pair<string,int> > v;
	string s;
	long long t1=0;
	for(int i=0;i<n;i++){
		cin>>s>>t;
		t1=t1+t;
		v.push_back({s,t1});
	}
	string x;
	cin>>x;
	for(int i=0;i<n;i++){
		if(v[i].first==x){
			cout<<t1-v[i].second;
			break;
		}
	}
}




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

int x[201];

int main(){
	ll n;
	scanf("%lld", &n);
	if (n < 100){
		printf("%lld\n", n << 1);
		for (int i = n; i > 0; --i)printf("%d ", i);
		printf("1");
		f(i, 2, n + 1)printf(" %d", i);
		printf("\n");
		return 0;
	}
	f(i, 1, 101)x[i] = 101 - i;
	f(i, 1, 101)x[i + 100] = i;
	ll need = n - 100, z = 1;
	int b = 0, l = 0;
	while (need){
		int i = 99;
		if (need >> b & 1)swap(x[100], x[99]), need ^= z, --i;
		z <<= 1;
		while (need >= z && i > 1 + l){
			swap(x[i], x[i + 1]);
			--i;
			swap(x[i], x[i + 1]);
			--i;
			need -= z;
		}
		++b;
		l = i + 1;
	}
	printf("200\n%d", x[1]);
	f(i, 2, 201)printf(" %d", x[i]);
	printf("\n");
}


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

int main(){
    
    int i, x = 0, N, a_max, keta = 0;
    cin >> N;
    
    vector<int> a(N, 0);
    for (i = 0; i < N; i++){
        cin >> a[i];
        x = x ^ a[i];
    }
    
    for (i = 0; i < N; i++){
        
        cout << (a[i] ^ x) << ' ';
    }
    
    cout << "\n";

    return 0;
}




Measured memory_bytes: 3604
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const Inf = 1 << 60

func main() {
	H, W, K := ReadInt(), ReadInt(), ReadInt()
	x1, y1, x2, y2 := ReadInt()-1, ReadInt()-1, ReadInt()-1, ReadInt()-1
	x1, y1 = y1, x1
	x2, y2 = y2, x2
	c := make([]string, H)
	for y := 0; y < H; y++ {
		c[y] = ReadString()
	}

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

	toID := func(x, y, dir int) int {
		return 4*(W*y+x) + dir
	}
	splatID := func(id int) (x, y, dir int) {
		return id / 4 % W, id / 4 / W, id % 4
	}

	dist := make([]int, W*H*4)
	for i := 0; i < W*H*4; i++ {
		dist[i] = Inf
	}

	q := Heap{}
	for i := 0; i < 4; i++ {
		q = append(q, State{
			Cost: 0,
			ID:   toID(x1, y1, i),
		})
	}
	push := func(dir, x, y, cost int) {
		if c[y][x] == '@' {
			return
		}
		id := toID(x, y, dir)
		if dist[id] <= cost {
			return
		}
		dist[id] = cost
		q.push(State{
			Cost: cost,
			ID:   id,
		})
	}

	for len(q) > 0 {
		now := q.pop()
		x, y, dir := splatID(now.ID)
		// if c[y][x] == '@' {
		// 	continue
		// }
		// if dist[now.ID] <= now.Cost {
		// 	continue
		// }
		// dist[now.ID] = now.Cost
		if x == x2 && y == y2 {
			break
		}
		nx := x + dx[dir]
		ny := y + dy[dir]
		if 0 <= nx && nx < W && 0 <= ny && ny < H {
			push(dir, nx, ny, now.Cost+1)
			// q.push(State{
			// 	Cost: now.Cost + 1,
			// 	ID:   toID(nx, ny, dir),
			// })
		}
		for i := 0; i < 4; i++ {
			push(i, x, y, (now.Cost+K-1)/K*K)
			// q.push(State{
			// 	Cost: (,
			// 	ID:   toID(x, y, i),
			// })
		}
	}
	ans := Inf
	for i := 0; i < 4; i++ {
		id := toID(x2, y2, i)
		if dist[id] < ans {
			d2 := (dist[id] + K - 1) / K
			if d2 < ans {
				ans = d2
			}
		}
	}
	if ans < Inf {
		fmt.Println(ans)
	} else {
		fmt.Println(-1)
	}
}

type State struct {
	Cost, ID int
}

type HeapElement = State
type Heap []HeapElement

func (h Heap) Less(i, j int) bool    { return h[i].Cost < h[j].Cost }
func (h Heap) Len() int              { return len(h) }
func (h Heap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *Heap) Push(x interface{})   { *h = append(*h, x.(HeapElement)) }
func (h *Heap) Pop() (x interface{}) { *h, x = (*h)[:len(*h)-1], (*h)[len(*h)-1]; return }
func (h *Heap) push(v HeapElement)   { heap.Push(h, v) }
func (h *Heap) pop() HeapElement     { return heap.Pop(h).(HeapElement) }

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

int main(void) {
  int n;
  cin >> n;

  int expensive=0;
  int total=0;
  for(int i=0; i<n; i++){
    int p;
    cin >> p;
    total += p;
    if(expensive<p) expensive = p;
  }

  total -= expensive/2;

  cout << total << endl;

}


Measured memory_bytes: 256
//
//  main.cpp
//  programming
//
//  Created by 安波暢道 on 2020/03/28.
//  Copyright © 2020年 安波暢道. All rights reserved.
//

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


long int count(vector<int> &data, int i, int division)
{
    long int p = data[i];
    for(int l = 0; l <division; l++)
    {
        p *= 10;
    }
    if(i != 0)
    {
        for(int k = 0 ; k< i; k++)
        {
            p *= 2;
        }
        
        p += count(data,i-1,0);
        p += count(data,i-1,division+1);
    }
    
    return p;
}

int main()
{
    string S;
    cin >> S;
    
    vector<int> data((int)S.length());
    
    for(int i=0;i<S.length();i++)
    {
        data[i] = S[i] - '0';
        
    }
    long int ans = count(data,(int)data.size()-1,0);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    vector<int> A(3, 0); cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    printf("%d\n", (A[2] * 10 + A[1]) + A[0]);
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N],b[N];

char s[N];


vector<int> g[10];

int main(){
//	#ifndef ONLINE_JUDGE
//		freopen("test.txt","r",stdin);
//	#endif
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&x);
		while(x--){
			scanf("%d",&y);
			g[i].push_back(--y);
		}
	}
	for(int i=0;i<m;i++)
		scanf("%d",&b[i]);
	for(int msk=0;msk<(1<<n);msk++){
        bool ok=true;
		for(int i=0;i<m;i++){
            int cnt=0;
		    for(auto j:g[i]){
                if ( (msk & (1<<j)) ){
                    cnt++;
                }
		    }
		    if ( (cnt % 2) != b[i] )
                ok=false;
		}
		if (ok)
            ans++;
	}
	printf("%d",ans);

}



Measured memory_bytes: 2304
def digit_sum(x):
    res = 0
    while x > 0:
        res += x % 10
        x //= 10
    return res


N = int(input())
ans = N
for i in range(1, N):
    A = i
    B = N - i
    ans = min(ans, digit_sum(A) + digit_sum(B))
print(ans)


Measured memory_bytes: 9000
H, W = map(int, input().split())
S = []
for i in range(H):
    s = input()
    S.append(list(s))

# 隣接のマスをループで表すために必要
di = [-1, 0, 1, 0]
dj = [0, -1, 0, 1]

def is_street(s, t):
    """
    道であること（壁ではないこと）を確認
    """
    return S[s][t] == '.'

def count(maze):
    """
    最大のコストを探索
    """
    r = -1
    for i in range(H):
        for j in range(W):
            r = max(r, maze[i][j])
    return r

def bfs(h, w):
    """
    h: スタート位置（高さ）
    w: スタート位置（横）
    """
    m = []  # スタート地点からの距離が入る
    for i in range(H):
        s = [-1] * W
        m.append(s)
    m[h][w] = 0  # スタート地点は0

    q = [[h, w]]
    while len(q) != 0:
        t, u = q.pop(0)
        cost = m[t][u]

        for i in range(4):
            ni = t + di[i]
            nj = u + dj[i]
            if not (0 <= ni < H and 0 <= nj < W):
                continue
            if not is_street(ni, nj): 
                continue
            if m[ni][nj] != -1:
                continue

            m[ni][nj] = cost + 1
            q.append([ni, nj])

    max_cost = count(m)
    return max_cost

ans = -1
# 壁以外のすべてのマスをスタートにして探索
for i in range(H):
    for j in range(W):
        if is_street(i, j):
            c = bfs(i, j)
            ans = max(ans, c)

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
		cout << 3;
	}
	else if ((s[0] == 'R' && s[1] == 'R') || ( s[1] == 'R' && s[2] == 'R')) {
		cout << 2;
	}
	else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') {
		cout << 1;
	}
	else {
		cout << 0;
	}
}


Measured memory_bytes: 3620
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() ;
const ll linf = numeric_limits<ll>::max() ;
const ull ulinf = numeric_limits<ull>::max();
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    ll q,h,s,d,n;
    cin >> q >> h >> s >> d>> n; 

    if(q*2 < h)h = q*2;
    if(h*2 < s)s = h*2;

    if(s*2 < d)P(n*s);
    else{
        P((n/2)*d + (n%2==1)*s);
    }
	return  0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[101];
int main()
{
	scanf("%s",s);
	int len=strlen(s),i,tmp,flag=false;
	for(i=0;i<len;i++) if(s[i]=='C') {flag=true,tmp=i;break;}
	for(i=tmp+1;i<len;i++) if(flag&&s[i]=='F') {printf("Yes\n");return 0;}
	printf("No\n");
	return 0;
 } 

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

int main() {
  int N, L, sum = 0;
  vector<int> apple;
  cin >> N >> L;
  for (int i = 0; i < N; i++) {
    apple.push_back(L + i);
  }
  if (L >= 0) {
    for (int i = 0; i < N - 1; i++) {
      sum += apple.at(i + 1);
    }
  }
  else if (- (L - 1)  < N)  {
    for (int i = 0; i < N; i++) {
      sum += apple.at(i);
    }
  }
  else {
    for (int i = 0; i < N - 1; i++) {
      sum += apple.at(i);
    }    
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
data = list(map(int, list(input().split())))
row = data[0]
column = data[1]
matrix = [[0 for i in range(column)] for j in range(row)]
vector = [[0] for k in range(column)]
vector_multi = [[0] for l in range(row)]

for i in range(row):
    data_row = list(map(int, list(input().split())))
    for j in range(column):
        matrix[i][j] = data_row[j]

for i in range(column):
    vector[i] = int(input())

for i in range(row): 
    element = 0
    for j in range(column):
        element += matrix[i][j] * vector[j]
    vector_multi[i][0] = element

for i in vector_multi:
    print(i[0])



Measured memory_bytes: 6028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            int a;
            int b;
            int x;

            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if (a * n < b)
                x = a * n;
            else 
                x = b;

            Console.WriteLine(x);

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    vector<int> lis(3, 0);
    cin >> lis[0] >> lis[1] >> lis[2];
    sort(ALL(lis), greater<>());
    int ans = lis[0] - lis[1];
    int c = lis[2] + ans;
    if((lis[0] - c) % 2 == 0){
        cout << ans + (lis[0] - c) / 2 << endl;
    }else{
        cout << ans + (lis[0] + 1 - c) / 2 + 1 << endl;
    }
}

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

int main()
{
		int H[10000], W[10000], n, i, j, k;
		while (1) {
				cin >> H[n] >> W[n];
				if (H[n]==0 && W[n]==0) break;
				n++;
		}

		for (i=0; i<n; i++) {
				for (j=0; j<H[i]; j++) {
						for (k=0; k<W[i]; k++) {
								cout << "#";
						}
						cout << "\n";
				}
				cout << "\n";
		}
}

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int x,y,a[7] = {1,3,5,7,8,10,12},b[4] = {4,6,9,11};
  cin >> x >> y;
  if (x == 2 || y == 2){
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < 7; i++){
    if (x == a[i]){
      for (int j = 0; j < 7; j++){
        if (y == a[j]){
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < 4; i++){
    if (x == b[i]){
      for (int j = 0; j < 4; j++){
        if (y == b[j]){
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  cout << "No\n";
  return 0;
}

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

typedef long long ll;
const int N=2e5+5, mod=998244353;
int n;
ll t[4*N];
 
void padd(int i, ll x, int u=1, int s=0, int e=n){ //point adding
 if(s>i or e<i)  return ;
 if(s==e){
   t[u] += x;
   if(t[u]>=mod)  t[u]-=mod;
   return ;
 }
 int v=2*u, w=2*u+1, m=(s+e)/2;
 padd(i,x,v,s,m);
 padd(i,x,w,m+1,e);
 t[u] = t[v] + t[w];
 if(t[u]>=mod)  t[u]-=mod;
}
 
ll csum(int i, int u=1, int s=0, int e=n){
 if(s>i)  return 0;
 if(e<=i) return t[u];
 int v=2*u, w=2*u+1, m=(s+e)/2;
 ll ret = csum(i,v,s,m)+csum(i,w,m+1,e);
 if(ret>=mod) ret -= mod;
 return ret;
}
 
void radd(int l, int r, ll x){ //range adding
 if(x==0) return;
 padd(l, x);
 padd(r+1, -x+mod);
}
 
ll at(int i){
 return csum(i);
}


int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int k;  cin >> n >> k;
  int l[k], r[k];
  for (int i = 0; i < n; ++i){
    cin >> l[i] >> r[i];
  }
  radd(0, 0, 1);
  for (int i = 0; i < n; ++i){
    for (int j = 0; j < k; ++j){
      int lf = i+l[j], rt=i+r[j];
      if(lf>n-1)  continue;
      if(rt>n-1)  rt = n-1;
      radd(lf, rt, at(i));
    }
  }
  cout << at(n-1) << "\n";
  return 0;
}

Measured memory_bytes: 7708
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<int> v(3);
  cin >> v[0] >> v[1] >> v[2];
  sort(v.begin(), v.end());
  cout << (v[0]==5 && v[1]==5 && v[2]==7 ? "YES": "NO") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x; cin >> x;
  ll ans = 1;
  for(int i=2; i<=x; i++) {
    int n = log10(x)/log10(i);
    if(n < 2) continue;
    ans = max(ans, (ll)pow(i, n));
  }
  cout << ans << "\n";
  return 0;
}


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

int n,c[200005];

int lowbit(int x)
{
	return x & (-x);
}

void add(int i, int x)
{
	while(i <= n){
		c[i] += x;
		i += lowbit(i);
	}
}

int sum(int i)
{
	int res = 0;
	while(i > 0){
		res += c[i];
		i -= lowbit(i);
	}
	return res;
}

int main()
{
	
	std::ios::sync_with_stdio(false);cin.tie(0);
	cin >> n;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		int x; cin >> x;		
		add(x,1);
		if(!sum(x - 1)) ans++;
		//cout << ans << endl;
	}		
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int a, b, c;
    cin >> a >> b >> c;
    dump(c - min(a - b, c));
    return 0;
}

Measured memory_bytes: 764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
    int n;
    cin >> n;
    int mae = n / 100;
    int ato = n % 100;
    bool ym = false;
    bool my = false;
    if (ato > 0 && ato < 13){
        ym = true;
    }
    if (mae > 0 && mae < 13){
        my = true;
    }

    if (ym && my) cout << "AMBIGUOUS";
    else if (ym && !my) cout << "YYMM";
    else if (!ym && my) cout << "MMYY";
    else cout << "NA";
    cout << "\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define mp make_pair
#define SIZE 2010
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n;
int main() {
	io(); cin >> n;
	ll num = n / 500ll;
	ll ans = 1000ll * num;
	n -= num * 500ll;
	ll num2 = n / 5ll;
	cout << ans + 5ll * num2;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}


//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main(){
  ll left = 0, right = pow_long(10, 9);
  while(right - left > 1){
    ll mid = (left + right) / 2;
    ll q1, q2;
    char res1, res2;
    q1 = mid;
    q2 = mid * pow_long(10, 9);
    cout << '?' << " " << q1 << endl;
    cin >> res1;
    cout << '?' << " " << q2 << endl;
    cin >> res2;
    if(res1 == 'Y' && res2 == 'Y') right = mid;
    if(res1 == 'Y' && res2 == 'N') left = mid;
    if(res1 == 'N' && res2 == 'Y') left = mid;
    if(res1 == 'N' && res2 == 'N') right = mid;
  }
  cout << '!' << " " << right << endl;
}


Measured memory_bytes: 688
import queue

while (True):
    s = input()
    if s == "-":
        break
    m = int(input())

    q = queue.Queue()
    for i in range(len(s)):
        q.put(s[i])

    for i in range(m):
        h = int(input())
        for j in range(h):
            tmp = q.get()
            q.put(tmp)

    while not (q.empty()):
        print(q.get(), end="")
    print()



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

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

  for( int i = 0; i < s.size(); i++ ){
    if( i % 2 == 0 ){
      cout << s.at(i);
    }
  }
  cout << " " << endl;
}


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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi A(N);
    for(auto &a:A) cin >> a;
    sort(all(A));
    A.erase(unique(all(A)),A.end());
    int M; cin >> M;
    vi B(M);
    for(auto &a:B) cin >> a;
    int cnt=0;
    rep(i,M){
        if(B[i]==*lower_bound(all(A),B[i]) && lower_bound(all(A),B[i])!=A.end()){
            cnt++;
        }   
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4000
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, s = 0;
    cin >> n;
    for (ll a = 1; a < n; a++)
        s += (n - 1) / a;
    cout << s;
}

Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

struct Dinic {
	using Flow = int;
	struct Edge {
		int to, rev;
		Flow cap;
		Edge() {}
		Edge(int to, int rev, Flow cap) :to(to), rev(rev), cap(cap) {}
	};
	int n;
	vector<vector<Edge>> g;
	vector<bool> used;
	vector<int> level;
	vector<int> iter;
	Dinic(int n) :n(n), g(n), used(n), level(n), iter(n) {};
	void addArc(int from, int to, Flow cap) {
		g[from].emplace_back(to, (int)g[to].size(), cap);
		g[to].emplace_back(from, (int)g[from].size() - 1, 0);
	}
	void addEdge(int a, int b, Flow cap) {
		g[a].emplace_back(b, (int)g[b].size(), cap);
		g[b].emplace_back(a, (int)g[a].size() - 1, cap);
	}
	Flow maximumFlow(int s, int t) {
		Flow total = 0;
		while (true) {
			levelize(s);
			if (level[t] < 0)return total;
			fill(iter.begin(), iter.end(), 0);
			Flow f;
			while (true) {
				f = augment(s, t, INF);
				if (f == 0)break;
				total += f;
			}
		}
	}
	Flow augment(int v, int t, Flow f) {
		if (v == t)return f;
		for (int &i = iter[v]; i < g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				Flow d = augment(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					g[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	void levelize(int s) {
		fill(level.begin(), level.end(), -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while (q.size()) {
			int v = q.front(); q.pop();
			for (int i = 0; i < g[v].size(); i++) {
				Edge &e = g[v][i];
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (int N, M, L; cin >> N >> M >> L&&N;) {
		static const int V = 110;
		static int wf[V][V];
		rep(i, 0, N)rep(j, 0, N)wf[i][j] = INF;
		rep(i, 0, N)wf[i][i] = 0;

		rep(i, 0, M) {
			int s, d, w; cin >> s >> d >> w; s--, d--;
			wf[s][d] = wf[d][s] = min(wf[s][d], w);
		}

		rep(k, 0, N)rep(i, 0, N)rep(j, 0, N) {
			if (wf[i][k] != INF&&wf[k][j] != INF)
				wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
		}

		vector<int> P(N); rep(i, 0, N) {
			cin >> P[i];
		}
		vector<int> K(N); rep(i, 0, N) {
			cin >> K[i];
		}

		Dinic dinic(N + N + 2);
		int s = dinic.n - 2, t = s + 1;

		rep(i, 0, N) {
			dinic.addArc(s, i, P[i]);
			dinic.addArc(i + N, t, K[i]);
		}

		rep(i, 0, N)rep(j, 0, N) {
			if (wf[i][j] < L)
				dinic.addArc(i, N + j, INF);
		}

		cout << dinic.maximumFlow(s, t) << endl;

	}
	return 0;
}

Measured memory_bytes: 3368
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n; cin>>n;
	int a[100010]={};
	rep(i,n){
		int b; cin>>b;
		a[b-1]++; a[b]++; a[b+1]++;
	}
	int ans=0;
	rep(i,100010){
		if(a[i]>ans) ans=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


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

int n, x, coun[100001];
int ans;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    while(n-- && cin >> x)
        coun[x]++;
    for(int i = 1 ; i < 100000 ; i++)
        ans = max(ans, coun[i]+coun[i-1]+coun[i+1]);
    cout << ans << endl;
    return 0;
}


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

public class Main
{
	public static void main(String args[])throws IOException
	{
		BufferedReader BR=new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(BR.readLine());
		int min=Integer.MAX_VALUE;
		for(int i=1;i<n;i++)
		{
			int a=i;
			int b=n-i;
			
			/*int c=(int) Math.log10(a)+1;
			int d=(int) Math.log10(b)+1;*/
			
			int temp=0;
			
			while(a!=0)
			{
				temp+=a%10;
				a=a/10;
			}
			
			while(b!=0)
			{
				temp+=b%10;
				b=b/10;
			}
			
			if(temp<min)
			{
				min=temp;
			}
		}
		System.out.println(min);
	}
	
}


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

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void){

  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  qsort(a, n, sizeof(int), cmpnum);
  int size = 1;
  for (int i = 1; i < n; i++) {
    if (a[i] != a[i-1]) {
      size++;
    }
  }
  int number_list[size][2];
  int list_number = 0;
  int number = a[0];
  int count = 0;
  for (int i = 0; i < n-1; i++) {
    count++;
    if (a[i] != a[i+1]) {
      number_list[list_number][0] = number;
      number_list[list_number][1] = count;
      list_number++;
      number = a[i+1];
      count = 0;
    }
  }
  count++;
  number_list[list_number][0] = number;
  number_list[list_number][1] = count;

  int max = number_list[0][1];
  if (number_list[1][0] == number_list[0][0]+1) {
    max += number_list[1][1];
  }
  for (int i = 1; i < size-1; i++) {
    count = number_list[i][1];
    if (number_list[i][0] == number_list[i-1][0]+1) {
      count += number_list[i-1][1];
    }
    if (number_list[i][0] == number_list[i+1][0]-1) {
      count += number_list[i+1][1];
    }
    if (count > max) {
      max = count;
    }
  }
  count = number_list[size-1][1];
  if (number_list[size-1][0] == number_list[size-2][0]+1) {
    count += number_list[size-2][1];
  }
  if (count > max) {
    max = count;
  }
  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 1012
#include<iostream>
#include<math.h>
#include<map>
#include<algorithm>
using namespace std;
map<int,int> dd;

int main(){
	int n;
	scanf("%d",&n);
	
	int s = 0;
	int j = 0;int c;
	map<int,int> :: iterator it = dd.begin();
	for(int i = 0;i<n;i++){
		scanf("%d",&c);
		it = dd.find(c);
		if(it!=dd.end()){
			it->second++;
		}else dd.insert(make_pair(c,1));
		
	}
	it = dd.begin();
	while(it!=dd.end()){
//		cout<<it->first<<" "<<it->second<<"\n";
		if(it->second%2 == 1){
			s++;
		}it++;
	}
//	for(int i = 0;i<j;i++) cout<<dd[i].first<<" "<<dd[i].second<<"\n";cout<<"\n";
	printf("%d\n",s);
	
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
const ll mod = 1e9+7;

int main() {
  ll a, b;
  cin >> a >> b;
  ll ans = max(a+b, a-b);
  ans = max(ans, a*b);
  cout << ans << endl;
}

Measured memory_bytes: 256