akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    string s;cin>>s;
    int ans=0;
    rep(i,s.length()){
        int k;
        switch (s[i])
        {
        case '0':
        k=0;
        break;
        case '1':
        k=1;
        break;
        case '2':
        k=2;
        break;
        case '3':
        k=3;
        break;
        case '4':
        k=4;
        break;
        case '5':
        k=5;
        break;
        case '6':
        k=6;
        break;
        case '7':
        k=7;
        break;
        case '8':
        k=8;
        break;
        case '9':
        k=9;
        break;
        }
        ans+=k;
    }
    if(ans%9==0)printf("Yes\n");
    else printf("No\n");
}


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

AB = [list(map(int, input().split())) for _ in range(n)]
CD = [list(map(int, input().split())) for _ in range(n)]

Red = sorted(AB, key=lambda x: x[1], reverse = True)
Blue = sorted(CD, key= lambda x: x[0])

ans = 0
for b in Blue:
    for r in Red:
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            Red.remove(r)
            break

print(ans) 

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;
typedef long long  ll;

int main() {
	ll N, M;
	cin >> N >> M;
	vector<vector<ll>> field(N);
	for (ll i = 0; i < M; i++)
	{
		ll a, b;
		cin >> a >> b;
		field[a - 1].push_back(b - 1);
		field[b - 1].push_back(a - 1);
	}
	vector<bool> possible(N, false);
	queue<pair<ll,ll>> que;
	que.push(make_pair(0, 0));
	possible[0] = true;
	ll cnt = 1;
	while (!que.empty())
	{
		cnt++;
		auto target = que.front();
		que.pop();
		for (auto val : field[target.first])
		{
			if (possible[val]) {
				continue;
			}
			if (target.second < 2) {
				que.push(make_pair(val, target.second + 1));
				possible[val] = true;
			}
		}
	}
	if (possible[N - 1]) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}

Measured memory_bytes: 14440
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

