akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include "limits.h"
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

  ll t1,t2,a1,a2,b1,b2;
  std::cin>>t1>>t2>>a1>>a2>>b1>>b2;

  if(t1*a1+t2*a2==t1*b1+t2*b2){
    std::cout<<"infinity\n";
    return 0;
  }

  if(t1*a1+t2*a2<t1*b1+t2*b2){
    std::swap(a1,b1);
    std::swap(a2,b2);
  }


  if(a1>b1){
    std::cout<<0<<"\n";
    return 0;
  }

  ll temp=0;

  if(((b1-a1)*t1)%(a1*t1+a2*t2-b1*t1-b2*t2)==0)temp++;

  ll num=((b1-a1)*t1)/(a1*t1+a2*t2-b1*t1-b2*t2);

  std::cout<<(num+1)*2-1-temp<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
struct unionf{
	vector <int> data;
	unionf(int size):data(size,-1){}
	bool unions(int x,int y){
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;}
			data[x]+=data[y];data[y]=x;
		}
		return x!=y;
	}
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		return data[x]<0?x:data[x]=root(data[x]);
	}
	int find(int x){
		return -data[x];
	}
};
int n,m;
int u[2010],v[2010];lint w[2010];
lint cal(int a){
	lint ret=w[a];
	unionf uni(n+10);
	uni.unions(u[a],v[a]);
	vector<tint> V;
	rep(i,m){
		if(i!=a) V.pb(mp(w[i],mp(u[i],v[i])));
	}
	sort(All(V));
	//cout<<u[a]<<' '<<v[a]<<' '<<m<<endl;
	rep(i,m-1){
		int x=V[i].se.fi,y=V[i].se.se;lint z=V[i].fi;//cout<<x<<' '<<y<<endl;
		if(uni.finds(x,y)) continue;
		uni.unions(x,y);ret+=z;
	}
	return ret;
}
int main()
{
	int lo=0,hi=0,mi=0;lint x,mo=1000000007;
	cin>>n>>m;cin>>x;rep(i,m) cin>>u[i]>>v[i]>>w[i];
	rep(i,m){
		lint ret=cal(i);
		//cout<<i<<' '<<ret<<endl;
		if(ret==x) mi++;if(ret<x) lo++;if(ret>x) hi++;
	}
	//cout<<lo<<mi<<hi<<endl;
	if(mi==0){
		cout<<0<<endl;return 0;
	}
	if(lo==0){
		lint out=1;
		rep(i,mi){
			out*=2;out%=mo;
		}
		out-=2;out+=mo;out%=mo;
		rep(i,hi){
			out*=2;out%=mo;
		}
		cout<<out%mo<<endl;
	}
	else{
		lint out=1;
		rep(i,mi){
			out*=2;out%=mo;
		}
		out-=1;out*=2;
		rep(i,hi){
			out*=2;out%=mo;
		}
		cout<<out%mo<<endl;
	}
}


Measured memory_bytes: 384
#import <Foundation/Foundation.h>
#import <stdarg.h>

@interface StdIO : NSObject
+(NSMutableString*)stringFromStdIn;
+(void)printf:(NSString*)format, ...;
@end
@implementation StdIO
+(NSMutableString*)stringFromStdIn
{
    NSFileHandle *handle = [NSFileHandle fileHandleWithStandardInput];
    NSMutableString *result = [NSMutableString string];
    NSData *data = [handle availableData];
    while ([data length] > 0) {
        [result appendString:[[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]];
        data = [handle availableData];
    }
    return result;
}
+(void)printf:(NSString*)format, ...
{
    va_list arguments;
    va_start(arguments, format);
    NSString *string = [[[NSString alloc] initWithFormat: format arguments: arguments] autorelease];
    NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
    [fileHandle writeData:[string dataUsingEncoding: NSUTF8StringEncoding]];
    va_end(arguments);
}
@end

int main() {
    @autoreleasepool {
        NSArray *numbers = [[StdIO stringFromStdIn] componentsSeparatedByString:@"\n"];
        NSInteger a = [[numbers objectAtIndex: 0] integerValue];
        NSInteger b = [[numbers objectAtIndex: 1] integerValue];
        NSInteger c = [[numbers objectAtIndex: 2] integerValue];
        NSInteger X = [[numbers objectAtIndex: 3] integerValue] / 50;
        NSInteger count = 0;
        NSInteger x = 0;
        while (x <= MIN(a,X/10)) {
            NSInteger Y = X-10*x;
            NSInteger y = 0;
            while (y <= MIN(b,Y/2)) {
                NSInteger z = Y-2*y;
                if (z <= c) {
                    count++;
                }
                y++;
            }
            x++;
        }
        [StdIO printf:@"%ld", count];
    }
    
    return 0;
}


Measured memory_bytes: 9248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int k,x;
  cin >> k >> x;
  
  int start,goal;
  
  start=max(-1000000,x-k+1);
  goal=min(1000000,x+k-1);
  
  for(int i=start;i<=goal;++i){
    cout << i << endl;
  }
}




Measured memory_bytes: 256
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>

#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>

#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>

