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

ll power(ll x,ll y)
{
    ll res = 1;
    while(y>0){
        if(y&1)
            res *= x;
        y>>=1;
        x*=x;
    }
    return res;
}

int main()
{
    int n;
    cin>>n;
    vector<int> a,b,c;
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        a.push_back(val);
    }
    for(int i=0;i<n;i++){
        int val;
        cin>>val;
        b.push_back(val);
    }
    for(int i=0;i<n-1;i++){
        int val;
        cin>>val;
        c.push_back(val);
    }
    ll ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1]+1==a[i]){
            ans+=(b[a[i]-1]+c[a[i-1]-1]);
        }
        else
            ans+=b[a[i]-1];
    }
    ans+=b[a[0]-1];
    cout<<ans<<'\n';
    return 0;
}


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

int n;
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=n; ++i){
		if(i % 2 == 0) continue;
		int cnt = 0;
		for(int j=1; j<=i; ++j)
			if(i % j == 0)
				++cnt;
		if(cnt == 8)
			++ans;
	}
	cout << ans << "\n";
}

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

using namespace std;

int ans = 1<<29;
int n, k;

void operate(int x, int m) {
  if (m == n) {
    ans = min(x, ans);
  } else {
    int y;
    y = 2 * x;
    operate(y, m + 1);
    y = x + k;
    operate(y, m + 1);
  }
}

