akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


template<class T>
class segment_tree_t {
public:
  segment_tree_t(int size) : size_(1) {
    while (size_ < size)
      size_ *= 2;

    a_ = new T[size_ * 2];

    memset(a_, 0, sizeof(T) * size_ * 2);
  };

  ~segment_tree_t() {
    delete[] a_;
  };

public:
  void update(int i, T x) {	// 0-index
    i += size_ - 1;

    a_[i] = x;

    while (i > 0) {
      i = (i - 1) / 2;

      a_[i] = a_[i * 2 + 1] + a_[i * 2 + 2];
    }
  };

  T query(int a, int b, int i = -1, int l = -1, int r = -1) {	// [a, b)
    if (i < 0) {
      return query(a, b, 0, 0, size_);
    }
    else {
      if (r <= a || b <= l)
        return 0;

      if (a <= l && r <= b) {
        return a_[i];
      }
      else {
        return
          query(a, b, i * 2 + 1, l, (l + r) / 2) +
          query(a, b, i * 2 + 2, (l + r) / 2, r);
      }
    }
  };

private:
  int size_;

  T* a_;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, K, a[222222];

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  long long s = 0, t = 0;

  std::multiset<long long> set;

  segment_tree_t<long long> tree(N);

  for (int i = 0; i < N; i ++) {
    s += a[i];
    t += K;

    set.insert(s - t);

    tree.update(i, 1);
  }

  std::map<long long, std::vector<int>> map;

  int ind = 0;
  
  for (const auto& i : set)
    map[i].push_back(ind ++);

  for (auto& kv : map)
    std::reverse(ALL(kv.second));

  s = t = 0;

  long long c = 0;

  for (int i = 0; i < N; i ++) {
    auto it = set.lower_bound(s - t);

    if (it != std::end(set)) {
      assert(! map[*it].empty());
      
      c += tree.query(map[*it].back(), N);
    }

    s += a[i];
    t += K;

    set.erase(set.find(s - t));

    assert(! map[s - t].empty());

    int x = map[s - t].back(); map[s - t].pop_back();

    tree.update(x, 0);
  }

  std::cout << c << std::endl;

  return 0;
}


Measured memory_bytes: 36352
#include<cstdio>
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int n,p,cnt1;
typedef long long ll;
ll ans;
ll pow2(int n)
{
	ll x=1;
	f(i,1,n)x*=2;
	return x;
}
int main()
{
	int x;
	scanf("%d%d",&n,&p);
	f(i,1,n)
	{
		scanf("%d",&x),x%=2;
		cnt1+=x;
	}
	if(p==0&&cnt1==0)ans=pow2(n);
	else if(cnt1==0)ans=0;
	else ans=pow2(n-1);
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

int nNode, nEdge;
vector<int> g[100000+10];
bool visited[100000+10];
int dp[100000+10];

void go(int u, vector<int>& topo) {
  if(visited[u]) {
    return;
  }
  visited[u] = true;
  for(int v : g[u]) {
    go(v, topo);
  }
  topo.push_back(u);
}

int main(void) {
  scanf("%d%d", &nNode, &nEdge);
  REP(iEdge, nEdge) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u-1].push_back(v-1);
  }
  vector<int> topo;
  REP(i, nNode) {
    go(i, topo);
  }
  assert((int)topo.size() == nNode);
  int maxi = 0;
  REP(i, nNode) {
    int u = topo[i];
    for(int v : g[u]) {
      dp[u] = max(dp[u], dp[v] + 1);
    }
    maxi = max(maxi, dp[u]);
  }
  cout << maxi << endl;
  return 0;
}


Measured memory_bytes: 8824
<?php

while( fscanf(STDIN, "%d %s %d", $a, $op, $b)){
      
    if($op == "?")
        break;
    
        switch($op){
            case "+": $c = $a + $b; break;
            case "-": $c = $a - $b; break;
            case "*": $c = $a * $b; break;
            case "/": $c = floor($a / $b); break;
        }
        echo $c."\n";
}


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

int wear[200][3], day[200];
int mem[200][200];
int D, N;
int dp(int d, int b)
{
  if(d == D)
    return 0;
  if(mem[d][b] != -1)
    return mem[d][b];
  int ans = 0;
  for(int i = 0; i < N; i++)
  {
    if(wear[i][0] <= day[d] && wear[i][1] >= day[d])
      ans = max(ans, dp(d + 1, i) + abs(wear[i][2] - wear[b][2]));
  }
  mem[d][b] = ans;
  return ans;
}

