akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;



const int mod = 100000;
struct Mod {
public:
	int num;
	Mod() : Mod(0) { ; }
	Mod(long long int n) : num((n % mod + mod) % mod) {
		static_assert(mod<INT_MAX / 2, "mod is too big, please make num 'long long int' from 'int'");
	}
	Mod(int n) : Mod(static_cast<long long int>(n)) { ; }
	operator int() { return num; }
};

Mod operator+(const Mod a, const Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator+(const long long int a, const Mod b) { return Mod(a) + b; }
Mod operator+(const Mod a, const long long int  b) { return b + a; }
Mod operator++(Mod &a) { return a + Mod(1); }
Mod operator-(const Mod a, const Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator-(const long long int a, const Mod b) { return Mod(a) - b; }
Mod operator--(Mod &a) { return a - Mod(1); }
Mod operator*(const Mod a, const Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator*(const long long int a, const Mod b) { return Mod(a)*b; }
Mod operator*(const Mod a, const long long int b) { return Mod(b)*a; }
Mod operator*(const Mod a, const int b) { return Mod(b)*a; }
Mod operator+=(Mod &a, const Mod b) { return a = a + b; }
Mod operator+=(long long int &a, const Mod b) { return a = a + b; }
Mod operator-=(Mod &a, const Mod b) { return a = a - b; }
Mod operator-=(long long int &a, const Mod b) { return a = a - b; }
Mod operator*=(Mod &a, const Mod b) { return a = a * b; }
Mod operator*=(long long int &a, const Mod b) { return a = a * b; }
Mod operator*=(Mod& a, const long long int &b) { return a = a * b; }
Mod operator^(const Mod a, const int n) {
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod mod_pow(const Mod a, const long long  int n) {
	if (n == 0) return Mod(1);
	Mod res = mod_pow((a * a), (n / 2));
	if (n % 2) res = res * a;
	return res;
}
Mod inv(const Mod a) { return a ^ (mod - 2); }
Mod operator/(const Mod a, const Mod b) {
	assert(b.num != 0);
	return a * inv(b);
}
Mod operator/(const long long int a, const Mod b) {
	return Mod(a) / b;
}
Mod operator/=(Mod &a, const Mod b) {
	return a = a / b;
}

#define MAX_MOD_N 1024000

Mod fact[MAX_MOD_N], factinv[MAX_MOD_N];
void init(const int amax = MAX_MOD_N) {
	fact[0] = Mod(1); factinv[0] = 1;
	for (int i = 0; i < amax - 1; ++i) {
		fact[i + 1] = fact[i] * Mod(i + 1);
		factinv[i + 1] = factinv[i] / Mod(i + 1);
	}
}
Mod comb(const int a, const int b) {
	return fact[a] * factinv[b] * factinv[a - b];
}

int main() {
	while (1) {
		int N, K; cin >> N >> K;
		if (!N)break;
		vector<int>as(N);
		for (int i = 0; i < N; ++i) {
			cin >> as[i];
		}
		long long int sum = 0;
		for (int i = 0; i < K; ++i) {
			sum += as[i];
		}
		long long int ans = sum;
		for (int i = K; i < N; ++i) {
			sum += as[i] - as[i - K];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}

	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll n, i, j, k;
  ll ans = 0;
  cin >> n;
  ll a[n];
  forn(0, n, i){
    cin >> a[i];
  }
  forn(0, n, i){
    forn(i + 1, n, j){
      ans += a[i] * a[j];
    }
  }

  cout << ans << '\n';

  ktj();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    double a;
    cin >> a;

    double a1 = a;

    double count = 0;
    
    for(int i=a;i>0;i--){
        if(i%2 != 0){
            count++;
        }
    }

    double ans = count/a1;

    cout << ans << endl;
}

// //配列
// vector<int> vec(N);
// for (int i = 0; i < N; i++) {
// cin >> vec.at(i);
// }

// //配列の要素数
// 配列変数.size();

// //初期値の指定
// vector<型> 配列名(要素数, 初期値);

// //要素の追加
// vec.push_back(10);

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int n;cin>>n;
	int x[N],y[N],h[N];
	rep(i,n) cin>>x[i]>>y[i]>>h[i];
	int p[N+1][N+1];
	rep(i,n){
		if(h[i]==0) continue;
		rep(j,N+1) rep(k,N+1) p[j][k]=h[i]+abs(j-x[i])+abs(k-y[i]);
		break;
	}
	rep(i,n) rep(j,N+1) rep(k,N+1){
		if(p[j][k]==-1) continue;
		if(h[i]!=max(p[j][k]-abs(j-x[i])-abs(k-y[i]),0)) p[j][k]=-1;
	}
	int cx=0, cy=0, mh=-1;
	rep(i,N+1) rep(j,N+1){
		if(p[i][j]>mh){
			cx=i;
			cy=j;
			mh=p[i][j];
		}
	}
	cout<<cx<<' '<<cy<<' '<<mh<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 2e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
 
// clock_t start = clock();


void solve() {
	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << '\n';
}
 
int main() {
	FASTIO;
	int T = 1;
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
	return 0;
} 

Measured memory_bytes: 3648
N = int(input())
count = 0
ok = False
for _ in range(N):
    d1, d2 = [int(s) for s in input().split()]
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        ok = True
if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,print;
	int y,m,d;
	getline(cin,s);
	y=(s[0]-48)*1000+(s[1]-48)*100+(s[2]-48)*10+(s[3]-48);
	m=(s[5]-48)*10+(s[6]-48);
	d=(s[8]-48)*10+(s[9]-48);
	if(y>2018)
	{
		if(y==2019)
		{
			if(m>3)
			{
				if(m==4)
				{
					if(d<31)
						print="Heisei";
					else
						print="TBD";
				}
				else
					print="TBD";
			}
			else
				print="Heisei";
		}
		else
			print="TBD";
	}
	else
		print="Heisei";
	cout<<print;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; cin >> n;
    int h[n+1];
    for (int i=0; i<n; i++) cin >> h[i];
    int ans = 0, move = 0;
    for (int i=0; i<n-1; i++){
        if (h[i]>=h[i+1]) {move++, ans = max(ans, move);}
        else move = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define ll long long 
#define all(x) x.begin() , x.end()
int const N = 1e6+1 , MOD = 1e9 + 7; 
int main(){
    //  freopen("input.txt" ,"r",stdin);
      int k ,an=0; scanf("%d",&k);
      for(int i=1;i<=k;++i)
         for(int j=i+1;j<=k;++j){
          if(i%2!=0 && j%2==0)++an;
          else if(i%2 == 0 && j%2 != 0)++an;
         } 
       cout<<an;
}

Measured memory_bytes: 256
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

ans = 0
divisors = make_divisors(N)[1:]
ans += len(make_divisors(N-1))-1

for divisor in divisors:
        divided_N = N
        while 1:
            if divided_N%divisor!=0:
                break
            else:
                divided_N //=divisor
        if divided_N % divisor == 1:
            ans += 1
print(ans)

Measured memory_bytes: 39152
n,x=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
a.sort()
cnt=0
for i in range(n):
    if a[i]<=x:
        x-=a[i]
        if i==n-1 and x!=0:
            break
        cnt+=1
    else:
        break
print(cnt)


Measured memory_bytes: 9092
package main
import "fmt"

func main() {
    ints := scanNums(2)
    N := ints[0]
    M := ints[1]
    var popularities [30]int
    for i := 0; i < N; i++ {
        K := scanNum()
        for j := 0; j < K; j++ {
            A := scanNum()
            popularities[A - 1] += 1
        }
    }
    var result int
    for i := 0; i < M; i++ {
        if popularities[i] == N {
            result += 1
        }
    }
    fmt.Println(result)
}

func scanNum() (num int) {
    fmt.Scan(&num)
    return
}

func scanString() (str string) {
    fmt.Scanf("%s", str)
    return
}

func scanNums(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanStrings(len int) (strings []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scanf("%s", str)
        strings = append(strings, str)
    }
    return
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll unsigned long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);
	ll l=1,x,p=101;
	cin>>x;
	while(p<x){
      p=(p*(1.01));
      l++;
   }
   cout<<l<<endl;
   return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	int value,cost;
};

Info info[100][50];
int item_num[100],sell_count[100];
int dp[301],next_dp[301];

int main(){

	int S,D,M;

	while(scanf("%d %d %d",&S,&D,&M) != EOF){

		for(int i = 0; i < S; i++)sell_count[i] = 0;

		for(int i = 0; i < S; i++){
			scanf("%d",&item_num[i]);

			for(int k = 0; k < item_num[i]; k++){
				scanf("%d %d",&info[i][k].value,&info[i][k].cost);
			}
		}

		int tmp;
		for(int i = 0; i < D; i++){
			scanf("%d",&tmp);
			sell_count[tmp]++;
		}

		dp[0] = 0;
		next_dp[0] = 0;
		for(int i = 1; i <= M; i++){
			dp[i] = -1;
			next_dp[i] = -1;
		}

		vector<int> Updated;

		for(int i = 0; i < S; i++){
			if(sell_count[i] == 0)continue;

			for(int k = 0; k < item_num[i]; k++){
				for(int num = 1; num <= sell_count[i]; num++){
					for(int budget = M; budget-num*info[i][k].cost >= 0; budget--){
						if(dp[budget-num*info[i][k].cost] >= 0){
							if(next_dp[budget] < dp[budget-num*info[i][k].cost]+num*info[i][k].value){
								next_dp[budget] = dp[budget-num*info[i][k].cost]+num*info[i][k].value;
								Updated.push_back(budget);
							}
						}
					}
				}
				for(int p = 0; p < Updated.size(); p++){
					dp[Updated[p]] = next_dp[Updated[p]];
				}
				Updated.clear();
			}
		}

		int max_effect = -1,min_budget;
		for(int budget = 0; budget <= M; budget++){
			if(max_effect < dp[budget]){
				max_effect = dp[budget];
				min_budget = budget;
			}
		}

		printf("%d %d\n",max_effect,min_budget);
	}
	return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
 
const LD eps=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}

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

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}



int main()
{
	int q;
	cin>>q;
	REP(tt,q)
	{
		LL a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		if(a==b&&a==1)
		{
			print(0);
			continue;
		}
		LL s=a*b;
		s--;
		LL sq=(LL)(sqrt<LD>(s).real()+eps);
		//while((sq+1)*(sq+1)<s) sq++;
		LL ans=sq*2;
		if(s/sq==sq) ans--;
		if(a<=sq) ans--;


		print(ans);
	}

}


Measured memory_bytes: 384
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();

    string s[4]={"Christmas Eve Eve Eve","Christmas Eve Eve","Christmas Eve","Christmas"};
    ll n;
    cin >> n;
    cout<<s[n%22];

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int main() {
	var(int, n);
	vec(int, p, n);
	print(sum(all(p), 0) - *maxi(all(p)) / 2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

#define PI 3.14159265

int main(){
	double a, b, x; cin >> a >> b >> x;
	double s = a * a * b;
	cout << fixed << setprecision(6);
	if (x <= s / 2) cout << 90 - atan(x / (a * b * b) * 2) * 180.0 / PI << '\n';
	else cout << atan((s - x)/(a * a * a / 2)) * 180.0 / PI << '\n';
}


Measured memory_bytes: 4028
import collections


def main():
    aList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    text = ""
    H, W = map(int, input().split())
    for h in range(H):
        wList = list(map(str, input().split()))
        if wList.count("snuke") == 1:
            text = aList[wList.index("snuke")] + str(h + 1)
    print(text)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9452
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int n, m;
  scanf("%d %d", &n, &m);
  cout << (1900*m + 100 * (n-m)) * pow(2,m);

//  printf("%d", (1900*m + 100 * (n-m)) * pow(2,m)); //longに対しては%ld

  return 0;
}


Measured memory_bytes: 888
def resolve():
    '''
    code here
    '''
    A, B, C = [int(item) for item in input().split()]
    cnt = 0

    while A%2 == 0 and B%2 == 0 and C%2 == 0:
        A, B, C = B//2 + C//2, A//2 + C//2, A//2 + B//2
        cnt += 1

        if A==B==C:
            cnt = -1
            break

    print(cnt)


if __name__ == "__main__":
    resolve()


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

int main(){

	int n;
	cin >> n;

	vector<double> a;
	double temp;

	for(int i=0;i<n;i++){
		cin >> temp;
		a.push_back(temp);
	}

	sort(a.begin(),a.end());

	double ans = a[0] ;

	for(int i=1;i<n;i++){
		ans = (ans+a[i])/2;
	}

	printf("%0.9f\n",ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {


	public static void main(String args[]){

		Scanner s=new Scanner(System.in);

		int n = s.nextInt();
		int k = s.nextInt();

		int[] pasta = new int[n];

		Arrays.fill(pasta, -1);
		for(int i=0; i<k; i++) {
			int day = s.nextInt()-1;
			pasta[day] = s.nextInt()-1;
		}

		int[][][] dp = new int[n][3][3]; // i日目,i-1目のpasta,i日目のpasta
		if(pasta[0] != -1) {
			dp[0][(pasta[0]+1)%3][pasta[0]] = 1;
		} else {
			dp[0][1][0] = dp[0][2][1] = dp[0][0][2] = 1;
		}

		for(int i=1; i<n; i++) {
			if(pasta[i]!=-1) {
				for(int j=0; j<3; j++) {
					dp[i][j][pasta[i]] += dp[i-1][(j+1)%3][j];
					dp[i][j][pasta[i]] += dp[i-1][(j+2)%3][j];
					if(j!=pasta[i]) dp[i][j][pasta[i]] += dp[i-1][j][j];
					dp[i][j][pasta[i]]%=10000;
				}
			} else {
				for(int j=0; j<3; j++) {
					for(int t=0; t<3; t++) {
						dp[i][j][t] += dp[i-1][(j+1) %3][j];
						dp[i][j][t] += dp[i-1][(j+2) %3][j];
						if(j!=t) dp[i][j][t] += dp[i-1][j][j];
						dp[i][j][t] %= 10000;
					}
				}
			}
		}

		int cnt=0;

		for(int i=0; i<3; i++) {
			for(int j=0; j<3; j++) {
				cnt += dp[n-1][i][j];
			}
		}
		System.out.println(cnt%10000);

	}
}



Measured memory_bytes: 26380
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Main{
	static BufferedReader br;
	static int cin() throws Exception
	{
		return Integer.valueOf(br.readLine());
	}
	static int[] split() throws Exception
	{
		String[] cmd=br.readLine().split(" ");
		int[] ans=new int[cmd.length];
		for(int i=0;i<cmd.length;i++)
		{
			ans[i]=Integer.valueOf(cmd[i]);
		}                                              
		return ans;
	} 
	static long mod=1000000007;
	static long power(long x,long y) 
    { 
        long res = 1; 
        x = x % mod; 
        while (y > 0) { 
            if (y % 2 == 1) 
                res = (res * x) % mod; 
            y = y >> 1;
            x = (x * x) % mod; 
        } 
        return res%mod; 
    } 
    static long modInverse(long n) 
    { 
        return power(n, mod-2); 
    } 
    public static void main(String[] args) throws Exception {
        br = new BufferedReader(new InputStreamReader(System.in));
        int[]ar=split();
        int n=ar[0];
        int m=ar[1];
        int x=2*n-m;
        int y=2*m-n;
        if(x<0 || y<0 || x%3!=0 || y%3!=0)
        	System.out.println(0);
        else
        {
        	x=x/3;
        	y=y/3;
        	long res=1;
        	long[]fac=new long[x+y+1];
        	for(int i=1;i<=(x+y);i++)
        	{
        		res=(res*(long)i)%mod;
        		fac[i]=res;
        	}
        	fac[0]=1;
        	long result=(((fac[x+y]*modInverse(fac[x]))%mod)*modInverse(fac[y]))%mod;
        	System.out.println(result);
        }
    }
}

Measured memory_bytes: 37848
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+5;
using namespace std;
const ll INF=1e13+7;
ll n,m;
char str[maxn];
ll dp[maxn];
ll q[maxn];
int pre[maxn];
void TraceBack(int x)
{
    if(pre[x]==-1)
    {
        printf("%d",x);
        return;
    }
    TraceBack(pre[x]);
    printf(" %d",x-pre[x]);
}
int main()
{
    memset(pre,-1,sizeof(pre));
    scanf("%lld%lld",&n,&m);
    scanf("%s",str);
    //数有n+1个
    int s=1,e=0;
    for(int i=0;i<=m;i++)
    {
        if(str[i]=='0')
            dp[i]=1;
        else
            dp[i]=INF;
        while(s<=e&&dp[i]<dp[q[e]]) e--;
        q[++e]=i;
    }
    s++;
    for(int i=m+1; i<=n; i++)
    {
        dp[i]=INF;
        if(str[i]=='0')
        {
            dp[i]=min(dp[q[s]]+1,dp[i]);
            if(dp[i]!=INF)
                pre[i]=q[s];
        }
        while(s<=e&&dp[i]<dp[q[e]]) e--;
        q[++e]=i;
        while(s<=e&&q[s]<i+1-m)
            s++;
    }
    if(dp[n]==INF) printf("-1\n");
    else TraceBack(n);
    return 0;
}



Measured memory_bytes: 15872
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];

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

    Set<Integer> lhs = new LinkedHashSet<Integer>();

    for (int i = 0; i < n; i++) {
      lhs.add(a[i]);
    }

    Object[] newa = lhs.toArray();

    System.out.println(newa.length);

  }
}

Measured memory_bytes: 35920
#include<stdio.h>

int main(void)
{
	int n=1, x=1, i, j, k, kumiawase;

	while (n!=0||x!=0)
	{
		kumiawase = 0;

		scanf("%d %d", &n, &x);

		if (n == 0 && x == 0)
		{
			return 0;
		}
		else
		{
			for (i = 1; i <= n; i++)
			{
				for (j = i + 1; j <= n; j++)
				{
					for (k = j + 1; k <= n; k++)
					{
						if (x == i + j + k)
						{
							kumiawase++;
						}
					}
				}
			}
			printf("%d\n", kumiawase);
		}
	}
	return 0;
}


Measured memory_bytes: 2056
//     . .. ... .... ..... be name khoda ..... .... ... .. .     \\

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

inline int in() { int x; scanf("%d", &x); return x; }
const int N = 200002;

set <int> g[N];
bool dadMark[N];

int main()
{
	int n = in();
	for(int i = 1; i < n; i++)
	{
		int u = in(), v = in();
		g[u].insert(v);
		g[v].insert(u);
	}
	for(int i = 0; i < n; i++)
		if(g[i].size() == 2)
		{
			int a = *g[i].begin();
			int b = *g[i].rbegin();
			g[a].insert(b);
			g[b].insert(a);
			g[a].erase(i);
			g[b].erase(i);
			g[i].clear();
		}
	int ans = 0;
	for(int i = 0; i < n; i++)
		if(g[i].size() == 1)
		{
			bool &b = dadMark[*g[i].begin()];
			if(b)
				ans++;
			b = true;
		}
	cout << max(1, ans) << endl;
}


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

int main() {
    int N;
    cin >> N;
	int64_t a = 2;
    int64_t b = 1;
    int64_t c = a + b;
    if(N == 1){
    	cout << 1 << endl;
    }else if(N == 2){
    	cout << 3 << endl;
    }else{
    	for(int i = 0; i < N - 2; i++){
            a = b;
            b = c;
            c = a + b;
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

int a[40];
int b[40];
int c[40];

int dp[40][401][401];
int main(){
   int N;
   int Ma;
   int Mb;
   int sum_a = 0;
   int sum_b = 0;
   cin >> N >> Ma >> Mb;
   for(int i = 0; i < N; i++){
       cin >> a[i] >> b[i] >> c[i];
       sum_a += a[i];
       sum_b += b[i];
   }
   
   for(int i = 0; i < N; i++){
       for(int j = 0; j <= sum_a; j++){
           for(int k = 0; k <= sum_b; k++){
               dp[i][j][k] = INT_MAX;
           }
       }
   }

   dp[0][0][0] = 0;
   dp[0][a[0]][b[0]] = c[0];
   for(int i = 1; i < N; i++){
       for(int j = 0; j <= sum_a; j++){
           for(int k = 0; k <= sum_b; k++){
               dp[i][j][k] = dp[i - 1][j][k];
               if(j - a[i] >= 0 && k - b[i] >= 0){
                   int prev = dp[i - 1][j - a[i]][k - b[i]];
                   if(prev != INT_MAX){
                       dp[i][j][k] = min(dp[i - 1][j][k], prev + c[i]);
                   }
               }
           }
       }
   }

   int ans = INT_MAX;
   for(int i = 1; i <= sum_a; i++){
       for(int j = 1; j <= sum_b; j++){
           if(i % Ma == 0 && j % Mb == 0 && i / Ma == j / Mb){
               ans = min(ans, dp[N - 1][i][j]);
           }
       }
   }
   if(ans == INT_MAX){
       cout << -1 << endl;
   } else {
       cout << ans << endl;
   }
   return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug  freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e6+10;
const int maxM = 1e6+10;
const int inf = 0x3f3f3f3f;
const ll inf2 = 0x3f3f3f3f3f3f3f3f;

ll X,K,D;
ll solve(){
	X = abs(X);
	ll yu = X%D;
	ll k1 = (X - yu)/D;
	if(K<=k1) return X - K*D;
	else if(K%2 == k1%2) return yu;
	else  return abs(yu-D);
}
int main(){
	// debug;
	ios;

	cin>>X>>K>>D;
	cout<<solve();

	
	return 0;
}


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

template<class MonoidPair>
struct LazySegmentTree {
	int n;
	using NODE = typename MonoidPair::NODE; using NODE_T = typename MonoidPair::NODE_T;
	using LAZY = typename MonoidPair::LAZY; using LAZY_T = typename MonoidPair::LAZY_T;
	vector<NODE> node;
	vector<LAZY> lazy;
	LazySegmentTree (int n_) {build(n_);}
	LazySegmentTree (const vector<NODE_T>& v) {build(v);}
	LazySegmentTree () {}
	void build(int n_) {
		n = calc_n(n_);
		node.clear(); node.resize(2*n-1);
		lazy.clear(); lazy.resize(2*n-1);
	}
	void build(const vector<NODE_T>& v) {
		build(v.size());
		for (size_t i = 0; i < v.size(); i++) {
			node[i+n-1].val = v[i];
		}
		for (int i = n - 2; i >= 0; i--){
			node[i] = node[i*2+1] + node[i*2+2];
		}
	}
	void eval(int len, int k) {
		if (lazy[k].val == LAZY::UNITY) return;
		if (2*k+1 < 2*n-1) {
			lazy[2*k+1] = lazy[2*k+1] + lazy[k];
			lazy[2*k+2] = lazy[2*k+2] + lazy[k];
		}
		node[k] = node[k] + lazy[k] * len;
		lazy[k].val = LAZY::UNITY;
	}
	NODE set(int a, int b, LAZY_T x, int k, int l, int r) {
		eval(r-l, k);
		if (r <= a || b <= l) return node[k];
		if (a <= l && r <= b) {
			lazy[k] = lazy[k] + LAZY(x);
			return node[k] + lazy[k] * (r-l);
		}
		return node[k] = set(a, b, x, 2*k+1, l, (l+r) / 2) + set(a, b, x, 2*k+2, (l+r) / 2, r);
	}
	void set(int a, int b, LAZY_T x) {set(a, b, x, 0, 0, n);}
	NODE get(int a, int b, int k, int l, int r) {
		eval(r-l, k);
		if (a <= l && r <= b) {
			return node[k];
		} else if (b <= l || r <= a) {
			return NODE();
		}
		return get(a, b, 2*k+1, l, (l+r) / 2) + get(a, b, 2*k+2, (l+r) / 2, r);
	}
	NODE_T get(int a, int b) {return get(a, b, 0, 0, n).val;}
	const NODE_T& operator[](int i) {
		return node[i+n-1].val;
	}
	int calc_n(int n_, int t = 1) {return n_ > t ? calc_n(n_, t << 1) : t;}
};

template<class T, class U>
struct RMQ_RUQ {
	struct RMQ {
		const static T UNITY = numeric_limits<T>::max();
		T val;
		explicit RMQ(T v) : val(v) {}
		explicit RMQ() : val(UNITY) {}
		inline RMQ operator+(const RMQ& rhs) const {
			return RMQ(min(val, rhs.val));
		}
	};
	struct RUQ {
		const static U UNITY = numeric_limits<U>::min();
		U val;
		explicit RUQ(U v) : val(v) {}
		explicit RUQ() : val(UNITY) {}
		inline RUQ operator+(const RUQ& rhs) const {
			return RUQ(rhs.val);
		}
	};
	friend RMQ operator+(const RMQ& lhs, const RUQ& rhs) {
		return RMQ(rhs.val);
	}
	friend RUQ operator*(const RUQ& lhs, const int len) {
		return RUQ(lhs);
	}
	using NODE = RMQ; using NODE_T = T;
	using LAZY = RUQ; using LAZY_T = U;
};

int main() {
	int N, Q;
	cin >> N >> Q;
	LazySegmentTree<RMQ_RUQ<int, int>> L(N);
	while (Q--) {
		int q;
		cin >> q;
		if (q == 0) {
			int s, t, x;
			cin >> s >> t >> x;
			L.set(s, t+1, x);
		} else {
			int s, t;
			cin >> s >> t;
			cout << L.get(s, t+1) << endl;
		}
	}
}


Measured memory_bytes: 4888
N = int(input())
H = list(map(int, input().split()))

inf = float('inf')
dp = [inf] * (N + 1)
dp[1] = 0

for i in range(1, N):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i - 1] - H[i]))
    if i + 2 <= N:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 1] - H[i - 1]))

print(dp[N])
# print(dp)


Measured memory_bytes: 52552
import math
while True:
    try:
        n=int(input())
        num=list(range(n+1)) #[0,1,,,,n]が出力される
        num[1]=0
        for i in range(n):
            if num[i]>pow(n,0.5):
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2, n+1, num[i]): #num[i]*2からn+1までnum[i]個飛ばしで
                num[j]=0
        print(n+1-num.count(0))
    except:
        break


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

using namespace std ;

char s[ 100010 ] ;
int n ; 

int main() {
	scanf( "%s" , s + 1 ) ;
	n = strlen( s + 1 ) ;
	int cnt = 0 ;
	for( int i = 2 ; i <= n ; ) {
		if( s[ i ] != s[ i - 1 ] ) {
			cnt ++ ;
			i ++ ;
			while( s[ i ] == s[ i - 1 ] ) i ++ ;
		} else i ++ ; 
	}
	printf( "%d\n" , cnt ) ;
}


Measured memory_bytes: 384
#include<stdio.h>
#define num 50
//データセットが50を超えないという記述があるので、numは50個用意しよう
int main()
{
    int i = 0, n[num], count[num];
    int input_amount=0;
    while (scanf("%d", &n[i]) != EOF)
    {
    	input_amount++;
        int a, b, c, d;
        count[i] = 0;
        for (a = 0; a < 10; a++)
        {
            for (b = 0; b < 10; b++)
            {
                for (c = 0; c < 10; c++)
                {
                    for (d = 0; d < 10; d++)
                    {
                        if (a + b + c + d == n[i])
                            count[i]++;
                    }
                }
            }
        }
        i++;
    }
    for (i = 0; i < input_amount; i++)
    {
        printf("%d\n", count[i]);
    }
    return 0;
}



Measured memory_bytes: 2036
#include <iostream>
#include <vector>

using namespace std;

int n;
vector<int> t(100001);
vector<int> x(100001);
vector<int> y(100001);

int main(){
    cin >> n;
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 1; i <= n; i++){
        int A = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
        int B = t[i] - t[i-1];

        if(B < A){
            cout << "No" << endl;
            return 0;
        }
        else{
            if(B % 2 == 0){
                if(A % 2 == 0) continue;
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
            else{
                if(A % 2 != 0) continue;
                else{
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == len(S)-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
cnt = 1        
for i in range(1,len(T)):
    if i == len(T)-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")

Measured memory_bytes: 7452
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL << 60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<int, int> P;


Int n;
Int happy[110000][3];
Int dp[110000][3];

int main() {
  cin >> n;
  rep(i, n) {
    cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
  }

  rep(j, 3) {
    dp[0][j] = happy[0][j];
  }

  rep(i, n) {
    rep(j, 3) {
      rep(k, 3) {
        if (i == 0) {
          continue;
        }
        if (j == k) {
          continue;
        }
        dp[i][j] = max(dp[i][j], 
                      dp[i - 1][k] + happy[i][j]);
        // cout << dp[i][j] << endl;
      }
    } 
  }

  Int ans = 0;
  rep(j, 3) {
    // cout << dp[n-1][j] << endl;
    ans = max(ans, dp[n-1][j]);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
package main

import (
	"fmt"
	"math"
)

func main() {
	var N, X, Y int
	fmt.Scanf("%d %d %d\n", &N, &X, &Y)
	result := make([]int, N+1)
	for i := 1; i < N; i++ {
		for j := i + 1; j <= N; j++ {
			x := X - i
			if x < 0 {
				x = -x
			}
			y := Y - j
			if y < 0 {
				y = -y
			}
			diff1 := j - i
			diff2 := x + 1 + y
			minDiff := int(math.Min(float64(diff1), float64(diff2)))
			result[minDiff]++
		}
	}
	for i := 1; i < N; i++ {
		fmt.Println(result[i])
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  for (int i = 0; i < 31; i++){
    if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1){
      cout << i << endl;
      return 0;
    }
    int a = B / 2 + C / 2;
    int b = A / 2 + C / 2;
    int c = A / 2 + B / 2;
    A = a;
    B = b;
    C = c;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3644
import sys
sys.setrecursionlimit(10**7)
def input():
	return sys.stdin.buffer.readline()[:-1]

class SCC():
	def __init__(self, adj):
		self.n = len(adj)
		self.adj = adj
		self.post_order = []
		self.visited = [False for _ in range(self.n)]
		self.dag_v_to_num = [-1 for _ in range(self.n)]
		self.dag_num_to_v = []
		self.inv = [[] for _ in range(self.n)]
		for i, l in enumerate(self.adj):
			for j in l:
				self.inv[j].append(i)
		return

	def dfs1(self, i):
		for j in adj[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs1(j)
		self.post_order.append(i)
		return

	def dfs2(self, i, num):
		self.dag_num_to_v[-1].append(i)
		self.dag_v_to_num[i] = num
		for j in self.inv[i]:
			if not self.visited[j]:
				self.visited[j] = True
				self.dfs2(j, num)
		return

	def make_scc(self):
		for i in range(self.n):
			if not self.visited[i]:
				self.visited[i] = True
				self.dfs1(i)

		self.visited = [False for _ in range(self.n)]
		num = 0
		for i in range(self.n-1, -1, -1):
			if not self.visited[self.post_order[i]]:
				self.visited[self.post_order[i]] = True
				self.dag_num_to_v.append(list())
				self.dfs2(self.post_order[i], num)
				num += 1

		return self.dag_v_to_num, self.dag_num_to_v

n, m = map(int, input().split())
adj = [set() for _ in range(n)]
for _ in range(m):
	u, v = map(int, input().split())
	if u != v:
		adj[u].add(v)
adj = [list(x) for x in adj]
scc = SCC(adj)
v_to_num, num_to_v = scc.make_scc()
print(len(num_to_v))
for x in num_to_v:
	print(len(x), end=" ")
	print(*x)

Measured memory_bytes: 209404
#include<bits/stdc++.h>
using namespace std;
#include<string>
int main()
{
	int k;
	cin>>k;
	string s;
	string str="...";
	cin>>s;
	string temp="";
	if(s.length()>k)
	{
		for(int i=0;i<k;i++)
		{
			char c=s[i];
			temp+=c;
		}
		temp+=str;
		cout<<temp<<endl;
	}
	else
	{
		cout<<s<<endl;
	}

	return 0;

}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
	char bun[100];
	int j = 0, i, k = 0;
	scanf("%s", bun);

	for (i = 0; bun[i] != '\0'; i++) {
	}
	k = i;

	for (i = 0; i < k / 2; i++) {
		if (bun[i] != bun[k - i - 1]) {
			j++;
		}
	}

	printf("%d", j);
}


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

int main() {
    int N, L;
    string list[100];
    string ans;
    cin >> N >> L;
    for (int i = 0; i < N; i++) {
        cin >> list[i];
    }
    sort(list, list + N);
    ans = list[0];
    for (int i = 1; i < N; i++) {
        ans += list[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    int N = S.length();
    int count = 0;
    char [] input = new char[N];
    for(int i=0;i<N;i++){
      input[i] = S.charAt(i);
    }
    for(int j=1;j<N+1;j++){
      if(j%2==0){
        if(input[j-1]=='L'|| input[j-1]=='U'|| input[j-1]=='D'){
          count++;
        }
      }
      else{
        if(input[j-1]=='R'|| input[j-1]=='U'|| input[j-1]=='D'){
          count++;
        }
      }
    }
    if(count==N){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}


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

int main() {
    string str1, str2;
    getline(cin, str1);
    getline(cin, str2);
    // loop each single element in a string one
    int j=0;
    bool flag = false;
    int len1 = str1.length(), len2 = str2.length();
    for (int i=0; i<len1; i++) {
        int curr = i;
        while(j<len2 && str1[curr%len1] == str2[j]) {
            curr++;
            j++;
        }
        if (j==len2) {
            flag = true;
            break;
        } else {
            j = 0;
        }
    }
    
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3204
data = list(map(int, input().split()))

x = data[2] - data[0]
y = data[3] - data[1]

go = x * "R" + y * "U"
come = x * "L" + y * "D"

path = go + come

temp = 'L' + (y + 1) * 'U' + (x + 1) * 'R' + 'D'
temp += 'R' + (y + 1) * 'D' + (x + 1) * 'L' + 'U'

ans = path + temp
print(ans)


Measured memory_bytes: 3188
x = int(input())

if 1 <= x < 100:
    print(0)
    exit(0)

elif 2000 <= x:
    print(1)
    exit(0)

n = int(x/100)

if n*100 <= x <= n*100+n*5:
    print(1)
else:
    print(0)

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a == c) cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

ll const mod = 1e9+7;

int up(int i,int k) {
  return (i+k-1)/k;
}

int main() {
  int X;
  cin >> X;
  if (up(X%100,5) <= X/100) cout << '1' << endl;
  else cout << '0' << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0;
    if(n%10==9)flag=1;
    if(n/10==9)flag=1;
    if(flag) printf("Yes\n");
    else printf("No\n");
}

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

using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;

    vector<int> a(M);
    vector<int> c(M);
    for (int i=0; i<M; i++)
    {
        int b;
        cin>>a[i]>>b;
        for (int j=0; j<b; j++)
        {
            int t;
            cin>>t;
            c[i] |= 1<<(t-1);
        }
    }

    int oo = 999999999;
    vector<int> T(1<<N, oo);
    T[0] = 0;

    for (int i=0; i<M; i++)
    {
        vector<int> P(1<<N, oo);
        P.swap(T);

        for (int b=0; b<1<<N; b++)
        {
            T[b] = min(T[b], P[b]);
            T[b|c[i]] = min(T[b|c[i]], P[b]+a[i]);
        }
    }

    int ans = T[(1<<N)-1];
    cout<<(ans<oo ? ans : -1)<<endl;
}


Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
# p gets.split.map(&:to_i)
a = []
b = []
for i in 0..n-1 do
    s = gets
    a.push(s.split.map(&:to_i))
end
while s = gets
    b.push(s.chomp.to_i)
end

for i in 0..n-1 do
    ans = 0
    for j in 0..m-1 do
        ans += a[i][j] * b[j]
    end
    puts ans
end





Measured memory_bytes: 6984
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

string rotate(string s){
    int i = 0;
    int len = s.size();
    char c = s[0];
    
    for(i = 0; i < len-1; i++){
        s.at(i) = s[i+1];
    }
    s.at(len-1) = c;
    
    return s;
}

int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int flag = 0;
    
    int len = s.size();
    
    for(int i = 0; i < len; i++){
        if(t == rotate(s)){
            flag = 1;
            break;
        }
        
        s = rotate(s);
    }
    
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    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];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }

        System.out.println(solve(N, A, B) ? YES : NO);
    }

    private static boolean solve(int N, int[] A, int[] B) {
        Job[] job = new Job[N];
        for (int i=0; i<N; i++) {
            job[i] = new Job(A[i], B[i]);
        }

        Arrays.sort(job);

        int time = 0;
        for (int i=0; i<N; i++) {
            if (time <= job[i].B - job[i].A) {
                time += job[i].A;
            } else {
                return false;
            }
        }

        return true;
    }

    public static class Job implements Comparable<Job> {
        public int A;
        public int B;
        public Job(int a, int b) {
            this.A = a;
            this.B = b;
        }

        public int compareTo(Job o1) {
            return B - o1.B;
        }
    }
}

Measured memory_bytes: 97300
#include <stdio.h>

int linear(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  if(i!=n)
    return 1;
  return 0;
}

int main(){
  int i,n,q,key,S[10001],sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
  if(linear(S,n,key)==1)
    sum++;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2148
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());

            if (N <= K)
            {
                Console.Write(X * N);
            }
            else
            {
                Console.Write(X * K + (N - K) * Y);
            }
            System.Threading.Thread.Sleep(1000);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define LL long long int
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    LL N;
    cin >> N;
    LL prod=1;
    LL prod2=1;
    LL prod3=1;
    for(LL i=1;i<=N;i++)
    {
        prod=  (prod   * 10 )%mod;
        prod2= (prod2 * 9)%mod;
        prod3= (prod3 * 8)%mod;
    }
    cout<<(prod + (prod3-(2*prod2)%mod +mod) +mod)%mod;
}

Measured memory_bytes: 3612
n = int(input())
h = list(map(int, input().split()))
dp = [0, abs(h[1] - h[0])]
for i in range(2, n):
    dp.append(min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2])))

print(dp[n - 1])


Measured memory_bytes: 55240
#include <cstdio>
#include <cstring>

const int N = 20;

char s[N];

inline void get(char *str) {
    int len;
    char c = getchar();
    while (c < 'a' || c > 'z') c = getchar();
    for (len = 0; c >= 'a' && c <= 'z'; c = getchar()) str[len++] = c;
    str[len] = '\0';
}

int main() {
    int len;
    get(s + 1);
    len = strlen(s + 1);
    if (len & 1) {
        puts("No");
        return 0;
    }
    for (int i = 1; i <= len; i++)
        if (i & 1) {
            if (s[i] ^ 'h') {
                puts("No");
                return 0;
            }
        } else {
            if (s[i] ^ 'i') {
                puts("No");
                return 0;
            } 
        }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 128