akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    ll N,A,B;
    cin >> N >> A >> B;
    print(min(A * N, B));

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


using namespace std;


string i_tos( int n ){
  ostringstream stream;
  stream << n;
  string result = stream.str();
  return result;
}

int s_to_i(string str){

  int ans=0;

  for(int i=0;i<str.length();i++){
    int keisu=1,n=0;

    if(str[i]=='m') n=1000; 
    else if(str[i]=='c') n=100;
    else if(str[i]=='x') n=10;
    else if(str[i]=='i') n=1;

    if(i-1>=0&&n!=0){
      keisu=str[i-1]-'0';
      if(keisu>9){
        keisu=1;
      }
    }

  
      //cout << "係数" << keisu << ",n" << n << endl;

    if(n!=0) ans+=keisu*n;
  }

  return ans;
}


string i_to_s(int num){
  string str;

  if(num>=1000){
    if(num/1000>1){
      str.append(i_tos(num/1000));
    }

    num=num%1000;
    str.append("m");
  }
  if(num>=100){
    if(num/100>1){
      str.append(i_tos(num/100));
    }

    num=num%100;
    str.append("c");
  }
  if(num>=10){
    if(num/10>1){
      str.append(i_tos(num/10));
    }
    
      num=num%10;
    str.append("x");
  }
  if(num>=1){
    if(num/1>1){
      str.append(i_tos(num/1));
    }
    
      num=num%1;
    str.append("i");
  }
   
  return str;
}


int main()
{
  int n,ans;
  cin >> n;
  rep(i,n){

    string a,b;
    cin >> a >> b;

    ans = (s_to_i(a)+s_to_i(b));

    cout << i_to_s(ans) << endl;

  }

  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define ordered_set tree <pair <int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
#define endl '\n'
const int _n = 1e6 + 11;
const long long inf = (long long)1e18 + 1LL;
const long long mod = 1e9 + 7;
const long double eps = 1e-7;

int n, a[_n], st[_n * 4];

void build (int p, int l, int r) {
  if (l == r) st[p] = l;
  else {
    build (2 * p, l, (l + r) / 2);
    build (2 * p + 1, (l + r) / 2 + 1, r);
    st[p] = ((a[st[2 * p]] < a[st[2 * p + 1]]) ? (st[2 * p]) : (st[2 * p + 1]));
  }
}

int get (int p, int l, int r, int L, int R) {
  if (l > r || l > R || r < L) return -1;
  if (l >= L && r <= R) return st[p];
  int v1 = get (2 * p, l, (l + r) / 2, L, R);
  int v2 = get (2 * p + 1, (l + r) / 2 + 1, r, L, R);
  if (v1 == -1 || v2 == -1) return max(v1, v2);
  return ((a[v1] < a[v2]) ? (v1) : (v2));
}

int solve (int l, int r) {
  if (l > r) return 0;
  int v = get(1, 0, n - 1, l, r);
  return (v - l + 1) * (r - v + 1) * a[v] + solve (l, v - 1) + solve (v + 1, r);
}

signed main () {
  boost();
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  build (1, 0, n - 1);
  cout << solve (0, n - 1) << endl;
  return 0;
}


Measured memory_bytes: 19840
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = vector<T>;
using vvi = vector<vt<int>>;

int main(){
  ll N,K;
  cin >> N >> K;
  vt<int> A(N);
  rep(i,N)  cin >> A[i];

  vt<int> check(N+1), a;
  int tl = A[0], num, cnt1 = 0;
  rep(i,N){
    if(K == cnt1)
      break;
    if(check[tl] == 0){
      a.push_back(tl);
      num = tl-1;
      tl = A[num];
      cnt1++;
    }
    else{
      break;
    }
  }

  if(K <= cnt1)
    cout << a[K-1] << endl;
  else{
    vt<int> loop;
    int cnt2 = 0;
    bool f = false;
    rep(i,a.size()){
      if(tl == a[i])
        f = true;
      if(f){
        loop.push_back(a[i]);
      }
      else
        cnt2++;
    }
    K -= cnt2+1;
    int loop_size = loop.size();
    cout << loop[K%loop_size] << endl;
  }
  return 0;
}


Measured memory_bytes: 7188
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())

