akhauriyash/Code-Regression huggingface dataset:
def main():
    while 1:
        N, M = map(int, input().split())
        if N == M == 0:
            break
        data = [0]*(M+1)
        def add(k, x):
            while k <= M:
                data[k] += x
                k += k & -k
        def get(k):
            s = 0
            while k:
                s += data[k]
                k -= k & -k
            return s
        M0 = 2**(M-1).bit_length()
        def lower_bound(x):
            w = i = 0
            k = M0
            while k:
                if i+k <= M and w + data[i+k] <= x:
                    w += data[i+k]
                    i += k
                k >>= 1
            return i+1
        *K, = map(int, input().split())
        su = 0
        ans = 0
        for k in K:
            su = (su + k) % M
            v = get(su+1)
            w = lower_bound(v)-1
            if w == M:
                w = 0
            ans = max(ans, (su - w) % M)
            add(su+1, 1)
        print(ans)
main()



Measured memory_bytes: 11160
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine
getNString n = map readString <$> replicateM n BS.getLine

comb :: Int -> [a] -> [[a]]
comb 0 xs = [[]]
comb _ [] = []
comb n (x:xs) = [x:y | y <- comb (n-1) xs] ++ comb n xs

counts :: [String] -> Integer -> Integer -> Integer -> Integer -> Integer ->[Integer]
counts [] a b c d e = [a, b, c, d, e]
counts (s:ss) a b c d e
  | s' == 'M' = counts ss (a+1) b c d e
  | s' == 'A' = counts ss a (b+1) c d e
  | s' == 'R' = counts ss a b (c+1) d e
  | s' == 'C' = counts ss a b c (d+1) e
  | s' == 'H' = counts ss a b c d (e+1)
  | otherwise = counts ss a b c d e
  where
    s' = head s

main = do
  n <- getInt
  ss <- getNString n
  let ss' = map head ss
  let ns = counts ss' 0 0 0 0 0
  let ns' = filter (\n -> n > 0) ns
  let r | l < 3 = 0
        | l == 3 = product ns'
        | l > 3 = sum(map product (comb 3 ns'))
        where
          l = length ns'
  print r

Measured memory_bytes: 25732
dp = {}
def rec(s):
    if s in dp:
        return dp[s]
    ret = int(s)
    for i in range(1,len(s)):
        ret += int(s[:i] )* (2**(len(s) - i - 1)) + rec(s[i:])
    dp[s] = ret
    return ret
print(rec(input()))

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;

  if(n%2==0) cout << n << endl;
  else cout << 2*n << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b)cout<<"delicious"<<endl;
    else if(b-a>x)cout<<"dangerous"<<endl;
    else cout<<"safe"<<endl;
    return 0;
}



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

def main():
    N = int(input())
    def prime(N):
        p_list = [True for _ in range(N+1)]
        p_list[0] = False
        p_list[1] = False
        for i in range(2,int(N**0.5)+1):
            if not p_list[i]:
                continue
            for j in range(i*2,N+1,i):
                p_list[j] = False
        return [i for i in range(N+1) if p_list[i]]

    pl = prime(55555)
    ans = []
    for i in pl:
        if (i-1)%5 == 0:
            ans.append(i)
        if len(ans) == N:
            print(*ans)
            exit()

if __name__ == "__main__":
    main()

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

int partition(int a[], int p, int r);

