akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

const int inf=1<<29;
int w,h,f,m,o;
int c[10][10],dp[11][10][51][10][10];

int main(){
	while(cin>>w>>h,w){
		cin>>f>>m>>o;
		rep(i,h)rep(j,w)cin>>c[i][j];
		
		rep(i,h+1)rep(j,w)rep(k,m+1)rep(l,w)rep(r,w)dp[i][j][k][l][r]=inf;
		rep(i,w)dp[0][i][o][i][i]=0;
		
		rep(i,h)rep(range,w)for(int k=m;k>1;k--)
		rep(it,2)rep(l,w-range)rep(x,range+1){
			int r=l+range,j=it?l+x:r-x,cost=dp[i][j][k][l][r];
			if(cost==inf)continue;
			
			if(c[i][j]>0){
				int sanso=min(m,k-1+c[i][j]);
				dp[i+1][j][sanso][j][j]=min(dp[i+1][j][sanso][j][j],cost);
			}
			else{
				dp[i+1][j][k-1][j][j]=min(dp[i+1][j][k-1][j][j],cost-c[i][j]);
			}
			if(i==0)continue;
			if(j>0){
				if(l<j)dp[i][j-1][k-1][l][r]=min(dp[i][j-1][k-1][l][r],cost);
				else{
					if(c[i-1][j-1]>0){
						int sanso=min(m,k-1+c[i-1][j-1]);
						dp[i][j-1][sanso][l-1][r]=min(dp[i][j-1][sanso][l-1][r],cost);
					}
					else{
						dp[i][j-1][k-1][l-1][r]=
						min(dp[i][j-1][k-1][l-1][r],cost-c[i-1][j-1]);
					}
				}
			}
			if(j<w-1){
				if(j<r)dp[i][j+1][k-1][l][r]=min(dp[i][j+1][k-1][l][r],cost);
				else{
					if(c[i-1][j+1]>0){
						int sanso=min(m,k-1+c[i-1][j+1]);
						dp[i][j+1][sanso][l][r+1]=min(dp[i][j+1][sanso][l][r+1],cost);
					}
					else{
						dp[i][j+1][k-1][l][r+1]=
						min(dp[i][j+1][k-1][l][r+1],cost-c[i-1][j+1]);
					}
				}
			}
		}
		int ans=inf;
		rep(i,w)for(int j=1;j<=m;j++)rep(l,w)rep(r,w)ans=min(ans,dp[h][i][j][l][r]);
		if(ans>f)cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    n = int(input())
    dic = {}
    mx = 0
    for i in range(n):
        s = input()
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
        mx = max(mx,dic[s])
    l = []
    for k,v in dic.items():
        if v == mx:
            l.append(k)
    l.sort()
    for i in range(len(l)):
        print(l[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 32152
#include <iostream>
#include <queue>

using namespace std;

int n,u,k,v,x;
int a[101][101]={};
int d[101]={0};
queue<int> q;

int main()
{
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> u >> k;
        u-=1;
        for(int j=0;j<k;j++)
        {
            cin >> v;
            v-=1;
            a[u][v]=1;
        }
    }
    q.push(0);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        for(int i=0;i<n;i++)
        {
            if(a[x][i]==0) continue;
            if(d[i]!=0) continue;
            d[i]=d[x]+1;
            q.push(i);
        }
    }
    cout << 1 << " " << 0 << endl;
    for(int i=1;i<n;i++)
    {
        cout << i+1 << " ";
        if(d[i]==0) cout << -1;
        else cout << d[i];
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_A&lang=ja

int main() {
    int n; cin >> n;
    int A[n]; REP(i, n) cin >> A[i];

    set<int> s;
    for (int msk = 0; msk < 1<<n; msk++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (msk & (1<<i)) sum+=(A[i]);
        }
        s.insert(sum);
    }


    int q; cin >> q;
    REP(i, q) {
        int t; cin >> t;
        if (s.count(t)) {
            cout << "yes" << "\n";
        } else {
            cout << "no" << "\n";
        }
    }


    return 0;
}


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


map<int,int>Map;
int N[8];
int n[8];
int ans=0;

void rot1(){
	int p[8];
	
	p[0]=n[1];
	p[1]=n[2];
	p[2]=n[3];
	p[3]=n[0];
	p[4]=n[5];
	p[5]=n[6];
	p[6]=n[7];
	p[7]=n[4];
	
	for(int i=0;i<8;i++)n[i]=p[i];
}

void rot2(){
	int p[8];
	
	p[0]=n[3];
	p[1]=n[2];
	p[2]=n[6];
	p[3]=n[7];
	p[4]=n[0];
	p[5]=n[1];
	p[6]=n[5];
	p[7]=n[4];
	
	for(int i=0;i<8;i++)n[i]=p[i];
}

void rot3(){
	int p[8];
	
	p[0]=n[1];
	p[1]=n[5];
	p[2]=n[6];
	p[3]=n[2];
	p[4]=n[0];
	p[5]=n[4];
	p[6]=n[7];
	p[7]=n[3];
	
	for(int i=0;i<8;i++)n[i]=p[i];
}


int INT(){
	int t=0;
	for(int i=0;i<8;i++){
		t=t*10+n[i];
	}
	return t;
}

void cal(){
	int p[8];
	for(int i=0;i<8;i++)p[i]=n[i];
	int f=1;
	for(int x=0;x<4;x++){
		for(int y=0;y<4;y++){
			for(int z=0;z<4;z++){
				for(int i=0;i<8;i++)n[i]=p[i];
				for(int i=0;i<x;i++)rot1();
				for(int i=0;i<y;i++)rot2();
				for(int i=0;i<z;i++)rot3();
				int t=INT();
				if(Map[t])f=0;
			}
		}
	}
	
	if(f){
		int t=INT();
		ans++;
		Map[t]=1;
	}
	
}

int main(){
	
	string t[8];
	while(cin>>t[0]){
		
		for(int i=1;i<8;i++){
			cin>>t[i];
		}
		ans=0;
		map<string , int>M;
		int cnt=0;
		for(int i=0;i<8;i++){
			if(M[t[i]]){
				N[i]=M[t[i]];
			}
			else{
				cnt++;
				M[t[i]]=cnt;
				N[i]=M[t[i]];
			}
		}
		
		
		sort(N,N+8);
		do{
			for(int i=0;i<8;i++)n[i]=N[i];
			cal();
		}while(next_permutation(N,N+8));
		cout<<ans<<endl;
	}
	
	
	
	return 0;
}


Measured memory_bytes: 5676
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long a[100000];
int main()
{
	int N;
	int count = 1;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + N);
	long long number = a[0];
	long long bit;
	int count0 = 1;
	int count1 = 0;
	int count2 = 0;

	//if (N % 3 == 0) {
		if (a[0] == 0) {
			for (int i = 1; i < N; i++) {
				if (a[i] == 0) {
					count0++;
				}
				if (a[i] != number) {
					number = a[i];
					count++;
				}
			}
			if (count == 2 && count0 == N / 3) {
				printf("Yes");
				return 0;
			}
			if (count0 == N) {
				printf("Yes");
				return 0;
			}
		}
		else {
			for (int i = 1; i < N; i++) {
				if (a[i] == a[0]) {
					count0++;
				}
				if (a[i] == a[N / 3]) {
					count1++;
				}
				if (a[i] == a[N / 3 * 2]) {
					count2++;
				}
				if (a[i] != number) {
					number = a[i];
					count++;
				}
			}
			if (count == 3 && count0 == N / 3 && count1 == N / 3 && count2 == N / 3) {
				bit = a[0] ^ a[N / 3];
				if (bit == a[N / 3 * 2]) {
					printf("Yes");
					return 0;
				}
			}
		}
	//}
	printf("No");
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int K, X;
    cin >> K >> X;
    if (K * 500 >= X) { cout << "Yes" << endl; }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = int(1e9) + 7

tf = [True for _ in range(N)]
for i in a:
    tf[i-1] = False

if N <= 2:
    if N == 1:
        if tf[0]:
            print(1)
        else:
            print(0)
    else:
        if tf[0] and tf[1]:
            print(2)
        elif tf[0] or tf[1]:
            print(1)
        else:
            print(0)
    exit()


# DP
dp = []
if tf[0]:
    dp.append(1)
else:
    dp.append(0)
if tf[1]:
    dp.append(dp[0] + 1)
else:
    dp.append(0)
for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        if tf[i]:
            dp.append((dp[i-1] + dp[i-2])%MOD)
        else:
            dp.append(0)
print(dp[N-1])


Measured memory_bytes: 8624
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].r != NIL) calcDepth(T[u].r, p);
  if(T[u].l != NIL) calcDepth(T[u].l, p+1);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 6412
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int n;
int x[15][15][2] = {{{0}}};
int a[15] = {0};
int ans = 0;

int katei[15] = {0};

void f(int k){
    if(k == n){
        bool ok = true;
        REP(i,n){
            REP(j,a[i]){
                if(katei[i] == 1){
                    if(katei[x[i][j][0]] != x[i][j][1]){
                        ok = false;
                        break;
                    }
                }
            }
            if(!ok)break;
        }
        if(ok){
            int cnt = 0;
            REP(i,n){
                cnt += katei[i];
            }
            ans = max(ans, cnt);
        }
    }else{
        katei[k] = 0;
        f(k+1);
        katei[k] = 1;
        f(k+1);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //REP(i,15)REP(j,15)cin>>x[i][j] = -1;
    cin>>n;
    REP(i,n){
        cin>>a[i];
        REP(j,a[i]){
            cin>>x[i][j][0]>>x[i][j][1];
            x[i][j][0]--;
        }
    }
    f(0);
    PUTS(ans);
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
    int N,res=0;
    int A[100001];

    scanf("%d",&N);

    REPI(N){
        scanf("%d",&A[i]);
    }

    REPI(N){
        res += A[i]%2;
    }
    
    res%=2;

    if(!res){
        printf("YES\n");
    }else{
        printf("NO\n");
    }

    return 0;
}

Measured memory_bytes: 640
N = int(input())
h = list(map(int,input().split()))
Inf = float("inf")
dp = [Inf]*N #dp[i]...カエルがh_iにいる時に支払ったコストの総和
dp[0] = 0
dp[1] =abs(h[1]-h[0])
for i in range(N-2):
        dp[i+2] = min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]))

