akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

public class program{
    public static void Main(){
        int elaps = 0;
        var Q = new Queue<Process>(100005);
        var nq = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var n = nq[0];
        var q = nq[1];

        for(int i=0; i<n; i++){
            var pro = Console.ReadLine().Split(' ').ToArray();
            Q.Enqueue(new Process(pro[0], int.Parse(pro[1])));
        }

        Process p;
        while(!Q.IsEmpty()){
            p = Q.Dequeue();
            if(q >= p.time){
                elaps += p.time;
                Console.WriteLine("{0} {1}", p.name, elaps);
            }else{
                elaps += q;
                p.time -= q;
                Q.Enqueue(p);
            }
        }
        //Q.Print();

    }
}

public class Queue<T>{
    private T[] Q;
    private int head;
    private int tail;
    private int MAX;

    public Queue(int n){
        Q = new T[n];
        MAX = n;
    }

    public void Initialize(){
        head = tail = 0;
    }

    public bool IsEmpty(){
        return head == tail;
    }

    public bool IsFull(){
        return head == (tail+1) % MAX;
    }

    public void Enqueue(T x){
        if(IsFull()){
            Console.WriteLine("error");
        }
        Q[tail] = x;
        tail = (tail+1) % MAX;
    }

    public T Dequeue(){
        if(IsEmpty()){
            Console.WriteLine("error");
        }
        T x = Q[head];
        head = (head+1) % MAX;

        return x;
    }

    public void Print(){
        while(!IsEmpty()){
            Console.WriteLine(this.Dequeue().ToString());
        }
    }
}

public class Process{
    public string name;
    public int time;

    public Process(string n, int t){
        name = n;
        time = t;
    }

    public override string ToString(){
        return this.name + " " + this.time;
    }
}



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

using Weight=long long int;

struct Edge{
    int src,dest;
    Weight weight;
    Edge(int s,int d,Weight w):src(s),dest(d),weight(w){};
    bool operator>(const Edge& rhs){
        return weight>rhs.weight;
    }
    bool operator<(const Edge& rhs){
        return weight<rhs.weight;
    }
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

class UnionFind {
    int N;
    vector<int> rank;
    vector<int> par;
    public:
    UnionFind(int n):N(n){
        rank.resize(n,0);
        par.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
        }
    }

    int find(int x){
        int xx=par[x];
        if(xx==x){
            return x;
        }
        return par[x]=find(xx);
    }

    bool same(int x,int y){
        return find(x)==find(y);
    }

    void unite(int x,int y){
        x=find(x),y=find(y);
        if(rank[x]<rank[y]){
            par[x]=y;
        }
        else{
            if(rank[x]==rank[y]) rank[x]++;
            par[y]=x;
        }
    }

};

Weight kruskal(int V,Edges &edges){
    sort(edges.begin(),edges.end());
    Weight res=0;
    UnionFind uf(V);
    for(auto e:edges){
        if(!uf.same(e.src,e.dest)){
            uf.unite(e.src,e.dest);
            res+=e.weight;
        }
    }
    return res;
}

Weight kruskal(Graph& g){
    Edges edges;
    for(auto es:g){
        edges.reserve(edges.size()+es.size());
        edges.insert(edges.end(),es.begin(),es.end());
    }
    return kruskal(g.size(),edges);
}

Weight prim(Graph& g){
    if(g.size()==0) return 0;
    vector<int> connected(g.size());
    int cnt=0;
    priority_queue<Edge,vector<Edge>,greater<>> que;
    que.push(Edge(-1,0,0));
    Weight res=0;
    while(!que.empty()){
        Edge e=que.top();
        que.pop();
        if(connected[e.dest]) continue;
        connected[e.dest]=true;
        cnt++;
        res+=e.weight;
        for(auto &ee:g[e.dest]) if(!connected[ee.dest]) que.push(ee);
    }
    return res;
}

int main(){
    int V,E;
    cin>>V>>E;
    Graph g(V);
    for(int i=0;i<E;i++){
        int s,t;
        Weight w;
        cin>>s>>t>>w;
        g[t].push_back(Edge(t,s,w));
        g[s].push_back(Edge(s,t,w));
    }
    cout<<prim(g)<<endl;
    return 0;
}

Measured memory_bytes: 10328
/*
in the name of ALLAH
author: Sepehr_Noori
*/
#include <bits/stdc++.h>

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define pp pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef unsigned long long  ll;
typedef map<int,int> mpii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef double db;
typedef long double ld;
const int mod = 1e9+7;
////////////////////////

