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

void rec(long num, bool seven, bool five, bool three);

int ans = 0;
long n = 0;

int main() {
    cin >> n;

    rec(0, false, false, false);

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

void rec(long num, bool seven, bool five, bool three)
{
    if(num<=n){
        if(seven && five && three) ans++;
    }
    else{
        return;
    }

    rec(num * 10 + 7, true, five, three);
    rec(num * 10 + 5, seven, true, three);
    rec(num * 10 + 3, seven, five, true);
}

Measured memory_bytes: 256
/**
* Author : zzy
* Date : 2020-04-19-19.59.01 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())
#define PI acos(-1)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    double r;
    scanf("%lf", &r);
    double res = 2*PI*r;
    printf("%.4f\n", res);

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

ll count(ll n) {
    ll ans = 0;
    ll x = 1;
    while (x <= n) {
        n -= x;
        x++;
        ans++;
    }
    return ans;
}

void solve() {
    cin >> N;
    map<int, int> m;
    ll a = 2;
    while (N >= a * a) {
        if (N % a == 0) {
            m[a] += 1;
            N /= a;
        } else {
            a++;
        }
    }
    if (N > 1) m[N] += 1;
    if (m.size() == 0) {
        cout << 0 << endl;
    } else {
        ll ans = 0;
        for (pair<int, int> p : m) {
            ans += count(p.second);
        }
        cout << ans << endl;
    }
}

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


Measured memory_bytes: 3600
n, k = map(int, input().split())

p_sum = 0.0
point = 0

for i in range(1, n+1):
    point = i
    p = 1.0

    # print('*** n:{}'.format(i))

    while True:
        if point >= k:
            p_sum += p * (1.0/n)
            # print('p_sum:{}'.format(p_sum))
            break

        p = p * 0.5
        point = point * 2

print(p_sum)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define iter set<int>::iterator
#define int long long
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=1e6+7;
const int inf=1e9+5;
const int mod=998244353;

main ()
{
    ios;
    int n;
    cin>>n;
    string s;
    cin>>s;
    for (int i=0;i<s.size();++i){
        if (s[i]=='R')s[i]='1';
        else if (s[i]=='G')s[i]='2';
        else if (s[i]=='B')s[i]='3';
    }
    int cnt1=0;
    int cnt2=0;
    int cnt3=0;
    int cnt12=0;
    int cnt23=0;
    int cnt13=0;
    int ans=1;
    for (int i=0;i<s.size();++i){
        if (s[i]=='1'){
            if (cnt23>0){
                ans=(ans*cnt23)%mod;
                --cnt23;
            }
            else {
                if (cnt2>0){
                    ans=(ans*cnt2)%mod;
                    cnt12++;
                    cnt2--;
                }
                else if (cnt3>0){
                    ans=(ans*cnt3)%mod;
                    cnt13++;
                    cnt3--;
                }
                else {
                    cnt1++;
                }
            }
        }
        else if (s[i]=='2'){
            if (cnt13>0){
                ans=(ans*cnt13)%mod;
                --cnt13;
            }
            else {
                if (cnt1>0){
                    ans=(ans*cnt1)%mod;
                    ++cnt12;
                    cnt1--;
                }
                else if (cnt3>0){
                    ans=(ans*cnt3)%mod;
                    cnt23++;
                    cnt3--;
                }
                else {
                    ++cnt2;
                }
            }
        }
        else if (s[i]=='3'){
            if (cnt12>0){
                ans=(ans*cnt12)%mod;
                --cnt12;
            }
            else {
                if (cnt1>0){
                    ans=(ans*cnt1)%mod;
                    ++cnt13;
                    --cnt1;
                }
                else if (cnt2>0){
                    ans=(ans*cnt2)%mod;
                    ++cnt23;
                    --cnt2;
                }
                else {
                    ++cnt3;
                }
            }
        }
    }
    for (int i=1;i<=n;++i){
        ans=(ans*i)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 720
N = int(input())
x = [list(map(str,input().split())) for _ in range(N)]
x_new=[]
for i in range(N):
  x_new.append([i+1,x[i][0],int(x[i][1])])
   
x_new.sort(key=lambda x: x[2],reverse=True)
x_new.sort(key=lambda x: x[1])

for j in x_new:
  print(j[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long ans=1;
int main()
{
	long long n,m;
	cin>>n>>m;
	if(abs(n-m)>1)
	{
		cout<<"0";
		return 0;
	}
	if(n==m)ans*=2;
	for(long long i=1;i<=n;i++)ans=(ans*i)%mod;
	for(long long i=1;i<=m;i++)ans=(ans*i)%mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),a,i;
		long s=-n;
		for(i=0;i<n;i++) {
			a=stdIn.nextInt();
			s+=a;
		}
		System.out.print(s);
	}
}

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

signed main(){
  int a, b, c;
  cin >> a >> b >> c;
  int cpyA = a;
  a = b;
  b = cpyA;
  cpyA = a;
  a = c;
  c = cpyA;
  cout << a << " " << b << " " << c << endl;
}

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

int main() {
  int N;
  cin >> N;
  map<string, int> str;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (str.count(s)) str.at(s)++;
    else str[s] = 1;
  }
  long long ans = 0;
  for (pair<string, int> p : str) {
    long long v = p.second;
    if (v == 1) continue;
    else ans += v * (v-1) / 2;
  }
  cout << ans << endl;
}

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

int main(int argc, const char * argv[]) {
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a;
    cin >> a;
    cout << 48 - a << endl;
}


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

#define M 1000000007
#define ll long long

using namespace std;
string s[1001];
ll ans[1001][1001];

ll solve(int i, int j) {
	if(i < 0 || j < 0)
		return 0;
	if(ans[i][j] != -1)
		return ans[i][j];
	ll upper = 0, left = 0;
	if(j >= 1)
		upper = (s[i][j - 1] == '#') ?  0 : solve(i, j - 1);
	if(i >= 1)
		left = (s[i - 1][j] == '#') ?  0 : solve(i - 1, j);
	ans[i][j] = (upper + left) % M;
	return ans[i][j];
}


int main() {
	int h, w;
	cin >> h >> w;
	for(int i = 0 ; i < h ; i++)
		cin >> s[i];
	for(int i = 0 ; i < h ; i++)
		for(int j = 0 ; j < w ; j++)
			ans[i][j] = -1;
	ans[0][0] = 1;
	
	solve(h - 1, w - 1);
	// for(int i = 0 ; i < h ; i++){
	// 	for(int j = 0 ; j < w ; j++)
	// 		cout << ans[i][j] << " ";
	// 	cout << endl;
	// }
	cout << ans[h - 1][w - 1] << endl;
	return 0;

}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;

int ar[ms];


int main()
{
    idfc;

    int h,n;
    cin>>h>>n;
    int a,b;
    int i;
    for(i=1;i<=h;i++)ar[i]=1e9;
    ar[0]=0;
    int p;
    while(n--)
    {
        cin>>a>>b;
        for(i=0;i<=h;i++)
        {
            p=min(h,i+a);
            ar[p]=min(ar[p],ar[i]+b);
        }
    }
    cout<<ar[h];

    return 0;
}

Measured memory_bytes: 3708
#include<iostream>
using namespace std;
int Q(int y,int m,int d) {
  if (m==1||m==2){--y;m+=12;}
   return 365*y+y/4-y/100+y/400+(306*(m+1))/10+d-428;
}
int main(){
  int a,b,c,d,e,f,g;
  while(cin>>a>>b>>c>>d>>e>>f){
    if(a<0)break;
    cout<<Q(d,e,f)-Q(a,b,c)<<endl;
  }
}

Measured memory_bytes: 3076
def main():
    n = int(input())
    s = [list(input()) for _ in range(n)]
    L_cnt = []
    R_cnt = []
    LR_cnt = []
    min_l,min_r = 10**6,10**6
    for i in range(n):
        t = s[i]
        flag = 0
        l = 0
        r = 0
        for j in range(len(t)):
            if not flag and t[j] == ')':
                r += 1
            elif t[j] == '(':
                flag = 1
                l += 1
            else:
                l -= 1
                if l == 0:
                    flag = 0
        if r == 0 and l == 0:
            continue
        if r == 0:
            L_cnt.append(l)
        elif l == 0:
            R_cnt.append(r)
        else:
            LR_cnt.append([l,r])
            min_l = min(min_l,l)
            min_r = min(min_r,r)
    L,R = sum(L_cnt),sum(R_cnt)
    if not LR_cnt:
        if L == R:
            print('Yes')
            return
        else:
            print('No')
            return
    if not (L_cnt and R_cnt):
        print('No')
        return
    box1 = []
    box2 = []
    for i in range(len(LR_cnt)):
        if L >= LR_cnt[i][1] and LR_cnt[i][1] <= LR_cnt[i][0]:
            L += LR_cnt[i][0] - LR_cnt[i][1]
        elif LR_cnt[i][1] <= LR_cnt[i][0]:
            box1.append(LR_cnt[i])
        else:
            box2.append(LR_cnt[i])
    for i in range(len(box1)):
        L -= box1[i][1]
        if L < 0:
            print('No')
            return
        L += box1[i][0]
    for i in range(len(box2)):
        L -= box2[i][1]
        if L < 0:
            print('No')
            return
        L += box2[i][0]
    if L == R:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 103796
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

#include <set>
//#include <unordered_map>
#include <stack>

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define INF 21474836

int N,M;


int main() {

	cin >> N >> M;
	if (N == M)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

int main(void)
{
    int i = 1,x;
    for (int j = 0;j < 5;j++)
    {
        cin >> x;
        if (x == 0) cout << i << endl;
        i++;
    }
    
    return 0;
}


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

const ll inf = 100000000000;

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

  queue<ll> que;
  for (ll i = 1; i <= 9; i++) que.push(i);
  ll cnt = 0;
  ll p;

  while (cnt != K) {
    p = que.front(); que.pop();
    cnt++;
    if (p%10 == 0) {
      que.push(p*10);
      que.push(p*10+1);
    }
    else if (p%10 == 9) {
      que.push(p*10+8);
      que.push(p*10);
    }
    else {
      que.push(p*10+(p%10)-1);
      que.push(p*10+(p%10));
      que.push(p*10+(p%10)+1);
    }
  }
  cout << p << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;

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

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

  for(int i = 0; i < N-1; i++){
    ans += p[i];
  }
  ans += p[N-1]/2;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <class T>
using ordered_set =
       tree <T,null_type,less <T>,rb_tree_tag,tree_order_statistics_node_update> ;
///find_by_order()
///order_of_key()

template <class T,class U>
void maximize(T &x,U y){
    if(x < y)x=y;
}
template <class T,class U>
void minimize(T &x,U y){
    if(x > y)x=y;
}
template <class T>
T Abs(T x){
    return (x < (T)0 ? -x : x);
}
template <class T>
T safe_sqrt(T x){
    return sqrt(max(x,(T)0));
}
template <class T,class U,class V>
T addmod(T x,U k,V MOD){
    return ((x+k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T submod(T x,U k,V MOD){
    return ((x-k)%MOD + MOD)%MOD;
}
template <class T,class U,class V>
T mul(T x,U y,V MOD){
    return ( (x % MOD) * (y % MOD) ) % MOD;
}

#define ll long long
#define pll pair <ll,ll>
#define pii pair <int,int>
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define emp emplace_back
#define MASK(i) ((1LL)<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)((c).size())
#define fn "test"    ///FILE_NAME_HERE

/*------------------------------------------END_OF_TEMPLATE------------------------------------------*/

namespace task{

	const int N = 2e5 + 5;
	int h[N],a[N];
	ll dp[N];
	int n;

	struct  FenwickTree {
		vector <ll> ft;
		FenwickTree(){
			ft.resize(N + 2,0);
		}
		void upd(int node,ll val){
			for(;node <= N;node += node & (-node)){
				maximize(ft[node],val);
			}
		}
		ll rmq(int node){
			ll res = 0;
			for(;node > 0;node -= node & (-node)){
				maximize(res,ft[node]);
			}
			return res;
		}
	}fen;

    void solve(){
    	cin>>n;
    	for(int i = 1;i <= n;++i){
            cin>>h[i];
    	}
    	for(int i = 1;i <= n;++i){
            cin>>a[h[i]];
    	}
    	for(int i = 1;i <= n;++i){
            maximize(dp[h[i]],fen.rmq(h[i]) + 1LL*a[h[i]]);
    		fen.upd(h[i],dp[h[i]]);
    	}
    	ll ans = 0;
    	for(int i = 1;i <= n;++i){
    		maximize(ans,dp[h[i]]);
    	}
    	cout<<ans;
    }
}

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    task::solve();
}


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