print(dp[N-1])

Measured memory_bytes: 13980
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define REP(i, n) rep (i, n)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset((a),0,sizeof(a))
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
template<typename T,typename U> ostream& operator<< (ostream& out, const pair<T,U>& val){return out << "(" << val.F << ", " << val.S << ")";}
template<class T> ostream& operator<< (ostream& out, const vector<T>& val){out << "{";rep(i,SZ(val)) out << (i?", ":"") << val[i];return out << "}";}
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};

int m,n;

vector<int> G[500];
bool vis[500];
int match[500];
int bl[500];
int re[500];

bool augment(int v){
  vis[v] = true;
  FOR(it,G[v]){
    if(match[*it]==-1 ||
       (!vis[match[*it]] && augment(match[*it]))){
      match[*it]=v;
      return true;
    }
  }
  return false;
}

void solve(){
  rep(i,m) G[i].clear();
  rep(i,m) cin >> bl[i];
  rep(i,n) cin >> re[i];
  rep(i,m) rep(j,n) if(__gcd(bl[i],re[j])!=1) G[i].pb(j);
  memset(match,-1,sizeof(match));
  int ans=0;
  rep(i,m){
    CLR(vis);
    ans += augment(i);
  }
  cout << ans << endl;
}

int main(){
  while(cin >> m >> n && m) solve();
}  

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

