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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const int N = 100*100+23;

int a[N];
int m[123][123];

void solve() {
	int h, w, n; scanf("%d%d%d", &h, &w, &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
	}
	int k = 0, c = 0;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; i%2 && j < w; ++j) {
			m[i][j] = k+1;
			++c;
			if (c == a[k]) {
				++k; c = 0;
			}
		}
		for (int j = w-1; i%2 == 0 && j >= 0; --j) {
			m[i][j] = k+1;
			++c;
			if (c == a[k]) {
				++k; c = 0;
			}
		}
	}
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			printf("%d ", m[i][j]);
		}
		puts("");
	}
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 384
N,K=map(int,input().split())
x=list(map(int,input().split()))
positive=[]
negative=[]
for i in range(N):
    if x[i]<0:
        negative.append(-x[i])
    else:
        positive.append(x[i])
negative.sort()
n=len(negative)
m=len(positive)
ans=1000000000
if n>=K:
    ans=min(ans,negative[K-1])
if m>=K:
    ans=min(ans,positive[K-1])

for i in range(n):
    j=K-(i+1)
    if j>m:
        continue
    if j<=0:
        continue
    ans=min(ans,negative[i]+positive[j-1]+min(negative[i],positive[j-1]))
print(ans)


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

const int mod=1e9+7;
const int maxn=1e5+10;
int a[maxn];
typedef long long ll;

ll f[maxn];
ll f0[maxn];
ll inv[maxn];

void init()
{
    f[0]=f[1]=1;
    f0[0]=f0[1]=1;
    inv[0]=inv[1]=1;
    for(int i=2;i<maxn;i++)
    {
        //阶乘数
        f[i]=f[i-1]*i%mod;
        //i在mod意义下的逆元
        f0[i]=(mod-mod/i)*f0[mod%i]%mod;
        //阶乘逆元
        inv[i]=inv[i-1]*f0[i]%mod;
    }
}

//求阶乘数C(a,b)在mod意义下的值
ll C(ll n,ll m)
{   if(n<m)return 0;
    if(n==m)return 1;
    return f[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main(){
    init();
    int n,k;
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
    }
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=a[i]*C(i-1,k-1)%mod;
        //printf("debug %Lld\n",ans);
        ans%=mod;
    }
    //printf("debug %Lld\n",ans);
    for(int i=1;i<=n;i++){
        ans=(ans+mod-a[i]*C(n-i,k-1)%mod)%mod;
    }
    printf("%lld\n",ans);
    return 0;

}


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

using namespace std;

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

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

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

template<class T> inline bool chmin(T& a, const T b) { if (a>b) { a=b; return true; } return false; }
template<class T> inline bool chmax(T& a, const T b) { if (a<b) { a=b; return true; } return false; }



int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    vi a(n);
    VIN(a);

    vi csl(n+1),csr(n+1);

    REP(i,n){
        csl[i+1] = csl[i]^a[i];
        csr[n-(i+1)] = csr[n-i]^a[n-(i+1)];
    }

    REP(i,n){
        int ans = csl[i]^csr[i+1];
        cout << ans;
        if(i<n-1) cout << " ";
        else cout << endl;
    }
    //cout << endl;
    return 0;
}

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

#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rrep(i,N) for(int i=(int)(N)-1;i>=0;--i)
#define debug(x) cout<<#x<<"="<<x<<endl;
constexpr int MOD=1000000007;
constexpr ll INF=(1LL<<61)-1;
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
    int N,M;
    cin>>N>>M;
        vector<vector<double>> A(N);
        rep(i,N){
            double L,a,b;cin>>L>>a>>b;
            A[i]={L,a,b};
        }
        double dp[1<<N];
        double res=0;
        rep(i,1<<N){
            dp[i]=0;
            rep(j,N)if(1&i>>j){
                dp[i]+=dp[i^(1<<j)];
                for(int k=j+1;k<N;k++)if(1&i>>k){
                    rep(l,3)dp[i]+=pow(A[j][l]-A[k][l],2);
                }
                break;
            }
            int ct=0;rep(j,N)ct+=1&i>>j;
            if(ct==M)chmax(res,dp[i]);
        }
        cout<<res<<endl;
    
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 11496
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

int main(){
    ll N; cin >> N;
    FOR(i,N,999){
        if(i == 111 
          || i == 222
          || i == 333
          || i == 444
          || i == 555
          || i == 666
          || i == 777
          || i == 888
          || i == 999
          ){
              cout << i << endl;
              break;
          }
    }
}


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

