akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <deque>
#include <numeric>
#include <set>
using namespace std;

const int INF = 1e+9;

int n;
vector<int> graph[205];
int color[205];
bool bipartite_jugding(int v, int c){
    if(color[v] != 0)   return color[v] * c > 0;

    color[v] = c;
    bool res = true;
    for(int i = 0; i < (int)graph[v].size(); ++i){
        res &= bipartite_jugding(graph[v][i], -c);
    }

    return res;
}

int dist[205][205];
void warshall_floyd(){
    for(int k = 0; k < n; ++k){
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < n; ++j){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

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

    cin >> n;
    fill((int*)dist, (int*)(dist + n), INF);
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < n; ++j){
            if(i < j && s[j] == '1'){
                graph[i].push_back(j);
                graph[j].push_back(i);
                dist[i][j] = 1;
                dist[j][i] = 1;
            }
        }
    }
    for(int i = 0; i < n; ++i){
        dist[i][i] = 0;
    }

    if(!bipartite_jugding(0, 1)){
        cout << -1 << endl;
        return 0;
    }

    int res = 0;
    warshall_floyd();
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(dist[i][j] != INF){
                res = max(res, dist[i][j]);
            }
        }
    }

    cout << res + 1 << endl;
}

Measured memory_bytes: 640
expected = {}

n, k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]

max_sum = 0
for i in range(k):
  max_sum += p[i]
  
last_sum = max_sum
max_init_index = 0

for i in range(1, n - k + 1):
  current_sum = last_sum - p[i - 1] + p[i + k - 1]
  if max_sum < current_sum:
    max_sum = current_sum
    max_init_index = i
  last_sum = current_sum

for i in range(1, 1001):
  expected[i] = 1 + (i - 1)/2

ans = 0
for i in range(max_init_index, max_init_index + k):
  ans += expected[p[i]]

print(ans)
  



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

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
//#include <bits/stdc++.h>
#include <cassert>
#include <map>
#include <bitset>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;


int cal(int x)
{
  if (x >= 0)
    return 0;
  return -x;
}