int main(){
  int K,X;
  cin >>K>>X;
  int M = 1000000;
  if((-M+K<=X)&(M-K>=X)){
    for(int i=X-K+1;i<X+K;i++){
      cout <<i<<" ";
    }
    cout <<endl;
  }
  else if(M>X-K){
    for(int i=0;i<K;i++){
      cout <<-M+i<<" ";
    }
    cout <<endl;
  }
  else if(M<X+K){
    for(int i=0;i<K;i++){
      cout <<M-K+1<<" ";
    }
    cout <<endl;
  }
}


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

using namespace std;

int main ()
{
    int N;

    cin >> N;

    switch ( N % 10 )
    {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
        break;
        case 3:
            cout << "bon" << endl;
        break;
    }

    return 0;
}

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

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>arr(m);
	for(int i=0; i<m; i++) cin>>arr[i];
	sort(arr.begin(),arr.end());
	vector<int>dist;
	for(int i=1; i<arr.size(); i++){
		dist.push_back(arr[i]-arr[i-1]);
	}
	sort(dist.begin(),dist.end());
	long long ret = 0;
	int pick = m-n;
	if(pick<=0) cout<<0;
	else{
		for(int i=0; i<pick; i++){
			ret+=dist[i];
		}
		cout<<ret;
	}
}

