akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;


long long A, B, K;

void read() {
    cin >> A >> B >> K;
}


void work() {
    if (A >= K) {
        cout << A - K << ' ' << B << endl;
    } else {
        cout << 0 << ' ' << max(0LL, B - (K - A)) << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

PQR = LI()
PQR.sort(reverse=True)
print(sum(PQR[1:]))


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

const int MAXN=100000;
const ll p = 7LL + ll(1e9); // both of these may need to be edited, problem dependent
 
ll fac[MAXN+1];
ll inv_fac[MAXN+1];
 
ll mod_exp(ll a, ll b)
{
	if(b==0LL) return 1LL;
 
	ll ans = mod_exp(a,ll(b/2LL));
	ans*=ans;
	ans%=p;
 
	if(b%2LL==1LL) ans*=a;
	ans%=p;
 
	return ans;
}
 
ll C(int n, int k)
{
	if(k<0 || k>n) return 0;

	ll ans = fac[n]*inv_fac[k];
	ans%=p;
	return (ans*inv_fac[n-k])%p;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif
 
	int n;
	cin>>n;

	vector<ll> addvals;
	vector<ll> minvals;

	for(int i=0; i<n; i++)
	{
		ll x,y;
		cin>>x>>y;
		addvals.push_back(x+y);
		minvals.push_back(x-y);
	}

	sort(all(addvals));
	sort(all(minvals));

	ll ans = addvals[len(addvals)-1]-addvals[0];
	ans = max(ans, minvals[len(minvals)-1]-minvals[0]);

	cout << ans << "\n";
}

Measured memory_bytes: 6744
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long A, long long B){
    if(A < 10 && B < 10)
        cout << A*B << endl;
    else
        cout << -1 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

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

class range {
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& rhs) {return val < rhs.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int e) : i({0, 1}), n({e, 1}) {}
  range(int b, int e) : i({b, 1}), n({e, 1}) {}
  range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int dis(int x, int y) {
    return x*x+y*y;
}
int main(){
    iostream_init();
    
    int N;
    cin >> N;
    vector<int> f(N);
    vector<int> a(N);
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    REP(i, N) {
        cin >> f[i] >> a[i] >> t[i] >> x[i] >> y[i];
    }

    pair<int, int> ans[2];
    ans[0].first = INT_MIN;
    ans[1].first = INT_MIN;
    REP(i, N-1) {
        if(t[i] == t[i+1] && a[i] != a[i+1]) {
            int tm = -(f[i+1] - f[i]);
            int dt = dis(x[i+1]-x[i], y[i+1]-y[i]);
            if(ans[t[i]] < make_pair(dt, tm)) {
                ans[t[i]] = make_pair(dt, tm);
            }
        }
    }

    REP(i, 2){
        int tm = -ans[i].second;
        int dt = ans[i].first;

        if(dt == INT_MIN) {
            cout << "-1 -1" << endl;
        } else {
            cout << sqrt(dt) << " " << tm/60.0 << endl;
        }
    }

    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 1280
N,L= map(int,input().split())

apples = [x+1 for x in range(N)]
tastes =  [L+i-1 for i in apples]
#print(apples,tastes)
pie = sum(tastes)
absmin = max(abs(tastes[-1]),abs(tastes[0]))
#print(absmin)
for i in tastes:
    if abs(i) < abs(absmin):
        absmin = i
print(pie-absmin)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> A;


int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,d,e,c;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);


    cin >> n >> x;

    if(n == x){

        cout << "Yes\n";

        for(c1 = 0; c1 < 2*n-1; c1++){
            cout << c1+1 << "\n";
        }
        return 0;
    }

    if(x != 1 && x != 2*n-1){

        cout << "Yes\n";

        ll bort;

        if(x == 2*n-2){

            bort = 2;
        }
        else{

        bort = x+2;
        }
        ll l = 0;
        ll nu = 1;
        for(c1 = 1; c1 <= 2*n-1; c1++){

            if(c1 != 1 && c1 != x && c1 != x+1 && c1 != bort){cout << c1 << "\n";l++;}
            nu = c1;
            if(l == n-3)break;

        }

        if(x == 2*n-2){

        cout << 1 << "\n";
        cout << x << "\n";
        cout << x+1 << "\n";
        cout << 2 << "\n";

        }
        else{
        cout << x+2 << "\n";
        cout << 1 << "\n";
        cout << x << "\n";
        cout << x+1 << "\n";

        }

        for(c1 = nu+1; c1 <= 2*n-1; c1++){

            if(c1 != 1 && c1 != x && c1 != x+1 && c1 != bort){cout << c1 << "\n";l++;}

        }

    }
    else{

        cout << "No\n";

    }


	return 0;
}


Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#define stop(x) {cout<<x<<endl;exit(0);}
#define all(x) x.begin(),x.end()
#define szz(s) int(s.size())
#define endl '\n'
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
typedef long long ll;
using namespace std;

void file() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    if (freopen("input.txt", "r", stdin));
    if (freopen("output.txt", "w", stdout));
#endif
}