int main() {
	int i, n, key, a[100000];
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	key = partition(a, 0, n - 1);
	for (i = 0; i < n; i++) {
		if (i == key)cout << "[" << a[i] << "]";
		else cout << a[i];
		if (i != n - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

int partition(int a[], int p, int r) {
	int i, j, x;
	x = a[r];
	i = p - 1;
	for (j = p; j < r; j++) {
		if (a[j] <= x) {
			i++;
			swap(a[i], a[j]);
		}
	}
	swap(a[i + 1], a[r]);
	return i + 1;
}

Measured memory_bytes: 3460
#include "algorithm"
#include "iomanip"
#include "iostream"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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

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

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

const int MAX = 410000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  ll N, K;
  cin >> N >> K;

  // 前処理
  COMinit();

  // 計算例
  ll res = 0;

  if (K >= N) {
    ll res = COM(N + (N - 1), N);
    drop(res);
  }

  if (K == 1) {
    ll res = N * (N - 1);
    drop(res);
  }

  rep(yobun, min(N - 1, K) + 1) {
    ll cand = N - yobun;
    ll aa = COM(yobun + (cand - 1), yobun);
    ll bb = aa * COM(N, N - cand);
    res += bb;
    res %= MOD;
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 9984
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];

        for(int i=0;i<n;i++)
        {
        	a[i] = sc.nextInt();
        	b[i] = sc.nextInt();
        	c[i] = sc.nextInt();
        }

        int[][] dp = new int[n][3];
        dp[0][0] = a[0];
        dp[0][1] = b[0];
        dp[0][2] = c[0];
        for(int i=1;i<n;i++)
        {
           dp[i][0] = Math.max(dp[i-1][2],dp[i-1][1])+a[i];
           dp[i][1] = Math.max(dp[i-1][2],dp[i-1][0])+b[i];
           dp[i][2] = Math.max(dp[i-1][1],dp[i-1][0])+c[i];
        }

        System.out.println(Math.max(Math.max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
        
 	}
}

Measured memory_bytes: 61096
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    long long N, P;
    vector<long long> A(2, 0);

    cin >> N >> P;
    for (long long i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        A[t % 2]++;
    }

    long long t = pow(2, A[0]);
    long long total = 0;
    for (long long i = P; i <= A[1]; i += 2)
    {
        long long c = 1;
        for (long long j = 0; j < min(i, A[1] - i); j++)
            c *= (A[1] - j);
        for (long long j = 1; j < min(i, A[1] - i) + 1; j++)
            c /= j;
        total += t * c;
    }

    cout << total << endl;
}

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

int main()
{
    char a[111], b[111], c[111], turn[2];
    turn[0] = 'a';
    int ac = 0, bc = 0, cc = 0;
    cin >> a >> b >> c;
    for (int i = 0; i < strlen(a) + strlen(b) + strlen(c); i++)
    {
        if (turn[0] == 'a')
        {
            if (strlen(a) > ac)
            {
                turn[0] = a[ac];
                ac++;
            }
            else
            {
                cout << 'A' << endl;
                return 0;
            }
        }
        else if (turn[0] == 'b')
        {
            if (strlen(b) > bc)
            {
                turn[0] = b[bc];
                bc++;
            }
            else
            {
                cout << 'B' << endl;
                return 0;
            }
        }
        else
        {
            if (strlen(c) > cc)
            {
                turn[0] = c[cc];
                cc++;
            }
            else
            {
                cout << 'C' << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<bool> vb;
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;}
int const INF = 1 << 30;


int main()
{
    int n,Q;
    cin >> n >> Q;
    n -= 2;

    ll white = 0;
    int H = n, W = n;
    vector<int> height(n),width(n);
    rep(q,Q) {
        int type,x;
        cin >> type >> x;
        x -= 2;
        if(type == 1) {
            if(x < W) {
                white += H;
                for(int i = x; i < W; ++i) {
                    height[i] = H;
                }
                W = x;
            }
            if(x > W) {
                white += height[x];
            }
        }

        if(type == 2) {
            if(x < H) {
                white += W;
                for(int i = x; i < H; ++i) {
                    width[i] = W;
                }
                H = x;
            }
            if(x > H) {
                white += width[x];
            }
        }
    }

    cout << (ll)n*n - white << endl;
    return 0;
}

Measured memory_bytes: 4760
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
int a[6] , k;
int main(){
    for(int i = 1 ; i <= 5 ; i ++){
        cin >> a[i];
    }
    cin >> k;
    if(a[5]-a[1] > k){
        cout << ":(";
    }else cout << "Yay!";
    return 0;
}


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

int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K)
    cout << S << endl;
  else {
    for (int i=0; i<K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


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

using namespace std;
typedef long long LL;

int bon[] = {3};
int hon[] = {2, 4, 5, 7, 9};
int pon[] = {0, 1, 6, 8};

int main() {
	int N;
	scanf("%d", &N);
	N %= 10;
	if (N == bon[0]) printf("bon\n");
	else {
		for (int i = 0; i < 5; i++) {
			if (N == hon[i]) {
				printf("hon\n");
				return 0;
			}
		}
		for (int i = 0; i < 4; i++) {
			if (N == pon[i]) {
				printf("pon\n");
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



  
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
    string a,b;
    int ans=0;
    cin >> a >> b;
    for(int i = 0; i<a.size(); i++){
		if(a[i] != b[i]){
			ans+=1;
		}
	}
    cout << ans;
    
}
	
	
	
	


	



Measured memory_bytes: 3792
#include<stdio.h>
#define MOD 1000000007
#define ll long long
ll modpow(ll a,ll n,ll mod){
    ll result=1;
    while(n>0){
        if(n&1)
            result=result*a%mod;
        a=a*a%mod;
        n/=2;
    }
    return result;
}
ll modinv(ll a,ll mod){
    return modpow(a,mod-2,mod);
}
int main(){
    int n,a,b,i;
    ll ans=0,m=1,c;
    scanf("%d%d%d",&n,&a,&b);
    ans=(modpow(2,n,MOD)-1)%MOD;
    c=n;
    for(i=2;i<=a;i++){
        m=m*i%MOD;
        c=c*(n-i+1)%MOD;
    }
    ans=(ans-c*modinv(m,MOD))%MOD;
    for(;i<=b;i++){
        m=m*i%MOD;
        c=c*(n-i+1)%MOD;
    }
    ans=(ans-c*modinv(m,MOD))%MOD;
    while(ans<0){
        ans+=MOD;
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;


namespace ALDS1_2_A_Bubble_Sort
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int numCount = int.Parse (Console.ReadLine ());
			int[] numArray = Console.ReadLine ().Split (' ').Select (x => int.Parse (x)).ToArray ();

			//process
			//ascending
			int sortCount = 0;

			bool flag = true;
			while (flag)
			{
				flag = false;
				for (int index = numCount - 1; 1 <= index; index--)
				{
					if (numArray[index] < numArray[index - 1])
					{
						var tmp = numArray[index];
						numArray[index] = numArray[index - 1];
						numArray[index - 1] = tmp;
						flag = true;

						sortCount++;
					}
				}
			}
			
			//output
			for (int lp = 0; lp < numCount; lp++)
			{
				if (lp + 1 < numCount)
				{
					Console.Write (numArray[lp] + " ");
				}
				else
				{
					Console.WriteLine (numArray[lp]);
				}
			}
			Console.WriteLine (sortCount);
		}
	}
}

Measured memory_bytes: 9608
#include <stdio.h>
int less(int dt[3], int y, int m, int d) {
	return (dt[0]<y || (dt[0]==y && (dt[1]<m || (dt[1]==m && dt[2]<d))));
}

int main(void) {
	int date[3];

	while (scanf("%d %d %d ", date, date+1, date+2) != EOF) {
		if (less(date, 1868, 9, 8)) {
			puts("pre-meiji");
		} else if (less(date, 1912, 7, 30)) {
			printf("meiji %d %d %d\n", date[0]-1867, date[1], date[2]);
		} else if (less(date, 1926, 12, 25)) {
			printf("taisho %d %d %d\n", date[0]-1911, date[1], date[2]);
		} else if (less(date, 1989, 1, 8)) {
			printf("showa %d %d %d\n", date[0]-1925, date[1], date[2]);
		} else {
			printf("heisei %d %d %d\n", date[0]-1988, date[1], date[2]);
		}
	}
	return 0;
}

Measured memory_bytes: 608
import sys
#import numpy as np
#import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

input=sys.stdin.readline
n,m=map(int,input().split())
lm=1
rm=n
for i in range(m):
    l,r=map(int,input().split())
    if l>lm:
        lm=l
    if r<rm:
        rm=r
ans=rm-lm+1 if rm>=lm else 0
print(ans)

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(int n) { return __builtin_popcount(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

//const int MAX = 300010;
//const int INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;




int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);


    ll a,b;
    cin >> a >> b;
    if(a*b==15) puts("*");
    else if(a+b==15) puts("+");
    else puts("x");

    return 0;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define yes(n) cout << ((n) ? "Yay!" : ":(") << endl
int main()
{
    int n,m;
    cin >> n >> m;
    if(max(n,m) >= 9)
    {
        yes(false);
    }
    else
    {
        yes(true);
    }
}

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

using namespace std ;

string s , t ;
int dp[ 3001 ][ 3001 ] ;
stack< char > st ;

void print()
{
    int i = t.size()  ;
    int j = s.size() ;

    while( i > 0 && j > 0 )
    {
        if( dp[ i - 1 ][ j ] < dp[ i ][ j ] && dp[ i ][ j -1 ] < dp[ i ][ j ] )
        {
            st.push( t[ i - 1 ] ) ;
            i-- , j-- ;
        }
        else if( dp[ i - 1 ][ j ] < dp[ i ][ j - 1 ] )
                    j-- ;
                else
                    i-- ;
    }

    while( !st.empty() )
    {
        cout << st.top() ;
        st.pop() ;
    }
}

int solve( int i , int j )
{
    if( i <= 0 || j <= 0 )
        return 0 ;

    if( dp[ i ][ j ] != -1 )
        return dp[ i ][ j ] ;

    int ans1 = 0 ;
    if( s[ j - 1 ] == t[ i - 1 ] )
        ans1 += ( 1 + solve( i - 1 , j - 1 ) ) ;

    int ans2 = solve( i , j - 1 ) ;
    int ans3 = solve( i - 1 , j ) ;


    dp[ i ][ j ] = max( ans1 , max( ans2 , ans3 ) ) ;
    return dp[ i ][ j ] ;
}
int main()
{
    cin >> s >> t ;
    memset( dp , -1 , sizeof(dp) ) ;

    for( int i = 0 ; i <= t.size() ; i++ )
        dp[ i ][ 0 ] = 0 ;
    for( int i = 0 ; i <= s.size() ; i++ )
        dp[ 0 ][ i ] = 0 ;

    int lcs_size = solve( t.size()  , s.size() ) ;
    ///cout << lcs_size << endl ;
    print() ;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	if(n%2==0)cout << n << endl;
	else cout << 2*n << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

constexpr int mod = 1e9 + 7;
using ll = long long;

ll modpow(ll a, ll p) {
  if (p == 0) return 1;
  ll r = modpow(a, p/2);
  r *= r;
  r %= mod;
  if (p & 1) r *= a;
  r %= mod;
  return r;
}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> cnt(K+1);
  ll res = 0;
  for (int i = K; i > 0; i--) {
    ll a = K / i;
    a = modpow(a, N);
    for (int j = i + i; j <= K; j += i) {
      a += mod - cnt[j];
    }
    cnt[i] = a % mod;
    res += cnt[i] * i;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int a[105],b[105],c,maxn,a1,b1,man;
int main()
{
    cin>>a1>>b1>>c;
    maxn=max(a1,b1);
    int o=0,p=0;
    for(int i=1;i<=maxn;i++)
    {
        if(a1%i==0&&a1>=i){a[o++]=i;}
        if(b1%i==0&&b1>=i){b[p++]=i;}
    }
    man=max(o,p);
    int k=0;
    for(int i=man;i>=0;i--)
    {
        for(int j=man;j>=0;j--)
        {
            if(a[i]==b[j]&&j<p&&i<o)
            {
                k++;
                //printf("%d\n",i);
                if(k==c){printf("%d\n",a[i]);}
                break;
            }
        }
        if(k==c){break;}
    }
    return 0;
}


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

#define ll long long
#define pii pair<ll, ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rev(a) reverse(all(a)

int main() {
    ll n;
    cin >> n;
    for(int i=1; i<=9; i++){
        if(n%i==0&&n/i>=1&&n/i<=9){
            cout << "Yes" <<endl;
            return 0;
        }
    }
    cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        int K = scan.nextInt();
        char[] data = S.toCharArray();
        int N = data.length;
        for (int i = 0; i < N - 1; i++) {
            if (data[i] == 'a') {
                continue;
            }
            int step = 26 - (data[i] - 'a');
            if (step <= K) {
                K -= step;
                data[i] = 'a';
            }
        }
        int last = (data[N - 1] - 'a' + K) % 26;
        data[N - 1] = (char) (last + 'a');
        System.out.println(data);
    }
}


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

int h,w,k;
int f(vector<string> &c){
  int x=0;
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='#') x++;
    }
  } 
  return x;
}

int main(){
  cin>>h>>w>>k;
  vector<string> c(h);
  rep(i,h) cin>>c[i];
  
  int ans=0;
  rep(bit,1<<h){
    rep(bit2,1<<w){
      vector<string> cc=c;
      rep(i,h){
        if(bit>>i&1) rep(t,w) cc[i][t]='.';
      }
      rep(i,w){
        if(bit2>>i&1) rep(t,h) cc[t][i]='.';
      }
      if(f(cc)==k) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b;
    cin >> a >> b ;
    
    /*
    if(a == b){
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }
    */
    
    cout << ( a + b ) % 24 << endl;

    return 0; 
}


Measured memory_bytes: 3588
N, M = map(int, input().split())
A = [0 for i in range(N)]
B = [1 for i in range(N)]
A[0] = 1
for i in range(M):
  a, b = map(int, input().split())
  B[a-1] -= 1
  B[b-1] += 1
  if A[a-1] == 1:
    A[b-1] = 1
  if B[a-1] == 0:
    A[a-1] = 0
print(sum(A))

Measured memory_bytes: 4752
import collections
N,K = map(int,input().split())
N_List = list(map(int,input().split()))

Chou_List = collections.Counter(N_List)
if len(Chou_List) <= K:
    print(0)
else:
    Chou_List = sorted(list(Chou_List.values()),reverse=True)
    print(sum(Chou_List[K:]))


Measured memory_bytes: 35272
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{

    int x,a,b,c;
    int ans = 0;

    cin >> a >> b >> c >> x;

    rep(i,a+1){
      rep(j,b+1){
        rep(k,c+1){
          if(500*i+100*j+50*k == x) ans++;
        }
      }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int INF = 5*1e8;

class UnionFind{
  vi p,r;
public:
  UnionFind(int n):p(n,-1),r(n,0){ }
  int find(int x){ return (p[x]<0)?x:(p[x] = find(p[x])); }
  bool same(int x,int y){return find(x)==find(y);}
  void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;

    if(r[x] < r[y])p[x] = y;
    else p[y] = x;
    if(r[x] == r[y])r[x]++;
  }
};

inline int MSB(int x){ return x>0?31-__builtin_clz(x):-1; }

struct LCA{
  vector<vi> par,w;
  vi depth;
  int ln;
  
  LCA(void){}
  LCA(const vector<vi> t, const vi weight, int root){
    int n = t.size(); ln = MSB(n)+1;
    depth.resize(n); par.resize(ln,vi(n));
    w.resize(ln,vi(n)); w[0] = weight;

    stack< pair<int,int> > s;
    s.push(make_pair(root,-1));
    while(s.size()){
      int v = s.top().first, p = s.top().second; s.pop();
      par[0][v] = p;
      depth[v] = ((p<0)?0:(depth[p]+1));

      for(int u : t[v]){
	if(u != p)s.push(make_pair(u,v));
      }
    }

    rep(k,ln-1)rep(v,n){
      if(par[k][v]<0){
	par[k+1][v] = -1;
	w[k+1][v] = INF;
      }else{
	par[k+1][v] = par[k][par[k][v]];
	w[k+1][v] = min(w[k][v], w[k][par[k][v]]);
      }
    }
  }

  inline int min_lca(int u, int v){
    int res = INF;
    if(depth[u] > depth[v])swap(u,v);
    rep(k,ln){
      if((depth[v]-depth[u])>>k & 1){
	res = min(res, w[k][v]);
	v = par[k][v];
      }
    }

    if(u==v)return min(res, w[0][u]);
    for(int k = ln-1;k>=0;k--){
      if(par[k][u] != par[k][v]){
	res = min(res, min(w[k][u], w[k][v]));
	u = par[k][u];
	v = par[k][v];
      }
    }
    return min(res, min(w[1][u], w[1][v]));
  }
  inline int dep(int v){ return depth[v]; }
};

int main(){
  int n,m,k,Q;
  cin >> n >> m >> k >> Q;
  vector< vector<pii> > g(n);
  rep(i,m){
    int a,b,l;
    cin >> a >> b >> l; a--; b--;
    g[a].push_back(pii(b,l));
    g[b].push_back(pii(a,l));
  }

  vi dis(n,INF);
  priority_queue<pii> q;
  rep(i,k){
    int f;
    cin >> f; f--;
    dis[f] = 0;
    q.push(pii(0,f));
  }

  while(q.size()){
    pii p = q.top(); q.pop();
    int d = -p.first, v = p.second;
    if(dis[v] < d)continue;
   
    for(pii nxt : g[v]){
      int u = nxt.first, cost = d+nxt.second;
      if(dis[u] > cost){
	dis[u] = cost;
	q.push(pii(-cost,u));
      }
    }
  }

  vector<pii> order(n);
  rep(i,n)order[i] = pii(dis[i],i);

  sort(all(order)); reverse(all(order));
  UnionFind uf(n);

  vector<vi> tree(n);
  rep(i,n){
    int v = order[i].second;
    vector<pii> nxt;
    for(pii p : g[v]){
      int u = p.first;
      nxt.push_back(pii(dis[u],u));
    }
    sort(all(nxt)); reverse(all(nxt));
    for(pii p : nxt){
      int u = p.second;
      if(dis[u] < dis[v])break;
      if(!uf.same(v,u)){
	tree[u].push_back(v);
	tree[v].push_back(u);
	uf.unite(v,u);
      }
    }
  }
 
  LCA query(tree, dis, 0);
  rep(i,Q){
    int u,v;
    cin >> u >> v; u--; v--;
    cout << query.min_lca(u,v) << endl;
  }
}

Measured memory_bytes: 36988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

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

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int H, W;
    cin >> H >> W;
    auto S = make_v<char>(H, W);
    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            cin >> S[i][j];
        }
    }
    vvint yoko = make_v<int>(H, W), tate = make_v<int>(H, W);
    for (size_t i = 0; i < H; i++)
    {
        int count = 0;
        for (size_t j = 0; j < W; j++)
        {
            if (S[i][j] == '#' or j == W - 1)
            {
                if (S[i][j] == '#')
                    yoko[i][j] = 0;
                else
                {
                    count++;
                    yoko[i][j] = count;
                }

                for (int k = j - 1; k >= 0 and S[i][k] != '#'; k--)
                {
                    yoko[i][k] = count;
                }

                count = 0;
            }
            else
            {
                count++;
            }
        }
    }
    for (size_t j = 0; j < W; j++)
    {
        int count = 0;
        for (size_t i = 0; i < H; i++)
        {
            if (S[i][j] == '#' or i == H - 1)
            {
                if (S[i][j] == '#')
                    tate[i][j] = 0;
                else
                {
                    count++;
                    tate[i][j] = count;
                }

                for (int k = i - 1; k >= 0 and S[k][j] != '#'; k--)
                {
                    tate[k][j] = count;
                }

                count = 0;
            }
            else
            {
                count++;
            }
        }
    }
    int ans = 0;
    for (size_t i = 0; i < H; i++)
    {
        for (size_t j = 0; j < W; j++)
        {
            chmax(ans, yoko[i][j] + tate[i][j] - 1);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <utility>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
#define min(a,b) a > b ? b : a 
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF = 1e9;

int main(){
    int h,n;
    cin >> h >> n;
    vector<pii> vp;
    vector<int> dp(20010);

    rep(i,20010){
        dp[i] = INF;
    }
    dp[0] = 0;

    rep(i,n){
        int a,b;
        cin >> a >> b;
        vp.push_back(make_pair(a,b));
    }

    rep(i,h+1){
        rep(j,n){
            dp[min(i+vp[j].first,h)] = min(dp[min(i+vp[j].first,h)],dp[i] + vp[j].second);
        }
    }

    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 384
/* author   : mpily :-()
title : Competing.cpp
time :Sat Apr 11 11:13:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>S(n);
	vector<int>T(m);
	for(int i = 0; i < n;++i){
		cin>>S[i];
	}
	for(int i = 0; i < m ;++i){
		cin>>T[i];
	}
	vector<long long>canSat(n+1);
	canSat[0] = 1;
	for(int i = 0; i < m; ++i){
		long long psum = 1;
		for(int j = 1; j <= n; ++j){
			long long tmp = psum+canSat[j];
			tmp%=mod;
			if(S[j-1] == T[i]){
				canSat[j]+=psum;
				canSat[j]%=mod;
			}
			psum = tmp;
		}
	}
	long long ans = 0;
	for(auto a : canSat){
		ans+=a;
		ans%=mod;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
'use strict'

const main = (input) => {
    input = input.split(' ')
    const a = parseInt(input[0])
    const op = input[1]
    const b = parseInt(input[2])
    if(op === '+'){
        console.log(a + b)
    }else{
        console.log(a - b)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 100005
vec adj[mex];
ll dp[mex][2];

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline ll dfs(int u,int p)
{
    dp[u][0]=1; dp[u][1]=1;
    rep(i,0,sz(adj[u])){
        int v=adj[u][i];
        if(v==p) continue;
        dp[u][0]*=dfs(v,u); dp[u][0]%=mod;
        dp[u][1]*=dp[v][0]; dp[u][1]%=mod;
    }
    return (dp[u][0]+dp[u][1])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    rep(i,0,n-1){
        int u,v; cin>>u>>v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    cout<<dfs(0,0)<<endl;
}

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

int main() {
  int n, m, x, temp, cnt1 = 0, cnt2 = 0;

  cin >> n >> m >> x;

  for (int i = 0; i < m; i++) {
    cin >> temp;
    if (temp < x) cnt1++;
    if (temp > x) cnt2++;
  }

  cout << min(cnt1, cnt2);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}

void print(unsigned char Q[8][8]) {
    for(int i = 0; i < 8; ++i) {
        for(int j = 0; j < 8; ++j)
            putchar_unlocked(Q[i][j] ? 'Q' : '.');
        putchar_unlocked('\n');
    }
}
void queen_eight(unsigned char Q[8][8], unsigned char row[8], unsigned char col[8], unsigned char lrd[15], unsigned char lld[15], int cnt) {
    if(cnt == 8) {
        print(Q);
        return;
    }
    if(row[cnt]) {
        queen_eight(Q, row, col, lrd, lld, cnt + 1);
        return;
    }
    for(int i = 0; i < 8; ++i) {
        if(col[i] || lrd[cnt - i + 7] || lld[cnt + i]) continue;
        Q[cnt][i] = row[cnt] = col[i] = lrd[cnt - i + 7] = lld[cnt + i] = 1;
        queen_eight(Q, row, col, lrd, lld, cnt + 1);
        Q[cnt][i] = row[cnt] = col[i] = lrd[cnt - i + 7] = lld[cnt + i] = 0;
    }
}
int main(int argc, char **argv) {
    unsigned char Q[8][8] = {};
    unsigned char row[8] = {};
    unsigned char col[8] = {};
    unsigned char lrd[15] = {};
    unsigned char lld[15] = {};

    int k = get_uint();
    for(int i = 0; i < k; ++i) {
        int r = get_uint();
        int c = get_uint();
        Q[r][c] = row[r] = col[c] = lrd[r - c + 7] = lld[r + c] = 1;
    }
    queen_eight(Q, row, col, lrd, lld, 0);
    return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define MAX_N 16
#define INF (1<<30)
#define Graph vector<vector<Edge>>
using namespace std;
int V, E;
/*
	Chinese Postman Problem	<Undirected>
	Reference:<http://www.prefield.com/algorithm/graph/undirected_chinese_postman.html>
*/

struct Edge {
	int from, to, cost;
	Edge(int from, int to, int cost) :from(from), to(to), cost(cost) {}
	bool operator < (const Edge &o) const {
		return cost != o.cost ? cost > o.cost :
			from != o.from ? from < o.to : to < o.to;
	}
};

int Chinese_Postman_Problem(Graph &g) {
	int ret = 0;
	vector<int> odds;
	for (int u = 0; u < V; u++) {
		for (auto e : g[u]) ret += e.cost;
		if (g[u].size() % 2) odds.emplace_back(u);
	}
	ret /= 2;
	int n = odds.size(), N = 1 << n;
	vector<vector<int>> w(n, vector<int>(n));
	for (int u = 0; u < n; u++) {
		int s = odds[u];
		vector<int> dist(V, INF);
		dist[s] = 0;
		vector<int> prev(V, -2);
		priority_queue<Edge> Q;
		Q.push(Edge(-1, s, 0));
		while (!Q.empty()) {
			Edge e = Q.top(); Q.pop();
			if (prev[e.to] != -2) continue;
			prev[e.to] = e.from;
			for (auto o : g[e.to]) {
				if (dist[o.to] > e.cost + o.cost) {
					dist[o.to] = e.cost + o.cost;
					Q.push(Edge(o.from, o.to, e.cost + o.cost));
				}
			}
		}
		for (int v = 0; v < n; v++) w[u][v] = dist[odds[v]];
	}
	vector<int> dp(N, INF);
	dp[0] = 0;

	for (int S = 0; S < N; S++) {
		for (int i = 0; i < n; i++) {
			if (!(S&(1 << i))) {
				for (int j = i + 1; j < n; j++) {
					if (!(S&(1 << j))) {
						dp[S | (1 << i) | (1 << j)] = min(dp[S | (1 << i) | (1 << j)], dp[S] + w[i][j]);
					}
				}
			}
		}
	}
	return ret + dp[N - 1];
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> V >> E;
	Graph g(V);
	for (int i = 0; i < E; i++) {
		int s, t, d; cin >> s >> t >> d;
		g[s].emplace_back(Edge(s, t, d));
		g[t].emplace_back(Edge(t, s, d));
	}
	cout << Chinese_Postman_Problem(g) << endl;
}

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


int main(void) {
	int R = 0;
	int G = 0;
	int B = 0;

	int N = 0;

	cin >> R >> G >> B;
	cin >> N;

	for (int i = 0; i < N; i++) {
		if (G <= R) {
			G = 2 * G;
		}
		else if (B <= G)
			B = 2 * B;
		else
			break;
	}

	if (R < G && G < B)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3560
import java.util.Scanner;

//Educational DP Contest / DP まとめコンテスト
//C - Vacation
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int h[][] = new int[N][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				h[i][j] = Integer.parseInt(sc.next());
			}
		}
		sc.close();

		int[][] dp = new int[N + 2][3];
		dp[0][0] = 0;
		for (int i = 0; i < N; i++) {
			if (i > 0) {
				for (int j = 0; j < 3; j++) {
					for (int k = 0; k < 3; k++) {
						if (j != k) {
							dp[i][j] = Math.max(dp[i][j], dp[i - 1][k] + h[i][j]);
						}
					}
				}
			} else {
				for (int j = 0; j < 3; j++) {
					dp[i][j] = h[i][j];
				}
			}
		}

		System.out.println(
				Math.max(
						Math.max(dp[N - 1][0], dp[N - 1][1]), dp[N - 1][2]));
	}
}


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

int main() {
    int a,b,c,d,i;
    cin >> a >> b >> c >> d;
    for(i = 0; i < 100; i++){
        c -= b;
        if(c<=0) break;
        a -= d;
        if(a<=0) break;
    }
    if(a <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

#define MD 1000000007

int dp[2097157], P[25];
int N, A[25][25];
bool H[25];

int solve()
{
    int h = 0;
    for (int i = 0; i < N; i++) if (H[i]) h += P[i];
    if (dp[h] != -1) return(dp[h]);
    int c = N;
    for (int i = 0; i < N; i++) if (H[i]) c--;
    if (c == N)
    {
        dp[h] = 1;
        return(1);
    }
    int res = 0;
    for (int i = 0; i < N; i++) if (H[i] && A[c][i])
    {
        H[i] = false;
        res = (res + solve()) % MD;
        H[i] = true;
    }
    dp[h] = res;
    return(res);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for (int i = 0; i < N; i++) P[i] = 1 << i;
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> A[i][j];
    for (int i = 0; i < N; i++) H[i] = true;
    int lim = 1 << N;
    for (int i = 0; i < lim; i++) dp[i] = -1;
    cout << solve() << '\n';
    return(0);
}

Measured memory_bytes: 8448
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


S = str(input())
P = str(input())

is_ok = False

for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break

    if FLG == True:
        is_ok = True
        break

if is_ok == True:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 5580
#include <stdio.h>

#define INF 99999999

int main(void) {
	int N, T;
	int i;
	int asumikana = INF;
	if (scanf("%d%d", &N, &T) != 2) return 1;
	for (i = 0; i < N; i++) {
		int c, t;
		if (scanf("%d%d", &c, &t) != 2) return 1;
		if (t <= T && c < asumikana) asumikana = c;
	}
	if (asumikana < INF) {
		printf("%d\n", asumikana);
	} else {
		puts("TLE");
	}
	return 0;
}


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

#define ll long long 
ll int pre[405];
ll int dp[405][405];

ll int kil(int l, int r)
{
    if(l == r)
        return 0;//pre[l] - pre[l-1];
        
    if(dp[l][r] != -1)
        return dp[l][r];
        
    dp[l][r] = 1e17;
    for(int i=l;i<r;i++)
    {
        dp[l][r] = min(dp[l][r], pre[r] - pre[l-1] + kil(l, i) + kil(i+1, r));
    }
    return dp[l][r];    
}

int main()
{
    int n, x;
    cin>>n;
    
    memset(dp, -1, sizeof dp);
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        pre[i] = pre[i-1] + x;
    }
    
    cout<<kil(1, n)<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int & x : a)
        cin >> x;
    int ans = INT_MAX;
    for (int c = 1; c <= 100; ++c) {
        int s = 0;
        for (int x : a)
            s += (x - c) * (x - c);
        ans = min(ans, s);
    }
    cout << ans << endl;
}


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

#include <atcoder/all>
using namespace atcoder;

constexpr int MOD = 998244353;

using S = pair<ll, ll>;

using F = ll;

S op(S a, S b) { return S{(a.first + b.first) % MOD, (a.second + b.second) % MOD}; }

S e() { return {0, 0}; }

S mapping(F f, S s) { return f ? S{s.first, f * s.first % MOD} : s; }

F composition(F a, F b) { return a ? a : b; }

F id() { return 0; }

int main() {
  int n, q;
  cin >> n >> q;

  vector<S> u(n);
  u.front() = {1, 1};
  for (int i = 1; i < n; i++) u[i].first = u[i].second = u[i - 1].first * 10 % MOD;

  lazy_segtree<S, op, e, F, mapping, composition, id> seg(u);

  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    seg.apply(n - r, n - l + 1, d);
    cout << seg.all_prod().second << endl;
  }
}


Measured memory_bytes: 16756
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
unordered_map<string, int> T;
typedef pair<int, string> P;
vector<P> Q;
vector<string> Q2;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> N;
  string S;
  rep(i, N) {
    cin >> S;
    T[S] += 1;
  }
  for (auto it=T.begin(); it !=T.end(); ++it){
    string c = it->first;
    int v = it->second;
    Q.push_back(P(v, c));
  }
  sort(ALL(Q), greater<P>());
  int count = Q[0].first;
  rep(i, Q.size()) {
    if (count!=Q[i].first) break;
    Q2.push_back(Q[i].second);
  }
  sort(ALL(Q2));
  rep(i, Q2.size()) cout << Q2[i] << "\n";
  return 0;
}

Measured memory_bytes: 30144
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    N=len(s)
    ans=0
    for i in range(N):
        a=int(s[i])
        ans=(ans+a)%9
        
    if ans==0:
        print("Yes")
    else:
        print("No")
    

main()


Measured memory_bytes: 67972
import java.io.PrintWriter
import java.util.*
import kotlin.math.min

fun main() {
    val reader = System.`in`.bufferedReader()
    val writer = PrintWriter(System.out, false)

    var tokenizer: StringTokenizer = StringTokenizer("")

    fun next(): String {
        while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
        return tokenizer.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextLine() = reader.readLine()

    fun PrintWriter.solve() {
        var (n,x,y) = List(3){nextInt()}
        var graph = Array(n){ mutableListOf<Int>()}

        for (i in 0..n-2){
            graph[i].add(i+1)
            graph[i+1].add(i)
        }

        graph[x-1].add(y-1)
        graph[y-1].add(x-1)

//        println(Arrays.toString(graph))
        var map = mutableMapOf<Int,Int>()
        val mxn = 1_000_000

        for (cur in 0..n-1){
            var q = ArrayDeque<Pair<Int,Int>>()
            var dist = IntArray(n){-1}
            dist[cur] = 0

            graph[cur].forEach { q.add(Pair(it,1)) }

            while (q.isEmpty().not()){
//                println(q)
                var pop = q.pollFirst()
                var u = pop.first
                var d = pop.second
                if (dist[u] != -1)continue

                dist[u] = d

                graph[u].filter { dist[it] == -1 }.forEach { q.add(Pair(it,d+1)) }
            }

//            println(Arrays.toString(dist))
            for (d in dist){
                map[d] = map.getOrDefault(d,0) + 1
            }


//            println(Arrays.toString(dist))

        }



        for (i in 1..n-1){
            println(map.getOrDefault(i,0)/2)
        }







    }

    writer.solve()
    writer.flush()


}




Measured memory_bytes: 65328
#include <string>
#include <iostream>
#include <map>

using namespace std;

const int MAXN=2e5+10;

string input;
int  suffix[MAXN];

int mod=2019;

typedef long long int ll;

int main(){
    cin>>input;
    int N=input.size();

    int power=1;
    for(int cur=N;cur>0;cur--,power=power*10%2019){
        char digit=input[cur-1];
        suffix[cur]=((digit-'0')*power%mod+suffix[cur+1])%mod;
    }

    map<int,int> occurence;
    ll sum=0;
    for(int i=N+1;i>0;i--){
        int count=occurence[suffix[i]]++;
        sum+=count;

    }

    printf("%lld\n",sum);

    return 0;
}

Measured memory_bytes: 4600
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

#define min(a,b) a > b ? b : a
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());

    // for(auto e : h){
    //     cout << e << endl;
    // }

//cout << endl;
    int ans = 1e9;
    rep(i,n-k+1){
        //cout << h[i] - h[i+k-1] << endl;
        ans = min(ans,h[i]-h[i+k-1]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N, T = map(int, input().split())
ans = []
for _ in range(N):
    c, t = map(int, input().split())
    if t <= T:
        ans.append(c)
    else:
        ans.append(999999)
ans = sorted(ans)
if ans[0] == 999999:
    print("TLE")
else:
    print(ans[0])

Measured memory_bytes: 3060