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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int f(int k){
    int ans = 1;
    
    while(1){
        int kk = k;
        int cnt = 0;
    
        while(k){
            if(k % 2) cnt++;
            k /= 2;
        }
        
        k = kk % cnt;
        if(k == 0) return ans;
        ans++;
    }
    
    cout << "error" << endl;
    return -1;
}

void Main(){
    int n; string x; cin >> n >> x;

    int pcnt = 0;
    rep(i, n){
        if(x[i] == '1') pcnt++;
    }
    
    int pcnt1 = pcnt + 1;
    int pcnt2 = pcnt - 1;
    int flag = 0;
    
    if(pcnt2 != 0) flag = 1;
    
    ll tot1 = 0;
    ll tot2 = 0;
    ll two1 = 1 % pcnt1;
    ll two2 = flag ? 1 % pcnt2 : -1;
    
    rep3rev(i, n-1, 0){
        int now = x[i] - '0';
        int tmp = (now * two1) % pcnt1;
        // cout << "now = " << now << ": ";
        // cout << two1 << ", " << two2 << ": ";
        // cout << tmp << " ";
        tot1 = (tot1 + tmp) % pcnt1;
        tmp = flag ? (now * two2) % pcnt2 : -1;
        // cout << tmp << endl;
        tot2 = flag ? (tot2 + tmp) % pcnt2 : -1;
        two1 = (two1 * 2) % pcnt1;
        two2 = flag ? (two2 * 2) % pcnt2 : -1;
    }
    
    // cout << pcnt1 << " " << tot1 << endl;
    // cout << pcnt2 << " " << tot2 << endl;
    
    two1 = 1 % pcnt1;
    two2 = flag ? 1 % pcnt2 : -1;
    vll ans(n);
    
    rep3rev(i, n-1, 0){
        int now = x[i] - '0';
        if(!now){
            ans[i] = (tot1 + two1) % pcnt1;
            // cout << i << " " << tot1 << " " << two1 << " " << ans[i] << endl;
        }else{
            ans[i] = flag ? (tot2 + pcnt2 - two2) % pcnt2 : -1;
            // cout << i << " " << tot2 << " " << two2 << " " << ans[i] << endl;
        }
        two1 = (two1 * 2) % pcnt1;
        two2 = pcnt2 != 0 ? (two2 * 2) % pcnt2 : 0;
    }
    
    // rep3(i, 1, 10) cout << i << " " << f(i) << endl;
    
    //*
    rep(i, n) {
        // cout << ans[i] << " ";
        if(ans[i] == -1) cout << 0 << endl;
        else if(ans[i] == 0) cout << 1 << endl;
        else cout << f(ans[i]) + 1 << endl;
    }
    //*/
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

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

int main(){
    int N, X;
    cin >> N >> X;
    int L[N];
    rep(i, N){
        cin >> L[i];
    }
    int sum = 0;
    int i=0;
    for(i;i<N;i++){
        sum += L[i];
        if(sum>X) break;
    }
    printf("%d\n", i+1);
    return 0;
}

Measured memory_bytes: 256
/*Allah vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define f first
#define s second
#define Max 200005
using namespace std;

vector<int> graph[Max];
int n, m;
bool vis[Max];
int ret;

void dfs(int src) {
    if(vis[src]) return;
    vis[src] = 1;
    ret++;
    for(int i = 0; i < (int)graph[src].size(); i++) {
        if(vis[graph[src][i]] == 0) {
            dfs(graph[src][i]);
        }
    }
}

int main() {
    cin >> n >> m;
    if(!m) {
        printf("1\n"); return 0;
    }
    set<int> st;
    for(int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        graph[u].pb(v);
        graph[v].pb(u);
        st.insert(u);
        st.insert(v);
    }
    int ans = 0;
    for(int node : st) {
        if(vis[node] == 0) {
            ret = 0;
            dfs(node);
            ans = max(ans, ret);
        }
    }
    int cnt = 0;
    ans = max(ans, cnt);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 30308
/**
 *    author:  FromDihPout
 *    created: 2020-08-04
**/

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] == i) {
            if (i < n) swap(a[i], a[i+1]);
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  vll a(n), s(n);
  re(i, n){
    std::cin >> a[i];
    s[i] = (i==0?0:s[i-1]) + a[i];
  }
  ll ans = 1000000000000000000;
  re(i, n-1) ans = min(ans, abs(s[n-1]-s[i] - s[i]));
  std::cout << ans << '\n';
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

class mod{
    public:
    ll N, M;
    vector<ll>fact;
    vector<ll>inv;
    vector<ll>finv;

    ll m_plus(ll a, ll b){return (a + b) % M;}
    ll m_minus(ll a, ll b){return (a + M - b) % M;}
    ll m_times(ll a, ll b){return (a * b) % M;}
    ll m_pow(ll a, ll b){
        ll ret = 1;
        while(b > 0){
            if(b & 1)(ret *= a) %= MOD;
            (a *= a) %= MOD;
            b >>= 1;
        }
        return ret;
    }

    void update(ll n){
        if(N > n)return;
        for(ll i = N; i <= n; i++){
            fact.push_back(m_times(fact[i - 1], i));
            inv.push_back(m_pow(i, M - 2));
            finv.push_back(m_times(finv[i - 1], inv[i]));
        }
        N = n + 1;
    }
    ll m_divs(ll a, ll b){
        if(N <= b)update(b);
        return m_times(a, inv[b]);
    }

    // N種の要素を並び替えてできる通りの数
    ll m_fact(ll a){
        if(N <= a)update(a);
        return fact[a];
    }

    // 階乗で割る
    ll m_finv(ll a){
        if(N <= a)update(a);
        return finv[a];
    }

    // N種の要素からk個取り出して並べる通りの数
    ll m_nPk(ll n, ll k){
        return m_times(m_fact(n), m_finv(n - k));
    }
    // N種の要素からk個を選ぶ通りの数
    ll m_nCk(ll n, ll k){
        return m_times(m_nPk(n, k), m_finv(k));
    }
    // N種の要素からk個を選ぶ通りの数(重複して良い)
    ll m_nHk(ll n, ll k){
        return m_nCk(n + k - 1, k);
    }
    
    mod(ll m){
        M = m;
        N = 1;
        fact = vector<ll>(1, 1);
        inv = vector<ll>(1, 1);
        finv = vector<ll>(1, 1);
    }
};

ll solve(ll x, ll y){
    if((x + y) % 3)return 0;
    ll a = (2 * x - y) / 3;
    ll b = x - 2 * a;
    if(a < 0 || b < 0)return 0;
    mod m(MOD);
    return m.m_nCk(a + b, a);
}

int main(){

    ll X, Y;
    cin >> X >> Y;
    cout << solve(X, Y) << endl;

    return 0;
}

Measured memory_bytes: 22848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;




int main(){
    string S; cin >> S;
    map<char, int> M;
    for(auto ch : S) M[ch]++;
    bool flag = true;
    if(M.size() != 2) flag = false;
    for(auto m : M){
        if(m.second != 2) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

int main(void)
{
	string s;
	vector<char> ans1, ans2;
	int a1 = 0, a2 = 0;
	cin >> s;

	for (int i = 0; i < s.size(); ++i)
	{
		ans1.emplace_back();
		ans2.emplace_back();
		if (i % 2)
		{
			ans1[i] = '0';
			ans2[i] = '1';
		}
		else
		{
			ans1[i] = '1';
			ans2[i] = '0';
		}
	}

	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] != ans1[i])
			++a1;
		else
			++a2;
	}

	cout << (a1 < a2 ? a1 : a2);

	return 0;
}