int main()
{
    file();

    ll n, m, sum = 0;
    cin >> m >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        sum += a;
    }
    cout << max(m - sum, -1LL) << endl;


}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = inf;
	rep(bit, (1 << n)) {
		int tmp = 1;
		rep(i, n) {
			if (bit & (1 << i)) tmp *= 2;
			else tmp += k;
		}
		mins(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int N,M,r,sum=0;
  scanf("%d",&N);
  scanf("%d",&M);
  for(int i=0;i<M;i++){
  scanf("%d",&r);
    sum += r;
  }
  if(sum > N)
    printf("-1");
  else
    printf("%d",N-sum);


return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		String N = scan.next();
		
			if(N.contains("7")) {
				System.out.println("Yes");
			}
			else {
				System.out.println("No");
			}		
	

	}
}


Measured memory_bytes: 26892
#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() {
    ll N;
    cin >> N;

    ll n = sqrt(N);

    ll m = N;

    REP(i, n+1){
        if (i == 0) continue;
        if (N % i == 0){
            m = min(m, i + (N / i) - 2);
            //cout << m << " " << i << endl;
        }
    }
    cout << m << endl;

    return 0;
}

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

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

    if(s[3] == s[2] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
    cout << endl;
}

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

namespace ConsoleApp11
{
    class Class6
    {
        public static void Main()
        {
            int N =int.Parse( Console.ReadLine());
            var A = Console.ReadLine().Split();
            var q = A.Select((a, b) => new { c = int.Parse(a), d = b }).OrderBy(x => x.c).Select(x => x.d+1);
            Console.WriteLine(string.Join(" ", q));
        }
    }
}


Measured memory_bytes: 34904
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> P;
vector<vector<char>> maze;
int H, W;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int bfs(int sx, int sy, int gx, int gy) {
    queue<P> que;
    vector<vector<int>> d(H, vector<int>(W, INF));
    que.push(P(sx, sy));
    d[sy][sx] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy) break;
        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && W > nx && 0 <= ny && H > ny && maze[ny][nx] != '#' && d[ny][nx] == INF) {
                que.push(P(nx, ny));
                d[ny][nx] = d[p.second][p.first] + 1;
            }
        }
    }
    return d[gy][gx];
}

