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

int divisor(int n) {
    int ret = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            ret++;
        }
    }
    return ret;
}

int main(void){

   int N,ans=0;
   cin >> N;
   for(int i=1;i<=N;i=i+2){
       if(divisor(i) == 8) ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll A, B, N;
    cin >> A >> B >> N;

    if (B > N) {
        cout << (A * N) / B << endl;
        return 0;
    }
    ll ans = 0;
    ll x;
    x = B - 1;
    ans = max(ans, (A * x) / B - A * (x / B));

    x = N;
    ans = max(ans, (A * x) / B - A * (x / B));
    x = N - 1;
    ans = max(ans, (A * x) / B - A * (x / B));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

// Light version
using Data = int;
const int len = 1 << 18;

struct BIT {
  vector<Data> data;
  BIT() : data(len, 0) {}
  void update(int i, Data value) {
    for (; i < len; i |= i+1) data[i] += value;
  }
  Data query(int i) {
    Data s = 0;
    for (; i >= 0; i = (i&i+1)-1) s += data[i];
    return s;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin>>s;
  int n=s.size();
  vecint cnt(26, 0);
  REP(i,n) {
    ++cnt[s[i]-'a'];
  }
  int oddc = 0;
  REP(i,26) if (cnt[i]%2 == 1) ++oddc;
  if (oddc > 1) {
    cout<<-1<<endl;
    return 0;
  }
  int lcnt = 0;
  vecint p(n);
  vecint cnt2(26, 0);
  vector<vecint> memo(26);
  REP(i,n) {
    int idx = s[i]-'a';
    if (cnt2[idx] < cnt[idx] / 2) { // left
      p[i] = lcnt;
      memo[idx].push_back(lcnt);
      ++lcnt;
    } else if (cnt2[idx] < (cnt[idx]+1) / 2) { // middle
      p[i] = n/2;
    } else { // right
      int co = cnt[idx] - 1 - cnt2[idx];
      p[i] = n - 1 - memo[idx][co];
    }
    ++cnt2[idx];
  }
  BIT bit;
  ll ans = 0;
  for(int i=n-1; i>=0; --i) {
    ans += bit.query(p[i]);
    bit.update(p[i], 1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3092
///e. next prime
#include <stdio.h>
#include <math.h>

int isPrime(int a)
{
    if(a==2) return 1;
    for(int i=2;i<=sqrt(a);i++){
        if(a%i==0) return 0;
    }
    return 1;
}
int main()
{
    int x;
    scanf("%d",&x);

    for(int i=x;;i++){
        if(isPrime(i)==1) {
            printf("%d",i);
            break;
        }
    }
}

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

int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

#define _AB 4
#define _AC 8
#define _BC 9

int main()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    string s;
    getline(cin, s);
    int *choice = mallocint(n);
    int *selected = mallocint(n);
    for( int i = 0; i < n; i++)
    {
        getline(cin, s);
        string tmp = s.substr(0, 2);
        if( tmp == "AB") choice[i] = _AB;
        if( tmp == "AC") choice[i] = _AC;
        if( tmp == "BC") choice[i] = _BC;        
    }

    int state[3];
    state[0] = a;
    state[1] = b;
    state[2] = c;

    for(int i = 0; i < n; i++)
    {
        int p1 = choice[i] & 3;
        int p2 = (choice[i] >> 2) & 3;

        if( state[p1] > state[p2] )
        {
            selected[i] = p2;
            state[p2]++;
            state[p1]--;
        }
        else if ( state[p1] < state[p2] )
        {
            selected[i] = p1;
            state[p1]++;
            state[p2]--;
        }
        else
        {
            if( state[p1] == 0 )
            {
                cout << "No";
                return 0;
            }
            else if( i + 1 < n )
            {
                int q1 = choice[i + 1] & 3;
                int q2 = (choice[i + 1] >> 2) & 3;

                if( p1 == q1 || p1 == q2 )
                {
                    selected[i] = p1;
                    state[p1]++;
                    state[p2]--;
                }
                else
                {
                    selected[i] = p2;
                    state[p1]--;
                    state[p2]++;                    
                }
            }
            else
            {
                selected[i] = p1;
                state[p1]++;
                state[p2]--;                
            }
        }
        
    }
    cout << "Yes" << endl;
    const char ac[3] = {'A', 'B', 'C'};
    for(int i = 0; i < n; i++)
    {
        cout << ac[selected[i]] << endl;
    }
}

Measured memory_bytes: 4404
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


int go(string &s,string &s1){
	int c=0;
	FER(i,0,sz(s))c+=(s[i]!=s1[i]);
	return c;
}


int main(){	
	fastio;
	string s;cin>>s;
	string s1,s0;
	FER(i,0,sz(s)){
		if(i&1){
			s1.pb('0');
			s0.pb('1');
		}
		else{
			s1.pb('1');
			s0.pb('0');
		}
	}
	
	cout<<min(go(s,s1),go(s,s0));
	return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


int main() {
    int N, M; cin >> N >> M;
    vector<int> G(N+1, 0);
    for (int i = 0; i < M; ++i) {
        int l, r; cin >> l >> r; --l;
        G[l]++;
        G[r]--;
    }
    for (int i = 0; i < N; ++i) G[i+1] += G[i];
    int res = 0;
    for (int i = 0; i < N; ++i) if (G[i] == M) ++res;
    cout << res << endl;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
  int N;
  int A, B;
 loop:  
  cin >> N;
  
  if(N == 1)
    cout << "Hello World" << endl;
  else if(N == 2){
    cin >> A >> B;
    cout << A+B << endl;
  }
  else
    goto loop;

  return 0;
}


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

int main() {

   int a[3];
   cin >> a[0] >> a[1] >> a[2];
   sort(a, a + 3);

   int step = a[2] - a[1];
   a[0] += step;

   if((a[2] - a[0]) % 2 == 0)
     step += (a[2] - a[0]) / 2; 
   else
     step += (a[2] - a[0] + 1) / 2 + 1;
   
   cout << step;
   
   return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
#define miz(x,y) x=min(x,y)
int ed[100][100],d[100][100][100],inf=1e8,n,m,c;
int main(){
	while(true){
		cin>>n>>m>>c;
		if(n==0) break;
		rep(i,n) rep(j,n) rep(k,n) if(i!=j) d[i][j][k]=inf;
		rep(i,n) rep(j,n) if(i!=j) ed[i][j]=inf;
		rep(i,m){
			int f,t,cc;
			cin>>f>>t>>cc;
			ed[f-1][t-1]=cc;
			d[f-1][t-1][0]=cc;
		}
		rep(i,n) rep(j,n) rep(k,n) miz(d[j][k][0],d[j][i][0]+d[i][k][0]);
		rep(a,n) rep(b,n) if(ed[a][b]!=inf){
			rep(i,n) rep(j,n) miz(d[i][j][1],d[i][a][0]+d[b][j][0]);
		}
		rep1(cnt,n-1){
			if(d[0][n-1][cnt]<=c){
				cout << cnt << endl;
				break;
			}
			rep(i,n) rep(j,n) rep(k,n) miz(d[j][k][cnt+1],d[j][i][cnt]+d[i][k][1]);
//			show(d[0][n-1][cnt+1]);
		}
	}
}

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

const int N = 1e6 + 5;
int n, m, a[N], vis[N], t[N];

struct node {
	int l, r, idx, ans;
}b[N];

void upd(int x, int v) {for(; x <= n; x += x & -x) t[x] += v;}
int qry(int x) {int res = 0; for(; x; x -= x & -x) res += t[x]; return res;}
int qry(int l, int r) {return qry(r) - qry(l - 1);}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= m; i++) scanf("%d %d", &b[i].l, &b[i].r), b[i].idx = i;
    sort(b + 1, b + m + 1, [](const node &x, const node &y) {
    	return x.r != y.r ? x.r < y.r : x.l < y.l;
    });
    int r = 1;
    for (int i = 1; i <= m; i++) {
        for (int j = r; j <= b[i].r; j++) {
        	if(vis[a[j]]) upd(vis[a[j]], -1);
        	upd(j, 1);
            vis[a[j]] = j;
        }  
        r = b[i].r + 1;
        b[i].ans = qry(b[i].l, b[i].r);
    }
    sort(b + 1, b + m + 1, [](const node &x, const node &y) {
    	return x.idx < y.idx;
    });
    for (int i = 1; i <= m; i++) printf("%d\n", b[i].ans);
    return 0;
}

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

using namespace std;

typedef long long Int;

Int n;
Int MOD;
Int ans;
Int dp[3100][3100];
Int frac[108000];
Int rfrac[108000];
Int pow(Int a, Int b){
	if(b == 0)return 1;
	Int res = pow(a, b / 2);
	res *= res;res %= MOD;
	if(b % 2 == 1)res *= a;
	return res % MOD;
}

Int rev(Int x){
	return pow(x, MOD-2);
}

Int C(Int n, Int k){
	return frac[n] * rfrac[n-k]  % MOD * rfrac[k] % MOD;
}


Int powpow2(int x){
	Int res = 2;
	while(x--){
		res *= res;
		res %= MOD;
	}
	return res;
}


Int hoge(Int k){
	Int ans = 0;
	Int pp = powpow2(n-k);
	Int poyo = 1;
	Int pupu = pow(2,(n-k));
	for(int i = 0;i <= k;i++){
		ans += dp[k][i] * poyo % MOD * pp % MOD;ans %= MOD;
		poyo *= pupu;poyo %= MOD;
	}
	return ans * C(n, k) % MOD;
}

int main(){
	dp[0][0] = 1;
	cin >> n >> MOD;
	for(int i = 0;i <= 3000;i++){
		if(i == 0)frac[i] = 1;
		else frac[i] = frac[i-1] * i % MOD;
		rfrac[i] = rev(frac[i]);
	}
	ans = powpow2(n);
	for(int i = 1;i <= 3000;i++){
		for(int j = 0;j <= 3000;j++){
			dp[i][j] += dp[i-1][j] * (j+1) % MOD;
			if(j) dp[i][j] += dp[i-1][j-1];
			dp[i][j] %= MOD;
		}
	}
	
	for(int i = 1;i <= n;i++){
		if(i % 2 == 1)ans -= hoge(i);
		else ans += hoge(i);
		ans %= MOD;
	}
	if(ans < 0)ans += MOD;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
int main()
{
    int n  , ans=0 , x;
    cin >> n;
    for(int i = 1;  i<=n ; i++)
    {
        cin >> x;
        if(i%2==1&&x%2==1)
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3608
# -*- coding: utf-8 -*-

def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 整数(1 <= N <= 10**6)
    """
    # 求解処理
    ans = 10**N - 2 * 9**N + 8**N
    ans %= 10**9 + 7

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 11116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

//根からの距離の偶奇が一致する時２点の距離は偶数になることを利用する
struct Edge{//一回で二つの整数を格納する　コンストラクタ？？
    ll to; ll cost;
    Edge(ll to,ll cost) : to(to), cost(cost){}// Edge(ll to,ll cost)においてtoを書いたらtoが出力される？？？
};

int N;
vector<Edge> G[101000];

int ans[101000];
bool visited[101000];
//偶数と奇数で塗り分ければできる？？？

void dfs(int s,ll cost){//全てを通ってそれぞれの根元からの距離を計算する sが次 costが距離
	if(visited[s]){
      return ;
    }

	visited[s]=true;

	if(cost % 2 == 0){
      ans[s]=0;
    }
	else{
      ans[s]=1;
    }
    

	for(auto p:G[s]){// struct Edgeで二つの整数を格納できるようにした場合のそれぞれの要素の特定方法 G[s]の引き出しの中から選ぶ
		dfs(p.to, cost + p.cost);//autoはforの型定義を省略したもの？？？
      //この場合pはvector<Edge>pを意味し、G[s]を出力していく？？？
	}
}

int main(){
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		ll u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		G[u].push_back(Edge(v,w));//int[]で定義して地点ごとにedgeを格納する
		G[v].push_back(Edge(u,w));
	}
	dfs(0,0);
	for(int i = 0; i < N; i++){
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n, s) for (int i = (s); i < (n); i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    int cnt = 1;
    int _min=1000000;
    reps(i, N, 1)
    {
        _min= min(_min,P[i-1]);
        int tmp = P[i];
        if (tmp <= _min)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
ll n,m,seg[600000];
void segstart(void){
    memset(seg,0,sizeof(seg));
    for(ll i=1;;i*=2){
        if(n<=i){m=i;break;}
    }
    m--;
    for(int i=m-1;i>=0;i--){
        seg[i]=max(seg[2*i+1],seg[2*i+2]);
    }

}
void update(ll a,ll b){
    a+=m;seg[a]=b;
    while(a){
        a=(a-1)/2;
        seg[a]=max(seg[2*a+1],seg[2*a+2]);
    }
}
ll ans(ll a,ll b){
    ll ret=a;a+=m;b+=m;
    while(1){
        if(a==b){
            ret=max(ret,seg[a]);
            break;
        }
        if(b==a+1){
            ret=max(ret,seg[a]);
            ret=max(ret,seg[b]);
            break;
        }
        if(a%2)a/=2;
        else{
            ret=max(ret,seg[a]);
            a/=2;
        }
        if(b%2){
            ret=max(ret,seg[b]);
            b/=2;b--;
        }
        else{b/=2;b--;}
    }
    return ret;
}

ll a[200001];
ll solve(ll le,ll ri){
	if(le==ri)return 2LL;
	if(a[le]==ri)return (solve(le+1,ri)+1)%mod;
	return (solve(le,a[le])*solve(a[le]+1,ri))%mod;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    segstart();
    ll x[n],d[n];
    vector<pair<ll,ll> > v;
    for(int i=0;i<n;i++){
    	cin>>x[i]>>d[i];
    	v.pb(make_pair(x[i],d[i]-1));
    }
    sort(be(v));
    for(int i=0;i<n;i++){
    	x[i]=v[i].first;
    	d[i]=v[i].second;
    }
    for(int i=n-1;i>=0;i--){
    	ll idx=(upper_bound(x,x+n,x[i]+d[i])-x);
    	idx--;
    	a[i]=max(ans(i,idx),idx);
    	update(i,a[i]);
    }
    cout << solve(0,n-1) <<endl;
    return 0;
}


Measured memory_bytes: 19948
#include<algorithm>
#include<string.h>
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int n=a-b;
	if(min(n,c)==c)
		cout<<"0";
	else
		cout<<c-n;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[] in;
	static HashSet<Character> left = new HashSet<Character>();
	static HashSet<Character> right = new HashSet<Character>();
	public static void main(String[] args) {
		char[] l = {'q','w','e','r','t',
					'a','s','d','f','g',
					'z','x','c','v','b'};
		for(int i = 0; i < l.length; i++)left.add(l[i]);
		char[] r = {'y','u','i','o','p',
					'h','j','k','l',
					'n','m'};
		for(int i = 0; i < r.length; i++)right.add(r[i]);
	
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		in = sc.next().toCharArray();
		if(in[0] == '#')return false;
		return true;
	}
	
	static void solve(){
		int res = 0;
		boolean isLeft = false, isRight = false;
		if(right.contains(in[0])){
			isRight = true;
		}else{
			isLeft = true;
		}
		for(int i = 1; i < in.length; i++){
			if(right.contains(in[i])){
				if(isLeft)res++;
				isRight = true;
				isLeft = false;
			}else{
				if(isRight)res++;
				isLeft = true;
				isRight = false;
			}
		}
		System.out.println(res);
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
void chmax (long long &a, long long b) { if (a < b) a = b; }
int bit (int n, int k) { return ((n>>k)&1); }
constexpr long long INF = 1e18;
constexpr int MAX = (1<<16) + 10;

int main() {
    int n;
    cin >> n;
    vector<vector<long long>> a(n, vector<long long>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    
    auto calc = [&] (int x) -> long long {
        long long res = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if (bit(x, i) and bit(x, j)) {
                    res += a[i][j];
                }
            }
        }
        return res;
    };
    
    vector<long long> dp(MAX, -INF);
    dp[0] = 0;
    for (int s = 1; s < (1<<n); s++) {
        dp[s] = calc(s);
        for (int t = (s-1)&s; t > 0; t = (t-1)&s) {
            chmax(dp[s], dp[t] + dp[t^s]);
        }
    }
    
    cout << dp[(1<<n)-1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	int k = a[n / 2];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += abs(a[i] - k);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  string s, p;
  bool re=true;

  cin >> s >> p;

  for(int i=0; i<s.length(); i++){
    re=true;
    for(int j=0; j<p.length(); j++){
      if( s[(i+j)%s.length()] != p[j] ){
        re = false;
        break;
      }
    }
    if(re){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  map<ll,ll> p;
  ll ans=0;
  rep(i,n) {
    cin>>a[i];
    p[a[i]]++;
    ans+=a[i];
  }
  ll q;
  cin>>q;
  rep(i,q){
    ll b,c;
    cin>>b>>c;
    ll cu=p[b];
    ans+=(c-b)*cu;
    p[b]=0;
    p[c]+=cu;
    COUT(ans);
  
  }
}

Measured memory_bytes: 10064
N,M = map(int,input().split())
pS = [list(input().split()) for _ in range(M)]
lis = [0]*N
pena = [0]*N
for p,S in pS:
    p = int(p)-1
    if S == "AC":
        lis[p] = 1
    else:
        if lis[p] == 0:
            pena[p] += 1
pe = 0
for i in range(N):
    if lis[i]:
        pe += pena[i]

print(sum(lis), pe)


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

// #undef LOCAL
#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

string dp[10001];

//                 1  2  3  4  5  6  7  8  9
int a2n[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

bool cmp(const string& a, const string& b)
{
  int f;
  f = a.size() - b.size();
  if (f < 0) {
    return 0;
  } else if (0 < f) {
    return 1;
  } else {
    for (int i = 0; i < a.size(); i++) {
      if (a[i] > b[i])
        return 1;
      else if (a[i] < b[i])
        return 0;
    }
    return 0;
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    if (0 < i && dp[i].size() == 0)
      continue;
    for (int j = 0; j < M; j++) {
      int digit = A[j];
      int nstick = a2n[digit];
      string s = dp[i].size() == 0 ? to_string(digit) : dp[i] + to_string(digit);
      if (i + nstick <= N)
        dp[i + nstick] = cmp(dp[i + nstick], s) ? dp[i + nstick] : s;
    }
  }
  cout << dp[N] << endl;
  return 0;
}


Measured memory_bytes: 33024
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = []
for i, a in enumerate(A, start=1):
    ans.extend([i] * a)

ans = [ans[(h * W): ((h + 1) * W)] for h in range(H)]
for i, a in enumerate(ans):
    if i % 2 == 0:
        print(*a, sep=' ')
    else:
        print(*a[::-1], sep=' ')


Measured memory_bytes: 3920
mod = int(1e9+7)
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    #A, B = [int(x) for x in raw_input().split()]
    n = int(raw_input())
    
    arr = [int(x) for x in raw_input().split()]
    
    cnt = {}
    
    cur_sum = 0
    
    for num in arr:
        cnt[num] = cnt.get(num, 0) + 1
        cur_sum += num 
    
    q = int(raw_input())
    
    for _ in range(q):
        frm, to = [int(x) for x in raw_input().split()]
        
        frm_cnt, to_cnt = cnt.get(frm, 0), cnt.get(to, 0)
        
        diff = to - frm
        
        total_diff = frm_cnt * diff
        
        cur_sum += total_diff
        
        cnt[to] = to_cnt + frm_cnt
        
        cnt[frm] = 0
        
        print(cur_sum)
        
        
           
        
    
    #queries = [ for x in raw_input().split()]
    

main()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    int ans = 0;
    double now = 100000000;
    for(int i = 1; i <= n; i++){
        double h;
        cin >> h;
        double New = t - 0.006 * h;
        if(abs(New  - a) < now){
            now = abs(New - a);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double dA = (double)A;
  
  vector<double> H(N);
  double kion = 10000.0;
  int basho;
  for( int i = 0; i < N; i++ ){
    cin >> H.at(i);
    double t = (double)T - ( (double)H.at(i) * 0.006 );
    if( kion > abs( A - t ) ){
      kion = abs( A - t );
      basho = i+1;
    }
  }
  cout << basho << endl;
  
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++)
  {
    cin>>h[i];
  }
  vector<int>dp(n,INT_MAX);
  dp[0]=0;
  for(int i=1;i<n;i++)
  {
    for(int j=max(i-k,0);j<i;j++)
    {
      dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  long long int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<long long int> redApples(a);
  vector<long long int> greenApples(b);
  vector<long long int> uncoloredApples(c);
  for(auto &x:redApples ){
    cin>>x;
  } 
  for(auto &x:greenApples){
    cin>>x;
  }
  for(auto &x:uncoloredApples){
    cin>>x;
  }
  sort(redApples.begin(),redApples.end(),greater<int>());
  sort(greenApples.begin(),greenApples.end(),greater<int>());
  sort(uncoloredApples.begin(),uncoloredApples.end(),greater<int>());

  long long int redPos=x-1;
  long long int greenPos=y-1;
  long long int uncoloredPos=0;
  while(uncoloredPos<c){
    if(redPos>=0&&greenPos>=0){
      if(uncoloredApples[uncoloredPos]<redApples[redPos]
        &&uncoloredApples[uncoloredPos]<greenApples[greenPos]){  
        break;
      }
      else if(redApples[redPos]<greenApples[greenPos]&&
        redApples[redPos]<uncoloredApples[uncoloredPos]){
        redApples[redPos]=uncoloredApples[uncoloredPos];
        redPos--;
        uncoloredPos++;
      }
      else if(greenApples[greenPos]<uncoloredApples[uncoloredPos]){
        greenApples[greenPos]=uncoloredApples[uncoloredPos];
        greenPos--;
        uncoloredPos++;
      }
      else{
        break;
      }
      
    }
    else if(redPos>=0){
      if(redApples[redPos]<uncoloredApples[uncoloredPos]){
        redApples[redPos]=uncoloredApples[uncoloredPos];
        redPos--;
        uncoloredPos++;
      }
      else{
        break;
      }
    }
    else if(greenPos>=0){
      if(greenApples[greenPos]<uncoloredApples[uncoloredPos]){
        greenApples[greenPos]=uncoloredApples[uncoloredPos];
        greenPos--;
        uncoloredPos++;
      }
      else{
        break;
      }
    }
  }
  long long int ans=0;
  for(int i=0;i<x;i++){
    ans+=redApples[i];
  }
  for(int i = 0;i<y;i++){
    ans+=greenApples[i];
  }
  cout<<ans<<"\n";  
  return 0;
}

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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i=0,t;
	cin>>n;
	t=n;
	while (t>0){
		i+=t%10;
		t/=10;
	}
	if (n%i==0){
		cout<<"Yes";
	}
	else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#define NG 9999999
using namespace std;
int main()
{
	int n, m;
	int i, j, k;
	int ain, bin;

	cin >> n >> m;
	vector< vector<int> > a(n + 1);

	for (i = 0; i < m; i++) {
		cin >> ain >> bin;
		a[ain].push_back(bin);
		a[bin].push_back(ain);
	}

	int *ans = new int[n + 1];
	int *prev = new int[n + 1];
	for (i = 2; i <= n; i++) {
		ans[i] = NG;
		prev[i] = NG;
	}
	ans[1] = prev[1] = 0;
	queue<int> heya;
	queue<int> kazu;

	heya.push(1);
	kazu.push(0);
	int now, nowkazu, next, nextkazu;
	while (1) {
		if (heya.empty() == true)break;
		now = heya.front();
		heya.pop();
		nowkazu = kazu.front() + 1;
		kazu.pop();
		for (i = 0; i < a[now].size(); i++) {
			next = a[now][i];
			nextkazu = ans[next];
			if (nextkazu > nowkazu) {
				ans[next] = nowkazu;
				prev[next] = now;
				heya.push(next);
				kazu.push(nowkazu);
			}
		}
	}

	for (i = 1; i <= n; i++) {
		if (ans[i] == NG) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (i = 2; i <= n; i++) {
		cout << prev[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 10836
while 1:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(0, H):
        print("#", end="")
        for j in range(1, W - 1):
            if i == 0 or i == H - 1:
                print("#", end="")
            else:
                print(".", end="")

        print("#")
    print("")

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

int H,W;
int M;
set<pair<int,int>> Q;
int cX[300000]={};
int cY[300000]={};
int Mx,My;
vector<int> mX;
vector<int> mY;
int G[300000];

int main() {
 scanf("%d%d",&H,&W);
 scanf("%d",&M);
 rep(i,M){
  int x,y;
  scanf("%d%d",&y,&x); x--; y--;
  Q.insert(make_pair(x,y));
  cX[x]++; cY[y]++;
 }
 Mx=My=0;
 rep(i,W) Mx=max(Mx,cX[i]);
 rep(i,W) if(cX[i]==Mx) mX.push_back(i);
 rep(i,H) My=max(My,cY[i]);
 rep(i,H) if(cY[i]==My) mY.push_back(i);

 if(M < ULL(mX.size())*mY.size()){ printf("%d\n",Mx+My); return 0; }
 bool down=true;
 for(int y:mY) for(int x:mX){
  if(Q.count(make_pair(x,y))==0) down=false;
 }

 if(down) printf("%d\n",Mx+My-1);
 else printf("%d\n",Mx+My);
 
 return 0;
}

Measured memory_bytes: 23928
#include <stack>
#include <cstring>
#include <cstdlib>
#include <cstdio>

typedef long L;

int main() {
	std::stack<L> S;
	char s[20];
	while (scanf("%s",s) != EOF) {
		if (s[0] == '+') {
			L b = S.top();S.pop();
			L a = S.top();S.pop();
			S.push(a+b);
		} else if (s[0] == '-') {
			L b = S.top();S.pop();
			L a = S.top();S.pop();
			S.push(a-b);
		} else if (s[0] == '*') {
			L b = S.top();S.pop();
			L a = S.top();S.pop();
			S.push(a*b);
		} else {
			L x = atol(s);
			S.push(x);
		}
	}
	printf("%ld\n",S.top());
	S.pop();
	return 0;
}


Measured memory_bytes: 2712
fun main(args: Array<String>) {
    val mod = 1000000007L
    val (N, K) = readInputLine().split(" ").map { it.toInt() }
    val dp = Array(N + 1, {Array(N + 2, {LongArray(K + 2 * N + 1)})})
    
    dp[0][0][0] = 1
    
    for (i in 0 until N) {
        for (j in 0..N) {
            for (k in 0..K) {
                // pi = iとするケース dp[i + 1][j][k + 2 * j]にdp[i][j][k]を加算
                dp[i + 1][j][k + 2 * j] = (dp[i + 1][j][k + 2 * j] + dp[i][j][k]) % mod
                
                // iについて何もしないケース dp[i + 1][j + 1][k + 2 * j]にdp[i][j][k]を加算
                dp[i + 1][j + 1][k + 2 * j] = (dp[i + 1][j + 1][k + 2 * j] + dp[i][j][k]) % mod
                
                // iにこれまで使っていなかったpxを使うケース dp[i + 1][j][k + 2 * j]にdp[i][j][k] * jを加算(これまで使っていなかったpxの数分)
                dp[i + 1][j][k + 2 * j] = (dp[i + 1][j][k + 2 * j] + dp[i][j][k] * j % mod) % mod
                
                // x < iなるxにpiを使うケース dp[i + 1][j][k + 2 * j]にdp[i][j][k] * jを加算(これまで使っていなかったpxの数分)
                dp[i + 1][j][k + 2 * j] = (dp[i + 1][j][k + 2 * j] + dp[i][j][k] * j % mod) % mod
                
                // iにこれまで使っていなかったpxを使い、かつx < iなるxにpiを使うケース dp[i + 1][j - 1][k + 2 * j]にdp[i][j][k] * j * jを加算
                // ※1つ前と2つ前の合わせ技
                if (j > 0) {
                    dp[i + 1][j - 1][k + 2 * j] = (dp[i + 1][j - 1][k + 2 * j] + dp[i][j][k] * j % mod * j % mod) % mod
                }
            }
        }
    }
    
    println(dp[N][0][K])
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 109044
//
using System;
public class Hello{
    public static void Main(){
        var N = int.Parse(Console.ReadLine());
        int res = N;
        for(var i = 0;i <= N;i++){
            int cc = 0;
            int t = i;
            
            while(t > 0){
                cc += t % 6;
                t /= 6;
            }
            t = N - i;
            while(t > 0){
                cc += t % 9;
                t /= 9;
            }
            res = Math.Min(res,cc);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  while(cin >> n,n){
    int ret = -n;
    for(int i = 1 ; i*i < n ; i++ ){
      if(n%i == 0){
	ret += i + n/i;
	if(i == n/i)ret-=i;
      }
    }
    if( n == ret)cout << "perfect number" << endl;
    else if(n > ret)cout <<"deficient number"<< endl;
    else cout << "abundant number" << endl;
}
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007


int main(){
	int N;
	cin >> N;
	vector<long long> L(86);
	L[0] = 2;
	L[1] = 1;
	for(int i = 2; i <= N; i++){
		L[i] = L[i-2] + L[i-1]; 
	}
	cout << L[N] << endl;
}

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

int main(int argc, char *argv[])
{
    int H, W;
    int i, j;
    while(1) {
        scanf("%d %d", &H, &W);
        if(H==0&&W==0) break;
        for(i=0;i<H;i++){
            for(j=0;j<W;j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1) printf("#");
                else printf(".");
            }printf("\n");
        }
        printf("\n");

    }
    return 0;
}


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

int main(){
	char a;
	cin >> a;
	if(islower(a)){ cout << "a" << endl;
	}else{ cout << "A" << endl;
	}
	return 0;
}




Measured memory_bytes: 3516
#include<iostream>
#include<algorithm>
using namespace std;
const int INF=10000;
char a[1001],b[1001],c[1001];
void rev(int pnt,char *cp){
    for(int i=0;i<pnt/2;i++){
        char work;
        work=*(cp+i);
        *(cp+i)=*(cp+pnt-i-1);
        *(cp+pnt-i-1)=work;
    }
}
int main(){
    int n;
    cin>>n;
    while(n--){
        for(int i=0;i<1000;i++)a[i]=b[i]=c[i]=0;
        cin>>a>>b;

        int apnt,bpnt;
        for(int i=0;i<1000;i++)if(a[i]==0){apnt=i;break;}
        for(int i=0;i<1000;i++)if(b[i]==0){bpnt=i;break;}

        if(apnt>80 || bpnt>80){cout<<"overflow"<<endl;continue;}

        rev(apnt,a);
        rev(bpnt,b);
        int d[100];
        for(int i=0;i<100;i++)d[i]=0;
        int big=max(apnt,bpnt);
        for(int i=0;i<big;i++){
            if(i<apnt)d[i]+=a[i]-'0';
            if(i<bpnt)d[i]+=b[i]-'0';
        }
        for(int i=0;i<big;i++){
            if(d[i]>=10){
                d[i]%=10;
                d[i+1]++;
            }
        }
        if(d[big]==1)big++;
        if(big>80){
            cout<<"overflow"<<endl;
            continue;
        }
        for(int i=0;i<big;i++){
            c[i]=d[i]+'0';
        }
        rev(big,c);
        cout<<c<<endl;
    }
    return 0;
}

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

testimonies = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        testimonies[i].append((x - 1, y))


def is_honest(people, number):
    return (bool)(people & (1 << number))


ans = 0
for assumption in range(2 ** n):
    contradicted = False
    for i in range(n):
        if not is_honest(assumption, i):
            continue
        for x, y in testimonies[i]:
            if is_honest(assumption, x) ^ y:
                contradicted = True
    if not contradicted:
        ans = max(ans, bin(assumption).count('1'))

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
   string s,t;
   cin>>s>>t;
   int d=-1;
   for(int i=0;i<=(int)(s.size()-t.size());i++)
   {
       int c=1;
       for(int j=0;j<t.size();j++)
       {
           if(s[i+j]!='?' && s[i+j]!=t[j])
           {
			   c=0;
			   break;
		   }
       }
       if(c==1){
           d=i;
	   }
   }
    if(d==-1)
		cout<<"UNRESTORABLE\n";
    else
    {
        int j=0;
        while(j<t.size())
        {
            s[d+j]=t[j];
            j++;
        }
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='?')
                s[i]='a';
        }
        cout<<s<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
def bfs(u, n, g):
    queue = deque([u])
    d = [None] * n # uからの距離の初期化
    d[u] = 0 # 自分との距離は0
    while queue:
        v = queue.popleft()
        for i in g[v]:
            if d[i] is None:
                d[i] = d[v] + 1
                queue.append(i)
    return d

N, X, Y =MI()
E = [[] for _ in range(N + 1)]
for i in range(1, N):
    a = i
    b = i + 1
    E[a].append(b)
    E[b].append(a)
E[X].append(Y)
E[Y].append(X)

dist = [0] * N

for i in range(1, N + 1):
    D = deque(bfs(i, N + 1, E))
    D.popleft()
    for d in D:
        dist[d] += 1

for i in range(1, N):
    print(dist[i] // 2)

Measured memory_bytes: 79680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();

        int answer = a == b ? 2 * a : Math.Max(a, b) * 2 - 1;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
int A,B,C;
cin>>A>>B>>C;
if(A==5&&B==5&&C==7)
{
cout<<"YES";
}
else if(A==5&&B==7&&C==5)
{
cout<<"YES";}
else if(A==7&&B==5&&C==5)
{
cout<<"YES";
}
else
{
cout<<"NO";
}
return 0;
}


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

long long k;

int n;
long long dp[5007][9];
int co[5007];

string slo="-FESTIVAL";

string wyn;

int main()
{
	scanf("%lld", &k);
	dp[0][0]=1;
	while(dp[n][7]*100<k)
	{
		n++;
		co[n]=(n-1)%7+1;
		for (int i=0; i<=7; i++)
			dp[n][i]=dp[n-1][i];
		dp[n][co[n]]+=dp[n-1][co[n]-1];
	}
	for (int i=n; i; i--)
	{
		while(k && dp[i][7]<=k)
		{
			k-=dp[i][7];
			wyn+='L';
		}
		wyn+=slo[co[i]];
	}
	reverse(wyn.begin(), wyn.end());
	cout << wyn << endl;
	return 0;
}


Measured memory_bytes: 768
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    aa=deque()
    for _ in range(n):
        qq=list(map(int, input().split()))
        if qq[0]==0:
            if qq[1]:aa.append(qq[2])
            else:aa.appendleft(qq[2])
        elif qq[0]==1:
            print(aa[qq[1]])
        else:
            if qq[1]:aa.pop()
            else:aa.popleft()

main()


Measured memory_bytes: 21844
N = int(input())
W = list(map(int,input().split()))
m = sum(W)
for i in range(1,N):
  S1 = sum(W[:i])
  S2 = sum(W[i:])
  if m > abs(S1-S2):
    m = abs(S1-S2)
print(m)

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

typedef long long ll;

int main() {
	ll n; cin >> n;
	auto digits = [&](ll x) {
		int len = 0;
		while (x != 0) {
			x /= 10;
			len++;
		}
		return len;
	};
	int ans = digits(n);

	for (ll i = 2; i * i <= n; i++) {
		if (n % i != 0)continue;
		int b = n / i, len;
		len = max(digits(i), digits(b));
		if (ans > len) {
			ans = len;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int mod = 1e9+7;
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;}

string s;

int main() {
    cin >> s;

    string t = "ATCG";

    ll ret = 0;
    ll now = 0;
    rep(i, s.size()) {
        bool isATCG = false;
        rep(j, t.size()) {
            if(s[i] == t[j]) isATCG = true;
        }
        if (!isATCG) now = 0;
        else {
            now++;
            ret = max(ret, now);
        }
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long temp[200000]={0};
int main()
{int n,ans=0,ans2;
  int a[200000];
     cin>>n;
   for(int i=1;i<=n;i++)
     cin>>a[i];
	 for(int i=1;i<=n;i++)
	 	{if(temp[a[i]]==0) 
		 {temp[a[i]]=1;ans++;
		    }else continue;
		 }
		 if(ans%2)  ans2=ans;
		 else ans2=ans-1;
		 cout<<ans2<<endl;
		 return 0;
}
 

Measured memory_bytes: 1408
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
    int src,to;
    T cost,coin;

    edge() = default;
    edge(int to, T cost, T coin) : src(-1), to(to), cost(cost), coin(coin) {}
    edge(int src, int to, T cost, T coin) : src(src), to(to), cost(cost), coin(coin) {}
    bool operator<(const edge &e) const {
        return cost < e.cost;
    }
};

using Tu = tuple<ll, int, ll>;
const int MAX = 20000;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M,S; cin >> N >> M >> S;
    vector<vector<edge<ll>>> G(N);
    rep(i,M) {
        int u,v,a,b; cin >> u >> v >> a >> b;
        --u; --v;
        G[u].emplace_back(v,b,a);
        G[v].emplace_back(u,b,a);
    }
    vector<ll> C(N),D(N);
    rep(i,N) cin >> C[i] >> D[i];

    chmin(S,MAX-1);
    vector<vector<ll>> dist(N,vector<ll>(MAX,4e18));
    vector<vector<bool>> check(N, vector<bool>(MAX));
    dist[0][S] = 0;
    priority_queue<Tu, vector<Tu>, greater<Tu>> pq;
    pq.emplace(make_tuple(0,0,S));
    while (!pq.empty()) {
        ll d,c;
        int v;
        tie(d,v,c) = pq.top(); pq.pop();
        //cout << d << " " << v << " " << c << ln;
        if (d > dist[v][c]) continue;
        for (auto &e : G[v]) {
            if (c < e.coin) continue;
            if (chmin(dist[e.to][c-e.coin],dist[v][c]+e.cost)) {
                pq.emplace(make_tuple(dist[e.to][c-e.coin], e.to, c-e.coin));
            }
        }
        if (!check[v][c]) {
            check[v][c] = 1;
            for (ll i = 1; c+i*C[v] < MAX; i++) {
                if (chmin(dist[v][c+i*C[v]],dist[v][c]+i*D[v])) {
                    pq.emplace(make_tuple(dist[v][c+i*C[v]], v, c+i*C[v])); 
                } 
                check[v][c+i*C[v]] = 1;
            }
        }
    }

    for (int i = 1; i < N; i++) {
        ll ans = 4e18;
        rep(j,MAX) {
            chmin(ans,dist[i][j]);
        }
        cout << ans << ln;
    }
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,d,k;cin >> n >> d >> k;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	int ans=k;
	rep(i,n){
		for(int j=1;j<=d;j+=a.at(i)) ans++;
	}
	cout << ans << endl;
}

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

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int k, n;
    cin >> k >> n;
    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    ll rem = 0;
    for(int i = 1; i <= n; i++){
        if(i < n) rem = max(rem, a[i + 1] - a[i]);
        else rem = max(rem, k - a[i] + a[1]);
    }
    cout << k - rem;
    return 0;
}


Measured memory_bytes: 1792