using namespace std;
int main() {

	int i, j;
	ll int n, k;
	cin >> n >> k;
	int a[100005] = {};
	int b[100005] = {};
	rep(i, 0, n)
		cin >> a[i]>> b[i];
	ll int ans = 0;
	int now = 0;
	ll int nans=0;
	rep(i, 0, 31) {
		now = k;
		if (bitget(k, i) == 1) {
			now >>= i + 1;
			now <<= i + 1;
			now = now | ((1 << i) - 1);
		}
		for (j = 0;j < n; j++) {
			if ((a[j] | now) == now) {
				nans += b[j];
			}
		}
		ans = max(ans, nans);
		nans = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  int A;
  int Asum = 0;
  for (int i=0; i<M; i++){
    scanf("%d", &A);
    Asum += A;
  }
  if (Asum>N){
    printf("-1\n");
  } else {
    printf("%d\n", N-Asum);
  }
  return 0;
}


Measured memory_bytes: 3224
from cmath import phase

N, *XY = map(int, open(0).read().split())

XY = sorted((complex(x, y) for x, y in zip(*[iter(XY)] * 2)), key=phase)
XY += XY

print(max(abs(sum(XY[i:j])) for i in range(2 * N + 1) for j in range(2 * N + 1) if j - i <= N))

Measured memory_bytes: 3188
#pragma GCC optimize ("Ofast")
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "homework"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;
	
int gcd(int a, int b) {
    while (b > 0) {
        a %= b;
        swap(a, b);
    }
    return a;
}

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 303;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int dp[2][3000][3000];

int32_t main() {
	FAST;
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int j = 0; j < n; j++) {
		for (int k = 0; k < n; k++) {
			dp[0][j][k] = -INF;
		}
	}
	for (int j = 0; j < n; j++) {
		for (int k = 0; k < n; k++) {
			dp[1][j][k] = INF;
		}
	}

	for (int i = 0; i < n; i++) {
		dp[0][i][i] = a[i];
		dp[1][i][i] = -a[i];
	}

	for (int l = 2; l <= n; l++) {
		for (int i = 0; i <= n - l; i++) {
			dp[0][i][i + l - 1] = max(dp[1][i][i + l - 2] + a[i + l - 1], dp[1][i + 1][i + l - 1] + a[i]);
			dp[1][i][i + l - 1] = min(dp[0][i][i + l - 2] - a[i + l - 1], dp[0][i + 1][i + l - 1] - a[i]);

		}
	}

	cout << dp[0][0][n - 1];
}

Measured memory_bytes: 144260
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

    ll N;
    cin >> N;
    vec p(N), order(N);
    Rep (i, N) {
        cin >> p[i];
        p[i]--;
        order[p[i]] = i;
    }

    vec a(N, 1), b(N, 1);
    ll x = 25000;
    Rep (i, N) {
        a[i] += x*i;
        b[N-1-i] += x*i;
        a[i] += order[i];
    }

    Rep (i, N) {
        cout << a[i] << " \n"[i==N-1];
    }
    Rep (i, N) {
        cout << b[i] << " \n"[i==N-1];
    }
    return 0;


}

Measured memory_bytes: 1280
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>
#include<queue>
#include<bitset>

using namespace std;

int main() {
	string S;
	cin >> S;

	int N = S.size() - 1;

	if (S.at(N) == 's') {
		cout << S << "es" << endl;
	}
	else {
		cout << S << "s" << endl;
	}


	return 0;
}

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