int main()
{
    cin >> H >> W;
    maze = vector<vector<char>>(H, vector<char>(W));

    rep(i, H) {
        rep(j, W) {
            cin >> maze[i][j];
        }
    }

    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            rep(k, H) {
                rep(l, W) {
                    if (maze[i][j] != '#' && maze[k][l] != '#') {
                        ans = max(ans, bfs(j, i, l, k));
                    }
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
#sys.setrecursionlimit(200000)
#input = sys.stdin.readline
#n = int(input())
#x,y = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a == [1,4,7,9]:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3444
#include<stdio.h>
int main()
{
	int i,n,a[20],b[20],c[20],sum=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	for(i=0;i<n;i++)
		scanf("%d",&b[i]);
	for(i=0;i<n-1;i++)
		scanf("%d",&c[i]);

	for(i=0;i<n;i++)
	{
		sum+=b[a[i]-1];
		if(i<n-1)
		{
		if((a[i+1]-a[i])==1)
			sum+=c[a[i]-1];
		}
	}
	printf("%d",sum);
	return 0;
}


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

using namespace std;

int main()
{
    int n, i, j, a, k, cnt = 0;
    string s;
    cin >> s;

    if(s == "Sunny")
        cout << "Cloudy\n";
    else if(s == "Cloudy")
        cout << "Rainy\n";
    else
        cout << "Sunny\n";

    return 0;
}


Measured memory_bytes: 256
/*
Articulation Points | Aizu Online Judge http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A
 */
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>

#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define sortuniq(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()),v.end())
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"

typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};

using namespace std;

typedef vector<list<int>> Graph;

class FindArticulationPoints {
public:
    Graph g;
    vector<bool> visited;
    vector<int> prenum, lowest, parent;
    int root, timer;
    FindArticulationPoints(){}

    void dfs(int u, int prev) {
        prenum[u] = timer;
        lowest[u] = timer;
        timer++;

        visited[u] = true;

        for (auto &v: g[u]) {
            if (!visited[v]) {
                parent[v] = u;
                dfs(v, u);
                lowest[u] = min(lowest[u], lowest[v]);
            }
            else if (v != prev) {
                lowest[u] = min(lowest[u], prenum[v]);
            }
        }
    }

    void solve(Graph &&graph) {
        g = move(graph);
        visited.resize(g.size(), false);
        prenum.resize(g.size());
        parent.resize(g.size(), -1);
        lowest.resize(g.size());
        root = 0;
        timer = 1;
        dfs(root, -1);

        // dumpc(prenum);
        // dumpc(parent);
        // dumpc(lowest);

        set<int> apoints;
        if (count(parent.begin(), parent.end(), root) > 1) apoints.insert(root);
        for (int i = 0; i < g.size(); ++i) {
            if (parent[i] < 0 || parent[i] == root) continue;
            if (prenum[parent[i]] <= lowest[i]) {
                apoints.insert(parent[i]);
            }
        }

        for (auto &u: apoints) cout << u << '\n';
    }

};


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

    int V, E;
    cin >> V >> E;
    Graph graph(V);
    FOR(i, E) {
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }

    FindArticulationPoints s;
    s.solve(move(graph));
    
    return 0;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define fastio ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 5e3 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, p[N], ans, t[N], dp[N], k, cnt, timer, was[N]; 
vi order, comp, gr[N];
bool bad;

int binpow (int a, int n) {
	int res = 1;
	while (n) {
		if (n & 1)
			res = res * 1ll * a % mod;
		a = a * 1ll * a % mod;
		n >>= 1;
	}

	return res;
}

void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	if (x < 0)
		x += mod;
}

void dfs (int v) {
	was[v] = 1;
	if (p[v] != -1 && !was[p[v]])
		dfs(p[v]);
	order.pb(v);
}

void dfs2 (int v) {
	++cnt;
	was[v] = timer;
	for (auto to : gr[v])
		if (!was[to])
			dfs2(to);			
}

void dfs1 (int v) {
	dfs2(v);
	if (p[v] == -1)
		return;
	if (was[p[v]] == timer) {
		bad = 1;
		return;
	}
	if (was[p[v]])
		return;
	dfs1(p[v]);
		
}


main () {
	fastio
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> p[i]; 
		if (p[i] == -1)
			++k;
		else
			gr[p[i]].pb(i);
	}

	ans = binpow(n - 1, k) * 1ll * n % mod;

	for (int i = 1; i <= n; ++i)
		if (!was[i])
			dfs(i);

	reverse(all(order));
	memset(was, 0, sizeof(was));
	
	for (auto i : order) 
		if (!was[i]) {
		    cnt = 0;
		    bad = 0;
		    ++timer;
			dfs1(i);  
			if (bad)
				add(ans, -binpow(n - 1, k));
			else
				comp.pb(cnt);	
		}
		
	

	dp[0] = 1;
	for (auto x : comp) 
		for (int i = k; i > 0; --i)
			add(dp[i], dp[i - 1] * 1ll * x % mod * max(1, i - 1) % mod);
	
	for (int i = 2; i <= k; ++i) 
		add(ans, -dp[i] * 1ll * binpow(n - 1, k - i) % mod);
	if (k)
		add(ans, -(dp[1] - k) * 1ll * binpow(n - 1, k - 1) % mod);
	cout << ans << endl;
}



