akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main() {
    string topping;
    cin >> topping;
    int counter = 0;
    for(int i = 0; i < topping.size(); i++) {
        if(topping[i] == 'o') {
            counter++;
        }
    }
    cout << 700 + 100 * counter << endl;
}

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

#define N 100000

int calc(char);
int pop();
void push(int);

int head = 0;
int S[N+1];

int main()
{
  char str[5];
  
  while(scanf("%s",str) != EOF){

    if( str[0] == '+' || str[0] == '-' || str[0] == '*')
      push(calc(str[0]));
    else push(atoi(str));
    
    if(getchar() == '\n'){
      printf("%d\n",pop());
      break;
    }
  }
  return 0;
}

int pop()
{
  return S[--head];
}

void push(int num)
{
  S[head++] = num;
}

int calc(char str){
  int b = pop();
  int a = pop();
  if(str == '+')return a+b;
  else if(str == '-')return a-b;
  else if(str == '*')return a*b;
}




Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

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

void solve(void){
    int N, M;
    cin >> N;
    string blue[100], red[100];
    rep(N, i){
        cin >> blue[i];
    }
    sort(blue, blue+N);
    cin >> M;
    rep(M, i){
        cin >> red[i];
    }
    sort(red, red+M);

    int i = 0, j = 0, maxi = 0;
    while(i < N){
        int t = 1;
        while(blue[i] == blue[i+1]) {
            i++; t++;
        }
        while(blue[i] > red[j] and j < M) j++;
        if (blue[i] == red[j]) {
            t--;
            while(red[j] == red[j+1] and j < M) {
                j++; t--;
            }
        }
        maxi = max(t, maxi);
        i++;
    }
    cout << maxi << '\n';

}

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


Measured memory_bytes: 256
N, M, X = map(int, input().split())
ans = [0] * M

book = []

for i in range(N):
    tmp = list(map(int, input().split()))
    book.append(tmp)

def check(ans):
    for i in range(len(ans)):
        if ans[i] < X:
            return 0
    return 1

price_sum = float("inf")
for i in range(2 ** N):
    ans = [0] * M
    tmp = 0
    for j in range(N):
        if (i >> j & 1):
            tmp += book[j][0]
            for k in range(1, M+1):
                ans[k-1] += book[j][k]
    if check(ans):
        price_sum = min(price_sum, tmp)

if price_sum == float("inf"):
    print(-1)
else:
    print(price_sum)

Measured memory_bytes: 68736
import itertools
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
vc=[]
for i in range(n):
  vc.append(v[i]-c[i])
sv=[]
for L in range(0, len(v)+1):
    for subset in itertools.combinations(vc, L):
      sv.append(sum(subset))
print(max(sv))

Measured memory_bytes: 44568
N = int(input())
L = list(map(int, input().split()))
M = sorted(L)
medi1 = M[N//2-1]
medi2 = M[N//2]
#print(medi1,medi2)
for x in L:
    if x <= medi1:
        ans = medi2
    else:
        ans = medi1
    print(ans)


Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[5]=='1'){
        cout <<"TBD"<<endl;
    }
    else{
        if(s[6]>='5'){
            cout << "TBD"<<endl;
        }
        else{
            cout << "Heisei"<<endl;
        }
    }
    return 0;
}




Measured memory_bytes: 256
import java.awt.*;
import java.awt.geom.*;
import java.io.*;

import java.util.*;
class Main {

	static char[] xx = new char[] {'S','H','C','D'};
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[][] l = new boolean[4][13];
		for(int i = 0; i < n; i++) {
			char k = sc.next().charAt(0);
			int r = sc.nextInt();
			if(k == 'S') {
				l[0][r-1] = true;
			}
			if(k == 'H') {
				l[1][r-1] = true;
			}
			if(k == 'C') {
				l[2][r-1] = true;
			}
			if(k == 'D') {
				l[3][r-1] = true;
			}
		}
		for(int i = 0 ; i< 4; i++) {
			for(int j = 0; j < 13; j++) {
				if(!l[i][j]) {
					System.out.println(xx[i] + " " + (j+1));
				}
			}
		}
	}
}