int main ()
{
    ll X;
    cin >> X;

    ll cur = 100L;
    for (int i = 0; i < 100000; i++) {
        if (X <= cur) {
            cout << i << endl;
            return 0;
        }
        cur += cur / 100L;
    }

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
using ll = long long int;
const int INF = 1e9;

int main(){
    int q; cin >> q;
    int id, a, b;
    ll ans = 0LL;

    // Get median with 2 priority_queue
    priority_queue<int> pq_lft;
    priority_queue<int, vector<int>, greater<int>> pq_rgt;
    pq_lft.push(-INF); pq_rgt.push(INF);
    for(int i=0; i<q; i++){
        cin >> id;
        // Update query
        if(id == 1){
            cin >> a >> b;
            // Add bias
            ans += b;
            // Insert a
            if(pq_lft.size() == pq_rgt.size()){
                if(a < pq_rgt.top()){
                    if(a < pq_lft.top()){
                        ans += pq_lft.top() - a;
                    }
                    pq_lft.push(a);
                }
                else{
                    ans += a - pq_rgt.top();
                    pq_rgt.push(a);
                    pq_lft.push(pq_rgt.top()); pq_rgt.pop();
                }
            }
            else{
                ans += abs(pq_lft.top() - a);
                if(a > pq_lft.top()){
                    pq_rgt.push(a);
                }
                else{
                    pq_lft.push(a);
                    pq_rgt.push(pq_lft.top()); pq_lft.pop();
                }
            }
        }
        // Get query
        if(id == 2){
            cout << pq_lft.top() << " " << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double a = scan.nextDouble(), b = scan.nextDouble();
        int C = scan.nextInt();
        double c2 = Math.pow(a, 2) + Math.pow(b, 2);
        double c = Math.sqrt(c2);

        double S = (a * b * Math.sin(Math.toRadians(C))) / 2;
        System.out.printf("%5.8f", S);
        System.out.println();

        double L = a + b + Math.sqrt(c2 - 2 * a * b * (Math.cos(Math.toRadians(C))));
        System.out.printf("%5.8f", L);
        System.out.println();

        double h = b * Math.sin(Math.toRadians(C));
        System.out.printf("%5.8f", h);
        System.out.println();
    }
}

Measured memory_bytes: 28068
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;

int main(){
    int N;
    cin >> N;
    int ans=0;
    
    for(int i=1; i<=N; i+=2){
        int num=0;
        for(int j=1; j<=N; j++){
            if(i%j==0){
                num++;
            }
        }
        
        if(num==8){
            ans++;
        }
        
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    for (const char &c: s) {
        mp[c]++;
    }
    if(mp.size() == 2){
        for(auto vk : mp){
            if(vk.second != 2){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;

    }

}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0;
	cin>>n;
	int evenBeven=0;
	int even=0;
	int odd=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if((a%2)==1){
			odd++;
		}else{
			if((a%4)==0){
				evenBeven++;
			}else{
				even++;
			}
		}
	}
	if((evenBeven-odd)<0){
		if((odd-evenBeven)==1){
			if(even==0){
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
		}else{
			cout<<"No"<<endl;
		}
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
  string S;
  int ans=0,count=2;
  cin >> S;
  for(int i=1;i<=100;i=i*10){
    if(S[count]=='1'){
      ans+=9*i;
    }
    else{
      ans+=1*i;
    }
    count--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

 
int main() {
    ll ans = 0;

    ll n, l;

    cin >> n >> l;

    if (l > 0) {
        for (int i = 1; i < n; i++) {
            ans += l + i;
        }
    } else if (l < 0 && l + n <= 0) {
        for (int i = 0; i < n-1; i++) {
            ans += l + i;
        }
    } else {
        for (int i = 0; i < n; i++) {
            ans += l + i;
        }
    }

    cout << ans << endl;

    
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String comparison = scan.next();
        String word;
        int count = 0;
        while ("END_OF_TEXT".equals((word = scan.next())) == false) {
            if (word.equalsIgnoreCase(comparison))
                count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 18200
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
string s; cin>>s;
int flag1,flag2;
int res=0;
if(s[0]=='W')flag1=1; 
else  flag1=0;

REP(i,s.size()){
  if(s[i]=='W')flag2=1;
  else flag2=0;
  if(flag1!=flag2)res++;
  flag1=flag2;

}
cout<<res<<endl;

}

Measured memory_bytes: 512
s = input()
t = set(list(s))
n = len(s)
al={chr(ord('a') + i) for i in range(26)}
if n != 26:
    p = al - t
    p = list(p)
    p.sort()
    print(s + p[0])
elif n == 26:
    if s == "zyxwvutsrqponmlkjihgfedcba":
        print(-1)
    else:
        now = s[25]
        p = []
        for i in reversed(range(26)):
            if ord(now) <= ord(s[i]):
                p.append(now)
                now = s[i]
            elif ord(now) > ord(s[i]):
                p.append(now)
                print(s[:i],end="")
                q = []
                for j in p:
                    if ord(s[i]) < ord(j):
                        q.append(ord(j))
                print(chr(min(q)))
                exit()

Measured memory_bytes: 9112
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minA = a[0]
for reizou in a[1:]:
    if reizou < minA:
        minA = reizou
minB = b[0]
for renzi in b:
    if renzi < minB:
        minB = renzi
kakaku = minA + minB
for i in range(M):
    x,y,c = map(int,input().split())
    sumKakaku = a[x-1] + b[y-1] - c
    if sumKakaku < kakaku:
        kakaku = sumKakaku

print(kakaku)

Measured memory_bytes: 18736
using System;
using System.Linq;

namespace ABC147B
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int ans = 0;
            var a = S.Take(S.Length / 2).ToArray();
            var b = S.Reverse().Take(S.Length / 2).ToArray();

            for (var i = 0; i < a.Length; i++)
                if (a[i] != b[i]) ans++;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main() {
	
	string a;
	
	getline(cin, a);
	
	for (int i=0; i<a.size(); i++){
		if (a[i] >= 'A' && a[i] <= 'Z'){
			a[i] = a[i]+32;
		} else if (a[i] >= 'a' && a[i] <= 'z'){
			a[i] = a[i]-32;
		} 
	}
	cout << a  << endl;
		
	return 0;
}


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

int main()
{
    int d, g;
    cin >> d >> g, g /= 100;

    vector<int> p(d), c(d);
    for (int i = 0; i < d; i++) cin >> p[i] >> c[i], c[i] /= 100;

    int ans = 1 << 29;
    for (int i = 0; i < 1 << d; i++) {
        int score = 0, cnt = 0;
        for (int j = 0; j < d; j++) {
            if ((i >> j) & 1) {
                score += (j + 1) * p[j] + c[j];
                cnt += p[j];
            }
        }
        for (int j = d - 1; j >= 0; j--) {
            if ((i >> j) & 1) continue;
            for (int k = 0; k < p[j] - 1; k++) {
                if (score >= g) continue;
                score += j + 1;
                cnt++;
            }
        }
        if (score >= g) ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int n,a,b;
int m;
int po[1<<17];
int it;

void dfs(int x, int y){
  // left x-bit odd, right y-bit even
  assert(x%2==1);
  // length: 1<<(x+y) - 1
  int l = x+y;
  if(l==1){
    po[it++] = 0;
    return;
  }
  REP(a,l)if(a%2==1){
    int b = l-1-a;
    int c = a+1-x;
    if(c<=0 || c>a || l-1-c<0 || c%2!=1)continue;
    int d = l-1-c;
    dfs(a,b);
    po[it++] = l-1;
    dfs(c,d);
    int sz = (1<<(c+d)) - 1;
    FOR(i,it-sz,it){
      po[i] = (c+d-1) - po[i];
      po[i] = (po[i] + b) % (a+b);
    }
    return;
  }
  REP(a,l)if(a%2==1){
    int b = l-1-a;
    int c = x-a-1;
    if(c<=0 || c>a || l-1-c<0 || c%2!=1)continue;
    int d = l-1-c;
    dfs(a,b);
    po[it++] = l-1;
    dfs(c,d);
    int sz = (1<<(c+d)) - 1;
    FOR(i,it-sz,it){
      po[i] = (po[i] + b) % (a+b);
    }
    return;
  }
}

int p[1<<17];

int main(){
  cin>>n>>a>>b;
  m = 1<<n;
  int diffbits = __builtin_popcount(a^b);
  if(diffbits%2==0){
    puts("NO"); return 0;
  }
  puts("YES");
  it = 0;
  dfs(diffbits, n - diffbits);
  p[0] = 0;
  REP(i,m-1){
    p[i+1] = p[i] ^ (1<<po[i]);
  }
  map<int,int> M;
  int xit = n-diffbits, yit = 0;
  REP(i,n){
    int bb = (a^b)>>i&1;
    if(bb){
      // diff
      M[xit++] = i;
    }else{
      M[yit++] = i;
    }
  }
  REP(i,m){
    int v = 0;
    REP(j,n){
      int bb = p[i]>>j&1;
      v |= bb<<M[j];
    }
    p[i] = v ^ a;
    printf("%d%c",p[i],i==m-1?'\n':' ');
  }
  // check
  bool ok = true;
  ok = ok && p[0] == a;
  ok = ok && p[m-1] == b;
  REP(i,m-1){
    ok = ok && __builtin_popcount(p[i]^p[i+1]) == 1;
  }
  if(!ok){
    puts("ERROR");
    printf("n=%d, a=%d, b=%d\n",n,a,b);
  }
  return 0;
}


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

int main()
{
  int n; cin >> n;
  
  int a[10005], ans;
  
  rep(i,n) {
    cin >> a[i];
    while (a[i] %2 == 0) {
        a[i] /= 2;
        ans++;
        }
  }
  cout << ans << endl;
  return 0;
}

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

string R(string s,string t,string u){
	int p=s.find(t);
	while(p!=string::npos){
		s.replace(p,t.size(),u);
		p=s.find(t,p+u.size());
	}
	return s;
}
string from[21]={"-0","-1","-2","(0*0)","(0*1)","(0*2)","(1*0)","(1*1)","(1*2)","(2*0)","(2*1)","(2*2)","(0+0)","(0+1)","(0+2)","(1+0)","(1+1)","(1+2)","(2+0)","(2+1)","(2+2)"};
string to[21]={"2","1","0","0","0","0","0","1","1","0","1","2","0","1","2","1","1","2","2","2","2"};
string kaga3(string s){
	while(1<s.size()){
		for(int i=0;i<21;i++)s=R(s,from[i],to[i]);
	}
	return s;
}

int main(){
	
	for(string S,s;cin>>S,S!=".";){
		int ans=0;
		for(char P='0';P<'3';P++){
			for(char Q='0';Q<'3';Q++){
				for(char R='0';R<'3';R++){
					s=S;
					replace(s.begin(),s.end(),'P',P);
					replace(s.begin(),s.end(),'Q',Q);
					replace(s.begin(),s.end(),'R',R);
					if(kaga3(s)=="2")ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1216
N,X=map(int ,raw_input().split())
L =list(map(int ,raw_input().split()))
p = 0
y = -1
for i in range(N):
    p += L[i]
    if p>X:
        y = i
        break
if y>=0:
    print y+1
else:
    print N+1

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

int main() {
  int N, ki;
  double ans;
  cin >> N;

  if (N % 2 == 0) {
    ki = N / 2;
  } else {
    ki = N / 2 + 1;
  }
  cout << fixed << setprecision(10);
  ans = (double)ki / N;
  cout << ans << endl;
}

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

int main() {
	//おまじない
	cin.tie(0);
	ios::sync_with_stdio(false);


	int A, B;
	cin >> A >> B;

	int maximum = -1e9;

	maximum = max(maximum, A + B);
	maximum = max(maximum, A - B);
	maximum = max(maximum, A * B);

	cout << maximum << "\n";

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  
  if(s[0]==t[2]&&s[1]==t[1]&&s[2]==t[0]){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sum1 = 0;
  int sum2 = 0;
  for(int i = 0;i < s.size();i++) {
    if(i % 2 == 0) {
      if(s.at(i) == '1') {
        sum1++;
      }else {
        sum2++;
      }
    }else {
      if(s.at(i) == '0') {
        sum1++;
      }else {
        sum2++;
      }
    }
  }
  cout << min(sum1,sum2) << endl;
}

Measured memory_bytes: 512
from collections import defaultdict

N,M = map(int, input().split())
H = list(map(int, input().strip().split()))

A=[0]*M
B=[0]*M
d = defaultdict(list)
count=0

for i in range(M):
    A[i],B[i]=map(int, input().split())
for i in range(M):
    d[A[i]].append(B[i])
    d[B[i]].append(A[i])



for i in range(N):
    # print(d[i+1])
    # print("---")
    check=1
    for k in d[i+1]:
        # print(k)
        if H[i] <= H[k-1]:
            check=0
            break
    if check==1:
        count=count+1
    # print("H=",i+1,"count=",count)

print(count)

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max({10*A + B + C, 10*B + A + C, 10* C + A + B}) << endl;
}

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

using namespace std;

const int N = (int) 1e5 + 5;

vector<int> g[N];
vector<int> vec;

bool mark[N];
int a[N];

void dfs(int v) {
  vec.push_back(a[v]);
  mark[v] = 1;
  for (int to : g[v]) {
    if (!mark[to]) {
      dfs(to);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int C = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      ++C;
      dfs(i);
    }
  }
  if (C == 1) {
    cout << 0 << endl;
    return 0;
  }
  memset(mark, 0, sizeof mark);
  vector<int> got;
  long long res = 0;
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      vec.clear();
      dfs(i);
      sort(vec.begin(), vec.end());
      res += vec[0];
      for (int i = 1; i < min((int) vec.size(), C - 1); i++) {
        got.push_back(vec[i]);
      }
    }
  }
  if ((int) got.size() < C - 2) {
    cout << "Impossible" << endl;
  } else {
    sort(got.begin(), got.end());
    for (int i = 0; i < C - 2; i++) {
      res += got[i];
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 9860
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]), dp[i-2] + abs(H[i]-H[i-2])
                ) if i >= 2 else dp[i-1] + abs(H[i] - H[i-1])
#print(*dp)
print(dp[N-1])


Measured memory_bytes: 52208
/*
 * FileName:     D
 * CreatedDate:  2020-05-31 22:04:17 +0900
 * LastModified: 2020-06-28 10:14:50 +0900
 */

#include <stdio.h>

int main(void){
    long long int n;scanf("%lld",&n);
    int ans=0;
    for(long long int i=2;i*i<=n;i++){
        if(n%i==0){
            int cnt = 0;
            while(n%i==0){
                n/=i;
                cnt++;
            }
            for(int j=1;j<=cnt;j++){
                cnt -= j;
                ans++;
            }
        }
    }
    if(n!=1)ans++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n){
    int ans=0;
    REP(i,1,n){
        int sum=0;
        rep(j,1000){
            sum+=i+j;
            if(sum==n)++ans;
            if(sum>n)break;
        }
    }
    cout<<ans<<endl;
}
int main(){
    int n;
    while(cin>>n,n!=0)solve(n);
    return 0;
}


Measured memory_bytes: 3080
N, Y = map(int, input().split(' '))

for i in range(N+1):
    for j in range(N+1):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j >=0:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
import math

q= int(input())
lrs = [list(map(int,input().split())) for l in range(q)]

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

primes = [0]
for i in range(1,10**5+3):
    if is_prime(i):
        primes.append(1)
    else:
        primes.append(0)

like20 = [0]
for i in range(1,10**5+3):
    if primes[i] == 1 and primes[(i+1) // 2] == 1:
        like20.append(like20[i-1]+1)
    else:
        like20.append(like20[i-1])

for lr in lrs:
    print(like20[lr[1]] - like20[lr[0]-1])
    

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


bool tv[100008][31];

int main() {

    
    int N, C;
    scanf("%d %d", &N, &C);
    int M = 1;
    int s,t,c;
    for(int i = 0; i < N; ++i){
        scanf("%d %d %d", &s, &t, &c);
        for(int k = s; k < t; ++k){
            tv[k][c] = true;
        }
        M = max(M, t);
    }
    int cur = 0;
    int ans = 1;
    int prev = 0;
    int rep = 0;
    
    for(int i = 0; i <= M; ++i){
        cur = 0, rep = 0;
        for(int k = 0; k <= C; ++k){
            cur += tv[i][k];
            if(i && tv[i][k] && tv[i-1][k]) rep++;
        }
        ans = max(ans, abs(cur + prev - rep));
        prev = cur;
    }
    
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,a,b;
    cin>>n>>a>>b;
    
    int ans=min(n*a,b);
    cout1(ans)
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
	cin>>s;
	map<char, int> d;
	d['N'] = 1;
	d['S'] = 2;
	d['W'] = 4;
	d['E'] = 8;
	int f = 0;
	for(char c: s) f |= d[c];
	if((1&f)!=(1&(f>>1)) || (1&(f>>2))!=(1&(f>>3))) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  if(N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  } else {
    cout << "Hello World" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	int i, j, k, c, H[100], W[100];
	i = 0;
	while (1) {
		scanf("%d %d", &H[i], &W[i]);
		if (0 == H[i] && 0 == W[i]) {
			break;
		}
		i++;
	}
	c = i;
	for (k = 0; k < c; k++) {
		for (j = 0; j < H[k]; j++) {
			for (i = 0; i <W[k]; i++) {
				if ((i == 0 || j == 0) ||( i == W[k]-1 || j ==H[k]-1)) {
					printf("#");
				}
				else {
					printf(".");
				}

			}
			printf("\n");
		}
		printf("\n");
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i); 
  }
  bool flag = true;
  int count = vec[0];
  for(int i:vec){
    if (count < i) count = i-1;
    else if (count == i) count = i;
    else{
      flag = false;
      break;
    }
  }
  if (flag == true) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n,k;
  cin >> n >> k;
  string s = "";
  while(n) {
    s += to_string(n%k);
    n /= k;
  }
  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int sx, sy, tx, ty;


string solve(){
	string ans;
	rep(i, sy, ty) ans.pb('U');
	rep(i, sx, tx) ans.pb('R');
	repr(i, ty, sy) ans.pb('D');
	repr(i, tx, sx) ans.pb('L');
	ans.pb('L');
	rep(i, sy, ty+1) ans.pb('U');
	rep(i, sx-1, tx) ans.pb('R');
	ans.pb('D');
	ans.pb('R');
	repr(i, ty, sy-1) ans.pb('D');
	repr(i, tx+1, sx) ans.pb('L');
	ans.pb('U');
	return ans;
}


signed main(){
	cin >> sx >> sy >> tx >> ty;
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL calc(LL A, LL B) {
    if (A == B) return 1;
    int t;
    for (t=61; t>=0; t--) {
	if ((A^B)>>t&1) {
	    break;
	} else {
	    A &= ~(1LL<<t);
	    B &= ~(1LL<<t);
	}
    }

    LL ret = (1LL<<t) - A;

    int u;
    for (u=t-1; u>=0; u--) {
	if (B>>u&1) {
	    break;
	}
    }
    // [0, 2<<u)+(1<<t) | [A, 1<<t)+(1<<t)
    LL l0 = (1LL<<t), r0 = (2LL<<u)+l0;
    LL l1 = A+l0, r1 = l0*2;
    if (B == (1LL<<t)) {
	r0 = l0 + 1;
    }
    if (r0 <= l1) ret += r0 - l0 + r1 - l1;
    else ret += max(r0, r1) - min(l0, l1);
    return ret;
}

void MAIN() {
    LL A, B;
    scanf("%lld%lld", &A, &B);
    LL ans = calc(A, B);
    printf("%lld\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const int MAX_N = 5e3 + 5;
const int MAX_M = 205;
const int LOGN = 14;

int n, m, lg[MAX_N], spt[MAX_M][LOGN][MAX_N];
ll a[MAX_N], ans = 0;

int query(int k, int i, int j) {
    int log = lg[j - i + 1];
    return max(spt[k][log][i], spt[k][log][j - (1 << log) + 1]);
}

void solve(int l, int r, int p1, int p2) {
    //printf("I am at (%d, %d)\n", l, r);
    if (l > r) return;
    int mid = (l + r) >> 1;
    int opt = mid;
    ll best = 0;
    for (int i = max(mid, p1); i <= max(mid, p2); i++) {
        ll cost = -(a[mid] - a[i]);
        for (int k = 1; k <= m; k++)
            cost += query(k, mid, i);
        if (cost > best) {
            best = cost;
            opt = i;
        }
    }
    ans = max(ans, best);
    solve(l, mid - 1, p1, opt);
    solve(mid + 1, r, opt, p2);
}

int main() {
    for (int i = 2; i < MAX_N; i++)
        lg[i] = lg[i >> 1] + 1;
    scanf("%d %d", &n, &m);
    for (int i = 1; i < n; i++)
        scanf("%lld", &a[i]);
    for (int i = n - 1; i >= 1; i--)
        a[i] += a[i + 1];
    for (int i = 1; i <= n; i++)
        for (int k = 1; k <= m; k++)
            scanf("%d", &spt[k][0][i]);
    for (int k = 1; k <= m; k++)
        for (int j = 1; j < LOGN; j++)
            for (int i = 1; i + (1 << j) - 1 <= n; i++)
                spt[k][j][i] = max(spt[k][j - 1][i], spt[k][j - 1][i + (1 << (j - 1))]);
    solve(1, n, 1, n);
    printf("%lld\n", ans);
    return 0;
}




Measured memory_bytes: 55040
#include <stdio.h>

int main(void)
{
	int a[4],b[2],i,j,c,d,g,sum;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<2;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<4;j++){
			if(a[i]<a[j]){
				c=a[i];
				a[i]=a[j];
				a[j]=c;
			}
		}
	}
	g=a[0]+a[1]+a[2];
	if(b[0]<b[1]){
		d=b[1];
	}
	else{
		d=b[0];
	}
	sum=g+d;
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2104
import java.util.Scanner;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
    		int n = scan.nextInt();
			int k = scan.nextInt();
			int count=0;
			int[] a = new int[n];
			for(int i=0;i<n;i++)
			{
				a[i]=scan.nextInt();
				if(a[i]>=k)
					count++;
			}
			System.out.println(count);
    	}
    }

Measured memory_bytes: 50300
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	ll n, v[1000];
	bool b = 1;
	cin >> n;
	TFOR(i, n) {
		cin >> v[i];
		if (v[i] % 2 != 0)b = 0;
	}
	int ans = 0;
	while (b) {
		++ans;
		TFOR(i, n) {
			v[i] /= 2;
			if (v[i] % 2 != 0)b = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, k, q = list(map(int, input().split()))
a = [0] * q
for i in range(q):
  a[i] = int(input())

cur_k = [k] * n

for i in range(q):
  cur_k[a[i] - 1] += 1

for i in cur_k:
  if (i > q):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 50904
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1e5+10;
struct Data{
	int mx,smx,valmx,valsmx;
	void init(){mx=smx=valmx=valsmx=0;}
	void update(int x,int num){
		if (num>=mx)
			valsmx=valmx,smx=mx,mx=num,valmx=x;
		else if (num>smx)
			valsmx=x,smx=num;
	}
}info[2];
int cnt[2][N],mx[2];
int n,ans;

int main(){
#ifndef ONLINE_JUDGE
	//freopen("a.in","r",stdin);
#endif
	int x,mxcnt,sum,smxcnt;
	scanf("%d",&n);
	for (int i=1;i<=n;++i){
		scanf("%d",&x);
		++cnt[i&1][x];
		mx[i&1]=max(mx[i&1],x);
	}
	ans=0;
	for (int i=0;i<2;++i){
		info[i].init();
		for (int j=1;j<=mx[i];++j)
			info[i].update(j,cnt[i][j]);
	}
	ans=n;
	if (info[0].valmx!=info[1].valmx)
		ans-=info[0].mx+info[1].mx;
	else{
		int tmp=0;
		if (info[0].valsmx!=info[1].valmx)
			tmp=max(tmp,info[0].smx+info[1].mx);
		if (info[0].valmx!=info[1].valsmx)
			tmp=max(tmp,info[0].mx+info[1].smx);
		ans-=tmp;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1024
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define vp(x,y) vector< pair<x,y> >
#define mp make_pair
#define all(x) x.begin(),x.end()
#define Sort(x) sort(all(x));
#define DSort(x) sort(all(x), greater<>());
#define l_b lower_bound
#define u_b upper_bound
#define u_set unordered_set
#define u_map unordered_map
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)

const ll M=1e9+7;
const ld PI=3.14159265;
using namespace std;

int main(){
    fast_io;
    ll c=0,n,l,r;
    string str;
	cin>>n>>str;	
 	l=0,r=n-1;
	while(l<r){
    	while((l<=n-1) and (str[l]=='R')) l++;
    	while((r>=0) and (str[r]=='W')) r--;
    	if(l<r){
        	swap(str[l],str[r]);
        	c++;
        }
    }
 	cout<<c;
	return 0;
}



Measured memory_bytes: 3736
#include <stdio.h>

int main(){
  int i;
  char s[11],t[12];
  scanf("%s",&s);
  scanf("%s",&t);
  for(i=0;s[i]!=0;i++){
    if(s[i]!=t[i]) break;
  }
  
  if(s[i]==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}

Measured memory_bytes: 1728
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int X,Y;
  cin >> X >> Y;
  cout << X+(Y/2) << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列


    if N>=30:
        print('Yes')
    else:
        print('No')



if __name__ == "__main__":
    main()

Measured memory_bytes: 72716
import java.util.Scanner;

public class Main {

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

		int N = s.nextInt();
		int L = s.nextInt();

		int ajiMin = 9999;
		int ajiSum = 0;
		for (int i = 1; i <= N; i++) {
			int aji = L + i - 1;
			ajiSum += aji;

			if(Math.abs(aji) < Math.abs(ajiMin)) {
				ajiMin = aji;
			}
		}
		System.out.println(ajiSum - ajiMin);

	}

}


Measured memory_bytes: 21972
#include<stdio.h>
#include<iostream>

using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    long long ans=0;
    for(int j=1;j<=5;j++)
    {
        for(int i=1;i<=11&&i<=n-2;i++)
        {
            if((8*i+9*j+9)%11==k)
            {
                ans+=(n-2-i)/11+1;
            }
        }
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

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

const int N = 1e6 + 20 , C = 26 + 4 ;
int n , last[N][C] , ans , add ;
string s , t ;

int deq[2 * N] , he = N , ta = N ;

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

	cin >> n ;
	cin >> s >> t ;

	memset(last , -1 , sizeof last) ;
	for (int i = 0 ; i < n ; i ++) {
		for (int j = 0 ; j < C ; j ++) last[i + 1][j] = last[i][j] ;
		last[i + 1][s[i] - 'a'] = i ;
	}

	int p = n ;
	add = 0 ;

	for (int i = n - 1 ; ~i ; i --) {
		if (i >= p && t[i] == t[i + 1]) continue ;

		int np = last[p][t[i] - 'a'] ;

		if (np == -1) return cout << "-1\n" , 0 ;

		add ++ ;
		deq[--he] = np + add ;

		while (ta - he >= 2 && deq[ta - 2] - add >= i) ta -- ;
		
		if (deq[ta - 1] < i + add) deq[ta ++] = i + add ;
		deq[ta - 1] = i + add ;

		ans = max(ans , ta - he - 1) ;
		
		p = np ;
	}

	cout << ans << '\n' ;
}


Measured memory_bytes: 126236
H,W=gets.chomp.split(" ").map(&:to_i)
N=H*W

node_list = []
edge_hash = {}
s_pre = "#"*W
(0..(H-1)).each do |h|
    s = gets.chomp
    (0..(W-1)).each do |w|
        next if s[w] == "#"
        node = h*W+w
        edge_hash[node] = []
        node_list.push(node)
        if s[w] == s_pre[w]
            edge_hash[node].push(node-W)
            edge_hash[node-W].push(node)
        end
        next if w==0
        if s[w] == s[w-1]
            edge_hash[node].push(node-1)
            edge_hash[node-1].push(node)
        end
    end
    s_pre = s
end

ret = 0
node_length = node_list.length
node_list.each do |start_node|
    nodes = [start_node]
    visited = {}
    visited[start_node] = 1
    turn = 0
    while node_length != visited.length
        next_nodes = []
        nodes.each do |n|
            edge_hash[n].each do |neighbor|
                next_nodes.push(neighbor) if visited[neighbor] == nil
                visited[neighbor] = 1
            end
        end
        turn += 1
        nodes = next_nodes
    end
    ret = [ret,turn].max
end
puts ret


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

int main(){
    int A, B, C;
    int ans;

    //input
    cin >> A >> B >> C;

    if(A > C && B < C){
        cout << "Yes" << endl;
    }else if(A < C && B > C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


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


int main(){
    long long int n,sum=0,ans=2000000000;
    cin>>n;
    vector<long long int>a(300000);
    vector<long long int>b(300000);
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    b[0]=a[0];
    for(int i=1;i<n-1;i++){
        b[i]=a[i]+b[i-1];        
    }
    for(int i=0;i<n-1;i++){
        if(abs((sum-b[i])-b[i])<ans){
            ans=abs((sum-b[i])-b[i]);
        }      
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
        int x; cin >> x;
        int temp = x / 100;
        if(temp == 0){
            cout << '0' << endl;
            return 0;
        }
        if(x % (temp * 100) <= temp * 5) cout << '1' << endl;
        else cout << '0' << endl;
    return 0;
}


Measured memory_bytes: 3628
from operator import itemgetter
N = int(input())
sp = []
for i in range(0,N):
    s,p = input().split()
    p = int(p)
    sp.append((s,p,i+1))

sp.sort(key=itemgetter(1), reverse=True)
sp.sort(key=itemgetter(0))

for s,p,i in sp:
    print(i, end=" ")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int T_H, T_A, A_H, A_A;
	cin >> T_H >> T_A >> A_H >> A_A;
	if((A_H-1)/T_A <= (T_H-1)/A_A) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
   


    int n;
    scanf("%d",&n);
    if(n<10)printf("%d",n);
    else if(n<100)printf("9");
    else if(n<1000)printf("%d",n-90);
    else if(n<10000)printf("909");
    else if(n<100000)printf("%d",n-9090);
    else printf("90909");

    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] cards = new int[n];
        for (int i = 0;i < n;++i){
            cards[i] = sc.nextInt();
        }
        Arrays.sort(cards);
        HashMap<Integer,Integer> counts = new HashMap<>();
        int c = 0;
        for (int i = 0;i < n;++i){
            if(counts.containsKey(cards[i])){
                counts.put(cards[i],counts.get(cards[i]) + 1);
                int k = counts.get(cards[i]);
                if(k >= 3){
                    counts.put(cards[i],k - 2);
                }
            }
            else{
                counts.put(cards[i],1);
                ++c;
            }
        }
        int cc = 0;
        for (int i:counts.keySet()){
            int k = counts.get(i);
            if(k == 2){
                ++cc;
            }
        }
        if(cc % 2 == 1){
            --c;
        }
        System.out.println(c);





    }

}

Measured memory_bytes: 55052