ll a[10000],b[10000];
ll dp[10000+5][10000+5];

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

    int h,n;
    cin>>h>>n;
    int cnt=1,dn=n;
    while(dn--){
        cin>>a[cnt]>>b[cnt];
        cnt++;
    }
    memset(dp,0,sizeof dp);
    // cout<<ceil((db)5/8)*b[1]<<endl;
    // return 0;
    for (int i = 1;i<=n;i++){
        for (int j=1;j<=h;j++){
            if(i==1){
                dp[i][j] = ceil((db)j/a[1])*b[1];
            }else if(a[i]>=j){
                dp[i][j] = min(dp[i-1][j],b[i]);
            }else{
                dp[i][j] = min(dp[i-1][j],dp[i][j-a[i]]+b[i]);
            }   
        }
    }
    cout<<dp[n][h]<<endl;

}
    /*ll solve(ll h){
    if(h == 1){
        return 1;
    }
    ll s=0,g=0;
    if(h%2 != 0){
        h--;
    }
    h/=2;
    // s++;
    g = solve(h);
    // s += 2*g;
    // cout<<h<<" "<<s<<" "<<g<<endl;
    return 2*g+1;
}
    ll h;
    cin>>h;
    ll ans = solve(h); 
    cout<<ans<<endl;
}
    /*ll s=0,k,n,x;
    vi h;
    cin>>n>>k;
    for (int i =1;i<=n;i++){
        cin>>x;
        h.pb(x);
    }
    sort(all(h));
    while(k-- &&SZ(h))
        h.pp();
    for (auto z:h){
        s+=z;
    }
    cout<<s<<endl;

}
    /*int h,n,x,s=0;
    cin>>h>>n; 
    for (int i = 0;i<n;i++){
        cin>>x;
        s+=x;
    }
    if(s>=h){
        cout<<"Yes"<<endl;
        return 0;
    }else
    {
        cout<<"No"<<endl;
        return 0;
    }
    
}
    /*db h,a;
    cin>>h>>a;
    cout<<ceil(h/a)<<endl;;

    return 0;
}*/

Measured memory_bytes: 782336
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		long sum=0;
		int cnt=0;
		int zero_cnt=0;
		int min=1_000_000_005;
		for (int i=0;i<N;i++) {
			int tmp=Math.max(A[i],-A[i]);
			sum+=tmp;
			if (A[i]<0) {
				cnt++;
			}
			if (A[i]==0) {
				zero_cnt++;
			}
			min=Math.min(min,tmp);
		}
		if (zero_cnt==0 && cnt%2==1) {
			sum-=min*2;
		}
		System.out.println(sum);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);

    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }

    bool can = true;
    sort(A.begin(),A.end());
    for(int i=0; i<N-1; i++){
        if(A.at(i) ==A.at(i+1)) can = false;
    }

    if(can) cout << "YES" << endl;
    else cout <<"NO" << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define SIZE(x) ((int)(x).size())
#define UQ(v) v.erase(unique(v,begin(),v,end()),v.end());
ll INF = 1LL <<61;
#define pb push_back 
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
ll mod7 = 1000000007;
ll mod9 = 1000000009;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i,x,n) for(int i=x;i<n;++i)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define print(x) cout<<x<<endl;
#define wait int xxxxxxx;cin>>xxxxxxx;
//vector< vector<int> > v (max1, vector<in t>(max2) );

int main(){
	int n,l,f=0,ans=-1;
	cin >> n>>l;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	rep(i, n-1) {
		if (a[i] + a[i + 1] >= l) {
			ans = i + 1;
			f = 1;
			break;
		}
	}
	if (f) { print("Possible"); }
	else { print("Impossible"); }
	rep(i, ans-1) {
		if(f)print(i + 1);
		
	}
	for (int i = n - 2; i >= ans; --i) {
		if (f)print(i + 1);
	}
	if(f)print(ans);
	wait;
	return 0;
}

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