Measured memory_bytes: 4288
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
   int i,j,k,l;
   int a,b,c,d;
   int memory[2];
   int n;

   for(i=1;i<=9;i++) {
      for(j=1;j<=9;j++) printf("%dx%d=%d\n",i,j,i*j);
   }
   return 0;
}

Measured memory_bytes: 1096
S=list(input())
N=len(S)+1
P=[0]*N
Q=[0]*N
p=0
q=0
r=0
for i in range(0,N-1):
	if S[i]=="<":
		P[i+1]=P[i]+1
	p+=P[i+1]     
for j in range(0,N-1):
	if S[-(j+1)]==">":
		Q[-j-2]=Q[-j-1]+1
	q+=Q[-j-2]
for l in range(0,N):
	r-=min(P[l],Q[l])
print(p+q+r)

Measured memory_bytes: 31200
N, H = gets.split.map(&:to_i)
arrs = N.times.map { gets.split.map(&:to_i) }

max_first = arrs.map { |arr| arr[0] }.max
seconds = arrs.map { |arr| arr[1] }.select { |second| second > max_first }.sort.reverse

counter = 0
hp = H
while hp > 0
  if !seconds.empty?
    hp -= seconds.shift
    counter += 1
  else
    counter += hp / max_first
    counter += 1 if hp % max_first != 0
    break
  end
end

puts counter

Measured memory_bytes: 13448
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll h, w;
        cin >> h >> w;
        if(h > w){
            swap(h, w);
        }
    
        if(h % 3 == 0 || w % 3 == 0){
            cout << 0;
            return 0;
        }
        ll ans = INF;
        if(h > 2){
            ll b = h / 3;
            ll left = (h - 2 * b) * w;
            ans = abs(b * w - left);
        }
        if(w > 2){
            ll b = w / 3;
            ll left = (w - 2 * b) * h;
            ans = min(ans, abs(b * h - left));
        }
        for(i = 1; i < h; i++){
            ll a1, a2, a3;
            a1 = i * w;
            a2 = (h - i) * ((w + 1) / 2);
            a3 = (h - i) * (w / 2);
            //cout << a1 << " "<< a2 << " " << a3 << endl;
            ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));
            ll ww = h - i;
            a2 = w * ((ww + 1) / 2);
            a3 = 2 * (ww / 2);
            ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));
            //cout << ans << endl;  
        }
        for(i = 1; i < w; i++){
            ll a1, a2, a3;
            a1 = i * h;
            a2 = (w - i) * ((h + 1) / 2);
            a3 = (w - i) * (h / 2);
            ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));
            //cout << ans << endl;
            ll hh = w - i;
            a2 =  (h * (hh + 1) / 2);
            a3 = h * (hh / 2);
            ans = min(ans, max({a1, a2, a3}) - min({a1, a2, a3}));   
        }
        cout << ans;
    }
    return 0;
}

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



