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



int main(){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long tmp1=c,tmp2=d;
    if(tmp1>tmp2)swap(tmp1,tmp2);
    while(tmp1>0){
        long long x=tmp1;
        tmp1=tmp2%tmp1;
        tmp2=x;
    }
    long long GCD=c/tmp2*d;
    long long ans=b-(a-1);
    ans-=b/c-(a-1)/c;
    ans-=b/d-(a-1)/d;
    ans+=b/GCD-(a-1)/GCD;
    cout<<ans<<endl;
    return 0;
}

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

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

    int ans = 1000000;

    int N;
    cin >> N;

    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        int c = 0;
        while(A % 2 == 0) {
            A /= 2;
            c++;
        }
        ans = min(ans, c);
    }

    cout << ans << endl;
}

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

#define M 1000000
#define L 14

char H[M][L];
int cnt=0;

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}


int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + key % (M-1);
}


int find(char str[]){
  int i=0;
  int j;
  int k=getKey(str);
  while(i<M)
    {
      j=(h1(k)+i*h2(k))%M;
      if(!strcmp(H[j],str))
        {
          return j;
        }
      else if(H[j][0]=='\0')
        {
          return 0;
        }
      else
        {
          i++;
        }
    }
  return 0;
}

int insert(char str[]){
  int i=0;
  int j;
  int k=getKey(str);
  while(i<M)
    {
      j=(h1(k)+i*h2(k))%M;
      if(!strcmp(H[j],str))
        {
          return j;
        }
      else if(H[j][0]=='\0')
        {
          strcpy(H[j],str);
          return j;
        }
      else
        {
          i++;
        }
    }
  return -1;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0'; // 初期化

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if(com[0] == 'i'){
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 15468
N, M = map(int, input().split())

AC_count = 0
WA_count = 0

problem_list = [0]*N
result_list = [0]*N
wa_list = [0]*N

for _ in range(M):
    p, s = map(str, input().split())
    p = int(p)
    p -= 1

    if problem_list[p] == 1:
        if result_list[p] == 'AC':
            continue
        elif result_list[p] == 'WA' and s =='AC':
            result_list[p] = 'AC'
            AC_count += 1
        else:
            wa_list[p] += 1
            
    else:
        problem_list[p] = 1
        result_list[p] = s

        if s == 'AC':
            AC_count += 1
        else:
            wa_list[p] += 1

for i in range(N):
    if result_list[i] == 'AC':
        WA_count += wa_list[i]

print(AC_count, WA_count)

Measured memory_bytes: 10964
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,w,ans=0;
    ll wei,val;
    cin>>n>>w;
    ll dp[n+1][N];
    rep(i,0,n) rep(j,0,N-1) dp[i][j]=INF;
    rep(i,0,n) dp[i][0]=0;
    // dp[1][0]=0;
    rep(i,1,n){
        cin>>wei>>val;
        rep(j,0,N-1){
            dp[i][j]=min(dp[i-1][j],dp[i][j]);
            if(dp[i-1][j]!=INF && (j+val)<N) dp[i][j+val]=min(dp[i][j+val],wei+dp[i-1][j]);
            // else dp[i][j]=min(dp[i-1][j],dp[i][j]);
            // ans=max(ans,dp[i][j]);
        }
    }
    // rep(i,1,n) {rep(j,0,100) {cout<<dp[i][j]<<" ";} cout<<endl;}
    rep(i,1,n) {rep(j,0,N-1) {if(dp[i][j]<=w) {ans=max(ans,j);}}}
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  map<pair<int,int>,int> m;
  Graph G(N);
  for (int i=0;i<N-1;i++){
    int u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    w%=2;
    G[u].push_back(v);
    G[v].push_back(u);
    m[make_pair(u,v)]=w;
    m[make_pair(v,u)]=w;
  }
  vector<int> color(N,-1);
  queue<int> que;
  que.push(0);
  color[0]=0;
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for (int nv : G[v]){
      if (color[nv]!=-1){
        continue;
      }
      else {
        que.push(nv);
        color[nv]=(color[v]+max(m[make_pair(v,nv)],m[make_pair(nv,v)]))%2;
      }
    }
  }
  for (int i=0;i<N;i++){
    cout << color[i] << endl;
  }
}