int main() {
    int X;
    cin >> X;
    vector<bool> vec(X+1, false);

    vec[1] = true;
    for(int i=2; i <= X; ++i) {
        int v = i*i;
        while(v <= X) {
            vec[v] = true;
            v *= i;
        }
    }
    
    for(int i = X; i > 0; --i) {
        if(vec[i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) { cout << "bust" << endl; }
	else { cout << "win" << endl; }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main(void) {
	int n, q;
	long long int k;
	cin >> n >> k >> q;
	vector<int>A(q);
	vector<long long int>ans(n);
	if (k > q) {
		for (int i = 0; i < n; i++){
			cout << "Yes"<<endl;
		}
	}
	else {
		for (int i = 0; i < q; i++) {
			cin >> A[i];
		}
		for (int i = 0; i < n; i++) {
			ans[i] = 0;
		}
		for (int i = 0; i < q; i++) {
			ans[A[i]-1] ++;
		}
		for (int i = 0; i < n; i++) {
			if (q - ans[i] >= k) {
				cout << "No"<<endl;
			}
			else {
				cout << "Yes"<<endl;
			}
		}
	}
}

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

#include <math.h>
#include <stdlib.h>


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

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

const int INF = 1001001001;
// long long max => LLONG_MAX

int table[205][205];


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M, R; cin >> N >> M >> R;

    vector<vector<int>> table(N, vector<int>(N,INF));
    for(int i = 0; i < N; i++) table[i][i] = 0;

    vector<int> v(R);
    for(int i = 0; i < R; i++) {
        cin >> v[i];
        v[i]--;
    }

    for(int i = 0; i < M; i++){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        table[a][b] = c;
        table[b][a] = c;
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                table[i][j] = min(table[i][j], table[i][k]+table[k][j]);
            }
        }
    }

    sort(v.begin(), v.end());

    int ans = INF;
    while(next_permutation(v.begin(), v.end())){
        int dist  = 0;
        for(int i = 1; i < v.size(); i++) dist += table[v[i]][v[i-1]];
        ans = min(ans, dist);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<cstdio>
using namespace std;
#define N 100005
#define LL long long
#define rep(i,j,k) for(i=j;i<=k;++i)
#define down(i,j,k) for(i=j;i>=k;--i)
int n,m,i,j,k,top;
LL cnt[N],xs[N],q[N];
LL len,t;
void read(int &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0';	x=getchar();}
}
void read(LL &p){
	p=0; char x=getchar();
	while(x<'0' || x>'9') x=getchar();
	while(x>='0'&&x<='9'){p=p*10+x-'0';	x=getchar();}
}
int find(int l,int r,LL x){
	int mid;
	while(l<r){
		if(r-l>1) mid=(l+r)>>1;
		else mid=r;
		if(q[mid]<x) l=mid;
		else r=mid-1;
	}
	return l;
}
int main(){
	
	read(n); read(m);
	top=1; q[1]=n;
	rep(i,1,m){
		read(len);
		while((top)&&(q[top]>=len)) top--;
		top++; q[top]=len;
	}
	m=top;
	xs[m]=1;
	while(top>1){
		len=q[top]; k=top-1;
		while(len>=q[1]){
			t=len/q[k];
			xs[k]+=xs[top]*t;
			len=len%q[k];
			if(len>=q[1]) k=find(1,k,len);
		}
		cnt[len]+=xs[top];
		top--;
	}
	len=xs[1];
	down(i,n-1,1) cnt[i]+=cnt[i+1];
	rep(i,1,n)  
		if(i<=q[1]) printf("%lld\n",len+cnt[i]);
		else printf("0\n");
	return 0;
}

Measured memory_bytes: 3968
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);

        int p = 0;
        int x = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (p == a[i]) {
                if (x == 0) {
                    x = p;
                    p = 0;
                } else {
                    out.println((long)x * p);
                    return;
                }
            } else {
                p = a[i];
            }
        }
        out.println(0);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 36296
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