int main() {
    int n, k;
    cin >> n >> k;
    
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    
    for(int i = k; i < n; i++) {
        if(a[i-k] < a[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    
    return 0;
}




Measured memory_bytes: 4048
n = int(input())
l = list(map(int, input().split()))
count = 0

for i in range(n-2):
    for j in range(i + 1, n-1):
        for k in range(j + 1, n):
            a = l[i]
            b = l[j]
            c = l[k]
            if a != b:
                if b != c:
                    if a != c:
                        if a + b > c:
                            if b + c > a:
                                if a + c > b:
                                    count += 1
                        
print(count)

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

int main(void) {
	int a, b, c, d;
	cin >> a;
	b = a / 3600;
	c = a % 3600/60;
	d = a % 60;
	cout << b << ":" << c << ":" << d << endl; 
	return 0;
} 


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

using namespace std;

const int maxn = 18;
const int mod = 998244353;
const int inv = (mod + 1) / 2;

int n, a[1<<maxn], b[1<<maxn];

int qpow(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1LL * ret * x % mod;
		x = 1LL * x * x % mod;
		y >>= 1;
	}
	return ret;
}

void fwt(int *a, int l, int r) {
	if (l == r) return;
	int m = (l + r) >> 1, t = (r-l+1) >> 1;
	fwt(a, l, m);
	fwt(a, m+1, r);
	for (int i = l; i <= m; i++) {
		int v0 = (a[i] + a[i+t]) % mod, v1 = (a[i] + mod - a[i+t]) % mod;
		a[i] = v0; a[i+t] = v1;
	}
}

void ifwt(int *a, int l, int r) {
	if (l == r) return;
	int m = (l + r) >> 1, t = (r-l+1) >> 1;
	for (int i = l; i <= m; i++) {
		int v0 = 1LL * inv * (a[i] + a[i+t]) % mod, v1 = 1LL * inv * (a[i] + mod - a[i+t]) % mod;
		a[i] = v0; a[i+t] = v1;
	}
	ifwt(a, l, m);
	ifwt(a, m+1, r);
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < (1<<n); i++) scanf("%d", &a[i]);
	int s = 0;
	for (int i = 0; i < (1<<n); i++) s = (s + a[i]) % mod;
	for (int i = 0; i < (1<<n); i++) a[i] = 1LL * qpow(s, mod-2) * a[i] % mod;
	for (int i = 0; i < (1<<n); i++) a[i] = (mod - a[i]) % mod;
	a[0] = (a[0] + 1) % mod;
	fwt(a, 0, (1<<n)-1);
	for (int i = 1; i < (1<<n); i++) a[i] = 1LL * qpow(a[i], mod-2) * (mod - (1<<n)) % mod;
	ifwt(a, 0, (1<<n)-1);
	for (int i = 1; i < (1<<n); i++) a[i] = (a[i] + mod - a[0]) % mod;
	a[0] = 0;
	for (int i = 0; i < (1<<n); i++) printf("%d\n", a[i]);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    string ans;
    rep(i,n){
        if (s[i]=='0') ans.pb('0');
        if (s[i]=='1') ans.pb('1');
        if (s[i]=='B' && !ans.empty()) ans.pop_back();
    }
    cout<<ans<<"\n";
    return 0;
}


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

typedef long long LL;
LL a[MAXN],top,ans;
int main()
{
	LL n,m;
	cin>>n>>m;
	for(int i = 1;i <= LL(sqrt(m*1.0)) + 1;i++){
		if(m%i==0){
			a[++top] = i;
		}
	}
	for(int i = top;i>=1;i--){
		if(a[i] * n <= m){
			ans = max(ans,a[i]); 
		}
		if((m/a[i])*n <= m){
			ans = max(ans,m/a[i]); 
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
package main

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

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	n, a := func() int { stdin.Scan(); i, _ := strconv.Atoi(stdin.Text()); return i }(), scanArrayInt()
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	m := map[int]int{0: 0, 1: 0}
	for i := 0; i < n; i++ {
		m[i%2] += a[i]
	}
	fmt.Println(m[0] - m[1])
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  vector<int> friends;
  for (int i=0; i<n; i++) {
    int t;
    cin >> t;
    friends.push_back(t);
    if (friends[i] >= k) {
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    int M = (int)  Math.sqrt( N ) + 1;

    int Fmin = String.valueOf(N).length();
    for(int i = 2 ; i <= M ; i ++){
      if( N % i == 0 ){
        long j = N / i ;
        int A = String.valueOf(i).length();
        int B = String.valueOf(j).length();
        int F = Math.max(A,B);
        if(Fmin > F){
          Fmin = F ;
        }
      }
    }
    System.out.println(Fmin);
  }
}


Measured memory_bytes: 23252
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import bisect_right as br
N, K = map(int, input().split())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y, c, d = map(int, input().split())
    X[x-1].append((y-1, c-1, d))
    X[y-1].append((x-1, c-1, d))

P = [(-1, 0, 0)] * N
Q = [(0, 0, 0)]
R = []
ET = []
ct = 0
CT = [0] * (N-1) * 2
CTA = [-1]* N
BT = [[[-1], [0], [0]] for _ in range(N)]
while Q:
    i, c, d = Q.pop()
    if i < 0:
        BT[c][0].append(ct)
        BT[c][1].append(BT[c][1][-1]-1)
        BT[c][2].append(BT[c][2][-1]-d)
        ct += 1
        continue
    R.append(i)
    if i > 0:
        if CTA[i] < 0: CTA[i] = ct
        BT[c][0].append(ct)
        BT[c][1].append(BT[c][1][-1]+1)
        BT[c][2].append(BT[c][2][-1]+d)
        ct += 1
    
    for a, c, d in X[i][::-1]:
        if a != P[i][0]:
            ET.append((i, a))
            P[a] = (i, c, d)
            for k in range(len(X[a])):
                if X[a][k][0] == i:
                    del X[a][k]
                    break
            Q.append((~a, c, d))
            Q.append((a, c, d))

L = [[0, 0] for _ in range(N)]
for i in R[1:]:
    p, c, d = P[i]
    L[i][0] = L[p][0] + 1
    L[i][1] = L[p][1] + d

D = [[P[i][0] for i in range(N)]] + [[-1]*N for _ in range(16)]
for k in range(1, 17):
    for i in range(N):
        a = D[k-1][i]
        if a > 0:
            D[k][i] = D[k-1][a]

def lca(u0, v0):
    u, v = u0, v0
    if L[u][0] < L[v][0]:
        u, v = v, u
    
    while L[u][0] > L[v][0]:
        d = L[u][0] - L[v][0]
        dd = d.bit_length() - 1
        u = D[dd][u]
    if u == v:
        return u
    
    for i in range(17)[::-1]:
        if D[i][u] != D[i][v]:
            u = D[i][u]
            v = D[i][v]
    
    return D[0][u]
    

def calc(x, y, w):
    aa = br(BT[x][0], CTA[w]) - 1
    c = BT[x][1][aa]
    d = BT[x][2][aa]
    return L[w][1] + c*y - d

for _ in range(K):
    x, y, u, v = map(int, input().split())
    x, u, v = x-1, u-1, v-1
    ll = lca(u, v)
    print(calc(x, y, u) + calc(x, y, v) - 2*calc(x, y, ll))


Measured memory_bytes: 157900
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
int n;

void dfs(string s,int k){
  if(s.size()==n){
    cout<<s<<endl;
  }
  else{
    rep(i,k+1){
      string t=s;
      t+='a'+i;
      dfs(t,max(k,i+1));
    }
  }
  return;
}

signed main(){
  cin>>n;
  dfs("",0);
  return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long int ll;

int main(){
    //累積和をとって同じ数字が現れたところでの組み合わせを考えるだけ
    
    ll N;
    cin >> N;
    vector<ll > A(N);
    
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        cin >> A[i];
    }

    //累積和
    vector<ll > ruiseki;
    ruiseki.push_back(0);
    for(ll i = 0; i < N; i++){
        sum += A[i];
        ruiseki.push_back(sum);
    }   
    //累積わにMOD
    ll ans = 0;
    //連想配列用意
    map<ll, ll> result;
    
    for(ll i = 0; i < ruiseki.size(); i++){
        result[ruiseki[i]]++;
    }     
    
    for(auto i = result.begin(); i != result.end() ; ++i){
        ll value = i->second;
        if(value == 1) continue;
        ans += value * (value - 1) / 2;
    }

    cout << ans << endl;


} 

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    ll x; cin >> x;
    ll res = x/11;
    res *= 2;
    if(x%11 == 0);
    else if(x%11 > 6) res += 2;
    else res += 1;

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
divisors = make_divisors(N)
ans = 0
divisors.sort(reverse=True)
for x in divisors:
    if x > 1:
        temp = x - 1
        d,m = divmod(N,temp)
        if d != m:
            break
        else:
            ans += temp
print(ans)

Measured memory_bytes: 9480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int main() {
    int N, Q;  cin >> N >> Q;
    string S;  cin >> S;
    vector<int> l(Q);
    vector<int> r(Q);
    rep(i, Q)  cin >> l[i] >> r[i];

    vector<int> t;
    int cnt = 0;
    t.push_back(cnt);
    rep(i, N-1) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            cnt++;
        }
        t.push_back(cnt);  // i番目の前までの個数を記録
    }

    rep(i, Q) {
        print(t[r[i]-1] - t[l[i]-1]);
    }
}

Measured memory_bytes: 2296
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
main ()


Measured memory_bytes: 21648
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    unsigned long long H,W;
    cin >> H >> W;
    if(H==1 || W==1){
        cout << 1 << endl;
    }else if(H%2==1){
        int f=H/2 + 1, s = H/2;
        if(W%2==1){
            cout << f*(W/2+1) + s*(W/2) << endl;
        }else{
            cout << f*W/2 + s*W/2 << endl;
        }
    }else{
        int f=H/2, s = H/2;
        if(W%2==1){
            cout << f*(W/2+1) + s*(W/2) << endl;
        }else{
            cout << f*W/2 + s*W/2 << endl;
        }
    }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

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

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi d(n);
	vvi g(n);
	vector<pii> p(n - 1);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
	
		p[i] = { a,b };
		g[a].push_back(b);
		g[b].push_back(a);
		d[a]++;
		d[b]++;
	}
	vi c(n);
	REP(i, n)cin >> c[i];
	sort(ALL(c));
	queue<int> q;
	int cnt = 0;
	vi ans(n);
	REP(i, n)if (d[i] == 1)q.push(i);
	while (!q.empty()) {
		int p = q.front(); q.pop();
		d[p] = 0;
		ans[p] = c[cnt++];
		REP(i, g[p].size()) {
			if (d[g[p][i]] == 0)continue;
			if (--d[g[p][i]] == 1) {
				q.push(g[p][i]);
			}
		}
	}
	int sum = 0;
	REP(i, n-1){
		sum += min(ans[p[i].first], ans[p[i].second]);
	}
	cout << sum << endl;
	REP(i, n)cout << ans[i] << " ";

}


