akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}

int main(){
  LL A,B,M,i,ans=INF,mina=INF,minb=INF;
  scanf("%lld%lld%lld",&A,&B,&M);
  LL a[A+1],b[B+1],x[M],y[M],c[M];
  FOR(i,1,A+1)scanf("%lld",&a[i]);
  FOR(i,1,B+1)scanf("%lld",&b[i]);
  rep(i,M)scanf("%lld%lld%lld",&x[i],&y[i],&c[i]);
  rep(i,M)ans=MIN(ans,a[x[i]]+b[y[i]]-c[i]);
  FOR(i,1,A+1)mina=MIN(mina,a[i]);
  FOR(i,1,B+1)minb=MIN(minb,b[i]);
  ans=MIN(ans,mina+minb);

  printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int N=s[0],W=s[1];
		long[] dp=new long[W+1];
		for(int i=1;i<=N;i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			int w=q[0],v=q[1];
			for(int j=W;j>=w;j--){
				dp[j]=Math.Max(dp[j],dp[j-w]+v);
			}
		}
		Console.WriteLine("{0}",dp[W]);
	}
}

Measured memory_bytes: 13792
n = int(input())
t, a = map(int, input().split())
for _ in range(n - 1):
    x, y = map(int, input().split())
    s = max((t + x - 1) // x, (a + y - 1) // y)
    t, a = s * x, s * y
print(t + a)

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

int main() {
  int A,B,i;
  cin >> A >> B;
  
  int Pa = 0;

  for (i = 0; i <= B-A; i++) {
    int j = i + A;
    int j1 = j % 10;
    int j2 = j % 100 / 10;
    int j4 = j % 10000 / 1000;
    int j5 = j / 10000;
    if (j1 == j5 && j2 == j4)
      Pa++;
  }
  cout << Pa << endl;
}

Measured memory_bytes: 3604
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,m,a,s;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a,s+=a;
	if(s>n)
	{
		cout<<-1;
		return 0;
	}
	cout<<n-s;
	return 0;
}


Measured memory_bytes: 3196
bldgs = [[[0]*10 for _ in range(3)] for _ in range(4)]

n = int(input())
for _ in range(n):
  b, f, r, v = (int(i) for i in input().split())
  bldgs[b - 1][f - 1][r - 1] += v

for i, floors in enumerate(bldgs):
  if i != 0: print ("####################")
  for rooms in floors:
    print ("", *rooms)

