akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111


	int mo  = 1e9+7;
	int dp[3100];
	void solve(){

		ini(n);
		ini(n1);
		vi morty(n);
		vi morty1(n1);
		FOR(i,0,n)in(morty[i]);
		FOR(i,0,n1)in(morty1[i]);

		FOR(i,0,n){
			int now = 1;
			FOR(i1,0,n1){
				int now1 = (now+dp[i1])%mo;
				if(morty[i] == morty1[i1]){
					dp[i1]=(dp[i1]+now)%mo;
				}
				now = now1;
			}
		}
		int rick = 1;
		FOR(i,0,3100){
			rick = (rick+dp[i])%mo;
		}
		out(rick);







	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
d_list = list(map(int, input().split()))
M = int(input().split()[0])
t_list = list(map(int, input().split()))

d_counter = collections.Counter(d_list)
t_counter = collections.Counter(t_list)
is_ok = True
for k, v in t_counter.items():
    if d_counter[k] < v:
        is_ok = False

ans = "YES" if is_ok else "NO"

print(ans)


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

int main(){
  int n;
  cin>>n;
  for(int i=1;i<=10;i++){
    int x=i*1000;
    if(x>=n){
      cout<<x-n<<endl;
      return 0;
    }
  }
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef bitset<256>bs;

int N;
string name[100];
bs latte[100];
signed main(){
    cin>>N;
    rep(i,N){
        cin>>name[i];
        int l,r;
        cin>>l>>r;
        for(int j=l;j<=r;j++)latte[i][j]=1;
    }

    stack<bs>st;
    int m;cin>>m;
    while(m--){
        string s;
        cin>>s;
        if(isdigit(s[0])){
            int d;stringstream ss(s);ss>>d;
            bs b;b[d]=1;
            st.push(b);
            continue;
        }
        if(isalpha(s[0])){
            int d=find(name,name+N,s)-name;
            st.push(latte[d]);
            continue;
        }

        bs a,b;
        b=st.top();st.pop();
        a=st.top();st.pop();

        if(s=="/"&&b[0]){
            cout<<"error"<<endl;
            return 0;
        }
        bs c;
        rep(i,256)rep(j,256){
            if(a[i]==0||b[j]==0)continue;
            int t;
            if(s=="+")t=(i+j)%256;
            else if(s=="-")t=(i-j+256)%256;
            else if(s=="*")t=i*j%256;
            else if(s=="/")t=i/j;
            c[t]=1;
        }
        st.push(c);
    }
    cout<<"correct"<<endl;
    return 0;
}

Measured memory_bytes: 3156
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//int A = sc.nextInt();

		ArrayList<Integer> lList = new ArrayList<>();

		for (int index = 1; index <= N; index++) {
			lList.add(sc.nextInt());
		}

		for (int i : lList) {
			if (i % 2 == 0) {
				if (i % 3 == 0 || i % 5 == 00) {
				} else {
					System.out.println("DENIED");
					return;
				}
			}
		}
		System.out.println("APPROVED ");
	}
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
ll gcd(ll a, ll b) {
    if(a < b) swap(a,b);
    
    if(b == 0) return a;
    return gcd(b, a % b);
}

int main(){
  cout << setprecision(10);

  int N;
  cin >> N;
  ll ans;
  for(int i = 0; i < N; i++){
    ll tmp;
    cin >> tmp;
    if(i == 0){
      ans = tmp;
    } else {
      ans = gcd(ans,tmp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
lw = []
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
for p in range(1, 4):
    r = 0
    q = 0
    for i in range(n):
        z = abs(x[i] - y[i])
        if p == 1:
            if q < z:
                q = z
            if i == n - 1:
                lw.append(q)
        r += pow(z, p)
    print(pow(r, float(1 / p)))
print(lw[0])



Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T vals) {if (a > vals) a = vals;}template<class T> void smax(T& a, T vals) {if (a < vals) a = vals;}
const int N = 13;
const int X = 1e3 + 10;

int n, m;
int cost[X], b[X];
bitset<N> c[X];
unordered_map<bitset<N>, int> M;

int solve(bitset<N> mask){
   if((int)(mask.count()) == n){
      return 0;
   }
 
   if(M.count(mask))
      return M[mask];

   int &ans = M[mask];

   ans = inf; 
   for (int i = 0; i < m; ++i)
   {
      bitset<N> nmask = mask | c[i];
      smin(ans, cost[i] + solve(nmask));
   }
 
   return ans;
}
 
int32_t main(){_
 
   cin>>n>>m;

   for (int i = 0; i < m; ++i)
   {
      int tot;
      cin >> cost[i] >> tot;
      for (int j = 0; j < tot; ++j)
      {
         int x;
         cin >> x;
         --x;
         c[i].set(x, 1);
      }
   }

   bitset<N> yy;
   int ans = solve(yy);
   if(ans > 1e15)
      ans = -1;

   cout<<ans;
 
   return 0;
}

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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */
long long N;
vector<long long> l(87);
//int c = 0;

ll cal(int c) {
    if (N == 1 || N == 0) {
        return l[N];
    }
    l[c] = l[c - 1] + l[c - 2];
    if (c == N) { return l[c]; }
    return cal(++c);
}

int main() {
    cin >> N;
    l[0] = 2;
    l[1] = 1;
    ll ans = cal(2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#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 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>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
ll cnt = 0;
vi G;
vi a;
inline void insertionSort(int n, int g) {
	rep(i, g, n) {
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v) {
			a[j + g] = a[j];
			j -= g;
			++cnt;
		}
		a[j + g] = v;
	}
}
inline void shellSort(int n) {
	for (int h = 1; h <= n; h = h * 3 + 1) {
		G.eb(h);
	}
	rrep(i, len(G) - 1, -1) {
		insertionSort(n, G[i]);
	}
}
int main() {
	int n; cin >> n;
	a.resize(n); rep(i, 0, n) cin >> a[i];
	shellSort(n);
	P(len(G));
	rrep(i, len(G) - 1, -1) cout << G[i] << (i == 0 ? "\n" : " ");
	P(cnt);
	rep(i, 0, n) P(a[i]);
	return 0;
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;


int main(){
	int cnt = 0, n;
	cin >> n;
	while(n){
		if(n%10 == 2)
			cnt++;
		n /= 10;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a=0;
ll zeros(ll p){
  p=p/10;
  a+=p;
  while(p!=0){
    a+=p/5;
    p=p/5;
  }
}
int main(){
  ll n,ans;
  cin>>n;
  if(n%2==1){
    ans=0;
  }else{
    zeros(n);
    ans=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned long long ll;
ll n,used[51],day[51];

int solve(){
  vector <int> l;
  for(int i=1;i<=30;i++){
    l.clear();
    for(int j=0;j<n;j++)if((day[j]>>i)%2)l.push_back(j);
    for(int j=0;j<l.size();j++){
      for(int k=0;k<l.size();k++) used[l[j]]=(used[l[j]]|used[l[k]]);
      if(used[l[j]]==((ll)1<<n)-1)return i;
    }
  }
  return -1;
}

int main(){
  while(1){
    cin >> n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      day[i]=0,used[i]=((ll)1<<i);
      ll a,b;
      cin>>a;
      while(a--)cin>>b,day[i]=(day[i]|(ll)1<<b);
    }
    cout << solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;
const int MAX = 510000;
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;
}
long long modpow(long long a, long long n, long long mod)
{
	long long res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod)
{
	return modpow(a, mod - 2, mod);
}
void solve()
{
	COMinit();
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans = modpow(2, n, M) - 1;
	ans %= M;
	ll mid = 1;
	FOR(i, 0, a)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;
	if (ans < 0)
	{
		ans += M;
	}
	mid = 1;
	FOR(i, 0, b)
	{
		mid *= n - i;
		mid %= M;
		mid *= modinv(i + 1, M);
		mid %= M;
	}
	ans -= mid;
	if (ans < 0)
	{
		ans += M;
	}
	cout << ans % M << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}


Measured memory_bytes: 12160
#include<iostream>
using namespace std;
//998244353,3
//469762049,3
//167772161,3
#include<vector>
template<int mod,int proot>
struct NTT{
	vector<long long>pp,invpp;//memoize proot^(mod-1>>i) and inv
	long long power(long long a,int b)
	{
		long long ret=1;
		while(b)
		{
			if(b&1)ret=ret*a%mod;
			a=a*a%mod;
			b>>=1;
		}
		return ret;
	}
	void dft(vector<int>&A,bool sign,int id)
	{
		if(id==0)return;
		int N=1<<id-1;
		vector<int>F(N),G(N);
		for(int i=0;i<N;i++)
		{
			F[i]=A[i<<1];
			G[i]=A[i<<1|1];
		}
		dft(F,sign,id-1);
		dft(G,sign,id-1);
		long long z=(sign?invpp:pp)[id],p=1;
		for(int i=0;i<N;i++)
		{
			A[i]=(F[i]+p*G[i])%mod;
			A[i+N]=(F[i]-p*G[i])%mod;
			if(A[i+N]<0)A[i+N]+=mod;
			(p*=z)%=mod;
		}
	}
	vector<int>multiply(vector<int>A,vector<int>B)
	{
		if(A.empty()||B.empty())
		{
			return(vector<int>){};
		}
		int N=1,sz=0;
		vector<int>ret(A.size()+B.size()-1);
		while(N<ret.size())N<<=1,sz+=1;
		pp.resize(sz+1);
		invpp.resize(sz+1);
		pp[sz]=power(proot,mod-1>>sz);
		invpp[sz]=power(pp[sz],mod-2);
		for(int i=sz-1;i>0;i-=1)
		{
			pp[i]=pp[i+1]*pp[i+1]%mod;
			invpp[i]=invpp[i+1]*invpp[i+1]%mod;
		}
		A.resize(N);
		B.resize(N);
		dft(A,false,sz);
		dft(B,false,sz);
		for(int i=0;i<N;i++)A[i]=(long long)A[i]*B[i]%mod;
		dft(A,true,sz);
		long long invN=power(N,mod-2);
		for(int i=0;i<ret.size();i++)ret[i]=invN*A[i]%mod;
		return ret;
	}
};
main()
{
	int N,M;
	cin>>N>>M;
	NTT<998244353,3>P;
	vector<int>A(N),B(M);
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=0;i<M;i++)cin>>B[i];
	A=P.multiply(A,B);
	for(int i=0;i<N+M-1;i++)cout<<A[i]<<(i==N+M-2?"\n":" ");
}


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

int nmax;

void update(vector<int> &list, int x){
  int index=x;
  while(index < list.size()){
    list.at(index)++;
    index += x;
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int nmax = a.at(n-1);
  vector<int> list(nmax+1,0);
  for(int i=0;i<n;i++){
    update(list, a.at(i));
  }
  
  int cnt=0;
  for(auto x : a){
    if(list.at(x) == 1){
      cnt++;
    }
  }
  
  cout << cnt << endl;

  return(0);
}

Measured memory_bytes: 8000
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		long N = Long.valueOf(s.next());
		
		char[] ret;
		
		int keta = 0;
		long now = 1;
		while(true) {
			now *= 26;
			keta++;
			if(N <= now) {
				ret = new char[keta];
				N--;
				for(int i = 0; i < keta; i++) {
					ret[keta-i-1] = (char)(N%26 + 'a');
					N /= 26;
				}
				break;
			}else {
				N -= now;
			}
		}
		System.out.println(new String(ret));
	}
}

Measured memory_bytes: 35624
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;

int main(){
    ll x;
    REP(i, 5){
        cin >> x;
        if(x == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18



int main() {
	
	string s, p; cin >> s >> p;

	s = s + s + s;

	int pos=s.find(p);

	if (pos!=string::npos) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}


Measured memory_bytes: 3208
N,K = map(int, input().split())

B = []
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in range(d):
        if (A[a]-1) not in B:
            B.append(A[a]-1)

ans = 0
for i in range(N):
    if i not in B:
        ans += 1

print(ans)

Measured memory_bytes: 9204
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
o = sum(i % 2 > 0 for i in a)
q = sum(i % 4 < 1 for i in a)
if n == o + q and o - 1 == q:
    print("Yes")
else:
    print("YNeos"[o > q::2])


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

const int MAX = 200000;
const int MOD = 1e9+7;

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()
{
    int H, W, A, B;
    cin >> H >> W >> A >> B;

    int firstBlockH = H - A;
    int firstBlockW = B;
    int secondBlockH = A;
    int secondBlockW = W - B;
    long long answer = 0;
    COMinit();
    for (int i = 1; i <= firstBlockH; i++)
    {
        long long firstBlockCount;
        if(i == 1 || firstBlockW == 1){
            firstBlockCount = 1;
        }else{
            int firstBlockAllChoiceNum = (i - 1) + (firstBlockW - 1);
            int firstBlockLeftChoiceNum = firstBlockW - 1;
            firstBlockCount = COM(firstBlockAllChoiceNum, firstBlockLeftChoiceNum);
        }
        long long secondBlockCount;
        if(secondBlockW == 1){
            secondBlockCount = 1;
        }else{
            int secondBlockAllChoiceNum = (H - i) + (secondBlockW - 1);
            int secondBlockLeftChoiceNum = secondBlockW - 1;
            secondBlockCount = COM(secondBlockAllChoiceNum, secondBlockLeftChoiceNum);
        }
        answer += firstBlockCount * secondBlockCount % MOD;
        answer = answer % MOD;
    }
    cout << answer << endl;
    return 0;
}

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

#define all(x) x.begin(), x.end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    string s; cin >> s;
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << '\n';
            return 0;
        }
    }
    for (int i = 0; i < s.length() - 1; i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << '\n';
            return 0;
        }
    }
    cout <<  "-1 -1" << '\n';
    return 0;
}


Measured memory_bytes: 512
def solve(n, m, A, B):
    if n == m:
        if all(a == b for a, b in zip(A, B)):
            return 'Yes'
        else:
            return 'No'
    for i in range(len(A) - len(B)):
        for j in range(len(A[0]) - len(B[0])):
            if all(a[j:j + len(B[0])] == b for a, b in zip(A[i:i + len(B)], B)):
                return 'Yes'
    return 'No'

_n, _m = map(int, input().split())
_A = [input() for _ in range(_n)]
_B = [input() for _ in range(_m)]
print(solve(_n, _m, _A, _B))


Measured memory_bytes: 3064
n, k = map(int, input().split())
p = list(map(int, input().split()))


def mean(value):
    return 0.5 * (value + 1)


res = 0
for l in range(k):
    res += mean(p[l])

cur = res
for l in range(k, n):
    cur += mean(p[l]) - mean(p[l-k])
    res = max(res, cur)
print(res)


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

int main(){
    int n, k; cin >> n >> k;
    vector<int64_t> a(n);
    for (auto i = 0; i < n; i++) cin >> a[i];
    for (auto i = k; i < n; i++) {
        if(a[i] > a[i - k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = MyScanner()
        val s = sc.next()
        var tmp = ""
        for (i in s.length - 1 downTo 0) {
            tmp = s[i] + tmp
            if (tmp.length > 7) {
                println("NO")
                return
            }
            if (tmp in listOf("dream", "dreamer", "erase", "eraser")) {
                tmp = ""
            }
        }
        println(if (tmp == "") "YES" else "NO")
    }
}


class MyScanner() {
    private var index = 0
    private var line = listOf<String>()

    fun next(): String {
        while (line.size <= index) {
            line = readLine()!!.split(' ')
            index = 0
        }
        return line[index++]
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextDouble() = next().toDouble()
    fun nextCharArray() = next().toCharArray()
    fun nextChar() = next()[0]

    fun strList(): List<String> {
        index = line.size
        return readLine()!!.split(' ')
    }

    fun intList() = strList().map { it.toInt() }
    fun longList() = strList().map { it.toLong() }
    fun doubleList() = strList().map { it.toDouble() }
}

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

int main(){

    /*---------*/
    /*  input  */
    /*---------*/

    int D;
    cin >> D;

    int i,j;
    vector<int> c(26+1);
    for( i = 1; i <= 26; i++ ){
        cin >> c[i];
    }

    vector< vector<int> > s(D+1, vector<int>(26+1));
    for( i = 1; i <= D; i++ ){
        for( j = 1; j <= 26; j++ ){
            cin >> s[i][j];
        }
    }

/*
    vector<int> t(365+1);
    for( i = 1; i <= D; i++ ){
        cin >> t[i];
    }
*/

    /*--------*/
    /*  calc  */
    /*--------*/

    long long int p = 0;
    int m = 0;
    int d;   // d: 1 --> D(365)
    vector<int> last(26+1);
    vector<int> real_last(26+1);
    long long int total = 0;
    long long int score;
    long long int ans = -10000000000;
    int x,k,tmp;

    for( d = 1; d <= D; d++ ){

        for( i = 1; i <= 26; i++ ){
            p = s[d][i];
            // minus
            // last[]を更新
            tmp = last[i];  // 記憶
            last[i] = d;
            if( i == 1 ){
                m = 0;
                for( j = 1; j <= 26; j++ ){
                    m += c[j] * ( d - last[j] );
                }
                ans = p - m;
                x = 1;
            }
            else{
                m = m + c[i-1]*(d-last[i-1]) - c[i]*(d-tmp);
                score = p - m;
                if( score > ans ){
                    x = i;
                    ans = score;
                }
                else last[i] = tmp;
            }
            for( k = 1; k <= 26; k++ ) last[k] = real_last[k];
        }
        // real_last[]を更新
        real_last[ x ] = d;
        last[ x ] = d;
        cout << x << endl;
    }


}


Measured memory_bytes: 3700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    int x=0;
    int n=s.size();
    rep(i,n){
        x += s[i]-'0';
        x %= 9;
    }
    if(x % 9 == 0) Yes;
    else No;
    
}/*
./problem.exe
*/

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

const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N];

int main() {
  int n; ll k;
  cin >> n >> k;
  rep(i,n) {
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i,D-1)rep(j,n) {
    to[i+1][j] = to[i][to[i][j]];
  }

  int v = 0;
  for (int i = D-1; i >= 0; --i) {
    ll l = 1ll<<i;
    if (l <= k) {
      v = to[i][v];
      k -= l;
    }
  }
  cout << v+1 << endl;
  return 0;
}

Measured memory_bytes: 50512
#include <iostream>
#include <cstring>
#include <cmath>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <vector>
#define LL long long
#define rg register
using namespace std;
int N,x,flag;

template<typename T>inline void in(T &a){
	T ch=getchar(),p=1;
	for(a=0;!isdigit(ch);ch=getchar()) if(ch=='-') p=-1;
	for(;isdigit(ch);ch=getchar()) a=a*10+ch-'0';
	a*=p;
}

signed main(){
	in(N);
	
	for(rg int i=1;i<=N;i++){
		in(x);
		if(x%2){
			flag=1;
			break;
		}
	}
	
	if(flag) printf("first\n");
	else printf("second\n");
	
	return 0;
}
/*

*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Cube{
    /**
    *   0
    * 3 1 2 4
    *   5
    * <:y ^:x <>:z
    **/
    Cube(){}
    int d[6];
    void roll(int i,int j,int k,int l){
        int t=d[i];d[i]=d[j];d[j]=d[k];d[k]=d[l];d[l]=t;
    }
    
    void z(){roll(1,2,4,3);}
    void y(){roll(0,2,5,3);}
    void x(){roll(0,1,5,4);}
    
    void n(){x();}
    void s(){x(),x(),x();}
    void e(){y(),y(),y();}
    void w(){y();}
    
    int getRight(int top,int front){
        int right;
        for(int i=0;i<6;++i){
            for(int j=0;j<4;++j){
                if(d[0]==top&&d[1]==front)right=d[2];
                z();
            }
            if(i&1)x();
            else y();
        }
        return right;
    }
    
    bool isSame(Cube c){
        auto chk=[&]{for(int i=0;i<6;++i)if(d[i]!=c.d[i])return false;return true;};
        bool res=false;
        for(int i=0;i<6;++i){
            for(int j=0;j<4;++j){
                if(!res&&chk())res=true;
                z();
            }
            if(i&1)x();
            else y();
        }
        return res;
    }
};
int main(){
  Cube c,d;
  int n;
  bool res=false;
  cin>>n;
  --n;
  for(int i=0;i<6;++i)cin>>c.d[i];
  for(int j=0;j<n;++j){
    for(int i=0;i<6;++i)cin>>d.d[i];
    res|=c.isSame(d);
  }
  if(!res)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const long long  max_n = 5000;
long long cnt[111];
long long b = 1;
long long n,a=1e9,W,maxn=1, minn=100;
const int INF = 1e9;
const int mod = 1e9 + 7;
long long s[max_n],v[max_n],w[1000];
long long dp[max_n];
vector<vector<int> > G;

void solve(){
    for(int i=minn ; i<=maxn ; i++){
        for(int j=0 ; j<n ; j++){
            dp[i] += abs(i - s[j]) * abs(i-s[j]);
        }
        a = min(a, dp[i]);
    }
    cout << a << endl;
}
int main(){
    cin >> n;
    for(int i=0 ; i<n ; i++){
        cin >> s[i];
        maxn = max(s[i], maxn);
        minn = min(minn, s[i]);
    }
    solve();
    return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    int cnt = 0;
    for (int i=0; i<1000; ++i) {
        int v[3] = {i/100, (i/10)%10, i%10};
        int k = 0;
        rep(j,n) {
            if (s[j] == (v[k] + '0')) ++k;
            if (k == 3) break;
        }
        if (k == 3) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int main(){
    int n;cin>>n;
    int ans,ptr=0;
    int a[n];
    fol(i,n) cin >> a[i];
    for (ans=1;ans<=n;++ans){
        if (a[ptr]==2){
            cout << ans << endl;
            return 0;
        }else{
            ptr = a[ptr];
            --ptr;
        }
    }cout << -1 <<endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int m;
  scanf("%d", &m);
  while(m--){
    unsigned int startMoney, maxMoney = 0;
    int year, n;
    scanf("%u", &startMoney);
    scanf("%d", &year);
    scanf("%d", &n);
    while(n--){
      int compound, fee;
      unsigned int money = startMoney, addMoney = 0;
      double rate;
      scanf("%d %lf %d", &compound, &rate, &fee);
      for(int i = 0; i < year; i++){
        if(compound){
          money += money * rate;
          money -= fee;
        }
        else{
          addMoney += money * rate;
          money -= fee;
        }
      }
      maxMoney = max(maxMoney, money + addMoney);
    }
    printf("%u\n", maxMoney);
  }
  return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
const long long INF = 1e12;

int main() {
string s;
cin >> s;
if(s=="ABC")cout << "ARC"<<endl;
else
    cout << "ABC" << endl;
}

Measured memory_bytes: 3620
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int  r = sc.nextInt();

        if( n >= 10){
            System.out.println(r);
        }else{
            System.out.println(r + 100 * (10 - n));
        }

    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}



Measured memory_bytes: 21076
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner (System.in);
		while(sc.hasNextInt()){
			int n=sc.nextInt();
			int sum=sc.nextInt();
			if(n==0&&sum==0)break;
			int count=0;
			for(int i=1;i<=n;i++){
				for(int j=1;j<=n;j++){
					for(int k=1;k<=n;k++){
						if(i+j+k==sum&&i!=j&&j!=k&&i!=k){
							count++;
						}
					}
				}
			}
			System.out.println(count/6);
		}
	}
}

Measured memory_bytes: 19864
a1,b1=map(int,input().split())
a=[0]*40
b=[0]*40
A=a1
B=b1
for i in range(1,41):
    a[-i]=a1%2
    b[-i]=b1%2
    a1=a1//2
    b1=b1//2
ans=[0]*40
if a[-1]==1:
    if (a[-2]-b[-2])%2==0:
        if b[-1]==1:
            ans[-1]=1
    else:
        if b[-1]==0:
            ans[-1]=1
else:
    if (a[-2]-b[-2])%2==0:
        if b[-1]==1:
            ans[-1]=1
    else:
        if b[-1]==0:
            ans[-1]=1
for i in range(2,41):
    if a[-i]==1 and a[-1]==1:
        if b[-i]==1 and b[-1]==0:
            ans[-i]=0
        else:
            ans[-i]=1
    else:
        if b[-i]==1 and b[-1]==0:
            ans[-i]=1
        else:
            ans[-i]=0
ans1=0
for i in range(1,41):
    ans1+=(2**(i-1))*ans[-i]
print(ans1)


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

int main(void)
{
	int n, l[15], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> l[i];
	}
	sort(l, l + n);
	for (int i = 0; i < n - 1; i++)
	{
		sum += l[i];
	}
	if (l[n-1] < sum) { cout << "Yes"; }
	else { cout << "No"; }
	return 0;
}

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

int main() {
	ll a, b; cin >> a >> b;

	if (a < b) swap(a, b);

	ll x = a * b;
	for (ll r = a % b; r != 0; r = a % b) {
		a = b;
		b = r;
	}

	cout << (x / b) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

struct Node
{
	int key;
	Node *parent,*left,*right;
};

Node BSI[505050];


void insert(Node *z)
{
	Node *y = nullptr;
	Node *x = BSI;
	while (x!=nullptr)
	{
		y = x;
		//cout<<x->key<<endl;
		//sleep(1);
		
		if(z->key<x->key)
		{
			x = x->left;
		}
		else
		{
			x = x->right;
		}
		//if(x->left==nullptr&&x->right==nullptr)break;
	}
	//cout<<'n'<<endl;
	z->parent = y;
	if(y==nullptr)
	{
		BSI[0] = *z;
	}
	else
	{
		if(z->key<y->key)
		{
			y->left = z;
		}
		else
		{
			y->right = z;
		}
	}
	
}

void Inorder(Node *x)
{
	if(x->left!=nullptr)Inorder(x->left);
	cout<<' '<<x->key;
	if(x->right!=nullptr)Inorder(x->right);
}

void Preorder(Node *x)
{
	cout<<' '<<x->key;
	if(x->left!=nullptr)Preorder(x->left);
	if(x->right!=nullptr)Preorder(x->right);
}

Node *find(int x)
{
	Node *now = BSI;
	while(now!=nullptr)
	{
		if(now->key==x)return now; 
		if(x<now->key)
		{
			now = now->left;
		}
		else
		{
			now = now->right;
		}
		
	}
	return now;
}

Node *getMinimum(Node *z)
{
	while(z->left!=nullptr)
	{
		z = z->left;
	}
	return z;
}

Node *getSuccessor(Node *z)
{
	return getMinimum(z->right);
}

void deleteNode(Node *z)
{
	if(z->left==nullptr&&z->right==nullptr)
	{
		Node *x = z->parent;
		if(x->right==z)
		{
			x->right = nullptr;
		}
		else
		{
			x->left = nullptr;
		}
		z->parent = nullptr;
		
	}
	else if(z->left!=nullptr&&z->right==nullptr)
	{
		
		
		Node *y = z->left;
		Node *x = z->parent;
		z->key = y->key;
		z->left = y->left;
		z->right = y->right;
		/*
		y->parent = x;
		if(x!=nullptr)x->left = y;
		*/
	}
	else if(z->left==nullptr&&z->right!=nullptr)
	{
		Node *y = z->right;
		Node *x = z->parent;
		z->key = y->key;
		z->left = y->left;
		z->right = y->right;
		/*
		y->parent = x;
		if(x!=nullptr)x->right = y;
		*/
	}
	else
	{
		Node *y = getSuccessor(z);//次にｚに入るもの
		z -> key = y ->key;
		if(y->parent->right==y)
		{
			y->parent->right=nullptr;
			z ->right = y->right;
		}
		else
		{
			y->parent->left = nullptr;
		}
		y ->right = nullptr;
		y -> left = nullptr;
		y -> right = nullptr;

	}
	
	
}

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

		string s;
		cin >> s;
		if(s=="insert")
		{
			
			
			
			int k;cin >> k;
			if(i==0)
			{
				BSI[0].key = k;
				continue;
			}
			BSI[i].key = k;

			insert(&BSI[i]);
		}
		else if(s=="find")
		{
			int x;
			cin >> x;
			if(find(x)!=nullptr&&find(x)->key==x)
			{
				cout<<"yes"<<endl;
			}
			else
			{
				cout<<"no"<<endl;
			}
			
		}
		else if(s=="delete")
		{
			int x;
			cin >> x;
			deleteNode(find(x));
		}
		else
		{
			Inorder(BSI);cout<<endl;
			Preorder(BSI);cout<<endl;
		}
		
	}
	return 0;
}



Measured memory_bytes: 15612
from math import gcd
k=int(input())
ans=sum(range(1,k+1))
for a in range(1,k):
    for b in range(a+1,k+1):
        ans+=6*gcd(a,b)
for a in range(1,k-1):
    for b in range(a+1,k):
        for c in range(b+1,k+1):
            ans+=6*gcd(a,gcd(b,c))
print(ans)

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

using namespace std;

int main()
{
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for(int i=0;i<N;++i){
        cin >> a[i];
    }

    vector<int> rows(W);
    int num = 0, index;
    for(int h=0;h<H;++h){
        for(int w=0;w<W;++w){
            if(a[num] == 0) ++num;
            index = (h%2) ? W-1-w:w;
            rows[index] = num+1;
            --a[num];
        }
        for(int i=0;i<W;++i){
            if(i) cout << " ";
            cout << rows[i];
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
<?php

    // 標準入力を配列化して取得する
    function get_input() {
        $input = [];
        while ($line = fgets(STDIN)) {
            $input[] = trim($line);
        }
        return $input;
    }

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $input = get_input();

    $n = $input[0];

    output(ceil($n / 2));


Measured memory_bytes: 4728
def main():
    n = int(input())
    if n % 2 == 0 and n >= 10:
        m = n // 2
        k = 5
        m5 = 0
        while k <= m:
            m5 += m // k
            k *= 5
    else:
        m5 = 0

    print(m5)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<math.h>
using namespace std;
#define MAX 10000

bool isPrime(int prime);

int main()
{
	int N,i,j,count=0,flag,prime;
	//int prime[MAX];
	bool primeFlag;

	cin >> N;
	for(i=0;i<N;i++){
		cin >> prime ;
		primeFlag = isPrime(prime);
		if(primeFlag == true) count++;
	}

	cout << count << endl ;

	return 0;
}

//?卒???属???????????蔵??属
bool isPrime(int prime){
	int i;
	double j ;

	j = sqrt((double)prime);

	if(prime == ((int)j*(int)j)) return false;
	
	if(prime == 2) return true ;
	if(prime == 3) return true ;
	
	if((prime % 2) == 0 ) return false ;
	if((prime % 3) == 0 ) return false ;

	

	for(i=3;(double)i<j;i+=2){
		if((prime % i) == 0 ) {
				return false ;
		}
	}
	return true ;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void){
  int n,m,sum=0;
  scanf("%d",&n);
  m=n;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  if(m%sum==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
int x,y;
scanf("%d %d",&x,&y);

while(x != 0 || y != 0){
if(x <=y){
printf("%d %d\n",x,y);
} else {
printf("%d %d\n",y,x);
}
scanf("%d %d",&x,&y);

}

return 0;

}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
int N,M,i,j,f[21];
double L[21],A[21],B[21],r=0;

void dfs(int d,int p,int q)
{
	double t;
	if(q==0)
	{
		for(i=t=0;i<d-1;i++)
			for(j=i+1;j<d;j++)
			{
				t+=(L[f[i]]-L[f[j]])*(L[f[i]]-L[f[j]])+
				(A[f[i]]-A[f[j]])*(A[f[i]]-A[f[j]])+
				(B[f[i]]-B[f[j]])*(B[f[i]]-B[f[j]]);
			}
		r=r>t?r:t;
	}
	else
	{
		for(p;p<=N-q;p++)
		{
			f[d]=p;
			dfs(d+1,p+1,q-1);
		}
	}
}
int main()
{
	scanf("%d%d",&N,&M);
	if(M<2)
	{
		printf("0\n");
		return 0;
	}
	for(i=0;i<N;i++)
		scanf("%lf%lf%lf",&L[i],&A[i],&B[i]);
	dfs(0,0,M);
	printf("%f\n",r);
	return 0;
}

Measured memory_bytes: 664
# ABC 107: B – Grid Compression
h, w = [int(s) for s in input().split()]
a = [input() for _ in range(h)]

grid_after_operations = []

for i in range(h):
    if a[i] != '.' * w:
        grid_after_operations.append(a[i])

for j in reversed(range(w)):
    if grid_after_operations[0][j] == '.':
        for i in range(1, len(grid_after_operations)):
            if grid_after_operations[i][j] != '.':
                break
        else:
            for i in range(len(grid_after_operations)):
                grid_after_operations[i] = grid_after_operations[i][:j] + grid_after_operations[i][j + 1:]

for i in range(len(grid_after_operations)):
    print(grid_after_operations[i])

Measured memory_bytes: 3064
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()

    # 負数、 0数、 正数
    neg, zero, pos = [], [], []
    for a in A:
        if a < 0:
            neg.append(a)
        elif a == 0:
            zero.append(a)
        else:
            pos.append(a)

    prod_neg = len(neg) * len(pos)
    prod_zero = len(zero) * (len(neg)+len(pos))+len(zero)*(len(zero)-1)//2
    # prod_pos = len(neg)*(len(neg)-1)//2 + len(pos)*(len(pos)-1)//2

    if prod_neg >= K:
        # 二分探索
        left = neg[0]*pos[-1]-1
        right = 0
        while right-left > 1:
            mid = (right + left)//2
            # しゃくとり法
            counter = 0
            ps = 0
            for ns in range(len(neg)):
                while ps < len(pos) and neg[ns]*pos[ps] > mid:
                    ps += 1
                if ps == len(pos):
                    break
                counter += len(pos)-ps
            if counter < K:
                left = mid
            else:
                right = mid
        print(right)
    elif prod_zero + prod_neg >= K:
        print(0)
    else:
        KK = K-prod_neg-prod_zero
        # 二分探索
        left = 0
        right = 0
        if len(neg) > 0:
            right = max(neg[0]**2, right)
        if len(pos) > 0:
            right = max(pos[-1]**2, right)
        while right - left > 1:
            mid = (left + right)//2
            # しゃくとり法
            counter = 0
            end = len(pos)-1
            for start in range(len(pos)):
                while end >= start and pos[start]*pos[end] >= mid:
                    end -= 1
                if end <= start:
                    break
                counter += end-start
            start = 0
            for end in range(len(neg)-1, -1, -1):
                while end >= start and neg[start]*neg[end] >= mid:
                    start += 1
                if end <= start:
                    break
                counter += end-start
            if counter < KK:
                left = mid
            else:
                right = mid
        print(left)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95188
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
const int mod = 1e9 + 7;

int dp[10005][101][2];
// 0 : white
int d;
int f(int idx, int sum_so_far, bool tight, string& s)
{
  if (idx == s.size())
    return (sum_so_far == 0);
  auto& ret = dp[idx][sum_so_far][tight];
  if (ret != -1)
    return ret;
  ret = 0;
  int ul = tight ? s[idx]-'0' : 9;
  for (int i = 0; i <= ul ; ++i) {
    ret += f(idx + 1,(sum_so_far + i) % d, tight & (i == ul), s);
    ret %= mod;
  }
  return ret;
}



int main()
{
  int n, k;
  string s;
  cin >> s;
  cin >> d;
  memset(dp, -1, sizeof dp);
  cout << (f (0, 0, 1, s) - 1 + mod) % mod << '\n';

  return 0;
}


Measured memory_bytes: 9216
//Solution for aoj 0573: Night Market
#include<iostream>
#include<algorithm>
using namespace std;
int n, s, t;
int sho[3001][2], dp[3001][3001];
void solve(){
	for (int i = 2; i <= n; i++){
		for (int j = 1; j <= t; j++){
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (j >= sho[i][1]){
				if (j <= s || j - sho[i][1] >= s)
					dp[i][j] = max(dp[i][j], dp[i - 1][j - sho[i][1]] + sho[i][0]);
			}
		}
	}
}
int main(){
	cin >> n >> t >> s;
	for (int i = 1; i <= n; i++){
		cin >> sho[i][0] >> sho[i][1];
	}
	for (int i = 0; i <= t; i++){
		if (i >= s || s >= sho[1][1] + i){
			if (t >= i + sho[1][1])
				dp[1][i + sho[1][1]] = sho[1][0];
		}
	}
	solve();
	cout << dp[n][t] << endl;
}

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

int main(){
    double a, b, x; cin >> a >> b >> x;
    double S = a * a * b / 2;
    double ans;
    if(x > S) ans = atan(2 * (b / a - x / (a * a * a))) * 180 / M_PI;
    else ans = atan(a * b * b / (2 * x)) * 180 / M_PI;

    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 512