Measured memory_bytes: 768
s = input()
t = input()
sl = len(s)
tl = len(t)
case = []

for i, si in enumerate(s):
    fault = False
    for j, tj in enumerate(t):
        if i + j >= sl:
            fault = True
            break
        if not s[i+j] in [tj, "?"]:
            fault = True
            break
    if not fault:
        case.append((s[0:i] + t + s[i+tl:]).replace("?", "a"))

if len(case) == 0:
    print("UNRESTORABLE")
else:
    print(sorted(case)[0])

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

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    if(t.size()==s.size()+1 && t.substr(0,t.size()-1)==s) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3628
import sys
from collections import Counter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

n, k, q = na()
d = {k:0 for k in range(1, n+1)}
for i in range(q):
    num = ni()
    d[num] += 1
for key in sorted(d.keys()):
    if k - (q - d[key]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 15468
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define Test ll t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define repR(i,a,b) for(ll i=a;i>=b;i--)
#define loopS(i,a,b,step) for(ll i=a;i<b;i+=step)
#define loopRS(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define pll pair<ll,ll>
#define puu pair<ull, ull>
#define V vector
#define M map
#define UM unordered_map
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define inf INT_MAX
#define S3(a,b,c) cin >> a >> b >> c
#define S2(a,b) cin >> a >> b
#define debug(x) cerr << #x << " = " << x << endl;
#define debug2(x,y) cerr << #x << " = " << x << " " << #y << " = " << y << endl;
#define debug3(x,y,z) cerr << #x << " = " << x << " " << #y << " = " << y <<  " " << #z << " = " << z << endl;
using namespace std;

void input(ll n, ll arr[]) {
	rep(i, 0, n)cin >> arr[i];
}
const ll mx = 1e7;
int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout.tie(NULL);
	ll n; cin >> n;
	ll d = 0, cnt = 0;
	while (cnt <= mx) {
		if ((d * 10 + 7) % n == 0) {
			cnt++;
			break;
		}
		d = (d * 10 + 7) % n;
		cnt++;
	}
	if (cnt > mx)cout << "-1\n";
	else cout << cnt << endl;
}