int main(){
	int r, d, x;
	cin >> r >> d >> x;

	for(int i = 0; i < 10; i++){
		x = r*x - d;
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec a(n+1);
	repn(i, n) cin >> a[i];
	Vec s(n+1);
	repn(i, n) s[i] = s[i-1]+a[i];

	map<ll, ll> mp;
	mp[0] = 1;
	ll ans = 0;
	repn(i, n){
		if(i >= k) mp[(s[i-k]-i+k)%k]--;
		ans += mp[(s[i]-i)%k]++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 15872
use std::collections::VecDeque;
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m): (usize, usize) = parse!(it, 2);
    let mut g = vec![vec![]; 3 * n];
    for _ in 0..m {
        let (u, v): (usize, usize) = parse!(it, 2);
        let (u, v) = (u - 1, v - 1);
        g[3 * u].push(3 * v + 1);
        g[3 * u + 1].push(3 * v + 2);
        g[3 * u + 2].push(3 * v);
    }
    let (s, t): (usize, usize) = parse!(it, 2);
    let (s, t) = (3 * (s - 1), 3 * (t - 1));
    let mut q = VecDeque::new();
    let mut seen = vec![false; 3 * n];
    q.push_back((s, 0));
    seen[s] = true;
    while let Some((u, l)) = q.pop_front() {
        for &v in &g[u] {
            if v == t {
                println!("{}", (l + 1) / 3);
                return;
            }
            if !seen[v] {
                q.push_back((v, l + 1));
                seen[v] = true;
            }
        }
    }
    println!("{}", -1);
}

fn test() {
    let mut f = fs::File::open("/Users/yohei_tamura/work/atcoder/abc132/src/bin/foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_main() {
        test();
    }
    #[test]
    fn test_input() {
        let s = "
        4 4
1 2
2 3
3 4
4 1
1 3
        ";
        solve(s);
    }
}


Measured memory_bytes: 22780
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      System.out.println((char)(br.readLine().charAt(0) + 1));
    }
  }
}


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

using namespace std;

