akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int mo = 1e9 + 7;
const int ma = 1000;
#define int long long
struct mint
{
    int x;
    mint() : x(0) {}
    mint(int x) : x((x % mo + mo) % mo) {}
    mint &fix()
    {
        x = (x % mo + mo) % mo;
        return *this;
    }
    mint operator-() const { return mint(0) - *this; }
    mint &operator+=(const mint &a)
    {
        if ((x += a.x) >= mo)
            x -= mo;
        return *this;
    }
    mint &operator-=(const mint &a)
    {
        if ((x += mo - a.x) >= mo)
            x -= mo;
        return *this;
    }
    mint &operator*=(const mint &a)
    {
        (x *= a.x) %= mo;
        return *this;
    }
    mint operator+(const mint &a) const { return mint(*this) += a; }
    mint operator-(const mint &a) const { return mint(*this) -= a; }
    mint operator*(const mint &a) const { return mint(*this) *= a; }
    bool operator<(const mint &a) const { return x < a.x; }
    bool operator==(const mint &a) const { return x == a.x; }
};
istream &operator>>(istream &i, mint &a)
{
    i >> a.x;
    return i;
}
ostream &operator<<(ostream &o, const mint &a)
{
    o << a.x;
    return o;
}
main()
{
    int n;
    cin >> n;
    string s;cin >> s;
    vector< mint > dp(1);
    dp[0] = 1;
    char pre = '<';
    for( int i = 0; i < n - 1; i++ )
    {
        vector< mint > p(dp.size() + 1 ) ; swap( dp, p );
        if( s[i] != pre )reverse( begin(p), end(p) );
        pre = s[i];
        mint x = 0;
        for( int j = 0; j < p.size(); j++ )
        {
            x += p[j];
            dp[j + 1] = x;
        }
    }
    mint ans = 0;
    for( int i = 0; i < dp.size(); i++ ) ans += dp[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
N,W = map(int,input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
v = [0]*N
w = [0]*N
for i in range(N):
    v[i], w[i] = map(int,input().split())
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[N][W])


Measured memory_bytes: 25496
import java.util.Scanner;

public class Main {

	public static final int MAX = 500000;
	public static final int SENTINEL = (int)Math.pow(10, 9) + 1;
	public static int[] A = new int[MAX];
	public static int[] L = new int[MAX/2+1];
	public static int[] R = new int[MAX/2+1];
	public static int count = 0;

	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		for(int i = 0; i < n; i++){
			A[i] = scan.nextInt();
		}
		merge_sort(0,n);
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < n; i++){
			sb.append(A[i]);
			sb.append(" ");
		}
		System.out.println(sb.toString().trim());
		System.out.println(count);
	}


	public static void merge_sort(int left,int right){
		if(left+1 == right) return;
		int mid = (right + left) / 2;
		merge_sort(left,mid);
		merge_sort(mid,right);

		merge(left,right);
	}

	public static void merge(int left,int right){
		int mid = (right + left) / 2;
		int n1 = mid - left;
		int n2 = right - mid;
		for(int i = 0; i < n1; i++) L[i] = A[left + i];
		for(int y = 0; y < n2; y++) R[y] = A[mid + y];
		L[n1] = R[n2] = SENTINEL;

		int x = 0;
		int y = 0;
		for(int i = left; i < right; i++){
			count++;
			if(L[x] <= R[y]){
				A[i] = L[x++];
			}else{
				A[i] = R[y++];
			}
		}
	}
}

Measured memory_bytes: 172724
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
a, p = map(int, input().split())

print((a*3+p)//2)

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res



Measured memory_bytes: 21712
FAST_IO = 1
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]
N, K = rrm()
arr = rrm()
def solve(N,K, arr):
    ans = []
    for i in range(K, N):
        if arr[i]>arr[i-K]:
            ans.append(True)
        else:
            ans.append(False)
    return ans
ans = solve(N, K, arr)
for res in ans:
    if res:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 101260
