akhauriyash/Code-Regression huggingface dataset:
n = int(input())
l = list(map(int, input().split()))
k = []
for i in range(n-1):
  k.append(l[i+1] - l[i])
e = 0;ans = 0
for i in range(n-1):
  if k[i] <1:
    e+=1
  else:
    ans = max(ans,e)
    e = 0
ans = max(e,ans)
print(ans)

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

typedef long long int ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> Pair;

#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mk make_pair
#define out(x) cout << (x) << endl;
#define DU(x) cerr << #x << " = " << (x) << endl;

template <typename _Ty>ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "[]";return ostr;}ostr << "[" << v.front();for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}ostr << "]";return ostr;}

int p[2001][2001];
int main() {
    int N, K;
    cin >> N >> K;

    p[0][0] = 1;
    REP(i, 1, 2001) rep(j, i + 1) if(j == 0 || j == i) {
        p[i][j] = 1;
    } else {
        p[i][j] = (int)(((ll)p[i - 1][j - 1] + (ll)p[i - 1][j]) % MOD);
    }

    REP(i, 1, K + 1) out(((ll)p[N - K + 1][i] * (ll)p[K - 1][i - 1]) % MOD);
    return 0;
}

Measured memory_bytes: 14976
#include <stdio.h>

int main(void){
    int m,d;
    int i,j,k;
    int d1,d10;
    int count=0;

    scanf("%d %d",&m,&d);

    for(i=22;i<=d;i++){
        d1=i/10;
        d10=i%10;
        if(d1>=2 && d10>=2){
            if(d1*d10<=m){
                count++;
            }
        }
    }

    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [1, _] = 1
solve [_, 1] = 1
solve [h, w] = let hw = h * w
               in hw `div` 2 + if odd hw then 1 else 0


Measured memory_bytes: 508
import java.io.*;
import java.util.Arrays;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while (!(buf = br.readLine()).equals("0")) {
				int n = Integer.parseInt(buf);
				int x = n/2;
				int y = n/2+1;
				int magic[][] = new int[n][n];
				for (int i=0;i<n;i++) Arrays.fill(magic[i],0);
				for (int i=1;i<=Math.pow(n,2);i++) {
					if (magic[y][x]==0) {
						magic[y][x] = i;
					}
					else {
						while (magic[y][x]>0) {
							x = ((x+n)-1)%n;
							y = (y+1)%n;
						}
						magic[y][x] = i;
					}
					x = (x+1)%n;
					y = (y+1)%n;
				}
				for (int i=0;i<n;i++) {
					for (int j=0;j<n;j++) System.out.printf("%4d",magic[i][j]);
					System.out.println("");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 19756
/*
 * main.c
 *
 *  Created on: 2019/07/07
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

typedef unsigned long long int uint64_t;


int main()
{
	uint64_t L = 0, R = 0, ans = 2019, i = 0, j = 0, k = 0;
	scanf("%llu %llu", &L, &R);
	for(i = L; i <= (L+(2019*2)); i++) {
		if(R < i) {
			break;
		}
		for(k = i+1; k <= (L+(2019*2)); k++) {
			if(R < k) {
				break;
			}
			j = (i * k)%(uint64_t)2019;
	        if(j < ans) {
	        	ans = j;
				//printf("%llu %llu\n", i, k);
	        }
		}
	}
	printf("%llu\n",ans);
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
 
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);
 
typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;
 
template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }
 
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
    if (b == 0) {
        return 1;
    }
    if (b == 1) {
        return a;
    }
    ll ans = pow(a, b / 2);
    ans *= ans;
    ans *= b % 2 == 1 ? a : 1;
    return ans;
}
 
namespace SOLVE {
    struct edge {
        ll v1, v2, weight;
    };
 
    VI id;
 
    ll parent(ll a) {
        if (id[a] == a) {
            return a;
        }
        id[a] = parent(id[a]);
        return id[a];
    }
 
    void unite(ll a, ll b) {
        id[parent(a)] = parent(b);
    }
 
    int query(ll a, ll b) {
        return (parent(a) == parent(b));
    }
 
    bool comp(edge a, edge b) {
        return a.weight < b.weight;
    }
 
    void main() {
        ll V, E, a, b, c;
        cin >> V >> E;
 
        vector<edge> edges;
 
        REP(i, 0, E) {
            cin >> a >> b >> c;
            edge x;
            x.v1 = a;
            x.v2 = b;
            x.weight = c;
            edges.push_back(x);
        }
 
        sort(edges.begin(), edges.end(), comp);
 
        id.resize(V);
        REP(i, 0, V) {
            id[i] = i;
        }
 
        ll ans = 0;
        for (edge e : edges) {
            if (!query(e.v1, e.v2)) {
                // join them
                unite(e.v1, e.v2);
                // cout << e.v1 << ' ' << e.v2 << ' ' << e.weight << endl;
                ans += e.weight;
 
            }
        }
        cout << ans << endl;
    }
}
 
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int t;
    //    in(t);
    t = 1;
    while (t--) {
        SOLVE::main();
 
    }
 
    return 0;
}



Measured memory_bytes: 6020
import java.util.*;
import java.math.*;

class Main{
    public static void cout(String str)
    {
        System.out.println(str);
    };
    public static void main(String args[])
    {
        Scanner cin=new Scanner(System.in);
        String a="",b="",str;
        int n;
        n=cin.nextInt();
        cin.nextLine();
        str=cin.nextLine();
        for(int i=0;i<n/2;i++)
        {
            a=a+str.charAt(i);
        }
        if(str.equals(a+a))
            cout("Yes");
        else cout("No");
    }
};


Measured memory_bytes: 22868
#include <stdio.h>

int main() {
  double n, m, d;
  scanf("%lf %lf %lf", &n, &m, &d);

  if(d == 0) {
    double res = (1.0 / n) * (m - 1);
    printf("%.10lf\n", res);
  } else {
    double res = (1.0 / (n * n)) * (2 * n - 2 * d) * (m - 1);
    printf("%.10lf\n", res);
  }

  return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
def f(x):
  c=[x[i-1]^x[i]for i in range(1,n)]
  k=[x[1:].count(1)%2]
  for i in c:
    k.append(k[-1]^i)
  return k
for i in range(31):
  t=1<<i
  x=[]
  for j in a:
    if t&j:x.append(1)
    else:x.append(0)
  m=f(x)
  for j in range(n):ans[j]+=t*m[j]
print(*ans)

Measured memory_bytes: 184388
#include <iostream>
#include <string>

using namespace std;

int Function(int x, int a, int b) {

	int z = x;
	int y = 0;

	while (x)
	{
		y += x % 10;
		x /= 10;
	}

	if (a <= y && y <= b) {
		return z;
	}

	return 0;
}


int main() {

	int N, A, B;
	cin >> N >> A >> B;

	int R = 0;
	for (int i = 1; i <= N; ++i)
	{
		R += Function(i, A, B);
	}

	cout << R << endl;

	return 0;
}

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

int main() {
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
    
    if ( N-K >=0 ){
      
    cout << K*X + ( N-K )*Y << endl;
    
  }
  
    else if ( N-K < 0 ){
          
    cout << N*X << endl;
      
  }
  
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define ll unsigned long long
using namespace std;
const int N=200100;
ll A[N],ans=1e18;
int n,X;
int main()
{
	scanf("%d%d",&n,&X);
	for(int i=1;i<=n;i++) scanf("%llu",&A[i]),A[i]+=A[i-1];
	for(int K=1;K<=n;K++)
	{
		ll res=0,bs=3;
		for(int i=n;i>=1;i-=K,bs+=2)
			res+=(A[i]-A[max(0,i-K)])*bs;
		res+=(A[n]-A[max(0,n-K)])*2;
		ans=min(ans,res+1ll*(n+K)*X);
	}
	printf("%llu\n",ans);
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] AB = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
            // List<long> kl=new List<long>(hs.Keys);
            // kl.Sort();
            // foreach(long k in kl){
            //     s[1]-=hs[k];
            //     if(s[1]<1){Console.WriteLine("{0}",k);break;}
            // }
            Console.WriteLine(abc[1]-abc[0]==abc[2]-abc[1]?"YES":"NO");
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}


Measured memory_bytes: 13140
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};


int n, a, b, fl, fl1, ans;


int main(){
	if(scanf("%d",&n)){};

	for(int i = 0; i < n; i++){
		if(scanf("%d",&a)){};
		if(i != 0){
			if(a - b > 0){
				if(fl == -1&&fl1 != 1){
					ans++;
					fl = 1;
					fl1 = 1;
				}else{
					fl = 1;
					fl1 = 0;
				}
			}else if(a - b < 0){
				if(fl == 1&&fl1 != 1){
					ans++;
					fl = -1;
					fl1 = 1;
				}else{
					fl = -1;
					fl1 = 0;
				}
			}
		}
		if(i == n - 1){
			ans++;
		}
		b = a;
	}
	printf("%d\n", ans);
	return 0;
}

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

#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(a) (a).begin(), (a).end()

using namespace std;

int main()
{
    int N, K; cin >> N >> K;
    int n = 1;

    REP( i, N )
    {
        int A = n * 2;
        int B = n + K;

        n = min(A, B);
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define pb push_back
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const int N=100;
const int W=10000;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	map<ll,ll> um;
	ll n,m,w=0,ans=0;
	cin>>n>>m;
	um[w]++;
	FOR(i,0,n){
		ll k;
		cin>>k;
		w+=k;
		w%=m;
		ans += um[w];
		um[w]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>

using namespace std;

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

const int mod=1e9+7;

int gcd(int a,int b){
    if(b==0){
        return a;
    }else{
        return gcd(b,a%b);
    }
}
int main(){
    int r,g,b,n;
    cin >> r >> g>> b >> n;
    int ans=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i*r+j*g>n){
                break;
            }
            if((n-i*r-j*g)%b==0)    ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif


#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1)
#define ld long double
#define prime (1000000000 + 7)

using namespace std;

#define INF 1000000000

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

    ll n, res;
	cin >> n;

	vl vet(n);
	for(auto &p: vet){
		cin >> p;
	}
	
	res = vet.front();
	
	for(auto &p: vet){
		res = __gcd(res, p);
	}

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


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int total_a=0, total_b=0, a, b;
    for(int i=1; i<=4; i++){
        cin >> a;
        total_a += a;
    }
    for(int i=1; i<=4; i++){
        cin >> b;
        total_b += b;
    }
    if(total_a >= total_b) cout << total_a << endl;
    else cout << total_b << endl;
    return 0;
    
}



Measured memory_bytes: 3080
using System;
namespace Application
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if (a * b % 2 == 0){
                Console.WriteLine("Even");
            }else{
                Console.WriteLine("Odd");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define rrep(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep1(i,n) for(ll i=1;i<=(n);++i)
#define rrep1(i,n) for(ll i=(n);i>=1;--i)
#define fr first
#define sc second
#define pb push_back
#define INF 0xfffffff
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
struct edge{ll to,cap,rev; }; // ????????????????????????

vector<edge> G[100];
vector<edge> rG[100];
ll d[100];
ll a[100];
ll cnt=0;
void add_edge(ll from,ll to,ll cap){
	G[from].pb((edge){to, cap, rG[to].size() });
	rG[to].pb((edge){from, 0, G[from].size()-1} );
}

ll calc(ll t){
	ll res = 0;
	rep(i,rG[t].size()){
		res+=rG[t][i].cap;
	}
	return res;
}

ll max_flow(ll V,ll E,ll s,ll t){
	ll res=0;
	memset( d, 0, sizeof(d) );
	memset( a, 0, sizeof(a) );
	d[s] = V;
	a[s]=-1;
	a[t]=-1;
	rep(i,G[s].size()){
		if(G[s][i].to!=t){
			edge &e = G[s][i];
			a[e.to] += e.cap;
			rG[e.to][e.rev].cap = e.cap;
			e.cap = 0;
		}
		else{
			res+=G[s][i].cap;
		}
	}

	for(;;){
		ll v = -1;  //1
		rep(i,V){
			if( a[i]>0 ){
				v = i;
				break;
			}
		}
		if(v < 0) return res+calc(t);
		ll J=0; //2
		ll id;
		rep(i,G[v].size()){
			if( G[v][i].cap>0 && d[v] - d[G[v][i].to] == 1 ){
				id = i;
				J=1;
				break;
			}
		}
		if(!J) rep(i,rG[v].size()){
			if( rG[v][i].cap>0 && d[v] - d[rG[v][i].to] == 1 ){
				id = i;
				J=2;
				break;
			}
		}
	
		if(J){  //3
			edge &e = (J==1?G[v][id]:rG[v][id]);
			if(J==1){
				ll f = min(a[v], e.cap );
				a[v] -= f;
				e.cap -= f;
				rG[e.to][e.rev].cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
			else{
				edge &efor = G[e.to][e.rev];
				ll f = min(a[v], e.cap);
				a[v] -= f;
				e.cap -= f;
				efor.cap += f;
				if(a[e.to]>=0) a[e.to] += f;
			}
		}

		else{  //4
			ll dmin=0xfffffff;
			rep(i,G[v].size()){
				if(G[v][i].cap>0) dmin = min(dmin,d[G[v][i].to]);
			}
			rep(i,rG[v].size()){
				if(rG[v][i].cap>0) dmin = min(dmin,d[rG[v][i].to]);
			}
			d[v] = dmin + 1;
		}
	}
}

ll V,E,A[1000],B[1000],C[1000];

void input(){
	scanf("%lld%lld",&V,&E);
	rep(i,E){
		scanf("%lld%lld%lld",&A[i],&B[i],&C[i]);
	}
}

int main()
{
	input();
	rep(i,V){
		G[i].clear(); rG[i].clear();
	}
	rep(i,E) add_edge(A[i], B[i], C[i]);
	cout<<max_flow(V,E,0,V-1)<<endl;
}

Measured memory_bytes: 3260
#include<stdio.h>
int main() {
 int i,n,sum,j;
 while(scanf("%d", &n)==1) {
 sum = 1;
 for(i=1; i<n; i++) {
 sum = sum + (i+1);
 }
 if(n==1) {
 printf("%d\n", sum);
 }
 else if(n>1 && n<10) {
 printf("%d\n", sum);
 }
 else if(n>=10 && n<=100) {
 printf("%d\n", sum);
 }
 }
 return 0;
}

Measured memory_bytes: 128
n,m,k = map(int, input().split())
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
lt = []
x = 0
a_max = 0
t = 0
for i in range(n):
  t += la[i]
  if t > k:
    a_max = i-1
    t -= la[i]
    x = i
    lt.append(x)
    break
  if i == n-1:
    x = n
    a_max = n-1
    lt.append(x)

j = 0
for i in range(m):
  t += lb[i]
  x += 1
  if t > k:
    lt.append(x-1)
    if j <= a_max:
      t -= la[a_max-j]
      x -= 1
      j += 1
    else:
      break
  if i == m-1:
    lt.append(x)

print(max(lt))

Measured memory_bytes: 40428
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

from collections import deque

N, K = mi()
D = list(map(str, sys.stdin.readline().split()))

for num in range(N, N*10+1):
    flag = 1
    s = str(num)
    for i in range(K):
        if s.count(D[i]):
            flag = 0
            break
    if flag:
        print(num)
        exit()

Measured memory_bytes: 40940
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	string s,ss="CODEFESTIVAL2016";
	int ans = 0;
	cin >> s;
	TFOR(i, s.size()) {
		if (s[i] != ss[i])++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int N;
vector<vector<int>> s;
void input() {
	cin >> N;
	s.resize(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		string si; cin >> si;
		for (int j = 0; j < N; ++j)
			s[i][j] = (int)(si[j] - '0');
	}
}

vector<int> assigned;
bool bfs(int r) {
	assigned.resize(N, 0);
	for (int i = 0; i < N; ++i)
		assigned[i] = 0;
	vector<bool> visited(N, false);
	visited[r] = true;
	queue<pair<int, int>> q;
	q.push(pair<int, int>(r, 0));
	while (!q.empty()) {
		pair<int, int> p = q.front();
		q.pop();
		for (int node = 0; node < N; ++node) {
			if (s[p.first][node]) {
				if (visited[node]) {
					if (abs(p.second - assigned[node]) != 1) {
						return false;
					}
				}
				else {
					assigned[node] = p.second + 1;
					q.push(pair<int, int>(node, assigned[node]));
					visited[node] = true;
				}
			}
		}
	}
	return true;
}

int main() {
	input();
	int res = -1;
	for (int root = 0; root < N; ++root) {
		if (bfs(root)) {
			int tmp = 0;
			for (auto i : assigned)
				tmp = max(tmp, i);
			res = max(res, tmp + 1);
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/*  Writen by : AS7
 *  "JUST KEEP GOING..."
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
const int N = 2e5+5;
map<int ,bool> vis;
int ans;
void solve(){
   int n,k;
   cin>>n>>k;
   int arr[n];
   lp(i,n)cin>>arr[i];
   sort(arr,arr+n);
   for(int i=0;i<k;i++)ans+=arr[i];
   cout<<ans<<endl;
}
int main() {
    int t = 1;
   //cin>>t;
    while (t--)solve();
}

Measured memory_bytes: 3620
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
num = 0
for i in range(N):
  for j in range(i+1, N):
    sum = 0
    for k in range(D):
      sum += (X[i][k] - X[j][k])**2
    if math.sqrt(sum) % 1 == 0:
      num += 1
print(num)

Measured memory_bytes: 38384
N = int(input())
S = []
for i in range(N):
    S.append(input())
    

#二部グラフ判定
L = [0 for i in range(N)]
L[0] = 1
q = [0]
res = 0

while len(q) > 0:
    idx = q.pop(-1)
    c = L[idx]*(-1)
    for i in range(N):
        if S[idx][i] == "1":
            if L[i] == 0:
                L[i] = c
                q.append(i)
            elif L[i] == c*(-1):
                res = 1
                q = []
                break
            

if res == 1:
    print(-1)
else:
    # Warshall-Floyd法で直径を求める
    d = [[10**4 for j in range(N)] for i in range(N)]
    # initialize
    for i in range(N):
        for j in range(N):
            if S[i][j] == "1":
                d[i][j] = 1
    
    # DP
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if i != j:
                    d[i][j] = min(d[i][j], d[i][k]+d[k][j])

                
    ans = 0
    for i in range(N):
        for j in range(N):
            if d[i][j] < 10**4:
                ans = max(ans, d[i][j])
                
    print(ans+1)

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

int H,W;

int main(){
    while(1){
        cin>>H>>W;
        if(H==0 && W==0)break;
        
        for(int i=0;i<H;++i){
            for(int j=0;j<W;++j){
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    
    return 0;
}


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

typedef struct
{
	int id;
	int parent;
	int depth;
	int numOfChild;
	string type;
	vector<int> children;

} Node;
int getDepth(Node nodes[],int n)
{
	int depth = 0;
	Node now = nodes[n];
	while (now.parent != -1)
	{
		now = nodes[now.parent];
		depth++;
	}

	return depth;
}

void setDepth(Node nodes[],int n,int d)
{
	nodes[n].depth = d;
	for (int i = 0; i < nodes[n].numOfChild; i++)
	{
		setDepth(nodes, nodes[n].children.at(i), d + 1);
	}
}
int main()
{
	static Node node[100000 + 1];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		node[i].depth = 0;
		node[i].parent = -1;
	}
	for (int i = 0; i < n; i++)
	{
		int id, k;
		cin >> id >> k;
		node[id].id = id;
		node[id].numOfChild = k;
		for (int j = 0; j < k; j++)
		{
			int c;
			cin >> c;
			node[id].children.push_back(c);
			node[c].parent = id;
			node[c].depth = node[id].depth + 1;
		}
	}
	int root;
	for (int i = 0; i < n; i++)
	{
		if (node[i].parent == -1)
		{
			root = i;
			node[i].type = "root";
		}
		else if (node[i].numOfChild > 0)
		{
			node[i].type = "internal node";
		}
		else
		{
			node[i].type = "leaf";
		}
	}
	setDepth(node, root, 0);
	for (int i = 0; i < n; i++)
	{
		cout << "node " << i << ": parent = " << node[i].parent << ", depth = " << node[i].depth<< ", " << node[i].type << ", [";
		for (int j = 0; j < node[i].numOfChild; j++)
		{
			if (j == 0)
			{
				cout << node[i].children[j];
			}
			else
			{
				cout << ", " << node[i].children[j];
			}
		}

		cout << "]" << endl;
	}
}

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

int main() {
  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


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

words = {}
max_count = 0
for i in range(N):
  word = input()

  count = words.get(word, 0) + 1
  words[word] = count

  if max_count < count:
    max_count = count

results = []
for k, v in words.items():
  if v == max_count:
    results.append(k)

for answer in sorted(results):
  print(answer)

Measured memory_bytes: 32988
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50



def run():
    N = input()
    val = 0
    for n in N:
        val += int(n)
    if not val % 9:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    run()

Measured memory_bytes: 9572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){


	string s;
	cin >> s;

	if(s[s.size()-1] == 's'){
		s += "es";
	}else{
		s += "s";
	}
	cout << s << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<queue>
using namespace std;
string s;
int n,a[1010];
bool f[50000000];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=7&&i+j-1<=n;j++)
        {
            sum=sum*10+a[i+j-1];
            f[sum]=true;
        }
    }
    for(int i=0;;i++)
    {
        if(!f[i]){cout<<i<<endl;return 0;}
    }
}

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define maxs 2020202
#define mkp make_pair
#define inf LONG_LONG_MAX
#define ll long long
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
vector< pair<ll,ll> >ed[maxs];
ll dis[maxs],n,m;
bool vis[maxs];

void Bellman_Ford(){
    fill(dis,dis+1+n,LONG_LONG_MAX);
    mme(vis,0);
    dis[1]=0;
    int sz;
    ll v,w;

    for(int k=1;k<n;k++){//无环
        for(int i=1;i<=n;i++){
           sz = ed[i].size();
           for(int j=0;j<sz;j++){

                v=ed[i][j].first,w = ed[i][j].second;
                if(dis[i]==LONG_LONG_MAX)
                    continue;
                if(dis[v]>dis[i]+w)
                    dis[v]=dis[i]+w;
           }
        }
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            sz = ed[i].size();
            for(int j=0;j<sz;j++){
                v=ed[i][j].first,w=ed[i][j].second;
                if(dis[i]==inf) continue;

                if(dis[v]>dis[i]+w){
                    vis[v]=1;
                    dis[v]=dis[i]+w;
                }
                if(vis[i]){
                    vis[v]=1;
                }
            }
        }
    }

    if(vis[n])
    puts("inf");
    else
        printf("%lld\n",-dis[n]);
}

int main()
{
    while(~scanf("%lld%lld",&n,&m))
    {
        ll u,v,w;
        for(int i=0;i<=n;i++) ed[i].clear();

        for(int i=1;i<=m;i++){
            scanf("%lld%lld%lld",&u,&v,&w);
            ed[u].push_back(mkp(v,-w));
        }
        Bellman_Ford();
    }
    return 0;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N, a, res = 0; cin >> N;

  REP(i, N) {
    cin >> a;
    while (a%2 == 0) {
      a /= 2;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

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

    string t;
    REP(0, i, s.length()) {
        if (i % 2 == 0) {
            t.push_back(s[i]);
        }
    }

    cout << t << endl;

    return 0;
}


Measured memory_bytes: 512
import math
a,b,h,m = map(float, input().split())
rot = 5.5 * (60.0*h + m)
ang = rot%360
rad = ang * math.pi / 180
cal = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
ans = math.sqrt(cal)
print(ans)

Measured memory_bytes: 9464
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    counts = [0,0,0,0]
    for i in range(3):
        a,b = map(int, lines.pop(0).split(' '))
        counts[a-1] += 1
        counts[b-1] += 1

    if max(counts) == 2 and min(counts) == 1:
        print('YES')
    else:
        print('NO')
#
# main
#
lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)


Measured memory_bytes: 3060
use proconio::{fastout, input};

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    return gcd(b, a % b);
}

fn lcm(a: u64, b: u64) -> u64 {
    let g = gcd(a, b);
    return a / g * b;
}

#[fastout]
fn main() {
    input! {
        n: usize,
        t: [u64; n],
    }

    let mut ans = 1;
    for item in t {
        ans = lcm(ans, item);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;

int dp[100005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v;
    ll six = 6, nine = 9;
    v.push_back(1);
    rep(i,15){
        v.push_back(six);
        v.push_back(nine);
        six *= 6;
        nine *= 9;
    }
    sort(v.begin(), v.end());
    rep(j,n+1) dp[j] = INF;
    dp[0] = 0;
    rep(i,20){
        rep(j,n+1){
            if(j+v[i] <= n) chmin(dp[j+v[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <type_traits>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    string s; cin >> s;

    int g_cnt = 0, p_cnt = 0, w_cnt = 0,l_cnt = 0;
    for(int i = 0; i < s.size(); i++) {
        if(g_cnt == p_cnt) {
            g_cnt++;
            if(s[i] == 'p') l_cnt++;
        }
        else {
            if(s[i] == 'p') p_cnt++;
            else {
                p_cnt++;
                w_cnt++;
            }
        }
    }

    cout << w_cnt - l_cnt << endl;
    return 0;
}


Measured memory_bytes: 512
import sys

n = int(input())
a = [num for num in map(int, input().split())]

# print(n)
# print(a)

for item in a:
  if item % 2 == 1:
    continue
  if item % 3 == 0 or item % 5 == 0:
    continue
  print('DENIED')
  sys.exit()
print('APPROVED')

Measured memory_bytes: 38256
H,w,d = map(int, raw_input().split())
mat = [map(int, raw_input().split()) for i in range(H)]

h = {}
cost = {}
for i in range(len(mat)):
	for j in range(len(mat[0])):
		h[mat[i][j]] = (i,j)

cost = {}
def f(uu,vv): return abs(uu[0] -vv[0]) + abs(uu[1] -vv[1]) 
for u in range(1,H*w + 1):
	if u - d >= 1:
		cost[u] = f(h[u], h[u - d]) + cost[u - d]
	else:
		cost[u] = 0 

def g(u,v, cost,d):
	p = u
	return cost[v] - (cost[p] if p in cost else 0) 

for qi in  range(int(raw_input())):
	u,v = map(int, raw_input().split())
	print g(u,v,cost, d)

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

int main() {
    int N, K, n, num;
    bool hate_num[10];
    bool flag = false;
    cin >> N >> K;
    for (int i = 0; i < 10; i++) hate_num[i] = false;
    for (int i = 0; i < K; i++) {
        cin >> num;
        hate_num[num] = true;
    }
    while (! flag) {
        n = N;
        while (n != 0) {
            if (hate_num[n % 10]) break;
            n /= 10;
        }
        if (n == 0) flag = true;
        else N++;
    }
    cout << N << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define MXN 200005
const int mod=1e9+7;
int m1[4][4]={
    {1,0,0,0},
    {1,1,0,0},
    {1,0,1,0},
    {1,1,1,1}
};
int m2[4][4]={
    {2,1,1,1},
    {1,1,0,0},
    {1,0,1,0},
    {1,1,1,1}
};
struct matrix{
    LL a[4][4];
    matrix(int op=0){
        if(op==0){
            MEM(a);
            for(int i = 0;i<4;i++)a[i][i]=1;
        }
        else if(op==1){
            for(int i = 0;i<4;i++)
                for(int j=0;j<4;j++)
                    a[i][j]=m1[i][j];
        }
        else{
            for(int i = 0;i<4;i++)
                for(int j=0;j<4;j++)
                    a[i][j]=m2[i][j];
        }
    }
};
matrix operator*(const matrix &a,const matrix &b){
    matrix c;
    MEM(c.a);
    for(int i =0;i<4;i++)
        for(int j=0;j<4;j++)
            for(int k = 0;k<4;k++){
                c.a[i][j]+=a.a[i][k]*b.a[k][j]%mod;
                c.a[i][j]%=mod;
            }
    return c;
}
matrix f_pow(LL b){
    matrix res(0),temp(2);
    while(b){
        if(b&1) res= res*temp;
        temp=temp*temp;
        b>>=1;
    }
    /*for(int i = 0;i<4;i++,printf("\n"))
            for(int j =0;j<4;j++)
                printf("%d",res.a[i][j]);*/
    return res;
}
int main(){ 
    int n,m;
    scanf("%d %d",&n,&m);
    int x[100005];
    for(int i = 0;i<m;i++)
        scanf("%d",&x[i]);
    x[m]=n;
    int last=0;
    matrix res(0);
    /*for(int i = 0;i<4;i++,printf("\n"))
        for(int j =0;j<4;j++)
            printf("%d",res.a[i][j]);*/
    for(int i = 0;i<=m;i++){
        res=f_pow(x[i]-last-1)*res;
        res=matrix(1)*res;
        /*for(int i = 0;i<4;i++,printf("\n"))
            for(int j =0;j<4;j++)
                printf("%d",res.a[i][j]);*/
        last=x[i];
    }
    printf("%lld\n",res.a[3][0]);
}
/*
1 2 2 3 3 3 4
2 2 1
3 2 3
4 2 4 4 7
 
1 1
*/

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

using namespace std;

int main() {
  int p, q, r;
  scanf("%d%d%d", &p, &q, &r);
  int a = p + q;
  int b = q + r;
  int c = r + p;
  if(a <= b && a <= c)
    printf("%d\n", a);
  else if (b <= c && b <= a)
    printf("%d\n", b);
  else
    printf("%d\n", c);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;
const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = true, flag = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
struct edge { ll to, cost; };
string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	ll n, count = 0, odd = 0, sum = 0;
	cin >> n;
	if (n == 3)cout << 2 << ' ' << 5 << ' ' << 63 << endl;
	else {
		for (int i = 1;i <= 30000;i++) {
			if (count != n - 2) {
				if (i % 2 == 0 || i % 3 == 0) {
					cout << i<<' ';
					count++;
					sum += i;
					if (i % 2 == 1)odd++;
				}
			}
			else {
				for (int j = i;j <= 30000;j++) {
					if (j % 2 != 0 && j % 3 != 0)continue;
					for (int k = j + 1;k <= 30000;k++) {
						if ((j % 2 == 0 || j % 3 == 0) &&( k % 2 == 0 || k % 3 == 0) && (sum + j + k) % 6 == 0) {
							if (j % 2 == 1 && k % 2 != 1) {
								if ((odd + 1) % 2 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
							else if (j % 2 != 1 && k % 2 == 1) {
								if ((odd + 1) % 2 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
							else {
								if (odd % 2 == 0) {
									cout << j << ' ' << k << endl;
									exit(0);
								}
							}
						}
					}
				}
			}
		}
	}
	
}

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

int maximize(int num, int i) {
    if(num > i) return 0;
    int val = num;
    while(val*num <= i) {
        val *= num;
    }
    return val;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N+1);
    A[0] = 0;
    for(int i=1; i<=N; i++) {
        int nine,six,one;
        if(maximize(9,i) == 0) nine = 1001001001;
        else nine = 1 + A[i - maximize(9,i)];
        if(maximize(6,i) == 0) six = 1001001001;
        else six = 1 + A[i - maximize(6,i)];
        one = 1 + A[i-1];
        A[i] = min(nine, min(six,one));
    }
    cout << A[N] << endl;
    return 0;
}

Measured memory_bytes: 640
m,k=map(int,input().split())
if k>=2**m:
    print(-1)
elif m==0: print(0,0)
elif m==1:
    if k==0: print(0,0,1,1)
    else: print(-1)
else:
    tmp=k
    for i in range(1,2**m):
        tmp^=i
    ans=[i for i in range(2**m) if i!=k]+[k]+[i for i in range(2**m-1,-1,-1) if i!=k]+[k]
    print(*ans)

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

int digit ( int n ) {
  int count=0;
  while (n) {
    n /= 10;
    count++;
  }
  return count;
}

int main () {
  ll n;
  cin >> n;
  
  ll count=0;
  rep ( i, 0, n+1 ) { 
    if ( digit (i) %2 != 0 ) {
		count++;
    }
  }
  
  cout << count << endl;
}

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

e = 0
for i in range(1, n):
    if s[i] == 'E':
        e += 1

ans = e
for i in range(n-1):
    if s[i] == 'W':
        e += 1
    if s[i+1] == 'E':
        e -= 1
    ans = min(ans, e)

print(ans)


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

int main(){
  int n;
  cin>>n;
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int z=500;
  int ans=0;
  for(int i=0;i<n-1;i++){
    if(vec[i]==vec[i+1]){
      ans++;
      vec[i+1]=z;
      z++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, N;
	cin >> W >> H >> N;
	bool maze[H][W];
	for(int h = 0; h < H; h++) {
		for(int w = 0; w < W; w++) {
			maze[h][w] = true;
		}
	}

	for(int i = 0; i < N; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		int start_w, start_h, end_w, end_h;
		
		if(a == 1) {
			start_w = 0;
			start_h = 0;
			end_w = x;
			end_h = H;
		} else if(a == 2) {
			start_w = x;
			start_h = 0;
			end_w = W;
			end_h = H;
		} else if(a == 3) {
			start_w = 0;
			start_h = 0;
			end_w = W;
			end_h = y;
		} else if(a == 4) {
			start_w = 0;
			start_h = y;
			end_w = W;
			end_h = H;
		}
		for(int w = start_w; w < end_w; w++) {
			for(int h = start_h; h < end_h; h++) {
				maze[h][w] = false;
			}
		}
	}

	int rslt = 0;
	for(int w = 0; w < W; w++) {
		for(int h = 0; h < H; h++) {
			if(maze[h][w]) rslt++;
		}
	}
	cout << rslt << endl;



}


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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int h, w, k;
  char c[10][10];
  cin>>h>>w>>k;
  REP(i, h){
    REP(j, w){
      cin>>c[i][j];
    }
  }
  int ans=0;
  REP(i, 1<<h){
    REP(j, 1<<w){
      int tmp=0;
      REP(x, h){
        REP(y, w){
          if(c[x][y]=='#' && !(j>>y&1) && !(i>>x&1)){
            ++tmp;
          }
        }
      }
      if(tmp==k){
        ++ans;
      }
    }
  }
  cout<<ans<<'\n';
  return 0;
}


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

using namespace std;

using ll=long long ;

void solve() {
    ll n; cin >> n;
    for (int i = 1; i <= 3500; i++) {
        for (int j = 1; j <= 3500; j++) {
            ll p = n*i*j;
            ll q = 4*i*j - n*(i+j);
            if (q > 0 && p%q==0) {
                ll k = p/q;
                cout << i << ' ' << j << ' ' << k;
                return;
            }
        }
    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N;
    cin >> N;
    vector<int> e(N / 2), o(N / 2);
    REP(i, N) {
        if (i % 2 == 0)cin >> e[i / 2];
        else cin >> o[i / 2];
    }

    int MAX_NUM = 100001;
    vector<int> me(MAX_NUM), mo(MAX_NUM);
    REP(i, N / 2) {
        me[e[i]]++;
        mo[o[i]]++;
    }

    int eMax = -1;
    int eMaxNum = -1;
    int oMax = -1;
    int oMaxNum = -1;
    REP(i, MAX_NUM) {
        if (me[i] > eMaxNum) {
            eMax = i;
            eMaxNum = me[i];
        }
        if (mo[i] > oMaxNum) {
            oMaxNum = mo[i];
            oMax = i;
        }
    }
    if (eMax != oMax) {
        int ans = (N / 2) - eMaxNum + (N / 2) - oMaxNum;
        cout << ans << endl;

        return 0;
    }

    int eMax2 = -1;
    int eMax2Num = -1;
    int oMax2 = -1;
    int oMax2Num = -1;
    REP(i, MAX_NUM) {
        if (i == eMax)continue;
        if (i == oMax)continue;

        if (me[i] > eMax2Num) {
            eMax2 = i;
            eMax2Num = me[i];
        }
        if (mo[i] > oMax2Num) {
            oMax2Num = mo[i];
            oMax2 = i;
        }
    }

    int ans = min(N - eMaxNum - oMax2Num, N - eMax2Num - oMaxNum);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408