Measured memory_bytes: 1152
//インクルード(アルファベット順)
#ifndef TEMPLATE
#define TEMPLATE
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

#endif // TEMPLATE
signed main() {
string S,T;
cin >> S >>T;
int itr;
for(int i=0;i<S.size();i++){
  itr = i;
  for(int j=0;j<S.size();j++){
   // cout << "?";
    if(S[itr+j] != T[j]){
     // cout << "!";
      break;
    }
    if(j== S.size()-1) {
      cout << "Yes" << endl;
      return 0;
    }
    if(itr+j==S.size()-1){
      itr= itr -S.size() ;
    }
  }
}
cout << "No" << endl;

return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++)
  cin >> v.at(i);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int k;
    cin >> k;
    if (binary_search(v.begin(), v.end(), k))
    cout << 1 << endl;
    else
    cout << 0 << endl;
  }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool nonANS(vl &b, vl &output){
    bool res=true;
    for(ll i=b.size()-1; i>=0; i--) {
        if(i+1 == b[i]) {
            res = false;
            output.PB(b[i]);
            b.erase(b.begin()+i);
            break;
        }
    }
    return res;
}

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

    // solution comes here

    ll N;
    cin >> N;
    vl b(N), output;
    rep(i, N) cin >> b[i];

    rep(_, N) {
        if(nonANS(b, output)) {
            cout << -1 << nl;
            return 0;
        }
    }

    rep(i, N) cout << output[N-1-i] << nl;
}

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