#include <memory.h>
#include <cassert>
#include <time.h>
#include <functional>

using namespace std;

#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)

#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()

typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;

const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;

#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif

void prepare(string s) {
#ifdef MY_DEBUG
  freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#else
  //freopen("input.txt", "r", stdin);
  //freopen ("output.txt", "w", stdout);
#endif
}

const int K = 100;

int a, b;
char ca = '.', cb = '#';
char c[K][K];

void read() {
  scanf("%d %d", &a, &b);
}

void solve() {
  forn(i, K) {
    forn(j, K) {
      if (i < K / 2) {
        c[i][j] = ca;
      } else {
        c[i][j] = cb;
      }
    }
  }

  a -= 1;
  b -= 1;

  for (int i = 0; i < 100 && b > 0; i += 2) {
    for (int j = 0; j < 100 && b > 0; j += 2) {
      c[i][j] = cb;
      --b;
    }
  }

  for (int i = 99; i > 0 && a > 0; i -= 2) {
    for (int j = 0; j < 100 && a > 0; j += 2) {
      c[i][j] = ca;
      --a;
    }
  }

  printf("%d %d\n", K, K);
  forn(i, K) {
    forn(j, K) {
      printf("%c", c[i][j]);
    }
    printf("\n");
  }
}

int main() {
  prepare("");

  read();
  solve();
  dbg("Clock = %.3f\n", clock() / (double)CLOCKS_PER_SEC);
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String line = br.readLine();
			String[] str = line.split(" ");
			int h = Integer.parseInt(str[0]);
			int w = Integer.parseInt(str[1]);
			if ( h == 0 && w == 0 ){ //??\????????¨??????0
				break;
			}

			for (int i = 0; i < h ; i++ ) {
				for (int k = 0; k < w ; k++ ) {
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 36116
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
typedef vector< vl > vvl;
const ll MAX = 1e5+5;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define EE '\n'
#define ll long long int
#define forn(i,j,n) for ( auto i=j ; i<n ; i++ )
#define fornd(i,j,n) for ( auto i=j ; i>n ; i-- )
#define PI 3.14159265
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
#define SOT(A) sort(A.begin(),A.end())
#define SOTR(A) sort(A.rbegin(),A.rend())

const int N = 200043;
const int MOD = 998244353;
//////////////// ncr ///////////////////////
int mul(int x, int y) {return (x * 1ll * y) % MOD;}
int binpow(int x, int y){
    int z = 1;
    while(y){
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}
int inv(int x) {return binpow(x, MOD - 2);}
int divide(int x, int y) {return mul(x, inv(y));}
int fact[N];
void precalc(){
    fact[0] = 1;
    for(int i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
int C(int n, int k)  {return divide(fact[n], mul(fact[k], fact[n - k]));}

/////////////// ncr  ///////////////////////


//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve(){
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) {
    	if (is_prime[i]) {
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main()
{
	ll k;
	ll s=0;
	cin>>k;
	//cout<<k;
	forn(i,1,k+1){
	    forn(j,1,k+1){
	        forn(n,1,k+1){
	            int x=__gcd(j,n);
	            //cout<<i<<" "<<j<<" "<<n<<" "<<x<<endl;
	            s+=__gcd(i,x);
	        }
	    }
	}
	cout<<s;
    
}	




Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main()
{
	string n;
	cin >> n;
	int ni = stoi(n);
	long long int ans = 0;
	int sz = n.size();
	rep2(i,1, ni+1)
	{
		string si = to_string(i);
		vector<vector<vector<vector<ll>>>> dp(sz + 1, vector<vector<vector<ll>>>(2, vector<vector<ll>>(2,vector<ll>(2,0))));
		dp[0][0][0][0] = 1;
		rep(j, sz)
		{
			int D = n[j] - '0';
			rep(k, 2)
			{
				rep(l,2){
					rep(m,2){
						for (int d = 0; d <= (k ? 9 : D);d++){
							if (m == 0 && (j < sz - 1 || si.back() == si[0]) && bool(d)){
								if (si.back() - '0' == d){
									dp[j + 1][k || (d < D)][1][bool(d) || m] += dp[j][k][l][m];
								} else {
									dp[j + 1][k || (d < D)][0][bool(d) || m] += dp[j][k][l][m];
								}
							} else if (j == sz - 1){
								if (si[0] - '0' == d && l == 1){
									dp[j + 1][k || (d < D)][1][bool(d) || m] += dp[j][k][l][m];
								} else {
									dp[j + 1][k || (d < D)][0][bool(d) || m] += dp[j][k][l][m];
								}
							} else {
								dp[j + 1][k || (d < D)][l][bool(d) || m] += dp[j][k][l][m];
							}
						}
					}
				}
				
			}
		}
		// cout << i << ":" << dp[sz][0][1][1] + dp[sz][1][1][1] << endl;

		ans += dp[sz][0][1][1] + dp[sz][1][1][1];
		// break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		int n;
		n = sc.nextInt();
		
		int a[][] = new int[2][n];
		
		for (int i = 0; i < n; i++) {
			a[0][i] = sc.nextInt();
			a[1][i] = i + 1;
		}
		
		//ソートする([0]の値でソート)
		//sort(a, n);
		quickSort(a, 0, n - 1);
		
		for (int i = 0; i < n; i++) {
			System.out.print( a[1][i] + " " );
		}
		
		return;
	}
	
	public static void sort(int array[][], int n) {
	
		if (array == null) {
			return;
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = n - 1; j > i; j--) {
				if (array[0][j] < array[0][j-1]) {
					int temp0 = array[0][j];
					int temp1 = array[1][j];
					
					array[0][j] = array[0][j-1];
					array[1][j] = array[1][j-1];
					
					array[0][j-1] = temp0;
					array[1][j-1] = temp1;
				}
			}
		}

		return;
	}
	
	
	public static void quickSort(int array[][], int left, int right) {
	
		
		if ( left > right ) {
			return;
		}
		
		
		int pivotValue = array[0][(left + right) / 2];
		
		int i = left;
		int j = right;
		
		while ( i <= j ) {
			while (array[0][i] < pivotValue) {
				i++;
			}
			
			while (array[0][j] > pivotValue) {
				j--;
			}
			
			if ( i <= j ) {
				quickSortSwap(array, i, j);
				
				i++;
				j--;
			}
		}
		
		quickSort(array, left, j);
		quickSort(array, i, right);
	}
		
	
	
	
	
	public static void quickSort2(int array[][], int left, int right){
	
		if ( left < right ) {
			int pivot = quickSortPartition( array, left, right );
			
			quickSort(array, left, pivot - 1);
			quickSort(array, pivot + 1 , right);
		}
	}
	
	public static int quickSortPartition(int array[][], int left, int right) {

		// 基準は左端の値とする
		int pivot = left;
		int pivotValue = array[0][pivot];
		
		//left ～ rightの間を大小比較
		int min = left + 1;
		int max = right;
		int i = min;
		int j = max;
		
		
		while ( i <= j ) {
			while ( i < max && i < j && array[0][i] < pivotValue ) {
				i++;
			}
			while ( j > min && i < j && pivotValue <= array[0][j] ) {
				j--;
			}
			
			if ( i <= j && array[0][i] > array[0][j]) {
				quickSortSwap(array, i, j);
				i++;
				j--;
			}
		}
		
		
		
		
		
		//最後 j が進んだ位置がpivot値が入る位置
		quickSortSwap(array, pivot, j);
		pivot = j;
		
//		String temp = "";
//		temp += "pivotValue:" + pivotValue;
//		temp += ", i:" + i + ", j:" + j + ", left:" + left + ", right:" + right;
//		if ( left <= i && i <= right ) { temp += ", array[i]:" + array[0][i]; }
//		if ( left <= j && j <= right ) { temp += ", array[j]:" + array[0][j]; }
//
//		temp += "***";
//		for (int x = left; x <= right; x++) {
//			temp += array[0][x] + "\t";
//		}
//
//		System.out.println(temp);
		
		return pivot;
	}
		
		
		
	public static void quickSortSwap(int array[][], int i, int j) {
		int temp0 = array[0][i];
		int temp1 = array[1][i];
		
		array[0][i] = array[0][j];
		array[1][i] = array[1][j];
		
		array[0][j] = temp0;
		array[1][j] = temp1;
		
		return;
	}

}

Measured memory_bytes: 62244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T def;
    function<T(T,T)> cmp;
    
public:
    SegmentTree(int _n, T _def, function<T(T,T)> _cmp) {
        n = 1;
        while(n < _n) n *= 2;
        def = _def; cmp = _cmp;
        node = vector<T>(2 * n - 1, def);
    }
    
    void update(int idx, T val) {
        idx += (n - 1);
        node[idx] = val;
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = cmp(node[idx * 2 + 1], node[idx * 2 + 2]);
        }
    }
    
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if ((r <= a) || (b <= l)) return def;
        if ((a <= l) && (r <= b)) return node[k];
        return cmp(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    SegmentTree<ll> st(n, 0, [](ll a, ll b){ return gcd(a, b); });
    rep(i, n) {
        ll a;
        cin >> a;
        st.update(i, a);
    }
    ll ans = LONG_LONG_MIN;
    rep(i, n) {
        ll l = st.query(0, i);
        ll r = st.query(i + 1, n);
        if (l == 0) ans = max(ans, r);
        else if (r == 0) ans = max(ans, l);
        else ans = max(ans, gcd(l, r));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(){
	kaijo[0]=1;
	for(int i=1;i<=2000000;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(!kaijo[0])init_fact();
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n;
string s;
signed main(){
	cin>>n>>s;
	int ans=0;
	for(char a='0';a<='9';a++){
		for(char b='0';b<='9';b++){
			for(char c='0';c<='9';c++){
				string t="";
				t.pb(a);
				t.pb(b);
				t.pb(c);
				int now=0;
				rep(i,n){
					if(s[i]==t[now])now++;
					if(now==3)break;
				}
				ans+=(now==3);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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 P = pair<int,int>;

int main(){
    int K, T;
    cin >> K >> T;
    vector<int> A(T+1);
    rep(i, T) cin >> A[i];
    vector<int> ans;
    int cnt = 0;
    int pre_idx = -1;
    int now_idx = T;
    rep(i, K){
        rep(j, T){
            if(pre_idx == j) continue;
            if(A[now_idx] < A[j]) now_idx = j;
        }
        if(now_idx == T){
            now_idx = pre_idx;
            cnt += 1;
        }
        A[now_idx] -= 1;
        ans.push_back(now_idx);
        pre_idx = now_idx;
        now_idx = T;
        
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
 int x,y,i;
	while(cin>>x){
		cin>>y;
			if(x==0&&y==0){
				break;		
			}
			if(x>y){
				i=x;
				x=y;
				y=i;	
		}
	cout<<x<<" "<<y<<endl;
	}
return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;

int func(int x){
  int sum = 0;
  while(x>0){
    sum += x%10;
    x /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin>>n;
  if(n%func(n)==0)cout<<"Yes";
  else cout<<"No";
  
        


}


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

int main(){
  int a,b,c;
  int i,f;

  scanf("%d %d %d", &a, &b, &c);

  f = 1;
  for(i = 1;i <= 1000000;i++){
    if((a*i + c) % b == 0) f = 0;
  }

  if(f) printf("NO\n");

  else printf("YES\n");

  return 0;
}


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

const int L 	= 128;
const int N 	= 130;
const int A		= 70;
const int INF 	= 0x3f3f3f3f;
int dp[N][N];

int med(string s, string t) {
	fill_n(dp[0], N * N, INF);
	for (int i = 0; i < N; ++i) {
		dp[i][0] = i;
		dp[0][i] = i;
	}
	for (int i = 1; i <= (int)s.size(); ++i) {
		for (int j = 1; j <= (int)t.size(); ++j) {
			dp[i][j] = min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + (s[i - 1] != t[j - 1])});
		}
	}
	return dp[s.size()][t.size()];
}

string secret;
int qcnt = 0;

int query(string s) {
	assert((int)s.size() <= L);
	++qcnt;
#ifdef LC
	return med(s, secret);
#else
	cout << "? " << s << endl;
	int x;
	cin >> x;
	return x;
#endif
}

string answer;
string alpha;
int n;
int a;
int p[A][N];
int cur[A];

void solve(int l, int r) {
	if (r - l == 1) {
		char add = 0;
		for (int i = 0; i < a; ++i) {
			if (p[i][l] < p[i][r]) {
				assert(!add);
				add = alpha[i];
			}
		}
		assert(add);
		answer += add;
		return;
	}
	int sum = 0;
	int m = (l + r) / 2;
	int z = 0;
	vector<int> ex;
	for (int i = 0; i < a; ++i) {
		if (p[i][l] < p[i][r]) {
			z = i;
			ex.push_back(i);
		} else {
			p[i][m] = p[i][l];
			sum -= p[i][l];
		}
	}
	assert(z);
	for (int i : ex) {
		if (i == z) {
			cur[i] = 0;
			continue;
		}
		string s = string(m, alpha[i]) + string(n - m, alpha[z]);
		sum += cur[i] = query(s) - (n - p[z][n]);
	}
	assert((sum + m) % ex.size() == 0);
	int bad = (sum + m) / (int)ex.size();
	for (int i : ex) {
		p[i][m] = bad - cur[i];
	}
	solve(l, m);
	solve(m, r);
}

int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
	cin >> secret;
#endif
	n = 0;
	for (char c = 'a'; c <= 'z'; ++c) {
		alpha += c;
	}
	for (char c = 'A'; c <= 'Z'; ++c) {
		alpha += c;
	}
	for (char c = '0'; c <= '9'; ++c) {
		alpha += c;
	}
	a = (int)alpha.size();
	for (int i = 0; i < a; ++i) {
		n += cur[i] = L - query(string(L, alpha[i]));
	}
	for (int i = 0; i < a; ++i) {
		p[i][n] = cur[i];
	}
	solve(0, n);
	cerr << qcnt << " queries" << endl;
	cout << "! " << answer << endl;
#ifdef LC
	assert(answer == secret);
#endif
	return 0;
}


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

n = int(input())
x = list(map(int, input().split()))

y = sorted(x)

median = int((x[int(n/2 - 1)] + x[int(n/2)]) / 2)

a = y[int(n/2)]
b = y[int(n/2 - 1)]

for i in range(n):

    if x[i] < a:
        print(a)
    else:
        print(b)

Measured memory_bytes: 25572
n,x=map(int,input().split())
l=list(map(int,input().split()))
l=sorted([abs(i-x) for i in l],reverse=True)

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

if n!=1:
    p=gcd(l[0],l[1])
    for i in l[2:]:
        q=gcd(i,p)
        p=q
else:
    p=l[0]
print(p)

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

#define testcases int t; cin>>t; while(t--)
#define int long long
const int MOD =  1e9 + 7;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

int32_t main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	FASTIO;

	int n;
	cin >> n;

	vector<int> v(n + 1);

	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j <= n; j += i)
		{
			v[j]++;
		}
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) ans += i * v[i];

	cout << ans;

}

Measured memory_bytes: 81276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=0;i<c-a;i++)
    cout<<'R';
  for(int i=0;i<d-b;i++)
    cout<<'U';
  for(int i=0;i<c-a;i++)
    cout<<'L';
  for(int i=0;i<d-b;i++)
    cout<<'D';
  cout<<'L';
  for(int i=0;i<d-b+1;i++)
    cout<<'U';
  for(int i=0;i<c-a+1;i++)
    cout<<'R';
    cout<<'D';
  cout<<'R';
  for(int i=0;i<d-b+1;i++)
    cout<<'D';
  for(int i=0;i<c-a+1;i++)
    cout<<'L';
  cout<<'U';
  }

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXL 100

char s1[MAXL+5],s2[MAXL+5],s3[MAXL+5];
int len1,len2,len3;
int zz1=0,zz2=-1,zz3=-1;

int main() {
	scanf("%s %s %s",s1,s2,s3);
	len1=strlen(s1),len2=strlen(s2),len3=strlen(s3);
	char tmp=s1[0];
	while(zz1<len1&&zz2<len2&&zz3<len3) {
		if(tmp=='a')
			zz1++,tmp=s1[zz1];
		else if(tmp=='b')
			zz2++,tmp=s2[zz2];
		else zz3++,tmp=s3[zz3];
	}
	if(zz1>=len1)
		printf("A\n");
	else if(zz2>=len2)
		printf("B\n");
	else printf("C\n");
	return 0;
}

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

using LL = long long;

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

    string str;
    cin >> str;

    cout << (int)str.rfind("Z") - (int)str.find("A") + 1 << endl;

    return 0;
}

Measured memory_bytes: 720
a,b,c = input().split(" ")
a = int(a)
b = int(b)
c = int(c)
for index in range(int(c)):
    if index % 2 == 0:
        if a % 2 == 0:
            a = a/2
            b += a
        else:
            a -= 1
            a = a/2
            b += a
    else: 
        if b % 2 == 0:
            b = b/2
            a += b
        else:
            b -= 1
            b = b/2
            a += b

print("{0} {1}".format(int(a),int(b)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

const int mod = 1e9+7;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> grid(n,vector<int>(n));
	for (int i=0; i<n; ++i){
		for (int j=0; j<n; ++j){
			cin >> grid[i][j];
		}
	}
	vector<int> dp((1<<n));
	dp[0] = 1;
	for (int j=0; j<n; ++j){
		for (int i=0; i<(1<<n); ++i){
			if (__builtin_popcount(i) == j+1){
				for (int k=0; k<n; ++k){
					if (grid[j][k] == 1 and i&(1<<k)){
						dp[i] = (dp[i]+dp[i^(1<<k)])%mod;
					}
				}
			}
		}
	}
	cout << dp[(1<<n)-1];
	return 0;
}


Measured memory_bytes: 19540
n = int(input())
for i in range(1, n + 1):
  if i % 3 == 0:
    print(" {}".format(i), end = "")
  else:
    x = i
    while x:
      if x % 10 == 3:
        print(" {}".format(i), end = "")
        break
      x //= 10
print()


Measured memory_bytes: 5876
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, M, X;
ll C[20], A[20][20];
ll ans = INF;

int main()
{
  std::cin >> N >> M >> X;

  rep( i, N )
  {
    std::cin >> C[i];

    rep( j, M ) 
      std::cin >> A[i][j];
  }

  rep( bit, 1<<N )
  {
    std::vector<ll> vs;

    rep( j, N ) if( bit>>j&1 )
      vs.emplace_back( j );

    ll sum = 0;
    std::vector<ll> us(20);

    for( auto v : vs )
    {
      sum += C[v];
      
      rep( j, M )
        us[j] += A[v][j];
    }

    bool fl = true;

    rep( j, M )
      fl &= us[j] >= X;

    if( fl )
      chmin( ans, sum );
  }

  std::cout << (ans==INF?-1:ans) << std::endl;

  return 0;
}

Measured memory_bytes: 3228
S = input()
n = len(S)

ans = 0
for bit in range(2**(n-1)):
    cand = []
    j = 0
    for i in range(n):
        if (bit >> i) & 1:
            cand.append(S[j:i+1])
            j = i + 1
    cand.append(S[j:])
    ans += sum(map(int, cand))
    #print(cand)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ha 1000000007
using namespace std;

const int N=210;
struct Edge{int to,next;} e[N];
int h[N],sum=0,n,m,K;
int low[N],pre[N],dfn=0;
stack<int> s;
set<int> scc;
int C[N][N];
int ans=1;

int Pow(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%ha)
		if(b&1) ans=1ll*ans*a%ha;
	return ans;
}

void Init()
{
	for(int i=0;i<=200;i++) C[i][0]=1;
	for(int i=1;i<=200;i++)
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%ha;
}

int Polya(int n)
{
	int ans=0;
	for(int i=1;i<=n;i++)
		ans=(ans+Pow(K,__gcd(i,n)))%ha;
	return 1ll*ans*Pow(n,ha-2)%ha;
}

void add_edge(int u,int v)
{
	e[++sum].to=v;
	e[sum].next=h[u];
	h[u]=sum;
}

void Tarjan(int u,int fa)
{
	low[u]=pre[u]=++dfn;s.push(u);
	for(int tmp=h[u];tmp;tmp=e[tmp].next)
	{
		int v=e[tmp].to;
		if(!pre[v])
		{
			Tarjan(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>=pre[u])
			{
				scc.clear();
				int o,cnt=0;
				do{
					o=s.top();
					scc.insert(o);
					s.pop();
				}while(o!=v);
				scc.insert(u);
				for(int x : scc)
					for(int t=h[x];t;t=e[t].next)
						if(scc.count(e[t].to)) cnt++;
				cnt>>=1;
				if(cnt<scc.size()) ans=1ll*ans*K%ha;
				if(cnt==scc.size()) ans=1ll*ans*Polya(cnt)%ha;
				if(cnt>scc.size()) ans=1ll*ans*C[cnt+K-1][K-1]%ha;
			}
		}
		else low[u]=min(low[u],pre[v]);
	}
	if(!fa) s.pop();
}

int main()
{
	int u,v;Init();
	scanf("%d%d%d",&n,&m,&K);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!pre[i]) Tarjan(i,0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    a, v = map(int,input().split())
    b, w = map(int,input().split())
    t = int(input())
    if v <= w or (v-w)*t < abs(a-b):
        print("NO")
    else:
        print("YES")

if __name__=='__main__':
    main()

Measured memory_bytes: 61868
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

#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(c) c.begin(),c.end()

int main()
{
	int N;
	cin >> N;
	const char march[] = "MARCH";
	set<char> march_set(march, march + sizeof march);
	map<char, int> march_map;
	rep(i, N) {
		string s;
		cin >> s;
		auto it = march_set.find(s[0]);
		if (it != march_set.end()) {
			march_map[*it]++;
		}
	}
	ll ans = 0;
	rep(bits, 1 << 5) {
		int num_of_bits = 0;
		rep(bit, 5) {
			if ((bits & (1 << bit)) != 0)
				num_of_bits++;
		}
		if (num_of_bits == 3) {
			ll tmp = 1;
			rep(i, 5) {
				if ((bits & (1 << i)) != 0) {
					tmp *= march_map[march[i]];
				}
			}
			ans += tmp;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(void)
{
	char *A, *B;
	
	A = (char*)malloc(150);
	B = (char*)malloc(150);

	scanf("%s", A);
	scanf("%s", B);

	int alen, blen;
	alen = strlen(A);
	blen = strlen(B);

	if (strcmp(A, B) == 0)
		printf("EQUAL");
	else {
		if (alen > blen) {
			printf("GREATER");
		}
		else if (alen < blen) {
			printf("LESS");
		}
		else {
			int i=0;
			while (i < alen) {
				if (A[i] < B[i]) {
					printf("LESS");
					break;
				}
			
				else if (A[i] > B[i]) {
					printf("GREATER");
					break;
				}
				else
					i++;
			}

		}
		
	}
	free(A);
	free(B);
	return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const long long int infLL = 9000000000000000000;
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(a) (a).begin(),(a).end()
#define mx_int_prime 999999937
const int inf = 2000000000;
const double PI = acos(-1);
const double eps = 1e-9;
typedef long double ld;
#define MOD 1000000007
typedef long long ll;
const int mx=2e5+125;
ll p[mx],a[mx],b[mx];
#define PB push_back
#define endl '\n'
#define S second
#define F first
int main()
{
    faster();
    ll n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a[i];
        b[i+1]=b[i]+a[i];
    }
    ll ans=0,k=0;
    for(int i=0; i<n; i++){
        k=a[i]*((b[n]-b[i+1])%MOD);
        ans+=k;
        ans=ans%MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6772
#include<vector>
#include<algorithm>
using namespace std;

// 辺を表す構造体
struct edge{
    int from, to;
    long long cost;
};

// v:=頂点数 es:=辺の集合 cost:=始点からの最短経路のコストを格納する配列
// s:=始点(指定しなければ頂点0) g:=終点(指定しなければ頂点v-1)
// 始点から到達可能で、かつ終点へ到達可能な負閉路が検出された場合falseを、それ以外の場合trueを返す
bool bellman_ford(int v, const vector<edge>& es, vector<long long>& cost, int s = 0, int g = -1){
    if(g == -1){
        g = v - 1;
    }

    const long long INF = 1LL << 61;

    cost.resize(v);
    fill(cost.begin(), cost.end(), INF);
    cost[s] = 0;

    for(int i = 0 ; i < v * 2 ; ++i){
        for(auto& e : es){
            if(cost[e.from] < INF && cost[e.from] + e.cost < cost[e.to]){
                if(i >= v - 1 && e.to == g){
                    return false;
                }else if(i >= v - 1){
                    cost[e.to] = -INF;
                }else{
                    cost[e.to] = cost[e.from] + e.cost;
                }
            }
        }
    }

    return true;
}

#include<iostream>

int main(){
    int n, m;
    long long p;
    cin >> n >> m >> p;

    vector<edge> es;
    for(int i = 0 ; i < m ; ++i){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        es.push_back({a - 1, b - 1, p - c});
    }

    vector<long long> cost;
    if(bellman_ford(n, es, cost)){
        cout << max(-cost[n - 1], 0LL) << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;
int check[1000010];

int main(){
    ll s;cin >> s;
    ll res = 0;
    for(int i=1;;i++){
        check[s]++;
        if(check[s]>1){
            res=i;
            break;    
        }
        if(s%2==0)s/=2;
        else s=3*s+1;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//AtCoder1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream> 
#include <algorithm>
#include <math.h> 
using namespace std;

int main()
{
    string S;
    cin >> S;
    if (S == "AAA" || S == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }

}


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


using namespace std;

#define ll long long

bool isprime(ll n) {
	if(n<=1) return 0;
	for(ll x=2;x*x<=n;x++) if(n%x==0) return 0;
	return 1;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int Q;
	cin >> Q;
	ll MAX=2e5;
	vector<ll> s(MAX);
	for(ll i=1;i<MAX;i++) {
		s[i]=s[i-1]+((i&1)&&isprime(i)&&isprime((i+1)/2));
	}
	while(Q--) {
	   ll l,r;
	   cin >> l >> r;
	   cout << s[r] - s[l-1] << "\n";
	}
   return 0;
}




Measured memory_bytes: 4744
import heapq
s = input()
t = input()

b = []

for i in range(len(s)-len(t)+1):
    flag = True
    for j, st in enumerate(s[i:i+len(t)]):
        if not st == t[j] and not st == '?':
            flag = False
            break
    if flag:
        heapq.heappush(b,(s[:i]+t+s[i+len(t):]).replace('?','a'))

if not b:
    print('UNRESTORABLE')
else:
    print(heapq.heappop(b))

Measured memory_bytes: 38384
import sys

s = list(input())  # 文字列を1文字ずつのリストにする(1文字ずつアクセスしたいので)
p = input()
for i in range(len(s)):
    j = i
    c = 0
    x = ""
    while c < len(p):
        if j == len(s):
            j = 0
        x += s[j]
        j += 1
        c += 1
    if p == x:
        print("Yes")
        sys.exit()
print("No")


Measured memory_bytes: 5564
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

int a[22];

void Main() {
  int n; cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for(int i = 1; i < n - 1; i++) {
    int b[3] = {a[i - 1], a[i], a[i + 1]};
    sort(b, b + 3);
    if(b[1] == a[i]) {
      ans++;
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int N[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    k--;
    cout<<N[k]<<endl;
}


Measured memory_bytes: 256
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)

long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[2000005]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=2000005; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


lld gcd(lld a,lld b)
{
    if(a>b) return gcd(b,a);
    if(b%a==0) return a;
    else return gcd(b%a,a);
}

lld p1=1e9 + 7,p2=998244353;
lld l,r,mid,ans;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;

// lld maxSumSub(vector<lld>& v , lld l)
// {
//     lld x = 0;
//     lld y =0 ;
//     for(i=0;i<l;i++)
//     {
//         y += v[i];
//         if(x<y)
//         {
//             x=y;

//         }
//         if(y<0)
//             y=0;
//     }
//     return x;
// }
void solve()
{
    string s;
    cin>>k>>s;
    n = s.size();
    ans =0 ;
    for(i=0;i<=k;i++)
    {
        x = nCrmodp(n+k,n+i,p1);
        x *= modp((lld)25 , p1,k-i);
        x%=p1;
        ans+=x;
        ans %=p1;
    }
    cout<<ans;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
   // cin>>t;
    //cout<<t;
     getfac(p1);
    //check the value by which modulo is to be taken
    lld ans=0;
    for(int i=0;i<t;i++)
    {
   //     cout<<"Case #"<<i+1<<": ";
                  solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 19868
package main

import "fmt"

func main() {
	var a, b, c string
	fmt.Scan(&a, &b, &c)
	if a[len(a)-1:len(a)] == b[0:1] && b[len(b)-1:len(b)] == c[0:1] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int n,d,x;
  scanf("%d%d",&n,&d);
  if(n%(2*d+1)==0){
    x=n/(2*d+1);
  }else{
    x=n/(2*d+1)+1;
  }
  printf("%d",x);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int N , a  ;
	scanf("%d", &N);
	if(N<15)
    {
      printf("%d", N*800)  ;
    }
    else if(N>=15)
    {
      a = N*800 - 200*((int)(N/15));
      printf("%d", a)  ;
    }
}


Measured memory_bytes: 256
#include <iostream>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freopen ("testcase.sevensegment", "r", stdin );

	const string num[] = { 
		"0111111", "0000110", "1011011", "1001111",
		"1100110", "1101101", "1111101", "0100111",
		"1111111", "1101111"
	};
	int n, m;

	while (1){
		string prev (7, '0');
		string curr (7, '0');
		cin >> n;
		if (n == -1){
			break;
		} // end if

		for (int i = 0; i < n; ++i){
			cin >> m;
			for (int j = 0; j < 7; ++j){
				curr[j] = ((num[m][j] - '0') ^ (prev[j] - '0')) + '0'; 
			} // end for
			cout << curr << endl;
			prev = num[m];
		} // end for
	} // end while
		
	return 0;
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	int l[n];
	for (int i = 0; i < n; i++) cin >> l[i];

	sort(l, l + n);

	int sum = 0;
	for (int i = 0; i < n - 1; i++) {
		sum += l[i];
	}

	if (sum > l[n - 1]) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int i;
	int flag = 0;
	int N;
	scanf("%d",&N);
	for(i=0;i<=50000;i++){
		if((int)(i*1.08)==N){
			flag = 1;
			break;
		}
	}
	if(flag==1)
		printf("%d",i);
	else
		printf(":(");
}

Measured memory_bytes: 128
N = int(input())
Ss, Ps = [ [], [] ]
for i in range(N):
    s, p = input().split(" ")
    Ss.append(s)
    Ps.append(int(p))
rests = list(zip(range(1, N+1), Ss, Ps))
rests.sort(key=lambda x: (x[1], -x[2]))
print('\n'.join([str(i) for i,_,_ in rests]))


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

int main(){
  ll q,h,s,d,n;
  cin >>q >>h >>s >>d >>n;
  h = min(2*q, h);
  s = min(2*h, s);
  cout << n/2*min(2*s,d) + n%2*s << endl;
  return 0; 
}

Measured memory_bytes: 3580
k, a, b = map(int, input().split())

if b - a <= 2:
    print(1+k)
    exit()

if k <= a:
    print(1+k)
    exit()

ans = 1

ans += a - 1
k -= a - 1

if k % 2 == 1:
    ans += 1
    k -= 1

ans += (b - a) * (k // 2)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
int n,m,x;
long long c[20];
long long a[20][20];
long long mn=1e18;
long long p[20];
void dfs(vector<int> v){
	memset(p,0,sizeof(p));
	long long ppp=0;
	for(int i=0;i<v.size();i++){
		ppp+=c[v[i]];
		for(int j=0;j<m;j++){
			p[j]+=a[v[i]][j];
		}
	}
	bool flag=0;
	for(int i=0;i<m;i++){
		if(p[i]<x)flag=1;
	}
	if(!flag){
		mn=min(mn,ppp);
		return ; 
	}
	if(v.empty()){
		for(int i=0;i<n;i++){
			v.push_back(i);
			dfs(v);
			v.erase(v.begin()+v.size()-1);
		}
	}
	else{
		for(int i=v[v.size()-1]+1;i<n;i++){
			v.push_back(i);
			dfs(v);
			v.erase(v.begin()+v.size()-1);
		}
	}
}
int main(){
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		bool flag=0;
		for(int j=0;j<n;j++){
			if(a[j][i]!=0)flag=1;
		}
		if(!flag){
			cout<<"-1"<<endl;
			return 0;
		}
	}
	vector<int> vvvvvvvvvvv;
	dfs(vvvvvvvvvvv);
	if(mn==1e18)cout<<"-1"<<endl;
	else cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 3640
h, w = map(int, input().split())
if h == 1 or w == 1:
    ans = 1
elif h % 2 == 0 or w % 2 == 0:
    ans = int(h * w / 2)
else:
    ans = int((h * (w - 1) / 2) + (h + 1) / 2)
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

#define INF 9999999

int n, m;
int c[10];

int memo[6][512];

int search(int leftMaisu, int leftKane) {
	int answer = INF;
	int i;
	if (leftKane < 0) return INF;
	if (leftMaisu <= 0) return 0;
	if (memo[leftMaisu][leftKane]) return ~memo[leftMaisu][leftKane];
	for (i = 0; i <= 9; i++) {
		if (c[i] <= leftKane) {
			int candidate = search(leftMaisu - 1, leftKane - c[i]) * 10 + i;
			if (candidate < answer) answer = candidate;
		}
	}
	return ~(memo[leftMaisu][leftKane] = ~answer);
}

int main(void) {
	int i;
	int kotae;
	if (scanf("%d%d", &n, &m) != 2) return 1;
	for (i = 0; i < 10; i++) {
		if (scanf("%d", &c[i]) != 1) return 1;
	}
	kotae = search(n, m);
	if (kotae < INF) {
		printf("%0*d\n", n, kotae);
	} else {
		puts("NA");
	}
	return 0;
}



Measured memory_bytes: 2144
//
//  main.cpp
//  c++proj
//
//  Created by chiiia12 on 2016/04/18.
//
//
#include <stdlib.h>
#include <iostream>

using namespace std;
int top,S[1000];
void push(int x){
//    cout<<"x:"<<x<<endl;
    S[++top]=x;
}
int pop(){
    top--;
    return S[top+1];
}
int main() {
    top = 0;
    string s;
    while(cin>>s){
        if(s=="+"){
            push(pop()+pop());
        }else if(s=="-"){
            int a = pop();
            int b = pop();
            push(b-a);
        }else if(s=="*"){
            push(pop()*pop());
        }else if(s=="/"){
            push(pop()/pop());
        }else{
            push(stoi(s));
//            push(atoi(s.c_str()));
        }
    }
    cout<<pop()<<endl;
    
    return 0;
}

Measured memory_bytes: 3156