akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main() {
    int n;
    scanf("%d", &n);
    int s[201];
    int ans=0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &s[i]);
        if ( s[i] % 2 != 0) {
            printf("0\n");
            return 0;
        }
        s[i] = s[i] / 2;
    }
    ans++;
    while(1) {
        for (int i = 0; i < n; i++) {
            if ( s[i] % 2 != 0) {
                printf("%d\n", ans);
                return 0;
            }else {
                s[i] = s[i] / 2;
            }
        }
        ans++;
    }
   return 0;
}


Measured memory_bytes: 128
def main():
    strings = "abcdefghijklmnopqrstuvwxyz"
    n = int(input())
    dict = {s: 0 for s in strings}
    first = input()
    for s in first:
        dict[s] += 1

    for _ in range(n-1):
        counts = {s: 0 for s in strings}
        S = input()
        for s in S:
            counts[s] += 1

        for s, count in counts.items():
            if count < dict[s]:
                dict[s] = count

    ans = ""
    for s in sorted(dict.keys()):
        count = dict[s]
        ans += s * count

    print(ans)


if __name__ == "__main__":
    main()


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

#define mp make_pair
typedef pair<int,int>pii;
const int N = 1e3;
const int H = 1e4;
int dp[H+100];
pii arr[N+100];

int main()
{
	int n,h;
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&arr[i].first,&arr[i].second);
	}
	for(int i=0;i<=H;i++){
		dp[i] = 1e9;
	}
	dp[0] = 0;
	for(int i=0;i<h;i++){
		for(int j=1;j<=n;j++){
			dp[min(h,i+arr[j].first)] = min(dp[min(h,i+arr[j].first)],dp[i]+arr[j].second);
		}
	}
	printf("%d\n",dp[h]);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int N,L;
    int num[201];
    int i,subnum;
    int origin=0;
    int fixed;
    scanf("%d %d",&N,&L);
    for(i=0;i<N;i++){
        num[i] = L+i;
    }
    if(L>=0){
        subnum = num[0]; // 味が正数だったら
    }else{
        for(i=0;i<N;i++){
            if(num[i] == 0){
                subnum = 0; // 0を含んでいたら
            }
        }
        // subnum = num[N-1];
    }
    if(num[N-1] < 0) subnum = num[N-1];
    for(i=0;i<N;i++){
        origin += L+i;
    }
    fixed = origin - subnum;
    printf("%d\n",fixed);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
#include <numeric>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
	ll n; cin >> n;
    ll ans = n/11*2; n=n%11;
    if(n){
        if(n>=1&&n<=6) ans++;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

using namespace std;

// change min/max
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; }

// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (typename std::vector<T>::const_iterator it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> void inputVec(std::vector<T>& vec) {
	for (typename std::vector<T>::iterator it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

void Main() {
	const int N = inputVal<int>();
	const int K = inputVal<int>();
	std::vector<int> vec(N);
	inputVec(vec);

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (vec[i] >= K) ++cnt;
	}

	outputVal(cnt);

}

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

	return 0;
}

Measured memory_bytes: 640
#include<iostream>

using namespace std;

/**
 * B - Uneven Numbers
 **/

string N;