int main() {
  int N;
  cin >> N;
  
  vector<uint64_t> A;
  A.push_back(2LL);
  A.push_back(1LL);
  
  for (int i = 2; i <= N ; i++) {
    A.push_back(A.at(i - 2) + A.at(i - 1));
  }
  cout << A.at(N) << endl;
}

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

using namespace std; 
const int MAX_N = 100005; 

int f[MAX_N][3]; 
int n; 
int a[MAX_N][3]; 

int main () {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%d", &n); 
	for (int i = 1; i <= n; i++) {
		scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]); 
	}

	int res = -1;
	for (int x = 0; x < 3; x++) {
		f[1][x] = a[1][x]; 
		res = max(res, f[1][x]); 
	} 
                
	for (int i = 2; i <= n; i++) {
		for (int x = 0; x < 3; x++) {
			f[i][x] = -1; 
			for (int y = 0; y < 3; y++) {
				if (y != x) {
					f[i][x] = max(f[i][x], f[i - 1][y] + a[i][x]); 
				}
			}
			res = max(res, f[i][x]); 
		}
	}
	printf("%d", res); 
	return 0; 
}

Measured memory_bytes: 2560
log = console.log;

var stdin = require("fs").readFileSync("/dev/stdin", "UTF-8");
var lines = stdin
  .split(" ")
  .map(Number);

  var N = lines[0]
  var K = lines[1]

  var diff = N -K
  if(K === 1) {
    log(0)
  } else {
    log(diff)
  }

Measured memory_bytes: 21064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

void dfs(int w, int h, int x, int y, std::vector<std::string> &image){
	image[y][x] = '0';

	for(int i = 1; i <= 3; i++){
		if(x + i < w && image[y][x + i] == '1'){
			dfs(w, h, x + i, y, image);
		}
		if(x - i >= 0 && image[y][x - i] == '1'){
			dfs(w, h, x - i, y, image);
		}
		if(y + i < h && image[y + i][x] == '1'){
			dfs(w, h, x, y + i, image);
		}
		if(y - i >= 0 && image[y - i][x] == '1'){
			dfs(w, h, x, y - i, image);
		}
	}
	return;
}

int main(int argc, char **argv){
	int n;
	std::string buf;
	std::vector<std::string> image;
	int X, Y;
	int w = 8;
	int h = 8;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin , buf);
#endif
	n = std::stoi(buf);

	for(int i = 0; i < n; i++){
		image.clear();
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		for(int y = 0; y < h; y++){
#if INPUT_FROM_FILE
			std::getline(ifs, buf);
#else
			std::getline(std::cin, buf);
#endif
			image.push_back(buf);
		}

#if INPUT_FROM_FILE
		std::getline(ifs, buf);
		X = std::stoi(buf);
		std::getline(ifs, buf);
		Y = std::stoi(buf);
#else
		std::getline(std::cin, buf);
		X = std::stoi(buf);
		std::getline(std::cin, buf);
		Y = std::stoi(buf);
#endif
		dfs(w, h, X - 1, Y - 1, image);

		std::cout << "Data " << i + 1 << ":" << std::endl;
		for(int y = 0; y < h; y++){
			std::cout << image[y] << std::endl;
		}
	}
 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


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


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

    # divisors.sort()
    return divisors

divisors = make_divisors(N)

if len(divisors) % 2 == 1:
    print(divisors[-1]*2-2)
else:
    print(divisors[-1]+divisors[-2]-2)

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

class Main {

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        long N = sc.nextInt();
        long sum = 0;
        for (long i=1; i<N; i++){
            sum += i;
        }

        System.out.println(sum);

    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
    
        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }
    
        int nextInt() {
            return Integer.parseInt(next());
        }
    
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i, n) for (LL i = 0; i < (LL)(n); i++)
#define REP2(i, n) for (LL i = 1; i <= (LL)(n); i++)
#define FOR(i, m, n) for (LL i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(),greater<int>())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0)
#define VLL(v,n) vector<LL> v(n); REP(i,n)cin>>v[i];
#define VSTR(v,n) vector<string> v(n); REP(i,n)REP(i,n)cin>>v[i];
LL INF = 1e9 + 1;
LL MOD = 1e9+7;
 long double a,b,c,d,e,n,m,l,r,x,y,z,ans=100000000,ans2=0,cnt=0;
