akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

bool cmp(const pii &a, const pii &b) {
    int tmp1 = max(a.first, b.first + a.second);
    int tmp2 = max(b.first, a.first + b.second);
    if (tmp1 < tmp2) return true;
    return false;
}


int main() {
    int N;
    cin >> N;
    vector<pii> cand1, cand2, cand3;
    for (int i = 0; i < N; i++) {
        string tmp;
        cin >> tmp;
        int mxneed = 0, backup = 0;
        for (int j = 0; j < (int)tmp.length(); j++) {
            if (tmp[j] == ')') {
                if (backup) backup--;
                else mxneed--;
            } else {
                backup++;
            }
        }
        if (mxneed == 0) cand1.push_back(make_pair(0, backup));
        else if (mxneed + backup >= 0) {
            cand2.push_back(make_pair(-mxneed, backup + mxneed));
        } else {
            cand3.push_back(make_pair(-mxneed, -(backup + mxneed)));
        }
    }
    sort(cand1.begin(), cand1.end());
    int sum = 0;
    for (auto i : cand1)
        sum += i.second;
    sort(cand2.begin(), cand2.end());
    bool OK = true;
    for (auto i : cand2) {
        if (sum < i.first) {
            OK = false;
        }
        sum += i.second;
    }
    sort(cand3.begin(), cand3.end(), cmp);
    for (auto i : cand3) {
        if (sum < i.first) {
            // cout << "sum = " << sum << "need = " << i.first << "\n";
            // cout << "lose = " << i.second << "\n";
            OK = false;
        }
        sum -= i.second;
    }
    if (sum != 0 || !OK) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 11324
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

# INF = float("inf")
INF = 10 ** 8
dp = [INF] * ((1<<n) + 1)
dp[0] = 0

for i in range(m):
    a, b = map(int, input().split())
    c = sum(1<<(ci-1) for ci in map(int, input().split()))

    for j in range(1<<n):
        # if dp[j] + a < dp[j | c]:
        #     dp[j | c] = dp[j] + a
        dp[j | c] = min(dp[j] + a, dp[j | c])

if dp[(1<<n) - 1] == INF:
    ans = -1
else:
    ans = dp[(1<<n) - 1]

print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        for (int i = 1; i <= N; i++) {

            if (N <= D) {
                System.out.println(1);
                break;
            }

            if (i - D > 0) {
                if (N % (i + D) != 0) {
                    System.out.println((N / (i + D)) + 1);
                    break;
                } else {
                    System.out.println(N / (i + D));
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

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

    int64_t ans = 0x7fffffffffffffffLL;
    for (int v = -100; v <= 100; v++) {
        int64_t cur = 0;
        for (auto &a: as) {
            cur += (a - v) * (a - v);
        }
        ans = min(ans, cur);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        char c = s.charAt(k-1);
        for(int i = 0; i < n; i++) {
            if(s.charAt(i) == c) {
                System.out.print(c);
            } else {
                System.out.print("*");
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int main()
{
	int n;
	cin >> n;
	vector< int > v(n);
	for(int i = 0 ; i < n ; i++)
		cin >> v[i];
	sort(v.begin() , v.end());
	cout << v[n-1] - v[0] << endl;
	return 0;
} 




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

int main() {
  int n; cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  
  int ans=0;
  sort(l.begin(), l.end());
  rep(i,n-2)  {
    for(int k=i+1; k<n-1; ++k) {
      for(int j=k+1; j<n; ++j) {
        if ((abs(l[i]-l[k]) < l[j]) && (l[j] < (l[i]+l[k]))) {
          ans++;
        }
        else continue;      
      }
  	}
  }
  cout << ans << endl;
  return 0;
}
 
  

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
// using Graph = vector<vector<int>>;

struct edge {
    int to, cost;
    edge(){}
    edge(int _to, int _cost) : to(_to), cost(_cost) {}
};
using Graph = vector<vector<edge>>;

int dp[100000];

int dfs(int now, int pre, const Graph& G) {
    for (auto e : G[now]) {
        if (e.to == pre) continue;
        chmax(dp[now], dfs(e.to, now, G) + e.cost);
    }
    return dp[now];
}

int dfs2(int now, int pre, int prop, const Graph& G) {
    vector<Pii> vp;
    vp.emplace_back(0, -1);
    for (auto e : G[now]) {
        if (e.to == pre) vp.emplace_back(e.cost + prop, e.to);
        else vp.emplace_back(e.cost + dp[e.to], e.to);
    }
    sort(rall(vp));
    int ret = vp[0].first + vp[1].first;
    for (auto e : G[now]) {
        if (e.to == pre) continue;
        chmax(ret, dfs2(e.to, now, vp[vp[0].second == e.to].first, G));
    }
    return ret;
}



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

    int n;
    cin >> n;
    Graph G(n);
    rep(i, n - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }

    dfs(n / 2, -1, G);
    cout << dfs2(n / 2, -1, 0, G) << endl;
}

Measured memory_bytes: 21516
#include<bits/stdc++.h>
using namespace std;
int main(void){
	long long int n;
	cin>>n;
	string s;
	long long int fake=n;
	while(fake>0){
		fake=fake/26;
		//cout<<fake<<endl;
		long long int i=fake*26;
		long long int j=n-i;
		if(j==0){
			fake=fake-1;
			s+='z';
		}
		else{
			char c=96+j;
			s+=c;
		}
		n=fake;
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}

Measured memory_bytes: 3628
#!/usr/bin/env python
# coding: utf-8

# In[26]:


N,K = map(int, input().split())
x = list(map(int, input().split()))


# In[35]:


ans = 10**10
for i in range(N-K+1):
    ans = min(ans, abs(x[i])+(x[i+K-1]-x[i]),abs(x[i+K-1])+(x[i+K-1]-x[i]))
print(ans)


# In[ ]:






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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m;
  cin>>n>>m;
  
  int as[200001] = {0}, bs[200001] = {0};
  
  rep(i,m) {
    int a,b;
    cin>>a>>b;
    
    if(a==1) as[b-1] = 1;
    if(b==n) bs[a-1] = 1;
  }
  
  rep(i,n) {
    int a = as[i];
    int b = bs[i];
    
    if(a==1 and b==1) {
      cout<<"POSSIBLE";
      return 0;
    }
  }
  
  cout<<"IMPOSSIBLE";
  
  return 0;
}

Measured memory_bytes: 1792
inf = - (10 ** 9)
n, k = map(int, input().split())
v = [int(i) for i in input().split()]
ans = inf
for left in range(k + 1):
    for right in range(k - left + 1):
        back = k - left - right
        if left + right <= n:
            vv = v[:left] + v[n - right:]
        else:
            vv = v
        vv.sort()
        if len(vv) > 0:
            back = k - left - right
            under_zero = len([v_i for v_i in vv if v_i < 0])
            if back <= under_zero:
                ans = max(sum(vv[back:]), ans)
            else:
                if (back - under_zero) % 2 == 1:
                    ans = max(sum(vv[under_zero:]), ans)
                else:
                    ans = max(sum(vv[under_zero - 1:]), ans)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main ()
{
int n;
cin>>n;
for(int i=0;i<3;i++)
{
    if(n%10==7)
    {
        cout<<"Yes";
        return 0;
    }
    else
    {
        n/=10;
    }
}
cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]
ans = {}

for v in L:
    a, b, c = v - 1, v, v + 1
    for p in [a, b, c]:
        if ans.get(p) == None:
            ans[p] = 0
        ans[p] += 1

print(max(ans.values()))

Measured memory_bytes: 19736
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,A,B;
    cin>>N>>A>>B;
    cout <<(abs(A-B)%2?"Borys":"Alice")<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.next();
        String b = scanner.next();
        String c = scanner.next();
        
        System.out.print("A" + b.substring(0,1) + "C");


    }
}

Measured memory_bytes: 21844
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 2147483647
#define lli long long int
#define MOD 1000000007
#define pb push_back

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

int main() {

	int n,m; cin >> n >> m;
	vvi d(n,vi(n,MOD));
	vvi edge(n,vi(n,MOD));
	vvi used(n,vi(n,1));
	for (int i = 0; i < m; i++) {
		int a,b,c; cin >> a >> b >> c;
		d[a-1][b-1] = c;
		d[b-1][a-1] = c;
		edge[a-1][b-1] = c;
		edge[b-1][a-1] = c;
		used[a-1][b-1] = 0;
		used[b-1][a-1] = 0;
	}

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

	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (d[i][j] == edge[i][j]) {
				used[i][j] = 1;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (used[i][j] == 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;



	
	return 0;
}





Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double ang_h = 2 * M_PI * (h / 12.0) + (1.0 / 6.0) * M_PI * (m / 60.0);
    double ang_m = 2 * M_PI * (m / 60.0);

    double kaku = min(abs(ang_h-ang_m), abs(ang_m-ang_h));

    double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(kaku));
    cout << setprecision(20) << ans << endl;

    return 0;
}

Measured memory_bytes: 4240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int[] b = new int[m];
		for (int i = 0; i < b.length; i++) {
			b[i] = Integer.parseInt(sc.next());
		}
		int[][] a = new int[n][m];
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				a[i][j] = Integer.parseInt(sc.next());
			}
		}
		int ans = 0;
		for (int i = 0; i < a.length; i++) {
			int sum = 0;
			for (int j = 0; j < a[i].length; j++) {
				sum += a[i][j] * b[j];
			}
			if (sum + c > 0) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21972
using System;
using System.Linq;
using System.Text.RegularExpressions;
namespace mytest
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            int N = int.Parse(input.Split(' ')[0]);
            int K = int.Parse(input.Split(' ')[1]);
          	var h = Console.ReadLine().Split(' ');
            int total = 0;
            for(int i = 0; i<N; i++)
            {
              if(int.Parse(h[i])>=K)
              total+=1;
            }
          Console.WriteLine(total);

        }
    }
}