#define int long long

signed main(void) {
  int a, b, x, ans = 0;
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> x;

  int aa = a / x, bb = b / x;
  if (a == b) {
    if (a % x == 0) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    ans = bb - aa;
    if (a % x == 0) ans++;
    cout << ans << endl;
  }
  return 0;
}


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

struct UnionFind{
    vector<ll> link;
    UnionFind(ll n):link(n,-1){}
    ll find(ll v){
        if(link[v]<0) return v;
        else return link[v]=find(link[v]);
    }
    bool unite(ll v,ll w){
        v=find(v),w=find(w);
        if(v==w) return 0;
        if(link[v]>link[w]) swap(v,w);
        link[v]+=link[w];
        link[w]=v;
        return 1;
    }
    bool same(ll v,ll w){
        return find(v)==find(w);
    }
};

int main(){
    ll n,m,x,y,z;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        cin>>x>>y>>z;
        x--,y--;
        uf.unite(x,y);        
    }
    map<ll,ll> mp;
    rep(i,n) mp[uf.find(i)];
    cout<<mp.size()<<endl;
    return 0;
}

Measured memory_bytes: 10156
N, M = map(int, input().split())
S = input()
T = input()

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

k = N * M // gcd(N, M)
if  all(s == t for s, t in zip(S[::k // M], T[::k // N])):
    print(k)
else:
    print(-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
signed main(){
  string S;cin>>S;
  int size=S.size();
  int dream=8-(15-size);
  int cnt=count(all(S),'o');
  dream<=cnt?puts("YES"):puts("NO");
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 2000010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
#define eps 1e-6
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
const ll mod = 1e9 + 7;
ll n, m;
string s;
ll a[SIZE];
int main() {
	io(); cin >> n;
	bool f = true;
	rep(i, 1, n) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 5 && a[i] % 3) f = false;
		}
	}
	if (f) cout << "APPROVED";
	else cout << "DENIED";
}
/*
5
6 7 9 10 31
*/

Measured memory_bytes: 256
N,M = map(int,input().split())
xyz = []
for i in range(N):
    ii = list(map(int,input().split()))
    xyz.append(ii)

xyz2 = [sorted(xyz,key = lambda x:((-1)**a)*x[0]+((-1)**b)*x[1]+((-1)**c)*x[2]) for a in range(2) for b in range(2) for c in range(2)]
ans = 0
for xyz1 in xyz2:
    x1 = 0
    y1 = 0
    z1 = 0
    for x,y,z in xyz1[:M]:
        x1 += x
        y1 += y
        z1 += z
    ans = max(ans,abs(x1)+abs(y1)+abs(z1))
print(ans)

Measured memory_bytes: 3444
import bisect
N = int(input())
L = []
def index(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return True
    else:
        return False
for i in range(N):
    L.append(int(input()))
L0 = L[::2]
L.sort()
Ls0 = L[::2]
cc = 0
for i in range((N+1)//2):
    if not index(Ls0, L0[i]):
        cc += 1
print(cc)

Measured memory_bytes: 8028
// Author : Mohamed Sameh
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
typedef long long ll ;
using namespace std ;
int n ,x , y ;
vector<int>adj[2000]; 
int cost[2000][2000];
int ans[2000]; 
int main()
{
     scanf("%d%d%d" , &n ,&x , &y ); 
     x--;
     y--;
     for (int i =0 ; i < n ;i++)
     for (int j =0 ; j < n ;j++)
     cost[i][j] = 1e9 ; 
     for (int i =0 ; i < n-1 ;i++)
     {
         adj[i].pb(i+1); 
         adj[i+1].pb(i); 
     }
     adj[x].pb(y); 
     adj[y].pb(x); 
     for (int i =0 ; i  < n ;i++)
     {
         queue<int> q ; 
         q.push(i); 
         cost[i][i] = 0; 
         while (!q.empty())
         {
             int cur = q.front(); 
             q.pop();
             for (int node : adj[cur])
             {
                 if (cost[i][node] > cost[i][cur] + 1 )
                 {
                     cost[i][node] = 1 + cost[i][cur]; 
                     ans[ 1 + cost[i][cur] ]++; 
                     q.push(node); 
                 }
             }
         }
     }
     for (int i = 1; i < n ;i++)
     {
         printf ("%d\n" ,ans[i]/ 2 ); 
     }
}


Measured memory_bytes: 16000
#include <bits/stdc++.h>
#include <cstring>
#define ll long long
#define pa pair<int,int>
using namespace std;
int a[1001];
int len(int x)
{
    int ans = 0;
    while(x)
    {
        ans++;
        x>>=1;
    }
    return ans-1;
}
int main()
{
    int d,n;
    cin>>d>>n;
    if(n == 100)
    {
        n++;
    }
    for(int i = 0;i<d;i++)
    {
        n *= 100;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
// #include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using ull = unsigned long long;
using namespace std;

inline ll modpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

inline ll mod(ll val, ll m) {
	ll res = val % m;
	if (res < 0) res += m;
	return res;
}

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

	vector<int> x;
	vector<int> y;
	vector<int> z;
	vector<int> w;


	REP(i,0,n) {
		int a, b;
		cin >> a >> b;
		x.emplace_back(a);
		y.emplace_back(b);
	}
	
	REP(i,0,n){
		z.emplace_back(x[i] + y[i]);
		w.emplace_back(x[i] - y[i]);
	}

	int max_z, min_z, max_w, min_w;

	REP(i, 0, n) {
		if (i == 0) {
			max_z = z[i];
			min_z = z[i];
			max_w = w[i];
			min_w = w[i];
		}
		else {
			if (max_z < z[i]) {
				max_z = z[i];
			}
			if (min_z > z[i]) {
				min_z = z[i];
			}
			if (max_w < w[i]) {
				max_w = w[i];
			}
			if (min_w > w[i]) {
				min_w = w[i];
			}
		}
	}
	if (max_z - min_z > max_w - min_w) {
		cout << max_z - min_z;
	}
	else {
		cout << max_w - min_w;
	}
	

	return 0;
}

Measured memory_bytes: 7204