Measured memory_bytes: 3660
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
ostream &operator<<(ostream &os, const set<T> &st) {
	for (const auto &e : st) os << e << " ";
	return os;
}

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

template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
	for (const auto &e : mp) os << e << " ";
	return os;
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<pair<lint, lint>> LR(N);
	for (int i = 0; i < N; i++) cin >> LR[i].first >> LR[i].second;

	// 両方が値を持つパターン
	auto solve = [&N](auto &LR) {

		vector<lint> L(N), R(N);
		for (int i = 0; i < N; i++) tie(L[i], R[i]) = LR[i];
		DMP(L, R);

		vector<lint> rL_f(N + 1), rL_b(N + 1), rR_f(N + 1), rR_b(N + 1);
		rR_f.front() = INF;
		rR_b.back() = INF;

		for (int i = 0; i < N; i++) {
			rL_f[i + 1] = max(rL_f[i], L[i]);
			rR_f[i + 1] = min(rR_f[i], R[i]);
		}
		for (int i = N - 1; i >= 0; i--) {
			rL_b[i] = max(rL_b[i + 1], L[i]);
			rR_b[i] = min(rR_b[i + 1], R[i]);
		}

		DMP(rL_f, rL_b, rR_f, rR_b);

		lint ans = 0;
		for (int i = 1; i < N; i++) {
			chmax(ans, max(rR_f[i] - rL_f[i] + 1, 0LL) + max(rR_b[i] - rL_b[i] + 1, 0LL));
			DMP(rR_f[i] - rL_f[i] + 1, rR_b[i] - rL_b[i] + 1);
		}


		for (int i = 0; i < N; i++) chmax(ans, R[i] - L[i] + 1 + max(min(rR_f[i], rR_b[i]) - max(rL_f[i], rL_b[i]) + 1, 0LL));

		return ans;

	};

	lint ans = 0;

	sort(LR.begin(), LR.end());
	DMP(LR);
	chmax(ans, solve(LR));

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 6528
import java.util.*;class Main{public static void main(String[]z){double[]b=new double[8];for(Scanner s=new Scanner(System.in);s.hasNext();System.out.println((f(b[0],b[1],b[4],b[5],b[6],b[7])>0&&f(b[4],b[5],b[0],b[1],b[2],b[3])>0&&f(b[2],b[3],b[6],b[7],b[0],b[1])>0&&f(b[6],b[7],b[2],b[3],b[4],b[5])>0)||(f(b[0],b[1],b[4],b[5],b[6],b[7])<0&&f(b[4],b[5],b[0],b[1],b[2],b[3])<0&&f(b[2],b[3],b[6],b[7],b[0],b[1])<0&&f(b[6],b[7],b[2],b[3],b[4],b[5])<0)?"YES":"NO")){z=s.next().split(",");for(int i=0;i<8;++i)b[i]=new Double(z[i]);}}static double f(double a,double b,double c,double d,double e,double f){return ((d-b)*e+(a-c)*f+c*b-a*d);}}

