akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int N,tmp;

int main(){
	cin>>N;
	int total=0;
	for(int i=0; i<N; i++){
		cin>>tmp;
		if(i%2==0&&tmp%2==1){
			total++;
		}
	}
	cout<<total<<'\n';
}

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

int main() {
    int h, w;
    cin >> h >> w;
    set<pair<int, int>> s;
    multiset<int> m;
    for(int i = 0; i < w; i++) {
        s.emplace(i + 1, i + 1);
        m.insert(0);
    }
    for(int i = 0; i < h; i++) {
        int a, b;
        cin >> a >> b;
        int t = 0;
        auto it = s.lower_bound({a, 0}), jt = it;
        for(; jt != s.end(); ++jt) {
            auto [y, x] = *jt;
            if(y > b)
                break;
            t = x;
            m.erase(m.find(y - x));
        }
        s.erase(it, jt);
        if(t && b < w)
            s.emplace(b + 1, t), m.insert(b + 1 - t);
        cout << (m.empty() ? -1 : *m.begin() + i + 1) << '\n';
    }
    return 0;
}


Measured memory_bytes: 22360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		double res = 0.0;
		
		for (int i = 0; i < n; i++) {
			double money = sc.nextDouble();
			String currency = sc.next();
			
			if (currency.equals("JPY")) {
				res += money;
			} else {
				res += (money * 380000.0);
			}
		}	
		System.out.println(res);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

#define M 800005
#define ll long long

int n, q, tot;
int fa[M];
ll ans, d[M];

struct Edge
{ int u, v; ll w; } e[M];

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { (x *= 10) += ch - '0'; ch = getchar(); }
	return x * f;
}

inline int findf(int x)
{ return fa[x] == x ? x : fa[x] = findf(fa[x]); }

inline bool cmp1(Edge a, Edge b)
{ return a.w < b.w; }

inline void kruscal()
{
	sort(e + 1, e + 1 + tot, cmp1);
	for (int i = 1; i <= tot; i++)
	{
		int uf = findf(e[i].u), vf = findf(e[i].v);
		if (uf == vf) continue;
		fa[uf] = vf; ans += e[i].w;
	}
}

int main()
{
	n = read(), q = read(); tot = q;
	for (int i = 0; i < n; i++) fa[i] = i;
	memset(d, 0x3f3f3f3f, sizeof(d));
	for (int i = 1; i <= q; i++)
	{
		e[i].u = read(), e[i].v = read(); e[i].w = read();
		d[e[i].u] = min(d[e[i].u], e[i].w + 1);
		d[e[i].v] = min(d[e[i].v], e[i].w + 2);
	}

	for (int i = 0; i < n; i++)
		d[i] = min(d[i], d[(i-1+n)%n] + 2);
	for (int i = 0; i < n; i++)
		d[i] = min(d[i], d[(i-1+n)%n] + 2);

	for (int i = 0; i < n; i++)
		e[++tot].u = i, e[tot].v = (i+1)%n, e[tot].w = d[i];

	kruscal();

	cout << ans;

	return 0;
}

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

"""
input:
4 6 1
0 1 1
0 2 4
2 0 1
1 2 2
3 1 1
3 2 5

output:
3
0
2
INF
"""

import sys
import heapq as hp
from math import isinf

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        source, target, cost = map(int, each)
        init_adj_table[source][target] = cost
    return init_adj_table


def dijkstra_path_heap():
    # path search init
    distance[root] = 0
    path_heap = []
    # heapq: rank by tuple[0], at here it's d[u]
    hp.heappush(path_heap, (0, root))

    while path_heap:
        current = hp.heappop(path_heap)[1]

        color[current] = BLACK

        for adj, cost in adj_table[current].items():
            if color[adj] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = distance[current] + cost
                if alt_path < distance[adj]:
                    # update path_list
                    distance[adj] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj))
                    color[adj] = GRAY
                    parents[adj] = current

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges, root = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    distance = [float('inf')] * vertices
    parents = [-1] * vertices
    color = [WHITE] * vertices
    init_adj_table = tuple(dict() for _ in range(vertices))

    adj_table = generate_adj_table(v_info)
    ans = dijkstra_path_heap()

    # print('\n'.join(('INF' if isinf(ele) else str(ele) for ele in ans)))
    for ele in ans:
        if isinf(ele):
            print("INF")
        else:
            print(ele)