Measured memory_bytes: 7756
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		Random r = new Random();
		int N = sc.nextInt();
		long L = sc.nextLong();
		long T = sc.nextLong();
		int[] x = new int[N];
		boolean[] w = new boolean[N];
		ArrayList<Integer> cw = new ArrayList<>();
		ArrayList<Integer> ccw = new ArrayList<>();
		for(int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			w[i] = sc.nextInt()==1;
			if(w[i])
				cw.add(x[i]);
			else
				ccw.add(x[i]);
		}
		Collections.reverse(cw);
		
		if(cw.size()==0 || ccw.size()==0) {
			for(int i=0; i<N; i++) {
				pw.println((x[i]+(w[i]? T%L : L-(T%L)))%L);
			}
		} else {
			int[] pos = new int[N];
			for(int i=0; i<N; i++)
				pos[i] = (int)((x[i]+(w[i]? T%L : L-(T%L)))%L);
			Arrays.sort(pos);
			
			long cnt = 0;
			for(int ccwx : ccw) {
				long dis = (ccwx-cw.get(0)+L)%L;
				cnt = (cnt + (2*T + L-dis-1)/L)%N;
			}
			
			int a = Arrays.binarySearch(pos, (int)((cw.get(0)+T)%L));
			if(a>0 && pos[a-1]==pos[a])
				a--;
			int idx = (a - Arrays.binarySearch(x, cw.get(0)) - (int)cnt + N + N)%N;
			
			for(int i=0; i<N; i++)
				pw.println(pos[(idx+i)%N]);
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 89664
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int A[101][101];

int main() {
	int n;
	cin >> n;
	for (int t = 0; t < n; t++) {
		int i, k;
		cin >> i >> k;
		for (int s = 0; s < k; s++) {
			int j;
			cin >> j;
			A[i][j] = 1;
		}
	}
	for (int i = 1; i < n + 1; i++) {
		for (int j = 1; j < n + 1; j++) {
			if (j != 1)cout << ' ';
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
// Born Sinner
// old but im not that old
// fuck all you hoes get a grip
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int modPower(int x, int y, int mod){
        int res = 1;
        x %= mod;
        if(x==0) return 0;
        while(y>0){
            if(y%2==1){
                res = (res*x)%mod;
            }
            y = y>>1;
            x = (x*x)%mod;
        }
        return res;
    }
    static class pair<T1, T2>{
        T1 first;
        T2 second;
        pair(T1 first, T2 second){
            this.first = first;
            this.second = second;
        }
    }
    
    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader in = new FastReader();
        String n = in.next();

        long s = 0;
        for(int i = 0; i < n.length(); i++){
            long x = (n.charAt(i) - '0');
            s += x;
        }
        System.out.println((s%9 == 0)?"Yes":"No");
    }
}


Measured memory_bytes: 36504
'use strict'

function main(s) {

  s = s.split('\n')[0].split('');

  let plus = 0;
  let minus = 0;

  for (let i = 0; i < s.length; i++) {
    if (s[i] === '+') plus++;
    if (s[i] === '-') minus++;
  }

  console.log(plus - minus);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

const int INF = 1000000007;

int main(){
  int n, m; cin >> n >> m;
  vector<pair<int, int>> key;
  rep(i, m){
    int a, b; cin >> a >> b;
    int x = 0;
    rep(j, b){
      int c; cin >> c;
      c--;
      x |= 1 << c;
    }
    key.emplace_back(x, a);
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  rep(i, 1<<n){
    rep(j, m){
      int t = i | key[j].first;
      int cost = dp[i] + key[j].second;
      dp[t] = min(dp[t], cost);
    }
  }
  int ans = dp.back();
  if(ans == INF){
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
import math

MOD = int(math.pow(10, 9)) + 7
N, M = map(int, input().split(' '))
broken_steps = {int(input()) for _ in range(M)}

dp = [0] * (N + 1)

dp[0] = 1
if 1 not in broken_steps:
    dp[1] = 1

for step in range(2, N + 1):
    if step not in broken_steps:
        dp[step] = (dp[step - 1] + dp[step - 2]) % MOD

print(dp[N])


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

using namespace std;
using ll = long long int;

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

  int n, q;
  cin >> n >> q;
  vector<ll> a_vec(n);
  vector<ll> x_vec(q);
  for (auto &e : a_vec)
    cin >> e;
  for (auto &e : x_vec)
    cin >> e;

  for (auto x : x_vec) {
    ll right = 0;
    ll sum = 0;
    ll ans = 0;
    for (ll left = 0; left < n; left++) {
      while (right < n && sum + a_vec[right] <= x) {
        sum += a_vec[right];
        right++;
      }
      ans += right - left;

      if (left == right) {
        right++;
      } else {
        sum -= a_vec[left];
      }
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3580
n = int(input())
line = list(map(int, input().split()))
count = 0
for i in range(n):
    result = []
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if line[i] != line[k] and line[i] != line[j] and line[j] != line[k]:
                _len = line[i] + line[k] + line[j]
                max_r = max(line[i], line[k], line[j])
                if max_r < _len - max_r:
                    count += 1
print(count)


Measured memory_bytes: 9232
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    int num = N/100;
    if(N%100/10 < num){
        cout << 111*num << endl;
        return 0;
    }else if(N%100/10 == num){
        if(N%10 <= num){
            cout << 111*num << endl;
            return 0;
        }else{
            cout << 111*(num+1) << endl;
            return 0;
        }
    }else{
             cout << 111*(num+1) << endl;
            return 0;       
    }
    return 0;
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {

    const rows = input.split('\n')
    const [N, M] = rows[0].split(' ').map(Number)
    const H = rows[1].split(' ').map(Number)
    const A = [], B = []
    for (let i = 0; i < M; i++) {
        [A[i], B[i]] = rows[i + 2].split(' ').map(Number)        
    }

    const dp = [...Array(N).fill(1)]
    
    for (let i = 0; i < M; i++) {
        if (H[A[i] - 1] === H[B[i] - 1]) {
            dp[A[i] - 1] = 0
            dp[B[i] - 1] = 0
        } else if (H[A[i] - 1] < H[B[i] - 1]) {
            dp[A[i] - 1] = 0
        } else {
            dp[B[i] - 1] = 0
        }
    }
    
    console.log(dp.reduce((a, b) => a + b))
    
})(input)


Measured memory_bytes: 65456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) {
        cin >> a[i];
        b[i] = a[i];
        }
    sort(b.begin(),b.end());
    rep(i,n){
        int ans = 0;
        if (a[i]!=b[n-1]) cout << b[n-1] << endl;
        else{
            cout << b[n-2] << endl;
            }
        }

}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define MOD 100000007
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define rep(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
inline ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
inline ll char_to_ll(char c) { return (int)(c - '0'); }
inline ll string_to_ll(string s) { return atoi(s.c_str()); }
inline bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }

int main(){
    string S;
    ll K;
    cin >> K >> S;

    if(S.size() <= K) cout << S << endl;
    else cout << S.substr(0, K) << "..." << endl;


    return 0;
}


Measured memory_bytes: 3600
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;

int main() {
	int i, j,k;
	long long N;
	long long sum[87] = {};
	cin >> N;
	for (i = 0; i <= N; ++i) {
		if (i == 0) {
			sum[0] = 2;
		}
		else if (i == 1) {
			sum[1] = 1;
		}
		else if (i > 1) {
			sum[i] = sum[i - 1] + sum[i - 2];
		}
	}
	cout << sum[N] << endl;
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const S = args[0][0]
	const md = S.match(/^(.+)FESTIVAL$/)
	console.log(md[1])
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21568
import itertools
import copy
S = input()

ans = 0
for v in itertools.product([1,0], repeat=len(S)-1):
    S_copy = copy.deepcopy(S)
    idx = 0
    sum = 0
    for i in range(1,len(S)):
        if v[i-1] == 1:
            sum += int(S[idx:i])
            idx = i
    ans += int(S[idx:])
    ans += sum
print(ans)

Measured memory_bytes: 9276
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include <map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
#include <complex>
#include <omp.h>
using namespace std;
#define eps 0.000001
#define LONG_INF 10000000000000
#define GOLD 1.61803398874989484820458
#define seg_size 65536*4
#define REP(i,n) for(long long i = 0;i < n;++i)
unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}



void solve(long long H, long long W, long long h, long long w){
    cout << (H-h) * (W-w) << endl;
    return;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long h;
    scanf("%lld",&h);
    long long w;
    scanf("%lld",&w);
    solve(H, W, h, w);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a,b,i,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	s="."+s+".";
	for(i=a;i<max(c,d);i++)
	{
		if(s[i]=='#'&&s[i+1]=='#')
		{
			cout<<"No"<<endl;
			exit(0);
		}
	}
	if(c<d)
	{
		cout<<"Yes"<<endl;
		exit(0);
	}
	for(i=b;i<=d;i++)
	{
		if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
		{
			cout<<"Yes"<<endl;
			exit(0);
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 772
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))

for i in range(n-k):
    if lst1[i] >= lst1[i+k]:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 93040
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n,m;
    cin>>n>>m;
    
    vector<pair<int,int>> vec(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        vec[i]=make_pair(b-1,a);
    }
    sort(all(vec));
    
    int ans=0;
    int now=-1;
    rep(i,m){
        int left,right;
        tie(right,left)=vec[i];
        if(left>now){
            ans++;
            now=right;
        }
    }
    cout<<ans<<endl;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    bool ans = false;
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n;i++)
    {
        cin>>a[i];
    }
    sort(all(a));
    if(a[0]==0&&a[n-1]==0)
    {
        ans=true;
    }
    else if(n%3==0)
    {
        ll nn = n/3;
        if(a[0]==a[nn-1] && a[nn]==a[nn*2-1] && a[nn*2]==a[nn*3-1])
        {
            if(a[0]==0 && a[nn]==a[nn*2])
            {
                ans=true;
            }
            else if ((a[0]^a[nn])==a[nn*2])
            {
                ans=true;
            }
        }
    }
    if(ans==true)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 1024
from array import array;
while True:
    n = int(raw_input())
    if n == 0:
        break
    m = int(raw_input())

    s = raw_input()

    cache = array('i', (0 for x in xrange(m)))

    for i in xrange(len(s) - 2):
        if s[i:i+3] == 'IOI':
            cache[i + 2] = cache[i] + 1

    print len(filter(lambda x: x >= n, cache))

Measured memory_bytes: 26888
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }

private fun gcd(a: Long, b: Long): Long = when {
    a < b -> gcd(b, a)
    b == 0L -> a
    else -> gcd(b, a % b)
}

private fun lcm(a: Long, b: Long) = a / gcd(a, b) * b
private fun gcd(a: Int, b: Int) = gcd(a.toLong(), b.toLong()).toInt()
private fun lcm(a: Int, b: Int) = lcm(a.toLong(), b.toLong()).toInt()

fun main(args: Array<String>) {
    val N = readInts()[0]
    val s = readLine()!!

    println(if (s.count { it == 'R' } > s.count { it == 'B' }) "Yes" else "No")    
}

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

int nn[1010],mm[1010],cnt[1010];
int main(){
	int N,M;
	cin>>N>>M;
	for(int i=1;i<=N;i++) cin>>nn[i];
	for(int i=1;i<=M;i++) cin>>mm[i];

	for(int i=1;i<=M;i++){
		for(int j=1;j<=N;j++){
			if(nn[j]<=mm[i]){
				cnt[j]++;
				break;
			}
		}
	}
	int res=0,tmp=0;
	for(int i=1;i<=N;i++){
		if(tmp<cnt[i]){
			res=i;tmp=cnt[i];
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc135/tasks/abc135_c



N = gets.to_i
monsters = gets.split.map(&:to_i)
fighters = gets.split.map(&:to_i)

ans = 0
fighters.each_with_index do |fighter, idx|
  this_city_monster = monsters[idx]
  next_city_monster = monsters[idx + 1]
  if fighter > this_city_monster
    ans += this_city_monster
    remain = fighter - this_city_monster
    monsters[idx + 1] = [next_city_monster - remain, 0].max
    ans += [remain, next_city_monster].min
  else
    ans += fighter
  end
end
puts ans


Measured memory_bytes: 19232
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
sat = sum(B)
for i in range(1, N):
    if A[i]  - A[i - 1] == 1:
        sat += C[A[i - 1] -1]
print(sat)

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


int main() {


int n;
cin>>n;
ll ans=0;
for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
    ans=ans+i;
    }
}
cout<<ans<<endl;

}

Measured memory_bytes: 3628
def B_OrdinaryNumber():
    n = int(input())
    pn = list(map(int, input().split()))
    ans = 0
    for i in range(n - 2):
        if ((pn[i] < pn[i + 1]) and (pn[i+1] < pn[i+2])) or ((pn[i] > pn[i + 1]) and (pn[i+1] > pn[i+2])):
            ans += 1
    print(ans)
    
if __name__ == "__main__":
    B_OrdinaryNumber()

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

int main() {
    int N, K, ans = 0;
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if(x <= K - x) {
            ans += x * 2;
        } else {
            ans += (K - x) * 2;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int,input().split())

from heapq import *

B1 = []
hpu = heappush
hpp = heappushpop
for a in A[:N]:
    hpu(B1,a)
S1 = [sum(B1)]
for a in A[N:2*N]:
    S1.append(S1[-1]+ a - hpp(B1,a))
B2 = []
for a in A[2*N:]:
    hpu(B2,-a)
S2 = [-sum(B2)]
for a in A[N:2*N][::-1]:
    S2.append(S2[-1] + a + hpp(B2,-a))

print(max(S1[i]-S2[-i-1] for i in range(N+1)))

Measured memory_bytes: 38676
#include<stdio.h>
#include<math.h>

int main(void) {

  int n,i;
  double x[4],y[4],a[2],b[2],c[2],r;

  scanf("%d",&n);

  while(n--){
    for(i=1;i<4;i++)
    scanf("%lf %lf",&x[i],&y[i]);

    a[0]=2*(x[2]-x[1]);
    b[0]=2*(y[2]-y[1]);
    c[0]=x[1]*x[1]-x[2]*x[2]+y[1]*y[1]-y[2]*y[2];

    a[1]=2*(x[3]-x[1]);
    b[1]=2*(y[3]-y[1]);
    c[1]=x[1]*x[1]-x[3]*x[3]+y[1]*y[1]-y[3]*y[3];

    x[0]=(b[0]*c[1]-b[1]*c[0])/(a[0]*b[1]-a[1]*b[0]);
    y[0]=(c[0]*a[1]-c[1]*a[0])/(a[0]*b[1]-a[1]*b[0]);

    r=sqrt(pow(fabs(x[1]-x[0]),2)+pow(fabs(y[1]-y[0]),2));

    printf("%.3f %.3f %.3f\n",x[0],y[0],r);
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int n, k;
	cin >> n >> k;
	int cnt = 0;
	do {
		n /= k;
		cnt++;
	} while (n);
	cout << cnt;
}


Measured memory_bytes: 384
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k;
string s;
vector<int> v;

inline int solve(){
	cin>>n>>s>>k;
	k--;
	for(int i=0;i<n;i++){
		if(s[i]!=s[k]) s[i]='*';
	}
	//~ s[k]='*';
	cout<<s<<endl;
	
	return 0;
}

int main(void){
	solve();
	
	return 0;
}


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

using namespace std;

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

    vector<int> aa;
    map<int, int> mp;


    int next = 0;
    int index;

    while (1) {
        aa.push_back(next);
        mp[next] = aa.size();
        next = a[next];
        mp[next];
        if (mp[next] != 0) {
            index = mp[next] - 1;
            break;
        }
    }

    int loop = aa.size() - index;

    if (k < aa.size()) {
        cout << (aa[k] + 1) << endl;
    } else {
        k -= index;
        k %= loop;
        cout << (aa[index + k] + 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 13896
#include <iostream>
using namespace std;
#define INF 200000000

int n,m[101],cm[101][101];

void calc(){
  int i,j,l,p,k;
  for (i=0;i<n;i++)cm[i][i]=0;
  for (l=1;l<n;l++){
    for(i=0;i<n-l;i++){
      j=i+l;
      cm[i][j]=INF;
      //cout << i << " "<< j << endl;
      for (k=i;k<j;k++){
	//cout << i << " "<< j <<" "<< k<<" "<<cm[i][k]<<" "<<cm[k+1][j] <<  endl;
	p=cm[i][k]+cm[k+1][j]+m[i]*m[k+1]*m[j+1];
	cm[i][j]=min(cm[i][j],p);
      }
    }
  }
}

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

  calc();

  cout << cm[0][n-1]<<endl;
  
  return 0;
}

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

using namespace std;

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

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

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

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

stack<int> st;

bool isop(string s) {
	return s == "+" || s == "-" || s == "*"||s=="/";
}

int solve(string str) {
	int b = st.top(); st.pop();
	int a = st.top(); st.pop();

	if (str == "+")return a + b;
	if (str == "-")return a - b;
	if (str == "*")return a * b;
	if (str == "/")return a / b;
}


int main() {
	

	string tk;
	
	while (cin >> tk) {
		if (isop(tk)) {
			st.push(solve(tk));
		}
		else {
			st.push(stoi(tk));
		}
	}

	cout << st.top() << endl;

	return 0;
}


Measured memory_bytes: 3200
N = int(input())
l  = []

for i in range(N):
	a = int(input())
	l.append(a)

l_max = max(l)
max_index = l.index(max(l))

for i in range(N):
	if i == max_index:
		b = l.pop(i)
		print(max(l))
	else:
		print(l_max)

Measured memory_bytes: 12520
#include <stdio.h>

int fibonacci(int);

int fibo[44];

int main(){
  int n,i;
  scanf("%d",&n);
  for(i=0;i<=44;i++)
    fibo[i]=-1;
  printf("%d\n",fibonacci(n));
  return 0;
}

int fibonacci(int n){
  if(n==0||n==1)
    return fibo[n]=1;
  if(fibo[n]!=-1)
    return fibo[n];
  return fibo[n] = fibonacci(n-1)+fibonacci(n-2);
}



Measured memory_bytes: 2712
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  llint x;
  std::cin >> x;

  for(llint i=-1000; i<1001; i++){
    for(llint j=-1000; j<1001; j++){
      llint tmp = i*i*i*i*i - j*j*j*j*j;
      if(x == tmp){
	std::cout << i << " " << j << std::endl;
	return 0;
      }
    }
  }


  return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int x, y, z;
    cin >> x >> y >> z;

    int tmp;

    tmp = x;
    x = y;
    y = tmp;

    tmp = x;
    x = z;
    z = tmp;

    cout << x << " " << y << " " << z << endl;
}

int main() {
    solve();

    return 0;
}


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

signed main() { 
        int n, m, i, j;
        cin >> n >> m;
        bool ans[404][404];
        for (i = 0; i < n; i ++) for (j = 0; j < n; j ++) ans[i][j] = true;
        while (m --) {
                int x, y;
                cin >> x >> y;
                x --;
                y --;
                if (ans[x][y]) {
                        for (j = 0; j < n; j ++) {
                                if (!ans[x][j]) {
                                        ans[y][j] = false;
                                        ans[j][y] = false;
                                }
                        }
                        for (j = 0; j < n; j ++) {
                                if (!ans[y][j]) {
                                        ans[x][j] = false;
                                        ans[j][x] = false;
                                }
                        }
                } else {
                        for (j = 0; j < n; j ++) {
                                ans[x][j] = false;
                                ans[j][x] = false;
                                ans[y][j] = false;
                                ans[j][y] = false;
                        }
                }
                ans[x][y] = false;
                ans[y][x] = false;
        }
        int res = 0;
        for (i = 0; i < n; i ++) for (j = i + 1; j < n; j ++) if (ans[i][j]) res ++;
        cout << res << endl;
        return 0;
}               


Measured memory_bytes: 384
// I want to AC  


#include <vector>
#include<stdio.h>
#include<string.h>
#include <cstring>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <set>
#include<cstring>
#include<queue>
#include<assert.h>
#define ll long long
#define MODD 1000000007
#define  pii  pair<int,int>
#include<stdio.h>
#include<string.h>
//#define  ll long long
using namespace std;
const int maxn = 1e6;


ll exgcd(ll a, ll b, ll &x, ll &y) {
 if (b == 0) { x = 1; y = 0; return a; }
 ll ret = exgcd(b, a % b, y, x);
 y -= a / b * x;
 return ret;
 }
ll inv(ll a, ll M) {
 static ll x, y;
 assert(exgcd(a, M, x, y) == 1);
 return (x % M + M) % M;
 }
//void gcd(ll a,ll b,ll &d,ll &x,ll &y){
//    if(!b){
//        d=a;x=1;y=0;
//    }else{
//        gcd(b,a%b,d,y,x);
//        y-=x*(a/b);
//    }
//}
//ll inv(ll a,ll n){
//    ll d,x,y;
//    gcd(a,n,d,x,y);
//    return d==1?(x+n)%n:-1;
//}
// LL get_inv(LL a, LL M) {
// static LL x, y;
// assert(exgcd(a, M, x, y) == 1);
// return (x % M + M) % M;
// }

//欧拉函数
ll euler(ll n)
{
    ll rt = n;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0)
        {
            rt -= rt / i;
            while (n % i == 0)
                n /= i;
        }
    if (n > 1)
        rt -= rt / n;
    return rt;
}

bool st[1000005];
int primes[50005];
void prime(int n)
{
    int cnt =0 ;
	for(int i=2;i<=n;i++)
	{
		if(!st[i])
		{
			primes[cnt++]=i;
		}
		for(int j=0;j<cnt&&i*primes[j]<=n;j++)
		{
			st[primes[j]*i]=true;
			if(i%primes[j]==0)
			{
				break;
			}
		}
	}

}


vector<int > div(int x){
	vector<int > res;
	for(int i=1 ;i<=x/i;i++) {
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i) res.push_back(x/i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}
ll mod = 1e9+7;
inline void read(int &x){
    x=0;int f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x*=f;
}


int cnt =0 ;
int dp[maxn],ar[maxn];
char ch [2500][2500];
int main() {
  	
	string s, ss;cin >>s>>ss;
	int n,m;cin >>n>>m;
	string sss;cin >>sss;
	if(sss==s){
		n--;
	}
	else m--;
	cout<<n<<" "<<m<<endl;
    return 0;



}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
  int a,q;cin >>a >> q;
  int sum = a*3 + q;
  cout << sum / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
const int INF=1001001001;
using namespace std;
int a[12][12];
int main(){
  int n,m,x;
  cin>>n>>m>>x;
  vector<int> c(n);
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  int ans=INF;
  for(int s=0;s<(1<<n);s++){
    int cost=0;
    vector<int> d(m);
    for(int i=0;i<n;i++){
      if(s>>i&1){
        cost+=c[i];
        for(int j=0;j<m;j++) d[j]+=a[i][j];
      }
    }
    bool ok=true;
    for(int j=0;j<m;j++) if(d[j]<x) ok=false;
    if(ok) ans=min(ans,cost);
  }
  if(ans==INF) cout<<-1<<endl;
  else cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3616
import heapq
from collections import defaultdict, deque
from math import ceil, factorial
from fractions import gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


N = ii()

ans = 0
for i in range(1, N+1):
    if i % 3 and i % 5:
        ans += i

print(ans)


Measured memory_bytes: 10392
n = int(input())
al = list(map(int, input().split()))

a_val_ind_l = []
for i, a in enumerate(al):
    a_val_ind_l.append((a,i))

a_val_ind_l.sort(reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]


for i in range(n):
    for j in range(0,n-i):
        dp[i+1][j] = max(dp[i][j] + a_val_ind_l[i+j][0] * abs(a_val_ind_l[i+j][1]-i), dp[i+1][j])
        dp[i][j+1] = max(dp[i][j] + a_val_ind_l[i+j][0] * abs(n-1-a_val_ind_l[i+j][1]-j), dp[i][j+1])


ans = 0
for row in dp:
    row_max = max(row)
    ans = max(row_max, ans)

print(ans)

Measured memory_bytes: 105480
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int a, b;
  cin >> a >> b;
  
  string ans = "";
  if (a <= b) {
    rep(i,b) ans += ('0' + a);
  } else {
    rep(i,a) ans += ('0' + b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
program prob2
    implicit none
    integer(8)::N, i
    integer(16):: ans
    integer(8), allocatable::A(:)
    read(*,*) N
    allocate(A(N))
    ans = 1

    read(*,*) A
    do i = 1,N
        if(A(i) == 0)then
            write(*,*) 0
            stop
        end if
    end do

    do i = 1, N
        ans = ans*A(i)
        if(ans > 10_8**18)then
            write(*,*) -1
            stop
        end if
    end do
    write(*,*) ans

    deallocate(A)
    stop
end program prob2

Measured memory_bytes: 3936
W,H,N = map(int,input().split())
XYA = [list(map(int,input().split())) for _ in range(N)]

E = [0,W,0,H]

for x,y,a in XYA:
  a -= 1
  XY = [x,y]
  if a % 2 == 0:
    E[a] = max(E[a],XY[a//2])
  else:
    E[a] = min(E[a],XY[a//2])

ans = 0
if E[0] < E[1] and E[2] < E[3]:
  ans = (E[1] - E[0]) * (E[3] - E[2])
  
print(ans)




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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char k[122];
    Scs(k);

    int a = 0;
    int n = strlen( k );
    Rep(i,15){
        if( k[i] == 'o' )
            a++;
    }

    if( ( 15 - n ) + a >= 8 ) printf ("YES\n");
    else printf ("NO\n");


    return 0;
}



Measured memory_bytes: 256
import sys

n = 104730
a = [True] * n
a[0] = a[1] = False
for i in xrange(2,n):
	if(a[i]):
		for j in xrange(i+i, n, i):
			a[j] = False
a = [i[0] for i in enumerate(a) if i[1]]

for s in sys.stdin:
	n = int(s)
	if n == 0:
		exit()
	print(sum(a[:n]))

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

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

  for (int i = 0; i < N; i++) {
    if (M <= K) M *= 2;
    else M += K;
  }
  
  cout << M << endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;

int main(){
    cin >> n;
    if(n == 7 || n == 5 || n == 3)  cout << "YES\n";
    else    cout << "NO\n";
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn gcd(a: usize, b: usize) -> usize {
    if b != 0 {
        gcd(b, a % b)
    } else {
        a
    }
}
fn lcm(a: usize, b: usize) -> usize {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        n: usize,
        t: [usize; n],
    }
    let mut l = 1;
    for t in t {
        l = lcm(t, l);
    }
    println!("{}", l);
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
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 long long INF = 1LL<<60;

int main() {
    int N, M;
    while (cin >> N >> M, N) {
        vector<vector<long long> > dps(N, vector<long long>(N, INF)), dpl(N, vector<long long>(N, INF));
        for (int v = 0; v < N; ++v) dps[v][v] = dpl[v][v] = 0;
        for (int e = 0; e < M; ++e) {
            int x, y;
            long long w;
            char type;
            cin >> x >> y >> w >> type;
            --x, --y;
            if (type == 'L') chmin(dpl[x][y], w), chmin(dpl[y][x], w);
            else chmin(dps[x][y], w), chmin(dps[y][x], w);
        }
        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    dpl[i][j] = min(dpl[i][j], dpl[i][k] + dpl[k][j]);
                    dps[i][j] = min(dps[i][j], dps[i][k] + dps[k][j]);
                }
            }
        }
        
        int R; cin >> R;
        vector<int> v(R);
        for (int i = 0; i < R; ++i) cin >> v[i], --v[i];
        
        vector<vector<long long> > dp(R, vector<long long>(N, INF));
        dp[0][v[0]] = 0;
        for (int i = 0; i < R-1; ++i) {
            for (int j = 0; j < N; ++j) {
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + dpl[v[i]][v[i+1]]);
                for (int k = 0; k < N; ++k) {
                    dp[i+1][k] = min(dp[i+1][k], dp[i][j] + dpl[v[i]][j] + dps[j][k] + dpl[k][v[i+1]]);
                }
            }
        }
        long long res = INF;
        for (int i = 0; i < N; ++i) {
            res = min(res, dp[R-1][i]);
        }
        cout << res << endl;
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,k,ans = 1e9;
    cin>>n>>k;
    vector<int> am,ap;
    
    for(int i = 0; i < n; i++)
    {
        int a;
        cin>>a;
        if(a==0) k--;
        else if(a>0) ap.push_back(a);
        else am.push_back(-a);
    }
    reverse(all(am));
    
    if(k==0)
    {
        ans=0;
    }
    else
    {
        for(int mi = 0; mi <= k; mi++)//
        {
            if(mi> am.size()) continue;
            int pi = k-mi;
            if(pi>ap.size()) continue;
            if(mi==0)
            {
                ans = min(ans,ap[pi-1]);
            }
            else if(mi==k)
            {
                ans = min(ans,am[mi-1]);
            }
            else
            {
                ans = min(ans,min(ap[pi-1]+am[mi-1]*2, ap[pi-1]*2+am[mi-1]));
            }
        }
    }
    
    cout<<ans<<endl;

    return 0;
}

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

int sum(int n){
  int ans=0;
  while(n>0){
    ans+=n%10;
    n/=10;
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  cout << (n%sum(n)==0?"Yes":"No") << endl;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

int n,a[101010]; vector<int> g[101010];

int dfs(int v,int p){
   if(g[v].size()==1)return a[v];
   vector<int> cs; int sum=0;
   for(int t:g[v])if(t!=p){
      int c=dfs(t,v);
      cs.push_back(c); sum+=c;
   }
   ll x=2*a[v]-sum,y=(sum-x)/2;
   if(((sum-x)&1) or y<0){puts("NO"); exit(0);}
   int ma=*max_element(ALL(cs));
   if(min(sum-ma,sum/2)<y){puts("NO"); exit(0);}
   return x;
}

int main(){
   cin>>n; rep(i,0,n)cin>>a[i];
   rep(i,0,n-1){
      int x,y; cin>>x>>y; x--; y--;
      g[x].push_back(y); g[y].push_back(x);
   }
   if(n==2){
      printf(a[0]==a[1]?"YES":"NO");
      return 0;
   }
   int r=-1;
   rep(i,0,n)if(g[i].size()>1){
      r=i; break;
   }
   int res=dfs(r,-1);
   printf(res==0?"YES":"NO");
   return 0;
}


Measured memory_bytes: 15488