const int H = 1e5+5, W = 1e5+5, N = 3005, MOD = 1e9 + 7;
vector<pii> bad;
ll dp[N];
int h, w, n;
ll fac[2*H];

ll inv(ll b, int e){
  ll ans = 1;
  while(e){
    if(e&1)ans = (ans*b)%MOD;
    b = (b*b)%MOD;
    e /= 2;
  }
  return ans;
}

ll pascal(int c, int r){
  ll den = (fac[r]*fac[c-r])%MOD;
  den = inv(den, MOD-2);
  ll ans = (fac[c]*den)%MOD;
  return ans;
}

ll f(int i){
  ll &ans  = dp[i];
  if(ans != -1)return ans;
  ans = 0;
  ans = pascal(bad[i].F+bad[i].S, bad[i].S);
  forn(j, 0, n+1){
    if(j == i)continue;
    if(bad[i].F < bad[j].F || bad[i].S < bad[j].S)continue;
    int dx = bad[i].F-bad[j].F;
    int dy = bad[i].S-bad[j].S;
    ll out = pascal(dx+dy, dy);
    ans = (ans - (f(j) * out) % MOD + MOD) % MOD;
  }
  return ans;
}


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

  cin >> h >> w >> n;
  int r, c;
  bad.pb({h-1, w-1});
  forn(i, 0, n){
    cin >> r >> c;
    r--, c--;
    bad.pb({r, c});
  }
  fac[0] = 1;
  forn(i, 1, 2*H){
    fac[i] = (fac[i-1]*i)%MOD;
  }
  memset(dp, -1, sizeof dp);

  cout << f(0) << endl;





}





Measured memory_bytes: 5184
import java.util.*;


import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		double a = nd();
		double b = ni();
		double x = ni();
		double target = 0D;
		double result = 0D;
		if(x > a *a*b/2) {
			target = 2*b/a - 2*x/Math.pow(a, 3);
			result = Math.toDegrees(Math.atan(target));
		} else {
			target = 2*x/a/Math.pow(b, 2);
			result = (Math.toDegrees(Math.atan(target)) - 90) * - 1;
		}
		System.out.println(result);
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21076
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut x: usize = read();
    let mut minv = std::usize::MAX;

    for _ in 0..n {
        let mi = read();
        x -= mi;
        if mi < minv {
            minv = mi;
        }
    }
    println!("{}", n + (x / minv));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>

using namespace std;