Measured memory_bytes: 18816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {

    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n){
        cin >> x[i];
    }

    ll ans = 0; 
    rep(i, n-1){
        if((x[i+1]-x[i]) * a < b){
            ans += (x[i+1]-x[i]) * a;
        }
        else{
            ans += b;
        }
    }
    cout << ans << endl;

    return 0;
}


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

public class Main {

    public static void main(String[] args) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            double sum = 0;
            while ((line = br.readLine()) != null) {
                if (line.contains(" ")) {
                    String[] tokens = line.split(" ");
                    if ("JPY".equals(tokens[1])) {
                        sum = sum + Integer.parseInt(tokens[0]);
                    }
                    if ("BTC".equals(tokens[1])) {
                        sum = sum + Double.parseDouble(tokens[0]) * 380000.0;
                    }
                }
            }
            System.out.println(sum);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i=0; i<N; i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    int cnt = 1;
    for (int i=0; i<N-1; i++) {
        if (vec.at(i) != vec.at(i+1)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**6)


N=int(input())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])

Q,K=map(int,input().split())

SD=[0]*N
def DFS(v,p,d):
    SD[v]=d
    for i,co in G[v]:
        if i==p:continue
        DFS(i,v,d+co)
    return

DFS(K-1,-1,0)

for i in range(Q):
    x,y=map(int,input().split())
    ans=SD[x-1]+SD[y-1]
    print(ans)



Measured memory_bytes: 138924
#include <cstdio>
	
int n, a[100100];
int main()
{
	int n; scanf ("%d", &n);
	for (int i = 1, w; i <= n; i++){
		scanf ("%d", &w);
		a[w] = i;
	}
	for (int i = 1; i <= n; i++) printf ("%d ", a[i]); puts("");

	return 0;
}

Measured memory_bytes: 1152
//wawando's template

#include <iostream>
#include <string>
#include <fstream>
#include <functional>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>  //clock_t , clock() , CLOCKS_PER_SEC
#include <cstring>
#include <cctype>
#include <climits> // LLONG_MAX , LLONG_MIN , INT_MAX , INT_MIN

//MACROS
#define pb              push_back
#define mp              make_pair
#define INF             1000000000     //1 billion safer for floyd warshall, avoid overflow

using namespace std;

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

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios::sync_with_stdio(false);
	int N, K;
	string S;
	cin >>N >>K;
	cin >>S;
	vi nodes, bridges;
	int k = 0;
	int ans = 0;
	while(k < N) {
		char cur = S[k];
		int cons = 0;
		while(k < N && S[k] == cur) {
			cons++;
			k++;
		}
		if(cur == '0') {
			if(nodes.size() == 0) {
				nodes.pb(0);
			}
			bridges.pb(cons);
			if(k >= N) {
				nodes.pb(0);
			}
		}
		else {
			nodes.pb(cons);
			ans = max(ans, cons);
		}
	}
	K++;
	int curWindow = 0;
	for(int i = 0; i < nodes.size() && i < K; i++) {
		curWindow += nodes[i];
		if(i > 0) curWindow += bridges[i-1];
	}
	ans = max(ans, curWindow);
	for(int i = K; i < nodes.size(); i++) {
		curWindow -= (nodes[i-K] + bridges[i-K]);
		curWindow += bridges[i-1] + nodes[i];
		ans = max(ans, curWindow);
	}
	cout <<ans <<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define MOD 1000000007
#define rep(i,l,r) for(ll i=l;i<r;i++)

typedef long long ll;

ll min(ll x, ll y) { return (x < y) ? x : y; }


