akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll=long long;

const int N=1e5+10;

int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a, a+3);
    if(a[0]==a[1]&&a[0]!=a[2]) cout<<"Yes";
    else if(a[1]==a[2]&&a[0]!=a[1]) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 100100
#define PI 3.141592653589793238
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans%p;
}
ll inv(ll a,ll m)
{
    return power(a,m-2,m);
}
//code begins
void solve(){
    ll l,r,d;cin>>l>>r>>d;
    ll ans=0;
    for(;l<=r;l++)
        if(l%d==0)ans++;
    cout<<ans<<endl;
}
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

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

//    ll t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n;
    scanf("%lli",&n);
    if (n%1000 == 0) {
        printf("%i",0);
    } else {
        printf("%lli",1000-n%1000);
    }
    return 0;
}

Measured memory_bytes: 1732
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int a[3];
    cin >> a[0];
    cin >> a[1];
    cin >> a[2];
    sort(a, a + 3);

    if(a[0] == a[1]) cout << a[2];
    else cout << a[0];
    cout << endl;

    return 0;
}



Measured memory_bytes: 888
#include<iostream>
#include<algorithm> 
using namespace std;
int main()
{
	int n;
	cin >> n;
	int* p=new int [2*n];  
	for (int i=0;i<2*n;i++)
	{
		cin >> p[i];
	}
	sort(p,p+2*n);
	int s=0;
	for(int i=0;i<2*n;i+=2)
	{
		s+=p[i];
	}
	cout << s << endl;
	return 0;
} 

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

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	
	string res = "";

	for (auto ch : s) {
		int index = ch - 'A';
		index += n;
		if (index >= 26) {
			index -= 26;
		}
		res += (index + 'A');
	}

	cout << res;
}

Measured memory_bytes: 256
using System;

namespace AtCoderCs
{
    class Program
    {
        static void Main(string[] args)
        {

            var num = int.Parse(Console.ReadLine());
            var str = Console.ReadLine().Split(' ');

            foreach(var @int in str)
            {

                int c = int.Parse(@int);

                if (c % 2 == 0 && c % 3 != 0 && c % 5 != 0)
                {
                    Console.WriteLine("DENIED");
                    return;
                }

            }

            Console.WriteLine("APPROVED");
            return;

        }
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N=2e5+5;

typedef long long LL;

int n,m,cnt[N],ans,len[N],a[N];

char c;

int read()
{
	int x=0,sig=1;
	for (c=getchar();c<'0' || c>'9';c=getchar()) if (c=='-') sig=-1;
	for (;c>='0' && c<='9';c=getchar()) x=x*10+c-48;
	return x*sig;
}

int main()
{
	n=read(); m=read(); ans=n;
	for (int i=1;i<=n;i++)
	{
		a[i]=read();
		if (len[a[i]]<a[i] && !cnt[a[i]-len[a[i]]]) ans--;
		if (len[a[i]]<a[i]) cnt[a[i]-len[a[i]]]++; len[a[i]]++;
	}
	for (;m--;)
	{
		int x=read(),y=read();
		len[a[x]]--; if (len[a[x]]<a[x]) cnt[a[x]-len[a[x]]]--;
		if (len[a[x]]<a[x] && !cnt[a[x]-len[a[x]]]) ans++;
		a[x]=y;
		if (len[a[x]]<a[x] && !cnt[a[x]-len[a[x]]]) ans--;
		if (len[a[x]]<a[x]) cnt[a[x]-len[a[x]]]++; len[a[x]]++;
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "abc")
	{
		cout << "Yes" << endl; return 0;
	}
	if (s == "acb") {
		cout << "Yes" << endl; return 0;
	}
	if (s == "bac") {
		cout << "Yes" << endl; return 0;
	}
	if (s == "bca") {
		cout << "Yes" << endl; return 0;
	}
	if (s == "cab") {
		cout << "Yes" << endl; return 0;
	}
	if (s == "cba") {
		cout << "Yes" << endl; return 0;
	}
	cout << "No" << endl;

	return 0;
}

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

bitset<50> func(long long n) {
  if (n % 2 == 0) {
    if ((n/2) % 2 == 0) return bitset<50>(n);
    else return bitset<50>(1) ^ bitset<50>(n);;
  }
  else {
    if (((n+1)/2) % 2 == 0) return bitset<50>(0);
    else return bitset<50>(1);
  }
}

int main() {
  long long A, B; cin >> A >> B;
  bitset<50> ans;
  if (A == 0 && B == 0) cout << 0 << endl;
  else if (A == 0) {
    ans = func(B);
    cout << ans.to_ullong() << endl;
  }
  else {
    ans = func(A-1) ^ func(B);
    cout << ans.to_ullong() << endl;
  }
}

Measured memory_bytes: 256
import math

A,B=(int(x) for x in input().split())
#N=int(input())
#A=list(map(int, input().split()))

a_1=math.ceil(A*12.5)
a_2=math.ceil((A+1)*12.5)
la=list(range(a_1,a_2))

b_1=int(format(B*10 ,'.0f'))
b_2=int(format((B+1)*10 ,'.0f'))
lb=list(range(b_1,b_2))

la_lb_and_list = list(set(la) & set(lb))

if len(la_lb_and_list) == 0:
    print('-1')
else :
    print(min(la_lb_and_list))

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
    int i=0;
    int x=0;
    int dice[6]={0};
    char mark;