int main()
{
  int N;
  cin >> N;
  
  char buf[N];
  bool yellow = false;
  for(int i = 0; i < N; i++)
  {
    char s;
    cin >> s;
    if(s == 'Y')
      yellow = true;
  }
  
  if(yellow == false)
    cout << "Three" << endl;
  else if(yellow == true)
    cout << "Four" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <map>
#include <ctime>
#include <cstdlib>
#include <random>
#include <unistd.h>
using namespace std;

#define int long long

signed main(){
	int a[5];
	for(int i = 0; i < 5; i++)cin >> a[i];
	for(int i = 0; i < 5; i++){
		if(a[i] == 0)cout << i + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
#include<stdio.h>

void insertionSort(double a[],int n);

int main(void){
    int n,i;
    double v[51],sum=0.0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf",&v[i]);
    }
    insertionSort(v,n);
    sum=v[0];
    for(i=1;i<n;i++){
        sum+=v[i];
        sum/=2;
        //printf("%f\n",sum);
    }
    printf("%f\n",sum);
    return 0;
}


void insertionSort(double a[],int n){
    int i,j;
    double v;
    for(i=1;i<n;i++){
        v=a[i];          //v:未ソート部分の先頭
        j=i-1;
        while(j>=0&&a[j]>v){
            a[j+1]=a[j];    //vより大きい要素を後方へ移動
            j--;
        }
        a[j+1]=v;
    }
}


Measured memory_bytes: 128
n = int(input())
AB = [ list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n-1,-1,-1):
    a = AB[i][0] + ans
    b = AB[i][1]
    #print(a,b)
    if a % b == 0:
        tmp = 0
    else:
        tmp = b - ( a % b )
    ans += tmp
print(ans)

Measured memory_bytes: 27380
//Breadth First Search (?????????) Algorithm
#include<iostream>
#include<queue>
#define WH 0
#define GR 1
#define BL 2
#define INF 2000000
void bfs(int);
int n, *color, **M, *d;
std::queue<int> Q;
int main(){
  std::cin>>n;
  color=new int[n], d=new int[n], M=new int*[n];
  for(int i=0, u, k;i<n;i++){
    M[i]=new int[n];
    color[i]=WH, d[i]=INF;
    for(int j=0;j<n;j++) M[i][j]=0;
    std::cin>>u>>k;
    for(int j=0, v;j<k;j++){
      std::cin>>v;
      M[u-1][v-1]=1;
    }
  }
  bfs(0);
  for(int i=0;i<n;i++) std::cout<<i+1<<" "<<(d[i]!=INF?d[i]:-1)<<std::endl;
  delete color;
  delete d;
  for(int i=0;i<n;i++) delete M[i];
  delete M;
  return 0;
}

void bfs(int s){
  color[s]=GR, d[s]=0;
  Q.push(s);
  while(!Q.empty()){
    int u=Q.front();
    Q.pop();
    for(int i=0;i<n;i++){
      if(M[u][i]&&color[i]==WH){
        color[i]=GR, d[i]=d[u]+1;
        Q.push(i);
      }
    }
    color[u]=BL;
  }
}

Measured memory_bytes: 3152
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int x = 0;
  int ans = 0;
  for(int i=0;i<N;++i) {
    if(S[i]=='I') x++;
    else x--;
    ans = max(ans, x);
  }
  cout<<ans<<endl;
}



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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int INF = 12345;
int H,W;
char S[2010][2010];
int x[2010];
int ans;

int main(){
	scanf("%d%d" , &H , &W);
	repp(i,0,H){
		scanf(" %s" , S[i]);
	}
	fill(x,x+W,1);
	ans = max(W,H);
	repp(i,1,H){
		stack<P2> v;
		v.push(MP(1,0));
		repp(j,1,W){
			if(1 ^ (S[i-1][j] == S[i][j]) ^ (S[i-1][j-1] == S[i][j-1])){
				++x[j];
			} else {
				x[j] = 1;
			}
			int p = v.top().first;
			int q = v.top().second;
			int r = 0;
			while(p > x[j]){
				r += q;
				ans = max(ans , p * (r+1));
				v.pop();
				p = v.top().first;
				q = v.top().second;
			}
			if(p < x[j]){
				v.push(MP(x[j],1+r));
			} else {
				v.top().second += 1+r;
			}
		}
		int r = 0;
		while(!v.empty()){
			int p = v.top().first;
			int q = v.top().second;
			r += q;
			ans = max(ans , p * (r+1));
			v.pop();
		}
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var r = ReadSplit();
            var n = r[0].Int();
            var k = r[1].Int();
            var s = Read();
            var ans = 0;
            var group = 1;
            for (int i = 0; i < n; i++)
            {
                if (i + 1 >= n) break;
                if (s[i] == s[i + 1])
                {
                    ans++;
                }
                else
                {
                    group++;
                }
            }
            ans += Math.Min(group * 2, k * 2);
            ans = Math.Min(ans, n - 1);
            WriteRead(ans);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}

Measured memory_bytes: 13280
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;



void solve()
{   
    int n;
    ll d,a;
    cin>>n>>d>>a;
    vector<pll> m(n);
    for(int i=0;i<n;i++){
        cin>>m[i].F>>m[i].S;
    }

    sort(m.begin(),m.end());
    vector<pll> pre;
    ll c;
    if(m[0].S%a==0) c = m[0].S/a;
    else c= m[0].S/a + 1;
    pre.push_back({c*a , m[0].F + 2*d});
    ll ans = c;
    int k = 0;
    for(int i=1;i<n;i++){
        ll cur = m[i].F;
        while(k<pre.size() &&pre[k].S < m[i].F)
            k++;
        if(k == 0)
            m[i].S -= pre[pre.size()-1].F;
        else if(k<pre.size()){
            m[i].S -= (pre[pre.size()-1].F - pre[k-1].F);
        }    
        if(m[i].S <= 0) continue;    
        if(m[i].S%a==0) c = m[i].S/a;
        else c= m[i].S/a + 1;    
        ans += c;
        pre.push_back({c*a + pre[pre.size()-1].F,m[i].F+2*d});
    }
    cout<<ans;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

int main()
{
	int n, a;
	cin >> n;
	set<int> paper;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		if(paper.count(a))
		{
			paper.erase(a);
		}
		else
		{
			paper.insert(a);
		}
	}
	
	cout << paper.size() << endl;
	return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;


public class Main {

	private static int[][] cache;
	private static char[] x;
	private static char[] y;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int set = sc.nextInt();

		for (int k = 0; k < set; k++) {
			x = sc.next().toCharArray();
			y = sc.next().toCharArray();
			int m = x.length;
			int n = y.length;
			
			// ボトムアップ型
			cache = new int[m + 1][n + 1];
			// 初期化不要(0)

			for (int i = 1; i <= m; i++) {
				for (int j = 1; j <= n; j++) {
					if (x[i - 1] == y[j - 1]) {
						cache[i][j] = cache[i - 1][j - 1] + 1;
					} else {
						cache[i][j] = Math.max(cache[i - 1][j], cache[i][j - 1]);
					}
				}
			}
			
			System.out.println(cache[m][n]);
		}
		
         sc.close();
	}
}

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

int main(){
	int N,W;
	cin>>N>>W;
	int v[N],w[N];
	for(int i=0;i<N;i++){
		cin>>v[i]>>w[i];
	}
	
	int DP[N+1][W+1];
	for(int i=0;i<N+1;i++){
		DP[i][0]=0;
	}
	for(int i=0;i<W+1;i++){
		DP[0][i]=0;
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=W;j++){
			if(j<w[i-1]){
				DP[i][j]=DP[i-1][j];
			}else{
				if(DP[i-1][j-w[i-1]]+v[i-1]>DP[i-1][j]){
					DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
				}
				else{
					DP[i][j]=DP[i-1][j];
				}
			}
		}
	}
	
	cout<<DP[N][W]<<endl;
	return 0;
		
}

Measured memory_bytes: 7000
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> W(N);
        rep(i, 0, N) cin >> W[i];
        int ans = INF;

        for (int t = 0; t + 1 < N; ++t) {
            int a = 0;
            int b = 0;
            for (int i = 0; i < N; ++i) {
                if (i <= t) a += W[i];
                else b += W[i];
            }
            chmin(ans, abs(a - b));
        }

        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i,num;
	int numA,numB;
	int Ascore,Bscore;
	while(scanf("%d",&num)!=EOF)
	{
		if(num==0)
		{
			break;
		}
	i=0;
	Ascore=0;
	Bscore=0;
	while(i!=num)
	{

		i++;
		scanf("%d %d",&numA,&numB);
		if(numA>numB)
		{
			Ascore=Ascore+numA+numB;
		}
		else if(numA<numB)
		{
			Bscore=Bscore+numB+numA;
		}
		else if(numA==numB)
		{
			Ascore=Ascore+numA;
			Bscore=Bscore+numB;
		}
	}
	printf("%d %d\n",Ascore,Bscore);
	}
	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>

using namespace std;


int main() {

	int a, b, c,x;
	cin >> a >> b >> c>>x;
	int count = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {

				int num = 500 * i + 100 * j + 50 * k;

				if (num == x) {
					count++;
				}

			}

		}
	}

	cout << count << endl;
	return 0;
}




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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e5+3;
const int INF = 1e9;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    //int ntest; cin >> ntest; while(ntest--)
    {
        string s; cin >> s;
        cout << ((s == "ABC") ? "ARC" : "ABC") << '\n';
    }

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <cstring>

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))

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