int main() {
    ll n, a, b, x[100001], dp[100001];
    scanf("%lld%lld%lld", &n, &a, &b);
    rep(i, 0, n) scanf("%lld", &x[i]);
    dp[0] = 0;
    rep(i, 0, n) {
        dp[i + 1] = dp[i] + min((x[i + 1] - x[i]) * a, b);
    }
    printf("%lld", dp[n - 1]);

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    int N;
    cin >> N;
    int X;
    vector<int> vs;
    for (int i = 0; i < N; ++i) {
        cin >> X;
        vs.push_back(X);
    }
    
    if (N == 1) {
        cout << 0 << endl;
    } else {
        int m = 1000000000;

        for (int i = 0; i <= 100; ++i) {
            int tmpSum = 0;
            for (int j = 0; j < N; ++j) {
                tmpSum += (vs[j] - i) * (vs[j] - i);
            }
            m = min(tmpSum, m);
        }

        cout << m << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define foi(i,a,n) for(int i=a;i<n;i++)
#define el "\n"
void solve(){
 	int n;cin>>n;
  	vector<int> h(n), c(n,0);rep(i,n) cin>>h[i];
  	c[0]=0,c[1]=abs(h[1]-h[0]);
  	foi(i,2,n) c[i]=min(c[i-2]+abs(h[i-2]-h[i]),c[i-1]+abs(h[i-1]-h[i]));
  	cout<<c[n-1]<<" ";
}

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

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
main()
{
	int m,d;
	cin>>m>>d;
	int cnt=0;
	for(int i=4;i<=m;++i)
	{
		for(int d1=2;d1<=9;++d1)
		{
			for(int d2=2;d2<=9;++d2)
			{
				int x = d1*10+d2;
				if(x<=d && i==d1*d2)
				++cnt;
			}
		}
	}
	cout<<cnt;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    ll N; cin >> N;

    vec.push_back(0);
    for(ll i = 0; i < N; i++){
        ll t = 0; cin >> t;
        vec.push_back(t);
    }
    vec.push_back(0);

    vector<ll > r;

    //累積和
    for(ll i = 0; i < vec.size(); i++){
        if(i == 0) r.push_back(vec[i]);
        else r.push_back(r[i-1] + abs(vec[i-1] - vec[i]));
        
        //cout << r[i] << endl;
    }

    for(ll i = 1; i <= N; i++){
        //この間だけ累積和無効
        ll jump = abs(vec[i-1]-vec[i+1]);
        ll ans = r[i-1] + jump + (r[N+1] - r[i+1]);
        cout << ans << endl;
    }

    //cout << ans << endl;

}

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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;


void solved()
{   
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB")cout << "No";
    else cout <<"Yes";
}


int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif 
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solved();
        cout <<"\n";
    }

#ifdef LOCAL
    system("pause");
#endif 
    return 0;
}

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

int main() {
    int n;
    std::cin >> n;
    int dp[100010][3];
    for (int i = 0; i < 100010; i++) {
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
    }
    int a, b, c;
    std::vector< std::tuple<int, int, int> > act;
    while (std::cin >> a >> b >> c) {
        act.push_back(std::make_tuple(a, b, c));
    }

    for (int i = 0; i < n; i++) {
        a = std::get<0>(act[i]);
        b = std::get<1>(act[i]);
        c = std::get<2>(act[i]);
        dp[i + 1][0] = a + std::max(dp[i][1], dp[i][2]);
        dp[i + 1][1] = b + std::max(dp[i][0], dp[i][2]);
        dp[i + 1][2] = c + std::max(dp[i][0], dp[i][1]);
    }

    std::cout << std::max(dp[n][0], std::max(dp[n][1], dp[n][2])) << std::endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;







void Main() {
    int N;
    ll W;
    cin >> N >> W;
    vector<ll> weight(N);
    vector<int> value(N);
    int total_value = 0;
    for (int i = 0; i < N; ++i) {
        cin >> weight[i] >> value[i];
        total_value += value[i];
    }
    vector<ll> dp(total_value+1, 2e9);
    dp[0] = 0;
    for (int i = 0; i < N; ++i) {
        for (int v = total_value; v >= value[i]; --v) {
            dp[v] = min(dp[v], dp[v - value[i]] + weight[i]);
        }
    }
    for (int v = total_value; v >= 0; --v) {
        if (dp[v] <= W) {
            cout << v << '\n';
            return;
        }
    }
}

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


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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b, n;
    cin >> a >> b >> n;
    int x = min(b - 1, n);
    cout << a*x/b << endl;
    return 0;
}



Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    int n;
    int m;
    int l;
 
   cin >> n >> m >> l;
  
  
  int a = n - m;
  int b = n - l;
  
  if (a < 0){
    
    a = -a;
    
  }
    if (b < 0){
    
    b = -b;
    
  }
  
  if (a > b){
     cout << "B" << endl;
  }else{
    
    cout << "A" << endl;
    
  }
  
 
  
  
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize, 
        mat: [[usize; m+1]; n]
    }

    let mut ans = 10000000;
    for b in 0..2u32.pow(n as u32) {
        let mut cost = 0;
        let mut score = vec![0; m];
        for i in (0..n).filter(|i| (b >> i) & 1 == 1) {
            cost += mat[i][0];
            for j in 0..m {
                score[j] += mat[i][j+1];
            }

        }
        if (score.iter().min() >= Some(&x)) & (ans > cost) { ans = cost; }
    }

    if ans == 10000000 { println!("-1"); } else { println!("{}",ans); }
}

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