int main()
{
  int a, b;
  scanf("%d %d", &a, &b);
  if (a <= 0 && 0 <= b)
    puts("Zero");
  else
    {
      int cnt = cal(a)-cal(b+1);
      if (cnt%2==0)
	puts("Positive");
      else
	puts("Negative");
    }
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;
  vector<bool> dp(k+1);
  for (int i = 0; i < k; i++) {
    for (auto a : A) if (i+a<=k)
      dp[i+a] = dp[i+a] || !dp[i];
  }
  cout << (dp[k] ? "First" : "Second") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;

int main()
{
	ll x;
	cin>>x;
	ll ans=1;
	while(x>0)
	{
		x-=ans;
		ans++;
	}
	cout<<ans-1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=1;i<=1000;i++)
	{
		int d=i*a;
		if(d%b==c)
		{
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

pair<ll, ll> preprocess(double x)
{
  ll a = (ll)round(x * 1e9);
  ll b = 1e9;
  ll a5(0), a2(0), b5(0), b2(0);
  while (a % 2 == 0)
    a /= 2, ++a2;
  while (a % 5 == 0)
    a /= 5, ++a5;
  while (b % 2 == 0)
    b /= 2, ++b2;
  while (b % 5 == 0)
    b /= 5, ++b5;
  a = a2 - b2;
  b = a5 - b5;
  return {a, b};
}

void mainSolve()
{
  get(n);
  vector<pair<ll, ll>> v;
  map<pair<ll, ll>, ll> m;
  for (int i = 0; i < n; i++)
  {
    double x;
    cin >> x;
    ++m[preprocess(x)];
  }
  ll ans = 0;
  for (auto it1 : m)
  {
    for (auto it2 : m)
    {
      if (it1.first.first + it2.first.first >= 0 && it1.first.second + it2.first.second >= 0)
      {
        if (it1 < it2)
          ans += (it1.second * it2.second);
        else if (it1 == it2)
          ans += ((it1.second * (it1.second - 1)) / 2);
      }
    }
  }
  p1(ans);
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 3732
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()

    if (b >= 0) {
        if (a > 0) {
            println("Positive")
        } else {
            println("Zero")
        }
        return
    }

    val diff = Math.abs(b - a)
    if (diff % 2 == 0) {
        println("Negative")
    } else {
        println("Positive")
    }
}


Measured memory_bytes: 31264
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main(void){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int x = 0, n;
    string s;
    cin >> n >> s;
    int tmp = 0, sum = 0;
    for (int i = 0; i < n;i++){
        if(s[i]=='I'){
            tmp++;
            sum = max(sum, tmp);
        }
        if(s[i]=='D'){
            tmp--;
            sum = max(sum, tmp);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int ans = 1000000001;
    for (int i = 0; i < n - k + 1; i++) {
        ans = min(ans, h[i + k - 1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
d={"AC":0, "WA":0, "TLE":0, "RE":0}
n = int(input())
for i in range(n):
    a = input()
    d[a]+=1
print("AC","x",d["AC"])
print("WA","x",d["WA"])
print("TLE","x",d["TLE"])
print("RE","x",d["RE"])

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

using namespace std;

long long int rise(long long int currentT,long long int currentA,int t,int a){
    long long int n;
    if(currentT<=t && currentA<=a){
        n = 1;
    }else{
        int x = currentT%t==0 ? 0 : 1;
        int y = currentA%a==0 ? 0 : 1;
        n = max(currentT/t+x,currentA/a+y);
    }
    return n;
}

int main(){
    int N;
    cin >> N;
    int T[N],A[N];
    for(int i=0;i<N;i++){
        cin >> T[i] >> A[i];
    }
    long long int currentT=1;
    long long int currentA=1;
    for(int i=0;i<N;i++){
        long long int n = rise(currentT,currentA,T[i],A[i]);
        currentT = n*T[i];
        currentA = n*A[i];
    }
    cout << currentT+currentA << endl;
    return 0;
}


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

// update sum segtree
struct S
{
	int x;
	S() {}
	S(int x) : x(x) {}
	void update(S a, S b) {
		x = a.x+b.x;
	}
};

struct SegmentTree
{
	int n;
	std::vector<S> data;
	SegmentTree(int n) : n(n), data(2*n,S(0)) {
	}
	void set(int i, S v) {
		data[i+n]=v;
	}
	void update(int i) {
		i+=n;
		for(;i>0;i>>=1) {
			data[i>>1].update(data[i],data[i^1]);
		}
	}
	void build() {
		for(int i=n-1;i>0;i--) {
			data[i].update(data[i<<1],data[(i<<1)^1]);
		}
	}
	S get(int l, int r) {
		l+=n;r+=n;
		S sum = S(0);
		while(r>l) {
			if(l&1) sum.update(sum,data[l++]);
			if(r&1) sum.update(sum,data[--r]);
			l>>=1;r>>=1;
		}
		return sum;
	}
};

int main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	std::vector<SegmentTree> seg(26,SegmentTree(n));
	for(int i=0;i<n;i++) {
		int c = s[i]-'a';
		seg[c].set(i,S(1));
	}
	for(int i=0;i<26;i++) seg[i].build();
	int q;
	std::cin >> q;
	for(int qq=0;qq<q;qq++) {
		int qt;
		std::cin >> qt;
		if(qt==1) {
			int i; char c;
			std::cin >> i >> c;
			i--;
			if(s[i]==c) continue;
			seg[s[i]-'a'].set(i,S(0));
			seg[s[i]-'a'].update(i);
			s[i]=c;
			seg[s[i]-'a'].set(i,S(1));
			seg[s[i]-'a'].update(i);
		} else {
			int l,r;
			std::cin >> l >> r;
			l--;r--;
			int count = 0;
			for(int i=0;i<26;i++) {
				if(seg[i].get(l,r+1).x) count++;
			}
			std::cout << count << '\n';
		}
	}
}



Measured memory_bytes: 106372
from collections import defaultdict
n = int(input())
result = False
numbers = defaultdict(int)
inputNum = list(input().split())
for i in range(n):
    numbers[inputNum[i]] += 1
if len(numbers) == 3:
    if n % 3 == 0:
        vals = list(numbers.values())
        if vals[0] == vals[1] and vals[1] == vals[2]:
            keys = list(numbers.keys())
            if int(keys[0]) ^ int(keys[1]) == int(keys[2]):
                result = True
elif len(numbers) == 2:
    if n % 3 == 0:
        vals = list(numbers.values())
        keys = list(numbers.keys())
        if keys[0] == "0":
            if vals[1] == vals[0] * 2:
                result = True
        elif keys[1] == "0":
            if vals[0] == vals[1] * 2:
                result = True
elif len(numbers) == 1:
    keys = list(numbers.keys())
    if keys[0] == "0":
        result = True

if result == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14376
from heapq import heappop,heappush

icase=0
if icase==0:
    n=int(input())
    g=[[] for i in range(n)]
    for i in range(n-1):
        ai,bi,ci=map(int,input().split())
        g[ai-1].append((bi-1,ci))
        g[bi-1].append((ai-1,ci))
if icase==1:
    n=5
    g=[[(1, 1), (2, 1)], [(0, 1), (3, 1)], [(0, 1), (4, 1)], [(1, 1)], [(2, 1)]]
if icase==2:
    n=7
    g=[[(1, 1), (2, 3), (3, 5), (4, 7), (5, 9), (6, 11)], [(0, 1)], [(0, 3)], [(0, 5)], [(0, 7)], [(0, 9)], [(0, 11)]]

q,k=map(int,input().split())
k=k-1

hq=[]
heappush(hq,(0,k)) 

inf=float("INF")
dist=[inf]*n
dist[k]=0
while len(hq)>0:
    dd,state = heappop(hq)
#    print("dd:",dd,"state:",state,"q:",q)
    for v,dv in g[state]:
#        print("v:",v,"dv:",dv,"g[state]:",g[state],"parent[v]:",parent[v])
        if dist[v]>dist[state]+dv:
            dist[v]=dist[state]+dv
            heappush(hq,(dist[v],v))
#            print(" state:",state,"v:",v,"dist[v]",dist[v])

for i in range(q):
    xi,yi=map(int,input().split())
    print(dist[xi-1]+dist[yi-1])
    

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/20  Problem: ABC 134 A / Link: http://abc134.contest.atcoder.jp/tasks/abc134_a  ----- */


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

	LL N;
	cin >> N;

	LL ans = 3 * N*N;
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
//#include<vector>
//using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int L=128,C=62;
int s[C*4+3][C*4+1];int diff,edit[C+1]={0},sz[2*C+2]={0};
static inline int decode(int x){return x<=26?64+x:(x<=52?96-26+x:48+x-52-1);}
static inline int ask(int u,int i,int j)
{
  int len=diff;
  printf("? ");rep(k,sz[u]){len--;putchar(decode(s[u][k]));}len--;putchar(decode(s[u<<1][i]));
  rep(k,sz[u<<1|1]-j){len--;putchar(decode(s[u<<1|1][k+j]));}puts("");fflush(stdout);
  int res;if(scanf("%d",&res)!=0)return res==len;else return -1;
}
static inline void solve(int u,int le,int ri)
{
  if(le==ri){sz[u]=edit[le];rep(i,edit[le]){s[u][i]=le;}return;}
  int mid=(le+ri)>>1;
  solve(u<<1,le,mid);solve(u<<1|1,mid+1,ri);
  for(int i=0,j=0;i<sz[u<<1]||j<sz[u<<1|1];)
  {
    if(i<sz[u<<1]&&(j==sz[u<<1|1]||ask(u,i,j))){s[u][sz[u]++]=s[u<<1][i];i++;}
    else{s[u][sz[u]++]=s[u<<1|1][j];j++;}
  }
}
int main(void)
{
  rep(i,C)
  {
    printf("? ");rep(j,L){putchar(decode(i+1));}puts("");fflush(stdout);
    int res;if(!scanf("%d",&res))return -1;
    edit[i+1]=L-res;diff+=L-res;
  }
  solve(1,1,C);
  printf("! ");rep(i,sz[1])putchar(decode(s[1][i]));puts("");fflush(stdout);
  return 0;
}

Measured memory_bytes: 3704
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  vll as(n);
  rep(i, n) cin >> as[i];

  Sort(as);

  // 1. find alpha
  auto f = [&](ll x){
    ll sum = 0;
    rep(i, n){
      ll a = as[i];
      ll idx = Lower_bound(as, x - a);
      sum += n - idx;
    }
    return sum;
  };

  ll l = 0, r = INF;
  while (l + 1 < r) {
    ll mid = (l + r)/2;
    if (f(mid) >= m)
      l = mid;
    else
      r = mid;
  }

  // 2. get tmp score
  vll csum(n+1, 0);
  repLRE(i, 1, n){
    csum[i] += csum[i-1] + as[i-1];
  }

  ll ans = 0;
  rep(i, n){
    ll a = as[i];
    ll idx = Lower_bound(as, r - a);
    ans += (csum[n] - csum[idx]) + a*(n - idx);
  }

  // 3. add 
  ll m0 = f(r);
  ans += (r-1)*(m - m0);

  // ans!
  cout << ans << endl;

  return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

string sub1(string s) {
  for (int i=s.size()-1; i>=0; --i) {
    if (s[i] == '0') s[i] = '9';
    else {
      s[i]--;
      break;
    }
  }
  return s;
}

const ll mod = 1e9+7;
inline void add(ll &a, ll b) {
  if (a == -1) a = 0;
  a += b;
  if (a > mod) a -= mod;
}

int *fail;

ll dp1[10001][501][2];
ll dp2[10001][2];

ll solve(const string &A, const string &C) {
  int n = A.size();
  int m = C.size();
  memset(dp1,0,sizeof(dp1));
  memset(dp2,0,sizeof(dp2));
  dp1[0][0][0] = 1;
  
  REP(i,n) {
    REP(ls,2) {
      // if (dp1[i][0][ls]) cout << i << " "  << " " << ls << " " << dp1[i][0][ls] << endl;
      REP(k,(ls?10:(A[i]-'0'+1))) {
        int nls = ls||k<A[i]-'0';
        char c = k+'0';
        add(dp2[i+1][nls], dp2[i][ls]);
        add(dp1[i+1][0][nls], dp1[i][0][ls]);
        
        REP(j,m) {
          if (C[j] == c) {
            if (j == m-1) {
              add(dp2[i+1][nls], dp1[i][j][ls]);
            } else {
              add(dp1[i+1][j+1][nls], dp1[i][j][ls]);
            }
          }
        }
      }
    }
  }
  ll ans = dp2[n][0];
  add(ans, dp2[n][1]);

  if (C == "0") {
    ll sum = 0;
    ll r = 10;
    REP(i,n-1) {
      add(sum, r);
      r = r*10 % mod;
    }
    ans = (ans - sum + mod) % mod;
  }
  
  return ans;
}


int main() {
  string A,B,C;
  while(cin >> A >> B >> C) {
    if (A == "0") {
      cout << solve(B,C) << endl;
    } else {
      ll ans = solve(B,C)-solve(sub1(A),C);
      ans = (ans+mod)%mod;
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 79692
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t x,y,z,k;
  cin >> x >> y >> z >> k;
  vector<int64_t> a(x),b(y),c(z);
  rep(i,x){
    cin >> a.at(i);
  }
  rep(i,y){
    cin >> b.at(i);
  }
  rep(i,z){
    cin >> c.at(i);  
  }
  vector<int64_t> aplusb;
  rep(i,x){
    rep(j,y){
      int64_t hoge = a.at(i)+b.at(j);
      aplusb.push_back(hoge);
    }
  }
  sort(aplusb.begin(),aplusb.end());
  reverse(aplusb.begin(),aplusb.end());
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  /*rep(i,aplusb.size()){
    cout << aplusb.at(i) << ",";
  }*/
  vector<int64_t> result;
  rep(i,min(3000L,x*y)){
    rep(j,z){
      result.push_back(aplusb.at(i)+c.at(j));
    }
  }
  sort(result.begin(),result.end());
  reverse(result.begin(),result.end());
  rep(i,k){
    cout << result.at(i) << endl;
  }
      
    
    
  
  
}

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

#define fi                      first
#define se                      second
#define pb                      push_back
#define endl                    '\n'
#define all(x)                  x.begin(),x.end()
#define pii                     pair<int,int>
#define pll                     pair< long long int, long long int> 
#define fast                    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define SZ(x)                   ((int)x.size())

#define FOR(i,a,b)              for(int i = a; i < b; ++i)
#define REV(i,a,b)              for(int i = a; i >= b; --i)
#define FORE(i,a,b)             for(int i = a; i <= b; ++i)

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

void solve();

int32_t main()
{
        fast;
        int t = 1;
        // cin >> t;
        for(int i = 1; i <= t; ++i)
                solve();
        cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}

void solve() {
        std::vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin >> k;
        cout << v[k-1] << endl;
}

Measured memory_bytes: 256
import bisect

def turn(S,l,r):
    S1=S[:l]
    S2=S[l:r+1][::-1]
    S3=S[r+1:]
    S2=S2.replace('L',' ')
    S2=S2.replace('R','L')
    S2=S2.replace(' ','R')
    return S1+S2+S3

def score(S):
    ans=0
    for i in range(N):
        if((i<N-1 and S[i]==S[i+1]=='R') or (i>0 and S[i]==S[i-1]=='L')):
            ans+=1
    return ans

N,K=map(int,input().split())
S=input()
L=[];R=[]
c0=S[0]

for i in range(1,N):
    c=S[i]
    if c0!=c=='L':
        L.append(i)
    elif c0!=c=='R':
        R.append(i)
    c0=c

lenL,lenR=len(L),len(R)

for i in range(K):
    if i<min(lenL,lenR):
        S=turn(S,min(L[i],R[i]),max(L[i],R[i])-1)
    elif i==min(lenL,lenR)<max(lenL,lenR):
        if lenL>lenR:
            S=turn(S,L[lenL-1],N-1)
        elif lenL<lenR:
            S=turn(S,R[lenR-1],N-1)
    else:
        break

print(score(S))

Measured memory_bytes: 7388
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll A,B,C,K; cin>>A>>B>>C>>K;
  ll ans=0;
  if(K>A){
    ans+=A;
    K-=A;
    K-=B;
    if(K>0) ans-=K;
  }
  else ans=K;
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  string S; cin>>S;
  int L = S.size();

  string ans = string(L, 'x');
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
import numpy as np

if __name__=='__main__':
    a = []
    for i in range(3):
        m = list(map(int, input().split(' ')))
        a.append(m)

    a = np.array(a).T
    for i in range(3):
        a[i] -= a[i][0]

    if np.allclose(a[0], a[1]) and np.allclose(a[0], a[2]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 21492
{-# OPTIONS_GHC -Wall -Werror #-}

import Data.List

solve :: String -> [Int]
solve = reverse . sort . (map read) . words

list2String :: [Int] -> String
list2String = tail . foldl (\s x -> s ++ " " ++ show x) ""

main :: IO ()
main = getLine >>= putStrLn . list2String . solve

Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int main() {
	string s, t;
	cin >> s;
	cin >> t;
	VSORT(s);
	VSORT(t);
	VREVERSE(t);
	if (s < t)cout << "Yes";
	else cout <<"No";
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <functional>

using namespace std;

#define ll long long

ll a[200050] = {};
ll b[200050] = {};

unsigned GetDigit(unsigned num) {
	unsigned digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}

int main() {
	ll n;
	ll a;
	ll ans = 0;
	
	cin >> n;

	for (int i = 1; i <= n; i++) {
		a = GetDigit(i);
		if (a % 2 != 0) {
			ans++;
		}
	}
	

	cout << ans;


	
}


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

ll f(vector<ll> a, ll mode) {
  ll a_size = a.size();

  ll count = 0;
  ll sum = 0;

  for(ll i = 0; i < a_size; i++) {
    if((i + mode) % 2 == 0 && sum + a[i] <= 0) {
      // sum + a[i] を １にする
      count += (1 - sum - a[i]);
      a[i] = 1 - sum;
    }
    if((i + mode) % 2 == 1 && sum + a[i] >= 0) {
      // sum + a[i] を -1にする
      count += (sum + a[i] + 1);
      a[i] = -1 - sum;
    }
    sum += a[i];
  }

  return count;
}


int main() {
  ll n;
  cin >> n;

  vector<ll> a(n);

  for(ll i = 0; i < n; i++) {
    cin >> a[i];
  }

  cout << min(f(a, 0), f(a, 1)) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
ll a1[101010], a2[101010];
ll sum1[101010], sum2[101010];
int main() {
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    sort(a, a+n);

    if(n==2) cout<<a[1]-a[0]<<endl;
    else{
        REP(i, 0, n/2+1){
            a1[2*i]=a[i];
            a2[2*i+1]=a[i];
        }
        ll cnt=0;
        RREP(i, n/2, n){
            a1[2*cnt+1]=a[i];
            a2[2*cnt]=a[i];
            cnt++;
        }

        REP(i, 0, n-1){
            sum1[i+1]=sum1[i]+abs(a1[i]-a1[i+1]);
            sum2[i+1]=sum2[i]+abs(a2[i]-a2[i+1]);
        }

        ll ans=0;
        ans=sum1[n-2]+abs(a1[n-1]-a1[0]);
        ans=max(ans, sum1[n-3]+abs(a1[n-3]-a1[n-1])+abs(a1[n-2]-a1[0]));
        RREP(i, 1, n-2){
            ans=max(ans, abs(sum1[i+1]-sum1[n-1])+abs(a1[i+1]-a1[i-1])+sum1[i-1]+abs(a1[i]-a1[0]));
        }
        ans=max(ans, sum2[n-2]+abs(a2[n-1]-a2[0]));
        ans=max(ans, sum2[n-3]+abs(a2[n-3]-a2[n-1])+abs(a2[n-2]-a2[0]));
        RREP(i, 1, n-2){
            ans=max(ans, abs(sum2[i+1]-sum2[n-1])+abs(a2[i+1]-a2[i-1])+sum2[i-1]+abs(a2[i]-a2[0]));
        }
      
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 4224
S = input()

for i in range(1,len(S)-1):
    x = list(S[:-i])
    if len(x)%2 != 0:
        continue
    #print(x[:int(len(x)/2)],x[int(len(x)/2):])
    if x[:int(len(x)/2)] == x[int(len(x)/2):]:
        print(len(x))
        exit()


Measured memory_bytes: 2940
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <functional>
#include <bitset>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
int main() {
    ll n, x, ans=0;
    cin>>n>>x;
    vector<ll> v(n);
    for (int i=0; i<n; ++i) cin>>v[i];
    for (int i=0; i<n-1; ++i) {
        if (v[i]+v[i+1]<=x)
            continue;
        int t=v[i]+v[i+1]-x;
        ans+=t;
        if (v[i+1]>=t) v[i+1]-=t;
        else v[i+1]=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).OrderByDescending(f => f).ToArray();

        var a = 0;
        var b = 0;
        for (var i = 2; n + 2 > i; i++)
        {
            if (i % 2 == 0) a += l[i - 2];
            else b += l[i - 2];
        }
        Console.WriteLine(a - b);
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <queue>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

int main() {
    int n,k;

    cin >> n >> k;

    int max = n - 1;
    char prev = 0;
    int total = 0;

    rep(i,n) {
        char c;
        cin >> c;

        if(c == prev) {
            total++;
        }
        prev = c;
    }

    // あまり難しいこと考えないで、
    // LRL RLR なところを入れ替えればいいっぽい？
    // LRRLRLRRLRLLR
    //  ** * ** *  *
    //  1  2 3  4  5
    // LLLLLLLLLRLLR
    //
    total += k*2;

    if (max < total) total = max;

    cout << total << endl;

    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  string s; cin >> s;
  bool ans = false;
  for (int i = 0; i + 1 < s.size(); i++) {
    if (s[i] == s[i+1]) {
      ans = true;
    }
  }
  if (ans) cout << "Bad" << endl; else cout << "Good" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

def main():
    N = int(input())
    blue_str_freq = defaultdict(int)
    for blue_str in [input() for _ in range(N)]:
        blue_str_freq[blue_str] += 1

    M = int(input())
    red_str_freq = defaultdict(int)
    for red_str in [input() for _ in range(M)]:
        red_str_freq[red_str] += 1

    max_val = 0
    for blue_str, blue_freq in blue_str_freq.items():
        if blue_freq - red_str_freq[blue_str] > max_val:
            max_val = blue_freq - red_str_freq[blue_str]
    print(max_val)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string devide[4] = {"dream","dreamer","erase","eraser"};

int main(){
	string S;
	cin >> S;
	
	reverse(S.begin(),S.end());
	for(int i=0;i<4;i++) reverse(devide[i].begin(),devide[i].end());
	
	bool can = true;
	for(int i=0;i<S.size();){
		bool can2 = false;
		for(int j=0;j<4;j++){
			string d = devide[j];
			if(S.substr(i,d.size()) == d){
				can2 = true;
				i+=d.size();
			}
		}
		if(!can2){
			can = false;
			break;
		}
	}
	
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 3148
N=int(input())
txy=[list(map(int,input().split())) for i in range(N)]
ans=0
for i in range(N):
    t,x,y=txy[i][0],txy[i][1],txy[i][2]
    if x+y<=t and t%2==(x+y)%2:ans+=1
print("Yes" if ans==N else "No")

Measured memory_bytes: 27380
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var p = vals[0];
        var q = vals[1];
        var r = vals[2];

        var min = Math.Min(p + q, q + r);
        min = Math.Min(min, r + p);

        Console.WriteLine(min);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>

int main () {
    int a[110]={1000}, n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        std::cin >> a[i];
    }
    std::sort(a, a+n, std::greater<int>());
    int ans = 0, op = 1;
    for(int i = 0; i < n; ++i){
        ans += op*a[i];
        op *= -1;
    }
    std::cout << ans << std::endl;
}

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

int main(){
    int a, b;
    int d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}


Measured memory_bytes: 3288
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = []
for i in range(M):
    x, y, c = map(int, input().split())
    xyc.append([x, y, c])

ans = min(a) + min(b)

for x, y, c in xyc:
    d = a[x-1] + b[y-1] - c
    if ans > d:
        ans = d

print(ans)

Measured memory_bytes: 30692
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#include <locale>

using namespace std;


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

	int cnt = 0;
	if (n < 10) {
		cnt += n;
		goto END;
	}
	cnt += 9;
	if (n < 100) goto END;
	if (n < 1000) {
		cnt += (n - 99);
		goto END;
	}
	cnt += (999 - 99);

	if (n < 10000) goto END;
	if (n < 100000) {
		cnt += (n - 9999);
		goto END;
	}
	cnt += (99999 - 9999);
END:
	cout << cnt << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define TMP 1000000007

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

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

Measured memory_bytes: 256
s=list(input())
t=list(input())

def shift(l,n):
    return l[n:]+l[:n]
flag=True
for i in range(len(s)):
    if flag:
        if s==t:
            flag=False
            print('Yes')
        
        else:
            t=shift(t,1)

if flag:
    print('No')

Measured memory_bytes: 3060
N = int(input())
S_list = [input() for i in range(N)]
 
S_count = {}
for Si in S_list:
    if Si in S_count:
        S_count[Si] += 1
    else:
        S_count[Si] = 1

S_max = max(S_count.values())
S_count_sorted = sorted([key for key, val in S_count.items()\
                  if val == S_max])
 
print('\n'.join(S_count_sorted))

Measured memory_bytes: 37324
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define x first
#define y second
#define bug(x) cerr<<#x<<'='<<x<<' '
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define FOR(a,b,c) for(int a=(b),a##_end=(c);a<=a##_end;++a)
#define ROF(a,b,c) for(int a=(b),a##_end=(c);a>=a##_end;--a)
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f,N=2e5+10,P=1e9+7;
template<class T>inline bool chkmin(T &A,const T &B){return B<A?A=B,1:0;}
template<class T>inline bool chkmax(T &A,const T &B){return A<B?A=B,1:0;}
int dp[N],nxt[N],n;
int now[N],A[N];
int main(){
	scanf("%d",&n);
	FOR(i,1,n)scanf("%d",&A[i]);
	ROF(i,n,1){
		nxt[i]=now[A[i]];
		now[A[i]]=i;
	}
	dp[1]=1;
	FOR(i,1,n-1){
		if(nxt[i]!=i+1)dp[nxt[i]]=(dp[nxt[i]]+dp[i])%P;
		dp[i+1]=(dp[i+1]+dp[i])%P;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int dp[105][4][2];

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  dp[0][0][0]=1;
  rep(i,s.size())rep(j,4)rep(k,2){
    int nd = s[i]-'0';
    rep(d,10){
      int ni,nj,nk;
      ni = i+1;
      if(d!=0)nj=j+1;
      else nj=j;
      if(nj>3)continue;
      if(k==1)nk=1;
      else{
        if(nd < d)continue;
        else if(nd==d)nk=0;
        else nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  cout << dp[s.size()][K][0]+dp[s.size()][K][1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    int ss=S.size(),ts=T.size();
    int ans = ts;
    for(int i=0; i<=ss - ts; i++){
        
        int hoge = 0;
        
        for(int k=0; k<ts; k++){
            
            if(S[i+k] != T[k]){
                
                hoge++;
            }
            
        
        
        }
    ans = min (ans,hoge);    
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int a[100010];
int main(){
	int i,j,k,m,n;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int ans=0,tmp;
	for (i=1;i<n;i++){
		if (a[i]==i){
			ans++;
			tmp=a[i];
			a[i]=a[i+1];
			a[i+1]=tmp;
		}
	}
	for (i=n;i>1;i--){
		if (a[i]==i){
			ans++;
			tmp=a[i];
			a[i]=a[i-1];
			a[i-1]=tmp;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#define N 100010
using namespace std;
char s[N];
int len, ans;
int main()
{
	scanf("%s", s);
	len = strlen(s);
	for(int i = 1; i < len; i++)
		if(s[i] != s[i - 1])
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // input
    double n, m, d;
    cin >> n >> m >> d;
    // output
    cout << fixed << setprecision(15);
    if (d == 0) {
        cout << 1.0 * (m - 1) / n << endl;
        // printf("%llf\n", 1.0 / n * (m - 1));
    } else {
        cout << 2.0 * (n - d) * (m - 1) / n / n << endl;
        // printf("%llf\n", 2.0 * (n - d) / n / n * (m - 1));
    }
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

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

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

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

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

int main() {
	int N, Q; ll M;
	cin >> N >> M >> Q;

	uf.init(N);

	int e = 0;

	vector<pii> two;

	rep(i, Q) {
		int A, B, C;
		cin >> A >> B >> C;
		if (C == 0) {
			if (!uf.same(A, B)) {
				uf.unite(A, B);
				++e;
			}
		} else {
			two.eb(A, B);
		}
	}

	for (pii p : two) {
		if (uf.same(p.fi, p.se)) {
			puts("No");
			return 0;
		}
	}

	ll cmp = N - e;
	ll mini = N - 1 + (two.size() > 0);
	ll maxi = e + cmp * (cmp - 1) / 2;

	if (M < mini || M > maxi) {
		puts("No");
		return 0;		
	}

	puts("Yes");

	return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

int a, b, q;
ll s[100002], t[100002], x;

ll binary1(int start, int end, ll find, ll arr[])
{
	while(start + 1 < end)
	{
		int mid = (start + end) / 2;
		ll val = arr[mid];

		if(val > find) end = mid - 1;
		else start = mid;
	}

	if(arr[end] <= find) return end;
	else return start;
}

ll binary2(int start, int end, ll find, ll arr[])
{
	while(start < end)
	{
		int mid = (start + end) / 2;
		ll val = arr[mid];

		if(val < find) start = mid + 1;
		else end = mid;
	}

	return end;
}

ll min(ll l1, ll l2)
{
	return l1 < l2 ? l1 : l2;
}

ll max(ll l1, ll l2)
{
	return l1 < l2 ? l2 : l1;
}

int main()
{
	cin.tie(NULL);

	cin >> a >> b >> q;
	for(int i = 0; i < a; i++) cin >> s[i];
	for(int i = 0; i < b; i++) cin >> t[i];

	for(int i = 0; i < q; i++)
	{
		ll ans;
		cin >> x;

		ll sl = s[binary1(0, a - 1, x, s)], sr = s[binary2(0, a - 1, x, s)];
		ll tl = t[binary1(0, b - 1, x, t)], tr = t[binary2(0, b - 1, x, t)];

		ans = abs(sl - x) + abs(sl - tr);
		ans = min(ans, abs(tr - x) + abs(sl - tr));
		ans = min(ans, abs(sr - x) + abs(sr - tl));
		ans = min(ans, abs(tl - x) + abs(sr - tl));
		
		if(sl <= x && tl <= x)
		{
			ans = min(ans, abs(min(sl, tl) - x));
		}

		if(x <= sr && x <= tr)
		{
			ans = min(ans, abs(max(sr, tr) - x));
		}

		cout << ans << '\n';
	}
}

Measured memory_bytes: 2816
var a, ck: array[1..200001] of longint;
    i, j, n, x, ans: longint;
begin
    read(n);
    for i := 1 to n do read(a[i]);
    for i := n downto 1 do 
    begin
        x := 0;
        j := 2 * i;
        while j <= n do
        begin
            x := x + ck[j];
            j := j + i;
        end;
        if x mod 2 <> a[i] then ck[i] := 1;
    end;
    for i := 1 to n do if ck[i] = 1 then ans := ans + 1;
    writeln(ans);
    for i := 1 to n do if ck[i] = 1 then write(i, ' ');
end.

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
using namespace std;
int main(){

  int H,W;
  cin>>H>>W;
  vector<string>C(H);
  for(int i=0;i<=H-1;i++){
  
    cin>>C[i];
    cout<<C[i]<<endl<<C[i]<<endl;
  }
  return 0;
}

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

int R, S, P;

int win(char c) {
  int ret;
  if (c == 'r') ret = P;
  if (c == 's') ret = R;
  if (c == 'p') ret = S;
  return ret;
}

int main() {
  int N, K;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i < K) {
      ans += win(T.at(i));
      continue;
    }
    if (T.at(i) == T.at(i - K)) T.at(i) = ' ';
    else ans += win(T.at(i));
  }
  cout << ans << "\n";
}

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

int main(void) {
    int N; cin >> N;
    vector<int> A(N+10,0);
    rep(i,N-1) {
        int a; cin >> a;
        A[a]++;
    }
    for(int i=1; i<=N; i++) cout << A[i] << endl;
}

Measured memory_bytes: 4016
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int ans[100010];
vector<vector<pii> > v;
void bfs(int now){
	for (auto p : v[now]){
		if(ans[p.first]!=-1)continue;
		if(p.second) ans[p.first]=(ans[now]+1)%2;
		else ans[p.first]=ans[now];
		bfs(p.first);
	}
}

int main(){
	int n;cin>>n;
	Fill(ans,-1);
	v.resize(n);
	rep(i,n-1){
		int a,b,w;cin>>a>>b>>w;
		a--;b--;
		w %= 2;
		v[a].push_back(make_pair(b,w));
		v[b].push_back(make_pair(a,w));
	}
	ans[0]=0;
	bfs(0);
	rep(i,n){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 7424