akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;

int main(){
  ll n,m,k; cin>>n>>m>>k;
  vector<ll>a(n+1);
  vector<ll>b(m+1);
  a[0]=0;b[0]=0;
  rep(i,n){
    ll A; cin>>A;
    a[i+1]=a[i]+A;
  }
  rep(i,m){
    ll B; cin>>B;
    b[i+1]=b[i]+B;
  }
  ll ans=0;
  for(int i=0;i<n+1;i++){
    ll K=k-a[i];
    if(K<0)break;
    ll mx;
    for(int j=m;0<=j;j--){
      if(b[j]>K)continue;
      mx=j;
      m=j;
      break;
  
    }
    ans=max(ans,mx+i);
  }
  cout<<ans<<endl;
  }



























































































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

#define int long long

signed main() {
  int n;
  cin >> n;

  vector<int> a(n);
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
    if ( i ) cout << " ";    
    cout << a[i];
  }
  cout << endl;

  for ( int i = 1; i < n; i++ ) {
    int v = a[i];
    int j = i-1;
    while ( j >= 0 && a[j] > v ) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    for ( int i = 0; i < n; i++ ) {
      if ( i ) cout << " ";    
      cout << a[i];
    }
    cout << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=100;

int main(){
    string s; cin>>s;
    int s1=-1,s2=-1;

    for(int i=0;i<s.size();i++){
        if(s[i] =='A'&&s1==-1)s1=i;
        if(s[i]=='Z')s2=i;
    }

    cout<<s2-s1+1<<"\n";
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

typedef long long ll;
const ll N = 110;
bool a[N];
ll n, k;

int main() {
	cin >> n >> k;

	for (ll i = 1; i <= k; i++) {
		ll d;
		cin >> d;
		for (ll j = 1; j <= d; j++) {
			ll x;
			cin >> x;
			a[x] = true;
		}
	}

	ll res = 0;
	for (ll i = 1; i <= n; i++) {
		if (!a[i])
			res++;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

LL n, p;

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	cin >> n >> p;
	if(n > log2(p))
		return cout << 1, 0;
	if(n == 1)
		return cout << p, 0;
	LL up = pow(p, LD(1) / n) + 1;
	for(int i = up; i; i --)
		if(p % LL(pow(i, n)) == 0)
			return cout << i, 0;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	int n;
	string s;
	cin >> n >> s;
	int cnt_r=0,cnt_b=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R')cnt_r++;	
		if(s[i]=='B')cnt_b++;	
	}
	if(cnt_r > cnt_b){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


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

int main(void){
  int a = 0, b = 0, c = 0, d = 0;
  char s[3];
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s", &s);
    if(s[0] == 'A'){
      a++;
    }
    else if(s[0] == 'W'){
      b++;
    }
    else if(s[0] == 'T'){
      c++;
    }
    else{
      d++;
    }
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", b);
  printf("TLE x %d\n", c);
  printf("RE x %d\n", d);
  
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
int main(){
   string s,t;
   cin>>s;
   cin>>t;
   int ans=INT_MAX;
   int l=s.length()-t.length();
   for(int i=0;i<l+1;i++){
       string str=s.substr(i,i+t.length());
       int c=0;
       for(int j=0;j<t.length();j++){
           if(str[j]!=t[j])
              c++;
       }
       ans=min(c,ans);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<cmath>
 
using namespace std;
 
int main(){
  int N,min_i,T,A;
  cin >> N >> T >> A;
  int h;
  double min=100000000000.,tmp_min;
  for(int i = 1;i <= N;++i){
    cin >> h;
    tmp_min = abs(A - (T - (h*0.006)));
    if(min > tmp_min){
      min =tmp_min;
      min_i = i;
    }
  }
  cout << min_i <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int x, y;
int c[17][17];

int dp[17][17];

bool input() {
  int i, j;
  scanf("%d %d", &x, &y);
  if (!x && !y) return false;
  fill(c[0], c[0] + 17 * 17, 1);
  for (i = 1; i <= y; i++) {
    for (j = 1; j <= x; j++) {
      scanf("%d", &c[i][j]);
    }
  }
  /*
  printf("\n");

  for (i = 0; i < 17; i++) {
    for (j = 0; j < 17; j++) {
      printf("%d ", c[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  return true;
}

void manage() {
  int i, j, output = 0;

  fill(dp[0], dp[0] + 17 * 17, 0);
  for (i = 1; i <= x; i++) {
    if (c[y][i] != 1) dp[y][i] = 1;
  }
  for (i = 1; i <= x; i++) {
    if (c[y - 1][i] == 2) dp[y - 1][i] = 1;
  }
  
  for (i = y; i > 0; i--) {
    for (j = x; j > 0; j--) {
      if (dp[i][j]) {
        if (c[i][j] == 0) {
          if (c[i - 1][j - 1] == 0) dp[i - 1][j - 1] += dp[i][j];
          if (c[i - 1][j    ] == 0) dp[i - 1][j    ] += dp[i][j];
          if (c[i - 1][j + 1] == 0) dp[i - 1][j + 1] += dp[i][j];
          if (c[i - 2][j    ] == 2) dp[i - 2][j    ] += dp[i][j];
        } else if (c[i][j] == 2) {
          if (c[i - 1][j] == 0) dp[i - 1][j] += dp[i][j];
          if (c[i - 2][j] == 2) dp[i - 2][j] += dp[i][j];
        }
      }
    }
  }
  
  /*
  for (i = 0; i < 17; i++) {
    for (j = 0; j < 17; j++) {
      printf("%d ", dp[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */

  for (i = 1; i <= x; i++) {
    output += dp[1][i];
  }
  printf("%d\n", output);
}


int main() {

  while(input()) {
    manage();
  }

  return 0;
}

Measured memory_bytes: 0
#include <cassert>
#include <chrono>
#include <cmath>
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(){
    int k;
    int x;
    cin >> k;
    cin >> x;
    //cin >> x;
    if(500 * k >= x){
        cout << "Yes" <<endl;
    }
    else    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
/*
	
*/

#include<stdio.h>

int Main();
int GCM(int m, int n);
int LCM(int m, int n);

int main(int argc, char *argv[]){
	while( Main() == 0 );
	return 0;
}

int Main(){
	int n = 0, a = 0, b = 0, gcm = 0, cm = 0, count = 0, i = 0, j = 0;	//?????????????????\????????????a??¨b???a??¨b????????§??¬?´???°???a??¨b???????°???¬?????°??¨n????°???????????????????????????§?????????????????°???
	if( scanf("%d %d %d", &n, &a, &b) != 3 ){ return -1; }
	if( n == 0 || a == 0 || b == 0 ){ return 1; }
	char list[n+1];	//????????§????????????????????????????????????0????????????????????????1???
	for( i = 0; i < n+1; i++ ){ list[i] = 1; }
	gcm = GCM(a, b);
	cm = LCM(a, b);
	cm = (cm <= n ? cm : n);
	for( i = 0; a * i <= cm; i++ ){
		for( j = 0; a * i + b * j <= cm; j++ ){
			list[a*i+b*j] = 0;
		}
	}
	for( i = 1; i <= cm; i++ ){ count += (int)list[i]; }
	count += (n - cm) / gcm * (gcm - 1);
	count += (n - cm) % gcm;
	printf("%d\n", count);
	return 0;
}

int GCM(int m, int n){
	int r = 0;
	//m>=n??¨?????????
	if( m < n ){
		r = m;
		m = n;
		n = r;
	}
	r = m % n;
	while( r > 0 ){
		m = n;
		n = r;
		r = m % n;
	}
	return n;
}

int LCM(int m, int n){
	return (int)((long)m * n / GCM(m,n));	//??????????????????????????¢????????????long??§?¨????????????????int????????£???????????????
}

Measured memory_bytes: 1576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int n = int.Parse(Console.ReadLine());

            while (n-- > 0)
            {
                string input = Console.ReadLine();

                string path = input[0].ToString();
                int cur = 0;
                int min = 0;
                int max = 0;
                int len = input.Length - 3;

                for (int i = 0; i < len; i += 3)
                {
                    if (input[i + 1] == '-')
                    {
                        cur++;

                        if (cur > max)
                        {
                            path = path + input[i + 3];
                            max = cur;
                        }
                    }
                    else
                    {
                        cur--;

                        if (cur < min)
                        {
                            path = input[i + 3] + path;
                            min = cur;
                        }
                    }
                }
                sb.AppendLine(path);
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 8904
def solve():
  N, M = map(int, input().split(' '))
  G = [[] for _ in range(N + 10)]
  dist = [[-1 for _ in range(3)] for _ in range(N + 10)]
  for _ in range(M):
    u, v = map(int, input().split(' '))
    G[u].append(v)
  S, T = map(int, input().split(' '))
  que = [[S, 0]]
  dist[S][0] = 0
  while que:
    q = que.pop(0)
    nv, np = q[0], q[1]
    for item in G[nv]:
      if dist[item][(np + 1) % 3] == -1:
        que.append([item, (np + 1) % 3])
        dist[item][(np + 1) % 3] = dist[nv][np] + 1
  if dist[T][0] == -1:
    return -1
  else:
    return dist[T][0] // 3
print(solve())

Measured memory_bytes: 39344
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

LL b[100005], x, sum;
int i, n,cnt;
map<LL, int> check;
int main()
{
	cnt = 0;
	cin >> n;
	for (i = 1;i <= n;i++)
	{
		cin >> x;
		if (check[x] + 1 > x)
			sum++;
		else
		{
			check[x]++;
			b[++cnt] = x;
		}
	}
	for (i = 1;i <= cnt;i++)
	{
		if (check[b[i]] != b[i])
		{
			sum += check[b[i]];
			check[b[i]] = 0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;

long long power(long long a, long long p) {
    long long res = 1;
    while (p) {
        if (p & 1) res = (res * a) % mod;
        p >>= 1;
        a = (a * a) % mod;
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin >> n;
    long long ans = power(10, n) - 2 * power(9, n) + power(8, n);
    cout << (ans % mod + mod) % mod << '\n';

    return 0;
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

bool include3(int x){
    bool ans = false;
    while (true){
        if(x%10 == 3){
            ans = true;
            break;
        }else{
            x /= 10;
            if(x == 0)break;
        }
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;cin >> n;
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0){
            cout << " " << i;
        }else{
            if(include3(i)){
                cout << " " << i;
            }
        }
    }
    cout << endl;
}


Measured memory_bytes: 3164
import sys
from collections import deque
inf=100000000000000000000
fastinput=sys.stdin.readline
N=int(fastinput())
path=[deque() for hoge in range(N)]
for fuga in range(N-1):
    a,b,c=[int(hoge) for hoge in fastinput().split()]
    path[a-1].append([b-1,c])
    path[b-1].append([a-1,c])
Q,K=[int(hoge) for hoge in fastinput().split()]
stack=deque()
stack.append(K-1)
Kcost=[0]*N#あとあと初期化
went=[False]*N
went[K-1]=True
while stack:
    cur=stack.pop()
    curcost=Kcost[cur]
    for next,c in path[cur]:
        if c and not went[next]:
            went[next]=True
            Kcost[next]=curcost+c
            stack.append(next)
for q in range(Q):
    x,y=[int(hoge) for hoge in fastinput().split()]
    print(Kcost[x-1]+Kcost[y-1])
    

Measured memory_bytes: 101868
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
T.append(T[-1])

fst = T[0]
cnt = 0
ans = 0
flg = 0

for i in range(N):
    cnt += 1
    flg = 0
    if T[i]-fst > K:
        fst = T[i]
        cnt = 1
        ans += 1
    
    elif cnt == C:
        fst = T[i+1]
        cnt = 0
        ans += 1
        flg = 1


    # print(i,T[i],flg,fst,ans,cnt)

if not(flg):
    ans += 1

print(ans)
        
        




Measured memory_bytes: 7420
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int used[200100];
int cir,cur;
ll k;
int a[200100];
int more;
void dfs(int now,int time)
{
//	cout<<now<<" "<<time<<endl;
	if(time==k)
	{
		cout<<now+1<<endl;
		exit(0);
	}
	if(used[now]) 
	{
	//	cout<<111<<endl;
		cir=time-used[now]+1;
		more=used[now]-1;
		cur=now;
		return;
	}
	used[now]=time+1; 
	dfs(a[now],time+1);
}
void dfs1(int now,int rest)
{
	rest--;
	if(rest==0)
	{
		cout<<now+1<<endl;
		exit(0);
	}
	dfs1(a[now],rest);
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n>>k;
	rep(i,n)
	{
		cin>>a[i];
		a[i]--; 
	} 
//	cout<<1;
	dfs(0,0);
	k++;
	k-=more;
	k%=cir;
	k+=cir; 
	//cout<<cir<<endl<<cur<<endl<<k<<endl; 
	dfs1(cur,k);
	return 0;
}



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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, int b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int h, w;
    string s[100];
    cin >> h >> w;
    for (int i = 0; i < h; i++)
        cin >> s[i];

    for (int i = 0; i < w + 2; i++)
        cout << "#";
    cout << endl;
    for (int i = 0; i < h; i++)
    {
        cout << "#";
        cout << s[i];
        cout << "#" << endl;
    }
    for (int i = 0; i < w + 2; i++)
        cout << "#";
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

void solve(int n, int m, int p){
    auto v = make_v(n+10, n+10, n+10, -1);
    array<int, 3> di = {-1, 0, 1};
    auto dj = di, dk = di;
    int uec = true;
    for (int l = 0; l < p; ++l) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--;
        y--;
        if(!uec) continue;
        for (int i = 0; i < n; ++i) {
            if (v[i+3][x+3][y+3] == -1) {
                v[i+3][x+3][y+3] = l % 2 + 1;
                break;
            }
        }
        for (int s = 0; s < 3; ++s) {
            for (int t = 0; t < 3; ++t) {
                for (int u = 0; u < 3; ++u) {
                    if(s*t*u == 1) continue;
                    for (int i = 0; i < n; ++i) {
                        for (int j = 0; j < n; ++j) {
                            for (int k = 0; k < n; ++k) {
                                if(v[i+3][j+3][k+3] == -1) continue;
                                int valid = true;
                                for (int w = 1; w < m; ++w) {
                                    if(v[i+3+w*di[s]][j+3+w*dj[t]][k+3+w*dk[u]] != v[i+3+(w-1)*di[s]][j+3+(w-1)*dj[t]][k+3+(w-1)*dk[u]])  {
                                        valid = false;
                                        break;
                                    }
                                }
                                if(valid){cout << (v[i+3][j+3][k+3]%2 ? "Black" : "White") << " " << l+1<< "\n";
                                   uec = 0;
                                   s = t = u = 3;
                                   i = n, j = n, k = n;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if(uec) puts("Draw");
}

int main() {
    int n, m, p;
    while(cin >> n >> m >> p, n){
        solve(n, m, p);
    }
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to,w;
};

int main() {
	int h, w,d;
	cin >> h >> w >> d;
	vector<pii> pos(h * w);
	vector<int> dis(h * w);
	REP(i, h) {
		REP(j, w) {
			int a;
			scanf("%d", &a);
			a--;
			pos[a] = { i,j };
		}
	}

	for(int i = h*w-1; i >= 0; i--) {
		if (dis[i] == 0) {
			int po = i;
			while (po-d >= 0) {
				dis[po-d] = dis[po] + abs(pos[po].second - pos[po - d].second) + abs(pos[po].first - pos[po - d].first);
				po = po - d;
			}
		}
	}

	int q;
	cin >> q;
	REP(i, q) {
		int l, r;
		scanf("%d %d", &l, &r);
		l--, r--;
		printf("%d\n", dis[l]-dis[r]);

	}
	return 0;
}

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

int main() {
    ll x,y;
    cin >> x >> y;
    ll sx,sy,tx,ty;
    sx = sy = tx = ty = 0;
    ll color = 0;
    ll dir = 0;
    while(sx > x || x > tx || sy > y || y > ty){
              switch(dir){
                    case 0:
                        tx += llabs(ty - sy) + 1;
                        break;
                    case 1:
                        ty += llabs(tx - sx) + 1;
                        break;
                    case 2:
                        sx -= llabs(ty - sy)+1;
                        break;
                    case 3:
                        sy -= llabs(tx - sx)+1;
              }
              color = (color+1)%3;
              dir = (dir+1)%4;
          }
    cout << color + 1 << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a < b || d < b) {
        cout << "No\n";
        return;
    }
    if(c + 1 >= b) {
        cout << "Yes\n";
        return;
    }
    ll g = gcd(b, d);
    if(b - g + a % g > c)
        cout << "No\n";
    else
        cout << "Yes\n";
}

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

    int t;
    cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3648
from sys import stdin

A = int(stdin.readline().rstrip())
B = list(stdin.readline().rstrip().split())
answer = []
do = ''
key = 0

for i in list(B[0]):
    i += str(B[1][key])
    answer += i
    key += 1

for i in answer:
    do += i

print(do)


Measured memory_bytes: 3060
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(input())
rs = []
for i in range(n):
    s, p = input().split()
    rs.append((s, -int(p), i))
rs = sorted(rs)


for r in rs:
    print(r[2] + 1)

Measured memory_bytes: 9472
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<pair<int, int>> ab(N), cd(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        cd[i] = make_pair(c, d);
    }

    sort(ab.begin(), ab.end());
    sort(cd.begin(), cd.end());

    vector<bool> used(N, false);
    for (int i = 0; i < N; i++) {
        auto p = cd[i];
        int x = p.first;
        int y = p.second;

        int index = -1;
        for (int j = 0; j < N; j++) {
            if (!used[j] && ab[j].first < x) {
                if (index == -1 && ab[j].second < y) index = j;
                else if (ab[j].second < y && ab[j].second > ab[index].second) index = j;
            }
        }
        if (index != -1) used[index] = true;
    }

    int ans = 0;
    for (int i = 0; i < N; i++) if (used[i]) ans++;

    cout << ans << endl;

    return 0;
}











































































Measured memory_bytes: 256
/**
 *    author:  Mohamad Milhem
 *    created: 2020-04-04-18.04.41
**/

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


int main(){

    FAST;

    int a,b,c;

    cin >> a >> b >> c;

    swap(a,b);
    swap(a,c);

    cout << a << " "<<  b << " "<< c;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int H, W;
	int i, j;
	
	while (1){
		scanf("%d%d", &H, &W);
		if (H == 0 && W == 0){
			break;
		}
		
		for (i = 1; i <= H; i++){
			for (j = 1; j <= W; j++){
				if (i % 2 == 0){
					if (j % 2 == 0){
						printf("#");
					}
					else {
						printf(".");
					}
				}
				else {
					if (j % 2 != 0){
						printf("#");
					}
					else {
						printf(".");
					}
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return (0);
}



Measured memory_bytes: 2040
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

Int dp[3240][3240];
Int a[3240];
Int n;

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

  for(int i = 0;i <= n;i++){
    for(int j = 0;j+i <= n;j++){
      if(i == 0){
	dp[j][j+i] == 0;
      }
      else if((n-i)%2 == 0){
	dp[j][i+j] = max(dp[j+1][i+j] + a[j], dp[j][i+j-1] + a[i+j-1]);
      }
      else{
	dp[j][i+j] = min(dp[j+1][i+j] - a[j], dp[j][i+j-1] - a[i+j-1]);
      }
      //      cout << j << " " << i+j << " " << dp[i][i+j] << endl;
    }
  }
  cout << dp[0][n] << endl;
  return 0;
}

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

ll mod = 998244353;

int main() {
    int N, K; cin >> N >> K;
    vector<int> L(K), R(K);
    rep(i, K){
        cin >> L[i] >> R[i];
    }
    vector<ll> dp(N+1);
    vector<ll> dpsum(N+1);
    dp[1] = 1;
    dpsum[1] = 1;

    for (int i = 2; i <= N; i++){
        for (int j = 0; j < K; j++){
            int li = i - R[j];
            int ri = i - L[j];
            if(ri < 1)continue;
            li = max(li, 1);
            ll x = dpsum[ri] - dpsum[li-1];
            if(x < 0)x += mod;
            dp[i] += x;
            dp[i] %= mod;
        }
        dpsum[i] = dpsum[i-1] + dp[i];
        dpsum[i] %= mod;
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 6392
import java.util.Scanner;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int area = a*b;
int length = 2*a + 2*b;
System.out.println(area+" "+length);
sc.close();
}
}






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

int main(){
    int l, r;
    cin >> l >> r;
    if(r - l >= 2019) cout << 0 << endl;
    else{
        vector<int> n;
        for(int i = l; i <= r; i++){
            n.push_back(i % 2019);
        }
        vector<int> m;
        rep(i,n.size()){
            for(int j = i+1; j < n.size(); j++) m.push_back((n[i]*n[j])%2019);
        }
        sort(m.begin(), m.end());
        cout << m[0] << endl;
    }
}

Measured memory_bytes: 11476
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  bool flag = true;
  long max_H;

  vector<long> H(N);
  cin >> H[0];
  max_H = H[0];
  if(N > 1){
    for(int i = 1;i < N;i++){
      cin >> H[i];
      max_H = max(max_H,H[i]);
      if((max_H - H[i]) > 1){
        flag = false;
        break;
      }
    }
  }


  if(flag == true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

long long cnt(long long A, long long B, long long C) {
  A--;
  return B / C - A / C;
}

long long gcd(long long a, long long b) {
  while (b) {
    long long tmp = a%b;
    a = b;
    b = tmp;
  }
  return a;
}
int main() {
  long long A, B, C, D;
  scanf("%lld%lld", &A, &B);
  scanf("%lld%lld", &C, &D);
  long long ans = (B - A + 1) - cnt(A, B, C) - cnt(A, B, D) + cnt(A, B, C/gcd(C,D)*D);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
bool p(string v){int n = v.size();for(int i=0;i<n;i++){if(v[i]!=v[n-1-i])return false;}return true;}
int main(){string s;cin>>s;int n=s.size();string a=s.substr(0,n/2),b=s.substr(n/2+1,n);if(p(s)&&p(a)&&p(b))puts("Yes");else puts("No");}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  char c;
  cin >> c;
  if(c=='A')
    cout << 'T' << endl;
  else if(c=='T')
    cout << 'A' << endl;
  else if(c=='C')
    cout << 'G' << endl;
  else
    cout << 'C' << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String arg[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int R = Integer.parseInt(br.readLine());
        if(R<1200){
            System.out.println("ABC");
        }else if(R<2800){
            System.out.println("ARC");
        }else{
            System.out.println("AGC");
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int> 
#define vll vector<ll> 
#define vpll vector<pair<ll ,ll>>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define map map<ll ,ll>
#define umap unordered_map<ll , ll>
#define endl "\n"
#define set set<ll> 
#define setC set<char>
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define fastcout ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define testcases int tt = 1 ; cin >> tt ; for(int i = 1 ; i <= tt ; ++i)
#define codejam cout << "Case #"<<i <<": "; 
#define FOR(i,a,n) for(int i = a ; i <= n ; ++i)
#define FORback(i,a,n) for(int i = n ; i >= a ; --i)
 
typedef long long int ll;
vvi dp ;

int doSome(string &a , string &b , int i , int j){

    int n = a.size();
    int m = b.size();

    if( i == n or j == m){
        return 0;
    }

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

    if(a[i] == b[j]){
        return dp[i][j] = 1 + doSome(a , b , i+1 , j+1);
    }
    else{
        return dp[i][j] = max(doSome(a ,b , i+1 , j ) , doSome(a , b , i, j+1));
    }
}

string findString(string&a , string &b ,int len){

    string ans = "";

    int i = 0 , j = 0 ;
    // len--;
    while(len){
        if(a[i] == b[j]){
            ans += b[j];
            ++i , ++j , --len;
        }
        else{
            if(dp[i][j+1] > dp[i+1][j]){
                ++j;
            }
            else{
                i++;
            }
        }
    }

    return ans;
}
 
void solv(){
    string a , b;
    cin >> a >>b;
    int n = a.size();
    int m = b.size();
 
    dp.assign(n+1 , vi(m+1 ,-1));
    // vvi dp(n+1 , vi(m+1 , 0 ));
 
    ll len = doSome(a , b , 0 , 0);
    // cout << len << endl;
    cout << findString(a , b , len) << endl ;
}
 
int main(){
    fast ;    
    // testcases{
        // codejam ;
        solv();
    // } 
}
 

Measured memory_bytes: 38776
# https://atcoder.jp/contests/abc139/tasks/abc139_e
# 詳しくは図の解説を。シミュレーションを高速化するか、トポロジカルソートをうまく使うか
# ここでは練習のためトポロジカルソートをうまく使うことにする

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

N = read_a_int()
A = read_matrix(N)
A = [mina(*a) for a in A]  # 0based indexに

# 試合idを決定する
matchID = {}
cnt = 0
for i, j in combinations(range(N), r=2):
    matchID[i, j] = cnt
    matchID[j, i] = cnt  # 一応逆に入力されても大丈夫なように
    cnt += 1

# 入力をmatchID形式に変換
for i, j in product(range(N), range(N - 1)):
    A[i][j] = matchID[i, A[i][j]]

# DAGを作る
graph = defaultdict(lambda: [])
indeg = [0] * cnt
for a in A:
    for i in range(N - 2):
        graph[a[i]].append(a[i + 1])
        indeg[a[i + 1]] += 1

# トポロジカルソートの容量ですべての試合の日数を割り振る
day = [-1] * cnt  # 何日目にその試合が行われたか
is_visited = [False] * cnt
que = deque()  # 各要素は(ノード, 到達可能な最短日数) #流入量0になったノードから加えていく
for i in range(cnt):  # 初期化
    if indeg[i] == 0:
        is_visited[i] = True
        que.append((i, 1))

while que:
    u, d = que.popleft()
    day[u] = d  # 流入量0になったときのdなので
    for to in graph[u]:
        indeg[to] -= 1
        if indeg[to] or is_visited[to]:  # 流入待ちがまだあるor訪問済みならやる必要はない
            continue
        que.append((to, d + 1))
        is_visited[to] = True

print(-1 if -1 in day else max(day))


Measured memory_bytes: 227960
n,x= map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans= 0

X=x
for i in range(n):
    
    if 0 <= X-a[i]:
        X = X-a[i]
        ans +=1
    elif X ==0:
        break

if ans == n and X >0 :
    ans -=1     
       
    
print(ans)



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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int main(){
    fIO
//    freopen("", "r", stdin);
//    freopen("", "w", stdout);

    char c;
    cin >> c;

    if(c >= 'a' && c <= 'z') cout << 'a';
    else cout << 'A';

}








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

using namespace std;

typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> pl;
typedef double db;

#define in(x) cin >> x
#define ini(x) int x; cin >> x
#define inl(x) ll x; cin >> x
#define ins(x) string s; cin >> x

#define out(x) cout << x
#define outb(x) cout << x << ' '
#define outn(x) cout << x << '\n'

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz size()
#define len length()
#define all(x) x.begin(), x.end()

#define forn(i, s, e) for (int i = s; i < e; i++)
#define forr(i, s, e) for (int i = s; i >= e; i--)
#define ford(i, s, e, d) for (int i = s; i < e; i += d)
#define fors(i, n) for (int i = 1; i*i <= n; i++)

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	ins(s);
	string k = "keyence";
	if (s == k) {
		outn("YES");
		return 0;
	}
	forn(i, 0, s.len) {
		forn(j, i, s.len) {
			string news;
			forn(k, 0, s.len) if (k <= i || j <= k) news += s[k];
			if (news == k) {
				outn("YES");
				return 0;
			}
		}
	}
	outn("NO");
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int a[100001],b[100001],c[100001];
int dp[100001][4];
int f(int x,int y)
{ 
  if(x==n)
    return 0;
  if(dp[x][y]!=-1)
    return dp[x][y];
  if(y==1)
    {      
      dp[x][y]=max(f(x+1,2)+b[x],f(x+1,3)+c[x]);
      return dp[x][y];
    }
  else if(y==2)
    {
      dp[x][y]=max(f(x+1,1)+a[x],f(x+1,3)+c[x]);
      return dp[x][y];
    }
  else
    {
      dp[x][y]=max(f(x+1,2)+b[x],f(x+1,1)+a[x]);
      return dp[x][y];
    }

}
int32_t main()
{  
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i]>>b[i]>>c[i];
  memset(dp,-1,sizeof(dp));
  int temp1=f(1,1)+a[0];
  int temp2=f(1,2)+b[0];
  int temp3=f(1,3)+c[0];
  cout<<max(temp1,max(temp2,temp3));
}


Measured memory_bytes: 10368
/*
 *Team hhu_6814
 *Author big_yellow_doge
 */
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <set>
#include <list>
using namespace std;
//ios::sync_with_stdio(false);
const int MINF = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int Maxn = 1e5+5;
typedef long long ll;

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(k>n) puts("NO");
    else{
        n+=n&1;
        if(n>=2*k) puts("YES");
        else puts("NO");
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
N=int(input())
n=list(map(int,(stdin.readline().strip().split())))
n.insert(0,None)
for i,j in enumerate(n):
    if i==0:continue
    left=i*2
    right=i*2+1
    if i==1:#parent
        if left<=N and right<=N:
            print("node %d: key = %d, left key = %d, right key = %d, " % (i,j,n[left],n[right]))
        elif left<=N:
            print("node %d: key = %d, left key = %d, " % (i,j,n[left]))
        elif right<=N:
            print("node %d: key = %d, right key = %d, " % (i,j,n[right]))
        else:
            print("node %d: key = %d, " % (i,j))
    else:
        parent=i//2
        if left<=N and right<=N:
            print("node %d: key = %d, parent key = %d, left key = %d, right key = %d, " % (i,j,n[parent],n[left],n[right]))
        elif left<=N:
            print("node %d: key = %d, parent key = %d, left key = %d, " % (i,j,n[parent],n[left]))
        elif right<=N:
            print("node %d: key = %d, parent key = %d, right key = %d, " % (i,j,n[parent],n[right]))
        else:
            print("node %d: key = %d, parent key = %d, " % (i,j,n[parent]))



Measured memory_bytes: 5632
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
//using namespace __gnu_pbds;
//typedef tree< pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>
//ordered_set;
int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
#define X first
#define Y second
#define int long long int 
const int N = (int)1e6 + 10;
const int MOD = (int) 1e9 + 7;

int fastpower(int a, int b){
    int res = 1;
    a %= MOD;
    while(b){
        if(b&1) res = (res * a) % MOD;
        a *= a; a %= MOD;
        b >>= 1;
    }
    return res;
}


void solve(){
    //THink in reverse..
    // we want to find contribution of each gcd to happen
    // consider we have k places _ , _ , _ , _ , __ ,n.
    // gcd = 1 -> k^n ways;
    // gcd = 2 -> total multiples of 2 are k/2 -> (k/2)^n ways
    // so on until gcd = n;
    // but we need to take care of overcounting
    int n, k;
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    for(int gd = k; gd >= 1; --gd){
        int total_multiples = k/gd;
        int temp = fastpower(total_multiples, n);
        temp %= MOD;
        temp %= MOD;
        int extra = 0;
        for(int j = gd * 2; j <= k; j += gd){
            extra = (extra + dp[j]) % MOD;
        }
        dp[gd] = (temp - extra + MOD) % MOD;
    }

    int ans = 0;
    for(int i = 1; i <= k; ++i){
        int add = ( dp[i] % MOD * i % MOD ) % MOD;
        ans += add, ans %= MOD;
    }

    cout << ans << '\n';
   
    
}

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}
/*
Sample inp
*/


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

using namespace std;

int main(){
    double a, b, C, S;
    cin >> a >> b >> C;
    C = C * M_PI / 180.0;
    S = (a * b * sin(C)) / 2;
    cout << fixed << setprecision(4) << S << endl
    << a+b+sqrt(a*a+b*b-2*a*b*cos(C)) << endl << 2*S/a << endl;
}

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

int main()
{
  int N, L, max = 0;
  int min = 1000000;
  int idx = 0;

  cin >> N >> L;

  vector<int> a(N);

  
  for(int i = 0; i < N; i++)
  {
    a[i] = i + L;
    max += a[i];
    if(min > abs(a[i])){
      min = abs(a[i]);
      idx = i;
    }
  }

  if(a[idx] < 0)min = -min;


  cout << max - min << endl; 

 return 0; 

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005 
#define INF 0x3f3f3f3f
#define FIO "c"
#define ll long long
#define mid ((l+r)>>1)
#define lid (id<<1)
#define rid (id<<1|1)

template <class T>
inline void read(T &x)
{
	T f=1;x=0;
	char ch=getchar();
	for (;!isdigit(ch) && ch!='-';ch=getchar());
	if (ch=='-')	ch=getchar(),f=-1;
	for (;isdigit(ch);ch=getchar())	x=x*10+ch-'0';
	x*=f;
}
int N,X,Q,t,a,cur=1,pre,mx,mi,r[MAXN],delta,flag=-1,ans;

inline int f(int x,int mi=0,int mx=X){return (x<mi||x>mx)?((x<mi)?mi:mx):x;}
int main()
{
//	freopen(FIO".in","r",stdin);
//	freopen(FIO".out","w",stdout);
	read(X);read(N);
	for (int i=1;i<=N;i++)	read(r[i]);
	read(Q);
	mx=X;
	while (Q--)
	{
		read(t);read(a);
		while (t>=r[cur] && cur<=N)
		{
			delta=flag*(r[cur]-r[cur-1]);pre+=delta;
			mx=f(mx+delta);mi=f(mi+delta);
			flag=-flag;cur++;
		}
	 	ans = f(flag * (t - r[cur - 1]) + f(a + pre, mi, mx));  
		printf("%d\n",ans);
	}
	fclose(stdin);fclose(stdout);
	return 0;
}



Measured memory_bytes: 1536
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	if(a > 8 || b > 8) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}


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

string S;

int main() {
    cin >> S;

    for(int i = 0; i < (int)S.size() - 1; i++) {
        if(S[i] == 'A' && S[i + 1] == 'C') {
            cout << "Yes";
            return 0;
        }
    }

    printf("No");
}


Measured memory_bytes: 256