int main()
{
    int n;
    cin >> n;
    int a = 0, b = 0;
    for (int i = 1; i < 10; i++)
    {
        if (n % i == 0)
        {
            a = i;
            b = n / i;
        }
    }
    cout << ((a >= 10 || b >= 10 || a * b != n) ? "No" : "Yes") << endl;
}

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

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int X;
    cin >> X;
    if(X >= 30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3676
#include<stdio.h>
#include<string.h>

int main(){
  int i, N, ac=0, wa=0, tle=0, re=0;
  char str1[]="AC", str2[]="WA", str3[]="TLE", str4[]="RE";
  scanf("%d", &N);

  for(i=0; i<N; i++){
    char result[100];
    scanf("%s", &result);
    if(strcmp(str1, result)==0)ac++;
    if(strcmp(str2, result)==0)wa++;
    if(strcmp(str3, result)==0)tle++;
    if(strcmp(str4, result)==0)re++;
  }
  
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
  return 0;
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
typedef pair<int,int> PII;
static const int INF = 1ll<<60;

string s[10];

signed main(){
    int w,h;
    cin>>h>>w;
    for(int y=0;y<h;++y)cin>>s[y];
    for(int y=0;y<h;++y){
        for(int x=0;x<w;++x){
            if(s[y][x]!='#')continue;
            if(x-1>=0&&y-1>=0)if(s[y-1][x]=='#'&&s[y][x-1]=='#'){
                cout<<"Impossible"<<endl;
                return 0;
            }
            if(s[y+1][x]=='#'&&s[y][x+1]=='#'){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
}


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

int main() {
	char l;
	int a=0, b=0, c=0;
	for (int i = 0; i < 3; i++) {
		cin >> l;
		if (l == 'a') {
			a++;
		}
		else if (l == 'b') {
			b++;
		}
		else if (l == 'c') {
			c++;
		}
	}
	if (a == 1 && b == 1 && c == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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


int main(){
	int n,a,b,cnt=0,cnt2=0,x=0;
	bool ok2=false;
	string s;
	cin >> n >> a >> b >> s;
	
	for(int i=0;i<n;i++){
		bool ok=false;
		if(s[i]=='a'){
			cnt++;
			if(ok2) x=-1;
			if(cnt+cnt2+x<=a+b) ok=true;
		}
		else if(s[i]=='b'){
			if(ok2) goto bb;
			cnt2++;
			if(cnt2>b){
				ok2=true;
				goto aa;
			}
			if(cnt+cnt2<=a+b) ok=true;
		}
		aa:;
		bb:;
		if(ok) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

XY = [(a, i) for i, a in enumerate(A)]
XY.sort(reverse=True)

# 解説
ans = [0] * N
min_y = IINF
for i, (x, y) in enumerate(XY):
    min_y = min(min_y, y)
    x2 = XY[i + 1][0] if i + 1 < N else 0
    ans[min_y] += (x - x2) * (i + 1)
print(*ans, sep='\n')


Measured memory_bytes: 24048
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> triple;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define popb()      pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"YES"<<endl
#define prN         cout<<"NO"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define ast(x,a,b)  assert(x>=a and x<=b)				
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define se          second
#define fi          first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ld A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
sc(n);
ld ss=0;
f1(i,n)sc(A[i]),A[i]=(ld)1/A[i],ss+=A[i];
pr((ld)1/ss);
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	ll JUDGE_ONLINE = 1;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	}
	if (!JUDGE_ONLINE) cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";  
		
}

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

int main () {
    int N; cin >> N;
    vector<int> edge_color(N, -1); // 親との辺の色（番号依存）
    vector<vector<int>> tree(N); // 無向グラフ
    vector<int> edge_number(N);  // 親との辺の番号

    for (int i = 1; i < N; i++) {
        int a, b; cin >> a >> b;
        a--; b--;
        tree[a].emplace_back(b);
        tree[b].emplace_back(a);
        edge_number[b] = i;
    }        
    int max_colors = 0;
    for (int i = 0; i < N - 1; i++) {
        max_colors = max(max_colors, (int)tree[i].size());
    }
    cout << max_colors << endl;
    queue<int> q;
    q.push(0);
    while (!q.empty()) {
        int obj = q.front();
        q.pop();
        int coloring = 1;
        for (int son: tree[obj]) {
            if (son > obj) {
                if (coloring == edge_color[edge_number[obj]]) coloring++;
                edge_color[edge_number[son]] = coloring;
                coloring++;
                q.push(son);
            }
        }
    }
    for (int i = 1; i < N; i++) {
        cout << edge_color[i] << endl;
    }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    int sum = 0, minv = 110;
    bool ok = false;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        sum += s[i];
        if (s[i] % 10 != 0) {
            ok = true;
            minv = min(minv, s[i]);
        }
    }

    if (sum % 10 != 0) {
        cout << sum << endl;
    } else if (ok) {
        cout << sum - minv << endl;
    } else {
        cout << 0 << endl;
    }
}

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

int main()
{
    int N, d4, d3, d2, d1;
    cin >> N;

    d4 = N / 1000;
    d3 = (N - d4 * 1000) / 100;
    d2 = (N - (d4 *1000 + d3 * 100)) / 10;
    d1 = (N - (d4 *1000 + d3 * 100 + d2 * 10));

    if (d4 == d3 && d3 == d2){
        cout << "Yes\n";
    }
    else if (d3 == d2 && d2 == d1){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int a, b, i, j;
  cin >>a>>b;
  if(a<b){
    for(int i=0;b>i;i++){
        cout <<a;
    }
  }
  else{
    for(int i=0;a>i;i++){
        cout <<b;
    }
  }
    return 0;
}

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

using namespace std;


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

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

    // 累積 GCD (左と右両方)
    vector<int> left(N+1, 0), right(N+1, 0);
    for (int i = 0; i < N; ++i) left[i+1] = GCD(left[i], a[i]);
    for (int i = N-1; i >= 0; --i) right[i] = GCD(right[i+1], a[i]);
    
  
    // 集計
    int res = 0;
    for (int i = 0; i < N; ++i) {
        // 左側
        int l = left[i];

        // 右側
        int r = right[i+1];

        // 更新
        res = max(res, GCD(l, r));
    }
    cout << res << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    ll ans = 1;
    vector<ll> minus, plus;
    rep(i, n) {
        cin >> a[i];
        if (a[i] < 0) {
            minus.push_back(a[i]);
        }
        if (a[i] > 0) {
            plus.push_back(a[i]);
        }
    }
    sort(minus.begin(), minus.end());
    sort(plus.begin(), plus.end(), greater<ll>());
    ll zero = n - minus.size() - plus.size();

    if (k > minus.size() + plus.size()) {
        cout << 0 << endl;
        return 0;
    }

    if (plus.size() == 0 && k % 2 == 1) {
        if (zero > 0) {
            cout << 0 << endl;
            return 0;
        }
        rep(i, k) {
            ll index = minus.size() - i - 1;
            ans *= -minus[index];
            ans %= mod;
        }
        ans = -ans + mod * 2;
        ans %= mod;
        cout << ans << endl;
        return 0;
    }

    ll minus_index = 0, plus_index = 0;
    ll minus_remain = minus.size(), plus_remain = plus.size();
    if (k % 2 == 1) {
        ans *= plus[plus_index];
        ans %= mod;
        plus_index++;
        plus_remain--;
        k--;
    }

    while (k > 0) {
        if (minus_remain == 1 && plus_remain == 1) {
            ans *= plus[plus_index];
            ans %= mod;
            ans *= minus[minus_index];
            while (ans < 0) {
                ans += mod;
            }
            ans %= mod;
            break;
        }

        if (minus_remain < 2) {
            ans *= plus[plus_index];
            ans %= mod;
            ans *= plus[plus_index + 1];
            ans %= mod;
            plus_index += 2;
            plus_remain -= 2;
            k -= 2;
            continue;
        }
        if (plus_remain < 2) {
            ans *= -minus[minus_index];
            ans %= mod;
            ans *= -minus[minus_index + 1];
            ans %= mod;
            minus_index += 2;
            minus_remain -= 2;
            k -= 2;
            continue;
        }
        if (plus[plus_index] * plus[plus_index + 1] >
            minus[minus_index] * minus[minus_index + 1]) {
            ans *= plus[plus_index];
            ans %= mod;
            ans *= plus[plus_index + 1];
            ans %= mod;
            plus_index += 2;
            plus_remain -= 2;
            k -= 2;
        } else {
            ans *= -minus[minus_index];
            ans %= mod;
            ans *= -minus[minus_index + 1];
            ans %= mod;
            minus_index += 2;
            minus_remain -= 2;
            k -= 2;
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 6712
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int N = sc.nextInt();
        sc.nextLine();
        int sumA = 0;
        for (int i = 0; i < N; i++) {
            sumA += sc.nextInt();
        }
        System.out.println(sumA >= H ? "Yes" : "No");
    }
}

Measured memory_bytes: 48140
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>

using namespace std;

using ii = pair<int, int>;
using i64 = long long int;
using ii64 = pair<long long int, long long int>;

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);

	map<int, int> counts;

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

	vector<int> v;

	for (auto& c : counts)
		v.push_back(c.second);

	sort(v.begin(), v.end());

	int ans = 0;

	for (int i = 0; i < (int)v.size() - k; i++)
	{
		ans += v[i];
	}

	printf("%d", ans);

	return 0;
}

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

int main(){
    int P, Q, R;
    cin >> P;
    cin >> Q;
    cin >> R;

    int res = P + Q;
    if(res > Q + R) res = Q + R;
    if(res > R + P) res = R + P;

    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	static int primeNum(int n){
		int count = 0;
		
		for(int i = 2; i <= n; i ++){
			if(isThisPrime(i)){
				count ++;
			}
		}
		
		return count;
	}
	
	static boolean isThisPrime(int n){
		if(n == 2){
			return true;
		}
		
		if(n % 2 != 0){ //odd num
			for(int i = 3; i <= Math.sqrt(n); i += 2){
				if(n % i == 0){
					return false;
				}
			}
			return true;
		}else{ //even num except 2
			return false;
		}
	}
	
    public static void main(String[] args){
    	Scanner in = new Scanner(System.in);
    	
    	while(in.hasNext()){
    		System.out.println(primeNum(in.nextInt()));
       	}
    	
    	in.close();
	}
}

Measured memory_bytes: 26280
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	var n, tmp int
	fmt.Scan(&n)

	sc.Split(bufio.ScanWords)
	d := []int{}
	for i := 0; i < n; i++ {
		tmp = nextInt()
		d = append(d, tmp)
	}

	sort.Ints(d)

	fmt.Println(d[n/2] - d[n/2-1])
}


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n - 1), b(n - 1);
  rep(i, n - 1) cin >> a[i] >> b[i];
  VI edge[n];
  ll rmEdge[n] = {0};
  rep(i, n - 1) {
    a[i]--, b[i]--;
    edge[a[i]].push_back(b[i]);
    edge[b[i]].push_back(a[i]);
  }
  VLL c(n);
  rep(i, n) cin >> c[i];
  sort(all(c));
  reverse(all(c));

  ll choose = 0;
  ll m = 0;
  ll ans[n];
  memset(ans, -1, sizeof(ans));
  int cidx = 0;
  // start
  queue<int> que;
  que.push(0);
  ans[0] = c[cidx];
  cidx++;
  while(que.empty() == false) {
    int cc = que.front();
    que.pop();
    for(int x : edge[cc]) {

      if(ans[x] == -1) {
        que.push(x);
        ans[x] = c[cidx];
        m += c[cidx];
        cidx++;
      }
    }
  }
  cout << m << endl;
  rep(i, n) { cout << ans[i] << " "; }
  cout << endl;
  return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}

int main() {

  loop {
    long double a; cin >> a;
    if (!cin) break;
    printf("%0.10Lf\n", a * 7.81481481);
  }

  return 0;
}

Measured memory_bytes: 1240
// Aizu Vol0 0044: Prime Number II
// 2017.7.30

#include <stdio.h>
#include <stdlib.h>

char *gets(char *);

#define MAX  50000
#define SQRT 223     // sqrt(MAX)
#define MAX1 50021

int table[MAX1 + 5];

int main()
{
	int i, j, n;
	char buf[100];

	for (i = 2; i <= SQRT; i++) {
		if (!table[i]) {
			for (j = i + i; j <= MAX; j = j + i) table[j] = 1;
		}
	}
	for (i = MAX; i < MAX1; i++) table[i] = 1;
	table[MAX1] = 0;

	while (gets(buf) != NULL) {
		n = atoi(buf);
		for (i = n - 1; table[i]; i--);
		for (j = n + 1; table[j]; j++);
		printf("%d %d\n", i, j);
	}
	return 0;
}

Measured memory_bytes: 716
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int n, t, a;
    int diff_min = numeric_limits<int>::max();
    int posn = 0;

    scanf("%d %d %d", &n, &t, &a);

    rep(i, n)
    {
        int h;
        scanf("%d", &h);
        int diff = abs(t * 1000 - h * 6 - a * 1000);
        if (diff < diff_min) {
            diff_min = diff;
            posn = i + 1;
        }
    }

    printf("%d\n", posn);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int xs,ys;
ll a[2003];
ll b[2003];
bool vis[1009][1009];
int ans[1000004];
// 10 min for problem A : 15
// 15 min for problem B : 16 - 26
// 30 min for problem C : 30
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
    int n,d;
    cin>>n;
    int q=0;
    for(int j=1,i=1;i<=n;i++)
    {
        q=q*10+7;
        q%=n;
        if(q==0)
        {
            cout<<i;
            return 0;
        }
    }
    cout<<-1;
}


Measured memory_bytes: 3616
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    int n; cin>>n;
    vector<int> a(n);
    vector<ll> cnt(n+1);
    vector<ll> cntc2(n+1);
    ll tot = 0;
    for(int &i : a){
        cin>>i;
        cntc2[i]+=cnt[i];
        cnt[i]++;
    }
    for(ll i : cntc2 ){
        tot+=i;
    }
    for(int i = 0 ; i< n; i++){
        cout<<tot - cntc2[a[i]] + max(0LL,(cnt[a[i]] -1)*(cnt[a[i]] - 2))/2<<endl;       
    }
    return 0;
}

