akhauriyash/Code-Regression huggingface dataset:
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

void pri(lli n)
{
    lli i=2;
    while(i*i<=n)
    {
        if(n%i==0)
            return;
        i++;
    }
    cout<<n<<endl;
    exit(0);
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    while(true)
    {
        pri(n);
        n++;
    }
}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
def count(base, ref):
    if base > ref:
        if (base - ref) % 2:
            return (base - ref) // 2 + 2
        else:
            return (base - ref) // 2
    else:
        return ref - base

def func(base, x, y):
    return count(base, x) + count(base, y)

a, b, c = list(map(int, input().split()))
ans = min(func(a, b, c), func(b, a, c), func(c, a, b))

print(ans)

Measured memory_bytes: 3060
s = input()
odd = "".join([i for idx,i in enumerate(s) if idx%2==0])
even = "".join([i for idx,i in enumerate(s) if idx%2==1])
if odd.replace("R","").replace("U","").replace("D","") or even.replace("L","").replace("U","").replace("D",""):
  print("No")
else:
  print("Yes")

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

int main() {
	string str;
	getline(cin, str);
	for (int i = 0; i < str.size(); ++i) {
		if (str[i] >= 'a' && str[i] <= 'z') {
			str[i] -= 'a' - 'A';
		}
		else if(str[i] >= 'A' && str[i] <= 'Z') {
			str[i] += 'a' - 'A';
		}
	}

	cout << str << endl;

	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 3010;
int A,B,C,D,E,F;
bool W[31];
int S[MC];
int ansW,ansS;

int main(){
	cin >> A >> B >> C >> D >> E >> F;
	fill(S,S+MC,-1);
	S[0] = 0;
	repp(i,0,MC){
		if(S[i] < 0){
			S[i] = S[i-1];
			continue;
		}
		if(i+C<MC) S[i+C] = i+C;
		if(i+D<MC) S[i+D] = i+D;
	}
	W[0] = 1;
	ansW = A;
	repp(i,0,31){
		if(!W[i]) continue;
		if(i+A<31) W[i+A] = 1;
		if(i+B<31) W[i+B] = 1;
		if(i==0) continue;
		if(100*i > F) break;
		int tmp = min(S[E*i],F-100*i);
		if(ansS * (100*i+tmp) < tmp * (100*ansW + ansS)){
			ansW = i;
			ansS = tmp;
		}
	}
	cout << 100*ansW+ansS << ' ' << ansS << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * Problem Description: Dynamic Programming - Fibonacci Number
 * Category:
 * Author: Khan
 * Date: 18th October, 2017
 */

#include <iostream>

using namespace std;

int n;
int Fibonacci[45];

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    cin >> n;
    Fibonacci[0] = 1;
    Fibonacci[1] = 1;
    for (int i = 2; i <= n; ++i)
    {
        Fibonacci[i] = Fibonacci[i - 1] + Fibonacci[i - 2];
    }
    cout << Fibonacci[n] << endl;
    return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(i,arr)       for(int& i:arr)cin>>i;
#define output(i,arr)      for(int& i:arr)cout<<i<<" ";
#define for_each(arr)      for(auto& it:arr)
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r",stdin);
  //  //freopen("output.txt","w",stdout);
  //  #endif
   cin>>a>>b;
   if(a>=10)
   	cout<<b<<endl;
   else{
   	cout<<b+(100*(10-a))<<endl;
   }
    
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
N = int(input())
Z, W = [], []
for i in range(N):
    A = int(input())
    Z.append([list(map(int, input().split())) for i in range(A)])
for a in range(2 ** N):
    flag = 1
    for i in range(N):
        if (((a >> i) + 1) & 1):
            continue
        z = Z[i]
        for x in z:
            if not (((a >> (x[0] - 1)) + 1 - x[1]) & 1):
                flag = 0
                break
        if flag == 0:
            break
    if flag == 1:
        W.append(a)
W = [bin(x).count("1") for x in W]
print(max(W))

Measured memory_bytes: 10432
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
#define pi 3.14159265359
using namespace std;

ld calcAngle(double h, double m)
{
    // validate the input
    if (h <0 || m < 0 || h >12 || m > 60)
        printf("Wrong input");

    if (h == 12) h = 0;
    if (m == 60) m = 0;

    // Calculate the angles moved
    // by hour and minute hands
    // with reference to 12:00
    long double hour_angle = 0.5 * (h * 60 + m);
    ld minute_angle = 6 * m;

    // Find the difference between two angles
    long double angle = abs(hour_angle - minute_angle);

    // Return the smaller angle of two possible angles
    angle = min(360 - angle, angle);

    return angle;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, a = 0, b = 0, sum = 0, y = 0, z = 0, c, p;
    long double h, m, x;
    cin >> a >> b >> h >> m;
    x = calcAngle(h,m);
    long double e, f, d;
    d = a*a + b*b - 2*a*b*cos((pi*x)/180);
    cout << fixed << setprecision(20) << sqrt(d);

    return 0;
}


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


int main(){
    ll K, N ,ans;
    cin >> K >> N;
    ll A[N + 1];
    for(int i = 0; i < N; i++) cin >> A[i];
    A[N] = A[0] + K;

    ll tmp = 0;
    for(int i = 0; i < N; i++){
        tmp = max(abs(A[i] - A[i + 1]) , tmp );
    }
    ans = K - tmp;

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
 
const int MAXN = 1e5+3;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a,b;
    cin >> a >> b;
    int s = a+b;
    if(s == 3) cout << 3;
    else if(s == 4) cout << 2;
    else cout << 1;
    cout << endl;
    return 0;
}


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

int top, S[1000];

void push( int x ){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top+1];
}
int main(){
	int a,b;
	top = 0;
	char s[100];
	
	while( scanf("%s", s) != EOF ){
		if( s[0] == '+' ){
			a = pop();
			b = pop();
			push( a + b );
		}else if( s[0] == '-' ){
			b = pop();
			a = pop();
			push( a - b );
		}else if( s[0] == '*' ){
			a = pop();
			b = pop();
			push( a * b );
		}else{
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());

	
	return 0;
}


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

int main()
{
	int a[5];
	for(int i=0;i<5;i++){
		cin >> a[i];
	}
	sort(a,a+5);
	cout << a[4] << ' ';
	cout << a[3] << ' ';
	cout << a[2] << ' ';
	cout << a[1] << ' ';
	cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <ctype.h>

int main(void){
  char a[1200];
  int i;

  for(i=0;;i++){
    scanf("%c",&a[i]);

    if(isalpha(a[i])){
      if(isupper(a[i])){
	a[i]=tolower(a[i]);
      }else{
	a[i]=toupper(a[i]);
      }
    }
  
    printf("%c",a[i]);

    if(a[i]=='\n'){
      break;
    }

  }

  return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
int main()
{
    int i,j;
    scanf("%d",&i);
    int  ara[i];
    for(int k=0;k<i;k++){
        scanf("%d",&ara[k]);
    }
    int rafin;
    for(int k=0;k<i;k++){
            for(j=0;j<i-k-1;j++)
        if(ara[j]>ara[j+1]){
            rafin=ara[j];
            ara[j]=ara[j+1];
            ara[j+1]=rafin;
        }
    }

    double sum;
    sum=(double)(ara[0]+ara[1])/2;

    for(j=2;j<i;j++){
            sum=(double)(sum+ara[j])/2;

    }
    printf("%lf\n",sum);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>

using namespace std;

int main(void)
{
    int pos[5];
    int k;
    for(int i = 0; i < 5; i++){
        cin >> pos[i];
    }
    cin >>k;

    if(pos[4] - pos[0] <= k){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let mut ans: String = "No".to_string();

    if (a == b && b != c) {
        ans = "Yes".to_string();
    }

    if (a == c && c != b) {
        ans = "Yes".to_string();
    }

    if (c == b && a != b) {
        ans = "Yes".to_string();
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
import itertools

N = int(input())
A = list(input().split())
A = [int(A[i]) for i in range(N+1)]
MAX = [1 for i in range(N+1)]
A_inter = list(reversed(list(itertools.accumulate(reversed(A)))))

for i in range(N+1):
    if A[i] > MAX[i]:
        print(-1)
        sys.exit()
    elif i != N:
        MAX[i+1] = (MAX[i] - A[i]) * 2
        
print(sum([min(MAX[i], A_inter[i]) for i in range(N+1)]))

Measured memory_bytes: 680964
N, L = map(int, input().split())
A = list(map(int, input().split()))
d = [A[i] + A[i+1] for i in range(N-1)]
if max(d) < L:
  print("Impossible")
else:
  print("Possible")
  j = 0
  while d[j] < L:
    j += 1
  for i in range(j):
    print(i+1)
  for i in range(j, N-1):
    print(N-i+j-1)

Measured memory_bytes: 14056
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int inf = 1000000000;

int main(void) {
  int a, b, c;
  while(cin >> a >> b >> c){
    vector<bool> x(11, false);
    x[a] = true;
    x[b] = true;
    x[c] = true;
    double ans = 0.0;
    int tmp = a+b;
    for(int i=1; i<11; i++){
      if( !x[i] ){
        if( tmp + i <= 20 ) ans += 1.0;
      }
    }
    ans /= 7.0;
    if( ans*100 >= 50.0 ) cout << "YES" << endl;
    else cout << "NO" << endl;

  }

  return 0;
}

// EOF

Measured memory_bytes: 2988
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)
	writer := bufio.NewWriter(os.Stdout)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)

	aa := getIntList(scanner)
	counts := 0

	for i := 0; i < n; i++ {
		minj := i
		for j := i; j < n; j++ {
			if aa[j] < aa[minj] {
				minj = j
			}
		}
		if i != minj {
			aa[i], aa[minj] = aa[minj], aa[i]
			counts++
		}
	}
	for i := 0; i < n; i++ {
		fmt.Fprint(writer, aa[i])
		if i < n-1 {
			fmt.Fprint(writer, " ")
		}
	}

	fmt.Fprintln(writer, "")
	fmt.Fprintln(writer, counts)
	writer.Flush()
}



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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;
    std::vector<int> v, odd;
    for (int i = 1; i * (i + 1) * (i + 2) / 6 <= 6 * 1e6; i++)
    {
        int tmp = i * (i + 1) * (i + 2) / 6;
        v.push_back(tmp);
        if (tmp % 2)
            odd.push_back(tmp);
    }
    std::vector<int> dp(1e6 + 1), odddp(1e6 + 1);
    for (int i = 1; i <= 1e6; i++)
    {
        dp[i] = i;
        odddp[i] = i;
    }
    for (int i = 1; i <= 1e6; i++)
    {
        for (int j = 0; j < (int)v.size(); j++)
        {
            if (i - v[j] >= 0)
                dp[i] = min(dp[i], dp[i - v[j]] + 1);
        }
        for (int j = 0; j < (int)odd.size(); j++)
        {
            if (i - odd[j] >= 0)
                odddp[i] = min(odddp[i], odddp[i - odd[j]] + 1);
        }
    }
    while (cin >> n, n)
    {
        cout << dp[n] << " " << odddp[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 10572
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
TAYA
*/
#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <cassert>
#include <iomanip>
#include <random>


using namespace std;



#define ll long long
#define ld double
#define null NULL
#define prev prev228
#define index index228
#define left left228
#define right right228
#define hash hash228
#define y1 y1228
#define y0 y0228
#define firn(i, n) for (int i = 0; i < (int)n; ++i)
#define forn(i, n) for (int i = 1; i <= (int)n; ++i)
#define int long long

template<typename T> inline void uin(T &a, T b) {
    if (b < a) a = b;
}

template<typename T> inline void uax(T &a, T b) {
    if (b > a) a = b;
}

signed main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s;
	cin >> t;
	int n = (int)s.size();
	int m = (int)t.size();
	if (n != m) {
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		s = s.substr(n - 1, 1) + s.substr(0, n - 1);
		if (s == t) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}



// kek













Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int N,A,B;
	cin >> N >> A >> B;
	if(A*N<=B){
		cout << A*N << endl;
	}
	else{
		cout << B << endl;
	}

}

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

#define mp make_pair
#define pb push_back 
#define pf push_front 
#define pbp pop_back
#define pfp pop_front 
#define sz(x) x.size()
#define all(x) x.begin(),x.end() 
#define ios_base ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define open(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define F first
#define S second

using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;

const int mod = 1e9+7;
const int N = 3*1e3+123;
const int inf = 1e9+123;
const long long INF = 1e18;
const double eps = 1e-5;

int n, k, a[N], k1, k2, ans, mn = inf;
vector <int> v[N];
int x[N], y[N];
void dfs(int x, int p, int d){
 if(d > k1){
  ans ++;
 }
 for(int i = 0; i < sz(v[x]); i ++){
  int to = v[x][i];
  if(to != p) dfs(to, x,  d + 1);
 }
}

int main (){
 cin >> n >> k;
 for(int i = 1; i < n; i ++){
  cin >> x[i] >> y[i];
  v[x[i]].pb(y[i]);
  v[y[i]].pb(x[i]);
 }
 k1 = k / 2;
 if(k % 2 == 0){
  for(int i = 1; i <= n; i ++){
   dfs(i, i, 0);
   mn = min(ans, mn);
   ans = 0;
  }
 }else{
  for(int i = 1; i < n; i ++){
   dfs(x[i], y[i], 0);
   dfs(y[i], x[i], 0);
   mn = min(mn, ans);
   ans = 0;
  }
 }
 cout << mn;
 return  0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

struct P{
    P(){}
    P(ll _r, ll _i):r(_r), i(_i){}
    void real(const ll& v){r = v;}
    void imag(const ll& v){i = v;}
    ll r, i;
};

ll real(const P& p){return p.r;}
ll imag(const P& p){return p.i;}
ll norm(const P& p){ll r = real(p), i = imag(p); return r * r + i * i;}

P operator+(const P& lhs, const P& rhs){
    return P(real(lhs)+real(rhs), imag(lhs)+imag(rhs));
}
P operator-(const P& lhs, const P& rhs){
    return P(real(lhs)-real(rhs), imag(lhs)-imag(rhs));
}
P operator-(const P& p){
    return P(-real(p), -imag(p));
}

ll cross(const P& lhs, const P& rhs){
    return real(lhs)*imag(rhs) - imag(lhs)*real(rhs);
}

ll dot(const P& lhs, const P& rhs){
    return real(lhs)*real(rhs) + imag(lhs)*imag(rhs);
}

ll distance(const P& a, const P& b, const P& p){
    ll c = cross(p-a, b-a);
    return c * c;
}

P ps[3], cc;
ll radius;

bool doesLineAcrossCircle(const P& a, const P& b){
    // if(cross(a-cc, b-cc) == 0){
    //     return dot(a-cc, b-cc) < 0 && norm(a) >= radius * radius && norm(b) >= radius * radius;
    // }
    if(distance(a, b, cc) > radius * radius * norm(b-a)){return false;}
    if(dot(cc-a, b-a) * dot(cc-b, b-a) <= 0){return true;}
    return norm(cc-a) <= radius * radius || norm(cc-b) <= radius * radius;
}

bool isCircleInTriangle(){
    REP(i, 3){
        if(distance(ps[i], ps[(i+1)%3], cc) < radius * radius * norm(ps[i]-ps[(i+1)%3])){return false;}
    }

    int count_n = 0, count_p = 0;
    REP(i, 3){
        ll c = cross(cc-ps[i], ps[(i+1)%3]-ps[i]);
        if(c < 0){
            count_n += 1;
        }else if(c == 0){
            count_n += 1; count_p += 1;
        }else{
            count_p += 1;
        }
    }

    if(count_n % 3 == 0 || count_p % 3 == 0){return true;}
    return false;
}

bool isTriangleInCircle(){
    REP(i, 3){
        if(norm(ps[i]-cc) > radius * radius){return false;}
    }
    return true;
}

bool isIntersected(){
    REP(i, 3){
        if(doesLineAcrossCircle(ps[i], ps[(i+1)%3])){return true;}
    }
    return false;
}

int main(){
    ll re, im;
    while(std::cin >> re >> im, re || im){
        ps[0].real(re); ps[0].imag(im);
        
        FOR(i, 1, 3){
            ll re, im;
            std::cin >> re >> im;
        
            ps[i].real(re); ps[i].imag(im);
        }
        
        {
            ll re, im;
            std::cin >> re >> im;
            
            cc.real(re); cc.imag(im);
        }
        
        std::cin >> radius;
        
        if(isCircleInTriangle()){puts("a");}
        else if(isTriangleInCircle()){puts("b");}
        else if(isIntersected()){puts("c");}
        else{puts("d");}
    }   
}

Measured memory_bytes: 1116
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
using namespace std;
#define REP(I,N) for (I=0;I<N;I++)
#define rREP(I,N) for (I=N-1;I>=0;I--)
#define rep(I,S,N) for (I=S;I<N;I++)
#define rrep(I,S,N) for (I=N-1;I>=S;I--)
#define FOR(I,S,N) for (I=S;I<=N;I++)
#define rFOR(I,S,N) for (I=N;I>=S;I--)
typedef unsigned long long ULL;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL INFF=0x3f3f3f3f3f3f3f3fll;
const LL M=1e9+7;
const LL maxn=1e6+7;
const double eps=0.00000001;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<typename T>inline T powMM(T a,T b){T ret=1;for (;b;b>>=1ll,a=1ll*a*a%M) if (b&1) ret=1ll*ret*a%M;return ret;}

int MIN[maxn],lazy[maxn];
inline void add(int x,int val){
    lazy[x]+=val;MIN[x]+=val;
}
void update(int x,int l,int r,int val,int L,int R){
    if (l<=L&&R<=r){add(x,val);return;}
    if (lazy[x]){
        add(x<<1,lazy[x]);
        add(x<<1|1,lazy[x]);
        lazy[x]=0;
    }int mid=(L+R)/2;
    if (l<=mid) update(x<<1,l,r,val,L,mid);
    if (mid<r) update(x<<1|1,l,r,val,mid+1,R);
    MIN[x]=min(MIN[x<<1],MIN[x<<1|1]);
}
int query(int x,int l,int r,int L,int R){
    if (l<=L&&R<=r) return MIN[x];
    if (lazy[x]){
        add(x<<1,lazy[x]);
        add(x<<1|1,lazy[x]);
        lazy[x]=0;
    }int mid=(L+R)/2,ret=0;
    if (l<=mid) ret=min(ret,query(x<<1,l,r,L,mid));
    if (mid<r) ret=min(ret,query(x<<1|1,l,r,mid+1,R));
    return ret;
}
int n,m;
vector<int> have[maxn];

int i,j,k;
int l,r;
int main(){
    scanf("%d%d",&n,&m);
    FOR(i,1,n){
        scanf("%d%d",&l,&r);
        have[l].push_back(r);
    }
    FOR(i,0,m) update(1,i,i,m-i+1,0,m+1);
    int ans=min(0,m-n);
    FOR(i,0,m){
//        if (i!=0) update(1,i,i,n,1,m);
        for (int r:have[i])
            update(1,i+1,r,-1,0,m+1);
//            printf("(%d)%d %d %d\n",i,r,m,-1);
//        printf("now ans=%d\n",MIN[1]);
        ans=min(ans,query(1,i+1,m+1,0,m+1)+i);
    }printf("%d\n",-ans);
}
/*
*/


Measured memory_bytes: 34560
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;
const int N = 1e5 + 2;
vi adj[N] , vis(N);
void dfs(int src){
    vis[src] = 1;
    for(int i : adj[src])
        if(!vis[i]) dfs(i);
}

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);


    int n , m;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++){
        int u , v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int ans =0;
    for(int i = 1 ; i <= n ;i++)
        if(!vis[i]) ans++ , dfs(i);
    
    cout << ans - 1 << '\n';
    return 0;

}



Measured memory_bytes: 9960
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= 10;
		w++;
	}
	return w;
}

int kaijou(int x) {
	int y = 1;
	for (int i = 1; i <= x; i++) {
		y *= i;
	}
	return y;
}
int check(vector<int>x, int y) {
	int z = 0;
	for (int j = 0; j < y; j++) {
		if (x[j] < x[y]) {
			z++;

		}
	}
	return x[y] - z - 1;
}
int main() {
	int n, a=0, b=0;
	cin >> n;
	vector<int>p(n);
	vector<int>q(n);
	for (int i = 0; i < n; i++) {
		cin >> p.at(i);
	}
	for (int i = 0; i < n; i++) {
		cin >> q.at(i);
	}
	for (int i = 0; i < n; i++) {
		a += check(p, i) * kaijou(n - 1 - i);
	}
	for (int i = 0; i < n; i++) {
		b += check(q, i) * kaijou(n - 1 - i);
	}
	cout << max(a - b, b - a) << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <set>
#include <map>


//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)
#define All(a) (a).begin(),(a).end()
#define RAll(a) (a).rbegin(),(a).rend()
#define dump(x)  cerr << #x << " = " << (x) << endl;

//定数
#define INF 1e9
#define INFL 1e18
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
using Graph = vector<vector<int>>;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

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

	int n, m;
	ll k;
	cin >> n >> m >> k;
	vector<ll> a = vector<ll>(n + 1);
	vector<ll> b = vector<ll>(m + 1);

	REPS(i, n) {
		cin >> a[i];
	}
	REPS(i, m) {
		cin >> b[i];
	}

	REP(i, n) {
		a[i + 1] += a[i];
	}
	REP(i, m) {
		b[i + 1] += b[i];
	}

	int ans = 0;
	int j = 0;
	
	RREP(i, n + 1) {
		if (a[i] > k)continue;
		while (j<m &&a[i] + b[j + 1] <= k) {
			j++;
		}
		chmax(ans, i + j);
	}
	cout << ans << endl;

}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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

void solver() {
    i64 X = input();
    i64 a = 100;

    i64 y = 1;
    while (true) {
        a = 1.01 * a;
        if (a >= X) {
            cout << y << endl;
            return;
        }
        y++;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3692
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  ll month=0;
  for(int i=1;i<1000;i++){
    if(i%3==0){
      month+=200;
    }else{
      month+=195;
    }
  }
  for(int i=1;i<=n;i++){
    int y,m,d;cin>>y>>m>>d;
    ll ans=0;
    for(int j=1;j<=y-1;j++){
      if(j%3){
	ans+=195;
      }else{
	ans+=200;
      }
    }
    for(int j=1;j<m;j++){
      if(y%3==0){
	ans+=20;
      }else{
	if(j%2)ans+=20;
	else ans+=19;
      }
    }
    ans+=d;
    cout<<month-ans+1<<endl;
  }
  return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;

const int MAXN = 100100;
const int MOD = 1e9 + 7;

int main() {
	int N;
	int check = 0;
	ll ans = 1;
	int A[MAXN] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[a]++;
	}

	if (N % 2 == 1) {
		if (A[0] != 1)check = 1;
		for (int i = 2; i < N; i += 2) {
			if (A[i] != 2)check = 1;
			(ans *= 2) %= MOD;
		}
	}
	else {
		for (int i = 1; i < N; i += 2) {
			if (A[i] != 2)check = 1;
			(ans *= 2) %= MOD;
		}
	}
	if (check == 0) { 
		cout << (int)ans << endl; 
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){
	cout << setiosflags(ios::fixed) << setprecision(10);
	while(true){
		int n, t, l, b;
		cin >> n >> t >> l >> b;
		if(n == 0 && t == 0 && l == 0 && b == 0){ break; }
		++n;
		vector<int> back(n), lose(n);
		while(l--){
			int c;
			cin >> c;
			lose[c] = 1;
		}
		while(b--){
			int c;
			cin >> c;
			back[c] = 1;
		}
		vector< vector<double> > dp(t + 1, vector<double>(n + n));
		const double r = 1.0 / 6.0;
		dp[0][0] = 1.0;
		for(int i = 0; i < t; ++i){
			for(int j = 0; j + 1 < n; ++j){
				for(int k = 1; k <= 6; ++k){
					int p = j + k;
					if(p >= n){ p = n - (p - n + 2); }
					if(lose[p]){
						dp[i + 1][p + n] += dp[i][j] * r;
					}else if(back[p]){
						dp[i + 1][0] += dp[i][j] * r;
					}else{
						dp[i + 1][p] += dp[i][j] * r;
					}
				}
			}
			dp[i + 1][n - 1] += dp[i][n - 1];
			for(int j = n; j < n + n; ++j){
				dp[i + 1][j - n] += dp[i][j];
			}
		}
		cout << dp[t][n - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1412
let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ass =
    Array.init h @@ fun _ ->
      Array.init w @@ fun _ ->
        Scanf.scanf "%d " @@ fun a -> a in
  let bss =
    Array.init h @@ fun _ ->
      Array.init w @@ fun _ ->
        Scanf.scanf "%d " @@ fun b -> b in
  let dp = Array.init 6401 @@ fun _ ->
    Array.make_matrix (h + 1) (w + 1) false in
  dp.(0).(0).(1) <- true;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      for k = 0 to 6400 do
        let k' = abs (k + ass.(i).(j) - bss.(i).(j)) in
        if
          k' <= 6400 && (dp.(k).(i + 1).(j) || dp.(k).(i).(j + 1))
        then dp.(k').(i + 1).(j + 1) <- true;
        let k' = abs (k - ass.(i).(j) + bss.(i).(j)) in
        if
          k' <= 6400 && (dp.(k).(i + 1).(j) || dp.(k).(i).(j + 1))
        then dp.(k').(i + 1).(j + 1) <- true
      done
    done
  done;
  Printf.printf "%d\n" @@
  Array.fold_left min max_int @@
  Array.init 6401 @@ fun i ->
    if dp.(i).(h).(w) then i else max_int



Measured memory_bytes: 341752
/* ***************************************************
 *	Author        :mutinner
 *	Created Time  :2018年11月04日 星期日 21时01分39秒
 *	File Name     :21:01:39.cpp
 *************************************************** */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	int n, m;	cin >> n >> m;
	vector< pair< ll, ll > > arr( m );
	map< pair< int, int >, int > cnt;
	for ( int i = 0; i < m; ++i ) {
		cin >> arr[ i ].first >> arr[ i ].second;
		cnt[ arr[ i ] ] = i;
	}
	vector< ll > ans( m );
	sort( arr.begin(), arr.end() );
	int cur = 1;
	for ( int i = 0; i < m; ++i ) {
		if ( i ) { arr[ i ].first == arr[ i - 1 ].first ? ++cur : cur = 1; }
		ans[ cnt[ arr[ i ] ] ] = arr[ i ].first * 1000000 + cur;
	}
	for ( auto &it : ans ) { printf( "%012lld\n", it ); }
	return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int n,m,s,g;
    cin>>n>>m;
    vector<int>a(m),b(m);
    rep(i,m)cin>>a[i]>>b[i];
    if(n==1){
        s=0;
        g=10;
    }
    else{
        s=pow(10,n-1);
        g=s*10;
    }
    string h;
    int c;
    for(int i=s;i<g;i++){
        h=to_string(i);
        c=1;
        rep(j,m){
            if(h[a[j]-1]-'0'!=b[j])c=0;
        }
        if(c){
            cout<<i;
            return 0;
        }
        
    }
    cout<<-1;
	return 0;
}


Measured memory_bytes: 3916
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  ll n, k;
  cin >> n >> k;
  
  
  ll s = 0, l = 0;
  for (ll i = 0; i < k; i++) {
    s += i;
    l += n - i;
  }

  ll ans = l - s + 1;
  ans %= MOD;
  for (ll i = k + 1; i <= n + 1; i++) {
    s += i - 1LL;
    l += n - i + 1LL;
    ans += (l - s + 1) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

//Moduic Squares
public class Main{

	int[][] a;
	int M, res;
	boolean[] u;
	
	void f(int k, int m){
		if(k==3){
			dfs(1, 0, m); return;
		}
		if(a[0][k]>0)f(k+1, (m+a[0][k])%M);
		else for(int j=1;j<=10;j++){
			if(!u[j]){
				u[j] = true;
				a[0][k] = j;
				f(k+1, (m+j)%M);
				u[j] = false;
				a[0][k] = 0;
			}
		}
	}
	
	void dfs(int i, int j, int m){
		if(i==3){
			res++; return;
		}
		if(a[i][j]>0){
			boolean f = true;
			if(j==2){
				if((a[i][0]+a[i][1]+a[i][2])%M!=m)f = false;
			}
			if(i==2){
				if((a[0][j]+a[1][j]+a[2][j])%M!=m)f = false;
			}
			if(i==2&&j==0){
				if((a[2][0]+a[1][1]+a[0][2])%M!=m)f = false;
			}
			if(i==2&&j==2){
				if((a[0][0]+a[1][1]+a[2][2])%M!=m)f = false;
			}
			if(f)dfs(i+(j+1)/3, (j+1)%3, m);
		}
		else{
			for(int k=1;k<=10;k++){
				if(!u[k]){
					u[k] = true;
					a[i][j] = k;
					boolean f = true;
					if(j==2){
						if((a[i][0]+a[i][1]+a[i][2])%M!=m)f = false;
					}
					if(i==2){
						if((a[0][j]+a[1][j]+a[2][j])%M!=m)f = false;
					}
					if(i==2&&j==0){
						if((a[2][0]+a[1][1]+a[0][2])%M!=m)f = false;
					}
					if(i==2&&j==2){
						if((a[0][0]+a[1][1]+a[2][2])%M!=m)f = false;
					}
					if(f)dfs(i+(j+1)/3, (j+1)%3, m);
					u[k] = false;
					a[i][j] = 0;
				}
			}
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			a = new int[3][3];
			for(int i=0;i<3;i++)for(int j=0;j<3;j++)a[i][j]=sc.nextInt();
			M = sc.nextInt();
			if(M<0)break;
			res = 0;
			u = new boolean[11];
			for(int i=0;i<3;i++)for(int j=0;j<3;j++)u[a[i][j]] = true;
			u[M] = true;
			if(M>0)f(0, 0);
			else for(int k=1;k<=10;k++){
				if(!u[k]){
					u[k] = true; M = k; f(0, 0); u[k] = false;
				}
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static boolean debug = true;
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// write herea
		int N=sc.nextInt();
		long K=sc.nextLong();
		Map<Integer,Long> m= new HashMap();
		for(int i=0;i<N;i++){
			int key=sc.nextInt();
			int value=sc.nextInt();
			m.put(key, m.getOrDefault(key, (long) 0)+value);
		}
		List<Entry<Integer,Long>> l= new ArrayList();
		l.addAll(m.entrySet());
		Collections.sort(l,(a,b)->a.getKey()-b.getKey());
		for(int i=0;i<l.size();i++){
			K-=l.get(i).getValue();
			if(K<=0){
				System.out.println(l.get(i).getKey());
				break;
			}
		}
	}

	private static void print(String string) {
		// TODO Auto-generated method stub
		if (debug)
			System.out.println(string);
	}

	private static void print(int[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(String[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(char[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(double[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(int[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}

	private static void print(char[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	private static void print(String[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	private static void print(double[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i + " " + j + ":" + data[i][j] + " ");
				}
				System.out.println();
			}
		}
	}

	public static void inPutData(char[][] c) {
		for (int i = 0; i < c.length; i++) {
			c[i] = sc.nextLine().toCharArray();
		}
	}

}


Measured memory_bytes: 93328
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int a, b; cin >> a >> b;
  auto ans = (a+b+1) / 2;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ll N,M,count=0,ans=0;
  cin>>N>>M;
  map<ll,string> m;
  vector<ll> vec(N);
  for(ll i=0;i<M;i++){
    ll a;
    string b;
    cin>>a>>b;
    if(m[a]!="AC"){
      m[a]=b;
      if(m[a]=="WA"){
        vec.at(a-1)++;
      }
      if(m[a]=="AC"){
        count++;
      }
    }
  }
  for(auto it=m.begin();it!=m.end();it++){
    if((*it).second=="AC"){ans+=vec.at((*it).first-1);}
  }
  cout<<count<<" "<<ans<<endl;
}

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
// #define DEBUG 10
 
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const ll mod = 1e9+7, maxn = 20, maxm = (1 << 18);
const ld PI = acos(-1);



int main (){
    ios_base::sync_with_stdio(false);

    int n;

    cin >> n;

    vector<int> a(n), b(n);

    for (int i=0; i<n; i++){
        cin >> a[i] >> b[i];
    }

    sort(all(a));
    sort(all(b));

    if (n&1){
        cout << b[n/2] - a[n/2] + 1 << endl;
    }
    else {
        cout << b[n/2] + b[n/2-1] - a[n/2] - a[n/2-1] + 1<< endl;
    }
    return 0;
}

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

using namespace std;

const int N = 52;


long long p2[N];
//15
int main() {
	int n, p;
	cin >> n >> p;
	p2[0] = 1;
	for (int i = 1; i < N; ++i) {
		p2[i] = 2LL*p2[i-1];
	}
	int odd = 0, even = 0;
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		if(x&1) odd++;
		else even++;
	}
	if(odd == 0 && p == 1) {
		printf("%lld\n", 0);
	} else {
		printf("%lld\n", p2[even+max(0,odd-1)]);
	}



}

Measured memory_bytes: 256