int main()
{
	int n,m;
	int i,j;
	char ch[100];
	string str;
	
	for(;;)
	{
		cin >> m >> n  ;
		if(n==0 && m==0)
			break;
		
		int ans[1024]={0};
		for(i=0;i<m;i++)
			ans[i]=i+1;
		
		j=0;
		for(i=1;i<=n;i++)
		{
			cin >> str ;
			
			sprintf(ch,"%d",i);
			int k;
/*			if(j==m)
			{
				j=0;
			}
			int over=0;
			for(k=j;ans[k]==0;++k)
			{
				if(k>=m)
				{
					over=1;
					break;
				}
			}
			if(over!=1)
				j=k;
*/
			int flag=0;
			for(int l=0;l<m;l++)
			{
				if(ans[l]!=0)
				flag++;
			}
//			cout << "--------nowflag:" << flag << "-----------  " ;
			if(flag>1)
			{
				if(i%3==0 && i%5==0)
				{
					if(str!="FizzBuzz")
					{
//						cout << "notFizzBuzz j:" << j << endl;
						ans[j]=0;
					}
					else
					{
//						cout << "safe j:" << j << endl;
					}
				}
				else if(i%3==0)
				{
					if(str!="Fizz")
					{
//						cout << "notFizz j:" << j << endl;
						ans[j]=0;
					}
					else
					{
//						cout << "safe j:" << j << endl;
					}
				}
				else if(i%5==0)
				{
					if(str!="Buzz")
					{
//						cout << "notBuzz j:" << j << endl;
						ans[j]=0;
					}
					else
					{
//						cout << "safe j:" << j << endl;
					}
				}
				else
				{
					if(str!=ch)
					{
//						cout << "notMath j:" << j << endl;
						ans[j]=0;
					}
					else
					{
//						cout << "safe j:" << j << endl;
					}
				}
				j++;
				int c;
				for(c=j;ans[c]==0;)
				{
					c++;
					if(c>m-1)
						c=0;
//					cout << "ans[" << c << "]:" << ans[c] << endl;
				}
				j=c;
			}
		}
		int las;
		for(i=0;i<m;i++)
		{
			if(ans[i]!=0)
				las=i;
		}
		
//		cout << "ans:" ;
		for(i=0;i<m;i++)
		{
			if(ans[i]!=0)
			{
				cout << ans[i] ;
				if(i<las)
					cout << " " ;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	vector<ll> x(n);
	vector<ll> y(n);
	vector<ll> h(n);
	rep(i,n) cin >> x.at(i) >> y.at(i) >> h.at(i);
	if(n==1){
		cout << x.at(0) << " " << y.at(0) << " " << h.at(0) << endl;
		return 0;
	}
	for(ll i=0;i<=100;++i){
		for(ll j=0;j<=100;++j){
			ll H;
			rep(k,n){
				if(h.at(k)!=0){
					H=h.at(k)+abs(x.at(k)-i)+abs(y.at(k)-j);
					break;
				}
			}
			bool flg=true;
			if(H<1) continue;
			for(ll k=0;k<n;++k){
				if(h.at(k)==0){
					if(abs(x.at(k)-i)+abs(y.at(k)-j) < H){
						flg=false;
						break;
					}
				}
				else if(h.at(k)+abs(x.at(k)-i)+abs(y.at(k)-j)!=H){
					flg=false;
					break;
				}
			}
			if(flg){
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
local max = math.max
local min = math.min
--[[ https://www.slideshare.net/iwiwi/ss-3578491 3~18of73 ]]--

--半分の実装のみ(これでも十分早いらしい)
local UFT = {}

---要素数nでpar[]を初期化
function UFT.new(n)
	local obj = {par = {}}
	for i = 1, n do
		obj.par[i] = i
	end
	return setmetatable(obj,{__index = UFT})
end

---木の根を求める
function UFT:find(x)
	if self.par[x] == x then
		-- 根
		return x
	else
		-- 経路圧縮
		self.par[x] = self:find(self.par[x])
		return self.par[x]
	end
end

---xとyが同じ集合に属するか否か
function UFT:same(x, y)
	return self:find(x) == self:find(y)
end

---xとyの属する集合を併合
function UFT:union(x, y)
	x = self:find(x)
	y = self:find(y)
	if x == y then
		return
	end

	self.par[max(x, y)] = min(x, y)
end

--[[ I referred until here. ]]--

local read = io.read

local n, m = read("n", "n")
local uft = UFT.new(n)
for i = 1, m do
	local a_i, b_i = read("n", "n")
	uft:union(a_i, b_i)
end

local is_finded_num_t = {}
for i = 1, n do
	local par_num = uft:find(i)
	if is_finded_num_t[par_num] then
		is_finded_num_t[par_num] = is_finded_num_t[par_num] + 1
	else
		is_finded_num_t[par_num] = 1
	end
end

local uft_par_max = -1
for i = 1, n do
	if is_finded_num_t[i] then
		uft_par_max = max(uft_par_max, is_finded_num_t[i])
	end
end

print(uft_par_max)


Measured memory_bytes: 10712
#include <stdio.h>

int main()
{
	char s[11];
	scanf("%s", s);
	
	char output[11] = {};
	int i, k;
	for (i = 0, k = 0; s[i] != 0; i++) {
		if (s[i] == 'B') {
			if (k > 0) output[--k] = 0;
		} else output[k++] = s[i];
	}
	
	printf(output);
	fflush(stdout);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
const int MAX = 1e9 + 1;

typedef long long ll;
typedef vector<vector<int>> Graph;

int main() {
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> A(a), B(b), C(c);
	rep(i, a)  cin >> A[i];
	rep(i, b)  cin >> B[i];
	rep(i, c)  cin >> C[i];

	sort(A.begin(), A.end(), greater<int>());
	sort(B.begin(), B.end(), greater<int>());
	sort(C.begin(), C.end(), greater<int>());

	//A.insert(A.begin(), MAX);
	//B.insert(B.begin(), MAX);

	int i = x - 1;
	int j = y - 1;
	for (int k = 0; k < c; k++){
		if (i < 0 && j < 0)  break;
		if (A[i] > C[k] && B[j] > C[k])  break;
		if (j < 0) {
			if (A[i] < C[k]) {
				A[i] = C[k];
				i--;
			}
		}
		else if (i < 0) {
			if (B[j] < C[k]) {
				B[j] = C[k];
				j--;
			}
		}
		else {
			if (A[i] > B[j]) {
				if (B[j] < C[k]) {
					B[j] = C[k];
					j--;
				}
			}
			else {
				if (A[i] < C[k]) {
					A[i] = C[k];
					i--;
				}
			}
		}
	}
	ll ans = 0;
	rep(i, x)  ans += A[i];
	rep(i, y)  ans += B[i];

	cout << ans << endl;
}


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

using namespace std;



int main () {

	int n;
	scanf("%d", &n);

	priority_queue<int> pq;

	int ans = 0;

	for (int i = 0, x; i < n; ++i) {
		scanf("%d", &x);

		if (pq.empty() || (-1)*(int)pq.top() > x) {
			++ans;
		}

		pq.push(-x);
	}	

	printf("%d\n", ans);
		

	return 0;
}
 

Measured memory_bytes: 1400
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char s[100005]={},ans[100005]={};
int check(int n)
{
	int l=n-1, r=1;
	for(int i=0;i<n;i++){
		if( (s[i]=='o'&&ans[i]=='S')||(s[i]=='x'&&ans[i]=='W') ){
			if(ans[l]!=ans[r]) return 0;
		}
		else{
			if(ans[l]==ans[r]) return 0;
		}
		l++; r++;
		if(l==n) l=0;
		if(r==n) r=0;
	}
	return 1;
}
void FS(int n)
{
	for(int k=1;k<=4;k++){ //四种假设情况
		memset(ans,0,sizeof(ans));
		if(k==1) {ans[0]='S'; ans[1]='S';} //羊羊
		if(k==2) {ans[0]='S'; ans[1]='W';} //羊狼
		if(k==3) {ans[0]='W'; ans[1]='S';} //狼羊
		if(k==4) {ans[0]='W'; ans[1]='W';} //狼狼
		for(int i=1;i<n-1;i++){
			if(s[i]=='o'){
				if(ans[i]=='S') ans[i+1]=ans[i-1]; //羊o则两边为同种动物
				else{ //狼o则两边为不同动物
					if(ans[i-1]=='S') ans[i+1]='W';
					else ans[i+1]='S';
				}
			}
			else{
				if(ans[i]=='S'){ //羊X则两边为不同动物
					if(ans[i-1]=='S') ans[i+1]='W';
					else ans[i+1]='S';
				}
				else ans[i+1]=ans[i-1]; //狼X则两边为同种动物
			}
		}
		if(check(n)==1){
			printf("%s\n",ans);
			return;
		}
	}
	printf("-1\n");
}
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	FS(n);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() {
  string s, t = "CODEFESTIVAL2016";
  cin >> s;
  int slen = t.size();
  int res = 0;
  rep(i, slen){
      if(s[i]!=t[i]){
          res++;
      }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    vector <int> a(3);
    REP(i,3)cin >> a[i];
    sort(ALL(a));
    cout << a[1]-a[0] + a[2]-a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	for i := 1; i <= n; i++ {
		x := i
		if x%3 == 0 {
			fmt.Printf(" %d", i)
			continue
		}
		for x > 0 {
			if x%10 == 3 {
				fmt.Printf(" %d", i)
				break
			}
			x /= 10
		}
	}
	fmt.Print("\n")
}



Measured memory_bytes: 1128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      mut aa: [usize; n],
    }
    aa.sort();

    fn is_ok(mid: usize, aa: &Vec<usize>) -> bool {
        let n = aa.len();
        let mut w = aa[mid];
        for i in 0..mid {
            w += aa[i];
        }
        let mut ok = true;
        for i in mid+1..n {
            if aa[i] > 2*w {
                ok = false;
            } else {
                w += aa[i];
            }
        }
        ok
    }

    let mut ok = n;
    let mut ng = 0;
    while ok != ng {
        let mid = (ok + ng) / 2;
        if is_ok(mid, &aa) {
            ok = mid;
        } else {
            ng = mid + 1;
        }
    }
    puts!("{}\n", n-ok);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll x;
   cin>>x;
   
   ll curr = 100;
   ll ans = 0;
   while(curr<x)
   {
       ld temp = (curr*((ld)1.01));
       curr = temp;
       ans++;
   }
   cout<<ans;
   
   return 0;        
}  
  
   

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
 
int main()
{
	double s;
	cin >> s;
	double length = s / 3.0;
    s -= length;
    double breadth = s / 2.0;
    double height = s - breadth;
 
    double sum = length * breadth * height;
    printf("%.12f\n",abs(sum));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[101],n,ans;
int cmp(int a,int b)
{
    return a>b;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n,cmp);
    if(n%2==1)
    {
        n-=1;
        ans+=a[n+1];
    }
    for(int i=1;i<=n;i+=2)
    {
        ans+=a[i]-a[i+1];
    }
    cout<<ans;
    //system("pause");
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

int n;
int l[222];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < 2*n; i++) scanf("%d", l+i);
  sort(l, l+2*n, greater<int>());

  int res = 0;
  for (int i = 0; i < 2*n; i+= 2) {
    res += l[i+1];
  }

  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  P data[1024];
  data[0] = P(1,0);
  REPR(i,1024){
    P p = data[i-1];
    P v = -p/abs(p);
    v *= P(0,-1);
    p += v;
    data[i] = p;
  }
  cout.precision(5);
  while(true){
    int n;
    cin>>n;
    if(n==-1)break;
    cout<<fixed<<data[n-1].real()<<endl<<data[n-1].imag()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    ll odp = 0;
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[i] + a[i + 1] > x)
        {
            ll d = a[i] + a[i + 1] - x;
            odp += d;
            if (a[i + 1] >= d)
                a[i + 1] -= d;
            else
            {
                d -= a[i + 1];
                a[i + 1] = 0;
                a[i] -= d;
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Arrays;
 
public class Main {
 
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int target, num;
    String str = br.readLine();
    StringTokenizer st = new StringTokenizer(str);
    target = Integer.parseInt(st.nextToken());
    num =Integer.parseInt(st.nextToken());
    boolean A[] = new boolean[200001];
    boolean B[] = new boolean[200001];
    Arrays.fill(A,false);
    Arrays.fill(B,false);
    for (int i = 0; i < num; i++) {
      int tmp1, tmp2;
      str = br.readLine();
      st = new StringTokenizer(str);
      tmp1 = Integer.parseInt(st.nextToken());
      tmp2 = Integer.parseInt(st.nextToken());
      
      if (tmp1 == 1) {
        A[tmp2] = true;
      } else if (tmp2 == target) {
        B[tmp1] = true;
      }
    }
    for (int i = 0; i <= 200000; i++) {
        if (A[i] && B[i]) {
          System.out.println("POSSIBLE");
          return;
        }
    }
      System.out.println("IMPOSSIBLE");
  }
 
}

Measured memory_bytes: 45828
#include <iostream>
using namespace std;
int find(int h[100],int n)
{ 
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int j=2;j<n;j++)
    {
        dp[j]=min(dp[j-1]+abs(h[j]-h[j-1]),dp[j-2]+abs(h[j]-h[j-2]));
    }
    return dp[n-1];
    

}
int main() {
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
      cin>>h[i];
    int ans=find(h,n);
    cout<<ans;
    
}


Measured memory_bytes: 4304
#include <stdio.h>
int main()
{
    long long n,m,i,j,k,sum=0,a=0,b=0,c=0,d=1;
   char ch[6002];
   scanf("%lld",&n);
   for(m=0;m<=n;m++)
   {
       scanf("%c",&ch[m]);
       if(ch[m]=='R')
        a++;
       if(ch[m]=='G')
        b++;
       if(ch[m]=='B')
        c++;
   }
   sum=a*b*c;
   for(i=1;i<=n-2;i++)
   {
       for(d=1;i+d+d<=n;d++)
       {
           if(ch[i]!=ch[i+d]&&ch[i]!=ch[i+d+d]&&ch[i+d]!=ch[i+d+d])
            sum--;
       }
   }
   printf("%lld",sum);
   return 0;
}


Measured memory_bytes: 1684
let () =
  let alphs = Array.init 26 (fun x -> x + 97 |> Char.chr ,0) in
  let set str dic =
    String.iter
      (fun c ->
         match c with
         | 'a'..'z' | 'A'..'Z' ->
           let lc = Char.lowercase c in
           let i = Char.code lc - 97 in
           dic.(i) <- lc, snd dic.(i) + 1
         | _ -> ())
      str;
    dic
  in 
  let buf = Buffer.create 1028 in
  try
    while true do
      Buffer.add_string buf (read_line ());
    done
  with End_of_file ->
    set (Buffer.contents buf) alphs
    |> Array.iter (fun x -> Printf.printf "%c : %d\n" (fst x) (snd x))

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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<int>B(N);
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    vector<int>C(N-1);
    for (int i = 0; i < N-1; ++i) {
        cin >> C[i];
    }
    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += B[i];
    }
    for (int i = 0; i < N - 1; ++i) {
        if(A[i+1] == A[i]+1) ans += C[A[i]-1];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

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())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = ns()
    uf = UnionFind(n + m)

    for _ in range(n):
        a = na()
        for i in range(1, a[0] + 1):
            uf.union(_, n + a[i] - 1)

    flg = True
    for i in range(1, n):
        if not uf.same(i, i - 1):
            flg = False
            break

    print("YES" if flg else "NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 80800
#include <stdio.h>

#define N 100

int main() {
	static char s[N][N + 1];
	int h, w, i;

	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++)
		scanf("%s", s[i]);
	for (i = 0; i < h; i++)
		printf("%s\n%s\n", s[i], s[i]);
	return 0;
}


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

int c[100][100];
int main() {
	int n; scanf("%d", &n);
	ll ans = 0;
	rep(i, n)rep(j, n) {
		scanf("%d", &c[i][j]);
		if (i > j)ans += min(c[i][j], c[j][i]);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3256
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
x = ni()
if 400<=x < 600:
    r=8
if 600<=x < 800:
    r=7
if 800<=x < 1000:
    r=6
if 1000<=x < 1200:
    r=5
if 1200<=x < 1400:
    r=4
if 1400<=x < 1600:
    r=3
if 1600<=x < 1800:
    r=2
if 1800<=x < 2000:
    r=1
print(r)


Measured memory_bytes: 9476
#include <iostream>
#include <vector>

using namespace std;

int main() {
  uint32_t N, Q;
  int64_t K;
  cin >> N >> K >> Q;
  vector<uint32_t> A(Q);
  for(auto& a : A) {cin >> a;}
  
  vector<int64_t> point(N);
  for(auto a : A) {
    point[--a]++;
  }
  for(auto& p : point) {
    if (K - (Q - p) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define deb(x) cout<<#x<<" "<<x
#define pi 3.1415926535
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double r;
    cin>>r;
    r=r*2*pi;
    cout<<prec(4,r);
    return 0;
}
//make all values ll

Measured memory_bytes: 3756
#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 unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
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};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  ld a, b, h, m;
  cin >> a >> b >> h >> m;

  ld theta = fabs(h * 30 + m * 0.5 - m * 6);
  theta = min(theta, 360 - theta);
  ld ans = a * a + b * b - 2 * a * b * cos(M_PI * theta / 180);
  ans = sqrt(ans);
  cout << ans << '\n';





  
  return 0;
}

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

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

	if(a==b&&b==c){
		cout<<1<<endl;
	}else if(a!=b&&a!=c&&b!=c){
		cout<<3<<endl;
	}else{
		cout<<2<<endl;
	}

}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

std::map<int64_t, int64_t> memo;
int64_t solve(int64_t h) {
    debug(h);
    if (memo.find(h) != memo.end()) {
        return memo.at(h);
    }
    int64_t res = -1;
    if (h == 0) {
        return 0L;
    }
    if (h == 1) {
        res = 1L;
    } else if (h > 1L) {
        int64_t r = solve(h / 2);
        res = 2 * r + 1;
    } else {
        assert(false);
    }
    debug(res);
    memo[h] = res;
    return res;
}

int main() {
    int64_t H;
    cin >> H;
    cout << solve(H) << endl;
}

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

typedef long long  LL;
const int mo=int(1e9+7);
int n,f[100010],g[100010],sf[100010],sg[100010];
LL a,b,s[100010];

void work()
{
	scanf("%d %lld %lld",&n,&a,&b),s[0]=-1LL<<60;
	for (int i=1; i<=n; i++)  scanf("%lld",&s[i]);
	f[0]=g[0]=sf[0]=sg[0]=1;
	for (int i=1,fl=0,gl=0,pa=0,pb=0; i<n; i++)
		{
			while ((pa<i)&&(s[pa]<=s[i+1]-a))  pa++;
			while ((pb<i)&&(s[pb]<=s[i+1]-b))  pb++;
			f[i]=sg[pa-1],g[i]=sf[pb-1];
			if (s[i+1]-s[i]<a)  for (; fl<i; fl++)  f[fl]=sf[fl]=0;
			if (s[i+1]-s[i]<b)  for (; gl<i; gl++)  g[gl]=sg[gl]=0;
			sf[i]=(sf[i-1]+f[i])%mo,sg[i]=(sg[i-1]+g[i])%mo;
		}
	printf("%d",(sf[n-1]+sg[n-1])%mo);
}

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


Measured memory_bytes: 2560
#include <stdio.h>
#define N 100000
#define Q 50000
int main()
{
    int i = 0, r, l, h, a[N], b[Q], n, q, c=0;
    scanf("%d",&n);
    for(i = 0; i < n; i++)
    {
        scanf("%d ",&a[i]);
    }
    scanf("%d",&q);
    for(i = 0; i < q; i++)
    {
        scanf("%d ",&b[i]);
    }
    for(i = 0; i < q; i++)
    {
        r = n;
        l = 0;
        while(l < r)
        {
            h = (l+r)/2;
            if(b[i] < a[h])
            {
                r = h;
            }
            else if(b[i] > a[h])
            {
                l = h+1;
            }
            else
            {
                c++;
                break;
            }
        }
    }
    printf("%d\n",c);
    

    return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    int K; cin >> K;
    string S; cin >> S;

    if (S.size() <= K) {
      cout << S << endl;
    } else {
      cout << S.substr(0, K) << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int N, M;

int main() {
  cin >> N >> M;
//  priority_queue<int, vector<int>, greater<int> > A;
  priority_queue<int> A;
  int64_t sum;
  for(int i=0,x; i<N; i++){cin >> x;A.push(x);}
  
  while(M--){
    int temp = A.top(); A.pop();
    A.push(temp/2);
  }

  while(!A.empty()){sum += A.top(); A.pop();}

  cout << sum << endl; 
  return 0;
}

Measured memory_bytes: 892
a = input()

count = 0


if a == "++++":
    count = 4
if a == "-+++" or a=="+-++" or a=="++-+" or a=="+++-":
    count = 2
if a == "++--" or a=="+-+-" or a=="-+-+" or a=="--++":
    count = 0
if a == "---+" or a=="--+-" or a=="-+--" or a=="+---":
    count = -2
if a == "----":
    count = -4

    
print(count)

Measured memory_bytes: 3064
def acinput():
    return list(map(int,input().split(" ")))



N=int(input())
B=acinput()

dp=[-1]*(N)

dp[0]=B[0]
for i in range(1,N-1):
    dp[i]=min(B[i],B[i-1])
dp[N-1]=B[N-2]
print(sum(dp))


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

h, w, kk = map(int, input().split())
ss = [[0 for _ in range(h)] for _ in range(w)]
for i in range(h):
    for j, c in enumerate(list(input().strip())):
        if c == '1':
            ss[j][i] = 1

ans = 100000
for i in range(2 ** (h - 1)):
    end = []
    for j in range(h - 1):
        if i & 2 ** j:
            end.append(j + 1)
    end.append(h)
    start = [0]
    for j in end:
        start.append(j)
    start.pop()
    sums = [0] * len(start)

    tans = len(start) - 1
    imp = False
    for j in range(w):
        reset = False
        for k, (s, e) in enumerate(zip(start, end)):
            sums[k] += sum(ss[j][s:e])
            if sums[k] > kk:
                reset = True
                break
        if reset:
            tans += 1
            for k, (s, e) in enumerate(zip(start, end)):
                sums[k] = sum(ss[j][s:e])
                if sums[k] > kk:
                    imp = True
        if imp:
            break
    if not imp:
        ans = min(ans, tans)

print(ans)


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

using namespace std;

const int MAX = 100000;

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

	int n;
	cin >> n;
	int dp[MAX + 1];
	dp[0] = 0;
	for (int i = 1; i <= n; ++i) {
		dp[i] = dp[i - 1] + 1;
		for (int j = 6; j <= i; j *= 6) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
		for (int j = 9; j <= i; j *= 9) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
	}
	cout << dp[n];
	return 0;
}


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

// 
// auto mod int
//
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){

    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];

    mint ans = 0;

    // ケタ数でスープ
    rep(h,60) {
        ll x=0;
        rep(i,n) if(a[i]>>h&1) x++;
        mint tmp = x*(n-x);
        rep(i,h) tmp *=2;
        ans += tmp;
    
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#pragma optimization_level 3
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("sumsqr.in");ofstream out("sumsqr.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    str t; cin>>t;
    t[1] = t[1]=='R' ? 'B' : 'R';
    cout<<t;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
long long int A,B,C;
int main()
{
	cin>>A>>B>>C;
	long long int v;
	v=A*B*C;
	if(v%2==0)
		cout<<"0"<<endl;
	else
	{
		long long int x,y,z;
		x=A*B;
		y=B*C;
		z=A*C;
		if(x<=y&&x<=z)
			cout<<x<<endl;
		else if(y<=x&&y<=z)
			cout<<y<<endl;
		else if(z<=x&&z<=y)
			cout<<z<<endl;	
	} 
	return 0;
 } 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 18

def main():
    N = int(input())
    A = list(map(int,input().split()))
    ans = 1
    if 0 in A:
        print(0)
        return
    for i in range(N):
        ans *= A[i]
        if ans > INF:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 21632
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    vi masu(n);
    rep(i,n)
      cin>>masu[i];
    vi me(m);
    rep(i,m)
      cin>>me[i];
    int now=0;
    rep(i,m){
      now+=me[i];
      if(now>=n-1)break;
      now+=masu[now];
      if(now>=n-1)break;
    }
    cout<<i+1<<endl;
  }
}

Measured memory_bytes: 2980
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

// ei1333さんからパクった
struct Bipartite_Matching
{
	vector< vector< int > > graph;
	vector< int > match, alive, used;
	int timestamp;

	Bipartite_Matching(int n)
	{
		timestamp = 0;
		graph.resize(n);
		alive.assign(n, 1);
		used.assign(n, 0);
		match.assign(n, -1);
	}

	void add_edge(int u, int v)
	{
		graph[u].push_back(v);
		graph[v].push_back(u);
	}

	bool dfs(int v)
	{
		used[v] = timestamp;
		for (int i = 0; i < graph[v].size(); i++) {
			int u = graph[v][i], w = match[u];
			if (alive[u] == 0) continue;
			if (w == -1 || (used[w] != timestamp && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return (true);
			}
		}
		return (false);
	}

	int bipartite_matching()
	{
		int ret = 0;
		for (int i = 0; i < graph.size(); i++) {
			if (alive[i] == 0) continue;
			if (match[i] == -1) {
				++timestamp;
				ret += dfs(i);
			}
		}
		return (ret);
	}
};

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

	int x, y, e;
	cin >> x >> y >> e;

	Bipartite_Matching graph(x + y);
	for (int i = 0; i < e; i++) {
		int xx, yy;
		cin >> xx >> yy;
		graph.add_edge(xx, x + yy);
	}

	cout << graph.bipartite_matching() << endl;
	return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <vector>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
int main() {
  int n, k;
  while (cin>>n>>k , n|k) {
    vector<int> s(k);
    REP(i,k) cin>>s[i];
    REP(j,n) REP(i,k) {
      int tmp; cin>>tmp;
      s[i] -= tmp;
    }
    bool ok = true;
    REP(i,k) if (s[i] < 0) ok = false;
    cout<<(ok?"Yes":"No")<<endl;
  }
  return 0;
}

Measured memory_bytes: 896