Measured memory_bytes: 7116
#include<stdio.h>

int main()
{
	int a,b;
	int d,r;
	double f;
	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

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

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

string s;

int main(){
	cin >> s;
	int L = 0;
	int R = 0;
	int ans = 0;
	while(L < s.size()){
		while(L < s.size() and s[L] != 'R') L += 1;
		if(L >= s.size()) break;
		R = L;
		while(R < s.size() and s[R] == 'R') R += 1;
		ans = max(ans, R - L);
		L = R;
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> H(N,0);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  sort(H.begin(),H.end());
  int ans=H.at(K-1)-H.at(0);
  for(int i=0;i+K-1<N;i++){
    ans = min(ans,H.at(i+K-1)-H.at(i));
  }
  cout << ans << endl;
}

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

using namespace std;

#define INF 999999999

int main(){
	int x, y, z, ans;
	while(1){
		cin >> x >> y >> z;
		if(!x) break;
		ans=0;
		for(int i=1;i<=z;i++){
			for(int j=1;i+j<=z;j++){
				if(i+j+i*x/100+j*x/100==z){
					if(i+j+i*y/100+j*y/100 > ans){
						ans = i+j+i*y/100+j*y/100;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    }
    
    else
    {
        cout << "Odd" << endl;
    }
    
}



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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s,t;

    cin>>s>>t;

    li n1=s.length(),n2=t.length();

    vector<vi> dp(n1+1,vi(n2+1));

    string ans="";

    f(i,1,n1)
    {
        f(j,1,n2)
        {
            if(s[i-1]!=t[j-1])
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
            else
            {   
                dp[i][j]=dp[i-1][j-1]+1;
            }   
        }
    }

    li i=n1,j=n2;

    while(i>0 && j>0)
    {

        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
                i--;
                j--;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
                i--;
            }
            else
            {
                j--;
            }
        }
    }

    reverse(ans.B,ans.E);

    // cout<<dp[n1-1][n2-1];
    cout<<ans;

    return 0;
}

Measured memory_bytes: 70784
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	set<string> cnt; forl(i, 0, n) { string s; cin >> s; cnt.insert(s); }
	println(cnt.size());
}


Measured memory_bytes: 19176
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;

  vector<Int> as(n);
  vector<Int> cs(n,1);
  for(Int i=0;i<n;i++){
    if(i){
      char c;
      cin>>c;
      if(c=='+') cs[i]=+1;
      if(c=='-') cs[i]=-1;
    }
    cin>>as[i];
  }
  const Int INF = 1e15;
  vector<Int> dp0(n+1,-INF);
  vector<Int> dp1(n+1,-INF);
  vector<Int> dp2(n+1,-INF);
  dp0[0]=0;

  for(Int i=0;i<n;i++){
    if(cs[i]>0){
      // stay
      chmax(dp0[i+1],dp0[i]+as[i]);
      chmax(dp1[i+1],dp1[i]-as[i]);
      chmax(dp2[i+1],dp2[i]+as[i]);

      // close
      chmax(dp0[i+1],dp1[i]-as[i]);
    }
    if(cs[i]<0){
      // open + stay
      chmax(dp1[i+1],dp0[i]-as[i]);
      chmax(dp2[i+1],dp1[i]+as[i]);
      chmax(dp2[i+1],dp2[i]+as[i]);

      // open + close
      chmax(dp0[i+1],dp0[i]-as[i]);
      chmax(dp1[i+1],dp1[i]+as[i]);
      chmax(dp2[i+1],dp2[i]+as[i]);
    }
  }
  cout<<max({dp0[n],dp1[n],dp2[n]})<<endl;
  return 0;
}


Measured memory_bytes: 4224
import java.util.Scanner;

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

        int R = sc.nextInt();

        System.out.println(solve(R));

        sc.close();
    }

    static double solve(int R) {
        return 2 * Math.PI * R;
    }
}