int main()
{
  for(int i = 0; i < 200; i++)
    for(int j = 0; j < 200; j++)
      mem[i][j] = -1;

  cin >> D >> N;
  for(int i = 0; i < D; i++)
    cin >> day[i];
  for(int i = 0; i < N; i++)
    cin >> wear[i][0] >> wear[i][1] >> wear[i][2];
  int ans = 0;
  for(int i = 0; i < N; i++)
  {
    if(wear[i][0] <= day[0] && wear[i][1] >= day[0])
      ans = max(ans, dp(1, i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1332
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>


using namespace std;

int covered(vector<char> a, vector<char> b) {
    int n = a.size()-1;

    while(a[n]=='.' && n>0) {
        n--;
    }

    /*for(int i = 0; i < a.size(); i++) {
        printf("%c ", a[i]);
    }
    printf("\n");
    for(int i = 0; i < a.size(); i++) {
        printf("%c ", b[i]);
    }
    printf("[%d]\n", n);*/

    // #がない
    if(n >= a.size()) return -1;
    // 上の段の#よりも左側に#がある
    for(int i = 0; i < n; i++) {
        if(b[i]=='#') return -1;
    }

    return 1;
}

int main() {
    int h, w;
    cin >> h; cin >> w;

    vector<vector<char>> board;
    for(int i = 0; i < h; i++) {

        vector<char> row;
        for(int j = 0; j < w; j++) {
            char a; cin >> a;
            row.push_back(a);
        }
        board.push_back(row);
    }

    for(int i = 0; i < h-1; i++) {
        vector<char> a = board[i];
        vector<char> b = board[i+1];

        if(covered(a,b) == -1) {
            cout << "Impossible" << endl;
            return 0;
        }
    }

    cout << "Possible" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define pb push_back
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define bump cout<<"bleh\n"
#define all(v) (v).begin(),(v).end()

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;
const ll infll=1e15;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n,k;
    cin>>n>>k;

    int ans=0;

    while(n){
        n/=k;
        ans++;
    }

    cout<<ans<<"\n";

    return 0;
}


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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  inline T root(T x)
  {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  inline bool same(T x, T y)
  {
    return root(x) == root(y);
  }

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

int r, d, x2000;

void input()
{
  cin >> r >> d >> x2000;
}

void solve()
{
  int xi = r*x2000 - d;
  for(int i = 1; i <= 10; i++)
  {
    if(i == 10) cout << xi;
    else cout << xi << '\n';
    xi = r*xi - d;
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
//string sort (s.begin(),s.end());

main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int a[n+10];
	for(int i=0;i<n;i++)
    {
        cin>>a[i];

    }
    sort(a,a+n);

    int mid1=(a[n-1]+a[0])/2;
    int mid2=((a[n-1]+a[0])/2)+ 1;
    int mid3=((a[n-1]+a[0])/2)-1;
    //cout<<mid<<endl;
    int sum1=INT_MAX;

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

        temp +=(j-a[i])*(j-a[i]);

    }
      sum1=min(temp,sum1);

    }
    cout<<sum1<<endl;








}



Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int saidaikouyakusuu(int a,int b){
    if(b==0) return a;
    return saidaikouyakusuu(b,a%b);
}
int saisyoukoubaisuu(int a,int b){
    return a*b/saidaikouyakusuu(a,b);
}
int n,m,cnt=0,aa[220000],d,ab[500][50],ac[500],ad[50];
pair<int,int> pp[220000];
string s,ss[220000];
char c;
queue<int> que;
signed main(){
    cin>>d;
    rep(i,26){
        cin>>aa[i];
    }
    rep(i,d){
        rep(j,26){
            cin>>ab[i][j];
        }
    }
    rep(i,d){
        cin>>ac[i];
        cnt+=ab[i][ac[i]-1];
        rep(j,26){
            if(j==ac[i]-1){
                ad[j]=0;
            }else{
                ad[j]++;
                cnt-=ad[j]*aa[j];
            }
        }
        cout<<cnt<<endl;
    }
}

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

int main(){
   int x,y;
   cin >> x >> y;
   if (x > y){
      cout << "a > b" << endl;
   }
   else if (x == y){
      cout << "a == b" << endl;
   }
   else{
      cout << "a < b" << endl;
}
}

Measured memory_bytes: 3096
import sys
sys.setrecursionlimit(10**6)
from heapq import heappop, heappush

def find(x):
    if x == pair_lst[x]:
        return x
    else:
        tmp = find(pair_lst[x])
        pair_lst[x] = tmp
        return tmp
x=[]
y=[]
z=[]
r=[]
def kr():
    que=[]
    for i in range(n-1):
        for j in range(i+1,n):
            wi=((x[i]-x[j])**2+(y[i]-y[j])**2+(z[i]-z[j])**2)**0.5
            wi=max(0,wi-r[i]-r[j])        
            heappush(que,(wi,i,j))
    length_sum = 0
    while que:
        w, s, t = heappop(que)
        root_s = find(s)
        root_t = find(t)
        if root_s != root_t:
            pair_lst[root_s] = root_t
            length_sum += w
    return length_sum

while True:
    n=int(input())
    x=[0.0]*n
    y=[0.0]*n
    z=[0.0]*n
    r=[0.0]*n
    pair_lst = [i for i in range(n)]
    
    if n==0:
        sys.exit()
    for i in range(n):
        x[i],y[i],z[i],r[i]=map(float,input().split())
    print("{:.3f}".format(kr()))



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

int main() {
  int64_t n;
  std::cin >> n;
  int64_t len = 0;

  for (int64_t i = 0; i < n; i++) {
    int64_t l, r;
    std::cin >> l >> r;
    len += r - l + 1;
  }

  std::cout << len << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long res;
int main(){
  int n,t;
  cin>>n;
  t=2*n;
  int a[t];
  int i;
  for(i=0;i<t;i++) cin>>a[i]; 
  sort(a,a+t);
  for(i=0;i<t;i++) if(i%2==0) res+=a[i];  
  cout<<res;
  return 0;
}

Measured memory_bytes: 256
def main():
    h, w = map(int, input().split())

    a = []
    for i in range(h):
        a.append(input())

    count = 0

    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                count += 1

    if count == h + w - 1:
        print("Possible")
    else:
        print("Impossible")


'''
    for i in range(h):
        a.append(input()+'.')

    a.append('.' * (w-1))

    print(a)
    i = 0
    j = 0
    while True:
        if last == 'up':
            if a[i+1][j] == '#' and a[i][j+1] == '.':
                last = 'up'
                i += 1
            elif a[i+1][j] == '.' and a[i][j+1] == '#':
                last = 'left'
                j += 1
            else:
                print('Impossible')
                return 0
        if i == h-1 and j == w-1:
            break
        print(i, j)

    print('Possible')
    return 0
'''

if __name__ == "__main__":
    main()


'''

possible判定条件

前のコマの位置（左or上）以外は右or下のみに#がある
コマの移動はすべて連続である
コマの移動数はH+W-1である

'''


Measured memory_bytes: 61704
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long int ll;

int main()
{
    int X, Y;
    cin >> X >> Y;
    int b = Y - 2 * X;

    if (2 * X <= Y && Y <= 4 * X && Y % 2 == 0 && b % 2 == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main() {
    int a,i,b,c[100],d,e;
    e=0;
    d=0;
    b=0;
    cin>>a;
    for (i=0;i<a;i++){
        cin>>c[i];
        
        if (b<=c[i]){
            b=c[i];
        }
    }
    
    
    for (i=0;i<a;i++){
        if (c[i]==b){
            e=e+1;
        }
        if (c[i]!=b){
            d=c[i]+d;
        }
    }
    d=d+b*(e-1);
    if (d>b){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    r = 0
    if False:
        for i in range(K+1):
            r += (A[-i-1] - A[i]) * cmb(N-i-1, K-1, mod)
    else:
        for i in range(N-K+1):
            r += (A[N-i-1] - A[i]) * cmb(N-i-1, K-1, mod)
 
    print(r % mod)
def cmb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, 10 ** 6 + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


main()



Measured memory_bytes: 133000
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int gcd(int a, int b) {
    if (a < b) {
        swap(a, b);
    }

    int r = a%b;
    while (a%b > 0) {
        a = b;
        b = r;
        r = a%b;
    }

    return b;
}

int main() {
    int N, X;
    cin >> N >> X;

    vector<int> d(N);

    int first;
    cin >> first;
    int ans = abs(X-first);
    for (int i = 1; i < N; ++i) {
        int tmp;
        cin >> tmp;

        if (ans) {
            ans = min(ans, gcd(ans, abs(tmp-first)));
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	string s, a, b;
	cin >> s;
	a = s[0];
	a = a + s[1];
	b = s[2];
	b = b + s[3];

	if (a > "12"||a=="00") {
		if (b > "12" || b == "00")cout << "NA" << endl;
		else cout << "YYMM" << endl;
	}
	else if (b > "12" || b == "00")cout << "MMYY" << endl;
	else cout << "AMBIGUOUS" << endl;


	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char rings[101][101];
char input[101];

int main(void)
{
    int i, n, len, ans = 0;
    scanf("%s%d", input, &n);
    for (i = 0; i < n; i++) {
        scanf("%s", rings[i]);
        len = strlen(rings[i]);
        strcpy(rings[i]+len, rings[i]);
        if (strstr(rings[i], input) != NULL) {
            ans++;
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 628
import math
input = raw_input

def fctr1(n): 
    f=[]
    c=0
    r=int(n**0.5)
    for i in range(2,r+2):
        while n%i==0:
            c+=1
            n=n//i
        if c!=0:
            f.append([i,c])
            c=0
    if n!=1:
        f.append([n,1])
    return f

def find_max(x):
    n0 = int(math.sqrt(2*x))

    if 2 * x < n0 * (n0+1):
        while True:
            n1 = n0 - 1
            if 2 * x >= n1 * (n1+1):
                return n1
            n0 = n1 
    else:
        while True:
            n1 = n0 + 1
            if 2 * x < n1 * (n1+1):
                return n0
            n0 = n1 

    #n0 = (-1 + math.sqrt(1+9*x)) // 2
    #n0 = int(n0)
    #return n0

n = int(input())

pairs = fctr1(n)

out = 0
for p, num in pairs:
    x0 = find_max(num)
    out += x0
print(out)

Measured memory_bytes: 66380
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int D[40][40],C[600][600],n,c,P[3][40],ans=2147483647;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>c;
	for (int i=1;i<=c;i++)
		for (int j=1;j<=c;j++)
			cin>>D[i][j];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			cin>>C[i][j];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			for (int k=1;k<=c;k++)
				P[(i+j)%3][k]+=D[C[i][j]][k];
	for (int i=1;i<=c;i++)
		for (int j=1;j<=c;j++)
			for (int k=1;k<=c;k++)
				if (i!=j&&i!=k&&j!=k)
					ans=min(ans,P[0][i]+P[1][j]+P[2][k]);
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
  
int main()
{
     ll n,d;
     cin>>n>>d;
     int ans=0;
     for( int i=1;i<=n;i++ )
	{
		ll x,y;cin>>x>>y;
		if( x*x+y*y<=d*d ) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program {
    static void Main(string[] args) {
        //入力
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();

        //計算
        //[0, i)のWの個数を計算する
        int[] vw = new int[N + 1];
        for (int i = 0; i < N; i++) {
            vw[i + 1] += vw[i];
            if (S[i] == 'W') {
                vw[i + 1]++;
            }
        }

        //[0, i)のEの個数を計算する
        int[] ve = new int[N + 1];
        for (int i = 0; i < N; i++) {
            ve[i + 1] += ve[i];
            if (S[i] == 'E') {
                ve[i + 1]++;
            }
        }

        //答えとなる数値
        int ans = 999999999;

        //検証
        for (int i = 0; i < N; i++) {
            int now = vw[i] + (ve[N] - ve[i + 1]);
            ans = Math.Min(ans, now);
        }

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 14432
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n = I()
    if '7' in str(n):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int main(){
    string s;
    cin >> s;
    bool ok = true;
    if(s.size()%2==0){
        for(int i = 0; i < s.size()/2; i++){
            if(s[2*i]=='h'&&s[2*i+1]=='i'){
                continue;
            }else{
                ok = false;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }

    }

    cout << "No" << endl;
    return 0;
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(n*a<=b)
		cout<<n*a;
	else
		cout<<b;
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int a = std.nextInt();
        int b = std.nextInt();
        if (a + b == 15) {
            System.out.println("+");
        } else if (a * b == 15) {
            System.out.println("*");
        } else {
            System.out.println("x");
        }
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] nkq = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = nkq[0];
            long k = nkq[1];
            long q = nkq[2];

            long[] a = new long[n + 1];
            
            for(int i = 1; i <= q; i++)
            {
                long current = long.Parse(Console.ReadLine());
                a[current]++;
            }

            for (int i = 1; i <= n; i++)
            {
                if(k - (q - a[i]) > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }

        }
    }
}


Measured memory_bytes: 18396
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<set<int> > alph(26);
	vector<int> ind(n);

	for (int i = 0; i < n; ++i)
	{
		alph[s[i] - 'a'].insert(i);
		ind[i] = s[i] - 'a';
	}

	int q; cin >> q;
	for (int i = 0; i < q; ++i)
	{
		int x; cin >> x;
		if (x == 1) {
			int i; char c; cin >> i >> c; i--;
			alph[ind[i]].erase(i);
			alph[c - 'a'].insert(i);
			ind[i] = c - 'a';
		}
		else {
			int l, r; cin >> l >> r;
			int ans = 0;
			for (int i = 0; i < 26; ++i)
			{
				if (alph[i].lower_bound(l-1) != alph[i].upper_bound(r-1)) ans++;
			}
			cout << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 26244
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
input=input.toLowerCase();
var Arr=(input.trim()).split("\n");
var W=Arr[0];
var ctn=0;
for(i=1;i<Arr.length;i++){
   if(Arr[i]==="END_OF_TEXT")break;
   var arr=Arr[i].split(" ");
   arr.forEach(function(v,i){
      if(v==W)ctn++;
   });
}
console.log(ctn);

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

bool is_prime(int n) {
  if (n<2) return false;
  for (int i=2; i*i<=n; i++) {
    if (n%i == 0) return false;
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  while (true) {
    if (is_prime(x)) {
      cout << x << endl;
      break;
    }
    x++;
  }
}

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

using namespace std;

const int SHIFT = 10000;
const int INF = 1 << 29;

int N, A, B, C, M;
int color[10000], small[10005];
vector< int > g[10005];
pair< int, int > v[3][10005];

void solve(int start, int id)
{
  queue< int > que;
  v[id][start] = {0, small[start]};
  que.emplace(start);
  while(!que.empty()) {
    int p = que.front();
    que.pop();
    for(auto &to : g[p]) {
      if(v[id][p].first + 1 == v[id][to].first) {
        v[id][to].second = min(v[id][to].second, v[id][p].second);
      } else if(v[id][p].first + 1 < v[id][to].first) {
        v[id][to] = {v[id][p].first + 1, min(small[to], v[id][p].second)};
        que.emplace(to);
      }
    }
  }
}

int main()
{
  memset(color, -1, sizeof(color));
  fill_n(small, 10005, INF);

  scanf("%d %d %d %d", &N, &A, &B, &C);
  for(int i = 0; i < N; i++) small[i] = i;
  for(int i = 0; i < A + B + C; i++) {
    int K;
    scanf("%d", &K);
    --K;
    if(i < A) color[K] = 0;
    else if(i < A + B) color[K] = 1;
    else color[K] = 2;
    small[color[K] + SHIFT] = min(small[color[K] + SHIFT], K);
  }

  scanf("%d", &M);
  while(M--) {
    int a, b;
    scanf("%d %d", &a, &b);
    --a, --b;
    if(~color[a]) a = color[a] + SHIFT;
    if(~color[b]) b = color[b] + SHIFT;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  fill_n(*v, 3 * 10005, make_pair(INF, INF));
  solve(SHIFT, 0);
  solve(SHIFT + 1, 1);
  solve(SHIFT + 2, 2);

  vector< int > vertex;
  vertex.push_back(SHIFT);
  vertex.push_back(SHIFT + 1);
  vertex.push_back(SHIFT + 2);
  for(int i = 0; i < N; i++) {
    if(~color[i]) continue;
    vertex.push_back(i);
  }
  int ret = 114514, beet;
  for(auto &i : vertex) {
    int cost = v[0][i].first + v[1][i].first + v[2][i].first;
    int latte = min({v[0][i].second, v[1][i].second, v[2][i].second});
    if(cost < ret) ret = cost, beet = latte;
    else if(cost == ret) beet = min(beet, latte);
  }
  printf("%d %d\n", ret, beet + 1);
}

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


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


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vi r(a);
	vi g(b);
	vi m(c);

    fi(0, a)
    	cin >> r[i];
    sort(all(r));
    reverse(all(r));
    while (r.size() != x)
    	r.pop_back();

    fi(0, b)
    	cin >> g[i];
    sort(all(g));
    reverse(all(g));
    while (g.size() != y)
    		g.pop_back();
    fx(xx, g)
    	r.push_back(xx);

    fi(0, c) {
    	int xx;
    	cin >> xx;
    	r.push_back(xx);
    }
    sort(all(r));
    int sum = 0;
    fi(siz(r) - x - y, siz(r))
    	sum += r[i];
 
    cout << sum << '\n';
}

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> L(N);
  for(int i=0; i<N; i++){
    cin >> L[i];
  }

  int p = 0;
  int cnt = 1;
  for(int i=0; i<N; i++){
    p += L[i];
    if(p <= X){
      cnt++;
    }else{
      break;
    }
  }  
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define bcnt(n) __builtin_popcountll(n)

using ll = long long;  // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using mll = map<long long, long long>;
using pll = pair<long long, long long>;
using sll = set<long long>;
using vpll = vector<pair<long long, long long>>;
using mlv = map<long long, vector<long long>>;

int main() {
	ll n;
	cin >> n;
	vll a(n);
	rep(i, n) cin >> a[i];
	vvll dp(n + 1, vll(n + 1, 0));
	rep(i, n + 1) dp[i][i] = 0;
	rep(i, n) {
		rep(j, n) {
			if(i + 1 + j > n) break;

			dp[j][i + 1 + j] = max(a[i + j] - dp[j][i + j], a[j] - dp[j + 1][i + 1 + j]);
		}
	}
	// dp[i][j]は[i,j)でその時点の先手が得る点数
	// rep(i, n) {
	// 	rep(j, n + 1) { cout << dp[i][j] << " "; }
	// 	cout << endl;
	// }
	cout << dp[0][n] << endl;
}


Measured memory_bytes: 70912
#include<iostream>
#include<string.h>
using namespace std;

int main()
{
  int N,i;
  cin>>N;
  for(i=9;i>0;i--)
  {
  if(N%i==0)
  {
    if(N/i<10){
      cout<<"Yes";
      break;}
    else{
      cout<<"No";
      break;}
  }
  }
}

Measured memory_bytes: 256
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim n As Long = NextLong()
        Dim m As Long = NextLong()
        Dim s As String = NextString()
        Dim t As String = NextString()
        Dim l As Long = LCM(n, m)
        Dim dic As New Dictionary(Of Long, Char)


        For i As Integer = 0 To Len(s) - 1
            Dim j As Long = i * l \ n
            dic(j) = s(i)
        Next

        For i As Integer = 0 To Len(t) - 1
            Dim j As Long = i * l \ m
            If dic.ContainsKey(j) AndAlso dic(j) <> t(i) Then
                WriteLine(-1)
                Return
            End If
        Next

        WriteLine(l)
    End Sub

    Function LCM(x As Long, y As Long) As Long
        Return x * y \ GCD(x, y)
    End Function

    Function GCD(x As Long, y As Long) As Long
        If x < y Then
            Return GCD(y, x)
        ElseIf y = 0 Then
            Return x
        Else
            Return GCD(y, x Mod y)
        End If
    End Function

    Function NextLong() As Long
        Return CLng(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function
End Module


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



int main(void){
    int n;
    int i;
    int cnt = 0;
    int tmpcnt = 0;
    int a;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a);
        if (a % 4 == 0){
            cnt++;
        }
        if (a % 4 != 0 && a % 2 == 0){
            tmpcnt++;
        }
    }

    if (cnt*2+1 >= n){
        printf("Yes\n");
        return 0;
    }
    if (n-cnt*2 == tmpcnt){
        printf("Yes\n");
        return 0;
    }

    printf("No\n");

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	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

	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
	{
		int a = s[i] - 'A' + 1;
		a += n;
		if (a >= 27)
			a++;
		a %= 27;
		// a++;
		char c = 'A' - 1 + a;
		s[i] = c;
	}
	cout << s;
	return 0;
}



Measured memory_bytes: 3624
import numpy as np
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
ac = np.zeros(N, dtype=np.int)
wa = np.zeros(N, dtype=np.int)
for n in range(M):
    p, S = input().split()
    p = int(p)
    if ac[p - 1] == 1:
        continue
    if S == 'AC':
        ac[p - 1] = 1
    else:
        wa[p - 1] += 1
wa = str(sum(wa * ac))
ac = str(sum(ac))
ans = ac + ' ' + wa
print(ans)


Measured memory_bytes: 14672
#include <bits/stdc++.h>
using namespace std;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;


const ll modo=1e9+7;
const ll inf=1e16;
const ll ms=(2e5) +5;



int main()
{
    idfc;
    ll a,b;
    cin>>a>>b;
    if(a==1||b==1)
    {
        cout<<1;
        return 0;
    }
    ll tt=2;
    ll ans=(a*b)/tt;

    if((a%tt)&&(b%tt))ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
m=1001
A=range(9)
d=[[0]*m for i in A]
for i in range(101):
  for j in A[1:][::-1]:
    for k in range(m-i): d[j][k+i]+=d[j-1][k]
  d[0][i]=1
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  print d[n-1][s]

Measured memory_bytes: 4384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll x, t;
    cin >> x >> t;
    cout << max((ll)0, x - t) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
long long int DP(long long int n);
long long int n, a, b, c, d;
map<long long int, long long int> mp;
int main() {

	//Agc044_a

	int t;
	cin >> t;
	int i;
	for (i = 0; i < t; i++) {

		mp.clear();
		cin >> n >> a >> b >> c >> d;
		cout << DP(n) << endl;
	}
	return 0;

}
long long int DP(long long int n) {
	if (n == 0) {
		return 0;
	}
	if (n == 1) {
		return d;
	}
	if (mp[n] > 0) {
		return mp[n];
	}

	long long int minnum = 1000000000000000000;
	  //cout << d << endl;
	if (n < minnum / d) {
		minnum = n * d;
	}

	if (DP((n - (n % 2)) / 2) + d * (n % 2) + a < minnum) {
		minnum = DP((n - n % 2) / 2) + d * (n % 2) + a;
	}
	if (DP((n + (n % 2)) / 2) + d * (n % 2) + a < minnum) {
		minnum = DP((n + n % 2) / 2) + d * (n % 2) + a;
	}
	if (DP((n - (n % 3)) / 3) + d * (n % 3) + b < minnum) {
		minnum = DP((n - (n % 3)) / 3) + d * (n % 3) + b;
	}
	if (DP((n + (3 - (n % 3))) / 3) + d * (3 - (n % 3)) + b < minnum) {
		minnum = DP((n + (3 - (n % 3))) / 3) + d * (3 - (n % 3)) + b;
	}
	if (DP((n - (n % 5)) / 5) + d * (n % 5) + c < minnum) {
		minnum = DP((n - (n % 5)) / 5) + d * (n % 5) + c;
	}
	if (DP((n + (5 - (n % 5))) / 5) + d * (5 - (n % 5)) + c < minnum) {
		minnum = DP((n + (5 - (n % 5))) / 5) + d * (5 - (n % 5)) + c;
	}
	mp[n] = minnum;
	return minnum;

}

Measured memory_bytes: 4620
N,A,B = map(int,input().split())
S = input()
Acount = 0
Bcount = 0
for i in range(len(S)):
  if(S[i] == "a"):
    if(Acount + Bcount < A + B):
      print("Yes")
      Acount += 1
    else:
      print("No")
  elif(S[i] == "b"):
    if(Acount + Bcount < A + B and Bcount < B):
      print("Yes")
      Bcount += 1
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 4016
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)


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

	std::vector<int> X;

	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		X.push_back(x);
	}
	long long sum = 0;
	long long la = a;
	long long lb = b;
	for (int i = 0; i < n - 1; ++i) {
		int d = X[i + 1] - X[i];
		if (la*d > lb) {
			sum += b;
		}
		else {
			sum += la * d;
		}
	}
	printf("%lld", sum);

	return 0;
}


Measured memory_bytes: 892
from collections import defaultdict

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
a = readInts()
rate = [0]*9


for i in a:
  rate[min(i//400,8)]+=1
base = 8-rate[:-1].count(0)
ma = base+rate[-1]
print(max(base,1),ma)


Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<string>vec;

int main(){
  ll f[100009];
  int n;
  cin>>n;
  f[0]=0;
  for(int i=1;i<=n;i++){
    f[i]=f[i-1]+i;
  }
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    vec.push_back(s);
  }
  sort(vec.begin(),vec.end());
  ll ans=0;
  int cnt=0;
  for(int i=0;i<n-1;i++){
    if(vec[i]==vec[i+1]){
      cnt++;
    }
    else{
      ans+=f[cnt];
      cnt=0;
    }
  }
  if(cnt>0){
    ans+=f[cnt];
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 6516
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  string s, t;
  cin >> s >> t;

  REP(i, s.size()){
    if(s == t) { cout << "Yes" << endl; return 0;}
    char c = s[0];
    //cout << c << endl;
    REP(j, s.size()-1){
      s[j] = s[j+1];
    }
    s[s.size()-1] = c;
    //cout << s << endl;
  }

  cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
// solution is at the bottom

import kotlin.math.*

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }


fun main() {
    val s = read()
    var sum = 0
    for (c in s) {
        val digit = c.toInt() - '0'.toInt()
        sum += digit
    }

    if (sum % 9 == 0) {
        println("Yes")
    } else {
        println("No")
    }
}

Measured memory_bytes: 35072
n = int(input())
a = list(map(int, input().split()))
b = set(a)
c = sorted(list(b))
if len(b)==1 and c[0]==0:
  print("Yes")
  exit()
elif n%3!=0:
  print("No")
  exit()
elif len(b)==2:
  if c[0]==0 and a.count(c[0])==n//3 and a.count(c[1])==(n//3)*2:
    print("Yes")
    exit()
elif len(b)==3:
  p, q, r = c[0], c[1], c[2]
  if p^q==r or q^r==p or r^p==q:
    if a.count(c[0])==n//3 and a.count(c[1])==n//3 and a.count(c[2])==n//3:
      print("Yes")
      exit()
print("No")

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

int main(void) {
  int N, X;
  cin >> N >> X;

  int m;
  int mini = 1010;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> m;
    sum += m;
    mini = min(mini, m);
  }

  cout << (X - sum) / mini + N << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>

typedef long long ll;

using namespace std;

int main(void)
{
    string str;

    cin >> str;
    int ans = 0;
    if (str == "SUN") {
        ans = 7;
    } else if (str == "MON") {
        ans = 6;
    } else if (str == "TUE") {
        ans = 5;
    } else if (str == "WED") {
        ans = 4;
    } else if (str == "THU") {
        ans = 3;
    } else if (str == "FRI") {
        ans = 2;
    } else if (str == "SAT") {
        ans = 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	nextReader = newScanner()
	n := nextInt()
	a := nextInts(n - 1)

	m := make(map[int]int)
	for _, v := range a {
		m[v]++
	}
	for i := 1; i <= n; i++ {
		fmt.Println(m[i])
	}
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 14492
#include<stdio.h>

int main(){
	int height[10];
	int i,j,temp;
	for(i = 0; i < 10; i++){
		scanf("%d",&height[i]);
	}
	
	for(i = 0; i < 10; i++){
		for(j = 0; j < 10; j++){
			if(height[i] > height[j]){
				temp = height[i];
				height[i] = height[j];
				height[j] = temp;
			}
		}
	}

	for(i = 0; i < 3; i++){
		printf("%d\n",height[i]);
	}
	return 0;
}

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

ans = ""


while n > 0:
    x = n % 26
    if x == 0:
        ch = 'z'
        ans += ch
        n -= 1
        n //=26
        continue
    else:
        ch = chr(122-(26-x))
    ans += ch
    n //= 26
    

res = ''
for i in range(len(ans)-1, -1, -1):
    res+=ans[i]

print(res)

Measured memory_bytes: 8912
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int n = Integer.parseInt(br.readLine());
			for (int i=0;i<n;i++) {
				int b[] = {0,0,0};
				int score = 0;
				int outcount = 0;
				while (outcount<3) {
					String op = br.readLine();
					if (op.equals("HIT")) {
						if (b[2]==1) {
							score++;
							b[2] = 0;
						}
						if (b[1]==1) {
							b[2] = 1;
							b[1] = 0;
						}
						if (b[0]==1) {
							b[1] = 1;
						}
						b[0] = 1;
					} else if (op.equals("HOMERUN")) {
						score++;
						for (int j=0;j<3;j++) {
							if (b[j]==1) {
								score++;
								b[j] = 0;
							}
						}
					} else if (op.equals("OUT")) outcount++;
				}
				System.out.println(score);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 16844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD (int)1e9+7
#define INF 1e15
typedef pair<int, int> P;
int a[5], k;
signed main() {
	rep(i, 5)cin >> a[i];
	sort(a, a + 5);
	cin >> k;
	if (a[4] - a[0] <= k)puts("Yay!");
	else puts(":(");
	return 0;
}

Measured memory_bytes: 256