Measured memory_bytes: 3948
#define _USE_MATH_DEFINES

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

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e8 + 7;

int main(){
	
	while(true){
		int n, S;
		cin >> n >> S;
		if(n == 0){
			break;
		}
		long long int ans = 0;
		long long int cnt[110] = {};
		for(int i = 0; i < n; i++){
			int num;
			cin >> num;
			cnt[num] += 1;
		}
		for(int i = 1; i <= 100; i++){
			for(int j = i + 1; j <= 100; j++){
				if(i + j > S){
					ans += cnt[i] * cnt[j];
				}
			}
			if(i * 2 > S){
				ans += cnt[i] * (cnt[i] - 1) / 2;
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define chmax(s, t) s=max(s,t);
#define chmin(s, t) s=min(s,t); 

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

/*組み合わせ(Combination)*/
const ll CMAX = 1010000;
const ll CMOD = 1e9+7;
ll fac[CMAX], finv[CMAX], inv[CMAX];
// テーブルを作る前処理
void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < CMAX; i++) {
		fac[i] = fac[i - 1] * i % CMOD;
		inv[i] = CMOD - inv[CMOD%i] * (CMOD / i) % CMOD;
		finv[i] = finv[i - 1] * inv[i] % CMOD;
	}
}
// 二項係数計算
ll comb(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % CMOD) % CMOD;
}

/*階乗*/
ll factorial(ll n){
    const ll FMOD = 1e9+7;
    ll ret = n;
    for(ll i=n-1;i>0;i--){
        ret*=i;
        ret%=FMOD;
    }
    return (ret?ret:1);
}


int main(){

    string s; cin >> s;

    ll ans = 0;
    if(s == "SSS") ans = 0;
    else if(s == "SSR") ans = 1;
    else if(s == "SRS") ans = 1;
    else if(s == "RSS") ans = 1;
    else if(s == "SRR") ans = 2;
    else if(s == "RRS") ans = 2;
    else if(s == "RSR") ans = 1;
    else if(s == "RRR") ans = 3;
    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main (String [] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int array[] = new int[n];
		
		for (int i = 0; i < n; i++ ) {
			array[i] = scan.nextInt();
		}
		scan.close();
		
		for (int i = 0; i < n; i++) {
			if ( i == n - 1) {
				System.out.println(array[i]);
			} else {
				System.out.print(array[i] + " ");
			}
			
		}
		
		for (int i = 1; i < n; i++) {
			int v = array[i];
			int j = i - 1;
			
			while ( j >= 0 && array[j] > v) {
				array[j + 1] = array[j];
				j--;
			}
			array[j + 1] = v;
			
			for (int k = 0; k < n; k++ ) {
				if ( k == n - 1) {
					System.out.println(array[k]);
				} else {
					System.out.print(array[k] + " ");
				}
				
			}
		}
		
	}
}



Measured memory_bytes: 30552
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m,x;
priority_queue<int> q;
void solve(){
	while(m--){
		int x = q.top(); q.pop();
		x /= 2;
		q.push(x);
	}
	ll ans = 0;
	while(!q.empty()){
		ans += q.top(); q.pop();
	}
	cout << ans << endl;
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	rep(i,0,n-1){
		cin >> x;
		q.push(x);
	}
	solve();
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 998244353
#define inf 1LL << 62
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template



struct edge {int to; ll cost;};
struct node {int pos; ll cost;};
bool operator < (const node &a, const node &b){
    return a.cost > b.cost;
}

vector<ll> dijkstra(vector<vector<edge>> &G, int root){
    vector<ll> ret(G.size(), inf);
    priority_queue<node> pq;
    pq.push({root, 0});
    while (!pq.empty()) {
        node t = pq.top();
        pq.pop();
        
        if (ret[t.pos] == inf) ret[t.pos] = t.cost;
        else continue;
        
        for (edge e : G[t.pos]) {
            pq.push({e.to, t.cost + e.cost});
        }
    }
    return ret;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
//    vector<ll> D(N, inf);
    vector<vector<edge>> A(N);
    rep(i, M) {
        int from, to;
        ll cost;
        cin >> from >> to >> cost;
        from--;
        to--;
        A[from].pb({to, cost});
    }
    rep(i, N - 1) {
        A[i + 1].pb({i, 0});
    }
    
    auto D = dijkstra(A, 0);
    if(D[N - 1] == inf) {
        output(-1);
        return 0;
    }
    
    output(D[N - 1]);
    
    
    return 0;
    
}



Measured memory_bytes: 10104
import java.util.*;
 
import java.io.*;
 
public class Main{
    
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int[] P = new int[N];
        for(int i = 0; i < N; i++){
            P[i] = s.nextInt();
        }
        
        int min = N+1;
        int count = 0;
        for(int i = 0; i < N; i++){
            if(min > P[i]){
                min = P[i];
                count++;
            }
        }
        System.out.println(count);
	}
} 

Measured memory_bytes: 65140
//Minimum Spanning Tree
//2019-01-27
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

#define N 128
#define MAX 100
#define INF 2500

void Count(void);

int n;
int A[N][N];

int main(){
  int i, j;
  int count;

  scanf("%d", &n);
  if(n < 1 || n > MAX){
    printf("頂点の数が適当ではありません。\n");
    exit(1);
  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      scanf("%d", &A[i][j]);
      if(A[i][j] == -1)
        A[i][j] = INF;
      else if(A[i][j] < 0 || A[i][j] > 2000){
        printf("辺の重みが適当ではありません。\n");
        exit(2);
      }
    }
  }
  Count();

  return 0;
}