string s,S,t;
bool flag=false;
int main() {
long double x;
ios_base::sync_with_stdio(false);
cin>>n;
string u;
REP2(i,n){
cin >>x>>u;
if(u=="JPY")
 {
 ans2+=x;   
}else{
    ans2+=x*380000;
     }
    }
  cout <<ans2<<endl;
   }


Measured memory_bytes: 3840
def keyence(s):
    # keyence
    if s.count('keyence'):
        if s[:7] == 'keyence' or s[-7:] == 'keyence':
            return('YES')

    # k eyence or keyenc e
    elif s.count('eyence'):
        if s[:1] == 'k' and s[-6:] == 'eyence':
            return('YES')

    elif s.count('keyenc'):
        if s[:6] == 'keyenc' and s[-1:] == 'e':
            return('YES')

    # ke yence or keyen ce
    elif s.count('yence'):
        if s[:2] == 'ke' and s[-5:] == 'yence':
            return('YES')

    elif s.count('keyen'):
        if s[:5] == 'keyen' and s[-2:] == 'ce':
            return('YES')

    # key ence or keye nce
    elif s.count('ence'):
        if s[:3] == 'key' and s[-4:] == 'ence':
            return('YES')

    elif s.count('keye'):
        if s[:4] == 'keye' and s[-3:] == 'nce':
            return('YES')

    return('NO')

print(keyence(input()))


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		List<Double>values= new ArrayList<>();
		for(int i=1;i<=N;i++) {
			values.add(sc.nextDouble());
		}
		Collections.sort(values);
		for(int j=1;j<N;j++) {
			double newvalue=(values.get(0)+values.get(1))/2.0;
			values.remove(0);
			values.remove(0);
			values.add(newvalue);
			Collections.sort(values);
		}
		System.out.println(values.get(0));
	}
}	

Measured memory_bytes: 23124
#include <iostream>

int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;

	if ((a + b) == (c + d)) {
		std::cout << "Balanced" << std::endl;
	} else if ((a + b) < (c + d)) {
		std::cout << "Right" << std::endl;
	} else {
		std::cout << "Left" << std::endl;
	}
}



Measured memory_bytes: 256
N = int(input()) 
d = [10*[0] for _ in range(10)]
for i in range(1, N+1):
    s = str(i)
    if s[0]=="0" or s[-1]=="0":
        continue
    d[int(s[0])][int(s[-1])]+=1   
ans = 0
for i in range(10):
    for j in range(10):
        ans+=d[i][j]*d[j][i]
print(ans)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

bool mainmain(){
	int n;
	cin>>n;
	ll K;
	cin>>K;
	vll v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	if(v.back()<K){
		return false;
	}
	rep(i,n){
		if(v[i]==K) return true;
	}
	ll t = v[0];
	rep(i,1,n){
		t = __gcd(t, v[i]);
	}
	if(t==1){
		return true;
	}
	rep(i,n){
		if(v[i]>=K&&(v[i]-K)%t==0){
			return true;
		}
	}
	return false;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    cout<<(mainmain()?"POSSIBLE":"IMPOSSIBLE")<<endl;
}

Measured memory_bytes: 1024
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        print("F")
    elif 80 <= m + f:
        print("A")
    elif 65 <= m + f < 80:
        print("B")
    elif 50 <= m + f < 65:
        print("C")
    elif 30 <= m + f < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    elif m + f < 30:
        print("F")




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

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, INF);
  vector<int> pre(n, -1);
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    for (int u : to[v]) {
      if (dist[u] != INF) continue;
      dist[u] = dist[v]+1;
      pre[u] = v;
      q.push(u);
    }
  }

  cout << "Yes" << endl;
  rep(i,n) {
    if (i == 0) continue;
    int ans = pre[i];
    ++ans;
    cout << ans << endl;
  }
  return 0;
}

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

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        int[][] dp = new int[s.length() + 1][t.length() + 1];

        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i) == t.charAt(j)) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = Math.max(dp[i][j + 1], dp[i + 1][j]);
                }
            }
        }

        String ans = "";
        int i = s.length();
        int j = t.length();
        while (i > 0 && j > 0) {
            if (dp[i][j] == dp[i - 1][j]) {
                i--;
            } else if (dp[i][j] == dp[i][j - 1]) {
                j--;
            } else {
                ans = s.charAt(i - 1) + ans;
                i--;
                j--;
            }
        }
        System.out.println(ans);
    }


    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 87160
