akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
#define ull unsigned long long
#define ALL(v) ((v).begin()), ((v).end())
#define INCREASING(v) sort(ALL(v))
#define DECREASING(v) INCREASING(v), reverse(ALL(v))
#define SZ(v)   ((int)((v).size()))
#define LP(c,x,n)  for(int c=x;c<n;c++)
#define LO(c,n,x)  for(int c=n;c>=x;c--)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define PI ( 2 * acos(0.0))
#define EPS 1e-8
#define INF 1.0/0.0
#define Yala_Besor3a ios_base::sync_with_stdio(0),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ReadFile freopen("delivery.in","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
using namespace std;
const int OO = 0x3f3f3f3f,NegOO= -1*OO,N =3e3+5,mod =998244353 ;
int dp[N][N];
string x,z;
int szx,szz;
int solve(int i,int j)
{
    if(i==szx||j==szz)return 0;
    int &rf=dp[i][j];
    if(~rf)return rf;
    if(x[i]==z[j])rf=max(1+solve(i+1,j+1),rf);
    else rf=max(rf,max(solve(i+1,j),solve(i,j+1)));
    return rf;
}
void Build(int i,int j)
{
    if(i==szx||j==szz)return ;
    if(x[i]==z[j])
    {
        cout<<x[i];
        Build(i+1,j+1);
    }
    else
    {
        int ch1=solve(i+1,j);
        int ch2=solve(i,j+1);
        if(ch1>=ch2)Build(i+1,j);
        else Build(i,j+1);
    }
    return ;
}
int main()
{
    cin>>x>>z;
    szx=SZ(x),szz=SZ(z);
    memset(dp,-1, sizeof(dp));
    solve(0,0);
    Build(0,0);
    return 0;
}

Measured memory_bytes: 35840
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N;
    scan(N);
    auto s = readln.split.to!(int[]).sort();
    int Q;
    scan(Q);
    auto t = readln.split.to!(int[]);

    int ans;
    foreach (ti ; t) {
        auto lw = s.lowerBound(ti + 1);
        if (!lw.empty && lw.back == ti) ans++;
    }
    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}



Measured memory_bytes: 6860
from collections import deque

def solve(N, X, Y):
    ret = [0] * N
    already_used = [[False for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(1, N + 1):
        already_used[i][i] = True
        reached = [False for _ in range(N + 1)]
        reached[i] = True
        stack = deque([[i, 0]])

        while stack:
            node, step = stack.popleft()
            if 1 <= step and not already_used[i][node]:
               ret[step] += 1
            already_used[i][node], already_used[node][i] = True, True

            for x in [node + 1, node - 1]:
                if 0 < x < N + 1 and not reached[x]:
                    stack.append([x, step + 1])
                    reached[x] = True
            if node == X and not reached[Y]:
                stack.append([Y, step + 1])
                reached[x] = True
            if node == Y and not reached[X]:
                stack.append([X, step + 1])
                reached[x] = True
    return ret

if __name__ == '__main__':
    N, X, Y = map(int, input().split())
    for r in solve(N, X, Y)[1:]:
        print(r)

Measured memory_bytes: 86876
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  	int a,b,c,d;
  	cin >> a >> b >> c >> d;
  	if (abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d)){
      cout << "Yes";
    }
  	else{
      cout << "No";
    }
}

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

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
using namespace std; 

#define MAX 100

int H, W;
char in[MAX][MAX];
int cnt;
vector<int> ans;
int dx[4] = {0, 1, 0, -1}; //????????????
int dy[4] = {-1, 0, 1, 0};

void dfs(int x, int y, char c)
{
	in[y][x] = '.';
	rep(i,0,4) {
		int tx = x+dx[i];
		int ty = y+dy[i];
		if(tx < 0 || tx >= W) continue;
		if(ty < 0 || ty >= H) continue;
		if(in[ty][tx] == c) dfs(tx,ty,c);
	}
}

void solve()
{
	rep(i,0,H) rep(j,0,W) {
		if(in[i][j] == '.') continue;
		if(in[i][j] == '#') dfs(j,i,'#');
		else if (in[i][j] == '*') dfs(j,i,'*');
		else if (in[i][j] == '@') dfs(j,i,'@');
		cnt++;
	}
	ans.pb(cnt);
}