void Count(){
  int i, j;
  int d[N], p[N], times[N];
  int min;
  int count = 0;
  int u;

  for(i = 0 ; i < n ; i++){
    d[i] = INF;
    p[i] = -1;
    times[i] = 0;
  }
  d[0] = 0;

  while(u != -1){
    min = INF;
    u = -1;
    for(i = 0 ; i < n ; i++){
      if(min > d[i] && times[i] != 2){
        u = i;
        min = d[i];
      }
    }
    if(u == -1)
      break;
    times[u] = 2;
    for(j = 0 ; j < n ; j++){
      if(times[j] != 2 && A[u][j] != INF){
        if(d[j] > A[u][j]){
          d[j] = A[u][j];
          p[j] = u;
          times[j] = 1;
        }
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    if(p[i] != -1){
      count = count + A[i][p[i]];
    }
  }
  printf("%d\n", count);
}



Measured memory_bytes: 2108
M, D = map(int, input().split())

cnt = 0
for i in range(20, D+1):
  d1 = i % 10
  d2 = i //10
  
  if 0 < d1*d2 <= M and d1>1 and d2>1:
#    print (i, d1*d2)
    cnt += 1

print (cnt)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll h;
	cin >> h;
	ll ans=1;
	h /= 2;
	ll cnt=2;
	while(h){
		ans += cnt;
		cnt *= 2;
		h /= 2;
	}
	
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 2e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll n, d, a;
  cin >> n >> d >> a;
  vector<pair<ll, ll>> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;

  sort(p.begin(), p.end());
  rep(i, n) {
    if (p[i].second % a == 0) p[i].second /= a;
    else p[i].second = p[i].second / a + 1;
  }
  vector<int> idx(n + 1, 0);
  rep(i, n) idx[i + 1] = upper_bound(p.begin(), p.end(), make_pair(p[i].first + 2 * d, INF)) - p.begin();
  vector<ll> cnt(n + 1, 0);
  ll ans = 0;
  rep(i, n) {
    cnt[i + 1] += cnt[i];
    int id = lower_bound(idx.begin(), idx.end(), i + 1) - idx.begin() - 1;
    ll res = -cnt[i + 1] + cnt[id] + p[i].second;
    if (res <= 0) continue;
    ans += res;
    cnt[i + 1] += res;
  }
  cout << ans << endl;





  
  return 0;
}

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

int main()
{
    int a,b,c,d,n;
    cin >> n >> a >> b;
    
    if(n*a<b){
        cout << n*a << endl;
    }else{
        cout << b << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);

    String arr = scan.next();
    String str1 = arr.substring(0,4);
    String str2 = arr.substring(4,12);

    System.out.println(str1+" "+str2);
  }
}


