akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
class Main
{
    public static void main(String args[])throws IOException
    {
        Scanner obj=new Scanner(System.in);
        int i,c=0;String ns="";
        String s=obj.nextLine();
        String t=obj.nextLine();
        for(i=0;i<s.length();i++)
           {
               if(s.charAt(i)!=t.charAt(i))
                    c++;
               else
                    continue;
            }
        System.out.println(c);   
    }
}

Measured memory_bytes: 33904
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;


int main(){

    ll N, K, a = 1;
    cin >> N >> K;
    rep(i, N){
        if(a > K)a += K;
        else a += a;
    }
    cout << a << endl;
    
    return 0;
}

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 13;

int H, W;
char s[MAXN][MAXN];

int to[MAXN], tmp[MAXN];
char vis[MAXN];

int tot;
char used[MAXN];

void check()
{
	FOR(i, 1, W) assert(to[i]);
	FOR(i, 1, W) tmp[i] = to[i]; FOR(i, 1, W) to[tmp[i]] = i;

	char fir = (H & 1);
	memset(used, 0, sizeof used);

	FOR(i, 1, H) {
		if (!used[i]) {
			used[i] = true;
			char ok = false;
			FOR(j, i + 1, H) {
				if (!used[j]) {
					char flag = true;
					FOR(k, 1, W) if (s[j][to[W - k + 1]] != s[i][to[k]]) {flag = false; break;}
					if (flag) {ok = true; used[j] = true; break;}
				}
			}
			if (!ok) {
				if (fir) {
					char can = true;
					FOR(k, 1, W) if (s[i][to[k]] != s[i][to[W - k + 1]]) {can = false; break;}
					if (can) {fir = false; continue;}
				}
			}
			else continue;
			FOR(j, 1, W) to[j] = tmp[j];
			return;
		}
	}

	puts("YES"); exit(0);
}

void search(int now, int pos)
{
	if (vis[now]) {
		if (now == W) check();
		else search(now + 1, pos);
		return;
	}
	vis[now] = true;
	if ((W & 1) && !vis[0]) {
		vis[0] = true;
		to[now] = (W + 1) / 2;
		if (now == W) check();
		else search(now + 1, pos);
		vis[0] = false;
		to[now] = 0;
	}
	FOR(i, now + 1, W) {
		if (!vis[i]) {
			vis[i] = true;
			to[now] = pos;
			to[i] = (W - pos + 1);
			if (now == W) check();
			else search(now + 1, pos + 1);
			vis[i] = false;
			to[now] = to[i] = 0;
		}
	}
	vis[now] = false;
}