int main() {
    int N, sx = 0, sy = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        int dist = abs(sx - x) + abs(sy - y);
        if (dist > t ||
            (dist % 2 == 0 && t % 2 != 0) ||
            (dist % 2 != 0 && t % 2 == 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

h = [int(x) for x in input().split()]

befor = 0

f = True

for i in range(num):
  if h[i] > befor:
    befor = h[i] - 1
  elif h[i] <  befor:
    f = False
    break
    
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const solve = memoization(function(i, m) {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  });

  arr2.map(m => solve(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();

function memoization(f) {
  let cache = {};
  function innerFunc(...param) {
    const c = cache[param];
    if (typeof c !== 'undefined') {return c;}
    return cache[param] = f(...param);
  }
  return innerFunc;
}



Measured memory_bytes: 24396
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
ll fact[MAX],inverse[MAX];
ll Bigmod(ll a,ll b)
{
    if(b==0)
        return 1%MOD;
    ll x=Bigmod(a,b/2);
    x=(x*x)%MOD;
    if(b%2==1)
        x=(x*a)%MOD;
    return x;
}
ll nCr(ll x, ll y)
{
    if(x<0 || y<0 || x<y)
        return 0;
    return fact[x] * (inverse[y] * inverse[x - y] % MOD) % MOD;
}
void pre_cal()
{

    fact[0]=1;
    for(int i=1; i<=3000; i++)
        fact[i]=(fact[i-1]*1LL*i)%MOD;
    inverse[3000]=Bigmod(fact[3000],MOD-2ll);
    for(ll i=3000; i>0; i--)
    {
        inverse[i-1ll]=(i* 1LL*inverse[i] )% MOD;
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k;
    cin>>n>>k;
    int r=n-k;
    pre_cal();
    for(int i=1; i<=k; i++)
    {

        ll a=nCr(k-1,i-1);
        ll b=nCr(r+1,i);
        ll ans=(a*b)%MOD;

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


Measured memory_bytes: 3648
#include <stdio.h>

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n-- > 0){
        int k, p;

        scanf("%d %d", &k, &p);
        printf("%d\n", (k % p + p - 1) % p + 1);
    }

    return 0;
}

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

int main() {
  std::string s, t;
  std::cin >> s >> t;
  int c_count = 0;
  for (int i = 0; i < s.size(); ++i) {
    c_count += (s[i] == t[i]);
  }
  int ans = s.size() - c_count;
  std::cout << ans << std::endl;
  
  return 0;
}

Measured memory_bytes: 3924
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dfs(int k, int n, int pn, int d, vi a){
  if (d == 0) {
    // if(k == 0) {
    //   for(auto aa:a) LOG("%2d ", aa);
    //   LOG("\n");
    // }
    return (k == 0) & 1;
  }
  int res = 0;
  FOR(i, pn + 1, n + 1){
    int nk = k - i;
    if(nk < 0) continue;
    vi aa = a;
    aa.push_back(i);
    res += dfs(nk, n, i, d - 1, aa);
  }
  return res;
}

int main() {
  int n, s, k;
  while(cin >> n >> s >> k, n | s | k) {

    vi a;
    cout << dfs(k, n, 0, s, a) << endl;
  }
}

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

int main() {
    int x, n;
    cin >> x >> n;
    set<int> st;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        st.insert(a);
    }
    for (int i = 0; ; ++i) {
        if (!st.count(x - i)) {
            cout << x - i << endl;
            return 0;
        }
        if (!st.count(x + i)) {
            cout << x + i << endl;
            return 0;
        }
    }
}


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

int main(){
    ll n; cin >> n;
    ll ans = 0;
    rep(i,n){
        if((i+1) %3 != 0 && (i+1) %5 != 0){
            ans += i+1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
template<class Key, class Compare = less<Key>>
using Tree = tree<Key, null_type, Compare, rb_tree_tag, tree_order_statistics_node_update>;






void Main() {

  int n;
  cin >> n;
  vector<int> h(n), c(n, 0);
  vector<pi> hs;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    hs.emplace_back(h[i], i);
  }
  sort(hs.begin(), hs.end());
  int ans = 0;
  for (int t = 0; t < n; ++t) {
    int tidx = hs[t].second;
    if (c[tidx] < h[tidx]) {
      int incr = h[tidx] - c[tidx];
      ans += incr;
      for (int i = tidx, j = tidx+1; ;) {
        bool did = 0;
        if (i >= 0 && c[i] < h[i]) {
          c[i] += incr;
          --i;
          did = 1;
        }
        if (j < n && c[j] < h[j]) {
          c[j] += incr;
          ++j;
          did = 1;
        }
        if (!did) break;
      }
    }
//    cout << "tidx=" << tidx << "; c: ";
//    for (int z : c) cout << z << ' ';
//    cout << "\n";
  }
  cout << ans << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  #ifdef _DEBUG
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  #endif
  Main();
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 0, k = 0 ,i = 0, ans = 0;
		k = sc.nextInt();n = sc.nextInt();
      	int[] e = new int[n];
		while(i < n) {
          e[i] = sc.nextInt();
          i++;
        }
		ans = e[n - 1] - e[0];
		for (int idx = 0; idx < n -1; idx++) {
			ans = Math.min(ans, k - (e[ idx + 1] - e[idx]));
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 66088
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc  = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();

		if(a >= 3200){
			System.out.println(s);
		}else{
			System.out.println("red");
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
int main(void)
{
	int i,j,k,c;
	char a[100000];
	scanf("%s",a);
	k=strlen(a);
	for(i=0;i<k;i++){
		c=i+1;
		if(c%2!=0) printf("%c",a[i]);
	}
	printf("\n");
	return 0;
}	

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if x >= 0:
   y = x - (d * k)
   if y >= 0:
      print(y)
   else:
      a = x // d
      x -= a * d
      k -= a
      if k % 2 == 0:
         y = min(x, abs(x-2*d))
      else:
         y = min(abs(x+d), abs(x-d))
      print(y)

if x < 0:
   y = x + (d * k)
   if y <= 0:
      print(abs(y))
   else:
      a = abs(x) // d
      x += a * d
      k -= a
      if k % 2 == 0:
         y = min(abs(x), abs(x+2*d))
      else:
         y = min(abs(x-d), abs(x+d))
      print(y)


Measured memory_bytes: 9224
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll llinf=(ll)1e18+7;
const ld eps=1e-7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	int n,k;
	cin>>n>>k;
	vi arr(n);
	trav(i,arr) cin>>i;
	auto isValid=[&](int sz){
		ll cnt=0;
		trav(i,arr){
			cnt+=(((i+sz-1)/sz)-1);
			if(cnt>(ll)k) return false;
		}
		return true;
	};
	int l=1,r=*max_element(all(arr));
	int ans=r;
	while(l<=r){
		int mid=(l+r)/2;
		if(isValid(mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<newl;
}

int main(){
	FAST_IO
	cout<<fixed<<setprecision(15);
	cerr<<fixed<<setprecision(10);
	//init_fact();
	//TEST_CASE(solve)
	//TEST_CASE_2{}
	//TEST_CASE_3(solve)
	solve();
	return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 5e3 + 5, M = 5e4 + 9, INF = 1e9, MOD = 1e9 + 7;

vector<pair<ll, ll>> vec[N];
ll n, m, p;
int u[M], v[M], c[M];
bool vis[N];

bool dfs(int node, int req) {
	if(node == req)
		return 1;
	vis[node] = 1;
	int ret = 0;
	for(auto it: vec[node]) {
		if(vis[it.first]) continue;
		ret |= dfs(it.first, req);
		if(ret) return ret;
	}
	return ret;
}

ll dist[N];
void runtestcase() {
	cin >> n >> m >> p;
	for (int i = 0; i < m; ++i) {
		cin >> u[i] >> v[i] >> c[i];
		c[i] -= p;
		vec[u[i]].push_back({v[i], c[i]});
	}
  for (int i = 0; i <= n; i++)
      dist[i] = -1e18;
  dist[1] = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			int x = u[j], y = v[j], cost = c[j];
			if(dist[x] != -1e18 && dist[x] + cost > dist[y])
				dist[y] = dist[x] + cost;
		}
	}
	for (int j = 0; j < m; ++j) {
		int x = u[j], y = v[j], cost = c[j];
		if(dist[x] != 1e18 && dist[x] + cost > dist[y]) {
			memset(vis, 0, sizeof vis);
			bool ret = dfs(x, n);
			if(!ret)
				continue;
			memset(vis, 0, sizeof vis);
			ret = dfs(1, x);
			if(!ret) continue;
			cout << -1;
			return;
		}
	}
	cout << max(0ll, dist[n]);
}


int main() {
    fastIO;
#ifdef LOCAL
    freopen("input.in", "rt", stdin);
//    freopen("cache.out", "wt", stdout);
#endif
  int t = 1, tt = 1;
//	cin >> t;
  while(t) {
//		cout << "Case #" << tt << ':' << ' ';
    runtestcase();
		cout << '\n';
    --t, ++tt;
  }
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == 'o') ++counter;
  if (s[1] == 'o') ++counter;
  if (s[2] == 'o') ++counter;
  int answer = 700 + (100 * counter);
  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	int n, a;

	cin >> n;
	cin >> a;

	int s;

	s = n * n;

	s -= a;

	cout << s;

	return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 211111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

vector<int>graph[N] ;
int dist[N] ;

int main() {
  int n, m ,a, b ;

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

  for(int i = 0 ;i<m ;i++){
    scanf("%d %d", &a, &b) ;
    graph[a].pb(b) ;
    graph[b].pb(a) ;
  }

  queue<int>q ;
  q.push(1) ;
  dist[1] = 1 ;

  while(!q.empty()){
    int u = q.front() ;
    q.pop() ;
    if(u == n){
      break ;
    }

    for(auto v: graph[u]){
      if(!dist[v]){
        dist[v] = dist[u] + 1 ;
        q.push(v) ;
      }
    }
  }
  if((dist[n]-1) == 2)
    printf("POSSIBLE") ;
  else printf("IMPOSSIBLE") ;
	
  return 0 ;
}

Measured memory_bytes: 13424
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        int health1 = nextInt();
        int attack1 = nextInt();
        int health2 = nextInt();
        int attack2 = nextInt();
        while (health1>0 && health2>0) {
            health2-=attack1;
            if (health2<=0) {
                System.out.println("Yes");
                return;
            }
            health1-=attack2;
            if (health1<=0) {
                System.out.println("No");
                return;
            }
        }
        if (health1<=0) { //reee captialization
            System.out.println("No");
        }
        else if (health2<=0) {
            System.out.println("Yes");
        }
    }
    
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

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

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}




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

vector<int> vr,vg,vb;

int main(){
	string s;
	int n;
	long long ans=0;
	cin>>n>>s;
	
	for(int i=0;i<n;i++){
		if(s[i]=='R') vr.push_back(i);
		else if(s[i]=='G') vg.push_back(i);
		else vb.push_back(i);
	}
	
	int a=vr.size(),b=vg.size(),c=vb.size();
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			ans+=c;
			
			int d=abs(vr[i]-vg[j]);
			int mi=min(vr[i],vg[j]),ma=max(vr[i],vg[j]);
			
			if(mi-d>=0&&s[mi-d]=='B') ans--;
			if(ma+d<n&&s[ma+d]=='B') ans--;
			if((vr[i]+vg[j])%2==0&&s[mi+d/2]=='B') ans--;
		}
	}
	
	cout<<ans;
	return 0;
}

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

public class Program
{

	static void Main(string[] args)
	{
		var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		if(array[0] >= array[1])
		{
			Console.WriteLine(10);
		}
		else
		{
			Console.WriteLine(0);
		}
	}
}


Measured memory_bytes: 13268
N, M = map(int, input().split())  # N個のスイッチ, M個の電球

# M個の電球がそれぞれどこのスイッチと繋がっているかを格納
SSS = [list(map(int, input().split()))[1:] for i in range(M)]
P = list(map(int, input().split()))

ans = 0

for i in range(1 << N):  # 2のN乗の値になる, bit全探索
    for mask in range(M):
        ans_2 = 0
        for s in SSS[mask]:
            if (1 << s-1) & i != 0:
                ans_2 += 1

        if ans_2 % 2 != P[mask]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    string s;cin>>s;
    ll m=s.size();
    ll dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    rep(i,0,n){
        rep(j,0,n+1){
            if(dp[i][j]==0)continue;
            ll y=j-1;
            if(y<0)y=0;
            (dp[i+1][y]+=dp[i][j])%=mod;
            (dp[i+1][j+1]+=dp[i][j]*2)%=mod;
            
        }
    }
    ll t=beki(2,m,mod);
    ll ans=dp[n][m];
    ans*=gyaku(t,mod);
    cout<<ans%mod<<endl;
}


Measured memory_bytes: 195712
n=gets.to_i
x=gets.chomp.chars.map &:to_i
b=x.count(1)
if b==0
  n.times{ puts 1 }
  exit
end
h=[0]
f=->x{
  t=h[x] and return t
  pc=x.to_s(2).chars.count(?1)
  h[x]=f[x%pc]+1
}
#p [n,x,b]
rp=rm=0
rps,rms=[0]*n,[0]*n
tm=tp=1
if b>2
  (n-1).downto(0){|i|
    rps[i]=tp
    rms[i]=tm
    if x[i]==1
      rp=(rp+tp)%(b+1)
      rm=(rm+tm)%(b-1)
    end
    tp=tp*2%(b+1)
    tm=tm*2%(b-1)
  }
else
  (n-1).downto(0){|i|
    rps[i]=tp
    if x[i]==1
      rp=(rp+tp)%(b+1)
    end
    tp=tp*2%(b+1)
  }
end
#p [rp,rm,rps,rms]
n.times{|i|
  if x[i]==0
    puts 1+f[(rp+rps[i])%(b+1)]
  elsif b==1
    puts 0
  else
    puts 1+f[(rm-rms[i])%(b-1)]
  end
}

Measured memory_bytes: 36408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n)           for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b)        for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a)           for (auto &i : a)
#define ALL(obj)            begin(obj), end(obj)
#define MAX(x)              *max_element(ALL(x))
#define MIN(x)              *min_element(ALL(x))
#define sum(x)              accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD    = (int)(1e9 + 7);
const int INF    = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI  = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class AAtCoderContest {
public:
  static void solve(istream &cin, ostream &cout) {
    string temp, temp2;
    cin >> temp >> temp2 >> temp;
    cout << 'A' << temp2[0] << 'C' << endl;
  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  AAtCoderContest solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	pp = [1]*(10**5 + 1)
	pp[0]=0
	pp[1]=0
	for i, _ in enumerate(pp):
		if pp[i]==0:
			continue
		st = i
		while st * i < len(pp):
			pp[st*i]=0
			st+=1
	like = pp[:]
	like[2]=0
	for i, v in enumerate(pp):
		
		if v == 1 and i != 2 and pp[(i+1)//2 ] == 0:
			like[i] = 0
	ss = [0] * len(pp)
	for i, v in enumerate(ss[:-1]):
		ss[i+1] = like[i+1]+ss[i]
	#pa(like[:10])
	q = int(input())
	#b , c = tin()
	#s = input()
	for _ in range(q):
		l, r = tin()
		print(ss[r] - ss[l-1])
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 78300
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s  = S()
if s[1] == 'B':
    print('ARC')
else:
    print('ABC')



Measured memory_bytes: 76644
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int main(){
    int n,p;
    cin >> n >> p;
    long long y=gcd(n,p);
    long long z=n/y*p;
    string s,t;
    cin >> s >> t;
    bool h=true;
    int a=n/y;
    int b=p/y;
    int c=0;
    int d=0;
    if(s[0]!=t[0]){
        cout<<-1<<endl;
        return 0;
    }
    while(c<n&&d<p){
        c += a;
        d += b;
        if(c>=n||d>=p){
            break;
        }
      //  cout<<c<<" "<<d<<endl;
        if(s[c]!=t[d]){
            h=false;
            break;
        }
    }
    if(h){
        cout<<z<<endl;
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 512
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N, M;
	cin >> N >> M;
	vector<int> a(N), b(N), c(M), d(M);
	REP(i, N) {
		cin >> a[i] >> b[i];
	}
	REP(i, M) {
		cin >> c[i] >> d[i];
	}
	
	REP(i, N) {
		pair<int, int> p(1, abs(a[i] - c[0]) + abs(b[i] - d[0]));
		FOR(j, 1, M) {
			int dest = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (p.second > dest) {
				p.first = j + 1;
				p.second = dest;
			}
		}
		cout << p.first << endl;
	}

	return 0;
}



Measured memory_bytes: 256