Measured memory_bytes: 8916
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABC067CSplittingPile solver = new ABC067CSplittingPile();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABC067CSplittingPile {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      int[] ar = new int[n];
      long[] ruiseki = new long[n + 1];
      long min = Long.MAX_VALUE;
      long sum = 0;

      for (int i = 0; i < n; i++) {
        ar[i] = in.nextInt();
        ruiseki[i + 1] = ruiseki[i] + (long) ar[i];
        sum += ar[i];
      }

      for (int i = 1; i < n; i++) {
        min = Math.min(min, Math.abs((sum - ruiseki[i]) - ruiseki[i]));
      }
      out.println(min);
    }

  }
}



Measured memory_bytes: 83820
n,C,*H=map(int,open(0).read().split());
dp=[0];
P=[0];
f=lambda I,h:dp[I]+H[I]*(H[I]-2*h)
for i in range(1,n):
    h=H[i]
    while len(P)>1 and f(P[0],h)>f(P[1],h):P.pop(0)
    dp+=[f(P[0],h)+h**2+C]
    while len(P)>1 and (H[P[-1]]-H[P[-2]])*(f(P[-1],0)-f(i,0))>(h-H[P[-1]])*(f(P[-2],0)-f(P[-1],0)):P.pop()
    P+=[i]
print(dp[-1])

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

namespace ARC85_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            long y = long.Parse(s[1]);

            for (int i = 0; i < n+1; i++)
            {
                for (int j = 0; j < n - i + 1; j++)
                {
                    if (i * 10000 + j * 5000 + (n-j-i) * 1000 == y)
                    {
                        Console.WriteLine($"{i} {j} {n-j-i}");
                        return;
                    }

                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13140
n,m,k = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))

def csum(l,ll):
    s = 0
    res = [0] * ll
    for i in range(ll):
        s += l[i]
        res[i] = s
    return res

csln = csum(ln,n)
cslm = csum(lm,m)

import numpy as np

lk = [k] + [k-x for x in csln if k-x >=0]
res = np.searchsorted(np.array(cslm), np.array(lk), side='right')
rmax = 0
for i,j in zip(range(len(lk)+1), res):
    rmax = max(rmax, i+j)
print(rmax)

Measured memory_bytes: 70628
a, b, c, d = map(int, input().split())

taka = a
aoki = c

while taka > 0 and aoki > 0:
    aoki = aoki - b
    if(aoki <= 0):
        print("Yes")
        break

    taka = taka - d
    if (taka <= 0):
        print("No")
        break



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

int main()
{
    int n; cin>>n;
    vector<long> a(n); for(auto& e: a) cin>>e;

    auto p=minmax_element(begin(a), end(a));
    if (*p.second+*p.first>=0) {
        cout<<n+n-1<<endl;
        int k=p.second-begin(a);
        for(int i=0; i<n; ++i) cout<<k+1<<' '<<i+1<<endl;
        for(int i=1; i<n; ++i) cout<<i<<' '<<i+1<<endl;
    }
    else {
        cout<<n+n-1<<endl;
        int k=p.first-begin(a);
        for(int i=0; i<n; ++i) cout<<k+1<<' '<<i+1<<endl;
        for(int i=n; i>1; --i) cout<<i<<' '<<i-1<<endl;
    }
}