N, A, B = map(int, input().split())
if (A - B) % 2 == 0:
    print(abs(A-B) // 2)
else:
    x = min(A, B)
    y = max(A, B) - x
    ans1 = x + (y - 1) // 2

    x = N - max(A, B) + 1
    y = min(A, B) + x
    ans2 = x + (N - y) // 2
    
    print(min(ans1, ans2))


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <cstdlib>
using namespace std;

const int N = 200000;
int n;
int a[N];

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

void solve()
{
    int c4=0,c2=0,c1=0;
    for(int i=0; i<n; i++)
    {
        if(a[i]%4 == 0)
            c4++;
        else if(a[i]%2 == 0)
            c2++;
        else
            c1++;
    }
    if(c2 > 0)
        c2 = 1;
    if(c1 == 0)
        cout << "Yes" << endl;
    else if(c4 >= c1-1+c2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

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

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

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 (b < a) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

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

  ll n, k;
  cin >> n >> k;
  if (2 * k > n + 1) {
    cout << -1 << endl;
    return 0;
  }

  if(n == 1) {
    cout << k << " " << k+1 << " " << k+2 << endl;
    return 0;
  }

  vvll ans(n, vll(3));

  int pos = 0;
  for (ll i = k; i < n + k; i += 2) {
    ans[pos][0] = i;
    pos++;
  }
  for (ll i = k + 1; i < n + k; i += 2) {
    ans[pos][0] = i;
    pos++;
  }

  pos = 0;
  for (ll i = k + n - 1 + n / 2 + n % 2; i >= k + n; i--) {
    ans[pos][1] = i;
    pos++;
  }
  for (ll i = k + 2 * n - 1; i > k + n - 1 + n / 2 + n % 2; i--) {
    ans[pos][1] = i;
    pos++;
  }

  pos = 0;
  for (ll i = k + 2 * n; i < k + 3 * n; ++i) {
    ans[pos][2] = i;
    pos++;
  }

  REP(i, n) {
    cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
  }


  return 0;
}

Measured memory_bytes: 8764
// https://atcoder.jp/contests/abc095/tasks/arc096_a
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	int ans=1e9;
	rep(z,2e5+1){
		int i = max(0, x-z/2), j=max(0,y-z/2);
		int res = i*a + j*b + z*c;
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

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

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

for (int i = x; x<=100000 ; i++)
{
  bool f =1;
  for (int j = sqrt(i)/1; j>1 ; j--)
  {
    if(i%j==0)
    {
      f=0;
      break;
    } 
  }
  if(f)
  {
    cout << i << endl;
    break;
  }
}

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int ans0 = 0, ans1 = 0;
        for (int i=0; i<s.length(); ++i) {
            if ((i&1)==0) {
                if (s.charAt(i)=='0') {
                    ans1++;
                } else {
                    ans0++;
                }
            } else {
                if (s.charAt(i)=='0') {
                    ans0++;
                } else {
                    ans1++;
                }
            }
        }
        System.out.println(Math.min(ans0, ans1));
    }
}


Measured memory_bytes: 27456
s = input().split()
x1=s[0][0]
x2=s[0][1]
x3=s[0][2]
flag = False
A = 'A'
B = 'B'
if x1==A and x2==A and x3==A:
    flag = True
elif x1==B and x2==B and x3==B:
    flag = True
else:
    flag = False
if (flag):
    result = 'No'
else:
    result = 'Yes'
print(result)

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

ll R, C, k;

int main() {
	cin>>R>>C>>k;
	ll r[k+1], c[k+1], V[k+1], v[R+1][C+1];
	memset(v, 0, sizeof(v));
	for (int i=1; i<=k; i++) {
		cin>>r[i]>>c[i]>>V[i];
		v[r[i]][c[i]]=V[i];
	}
	ll dp[C+1][2][4];
	memset(dp, 0, sizeof(dp));
	dp[1][0][0]=0, dp[1][0][1]=v[1][1];
	for (int i=2; i<=C; i++) {
		for (int j=1; j<=3; j++) {
			dp[i][0][j]=dp[i-1][0][j];
			dp[i][0][j]=max(dp[i][0][j], dp[i-1][0][j-1]+v[1][i]);
		}
	}
	for (int i=2; i<=R; i++) {
		for (int j=1; j<=C; j++) {
			for (int l=0; l<=3; l++) {
				if (l==0) {
					for (int m=0; m<=3; m++) {
						dp[j][1][l]=max(dp[j][1][l], dp[j][0][m]);
					}
					dp[j][1][l]=max(dp[j][1][l], dp[j-1][1][0]);
				}
				else {
					if (l==1) {
						for (int m=0; m<=3; m++) {
							dp[j][1][l]=max(dp[j][1][l], dp[j][0][m]+v[i][j]);
						}
					}
					dp[j][1][l]=max(dp[j][1][l], dp[j-1][1][l]);
					dp[j][1][l]=max(dp[j][1][l], dp[j-1][1][l-1]+v[i][j]);
				}
			}
		}
		for (int j=1; j<=C; j++) {
			for (int l=0; l<=3; l++) {
				dp[j][0][l]=dp[j][1][l];
			}
		}
	}
	ll ans=0;
	for (int i=0; i<=3; i++) {
		ans=max(ans, dp[C][0][i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 78816
import java.util.*;
public class Main {
    static public void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if(h == 0 && w==0) break;
            for(int i = 0;i<h;i++){
                for(int j = 0;j<w;j++){
                    System.out.printf("#");
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        sc.close();
    }
}


Measured memory_bytes: 56864
'use strict'

function main(input) {
  input = input.split(' ')
  let a = input[0] * input[1]
  let b = input[2] * input[3]
  if (a <= b) {
    console.log(b)
  } else {
    console.log(a)
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  a+='0';
  b+='0';
  c+='0';
  char i ='a';
  char d = '0';
  while(i!='0'){
    if(i == 'a'){
      i = a[0];
      a.erase(a.begin());
      d='A';
    }
    if(i == 'b'){
      i = b[0];
      b.erase(b.begin());
       d='B';
    }
    if(i =='c'){
      i = c[0];
      c.erase(c.begin());
      d ='C';
    }
  }
  cout << d << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

void dfs(vvi &G, vi &cnt, int v, int p){
  for(int nv : G[v]){
    if (nv == p) continue;
    cnt[nv] += cnt[v];
    dfs(G, cnt, nv, v);
  }
}

int main(){
  int n,q; cin >> n >> q;
  vvi G(n);
  rep(i, n-1){
    int a,b; cin >> a >> b;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vi cnt(n);
  rep(i, q){
    int p,x; cin >> p >> x;

    cnt[--p] += x;
  }
  dfs(G, cnt, 0, -1);

  rep(i, n) std::cout << cnt[i] << ' ';
  std::cout << '\n';
}


Measured memory_bytes: 29696
class UnionFind:
    def __init__(self, max_size):
        self.parent = [i for i in range(max_size+1)]
        self.depth = [0 for _ in range(max_size+1)]
        self.cnt = [1 for i in range(max_size+1)]
    def find(self, x):
        t = x
        while t!=self.parent[t]:
            t = self.parent[t]
        self.parent[x]=t
        return t
    
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return
        elif self.depth[x]<self.depth[y]:
            self.parent[x] = y
            self.cnt[y] += self.cnt[x]
        else:
            self.parent[y] = x
            self.cnt[x]+=self.cnt[y]
            if self.depth[x]==self.depth[y]:
                self.depth[x]+=1
    def same(self, x, y):
        return self.find(x)==self.find(y)
    def size(self,x):
        return self.cnt[self.find(x)]

n,m = map(int,input().split())
utree = UnionFind(n+10)
for _ in range(m):
    x,y,z = map(int,input().split())
    utree.unite(x,y)
s = {utree.find(i) for i in range(1,n+1)}
print(len(s))

Measured memory_bytes: 14836
#include<stdio.h>
int main(void){
	int t[4],n[4],i;
	for(i=0;i<4;i++){
		scanf("%d %d",&t[i],&n[i]);
	}
	for(i=0;i<4;i++){
		switch(t[i]){
			case 1 : printf("%d\n",6000*n[i]);break;
			case 2 : printf("%d\n",4000*n[i]);break;
			case 3 : printf("%d\n",3000*n[i]);break;
			case 4 : printf("%d\n",2000*n[i]);break;
		}
	}
	return 0;
}

Measured memory_bytes: 1824
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll dp[202020][30];
pair<ll, ll>nxt[202020][30];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	string A;
	cin >> A;
	int N = A.size();
	for (int i = 0; i < 202020; i++)for (int j = 0; j < 27; j++)dp[i][j] = inf;
	for (int j = 0; j < 26; j++) {
		if (A[N - 1] - 'a' != j)dp[N - 1][j] = 1;
		else dp[N - 1][j] = 2;
		nxt[N - 1][j] = { N,-1 };
	}

	for (int i = N - 2; i >= 0; i--) {
		for (int j = 0; j < 26; j++) {
			if (A[i] - 'a' != j) {
				dp[i][j] = dp[i + 1][j];
				nxt[i][j] = nxt[i + 1][j];
			}
			else {
				ll mi = *min_element(dp[i + 1], dp[i + 1] + 26);
				dp[i][j] = *min_element(dp[i + 1], dp[i + 1] + 26) + 1;
				for (int k = 0; k < 26; k++) {
					if (mi == dp[i + 1][k]) {
						nxt[i][j] = {i+1,k};
						break;
					}
				}
			}
		}
	}
	
	string ans;
	int curi = 0;
	int curj = min_element(dp[0],dp[0]+26)-dp[0];
	ll mi = *min_element(dp[0], dp[0] + 26);
	while (1) {
		if (curi == N) {
			if (ans.size() == mi)break;
			else {
				ans.pb('a');
				break;
			}
		}
		ans += (char)('a'+curj);
		int tmpi = curi;
		int tmpj = curj;
		curi = nxt[tmpi][tmpj].first;
		curj = nxt[tmpi][tmpj].second;
	}
	puts(ans);


	return 0;
}

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

using namespace std;

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

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cou = 0;

    rep(a, A+1) {
        rep(b, B+1) {
            rep(c, C+1) {
                if (X==a * 500 + b * 100 + c * 50) {
                    cou++;
                }
            }
        }
    }
    cout << cou << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define swap(X, Y){int Z; Z=Y; Y=X; X=Z;}
int main()
{
	int a, b;
	
	while(scanf("%d %d", &a, &b))
	{
		
		if(a == 0 && b == 0)
		{
			break;
		}
		if(a>b)
		{
			swap(a, b);
		}
		printf("%d %d\n", a, b);
	}

	return 0;
} 


Measured memory_bytes: 2620
n, k = list(map(int, input().split()))
dic = {}
for _ in range(n):
    a, b = list(map(int, input().split()))
    if a not in dic:
        dic[a] = b
    else:
        dic[a] += b
total = 0
for key, val in sorted(dic.items(), key=lambda x: x[0]):
    total += val
    if k<= total:
        print(key)
        break

Measured memory_bytes: 15084
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0,sol=INT_MAX,j;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=1;i<=100;i++){
        ans=0;
        for(j=0;j<n;j++){
            ans = ans + (i-arr[j])*(i-arr[j]);
        }
        sol=min(sol,ans);
    }
    cout<<sol<<endl;
    return 0;
}


Measured memory_bytes: 256
import heapq

N,M = map(int,input().split())
L = list(map(int,input().split()))

q=[]
for l in L:
    heapq.heappush(q, -l)

for _ in range(M):
    p = -heapq.heappop(q)//2
    heapq.heappush(q, -p)

print(-sum(q))

Measured memory_bytes: 14180
fun main(args: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val B = A.mapIndexed { index, v -> v - (index + 1) }.sorted()
    val b = B[N / 2]
    val ans = A.withIndex().sumByLong { Math.abs(it.value - (b + it.index + 1)).toLong() }
    println(ans)
}
inline fun <T> Iterable<T>.sumByLong(selector: (T) -> Long): Long {
    var sum = 0L
    for (element in this) sum += selector(element)
    return sum
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun nextInt(offset: Int = 0) = nextInt() + offset
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }






Measured memory_bytes: 82820
import collections
import bisect
N,M=map(int, input().split())
p=[[int(j) for j in input().split()] for i in range(M)]
a=collections.defaultdict(list)
for x,y in sorted(p):
  a[x].append(y)
for x,y in p:
  z=bisect.bisect(a[x],y)
  print("%06d%06d"%(x,z))

Measured memory_bytes: 41032
D,G = map(int,input().split())

p = []
c = []
ans = []
for _ in range(D):
	p_dash,c_dash = map(int,input().split())
	p.append(p_dash)
	c.append(c_dash)

for i in range(2**D):
	l = [0]*D
	score = 0
	count = 0
	for j in range(D):
		if i & (1<<j):
			l[j] = 1

	for a,b,num in zip(l,p,range(1,D+1)):
		if a == 1:
			score += b*100*num
			score += c[num-1]
			count += b

	if score < G:
		index = D
		for bit in l[::-1]:
			index -= 1
			if bit == 0:
				break
		tmp = 0
		while True:
			tmp += 1
			if tmp > p[index]:
				break
			if score + tmp*100*(index+1) >= G:
				ans.append(count+tmp)
				break
	else:
		ans.append(count)

print(min(ans))


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,K,ans;
  cin>>N>>K;
  //1~K ... N-K+1~N
  ans=N-K+1;
  cout<<ans<<"\n";
return 0;
}

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

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

  if(Z.size() < 26){
    int a[26];
    for(int i=0;i<26;i++){
      a[i]=0;
    }

    for(int i=0;i<Z.size();i++){
      int c = Z.at(i) - 'a';
      a[c] = 1;
    }
    char add;
    for(int i=0;i<26;i++){
      if(a[i] == 0){
	add = 'a' + i;
	break;
      }
    }
    cout << Z << add << endl;
  }else{
    if(Z == "zyxwvutsrqponmlkjihgfedcba"){
      cout << "-1" << endl;
      return 0;
    }
    for(int i=24;i>=0;i--){
      string s1 = Z.substr(0, i);
      string s2 = Z.substr(i);
      sort(s2.begin(), s2.end());
      for(int j=0;j<s2.length();j++){
	if(s1 + s2[j] > Z){
	  cout << s1 + s2[j] << endl;
	  return 0;
	}
      }
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N+1);
  
  for (int i=1; i<N+1; i++) {
    cin >> vec.at(i);
  }
  
  int check=1;
  
  for (int i=1; i<N+1; i++) {
    check = vec.at(check);
    if (check==2) {
      cout << i << endl;
      break;
    }
    if (i==N) {
      cout << -1 << endl;
    }
  }
}

 
  

Measured memory_bytes: 640
n,k = map(int, input().split( ))
import sys
from collections import Counter
input = sys.stdin.readline
a = list(map(int,input().split( )))

ac = Counter(a)
cnt = []
for ke in ac:
    cnt.append(ac[ke])
cnt.sort()
if len(cnt)<=k:
    print(0)
else:
    print(sum(cnt[:-k]))

Measured memory_bytes: 97096
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}


int main() {
  ll n,a[100005],ans;
  ans=0;
  cin >> n;
  rep(i,n)cin >> a[i];
  rep(i,n)if(a[i]%2==1)ans=1;
  if(ans==1)printf("first");
  else printf("second");
}

Measured memory_bytes: 1024
n,k = map(int,input().split())
m = [0] + list(map(int,input().split()))
p = 1

c = [0] * (n + 1)

q = [1]

while True:
  p = m[p]
  if (c[p] == 1):
    break
  c[p] += 1
  q.append(p)
i = q.index(p)
q1 = q[:i]
q2 = q[i:]
if len(q1) > 0 and k < len(q1):
  print(q1[k])
else: 
  print(q2[(k - len(q)) % len(q2)])

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


int main()
{
    ll a[3];
    for(int i=0;i<3;i++)
        cin>>a[i];
    sort( a, a+3);
    if( a[2]%2==0)
        cout<<0;
    else cout<<a[0]*a[1];
}

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

const int MAX_N = 2e5;
int N;
int a[MAX_N+5], b[MAX_N+5];
int ca[MAX_N+5], cb[MAX_N+5];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++) cin >> b[i];

    ll ans = 0, p = 1;
    for(int i=0;i<30;i++){
        for(int j=0;j<N;j++){
            ca[j] = a[j] % (p<<1);
            cb[j] = b[j] % (p<<1);
        }

        sort(cb, cb+N);

        int cnt = 0;
        for(int j=0;j<N;j++){
            int d1 = distance(lower_bound(cb, cb+N, p-ca[j]), lower_bound(cb, cb+N, 2*p-ca[j]));
            int d2 = distance(lower_bound(cb, cb+N, 3*p-ca[j]), lower_bound(cb, cb+N, 4*p-ca[j]));
            cnt ^= (d1+d2) % 2;
        }

        if(cnt) ans += p;
        p <<= 1;
    }

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


Measured memory_bytes: 3328
A,B=[int(i) for i in input().split(" ")]



def f0_n(B,n):
    if n==1:
        return  ((B+1)//2)%2


    B=(B+1)%(2**n)
    if B<=2**(n-1):
        return 0
    else:
        B-=2**(n-1)
        return B%2



def f0(B):
    retval=""
    for n in range(1,len(bin(B).replace("b",""))+10):
        retval+=str(f0_n(B,n))
    retval=retval[::-1]
    return int(retval,2)


if A==0:
    print(f0(B))
else:
    print(f0(B)^f0(A-1))


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <queue>
using namespace std;
int main(void){
    int X;
    cin >> X;
    priority_queue<int> que;
    que.push(1);
    for (int i = 2; i <= 31; i++)
        for (int j = 2; j <= 10; j++)
            if (pow(i, j) <= 1000)
                que.push(pow(i, j));
    while (que.top() > X)
        que.pop();
    cout << que.top() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  ll ans = (n - 1) / 2;
  print(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  vector<int> v(3);
  rep(i, 3) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[0] << " " << v[1] << " " << v[2] << endl;
  return 0;
}


Measured memory_bytes: 3152
n = int(input())
a = [int(i) for i in input().split()]

b = []

for i in range(n):
    b.append(a[i]-(i+1))

b = sorted(b)

x = b[n//2] if n%2==1 else (b[n//2] + b[(n//2)-1]) // 2

sum_num = 0
for b_ in b:
    sum_num += abs(b_-x)

print(sum_num)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int x;
    cin >> x;
    
    int tmp = 0, res;
    for(int i = 1; ; i++){
        tmp += i;
        if(tmp >= x){
            res = i;
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    loop {
        let mut buf = String::new();

        stdin.read_line(&mut buf).unwrap();

        let mut buf = buf.trim().split(" ");

        let h = buf.next().unwrap().parse::<i64>().unwrap();
        let w = buf.next().unwrap().parse::<i64>().unwrap();

        if h == 0 && w == 0 { break; }

        for _ in 0..w {
            print!("#");
        }
        println!();
        for _ in 0..(h - 2) {

            print!("#");
            for _ in 0..(w - 2) {
                print!(".");
            }
            print!("#");
            println!();
        }
        for _ in 0..w {
            print!("#");
        }
        println!();
        println!();
    }
}


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

int main () {
  int N;
  cin >> N;
  vector <int> num(N);
  for (int i = 0; i < N; i++) cin >> num.at(i);
  int ans = 0;
  for (int i = 0; i < N; i+= 2){
    if (num.at(i)%2 == 1) ans ++;
  }
  cout << ans << endl;
}

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

const int MOD = 1000000007, maxn = 1020000;
int muln(int x, int y) { return 1LL * x  * y % MOD; }
int qpow(int x, int y) {
    int ret = 1;
    for(; y; y >>= 1, x = muln(x, x))
        if(y & 1) ret = muln(ret, x);
    return ret;
}
int inv(int x) { return qpow(x, MOD - 2); }
int n, ans, i3 = inv(3), in, p3 = 1;

int main() {
    scanf("%d", &n);
    in = inv(n);
    for(int i = 1; i <= n; ++i) {
        p3 = muln(p3, i3);
        ans += muln(p3, muln(in, inv(n - i + 1)));
        if(ans >= MOD) ans -= MOD; 
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 256
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

template<class F>
class MaxFEdge {
public:
	int to;
	F cap;
	int rev;
	MaxFEdge(int _to, F _cap, int _rev) :to(_to), cap(_cap), rev(_rev) {}
};

template<class F>
class Dinic {
public:
	int V;
	vector<vector<MaxFEdge<F>>> G;
	VI itr, level;
	Dinic(int _v) :V(_v) {
		G.resize(V);
	}
	void AddEdge(int src, int to, F cap) {
		G[src].push_back(MaxFEdge<F>(to, cap, G[to].size()));
		G[to].push_back(MaxFEdge<F>(src, 0, G[src].size() - 1));
	}
	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		level[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (auto& e : G[v]) {
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	F dfs(int v, int t, F f) {
		if (v == t)return f;
		F res = 0;
		for (int& i = itr[v]; i < (int)G[v].size(); i++) {
			MaxFEdge<F>& e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				F d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					res += d;
					f -= d;
				}
			}
		}
		return res;
	}
	F MaxFlow(int s, int t) {
		F res = 0;
		F f = 0;
		F inf = numeric_limits<F>::max();
		while (true) {
			bfs(s);
			if (level[t] < 0)return res;
			itr.assign(V, 0);
			while (true) {
				f = dfs(s, t, inf);
				if (f <= 0)break;
				res += f;
			}
		}
	}
};

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int N;
	cin >> N;
	VLL A(N + 1,0);
	for (int n = 1; n <= N; n++)cin >> A[n];
	LL pad = 0;
	for (int n = 1; n <= N; n++) {
		if (A[n] >= 0)pad += A[n];
	}
	Dinic<LL> D(N + 2);
	for (int n = 1; n <= N; n++) {
		if (A[n] >= 0) {
			D.AddEdge(0, n, A[n]);
			D.AddEdge(n, N + 1, 0);
		}
		else {
			D.AddEdge(0, n, 0);
			D.AddEdge(n, N + 1, -A[n]);
		}
		for (int p = 2 * n; p <= N; p += n) {
			D.AddEdge(p, n, 1e15);
		}
	}
	LL res = D.MaxFlow(0, N + 1);
	cout << pad - res << "\n";
	return 0;
}

Measured memory_bytes: 3256
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


n = int(input())
a = [int(item) for item in input().split()]

g_pre = [0] * (n + 1)
for i in range(n):
    g_pre[i] = gcd(g_pre[i - 1], a[i])

g_suf = [0] * (n + 1)
for i in range(n - 1, -1, -1):
    g_suf[i] = gcd(g_suf[i + 1], a[i])

ans = -1

for i in range(n):
    ans = max(ans, gcd(g_pre[i - 1], g_suf[i + 1]))

print(ans)


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

int main()
{

  while( true ) {
    bool bary[ 100 ][ 100 ][ 100 ] = { false };

    int n, x;
    cin >> n >> x;
    if( n == 0 and x == 0 ){
      break;
    }

    int cnt = 0;
    for( int i = 1; i <= n; i++ ) {
      for( int j = 1; j <= n; j++ ) {
        for( int k = 1; k <= n; k++ ) {
          if( i == j or j == k or k == i ) {
            continue;
          }
          if( i + j + k == x ) {
            int ary[3] = { i, j, k };
            sort( ary, ary + 3 );
            int x, y, z;
            x = ary[ 0 ], y = ary[ 1 ], z = ary[ 2 ];
            if( bary[ x ][ y ][ z ] == false ) {
              bary[ x ][ y ][ z ] = true;
              cnt += 1;
//            cout << x << ":" << y << ":" << z << endl;
            }
          }
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 4132
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef long double ld;

int main(){
  string s;
  cin >> s;
  string s1 = s.substr(0,(s.size()-1)/2);
  string s2 = s.substr(((s.size()-1)/2)+1,(s.size()-1)/2);

  bool isstrong = true;
  for(ll i=0;i<s1.size()/2;i++){
    if(s1[i]!=s1[s1.size()-1-i]){
      isstrong = false;
    }
  }
  if(!isstrong){
    cout << "No";
    return 0;
  }
  else{
    for(ll i=0;i<s1.size();i++){
      if(s1[i]!=s2[s1.size()-1-i]){
        isstrong = false;
      }
    }
  }
  if(!isstrong){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
  
  
  
}

Measured memory_bytes: 256
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

const int N = 3004;
int n, ar[N];
ll dp[N][N];
// dp[i][j] := max value of X-Y using a[i...j]

void solve() {
   for (int i = 1; i <= n; ++i)
      dp[i][i] = ar[i];


   for (int j = 2; j <= n; ++j) {
      for (int i = j-1; i >= 0; --i) {
         dp[i][j] = max(ar[i] - dp[i+1][j], ar[j] - dp[i][j-1]);
      }
   }


   cout << dp[1][n] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;
   for (int i = 1; i <= n; ++i) cin >> ar[i];
   solve();


   return EXIT_SUCCESS;
}



Measured memory_bytes: 70016
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    string s;
    cin>>s;
    if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }







    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main()
{
	long N;
	cin >> N;
	long X;
	cin >> X;
	long T;
	cin >> T;

	long result = 0;
	if (N % X == 0)
	{
		cout << T * (N / X) << endl;
	}
	else
	{
		cout << T * (N / X + 1) << endl;
	}
}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			String s = sc.nextLine();
			String p = sc.nextLine();
			boolean yes = false;
			for(int i = 0;i<s.length();i++) {
				int j;
				for(j=0;j<p.length();j++) {
					if(s.charAt((i+j)%s.length())!=p.charAt(j)) break;
				}
				if(j==p.length()) {
					yes = true;
					break;
				}
			}
			System.out.println(yes?"Yes":"No");
		}
	}
}


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

int main()
{
    double N; cin>>N;
    double x=1.08;
    double d= (N/x);
    double p = (d*x);
    double ans= ceil(d);
    if(ans*x - N >= 1) cout<<":(";
    else cout<<ans;
}


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

int main() {
  int n;
  unsigned long long c=0;
  cin>>n;
  vector<int> a(n+1),b(n);
  for(int i=0;i<=n;i++) cin>>a.at(i);
  for(int i=0;i<n;i++) cin>>b.at(i);
  for(int i=0;i<n;i++){
    int A=a.at(i);
    int B=a.at(i+1);
    int C=b.at(i);
    if(a.at(i)+a.at(i+1)>b.at(i)){
      c+=b.at(i);
      if(C>A) a.at(i+1)-=(b.at(i)-a.at(i));
    }
    else{
      c+=(A+B);
      a.at(i+1)=0;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll a,b,x;
    cin >> a >> b >> x;
    ll ans = b/x - a/x;
    if(0 == a%x)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <atcoder/segtree.hpp>

using namespace std;
using boost::sort;
using boost::adaptors::reversed;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }
int main() {
    int n, k;
    cin >> n >> k;
    atcoder::segtree<int, op, e> seg(300010);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        int l = max(a - k, 0);
        int r = min(a + k, 300000);
        int tmp = seg.prod(l, r + 1) + 1;
        ans = max(ans, tmp);
        seg.set(a, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n, long long modvalue) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2, modvalue);
        return t * t % modvalue;
    } else {
        return modpow(m, n - 1, modvalue) * m % modvalue;
    }
}

long long moddiv(long long a, long long b, ll modvalue) { return (a * modpow(b, mod - 2, modvalue)) % modvalue; }

const ll INF = 1LL << 60;

string change_binary(long long a) {
    string ret;
    for (int i = 31; i >= 0; i--) {
        ret += (a >> i & 1) + '0';
    }
    return ret;
}

ll nCkmod(ll n, ll k, ll modvalue) {
    ll numera = 1;
    for (int i = n; i > n - k; i--) {
        numera *= i;
        numera %= modvalue;
    }
    ll denomi = 1;
    REP(i, k) {
        denomi *= (i + 1);
        denomi %= modvalue;
    }
    return moddiv(numera, denomi, modvalue);
}

map<ll, ll> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}
vector<ll> dijkstra(vector<vector<P>> graph, ll s) {
    vector<ll> ans(graph.size(), -1);
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.push({0, s});
    while (pq.size() > 0) {
        ll cur1 = 0;
        ll cur2 = 0;
        if (ans[pq.top().second] != -1) {
            pq.pop();
        } else {
            cur1 = pq.top().first;
            cur2 = pq.top().second;
            pq.pop();
            ans[cur2] = cur1;
            for (ll i = 0; i < graph[cur2].size(); i++) {
                pq.push({cur1 + graph[cur2][i].first, graph[cur2][i].second});
            }
        }
    }
    return ans;
}
vector<string> maze;
ll h, w;
bool check(ll y, ll x) {
    if (x < 0 || x >= w || y < 0 || y >= h || maze[y][x] == '#') {
        return false;
    }
    return true;
}
double p;
long double f(long double x) { return x + p / (pow(2, x / 1.5)); }
ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}
int main() {
    ll n;
    cin >> n;
    vector<ll> t(n);
    ll ans = 1;
    REP(i, n) {
        cin >> t[i];
        ans = ans / gcd(ans, t[i]);
        ans *= t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
<?php
fscanf(STDIN, "%d", $n);
fscanf(STDIN, "%s", $s);
$r['W'] = substr_count($s, 'W') - ($s[0] == 'W');
$r['E'] = $n - 1 - $r['W'];
$l['W'] = 0;
$l['E'] = 0;
$x = $r['E'];
if ($x == 0) exit('0');
for ($i = 1; $i < $n; $i++) {
	$r[$s[$i]]--;
	$l[$s[$i-1]]++;
	$p = $r['E'] + $l['W'];
	if ($p < $x) {
		if (!$p) exit('0');
		$x = $p;
	}
}
echo $x;

Measured memory_bytes: 4984
#include <bits/stdc++.h>
using namespace std;
#define kaage72 main()
#define kaagecute {
#define kaagesocute }
#define kaage int
#define Kaage ;
#define kaAge for
#define kaaGe (
#define kaAgE )
#define kaage long long
#define kaageiscute =
#define KAAGE <
#define KAAge cin>>
#define KAAGe [k]
#define kaagewosort sort(ka.rbegin(),ka.rend())
#define defineiscute [(k+1)/2]
#define kaagehasuhasu cout
#define kaagesyuturyoku << cute << endl
#define kaagedaisuki signed
kaage kaa kaageiscute 0;
using kAage = vector<kaage>;
kaagedaisuki kaage72 kaagecute
    kaage age Kaage
    KAAge age Kaage
    kAage ka(age) Kaage
    kaAge kaaGe kaage k kaageiscute kaa Kaage k KAAGE age Kaage k++ kaAgE
        KAAge ka KAAGe Kaage
    kaagewosort Kaage
    kaage cute kaageiscute kaa Kaage
    kaAge kaaGe kaage k kaageiscute kaa Kaage k KAAGE age-1 Kaage k++ kaAgE
        cute += ka defineiscute Kaage
    kaagehasuhasu kaagesyuturyoku Kaage
kaagesocute

Measured memory_bytes: 4776
N, M = gets.split.map!(&:to_i)
l, r = [], []
while temp = gets do
	l_i, r_i = temp.split.map!(&:to_i)
	l << l_i
	r << r_i
end
l_max = l.max
r_min = r.min
anser = r_min - l_max + 1
puts (anser < 0) ? 0 : anser

Measured memory_bytes: 3504
/* Sudipta Banik Trisha */
/* Sylhet Engineering College */

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

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

	
	


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
	int A1;
	int A2;
	int A3;
	int hasil;
	scanf("%d", &A1);
	scanf("%d", &A2);
	scanf("%d", &A3);
	
	if( A1 + A2 + A3 >= 22){
		hasil = A1 + A2 + A3;
		printf("bust\n");
	}
	else {
		hasil = A1 + A2 + A3;
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 1624
#include <iostream>

using namespace std;
 
int main(){
    int N,M,P;
 
    while(true){
	cin >> N >> M >> P;
	if(!N && !M && !P) break;
	int nm[101],sum = 0;
	for(int i = 0 ; i < N ; i++){
	    cin >> nm[i];
	    sum += nm[i];
	}
	if(!nm[M-1]){
	    cout << '0' << endl;
	    continue;
	}
	int money = sum*(100-P)/nm[M-1];
	cout << money << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define input_output freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)

using namespace std;

ll power(ll base, ll exp)
{
	if (exp == 0)
		return 1;
	if (exp % 2 == 1)
	{
		return base * power(base, exp - 1);
	}
	else
	{
		long half = power(base, exp / 2);
		return half * half;
	}
}

int main()
{
	//input_output;
	the_flash;
	int a;
	cin >> a;
	int sum = 0;
	
	for (int i = 1; i <= 3; i++)
		sum += power(a, i);
	
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3620