void input()
{
	while (1) {
		cin >> H >> W;
		if(H == 0 && W == 0) break;
		cnt = 0;
		rep(i, 0, H) rep(j, 0, W) {
			cin >> in[i][j];
		}
		solve();
	}
	//rep(i,0,H) { rep(j,0,W) cout << in[i][j]; cout << endl; }
}

int main(void)
{
	input();
	rep(i,0,ans.size()) cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 1692
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
char buf[111111];
int L;
int solve(int p,int l,int r,int a)
{
  if(p==L)return 0;
  //printf("%d %d %d %d\n",p,l,r,a);
  if(a){//ツ陳シツ前ツ債カ
    if(buf[p]<l){
      return solve(p+1,buf[p],r,a)+1;
    } else {
      return solve(p+1,l,buf[p],!a);
    }
  } else {//ツ陳シツ前ツ右
    if(buf[p]>r){
      return solve(p+1,l,buf[p],a)+1;
    } else {
      return solve(p+1,buf[p],r,!a);
    }
  }
}
int main(void)
{
  for(;;){
    scanf("%s",buf); if(*buf=='#')break;
    L=strlen(buf);
    for(int i=0;buf[i];++i) --buf[i],buf[i]-='0',buf[i]%=3;
    printf("%d\n",min(solve(1,*buf,*buf,0),solve(1,*buf,*buf,1)));
  }
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int a[3];
    REP(i,3)cin>>a[i];
    sort(a,a+3);
    cout<<a[2]*10+a[1]+a[0]<<endl;

}

Measured memory_bytes: 256
def combination(n, r, mod=10 ** 9 + 7):
	n1, r = n + 1, min(r, n - r)
	numer = denom = 1
	for i in range(1, r + 1):
		numer = numer * (n1 - i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod - 2, mod) % mod


X, Y = map(int, input().split())
# 例外処理
if (X + Y) % 3 != 0 or not (X <= 2 * Y and Y <= 2 * X):
	print(0)
	exit()

n = (X + Y) // 3

r = Y - n # 差
print(combination(n, r))


Measured memory_bytes: 3064
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-07 21:33:43
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e3+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int n , a[maxn][maxn] , b[maxn][maxn];
ll ans ;
void check(){
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(!b[i][j])ans+=a[i][j];
        }
    }cout << ans/2 << endl;
}
int main()
{
    cin >> n;
    for(int i = 1; i <= n ; i++){
        for(int j = 1; j <= n; j++){
            cin >> a[i][j];
        }
    }
    int flag = 0;
    for(int i = 1; i <= n ; i++){
        for(int j = 1; j <= n ; j++){
            for(int k = 1; k <= n ; k++){
                if(i != j && i != k && j != k && a[i][j] > a[i][k] + a[k][j]){
                    flag = 1;
                }
                 if(i != j && i != k && j != k && a[i][j] == a[i][k] + a[k][j]){
                    b[i][j] = 1;  //i到j这条边不要
                }
            }
        }
    }
    if(flag)puts("-1");
    else {
        check();
    }
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 5752
import java.util.*;

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

    String str = sc.next();
    int q = sc.nextInt();

    for(int i = 0; i < q; i++){
      String fanc = sc.next();
      int a = sc.nextInt();
      int b = sc.nextInt();

      if(fanc.equals("print")){
        System.out.println(str.substring(a, b + 1));
      } else if(fanc.equals("reverse")){
        String rev = "";
        for(int j = b; j >= a; j--){
          rev += str.substring(j, j + 1);
        }
        str = str.substring(0, a) + rev + str.substring(b + 1);
      } else if(fanc.equals("replace")){
        String p = sc.next();

        str = str.substring(0, a) + p + str.substring(b + 1);
      }
    }

  }
}



Measured memory_bytes: 46980
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  string S;

  cin>>S;

  reps(i,1,S.length()){
    rep(j,i){
      if(S[i]==S[j]){
        cout<< "no"<<"\n";
        return;
      }
    }
  }

  cout<< "yes"<<"\n";

}
//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    H, W, K = map(int, input().split())
    c = [input() for i in range(H)]

    ans = 0
    for maskR in range(2 ** H):
        for maskC in range(2 ** W):
            black = 0
            for i in range(H):
                for j in range(W):
                    if ((maskR >> i) & 1) and ((maskC >> j) & 1) and c[i][j] == '#':
                        black += 1
                    
            if black == K:
                ans += 1
            
    print(ans) 