Measured memory_bytes: 256
n = int(input())
h = list(reversed(list(map(int, input().split()))))
for i in range(1, n):
    if h[i] > h[i - 1]:
        if h[i] - h[i - 1] > 1:
            print("No")
            exit()
        else:
            h[i] -= 1
print("Yes")

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

int main() {
  int n;
  while (cin >> n, n) {
    int a;
    cin >> a;
    int sum = a;
    int max_sum = sum;
    for (int i = 1; i < n; i++) {
      cin >> a;
      sum = max(sum + a, a);
      max_sum = max(max_sum, sum);
    }
    cout << max_sum << endl;
  }
}



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

using namespace std;

int a[60],b[60],c[60],d[60];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>c[i]>>d[i];
    }

    for(int i=1;i<=n;i++)
    {
        int ans=1000000000;
        int k;
        for(int j=1;j<=m;j++)
        {
            int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(t<ans){
                ans=t;
                k=j;
            }
        }
        cout<<k<<endl;
    }
    return 0;
} 

Measured memory_bytes: 256
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    if N == 1:
        print "Hello World"
    else:
        input_raw = read_func().strip().split()
        A = int(input_raw[0])
        input_raw = read_func().strip().split()
        B = int(input_raw[0])
        print A+B

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

int N;
string s;
map<string,int> M;
int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N;

    for(int i=1;i<=N;i++)
        cin >> s , M[s];

    cout << M.size();


}


Measured memory_bytes: 19248
A,B,C,D,E,F = map(int,input().split())

ws = []
for a in range(0,F+1,100*A):
	for b in range(0,F-a+1,100*B):
		x = a + b
		if x <= F:
			ws.append(x)
			
ss = []
for c in range(0,F+1,C):
	for d in range(0,F-c+1,D):
		y = c + d
		if y <= F:
			ss.append(y)
				
wss = []
for w in ws:
	for s in ss:
		ws = w+s
		
		if not ws <= F:
			continue
		
		if ws == 0:
			continue
		
		e = s/ws*100
				
		if not e <= E/(100+E)*100:
			continue
				
		wss.append([e,ws,s])
				
l = (sorted(wss,reverse=True,key=lambda x:x[0]))[0]
print(l[1],l[2])

Measured memory_bytes: 137684
#include <iostream>

int main(){
    int n,a,b,ina,inb;
    
    while(std::cin >> n,n){
        a=0;b=0;
        for(int i=0;i<n;i++){
            std::cin >> ina >> inb;
            if(ina>inb){
                a += ina + inb;
            }else if(ina==inb){
                a += ina;
                b += inb;
            }else{
                b += ina + inb;
            }
        }
        std::cout << a << ' ' << b << std::endl;
    }
    
    return 0;
}

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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n, k;
    cin >> n >> k;
    vector<lli> c(n + 1), p(n + 1);
    for(int i = 1; i <= n; i++) {
        cin >> p[i];
    }
    for(int j = 1; j <= n; j++) {
        cin >> c[j];
    }
    vector<bool> visited(n + 1);
    lli ans = -1e18;
    for(int i = 1; i <= n; i++) {
        if(!visited[i]) {
            visited[i] = true;
            vector<lli> group;
            group.push_back(c[i]);
            int j = p[i];
            while(j != i) {
                visited[j] = true;
                group.push_back(c[j]);
                j = p[j];
            }
            for(int i = 0; i < group.size(); i++) {
                vector<lli> prefix(group.size() + 1);
                for(int j = 1; j < prefix.size(); j++) {
                    prefix[j] = prefix[j - 1] + group[j - 1];
                }
                lli best = 0ll;
                for(int j = 1; j <= min((lli)prefix.size() - 1, k); j++) {
                    ans = max(ans, prefix[j]);
                    best = max(best, prefix[j]);
                }
                lli m = prefix.size() - 1;
                if(prefix[m] >= 0) {
                    lli d = k % m;
                    lli sum = 0ll;
                    for(int j = 1; j <= d; j++) {
                        sum = max(sum, prefix[j]);
                    }
                    ans = max(ans, sum + (k / m) * prefix[m]);
                    ans = max(ans, best + ((k / m) - 1) * prefix[m]);
                }
                rotate(group.begin(), group.begin() + 1, group.end());
            }
        }
    }
    cout << ans <<  endl;
    return 0;
}


