akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
int32_t main() {
    ios::sync_with_stdio(false);
    int n,m ,k;
    cin >> n >> m >> k;
    vector<int>a(n);
    vector<int>b(m + 1);
    forn(i, n)
    cin >> a[i];
    b[0]=0;
    forn(i,m)
    cin >> b[i + 1];
    int ans = 0;
    vector<int>pre(n);
    pre[0]=a[0];
    for(int i = 1; i < n; i++){
        pre[i]=a[i]+pre[i - 1];
    }
//    for(auto x:pre)
//        cout << x << " ";
//    cout << "\n";
    //pre.push_back(0);
    //reverse(pre.begin(),pre.end());
    //reverse(b.begin(),b.end());
    int cur = 0;
    forn(i, m + 1){
        cur += b[i];
        if(cur > k)
            break;
        int ind = lower_bound(pre.begin(),pre.end(), k - cur) - pre.begin();
        int temp = 0;
        if(ind != n && pre[ind] <= k - cur)
            temp = ind + 1;
        else if(ind != 0) {
            ind--;
            temp += ind + 1;
        }
        else
            temp = 0;
//       cout << b[i] << " " << ind << "\n";
//       cout << temp << "\n";
//        cout << "####################\n";
        ans = max(ans , i + temp);
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main() {
  int n, a; cin >> n >> a;
  vector<int> v(n);
  int s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    s += v[i];
  }

  vector<vector<long long>> dp(n + 1, vector<long long>(s + 1, 0));

  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = i; j >= 0; --j) {
      for (int k = 0; k + v[i] <= s; ++k) {
        dp[j + 1][k + v[i]] += dp[j][k];
      }
    }
  }

  long long ans = 0;
  for (int j = 1; j <= n; ++j) {
    int need = j * a;
    if (need <= s)
      ans += dp[j][need];
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int x=1;
		for(int i=0;i<n;i++) {
			if(x>k) {
				x+=k;
			}
			else {
				x*=2;
			}
		}
		System.out.println(x);
	}
}


Measured memory_bytes: 21844
from itertools import permutations

l = [int(input()) for _ in range(5)]

minT = 10000

for a in permutations(l,5):
    t = 0
    for dish in a:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT,t)
print(minT)


"""
from itertools import permutations

dishes = [int(input()) for _ in range(5)]

minT = 10000
for sample in permutations(dishes, 5):
    t = 0
    for dish in sample:
        if t%10 != 0:
            t += 10 - t%10
        t += dish
    minT = min(minT, t)
print(minT)
"""


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