using namespace std;

void check(string s){
    int a = (s[0] - '0')*10 + (s[1] - '0');
    int b = (s[2] - '0')*10 + (s[3] - '0');

    bool flag1 = false;
    bool flag2 = false;

    if(a >= 0 && a <= 99){
        if(b >= 1 && b <= 12){
            flag1 = true;
        }
    }
    swap(a, b);
    if(a >= 0 && a <= 99){
        if(b >= 1 && b <= 12){
            flag2 = true;
        }
    }

    if(flag1 && flag2){
        cout << "AMBIGUOUS" << endl;
    }
    else if(flag1){
        cout << "YYMM" << endl;
    }
    else if(flag2){
        cout << "MMYY" << endl;
    }
    else{
        cout << "NA" << endl;
    }
}

int main(){
    string s;

    cin >> s;

    check(s);

    return 0;
}


Measured memory_bytes: 256
x,y,z,K = map(int, input().split())
abc = [sorted(list(map(int, input().split())), reverse=True) for i in range(3)]

ans = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1) <= K:
                ans.append(abc[0][i]+abc[1][j]+abc[2][k])
            else:
                break
for i in sorted(ans)[::-1][:K]:
    print(i)

Measured memory_bytes: 9996
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

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

using namespace std;

typedef pair<int, int> P;