Measured memory_bytes: 15584
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    #根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

#初期化
uf = UnionFind(n)
for i in range(m):
    a,b,c = inpl()
    uf.union(a-1,b-1)
print(uf.group_count())


Measured memory_bytes: 89172
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

int main(){
  int64_t N;
  string S;
  cin >> N >> S;
  vector<vector<int> > next = calcNext(S);
  vector<long long> dp0(sz(S)+1, 0);
  vector<long long> dp1(sz(S)+1, 0);
  vector<long long> dp2(sz(S)+1, 0);
  vector<long long> dp3(sz(S)+1, 0);
  dp0.at(0) = 1;
  dp1.at(0) = 0;
  dp2.at(0) = 0;
  dp3.at(0) = 0;
  rep(i, sz(S)){
    rep(j, 10){
      if (next[i][j] >= sz(S)) continue;
      dp1.at(next.at(i).at(j) + 1) += dp0.at(i);
      dp2.at(next.at(i).at(j) + 1) += dp1.at(i);
      dp3.at(next.at(i).at(j) + 1) += dp2.at(i);
    }
  }
  int64_t ans=0;
  rep(i, sz(S)+1){
    ans += dp3.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4224
C = [list(map(int, input().split())) for _ in range(3)]

cnd = True

cnd &= C[0][0] - C[0][1] == C[1][0] - C[1][1]
cnd &= C[0][0] - C[0][1] == C[2][0] - C[2][1]

cnd &= C[0][0] - C[0][2] == C[1][0] - C[1][2]
cnd &= C[0][0] - C[0][2] == C[2][0] - C[2][2]

cnd &= C[0][1] - C[0][2] == C[1][1] - C[1][2]
cnd &= C[0][1] - C[0][2] == C[2][1] - C[2][2]

print('Yes' if cnd else 'No')


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[200005],b[200005],cnt[200005],x,y,ans;
inline int read(){
	char c=getchar();
	for(;c>'9'||c<'0';) c=getchar();
	int xx=c-'0';
	c=getchar();
	for(;c>='0'&&c<='9';){
		xx=(xx<<3)+(xx<<1)+c-'0';
		c=getchar();
	}
	return xx;
}
int main(){
	n=read(),m=read(),ans=n;
	for(int i=1;i<=n;i++){
		cnt[a[i]=read()]++;
		if(a[i]-cnt[a[i]]>=0){
			if(!b[a[i]-cnt[a[i]]]) ans--;
			b[a[i]-cnt[a[i]]]++;
		}
	}
	for(int i=1;i<=m;i++){
		x=read(),y=read();
		if(a[x]-cnt[a[x]]>=0){
			b[a[x]-cnt[a[x]]]--;
			if(!b[a[x]-cnt[a[x]]]) ans++;
		}
		cnt[a[x]]--,a[x]=y,cnt[y]++;
		if(a[x]-cnt[a[x]]>=0){
			b[a[x]-cnt[a[x]]]++;
			if(b[a[x]-cnt[a[x]]]==1) ans--;
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

quickSortVec l u arr
  | l >= u    = return ()
  | otherwise = do
      VM.unsafeSwap arr l ((u+l)`div`2)
      t <- VM.unsafeRead arr l
      let i = l
          j = u + 1
      nj <- loopVec t u i j arr
      VM.unsafeSwap arr l nj
      quickSortVec l (nj-1) arr
      quickSortVec (nj+1) u arr

loopVec !t !u !i !j arr = do
  ni <- doWhile i (+1)         (< t)
  nj <- doWhile j (subtract 1) (> t)
  if ni > nj
    then return nj
    else do VM.unsafeSwap arr ni nj
            loopVec t u ni nj arr
              where
                {-# INLINE doWhile #-}
                doWhile k op p
                  | nk > u    = return nk
                  | otherwise = do
                      x <- VM.unsafeRead arr nk
                      if p x then
                        doWhile nk op p
                        else
                        return nk
                        where
                          nk = op k

main = do
  [n, c] <- getIntList

  ps <- VM.new n
  forM_ [0..(n-1)] $ \i -> do
    [s, t, c] <- getIntList
    VM.write ps i (s, t, c)

  quickSortVec 0 (n-1) ps

  tvs <- VM.new 30
  VM.set tvs ((0,0) :: (Int, Int))

  let findTv :: Int -> Int -> Int -> IO Int
      findTv i s c = do
        (onCh, busyTo) <- VM.read tvs i
        if onCh == 0 || busyTo < s || (onCh == c && busyTo == s)
          then return i
          else findTv (i+1) s c

      solve :: Int -> Int -> IO Int
      solve i res | i == n = return res
                  | otherwise = do
                      (s, t, c) <- VM.read ps i
                      tvNum <- findTv 0 s c
                      let res' = max res (tvNum + 1)
                      VM.write tvs tvNum (c, t)
                      solve (i+1) res'

  ans <- solve 0 0
  print ans

Measured memory_bytes: 11900
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  string s;
  cin >> s;
  for (long i = 0; i < s.size(); i += 2) cout << s[i];
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

const int maxn = 2e5+5;
int n;
ll k;
ll a[maxn], f[maxn];

ll ceil(ll a, ll b) {
    return (a+b-1)/b;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> f[i];
    }
    sort(a,a+n);
    sort(f,f+n,greater<ll>());
    ll lo = -1, hi = 1e18+5;
    while (lo + 1 < hi) {
        ll mid = (lo+hi)/2;
        ll s = 0;
        for (int i = 0; i < n; i++) {
            ll need = max(0LL,ceil(a[i]*f[i]-mid,f[i]));
            s += need;
            assert((a[i]-need)*f[i] <= mid);
        }
        //cout << mid << ": " << s << '\n';
        if (s <= k) {
            hi = mid;
        }
        else {
            lo = mid;
        }
    }
    cout << hi << '\n';
}



Measured memory_bytes: 3456
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string.h>

using namespace std;
#define N_MAX 42

int cnt[N_MAX];
long long dp[N_MAX][2];
int N;
long long K;

long long f(int bit, bool det)
{
	if(bit < 0) return 0;
	if(dp[bit][det] != -1) return dp[bit][det];
	if(!det){
		if(!(K & (1ll << bit))) return dp[bit][det] = (1ll << bit)*cnt[bit] + f(bit-1, false);
		long long ans_tmp = (1ll << bit)*cnt[bit] + f(bit-1, true);
        ans_tmp = max(ans_tmp, (1ll << bit)*(N-cnt[bit]) + f(bit-1, det));
        return dp[bit][det] = ans_tmp;
	} else {
    	return dp[bit][det] = (1ll << bit)*max(cnt[bit], N-cnt[bit])+f(bit-1, det);
    }
}

int main()
{
	cin >> N >> K;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < N; i++){
		long long a;
		cin >> a;
		for(int j = 0; j < N_MAX; j++){
			if(1ll << j & a) cnt[j]++;
		}
	}
	long long ans;
	ans = f(N_MAX-1, false);
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=1000;
const int A=26;
char buf[N];
vi d[N];

int main() {
    int i, j, ans, ch;
    scanf("%s", buf);
    string s(buf);
    int n=sz(s);
    for(i=0; i<n; i++) {
        d[i].assign(A, n-i);
        for(j=i; j<n; j++) {
            ch=s[j]-'a';
            d[i][ch]=min(d[i][ch], j-i);
        }
    }
    ans=n;
    for(ch=0; ch<A; ch++) {
        j=0;
        for(i=0; i<n; i++) j=max(j, d[i][ch]);
        ans=min(ans, j);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b;
 cin >> a >> b;
 if(a > b){
  cout << "a > b" << endl;
 }
 else if(a < b){
 cout << "a < b" << endl;
 }
 else{
 cout << "a == b" << endl;
 }
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
#define BIG 2000000007
 
#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;
 
typedef struct {
	int a;
	int b;
} hw;
 
#define N_MAX 100000
#define M_MAX 100000
 
ull n, m, k;
ull h, w;
ull va, vb, vc, vd;
// ull a[N_MAX];
// sll a[N_MAX];
// ull b[N_MAX];
// ull dp[N_MAX][M_MAX + 1];
char s[N_MAX + 1];
// char t[N_MAX + 1];
// hw arr[N_MAX];
 
void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

ull divide(ull a, ull b){
	ull x = MOD - 2;
	ull ans = 1;
	while (x) {
		if (x & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		x /= 2;
	}
	return (a * ans) % MOD;
}
 
int digits(ull x){
	int i = 1;
	while (x >= 10) {
		x /= 10;
		i++;
	}
	return i;
}
 
int min(ull x, ull y){
	return (x < y) ? x : y;
}
 
ull gcd(ull x, ull y){
	if (x < y) {
		return gcd(y, x);
	} else if (y == 0) {
		return x;
	} else {
		return gcd(y, x % y);
	}
}
 
ull bitpow(ull a, ull x){
	ull result = 1;
	while (x) {
		if (x & 1) {
			result *= a;
			result %= MOD;
		}
		x /= 2;
		a = (a * a) % MOD;
	}
	return result;
}

int comp(const void *left, const void *right){
	if ((*(int*)left) < (*(int*)right)) {
		return -1;
	} else if ((*(int*)left) > (*(int*)right)) {
		return +1;
	} else {
		return 0;
	}
}

// int nextroute(int arr[]){
// 	int i = n - 1;
// 	int j, x;
// 	while (arr[i - 1] > arr[i]) i--;

// 	x = n;
// 	for (j = i; j < n; j++) {
// 		if (arr[j] < arr[i - 1]) continue;
// 		if (x == n || arr[x] > arr[j]) x = j;
// 	}
// 	arr[i - 1] ^= arr[x];
// 	arr[x] ^= arr[i - 1];
// 	arr[i - 1] ^= arr[x];

// 	qsort(&arr[i], n - i, sizeof(int), comp);
// 	return 0;
// }

ull solve(){
	int i, j;
	ull result;
	const size_t len = strlen(s);

	result = len * (len - 1);
	for (i = 0; i < len - 1; i++) {
		if (s[i] == 'U') {
			result += i;
		} else {
			result += (len - i - 1);
		}
	}

	printf("%llu\n", result);

	return 0;
}
 
int main(void){
	int i, j;
 
	scanf("%d", &i);

	// solve();

	printf("%d\n", i * 800 - (i / 15) * 200);
 
	return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    
    int r = N%10;
    string s;
    switch (r)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        s = "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        s = "pon";
        break;
    case 3:
        s = "bon";
        break;
    default:
        break;
    }
    cout << s << endl;
}

Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();
    let mut board = vec![vec![(0, 0); w]; h];
    for y in 0..h {
        for x in 0..w {
            board[y][x].0 = read::<usize>();
        }
    }
    for y in 0..h {
        for x in 0..w {
            board[y][x].1 = read::<usize>();
            if board[y][x].0 < board[y][x].1 {
                let t = board[y][x].0;
                board[y][x].0 = board[y][x].1;
                board[y][x].1 = t;
            }
        }
    }
    let mut row = vec![vec![false; 14000]; w + 1];
    row[0][7000] = true;
    for y in 0..h {
        let mut nrow = vec![vec![false; 14000]; w + 1];
        for x in 0..w {
            let d = board[y][x].0 - board[y][x].1;
            for i in d..14000 {
                nrow[x][i - d] |= row[x][i];
                row[x + 1][i - d] |= row[x][i];
            }
            for i in 0..14000 - d {
                nrow[x][i + d] |= row[x][i];
                row[x + 1][i + d] |= row[x][i];
            }
        }
        row = nrow;
    }
    for i in 0..7000 {
        if row[w - 1][7000 + i] || row[w - 1][7000 + i] {
            println!("{}", i);
            break;
        }
    }
}


Measured memory_bytes: 4380
#include<stdio.h>

int main(){
	long k,i,j;
	scanf("%ld",&k);
	
	long long int a[k],b[k],c[k];
	long long int max,min;
	int flag;
	
	for(i=0;i<k;i++){
		scanf("%lld",&a[i]);
	}
	
	if(a[k-1]!=2){
		printf("-1\n");
		return 0;
	}
	
	b[k-1]=1;
	c[k-1]=1;
	
	for(i=k-2;i>=0;i--){
		flag=0;
		max = a[i+1]*(c[i+1]+1)-1; 
		min = a[i+1]*b[i+1];
		if(min - (min%a[i]) + a[i] <= max || min%a[i] == 0){
			flag=1;
		}
		if(flag==0){
			printf("-1");
			return 0;
		}
		b[i]=min/a[i];
		if(min%a[i]>0){
			b[i]++;
		}
		c[i]=max/a[i];
	}
	printf("%lld %lld\n",a[0]*b[0],a[0]*(c[0]+1)-1);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    string s, t;
    cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) +(s[2] == t[2]) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int j;
string a;
int main()
{
	cin>>a;
	for(int i=0; i<a.size(); i++)
	{
		if(a[i]=='C') j=1;
		if(j==1 && a[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0; 
		} 
	}
	cout<<"No"<<endl;
						
	return 0;
}

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

const int maxn = 1e5 + 10;

int N;
int a[maxn];

int main(){
	scanf("%d" , &N);
  	for(int i = 1; i <= N; ++i)scanf("%d" , &a[i]);
  	multiset<int> s;
  	int ans = 0;
  	for(int i = N; i >= 1; --i){
      auto it = s.upper_bound(a[i]);
      if(it == s.end()){
      	++ans;
        s.insert(a[i]);
      }
      else{
		s.erase(it);
        s.insert(a[i]);
      }
    }
  	printf("%d\n" , ans);
}

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

#define vint vector<int> 
#define vbool vector<bool>
#define vvint vector<vector<int>>

#define rep(a, b, c) for(int (a)=(b); (a)<(c); (a)++)
#define all(a) (a).begin(), (a).end()

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());

    int k, n;
    cin >> k >> n;
    vint a(n);
    rep(i, 0, n) cin>>a[i];
    
    vint d(n);
    d[0] = k + a[0] - a[n-1];
    rep(i, 1, n){
        d[i] = a[i] - a[i-1];
    }
    vint::iterator max_iter = max_element(all(d));
    cout<<k-*max_iter;

    //for(vector<int> a : ans) cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<endl;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

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

	ll red = 0;
	ll blue = 0;

	for (int i = 0; i < s.length(); i++)
	{
		(s[i] == '0') ? red++ : blue++;
	}

	cout << min(red, blue) * 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   ll n,m;
   cin >> n >> m;
   if (m <= n*2) cout << m/2 << endl;
   else{
      ll ans = 0LL;
      ans = n;
      m -= 2*n;
      ans += m/4;
      cout << ans << endl;
   }

   return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var maxint = 10000
var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	scanner.Scan()
	return strconv.Atoi(scanner.Text())
}

func main() {
	scanner.Split(bufio.ScanWords)
	arr := make([]int, 10)
	for i := range arr {
		n, _ := nextInt()
		arr[i] = n
	}

	sort.Slice(arr, func(i, j int) bool {
		return arr[i] >= arr[j]
	})

	arrStr := fmt.Sprintf("%+v", arr[0:3])
	arrStr = arrStr[1:(len(arrStr) - 1)]
	arrStr = strings.Replace(arrStr, " ", "\n", -1)
	fmt.Println(arrStr)
}



Measured memory_bytes: 1136
#include<algorithm>
#include<cassert>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<iomanip>
#include<map>
#include<numeric>
#include<queue>
#include<vector>
#include<set>
#include<string>
#include<stack>
#include<sstream>
#include<complex>

#define pb push_back
#define clr clear()
#define sz size()
#define fs first
#define sc second

#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define rrep(i,a) for(int i=(int)(a)−1;i>=0;i−−)
#define all(a) (a).begin(),(a).end()
#define EQ(a,b) (abs((a)−(b)) < EPS)
#define INIT(a) memset(a,0,sizeof(a))

using namespace std;
typedef double D;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const D EPS = 1e-7;
const D INF = 1e9;
const D PI = acos(-1);
const int N = 100100;

P par[N];
int r[N];

void init(int n){
  rep(i,n)par[i] = P(i,0);
  INIT(r);
}

P find(int a){
  if(par[a].fs == a)return par[a];
  P tmp = find(par[a].fs);
  return par[a] = P(tmp.fs,tmp.sc + par[a].sc);
}

bool same(int a,int b){
  return (find(a).fs == find(b).fs);
}

bool unite(int a,int b,int cost){
  P x = find(a);
  P y = find(b);
  if(same(x.fs,y.fs)){
    if(y.sc - x.sc != cost)return false;
  }else{
    if(r[x.fs]<r[y.fs]){
      par[x.fs] = P(y.fs,y.sc-x.sc-cost);
    }else{
      par[y.fs] = P(x.fs,x.sc-y.sc+cost);
      if(r[x.fs] == r[y.fs])r[x.fs]++;
    }
  }
  return true;
}

int dis(int a, int b){
  return find(b).sc - find(a).sc;
}

int main(){
  int n,m;
  int a,b,w;
  char c;

  while(cin >> n >> m,n){
    init(n+1);
    rep(i,m){
      cin >> c;
      if(c == '!'){
	cin >> a >> b >> w;
	unite(a,b,w);
      }else{
	cin >> a >> b;
	if(!same(a,b))cout << "UNKNOWN" << endl;
	else cout << dis(a,b) << endl;
      }
    }
  }
}

Measured memory_bytes: 2344
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  va.resize(N);
  rep(i, 0, N - 1) { cin >> va[i]; };
}
void solve() {
  int whole = 0;
  for (auto x : va) {
    whole += x;
  }

  int i = 0, l = 0;
  while (l < whole / 2) {
    l += va[i];
    ++i;
  }
  --i;

  int ans = 0;
  // ans = (l - whole / 2);
  // debug((l - whole / 2));
  // if (whole & 1) {
  //   ans++;
  // }

  // debug2(whole - l, l);

  // debug2(i, l);
  // ;
  int ans1, ans2;
  ans1 = abs(l - (whole - l));
  int l2 = l - va[i];
  ans2 = abs(l2 - (whole - l2));

  ans = min(ans1, ans2);
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

namespace AOJ2
{
    class Program
    {
        class Point
        {
            public int X { set; get; }
            public int Y { set; get; }

            public Point()
            {
                this.X = 0;
                this.Y = 0;
            }

            public Point(int x, int y)
            {
                this.X = x;
                this.Y = y;
            }


        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] ab = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int[] cd = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int a = ab[0];
            int b = ab[1];
            int c = cd[0];
            int d = cd[1];

            int sum = Math.Abs(a - b) + Math.Abs(c - d);
            for (int i = n-1; i >= 1; i--)
            {
                Point A = new Point((a - 1) % i, (a - 1) / i);
                Point B = new Point((b - 1) % i, (b - 1) / i);
                Point C = new Point((c - 1) % i, (c - 1) / i);
                Point D = new Point((d - 1) % i, (d - 1) / i);

                int distance = Distance(A, B) + Distance(C, D);
                if (sum > distance)
                {
                    sum = distance;
                }
            }

            Console.WriteLine(sum);

        }

        static int Distance(Point A, Point B)
        {
            return Math.Abs(A.X - B.X) + Math.Abs(A.Y - B.Y);
        }
        
    }
}

Measured memory_bytes: 5928
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import MapHelper._

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toInt)
  val map = mu.HashMap.empty[Int,Int]
  in.readLine.split(" ").map(_.toInt).foreach(map.addOrUpdate(_,1))
  val g = map.keySet.size
  val ans = map.values.toArray.sorted.take(g-k).sum
  println(ans)
}

object MapHelper {
  implicit class AddOrUpdate[A](map:mu.HashMap[Int,Int]) {
    def addOrUpdate(key:Int, value:Int):mu.HashMap[Int,Int] =
    {
      if(map.contains(key)) map(key) += value
      else map += (key -> value)
      map
    }
  }
}

Measured memory_bytes: 78172
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    from fractions import gcd
    return A * B // gcd(A, B)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(solve(A, B))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

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

    int bot = 2000000000;
    int gain = -1000000000;
    for (int i = 0; i < n; i++) {
        int r;
        cin >> r; cin.ignore();
        if (r - bot > gain) gain = r - bot;
        if (bot > r) bot = r;
    }
    cout << gain << endl;

    return 0;
}

Measured memory_bytes: 3120
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        n: u16,
        k: u16,
    }

    let mut sunuke = vec![0; n as usize];
    for _i in 0..k {
        input! {
            dd: u16,
            aa: [u16; dd as usize],
        }
        for j in 0..dd {
            sunuke[aa[j as usize] as usize - 1] += 1;
        }
    }
    println!("{}", sunuke.into_iter().filter(|&s| s == 0).count());
}