    for(i=0;i<=5;i++){    
        scanf("%d",&dice[i]);
    }

    scanf("%c",&mark);

    while(1){
        scanf("%c",&mark);
        if(mark=='\n'){
            break;
        }else if(mark=='S'){
            x=dice[0];
            dice[0]=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=x;            
        }else if(mark=='N'){
            x=dice[0];
            dice[0]=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=x;  
        }else if(mark=='W'){
            x=dice[0];
            dice[0]=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=x; 
        }else if(mark=='E'){
            x=dice[0];
            dice[0]=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=x; 
        }
    }
       printf("%d\n",dice[0]);

    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

int n, A[50];

int solve(int i, int m)
{
	if(m==0) return 1;
	if(i>=n) return 0;
	int res = solve(i+1, m) || solve(i+1, m-A[i]);
	return res;
}

int main()
{
	int q, m, i;
	scanf("%d", &n);
	for(i=0;i<n;i++)
	{
		scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for(i=0;i<q;i++)
	{
		scanf("%d", &m);
		if(solve(0, m))
		{
			printf("yes\n");
		}
		else
			printf("no\n");
	}
	return 0;
}


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

int x;
bool val[1005];
int main()
{
	memset(val,0,sizeof(val));
	val[1]=1;
	for(int i=2;i*i<=1000;i++)
	{
		int now=i*i;
		while(now<=1000)
		{
			val[now]=1;
			now*=i;
		}
	}
	scanf("%d",&x);
	for(int i=x;i>=1;i--)
	{
		if(val[i])
		{
			printf("%d\n",i);break;
		}
	}
	return 0;
}


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

int main() {
    int x[3];
    for (int i = 0; i < 3; i++) {
        cin >> x[i];
    }
    sort(x, x + 3);
    int count = 0;
    for (int i = 0; x[0] + 2 <= x[2]; i++) {
        x[0] += 2;
        count++;
    }
    for (int i = 0; x[1] + 2 <= x[2]; i++) {
        x[1] += 2;
        count++;
    }
    if (2 * x[2] - x[0] - x[1] == 1) count += 2;
    if (2 * x[2] - x[0] - x[1] == 2) count += 1;
    cout << count << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int fie[1001][1001];

int main(void){
	int a=1;
	for(int i=0;i<1000;i++){
		for(int j=0;j<=i;j++){
			fie[i][j]=a++;
		}
	}
	scanf("%d",&n);
	for(int i=1;i<=1000;i++){
		if(i*(i-1)==n*2){
			printf("Yes\n%d\n",i);
			for(int j=0;j<i;j++){
				printf("%d",i-1);
				int sx=0,sy=j;
				int dx=1,dy=0;
				if(j+1==i){
					dy=1;
					sy=0;
				}
				for(int k=0;k<i-1;k++){
					printf(" %d",fie[sy][sx]);
					if(sx==sy && dy==0){
						dx=0;
						dy=1;
					}
					sx+=dx;
					sy+=dy;
				}
				printf("\n");
			}
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 5248
#include<cstdio>

int main(void){
    int w=0,h=0,x=0,y=0,r=0;
    
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
    int up=y+r;
    int down=y-r;
    int left=x-r;
    int right=x+r;
    
    if(up<=h){
        if(down>=0){
            if(left>=0){
                if(right<=w) {
                    printf("Yes\n"); return 0;
                }
            }
        }
    }
    printf("No\n");
    return 0;
    
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN = 200007;
const LL LOG = 60;

LL last[MAXN];
LL a[MAXN];
LL exist[MAXN];

LL jump[MAXN][LOG];
LL dist[MAXN][LOG];

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

    LL n, m;
    cin >> n >> m;
    LL moves = n*m-1;

    for (LL i = 0; i < n; i++) cin >> a[i];

    for (LL i = n-1; i >= 0; i--) last[a[i]] = i+n;

    for (LL i = n-1; i >= 0; i--) {
        jump[i][0] = (1+last[a[i]])%n;
        dist[i][0] = 1+last[a[i]]-i;
        assert(dist[i][0] >= 0);
        last[a[i]] = i;
    }

    for (LL k = 1; k < LOG; k++) {
        for (LL i = 0; i < n; i++) {
            jump[i][k] = jump[jump[i][k-1]][k-1];
            dist[i][k] = dist[i][k-1] + dist[ jump[i][k-1] ][k-1];
            dist[i][k] = min(dist[i][k], moves+1);
        }
    }

    LL i = 0;
    for (LL k = LOG-1; k >= 0; k--) {
        if (dist[i][k] <= moves) {
//            cout << "at " << i << " " << dist[i][k] << endl;
            moves -= dist[i][k];
            i = jump[i][k];
        }
    }

//    cout << "at " << i << " rem moves: " << moves << endl;

    vector< LL >ans;
    ans.push_back(a[i]);
    exist[a[i]] = 1;
    while (moves--) {
        i = (i+1)%n;
        if (exist[a[i]]) {
            while (exist[a[i]]) {
                exist[ans.back()] = 0;
                ans.pop_back();
            }
        } else {
            ans.push_back(a[i]);
            exist[a[i]] = 1;
        }
    }

    for (LL x : ans) cout << x << " ";

    return 0;
}


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

int main() {
  int n,ans=0;
  cin >> n;
  vector<int> num(n);
  for(int i=0; i<n; i++) cin >> num[i];
  for(int i=1; i<n-1; i++) {
    if(num[i-1] < num[i] && num[i] < num[i+1]) ans++;
    else if(num[i+1] < num[i] && num[i] < num[i-1]) ans++;
  }
  cout << ans << endl;
}

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

int n,m,X,tot=0,root,r[100005];
int lch[8000005],rch[8000005];
int minv[8000005],maxv[8000005];
int set[8000005],add[8000005];
struct Question{
    int t,a,id;
}q[100005];
int ans[100005];

bool comp(Question a,Question b){return a.t<b.t;}

int newnode(int &o,int x,int y){
    o=++tot,minv[o]=x,maxv[o]=y,set[o]=-1;
}

void pushup(int o){
    minv[o]=min(minv[lch[o]],minv[rch[o]]);
    maxv[o]=max(maxv[lch[o]],maxv[rch[o]]);
}

void pushdown(int o,int l,int r){
    int mid=l+r>>1;
    int &lc=lch[o],&rc=rch[o];
    if(!lc)newnode(lc,l,mid-1);
    if(!rc)newnode(rc,mid,r-1);
    if(~set[o]){
        minv[lc]=maxv[lc]=set[lc]=set[o];
        minv[rc]=maxv[rc]=set[rc]=set[o];
        add[lc]=add[rc]=0,set[o]=-1;
    }
    if(add[o]){
        minv[lc]+=add[o],maxv[lc]+=add[o],add[lc]+=add[o];
        minv[rc]+=add[o],maxv[rc]+=add[o],add[rc]+=add[o];
        add[o]=0;
    }
}

void Sub(int &o,int l,int r,int x){
    if(o==0)newnode(o,l,r-1);
    if(maxv[o]<=x)
        maxv[o]=minv[o]=add[o]=set[o]=0;
    else if(minv[o]>=x)
        maxv[o]-=x,minv[o]-=x,add[o]-=x;
    else{
        pushdown(o,l,r);
        int mid=l+r>>1;
        Sub(lch[o],l,mid,x),Sub(rch[o],mid,r,x);
        pushup(o);
    }
}

void Add(int &o,int l,int r,int x){
    if(o==0)newnode(o,l,r-1);
    if(minv[o]>=X-x)
        maxv[o]=minv[o]=set[o]=X,add[o]=0;
    else if(maxv[o]<=X-x)
        maxv[o]+=x,minv[o]+=x,add[o]+=x;
    else{
        pushdown(o,l,r);
        int mid=l+r>>1;
        Add(lch[o],l,mid,x),Add(rch[o],mid,r,x);
        pushup(o);
    }
}

int query(int o,int l,int r,int x){
    if(o==0)newnode(o,l,r-1);
    if(r-l==1)return minv[o];
    pushdown(o,l,r);
    int mid=l+r>>1;
    if(x<mid)return query(lch[o],l,mid,x);
    else return query(rch[o],mid,r,x);
}

int main(){
    scanf("%d%d",&X,&n);
    for(int i=1;i<=n;i++)scanf("%d",r+i);
    r[n+1]=1e9;
    scanf("%d",&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&q[i].t,&q[i].a);
        q[i].id=i;
    }
    sort(q+1,q+m+1,comp);
    for(int i=0,j=1,rev=0;i<=n;i++,rev^=1){
        while(j<=m&&q[j].t<=r[i+1]){
            int tmp=query(root,1,X+1,q[j].a);
            if(rev)tmp=min(X,tmp+q[j].t-r[i]);
            else tmp=max(0,tmp-q[j].t+r[i]);
            ans[q[j++].id]=tmp;
        }
        if(j>m)break;
        int tmp=r[i+1]-r[i];
        if(rev)Add(root,1,X+1,tmp);
        else Sub(root,1,X+1,tmp);
    }
    for(int i=1;i<=m;i++)printf("%d\n",ans[i]);
} 

Measured memory_bytes: 131456
n = int(input())
s = input()

count = {"R":0,"G":0,"B":0}
for c in s:
  count[c] += 1

r,g,b = count.values()
ans = r*g*b
for i in range(1,(n-1)//2+1):
  for rgb in zip(s,s[i:],s[i*2:]):
    if len(set(rgb)) == 3:
      ans -=1
print(ans)

Measured memory_bytes: 9176
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "tmp.cpp"

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

  int n;
  ll k;
  cin >> n >> k;
  vi next(n);
  REP(i, n) {
    cin >> next[i];
    next[i]--;
  }
  if (k < n) {
    int ans = 0;
    REP(i, k) { ans = next[ans]; }
    cout << ans + 1 << endl;
    return 0;
  }

  vi d(n, n + 1);
  int cur = 0;
  int cnt = 0;
  while (d[cur] == n + 1) {
    d[cur] = cnt;
    cur = next[cur];
    cnt++;
  }
  int loop = cnt - d[cur];
  k -= d[cur];
  k %= loop;
  REP(i, k) { cur = next[cur]; }
  cout << cur + 1 << endl;

  return 0;
}


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

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  ll n,k; cin >> n >> k;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    int a = i % k;
    int aa = ((-a * 2) % k + k)%k;
    if(aa % k == 0) {
      ll r = (i + n) / k;
      r -= i / k;
      ans += r * r;
    }
  }
  cout << ans << endl;
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a[] = new long[n + 1];
        Arrays.fill(a, 1);
        for (int i = 2; i <= n; i++) {
            int j = 1;
            while (i * j <= n) {
                a[i * j]++;
                j++;
            }
        }
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += i * a[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 116152
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 1000000000
int main()
{
    int n,k,i,j;
    scanf("%d %d",&n,&k);
    lli a[n];
    for(i=0;i<n;i++)
    scanf("%lld",&a[i]);
    lli ans[n];
    ans[n-1]=0;
    for(i=n-2;i>=0;i--)
    {
        ans[i]=INF;
        for(j=1;j<=k;j++)
        {
            if(i+j<n)
            ans[i]=min(ans[i],ans[i+j]+abs(a[i+j]-a[i]));
        }
    }
    printf("%lld",ans[0]);
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int h, w, n, a[100000], ans[100][100];
bool us[100][100];

int main() {
	cin >> h >> w >> n;
	rep(i,n) cin >> a[i];
	
	// 左上から始まって壁にぶつかる度にぐるぐる回りながら真ん中に進めば絶対途切れない
	int i = 0, j = 0, x = 0, y = 0, d = 0;
	while (i<n) {
		// 答えの配列を埋める
		ans[x][y] = i+1;
		// iのj個目を埋めました
		j++;
		// iをa[i]個全部埋めたなら次の要素(i+1)に移る
		if (j==a[i]) {
			i++, j = 0;
		}
		// 壁を作っとく
		us[x][y] = true;
		// 盤からはみ出そう/壁に当たりそうな場合方向を90度回転
		if ((x+dx[d]<0 || x+dx[d]>=w || y+dy[d]<0 || y+dy[d]>=h) || us[x+dx[d]][y+dy[d]]) d++;
		if (d==4) d = 0;
		// 前に1歩進む
		x += dx[d], y += dy[d];
	}
	rep(yy,h) rep(xx,w) cout << ans[xx][yy] << (xx==w-1 ? '\n' : ' ');
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int money_min = 100000000;//金額の最小値をここに求める
    	int ans = -1;//
    	int all_XormorethanX = 1;

    	//N,M,Xの読み込み処理を行う
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int C[] = new int[N+1];
		int A[][] = new int[N+1][M+1];
		int skill_sum[] = new int[M+1];
		int money_sum = 0;

		//CとAの読み込み処理
		for(int i=1;i<=N;i++){
			C[i]=sc.nextInt();
			for(int j=1;j<=M;j++){
				A[i][j]=sc.nextInt();
			}
		}

		//bit全探索処理、探索すると同時に条件を満たすものについては最小値を更新する
		for (int i=0; i<(1<<N); i++) {//ex. 1<<3=1000		
			//条件を満たすかどうかの判定処理
			//1.判断材料を整える処理
			//初期化処理
		    for(int k=1;k<=M;k++){
		        skill_sum[k] = 0;		
		    }

		    for (int j = 0; j < N; j++) {
		        if ((1 & (i >> j)) == 1){//bitからj(0~)桁目を抽出する
		        	for(int k=1;k<=M;k++){
		        		skill_sum[k] = skill_sum[k] + A[j+1][k];

		        	}
		    	}
			}

		    //2.整えた判断材料に対する判断処理
		    all_XormorethanX = 1;//初期化    	
		    for(int l=1;l<=M;l++){
		    	if (skill_sum[l]<X){
		    		all_XormorethanX = -1;
		    		break;
		    	}
		    }
		    //条件を満たす場合は金額の最小値を更新しておく
		    //金額の合計を求める
		    if (all_XormorethanX==1) {
		    	money_sum = 0;
		    	for (int j = 0; j < N; j++) {
		        	if ((1 & (i >> j)) == 1) {//bitからj(0~)桁目を抽出する
		        		money_sum = money_sum + C[j+1];
		        	}
		    	}
		    //金額の合計を最小値に更新する
		    money_min = Math.min(money_sum,money_min);
		    }
		}
		if (money_min==100000000) {
			System.out.println(ans);
		}
		else{
			ans=money_min;
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 28348
package main

import (
	"fmt"
	"strconv"
)

func main() {

	var ans int = 0

	var n int
	fmt.Scan(&n)

	//全探索
	for i:= 1 ; i <=  n ; i++ {
		keta := strconv.Itoa(i)
		if(len(keta) % 2 == 1){
			ans++
		}
	}

	fmt.Println(ans)
	
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int N,L;
string arr[101];
int main()
{
	scanf("%d %d",&N,&L);
	for(int i=0;i<N;++i)
		cin>>arr[i];
	sort(arr,arr+N);
	for(int i=0;i<N;++i)
		printf("%s",arr[i].c_str());
	printf("\n");
}

Measured memory_bytes: 256
[n,q] = [int(i) for i in input().split()]

i = 0
queue = []
for j in range(n):
	queue.append([])

while i < q:
	query = [int(i) for i in input().split()]
	if query[0] == 0:
		queue[query[1]].append(query[2])
	
	elif query[0] == 1:
		if len(queue[query[1]]) == 0:
			pass
		else:
			print(queue[query[1]][0])
		
	else:
		if len(queue[query[1]]) == 0:
			pass
		else:
			del queue[query[1]][0]
			
	i += 1
		



Measured memory_bytes: 13448
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

int ab[2050];

int main(void)
{
	int n;
	
	for (int a = 0; a <= 1000; a++){
		for (int b = 0; b <= 1000; b++){
			ab[a + b]++;
		}
	}

	while (cin >> n){
		if (cin.eof()) break;

		int ret = 0;
		for (int cd = 0; cd <= 2000; cd++){
			if (n - cd >= 0 && n - cd <= 2000){
				ret += ab[cd] * ab[n - cd];
			}
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1172
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a: bigint = 0n;
    let b: bigint = 0n;
    let c: bigint = 0n;
    let d: bigint = 0n;
    let ans: string = "";
    // init
    [a, b, c, d] = input.shift().split(" ").map(x => BigInt(x));
    // solve
    let val: bigint = a * c;
    if (val < a * d) val = a * d;
    if (val < b * c) val = b * c;
    if (val < b * d) val = b * d;
    ans = String(val).replace("n", "");
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29640
#include <stdio.h>


int main() {
int i,j;
	int n, number[100];

	long long int dp[100][21] = {};


	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d",&number[i]);

	dp[0][number[0]] = 1;

	for (i = 1; i < n - 1; i++) {
		for (j = 0; j <= 20; j++) {

			if (j + number[i] <= 20) dp[i][j] += dp[i - 1][j + number[i]];

			if (j - number[i] >= 0) dp[i][j] += dp[i - 1][j - number[i]];
		}
	}

	
	printf("%lld\n",dp[n - 2][number[n - 1]]);
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n; string s;
    cin>>n>>s;
    ll sum=0;
    ll r=0,g=0,b=0;
    rep(i,n){
        if(s[i]=='R')r++;
        if(s[i]=='G')g++;
        if(s[i]=='B')b++;
    }
    sum=r*g*b;
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            ll k=j*2-i;
            if(k>=n||i==j)continue;
            if(s[i]!=s[j]&&s[j]!=s[k]&&s[k]!=s[i])sum--;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3604
#!/usr/bin/python
# coding: utf-8

from sys import stdin

def solve(a):
  n = len(a)
  xmemo = [0 for i in range(n)]  # player X の手番での最適スコア
  ymemo = [0 for i in range(n)]  # player Y 　　　〃

  # 自分がj (< i) 枚目, 相手がi枚目を持っている
  for i in range(n - 2, -1, -1):
    # 自分が取り切ったときのスコア
    f = abs(a[i] - a[n - 1])
    # j, i の差が何枚でも同じ
    xmemo[i] = max([f] + [ymemo[jj] for jj in range(i + 1, n - 1)])
    ymemo[i] = min([f] + [xmemo[jj] for jj in range(i + 1, n - 1)])

  return xmemo[1]

N, Z, W = map(int, stdin.readline().split())
a       = map(int, stdin.readline().split())
if len(a) != N: raise

# Z, Wを山の先頭に置く
a = [Z, W] + a

print(solve(a))


Measured memory_bytes: 2928
#include <bits/stdc++.h>
using namespace std;
  
int main() {
    int N,M;
    cin >> N >> M;
    vector <int> data(M*2);
    
    
    for (int i=0;i<M*2;i++) {
        cin >> data.at(i);
    }
    
    
    for (int n=1;n<N+1;n++) {
    int count=0;    
    for (int i=0;i<data.size();i++) {
        if(data.at(i) == n){
            count++;
        }
    }
    cout << count << endl;
    
    }
    
    
    
   }

 

Measured memory_bytes: 3636
s = input()

N = [i for i in range(len(s)-1)]  # N = bit探索する桁数
# Nの要素の全組み合わせが出力
sum = 0
for i in range(1 << len(N)):
    output = []
    tmp = s[0]
    for j in range(len(N)):
        if ((i >> j) & 1) == 1:
            tmp += "+" + s[j + 1]
            output.append(j)  # このjが今回探索するindexの1つ
        else:
            tmp += s[j+1]
    # print(output)
    # print(tmp)
    sum += eval(tmp)
print(sum)

Measured memory_bytes: 3064
n, m = map(int, input().split())
sa = set()
sb = set()

for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('IMPOSSIBLE' if len(sa & sb) == 0 else 'POSSIBLE')


Measured memory_bytes: 57944
#include<bits/stdc++.h>
using namespace std;
int main(){
vector<int>a(3);
  for(int i = 0; i < 3; i++)
    cin >> a[i];
  sort(a.begin(),a.end());
  int cnt = 0;
  if(a[0] == a[1])
    cnt++;
  if(a[1] == a[2])
    cnt++;
  cout << 3 - cnt << endl;
  
}

Measured memory_bytes: 256
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
       ll a,b,c;
       cin>>a>>b>>c;
       if((a+b-c)*(a+b-c)>4*a*b&&(c-a-b)>0)
        cout<<"Yes";
    else
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import bisect

INF = 2 ** 60

A, B, Q = map(int, input().split())
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    a, c = b - 1, d - 1
    res = INF
    for S in s[a:b+1]:
        for T in t[c:d+1]:
            d1 = abs(S - x) + abs(T - S)
            d2 = abs(T - x) + abs(T - S)
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 12804
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const int inf=1e9+7;
const int mod=1e9+7;

const int maxn=1e5+5;

ll int dp[maxn][14];


int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    string str;
    
    while(cin>>str)
    {
    	memset(dp,0,sizeof(dp));
    	
    	if(str[0]!='?')
    		dp[0][(str[0]-'0')%13]=1;
    	else
    	{
    		for(int i=0;i<10;i++)
    			dp[0][i]=1;
		}
    	
    	for(int k=1;k<str.size();k++)
    	{
    		if(str[k]=='?')
    		{
    			for(int i=0;i<10;i++)//枚举放数字 
    			{
    				for(int j=0;j<13;j++)
    				{
    					dp[k][(j*10+i)%13]+=dp[k-1][j];
    					dp[k][(j*10+i)%13]%=mod;
					}
				}
			}
			else
			{
				for(int i=0;i<13;i++)
				{
					dp[k][(i*10+(str[k]-'0'))%13]+=dp[k-1][i];
					dp[k][(i*10+(str[k]-'0'))%13]%=mod;
				}
			}
		}
    	
    	cout<<dp[str.size()-1][5]<<endl;
    	
	}

    return 0;
 } 

Measured memory_bytes: 11472
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

ll AN(ll A, ll N){
  if (N == 0){
    return 1;
  }else if(N % 2 == 0){
    return (AN((A * A) % nmax, N / 2)) % nmax;
  }else{
    return (A * (AN((A * A) % nmax, N / 2))) % nmax;
  }
  
}

ll nCk(ll N, ll K){
  K = min(K, N - K);
  ll ans = 1;
  for (int i = 0; i < K; i++){
    ans = (ans * (N - i)) % nmax;
    ans = ans * AN(i + 1, nmax - 2) % nmax;
  }
  return ans;
}

int main(){
  int X, Y; cin >> X >> Y;

  if ((2 * X - Y) < 0 || (2 * X - Y) % 3 != 0){
    cout << 0 << endl;
  }else if((-1 * X + 2 * Y) < 0 || (-1 * X + 2 * Y) % 3 != 0){
    cout << 0 << endl;
  }else{
    int K = (-1 * X + 2 * Y) / 3;
    int L = (2 * X - Y) / 3;

    cout << nCk(K + L, K) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    ll x;
    cin >> x;
    double s = 100;
    ll cnt = 0;
    while (true) {
        cnt++;
        s *= 1.01;
        s = floor(s);
        if (s >= x) {
            cout << cnt << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
A_B = [list(map(int, input().split())) for _ in range(N)]
A_B.sort(key=lambda x: x[1])
t = 0
for a_b in A_B:
    t += a_b[0]
    if t > a_b[1]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 53724
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() {
  int a, b, c, res;
  cin >> a >> b >> c;
  res = 0;
  for (int i = a; i <= b; i++)
  {
    if (c % i == 0) res++;
  }

  cout << res << "\n";
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
main(){
  string A,B;
  cin>>A>>B;
  if(A==B){
    cout<<"EQUAL"<<endl;
    return 0;
  }
  if(A.size()!=B.size()){
    cout<<(A.size()>B.size()?"GREATER":"LESS")<<endl;
    return 0;
  }
  for(int i=0;i<A.size();++i){
    if(A[i]==B[i])continue;
    cout<<(A[i]>B[i]?"GREATER":"LESS")<<endl;
    return 0;
  }
}


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

import math

from operator import mul
from functools import reduce
def combinations_count(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

ans_x = 0
c = combinations_count(N*M-2, K-2)
#for i in range(1, N+1):
#    ans_x += N*(N+1)//2-i*(i+1)//2-i*(N-i)
    #for j in range(i+1, N+1):
    #    ans_x += j-i
ans_x = (N*N*(N+1) + N*(N+1)*(2*N+1)//6 - (2*N+1)*N*(N+1)//2)//2
ans_x = M*M*ans_x*c

ans_y = 0
c = combinations_count(N*M-2, K-2)
#for i in range(1, M+1):
#    ans_y += M*(M+1)//2-i*(i+1)//2-i*(M-i)
    #for j in range(i+1, M+1):
    #    ans_y += j-i
ans_y = (M*M*(M+1) + M*(M+1)*(2*M+1)//6 - (2*M+1)*M*(M+1)//2)//2
ans_y = N*N*ans_y*c
ans = (ans_x+ans_y)%(10**9+7)
print(ans)

Measured memory_bytes: 64164
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

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

Measured memory_bytes: 256
using System;
using System.IO;

class MainClass
{
    static void Main()
    {
        string line;
        line = Console.ReadLine();

        string[] tokens = line.Split(' ');
        int[] ConvertedInt = new int[2];

        for (int i = 0; i < 2; i++)
        {
            ConvertedInt[i] = int.Parse(tokens[i]);
        }
        int a = ConvertedInt[0];
        int b = ConvertedInt[1];
        Console.WriteLine(division(a,b));
    }

    static private int division(int a,int b)
    {
        int r = 1;
        int result = 0;

        if (a > b)
        {
            r = a % b;
            while(r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            result = b;

        }
        else
        {
            r = b % a;
            while (r != 0)
            {
                b = a;
                a = r;
                r = b % a;
            }
            result = a;
        }

        return result;
    }
}


Measured memory_bytes: 18016
#include <iostream>

using namespace std;
int a[100005]={0};
int main(int argc, char *argv[])
{
    int n,t;
    scanf("%d",&n);
    int maxs=0;
    for(int i=0;i<n;i++){
        scanf("%d",&t);
        if(t==0){
            a[t]++,a[t+1]++;
            maxs=maxs<a[t]?a[t]:maxs;
            maxs=maxs<a[t+1]?a[t+1]:maxs;
        }
        else{
            a[t-1]++,a[t]++,a[t+1]++;
            maxs=maxs<a[t]?a[t]:maxs;
            maxs=maxs<a[t+1]?a[t+1]:maxs;
            maxs=maxs<a[t-1]?a[t-1]:maxs;
          }

    }
    printf("%d\n",maxs);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    // if(a > b)swap(a,b);
    ll ans = 0;

    if(abs(a - b) % 2 == 0){
        ans = abs(a - b) / 2;
    }else{
        ll tmp1 = a - 1;
        ll aa = 1;
        ll bb = b - (a - 1);
        tmp1++;
        bb--;
        tmp1 += (abs(b - a) / 2);
        ll tmp2 = n - b;
        aa = a + (n - b);
        bb = n;
        aa++;
        tmp2++;
        tmp2 += abs(b - a) / 2;
        ans = min(tmp1, tmp2);
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r,g;
  cin >> r >> g;
  cout << 2*g -r << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <utility>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<string, int> P;
bool check(string &pazzle) {
	bool same = 1;
	for (int i = 0; i < 9; i++) {
		if (pazzle[i] != pazzle[0]) same = 0;
	}
	for (int i = 9; i < 12; i++) {
		if (pazzle[i] != pazzle[9]) same = 0;
	}
	for (int i = 12; i < 15; i++) {
		if (pazzle[i] != pazzle[12]) same = 0;
	}
	for (int i = 15; i < 18; i++) {
		if (pazzle[i] != pazzle[15]) same = 0;
	}
	for (int i = 18; i < 21; i++) {
		if (pazzle[i] != pazzle[18]) same = 0;
	}
	for (int i = 21; i < 30; i++) {
		if (pazzle[i] != pazzle[21]) same = 0;
	}
	return same;
}
string op(string pazzle, int n) {
	if (n == 0) {
		swap(pazzle[12], pazzle[17]);
		swap(pazzle[9], pazzle[11]);
		swap(pazzle[8], pazzle[23]);
		swap(pazzle[7], pazzle[22]);
		swap(pazzle[6], pazzle[21]);
	}
	else if (n == 1) {
		swap(pazzle[14], pazzle[15]);
		swap(pazzle[18], pazzle[20]);
		swap(pazzle[0], pazzle[27]);
		swap(pazzle[1], pazzle[28]);
		swap(pazzle[2], pazzle[29]);
	}
	else if (n == 2) {
		swap(pazzle[9], pazzle[20]);
		swap(pazzle[15], pazzle[17]);
		swap(pazzle[0], pazzle[23]);
		swap(pazzle[3], pazzle[26]);
		swap(pazzle[6], pazzle[29]);
	}
	else {
		swap(pazzle[11], pazzle[18]);
		swap(pazzle[12], pazzle[14]);
		swap(pazzle[2], pazzle[21]);
		swap(pazzle[5], pazzle[24]);
		swap(pazzle[8], pazzle[27]);
	}
	return pazzle;
}
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		string pazzle;
		for (int j = 0; j < 30; j++) {
			int x;
			scanf("%d", &x);
			pazzle += ('0' + x);
		}
		queue<P> Q;
		Q.push(P(pazzle, 0));
		set<string> S;
		S.insert(pazzle);
		while (!Q.empty()) {
			P p = Q.front(); Q.pop();
			if (check(p.first)) {
				printf("%d\n", p.second);
				break;
			}
			string np;
			for (int i = 0; i < 4; i++) {
				np = op(p.first, i);
				if (S.find(np) == S.end()) {
					S.insert(np);
					Q.push(P(np, p.second + 1));
				}
			}
		}
	}
}

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

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> H;

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

    for (int i = N - 2; i > 0; --i)
    {
        if (H[i] - 1 == H[i + 1])
        {
            H[i] -= 1;
        }
        else if (H[i] > H[i + 1])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

ll f(ll num){
	if(num==1) return 1;
	ll res = f(num/2);
	return 2*res+1;
}

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

    ll H;
    cin >> H;

    cout << f(H) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> black(N + 1, 0), white(N + 1, 0);

  for(int i = 0; i < N; i++) {
    black[i + 1] = black[i];
    white[i + 1] = white[i];
    if(S[i] == '#') black[i + 1]++;
    else white[i + 1]++;
  }
  int ans = INT_MAX;
  for(int i = 0; i < N + 1; i++) {
    ans = min(ans, black[i] + white[N] - white[i]);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> vx(n, 0);
  vector<int> vy(m, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> vx[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> vy[i];
  }

  for (int i = x+1; i <= y; i++) {
    bool flag = true;
    for (int j = 0; j < n; j++) {
      if(i <= vx[j]){
        flag = false;
        break;
      }
    }
    for (int j = 0; j < m; j++) {
      if(i > vy[j]){
        flag = false;
        break;
      }
    }
    if(flag){
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=2;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n,ans,b;
  ans=0;
  cin>>n;
  Fr(i,1000000){
    b=i;
    while(n%b==0){
      ++ans;
      n=n/b;
      b=b*i;
    }
    while(n%i==0){
      n=n/i;
    }
  }
  if(n!=1){
    ++ans;
  }
  cout<<ans;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N >> M;
  int s[N][2];
  int p[M][2];
  for(int i=0;i<N;i++){cin >> s[i][0] >> s[i][1];}
  for(int i=0;i<M;i++){cin >> p[i][0] >> p[i][1];}
  
  for(int i=0;i<N;i++){
    int p_min;
    int d_min = pow(10,9);
    for(int j=0;j<M;j++){
      int d = abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1]);
      if(d<d_min){
        p_min = j+1;
        d_min = d;
      }
    }
    cout << p_min << endl;
    
  }
}

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


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

  ll n;
  cin >> n;
  deque<char> ans;
  // n--;
  while(n>0){
    n--;
    char p = 'a' + (n%26);
    n/=26;
    ans.push_front(p);
  }
  rep(i,ans.size()){
    cout << ans[i];
  }
  cout << endl;
  return 0;
    

}


Measured memory_bytes: 3656
N, M = map(int, input().split())
KS = [list(map(int, input().split())) for _ in range(M)]
P = list(map(int, input().split()))

switch = []
for i in range(2**N):
    tmp = []
    for j in range(N):
        if (i >> j) & 1:
            tmp.append(j+1)
    switch.append(tmp)

cnt = 0
for s in switch:
    judge = True
    for idx,ks in enumerate(KS):
        kcnt = 0
        for k in ks[1:]:
            kcnt += s.count(k)
        if kcnt % 2 == P[idx]:
            continue
        judge = False
        break
    if judge:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int K; cin>>K;
	int X; cin>>X;
	ote(K*500>=X?"Yes":"No");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
long long pow(int x,int y){
  long long z = 1;
  while(y){
    z *= x;y--;
  }
  return z;
}
int main(){
  string s;cin >> s;
  if(s.size()==1){
    cout << int(s[0]-'0') << endl;
    return 0;
  }
  int n = s.size(),num[n],i,j,c,b[n] = {};b[0] = -1,b[n-1] = 1;long long ans = 0;
  for(i=0;i<n;i++) num[i] = s[i]-'0';
  for(i=0;i<pow(2,n-1);i++){
    b[0]++;
    for(j=0;j<n-1;j++){
      if(b[j]==2){
  		b[j+1]++;b[j]=0;
      }
    }
    for(j=0;j<n;j++){
      c = j;
      while(b[c]==0) c++;
      ans += num[j]*pow(10,c-j);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256