akhauriyash/Code-Regression huggingface dataset:
/**
 *      ABC 51 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-06 01:29:04
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int K, S; cin >> K >> S;
    int count = 0;
    for (int i = 0; i <= K; ++i) {
        for (int j = 0; j <= K; ++j) {
            if (S - (i + j) <= K && S - (i + j) >= 0){
                ++count;
            }            
        }        
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    int a,b;
    cin>>a>>b;
    string sa="";
    string sb="";

    rep(i,b){
        sa+='0'+a;
    }
    rep(i,a){
        sb+='0'+b;
    }

    if(sa>sb){
        cout<<sb<<endl;
    }
    else{
        cout<<sa<<endl;
    }


}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
ll MOD = 1000000007;
#define INF (1e9)

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; }
typedef pair <ll,ll> P;

int main()
{
    ll x;
    cin >> x;
    ll amari = x % 11;
    ll ans = 2 * (x / 11);
    if (amari == 0) {
        ans = ans;    
    } else if (amari <= 6){
        ans += 1;
    } else {
        ans += 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
lists=list(map(int,input().split()))
mod_4=[]
mod_2=[]
elser=[]
for i in lists:
    if i%4==0:
        mod_4.append(i)
    elif i%4==2:
        mod_2.append(i)
    else:
        elser.append(i)
number_of_4=len(mod_4)
if number_of_4>=(n//2):
    print("Yes")
else:
    j=number_of_4*2+len(mod_2)
    if j>=n:
        print("Yes")
    else:
        print("No")
    

Measured memory_bytes: 14252
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int s, m[1000000] = {}, tmp;

	cin >> s;

	for (int k = 1;; k++) {
		if (k == 1)tmp = s;
		else if (tmp%2 == 0)tmp = tmp / 2;
		else tmp = 3 * tmp + 1;

		//printf("k=%d,tmp=%d\n", k, tmp);

		m[tmp]++;
		if (m[tmp] == 2) {
			cout << k << "\n";
			break;
		}
	}
	
	return 0;
}

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

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

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)        for(int i = 0; i < n; i++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
     IOS
     ll n,i,k,x;
     string s;
     cin>>n>>k>>x;
     if(n%k)
          k = n/k +1;
     else
          k = n/k;
     cout<<(k*x);


     return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int a[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    int nw = 0;
    int c = 0;
    vvi ans(h, vi(w,0));
    rep(i,h){
        if(i % 2){
            rrep(j,w){
                if(nw < a[c]){
                    ans[i][j] = c;
                }
                nw++;
                if(nw == a[c]){
                    nw = 0;
                    c++;
                }
            }
        }else{
            rep(j,w){
                if(nw < a[c]){
                    ans[i][j] = c;
                }
                nw++;
                if(nw == a[c]){
                    nw = 0;
                    c++;
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << ans[i][j] + 1 << " ";
        }
        cout << "\n";
    }
    return 0;
}

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

typedef long long ll;
typedef long double ld;

const int inf = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> vx = {0, -inf, inf}, vy = {0, -inf, inf};
	vector<pair<pair<int, int>, int>> hor(n);
	for (auto& x : hor) {
		cin >> x.first.first >> x.first.second >> x.second;
		vx.push_back(x.first.first);
		vx.push_back(x.first.second);
		vy.push_back(x.second);
	}
	vector<pair<int, pair<int, int>>> ver(m);
	for (auto& x : ver) {
		cin >> x.first >> x.second.first >> x.second.second;
		vx.push_back(x.first);
		vy.push_back(x.second.first);
		vy.push_back(x.second.second);
	}
	auto compr = [&] (vector<int>& v) {
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
	};
	auto f = [&] (vector<int>& v, int& x) {
		x = lower_bound(v.begin(), v.end(), x) - v.begin();
	};
	compr(vx);
	compr(vy);
	for (auto& x : hor) {
		f(vx, x.first.first);
		f(vx, x.first.second);
		f(vy, x.second);
	}
	for (auto& x : ver) {
		f(vx, x.first);
		f(vy, x.second.first);
		f(vy, x.second.second);
	}
	vector<vector<bool>> kek(vx.size(), vector<bool>(vy.size(), false));
	vector<vector<bool>> lol(vx.size(), vector<bool>(vy.size(), false));
	for (auto x : hor) {
		for (int i = x.first.first; i < x.first.second; i++) kek[i][x.second] = true;
	}
	for (auto x : ver) {
		for (int i = x.second.first; i < x.second.second; i++) lol[x.first][i] = true;
	}
	vector<vector<bool>> used(vx.size(), vector<bool>(vy.size(), false));
	pair<int, int> st = {0, 0};
	f(vx, st.first);
	f(vy, st.second);
	auto ok = [&] (pair<int, int> p) {
		return p.first >= 0 && p.first + 1 < vx.size() && p.second >= 0 && p.second + 1 < vy.size() && !used[p.first][p.second];
	};
	vector<pair<int, int>> q = {st};
	used[st.first][st.second] = true;
	auto add = [&] (pair<int, int> p) {
		used[p.first][p.second] = true;
		q.push_back(p);
	};
	while (!q.empty()) {
		auto v = q.back();
		q.pop_back();
		if (ok({v.first - 1, v.second}) && !lol[v.first][v.second]) add({v.first - 1, v.second});
		if (ok({v.first + 1, v.second}) && !lol[v.first + 1][v.second]) add({v.first + 1, v.second});
		if (ok({v.first, v.second - 1}) && !kek[v.first][v.second]) add({v.first, v.second - 1});
		if (ok({v.first, v.second + 1}) && !kek[v.first][v.second + 1]) add({v.first, v.second + 1});
	}
	for (int i = 0; i + 1 < vx.size(); i++) {
		for (int j = 0; j + 1 < vy.size(); j++) {
			if (used[i][j] && (i == 0 || j == 0 || i + 2 == vx.size() || j + 2 == vy.size())) {
				cout << "INF\n";
				return 0;
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i + 1 < vx.size(); i++) {
		for (int j = 0; j + 1 < vy.size(); j++) {
			if (used[i][j]) ans += (ll) (vx[i + 1] - vx[i]) * (vy[j + 1] - vy[j]);
		}
	}
	cout << ans;
	return 0;
}



Measured memory_bytes: 39968
#include<iostream>
#include<vector>
int main()
{
	int n;
	long long int k=0;
	std::vector<int> a;
	std::vector<int> b;
	std::cin>>n;
	a.resize(n+1);
	b.resize(n);
	for(int i=0;i<=n;i++){
		std::cin>>a[i];
	}
	for(int i=0;i<n;i++){
		std::cin>>b[i];
	}
	for(int i=0;i<n;i++){
		if((a[i]+a[i+1])<=b[i]){
			k+=a[i]+a[i+1];
			a[i+1]=0;
		}else{
			k+=b[i];
			if(a[i]<b[i]){
				b[i]-=a[i];
				a[i+1]-=b[i];
			}
		}
	}
	std::cout<<k<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll n, l;
	cin >> n >> l;
	ll yotei = n * (2 * l + n - 1) / 2;
	ll sa = 1000000000;
	ll ans = 1000000000;
	reps(i, 1, n + 1) {
		if (sa > abs(l + i - 1)) {
			ans = i;
			sa = abs(l + i - 1);
		}
	}
	cout << yotei - (l + ans - 1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
using namespace std;
using ll = long long;

ll n, m;
string s, t;

ll GCD(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
	return a * b / (GCD(a, b));
}

int main() {
	cin >> n >> m;
	cin >> s >> t;
	ll a = LCM(n, m);
	bool flag = true;
	map<int, char>v;
	for (int i = 0; i < n; i++) {
		v[i * a / n] = s[i];
	}
	for (int i = 0; i < m; i++) {
		if (v[i*a / m] >= 'a'&&v[i*a / m] <= 'x' && v[i * a / m] != t[i])flag = false;
		else v[i *a / m] = t[i];
	}
	cout << (flag ? a : -1) << endl;
}

Measured memory_bytes: 8192
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}


Measured memory_bytes: 3208
import sys

while True:
    N = int(sys.stdin.readline().rstrip())
    if N == 0:
        break;
    max_value = 0
    prev_row = [0] * N
    for i in range(N):
        row = sys.stdin.readline().rstrip()
        curr_row = [0] * N
        for x,d in enumerate(row):
            if d == '.':
                if x == 0:
                    curr_row[x] = 1
                else:
                    curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
        max_value = max(max(curr_row), max_value)
        prev_row = curr_row

    print(max_value)

Measured memory_bytes: 7680
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  int n;
  cin >> n;
  cout << "ABC" << to_string(n) << endl;

  return 0;
}


Measured memory_bytes: 256
MOD =  pow(10,9)+7
def MODINV(n:int, MOD=MOD):
    return pow(n, MOD-2, MOD)

def main():
    N = int(input())
    if N < 2:
        print(0)
        return
    not0 = pow(9, N, MOD)
    not9 = pow(9, N, MOD)
    not0and9 = pow(8, N, MOD)
    ans = pow(10, N, MOD) - not0 - not0 + not0and9
    ans %= MOD
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define x first
#define y second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ll long long
#define ld long double
#define ii pair<int,int>
#define heap priority_queue
#define all(k) k.begin(),k.end()
#define rall(k) k.rbegin(),k.rend()
#define fa(a,c) for(auto &a:c)
#define yes "YES"
#define no "NO"




int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0);
ll r, a; cin>>r>>a; cout<<max(0ll,r-a-a)<<endl;




	return 0;
}


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

using namespace std;

int main() {
	int a, b, len;
	string s;
	cin >> s; len = s.length();
	a = b = -2;
	for(int i=1;i<len;i++) {
		if(s[i-1] == s[i]) {
			a = i-1; b = i;
			break;
		}
		if(i >= 2 && s[i-2] == s[i]) {
			a = i - 2; b = i;
			break;
		}
	}
	a++; b++;
	
	cout << a << " " << b << endl;
}


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

int LinearSearch(int n, int q, int *S, int *T){
	int count = 0;
	for(int i=0; i<q; i++){
		bool flag = true;
		for(int j=0; j<n; j++){
			if(S[j] == T[i] && flag == true){
				count++;
				flag = false;
			}
		}
	}
	return count;
}

int main(){
	int n; cin >> n;
	int S[n];
	for(int i=0; i<n; i++)
		cin >> S[i];
	int q; cin >> q;
	int T[q];
	for(int i=0; i<q; i++)
		cin >> T[i];

	int count = LinearSearch(n,q,S,T);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main()
{
    long long int n,a,b;
    cin>>n>>a>>b;
    if ((a>b)||(n==1&&a!=b))
    {
        cout<<0;
        return 0;
    }
    if (n==1&&a==b)
    {
        cout<<1;
        return 0;
    }
    cout<<((n-1)*b+a)-((n-1)*a+b)+1;
    return 0;
}


Measured memory_bytes: 256
S=str(input())
n=len(S)
Srev=''.join(list(reversed(S)))
S1=S[0:(n-1)//2]
S2=S[((n+1)//2):n]
S1rev=''.join(list(reversed(S1)))
S2rev=''.join(list(reversed(S2)))
if S==Srev and S1==S1rev and S2==S2rev:
    print('Yes')
else:
    print('No')

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  set<int> score;
  int N;
  score.insert(0);

  cin >> N;

  FOR(i, N) {
    int s;
    set<int> score2(score);
    cin >> s;
    for (auto x : score) {
      score2.insert(x + s);
    }
    score = score2;
  }

  auto it = max_element(score.begin(), score.end(), [](int a, int b) {
    if (a % 10 == 0) a = 0;
    if (b % 10 == 0) b = 0;
    return a < b;
  });

  cout << *it << endl;
  
  return 0;
}


Measured memory_bytes: 896
import collections
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))

count=1
mode=0
for i,Num in enumerate(A):
    if(mode==0):
        mode=1
    elif(mode==1):
        if(A[i]==A[i-1]):
            mode=1
        elif(A[i]>A[i-1]):
            mode=2
        elif(A[i]<A[i-1]):
            mode=3
    elif(mode==2):
        if(A[i]<A[i-1]):
            mode=1
            count+=1
    elif(mode==3):
        if(A[i]>A[i-1]):
            mode=1
            count+=1

print(count)

Measured memory_bytes: 14636
#include<bits/stdc++.h>
using namespace std;
#define GO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
const int maxr = 1e5 + 5;
int best(int x)
{
	for (int i = 1; true; i++)
    {
		int value = (i * (i + 1)) / 2;
		if (value > x)
			return i - 1;
	}
}

int32_t main()
{
	GO;
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 2; i * i <= n; i++)
    {
		if (n % i == 0)
        {
			int count = 0;
			while (n % i == 0)
            {
				n /= i;
				count++;
			}
			ans += best(count);
		}
	}
	if (n > 1)
		ans ++;
	cout << ans << endl;
	return 0;
}

//!


Measured memory_bytes: 3660
#include <stdio.h>
int main(void)
{
  int a,b,m;
  scanf("%d",&a);
  scanf("%d",&b);
  
  if(a-b>1)
  m=a+a-1;
  if(a-b==1)
   m=a+b;
  if(a==b)
  m=a+b;
  if(b-a>1)
    m=b+b-1;
  if(b-a==1)
    m=b+a;
  printf("%d",m);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <bitset>

int main() {
    int N;
    std::cin >> N;
    std::vector<std::bitset<64>> b(N);
    for (auto& e : b) {
        int k;
        std::cin >> k;
        for (int i = 0; i < k; ++i) {
            int j;
            std::cin >> j;
            e.set(j);
        }
    }

    std::bitset<64> a;
    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int t;
        std::cin >> t;
        int i;
        std::cin >> i;
        std::bitset<64> c;
        switch (t) {
            case 0:
                std::cout << a.test(i) << std::endl;
                break;

            case 1:
                a |= b[i];
                break;

            case 2:
                a &= ~b[i];
                break;

            case 3:
                a ^= b[i];
                break;

            case 4:
                c = a | ~b[i];
                std::cout << c.all() << std::endl;
                break;

            case 5:
                c = a & b[i];
                std::cout << c.any() << std::endl;
                break;

            case 6:
                c = a & b[i];
                std::cout << c.none() << std::endl;
                break;

            case 7:
                c = a & b[i];
                std::cout << c.count() << std::endl;
                break;

            default:
                c = a & b[i];
                std::cout << c.to_ullong() << std::endl;
                break;
        }
    }
    return 0;
}



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

int main() {
    int height;
    int width;
    cin >> height >> width;
    vector<string> str(height);
    for (int i=0; i<height; ++i) {
        cin >> str.at(i);
    }
    
    for (int i=0; i<width+2; ++i){
        cout << "#" ;
    }
    cout << endl;
    
    for (int i=0; i<height; ++i){
        cout << "#" << str.at(i) <<"#"<< endl;
    }
    
     for (int i=0; i<width+2; ++i){
        cout << "#" ;
    }
}

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

int main()
{
	vector<int> a(3);
	for(int i = 0;i<3;i++)cin >> a[i];
	sort(a.begin(),a.end());
	if(a[0]==5&&a[1]==5&&a[2]==7)
	{
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int r,D,x,x1;
    cin>>r>>D>>x;
    REP(i,10){
        x1=r*x-D;
        cout<<x1<<endl;
        x=x1;
    }
}

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

int main() {
    int64 W, H;
    cin >> W >> H;
    using P = pair<int, int>;
    priority_queue<P, vector<P>, greater<P>> pq;
    rep(i, 0, W + H) {
        int p; cin >> p;
        pq.push({p, i >= W});
    }
    W++, H++;
    int64 ans = 0;
    while(!pq.empty()) {
        P t = pq.top(); pq.pop();
        if(t.second) {
            ans += W * t.first;
            H--;
        }
        else {
            ans += H * t.first;
            W--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
const int maxn = 1e5;
int main(void)
{
	ll H, W;
	scanf("%lld %lld", &H, &W);
	ll a, b;
	if (W % 2)
		b = W / 2 + 1;
	else
		b = W / 2;
	ll ans = 0;
	if (W % 2 == 0)
		ans = H * b;
	else {
		if (H % 2)
			ans = (H / 2) * (b - 1LL) + (H / 2 + 1LL) * b;
		else
			ans = (H / 2) * b + (H / 2) * (b - 1LL);
	}
	if (W == 1 || H == 1)
		ans = 1;
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int x, y, b, p;
		cin >> x >> y >> b >> p;
		int ans;
		//pattern 1
		ans = x * b + y * p;
		//pattern 2
		if (b < 5) b = 5;
		if (p < 2) p = 2;
		x = x / 5 * 4;
		y = y / 5 * 4;
		ans = min(ans, x * b + y * p);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<algorithm>
#include <iostream>
#include<stdio.h>
using namespace std;

int main() {
	int n, i;
	int a[200001];
	int big = 0, bignum;
	scanf("%d", &n);
	for (i = 0;i < n;i++) {
		scanf("%d", &a[i]);
		if (a[i] >= big) {
			big = a[i];
			bignum = i;
		}
	}

	sort(a, a + n);

	for (i = 0;i < n;i++) {
		if (bignum != i) {
			printf("%d\n", a[n - 1]);
		}
		else {
			printf("%d\n", a[n - 2]);
		}

	}

	return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

static const int MAXN = 1005;
static const int MAXV = MAXN*MAXN;
vector<int> to[MAXV];
int id[MAXN][MAXN];

int toId(int i, int j) { // 選手i, jの試合に対応する頂点番号を返す
  if (i > j) swap(i, j);
  return id[i][j];
};

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV]; // max length of path from v（vからstartしたときの最長経路）
int dfs(int v) {
  if (visited[v]) {
    if (!calculated[v]) return -1;
    return dp[v];
  }
  visited[v] = true;
  dp[v] = 1;
  for (int u: to[v]) {
    int res = dfs(u);
    if (res == -1) return -1;
    dp[v] = max(dp[v], res+1);
  }
  calculated[v] = true;
  return dp[v];
};

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int> (n-1));
  rep(i, 0, n) {
    rep(j, 0, n-1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }

  int V = 0;
  // idテーブルの初期化
  rep(i, 0, n) {
    rep(j, 0, n) {
      if (i < j) {
        id[i][j] = V++;
      }
    }
  }

  rep(i, 0, n) {
    rep(j, 0, n-1) {
      a[i][j] = toId(i, a[i][j]); // 試合の頂点idに変更
    }
    rep(j, 0, n-2) {
      to[a[i][j+1]].pb(a[i][j]); // 試合の逆順序のグラフを作成
    }
  }

  int ans = 0;
  rep(i, 0, V) {
    int res = dfs(i);
    if (res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, dfs(i));
  }

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


Measured memory_bytes: 53248
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const int INF=1e9;


int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i,n) cin>>a[i];

  sort(a.begin(),a.end());
  int ans=0;

  rep(i,k){
    ans+=a[i];
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;
#define len(x) x.length()
#define vsort(x) sort(x.begin(), x.end();
using namespace std;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
   // freopen("bruh.txt","r",stdin);
    #endif
     int a, b , c;
     ll sum=0;
     cin >>a;
     for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            for(int k=1;k<=a;k++){
                int temp=__gcd(i,j);
                sum+=__gcd(temp,k);
            }
        }
     }
     cout<<sum<<nl;
}


Measured memory_bytes: 3608
#include <cstdio>

int main(){
	int n;
	while(~scanf("%d",&n)){
		int res = n % 39;
		if(!res)res = 39;
		if(res < 10){
			printf("3C0%d\n",res);
		}
		else{
			printf("3C%d\n",res);
		}
	}
}

Measured memory_bytes: 0
/**
 * author:    Ziel
 * created:   15.04.2020 19:51:56
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;

	vector<int> a(n);
	vector<int> cnt(n + 1);
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}

	for (int i = 1; i <= n; i++) cout << cnt[i] << '\n';

	return 0;
}




Measured memory_bytes: 4808
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include<iomanip>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

int main(){
  int n,m;
  cin >> n >> m;
  
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;

  return 0;
}


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



int main(){
  int n;
  cin >> n;
  int minc = 2000000000;
  REP2(i,1,n){
    int a = i;
    int b = n - a;
    int cnt_a = 0;
    int cnt_b = 0;
    for(int j = 5; j >= 0; --j){
      int x = 1;
      REP(k,j) x *= 10;
      cnt_a += a/x;
      a %= x;
      cnt_b += b/x;
      b %= x;
    }

    //cout << cnt_a<<" " << cnt_b << endl;

    minc = min(minc, cnt_a + cnt_b);
  }

  cout << minc << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  char c;
  cin >> a >> c >> b;
  if(c == '+')
    cout << a+b << endl;
  if(c == '-')
    cout << a-b << endl;
  if(c == '*')
    cout << a*b << endl;
  if(c == '/')
    cout << a/b << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

c = Hash.new

a.each do |ai|
  if c[ai].nil?
    c[ai] = 1
  else
    c[ai] += 1
  end
end

count = 0

c.each do |k, v|
  if k <= v
    count += (v - k)
  else
    count += v
  end
end

print count

Measured memory_bytes: 15492
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;
const int JJJ = 100009;

int N,A;
vector<int>grafo[JJJ];
bool visited[JJJ];
int dp[JJJ];

int sol = 0;
void dfs(int nod){
    visited[nod] = true;
    dp[nod] = -1;
    for(int i = 0;i < (int)grafo[nod].size();i++){
        int xx = grafo[nod][i];
        if(!visited[xx]){
            dfs(xx);
        }
        dp[nod] = max(dp[nod],dp[xx]);
    }
    dp[nod]++;
}



int main(){

  
    ios_base::sync_with_stdio(0); cin.tie(0);


    cin >> N >> A;
    for(int i = 0;i < A;i++){
        int a,b;
        cin >> a >> b;
        grafo[a].pb(b);
    }

    for(int i = 1;i <= N;i++){
        if(!visited[i]){
            dfs(i);
        }
        sol = max(sol,dp[i]);
    }

    cout<<sol;



    return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    string s,t;
    cin>>s>>t;
    ll ans=hell;
    for(int i=0;i<=s.size()-t.size();i++)
    {
        string p=s.substr(i,t.size());
        ll count=0;
        rep(j,0,t.size())
        {
            if(t[j]!=p[j])
                count++;
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3664
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };
    let sc: i32 = s.parse().unwrap();
    let h: i32 = sc / 3600;
    let m: i32 = (sc - h * 3600) / 60;
    let os: i32 = sc - (h * 3600) - (m * 60);

    println!("{:?}:{:?}:{:?}", h, m, os);
}


Measured memory_bytes: 5036
#include<stdio.h>
#define MAXN 100
int main(void){
    int A[MAXN];
    int i;
    int n;
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &A[i]);
    }
    for(i=n-1;0<=i;i--){
        if(i != n-1)printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2036
#include<stdio.h>
int main(void)

{
	int H, W, i,a;

	while (1)
	{
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)
		{
			break;
		}
		for (i = 0; i < H; i++)
		{
			for (a = 0; a < W; a++)
			{
				printf("#");
			}printf("\n");
		}
		printf("\n");

	}

	return 0;
}


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

int main () {
  int64_t a, b, c, d, p, ans;
  cin >> a >> b >> c >> d;
  p = b - a + 1;
  ans = p - (b/c + b/d - b/(c*d/__gcd(c,d)) - ((a-1)/c + (a-1)/d - (a-1)/(c*d/__gcd(c,d))));
  cout << ans;
}

Measured memory_bytes: 256
x=int(input())

def prime(n):
  if n==2:
    ans=True
  else:
    limit=int(n**(1/2)+1)
    ans=True
    for i in range(2,limit+1):
      if n%i==0:
        ans=False
        break
  return ans

expected=x-1
flag=True
while flag==True:
  expected+=1
  if prime(expected):
    flag=False
    ans=expected
    break
print(ans)


Measured memory_bytes: 3060
def v():
 for e in iter(input,'0 0'):
  r=int(e.split()[0])
  d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
  a=0
  for m in range(1<<~-r):
   t=0
   for s in d:
    c=bin(m^s).count('1')
    t+=c if c>r//2 else r-c
   if a<t:a=t
  print(a)
if'__main__'==__name__:v()


Measured memory_bytes: 6920
#include <array>
#include <iostream>

int main() {
  std::array<int, 5> v;
  for (int i = 0; i < 5; ++i) std::cin >> v[i];

  int t = 0;
  int dt = 10;
  for (int i = 0; i < 5; ++i) {
    if (v[i] % 10 == 0)
      t += v[i];
    else {
      dt = std::min(dt, v[i] % 10);
      t += (v[i] / 10 + 1) * 10;
    }
  }
  std::cout << t + dt - 10 << std::endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int k,s,x,y,ans;
int main(){
	scanf("%d%d",&k,&s);
	for(x=0;x<=k;x++){
		if(s<x) break;
		for(y=0;y<=k;y++){
			if(s<x+y) break;
			if(s>=x+y&&s-x-y<=k) ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	char s[4];
	int i,j,c;
	c=0;
	scanf("%s",&s);
	for(i=0;i<3;i++){
		j=i+1;
		if(s[i]==s[j]){
			c++;
		}
	}
	if(c>=1){
		printf("Bad");
	}else{
		printf("Good");
	}

		
	// your code goes here
	return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    map<ll, ll> c;
    REP(i, N){
        ll a; cin >> a;
        ll m = min(a / 400, (ll)8);
        c[m]++;
    }
    
    ll ret = 0;
    for(ll i = 0; i * 400 <= 3199; i++){
        if(c[i] != 0) ret++;
    }
    
    cout << max(ret, (ll)1) << " " << ret + c[8] << endstr;
    return 0;
}


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

using namespace std;

int main() {
    int K, N;
    vector<int> A;
    
    cin >> K >> N;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A.emplace_back(tmp);
    }

    int diff_max = 0;

    for (int i = 0 ; i < N; i++) {
        int house1 = A[i], house2 = A[i + 1];
        if (i == N - 1) house2 = A[0] + K; 
        if (house2 - house1 > diff_max) diff_max = house2 - house1;
    }

    int answer;
    answer = K - diff_max;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

long modpow(long a, long n, long mod){
  long size;
  for (long i = 1; ; i++) {
    if (pow(2,i) > n) {
      size = i;
      break;
    }
  }
  long bit[size];
  bit[0] = n;
  for (long i = 1; i < size; i++) {
    bit[i] = bit[i-1]/2;
    bit[i-1] %= 2;
  }
  long powa[size];
  powa[0] = a;
  for (long i = 1; i < size; i++) {
    powa[i] = powa[i-1]*powa[i-1];
    powa[i] %= mod;
  }
  long answer = 1;
  for (long i = 0; i < size; i++) {
    if (bit[i] == 1) {
      answer *= bit[i]*powa[i];
      answer %= mod;
    }
  }
  return answer;
}

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long mod = pow(10,9)+7;
  qsort(a, n, sizeof(long), cmpnum);
  if (n%2 == 1) {
    if (a[0] != 0) {
      printf("0\n");
      return 0;
    }
    for (long i = 1; i < n; i += 2) {
      if (a[i] != a[i-1]+2 || a[i] != a[i+1]) {
        printf("0\n");
        return 0;
      }
    }
  } else {
    if (a[0] != 1 || a[1] != 1) {
      printf("0\n");
      return 0;
    }
    for (long i = 2; i < n; i += 2) {
      if (a[i] != a[i-1]+2 || a[i] != a[i+1]) {
        printf("0\n");
        return 0;
      }
    }
  }
  printf("%ld\n", modpow(2,n/2,mod));

  return 0;
}

Measured memory_bytes: 1788
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CToInfinity {
public:
    void solve(std::istream &in, std::ostream &out) {
        string str;
        in >> str;
        ll k;
        in >> k;
        char res = '0';
        trav(c, str) {
            k--;
            if (not k or c != '1') {
                res = c;
                break;
            }
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CToInfinity solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin>>N;
 if(N==10 || N==100 || N==1000 || N==10000 || N==100000)
 {
   cout<<10<<endl;
 }else{
 int dig;
 int sum=0;
 while(N)
  {
    dig=N%10;
    sum=sum+dig;
    N=N/10;
  }
  cout<<sum<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int cnt[105];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n,k;cin>>n>>k;
    int ans = 0;
    _for(i,0,k){
        int x;cin>>x;
        _for(i,0,x){
            int c;cin>>c;
            cnt[c]=1;
        }
    }
    _for(i,1,n+1){
        if(!cnt[i])++ans;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>

main(){
	int a, b, c,i,sort[3];
	
	scanf("%d%d%d",&a,&b,&c);
	
	if(a<b&&b<c){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define ull unsigned long long
#define y1 asjdlfaskavslbcjasndscf
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define iter vector< int >::iterator
#define iter1 multiset<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=500+7;
const int inf=1e18+1e9;
const int mod=998244353;
const ld eps=1e-9;

//const int MAX_MEM=1e8;
//int mpos=0;
//char mem[MAX_MEM];
//
//inline void * operator new(size_t n){
//    char *res=mem+mpos;
//    mpos+=n;
//    assert(mpos<=MAX_MEM);
//    return (void*)res;
//}
//
//inline void operator delete(void *) {}

int n;
bool used[N];
vector<int>g[N];
bool f[N][N];
int t[N],d[N][N];

void dfs(int v,int c=0)
{
    used[v]=1;
    t[v]=c+1;
    for (int i=0;i<g[v].size();++i){
        int to=g[v][i];
        if (!used[to]){
            dfs(to,(c^1));
        }
    }
}

main ()
{
    ios;
    cin>>n;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=n;++j){
            char ch;
            cin>>ch;
            if (ch=='0'){
                f[i][j]=0;
            }
            else {
                g[i].pb(j);
                f[i][j]=1;
            }
        }
    }
    for (int i=1;i<=n;++i){
        if (!used[i]){
            dfs(i);
        }
    }
    for (int i=1;i<=n;++i){
        for (int j=1;j<=n;++j){
            if (f[i][j]){
                if (t[i]==t[j]){
                    cout<<-1<<endl;
                    exit(0);
                }
            }
        }
    }
    for (int i=1;i<=n;++i){
        for (int j=1;j<=n;++j){
            d[i][j]=inf;
        }
    }
    for (int i=1;i<=n;++i){
        d[i][i]=0;
        for (int j=1;j<=n;++j){
            if (f[i][j]){
                d[i][j]=1;
            }
        }
    }
    for (int k=1;k<=n;++k){
        for (int i=1;i<=n;++i){
            for (int j=1;j<=n;++j){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int ans=0;
    for (int i=1;i<=n;++i){
        for (int j=1;j<=n;++j){
            ans=max(ans,d[i][j]);
        }
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 1408
judge as = if jsub as then "Yes" else "No"
jsub as
  | e == 0 = o<=q+1
  | otherwise = o<=q
  where 
    mods = map (flip mod 4) as
    q = length $ filter (==0) mods
    e = length $ filter (==2) mods
    o = length $ filter odd mods

main = getLine >> getLine >>= putStrLn . judge . map read . words

Measured memory_bytes: 36220
import Control.Monad
import Control.Applicative

calcPath :: Int -> Int -> [(Int, Int)] -> IO Int
calcPath 0 _ _  = return 1
calcPath _ _ [] = return 0
calcPath l n xs = sum <$> (forM nextXs' $ (\i -> do
  --putStrLn $ show (l, n, xs ,nextXs, map snd nextXs')
  --(putStrLn . show) =<< calcPath 2 3 [(2,3),(3,4),(2,4)]
  calcPath (l - 1) i nextXs))
  where f x = (snd.includeN x) n
        nextXs  = [xs' | xs' <- xs, not.fst.includeN xs' $ n]
        nextXs' = [f y | y <- xs, fst.includeN y $ n] 

includeN :: (Int, Int) -> Int -> (Bool, Int)
includeN (x, y) n
  | x == n    = (True, y)
  | y == n    = (True, x)
  | otherwise = (False, 0)


main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine
  numPares <- replicateM m $ do
              [a, b] <- map read . words <$> getLine
              return (a, b)
  putStrLn =<< (show <$> calcPath (n - 1) 1 numPares)

Measured memory_bytes: 1532
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int main(void)
{
  int N;
  cin >> N;
  vector<string> w(N);
  map<string, int> mp;
  for (int i = 0; i < N; i++) {
    cin >> w[i];
    // 過去に言った発言があったらしりとり失敗
    if (mp.count(w[i]) > 0) {
      cout << "No" << endl;
      return 0;
    }
    // 発言を記録する
    mp[w[i]]++;

    if (i == 0) continue;
    // 最初と最後が一致してなければしりとり失敗
    if (*(w[i - 1].end() - 1) != *(w[i].begin())) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 504
#include<iostream>
using namespace std;
int main(){
	int n,a,b,c,d,s;
	while(true){
		a=0,b=0;
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>c>>d;
			s=c+d,b+=s;
			if(c>d)a+=s;
			if(c==d)a+=c;
		}
		cout<<a<<" "<<b-a<<endl;
	}
	return 0;
}
 

Measured memory_bytes: 1160