Measured memory_bytes: 18256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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 <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e18+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<ll,int>> a(n);
    rep(i,0,n){
        ll x; cin >> x;
        a[i] = make_pair(x,i);
    }
    sort(all(a));
    ll ans = 0ll;
    rep(i,0,n){
        if(i%2!=a[i].second%2){
            ans++;
        }
    }
    ans /= 2ll;
    cout << ans << endl;
}

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

int main(){
    vector<vector<int>>A(3,vector<int>(3,0));
    int N;
    vector<int>B(10);
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >>A.at(i).at(j);
        }
    }
    cin >>N;
    for(int i=0;i<N;i++){
        cin>>B.at(i);
    }
    for(int k=0;k<N;k++){
        for(int i=0;i<3;i++){
            for(int j=0;j<3;j++){
                if(B.at(k)==A.at(i).at(j)){
                    A.at(i).at(j)=0;
                }
            }
        }
    }
    if(A.at(0).at(0)==0&&A.at(1).at(0)==0&&A.at(2).at(0)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(0).at(0)==0&&A.at(0).at(1)==0&&A.at(0).at(2)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(0).at(0)==0&&A.at(1).at(1)==0&&A.at(2).at(2)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(1).at(0)==0&&A.at(1).at(1)==0&&A.at(1).at(2)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(2).at(0)==0&&A.at(2).at(1)==0&&A.at(2).at(2)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(0).at(1)==0&&A.at(1).at(1)==0&&A.at(2).at(1)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(0).at(2)==0&&A.at(1).at(2)==0&&A.at(2).at(2)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(A.at(0).at(2)==0&&A.at(1).at(1)==0&&A.at(2).at(0)==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout <<"No"<<endl;
}

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

int main() {
	int n;
	scanf("%d", &n);
	int a[n+1];
	for (int i = 0; i < n+1; i++) {
		scanf("%d", &a[i]);
	}
	int b[n];
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	long int m = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < b[i]) {
			m+=a[i];
			if (a[i+1] < b[i]-a[i]) {
				m+=a[i+1];
				a[i+1] = 0;
			}else {
				m-=a[i];
				m+=b[i];
				a[i+1] -= b[i]-a[i];
			}
		}else {
			m+= b[i];
		}
	}
	printf("%ld", m);
	return 0;
}

Measured memory_bytes: 896
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

dist = 1
tmp = abs(T - H[0]*0.006 - A)
for i in range(1,N):
  tempra = abs(T - H[i]*0.006 - A)
  if(tempra < tmp):
    tmp = tempra
    dist = i + 1
print(dist)

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

using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)

typedef long long ll;