void solve() {
    int ans = 0;
    int num_n = atoi(N.c_str());
    for (int i = 1; i < num_n + 1; i++) {
        if (to_string(i).length() % 2 == 1) {
            ans += 1;
        }
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S;
    deque<char> deq;
    REP(i, S.size()) {
        deq.push_back(S[i]);
    }
    cin >> Q;
    bool rev = false;
    REP(q, Q) {
        cin >> T;
        if (T == 1) {
            rev ^= 1;
        } else {
            char c;
            cin >> F >> c;
            F--;
            if (rev) {
                F ^= 1;
            }
            if (F == 0) {
                deq.push_front(c);
            } else {
                deq.push_back(c);
            }
        }
    }
    if (rev) {
        for (auto itr = deq.rbegin(); itr != deq.rend(); itr++) {
            cout << *itr;
        }
    } else {
        for (auto itr = deq.begin(); itr != deq.end(); itr++) {
            cout << *itr;
        }
    }
}

Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  for(int i = 0; i < 26; i++){
    if(s.find(i + 'a') >= s.size()){
      cout << char(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

class Edge{
public:
    int a, b, w;
    
    Edge(int a, int b, int w): a(a), b(b), w(w){};
    
    bool operator < (const Edge& right) const {
        return w < right.w;
    }
};

class UnionFind{
private:
    vector<int> _root;
    vector<int> _rank;
    
public:
    UnionFind(int n){
        _root.resize(n);
        _rank.resize(n);
        for(int i=0; i<n; i++){
            _root[i] = i;
            _rank[i] = 0;
        }
    }
    
    int root(int x){
        if(_root[x] == x)
            return x;
        return _root[x] = root(_root[x]);
    }
    
    bool unite(int x, int y){
        if(is_same_group(x, y))
            return false;
        
        x = root(x);
        y = root(y);
        
        if(_rank[x] < _rank[y]){
            _root[x] = y;
        }else{
            _root[y] = x;
            if(_rank[x] == _rank[y])
                _rank[x]++;
        }
        return true;
    }
    
    bool is_same_group(int x, int y){
        return root(x) == root(y);
    }
};


int N, M;
vector<Edge> edges;

int calc(int s){
    UnionFind uf = UnionFind(N);
    int count = 0;
    int res = -1;
    
    for(int i=s; i<M; i++){
        if(uf.unite(edges[i].a, edges[i].b)){
            count++;
            res = edges[i].w;
        }
    }
    return (count == N-1? res-edges[s].w: INF);
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    while(cin>>N>>M, N|M){
        edges.clear();
        
        for(int i=0; i<M; i++){
            int a, b, w; cin >> a >> b >> w; a--; b--;
            edges.push_back(Edge(a, b, w));
        }
        sort(edges.begin(), edges.end());
        
        int ans = INF;
        for(int i=0; i<M; i++){
            ans = min(ans, calc(i));
        }
        cout << (ans == INF? -1: ans) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=52;
struct node{
	int x,y;
}a[N];
int n,x,y,i,ans,las,k,t,j,rx,ry,fa[N];
set<int>s;
int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
signed main(){
	scanf("%lld",&n);
	for (i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y);
	ans=n;
	for (i=1;i<=n;i++)
		for (j=i+1;j<=n;j++){
			x=a[i].x-a[j].x,y=a[i].y-a[j].y;
			for (k=1;k<=n;k++) fa[k]=k;
			for (k=1;k<=n;k++)
				for (t=1;t<=n;t++)
					if (a[k].x+x==a[t].x && a[k].y+y==a[t].y){
						rx=find(k),ry=find(t);
						if (rx!=ry) fa[rx]=ry;
					}
			s.clear();
			for (k=1;k<=n;k++) s.insert(find(k));
			ans=min(ans,(int)s.size());
		}
	printf("%lld",ans);
}

Measured memory_bytes: 256
n=int(input())
count=0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

for i in range(1,n+1):
  if i%2==1:
    d_list=make_divisors(i)
    if len(d_list)==8:
      count+=1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define INF 1000000007
#define N 100005
#define PI 3.14159265
bool compare(pair<ll,ll> i, pair<ll,ll> j) 
{
  return i.S < j.S;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
}
int main()
{
	ll h,a=0,n,b;
  	cin>>h>>n;
  	rep(i,0,n)
    {
      	cin>>b;
      	a+=b;
    }
  	if(h>a)
      	cout<<"No";
  	else
      	cout<<"Yes";
}

Measured memory_bytes: 384
s = input()
k = int(input())
not_1_p = 101
not_1 = 1
for i in range(len(s)):
    if s[i] != "1":
        not_1 = s[i]
        not_1_p = i + 1
        break
if k < not_1_p:
    print(1)
else:
    print(not_1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	makei(a);
	makei(b);
	yn((a*b) % 2 == 1);
}

Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    s = str(readline().rstrip().decode('utf-8'))
    w = s.count(".")
    b = 0
    mc = w + b
    for i in range(n):
        if s[i] == "#":
            b += 1
        else:
            w -= 1
        mc = min(mc, b + w)
    print(mc)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 41712
matlix=list(map(int,input().split()))
n=matlix[0]
m=matlix[1]

A=[]
b=[]
C=[]
c=0

for i in range(n):
    A.append(list(map(int,input().split())))

for i in range(m):
    b.append(int(input()))

for i in range(n):
    for j in range(m):
        c=c+A[i][j]*b[j]
    print(c)
    c=0



Measured memory_bytes: 6012
#region Using directives
using System;
using static System.Console;
using static System.Convert;
using System.Collections.Generic;
using System.Linq;
#endregion

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            if (s.Length >= 4)
                if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I')
                    WriteLine("Yes");
                else
                    WriteLine("No");
            else
                WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        String[] S = new String[n];

        for(int i=0; i<n; i++){
            S[i] = sc.next();
            int lx = S[i].length();
            ArrayList<String> al = new ArrayList<String>();
            for(int j=0; j<lx; j++){
                al.add(String.valueOf(S[i].charAt(j)));
            }
            Collections.sort(al);
            S[i] = "";
            for(int j=0; j<lx; j++){
                S[i] += al.get(j);
            }
        }
        String ans = S[0];
        for(int i=1; i<n; i++){
            int ls = S[i].length();
            int la = ans.length();
            String b = "";
            int x = 0;
            for(int j=0; j<la; j++){
                for(int k=x; k<ls; k++){
                    if(ans.charAt(j)==S[i].charAt(k)){
                        b += String.valueOf((char)ans.charAt(j));
                        x = k +1;
                        break;
                    }
                }
            }
            ans = b;
        }

        ArrayList<String> list = new ArrayList<String>();
        int l = ans.length();
        if(l>1){
            for(int i=0; i<l-1; i++){
                list.add(ans.substring(i, i+1));
            }
            list.add(ans.substring(l - 1));
            Collections.sort(list);
            ans = "";
            for(int i=0; i<l; i++){
                ans += list.get(i);
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 24020
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.nextLine();

		int map[][] = new int[h + 2][w + 2];

		Arrays.fill(map[0], 1);
		Arrays.fill(map[h + 1], 1);
		int defaultWalls = 0; 
		for (int i = 0; i < h; i++) {
			map[i + 1][0] = 1;
			map[i + 1][w + 1] = 1;
			String s = sc.nextLine();
			for (int j = 0; j < w; j++) {
				if (s.charAt(j) == '#') {
					map[i + 1][j + 1] = 1;
					defaultWalls++;
				}
			}
		}

		int cost[][] = new int[h + 2][w + 2];
		for (int i = 0; i < h + 2; i++) {
			Arrays.fill(cost[i],h*w*2);
		}
		
		PriorityQueue<E> queue = new PriorityQueue<E>();
		queue.add(new E(1,1,1));
		for (;;) {
			if(queue.isEmpty()){
				System.out.println(-1);
				return;
			}
			E now = queue.poll();
			if(now.cost >= cost[now.i][now.j]){
				continue;
			}
			cost[now.i][now.j] = now.cost;
			if(now.i == h && now.j == w){
				break;
			}
			
			int dx[] = {1,-1,0,0};
			int dy[] = {0,0,1,-1};

			for(int i = 0 ; i< 4; i++){
				int ii = now.i + dx[i];
				int jj = now.j + dy[i];
				if(map[ii][jj] == 0){
					if(now.cost + 1 < cost[ii][jj]){
						queue.add(new E(ii,jj,now.cost+1));
					}
				}
			}
		}
		System.out.println(h*w-cost[h][w]-defaultWalls);
	}

	class E implements Comparable<E> {
		int i;
		int j;
		int cost;

		E(int ii, int jj, int cc) {
			i = ii;
			j = jj;
			cost = cc;
		}

		@Override
		public int compareTo(E o) {
			return this.cost - o.cost;
		}
	}

}

Measured memory_bytes: 21844
N, Q = map(int, input().split())
s = input()

def conv(t, d):
	return t, (1 if d == 'R' else -1)

*queries, = (conv(*input().split()) for i in range(Q))

def simulate(i, left=True):
	if i < 0:
		return left
	elif N <= i:
		return not left
	
	for t, d in queries:
		if t == s[i]:
			i += d
		if i < 0:
			return left
		elif N <= i:
			return not left
	return False

def search(ok=0, ng=N+1, left=True):
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if simulate(mid, left):
			ok = mid
		else:
			ng = mid
	return ok

print(N - (1 + search(-1, N, True) + (N - search(N, -1, False))))


Measured memory_bytes: 17736
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    int a,b;
    cin>>a>>b;
    if(a>=10)cout<<b;
    else cout<<b+(100*(10-a));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string s;
  cin>>s;


  bool cond1=false;
  bool cond2=false;
  bool cond3=true;

  if(s.at(0)=='A')
    cond1=true;

  int cnt=0;
  int index=0;
  for(int i=2;i<=s.size()-2;i++){
    if(s.at(i)=='C'){
      cnt++;
      index=i;
    }
  }
  if(cnt==1)
    cond2=true;


  for(int i=0;i<s.size();i++){
    if( (i!=0) && (i!=index) && isupper(s.at(i))){
      cond3=false;
      break;
    }
  }

  if(cond1&&cond2&&cond3)
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;

	return 0;
}

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

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()

template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

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

const int inf = 1e9;
const ll linf = 3e18;

int sum[1000001];
bool prime[1000001];

void sieve()
{
    fill_n(prime, 1000001, true);

    prime[1] = false;

    for (int i = 2; i <= 1000000; ++i) {
        if (!prime[i]) continue;
        sum[i] = 1;
        for (int k = i + i; k <= 1000000; k += i) {
            prime[k] = false;
        }
    }
}

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

    sieve();

    for (int i = 2; i <= 1000000; ++i) sum[i] += sum[i - 1];

    int n;
    
    while (cin >> n) {
        cout << sum[n] << endl;
    }
}

Measured memory_bytes: 6076
R,C,K = map(int, input().split())
a = [[0] * (C+1) for i in range(R+1)]
dp = [[[0] * (C+1) for i in range(R+1)] for j in range(4)]

for i in range(K):
  r,c,v = map(int, input().split())
  r -= 1
  c -= 1
  a[r][c] = v 
  
for i in range(R):
  for j in range(C):
    for k in range(2,-1,-1):
      dp[k+1][i][j] = max(dp[k+1][i][j], dp[k][i][j] + a[i][j])
    for k in range(4):
      dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j])
      dp[0][i+1][j] = max(dp[0][i+1][j], dp[k][i][j])
ans = 0
for k in range(4):
  ans = max(ans, dp[k][R-1][C-1])
  
print(ans)
  


Measured memory_bytes: 430208
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        int ans = 0;
        for(int i = 1; i <= N; i+=2){
            for(int j = 1; j <= N; j++){
                if(i%j == 0){
                    count++;
                }
            }
            if(count == 8){
                ans++;
            }
            count = 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll X, K, D;
  cin >> X >> K >> D;
  if (X < 0) X *= -1;
  if ((X / D) >= K) {
    cout << X - (D * K) << endl;
  } else {
    if ((K - (X / D)) % 2 == 0) {
      cout << X % D << endl;
    } else {
      cout << abs((X % D) - D) << endl;
    }
  }
}

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

int main() {
  int N,a,b;
  cin >> N;
  long int sum = 0;
  
  for (int i = 1; i < N + 1; i++) {
    a = i % 3;
    b = i % 5;
    if (a != 0 && b != 0) {
      sum = sum + i;
    }
  }
  
  cout << sum << endl;
}
  
  


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool ok = (abs(a-c)<=d) || (abs(a-b)<=d&&abs(b-c)<=d);
  cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  vector<Pair> A;
  for (int64_t i = 0; i < N; ++i) {
    int64_t a;
    cin >> a;
    A.emplace_back(Pair(a, 1));
  }
  for (int64_t j = 0; j < M; ++j) {
    int64_t b, c;
    cin >> b >> c;
    A.emplace_back(Pair(c, b));
  }
  sort(A.begin(), A.end(), std::greater<Pair>());

  int64_t result = 0;
  for (int64_t i = 0; i < static_cast<int64_t>(A.size()); ++i) {
    const int64_t card = A[i].first;
    const int64_t count = A[i].second;
    const int64_t counted = min(N, count);
    result += card * counted;
    N -= counted;
    if (N <= 0) {
      break;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 6384
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	double x;
	cin>>n;
	if(n%2==1) x=(n+1)/2.0/n;
	else x=n/2.0/n;
	cout<<fixed<<setprecision(10);
	cout<<x<<endl;
	return 0;
} 

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

using namespace std;

#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MS multiset
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

const db eps = 0.00001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int M = 1125;

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    while (b <= a){
        b *= 2;
        k--;
    }
    while (c <= b){
        c *= 2;
        k--;
    }

    if (k >= 0) cout << "Yes"; else
        cout << "No";

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main() {
	int w, h, x, y, r;
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

	if (x - r >= 0 && y - r >= 0) {
		if (x + r <= w && y + r <= h) {
			printf("Yes\n");
			return 0;
		}
	}

	printf("No\n");
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> graph(n);
    for(i = 0;i < m;++i){
        ll u,v;
        cin >> u >> v;
        --u;    --v;
        graph.at(u).push_back(v);
    }
    ll s,t;
    cin >> s >> t;
    --s;    --t;
    queue<pair<ll,ll>> que;
    vector<vector<ll>> vdis(n,vector<ll>(3,-1));
    ll top = s;
    vdis.at(top).at(0) = 0;
    que.emplace(top,0);
    while(!que.empty()){
        auto x = que.front();
        que.pop();
        ll now = x.first;
        ll dist = x.second;
        for(i = 0;i < graph.at(now).size();++i){
            ll next = graph.at(now).at(i);
            if(vdis.at(next).at((dist+1)%3) == -1){
                vdis.at(next).at((dist+1)%3) = dist+1;
                que.emplace(next,dist+1);
            }
        }
    }
    if(vdis.at(t).at(0) != -1){
        cout << vdis.at(t).at(0)/3 << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

int main() {
	string s;
	cin >> s;
	int count=0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'o')count++;
	}
	count += 15 - s.length();

	if (count >= 8)cout << "YES";
	else cout << "NO";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=110;
int i,j,k,n,m,ma,mi;
int a[N],nm[N];
int main() {
	scanf("%d",&n);
	mi=n;
	for (i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		nm[a[i]]++;
		ma=max(ma,a[i]);
		mi=min(mi,a[i]);
	}
	k=(ma+1)/2;
	if (mi<k) return puts("Impossible"),0;
	if (ma&1) {
		if (nm[k]!=2) return puts("Impossible"),0;
	}
	else {
		if (nm[k]!=1) return puts("Impossible"),0;
	}
	for (i=k+1;i<=ma;i++) if (nm[i]<2) return puts("Impossible"),0;
	puts("Possible");
}

Measured memory_bytes: 128
def main():
    n, w = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(n)]
    dp = [[None]*(w+1) for _ in range(n+1)]
    dp[0] = [0]*(w+1)
    for i in range(1, n+1):
        wi, vi = wv[i-1]
        di = dp[i]
        dio = dp[i-1]
        for j in range(wi):
            di[j] = dio[j]
        for j in range(wi, w+1):
            di[j] = max(dio[j], dio[j-wi]+vi)
    print(dp[-1][-1])

if __name__ == "__main__":
    main()

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

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

	int ans = 0;
	if (a < b) {
		ans = b - a - w;
	} else {
		ans = a - b - w;
	}
	if (ans < 0) {
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int W = 0, H = 0, x = 0, y = 0, r = 0;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1160
n = int(input())
nList = []
for i in range(1, n // 2 + 1):
    aSum = 0
    bSum = 0
    for j in range(len(str(i))):
        aSum += int(str(i)[j])
    for j in range(len(str(n - i))):
        bSum += int(str(n - i)[j])
    nList.append(aSum + bSum)
print(min(nList))

Measured memory_bytes: 3480
//Malfurion_Drake
#include<bits/stdc++.h>
#define Maxn 100005
using namespace std;

int n,m,a[Maxn],b[Maxn],c[Maxn];

template<typename Drake>
void read(Drake &x){
	x=0;char ch=getchar();bool f=1;
	while(!isdigit(ch)){
		if(ch=='-')f^=1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=(2*f-1);
}

template<typename Drake>
void write(Drake x){
	if(x<0){x=-x;putchar('-');}
	if(x>9)write(x/10);
	putchar(x%10+'0');
}

template<typename Drake>
void writeln(Drake x){
	write(x);
	puts("");
}

void init(){
	read(n);
	for(int i=1;i<=n;++i){
		read(a[i]);read(b[i]);read(c[i]);
	}
}

int main(){
	init();
	int id=1;
	for(int i=1;i<=n;++i)
	if(c[i]>0){
		id=i;break;
	}
	
	for(int i=0;i<=100;++i){
		
		for(int j=0;j<=100;++j){
			bool tag=1;
			int dis=abs(a[id]-i)+abs(b[id]-j);
			int H=dis+c[id];
			for(int ii=1;ii<=n;++ii){
				if(max(H-abs(a[ii]-i)-abs(b[ii]-j),0)!=c[ii])
				{tag=0;break;}
			}
			if(tag){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
			tag=1;
			H=c[id]-dis;
			for(int ii=1;ii<=n;++ii){
				if(max(H-abs(a[ii]-i)-abs(b[ii]-j),0)!=c[ii])
				{tag=0;break;}
			}
			if(tag){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
			tag=1;
			H=dis-c[id];
			for(int ii=1;ii<=n;++ii){
				if(max(H-abs(a[ii]-i)-abs(b[ii]-j),0)!=c[ii])
				{tag=0;break;}
			}
			if(tag){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
		}
		
	}
	
	return 0;
}

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

int main()
{
    int n,r;
    cin>>n>>r;
    if(n>=10)
    {
        cout<<r;
    }
    else
    {
        int m=100*(10-n);
        cout<<m+r;
    }
    return 0;
}


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

int main(){
    ll R, G, B, N;
    cin >> R >> G >> B >> N;

    ll ans = 0;
    for(ll r = 0; r * R <= N; r++){
        for(ll g = 0; g * G <= N; g++){
            if(r * R + g * G > N) continue;
            ll num = N - r * R - g * G;
            if(num % B == 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

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

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  int N; cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S[i];
  
  map<string, int> vec;
  rep(i, N){
    vec[S[i]]++;
  }
  int max = 0;
  rep(i, N){
    if (vec[S[i]] > max) max = vec[S[i]];
  }
  set<string> ans;
  rep(i, N){
    if (vec[S[i]] == max) ans.insert(S[i]);
  }
  for (auto x : ans){
    cout << x << endl;
  }
}


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

int main(){
  int start[2], end[2];
  for(int i=0;i<2;i++){
    cin >> start[i] >> end[i];
  }
  sort(start, start+2, greater<int>());
  sort(end, end+2);
  
  int diff = end[0] - start[0];
  if(diff < 0) cout << 0 << endl;
  else cout << diff << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    int N;
    cin >> N;
    vector<vector<ll>> dp(N, vector<ll>(3));
    REP(i, N) cin >> dp[i][0] >> dp[i][1] >> dp[i][2];

    REP(i, 101)REP(j, 101){
        ll h;
        REP(k, N) if (dp[k][2] > 0){
            h = dp[k][2] + abs(dp[k][0] - i) + abs(dp[k][1] - j);
            break;
        }
        bool flag = true;
        REP(k, N){
            if (max(h - abs(dp[k][0] - i) - abs(dp[k][1] - j), 0LL) != dp[k][2]){
                flag = false;
                break;
            }
        }
        if (flag){
            cout << i << " " << j << " " << h << endl;
            return 0;
        }
    } 

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <class It> string join(It i1, It i2)
{
    ostringstream ss;
    for (auto it = i1; it != i2; ++it)
        ss << ((it == i1) ? "" : ", ") << (*it);
    return ss.str();
}

#ifdef DEBUG
#define Dump(x) cerr << #x << " = " << x << endl;
#define Dumps(x) cerr << #x << " : { " << join(x.begin(), x.end()) << " }" << endl;
#else
#define Dump(x)
#define Dumps(x)
#endif

using count_t = pair<long, long>;
ostream& operator << (ostream &os, const count_t &c)
{
    os << "(" << c.first << ", " << c.second << ")";
    return os;
}


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

    vector<int> V(N);
    for (auto &v : V)
        cin >> v;
    
    unordered_map<long, long> c_odd, c_even;
    for (int i = 0; i < N; ++i)
    {
        auto *c = (i % 2) ? &c_odd : &c_even;
        auto r = c->insert(make_pair(V[i], 1));
        if (not r.second)
            ++(r.first->second);
    }

    vector<count_t> v_odd(c_odd.begin(), c_odd.end());
    vector<count_t> v_even(c_even.begin(), c_even.end());
    sort(v_odd.begin(), v_odd.end(),
         [](const count_t &x, const count_t &y) { return x.second > y.second; });
    sort(v_even.begin(), v_even.end(),
         [](const count_t &x, const count_t &y) { return x.second > y.second; });
    Dumps(v_odd);
    Dumps(v_even);

    int n_odd((N + 1) / 2), n_even(N / 2);
    v_odd.push_back(make_pair(-1, 0));
    v_even.push_back(make_pair(-1, 0));
    
    if (v_odd[0].first != v_even[0].first)
    {
        n_odd -= v_odd[0].second;
        n_even -= v_even[0].second;
    }
    else 
    {
        int n_odd1 = n_odd - v_odd[0].second;
        int n_odd2 = n_odd - v_odd[1].second;
        int n_even1 = n_even - v_even[1].second;
        int n_even2 = n_even - v_even[0].second;
        if (n_odd1 + n_even1 < n_odd2 + n_even2)
        {
            n_odd = n_odd1;
            n_even = n_even1;
        }
        else
        {
            n_odd = n_odd2;
            n_even = n_even2;
        }
    }
    Dump(n_odd);
    Dump(n_even);

    cout << (n_odd + n_even) << endl;
}


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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int r = a.size() + b.size();
	for (int i = 0; i < r; i++) {
		if (i % 2 == 0) {
			cout << a[i / 2];
		} else {
			cout << b[i / 2];
		}
	}
	cout << "\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int K,N,A[200000],maxsa=-1;
    
    scanf("%d %d", &K, &N);
    scanf("%d", &A[0]);
    
    for(int i = 1; i < N; i++)
    {
        scanf("%d", &A[i]);
        maxsa = (A[i]-A[i-1] > maxsa)? (A[i]-A[i-1]):maxsa;
    }
    
    maxsa = (K-A[N-1]+A[0] > maxsa)? (K-A[N-1]+A[0]):maxsa;
    
    printf("%d\n", K-maxsa);
}


Measured memory_bytes: 1024
'use strict'

const main = (INPUT) => {
  const S = INPUT.split('\n')[0]
  const mae = S.slice(0, 2)
  const usiro = S.slice(2)
  if (mae >= '01' && mae <= '12' && usiro >= '01' && usiro <= '12') {
    console.log('AMBIGUOUS')
  } else if (mae >= '00' && mae <= '99' && usiro >= '01' && usiro <= '12') {
    console.log('YYMM')
  } else if (mae >= '01' && mae <= '12' && usiro >= '00' && usiro <= '99') {
    console.log('MMYY')
  } else {
    console.log('NA')
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include <iostream>
#include <climits>

const int MAX = 1<<19;

using namespace std;

int n;
int tree[MAX];

void init(int an){
  n = 1;
  while(n < an){
    n *= 2;
  }
  for(int i=0;i < 2*n-1;i++){
    tree[i] = INT_MAX;
  }
}

void update(int i,int x){
  i += n - 1;
  tree[i] = x;
  while(i > 0){
    i = (i-1)/2;
    tree[i] = min( tree[2*i+1], tree[2*i+2] );
  }
}

int query(int a,int b,int k,int l,int r){
  if(b <= l || r <= a){
    return INT_MAX;
  }else if(a <= l && r <= b){
    return tree[k];
  }else{
    return min(
      query( a, b, 2*k+1, l, (l+r)/2),
      query( a, b, 2*k+2, (l+r)/2, r)
    );
  }
}

int main(){
  int an, q, com, x, y;
  cin >> an >> q;
  init(an);
  while(cin >> com >> x >> y){
    if(com){
      cout << query( x, y+1, 0, 0, n) <<endl;
    }else{
      update( x, y);
    }
  }
  return 0;
}

Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
int m1,m2;
string mp[5][5],tmp[5][5];
int A[30],B[30];
int n;

int Count(int z,int y,int x){
  int res=0;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int nx=x+j,ny=y+i;
      if(nx<0||ny<0||nx>=5||ny>=5) continue;
      if((i!=0||j!=0)&&(mp[z][ny][nx])=='1')res++;
      if(z&&mp[z-1][ny][nx]=='1') res++;
      if(z<4&&mp[z+1][ny][nx]=='1')res++;
    }
  return res;
}

void solve(){
  while(n--){
    for(int i=0;i<5;i++)for(int j=0;j<5;j++) tmp[i][j]=mp[i][j];

    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++)
	for(int k=0;k<5;k++){
	  int cnt=Count(i,j,k);
	  for(int l=0;l<m1&&mp[i][j][k]=='0';l++) if(cnt==A[l]) tmp[i][j][k]='1';
	  int f=(mp[i][j][k]=='1');
	  for(int l=0;l<m2&&mp[i][j][k]=='1';l++) if(cnt==B[l]) f=0;
	  if(f) tmp[i][j][k]='0';
	}
    for(int i=0;i<5;i++)for(int j=0;j<5;j++) mp[i][j]=tmp[i][j];
  }
}


int main(){
  int cnt=0;
  while(cin>>n,n){
    cnt++;
    if(cnt!=1)cout <<endl;
    for(int i=0;i<5;i++)
      for(int j=0;j<5;j++) cin>>mp[i][j];

    cin>> m1;
    for(int i=0;i<m1;i++) cin>>A[i];
    cin>>m2;
    for(int i=0;i<m2;i++) cin>>B[i];
    solve();
    cout <<"Case "<<cnt<<":"<<endl;
    for(int i=0;i<5;i++){
      for(int j=0;j<5;j++)cout << mp[i][j]<<endl;
      if(i!=4)cout <<endl;
    }
  }
  
  return 0;
}

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

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a) cout<<k<<endl;
  else if(k<=a+b) cout<<a<<endl;
  else cout<<a-(k-a-b)<<endl;
  return 0;
}


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

using namespace std;

#if !defined(ONLINE_JUDGE) && 1
#define DEBUG(x) cerr << " --- " << #x << "\t" << (x) << endl;
#define DEBUG2(x) cerr << "DEBUG: " << x << endl;
#else
#define DEBUG(x)
#define DEBUG2(x)
#endif

using ll = long long;
using uint = unsigned int;
using rl = double;
using pii = pair<int, int>;

const int MAXN = 2 * 100009;
int n;
int dp[MAXN];
int c[MAXN];

const int modd = 1000000000 + 7;

int add(int a, int b)
{
    a += b;
    if (a >= modd)
        a -= modd;
    return a;
}

int mult(int a, int b)
{
    ll c = a * (ll)b;
    if (c >= modd)
        c %= modd;
    return c;
}

int acnt[MAXN];
int ccnt[MAXN];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", c + i);
    }

    int pos = 0;
    acnt[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        if (c[i] == c[i - 1])
            continue;
        pos++;
        int col = c[i];

        acnt[pos] = add(acnt[pos - 1], ccnt[col]);
        ccnt[col] = add(ccnt[col], acnt[pos - 1]);
    }
    printf("%d\n", acnt[pos]);
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main() {
	int K;
	int A;
	int B;
	int a;
	int b;
	cin >> K >> A >> B;
	b = B / K;
	a = A / K;
	if (b != a) {
		cout << "OK";
	}
	else {
		if (B == b*K|| A==a*K) {
			cout << "OK";
		}
		else {
			cout << "NG";
		}
	}
	return 0;
}

Measured memory_bytes: 3636
// Author -> Preeyadarshee Dev
//
// train hard win easy :D
// nik is love
// nik is motivation
//
// do modulo operations very carefully
// try to avoid binary search, use linear search preferrably to make calculations easier
// always make your custom binary search and watch out for overflows
// read the problems carefully
// never rely on floating point calculation
#include <bits/stdc++.h>
#define mp                    make_pair
#define pb                    push_back
#define ll                   long long
#define ss                       second
#define ff                        first
#define fr(i,a,b)   for(ll i=a;i<b;i++)
#define f(i,n)                fr(i,0,n)
#define rf(i,b,a) for(ll i=b-1;i>=a;i--)
#define r(i,n)                rf(i,n,0)
#define inf                  1000000007
#define eps                  0.000000000000001
#define endl                       '\n'
#define sz(a)                int((a).size())
#define all(c)               (c).begin(),(c).end()
#define tr(c,i)              for(typeof(c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x)         ((c).find(x) != (c).end())
#define cpresent(c,x)        (find(all(c),x) != (c).end())
#define pi                   pair<int,int>
#define pll                  pair < ll , ll >
#define PI                   3.141592653589793238462643383279502884197169399375105820974944592307816406286
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef vector< int > vi;
typedef vector< vi > vvi;
int dx[8]={-2,-2,1,-1,-1,-1,1,1};
int dy[8]={1,-1,-2,-2,-1,1,-1,1};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //ifstream fin;
    //ofstream fout;
    //fin.open("input.txt");
    //fout.open("output.txt");
    int n;
    cin>>n;
    vector<long double> v(n);
    f(i,n)
    {
        cin>>v[i];
    }
    vector<vector<long double>> dp(n+1,vector<long double> (n+1,0));
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j-1>=0)
            {
                dp[i][j]=v[i-1]*dp[i-1][j-1];
            }
            dp[i][j]+=(1-v[i-1])*dp[i-1][j];
        }
    }
    long double ans=0;
    for(int i=1;i<=n;i++)
    {
        if(2*i>n)
        {
            ans=ans+dp[n][i];
        }
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 141056
#include <iostream>
#include <algorithm> 
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;

using ll = long long;

int main() {
	int n;
	cin >> n;
	char s[51];
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
			ans++;
	}
	cout << ans;
	return 0;
}


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

typedef array<int, 6> dice;

int main()
{
    dice d;
    enum {N, S, E, W};
    array<dice, 4> rot = {
        1, 5, 2, 3, 0, 4,
        4, 0, 2, 3, 5, 1,
        3, 1, 0, 5, 4, 2,
        2, 1, 5, 0, 4, 3};

    for (int &x: d)
        cin >> x;

    for (char c; cin >> c;) {
        int r; 
        switch (c) {
        case 'N': r = N; break;
        case 'S': r = S; break;
        case 'E': r = E; break;
        case 'W': r = W; break;
        }

        dice res;
        for (size_t i = 0; i < res.size(); i++)
            res[i] = d[rot[r][i]];
        d = move(res);
    }

    cout << d[0] << endl;

    return 0;
}


Measured memory_bytes: 3092
a, b, c = map(int, raw_input().split())
total = a + b + c
if total % 2 != 0:
  print('No')
else:
  half = total // 2
  if a == half or b == half or c == half or a+b == half or b+c == half or a+c == half:
    print('Yes')
  else:
    print('No')


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


void solve(long long N, long long X, std::vector<long long> m){
    long long total = X - accumulate(m.begin(), m.end(), 0);
    long long min_val = *std::min_element(m.begin(), m.end());
    //cout << total << " " << min_val << " " << total / min_val << endl;
    cout << N + total / min_val << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    std::vector<long long> m(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&m[i]);
    }
    solve(N, X, std::move(m));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;    
        for(int j=0;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0' && j!=0){
                    cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}

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

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

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int cnt = x;
  rep(i, n) {
    int a;
    cin >> a;
    cnt += 1 + (d - 1) / a;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256