#include <bits/stdc++.h>
using namespace std;
int N;
int count(vector<int> X) {
  int v[9];
  for(int i = 1; i <= N; ++i) v[i] = i;
  int cnt = 0; bool ok;
  do {
    ok = true; cnt++;
    for(int i = 1; ok && i <= N; i++) {
      if(X[i] != v[i]) ok = false;
    }
  } while(!ok && next_permutation(v+1, v+N+1));
  return cnt;
}
int main() {
  vector<int> P(9),Q(9); cin >> N;
  for(int i = 1; i <= N; ++i) cin >> P[i];
  for(int i = 1; i <= N; ++i) cin >> Q[i];
  int a = count(P), b = count(Q);
  cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
#Crossing
n=int(input())
flag=False
index=0
for i in range(1000):
    if i*(i+1)//2==n:
        flag=True
        index=i
        break
if flag:
    print("Yes")
    print(i+1)
    uselist=[[1],[1]]
    if index==1:
        print(1,1)
        print(1,1)
    else:
        def plus(N):
            base=(N)*(N-1)//2
            for k in range(1,N+1):
                uselist[k-1].append(base+k)
            uselist.append([base+i+1 for i in range(N)])

     
        
        for k in range(2,index+1):
            plus(k)
        for some in uselist:
            print(index,*some)
            
else:
    print("No")

Measured memory_bytes: 12420
#include<bits/stdc++.h>
using namespace std;
int d[1000], mmax, used[1000][1000];
int main(){
  int n; scanf("%d", &n);
  string s;
  cin >> s;
  for(int i = 0; i < n-1; i++){
    //split
    int tmp=0;
    //cout << i;
    for(int j = i; j>=0; j--){
      
      char find_s= s[j];
      //cout << find_s;
      if(used[i][find_s]==1) continue;
      else used[i][find_s] = 1;
      for(int k = i+1; k < n; k++){
        if(s[k] == find_s){
          tmp++;
          //puts("");
          break;
        }
      }
    }
    mmax= max(mmax, tmp);
    //printf("%d\n\n", mmax);
  }
  printf("%d\n", mmax);
}

Measured memory_bytes: 640
while True:
    card = [w for w in input()]
    if card[-1] == "-":
        break
    m = int(input())
    for i in range(m):
        h = int(input())
        for i in range(h):
            t = card[0]
            del card[0]
            card.append(t)
    for i in range(len(card)):
        print(card[i], end="")
    print()      

Measured memory_bytes: 7732
import numpy as np


def read():
    S = input()
    return S,

def solve(S):
    N = len(S)
    counts = [0 for i in range(N)]
    r = 0
    for i in range(N):
        if S[i] == 'R':
            r += 1
        else:
            counts[i] += r // 2
            counts[i-1] += r - r // 2
            r = 0
    l = 0
    for i in range(N-1, -1, -1):
        if S[i] == 'L':
            l += 1
        else:
            counts[i] += l // 2
            counts[i+1] += l - l // 2
            l = 0
    return ' '.join(map(str, counts))

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 19688
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c)cout <<"Yes";
	else cout << "No"; 
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n;
  cin >> n;
  int p[n];
  int max = 0;
  int index = 0;
  for(int i = 0; i < n; i++){
    cin>> p[i];
    if(max < p[i]){
      max = p[i];
      index = i;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(i == index){
      ans += p[i]/2;
    } else {
      ans += p[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
ps = [list(map(int, input().split())) for i in range(n)]

prev = None
for x, y in ps:
    mandist = abs(x) + abs(y)
    if prev is not None and mandist % 2 != prev:
        print(-1)
        exit()
    prev = mandist % 2

isodd = mandist % 2
ds = [2 ** i for i in range(31)]
ds = ds[::-1]
if isodd:
    m = 31
else:
    m = 32
    ds += [1]

print(m)
print(*ds)
for x, y in ps:
    px = py = 0
    ans = ""
    for d in ds:
        dx = x - px
        dy = y - py
        if abs(dx) >= abs(dy):
            if dx >= 0:
                ans += "R"
                px += d
            else:
                ans += "L"
                px -= d
        else:
            if dy >= 0:
                ans += "U"
                py += d
            else:
                ans += "D"
                py -= d
    print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 3e18+100;
const int inf = 1e8+100;
const int nmax = 1e5+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

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

    int m,d;
    cin>>m>>d;
    int ret = 0;
    for(int i=1; i<=d; i++) for(int j=1; j<=m; j++){
        if(i%10>=2 and i>=20 and ( (i%10) * (i/10) )==j)
            ret++;
    }
    cout<<ret<<endl;

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define INF 0x3f3f3f3f3f
//#define Local
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 20;

int n;
pii a[1 << N];

pii merge(pii A, pii B) {
    if(A.fi < B.fi) swap(A, B);
    pii ans = A;
    if(B.fi > ans.se) ans.se = B.fi;
    return ans;
}

void run() {
    for(int i = 0; i < 1 << n; i++) {
        int x; cin >> x;
        a[i] = MP(x, -INF);
    }
    for(int j = 0; j < n; j++) {
        for(int i = 0; i < 1 << n; i++) {
            if(i >> j & 1) a[i] = merge(a[i], a[i ^ (1 << j)]);
        }
    }
    int ans = 0;
    for(int i = 1; i < 1 << n; i++) {
        ans = max(ans, a[i].fi + a[i].se);
        cout << ans << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
#ifdef Local
    freopen("../input.in", "r", stdin);
    freopen("../output.out", "w", stdout);
#endif
    while(cin >> n) run();
    return 0;
}

Measured memory_bytes: 5704
N = gets.to_i
a = gets.split().map(&:to_i)

box = []

N.times do 
  box.push(0)
end

sum = 0
num = 0
count = 0

(N-1).downto(0) do |i|
  num = i + 1
  while N >= num
    sum += box[num-1]
    num += i + 1
  end
  unless a[i] == sum % 2 
    box[i] = 1 
    count += 1
  end
  sum = 0
end

puts count
N.times do |i|
  print "#{i+1} " if box[i] == 1
end

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

int main(void){
  string s;
  char buf;
  long int cnt = 0;

  cin >> s;

  buf = s[0];
  for (int i = 1; i < s.length(); i++){
    if (buf != s[i]) cnt++;
    buf = s[i];
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	double ret = 0.5;
	if (N & 1) ret = (double)(N / 2 + 1) / N;

	cout << fixed << setprecision(10) << ret << endl;
}

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

int main(){
    vector<string> a = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;

    int cnt=0;
    for(int i=0; i<7; i++){
        if(s==a[i]) break;

        else cnt++;
    }

    cout << 7-cnt << endl;
}

Measured memory_bytes: 256
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	string s;
	cin >> s;
	unordered_map<char, ll> ump;
	rep(i, n) ump[s[i]]++;
	ll ans = 1;
	char ch = 'a';
	rep(i, 26){
		ans *= (ump[ch++]+1);
		ans %= MOD;
	}
	co(ans-1);

	return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  long long int count = 0;
  for (int i = 0; i < N; i++) {
    count += i + L;
  }
  if (0 - L < N && L <= 0) {
    cout << count <<endl;
  }
  else if (L > 0) {
    cout << count - L <<endl;
  }
  else if (0 - L >= N) {
    cout << count - L + 1 - N <<endl;
  }
}




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

int kaijo(int s) {
  if (s ==1) return 1;
  return kaijo(s-1) * s;
}

int qdict(int N, deque<int> Q) {
  int x = 0;
  while (N > 1) {
    x += (Q.front() - 1) * kaijo(N-1);
    for (int i = 1; i < N; i++) {
      if (Q.front() < Q.at(i)) {
        Q.at(i) -= 1;
      }
    }
    Q.pop_front();
    N -= 1;
  }
  if (N == 1) {
    x += 1;
    return x;
  }
}

int main() {
  int N;
  cin >> N;
  deque<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  int a = qdict(N,A);
  int b = qdict(N,B);
  
  cout << max(a-b, b-a) << endl;
}

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

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

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

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

	int d,t,s;
	cin>>d>>t>>s;
	if (t*s>=d) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3656
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
ans = 0
for i, a in enumerate(As, 1):
    if i%2==1 and a%2==1:
        ans += 1
print(ans)

Measured memory_bytes: 61960
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned ui;
typedef unsigned long long ul;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef pair<ul, ul> puu;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define ls (i << 1)
#define rs (i << 1 | 1)
#define mid (l + r >> 1)
#define enum(i, j, k) for(int i = j; i <= (k); i ++)
#define open(i, j, k) for(int i = j; i <  (k); i ++)
#define dec(i, j, k)  for(int i = j; i >= (k); i --)
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define mfil(x, k) memset(x, k, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
#define fio(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout)
template <class T> bool chkmin(T &x, T y)
{ return y < x ? (x = y, true) : false; }
template <class T> bool chkmax(T &x, T y)
{ return y > x ? (x = y, true) : false; }
struct __init { __init()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cout.precision(16); cout << fixed;
    srand(time(0) ^ ui(ul(new char)));
} } static __init__;
/* default code ends here */

const ll mod = 924844033;
const int maxn = 2010;

ll fpow(ll x, ll a)
{
    ll ret = 1;
    for( ; a; a >>= 1, x = x * x % mod)
        if(a & 1)
            ret = ret * x % mod;
    return ret;
}
ll ni(ll x)
{
    return fpow(x, mod - 2);
}

int n, k;

ll peng[maxn], np[maxn];
ll C(ll x, ll y)
{
    if(x < y)
        return 0;
    else if(x == y)
        return 1;
    else
        return peng[x] * np[y] % mod * np[x - y] % mod;
}

ll dp[2][maxn], tmp[maxn];

int main()
{
    cin >> n >> k;
    peng[0] = np[0] = 1;
    enum(i, 1, n)
    {
        peng[i] = peng[i - 1] * i % mod;
        np[i] = ni(peng[i]);
    }
    bool cur = true;
    dp[!cur][0] = 1;
    tmp[0] = 1;
    enum(i, 1, k)
    {
        int len = (n - i) / k;
        int up = (len + 1) / 2;
        enum(i, 1, up)
            tmp[i] = (C(len - i, i) + C(len - i, i - 1)) % mod;
        mfil(dp[cur], 0);
        enum(i, 0, n)
            if(dp[!cur][i])
                enum(j, 0, up)
                    (dp[cur][i + j] += dp[!cur][i] * tmp[j]) %= mod;
        /*enum(i, 0, n)
            cerr << dp[cur][i] << ' ';
        cerr << endl;
        cerr << up << endl;
        enum(j, 0, up)
            cerr << tmp[j];*/
        cur = !cur;
        mfil(dp[cur], 0);
        enum(i, 0, n)
            if(dp[!cur][i])
                enum(j, 0, up)
                {
                    //cerr << i << ' ' << j << ' ' << dp[!cur][i] << ' ' << tmp[j] << endl;
                    dp[cur][i + j] = (dp[cur][i + j] + dp[!cur][i] * tmp[j]) % mod;
                }
        cur = !cur;
    }
    cur = !cur;
    /*enum(i, 0, n)
        cerr << dp[cur][i] << ' ';
    cerr << endl;*/
    ll ans = 0;
    enum(i, 0, n)
        ans = (ans + (i & 1 ? -1 : 1) * dp[cur][i] * peng[n - i]) % mod;
    ans = (ans + mod) % mod;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    int h,w;
    bool flag=true;
    cin >> h >>w;
    vector<vector<char>>s(h,vector<char>(w));
    rep(i,h) rep(j,w)  cin >> s[i][j];
    rep(i,h){
        if(flag==false) break;
        rep(j,w){
            if(s[i][j]=='#'){
                int count=0;
                rep(k,4){
                    int x=j+nx[k];int y=i+ny[k];
                    if(x<0||x>=w||y<0||y>=h) continue;
                    if(s[y][x]=='#')count++;
                }
                if(count==0) flag=false;
            }
        }
    }
    if(flag) cout << "Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}


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

using namespace std;

int main(){
    string s;
    while(getline(cin,s)){
        if(s==".")break;
        stack<char>st;
        for(auto x:s){
            if(x=='(')st.push(x);
            if(x=='[')st.push(x);
            if(x==')'){
                if(!st.empty() && st.top()=='(')st.pop();
                else{
                    st.push(x);
                    break;
                }
            }
            if(x==']'){
                if(!st.empty() && st.top()=='[')st.pop();
                else{
                    st.push(x);
                    break;
                }
            }
        }
        if(st.empty())cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}

Measured memory_bytes: 3120
def game():
    score=out=0
    runner=[0]*3
    while 1:
        t=raw_input()
        if t=='OUT':
            out+=1
            if out==3:
                return score
        elif t=='HOMERUN':
            score+=(1+runner.count(1))
            runner=[0]*3
        elif t=='HIT':
            if runner[2]==1:
                score+=1
                runner[2]=0
            runner=[1,runner[0],runner[1]]

n=int(raw_input())
for i in range(n):
    print game()

Measured memory_bytes: 6304
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args...);
}

/*Input*/
/*Input*/

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
        string s;
        cin >> s;
        if(s=="Sunny") cout << "Cloudy" << endl;
        if(s=="Cloudy") cout << "Rainy" << endl;
        if(s=="Rainy") cout << "Sunny" << endl;
	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 256
S = input()

can1 = 0
can2 = 0

for i in range(len(S)):
    if abs(int(S[i])-i%2) == 1:
        can1 += 1
    elif abs(int(S[i])-(i+1)%2) == 1:
        can2 += 1

if can1 > can2:
    print(can2)
else:
    print(can1)

Measured memory_bytes: 3188
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
typedef struct node* Node;
struct node{
  Node right;
  Node left;
  Node parent;
  int key;
};
Node root;

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key)
      x = x->left;
    else 
      x= x->right;
  }
  z->parent = y;
  
  if(y == NIL) 
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else 
    y->right = z;
}

void inorder(Node u) {
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u) {
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() 
{
  int n, i, x;
  char c[10];
  scanf("%d",&n);
  
  for (i=0; i<n; i++){
    scanf("%s",c);
    if(c[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if(c[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  } 
  return 0;
}

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

int main(){
  int data[5];
  for (int i=0;i<5;i++){
    scanf("%d",data+i);
  }
  int ans=100000;
  sort(data,data+5);

  do{
    int time=0;
    for (int i=0;i<4;i++){
      if (time%10!=0){
        time = (time/10)*10+10;
      }
      time += data[i];
    }

    if (time%10!=0){
      time = (time/10)*10+10;
    }
    time += data[4];
    ans = min(time,ans);
  }while(next_permutation(data,data+5));
  
  printf("%d\n",ans);

  return 0;
}


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

#pragma GCC optimze("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()

#define ll long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    cout << r * r;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  n%=k;
  int ans=n;
  ans=min(ans,abs(ans-k));
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,i;
    cin >> N;
    int A[N], count;
    rep(i, N) cin >> A[i];
    while (true) {
        bool have_odd = false;
        rep(i, N) {
            if (A[i] % 2 != 0) {
                have_odd = true;
            }
        }
        if (have_odd) {
            break;
        }
        rep(i, N) { A[i] /= 2; }
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from decimal import Decimal  as D
def resolve():
    A,B=input().split()
    a=D(A)
    b=D(B)
    print(int(a*b))
#%%submit!
resolve()


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

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

  x = a * b % 2; 
  
  if (x == 0) {
    cout << "Even" << endl;
  }
  else {
    cout  << "Odd" << endl;
  }
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 17;
int n;
vector<pair<int,int>> a[maxn];

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

  cin>>n;
  for (int i=0; i<n; i++) {
    int q; cin>>q;
    while (q--) {
      int x,y; cin>>x>>y;
      a[i].push_back({x,y});
    }
  }

  int ans = 0;

  for (int mask=1; mask < (1<<n); mask++) {
    bool ok=true;
    //cout<<bitset<3>(mask)<<endl;
    for (int j=0; j<n; j++) {
      if (mask>>j&1) {
	for (auto p: a[j]) {
	  int i = p.first-1; int res = p.second;
	  if (res!=(mask>>i&1)) {
	    ok = false;
	  }
	}
      }
    }
    if (ok) {
      ans = max(ans, __builtin_popcount(mask));
    }
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
using System;

namespace Subscribers
{
    class Program
    {
        static void Main(string[] args)
        {
            String[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int a = int.Parse(s[1]);
            int b = int.Parse(s[2]);

            int min = a + b - n;
            Console.WriteLine(String.Format("{0} {1}", a < b ? a : b, min < 0 ? 0 : min));
        }
    }
}


Measured memory_bytes: 13140
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        int b = scan.nextInt();

        if (a + b >= 10) {
            System.out.println("error");
        } else {
            System.out.println(a + b);
        }
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> x;


    for (int i = 0; i < N; ++i) {
        ll a;
        cin >> a;
        x.push_back(a);
    }
    //全部正
    if(x[0] >= 0){
        cout << x[K-1] << endl;
        return 0;
    }
    //全部負
    if(x[N - 1] <= 0){
        cout << -1 * x[N - K] << endl;
        return 0;
    }


    ll beforex = 0;

    int b = 0;
    int g = 0;
    for (auto itr = x.begin(); itr != x.end(); ++itr) {
        if(beforex < 0 && *itr >0){
            x.insert(itr, 0);
            b = g;
            N++;
            break;
        }
        if(*itr == 0){
            b = g;
            K--;
            break;
        }
        g++;
        beforex = *itr;

    }

    ll minTotal = 0;
    for (int i = 0; i <= b; ++i) {
        int m = b - i;
        if(m > K){
            continue;
        }
        int n = K - m;
        if(n + b > N -1){
            break;
        }
        ll mlength = x[b] - x[b - m];
        ll nlength = x[b + n] - x[b];
        ll total = 0;
        if(mlength> nlength){
            total = mlength + 2 * nlength;
        } else{
            total = 2 * mlength + nlength;
        }
        if(minTotal == 0 || total < minTotal){
            minTotal = total;
        }

    }

    cout << minTotal << endl;

    return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int a, b, c, d;

int main()
{
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) puts("Yes");
    else puts("No");

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int S,W;
    cin >> S >> W;
    if (S<=W) {
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int cnt = 0;

    if(k <= a){
        cout << k << endl;
    }
    else if(k <= a + b){
        cout << a << endl;

    }
    else{
        cnt = k - (a + b);
        cout << a - cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, u, v;
vector<vector<int>> G;
int deep;
vector<int> u2v;

int dfs1(int a, int p) {
  if (a == u) {
    u2v.push_back(u);
    return 0;
  }
  for (auto b : G[a]) {
    if (b == p) continue;
    int d = dfs1(b, a);
    if (d != -1) {
      u2v.push_back(a);
      return d + 1;
    }
  }
  return -1;
};

int dfs2(int a, int p) {
  if (G[a].size() == 1) return 0;
  int m = 0;
  for (auto b : G[a]) {
    if (b == p) continue;
    m = max(m, dfs2(b, a));
  }
  return m + 1;
};

void Main() {
  cin >> n >> u >> v;
  u--;
  v--;
  G.resize(n);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  int d12 = dfs1(v, -1);
  reverse(u2v.begin(), u2v.end());
  int d1r = d12 / 2 + 1;
  // int dr2 = d12 - d1r;
  int dr3 = dfs2(u2v[d1r], u2v[d1r - 1]);
  cout << d1r + dr3 - 1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int pow(int x, int p) {
  int res = 1;
  while(p) {
    res *= x;
    p--;
  }
  return res;
}

int main() { 
  int x;
  cin >> x;
  int ans = 0;
  if(x==1) {
    cout << 1 << endl;
    return 0;
  }
  for(int i = 2; i<=x; i++) {
    int j = 2;
    while(true) {
      int tmp = pow(i, j);
      if(tmp > x) break;
      ans = max(tmp, ans);
      j++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = ["3", "5", "7"]
s2 = ["357", "375", "537", "573", "735", "753"]
s3 = []
s4 = []
s5 = []
s6 = []
s7 = []
s8 = []

def PowerGorilla(s_t, s_i):
    s_new = []
    for j in range(len(s_t)):
        for i in range(len(s_t[0])+1):
            for k in range(3):
                s_new.append(s_t[j][:i] + s_i[k] + s_t[j][i:])

    sss = list(set(s_new))
    return sss

s3 = PowerGorilla(s2, s)
s4 = PowerGorilla(s3, s)
s5 = PowerGorilla(s4, s)
s6 = PowerGorilla(s5, s)
s7 = PowerGorilla(s6, s)
s8 = PowerGorilla(s7, s)

#print(PowerGorilla(s8, s))

num = []
num.extend(int(i) for i in s2)
num.extend(int(i) for i in s3)
num.extend(int(i) for i in s4)
num.extend(int(i) for i in s5)
num.extend(int(i) for i in s6)
num.extend(int(i) for i in s7)
num.extend(int(i) for i in s8)

num.sort()

count = 0

n = int(input())
for i in range(len(num)):
    if num[i] <= n:
        count += 1

print(count) 

Measured memory_bytes: 16020