int main() {
    int N, K; cin >> N >> K;
    int h[N];
    rep(i,N) cin >> h[i];
    sort(h, h+N);
    int ans = 1e9;
    //前からK個だけ見る
    for(int i=0;i<N-K+1;i++){
        ans = min(ans, h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int n;
int num[500000];
long long ans;
string s;
int main(){
    cin>>s;
    int n=s.size()+1;
    s=">"+s+"<";
    for(int i=0;i<n;i++){
        if(s[i]=='<')num[i]=num[i-1]+1;
    }for(int i=n;i;i--){
        if(s[i]=='>')num[i-1]=max(num[i]+1,num[i-1]);
    }
    for(int i=0;i<n;i++)ans+=num[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2840
#include<stdio.h>
int main(void)
{
  int n,p,a,b,i,d;
  for(;;){
    scanf("%d",&n); if(!n)break;
    d=0;
    while(n--){
      scanf("%d%d%d",&p,&a,&b);
      if(d<a+b)d=a+b,i=p;
    }
    printf("%d %d\n",i,d);
  }
  return 0;
}

Measured memory_bytes: 416
#include <stdio.h>
int main (){
int n,a,b,k,sum=0;
scanf ("%d%d%d",&n,&a,&b);
  for (int i=1;i<n+1;i++){
  if (i==10000){
  k=1;
  }
  else {
  k=(i/1000)+((i%1000)/100)+((i%100)/10)+(i%10);
  }
  if (k>a-1 && k<b+1){
  sum=sum+i;
  }
  }
  printf ("%d",sum);
return 0;
}

Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var n = ScanInt();
      var a = ScanIntArray();
      int max = 0;
      int count = 0;
      for(int i=0; i<n; i++){
        if(a[i]>=max) count++;
        max = Math.Max(max, a[i]);
      }
      
      WriteLine(count);
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 2018;

int n, k, q, i, j, ans;
int a[maxN];
vector<int> v, glob, loc;

void execute() {
    if (loc.size() < k) {
        loc.clear();
        return;
    }

    nth_element(loc.begin(), loc.begin() + (loc.size() - k), loc.end());
    //sort(loc.begin(), loc.end());
    loc.resize(loc.size() - k + 1);
    for (auto e : loc) glob.pb(e);

    loc.clear();
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d%d%d", &n, &k, &q);
    for (i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        v.pb(a[i]);
    }
    
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());

    ans = 1 << 30;
    for (auto base : v) {
        glob.clear();
        
        loc.clear();
        for (i = 1; i <= n; i++) {
            if (a[i] < base) {
                execute();
            } else {
                loc.pb(a[i]);
            }
        }
        execute();

        if (glob.size() < q) break;
        nth_element(glob.begin(), glob.begin() + q - 1, glob.end());
        //sort(glob.begin(), glob.end());

        //cerr << base << ' ' << '\n';
        //for (auto e : glob) cerr << e << ' ';
        //cerr << "\n\n";

        int maxi = glob[q - 1];
        ans = min(ans, maxi - base);
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 500000
#define INFINITY 1000000000
void merge(int *, int, int, int);
void mergeSort(int *, int, int);

int count=0;
int main(){
  int i,n,S[MAX];

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

  mergeSort(S,0,n);
  
  for(i=0; i<n; i++){
    printf("%d",S[i]);
    if(i == n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

void merge(int *S, int left, int mid, int right){
  int i,j,k;
  int L[MAX],R[MAX];
  int n1 = mid-left;
  int n2 = right-mid;

  for(i=0; i<n1; i++){
    L[i] = S[left+i];
  }
  for(i=0; i<n2; i++){
    R[i] = S[mid+i];
  }
  L[n1] = INFINITY;
  R[n2] = INFINITY;
  i = 0;
  j = 0;
  for(k=left; k<right; k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i+1;
    }
    else{
      S[k] = R[j];
      j = j+1;
    }
    count++;
  }  
  
}

void mergeSort(int *S, int left, int right){
  int mid;
  if(left+1 < right){
    mid = (left+right)/2;
    mergeSort(S, left, mid);
    mergeSort(S, mid, right);
    merge(S,left,mid,right);
  }

}




Measured memory_bytes: 5616
#include <iostream>

#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef long long ll;

int main()
{

    int a, b;
    cin >> a;
    cin >> b;

    if (b > (a / 2))
        cout << "0" << endl;
    else
        cout << a - (b * 2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define loop(i,L,R) for(int i=(L);i<=(R);i++)
const int maxn=1e5+5;
int a[maxn];
int main()
{
    int n,k,ma=0;
    scanf("%d%d",&n,&k);
    loop(i,1,n)
    {
        int p,s=1;
        rep(j,20)
        {
            if(i*s>=k)
            {
                p=j;
                break;
            }
            s*=2;
        }
        ma=max(ma,p);
        a[i]=p;
    }
    ll x=0;
    ll y=(ll)n*(ll)pow(2,ma);
    loop(i,1,n)
    {
        x+=(ll)pow(2,ma-a[i]);
    }
    printf("%.12f\n",(double)x/(double)y);
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n + 1);
    cin >> a;
    vl ne_max(n + 1);
    rep(i, n + 1) {
        ll maxv = 0;
        if (i > 50)
            maxv = ll_inf;
        else
            maxv = pow(2, i);
        if (i >= 1) {
            ne_max[i] = max(0LL, min(ne_max[i - 1] * 2 - a[i], maxv - a[i]));
        } else {
            ne_max[i] = max(0LL, maxv - a[i]);
        }
    }
    if (n == 0) {
        if (a[0] == 0) cout << 0 << '\n';
        else if (a[0] ==1) cout << 1 << '\n';
        else cout << -1 << '\n';
        return;
    }

    if (a.back() == 0) {
        cout << -1 << '\n';
        return;
    }
    ll now_v = a.back();
    ll ans = now_v;
    for (ll i = n - 1; i >= 0; --i) {
        if (now_v > ne_max[i] * 2) {
            cout << -1 << '\n';
            return;
        }
        now_v = min(ne_max[i] + a[i], now_v + a[i]);
        ans += now_v;
    }
    if (ans < 0) {
        cout << -1 << '\n';
    } else
        cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 4876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
int row[10],col[10];
main()
{
    int h,w,n,i,j,cnt=0,ans=0,i1,j1,k;
    cin>>h>>w>>n;
    char s[h][w+5];
    for(i=0;i<h;i++)
    {
        cin>>s[i];
    }
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(s[i][j]=='#')
            {
                row[i]++;col[j]++;cnt++;
            }
        }
    }
    //cout<<cnt<<endl;
    int a[h],b[w];
    int w1=pow(2,h),w2=pow(2,w);
    for(i=0;i<w1;i++)
    {
        for(j=0;j<w2;j++)
        {
            int g1=i,h1=j;
            for(k=h-1;k>=0;k--)
            {
                a[k]=g1%2;
                g1/=2;
            }
            for(k=w-1;k>=0;k--)
            {
                b[k]=h1%2;
                h1/=2;
            }
            /*if(i==2 && j==2)
            {
                for(int l=0;l<h;l++)
                {
                    cout<<a[l];
                }
                cout<<endl;
            }*/
            int d=cnt;
            for(i1=0;i1<h;i1++)
            {
                for(j1=0;j1<w;j1++)
                {
                    if(s[i1][j1]=='#' && (a[i1]==1 || b[j1]==1))
                    {
                        d--;
                    }
                }
            }
            if(d==n)
            {
                ans++;
            }
            //cout<<i<<" "<<j<<" "<<d<<endl;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
string s;
vector<char>a;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C'||s[i]=='F')
			a.push_back(s[i]);
	}
	if(a.empty())
	{
		puts("No");
		return 0;
	}
	for(int i=0;i<a.size()-1;i++)
	{
		if(a[i]=='C'&&a[i+1]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  1000001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, a[max];
    int dp[max];
    
    scanf("%d", &n);
    rep(i, n){
        scanf("%d", &a[i]);
    }
    
    qsort(a, n, sizeof(int), up_comp);
    int last=a[n-1];
    
    rep(i, last+1){
        dp[i]=0;
    }
    dp[0]=10;
    
    rep(i, n){
        int j=0;
        while (a[i]*j<=last) {
            dp[a[i]*j]++;
            j++;
            //printf("%d\n", j);
        }
    }
    
    int cnt=0;
    rep(i, last+1){
        if (dp[a[i]]==1) {
            //printf("%d, ", a[i]);
            cnt++;
        }
    }
    
    printf("%d\n", cnt);
    
    return 0;
}



Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,x,d=0;
    cin>>a>>b>>c>>x;
    for(int i=0; i<=a; i++){
        for(int g=0; g<=b; g++){
            for(int t=0; t<=c; t++){
                if(500*i+100*g+50*t==x){
                    d++;
                }
            }
        }
    }
    cout<<d<<endl;
    return 0;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, x;
	cin >> n >> x;
	vector<ll> L(n), D(n + 1, 0);
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		D[i + 1] = D[i] + L[i];
		if (D[i + 1] <= x) ans++;
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
N, Q = [int(x) for x in input().split()]
to = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b = [int(x)-1 for x in input().split()]
    to[b].append(a)
    to[a].append(b)
ans = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    p -= 1
    ans[p] += x

from collections import deque
q = deque()
q.append(0)
visited = [0] * N

while(q):
    v = q.pop()
    visited[v] = 1    
    for u in to[v]:
        if visited[u] == 1: continue
        ans[u] += ans[v]
        q.append(u)
print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 122104
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 2600;
const int MLOG = 18;
const int NMAX = 60;

#define int ll
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define ct(x) const_cast<const int&>(x)

signed main(){
	int n, ans = 0;
	cin >> n;	
	int a;
	for(int i = 0 ; i < n ; i++){
		cin >> a;
		while(a%2 == 0 && a > 0){
			ans++;
			a /= 2;
		}
	}
	cout << ans ;
}

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

bool palindrome(string s){
  string t(s.rbegin(), s.rend());
  return s==t;
}

int main(){
  string s;
  cin >>s;
  int n = s.size();
  if(palindrome(s) && palindrome(s.substr(0,(n-1)/2)) && palindrome(s.substr((n+1)/2))){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}



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

int main() {
  string s;
  int k;
  cin >> s >> k;
  
  int l = s.size();
  for(int i = 0; i < l; i++){
    char now = s.at(i);
    if(now == 'a' && i < l-1) continue;
    int dis = 'z' - now + 1;
    if(i == l-1) s.at(i) = 'a' + (s.at(i) + k - 'a') % 26;
    else if(k >= dis) s.at(i) = 'a', k -= dis;
  }
  
  cout << s << endl;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll k,s=0;
    cin>>k;
    for(int a=1;a<=k;a++)
    {
        for(int b=1;b<=k;b++)
        {
            for(int c=1;c<=k;c++)
            {
                 ll temp=gcd(a,b);
                 s+=(gcd(temp,c));
            }
        }
    }
    cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 3608
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
               self.rank[x] += 1

class Kruskal:
    def __init__(self, Q, n):
        self.uf = UnionFind(n)
        self.cost = 0
        self.Q = Q
        for i in range(2 * (n - 1)):
            w, u, v = self.Q[i][0], self.Q[i][1], self.Q[i][2] 
            if self.uf.same_check(u, v) != True:
                self.uf.union(u, v)
                self.cost += w

#処理内容
def main():
    N = int(input())
    Lx = []
    Ly = []
    for i in range(N):
        x, y = getlist()
        Lx.append((x, i))
        Ly.append((y, i))
    Lx = sorted(Lx)
    Ly = sorted(Ly)
    Q = []

    for i in range(N - 1):
        u = Lx[i][1]
        v = Lx[i + 1][1]
        w = Lx[i + 1][0] - Lx[i][0]
        Q.append((w, u, v))
        u = Ly[i][1]
        v = Ly[i + 1][1]
        w = Ly[i + 1][0] - Ly[i][0]
        Q.append((w, u, v))
    Q = sorted(Q)
    Km = Kruskal(Q, N)
    print(Km.cost)

if __name__ == '__main__':
    main()

Measured memory_bytes: 115292
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int size = s.size();
  int i;
  for(i=0;i<size-1;i++){
    if(s[i]==s[i+1]){
      cout << i+1 << " " <<i+2 << "\n";
      return 0;
    }
    else if(s[i]==s[i+2]){
      cout << i+1 << " " <<i+3 << "\n";
      return 0;
    }
  }
  cout << -1 << " " << -1 << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  if(s.size()>k){
  string r=s.substr(0,k);
  string m="...";
  r.append(m);
  cout << r;
  }
  else{
    cout << s;
  }
  return 0;
}

Measured memory_bytes: 3596
x1, y1, x2, y2 = gets.split.map(&:to_i)

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

puts "#{x3} #{y3} #{x4} #{y4}"

Measured memory_bytes: 1788
#include <iostream>
#include <stack>

using namespace std;

const int maxn = 2e5;
long long a[maxn + 100];
pair <long long, long long> p[maxn + 100];
stack <pair<int, int> > s;

int main() {
    int n;
    long long ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++){
        if (s.empty() || s.top().first < a[i]){
            p[i].first = 1;
        }
        else {
            while (!s.empty() && s.top().first > a[i]){
                s.pop();
            }
            if (!s.empty()){
                p[i].first = i - s.top().second + 1;
            }
            else
                p[i].first = i + 1;
        }
        s.push(make_pair(a[i], i + 1));
    }

    while (!s.empty())
        s.pop();

    for (int i = n - 1; i >= 0; i--){
        if (s.empty() || s.top().first < a[i]){
            p[i].second = 1;
        }
        else {
            while (!s.empty() && s.top().first > a[i]){
                s.pop();
            }
            if (!s.empty()){
                p[i].second = s.top().second - i - 1;
            }
            else
                p[i].second = n - i;
        }
        s.push(make_pair(a[i], i + 1));
    }
    long long sum = 0;
    for (int i = 0; i < n; i++){
        sum += 1ll * p[i].second * p[i].first * a[i];
    }
    cout << sum << endl;
}

Measured memory_bytes: 6528
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
const int N=1e6+5;
typedef long long ll;
int a[N],a1[N];
int b[N],b1[N];
int n,cnt;
map<int,int>z;
int fa[N],sz[N];
int find_father(int x){
    if(fa[x]==x)
        return x;
    return fa[x]=find_father(fa[x]);
}
void Merge(int x,int y){
    int f1=find_father(x),f2=find_father(y);
    if(f1==f2)
        return ;
    fa[f1]=f2;
    sz[f2]+=sz[f1];
    return ;
}
int main()
{
    scanf("%d",&n);
    int x=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        x^=a[i];
    }
    a[n+1]=x;
    x=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        x^=b[i];
    }
    b[++n]=x;
    bool flag=true;
    for(int i=1;i<=n;i++){
        if(a[i]!=b[i]){
            flag=false;
        }
        a1[i]=a[i];
        b1[i]=b[i];
    }
    if(flag){
        puts("0");
        return 0;
    }
    sort(a1+1,a1+n+1);
    sort(b1+1,b1+n+1);
    for(int i=1;i<=n;i++){
        if(a1[i]!=b1[i]){
            puts("-1");
            return 0;
        }
        if(z.find(a1[i])==z.end())
            z[a1[i]]=++cnt;
    }
    for(int i=1;i<=cnt;i++)
        fa[i]=i,sz[i]=1;
    for(int i=1;i<=n;i++){
        a[i]=z[a[i]];
        b[i]=z[b[i]];
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(a[i]!=b[i]){
            ans++;
            Merge(a[i],b[i]);
        }
    }
    ans+=find_father(a[n])==a[n]&&sz[a[n]]==1;
    for(int i=1;i<=cnt;i++){
        if(find_father(i)==i&&sz[i]>1)
            ans++;
    }
    ans--;
    printf("%d\n",ans);
}


Measured memory_bytes: 21248
H, W = map(int, input().split())
c = [0] * 10
for i in range(10):
    c[i] = list(map(int, input().split()))
A = [0] * H
for i in range(H):
    A[i] = list(map(int, input().split()))


def warshall_floyd(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


d = warshall_floyd(c)
cnt = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        else:
            cnt += c[A[i][j]][1]
print(cnt)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(ll i=a;i<b;i++)
#define rFor(i,a,b) for(ll i=a;i>b;i--)
#define wFor(i,a,b) for(ll i=a;i<b;i+=2)
#define wrFor(i,a,b) for(ll i=a;i>b;i-=2)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//(char-'0') 数字に変換
//vector<vector<int>> data(a,vector<int>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll a;
  ci(a);
  vec b(a);
  For(i,0,a)
    ci(b[i]);
  ll an=0;
  ll k=0;
  For(i,0,a){
    if(b[i]==i+1){
      an++;
      k++;
    }
    else
      k=0;
    if(k>0&&k%2==0)
      an--;
  }
  co(an);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m;cin>>n>>m;
        vector<int> arr(n);
int sum=0;
        for(int i=0; i<n; i++){
cin>>arr[i];
sum+=arr[i];
}
int cnt=0;
for(int i=0; i<n; i++){
 if((double)arr[i]>=((double)sum/(double)(4*m)))cnt++;
}
if(cnt>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>

using namespace std;

class Queue{
private:
  int head;
  int tail;
  int length;
  vector<int> queue;
  vector<string> str_queue;

public:
  Queue(vector<int> vec,int size){
    head=0;
    tail=0;
    queue=vec;
    length=size;
  }
  Queue(vector<int> vec,vector<string> prcss,int size){
    head=0;
    tail=0;
    queue=vec;
    length=size;
    str_queue=prcss;
  }

  bool isEmpty(){
    if(head==tail) return true;
    else return false;
  }

  bool isFull(){
    if((head+1)%length==tail) return true;
    else return false;
  }

  bool enqueue(int value){
    if((head+1)%length==tail) return false;
    else{
      queue.at(head)=value;
      head=(head+1)%length;
    }
  }

  int dequeue(){
    if(head==tail) return -1;
    else{
      int idx=tail;
      tail=(tail+1)%length;
      return queue.at(idx);
    }
  }
    bool enqueue_v2(int value,string pname){
      if((head+1)%length==tail) return false;
      else{
        queue.at(head)=value;
        str_queue.at(head)=pname;
        head=(head+1)%length;
      }
    }

    void dequeue_v2(){
      if(head==tail);
      else{
        int idx=tail;
        tail=(tail+1)%length;
      }
  }

  int get_tail(){
    if(head==tail) return -1;
    else return queue.at(tail);
  }

  string get_tail_str(){
    if(head==tail) return "\0";
    else return str_queue.at(tail);
  }
};

int main(void){
  int size,quantum,temp,count=0;
  cin>>size>>quantum;
  string strtemp;
  vector<string> process(size+1);
  vector<int> ptime(size+1);

  Queue queue(ptime,process,size+1);
  for(int i=0;i<size;i++){
    cin>>strtemp>>temp;
    queue.enqueue_v2(temp,strtemp);
  }
  while(queue.isEmpty()==false){
    if(queue.get_tail()>quantum){
      count+=quantum;
      temp=queue.get_tail()-quantum;
      strtemp=queue.get_tail_str();
      queue.dequeue_v2();
      queue.enqueue_v2(temp,strtemp);
    }
    else{
      count+=queue.get_tail();
      cout<<queue.get_tail_str()<<" ";
      queue.dequeue_v2();
      cout<<count<<endl;
    }
  }
  return 0;

}



Measured memory_bytes: 6148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      final int numMax = 999_999;
      String line;
      int num;
      int result;

      List<Integer> prime = new ArrayList<>();
      prime.add(2);
      for ( int i = 3; i != numMax; i+=2 ) {
        if( isPrime(i,prime) ) {
          prime.add(i);
        }
      }

      while(true) {

        if( ((line = br.readLine()) == null) || line.isEmpty() ) break;

        num = Integer.parseInt(line);
        if( num == 0 || num == 1) {
          result = 0;
          System.out.println(result);
          continue;
        }
        
        result = 1;
        for ( int i = 3; i <= num; i+=2 ) {
          if( isPrime(i,prime) ) {
            result += 1;
          }
        }
        System.out.println(result);
      }
    }
  }

  public static boolean isPrime(int num,List<Integer> prime) {
    int k = Double.valueOf( Math.sqrt(num) ).intValue();
    for(Integer i: prime) {
      if ( num % i == 0 ) return false;
      if ( i > k ) return true;
    }
    return true;
  }
}


Measured memory_bytes: 38688
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
#include<math.h>
using namespace std;

int main() {
	int n=0;
	string o,e,ans;
	cin >> o >> e;
	for (int i = 0; i < e.size(); i++)
	{
		ans.push_back(o[i]);
		ans.push_back(e[i]);
		n++;
	}
	if (o.size() > e.size())ans.push_back(o[n]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

A,B,C,D=MI()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b

a = (A-1) - ((A-1) // C + (A-1) // D - (A-1) // lcm(C, D))
b = B - (B // C + B // D - B // lcm(C, D))
print(b-a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int64_t N;
    cin >> N;
    map<string,string>dic;
    int64_t count = 0;
    for (int i=0; i < N; i++) {
        string str;
        cin >> str;
        if (dic.count(str)) {
            // pass
        } else {
            dic[str] += 1;
            count += 1;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 25472
N = gets.to_i
candies = 2.times.map { gets.split.map(&:to_i) }

def dfs(candies, i, j, sum)
  c = candies[j][i]
  return sum + c if i == N - 1 && j == 1
  if i < N - 1 && j < 1
    [
      dfs(candies, i, j + 1, sum + c),
      dfs(candies, i + 1, j, sum + c)
    ].max
  elsif i == N - 1
    dfs(candies, i, j + 1, sum + c)
  else
    dfs(candies, i + 1, j, sum + c)
  end
end

ans = dfs(candies, 0, 0, 0)
puts ans


Measured memory_bytes: 1788
import sys
input = sys.stdin.readline

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab, key=lambda x:x[1])
now = 0
for a, b in ab:
  if now + a <= b:
    now += a
  else:
    print('No')
    exit()
print('Yes')

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

int main() {
	int a,b,c;
	cin>>a>>b>>c;
	int ans=(b/c)-(a/c);
	if ((b%c==0) && (a%c==0)){
		ans+=1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())


def count_divisors(target):
    _i = 1
    _count = 0
    while _i*_i <= target:
        if target % _i == 0:
            _count += 1
            if _i != target // _i:
                _count += 1
        _i += 1
    return _count


count = 0
for i in range(1, n+1, 2):
    if count_divisors(i) == 8:
        count += 1

print(count)


Measured memory_bytes: 9040
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		int n = sc.nextInt();
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = sc.nextInt();
		for (int i=n-1; i>=0; i--) System.out.print((i!=n-1?" ":"")+ar[i]);
		System.out.println();
		
	}
}


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

using namespace std;

int main() {
  int N, c = 0;
  string p;
  cin >> p >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    s += s;
    if (s.find(p) != string::npos)
      c++;
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  char a[5];
  cin >> a;
  if(a[0]==a[1]){
    cout <<"Bad"<<'\n';
  }else if(a[1]==a[2]){
    cout <<"Bad"<<'\n';
  }else if(a[2]==a[3]){
    cout <<"Bad"<<'\n';
  }else{
    cout <<"Good"<<'\n';
  }
  return(0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    //cord: x,y
    static final int dir[][] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            int n = Integer.parseInt(line);
            if (n == 0) {
                break;
            }
            int[][] square = new int[n][2];
            int[] xs = {0, 0};
            int[] ys = {0, 0};

            for (int i = 1; i < n; i++) {
                line = br.readLine();
                int t = Integer.parseInt(line.substring(0, line.indexOf(' ')));
                int d = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
                square[i][0] = square[t][0] + dir[d][0];
                square[i][1] = square[t][1] + dir[d][1];
                if (square[i][0] < xs[0]) {
                    xs[0] = square[i][0];
                }
                if (square[i][0] > xs[1]) {
                    xs[1] = square[i][0];
                }
                if (square[i][1] < ys[0]) {
                    ys[0] = square[i][1];
                }
                if (square[i][1] > ys[1]) {
                    ys[1] = square[i][1];
                }
            }
            System.out.println((xs[1] - xs[0] + 1) + " " + (ys[1] - ys[0] + 1));
        }
    }
}

Measured memory_bytes: 22480
s = input()

n = len(s)

for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit()

for i in range(n - 2):
    if s[i] == s[i + 2]:
        print(i + 1, i + 3)
        exit()

print(-1, -1)


Measured memory_bytes: 3188
a, b, c = map(int, input().split())

if a%2 == 0 and (b+c)%2 != 0:
    print('NO')
else:
    for i in range(1,101):
        if (b*i+c)%a == 0:
            print('YES')
            break
    else:
        print('NO')

Measured memory_bytes: 3060
#define SORT(v) sort(v.begin(), v.end())
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#include <cstdarg>
#include <cstdio>
#include <numeric>

// #include "ane.cpp"

#define INF (int)1e9
#define INFLL (long long)1e18
#define NMAX 200
#define MMAX 200
#define MOD 100000
using namespace std;

// コメントアウトするとdb_printf()を実行しない
#define DEBUG
// デバッグ用printf
void db_printf(const char* format, ...){
    #ifndef DEBUG
    return;
    #endif
    va_list arg;
    va_start(arg, format);
    vprintf(format, arg);  // コンソールに出力
    va_end(arg);
}
// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
typedef pair<int, int> p;
typedef long long ll;

ll N,M,K,A,B,C,D,E;
int dp[NMAX][MMAX] = {};

static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

ll ans = 0;

void solve(){
    // 解答アルゴリズム
}
void debug(){
    // デバッグ用出力
}
void answer(){
    // 解答出力
    printf("%lld\n", ans);
}
int main(int argc, char const *argv[])
{
    // 入力の読み込み，番兵法

    char ch[2];

    for (int i = 0; i < 2; ++i)
    {
        cin >> ch[i];
    }
    if (ch[0] == ch[1])
    {
        cout << "H\n";
    }else{
        cout << "D\n";
    }
    // solve();
    #ifdef DEBUG
    debug();
    #endif
    // answer();

    return 0;
}

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

using namespace std;

int main()
{
	long long ans=0, i, j=0, k, N, sl;
	string S;

	cin >> N >> S;
	sl = S.length();

	for (i = 0; i < sl; i++) {
		if (S[i] == 'I')
			j++;
		if (S[i] == 'D')
			j--;
		if (ans < j)
			ans = j;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int n;

int main() {
    cin >> n;
    if (n < 1200){
        cout << "ABC" << endl;
    } else if(n < 2800){
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }

    return 0;
}

Measured memory_bytes: 256