int main()
{
	in(H); in(W);
	FOR(i, 1, H) scanf("%s", s[i] + 1);
	search(1, 1);
	puts("NO");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    ll n,T,ans = 0;
    cin >> n >> T;
    vector<ll> t(n);
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    ans = T;
    for (int i = 0; i < n-1; ++i) {
        ans += (min(T,t[i+1]-t[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 17:55:54 2019

@author: avina
"""

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

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

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> row(n+1, 0), col(m+1, 0);
	
	set<int> have[n+1];
	
	for(int i = 0, x, y; i < k; i++) {
		cin >> x >> y;
		row[x]++;
		col[y]++;
		have[x].insert(y);
	}
	
	int maxx = 0, maxy = 0;
	for(int i = 1; i <= n; i++) {
		if(row[i] > row[maxx])
			maxx = i;
	}
	for(int i = 1; i <= m; i++) {
		if(col[i] > col[maxy])
			maxy = i;
	}
	vector<int> x, y;
	for(int i = 1; i <= n; i++) {
		if(row[i] == row[maxx])
			x.push_back(i);
	}
	for(int i = 1; i <= m; i++) {
		if(col[i] == col[maxy])
			y.push_back(i);
	}
	int ans = row[maxx] + col[maxy] - 1;
	if(x.size() * y.size() > 300000) {
		cout << ans + 1;
		return 0;
	}
	
	for(int i : x) {
		for(int j : y) {
			ans = max(ans, row[i] + col[j] - (int)(have[i].count(j)));
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 37864
import java.util.Scanner;
//import java.io.*;
//import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		//InputStreamReader is = new InputStreamReader(System.in);
		//BufferedReader br = new BufferedReader(is);
		int n = scan.nextInt();
		int tensuu[] = new int[n];
		String action;
		for(int i = 0 ; i < n ; i++){
			int out = 0;
			int rui = 0;
			while(out < 3){
				action = scan.next();
				if(action.equals("OUT")){
					++out;
				}else if(action.equals("HIT")){
					++rui;
					if(rui == 4){
						++tensuu[i];
						rui = 3;
					}
				}else{
					tensuu[i] += rui+1;
					rui = 0;
				}
			}
		}
		for(int i = 0 ; i < n ; i++){
			System.out.println(tensuu[i]);
		}
	}
}

Measured memory_bytes: 25892
N = gets.to_i
A = gets.split.map(&:to_i)

INF = 10**9
dp0 = [-INF] * (N+1)
dp1 = [-INF] * (N+1)
dp0[0] = 0

N.times do |i|
  dp0[i+1] = [dp0[i+1], dp0[i] + A[i]].max
  dp0[i+1] = [dp0[i+1], dp1[i] - A[i]].max
  if i<N-1
    dp1[i+1] = [dp1[i+1], dp0[i] - A[i]].max
    dp1[i+1] = [dp1[i+1], dp1[i] + A[i]].max
  end
end
puts [dp0[N], dp1[N]].max


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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

int N;
int a[2][100];

signed main(){
	cin >> N;
	
	REP(i, 0, 2)	REP(j, 0, N)	cin >> a[i][j];
	
	int ans = 0;
	int u, wk;
	REP(i, 0, N) {
		u = 0;
		wk = 0;
		REP(j, 0, N) {
			if(j == i){
				wk += a[u][j];
				u = 1;
			}
			wk += a[u][j];
		}
		ans = max(ans, wk);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
line1 = input().split(" ")
line2 = input().split(" ")
line3 = input().split(" ")
N = int(input())


line1hit = [0,0,0]
line2hit = [0,0,0]
line3hit = [0,0,0]

for i in range(N):
    val = input()

    for index in range(len(line1)):
        if val == line1[index]:
            line1hit[index] =1

        if val == line2[index]:
            line2hit[index] =1

        if val == line3[index]:
            line3hit[index] =1

if line1hit[0] * line1hit[1] * line1hit[2] == 1:
    print('Yes')
elif  line2hit[0] * line2hit[1] * line2hit[2] ==1:
    print('Yes')
elif  line3hit[0] * line3hit[1] * line3hit[2] ==1:
    print('Yes')

elif line1hit[0] * line2hit[0] * line3hit[0] ==1:
    print('Yes')
elif  line1hit[1] * line2hit[1] * line3hit[1] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[2] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[0] * line2hit[1] * line3hit[2] ==1:
    print('Yes')
elif  line1hit[2] * line2hit[1] * line3hit[0] ==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

pair<int, int> pd[10010];

int main(void) {
	while(true) {
		int N, M;
		cin >> N >> M;
		if ( N==0 ) { break; }
		
		
		REP(i, N) {
			int D, P;
			cin >> D >> P;
			pd[i] = make_pair(P,D);
		}
		//sort(pd, pd+N);
		//reverse(pd, pd+N);
		sort(pd, pd+N, greater<pair<int, int> >());
		
		int ret = 0;
		REP(i, N) {
			if ( M > 0 ) {
				M -= pd[i].second;
				if ( M < 0 ) {
					ret += -M * pd[i].first;
				}
			} else {
				ret += pd[i].first*pd[i].second;
			}
		}
		
		cout << ret <<endl;
	}
}

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

int main(){
  int X, A, B;
  cin >> X >> A >> B;
  
  if(X >= B - A && A < B){
    cout << "safe" << endl;
  }
  else if(B - A <= 0)
  {cout << "delicious" << endl;}
  else{cout << "dangerous" << endl;}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll roundd(ll x,ll n){
  if(x>n){return x%n;}
  else if(x<0){return x%n+n;}
  else return x;
}
int main(){
  ll n;cin>>n;
  vvll g(10,vll(10,0));
  rep(i,1,n+1){
    string s=to_string(i);
    g[s[0]-'0'][s[s.size()-1]-'0']++;
  }
  ll ans=0;
  rep(i,1,10){
    rep(j,1,i+1){
      ans+=g[i][j]*g[j][i];
      if(i!=j)ans+=g[i][j]*g[j][i];
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3648
//package may2020;

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();
		OutputStream out = new BufferedOutputStream(System.out);
		
		int n =scn.nextInt();
		
//		int[] a = new int[n];
		HashMap<Integer, pair> map1 = new HashMap<>();
		HashMap<Integer, pair> map2 = new HashMap<>();
		
		for(int i=0;i<n;i++) {
			if(i%2==0) {
				addMap(map1, scn.nextInt());
			}else {
				addMap(map2,scn.nextInt());
			}
		}
		
		pair[] arr1 = getArr(map1);
		pair[] arr2 = getArr(map2);
		if(arr1[0].v!=arr2[0].v) {
			int ans =n-arr1[0].f-arr2[0].f;
			out.write((ans+"\n").getBytes());
		}else {
			if(arr1.length==1) {
				if(arr2.length==1) {
					out.write((n/2+"\n").getBytes());
				}else {
					out.write((n-arr1[0].f-arr2[1].f+"\n").getBytes());
				}
			}else {
				if(arr2.length==1) {
					out.write((n-arr1[1].f-arr2[0].f+"\n").getBytes());
				}else {
					int m = Math.max(arr1[0].f+arr2[1].f, arr1[1].f+arr2[0].f);
					out.write((n-m+"\n").getBytes());
				}
			}
		}
		
		out.close();
	}
	static class pair{
		int v,f;
		public pair(int v,int f) {
			this.v = v;
			this.f = f;
		}
	}
	static pair[] getArr(HashMap<Integer, pair> map) {
		pair[] res = map.values().toArray(new pair[0]);
		Arrays.sort(res,(p1,p2)->p2.f-p1.f);
		return res;
	}
	static void addMap(HashMap<Integer, pair> map,int o) {
		if(!map.containsKey(o)) {
			map.put(o, new pair(o,1));
		}else {
			map.get(o).f++;
		}
	}
	static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    }
}


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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<ll, ll> Pair;
typedef vector<Pair> VP;

#define MOD 1000000007
#define times(n) rep(_idx, n)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define in(a, l, r) (l <= a && a < r)
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template<typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

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

    char ch[] = { 'L', 'R' };
    rep(i, S.size()) if(S[i] == ch[i % 2]) {
        out("No")
        return 0;
    }
    out("Yes");
    return 0;
}

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


//////////////////

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int N, L;
    cin >> N >> L;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    
    vector<int> max_idx(N);
    deque<int> deq;
    rep(i,N){
        if(!deq.empty() && deq[0] <= i-L)
            deq.pop_front();
        while(!deq.empty() && a[deq.back()] > a[i])
            deq.pop_back();
        deq.push_back(i);

        if(i>=L-1){
            cout << a[ deq[0] ];
            if(i!=N-1) cout << " ";
        }
    }
    cout << endl;
    
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



Measured memory_bytes: 18928
#include <stdio.h>

int main()
{
	long long T[3], A[3], B[3];
	scanf("%lld %lld", &(T[1]), &(T[2]));
	scanf("%lld %lld", &(A[1]), &(A[2]));
	scanf("%lld %lld", &(B[1]), &(B[2]));
	if (A[1] * T[1] + A[2] * T[2] == B[1] * T[1] + B[2] * T[2]) {
		printf("infinity\n");
		fflush(stdout);
		return 0;
	}
	
	if (A[1] > B[1]) {
		A[1] += B[1];
		B[1] = A[1] - B[1];
		A[1] -= B[1];
		A[2] += B[2];
		B[2] = A[2] - B[2];
		A[2] -= B[2];
	}
	if ((B[1] - A[1]) * T[1] > (A[2] - B[2]) * T[2]) printf("0\n");
	else if ((B[1] - A[1]) * T[1] % ((A[2] - B[2]) * T[2] - (B[1] - A[1]) * T[1]) == 0) printf("%lld\n", (B[1] - A[1]) * T[1] / ((A[2] - B[2]) * T[2] - (B[1] - A[1]) * T[1]) * 2);
	else printf("%lld\n", (B[1] - A[1]) * T[1] / ((A[2] - B[2]) * T[2] - (B[1] - A[1]) * T[1]) * 2 + 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int c;
    cin >> c;
    if(c<1200){
        cout <<"ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 100005

using namespace std;

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


Measured memory_bytes: 8296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());
    while(1){
        if (v.size() == 1) break;
        v[0] = (v[0] + v[1]) / 2;
        v.erase(v.begin() + 1);
        sort(v.begin(), v.end());
    }
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    long long h, w; cin >> h >> w;
    long long ans=numeric_limits<long long>::max();
    for(int i=1; i<=(h+1)/2; ++i){
        long long a=w*i;
        long long r=h-i;
        long long b=r*(w/2), c=r*(w-w/2);
        long long mx=max(a, max(b, c)), mn=min(a, min(b, c));
        ans=min(ans, mx-mn);
        if(h-i*2>0){
            long long a=i*w, b=i*w, c=(h-i*2)*w;
            long long mx=max(a, max(b, c)), mn=min(a, min(b, c));
            ans=min(ans, mx-mn);
        }
    }
    for(int i=1; i<=(w+1)/2; ++i){
        long long a=h*i;
        long long r=w-i;
        long long b=r*(h/2), c=r*(h-h/2);
        long long mx=max(a, max(b, c)), mn=min(a, min(b, c));
        ans=min(ans, mx-mn);
        if(w-i*2>0){
            long long a=i*h, b=i*h, c=(w-i*2)*h;
            long long mx=max(a, max(b, c)), mn=min(a, min(b, c));
            ans=min(ans, mx-mn);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    int cnt = 0;
    while(A>=B)
    {
        B *= 2;
        cnt++;
    }
    while(B>=C)
    {
        C*=2;
        cnt++;
    }
    if(cnt<=K)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
def check():
    N = int(input())
    plus,minus = [],[]
    for i in range(N):
        S = input()
        now = 0
        mini = 0
        for s in S:
            if s=='(':
                now += 1
            else:
                now -= 1
                mini = min(mini,now)
        if now>=0:
            plus.append([mini,now])
        else:
            minus.append([now-mini,now])
    plus.sort(reverse=True)
    minus.sort(reverse=True)
    now = 0
    for a,b in plus:
        if now + a <0:
            return 'No'
        now += b
    for a,b in minus:
        if now + b-a <0:
            return 'No'
        now += b
    if now > 0:
        return 'No' 
    return 'Yes'
print(check())

Measured memory_bytes: 229276
from collections import deque
class UnionFind():
    def __init__(self,num):
        self.n = num         #class内変数nに、外部から入力した値numを代入
        self.parents = [-1 for i in range(self.n)]
          #parentsは要素の親(1こ上のやつ)番号0~n-1を格納、自分が最親なら-(要素数)を格納(初期値は-1)

    #xの最親は誰？
    def find(self,x):
        if self.parents[x]<0:
            return x
        else:
            self.parents[x]=self.find(self.parents[x]) #再帰して1番上までいってる
                #調べながらparentsの値を更新してる！（経路圧縮）
            return self.parents[x]

    #結合せよ
    #xの親とyの親をくっつける
    def union(self,x,y):
        xx=self.find(x)  #xxはxの最親
        yy=self.find(y)  #yyはyの最親
        if xx==yy:
            return     #同じ屋根の下にあった場合は何もしない
        else:
            size_xx=abs(self.parents[xx]) #xが含まれる木のサイズ
            size_yy=abs(self.parents[yy]) #yが含まれる木のサイズ
            if size_xx>size_yy:
                xx,yy=yy,xx  #yyの方が大きい木、ってことにする

            self.parents[yy]+=self.parents[xx] #大きい木のサイズ更新
            self.parents[xx]=yy   #サイズが小さい木を大きい木に接ぐ

    #xの属する木の大きさ（まあunionでも使ったけど）
    def size(self,x):
        xx=self.find(x)
        return abs(self.parents[xx])

    #xとyはこの空の続く場所にいますか　いつものように笑顔でいてくれますか　今はただそれを願い続ける
    def same(self,x,y):
        return True if self.find(x)==self.find(y) else False

    #xと　同じ木にいる　メンバーは？
    def members(self,x):
        xx=self.find(x)
        return [i for i in range(self.n) if self.find(i)==xx]
             #ifの条件式に漏れたら無視

    #最親だけを並べあげる
    def roots(self):
        return [i for i,x in enumerate(self.parents) if x < 0]
        #いやこれは天才すぎる、basisのenumerate.py参照

    #すべての最親について、メンバーを辞書で
    def all_group_members(self):
        return {r:self.members(r) for r in self.roots()}

    #グループ分けどうなりましたか、２重リストで
    def state_grouping(self):
        return list(self.all_group_members().values())

    #出力用
    def __str__(self):
        return "\n".join("{}: {}".format(r,self.members(r)) for r in self.roots())
        #"\n"はただの改行コード
        #str(辞書)を改行しながら表示する
        #print(インスタンス)で__str__に飛ぶ
        #出力過程で、membersで全要素にfindをしてる→逐一経路圧縮されてる！


n,m=map(int,input().split())
uf=UnionFind(n)
A=[]
for i in range(m):
    A.append(list(map(int,input().split())))
ans=[0 for i in range(m)] #つながるかず

for i in range(1,m):
    q,w=A[-i] ; q-=1 ; w-=1 ; 
    if uf.same(q,w) :
      ans[i]=ans[i-1]
      continue
    a=uf.size(q) ; b=uf.size(w)
    ans[i]=ans[i-1]-a*(a-1)//2-b*(b-1)//2+(a+b)*(a+b-1)//2
    uf.union(q,w)

    
for i in range(m):

    print(n*(n-1)//2 - ans[m-1-i])


    

Measured memory_bytes: 112800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (ll i = a; i < n; ++i)
#define all(x) x.begin(), x.end()
const ll MAX = 510000;
const ll MOD = 1000000007;
const ll INF = 10e12;

int main(void)
{
    ll n;
    cin >> n;
    if (n == 1)
        cout << "Hello World" << endl;
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
const int INF = 1e9;
const ll MOD = 1000000007;
const ll LINF = 1e18;
using namespace std;



int main()
{
    int a;
    string s, t,j = "Yes";
    
    cin>>s>>t;
    
    for(int i =0; i<s.size(); i++){
        if(s[i]!=t[i]) j = "No";
    }
    
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(x + r > W || x - r < 0 || y + r > H || y - r < 0)
    {
        printf("No\n");
    }

    else
    {
        printf("Yes\n");
    }

    return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 3e5 + 5;

typedef pair<int,int>   ii;

struct BIT  {
    int t[N];

    int upd(int p,int x)    {
        for(; p > 0 ; p -= p & -p)
            t[p] += x;
        return  1;
    }
    int get(int p)  {
        int ans = 0;
        for(; p < N ; p += p & -p)
            ans += t[p];
        return  ans;
    }
}   T[2];

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

    int n;  cin >> n;
    ll  x = 0;
    ll  y = 0;

    for(int i = 1 ; i <= n ; ++i)   {
        int p;  cin >> p;
        int v = i % 2;

        if (p % 2 != v) {
            cout << "No";
            return  0;
        }
        x += T[v].get(p);   v ^= 1;
        y += T[v].get(p);   v ^= 1;

        T[v].upd(p,1);
    }
    if (y == x + x) cout << "Yes";
    else            cout << "No";
}

Measured memory_bytes: 2560
#include <functional>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int c=0;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<3;i++)
	{
		if(s[i]==t[i])
		{
			c++;
		}
	 } 
	 cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,b,f,r,v=0;
  int a,c,d,e=0;
  int g,h,i=0;
  int A[4][3][10]={0};
  scanf("%d",&n);
  for(c=0;c<n;c++){
    scanf("%d %d %d %d",&b,&f,&r,&v);
    a=b-1;
    d=f-1;
    e=r-1;
    A[a][d][e]=A[a][d][e]+v;
    if(A[a][d][e]<0){
      A[a][d][e]=0;
    }
  }
  for(g=0;g<=3;g++){
    for(h=0;h<=2;h++){
      for(i=0;i<10;i++){
	if(i==9){
	  printf(" %d\n",A[g][h][i]);
	}
	else{
	  printf(" %d",A[g][h][i]);
	}
      }
    }
    if(g!=3){
      printf("####################\n");
    }
  }
  return 0;
}

Measured memory_bytes: 608
n = int(input())
if n < 600:
  print(8)
elif n < 800:
  print(7)
elif n < 1000:
  print(6)
elif n < 1200:
	print(5)
elif n < 1400:
  print(4)
elif n < 1600:
  print(3)
elif n < 1800:
	print(2)
else:
  print(1)

Measured memory_bytes: 9044
#include<stdio.h>
int main(){
  int n,h,m;
  scanf("%d",&n);
  while(n--){
    scanf("%d:%d",&h,&m);
    h=h*300+m*5;
    m*=60;
    h=abs(h-m);
    if(h>60*60-h)h=60*60-h;
    if     (h< 5*60)printf("alert\n");
    else if(h<15*60)printf("warning\n");
    else            printf("safe\n");
  }
  return 0;
}

Measured memory_bytes: 580
a, b, c = map(int, input().split())
b_list = list(map(int, input().split()))
ans = 0
for i in range(a):
        a_list = list(map(int, input().split()))
        chk = c
        for j in range(b):
                chk += a_list[j] * b_list[j]
        if chk > 0:
                ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int p,d,d2;
    for(int i=0;i<n;i++){
      cin>>p>>d>>d2;
      if(p==100||d==100||d2==100){
	cout<<'A'<<endl;
      }else if((p+d)/2>=90){
	cout<<'A'<<endl;
      }else if((p+d+d2)/3>=80){
	cout<<'A'<<endl;
      }else if((p+d+d2)/3>=70){
	cout<<'B'<<endl;
      }else if((p+d+d2)/3>=50&&(p>=80||d>=80)){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return(0);
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x ,n) for(int i = x; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n,l;
    string s[110];
    cin >> n >> l;
    
    rep(i,n)cin >> s[i];
    sort(s,s+n);
    
    rep(i,n)cout << s[i];
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 3600
#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];
	}
	sort(h.begin(), h.end());
	reverse(h.begin(), h.end());

	int ans=1e9;
	for (int i = 0; i <= N - K; i++) {
		ans = min(ans, abs(h[i+K-1]-h[i]));
	}

	cout << ans << endl;

}


Measured memory_bytes: 640
import java.util.Scanner;
class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		for(;;) {
		int max= -100000;
		int n=sc.nextInt();
		if(n==0)break;
		int a[]=new int[n];
		for(int i=0;i<n;i++)a[i]=sc.nextInt();

		for(int i=0;i<n;i++) {
			int sum=0;
				for(int j=i;j<n;j++) {
				sum+=a[j];
			max=Math.max(max, sum);
		}
		}
		System.out.println(max);
		}
	}
	}




Measured memory_bytes: 35484
N = int(input())
A = input()
B = input()
C = input()

if A == B and A == C and B == C:
    print(0)
    quit()

count = 0
for a, b, c in zip(A, B, C):
    if a != b and a != c and b != c:
        count += 2
    elif a == b and a == c and b ==c:
        continue
    else:
        count += 1
print(count)


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a[n+1], ans = INF;
    a[0] = 0;
    REP(i, n) a[i+1] = a[i] + (s[i]=='#');
    REP(i, n+1){
        int b = a[i];
        int w = (n-i) - (a[n]-a[i]);
        ans = min(ans, b+w);
    }
    cout << ans << endl;
}

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

#define infile "../test/sample-1.in"
#define int long long
// #define INF 2147483647
#define INF 1000000000000000000LL
#define MOD 1000000007LL

// {{{ define basic macro
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) repi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)

#define foreach(x,a) for(auto& (x) : (a) )
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

#define all(x) (x).begin(),(x).end()
#define sum(v) accumulate(all(v), 0)
#define sz(x) ((int)(x).size())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define fill(x,y) memset(x,y,sizeof(x))
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)

template <class T = int>
T in() {T x; cin>>x; return (x);}

struct Fast {
  Fast(){
    std::cin.tie(0);
    ios::sync_with_stdio(false);
  }
} fast;
// }}}
//{{{ dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}
//{{{ others
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;

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


int solve(){
  int q,h,s,d;cin>>q>>h>>s>>d;
  int n;cin>>n;

  int c = min(min(4*q, 2*h), s);

  if (2*c<d) {
    cout << n*c << endl;
  }
  else{
    cout << (n/2)*d + (n%2)*c << endl;
  }

  return 0;
}

int test(){ //{{{
  return 0;
}
//}}}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
#ifdef PCM
  test();
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
N,M = map(int, input().split())
L = []
K = []

A = []
B = []
C = []
D = []
E = []
F = []
G = []
H = []

for i in range(M):
    s,c = map(int, input().split())
    L.append([s,c])
for i in range(M):
    for j in range(M):
        if L[i][0] == L[j][0] and L[i][1] != L[j][1]:
            K.append(-1)
            break
    break
if len(K) == 1:
    print(K[0])

elif N == 1:
    if M == 0:
        print(0)
    else:
        for a in range(M):
            A.append(L[a][1])
        print(min(A))
elif N == 2:
    if M == 0:
        print(10)
    else:
        for b in range(M):
            if L[b][0] == 1 and L[b][1] != 0:
                B.append(L[b][1])
            elif L[b][0] == 2:
                C.append(L[b][1])
            elif L[b][0] == 1 and L[b][1] == 0:
                G.append(-1)
        if G != []:
            print(-1)
        elif B == []:
            print('1' + str(min(C)))
        elif C == []:
            print(str(min(B)) + '0')
        else:
            x = min(B)
            y = min(C)
            print(str(x) + str(y))

elif N == 3:
    if M == 0:
        print(100)
    else:
        for b in range(M):
            if L[b][0] == 1 and L[b][1] != 0:
                D.append(L[b][1])
            elif L[b][0] == 2:
                E.append(L[b][1])
            elif L[b][0] == 3:
                F.append(L[b][1])
            elif L[b][0] == 1 and L[b][1] == 0:
                H.append(-1)
        if H != []:
            print(-1)
        elif D == [] and E == []:
            print('10' + str(min(F)))
        elif D == [] and F == []:
            print('1' + str(min(E)) + '0')
        elif E == [] and F == []:
            print(str(min(D)) + '00')
        elif D == []:
            print('1' + str(min(E)) + str(min(F)))
        elif E == []:
            print(str(min(D)) + '0' + str(min(F)))
        elif F == []:
            print(str(min(D)) + str(min(E)) + '0')
        else:
            print(str(min(D)) + str(min(E)) + str(min(F)))


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll L, R;
	cin >> L >> R;
	if (R - L >= 2019) {
		cout << 0 << endl;
		return 0;
	}
	vvi V(2020);
	REP(i, 2020) {
		REP(j, 2020) {
			V[i].push_back( (i * j) % 2019);
		}
	}
	vi A;
	for (int i = L; i <= R; i++) {
		A.push_back(i % 2019);
	}
	so(A);
	int ans = 2018;
	REP(i, SZ(A)) {
		REP(j, i) {
			chmin(ans,( A[i] * A[j]) % 2019);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String input = br.readLine();
    	char [] c = input.toCharArray();
    	for(int i = 0;i <c.length; i++){
    		if(Character.isUpperCase(c[i])){
    			c[i] = Character.toLowerCase(c[i]);
    		}
    		else if(Character.isLowerCase(c[i])){
    			c[i] = Character.toUpperCase(c[i]);
    		}
    		else{
    			c[i] = c[i];
    		}
    	}
    	System.out.println(c);
    }
}

Measured memory_bytes: 24340
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int E = sc.nextInt();
            if(E==0)break;
            
            int ans = E;
            
            for(int z=0; z*z*z<=E ;z++){
                int Cz = z*z*z;
                for(int y=0;y*y<=E-Cz;y++){
                    
                    int x = E - Cz - y*y;
                    
                    if(ans>x+y+z){
                        ans = x+y+z;
                    }
                }
            }
            
            System.out.println(ans);
            
        }
        
    }
}

Measured memory_bytes: 26744
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
	  result=(result*base)%modulus;
	  exponent=exponent>>1;
	  base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
string s,t;
int main(){FAST;
cin>>s>>t;
ll n = s.length();
for(ll i=0;i<n;i++){
	string S = s.substr(i,n);
	if(S == t){
		cout<<"Yes";
		return 0;
	}
	s.pb(s[i]);
}
cout<<"No";
return 0;
}

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

int main () {
    int a, b;
    cin >> a >> b;
    string c;
    if(a > b) c = ">";
    if(a < b) c = "<";
    if(a == b) c = "==";
    cout << "a" << " " << c << " " << "b" << endl;
}


Measured memory_bytes: 3204
alps = 'abcdefghijklmnopqrstuvwxyz'
def dfs(last, curr_s, sl, n):
    if len(curr_s) == n:
        sl.append(curr_s)
        return
    for i in range(0,last+2):
        s = curr_s + alps[i]
        dfs( max(last,i), s, sl, n )   


def main():
    n = int(input())
    sl = []
    dfs(0, 'a', sl, n)
    # print(sl)
    for s in sl:
        print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 17304
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <math.h>
#include <string>
#include <iomanip>
#include <locale>
#include <list>
#include <bitset>
using namespace std;
#define FORN(i,m,n) for(int i=(m); i<int(n); i++)
#define PRINTVEC(v) FORN(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define PRINTMAT(m) FORN(j,0,m.size()) {PRINTVEC(m[j]);}
#define PB(x) push_back(x)
#define MP(a,b) make_pair(a,b)
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  ll a,b,k,tmp;
  cin>>a>>b>>k;
  tmp = min(a,k);
  a -= tmp;
  k -= tmp;
  b -= min(b,k);
  cout<<a<<" "<<b<<endl;
}

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

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

using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	vector<int>dp(100001,0);
	dp[0] = 1;

	for (int i = 100; i < 100001; i++) {
		if (dp[i - 100] == 1)dp[i] = 1;
		if (i >= 101) {
			if (dp[i - 101] == 1)dp[i] = 1;
		}
		if (i >= 102) {
			if (dp[i - 102] == 1)dp[i] = 1;
		}
		if (i >= 103) {
			if (dp[i - 103] == 1)dp[i] = 1;
		}
		if (i >= 104) {
			if (dp[i - 104] == 1)dp[i] = 1;
		}
		if (i >= 105) {
			if (dp[i - 105] == 1)dp[i] = 1;
		}
	}
	cout << dp[x] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,ans,a[1000000];
int main(){
	scanf("%d",&n),a[n+1]=INT_MAX;
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		int res=0;
		while(a[i+1]<=a[i])
			++i,++res;
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
    int N, K;
    cin >>  N >> K;
    vector<vector<int>> g(N);
    for(int i = 0; i < N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> children(N);
    children[0] = (int) g[0].size();
    for(int i = 1; i < N; i++) children[i] = (int)g[i].size() - 1;

    ll res = K;
    for(int i = K - 1; i >= K - children[0]; i--){
        (res *= i) %= MOD;
    }

    for(int i = 1; i < N; i++){
        for(int j = K - 2; j >= K - children[i] - 1; j--){
            (res *= j) %= MOD;
        }
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 6520
#include<stdio.h>

int main(){
	int a[3]={0};
	int f=0;
	int s=0;
	
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	
	for(int i=0;i<3;i++){
		if(a[i] == 5)
			f++;
		else if(a[i] == 7)
			s++;
	}
	
	if(f==2 && s==1)
		printf("YES\n");
	else
		printf("NO\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++)
        cin >> S[i];
    
    vector<vector<int>> s_w(H, vector<int>(W, 0));
    for (int i = 0; i < H; i++) {
        int c = 0;
        for (int j = 0; j < W; j++) {
            if (c == 0 && S[i][j] == '.') {
                for (int k = j; k < W; k++) {
                    if (S[i][k] == '.')
                        c++;
                    else
                        break;
                }
            }
            if (S[i][j] == '.')
                s_w[i][j] = c;
            else
                c = 0;
        }
    }
    
    vector<vector<int>> s_h(H, vector<int>(W, 0));
    for (int i = 0; i < W; i++) {
        int c = 0;
        for (int j = 0; j < H; j++) {
            if (c == 0 && S[j][i] == '.') {
                for (int k = j; k < H; k++) {
                    if (S[k][i] == '.')
                        c++;
                    else
                        break;
                }
            }
            
            if (S[j][i] == '.')
                s_h[j][i] = c;
            else
                c = 0;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++)
            if (S[i][j] == '.')
                ans = max(ans, s_w[i][j]+s_h[i][j]-1);
                
    cout << ans << endl;
}

Measured memory_bytes: 35712
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int k = vs[2];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();

			long[] sumA = new long[200002];
			long[] sumB = new long[200002];
			for (int i = 0; i < n; i++) {
				sumA[i + 1] = sumA[i] + a[i];
				if (sumA[i] > 1000000000) {
					break;
				}
			}
			for (int i = 0; i < m; i++) {
				sumB[i + 1] = sumB[i] + b[i];
				if (sumB[i] > 1000000000) {
					break;
				}
			}
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", sumA));
			//System.Diagnostics.Debug.WriteLine(string.Join(" ", sumB));

			int ai = 0;
			int bi = 0;
			while (sumA[ai + 1] != 0 && sumA[ai + 1] <= k) {
				ai++;
			}
			while (sumB[bi + 1] != 0 && sumB[bi + 1] <= k - sumA[ai]) {
				bi++;
			}
			//System.Diagnostics.Debug.WriteLine($"a:{ai},b:{bi}={sumA[ai]}+{sumB[bi]}={sumA[ai] + sumB[bi]}");

			int ans = ai + bi;
			while (ai > 0) {
				ai--;
				while (sumB[bi + 1] != 0 && sumB[bi + 1] <= k - sumA[ai]) {
					bi++;
				}
				//System.Diagnostics.Debug.WriteLine($"a:{ai},b:{bi}={sumA[ai]}+{sumB[bi]}={sumA[ai] + sumB[bi]}");
				ans = Math.Max(ans, ai + bi);
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 68600