Measured memory_bytes: 35772
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 123456;
const LL MOD = (int)1e9 + 7;
LL dp1[123][MAXN];
LL dp2[123][MAXN];
int cnt[MAXN];

LL add(LL a, LL b) {
    LL res = a + b;
    if (res >= MOD) res -= MOD;
    return res;
}

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

int main() {
    int N, K;
    scanf("%d %d", &N, &K);
    LL mx;
    for (LL i = 1; i * i <= N; i++) {
        cnt[i] = (N / i) - (N / (i + 1));
        mx = i;
        //printf("i = %lld cnt = %d\n", i, cnt[i]);
    }
    //if (cnt[mx] == 1) cnt[mx] = 0;
    if (mx * (mx + 1) > N) cnt[mx]--;
    for (int i = 1; i <= mx; i++) {
        dp1[1][i] = cnt[i];
        dp2[1][i] = 1;
    }
    for (int i = 2; i <= K; i++) {
        //update dp1
        LL sum2 = 0;
        for (int j = 1; j <= mx; j++) {
            sum2 = add(sum2, dp2[i - 1][j]);
            dp1[i][j] = mul(sum2, cnt[j]);
            //printf("i = %d j = %d dp = %lld\n", i, j, dp1[i][j]);
        }
        //update dp2
        for (int j = mx; j >= 1; j--) {
            sum2 = add(sum2, dp1[i - 1][j]);
            dp2[i][j] = sum2;
        }
    }
    LL ans = 0;
    for (int i = 1; i <= mx; i++)
        ans = add(ans, add(dp1[K][i], dp2[K][i]));
    printf("%lld\n", ans);

    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 53880