int calc(int x, vector<int>& d) {
    int tt = lower_bound(d.begin(), d.end(), x) - d.begin();
    int res = abs(x - d[tt]);
    if (tt > 0) {
        res = min(res, abs(x - d[tt - 1]));
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int A, B, Q;
    cin >> A >> B >> Q;
    vector<int> s(A);
    vector<int> t(B);
    vector<int> m(A + B);
    map<int, int> kind;
    REP(i, A) {
        cin >> s[i];
        m[i] = s[i];
        kind[s[i]] = 0;
    }
    REP(i, B) {
        cin >> t[i];
        m[i + A] = t[i];
        kind[t[i]] = 1;
    }
    sort(m.begin(), m.end());

    while (Q--) {
        int x;
        cin >> x;
        int res = 0;
        int tt = lower_bound(m.begin(), m.end(), x) - m.begin();
        res += abs(m[tt] - x);
        if (kind[m[tt]] == 0) {
            res += calc(m[tt], t);
        }
        else {
            res += calc(m[tt], s);
        }

        if (tt > 0) {
            int tmp = abs(x - m[tt - 1]);
            if (kind[m[tt - 1]] == 0) {
                tmp += calc(m[tt - 1], t);
            }
            else {
                tmp += calc(m[tt - 1], s);
            }
            res = min(tmp, res);
        }
        cout << res << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll ai, ao, at, aj, al, as, az;
  cin >> ai >> ao >> at >> aj >> al >> as >> az;
  ll result = 0;
  result += ao;
  ll ijl1 = ai/2*2 + aj/2*2 + al/2*2;
  ll ijl2 = (ai-1)/2*2 + (aj-1)/2*2 + (al-1)/2*2 + 3;
  result += (ai==0||aj==0||al==0) ? ijl1 : max(ijl1, ijl2);
  cout << result << endl;
  return 0;
}

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


bool is_bipartite(vector<vector<ll>> &link_list,vector<int>&color,ll node, int current_color){
    color[node] = current_color;
    for (const auto &next_node :link_list[node]){
        if (color[next_node] == current_color) return false;
        if (color[next_node] == 0 && !is_bipartite(link_list,color,next_node,-current_color)) return false;//dfsでfalseだったらfalseを返す
    }
    return true;
}


void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B){
    vector<vector<ll>> link_list(N+1);
    for (ll i = 0;i<M;i++){
        link_list[A[i]].push_back(B[i]);
        link_list[B[i]].push_back(A[i]);
    }
    vector<int> color(N+1,0);
    bool flag = is_bipartite(link_list,color,1,1);
    if (!flag){
        printf("%lld\n",N*(N-1)/2-M);
    }else{
        ll W = 0;
        for (const auto &c :color){
            if (c==1) W++;
        }
        ll B = N-W;
        printf("%lld\n",B*W-M);
    }
    

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(A), std::move(B));
    return 0;
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ss second
#define ff first

#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

const int inf = 2e18;
const int ninf = -2e18;

vector<int> g[200010];
vector<int> vis(200010);
vector<int> c(200010, -1);
vector<int> col(200010);

void dfs(int u, int x) {
	vis[u] = 1;
	c[u] = x;
	col[x]++;

	for (auto v: g[u]) {
		if (vis[v]) continue;

		dfs(v, x);
	}
}
signed main() {

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif

	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
	int x = 1;
	for (int i = 0; i < n; i++) {
		if (vis[i]) continue;
		dfs(i, x);
		x++;
	}

	int mx = 0;
	for (int i = 1; i < n + 2; i++) {
		// cout << col[i] << endl;
		mx = max(mx, col[i]);
	}

	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 25096
from collections import Counter
N, *A = map(int, open(0).read().split())
l = [v for _, v in sorted(Counter(A).items())]
if all(v == 2 for v in l[N % 2:]) and (N % 2 == 0 or l[0] == 1):
    print(2 ** (N // 2) % (10 ** 9 + 7))
else:
    print(0)

Measured memory_bytes: 15144
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
# https://atcoder.jp/contests/abc097/tasks/abc097_b
X = read_a_int()

# 素因数分解して？いや
# べき乗の数を予め全列挙
candi = []
for i in range(1, 1000 + 1):
    for j in range(2, 11):
        tmp = pow(i, j)
        if tmp > 1000:
            break
        candi.append(tmp)
candi.sort()
print(candi[bisect_right(candi, X) - 1])


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cout << fixed << setprecision(15);
    ll S;
    cin >> S;

    ll ans = 0;

    // 前処理
    COMinit();

    ll count = 0;
    while(S > 0){
        S -= 3;
        count++;

        if(S < 0) break;

        ans += COM(S+count-1, count-1);
        ans = ans % MOD;
        // cout << ans << endl;
        
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	set<int> se;
	se.insert(a);
	se.insert(b);
	se.insert(c);

	if(se.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();;
		if(a > b) {
			System.out.println("a > b");
		} else if(a == b) {
			System.out.println("a == b");
		}else {
			System.out.println("a < b");
		}
	}
}

Measured memory_bytes: 26016
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  map<int,int> mp;
  rep(i,N) {
    int d;
    cin >> d;
    mp[d]++;
  }
  int M;
  cin >> M;
  vi t(M);
  rep(i,M) {
    cin >> t[i];
  }
  rep(i,M) {
    if(mp[t[i]] > 0) {
      mp[t[i]]--;
    } else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		int n, current;
		
		n = Integer.valueOf(reader.readLine());
		for(int i = 0; i < n; i++){
			char ch[] = reader.readLine().toCharArray();
			char res[] = new char[52];
			res[current = 26] = ch[0];
			
			for(int j = 3; j < ch.length; j += 3){
				if((ch[j - 2] + "" + ch[j - 1]).equals("<-")){
					--current;
					res[current] = ch[j];
				}else{
					++current;
					res[current] = ch[j];
				}
			}
			for(char var : res){
				if((int)var != 0)
				System.out.print(var);
			}
			System.out.println();
		}
		reader.close();
	}
}

Measured memory_bytes: 26936
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    H = II()
    from math import log2,floor
    print( 2**(floor(log2(H))+1)-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include <stdio.h>
#include<string>
using namespace std;
int main() 
{
	int a = 0;
	int b = 0;
	bool c = false;
	cin >> a ;
	if (a % 4 == 0 || a % 7 == 0) {
		c = true;
	}
	for (int i = 0; i * 4 < a; i++) {
		b=a -i*4;
		if (b % 7 == 0) {
			c = true;
		}
	}
	if (c == true) {
		cout << "Yes"<<endl;
	}
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	int N;
  	cin >> N;
  	int ans[N+1];
  	for(int i=1;i<=N;i++) ans[i] = 0;


  	for(int i=0;i<N-1;i++){
  		int tmp;
  		cin >> tmp;
  		ans[tmp]++;
  	}

  	for(int i=1;i<=N;i++){
  		cout << ans[i] <<endl;
  	}

    
  	return 0;
}


Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>
#include <cctype>
#include <map>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    
    return 0;
}

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

int main() {
    int N, Q;
    while(cin >> N >> Q, N) {
        vector<int> v(101);
        for(int i=0; i<N; ++i) {
            int M;
            cin >> M;
            for(int j=0; j<M; ++j) {
                int d;
                cin >> d;
                v[d] += 1;
            }
        }
        int ret = 0, cnt=0;
        for(int i=v.size()-1; i>=1; --i) {
            if(cnt <= v[i] && v[i] >= Q) {
                ret = i;
                cnt = v[i];
            }
        }
        cout << ret << endl;
    }
}


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


void solve(long long N, long long K, std::vector<long long> A){
    vector<ll> sum(N+1,0);
    for(int i=0;i<N;i++){
        sum[i+1] = sum[i] + A[i];
    }
    map<ll,vector<ll>> mp;
    for(int i=0;i<N+1;i++){
        ll val = sum[i] -i;
        val %= K;
        mp[val].push_back(i);
        // cerr <<"val=" <<val <<"i="<<i << endl;
    }
    ll ans =0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
        auto vec = itr->second;
        if(vec.size()==1){
            continue;
        }
        ll r =0;
        for(int i=0;i<vec.size();i++){
            while(vec[r]<vec[i] +K){
                if(r== vec.size()-1){
                    break;
                }
                r++;
            }
            if(vec[r] >= vec[i]+K){
                --ans;
            }
            ans += (r-i);
        }
    }
    cout << ans << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    ll x = N;
    if ( x >= K ) {
        x %= K;
    }
    ll ans = min(x, K-x);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define ll long long
#define sz size()
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int m5=100042;
int n;
int a,b;
ll cnt[2020];
int main(void)
{
	int i,j;
	cin>>n>>a>>b;
	for(j=2;j<=n;j++)
	{
		for(i=1;i<j;i++)
		{
			int com=abs(i-j);
			com=min(com,abs(i-b)+1+abs(j-a));
			com=min(com,abs(i-a)+1+abs(j-b));
			cnt[com]++;
		}
	}
	for(i=1;i<n;i++)
	{
		cout<<cnt[i]<<endl;
	}
    return 0;
}



Measured memory_bytes: 256