Measured memory_bytes: 2228
#include<iostream>
#include<cmath>
using namespace std;
bool pr[300000]={0};
bool is_sosu(int a){
	for(int i=2;i<=sqrt(a);i++){
		if(a%i==0)return false;
	}
	return true;
}
int main(){
	for(int i=2;i<=300000;i++){
		pr[i]=is_sosu(i);
	}
	int n;
	while(cin>>n,n){
		int cnt=0;
		for(int i=n+1;i<=2*n;i++){
			if(pr[i]){
			//cout<<i<<endl;
			cnt++;
			}
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1452
#include<stdio.h>

int main(void) {
  int N, red = 0, blue = 0;
  char s[101];
  scanf("%d", &N);
  scanf("%s", s);

  for(int i=0;i<N;i++) if(s[i] == 'R') red++; else blue++;

  if(red > blue) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}



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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

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

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

//---------------------------------------------------------------
// 解説を読んで修正
//---------------------------------------------------------------
int N;
int A[1000002];

signed main(){
	cin >> N;
	int max = 0;
	REP(i, 1 , N+1) {
		scanf("%d", &A[i]);
		max += abs(A[i-1] - A[i]);
//		cout << i << " max = " << max << endl;
	}
	max += abs(A[N]);
//	cout << "last max = " << max << endl;
	
	int c;
	REP(i, 1, N+1) {
		cout << (max + abs(A[i-1]-A[i+1]) - abs(A[i-1]-A[i]) - abs(A[i]-A[i+1])) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1664
#include<stdio.h>

int main(void){
  int m1,m2,d1,d2;
  
  scanf("%d %d",&m1,&d1);
  scanf("%d %d",&m2,&d2);
  
  if(m1 == m2)
    printf("0\n");
  else
    printf("1\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 1e5;
set<int> es[MAX_V], rs[MAX_V];
int par[MAX_V];

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, N+M-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].insert(v), rs[v].insert(u);
    }
    int root;
    rep(i, N){
        if(sz(rs[i]) == 0) root = i;
    }
    par[root] = -1;
    queue<int> que;
    que.push(root);
    while(!que.empty()){
        int i = que.front();
        que.pop();
        for(auto &e: es[i]){
            if(sz(rs[e]) == 1){
                que.push(e);
                par[e] = i;
            }
            else rs[e].erase(i);
        }
    }
    rep(i, N) cout << par[i]+1 << endl;
}

Measured memory_bytes: 21632
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
#define vl vector<ll>
#define vi vector<int>
#define vli vector <pair <ll, int> >
#define vll vector <pair <ll, ll> >
using namespace std;

ll n;

ll get(ll x) {

    ll sum = 0;

    while(x) {
        sum += (x % 10);
        x /= 10;
    }

    return sum;

}

int main(){


cin >> n;

ll ans = 0;

for(int i = 1; i <= n / 2; ++i) {

    if(!ans) {ans = get(i) + get(n - i);}

    ans = min(ans, get(i) + get(n - i));

}

cout << ans;


return 0;
}



Measured memory_bytes: 256
n = int(input())
d = input().split()
m = int(input())
t = input().split()

d.sort()
t.sort()
a = 0

for x in t:
    for i in range(a, n):
        if d[i] > x:
            print('NO')
            exit()
        if x == d[i]:
            a = i+1
            break

print('YES')


Measured memory_bytes: 33784
#!python3

import numpy as np


# input
N = int(input())
A, B = np.zeros(N, int), np.zeros(N, int)
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))


def main():
    if (A == B).all():
        print(0)
        return
    
    ans = A.sum() - B[A > B].min()
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12776
try:
    k = int(input())
    l = list(map(int,input().split(' ')))
    c = 0
    for i in range(len(l)-1):
      x = l[i+1]-l[i]
      if x<0:
        l[i+1]+=abs(x)
        c+=abs(x)
    print(c)
except:
    pass


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

int main(){
  int n, T;
  cin >> n >> T;
  vector<int> a(200000);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  long long ans = T;
  for(int i = 0; i < n - 1; i++){
    ans += min(T, a.at(i+1) - a.at(i));
  }
  cout << ans << endl;
}

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

int main(){
    int a,b,k;cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<< "OK" <<endl;
            break;
        }
        if(i==b){
            cout<<"NG"<<endl;
        }
    }
    
    
    
}

Measured memory_bytes: 3592
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	pair<int, int> D;
	int mina = INF;
	int a;

	cin >> N >> K;
	rep(i, 0, N)
	{
		cin >> a;
		if (chmin(mina, a))
		{
			D.first = i;
			D.second = N - i - 1;
		}
	}

	int ans = 0;
	while (D.first > 0)
	{
		ans++;
		D.first -= (K - 1);
	}
	D.second += D.first;
	while (D.second > 0)
	{
		ans++;
		D.second -= (K - 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256