Measured memory_bytes: 129416
#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,n)    for(auto i=s;i<n;++i)
#define foo(i,s,n)    for(auto i=s;i>=n;--i)
#define ll long long
#define ull unsigned long long int
#define fast  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            int t; cin>>t; while(t--)
const int MOD = 1000000007;
ll mod(ll x){
    return (x%MOD + MOD)%MOD;
}
ll mul(ll a , ll b){
    return mod(mod(a)*mod(b));
}
bool comp(pair<ll,ll>& a, pair<ll,ll>& b)
{
    if(a.second == b.second)
    return a.first > b.first;
    else
    return b.second < a.second;
}
static int rowNbr[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
static int colNbr[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int main()
{
    fast
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cr=0;
    fo(i,0,n)
    {
        if(s[i]=='R') cr++;
    }
    int cnt=0;
    fo(i,0,cr)
    {
        if(s[i]=='W') cnt++;
    }
    cout<<cnt<<endl;



    return 0;
}





Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<ll> L(N);
    ll ans=0;
    rep(i,N)cin>>L.at(i);
    rep(i,N){
        for(int j=i+1;j<N;j++){
            for(int k=j+1;k<N;k++){
                vector<ll> a(3);
                a.at(0)=L.at(i);
                a.at(1)=L.at(j);
                a.at(2)=L.at(k);
                sort(a.begin(),a.end());
                if(a.at(0)<a.at(1) && a.at(1)<a.at(2) && a.at(0)+a.at(1)>a.at(2))ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main() {
	int t;
	//cin>>t;
	t = 1;
	while(t--) {
		ll n,k;
		cin>>n>>k;
		ll a[n];
		for(int i=0; i<n; i++) cin>>a[i];

		for(int i = k; i<n; i++) {
			if(a[i] > a[i-k]) cout<<"Yes \n";
			else cout<<"No \n";
		}

	}
	return 0;
}
// 0 1 2 3 4 5

Measured memory_bytes: 5196
a = input()
b = input()
c = input()
s = {"a":a,"b":b,"c":c}

t = "a"
while True:
    p = s[t]
    if len(p) == 0:
        ans = t
        break
    s[t] = s[t][1:len(s[t])]
    t = p[0]

print(ans.upper())

Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long

ll mabs(ll a, ll b)
{
  return (a > b) ? a - b : b - a;
}

int main(void)
{
  ll n, k, m;
  scanf("%lld%lld", &n, &k);
  if (n >= k)
  {
    ll a = n / k;
    n = n - (a * k);
  }
  m = mabs(n, k);
  if (m < n)
    printf("%lld\n", m);
  else
    printf("%lld\n", n);

  return 0;
}

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

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

  int count=1;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    if(a==count){
      count++;
    }
  }
  if(count==1){
    cout << "-1" << endl;
  }
  else{
    cout << N-(count-1) << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define Set(a,b) memset(a,b,sizeof(a))
using namespace std;
const int N=2e3+10;
const int mod=1e9+7;
template <typename T> inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
template <typename T>inline void upd(T&x,int y){x+=y;if(x>=mod) x-=mod;return;}
template <typename T>inline void dec(T&x,int y){x-=y;if(x <  0) x+=mod;return;}
template <typename T,typename S>inline T fpow(T x,S k){T ret=1;for(;k;k>>=1,x=1ll*x*x%mod) if(k&1) ret=1ll*ret*x%mod;return ret;}
int k;
inline int calc(int x){
	if(x==1) return 1;
	int d=x/k*k+x%k-1;
	return d;
}
int st[N][N];
int main()
{
	int n;init(n);
	if(n==1) puts("Yes\n2\n1 1\n1 1");
	else{
		k=1;
		for(;k<=1e5;++k){if(1ll*k*(k-1)/2>n) return puts("No"),0;else if(k*(k-1)/2==n) break;}
		puts("Yes");printf("%d\n",k);
		int l=1;
		for(int i=1;i<=k;++i){
			for(int j=i;j<=k;++j) {
				if(i==j) continue;
				st[i][++st[i][0]]=l;
				st[j][++st[j][0]]=l;
				++l;
			}
		}
		for(int i=1;i<=k;++i) {
			printf("%d ",k-1);
			for(int j=1;j<k;++j) printf("%d ",st[i][j]);
			puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 4992
#include <iomanip>
#include <limits>
#include <thread>
#include <utility>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <numeric>
#include <cassert>
#include <random>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <list>
#include <functional>
#include <bitset>
#include <complex>
#include <tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;
typedef complex<D> P;
const ll E = 1e18 + 7;
const ll MOD = 1000000007;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define fill(x, y) memset(x, y, sizeof(x))
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
template <class... A>
void prints() { cout << endl; }
template <class... A>
void prints_rest() { cout << endl; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }
 
template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
 
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    int N;
    vector<int> used;
    cin >> N;

    int a;
    int sum = 0;
    rep(_, N) {
        cin >> a;
        auto result = find(all(used), a);
        if ( result == used.end() ) {
            used.push_back(a);
        }
        if ( sz(used) > 3 ) {
            prints("No");
            return 0;
        }

        sum ^= a;
    }

    if (sum == 0) {
        prints("Yes");
    } else {
        prints("No");
    }

    return 0;
}
 

Measured memory_bytes: 256
/* Prime Numbers */

#include <iostream>
#include <cmath>

using namespace std;

inline bool IsPrime(unsigned long a) {
  if (a < 1) return false;
  unsigned long rt_a = sqrt(a);
  for (unsigned long i = 2; i <= rt_a; i++) {
    if (a % i == 0) return false;
  }
  return true;
}

int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    unsigned long a;
    cin >> a;
    if (IsPrime(a)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

using namespace std;

void Main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int minute1 = H1 * 60 + M1;
    int minute2 = H2 * 60 + M2;
    int ans = (minute2 - minute1) - K;
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(K: int, X: int):
    print(' '.join(map(str, [i for i in range(max(-1000000, X-K+1), min(1000000, X+K))])))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int K , X ;
  cin >> K >> X ;
  for( int i = K - 1 ; i > 0 ; i-- ) cout << X - i << ' ' ;
  for( int i = 0 ; i < K ; i++ ) cout << X + i << ' ' ;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

long long int f(long long int n) {
  if (n % 2 == 0) {
    return n/2;
  } else {
    return 3*n+1;
  }
}
int main() {
  
  long long int s;
  cin >> s;
  
  set<long long int> st;
  st.insert(s);
  
  for (long long int i = 2;;i++) {
    s = f(s);
    if (st.find(s) != st.end()) {
      cout << i << endl;
      break;
    } else {
      st.insert(s);
    }
  }
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  int m;
  int n;
  cin>>n>>m;
  vector<pair<ll,int>> p;
  rep(i,n){
    ll a;int b;cin>>a>>b;
    p.push_back(make_pair(a,b));
  }
  sort(p.begin(),p.end());
  ll ans =0,l=0;
  rep(i,m){
    ans += p[l].first;
    p[l].second--;
    if(p[l].second==0) l++;
    
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;
import java.util.Arrays;

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

        int x = sc.nextInt();
        int n = sc.nextInt();
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = sc.nextInt();
        }

        Arrays.sort(p);
        int ans = -100000000;
        int ansLow, ansHigh;
        int count = 0;
        int matchNotAns = -1000000000;

        for(int j = 0; j<1000; j++){
            for(int k = 0; k<n; k++){
                if(x - j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
                else if(x + j == p[k]){
                    count++;
                    matchNotAns = p[k];
                }
            }
            if(count == 1 && x != x - j){
                if(matchNotAns == x - j){
                    ans = x + j;
                }
                else if(matchNotAns == x + j){
                    ans = x - j;
                }
                break;
            }
            else if(count == 0){
                ans = x - j;
                break;
            }
            count = 0;
        }

        System.out.println(ans);
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<vector<char> > c(h,vector<char>(w));
    vector<vi> yidx(h), xidx(w);
    rep(i,h) yidx[i].pb(-1);
    rep(i,w) xidx[i].pb(-1);
    rep(i,h)rep(j,w){
        cin>>c[i][j];
        if (c[i][j]=='#'){
            yidx[i].pb(j);
            xidx[j].pb(i);
        }
    }
    rep(i,h) yidx[i].pb(w);
    rep(i,w) xidx[i].pb(h);
    int ans=0;
    rep(i,h)rep(j,w){
        int sum=0;
        if (c[i][j]=='#') continue;
        auto itr = upper_bound(all(yidx[i]), j);
        sum += (*itr-j)+(j-*(itr-1))-1;
        itr = upper_bound(all(xidx[j]), i);
        sum += (*itr-i)+(i-*(itr-1))-1;
        sum--;
        chmax(ans, sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 38400
/*input
1000000000000000 1000000000000000 1000000000000000
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>

using namespace std; 

int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	ll x, k, d;
	cin >> x >> k >> d;
	if(k<=abs(x)/d) cout << abs(x)-k*d;
	else {
		x = abs(x);
		k -= x/d;
		x %= d;
		if(abs(x-d)<x) {
			k--;
			x=d-x;
		}
		if(k%2) cout << min(abs(x+d), abs(x-d));
		else cout << x;
	}
	return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(void)
{
	int num_K;
	char str_S[101];
	int i;
	int word_count;

	scanf("%d", &num_K);
	scanf("%s", str_S);

	word_count = 0;

	for (i = 0; str_S[i] != '\0'; i++)
	{
		word_count++;
	}

	if (word_count > num_K)
	{
		for (i = 0; i < num_K; i++)
		{
			printf("%c", str_S[i]);
		}

		printf("...\n");
	}
	else
	{
		printf("%s", str_S);
	}

	return 0;
}

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

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)


#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
} 

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	fast;
	ll a,b,c,d,flag;
	cin >> a  >> b >> c >> d;
	flag=0;
	while(1)
	{
		if(!flag)
		{
			c-=b;
			if(c<=0)
				break;
			flag=1;
		}
		else
		{
			a-=d;
			if(a<=0)
				break;
			flag=0;
		}
	}
	if(a<=0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3548
import std.math;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.container;
import std.algorithm;

void main()
{
    long n, k;
    readf("%d %d\n", &n, &k);
    long ans = (n / k) ^^ 3;
    if (!(k & 1)) {
        ans += ((2 * n / k + 1) / 2) ^^ 3;
    }
    writeln(ans);
}



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

#define EPS 1e-10

int main() {
    int n; cin >> n;
    double x1, y1, x2, y2, x3, y3, x4, y4;
    for (int i = 0; i < n; i++) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        if (abs(x1-x2) < EPS && abs(x3-x4) < EPS) {
//            if (abs(x1-x3) > EPS) cout << "YES" << endl;
//            else cout << "NO" << endl;
            cout << "YES" << endl;
            continue;
        }

        double s1 = (y2-y1)/(x2-x1);
        double s2 = (y4-y3)/(x4-x3);
        if ( abs(s1-s2) < EPS ) {
//            if ( abs((y1 - x1 * s1) - (y3 - x3 * s2)) < EPS ) {
//                cout << "NO" << endl;
//            } else {
//                cout << "YES" << endl;
//            }
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
using namespace std;

void solve(){
  int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
  string str; cin >> str;
  long long sum = 0;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    int t;
    if(str[i] == 'r'){
      v[i] = 'p';
      t = p;
    }
    else if(str[i] == 's'){
      v[i] = 'r';
      t = r;
    }
    else{
      v[i] = 's';
      t = s;
    }
    if(i >= k && v[i - k] == v[i]) v[i] = 'x';
    else sum += t;
  }
  cout << sum << endl;

  return;
}

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


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int cnt;
char str[1000001];

int main(){
	scanf("%s",str);
	if(str[0]!='A'){
		puts("WA");
		return 0;
	}
	int n=strlen(str);
	if(str[1]=='C'||str[n-1]=='C'){
		puts("WA");
		return 0;
	}
	for(int i=2;i<n-1;++i){
		if(str[i]=='C')++cnt;
		else if(str[i]>='B'&&str[i]<='Z'){
			puts("WA");
			return 0;
		}
	}
	for(int i=0;i<n;++i)if(str[i]!='A'&&str[i]!='C'&&str[i]>='A'&&str[i]<='Z'){
		puts("WA");
		return 0;
	}
	if(cnt==1)puts("AC");else puts("WA");
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    int res = 0;
    vector<bool> v(n, false);
    for (int i = 0; i < n; ++i) {
        if (t[i] == 'r'){
            if (i >= k && t[i-k] == 'r' && !v[i-k]){
                v[i] = true;
                continue;
            }
            res += p;
        }
        if (t[i] == 's'){
            if (i >= k && t[i-k] == 's' && !v[i-k]){
                v[i] = true;
                continue;
            }
            res += r;
        }
        if (t[i] == 'p'){
            if (i >= k && t[i-k] == 'p' && !v[i-k]){
                v[i] = true;
                continue;
            }
            res += s;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   // your code goes here
    int t;long long c0=0,c1=0,c2=0,c3=0;
    string s;
    cin>>t;
    for (int i=1;i<=t;i++)
    {
        cin>>s;
        if (s=="AC")c0++;
        else if (s=="WA")c1++;
        else if (s=="TLE")c2++;
        else if (s=="RE")c3++;
    }
    cout<<"AC x "<<c0<<endl;
    cout<<"WA x "<<c1<<endl;
    cout<<"TLE x "<<c2<<endl;
    cout<<"RE x "<<c3<<endl;
}


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

#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)

int main() {
	int N;
	cin>>N;
	string ans="ABC";
	if(N>=1000){
		ans="ABD";
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
s = rs()
print(s[0] + str(len(s)-2) + s[-1])

Measured memory_bytes: 63724
import sys
sys.setrecursionlimit(10000)
input = sys.stdin.readline

def binize(vn):
    res = 0
    for n in vn:
        res |= 1 << (n-1)
    return res


N, M = map(int, input().split())
mK = []
for i in range(M):
    a, b = map(int, input().split())
    vc = list(map(int, input().split()))
    mK.append((a, binize(vc)))

# 2**N up to 4096
allOpen = 2**N - 1
INF = float("inf")

# dp[i:keyM(<=1000)][n:openedN(<4096)] := min(sum(a))
dp = []
dp.append([0,]+[INF,]*allOpen)

#print(dp)
for na,n in mK:
	nDP = dp[-1]
	for c,pa in enumerate(dp[-1]):
		nDP[n|c] = min(nDP[n|c], pa+na)
	dp.append(nDP)

res = dp[-1][-1]
#print(res)
print(res if res != INF else -1)


Measured memory_bytes: 44124
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [0] * 45
for i in c:
    e = bin(i)[2:]
    for j in range(len(e)):
        d[j] += 1 if e[-j-1] == "1" else 0
ans = 0
s = 0
for i in range(44, -1, -1):
    if 2 ** i + s <= b:
        if a > d[i] * 2:
            s += 2 ** i
for i in c:
    ans += i ^ s
print(ans)


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

int main() {
    int N, M;
    cin >> N >> M;
    vector< vector< int > > edge(N, vector< int >(N));
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }

    int ans = 0;
    vector< int > perm(N - 1);
    rep(i, N - 1) perm[i] = i + 1;
    do {
        bool feasible = true;
        int s = 0;
        rep(i, N - 1) {
            int n = perm[i];
            if (edge[s][n] != 1) {
                feasible = false;
                break;
            }
            s = n;
        }
        if (feasible) ++ans;
    } while (next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read() {
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch == '-') f = 1;ch = getchar();}
	while(isdigit(ch)) {x = x*10 + ch - '0';ch = getchar();}
	return f?-x:x;
}
const int N = 2e5 + 100,p = 998244353;
#define LL long long 
LL n,m,t[N],A[12],B[12];
LL ask(LL x) {
	LL tot = 0;
	for(LL i = x;i;i-=i&-i) tot = (tot + t[i]) % p;
	return tot;
}
void add(LL x,LL d) {
	for(LL i = x;i <= n;i+=i&-i) t[i] = (t[i] + d + p) % p;
}
int main() 
{
	n = read();m = read();
	for(int i = 1;i <= m;i++) {
		A[i] = read(),B[i] = read();
		if(A[i] > B[i]) swap(A[i],B[i]);
	} 
	add(1,1);add(2,-1);
	for(LL i = 1;i <= n;i++) {
		LL a = ask(i);
		if(!a) continue;
		for(LL j = 1;j <= m;j++) 
		{
			if(i + A[j] <= n) add(i + A[j],a);
			if(i + B[j] + 1 <= n) add(i + B[j] + 1,-a);
		}
	}
	cout << ((ask(n)%p+p)%p) << endl; 
	return 0;
}

Measured memory_bytes: 5172
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLn >>= print . solve

solve :: Int -> Int
solve n = (c5 * (c5 - 1) * (c3 - 2) `div` 2) + c25 * (c3 - 1) + c15 * (c5 - 1) + c75
    where
        es = map length . group . sort $ generate n 
        [c3, c5, c15, c25, c75] = map count [3, 5, 15, 25, 75]

        generate 1 = [1]
        generate n = gen n ps
            where
                gen 1 _ = generate $ n - 1 
                gen c (p : xs) 
                    | m == 0 = p : gen r (p : xs)
                    | otherwise = gen c xs 
                    where
                        (r, m) = c `divMod` p 
                        
        count c = length $ filter (>= (c - 1)) es

        ps = takeWhile (< 100) $ primes


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

primes :: [Int]
primes = build [2..]
    where
        build (x : xs) = x : build (filter (\n -> n `mod` x /= 0) xs)

Measured memory_bytes: 636
N=int(input())
W=input().split()
sumTotal=0
for i in range(N):
    W[i]=int(W[i])
    sumTotal+=W[i]

sum1=0
min1=sumTotal
for i in range(N):
    sum1+=W[i]
    rest=sumTotal-sum1
    min1=min(min1, abs(sum1-rest))

print(min1)

Measured memory_bytes: 3064
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<int> > mat;

ll dp[50][2];//2つめは1で制限解除

int main()
{
  ll n, k;
  cin >> n >> k;
  ll a[100100];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));
  dp[45][0] = 0;
  for (int d = 44; d >= 0; d--)
  {
    ll mask = 1LL << d;
    ll num = 0;

    for (int i = 0; i < n; i++)
    {
      if (a[i] & mask)
      {
        num++;
      }
    }

    if (dp[d + 1][1] >= 0)
    {
      dp[d][1] = max(dp[d][1], dp[d + 1][1] + mask * max(num, n - num));//0でも1でもいい
    }

    if (dp[d + 1][0] >= 0)
    {
      if (k & (1LL << d))//kがd桁目で1
      {
        dp[d][1] = max(dp[d][1], dp[d + 1][0] + mask * num);//0採用
        dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * (n - num));//1採用
      }
      else
      {
        dp[d][0] = max(dp[d][0], dp[d + 1][0] + mask * num);//0採用しかない
      }
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  REP(i,n) cin >> p[i] ;
  sort(p.rbegin(), p.rend());
  int ans = 0;
  ans += p[0]/2;
  for(int i = 1; i < n; ++i){
    ans += p[i];
  }

  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(0); cin.tie(0) ; cout.tie(0)
#define err(x) cerr << #x << " is : " << x << endl
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()

const int N = 1e5 + 20;
const int mod = 1e9 + 7;

int32_t main()
{
      tie();
      int t = 1;
      //cin >> t;
      while(t--)
      {
            int a , b , c;
            cin >> a >> b >> c;
            swap(a , b), swap(a , c);
            cout << a << " " << b << " " << c << endl;
      }
      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 998244353
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int m1,d1,m2,d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(d2 == 1){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    
    int b,f,r,v,n,human[4][3][10] = {0},i,j,k;
    
    scanf("%d",&n);
    
    for (i = 0; i < n; i++) {
        scanf("%d %d %d %d",&b,&f,&r,&v);
        
        b -= 1;
        f -= 1;
        r -= 1;
        human[b][f][r] += v;
        
        if (human[b][f][r] < 0) {
            human[b][f][r] = 0;
        } else if (human[b][f][r] > 9) {
            human[b][f][r] = 9;
        }
    }
    
    for (i = 0; i < 4 ; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                printf(" %d",human[i][j][k]);
            }
            printf("\n");
        }
        
        if (i != 3) {
            for (k = 0; k < 20; k++) {
                printf("#");
            }
            printf("\n");
        }
        
    }
    return 0;

}

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

int main(){
int n,k,s,ans;
int a[100001];
while(cin>>n>>k){
if(n==0&&k==0)break;
for(int i=0;i<n;i++)cin>>a[i];
s=0;
for(int i=0;i<n-k+1;i++){
if(i==0)for(int j=i;j<i+k;j++)s+=a[j];
if(i!=0){s-=a[i-1]; s+=a[i+k-1];}
if(i==0)ans=s;
if(s>ans)ans=s;}
cout<<ans<<endl;}}

Measured memory_bytes: 1552
#include "bits/stdc++.h"
using namespace std;

#define show(x) cerr << #x << " = " << x << endl ;
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'


int main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
    fastio;cin.tie(0);cout.tie(0);
    long long n , ans = 1e14; cin >> n ;
    for(long long i = 1 ; i <= sqrtl(n) ; ++i)
    {
        if(n%i == 0)
        {
            ans = min(ans , i + n/i -2);
        }
    }
    cout << ans ;

    return 0;
}


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

using namespace std;

int main() {
  char acgt[4] = {'A', 'C', 'G', 'T'};
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < (int)S.size(); ++i) {
    int tmp = 0;
    for (int j = i; j < (int)S.size(); ++j) {
      bool isAcgt = false;
      for (int k = 0; k < 4; ++k) {
	if (S[j] == acgt[k]) isAcgt = true;
      }
      if (isAcgt) {
	tmp++;
	ans = max(ans, tmp);
      } else {
	break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

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

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

string s1,s2;
ll dp[3004][3004];

vector <char> a;

ll lcs(ll n ,ll m)
{
	if(n < 1 || m < 1)
	{
		return 0;
	}
	if(s1[n-1] == s2[m-1])
	{
		a.push_back(s1[n-1]);
		return lcs(n-1,m-1);
	}
	else
	{
		if(dp[n-1][m] > dp[n][m-1])
			return lcs(n-1,m);
		else
			return lcs(n,m-1);

	}

}

ll solve(ll n , ll m)
{
	if(dp[n][m] != -1)
		return dp[n][m];

	if(n == 0 || m == 0)
		 return 0;

	if(s1[n-1] == s2[m-1])
		dp[n][m] = 1 + solve(n-1,m-1);
	else
		dp[n][m] = max(solve(n-1,m) , solve(n,m-1));

	return dp[n][m];
}

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

	cin >> s1 >> s2;

	ll len1 = s1.size();
	ll len2 = s2.size();

	memset(dp,-1,sizeof(dp));


	ll ans = solve(len1,len2);

	lcs(len1,len2);

	reverse(a.begin() , a.end());

	for(ll i=0;i<ans;i++)
		cout << a[i];
	cout << endl;

}

Measured memory_bytes: 71040
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

best = 9999
ans = 0
for i in range(1,N+1):
    h = H[i-1]
    if abs(A-(T-h*0.006))<best:
        best = abs(A-(T-h*0.006))
        ans = i
        #print(i,best)
        
print(ans)

Measured memory_bytes: 3064
n,k = map(int,input().split())
X = [int(i) for i in input().split()]
ans = 10**9

for i in range(n-k+1):
    Max = X[i+k-1]
    Min = X[i]
    
    if Max<0 and Min<0:
        tmp_ans = abs(Min)
    elif Max>0 and Min >0:
        tmp_ans = abs(Max)
    else:
        tmp_ans = abs(Max) + abs(Min) + min(abs(Max),abs(Min))
    ans = min(ans,tmp_ans)
print(ans)

Measured memory_bytes: 14384
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,len;
	char x[100];
	gets(x);
	len = strlen(x);
	for (i = 1;i <= len;i++) {
		if (x[i-1]==x[i]) {
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

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

int main() {
	int n, yel = 0;
	string s[105];
	cin >> n;
	for (int i = 0; i < n; i++) {
	    cin >> s[i];
	    if (s[i] == "Y") yel++;
	}
	if (yel > 0) cout << "Four";
	else cout << "Three";
	return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const ll mod = 1e9+7;
const int maxn = 1e6+10;
ll memo[maxn][2][2];
int N;

ll dp(int pos,int cnt1,int cnt2){
	if(pos >= N){
		return (cnt1 && cnt2);
	}
	ll &res = memo[pos][cnt1][cnt2];
	if(res != -1)return res;
	res = 0;
	forn(i,0,10){
		int newCnt1 = cnt1|(i == 9);
		int newCnt2 = cnt2|(i == 0);
		
		res += dp(pos+1,newCnt1,newCnt2);
		res %= mod;
	}
	return res;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,2)forn(k,0,2)memo[i][j][k] = -1;
	cin >> N;
	ll res = dp(0,0,0);
	if(res < 0)res += mod;
	cout << res << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


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

int n;
Graph G;

int main()
{
    cin >> n;
    G.resize(n);
    rep(i, n)
    {
        int id, k;
        cin >> id >> k;
        rep(j, k)
        {
            int v;
            cin >> v;
            G[i].push_back(v - 1);
        }
    }
    vector<int> dist(n, -1);
    queue<int> que;
    dist[0] = 0;
    que.push(0);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();
        for (int nv : G[v])
        {
            if (dist[nv] != -1)
                continue;
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
    rep(i, n)
    {
        cout << i + 1 << " " << dist[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N <= 9) {
        cout << N << endl;
    } else if(N < 100) {
        cout << 9 << endl;
    } else if(N < 1000) {
        cout << 9 + (N-100+1) << endl;
    } else if(N < 10000) {
        cout << 9 + 900 << endl;
    } else if(N < 100000) {
        cout << 9 + 900 + (N-10000+1) << endl;
    } else {
        cout << 9 + 900 + 90000 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::f64;
use std::fmt;
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};


fn solve(n: u32, m: u32) -> u32 {
    pow(2, m) * (100 * (n - m) + 1900 * m)
}


fn pow(b: u32, e: u32) -> u32 {
    (0..e).map(|_| b).fold(1, |a, b| a * b)
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()))
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }
}


trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: fmt::Display, I: IntoIterator<Item = T>>(xs: I) {
    let stdout = io::stdout();
    let mut stdout = BufWriter::new(stdout.lock());
    for x in xs.into_iter() {
        writeln!(stdout, "{}", x).unwrap();
    }
    stdout.flush().unwrap();
}


#[allow(dead_code)]
fn print_or<T: fmt::Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

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

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int n, k;
int a[1200];
int dp[120000];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	dp[0] = 0;
	for (int i = 1; i <= k; ++i) {
		int fl = 1;
		for (int j = 0; j < n; ++j)
			if (a[j] <= i)
				fl &= dp[i - a[j]];
		dp[i] = 1 - fl;
	}
	if (dp[k])
		cout << "First\n";
	else
		cout << "Second\n";
	return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
using namespace std;

typedef long long int lli;

lli A, B, N, ans;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> A >> B >> N;
    lli x = min(B - 1, N);
    ans = (lli)(A * x / B) - A * (lli)(x / B);
    cout << ans;
    return 0;
}

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

int main(){
  string s,t;
  int num,sa,Min=999;
  cin>>s;
  for(int i=0;i<=s.size()-3;i++){
    t=s.substr(i,3);
    num=atoi(t.c_str());
    sa=abs(num-753);
    Min=min(Min,sa);
  }
  cout<<Min;
  return 0;
}

Measured memory_bytes: 256