Measured memory_bytes: 17152
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    final String T;

    AtCoder(FastScanner sc) {
        T = sc.next();
    }

    void solve(PrintWriter out) {
        String sd = T.replace('?', 'D');
        out.println(sd);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 35288
import copy
N,W=map(int,input().split())
dp_1=[0]*(W+1)
dp_2=[0]*(W+1)

for i in range(1,N+1):
    w,v=map(int,input().split())
    #dp_2=[0]*(W+1)
    for j in range(1,W+1):
        if j-w>=0:
            dp_2[j]=max(dp_1[j],dp_1[j-w]+v)
        else:
            dp_1[j]=dp_2[j]
    dp_1=copy.copy(dp_2)
print(dp_2[-1])

Measured memory_bytes: 59784
# 再帰の制限を上げる
import sys
sys.setrecursionlimit(10**8)

import itertools
import queue

H,W = map(int,input().split())
S = []
for i in range(H):
    S.append(input())

# (x,y)がエリア内である
def check(x,y):
    return not(x<0 or x>H-1 or y<0 or y>W-1 or S[x][y] == "#")

# 到達可能な場所を，距離を記録しながら幅優先探索で埋め尽くす
def bfs(start):
    # 各ノードへの距離 (-1: 未訪問or到達不可)
    dists = [[-1 for _ in range(W)] for _ in range(H)]

    # startが範囲外なら終了
    if not check(*start): return dists
    
    q = queue.Queue()    
    # start位置をput
    q.put(start)
    dists[start[0]][start[1]] = 0
    
    # キューからデータがなくなるまで取り出しを行う
    while not q.empty():
        here = q.get()
        x = here[0]
        y = here[1]

        # この場所の距離
        dist = dists[x][y]
        
        # x,yがエリア内なら
        if check(*here):
            # 訪問済みでない隣接するノードをキューに追加
            for dx,dy in [(1,0),(-1,0),(0,1),(0,-1)]:
                # エリア内かつ未訪問
                if check(x+dx,y+dy) and dists[x+dx][y+dy] == -1:
                    q.put((x+dx,y+dy))
                    dists[x+dx][y+dy] = dist + 1

    return dists

ans = []
for start in itertools.product(range(H),range(W)):

    dists = bfs(start)
    ans.append(max([max(_) for _ in dists]))

print(max(ans))

Measured memory_bytes: 3952
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define ld long double
#define int long long

void SOLVE() {
	string s, t;
	cin >> s >> t;
	t += s;
	cout << t << '\n';
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed;
	cout.precision(10);
	//freopen("longpath.in", "r", stdin);
	//freopen("longpath.out", "w", stdout);
	int Q = 1;
	//cin >> Q;
	while (Q--)
		SOLVE();

	return 0;
}
/*
*/

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

b = list(map(int,input().split()))
a = [0 for _ in range(n)]
a[0] = b[0]
a[-1] = b[-1]

for i in range(1,n-1):
	if b[i-1] > b[i]:
		a[i] = b[i]
	else:
		a[i] = b[i-1]

print(sum(a))


Measured memory_bytes: 38256
# coding: utf-8

N, X = map(int, input().split())
m_list = []
for i in range(N):
    mi = int(input())
    m_list.append(mi)

min_total = sum(m_list)
resi = X - min_total
m_min = min(m_list)

addNum = resi // m_min

num = len(m_list) + addNum

print(num)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int M,K;

int main(void) {
    cin>>M>>K;

    if (K >= pow(2.0,M)) {
        cout<<-1<<endl;

        return 0;
    }
    
    if(M == 1) {
        if(K == 1) {
            cout<<-1<<endl;

            return 0;
        } else if(K == 0) {
            cout<<0<<" "<<0<<" "<<1<<" "<<1<<endl;

            return 0;
        }
    }

    vector<int> up;
    for(int i = 0;i < pow(2.0,M);i++) {
        if(i != K)
            up.push_back(i);
    }

    vector<int> a;
    sort(up.begin(),up.end());
    for(int i = 0;i < up.size();i++)
        a.push_back(up[i]);
    a.push_back(K);
    sort(up.begin(),up.end(),greater<int>());
    for(int i = 0;i < up.size();i++)
        a.push_back(up[i]);
    a.push_back(K);

    for(int i = 0;i < a.size();i++) {
        cout<<a[i]<<" ";
    }
    cout<<endl;

    return 0;
}




Measured memory_bytes: 3444
from operator import itemgetter
from math import log,ceil
from fractions import gcd
mod = 10**9 + 7


def euclid(a:int,b:int)->(int,int):
    #return x,y s.t ax + by = gcd(a,b)
    #a > b >= 0
    if b == 0:
        return 1,0
    x,y = euclid(b,a%b)
    return y,x - y*(a // b)

def inverse(a:int,mod:int)->int:
    #gcd(p,b) == 1
    if mod > a:
        n,x = euclid(mod,a)
    else:
        x,n = euclid(a,mod)
    return x

def devide_mod(a:int,b:int,mod:int)->int:
    #a // b
    x = inverse(b,mod)
    return  (a*x)%mod



def lcm(a:int,b:int):
    return a*b // gcd(a, b)

def main():
    N = int(input())
    A  =list(map(int,input().split()))
    neko = 1
    for a in A:
        neko = lcm(neko,a)
    sm = 0
    neko = neko%mod
    for a in A:
        sm = (sm + devide_mod(neko , a,mod))%mod
    print(sm)

    return


if __name__ == "__main__":
    main()

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

int main(){
  int A,B;
  cin >> A >> B;
  int i=1;
  int sum=A;
  while(sum<B){
    sum+=A-1;
    i++;
  }
  if (B==1)
    cout << 0 << endl;
  else
    cout << i << endl;
}


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

#define int long long
#define pb push_back
#define st first
#define nd second
#define sz(x) ((int)x.size())
#define ins insert
using namespace std;

const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int tmp=0;
    for(int i=0;s[i];++i){
        tmp+=s[i]-'0';
    }
    if(tmp%9)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;


}
/**
1
3 1
1 3
**/


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

int main(){
    int n;
    cin>>n;
    long long sum = 0;

    for(long long i=1; i<=n; i++){
        if(i%3 == 0 || i%5 == 0 || i%15 == 0){
            continue;
        }
        else{
            sum += i;
        }
    }

    cout<<sum<<endl;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using pll = pair<ll, ll>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  map<pll, ll> mp;
  for (ll k = a; k <= b; k++) {
    vector<vector<pll>> dp(n + 1, vector<pll>(k + 1));
    dp[0][0] = make_pair(0, 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= k; j++) {
        if (dp[i + 1][j].first == dp[i][j].first) {
          dp[i + 1][j].second += dp[i][j].second;
        }
        if (dp[i + 1][j].first < dp[i][j].first) {
          dp[i + 1][j] = dp[i][j];
        }
        if (j < k) {
          if (dp[i + 1][j + 1].first == dp[i][j].first + v[i]) {
            dp[i + 1][j + 1].second += dp[i][j].second;
          }
          if (dp[i + 1][j + 1].first < dp[i][j].first + v[i]) {
            dp[i + 1][j + 1].first = dp[i][j].first + v[i];
            dp[i + 1][j + 1].second = dp[i][j].second;
          }

        }
      }
    }
    ll g = __gcd(k, dp[n][k].first);
    mp[make_pair(dp[n][k].first / g, k / g)] += dp[n][k].second;
  }
  ll mx = 0;
  double ans = 0.;
  for (auto &pr : mp) {
    if (pr.first.first >= ans * pr.first.second) {
      ans = (double) pr.first.first / pr.first.second;
      mx = pr.second;
    }
  }
  printf("%.9lf\n%lld\n", ans, mx);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
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;}
template<class T> inline bool chmax(T& a, T b){if(a<b) {a=b; return 1;} return 0; }
template<class T> inline bool chmin(T& a, T b){if(a>b) {a=b; return 1;} return 0; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

int main(){
    ll N,M;cin>>N>>M;
	vll a(M),dp(N+1,INF);
	rep(i,M){
		cin>>a[i];
        dp[(a[i])]=0;
	}
    dp[0]=1;
	//rep(i,N) cout<<i<<":"<<dp[i]<<endl;
	rep(i,N){
		if(dp[i+1]==0)continue;
        if(i==0)dp[i+1]=dp[i];
        else dp[i+1]=dp[i]+dp[i-1];
        dp[i+1]%=mod;
      
	}
    //rep(i,N) cout<<i<<":"<<dp[i]<<endl;

	cout<<dp[N]<<endl;

}

Measured memory_bytes: 1792
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<pair<pair<string, int>, int>> sp(n);
		REP(i, n) cin >> sp[i].F.F >> sp[i].F.S;
		REP(i, n) {
			sp[i].F.S = -sp[i].F.S;
			sp[i].S = i;
		}
		sort(ALL(sp));
		// vector<int> ans(n);
		REP(i, n) {
			// ans[sp[i].S] = i+1;
			cout << sp[i].S+1 << endl;
		}
		// REP(i, n) {
		// 	cout << ans[i] << endl;
		// }
	}
	return 0;
}