main()

Measured memory_bytes: 9108
N = int(input())
A = list(map(int,input().split()))

B = [0] * N
M = 0
ans = []
for i in range(N,0,-1):
    S, idx = 0, i-1
    while idx <= N-1:
        S += B[idx]
        idx += i

    if S % 2 != A[i-1]:
        B[i-1] = 1
        M += 1
        ans.append(i)
        

print(M)
for a in ans:
    print(a, end=" ")
print("")

Measured memory_bytes: 90788
N, P = map(int, input().split())

def solve(a):
	l = {}
	count = 0
	while 0 == a % 2:
		a //= 2
		count += 1
	else:
		if count:
			l[2] = count

	for n in range(3, int(a ** 0.5) + 1, 2):
		if a == 1:
			return l

		count = 0
		while 0 == a % n:
			a //= n
			count += 1
		else:
			if count:
				l[n] = count
	else:
		if 1 != a:
			l[a] = 1
	return l

l = solve(P)
#print(l)

keys = sorted(l, reverse=True)
r = 1
for key in keys:
	if N <= l[key]:
		r *= key ** (l[key] // N)
print(r)


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

int main(void)
{
	int first = 0;
	int second = 0;
	int third = 0;
	int inning = 0;
	int inlim = 0;
	int	scores[65536] = {0} ;
	char ev[10] = {0};
	int out = 0 ;
	int i ;
	
	scanf("%d",&inlim);

	for( inning = 0 ; inning < inlim ; inning++ ){
	for( i = 0 ; i < 100 ; i++ ){
		scanf("%s",ev);

		if(strcmp(ev,"HIT")==0){
			if(third){
				scores[inning]++;
				third=0;
			}

			if(second){
				third=1;
				second=0;
			}

			if(first){
				second=1;
			}
			first = 1;
		}

		if(strcmp(ev,"HOMERUN")==0){
			scores[inning]++;
			if(first){
			first=0;
			scores[inning]++;}
			if(second){
			second=0;
			scores[inning]++;}
			if(third){
			third=0;
			scores[inning]++;}
			
		}

		if(strcmp(ev,"OUT")==0)
			out++;

		if( out >= 3 )
			break;
		}

		out = 0;
		first = 0;
		second = 0;
		third = 0;

	}
	
	for( i = 0 ; i < inlim ; i++ )
	printf("%d\n",scores[i]);

	return 0;
}

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

using namespace std;
typedef long long ll;

int N;


int main(){
  cin >> N;
  double X[N];
  double Y[N];
  for (int i=0;i<N;i++){
    cin >> X[i] >> Y[i];
  }
  double sum=0;
  for (int j=0;j<N-1;j++){
    for (int k=j+1;k<N;k++){
      sum += sqrt(pow((X[j]-X[k]),2)+pow((Y[j]-Y[k]),2));
    }
  }
  double mm = N*(N-1)/2.0 * 2 / N;
  double m=N*(N-1)/2.0;
  int m2=N*(N-1)/2.0;
  int ans =  int(sum*mm/m2);
  //cout << ans << endl;
  ll ans2 = sum*mm/m*pow(10,10) - ans *pow(10,10);
    printf("%d.%lld\n", ans ,ans2);
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll a, b, n;
    cin >> a >> b >> n;

    if (a % b == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll mem;
    if (n % b == b - 1) mem = n;
    else mem = n - (n % b + 1);

    if (b > n) mem = n;

    ll res = a * mem / b - a * (mem / b);
    cout << res << endl;
    return 0;
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

string inttos(int num)
{
    return to_string(num);
}

int stoint(string sss)
{
    return stoi(sss);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T=1;
	while(T--)
	{
		int x;
		cin >> x;
		int ans = (x/500)*1000;
		int rem = x%500;
		ans += (rem/5) * 5;
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a < b) {
      for(int n = 0;n < b; n++) {
        System.out.print(a);
      }
    } else {
      for(int n = 0;n < a; n++) {
        System.out.print(b);
      }
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
    ll a, k;
    double b;
    cin >> a >> b;
    if (a != 0 && b != 0) {
        k = b * 1000;
        a *= k;
        a /= 1000;
        cout << a << endl;
    } else {
        cout << 0 << endl;
    }
}

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

num_list = [ int(v) for v in input().split() ]
right_list = [ i+1 for i in range(n) ]

wrong = 0
for i in range(n):
    if num_list[i] != right_list[i]:
        wrong += 1
if wrong in [0,2]:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer cout<<endl<<"answer : ";
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0;string s;bool flag=false;
        cin>>x>>y>>z;
        ans=z-(x-y);
        if(ans<0)
            ans=0;
        cout<<ans<<endl;
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3616
k, n = map(int, input().split())
list_A = list(map(int, input().split()))
list_ans = []
list_ans.append(list_A[0]+(k-list_A[-1]))

for i in range(1, n):
    list_ans.append(list_A[i]-list_A[i-1])

print(k-max(list_ans))

Measured memory_bytes: 26444
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<double, double >pd;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;


const ll mod = 1e4;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const double eps = 1e-10;
const double PI = 3.14159265358979323846;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll n, d[2010], k, ans = INF, x[2010], y[2010];
vector<ll>tree[2010];

struct double_sweep_ret { ll start, goal, cost; };

void dfs(int s, int cnt) {
	for (auto u : tree[s]) {
		if (d[u] == INF) {
			d[u] = cnt + 1;
			dfs(u, d[u]);
		}
	}
	return;
}

double_sweep_ret solve(int n) {
	//nはノードの数
	//return 木の直径の{start,goal,cost}
	//木 T の直径を D とする．
	// D が偶数ならば，ある頂点 v が存在して v から他の頂点への距離が D / 2以下となる．
	// D が奇数ならば，ある辺 e が存在して e から他の頂点への距離が(D −1) / 2以下となる．
	//v と e は木の中心とよばれる．

	int st, go, co = 0;
	for (int i = 1;i <= n;i++) {
		d[i] = INF;
	}
	d[1] = 0;
	dfs(1, 0);
	int  mx = 0;
	for (int i = 1;i <= n;i++) {
		if (mx < d[i])mx = d[i], st = i;
	}
	for (int i = 1;i <= n;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	dfs(st, 0);
	for (int i = 1;i <= n;i++) {
		if (co < d[i])co = d[i], go = i;
	}
	return double_sweep_ret{ st,go,co };
}

int main() {
	cin >> n >> k;
	for (int i = 0;i < n - 1;i++) {
		cin >> x[i] >> y[i];
		tree[x[i]].pb(y[i]);
		tree[y[i]].pb(x[i]);
	}
	double_sweep_ret dsr = solve(n);//いらんわアホ
	if (k % 2 == 0) {
		for (int i = 1;i <= n;i++) {
			for (int j = 1;j <= n;j++)d[j] = INF;
			d[i] = 0;
			dfs(i, 0);
			ll cnt = 0;
			for (int j = 1;j <= n;j++) {
				if (i == j)continue;
				if (d[j] > k / 2)cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 0;i < n - 1;i++) {
				for (int j = 1;j <= n;j++)d[j] = INF;
				d[x[i]] = 0;
				d[y[i]] = 0;
				dfs(x[i], 0);
				dfs(y[i], 0);
				ll cnt = 0;
				for (int j = 1;j <= n;j++) {
					if (d[j] > (k - 1) / 2)cnt++;
				}
				ans = min(ans, cnt);
			}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 512
#include <iostream>

int getDigit (int num) {
  int digit = 0;
  while (num != 0) {
    num /= 10;
    ++digit;
  }
  return digit;
}

int main() {
  int num;
  std::cin >> num;

  int count = 0;
  for (int i = 1; i <= num; ++i) {
    if (getDigit(i) % 2 == 1) ++count;
  }
  std::cout << count << std::endl;
}


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

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

	for (int i = 1; i < 4; i++)
	{
		if (S[i - 1] == S[i])
		{
			cout << "Bad" << endl;
			return 0;
		}
	}

	cout << "Good" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ab = a + b;
  ll c = n / ab;
  ll d = n % ab;
  ll ans = c * a;
  if (d <= a) {
    ans += d;
  } else {
    ans += a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <vector>

#define PI 3.1415927

using namespace std;

int ans[30];
int temp[30];

int main(){
    memset(temp,0,sizeof(temp));
    int n;
    cin>>n;
    char str[55];
    cin>>str;
    int l=strlen(str);
    for (int i=0;i<l;i++){
        ans[str[i]-'a']++;
    }
    for (int i=0;i<n-1;i++){
        memset(temp,0,sizeof(temp));
        cin>>str;
        l=strlen(str);
        for (int j=0;j<l;j++){
            temp[str[j]-'a']++;
        }
        for (int j=0;j<26;j++){
            ans[j]=min(ans[j],temp[j]);
        }
    }
    for (int i=0;i<26;i++){
        while(ans[i]){
            cout<<(char)(i+'a');
            ans[i]--;
        }
    }
    cout<<endl;
}


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

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

int main() {
	int n;
	cin >> n;
	int cnt = 0;
	rep(i, n) {
		int x;
		cin >> x;
		if (is_prime(x)) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <functional>
#include <assert.h>
#include <iomanip>
using namespace std;
const int N = 1e5 + 5;
// const int M = 1005;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
typedef long long ll;

int h[N];
int main() {
    int n;
    while(~scanf("%d", &n)) {
        int t, a;
        scanf("%d %d", &t, &a);
        for(int i = 0; i < n; ++i) {
            scanf("%d", &h[i]);
        }
        int pos; double ans = INF;
        for(int i = 0; i < n; ++i) {
            double temple = t  - h[i] * 0.006;
            double absTemple = abs(temple - a);
            if(absTemple < ans) {
                ans = absTemple;
                pos = i + 1;
            }
        }
        printf("%d\n", pos);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }

int main(){
  int S,W; cin>>S>>W;
  
  cout << (W>=S?"unsafe":"safe") <<"\n";
}

Measured memory_bytes: 3604
#6
N = int(input())
a = sorted(list(map(int, input().split())))
Alice_list = []
Bob_list = []
for i in range(1, N+1):
    if i%2==1:     
        Alice_list.append(a[-i])
    else:
        Bob_list.append(a[-i])
print(sum(Alice_list)-sum(Bob_list))

Measured memory_bytes: 3060
#include <stdio.h>

void sort(int *a, int n){
    int dummy, i, j;
    
    for(i = 0; i<n; i++){
        for(j = 0; j<n; j++){
            if(i>=j){
                continue;
            }
            if(a[i]>a[j]){
                dummy = a[i];
                a[i] = a[j];
                a[j] = dummy;
            }
        }
    }
}

int main(void){
    int n, x, m[100], i, counter = 0;
    
    scanf("%d %d", &n, &x);
    for(i = 0; i<n; i++){
        scanf("%d", &m[i]);
    }
    sort(m, n);
    for(i = 0; i<n; i++){
        if(m[i]<=x){
            x -= m[i];
            counter++;
        }
    }
    while(1){
        if(m[0]>x){
            break;
        }
        x -= m[0];
        counter++;
    }
    
    printf("%d\n", counter);
    return 0;
}


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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


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

    string s; cin >> s;
    if((int)s.length() == 2 && s[0] == s[1])
    {
        cout << 1 << " " << 2 << endl;
        return 0;
    }
    for(int i = 0; i + 2 < (int)s.length(); i++)
    {
        string t = s.substr(i, 3);
        if(t[0] == t[1] || t[0] == t[2] || t[1] == t[2])
        {
            cout << i+1 << " " << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long all_cases = po(10, n);
  long long comp = mod(po(9, n) * 2);
  comp -= po(8, n);
  comp = mod(comp);
  long long ans = all_cases - comp;
  ans = mod(ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define popb pop_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
// #define int long long

const int mod = 1e9+7;

using namespace std;

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

ll power(ll x, ll y, ll m){
	if(y==0) return 1;
	ll p = power(x,y/2,m) % m;
	p = (p*p)%m;
	return (y%2==0) ? p : (x*p)%m;
}

void solve(){

	vector <int> a(3);
	rep0(i,3) cin >> a[i];
	sort(a.begin(),a.end());
	cout << a[0] + a[1];
	
	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

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

bool match(int l, int m, int r, int c, string arr1[], string arr2[]){
	for (int i=0; i<m; i++){
		for (int j=0; j<m; j++){
			char char1 = arr1[i+r][j+c]; 
			char char2 = arr2[i][j];
			if (char1 != char2){
				return false;
			}
		}
	}
	return true;
}
  
//#.#         #.  00 01   for (int i=0; i<2; i++)
//.#.  11 12  .#  10 11        for (int j=0; j<2; j++)
//#.#  21 22                         arr1[i+r][j+c]==arr2[i][j]




 
int main() {
    int l, m;
    cin >> l >> m;
    string arr1[l];
    string arr2[m];
    for (int i=0; i<l; i++){
    	cin>> arr1[i];
    }
    for (int i=0; i<m; i++){
    	cin>> arr2[i];
    }
    for (int i=0; i<=l-m; i++){
    	for (int j=0; j<=l-m; j++){
    		if (match(l, m, i, j, arr1, arr2)){
    			cout << "Yes\n";
    			return 0;
    		}
    	}
    }
    cout <<"No\n";
}


Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))

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

ans = 0
for i in range(n):
	ans = max(ans, gcd(l[i],r[i+1]))
print (ans)

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	4 * MAX5;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll t = 1;
ll n, x, k, q, m, y, r;
string s;

ll day[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

// <------------- Implement Functions Here ----------> //

  


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	ll ans = (ll)(ceil((ld)n/(1.08)));
	
	if((ll)(ans * 1.08) == n) {
		cout<<ans;
	}
	else cout<<":(";
}

int main() {
	fastio; randomINT;
	//cin >> t;
	while (t--) {
		MAIN();
	}
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
string n;

int main() {
    cin >> n;
    string s = "ABC";
    cout << s + n << endl;
    return 0;
}


Measured memory_bytes: 3664
using System;
namespace AtCoder {
    class Program {
        static void Main(string[] args) {
            var N = int.Parse(Console.ReadLine());

            if (N < 10) {
                Console.WriteLine(N);
            } else if (N < 1000) {
                Console.WriteLine(9 + Math.Max(N - 99, 0));
            } else if (N < 100000) {
                Console.WriteLine(909 + Math.Max(N - 9999, 0));
            } else {
                Console.WriteLine("90909");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <list>
using namespace std;

int main(){

    string s;cin >> s;
    int n=s.length();

    string s1 = "", s2 = "";
    for(int i=0; i<n; i++){
        if(i % 2 == 0){
            s1.push_back('0');
            s2.push_back('1');
        }
        else{
            s1.push_back('1');
            s2.push_back('0');
        }
    }

    int cnt1 = 0, cnt2 = 0;
    for(int i=0; i<n; i++){
        if(s[i] != s1[i]) cnt1++;
        if(s[i] != s2[i]) cnt2++;
    }

    cout << min(cnt1, cnt2);

    return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    string s;
    cin >> s;
    for (int i= 0; i < 19; i++) {
        if (s[i] == ',') {
            s[i] = ' ';
        } 
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
n, m = map(int,input().split())
graph = {}
for i in range(0, m):
    am, bm = map(int, input().split())
    if am not in graph:
        graph[am] = [bm]
    else:
        graph[am].append(bm)
    if bm not in graph:
        graph[bm] = [am]
    else:
        graph[bm].append(am)
signs = {1:0}
current = [1]
while current:
    node = current.pop(0)
    for j in graph[node]:
        if j not in signs:
            signs[j] = node
            current.append(j)  
if len(signs) == n:
    print("Yes")
    for x in range(2, n+1):
        print(signs[x])
else:
    print("No")


Measured memory_bytes: 48812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

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

    ll N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    //X未満の数がK個未満かどうか
    auto check = [&](ll X){
        ll res = 0;
        //vector<ll> cnt(N, 0);
        rep(i,N){
            ll cnt = 0;
            //左側を数える
            if(A[i]>0){
                //indexの二分探索
                int ok = -1;
                int ng = N;
                while(ng - ok > 1){
                    int mid = (ok + ng) / 2;
                    if(A[i] * A[mid] < X)ok = mid;
                    else ng = mid;
                }
                //0-indexedなので
                cnt = ok + 1;
                if(A[i] * A[i] < X)cnt--;
            }
            //右側を数える
            else if(A[i]<0){
                //indexの二分探索
                int ng = -1;
                int ok = N;
                while(ok - ng > 1){
                    int mid = (ok + ng) / 2;
                    if(A[i] * A[mid] < X)ok = mid;
                    else ng = mid;
                }
                cnt = N - ok;
                if(A[i] * A[i] < X)cnt--;
            }
            //A[i] == 0
            else{
                if(X > 0){
                    cnt = N - 1;
                }
            }
            res += cnt;
        }
        //print(cnt);
        //cerr<<X<<": "<<res/2<<" 個"<<endl;
        return res/2 < K;
    };

    ll ok = - INFLL -1;
    ll ng = INFLL + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

template <class Weight>
constexpr Weight inf=(Weight(1)<<(8*sizeof (Weight)-3));

template <class Weight>
class WeightedUnionFind {
  std::vector<intmax_t> tree;
  std::vector<Weight> cost;

public:
  WeightedUnionFind(size_t n): tree(n, -1), cost(n) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    size_t r=find(tree[v]);
    cost[v] += cost[tree[v]];
    return (tree[v] = r);
  }

  bool unite(size_t u, size_t v, Weight w) {
    size_t ru=find(u), rv=find(v);
    if (ru == rv)
      return false;  // FIXME assuming no multi-edges

    if (-tree[ru] < -tree[rv]) {
      tree[rv] += tree[ru];
      tree[ru] = rv;
      cost[ru] = w-(cost[u]-cost[v]);
    } else {
      tree[ru] += tree[rv];
      tree[rv] = ru;
      cost[rv] = -w+(cost[u]-cost[v]);
    }
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  Weight diff(size_t u, size_t v) {
    return connected(u, v)? (cost[u]-cost[v]):inf<Weight>;
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N;
  int M;
  scanf("%zu %d", &N, &M);

  WeightedUnionFind<intmax_t> uf(N);

  for (int i=0; i<M; ++i) {
    size_t L, R;
    intmax_t D;
    scanf("%zu %zu %jd", &L, &R, &D);

    --L;
    --R;
    if (!uf.connected(L, R)) {
      uf.unite(L, R, D);
    } else if (uf.diff(L, R) != D) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	string a, b;
	cin >> a >> b;
	bool ans = false;
	for (int i = 0;i < a.size();++i) {
		if (a == b) {
			ans = true;
			break;
		}
		else {
			b = b.back() + b.substr(0, b.size() - 1);
		}
	}
	if (ans)cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
   long int a[1000],n,k,max=0,count=0,i,min=9999;
   scanf("%ld",&n);
   for(i=0;i<n;i++)
   {
       scanf("%ld",&k);
       a[k]=1;
     if(k>max)
     {
         max=k;
     }
     if(min>k)
     {
         min=k;
     }
     
   }
  for(i=min;i<max;i++)
  {
      count++;
  }
  printf("%ld",count);
    return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

S = 0
C = 0
S = a[0]
if S > 0:
    pm = 1
elif S < 0:
    pm = 0
else:
    S += 1
    C += 1
    pm = 1
for i in range(1, n):
    S += a[i]
    if pm == 1 and S >= 0:
        C += S + 1
        S -= S + 1
    elif pm == 0 and S <= 0:
        C += -S + 1
        S += -S + 1
    pm = 1 - pm 

T = 0
D = 0
T = a[0]
if T > 0:
    D += T + 1
    T -= T + 1
    pm = 0
elif T < 0:
    D += -T + 1
    T += -T + 1
    pm = 1
else:
    T -= 1
    D += 1
    pm = 0
for i in range(1, n):
    T += a[i]
    if pm == 1 and T >= 0:
        D += T + 1
        T -= T + 1
    elif pm == 0 and T <= 0:
        D += -T + 1
        T += -T + 1
    pm = 1 - pm

print(min(C, D))

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

int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 0; i <= 1000000000; ++i){
        if(abs(a-i) == abs(b-i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
  	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

ll d[5005]={};
ll dm[5005]={};

ll solve(ll n, ll x, ll m, ll k){
    ll begin=x;
    REP(i,5005)dm[i]=d[i]%m;
    ll syu = 0;
    REP(i,k)syu+=dm[i];
    ll end=syu*((n-1)/k)+begin;
    REP(i,(n-1)%k)end+=dm[i];
    ll down = end/m - begin/m;

    ll samsyu=0;
    REP(i,k){
        if(dm[i]==0)samsyu++;
    }
    ll same = samsyu*((n-1)/k);
    REP(i,((n-1)%k))if(dm[i]==0)same++;

    return n-1-same-down;
}

int main(){
    ll k,q,dd;
    cin>>k>>q;
    ll n,x,m;
    REP(i,k){
        cin>>dd;
        d[i]=dd;
    }
    REP(i,q){
        cin>>n>>x>>m;
        cout<<solve(n,x,m,k)<<endl;
    }
}

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

using namespace std;

int main() {
	char c[3][5];
	
	for (int i=0; i<3; i++) {
		scanf("%s", c[i]);
	}
	
	
	printf("%c%c%c\n", c[0][0], c[1][1], c[2][2]);
	
	
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int main()
{
	int N;
	string s;
	cin>>N>>s;

	map<int,int> mpl, mpr;
	mpl[s.front()-'0']++;
	REP(i,2,N)mpr[s[i]-'0']++;

	set<int> res;
	REP(mid,1,N-1){
		int m = s[mid]-'0';
		for(auto itr:mpl)for(auto itr2:mpr)if(itr.second>0&&itr2.second>0){
			res.insert(itr.first*100 + m*10 + itr2.first);
		}
		mpl[m]++;
		mpr[s[mid+1]-'0']--;
	}

	cout<<res.size()<<endl;
	return 0;
}


Measured memory_bytes: 384
# ans = 全白マス数 - 最短距離のマス数

H,W=map(int,input().split())
grid=[None]*H
white=0
for i in range(H):
  grid[i]=input()
  white+=grid[i].count(".")
  
from collections import deque
q=deque()
q.append([0,0,0])

seen=[[False for i in range(W)] for j in range(H)]

while q:
  v=q.popleft()
  y=v[0]
  x=v[1]
  p=v[2]
  if grid[y][x]=="#" or seen[y][x]:
    continue
  if y==H-1 and x==W-1:
    print(white-(p+1))
    break
  seen[y][x]=True
  if y-1>=0:
    q.append([y-1,x,p+1])
  if y+1<H:
    q.append([y+1,x,p+1])
  if x-1>=0:
    q.append([y,x-1,p+1])
  if x+1<W:
    q.append([y,x+1,p+1])
else:
  print(-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>                          
using namespace std;
long long n,a,b,p,ans;
int main(){
    cin>>n>>a>>b;
    if(a==0) {cout<<0<<endl;return 0;}
    p=n/(a+b);
    ans=p*a+min((n-p*(a+b)),a);
    cout<<ans<<endl;
	return 0;
}

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

const int N = 510;
const int INF = 1e9;

int n;
string a[N];
int res = INF;
int col[N];
bool any;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int j = 0; j < n; ++j) if (a[i][j] == '#') ++col[j], any = 1;
    }
    if (!any) {
        printf("-1\n"); return 0;
    }

    for (int i = 0; i < n; ++i) {
        int cur = 0;
        if (!col[i]) ++cur;
        for (int j = 0; j < n; ++j) {
            if (col[j] != n) ++cur;
        }
        for (int j = 0; j < n; ++j) {
            if (a[i][j] == '.') ++cur;
        }
        res = min(res, cur);
    }

    if (res != INF) printf("%d\n", res); else printf("-1\n");
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}

signed main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (a != c) << endl;
	
    return 0;
}

Measured memory_bytes: 256
N = int(input())
s = input()[::-1]
T = list(input()[::-1])

index = len(T)
for i, t in enumerate(T):
    if t == s[0]:
        j = 0
        while j < len(T) - i:
            if s[j] != T[i + j]:
                break
            j += 1
        else:
            index = i
            break

res = s[::-1] + "".join((T[:index])[::-1])
print(len(res))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M;
    if (N == M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int n,q;
    cin >> n;
    int s[n];
    REP(i,n)cin >> s[i];
    cin >> q;
    int t[q];
    int cnt = 0;
    REP(j,q)cin >> t[j];
    REP(i,q){
        REP(j,n){
            if(t[i] == s[j]){
                cnt++;
                break;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3112
k = 26
D = gets.to_i
c = gets.split.map(&:to_i)
s = D.times.map { gets.split.map(&:to_i) }
max_satis = -1000000000
max_t = []
1000.times do |r|
  t = []
  D.times do |d|
    t[d] = rand(k)
  end
  
  last = Array.new(k, 0)
  satis = 0
  D.times do |d|
    satis += s[d][t[d] - 1]
    last[t[d] - 1] = d + 1
    k.times do |i|
      satis -= c[i] * ((d + 1) - last[i])
    end
  end
  if max_satis < satis
    max_satis = satis
    max_t = t
  end
end

D.times do |d|
  puts max_t[d] + 1
end


Measured memory_bytes: 20788