int main(){
  int n;
  cin >> n;
  int h[n];
  rep(i, n) cin >> h[i];
  int dp[n] = {};
  dp[0] = 0, dp[1] = abs(h[1]-h[0]);
  for(int i = 2; i < n; i++){
    dp[i] = min(dp[i-1]+ abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    reverse(h.begin(), h.end());
    int tmp = h[0];
    bool flag = true;
    for (int i = 1; i < n; ++i) {
        if(h[i] > tmp + 1){
            flag = false;
        }
        else if(h[i] == tmp + 1){
            continue;
        }
        else{
            tmp = h[i];
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 640
M, D = [int(x) for x in input().split()]
cnt = 0
for i in range(10, 1+D):
    d1, d10 = [int(s) for s in str(i)]
    if (d1 == 1 or d10 == 1): continue
    cnt += (1 <= d1 * d10 <= M)
print(cnt)


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

int main(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    bool flag=false;
    int j=1;
    int ans=0;
    for(int i=0;i<n;i++){
        j=a[j];
        ans++;
        if(j==2){
            cout<<ans<<endl;
            flag=true;
            break;
        }
    }
    if(!flag)cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 4008
// https://atcoder.jp/contests/abc081/tasks/abc081_b

#include <iostream>
#include <vector>
using namespace std;
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  int n, gc, cnt = 0;
  vector<int> v;
  cin >> n;
  v.resize(n);

  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  // 最大公約数を求める
  gc = gcd(v[0], v[1]);
  for (int i = 2; i < n; i++) {
    gc = gcd(gc, v[i]);
  }
  // ２で割り切れる回数を数える
  while (gc % 2 == 0) {
    gc = gc / 2;
    cnt++;
  }
  cout << cnt;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define ms(s, n) memset(s, n, sizeof(s))
#define rp(i,l,m) for(int i=l; i<m; ++i)
#define Rp(i,l,m) for(int i=l; i<=m; i++)
#define rpD(i,l,m) for(int i=m; i>l; i--)
#define RpD(i,m,l) for(int i=m; i>=l; i--)
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define sz(a) int((a).size())
#define is insert
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = (int) 1e9 + 7;
const ld PI = acos((ld) -1);
inline ll gcd(ll a, ll b) {ll r; while (b) {r=a%b;a=b;b=r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p=MOD){ll r=1; for(;k;k>>=1){if(k&1)r=r*n%p;n=n*n%p;}return r;}
inline ll Pow(int n, int k){int r=1; for(;k;k>>=1){if(k&1)r=r*n;n=n*n;}return r;}
#define N 5005

ll ans, n;

inline void input(){
    cin >> n;
    //if(n==2) cout << 0, exit(0);
}

inline void solve(){
    for(int i=1; i<sqrt(n); i++){
        if(1.0*(n-i)/i==(n-i)/i && n%((n-i)/i)!=0) ans+=(n-i)/i;
    }
    cout << ans;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    input();
    solve();
  return 0;
}












Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
#include <stack>
using namespace std;
int grid[51][51];
int w, h, ans;
void dfs(int i, int j){ //iが縦jが横
    if(i<0||j<0||grid[i][j]==0) return ;
    grid[i][j]=0;
    
    for(int n=-1; n<=1; ++n){
        for(int m=-1; m<=1; ++m){
            dfs(i+n, j+m);
        }
    }
    return ;
}
int main() {
    while(cin >> w >> h, w||h){
        
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                cin >> grid[i][j];
            }
        }
        ans = 0;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if(grid[i][j]==1){
                    dfs(i, j);
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
        
    return 0;
}


Measured memory_bytes: 3224
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 113
	// https://atcoder.jp/contests/abc113/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int x = sc.nextInt();
		int y = sc.nextInt();
		System.out.println(x + (y / 2));
	}
	
	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 (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


Measured memory_bytes: 23124
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int
import math
from itertools import accumulate

def mod_factorial(n):
    value = 1
    for i in range(n,0,-1):
        value*=i
        value%=MOD

    return value

def solve(N: int, x: "List[int]"):
    dif_x = []

    # factmod[i] = (N-1)!/iをMODで割ったあまり
    factmod = [0]*(N)
    factmod[1] = mod_factorial(N-1)
    for i in range(1,N):
        dif_x.append(x[i]-x[i-1])
    
    for i in range(2,N):
        factmod[i] = factmod[1]*pow(i,MOD-2,MOD)
    
    accum_fact_mod = list(accumulate(factmod))
        
    answer = 0

    for i in range(N-1):
        answer += accum_fact_mod[i+1]*dif_x[i]
        answer %= MOD
    
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 27748
#include<bits/stdc++.h>
using namespace std;
string s;
int len,i,j,k,l,sum,ans;
int main(){
    getline(cin,s);
    len=s.size();
    for(i=0;i<len;i++){
        if(s[i]=='C'){
            for(j=i+1;j<len;j++){
                if(s[j]=='F'){
					printf("Yes");
                    return 0;
                }
            }
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string

	fmt.Scan(&s)

	y, _ := strconv.Atoi(s[0:4])
	m, _ := strconv.Atoi(s[5:7])
	d, _ := strconv.Atoi(s[8:10])

	if y > 2020 {
		fmt.Println("TBD")
		return
	} else if y < 2019 {
		fmt.Println("Heisei")
		return
	}

	if m > 4 {
		fmt.Println("TBD")
		return
	} else if m < 3 {
		fmt.Println("Heisei")
		return
	}

	if d <= 30 {
		fmt.Println("Heisei")

		return
	} else if d > 30 {
		fmt.Println("TBD")
		return
	}

}


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

int main(void){
  int D;
  cin >> D;
  if(D == 25)
    cout << "Christmas" << "\n";
  else if(D == 24)
    cout << "Christmas Eve" << "\n";
  else if(D == 23)
    cout << "Christmas Eve Eve" << "\n";
  else if(D == 22)
    cout << "Christmas Eve Eve Eve" << "\n";
  return 0;
}


Measured memory_bytes: 3560
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	D = defaultdict(int)
	for i in range(N):
		S = input()
		D[S] += 1

	print("AC" + " x " + str(D["AC"]))
	print("WA" + " x " + str(D["WA"]))
	print("TLE" + " x " + str(D["TLE"]))
	print("RE" + " x " + str(D["RE"]))



if __name__ == '__main__':
	main()

Measured memory_bytes: 70092
A=gets.chomp
B=gets.chomp
C=gets.chomp
dare=A.slice!(0)
win=""
while 1
	if dare=="a"
		if A==""
          	win="A"
      		break
    	end
  		dare=A.slice!(0)
	elsif dare=="b"
      	if B==""
            win="B"
      		break
    	end
  		dare=B.slice!(0)
    else
      	if C==""
            win="C"
      		break
    	end
  		dare=C.slice!(0)
    end
end
puts win

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    set<string> S;
    REP(i, 0, N) {
        string s; cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;
    return 0;
}

Measured memory_bytes: 19204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);vector<int> b(n);
  for(int i = 0; i < n; ++i)
    cin >> a[i] >> b[i];
  ll ans = 10000000000000000;
  for(int p = 0; p < 1<<n; ++p){
    ll kp = k;
    ll pr = 0;
    for(int i = 0; i < n; ++i)
      if(p & (1 << i)){
        kp -= ((100 * (i+1)) * a[i] + b[i]);
        pr += a[i];
      }
    for(int i = n-1; i != -1; --i){
      if(p & (1 << i))continue;
      int num = min(1LL * a[i], max(0LL, (kp + 100 * (i+1) - 1) / (100 * (i+1)) ));
      pr += num;
      kp -= 100 * (i+1) * num;
    }
    if(kp <= 0)ans = min(ans, pr);
  }
  cout << ans << endl;
  
}


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

#define ll long long
#define endl "\n"

const ll lmt=2e5+5;
ll a[lmt],n,k;

bool ok(ll range){
	ll move=0;
	for(ll i=1;i<=n;i++){
		move+=(a[i]/range);
		if(a[i]%range==0) move--;
	}
	if(move<=k) return true;
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);

	cin>>n>>k;
	ll lo=1,hi=1;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
		hi=max(hi,a[i]);
	}
	while(hi-lo>1){
		ll mid=(lo+hi)/2;
		if(ok(mid)){
			hi=mid;
		}else{
			lo=mid;
		}
	}
	if(ok(lo)){
		cout<<lo<<endl;
		return 0;
	}
	cout<<hi<<endl;
	return 0;
}

Measured memory_bytes: 5132
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,m,a;
    cin>>n>>m;
    if(m-n*2>0){
        a=(m-n*2)/4;
        n+=a;
        cout<<n<<endl;
    }
    else{
        cout<<m/2<<endl;
    }
    return 0;
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W;
int Q;
int S[3][1010][1010];
char F[1010][1010];
signed main(){
    scanf("%lld%lld%lld",&H,&W,&Q);
    rep(i,H)rep(j,W){
        scanf(" %c",&F[i][j]);
        int t;
        if(F[i][j]=='J')t=0;
        if(F[i][j]=='O')t=1;
        if(F[i][j]=='I')t=2;
        S[t][i+1][j+1]++;
        rep(k,3)S[k][i+1][j+1]+=S[k][i][j+1]+S[k][i+1][j]-S[k][i][j];
    }

    while(Q--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        rep(i,3){
            if(i)printf(" ");
            printf("%lld",S[i][c][d]-S[i][c][b]-S[i][a][d]+S[i][a][b]);
        }
        puts("");
    }
    return 0;
}

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

int main(){
  int64_t N,A,B;
  cin >> N >> A >> B;
  
  int64_t count = 0;
  count=N/(A+B);
  count=A*count;
 
  int64_t count2 =0;
  count2=N%(A+B);
  
  count+=min(count2,A);
  cout << count << endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

int[] dist, prev;

void main() {
    int N;
    scan(N);

    foreach (x ; 1 .. 10) {
        if (N % x == 0 && N / x < 10) {
            writeln("Yes");
            return;
        }
    }

    writeln("No");
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
/* Huyyt */
#include <bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define mkp(a,b) make_pair(a,b)
#define pb push_back
const int dir[8][2] = {{0, 1}, {1, 0}, {0, -1}, { -1, 0}, {1, 1}, {1, -1}, { -1, -1}, { -1, 1}};
using namespace std;
typedef long long ll;
inline void read(int &v)
{
        v = 0;
        char c = 0;
        int p = 1;
        while (c < '0' || c > '9')
        {
                if (c == '-')
                {
                        p = -1;
                }
                c = getchar();
        }
        while (c >= '0' && c <= '9')
        {
                v = (v << 3) + (v << 1) + c - '0';
                c = getchar();
        }
        v *= p;
}
const long long mod = 1e9 + 7;
const int N = 2e5 + 5;
int n;
int num[N];
int aim[N];
int main()
{
        read(n);
        int now;
        for (int i = 1; i <= n; i++)
        {
                read(now);
                num[now] = i;
        }
        int ans = 1;
        int ansmaxn = 1;
        for (int i = 2; i <= n; i++)
        {
                if (num[i] > num[i - 1])
                {
                        ans++;
                }
                else
                {
                        ans = 1;
                }
                ansmaxn = max(ansmaxn, ans);
        }
        cout << n - ansmaxn << endl;
        return 0;
}


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

struct UnionFind
{
    std::vector<int> data;
    UnionFind(int size) : data(size, -1){}
    void initialize(void){
        for(int i=0; i<(int)data.size(); i++) data[i] = i;
    }
    bool merge(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return false;
        else{ data[x] = y; return true; }
    }
    int find(int x){ //根っこを見つける関数
        if(data[x] == x) return x;
        else return data[x] = find(data[x]); //経路圧縮
    }
    bool isSame(int x, int y){
        return find(x) == find(y);
    }
};



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


    int N, M;
    cin >> N >> M;
    vector<int> L[M];
    for(int i=0; i<N; i++){
      int K; cin >> K;
      for(int j=0; j<K; j++){
        int l; cin >> l; l--;
        L[l].push_back(i);
      }
    }
    UnionFind uni(N);
    uni.initialize();
    for(int i=0; i<M; i++){
      for(int j=0; j<len(L[i])-1; j++){
        uni.merge(L[i][j], L[i][j+1]);
      }
    }
    bool is = true;
    for(int i=0; i<N-1; i++){
      if(!uni.isSame(i, i+1)){
        is = false;
      }
    }
    if(is){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 4608
//c
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#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 BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;

int m, n, k;
vector<string> field;
int sum[3][1024][1024];

int main(){

	cin >> m >> n >> k;
	
	for(int i=0; i<m; ++i){
		
		string s;
		cin >> s;
		field.push_back(s);
	}
	
	CLR(sum);
	
	for(int i=0; i<m; ++i){
		
		int tmp[3] = {0};
		
		for(int j=0; j<n; ++j){
			
			tmp[(field[i][j]=='J')?0:((field[i][j]=='O')?1:2)]++;
			
			for(int k=0; k<3; ++k){
				sum[k][i][j] = tmp[k] + (i>0?sum[k][i-1][j]:0);
			}
		}
	}
	
	for(int i=0; i<k; ++i){
		
		int a, b, c, d, w, x, y, z;
		cin >> a >> b >> c >> d;
		a--; b--; c--; d--;
		
		for(int t=0; t<3; ++t){
			
			w = sum[t][c][d];
			x = (a!=0&&b!=0?sum[t][a-1][b-1]:0);
			y = (a!=0?		sum[t][a-1][d]	:0);
			z = (b!=0?		sum[t][c][b-1]	:0);
			
			cout << w + x - y - z << (t!=2?' ':'\n');
		}
		
		cout << flush;
	}
	
	return 0;
}

Measured memory_bytes: 14416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


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

	for (int i = 0; i < 4; i++) {
		cout << s[i];
	}
	cout << " ";

	for (int i = 4; i < 12; i++) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}








Measured memory_bytes: 256
N, K, Q = map(int, input().split())  # N人の参加者, Kポイント, Q回数の正解

A = [int(input()) for _ in range(Q)]

count = {}
for i in range(1, N+1):
    count.setdefault(i, 0)

for i in range(len(A)):
    count[A[i]] += 1

for sanksya, score in count.items():
    if K - Q + score > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 19088
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int w,h;
    cin >> w >> h;
    priority_queue<ll, vector<ll>, greater<ll>> que_p, que_q;
    que_p.emplace(LINF);
    que_q.emplace(LINF);
    REP(i,w){
        ll p;
        cin >> p;
        que_p.emplace(p);
    }
    REP(i,h){
        ll q;
        cin >> q;
        que_q.emplace(q);
    }
    ll ans = 0;
    ll now_w = w + 1, now_h = h + 1;
    while(!(que_p.size() == 1 && que_q.size() == 1)){
        if(que_p.top() < que_q.top()){
            ans += que_p.top() * now_h;
            que_p.pop();
            now_w--;
        }else{
            ans += que_q.top() * now_w;
            que_q.pop();
            now_h--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  vector<set<int>> se(26);
  for (int i = 0; i < s.size(); i++) {
    se[s[i] - 'a'].insert(i);
  }
  for (int i = 0; i < q; i++) {
    int type;
    cin >> type;
    if (type == 1) { //puts("hoge");
      int a; char b;
      cin >> a >> b; --a;
      auto lb = se[s[a] - 'a'].find(a) ;
      if (lb != se[s[a] - 'a'].end()) se[s[a] - 'a'].erase(lb);
      se[b - 'a'].insert(a);
      s[a] = b;
    }
    else { //puts("fuga");
      int a, b;
      cin >> a >> b; --a, --b;
      int cnt = 0;
      for(int c = 0; c < 26; c++) {
        auto it = se[c].lower_bound(a);
        cnt += (it != se[c].end() && *it <= b);
      }
      cout << cnt << "\n";
    }
  }
}

Measured memory_bytes: 26244
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N,M;
  cin >> N >> M;
  vector<pair<ll,ll>> shop(N);
  for(int i=0;i<N;++i){
    cin >> shop.at(i).first >> shop.at(i).second;
  }
  sort(shop.begin(),shop.end());

  ll ans=0;
  ll buy=0;
  for(int i=0;i<N;++i){
    if(M-buy<=shop.at(i).second){
      ans+=shop.at(i).first*(M-buy);
      break;
    }
    ans+=shop.at(i).second*shop.at(i).first;
    buy+=shop.at(i).second;
  }

  cout << ans << endl;

  return 0;
}


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

void printAll(vector<int> &vt) {
    rep(i, vt.size()-1) cout << vt.at(i) << ' ';
    cout <<  vt.at(vt.size()-1) << endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(s.size());

    char now = 'R';
    int odd = 0, even = 0;
    int pos = 0;
    rep(i, n) {
        if(now == 'R' && s.at(i) == 'L') {
            pos = i-1;
        }
        if(now == 'L' && s.at(i) == 'R') {
            ans.at(pos) = odd;
            ans.at(pos+1) = even;
            if((pos%2) == 0) {
                swap(ans.at(pos), ans.at(pos+1));
            }
            even = 0; odd = 0;
        }
        now = s.at(i);
        if((i%2) == 0) {
            even++;
        }
        else {
            odd++;
        }
    }
    ans.at(pos) = odd;
    ans.at(pos+1) = even;
    if((pos%2) == 0) {
        swap(ans.at(pos), ans.at(pos+1));
    }

    printAll(ans);
    
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N;
int T[105];

int GCD(int a,int b){
    if(b==0)return a;
    return GCD(b,a%b);
}

int LCM(int a,int b){
    return a/GCD(a,b)*b;
}

signed main(){
    cin>>N;
    int time = 1ll;
    for(int i=0;i<N;++i){
        int t;
        cin>>t;
        time = LCM(max(t,time),min(t,time));
    }
    cout<<time<<endl;
}


Measured memory_bytes: 256
object Main extends App{
  val n = readInt
  val a = readLine.split(" ").map(_.toInt).toList

  val f: Int => Boolean = (n:Int) => n % 3 != 0 && n % 5 != 0
  val t = if( a.filter(_ % 2 == 0).filter(f).size == 0) "APPROVED" else "DENIED"
  println(t)
}

Measured memory_bytes: 27344
#!/usr/bin/env python3
import sys


def solve(R: int):
    if R < 1200:
        ret = 'ABC'
    elif R < 2800:
        ret = 'ARC'
    else:
        ret = 'AGC'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    solve(R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

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

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

bool need(vector<ll> A, vector<ll> B, set<ll> X){//xの要素のみでA->Bが全て実現可能か
  ll dist[51][51];
  rep(i, 51)rep(j, 51) dist[i][j] = 1;
  rep(i, 51) dist[i][i] = 0;
  for(ll i = 0; i < 51; i++){
    for(auto itr = X.begin(); itr != X.end(); itr++){
      dist[i][i%(*itr)] = 0;
    }
  }
  rep(k, 51)rep(i, 51)rep(j, 51) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  rep(i, A.size()){
    if(dist[A[i]][B[i]] != 0) return 0;
  }
  return 1;
}

ll N;
vector<ll> A, B;
void solve(){
  set<ll> X;
  for(ll i = 1; i <= 50; i++){
    X.insert(i);
  }
  if(need(A, B, X) == 0){
    cout << -1 << endl;
    return;
  }
  for(ll i = 50; i >= 1; i--){
    X.erase(i);
    if(need(A, B, X) == 0){
      X.insert(i);
    }
  }
  ll ans = 0;
  for(auto itr = X.begin(); itr != X.end(); itr++){
    ans += pow_long(2, *itr);
  }
  cout << ans << endl;
}
int main(){
  cin >> N;
  A.resize(N), B.resize(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  solve();
}


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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string S;
  ll Q;
  cin >> S >> Q;

  string l = "";
  string r = S;

  ll t, f;
  char c;

  bool rev = false;

  for (ll i = 0; i < Q; i++) {
    cin >> t;

    if (t == 1) {
      rev = !rev;
    } else {
      cin >> f >> c;

      if (f == 1) {
        if (rev) {
          r += c;
        } else {
          l += c;
        }
      } else {
        if (rev) {
          l += c;
        } else {
          r += c;
        }
      }
    }
  }

  if (!rev) {
    reverse(l.begin(), l.end());
    cout << l + r << endl;
  } else {
    reverse(r.begin(), r.end());
    cout << r + l << endl;
  }

  return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

int chk(int x, int y){
    if (x == y-1){
        
    }  
}

int main(void)
{
    int N;
    cin >> N;

    vector<int> A(N);
    vector<int> B(100010);
    REP(i,N){
        cin >> A[i];
        if (A[i]>0)B[A[i]-1]++;
        B[A[i]]++;
        B[A[i]+1]++;
    }

    sort(ALL(B));
    reverse(ALL(B));

    cout << B[0] << endl;

    return 0;
}


Measured memory_bytes: 4068
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int cnt1 = A / D;
    if (A % D != 0) ++cnt1;
    int cnt2 = C / B;
    if (C % B != 0) ++ cnt2;
    if (cnt1 >= cnt2)
    {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
      
      // 値の取得
	  int n = sc.nextInt();
      int[] p = new int[n];
      for(int i=0;i<n;i++){
        p[i] = sc.nextInt();
      }
      int count = 0;
      
      for(int i=1;i<n-1;i++){
        if(p[i-1]<p[i] && p[i]<p[i+1]){
        count++;
        }else if(p[i-1]>p[i] && p[i]>p[i+1]){
          count++;
        }
      }
      System.out.println(count);
    }
}

Measured memory_bytes: 35560
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD2 1000000007
#define MOD  998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

map<vector<int>, Int> memo_whole; 

Int solve(vector<int> s);

Int whole(vector<int> s){
    if(memo_whole.count(s))return memo_whole[s];
    Int &res = memo_whole[s];
    res = 0;
    if(s.size() == 1){
        res = 1;
        if(s[0] == 1)res++;
        return res;
    }
    for(int len = 1;len*2 <= s.size();len++){
        if(s.size() % len)continue;
        vector<int> tmp(len, 1);
        for(int j = 0;j < len;j++){
            for(int k = j;k < s.size();k += len){
                tmp[j] &= s[k];
            }
        }
        res += solve(tmp);
        res %= MOD;
    }
    return res;
}

map<vector<int>, Int> memo_solve; 

Int solve(vector<int> s){
    if(memo_solve.count(s))return memo_solve[s];
    Int &res = memo_solve[s];
    res = 0;
    if(s.empty())return res = 1;
    vector<int> prefix, suffix = s;
    for(int i = 0;i < s.size();i++){
        prefix.push_back(suffix[0]);
        suffix.erase(suffix.begin());
        res += whole(prefix) * solve(suffix) % MOD;
        res %= MOD;
    }
    return res;        
}

int main(){
    string _s;
    vector<int> s;
    cin >> _s;
    for(auto c: _s)s.push_back(c == '1');
    cout << solve(s) << endl;
}

Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    int n;
    cin >> n;
    vl a(n);
    rep(i,0,n) {
        cin >> a[i];
    }
    if(a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    rep(i,0,n-1) {
        if(a[i+1] - a[i] > 1) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ret = 0;
    rep(i,1,n) {
        if(a[i-1] + 1 == a[i]) 
            ret++;
        else 
            ret += a[i];
    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s[]=new String[n];
		int t[]=new int[n];
		for(int i=0;i<n;i++) {
			s[i]=scan.next();
			t[i]=scan.nextInt();
		}
		String x=scan.next();
		scan.close();
		int cnt=0;
		int check=0;
		for(int i=0;i<n;i++) {
			if(check==1)cnt+=t[i];
			if(x.equals(s[i])==true)check=1;

		}
		System.out.println(cnt);

	}

}

Measured memory_bytes: 24148
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;

int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    A[i]--;
  }
  vector<int>id(N,-1);
  vector<int>past;
  int now=0;
  while(id[now]==-1){
    if(past.size()==K){cout<<now+1<<endl;return 0;}
    id[now]=past.size();
    past.push_back(now);
    
    now=A[now];
  }
  int roop=past.size()-id[now];
  int x=(K-id[now])%roop;
  cout<<past[id[now]+x]+1<<endl;
  return 0;  
}

Measured memory_bytes: 5864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 300002
int N, a[MAX];
int main(){
	scanf("%d", &N);
	for(int i = 0; i < N * 3; i++)
		scanf("%d", a + i);
	sort(a, a + 3 * N);
	ll ans = 0;
	for(int i = 0; i < N; i++){
		ans += 1LL * a[3 * N - 2 * i - 2];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define int           long long
#define pb            push_back
#define ppb           pop_back
#define si            set <int>
#define endl          '\n'
#define fr            first
#define sc            second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define mci       	  map<char,int>  	
#define rep(i,a,b)    for(int  i=a;i<b;i++)
#define repr(i,a,b)	  for(int i=b-1;i>=a;i--)
#define trav(it,v)	  for(auto it=v.begin();it!=v.end();it++)
#define all(v)        v.begin(),v.end()
#define srt(v)        sort(all(v))
#define pii           pair<int ,int >
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define bs            binary_search
#define mp            make_pair
#define sp(n)         setprecision(n)
#define spl           " "
#define arr(a,n)      rep(i,0,n) cin>>a[i]
#define mod           998244353
#define MAXN   		  1000000
#define f(n) for(int i=0;i<n;i++)
using namespace std;
 
//vector<int> adj[101];
int prime[10000000]={0};
int vis[150001]={0};
//int visi[101][101]={0};
 
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
 
int isPrime(int n) 
{ 
 
    if (n <= 1) 
        return 0; 
  
    for (int i = 2; i < n; i++) 
        if (n % i == 0) 
            return 0; 
  
    return 1; 
} 

int power(int x, unsigned int y, int p) 
{ 
    int res = 1; 
  
    x = x % p;  
  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
  
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

 
 
 
void solve()
{
	int a,b;
	cin>>a>>b;
	if(2*b>=a)
		cout<<"0";
	else
		cout<<a-2*b;



 
}
 
 
 
signed main()
{
		ios_base::sync_with_stdio(false);
		cin.tie(0);
		cout.tie(0);
		/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif*/
		int t=1;
		//cin>>t;
		while(t--)
			solve();
		return 0;
}
 

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int n;cin >> n;

  if(1 == n)
  {
    cout << 1 << endl;
  }
  else if(2 <= n && n < 4)
  {
    cout << 2 << endl;
  }
  else if(4 <= n && n < 8)
  {
    cout << 4 << endl;
  }
  else if(8 <= n && n < 16)
  {
    cout << 8 << endl;
  }
  else if(16 <= n && n < 32)
  {
    cout << 16 << endl;
  }
  else if(32 <= n && n < 64)
  {
    cout << 32 << endl;
  }
  else
  {
    cout << 64 << endl;
  }
  



  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
#define INF 1e9
using ll = int64_t;
template <class T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b)
{
  if (b < a)
  {
    a = b;
    return true;
  }
  return false;
}

//10^9 + 7
#define yojo 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b)
{
  // a >= b && b != 0
  std::int64_t c;
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb)
{
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0)
  {
    return -1;
  }
  do
  {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str)
{
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++)
  {
    if (i == str.size())
    {
      data.push_back(make_pair(str[i - 1], count));
      break;
    }
    else if (now != str[i])
    {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 200001

void Main()
{
  string s;
  cin >> s;
  if (s == "Sunny")
  {
    std::cout << "Cloudy" << std::endl;
  }
  else if (s == "Cloudy")
  {
    std::cout << "Rainy" << std::endl;
  }
  else
  {
    std::cout << "Sunny" << std::endl;
  }
  
  
  
  return;
}

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


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


int main() {
  int A, B, result;
  int i;
  scanf ("%d %d", &A, &B);
  
  
  result = (B-1)/(A-1) + (((B-1)%(A-1))?1:0);
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;

ll r,c,k,a,b,d,dp[3001][3001][4],v[3001][3001];

int main(){
  cin>>r>>c>>k;
  for(int i=1;i<=k;i++){cin>>a>>b>>d;v[a][b]=d;}
  for(int i=1;i<=r;i++){
    for(int j=1;j<=c;j++){
      for(int k=0;k<=3;k++){
        dp[i][j][k]=max(dp[i][j-1][k],dp[i-1][j][3]);
        if(k){
          dp[i][j][k]=max(dp[i][j][k],max(dp[i][j-1][k-1],dp[i-1][j][3])+v[i][j]);
        }
      }
    }
  }
  cout<<dp[r][c][3]<<endl;
}


Measured memory_bytes: 355304
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int diff = (a + b) - (c + d);
    if(diff < 0)
        cout << "Right" << endl;
    else if(diff == 0)
        cout << "Balanced" << endl;
    else
        cout << "Left" << endl;

    return 0;
}


Measured memory_bytes: 256
c = input()
if c == "a":
    print("b")
elif c == "b":
    print("c")
elif c == "c":
    print("d")
elif c == "d":
    print("e")
elif c == "e":
    print("f")
elif c == "f":
    print("g")
elif c == "g":
    print("h")
elif c == "h":
    print("i")
elif c == "i":
    print("j")
elif c == "j":
    print("k")
elif c == "k":
    print("l")
elif c == "l":
    print("m")
elif c == "m":
    print("n")
elif c == "n":
    print("o")
elif c == "o":
    print("p")
elif c == "p":
    print("q")
elif c == "q":
    print("r")
elif c == "r":
    print("s")
elif c == "s":
    print("t")
elif c == "t":
    print("u")
elif c == "u":
    print("v")
elif c == "v":
    print("w")
elif c == "w":
    print("x")
elif c == "x":
    print("y")
elif c == "y":
    print("z")

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

int main(){
	int a,b;
	cin>>a>>b;
	
	if(a*b>a+b&&a*b>a-b)
		cout<<a*b;
	else if(a+b>a*b &&a+b>a-b)
		cout<<a+b;
	else
		cout<<a-b;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(auto& c: s) if ("ACGT"s.find(c)==string::npos) c=' ';
    stringstream ss(s);
    int res=0;
    while (ss>>s) res=max<int>(res, s.size());
    cout<<res<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - Similar Arrays
https://atcoder.jp/contests/code-festival-2017-qualc/tasks/code_festival_2017_qualc_b

"""
import sys


def solve(N, array):
    ans = 3**N
    evens = [a for a in array if a%2==0]
    ans -= 2**len(evens)
    return ans


def main(args):
    N = int(input())
    array = [int(a) for a in input().split()]
    ans = solve(N, array)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
cmp [] = []
cmp (s:sx) =
  let n = length $ takeWhile (== s) sx
      r = drop n sx
  in
    (s,n+1):(cmp r)

scn [] = []
scn (('J',nj):('O',no):('I',ni):xs) =
  if nj >= no && ni >= no
  then no:(scn xs)
  else scn xs
scn (x:xs) = scn xs

ans s =
  let c = cmp s
      r = scn c
  in
    if r == []
    then 0
    else maximum r

main = do
  l <- getLine
  let o = ans l
  print o

Measured memory_bytes: 62436