Measured memory_bytes: 256
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu z
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N , M;
	cin >> N >> M;
	vector<ll> a(N),b(N),c(M),d(M);
	FOR(i,0,N){
		cin >> a[i] >> b[i];
	}
	FOR(j,0,M){
		cin >> c[j] >> d[j];
	}	
	FOR(i,0,N){
		ll ma=10000000000;
		ll ans=0;
		FOR(j,0,M){
			if(abs(a[i]-c[j])+abs(b[i]-d[j])<ma){
				ma = abs(a[i]-c[j])+abs(b[i]-d[j]);
				ans = j+1;
			}
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int abs(int a){
  return (a>0)?a:-1*a;
}
int main(){
  int n,usual=0,load,i;
  cin >> n;
  int a[n];
  cin >> a[0];
  usual=abs(a[0]);
  for(i=1;i<n;i++){
    cin >>a[i];
    usual+=abs(a[i]-a[i-1]);
  }
  usual+=abs(a[i-1]);
  load=usual-abs(a[0])-abs(a[1]-a[0])+abs(a[1]);
  cout << load << endl;
  for(i=1;i<n-1;i++){
    load=usual-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]);
    cout << load << endl;
  }
  load = usual -abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2]);
  cout <<load <<endl;
}


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


int main()
{
  int n;
  cin >> n;
  int c = 0;
  int da, db;
  for(int i = 0 ;i < n; ++i){
    cin >> da >> db;
    if(da != db) c = 0;
    else c++;
    if(c == 3) break;
  }
  if(c == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

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

  map<char, int> mp[n];
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;

    for(int j = 0; j < s.size(); j++){
      mp[i][s[j]]++;
    }
  }

  string ans;
  for(int i = 0; i < 26; i++){
    int cnt = 1e9;
    for(int j = 0; j < n; j++){
      cnt = min(cnt, mp[j]['a'+i]); 
    }
    for(int j = 0; j < cnt; j++){
      ans += ('a'+i);
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int p,q,a,n;

int rec(int x,int y,int now,int dep){
  
  if(x*p==q*y)return 1;
  if(dep==0)return 0;

  int sum=0;
  for(int z=now;z*x<=a;z++){
      sum+=rec(z*x,z*y+x,z,dep-1);
  }
  return sum;
}

int main(void){
  
  while(cin >> p >> q >> a >> n,p|q|a|n){
    cout << rec(1,0,1,n) << endl;
  }

  return 0;
}

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

int main() {
	// your code goes here
	char c;
	cin>>c;
	int k=c-97;
	if(k>=0){
		k=k+98;
		char j=k;
		cout<<j;
	}
	else
	{
	cout<<"a";
	}
	return 0;
}

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

int A,B,C,K;

int main(){
    cin>>A>>B>>C>>K;
    if(A>=K){cout<<K<<endl;
    }else if(A<K&&A+B>=K){cout<<A<<endl;
    }else if(A+B<K){cout<<A-(K-(A+B))<<endl;}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int a, b;

int main() {
	scanf("%d %d", &a, &b);
	if(a >= 13) cout << b << endl;
	else if(a >= 6 && a <= 12) cout << b / 2 << endl;
	else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int i;
	int count=0;
	int n;
	int k;
	scanf("%d%d",&n,&k);
	int h[n];
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
		if(h[i]>=k){
			count++;
		}
	}
	printf("%d",count);

return(0);
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
vector<ll> A,B;
ll N,K;
ll solve(int border){
  ll mask = (1LL << border);
  ll bit = K;
  if ((K & mask) != 0){
    bit |= (mask - 1);
    bit ^= mask;
  }
  ll res = 0;
  for (int i = 0; i < A.size(); i++){
    if ((A[i] | bit) == bit){
      res += B[i];
    }
  }
  return res;
}
int main() {
  cin >> N >> K;
  A.resize(N);
  B.resize(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
  }
  ll ans = 0;
  for (int i = 0; i < 32; i++){
    ans = max(ans, solve(i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1920
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
 ll n,m,k;
 cin>>n>>m>>k;
 V<ll> a(n,0),b(m,0);
 for(int i=0;i<n;i++){
   cin>>a[i];
   if(i)a[i]+=a[i-1];
 }
  int ans=0;
  for(int i=0;i<m;i++){
   cin>>b[i];
   if(i)b[i]+=b[i-1];
   if(b[i]<=k)ans=i+1;
 }
 for(int i=0;i<n;i++){
   if(k-a[i]<0)break;
   int d=upper_bound(all(b),k-a[i])-b.begin();
   chmax(ans,d+i+1);
 }
 cout<<ans<<"\n";
}



Measured memory_bytes: 6360
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int N;
	cin>>N;
	ce(N*(N+1)/2)
	
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   cin >> n;
 
  
   cout << n*n*n << endl;
   
  return 0;
}

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


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define     endl        '\n'
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	vll         vector<ll>
#define     F           first
#define     S           second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define     rep(i,n)    for(i=0;i<n;i++)
#define     repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair




int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0,a,b;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>a>>b>>c;
		// ll a[n];
		n=b+min(b+a,c);
		if(c>b+a)
			n++;
		
		cout<<n;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int x;
    cin >> x;

    int ans = 0;
    for (int i = 1; i <= 360; ++i)
    {
        if (x * i % 2 == 0 && x * i / 2 % 180 == 0)
        {
            ans = i;
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3620
l,r = map(int,input().split())

chk = 0
flg = 1
i = l
mod_min = 100000

while flg:
    for j in range(i+1,r+1):
        chk = (i*j)%2019
        if chk == 0:
            print(0)
            flg = 0
            break
        elif chk < mod_min:
            mod_min = chk
    i += 1
    if i >= r-1:
        print(mod_min)
        flg = 0

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

int main(){
    int n,m; cin>>n>>m;
    vector<P> p(m);
    //firstで一番目にアクセス
    rep(i,m) cin>>p[i].first>>p[i].second;
    //nx
    rep(x,1000){
        int keta=1;
        int nx=x/10;//(xは0-999)
        vector<int> d(1,x%10);//初期値を10で割ったあまりにしている
        //nxが0でないときに繰り返す
        while(nx){
            keta++;
            d.push_back(nx%10);
            nx/=10;
        }
        reverse(d.begin(),d.end());
        if(keta!=n) continue;//そもそも桁数があってないとここから先はスキップする
        bool ok=true;
        rep(i,m){
            if(d[p[i].first-1]!=p[i].second) ok=false;
        }
        if(ok){
            //一番小さいものを出力させて終了させる
            cout<<x<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define chmin(a,b) a=min(a,(b))

using namespace std;
int main(void)
{
  const LL INF=2012345678;
  for(;;){
    int n,m;
    cin >> n >> m;
    if(!n&&!m) return 0;
    LL wf[2][256][256];
    REP(l,2) REP(i,n+1) REP(j,n+1) wf[l][i][j]=INF;
    REP(l,2) REP(i,n+1) wf[l][i][i]=0;
    REP(i,m){
      LL x,y,t;
      string s;
      cin >> x >> y >> t >> s;
      chmin(wf[s=="L"?0:1][x][y],t);
      chmin(wf[s=="L"?0:1][y][x],t);
    }
    REP(l,2) REP(k,n+1) REP(i,n+1) REP(j,n+1) chmin(wf[l][i][j],wf[l][i][k]+wf[l][k][j]);
    int r;
    cin >> r;
    vector<int> z;
    z.resize(r);
    REP(i,r) cin >> z[i];
    LL cost[1024][256];
    // i, boat
    REP(i,r) REP(j,n+1) cost[i][j]=INF;
    cost[0][z[0]]=0;
    REP(i,r-1) REP(pre,n+1) REP(suc,n+1){
      if(pre==suc) chmin(cost[i+1][suc],cost[i][pre]+wf[0][z[i]][z[i+1]]);
      chmin(cost[i+1][suc],cost[i][pre]+wf[0][z[i]][pre]+wf[1][pre][suc]+wf[0][suc][z[i+1]]);
    }
    LL answer=INF;
    REP(i,n+1) chmin(answer,cost[r-1][i]);
    cout << answer << endl;
  }
}

Measured memory_bytes: 5940
#include <stdio.h>

int main(void) {
int N;
int n;
scanf("%d", &N);

if(N>=100000){
	printf("90909");
}
if(N>=10000 && N<100000){
	n=(N-9999)+909;
	printf("%d\n", n);
}
if(N<10000 && N>=1000){
	printf("909");
}
if(N<1000 && N>=100){
	n=(N-99)+9;
	printf("%d\n", n);
}
if(N<100 && N>=10){
	printf("9");
}
if(N<10){
	printf("%d\n",N);
}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 7368799;
bool used[MAX + 1];
void solve(int m, int n) {
    memset(used, false, sizeof(used));
    for (int i = m; i <= MAX; i++) if (!used[i]) {
        used[i] = true;
        n--;
        for (int j = i * 2; j <= MAX; j += i) {
            used[j] = true;
        }
        if (n == 0) {
            while (used[i++]);
            printf("%d\n", i - 1);
            return;
        }
    }
}

int main(void) {
	int a, b, c, x, y, z, n, m, p;
	string s;
	while (cin >> m >> n, n) {
		solve(m, n);
		//break;
	}
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    vi v;
    int s;
    float w, h;
    while(scanf("%d,%f,%f",&s,&w,&h)!=EOF) {
        if (w/(h*h)>=25) v.push_back(s);
    }
    for (int el : v) P(el);
    return 0;
}

Measured memory_bytes: 3280