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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K;
ll A[100];

ll i, j, k;

void mxin(ll& a,ll b){
    if(a<b){
        a = b;
    }
}


int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        scanf("%lld", &A[i]);
    }
    map<ll,ll> dp,odp;
    dp[0] = 1000;
    rep(i,0,N){
        odp = dp;
        dp.clear();
        for(auto a:odp){
            //printf("%lld:%lld,%lld\n", i, a.first, a.second);
            mxin(dp[a.first], a.second);
            mxin(dp[0], a.first * A[i] + a.second);
            mxin(dp[a.first + a.second / A[i]], a.second - a.second / A[i] * A[i]);
        }
    }
    printf("%lld\n", dp[0]);

    return 0;
}

Measured memory_bytes: 3800
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
	int H = 0;
	int W = 0;
	cin >> H >> W;
	vector<vector<char>> m(W, vector<char>(H));
	rep(j, H) {
		rep(i, W) {
			cin >> m.at(i).at(j);
		}
	}
	vector<vector<char>> M(W, vector<char>(2 * H));
	rep(j, H) {
		rep(i , W) {
			M.at(i).at(2*j) = m.at(i).at(j);
			M.at(i).at(2*j+1) = m.at(i).at(j);
		}
	}
	rep(j, H) {
		rep(i, W) {
			cout << M.at(i).at(2*j) ;
		}
		cout << endl;
		rep(i, W) {
			cout << M.at(i).at(2 * j + 1 );
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rp(i,n) for(long long i=0;i<n;i++)

using namespace std;
using ll = long long;

int main(void)
{
    int N,M,n,m;
    cin>>N>>M;
    n=N*(N-1)/2;
    m=M*(M-1)/2;

    cout<<n+m<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;


 string devide[4] = {"dream", "dreamer","erase","eraser"};

int main(){

 string s;
 cin>>s;
  reverse(s.begin(),s.end());

  for(int i=0;i<4;i++){
    reverse(devide[i].begin(),devide[i].end());
  }

   bool can = true;

  for(int i=0;i<s.length();)
 {
    bool can2 = false;
    for(int j =0;j<4;j++)
    {
        string d = devide[j];
        if(s.substr(i,d.size()) == d){
            can2 = true;
            i +=d.size(); }
    }

    if(!can2){
        can  = false;
        break; }
  }

  if(can)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;

 return 0;
}

Measured memory_bytes: 3748
n,m,q = map(int,input().split())
a,b,c,d = [],[],[],[]
ans = 0
A = [1]

for i in range(q):
    ai,bi,ci,di = map(int, input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

def dfs(A):
    global ans
    if n == len(A):
        now = 0
        for i in range(q):
            if A[b[i]-1] - A[a[i]-1] == c[i]:
                now += d[i]
        ans  = max(ans,now)
        return

    for i in range(A[-1], m+1):
        A.append(i)
        dfs(A)
        A.pop() #最後の要素を削除
dfs(A)
print(ans)


Measured memory_bytes: 9252
#include <iostream>
#include <cstdlib>

using namespace std;

int main(void)
{
    int apple_count;
    int taste_offset;

    cin >> apple_count >> taste_offset;

    int taste_sum = 0;
    int abs_lowest = taste_offset;
    for(int i = 0; i < apple_count; i++){
        int taste = taste_offset + i;
        if(abs(abs_lowest) > abs(taste)){
            abs_lowest = taste;
        }
        taste_sum += taste;
    }

    cout << taste_sum - abs_lowest << endl;

    return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int a_1, a_2, a_3;
  cin >> a_1 >> a_2 >> a_3;

  if (a_1 + a_2 + a_3 >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
N=int(input())
S=[]
for i in range(N):
  S.append(input())  
  
dic={}
for s in S:
  if s in dic:
    dic[s]=dic[s]+1
  else:
    dic[s]=1
num=max(dic.values())
[print(k) for k, v in sorted(dic.items()) if v==num]





Measured memory_bytes: 46732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;

  rep(i, B) {
    rep(j, A) {
      cout << 1;
    }
    rep(j, W-A) cout << 0;
    cout << endl;
  }

  rep(i, H-B) {
    rep(j, A) cout << 0;
    rep(j, W-A) cout << 1;
    cout << endl;
  }

  return 0;
}


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

int main() {
    string s;
    cin>>s;
    long long ans = 0;
    long long rem = 0;

    map<int, int> m;

    long long t = 1;

    for(int i=s.length()-1;i>=0;i--) {
        rem = (rem + (s[i]-'0')*t) % 2019;
        if(rem == 0) {
            ans += 1;
        }

        ans += m[rem];
        m[rem]++;

        t = (t*10)%2019; 
    }

    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3732
// UTPC2010 F. UTF-8

#include <iostream>
#include <vector>
#include <string>
#include <string.h>

using namespace std;

int main(){
	int n;
	string cmp[4] = {"0xxxxxxx", "110yyyyx10xxxxxx", "1110yyyy10yxxxxx10xxxxxx", "11110yyy10yyxxxx10xxxxxx10xxxxxx"};
	long long dp[1001];
	while(cin >> n, n){
		vector<string> vs(n);
		for(int i=0;i<n;i++) cin >> vs[i];
		memset(dp, 0, sizeof(dp));
		dp[0] = 1;
		for(int i=0;i<n;i++){
			string cur;
			for(int j=0;j<4&&i+j<n;j++){
				cur += vs[i+j];
				int mul = 1;
				bool one = false;
				bool zero = true;
				bool seen = false;
				for(int k=0;k<cur.size();k++){
					if(isdigit(cmp[j][k])&&cmp[j][k]!=cur[k]&&cur[k]!='x') mul = 0;
					if(cmp[j][k]=='y'){
						if(cur[k]=='1') one = true;
						if(cur[k]!='0') zero = false;
						if(cur[k]=='x') mul *= 2;
					}
					if(cmp[j][k]=='x'){
						if(j!=0&&!seen){
							if(zero) mul = 0;
							if(!one&&mul>1) mul--;
							seen = true;
						}
						if(cur[k]=='x') mul = (mul*2)%1000000;
					}
				}
				dp[i+j+1] = (dp[i+j+1]+dp[i]*mul)%1000000;
			}
		}
		cout << dp[n] << endl;
	}
}

Measured memory_bytes: 972
/*
god taekyu
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int n;
int A[105];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b;
    cin>>n;
    cin>>a>>b;
    for(int i=1;i<=n;i++) cin>>A[i];
    int c[105] = {0,};
    for(int i=1;i<=n;i++) {
        if(A[i] <= a) c[0]++;
        else if(A[i] <= b) c[1]++;
        else c[2]++;
    }
    cout<<min({c[0],c[1],c[2]});
    return 0;
}

/*
god taekyu
*/


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

int a, b;

int main(void){
  cin >> a >> b;
  if(a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0){
    cout << "Possible" << endl;
  }
  else{
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
long long n,temp,tmp,p[100005];
bool b[1000005];
int x,m,ans;
int main()
{
	cin>>n;
	x=sqrt(n);
	for(int i=2;i<=x;++i)
	  if(!b[i])
	    for(int j=i<<1;j<=x;j+=i)
	      b[j]=true;
	for(int i=2;i<=x;++i)
	  if(!b[i]&&n%i==0)
	    {
	      temp=n;tmp=1;
	      while(temp%i==0)
	        {
	          temp/=i;
	          tmp*=i;
	          p[++m]=tmp;
			}
		}
	sort(p+1,p+m+1);
	for(int i=1;i<=m;++i)
	  if(n%p[i]==0)
	    {
	      ++ans;
	      n/=p[i];
		}
	for(int i=2;i<=x;++i)
	  if(!b[i]&&n%i==0)
	    {
	      while(n%i==0)n/=i;
		}
	if(n>x)++ans;
	cout<<ans;
}

Measured memory_bytes: 4564
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0109&lang=jp
// Appendix??????????????????
#include <bits/stdc++.h>
using namespace std;
int n, cur;
string str;
int expression();
int factor();
int digit() {
    assert(isdigit(str[cur]));
    int n = str[cur] - '0';
    cur++;
    return n;
}
int number() {
    int n = digit();
    while (cur < str.size() && isdigit(str[cur])) n = n * 10 + digit();
    return n;
}
int factor() {
    if (str[cur] != '(') return number();
    cur++;
    int n = expression();
    assert(str[cur] == ')');
    cur++;
    return n;
}
int term() {
    int a = factor();
    while (cur < str.size() && (str[cur] == '*' || str[cur] == '/')) {
        char op = str[cur++];
        int b = factor();
        if (op == '*') a *= b;
        else a /= b;
    }
    return a;
}
int expression() {
    int a = term();
    while (cur < str.size() && (str[cur] == '+' || str[cur] == '-')) {
        char op = str[cur++];
        int b = term();
        if (op == '+') a += b;
        else a -= b;
    }
    return a;
}
int main() {
    scanf("%d", &n);
    for (int i=0; i<n; i++) {
        cur = 0;
        cin >> str;
        str.resize(str.size() - 1);
        printf("%d\n", expression());
    }
}

Measured memory_bytes: 1224
# -*- coding: utf-8 -*-

def devide_recursive(a, count):
    for number in a:
        if number % 2 != 0:
            return count
    count += 1
    return devide_recursive(list(map(lambda x: x / 2, a)), count)

def main():
    n = int(input())
    a = list(map(int, input().split()))

    count = devide_recursive(a, 0)
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N,K=map(int,input().split())

a=list(map(int,input().split()))
tentou1=0
for i in range(len(a)):
  for j in range(i+1,len(a)):
    if(a[i]>a[j]):
      tentou1+=1
a.sort()
a.reverse()
stentou=0
for i in range(len(a)):
  for j in range(i+1,len(a)):
    if(a[i]>a[j]):
      stentou+=1
answer=int(tentou1*K + int(stentou*K*(K-1)//2))
print(answer%1000000007)


Measured memory_bytes: 3188
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

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

    let ans = a.into_iter().fold(1_u64, |acc, ai| acc.saturating_mul(ai));
    if ans > 10_u64.pow(18) {
        println!("{}", -1);
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4536
#include <stdio.h>
int main(void){
    // Your code here!
    char number[1001]; 
     int i, sum; 
     while(1){ 
         scanf("%s", number); 
         if(number[0]=='0')break; 
         sum=0; 
         for(i=0;number[i]!='\0';i++){ 
             sum+=number[i]-'0'; 
         } 
         printf("%d\n", sum); 
     } 
      return 0; 

 } 




Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define sp ' '
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;

int A, B, K;

int main() {
	cin >> A >> B >> K;
	for (int i = 0; i < K; ++i) {
		if (i % 2 == 0) {
			A -= A % 2;
			B += A / 2;
			A /= 2;
		}
		else {
			B -= B % 2;
			A += B / 2;
			B /= 2;
		}
	}
	cout << A << sp << B << endl;
	return 0;
}

Measured memory_bytes: 256
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;

    typedef set<int> SET;
    typedef long long LL;
    const int SIZE = 101;
    int n;
    int m[SIZE];
    int a[SIZE];
    int b[SIZE];

    const string YES = "OK";
    const string NO = "NG";

    class Solution: public ISolution {
    public:
        bool input() {
            if ( ! ( cin >> n && n ) )
                return false;
            for ( int i = 0; i < n; ++ i )
                cin >> m[i] >> a[i] >> b[i];
            return true;
        }
        bool solve() {
            SET T;
            for ( int i = 0; i < n; ++ i ) {
                T.insert(a[i]);
                T.insert(b[i]);
            }
            for ( SET::iterator it_i = T.begin(); it_i != T.end(); ++ it_i ) {
                int t = *it_i; 
                int sum = 0;
                for ( int i = 0; i < n; ++ i ) {
                    if ( a[i] <= t && t < b[i] )
                        sum += m[i];
                }
                if ( sum > 150 )
                    return false;
            }
            return true;
        }
        void output( bool result ) {
            cout << ( result ? YES : NO ) << endl;
        }
        int run() {
            while ( init(), input() ) {
                output(solve());
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;

    ll ans = 0;
    V<char> memo(n);
    for(int i = 0; i < n; i++){
        if(t[i] == 'r'){
            if(i - k < 0 || (0 <= i - k && memo[i - k] != 'p')){
                ans += p;
                memo[i] = 'p';
            }else if(n <= i + k || (i + k < n && t[i + k] != 's')){
                memo[i] = 'r';
            }else{
                memo[i] = 's';
            }
        }
        if(t[i] == 's'){
            if(i - k < 0 || (0 <= i - k && memo[i - k] != 'r')){
                ans += r;
                memo[i] = 'r';
            }else if(n <= i + k || (i + k < n && t[i + k] != 'p')){
                memo[i] = 's';
            }else{
                memo[i] = 'p';
            }
        }
        if(t[i] == 'p'){
            if(i - k < 0 || (0 <= i - k && memo[i - k] != 's')){
                ans += s;
                memo[i] = 's';
            }else if(n <= i + k || (i + k < n && t[i + k] != 'r')){
                memo[i] = 'p';
            }else{
                memo[i] = 'r';
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3784
while True:
  b,r,g,c,s,t=map(int, input().split())
  if t==0:
    break
  x=100
  y=b*5+r*3
  z=t-y-s
  a=x+(b+r)*15+g*7+y*13+c*2-z*3
  print(a)


Measured memory_bytes: 5596
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;

const int MAXN = 1e5 + 10;

int N;
bool vist[MAXN], noSolution;
vector <int> Adj[MAXN];

inline void addEdge(int u, int v)
{
	Adj[u].push_back(v), Adj[v].push_back(u);
}

void DFS(int cur, int pre)
{
	if(noSolution)
		return;

	// If it's a leaf, match it with its parent
	if(Adj[cur].size() == 1)
	{
		if(vist[pre])
			noSolution = true;
		vist[cur] = true;
		vist[pre] = true;
		return;
	}

	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
	{
		if(*itr == pre)
			continue;
		DFS(*itr, cur);
	}

	// If it's not matched
	if(!vist[cur])
	{
		// It's parent is used or its the root
		if(vist[pre] || pre == 0)
			noSolution = true;
		vist[cur] = true;
		vist[pre] = true;
		return;
	}
}

int main()
{
	//REDIRECT("blackwhite");

	int u, v;
	scanf("%d", &N);
	for(int i = 1; i < N; i++)
		scanf("%d%d", &u, &v),
		addEdge(u, v);

	for(int i = 1; i <= N; i++)
		if(Adj[i].size() > 1)
		{
			DFS(i, 0);
			break;
		}

	puts(noSolution ? "First" : "Second");

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
double Q,H,S,D;
int N;
vector <pair<double,int> > q;





int main()
{

	cin >> Q >> H >> S >> D >> N;


	q.push_back({Q/0.25,0});
	q.push_back({H/0.5,1});
	q.push_back({S,2});
	q.push_back({D/2,3});

	double li[4] = {0.25,0.5,1,2};
	double cost[4] = {Q,H,S,D};

	sort(q.begin(),q.end());
	int a = (int)N/li[q[0].second];
	double b = li[q[1].second];

	long double ans = (long double)a*cost[q[0].second];

	if(q[0].second == 3){
		int c  =(N%2)/b;
		ans += (long double)c*cost[q[1].second];
	}
	cout <<fixed << setprecision(0) << ans << endl;

}




Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long[] arr = sc.nextLongArray(n);
        long left = 0;
        long right = (long)1e10+1;
        long diff = a-b;
        while(right - left > 1){
            long mid = (right+left)/2;
            long acnt = 0;
            for(long v : arr){
                if((v-b*mid) <= 0){
                    continue;
                }
                acnt += (v-b*mid)/diff;
                acnt += (v-b*mid)%diff == 0 ? 0 : 1;
            }
            if(acnt <= mid){
                right = mid;
            }else{
                left = mid;
            }
        }
        System.out.println(right);
    }
    
}

class Point{
    long x,y;
    public Point(long x, long y){
        this.x = x;
        this.y = y;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 41248
daydream = ['dream', 'dreamer', 'erase', 'eraser']
s = input()
import sys
while s:
    for i in daydream:
        if s.endswith(i):
            s = s[:-len(i)]
            break
    else:
        break
else:
    print('YES')
    sys.exit()
print('NO')

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n), acc(n+1);

    for (auto& e : v) cin >> e;
    for (int i=0; i<n; i++) acc[i+1] = acc[i] + v[i];

    int limit = min(n, k);
    int64_t ans = 0;
    for (int left = 0; left <= limit; left++) {
        for (int right = 0; left + right <= limit; right++) {
            int64_t can = acc[left] + acc[n] - acc[n - right];

            vector<int> tmp(left + right);
            copy_n(v.begin(), left, tmp.begin());
            copy_n(v.rbegin(), right, tmp.rbegin());
            sort(tmp.begin(), tmp.end());
            auto itr = min(lower_bound(tmp.begin(), tmp.end(), 0), tmp.begin() + (k - left - right));
            can -= accumulate(tmp.begin(), itr, 0);
            ans = max(ans, can);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A == B && B == C) {
            System.out.println("No");
        } else if (A == B || B == C || C == A) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

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


Measured memory_bytes: 21588
#include<stdio.h>

int main(void){
    int H=0,W=0;
    char board[51][51];
    int count=0;
    scanf("%d %d",&H,&W);
    for(int i=0;i<H;i++){
        scanf("%s",board[i]);
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(board[i][j]=='.'){
                if(i>0){
                    if(board[i-1][j]=='#'){
                        count++;
                    }
                }
                if(i<H-1){
                    if(board[i+1][j]=='#'){
                        count++;
                    }
                }
                    
                if(j>0){
                    if(board[i][j-1]=='#'){
                        count++;
                    }
                    if(i>0){
                        if(board[i-1][j-1]=='#'){
                            count++;
                        }
                    }
                    if(i<H-1){
                        if(board[i+1][j-1]=='#'){
                            count++;
                        }
                    }
                
                }
                if(j<W-1){
                    if(board[i][j+1]=='#'){
                        count++;
                    }
                    if(i>0){
                        if(board[i-1][j+1]=='#'){
                            count++;
                        }
                    }
                    if(i<H-1){
                        if(board[i+1][j+1]=='#'){
                                count++;
                            }
                        }
                    }
                    board[i][j]='0'+count;
                    count=0;
                }
            }
        }
        for(int i=0;i<H;i++){
            printf("%s\n",board[i]);
        }
        return 0;
    }

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

import math
from collections import deque
    
n,d,a = l_in()
xh = []
for _ in range(n):
    x,h=l_in()
    xh.append((x,math.ceil(h/a)))

xh.sort()
res = 0
currentX = -1
currentH = 0
q=deque()
q_sum = 0

for x,h in xh:
    while len(q) > 0:
        bx, bh = q[0]
        if bx < x:
            q.popleft()
            q_sum -= bh
        else:
            break
    h -= q_sum
    if h > 0:
        q.append((x+2*d, h))
        q_sum += h
        res += h

print(res)



Measured memory_bytes: 98264
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CTaxIncrease {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int A, B;
        cin >> A >> B;
        FOR(res, 1, 100000) {
            if (res * 8 / 100 == A && res * 10 / 100 == B) {
                cout << res << endl;
                return;
            }
        }
        cout << -1 << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CTaxIncrease solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
st = input()
sn = len(st)

n, s, e, w = 0, 0, 0, 0
for i in range(sn):
  if st[i] == "N":
    n += 1
  if st[i] == "S":
    s += 1
  if st[i] == "E":
    e += 1
  if st[i] == "W":
    w += 1

false = (n > 0 and s == 0) or (s > 0 and n == 0) or (e > 0 and w == 0) or (w > 0 and e == 0)
if false:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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; }

using ll = long long;

ll N;
ll A[200010], S[200010];
std::map<ll, ll> mp;
ll ans;

int main()
{
  std::cin >> N;

  rep( i, N )
    std::cin >> A[i];

  rep( i, N )
    S[i+1] = S[i]+A[i];

  rep( i, N+1 )
  {
    ans += mp[S[i]];
    ++mp[S[i]];
  }

  std::cout << ans << std::endl;

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

#define __STDC_FORMAT_MACROS
#define p64 PRId64

using namespace std;
using ll = int64_t;

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

    bool even = true;
    REP(i, N)
    {
        int A;
        cin >> A;

        if (A % 2 == 1) even = false;
    }

    if (even && P == 0) cout << ((ll)1 << N) << endl;
    else if (even) cout << 0 << endl;
    else cout << ((ll)1 << (N - 1)) << endl;

    return 0;
}


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

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        String[] s = in.ss();
        out.println(s[1]+s[0]);
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  while(n){
    ++ans;
    n/=m;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
	static Map<Long, Long> map;
	static long n, a, b, c, d, e;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int t = Integer.parseInt(sa[0]);
		for (int i = 0; i < t; i++) {
			sa = br.readLine().split(" ");
			n = Long.parseLong(sa[0]);
			a = Long.parseLong(sa[1]);
			b = Long.parseLong(sa[2]);
			c = Long.parseLong(sa[3]);
			d = Long.parseLong(sa[4]);

			e = Long.MAX_VALUE / d;
			map = new HashMap<>();
			map.put(0L, 0L);
			map.put(1L, d);
			System.out.println(dfs(n));
		}
		br.close();
	}

	static long dfs(long x) {
		if (map.containsKey(x)) {
			return map.get(x);
		}

		long ret = Long.MAX_VALUE;
		if (x % 2 == 0) {
			ret = Math.min(ret, dfs(x / 2) + a);
			if (x / 2 <= e) {
				ret = Math.min(ret, dfs(x / 2) + x / 2 * d);
			}
		} else {
			ret = Math.min(ret, dfs(x / 2) + a + d);
			ret = Math.min(ret, dfs(x / 2 + 1) + a + d);
			if (x / 2 < e) {
				ret = Math.min(ret, dfs(x / 2) + x / 2 * d + d);
			}
		}
		if (x % 3 == 0) {
			ret = Math.min(ret, dfs(x / 3) + b);
		} else {
			long y = x % 3;
			ret = Math.min(ret, dfs(x / 3) + b + d * y);
			y = 3 - y;
			ret = Math.min(ret, dfs(x / 3 + 1) + b + d * y);
		}
		if (x % 5 == 0) {
			ret = Math.min(ret, dfs(x / 5) + c);
		} else {
			long y = x % 5;
			ret = Math.min(ret, dfs(x / 5) + c + d * y);
			y = 5 - y;
			ret = Math.min(ret, dfs(x / 5 + 1) + c + d * y);
		}
		map.put(x, ret);
		return ret;
	}
}


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

using namespace std;

int main()
{ int N; cin >> N;
 
 map<int,int> mp;
 
 int cnt = 0;
 
 for(int i = 0; i < N; i++){
   int a; cin >> a; mp[a]++;}
 
 for(auto p:mp){
   int s = p.first;
   int t = p.second;
   //sが値、tが頻度
   if( t >= s){ cnt += t - s;}
   else{ cnt += t;}
 }
 cout << cnt << endl;
 return 0;}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
//#define int long long
#define double long double
const int INF = (int) 1e9 + 9;
const int maxn = (int) 1e6 + 6;
using namespace std;

signed main() {

      int n; cin >> n;

      vector<int> v(n);
      int ans = 1, cmp;
      for(int i = 0; i < n; i++) {
            cin >> v[i];
            if(!i) cmp = v[i];
            if(i && v[i] < cmp){
                  cmp = v[i];
                  ans++;
            }
      }

      cout << ans << endl;

return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;
    int ans = 0;

    vector<vector<int>> s(M, vector<int>());
    vector<int> p(M);
    REP(i, M)
    {
        int k;
        cin >> k;

        REP(j, k)
        {
            int tmp;
            cin >> tmp;
            s.at(i).push_back(tmp - 1);
        }
    }

    REP(i, M)
    {
        cin >> p[i];
    }

    REP(i, pow(2, N))
    {
        // スイッチの状態を表す文字列を生成
        string pw = "";
        int tmp = i;
        REPR(j, N-1)
        {
            if ( int(tmp / pow(2, j)) == 1)
            {
                pw += '1';
                tmp -= pow(2, j);
            }
            else
            {
                pw += '0';
            }
        }

        bool flag = true;
        // 電球ごとに点灯可否を判定
        REP(j, M)
        {
            int sw_cnt = 0;
            REP(k, s[j].size())
            {
                if (pw[s[j][k]] == '1')
                {
                    sw_cnt++;
                }
            }

            if (sw_cnt % 2 != p[j])
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int n,m,a,b,ma=-1,mi=1e9;
int main()
{
	cin>>n>>m;
	mi=n;
	for(int i=0;i<m;i++)
	{
		cin>>a>>b;
		ma=max(a,ma);
		mi=min(mi,b);
	}
	cout<<max(mi-ma+1,0);
}

Measured memory_bytes: 256
def check():
    S = input()
    a = 1
    
    for s in S:
        if a % 2 == 0:
            if s == 'R':
                return 'No'
        else:
            if s == 'L':
                return 'No'
        a += 1
    return 'Yes'
  
print(check())

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int l[2005][2005], r[2005][2005], u[2005][2005], d[2005][2005];

int main() {
	int h, w;
	cin >> h >> w;
	int count = 0;
	vector<string>maze(h);
	repp(i, 0, h)cin >> maze[i];
	repp(i, 0, h) {
		count = 0;
		repm(j, w - 1, -1) {
			if (maze[i][j] == '#')count = 0;
			else count++;
			r[i][j] = count;
		}count = 0;
		repp(j, 0, w) {
			if (maze[i][j] == '#')count = 0;
			else count++;
			l[i][j] = count;
		}
	}
	repp(j, 0, w) {
		count = 0;
		repm(i, h - 1, -1) {
			if (maze[i][j] == '#')count = 0;
			else count++;
			d[i][j] = count;
		}count = 0;
		repp(i, 0, h) {
			if (maze[i][j] == '#')count = 0;//#は数えられず、そこでリセット
			else count++;
			u[i][j] = count;
		}
	}
	int maxv = 0;
	repp(i, 0, h)repp(j, 0, w) {
		if (maze[i][j] == '#')continue;
		maxv = max(maxv, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3);//ランプを置いたマスは4回数えられているので-3
	}
	cout << maxv << endl;
	return 0;
}

Measured memory_bytes: 67072
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

struct node{
  ll id;
  ll value;
}; 

bool operator<(const node& left, const node& right) {
  return left.value < right.value;
}

bool operator>(const node& left, const node& right) {
  return left.value > right.value;
}

bool compare_id(const node& left, const node& right) {
  return left.id < right.id;
}

int main(int argc, char const *argv[])
{
  ll a, b, q;
  cin >> a >> b>> q;
  vector<ll> s = vector<ll>(a);
  vector<ll> t = vector<ll>(b);
  vector<node> x =  vector<node>(q);
  vector<vector<ll>> nearnodes = vector<vector<ll>>(q,vector<ll>(4));
  REP(i,a) cin >> s[i];
  REP(i,b) cin >> t[i];
  REP(i,q) {
    ll v;
    cin >> v;
    x[i] = {i,v};
  }
  std:sort(ALL(x));

  ll j = 0;
  ll left = -1;
  ll right = -1;
  REP(i,a) {
    if (j == q) break;
   if (s[i] < x[j].value){
     left = i;
   } 
   else {
     right = i;
   }
     nearnodes[x[j].id][0] = left == -1 ? pow(10,11) : abs(s[left]-x[j].value);
     nearnodes[x[j].id][1] = right == -1 ? pow(10,11) : abs(s[i]-x[j].value);
     if (right != -1 || left == a-1) {
       right = -1;
       j++;
       i--;
     }
  }
  j = 0;
left = -1;
right = -1;
  REP(i,b) {
    if (j == q) break;
   if (t[i] < x[j].value){
     left = i;
   } 
   else {
     right = i;
   }
     nearnodes[x[j].id][2] = left == -1 ? pow(10,11): abs(t[left]-x[j].value);
     nearnodes[x[j].id][3] = right == -1 ? pow(10,11) : abs(t[i]-x[j].value);
     if (right != -1 || left == b-1){
right =-1;
     j++;
     i--;
     }
  }
  std::sort(ALL(x),compare_id);
  for (auto p : x) {
    ll ans;
    ll tmp = max(nearnodes[p.id][0],nearnodes[p.id][2]);
    ll tmp2 = max(nearnodes[p.id][1],nearnodes[p.id][3]);
    ans = min(tmp,tmp2);
    if (((nearnodes[p.id][0] -nearnodes[p.id][2]) < 0 && (nearnodes[p.id][1]-nearnodes[p.id][3]) > 0) 
    || ((nearnodes[p.id][0] -nearnodes[p.id][2]) > 0 && (nearnodes[p.id][1]-nearnodes[p.id][3]) < 0)){
    tmp = min(nearnodes[p.id][0],nearnodes[p.id][2]);
    tmp2 = min(nearnodes[p.id][1],nearnodes[p.id][3]);
    ans = min(ans, min(tmp*2+tmp2,tmp2*2+tmp));
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
	int num[100][100]={0};
	int i,j,k=0,m=1,n,len=0;
	double outline=0.0;
	
	while(1){
	scanf("%d",&n);
		if(n==0)break;
	len=2*n-2;
	outline=(double)(0.5*n)-0.5;
	
	for(i=0;i<=len,m<=n*n;i++){
		for(j=i,k=len/2-i;j<=len,m<=i*n+n;j++,k++,m++)num[j][k]=m;
	}
	
	for(i=0;i<outline;i++){
		for(j=0;j<=len;j++){
			if(num[i][j]!=0)num[i+n][j]=num[i][j];
		}
	}
	for(i=len;i>(len-outline);i--){
		for(j=0;j<=len;j++){
			if(num[i][j]!=0)num[i-n][j]=num[i][j];
		}
	}
	for(i=0;i<=len;i++){
		for(j=0;j<outline;j++){
			if(num[i][j]!=0)num[i][j+n]=num[i][j];
		}
	}
	for(i=0;i<=len;i++){
		for(j=len;j>(len-outline);j--){
			if(num[i][j]!=0)num[i][j-n]=num[i][j];
		}
	}
	
	for(i=outline;i<=len-outline;i++){
		for(j=outline;j<=len-outline;j++)printf("%4d",num[i][j]);
		printf("\n");
	}
		for(i=0;i<=len;i++){
			for(j=0;j<=len;j++)num[i][j]=0;
		}
		
		k=0;
		m=1;
		len=0;
		outline=0;
	}
return 0;
}

Measured memory_bytes: 656
#include <cstdio> 
#include <algorithm>
#include <cstring>
using namespace std;
long long a[51];

int main(){
	long long k;
	scanf("%lld",&k);
	printf("50\n");
	long long k1 = k / 50;
	long long k2 = k % 50;
	for (int i = 1; i <= 50; i++) a[i] = 49 + k1;
	for (int i = 1; i <= k2; i++) a[i] += 50 - k2 + 1;
	for (int i = k2 + 1; i <= 50; i++) a[i] -= k2;
	for (int i = 1; i <= 50; i++) printf("%lld ",a[i]);
	return 0;	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int N;
string a[200001];
map<string, int> mp;
int ans = 0;

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> a[i];

    for(int i=0; i<N; i++){
        mp[a[i]] = 1;
    }

    for(auto i = mp.begin(); i != mp.end(); ++i){
        ans += i->second;
    }
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 25516
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n,m;
  vector<pair<int,int>>a;
  cin>>n>>m;
  for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    a.push_back(make_pair(x,y));
  }
  sort(a.begin(),a.end());
  int c = 0;
  ll ret = 0;
  for(int i=0;i<n;i++){
    if(c+a[i].second>=m){
      ret+=(m-c)*(ll)a[i].first;
      break;
    }
    ret+=a[i].first*(ll)a[i].second;
    c+=a[i].second;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

map<ll,int> cnt;

int main(void){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n) cnt[a[i]]++;

	int ans = 0;
	rrep(k,31){
		const ll tar = (1LL << k);
		for(auto &it: cnt){			
			const ll val = it.first;
			const ll nval = tar - it.first;
			if(val < tar/2 or tar <= val) continue;
			
			if(val == nval){
				const int num = it.second / 2;
				ans += num;
				it.second -= 2 * num;
			} else {
				const int num = min(it.second, cnt[nval]);
				ans += num;
				it.second -= num;
				cnt[nval] -= num;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 87168
#include<iostream>
#include<map>
#include<string>
#include<algorithm>


#define MAX 200005
using namespace std;
map<string,int> dic;
struct st{
	string s;
	int cnt;
};
st sa[MAX];
bool cmp(st a,st b){
	if(a.cnt != b.cnt){
		return a.cnt > b.cnt;
	}else{
		return a.s < b.s;
	}
}
int main( )
{
	
	int n;
	cin >> n;
	dic.clear();
	for(int i = 0;i < n; i++){
		string s;
		cin >> s;
		dic[s]++; 
	}
	map<string,int>::iterator it;
	int index = 0;
	for(it = dic.begin(); it != dic.end(); it++){
		sa[index].s = (it->first);
		sa[index].cnt = (it->second);
		index++;
	}
	sort(sa,sa + index,cmp);
	for(int i = 0; i < index && sa[i].cnt == sa[0].cnt; i++){
		cout << sa[i].s << endl;
	}
	
	return 0;
}

 

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

int main(void){
    int sum = 0;
    int n,x;
    cin >> n >> x;
    int l[n];
    for(int i=0; i < n; i++) cin >> l[i];
    int d[n];
    for(int i=0; i < n+1; i++){
        if(i == 0) d[0] = 0;
        else d[i] = d[i-1] + l[i-1];

        if(d[i] <= x) sum++;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int X,b,p,x,z=1;
 scanf("%d",&X);
 for(b=1;b<32;b++){
  x=b;
  for(p=2;p<10;p++){
   x=x*b;
   if(X>=x&&z<x){
    z=x;
   }
  }
 }
 printf("%d",z);
}


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

int main()
{
  long long int n;
  cin>>n;
  int count=0;

  while(n!=1){
    if(n%3==1){
      n+=2;
    }else if(n%3==2){
      n++;
    }
    n/=3;
    count++;
  }

  cout<<count<<endl;

  return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int now = c;
    while(now <= a*b) {
        if(now%a == 0) {
            cout << "YES" << endl;
            return 0;
        }
        now += b;
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;
string S;

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

  cin >> N;

  map<char, int> mp;
  REP(i, N)
  {
    cin >> S;
    mp[S[0]]++;
  }

  ll ans = 0;
  const char charset[5] = {'M', 'A', 'R', 'C', 'H'};
  for (int i = 0; i < 5; i++) {
    int ni = mp[charset[i]];
    for (int j = i + 1; j < 5; j++) {
      int nj = mp[charset[j]];
      for (int k = j + 1; k < 5; k++) {
        int nk = mp[charset[k]];
        ans += (ll)ni * nj * nk;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//Name: Prime Number II
//Level: 1
//Category: f,Tõ,upper_bound,lower_bound
//Note:

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    vector<int> primes;
    vector<int> is_prime(200001, 1);
    is_prime[0] = is_prime[1] = 0;
    int lim = (int)sqrt(200000);
    for(int i = 2; i <= lim; ++i) {
        if(is_prime[i]) {
            if(i < lim) {
                for(int j = i*i; j <= 200000; j += i) is_prime[j] = 0;
            }
        }
    }
    for(int i = 2; i <= 200000; ++i) 
        if(is_prime[i]) primes.push_back(i);

    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        int sum = 0;
        for(int i = 0; i < N; ++i) sum += primes[i];
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 0