int main() {
  cin >> n; cin >> k;
  operate(1, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<cctype>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (2 * b == a + c)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;

struct edge {
    ll from,to;
    ll cost;
};
vector<edge> ess;

vll d(2600,MOD);
ll n,m,p;

/*void spath(int s){
    for (int i=0;i<n;i++) d[i]=MOD;
    int b=1;
    d[s]=0;
    while (b){
        b=0;
        for (int i=0;i<m;i++){
            edge e=ess[i];
            if (d[e.from]!=MOD && d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                b=1;
            }
        }
    }
}*/

/*bool nloop(){
    memset(d,0,sizeof(d));
    for (int i=1;i<n+1;i++){
        for (int j=0;j<m;j++){
            edge e=es[j];
            if (d[e.to]>d[e.frm]+e.cost){
                d[e.to]=d[e.frm]+e.cost;
                if (i==n-1) return true;
            }
        }
    }
    return false;
}*/

bool bellman_ford(int v, const vector<edge>& es, vector<long long>& cost, int s = 0, int g = -1){
    if(g == -1){
        g = v - 1;
    }

    constexpr long long INF = 1LL << 61;

    cost.assign(v, INF);
    cost[s] = 0;

    for(int i = 0 ; i < v * 2 ; ++i){
        for(auto& e : es){
            if(cost[e.from] < INF && cost[e.from] + e.cost < cost[e.to]){
                if(i >= v - 1 && e.to == g){
                    return false;
                }else if(i >= v - 1){
                    cost[e.to] = -INF;
                }else{
                    cost[e.to] = cost[e.from] + e.cost;
                }
            }
        }
    }

    return true;
}


int main() {
    cin>>n>>m>>p;
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        edge e1={a-1,b-1,p-c};
        ess.push_back(e1);
    }
    if (!bellman_ford(n,ess,d,0,n-1)){
        cout<<-1<<endl;
    }
    else{
        cout<<max(0,-int(d[n-1]))<<endl;
    }


    

    return 0;
}

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

int n, qnt[100];
char s[100][100];

int main(){
	while(scanf("%d\n", &n)!=EOF){
		int min_[100];
		for(int i=0; i<26; i++) min_[i]=INF;
		for(int i=0; i<n; i++){
			scanf("%s", &s[i]);
			int tam = strlen(s[i]);
			memset(qnt, 0, sizeof(qnt));
			for(int j=0; j<tam; j++){
				qnt[s[i][j]-'a']++;
			}
			for(int j=0; j<26; j++){
				min_[j] = min(min_[j], qnt[j]);
			}	
		}
		for(int i=0; i<26; i++){
			for(int j=0; j<min_[i]; j++) printf("%c", 'a'+i);
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int n,p[200100];

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

  for (int i = 0;i < n; i++) {
    scanf("%d", &p[i]);
  }
  int mi = n + 2;
  int sol = 0;
  for (int i = 0; i < n; i++) {
    if (mi >= p[i]) {
      sol++;
      mi = p[i];
    }
  }

  printf("%d", sol);

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX 100002
#define inf 1<<29
#define linf (1e14)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

ll s,t,d,w[MAX];

ll solve(){
  ll sum = 0, ans = linf,sub = 0;
  FOR(i,0,d)sum+=w[i];
  FOR(i,0,d){
    sub+=w[i];
    if(sub+s<=t){
      ans = i+1;
      break;
    }
    if(sum<0){
      ll c = s-t+sub;
      if((c%abs(sum))==0)ans = min(ans,i+1+d*(c/abs(sum)));
      else ans = min(ans,i+1+d*(c/abs(sum)+1));
    }
  }
  if(ans==linf)return -1;
  return ans;
}

int main()
{
  cin>>s>>t>>d;
  FOR(i,0,d)cin>>w[i];
  cout<<solve()<<endl;
  return 0;
}



Measured memory_bytes: 3904
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h)rep(j, w) cin >> s[i][j];

    char ans[h][w];
    rep(i, h)
        rep(j, w) {
            if (s[i][j] == '#') {
                ans[i][j] = '#';
                continue;
            }
            int c = 0;
            for (int k = -1; k <= 1; ++k) {
                for (int l = -1; l <= 1; ++l) {
                    int nx = i + k, ny = j + l;
                    if (nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1) {
                        if (s[nx][ny] == '#') c++;
                    }
                }
            }
            ans[i][j] = static_cast<char>(c + '0');
        }
    rep(i, h) {
        rep(j, w) cout << ans[i][j];
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n, a, b; cin >> n >> a >> b;

    if (a > b) swap(a, b);

    ll a2 = n - a + 1;
    ll b2 = n - b + 1;
    if (a2 > b2) swap(a2, b2);

    if (abs(a - b) % 2 == 0) {
        cout << abs(a - b) / 2 << endl;
    } else {
        ll x1 = (b - a + 1) / 2;
        ll x2 = (b2 - a2 + 1) / 2;
        cout << min(b2 - x2, b - x1) << endl;
    }
    
}

Measured memory_bytes: 384
from itertools import permutations, product
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

MX = 2005
d = [[[0]*MX for _ in range(3)] for _ in range(3)]
# print(d)

s = [input() for _ in range(3)]
s.sort()
# print(s)

ans = MX*3
for sss in permutations(s):
    # print(sss)
    for i, j in product(range(3), repeat=2):
        for k in range(len(sss[i])):
            if i >= j: continue
            # print(i,j,k)
            ok = True
            for ni in range(k, len(sss[i])):
                nj = ni - k
                if nj >= len(sss[j]): break
                if sss[i][ni] == '?' or sss[j][nj] == '?': continue
                if sss[i][ni] != sss[j][nj]: ok = False
            d[i][j][k] = ok
    def f(i, j, k):
        if k >= len(sss[i]):
            return True
        return d[i][j][k]
    # print(sss)
    for x, y in product(range(MX), repeat=2):
        if f(0,1,x) == False: continue
        if f(1,2,y) == False: continue
        if f(0,2,x+y) == False: continue
        now = 0
        now = max(now, len(sss[0]))
        now = max(now, x+len(sss[1]))
        now = max(now, x+y+len(sss[2]))
        ans = min(ans, now)
print(ans)


Measured memory_bytes: 69852
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
ll A[100000];
ll allXOR = 0;
ll ans = 0;
bool selected[100000] ={};

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];

    rep(i, N) allXOR ^= A[i];

    int k = 0;
    rep(i, 60){
        /*for(int b=57; b<60; b++){
            rep(j, N){
                cout << ((A[j]>>59-b)&1) << " ";
            }
            cout << endl;
        }
        cout << endl;*/

        if((allXOR>>59-i)&1) ans += 1LL<<59-i;
        else{
            for(int j=k; j<N; j++){
                if((A[j]>>59-i)&1){
                    swap(A[k], A[j]);
                    break;
                }
            }
            if((A[k]>>59-i)&1){
                ans += 1LL<<60-i;
                for(int j=0; j<N; j++){
                    if(j == k) continue;
                    if((A[j]>>59-i)&1) A[j] ^= A[k];
                }
                k++;

                int cnt = 0;
                rep(j, N){
                    cnt += (A[j]>>59-i)&1;
                }
                if(cnt%2) selected[k-1] = true;
            }
            else{
                int cnt = 0;
                rep(j, N){
                    cnt += (A[j]>>59-i)&1&selected[j];
                }
                if(cnt%2) ans += 1LL<<60-i;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1152
l = input().split()
n = int(l[0])
x = int(l[1])
l = input().split()
cnt = 1
d = 0

while(cnt -1 < len(l)):
    d = d + int(l[cnt-1])
    if(d<=x):
        cnt = cnt + 1
    else:
        break

if(cnt > n+1):
    cnt = n+1
print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	string s;
/* BIEN CUC BO END*/

void solve(){	
	cin >> s;
	if ((s[5]-'0')*10 + (s[6]-'0') > 4){
		cout << "TBD";
	}
	else {
		cout << "Heisei";
	}
}	

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


Measured memory_bytes: 256
n = list(map(int,input().split()))

s = sum([i%2 for i in n])

if s == 0 or s == 3:
    m = max(n)
    res = 0
    for i in n:
        res += (m-i)//2
    print(res)
elif s == 1:
    for i in range(3):
        if n[i]%2 == 0:
            n[i] += 1
    res = 1
    m = max(n)
    for i in n:
        res += (m-i)//2
    print(res)
else:##s == 2
    for i in range(3):
        if n[i]%2:
            n[i] += 1
    res = 1
    m = max(n)
    for i in n:
        res += (m-i)//2
    print(res)

Measured memory_bytes: 9236
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

int main() {

	string S;

	cin >> S;

	S[3] = '8';

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
import heapq
X,Y,Z,K = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=1)
B = sorted(list(map(int,input().split())),reverse=1)
C = sorted(list(map(int,input().split())),reverse=1)
Q = [(-A[0]-B[0]-C[0],0,0,0)]
heapq.heapify(Q)
for i in range(K):
    n,a,b,c = heapq.heappop(Q)
    if a < X-1 and (n+A[a]-A[a+1],a+1,b,c) not in Q:
        heapq.heappush(Q,(n+A[a]-A[a+1],a+1,b,c))
    if b < Y-1 and (n+B[b]-B[b+1],a,b+1,c) not in Q:
        heapq.heappush(Q,(n+B[b]-B[b+1],a,b+1,c))
    if c < Z-1 and (n+C[c]-C[c+1],a,b,c+1) not in Q:
        heapq.heappush(Q,(n+C[c]-C[c+1],a,b,c+1))
    print(-n)

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

int main() {
	int N = 0, lunch = 800, paybuck = 200, x = 0, y = 0;

	cin >> N;

	x = N * lunch;
	y = N / 15;
	cout << x - y * paybuck << endl;
	
	return 0;
}

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

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

	int sum = 0, tmp = n;
	while(n) {
		sum += n % 10;
		n /= 10;
	}
	n = tmp;

	printf("%s\n", n % sum == 0 ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String s = sc.next();

        String s1 = s.substring(a-1, c);
        String s2 = s.substring(b-1, d);
        if (s1.contains("##") || s2.contains("##")) {
            System.out.println("No");
        } else {
            if (d < n) {
                s2 = s.substring(b-2, d+1);
            } else {
                s2 = s.substring(b-2, d);
            }
            if (d < c && !s2.contains("...")) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }

    }
}

Measured memory_bytes: 40548
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
         Scanner sc=new Scanner(System.in);
         int r=sc.nextInt();
         int D=sc.nextInt();
         int x=sc.nextInt();
         for(int i =1; i<=10; i++)
         {
             System.out.println(recur(i, r, D, x));
         }

    }
    static int recur(int index, int r, int D, int x)
    {
        if(index==0)
        {
            return x;
        }
        return r*recur(index-1, r, D, x)-D;
    }


}


Measured memory_bytes: 21588
///
// File:  alds1_1_b.cpp
// Author: ymiyamoto
//
// Created on Mon Nov 13 03:00:08 2017
//

#include <cstdint>
#include <iostream>

using namespace std;

uint64_t gcd(uint64_t a, uint64_t b)
{
  if (b > a) gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int32_t main()
{
  uint64_t a, b;
  cin >> a >> b;

  cout << gcd(a, b) << endl;

  return 0;
}

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

#define STRMAXT 1000000
#define STRMAXP 10000

void KMP(const string T, const string P){
	int tcur = 0;
	int pcur = 2;
	int tablecur = 0;
	int plen = P.length();
	int tlen = T.length();
	int* Table = new int[plen + 1];
	Table[0] = -1;
	if (plen >= 2){
		Table[1] = 0;
		while (pcur <= plen){
			if (P[pcur - 1] == P[tablecur]){
				Table[pcur] = tablecur + 1;
				pcur = pcur + 1;
				tablecur = tablecur + 1;
			}
			else if (tablecur > 0){
				tablecur = Table[tablecur];
			}
			else{
				Table[pcur] = 0;
				pcur = pcur + 1;
			}
		}
	}
	pcur = 0;
	while (tcur + pcur < tlen){
		if (P[pcur] == T[tcur + pcur]){
			pcur++;
			if (pcur == plen){
				cout << tcur << endl;
				tcur = tcur + pcur - Table[pcur];
				if (pcur > 0){
					pcur = Table[pcur];
				}
			}
		}
		else{
			tcur = tcur + pcur - Table[pcur];
			if (pcur > 0){
				pcur = Table[pcur];
			}
		}
	}
	delete[] Table;
}

int main(){
	string T;
	string P;
	std::cin >> T >> P;
	KMP(T, P);

	return 0;
}


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

int main() {
    ll n;
    cin>>n;
    vector<int> ans;
    while(n>0){
        ll a = n%26;
        if(a==0) a=26;
        ans.push_back(a);
        n=(n-a)/26;
    }

    string alp = "0abcdefghijklmnopqrstuvwxyz";

    reverse(ans.begin(),ans.end());
    rep(i,ans.size()){
        cout << alp[ans[i]];
    }
    cout << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int x[10][10];
int f(int a,int b,int c,int d,int e)
{
	return x[x[x[x[x[0][a]][b]][c]][d]][e];
}
int check(int a,int b,int c,int d,int e)
{
	for(int i=0;i<10;i++)
	{
		if(a!=i&&f(i,b,c,d,e)==0)return 1;
		if(b!=i&&f(a,i,c,d,e)==0)return 1;
		if(c!=i&&f(a,b,i,d,e)==0)return 1;
		if(d!=i&&f(a,b,c,i,e)==0)return 1;
		if(e!=i&&f(a,b,c,d,i)==0)return 1;
	}
	if(a!=b&&f(b,a,c,d,e)==0)return 1;
	if(b!=c&&f(a,c,b,d,e)==0)return 1;
	if(c!=d&&f(a,b,d,c,e)==0)return 1;
	if(d!=e&&f(a,b,c,e,d)==0)return 1;
	return 0;
}
main()
{
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>x[i][j];
	int cnt=0;
	for(int a=0;a<10;a++)for(int b=0;b<10;b++)
		for(int c=0;c<10;c++)for(int d=0;d<10;d++)
			cnt+=check(a,b,c,d,x[x[x[x[0][a]][b]][c]][d]);
	cout<<cnt<<endl;
}



Measured memory_bytes: 3108
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<cstring>
#include<string>
#include<ctime>


using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const double PI = acos(-1.0);
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define all(v) v.begin(), v.end()
const long MOD = pow(10, 9) + 7;

char alfa[] = { 'A','B' ,'C','D' ,'E' ,'F' ,'G' ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' ,'X' ,'Y','Z' };

inline void finish() {
	cout << -1 << endl;
	exit(0);
}

unsigned GetDigit(unsigned num) {
	return log10(num) + 1;
}

ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

class Mod {
public:
	static inline ll Add(ll a, ll b) {
		return (a + b) % MOD;
	}

	static inline ll Sub(ll a, ll b) {
		ll ans = (a - b) % MOD;
		return (ans < 0) ? (ans + MOD) : ans;
	}

	static inline ll Mul(ll a, ll b) {
		return (a * b) % MOD;
	}

	static inline ll Div(ll a, ll b) {
		return (a % MOD) * modinv(b, MOD) % MOD;
	}
};



template <typename T>
inline void debug(vector<T> v) {
	cout << "[";
	for (ll i = 0; i < v.size() - 1; ++i) {
		cout << v[i] << ", ";
	}
	cout << v[v.size() - 1] << "]" << endl;
}

void Main();
inline void DebugMain() {
	while (true) {
		Main();
	}
}

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

	bool debug = false;
	if (debug) {
		cout << "\x1b[41m" << "Debug Mode " << endl;
	}
	(debug) ? DebugMain() : Main();
	return 0;
}

class man
{
public:
	int A;
	vector<pii> X;
	bool HeIsTrue;
private:

};

inline void Main() {
	ll X, Y, N;
	vector<ll> A;
	ll M1, D1, M2, D2;
	ll ans;
	ll sum = 0, count = 0;
	string S;
	string T;
	string Ans = "";
	int b[60];
	bool flag = false;

	cin >> X >> Y;

	for (ll i = 1; i <= Y; i++) {
		if ((X * i) % Y == 0) {
			cout << X * i;
			return ;
		}
	}



}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <regex>
#include <bitset>
#include <string>
#include <vector>
#include <iomanip>
#include <sstream>
#include <utility>
#include <iterator>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pq priority_queue<int,vector<int>,greater<int>>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define INF 9999999999
#define F first
#define S second

using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pp;

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

unsigned long long a, b, k, i;
int main() {
	cin >> a >> b >> k;
	while(i!=k) {
		if (a % 2 == 0) {
			b += a / 2;
			a /= 2;
		}
		else {
			a--;
			b += a / 2;
			a /= 2;
		}
		i++;
		if (i == k) break;
		if (b % 2 == 0) {
			a += b / 2;
			b /= 2;
		}
		else {
			b--;
			a += b / 2;
			b /= 2;
		}
		i++;
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int cnt = 0;
  rep(i, n) cin >> l[i];
  if (n == 1 || n == 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n - 2; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        vector<int> len(3);
        len[0] = l[i];
        len[1] = l[j];
        len[2] = l[k];
        sort(len.begin(), len.end());
        if ((len[0] + len[1] > len[2]) &&
            (len[0] != len[1] && len[1] != len[2] && len[2] != len[0])) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
s = gets.chomp.split("")
t = gets.chomp.split("")

min = Float::INFINITY

(0 .. s.size - t.size).each{ |i|
	count = 0
	
	t.each_with_index{ |tt, j|
		if tt != s[i, t.size][j] then
			count += 1
		end
	}
	
	if min > count then
		min = count
	end
}

puts min


Measured memory_bytes: 14380
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let a: usize = iter.next().unwrap().parse().unwrap();

    let days = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];

    let x = (a % 7 + 3) % 7;
    println!("{}", days[x]);
}



Measured memory_bytes: 5032
/**
 *  Hi, I'm Arpan.
 *  Hardwork beats talent if talents doesn't work hard, friend me if you want to. ✌.|•͡˘‿•͡˘|.✌
 *
*/

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
#define inv(v)         \
    for (auto &it : v) \
        cin >> it;
#define MOD 1000000007
#define pb push_back

ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}

void solve()
{
    char x;
    cin >> x;
    if(x >= 'A' && x <= 'Z'){
		cout << "A";
    }
    else{
		cout << "a";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
		solve();
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

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

signed main(){
    io();
    int n; cin >> n;
    vector<int> v(n);
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    for(int i = 1; i < n - 1; ++i){
        if((v[i] >= v[i - 1] && v[i] <= v[i + 1]) || (v[i] <= v[i - 1] && v[i] >= v[i + 1])){
            ++cnt;
        }
    }
    return cout << cnt << '\n',0;  
}

Measured memory_bytes: 3592
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){
    
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    
    int a[n];
    int b[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=0;j<m;j++){
        cin>>b[j];
    }
    
    int id=0;
    
    if(x>=y){
        id=1;
    }
    
    sort(a,a+n);
    sort(b,b+m);
    
    if(a[n-1]>=b[0]){
        id=1;
    }
   // a[n-1]とb[0]の間の整数がxとyの間にあるかどうか
    if(a[n-1]>=y||b[0]<=x){
        id=1;
    }
    
    if(id==0){
        cout<<"No War"<<endl;
    }else{
        cout<<"War"<<endl;
    }
    
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000000
#define endl "\n"
#define PI 3.14159265358979323846264338327950288

using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;


int main(){
    FAST_IO ;
    int N , M ; cin >> N >> M ;
    map<int , int> AC , WA ;
    int ac = 0 , wa = 0 ;
    for( int i = 0 ; i < M ; i++ ){
        int p ; cin >> p ;
        string str ; cin >> str ;
        if( str == "AC" && AC[p] == 0 ){
            AC[p]++ ;
            ac++ ;
            wa += WA[p] ;
        }
        else{
            WA[p]++ ;
        }
    }
    cout << ac << " " << wa << endl ;
    return 0 ;
  }










// dp[x] = represents the expected value of steps to get gcd = 1 when current gcd = x


// Exepected Value  = 1 + sigma ( dp[i] / M ) from i = 1 to M ;

// 001
// 110
// 011
// 100
//1 2 3 4
//1 0 3 0
//



//
//string str ; cin >> str ;
//   int N ; cin >> N ;
//   unordered_set<string> s ;
//   for( int i = 0 ; i < N ; i++ ){
//       string x ; cin >> x ;
//       s.insert(x) ;
//   }
//   dp[0] = 0 ;
//   int L = ( int ) str.length() ;
//   dp[L] = 1 ;
//   for( int i = L - 1 ; i >= 0 ; i-- ){
//       string word ;
//       for( int j = i ; j < L ; j++ ){
//           word.push_back(str[j]) ;
//           if( s.find(word) != s.end() && dp[j+1] != 0 )
//               dp[i] = dp[j+1] ;
//       }
//   }
//   cout << dp[0] << endl ;



























Measured memory_bytes: 12852
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

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

int main(){
    int N;cin >> N;
    int a[N+1];
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 1; i <= N; i+=2)
    {
        if((a[i]%2)==1) ans++; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t d[100000];

int main(void) {
    size_t N;

    scanf("%zu", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%zu", &(d[i]));
        if (i < N - 1) {
            scanf(" ");
        }
    }

    qsort(d, N, sizeof(size_t), compare_sz_asc);

    printf("%zu", d[N / 2] - d[N / 2 - 1]);

    return 0;
}


Measured memory_bytes: 1788
R, G, B, N = map(int, input().split())

count = 0
ans = 0
for r in range(0, N+1, R):
    for g in range(0, N+1-r, G):
        rg = r + g
        if rg == N or (N - rg) % B == 0:
            ans += 1
            count = 0

print(ans)

Measured memory_bytes: 41436
#include<stdio.h>
int main(void)
{
int x[3000]={0};
int y[3000]={0};
int i, j, a;
a=0;

for(j=0;j<3000;j++){
scanf("%d %d", &x[j], &y[j]);
if(x[j]==0&&y[j]==0)
break;
a++;
}
for(i=0;i<a;i++){
if(x[i]>y[i])
printf("%d %d\n", y[i], x[i]);
else if(x[i]<=y[i])
printf("%d %d\n", x[i], y[i]);
}

return 0;
}

Measured memory_bytes: 2708
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct segt
{
	int l,r,maxv;
}tree[2400010];
int a[300010],dp[300010];
void build(int le,int ri,int i)
{
	tree[i].l=le;
	tree[i].r=ri;
	tree[i].maxv=0;
	if(le==ri)
		return;
	int mid=(le+ri)>>1;
	build(le,mid,i<<1);
	build(mid+1,ri,i<<1|1);
}
void change(int p,int x,int i)
{
	if(tree[i].l==tree[i].r)
	{
		tree[i].maxv=max(tree[i].maxv,x);
		return;
	}
	if(tree[i<<1].r>=p)
		change(p,x,i<<1);
	else
		change(p,x,i<<1|1);
	tree[i].maxv=max(tree[i<<1].maxv,tree[i<<1|1].maxv);
}
int ask(int le,int ri,int i)
{
	if(le<=tree[i].l&&tree[i].r<=ri)
		return tree[i].maxv;
	int cnt=0;
	if(tree[i<<1].r>=le)
		cnt=ask(le,ri,i<<1);
	if(tree[i<<1|1].l<=ri)
		cnt=max(cnt,ask(le,ri,i<<1|1));
	return cnt;
}
signed main()
{
	int n,k,i,ans=1;
	cin>>n>>k;
	for(i=1;i<=n;i++)
		cin>>a[i];
	build(1,300002,1);
	//dp[1]=1;
	//change(2,1,1);
	for(i=1;i<=n;i++)
	{
		dp[i]=max(1ll,ask(max(0ll,a[i]-k)+1,min(300000ll,a[i]+k)+1,1)+1);
		change(a[i]+1,dp[i],1);
		ans=max(ans,dp[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 32832
module LazySegmentTree : sig
    type t

    val create: int array -> t
    val add : t -> int -> int -> int -> unit
    val getsum : t -> int -> int -> int
end = struct
    type t = int * int array * int array

    let z = 998244353

    let ( +@) a b = (a + b) mod z
    let ( *@) a b = (a * b) mod z

    let div2 a = if a mod 2 = 0 then a / 2 else (a + z) / 2

    let create arr =
        let sz = Array.length arr in
        let rec loop n =
            if n < sz then loop (n * 2) else n
        in
        let n = loop 1 in
        let node = Array.make (2 * n - 1) 0 in
        let laze = Array.make (2 * n - 1) 0 in
        for i = 0 to sz - 1 do node.(i + n - 1) <- arr.(i); done;
        for i = n - 2 downto 0 do node.(i) <- node.(i * 2 + 1) +@ node.(i * 2 + 2); done;
        n, node, laze

    let eval (n, node, laze) k l r =
        if laze.(k) <> 0 then (
            node.(k) <- node.(k) +@ laze.(k);
            if (r - l > 1) then (
                laze.(2 * k + 1) <- laze.(2 * k + 1) +@ div2 laze.(k);
                laze.(2 * k + 2) <- laze.(2 * k + 2) +@ div2 laze.(k);
            );
            laze.(k) <- 0
        )

    let rec add2 ((n, node, laze) as tree) a b x k l r =
        let r = if r < 0 then n else r in
        eval tree k l r;

        if b <= l || r <= a then () else (
            if a <= l && r <= b then (
                laze.(k) <- laze.(k) +@ (r - l) *@ x;
                eval tree k l r
            ) else (
                add2 tree a b x (2 * k + 1) l ((l + r) / 2);
                add2 tree a b x (2 * k + 2) ((l + r) / 2) r;
                node.(k) <- node.(2 * k + 1) +@ node.(2 * k + 2)
            )
        )
    let rec getsum2 ((n, node, laze) as tree) a b k l r =
        let r = if r < 0 then n else r in
        if b <= l || r <= a then 0 else (
            eval tree k l r;
            if a <= l && r <= b then node.(k) else
                let vl = getsum2 tree a b (2 * k + 1) l ((l + r) / 2) in
                let vr = getsum2 tree a b (2 * k + 2) ((l + r) / 2) r in
                vl +@ vr
        )

    let add tree a b x = add2 tree a b x 0 0 (-1)
    let getsum tree a b = getsum2 tree a b 0 0 (-1)
end ;;
Scanf.scanf "%d %d" (fun n k ->
    let lr = Array.init k (fun _ -> Scanf.scanf " %d %d" (fun l r -> l, r)) in
    let arr = Array.make n 0 in
    arr.(0) <- 1;
    let tr = LazySegmentTree.create arr in
    for i = 0 to n - 1 do
        let g = LazySegmentTree.getsum tr i (i + 1) in
        Array.iter (fun (l, r) ->
            if i + l < n then LazySegmentTree.add tr (i + l) (min (i + r + 1) n) g
        ) lr
    done;
    Printf.printf "%d\n" @@ LazySegmentTree.getsum tr (n - 1) n
)

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define yes "Yes"
#define yse "Yes"
#define no "No"

#define pb push_back
#define mp make_pair

#define NIL -1

#define list_itr list<ll>::iterator

#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define rep_cs(i, l, n) for (int i = (l); i <= (n); i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, n, a) for (int j = n; j >= a; j--)

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

const int MOD = 1000000007;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};
const ll INF = 1LL << 60;

// int max = *std::max_element(v.begin(), v.end());
// int sum = accumulate(v, v + v.size(), 0);

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

bool binary_search(int a[], int n, int key)
{
    int l = 0;
    int r = n;
    int middle;
    while (l < r)
    {
        middle = (l + r) / 2;
        if (key == a[middle])
        {
            return true;
        }

        if (key > a[middle])
        {
            l = middle + 1;
        }
        else if (key < a[middle])
        {
            r = middle;
        }
    }
    return false;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long combination(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_C = 1000;
long long Com[MAX_C][MAX_C];

void combination_for_small()
{
    memset(Com, 0, sizeof(Com));
    Com[0][0] = 1;
    for (int i = 1; i < MAX_C; ++i)
    {
        Com[i][0] = 1;
        for (int j = 1; j < MAX_C; ++j)
        {
            Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
        }
    }
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if ((a == b && b == c) || (a != b && b != c && c != a))
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;;

double dis(double a,double b) {
    return sqrt(a*a+b*b);
}

int main() {
    ios_base::sync_with_stdio(false); 
    
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double pi=3.14159265359;
    double hx=a*cos(2.0*pi*(h/12+m/(60*12))),hy=a*sin(2.0*pi*(h/12+m/(60*12))); 
    double mx=b*cos(2.0*pi*m/60),my=b*sin(2.0*pi*m/60);
    cout << fixed << setprecision(18) << dis(hx-mx,hy-my) << endl;

    return 0;
}

Measured memory_bytes: 4112
#include <cstdio>
#include <map>
#include <cmath>
const int P = 2154, V = 325;
int N, m[P + 1], pr[V + 1], v, O;
std::map < long long, int > MAP;
int main()
{
	for (int i = 2; i <= P; i++)
	{
		if (!m[i])
			m[i] = pr[++v] = i;
		for (int j = 1; j <= v && pr[j] * i <= P && pr[j] <= m[i]; j++)
			m[pr[j] * i] = pr[j];
	}
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		long long x;
		scanf("%lld", &x);
		for (int j = 1; j <= v; j++)
			while (x % (pr[j] * pr[j] * pr[j]) == 0)
				x /= pr[j] * pr[j] * pr[j];
		if (x == 1)
			O = 1;
		else
			MAP[x]++;
	}
	for (auto i : MAP)
	{
		long long tmp = i.first;
		static long long got[100];
		static int cnt[100];
		int D = 0;
		for (int j = 1; j <= v; j++)
			if (tmp % pr[j] == 0)
			{
				got[++D] = pr[j];
				cnt[D] = 0;
				do
				{
					cnt[D]++;
					tmp /= pr[j];
				}
				while (tmp % pr[j] == 0);
			}
		long long rest = sqrt(tmp) + 0.01;
		if (tmp > 1 && rest * rest == tmp)
		{
			got[++D] = rest;
			cnt[D] = 2;
		}
		long long Even = 1;
		for (int i = 1; i <= D; i++)
			if (cnt[i] == 2)
				Even *= got[i];
		long long Odd = i.first / Even / Even;
		long long Partner = Odd * Even;
		if (Partner <= 10000000000LL / Odd)
			Partner *= Odd;
		else
			Partner = 10000000001LL;
		auto partner = MAP.find(Partner);
		if (partner == MAP.end())
			O += i.second;
		else
		{
			O += std::max(i.second, partner -> second);
			MAP.erase(partner);
		}
	}
	printf("%d\n", O);
	return 0;
}


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

int main(){
    int N,X;
    cin >> N >> X;
    vector<int> vec(N);

    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    int sum = 1;
    int r = 0;
    for(int i=0;i<N;i++){
        r += vec.at(i);
        if(r<=X){
            sum++;
        }
    }
    cout << sum << endl;
}

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

x = [""]*len(s)

for i in range(len(s)):
    for j in range(len(s)):
        x[j] = s[j-i-1]
    y="".join(x)
    if t in y:
        print("Yes")
        break
else:
    print("No")
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define endl            "\n"
#define forn(i,x,n)     for(int i=x; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    int l, r, d; cin >> l >> r >> d;

    int count = 0;

    forn(i, l, r + 1) {
        if (i % d == 0) {
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3584
n, x, m = (int(x) for x in input().split())
A = [x]
used = {x, }
while True:
    x = pow(x, 2, m)
    if x in used:
        index = A.index(x)
        break
    else:
        A.append(x)
        used.add(x)
if n <= len(A):
    print(sum(A[:n]))
else:
    ans = sum(A)
    n -= len(A)
    m = len(A) - index
    ans += (n // m) * sum(A[index:])
    ans += sum(A[index:index + (n % m)])
    print(ans)

Measured memory_bytes: 77088
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
 
public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    in.close();
    int k = Integer.parseInt(str[0]);
    int x = Integer.parseInt(str[1]);
    System.out.println(500 * k >= x ? "Yes":"No");
  }
}

Measured memory_bytes: 21460
n,m = list(map(int, input().split()))

for j in reversed(range(0, n+1)):
  if 10000*j <= m:
    for k in reversed(range(0, n+1)):
      if 10000*j + 5000*k + 1000*(n-(j+k)) == m:
        if n-(j+k) >=0:
          print(j,k,n-(j+k))
          exit(0)

print(-1,-1,-1)


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

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

    int N;
    cin >> N;
    vector<int> pos, neg;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (A >= 0) pos.push_back(A);
        else neg.push_back(A);
    }
    sort(pos.rbegin(), pos.rend());
    sort(neg.rbegin(), neg.rend());
    if (neg.size() == 0) {
        neg.push_back(pos.back());
        pos.pop_back();
    }
    int x = neg[0];
    vector<pair<int, int>> ans;
    if (pos.size() > 0) {
        for (int i = 0; i < pos.size() - 1; i++) {
            ans.push_back({x, pos[i]});
            x -= pos[i];
        }
        ans.push_back({pos.back(), x});
        x = pos.back() - x;
    }
    for (int i = 1; i < neg.size(); i++) {
        ans.push_back({x, neg[i]});
        x -= neg[i];
    }
    cout << x << '\n';
    for (auto& p : ans) cout << p.first << " " << p.second << '\n';
}

Measured memory_bytes: 5048
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    vector<string>x(h);
    for(int i=0;i<h;i++){
        cin >> x[i];
    }
    for(int i=0;i<h;i++){
        cout << x[i] << "\n";
        cout << x[i] << "\n";
    }
}

Measured memory_bytes: 256
/*
AtCoder Beginner Contest 101 A - Eating Symbols Easy
結果:
*/

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

#define max(x,y)(x<y?y:x)
#define int long long

int compare(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

//尺取法
//scanf("%d", &N);
//for (i; i < N; ++i) {
//	scanf("%d", &A[i]);
//	if (b[A[i]] == 1) {
//		ans = max(ans, i - j);
//		while (b[A[i]] == 1) {
//			b[A[j++]] = 0;
//		}
//	}
//	b[A[i]] = 1;
//}
//ans = max(ans, i - j);
//printf("%d\n", ans);

//文字列の最大出現
//static int N, i, j, ans;
//static int A, B;
//static char A[50][51];
//static int cnt, max;
//char *max_name;
//
//scanf("%d", &N);
//for (i = 0; i < N; i++) {
//	scanf("%s", A[i]);
//}
//max_name = A[0];
//for (i = 0; i < N; i++) {
//	cnt = 0;
//	for (j = 0; j < N; j++) {
//		if (strcmp(A[i], A[j]) == 0) {
//			cnt++;
//		}
//		if (cnt > max) {
//			max = cnt;
//			max_name = A[i];
//		}
//	}
//}
//printf("%s\n", max_name);

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int main() {
	static int N, i, j, cnt, ans;
	//static int AN, BN, A[100] = {}, B[100] = {}, i, j, ans;
	//static int A, B;
	//static int A, B, C;
	//static int a[31] = {}, b[31] = {}, cnt = 0;
	//static char A[50][51];
	//static int cnt, max;
	//char *max_name;
	//static int ans;
	static char A[4];

	scanf("%s", &A);

	for (i = 0; i < 4; i++) {
		if (A[i] == '+') { cnt++; }
		if (A[i] == '-') { cnt--; }
	}
	ans = cnt;
	//qsort(A, N, sizeof(int), compare);

	//ans = ;
	printf("%d\n", ans);
	//printf("%s\n", max_name);

#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128