Measured memory_bytes: 3804
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return key % (M - 1); }

int find(char str[]){
  long long int key, h;
  int i;

  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
  	else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long int key , h;
  int i;

  key = getKey(str);
  for(i = 0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
  	else if(strlen(H[h]) == 0){
  		strcpy(H[h], str);
  		return 0;
  	}
  }
	return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	     scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		      printf("yes\n");
	    } else {
		      printf("no\n");
	    }
	   }
    }

    return 0;
}



Measured memory_bytes: 15368
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n,m;
int tbl[10001][1300];
int main(){
  while(cin>>n>>m,n||m){
    memset(tbl,0,sizeof(tbl));
    int r;
    cin >> r;
    for(int i=0;i<r;++i){
      int t,a,b,s;
      cin >> t >> a >> b >> s;
      if(s)
	tbl[b][t]++;
      else
	tbl[b][t]--;
    }
    for(int i=0;i<=m;++i){
      for(int j=1;j<1300;++j) tbl[i][j]+=tbl[i][j-1];
    }
    int q;
    cin >> q;
    for(int i=0;i<q;++i){
      int s,t,a;
      cin >> s >> t >> a;
      int cnt = 0;
      for(int j=s;j<t;++j){
	if(tbl[a][j]) ++cnt;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 51952
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define INF 0X3F3F3F3F
#define N 600005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
int n, a, b, f[N];
int main(){
    //IN;
    SCCC(n, a, b);
    int flag = 0;
    if(a < b){
        flag = 1;
        swap(a, b);
    }
    if(a + b > n + 1){
        puts("-1");
        return 0;
    }
    int up = n, down = 1;
    int p = 0, ok = 1;
    while(1){
        if(p < n)FF(i, max(up - a + 1, up - (n - p) + 1), up){
            f[++p] = i;
            if(p == n){
                break;
            }
        }
        if(p < n)RR(i, min(down + b - 2, down + n - p - 1), down){
            f[++p] = i;
            if(p == n){
                break;
            }
        }
        if(p == n) break;
        up -= a;
        down += b - 1;
        --a;
        --b;
        if(a < 0 || b < 1){
            ok = 0;
            break;
        }
    }
    if(ok){
        if(flag) RR(i, n, 1) printf("%d%c", f[i], i == 1 ? '\n' : ' ');
        else FF(i, 1, n) printf("%d%c", f[i], i == n ? '\n' : ' ');
    }
    else puts("-1");
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

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

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

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

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

const int inf = 1012345678;
int main(){
    int n;
    char w[100][11];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%s", w[i]);
    }

    for(int i = 0; i < n - 1; ++i){
        int size = (int)strlen(w[i]);
        if(w[i][size - 1] != w[i+1][0]){
            puts("No");
            return 0;
        }
    }
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            if(strcmp(w[i], w[j]) == 0){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");

    return 0;
}


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


int Primer(long long a){
  int count = 1;
  long double x = sqrtl(a);
  for(int i = 2; i <= x; ++i){
    if(a % i == 0){
      a /= i;
      ++count;
      while(a % i == 0){
        a /= i;
      }
    }
  }

  if(a != 1){
    ++count;
  }

  return count;
}

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

  long long A, B;
  cin >> A >> B;
  
  cout << Primer(__gcd(A, B)) <<endl;;
}


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

int main() {
  int a,b,c,d,e,f;
  cin >> a;
  b = a / 100;
  c = a - (b * 100);
  d = c / 10;
  e = c - (d * 10);
  f = b + d + e;

  cout << f << endl;
}

Measured memory_bytes: 256