akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
// #define int ll
// #define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
vector<int> g[N],g2[N];
int u2[N],c=0,u[N];
void dfs2(int v){
    u2[v]=c;
    for(int to:g2[v])if(!u2[to])dfs2(to);
}
vector<int> comp;
void dfs(int v){
    u[v]=1;
    comp.pb(v);
    for(int to:g[v])if(!u[to])dfs(to);
}
int ans[N],cnt[N];
int32_t main(){
    int n,m1,m2;
    cin>>n>>m1>>m2;
    forn(i,m1){
        int a,b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    forn(i,m2){
        int a,b;
        cin>>a>>b;
        g2[a].pb(b);
        g2[b].pb(a);
    }
    for(int i=1;i<=n;++i){
        if(!u2[i]){
            c++;
            dfs2(i);
        }
    }
    for(int i=1;i<=n;++i){
        if(!u[i]){
            comp.clear();
            dfs(i);
            for(int v:comp)cnt[u2[v]]++;
            for(int v:comp)ans[v]=cnt[u2[v]];
            for(int v:comp)cnt[u2[v]]--;
        }
    }
    for(int i=1;i<=n;++i)cout<<ans[i]<<' ';cout<<'\n';
    return 0;
}

Measured memory_bytes: 22220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n;
    string s;

    cin >> n;
    cin >> s;

    ll num = 1000000000;
    ll tmp = 0;

    ll cx[n];
    if(s[0] == '#') cx[0] = 1;
    else cx[0] = 0;
    rep(i, 1, n){
        if(s[i] == '#') cx[i] = cx[i-1] + 1;
        else cx[i] = cx[i-1];
    }

    ll cy[n];
    if(s[n-1] == '#') cy[n-1] = 0;
    else cy[n-1] = 1;
    rrep(i, n-2, 0){
        if(s[i] == '.') cy[i] = cy[i+1] + 1;
        else cy[i] = cy[i+1];
    }

    ll ans = 1000000000;
    rep(i, 0, n){
        ans = min(ans, cx[i] + cy[i] - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3716
#include <stdio.h>
#include <math.h>

int main(void)
{
  int h,i;
  int e[3]={0};

  for(i=0;i<10;i++)
  {
   
    scanf("%d",&h);

    if(h>=e[2])
    {
      if(h>=e[1])
      {
        if(h>=e[0])
        {
          e[2]=e[1];
          e[1]=e[0];
          e[0]=h;
          continue;
        }
        e[2]=e[1];
        e[1]=h;
        continue;
      }
      e[2]=h;
      continue;
    }
  }


  for(i=0; i<3; i++)
  {
    printf("%d\n",e[i]);
  }

  return 0;

}



Measured memory_bytes: 2100
#Walayn3al mok a pc dlmard
#python d zab
mod=1000000007
def p(a,b):
    if b==0:
        return 1
    z=p(a,b//2)
    z%=mod
    if b%2==1:
        return (a*z*z)%mod
    else:
        return (z*z)%mod
n,k=map(int,input().split())
dp=[0]*(k+3)


for i in range(k,0,-1):
    dp[i]=p(int(k/i),n)
    dp[i]%=mod
    for j in range(2,int(k/i)+1):
        dp[i]-=dp[i*j]
ans=0
for i in range(1,k+1):
    ans+=i*dp[i]
    ans%=mod;
print(ans)

Measured memory_bytes: 11292
N = int(input())
ans = [0 for _ in range(N + 100)]
for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            cnt = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + i * k
            if cnt <= N:
                ans[cnt - 1] += 1
for i in range(N):
    print(ans[i])

Measured memory_bytes: 69624
#include <iostream>
#include <algorithm>
#include <vector>

using pii = std::pair<int64_t, int64_t>;
using vpii = std::vector<pii>;

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);


    vpii v(4);
    int a;
    std::cin >> a; v[0] = {a * 8, 8};
    std::cin >> a; v[1] = {a * 4, 4};
    std::cin >> a; v[2] = {a * 2, 2};
    std::cin >> a; v[3] = {a * 1, 1};

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

    int64_t n; std::cin >> n;
    n *= 4;

    int64_t r = 0;
    for (auto p : v) {
        if (!n) break;
        int price = p.first / p.second;
        int size = 8 / p.second;
        r = r + (n / size) * price;
        n = n % size;
    }
    std::cout << r << std::endl;
}


Measured memory_bytes: 256
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

const bool ready = [](){
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define all(v) (v).begin(), (v).end()
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

void solve() {
    cins(s);
    cins(t);
    int ans=0;
    for(int i=0; i<s.size(); i++) {
        if(s[i]!=t[i])
            ans++;
    }
    cout<<ans<<endl;
}

signed main() {
    solve();
}

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS


Measured memory_bytes: 3884
n=int(input())
a=list(map(int,input().split()))
inf=float("inf")
M=max(a)
m=min(a)
data=[]
if abs(m)>abs(M):
    b=a.index(m)
    for i in range(n):
        data.append(str(b+1)+" "+str(i+1))
    for i in range(n-1):
        data.append(str(n-i)+" "+str(n-i-1))
else:
    b=a.index(M)
    for i in range(n):
        data.append(str(b+1)+" "+str(i+1))
    for i in range(1,n):
        data.append(str(i)+" "+str(i+1))
print(len(data))
for u in data:
    print(u)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define M 1e9 + 7
#define MAXN 1000005
#define C 998244353
#define pi 3.14159265359
#define loop(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define rloop(i,a,b) for(ll i = ll(a); i >= ll(b); --i)
#define sloop(i,a) for (std::set<ll>::iterator i = a.begin(); i != a.end(); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
typedef long long int ll;
typedef unsigned long long int ull;

int solve(){
    ll n,x,wa=0,ac=0,tle=0,re=0;
    cin >> n;
    loop(i,0,n){
        string s;
        cin >> s;
        if(s=="WA")
            wa++;
        else if(s=="AC")
            ac++;
        else if(s=="TLE")
            tle++;
        else
            re++;
    }
    string sac = "AC x ",swa = "WA x ",stle = "TLE x ",sre = "RE x ";
    cout << sac << ac << "\n";
    cout << swa << wa << "\n";
    cout << stle << tle << "\n";
    cout << sre << re << "\n";

    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    loop(f,0,t){    
        solve();
    }   
}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define PER(j,n,a) for (int j=n-1;j>=a;j--)
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define show(x) cout<<(x)<<endl
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/

int main() {
	FAST;
	int n,m;
	cin>>n;
	V<int> sp(n+1,-1);
	for(int i=2;i<=n;i+=2) sp[i]=2;
	for(int i=3; i<=n; i+=2) {
		if(sp[i] == -1) {
			for(int j=i; j<=n; j+=i)
				sp[j]=i;
		}
	}
	ll temp, ans = 0;
	REP(c,1,n) {
		m = n-c;
		map<int,int> cnt;
		while(m!=1) {
			if(cnt.count(sp[m])==0)
				cnt[sp[m]]=0;
			cnt[sp[m]]++;
			m /= sp[m];
		}
		temp = 1LL;
		for(auto i:cnt)
			temp *= i.second + 1;
		ans += temp;
	}
	show(ans);
	return 0;
}



Measured memory_bytes: 7144
use std::io::{Read, stdin};
use std::str::FromStr;
use std::cmp::min;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut h: Vec<i64> = vec![0; n];
    for i in 0..n{
        h[i] = read();
    }
    h.sort();
    let mut ans = 1_000_000_000;
    for i in 0..n-k+1{
        ans = min(ans, h[i+k -1] - h[i]);
    }
    println!("{}", ans);
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    string a;
    cin >>a;
    vector<int>b;
    for(int i;i<a.size();i++)b.push_back(a[i]);
    sort(b.begin(),b.end());
    if(b[0]=='a'&&b[1]=='b'&&b[2]=='c'){
        cout<<"Yes";
    }
    else{cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
VV = list(map(int, input().split()))
v_even = VV[::2]
v_odd = VV[1::2]

e = collections.Counter(v_even)
o = collections.Counter(v_odd)
e_common = e.most_common()
o_common = o.most_common()


if (e_common[0] != o_common[0]):
    tmp = e_common[0][1] + o_common[0][1]
    answer = N - tmp

elif (len(e_common) == 1 or len(o_common) == 1): # case one type
    if (len(e_common) == 1 and len(o_common) == 1):
        answer = N // 2
    elif (len(e_common) == 1):
        answer = N // 2 - o_common[1][1]
    elif (len(o_common) == 1):
        answer = N // 2 - e_common[1][1]

else:
    tmp1 = e_common[0][1] + o_common[1][1]
    tmp2 = e_common[1][1] + o_common[0][1]
    tmp = max(tmp1, tmp2)
    answer = N - tmp

print(answer)

Measured memory_bytes: 21952
N, M = map(int, input().split())
P = []
S = []
flag = [False for i in range(0, N)]
for i in range(0, M):
    x, y = map(str, input().split())
    P.append(int(x)-1)
    S.append(y)
ans = [0, 0]
wa = [0 for i in range(0, N)]
for i in range(0, M):
    if not flag[P[i]]:
        if S[i] == 'AC':
            flag[P[i]] = True
            ans[0] += 1
            ans[1] += wa[P[i]]
        else:
            wa[P[i]] += 1
print(*ans)


Measured memory_bytes: 14952
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  if( u == NIL || k == u->key ) return u;
  if( k < u->key ) return treeSearch(u->left, k);
  else return treeSearch(u->right, k);
}

void insert(int k){
  Node y = NIL;  //xの親
  Node x = root; //rootの根
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL )
    {
      y = x;  //親を設定
      if( z->key < x->key ) x = x->left;  //左の子へ移動
      else x = x->right;  //右の子へ移動
    }
  z->parent = y;

  if( y == NIL ) root = z;  //treeが空のとき
  else if( z->key < y->key ) y->left = z;  //zをyの左の子にする
  else y->right = z;   //zをyの右の子にする
}

void inorder(Node u){
  if( u != NIL )
    {
      inorder( u->left );
      printf(" %d",u->key);
      inorder( u->right );
    }
}
void preorder(Node u){
  if( u != NIL)
    {
      printf(" %d", u->key);
      preorder( u->left );
      preorder( u->right );
    }
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d", &n);

  for( i = 0; i < n; i++ )
    {
      scanf("%s", com);
      if ( com[0] == 'i' )
        {
          scanf("%d", &x);
          insert(x);
        }
      else if( com[0] == 'p')
        {
          inorder(root);
          printf("\n");
          preorder(root);
          printf("\n");
        }
      else if( com[0] == 'f')
        {
          scanf("%d", &x);
          Node t = treeSearch(root, x);
          if ( t != NIL ) printf("yes\n");
          else printf("no\n");
        }
    }

  return 0;
}


Measured memory_bytes: 20468
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	S := scanner.Text()
	answer := ""
	for i := 0; i < len(S); i++ {
		answer += "x"
	}
	fmt.Println(answer)
}


Measured memory_bytes: 1784
#include<stdio.h>

int main(void){
	int n,i,j,count,tmp;
	char s[1000000]={0},t[1000000]={0};

	while(scanf("%d",&n),n){
		count=0;
		scanf("%s",s);
		while(n--){
			count=0;
			for(i=0;s[i]!='\0';i++){
				for(j=1;s[i]==s[i+j-1];j++);
				tmp=j-1;
				j--;
				if(j>99){
					t[count++]=j/100+'0';
					j%=100;
					t[count++]=j/10+'0';
					j%=10;
					t[count++]=j+'0';
					t[count++]=s[i];
				}else if(j>9){
					t[count++]=j/10+'0';
					j%=10;
					t[count++]=j+'0';
					t[count++]=s[i];
				}else{
					t[count++]=j+'0';
					t[count++]=s[i];
				}
				i=i+tmp-1;
			}
			for(i=0;i<1000000;i++){
				s[i]=t[i];
				t[i]=0;
			}
		}
	printf("%s\n",s);
	}
	return 0;
}

Measured memory_bytes: 2544
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, ans;
ll a[100100], sum[100100];
vector<int> adj[100100];

void dfs (int i, int p) {
        ans++;
        for (int j : adj[i]) if (j != p) dfs(j, i);
}

int main () {
        scanf("%d", &N);
        fo(i, 0, N) scanf("%lld", &a[i]);
        sort(a, a+N);
        fo(i, 0, N) sum[i] = a[i] + (i ? sum[i-1] : 0);
        int j = 0;
        fo(i, 0, N) {
                while (j < N && a[j] <= sum[i]*2) j++;
                if (i != j-1) {
                        adj[j-1].PB(i);
                }
        }
        dfs(N-1, -1);
        printf("%d\n", ans);
        return 0;
}


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

int main()
{
    long long n,ruikei=0;
    cin >> n;
    long long kiroku[n];
    char moji;
    for(long long i=0;i<n;i++){
        cin >> moji;
        if (moji=='#'){//黒の数数えてる
            ruikei++;  
        }
        kiroku[i] = ruikei;
        //cout << "r:" <<ruikei << "\n";
        //cout << "k:" <<kiroku[i] << "\n";
    }
    
    //nを境に変化させた場合
    //-(n)ここまで白,(n+1)-ここが黒
    //としたいので
    
    long long min=n-kiroku[n-1];//-1を境とする値を予め代入
    //cout << "m:" <<min << "\n";
    for(long long i=0;i<n;i++){
        if (kiroku[i]+(n-i-1-(kiroku[n-1]-kiroku[i]))<min) {min=kiroku[i]+(n-i-1-(kiroku[n-1]-kiroku[i]));/*cout << "r:" <<ruikei << "\n";*/}
    }
    cout << min;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    var N = long.Parse(aho[0]);
    var A = long.Parse(aho[1]);
    var B = long.Parse(aho[2]);
    if(N < A){
      Console.WriteLine(N);
      return;
    }
    long goukei = A+B;
    long amari = N%goukei;
    long setto = (N-amari)/goukei*A;
    if(amari >= A){
      Console.WriteLine(setto+A);
    }
    else{
      Console.WriteLine(setto+amari);
    }
  }
}
 

Measured memory_bytes: 13140
N=int(input())
A=list(map(int, input().split()))
R=[0]*N

tmp1=0
fugou=1
for i in range(N):
    tmp1+=fugou * A[i] * 2
    fugou=-1 if fugou==1 else 1

R[0]=tmp1 // 2
R[N-1]=A[N-1]*2 - R[0]

for i in range(N-2,0,-1):
    R[i]=A[i]*2-R[i+1]

print(*R)


Measured memory_bytes: 14092
if __name__=='__main__':
    N = int(input())
    WORDs = [input() for i in range(N)]
    for i in range(N-1):
        if not WORDs[i][-1] == WORDs[i+1][0]:
            print("No")
            break;
    else:
        if len(WORDs) == len(set(WORDs)):
            print("Yes")
        else:
            print("No")

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a == b){
		cout << "a == b" << endl;
	}
	else if(a > b){
		cout << "a > b" << endl;
	}
	else{
		cout << "a < b" << endl;
	}
	return 0;
}


Measured memory_bytes: 3088
def partition(A):
    l = len(A) - 1
    x = A[l]
    i = -1
    for j in range(l):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[l] = A[l], A[i+1]
    return i + 1

n = int(input())
A = [int(x) for x in input().split()]
standard = partition(A)
for i in range(len(A)):
    if i == standard:
        print("[{}]".format(A[i]), end=' ')
    elif i != standard and i != len(A)-1:
        print(A[i], end=' ')
    else:
        print(A[i])

Measured memory_bytes: 18240
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)\

int main()
{
  int k;
  string s1,s2;
  cin>>k>>s1;
  if(s1.size()<=k)
  {
      cout<<s1<<endl;
      return 0;
  }
  else
  {
      s2=s1.substr(0,k);
      s2=s2+"...";
      cout<<s2<<endl;
      return 0;
  }
}








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

public class Main
{

  public static void main(String[] args) throws NumberFormatException, IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      String[] INPUT_STR = input.readLine().split(" ");
      int numCount = Integer.valueOf(INPUT_STR[0]);
      int sumNumber = Integer.valueOf(INPUT_STR[1]);

      if (numCount == 0 && sumNumber == 0)
      {
        break;
      }

      int ans = solver(numCount, sumNumber);
      System.out.println(ans);
    }

  }

  private static int solver(int numCount, int sumNumber)
  {
    return solver(numCount, sumNumber, 0, 0);
  }

  private static int solver(int numCount, int sumNumber, int currentSum, int startIndex)
  {
    int ret = 0;
    if (numCount - 1 == 0)
    {
      for (int i = startIndex; i < 10; i++)
      {
        if (currentSum + i == sumNumber)
        {
          ret++;
        }
      }
    }
    for (int i = startIndex; i < 10; i++)
    {
      ret += solver(numCount - 1, sumNumber, currentSum + i, i + 1);
    }
    return ret;
  }
}

Measured memory_bytes: 24432
import Foundation
let rl = Int(readLine()!)!
var ACcount = 0
var WAcount = 0
var TLEcount = 0
var REcount = 0
for i in 0 ..< rl {
    let rl = readLine()!
    switch rl {
    case "AC":
        ACcount += 1
    case "WA":
        WAcount += 1
    case "TLE":
        TLEcount += 1
    default:
        REcount += 1
    }
}

print("AC x \(ACcount)")
print("WA x \(WAcount)")
print("TLE x \(TLEcount)")
print("RE x \(REcount)")

Measured memory_bytes: 13252
def solve():
    s = input()
    v = 0
    h = 0
    if 'N' in s:
        v -= 1
    if 'S' in s:
        v += 1
    if 'W' in s:
        h -= 1
    if 'E' in s:
        h += 1
    print('Yes' if v == 0 and h == 0 else 'No')


def main():
    solve()


if __name__ == '__main__':
    main()


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

int comp(const void *p,const void *q){
	return *(int *)p-*(int *)q;
}
int mabs(int a,int b){
	if(a>=b)return a-b;
	else return b-a;
}
int id[100005],x[100005],y[100005];
int x2[100005],y2[100005];
int x3[5],y3[5];
int main(){
	int i,j,k;
	int w,h,n,t,xn,yn;
	long long ans,sa[5],md,z;
	
	scanf("%d%d",&w,&h);
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d%d",&x[i],&y[i]);
		x2[i]=x[i];
		y2[i]=y[i];
	}
	xn=yn=n;
	qsort(x,n,sizeof(int),comp);
	//t=0;id[t++]=x[0];
	//for(i=1;i<n;i++)if(x[i]!=id[t-1])id[t++]=x[i];
	//for(i=0;i<t;i++)x[i]=id[i];
	//xn=t;
	qsort(y,n,sizeof(int),comp);
	//t=0;id[t++]=y[0];
	//for(i=1;i<n;i++)if(y[i]!=id[t-1])id[t++]=y[i];
	//for(i=0;i<t;i++)y[i]=id[i];
	//yn=t;
	
	//printf("xn %d   xn/2 %d\n",xn,xn/2);
	x3[0]=x[xn/2];y3[0]=y[yn/2];
	x3[1]=x[xn/2];y3[1]=y[yn/2-1];
	x3[2]=x[xn/2-1];y3[2]=y[yn/2];
	x3[3]=x[xn/2-1];y3[3]=y[yn/2-1];
	
	for(k=0;k<4;k++){
		//printf("%d %d\n",x3[k],y3[k]);
		md=0;
		sa[k]=0;
		for(i=0;i<n;i++){
			z=mabs(x2[i],x3[k])+mabs(y2[i],y3[k]);
			sa[k]+=z*2;
			if(md<z)md=z;
		}
		sa[k]-=md;
		//printf("%d %d\n",k,sa[k]);
		if(k==0)ans=sa[k];
		if(ans>sa[k])ans=sa[k];
	}
	for(k=3;k>=0;k--){
		if(ans==sa[k]){
			printf("%lld\n",ans);
			printf("%d %d\n",x3[k],y3[k]);
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1e13;
LL n,s,st,sum;

void dfs(LL num, LL base)
{
    if(num == 0) return;
    dfs(num/base,base);
    sum += num%base;
}

int main()
{
    cin >> n >> s;
    if(s > n)
    {
        cout << -1 << endl;
        return 0;
    }
    if(s == n)
    {
        cout << s+1 << endl;
        return 0;
    }

    st = sqrt(n) + 1;
    for(LL i = 2; i <= st; ++i)
    {
        sum = 0;
        dfs(n,i);
        if(sum == s)
        {
            cout << i << endl;
            return 0;
        }
    }
    LL b,q,res = INF;
    n = n-s;
    for(LL i = 1; i*i <= n; ++i)
    {
        if(n%i == 0)
        {
            b = n/i+1;
            q = s-i;
            if(q >= 0 && b >= 2 && q < b && i < b)
                res = min(res,b);
        }
    }
    cout << (res==INF?-1:res) << endl;
    return 0;
}



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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << s1[0] << s2[0] << s3[0] << endl;
  return 0;
}

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

template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

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

    vector<int> lefts(Q), rights(Q), ids(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> lefts[i] >> rights[i];
        --lefts[i];
        ids[i] = i;
    }
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return rights[i] < rights[j];});

    BIT<int> bit(N+5);
    vector<int> prev(550000, -1);
    vector<int> res(Q, 0);
    int r = 0;
    for (auto i : ids) {
        for (; r < rights[i]; ++r) {
            bit.add(prev[a[r]]+2, r+2, 1);
            prev[a[r]] = r;
        }
        int tmp = bit.sum(lefts[i]+1, lefts[i]+2);
        res[i] = max(res[i], tmp);
    }
    for (int i = 0; i < Q; ++i) cout << res[i] << endl;
}

Measured memory_bytes: 19552
#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>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

bool check(vector<int> v, int n) {
    if (n % 2 == 1) {
        for (int i = 0; i < n; i += 2) {
            if (i == 0) {
                if (v[i] != 1) return false;
            }else{
                if(v[i] != 2) return false;
            }
        }
    }else if(v[0] == 0){
        for(int i = 1; i < n; i += 2){
            if(v[i] != 2) return false;
        }
    }else return false;

    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> v(100000,0);
    REP(i, 0, n) {
        int tmp;
        cin >> tmp;
        v[tmp]++;
    }

    if(!check(v,n)){
        cout << 0 << endl;
        return 0;
    }else{
        int p;
        if(n % 2 == 0) p = n/2;
        else p = (n-1)/2;
        ll ret = 1;
        REP(i,0,p){
            ret *= 2;
            ret %= 1000000007;
        }
        cout << ret << endl;
    }


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    int n;
    cin >> n;

    vi a(n);
    rep(i,n) cin >> a[i];
    string s;
    rep(i,n-1){
        if(a[i] > a[i+1])  s += '>'; //cout << ">";
        else if(a[i] < a[i+1])  s += '<';//cout << "<";
        //else s+="="; //cout << "=";
    }
    int ans = 1;
    if(s.length() == 0){
        cout << 1 << endl;
        return 0;

    }
    rep(i,s.length()-1){
        if(s[i] == '>' && s[i+1] == '<'){ans++;
            i++;
        }
        else if(s[i] == '<' && s[i+1] == '>'){ans++;
        i++;
        }
    }

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

Measured memory_bytes: 3876
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var arg   = input.split("\n");
  var line0 = arg[0].split(" ");
  var line1 = arg[1].split(" ");
//  var line2 = arg[2].split(" ");
//  var line3 = arg[3].split(" ");

  var a = (line0[0]);
  var b = (line1[0]);
  //var c = Number(line0[2]);
//  var d = Number(line1[1]);

  var ans = "initial_answer";
  //console.log( "[INPUT] "+ input1 +" "+ input2 +" "+ input3 + " " + input4 );
  
  // LOGIC //
  ans = "";
  
  for(var i=0; i<a.length; i++){
    ans= ans + a.charAt(i) + b.charAt(i);
  }
  


  console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    k = 10001
    for i in range(n - 2):
        if a[i] == a[i + 1] and a[i + 1] == a[i + 2]:
            ans += 1
            a[i + 1] = k
            k += 1
    for i in range(n - 1):
        if a[i] == a[i + 1]:
            ans += 1
            a[i + 1] = k
            k += 1
    print(ans)


if __name__ == '__main__':
    main()


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


int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n, k;
	int a, b;
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", &b);
	n = n - k;
	if (n <= 0)printf("1\n");
	else
	{
		a = 1;
		if (n % (k - 1) == 0)a += n / (k - 1);
		else a = a + n / (k - 1) + 1;
		printf("%d\n", a);
	}
	
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        Integer[] A = new Integer[N];
        for (int i = 0; i < N; i++) {
            A[i] = cin.nextInt();
        }

        Arrays.sort(A, Collections.reverseOrder());

        int alice = 0, bob = 0;

        for (int i = 0; i < N; i++) {
            if (i % 2 == 0) {
                alice += A[i];
            } else {
                bob += A[i];
            }
        }

        System.out.println(alice - bob);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <map>
#define INF 1000000000
#define int long long
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;


int gcd(int a, int b){
  int m = a>=b ? a : b;
  int n = a>b ? b : a;
  int q;
  while(n!=0){
    q = m % n;
    m = n;
    n = q;
  }
  return m;
}

signed main(){
  int N;
  cin >> N;
  int ans;
  int a;
  cin >> ans;
  LOOP(i,N-1){
    cin >> a;
    ans = gcd(ans, a);
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    int x[N], y[M];
    for (int i = 0; i < N; i++) cin >> x[i];
    for (int i = 0; i < M; i++) cin >> y[i];
    sort(x, x+N); sort(y, y+M);
    int x_max = x[N-1];
    int y_min = y[0];
    string ans = "War";
    if (X < Y) {
        for (int Z = X+1; Z <= Y; Z++) {
            if (Z > x_max && Z <= y_min) {
                ans = "No War";
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N,M,C;
int B[20];
int A[20][20];

int main(){
    cin>>N>>M>>C;
    rep(i,M) cin>>B[i];
    rep(i,N) rep(j,M) cin>>A[i][j];

    int ans=0;
    rep(i,N){
        int sum=C;
        rep(j,M){
            sum+=A[i][j]*B[j];
        }
        if(sum>0) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll pwr[210], mod=998244353;
void pre(){
  pwr[0]=1;
  for(int i=1; i<=200; ++i){
    pwr[i]=(pwr[i-1]*2)%mod;
  }
}
ll x[210], y[210];
map<pair<ll, ll>, ll> mp;
int main(){
  int n;
  pre();
  while(cin>>n){
    for(int i=0; i<n; ++i){
      scanf("%lld%lld",&x[i],&y[i]);
    }
    ll ans=pwr[n]-n-1, tmp1, tmp2, tmp;
    for(int i=0; i<n; ++i){
      mp.clear();
      for(int j=i+1; j<n; ++j){
        tmp1=(y[i]-y[j]);
        tmp2=(x[i]-x[j]);
        tmp=__gcd(tmp1, tmp2);
        tmp1/=tmp;
        tmp2/=tmp;
        ++mp[mk(tmp1, tmp2)];
      }
      for(map<pair<ll, ll>, ll>::iterator it=mp.begin(); it!=mp.end(); ++it){
        ans-=(pwr[it->second])-1;
        ans%=mod;
      }
    }
    ans%=mod;
    if(ans<0)
      ans+=mod;
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace ABC158c
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            for (int i = 1; i <= 1009; i++)
            {
                int g1 = (int)Math.Floor(i * 0.08);
                if (g1 != a) { continue; }

                int g2 = (int)Math.Floor(i * 0.1);
                if (g2 != b) { continue; }

                Console.WriteLine(i);
                return;
            }

            Console.WriteLine(-1);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll x; cin >> x;
  ll ans = x / 11;
  if (x % 11 == 0) cout << ans*2 << endl;
  else if (x%11 > 6) cout << ans*2 + 2 << endl;
  else cout << ans*2 + 1 << endl;
  return 0;
}


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

int main()
{
  int n,m,s,g1,g2,a,b,cost,mi;
  int map[101][101];
  while(1){
    cin>>n>>m>>s>>g1>>g2;
    if(n==0 && m==0 && s==0 && g1==0 && g2==0)break;
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++){
	if(i==j)map[i][j]=0;
	else map[i][j]=1000000;
      }
    }
    for(int i=0;i<m;i++){
      cin>>a>>b>>cost;
      map[a-1][b-1]=cost;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
	  map[j][k]=min(map[j][k],map[j][i]+map[i][k]);
	}
      }
    }
    mi=1000000;
    for(int i=0;i<n;i++)mi=min(mi,map[s-1][i]+map[i][g1-1]+map[i][g2-1]);
    cout<<mi<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
N, M = map(int, input().split())
H = list(map(int, input().split()))
ma = [0]*(N+1)
cnt = 0
for _ in range(M):
    a, b = map(int, input().split())
    ma[a] = max(ma[a], H[b-1])
    ma[b] = max(H[a-1], ma[b])
for i in range(1, N+1):
    if H[i-1] > ma[i]:
        cnt += 1
print(cnt)

Measured memory_bytes: 20100
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , a[N];
ll ans[N];

int main(){
  cin >> n;
  rep(i,1,n+1) cin >> a[i];
  vi pos;pos.pb(0);
  rep(i,1,n+1) if(a[i]>a[pos.back()])
    pos.pb(i);
  int cnt = 0 , cur = n;
  priority_queue<int> Q;
  per(i,1,sz(pos)) {
    while(cur >= pos[i-1]) Q.push(a[cur--]);
    ll del = ll(cnt) * (a[pos[i]] - a[pos[i-1]]);
    while(sz(Q) && Q.top() >= a[pos[i-1]]) {
      del += Q.top() - a[pos[i-1]] , cnt++;
      Q.pop();
    }
    ans[pos[i]] = del;
  }
  rep(i,1,n+1) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 2808
import java.util.*;

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

        for(int i = 0; i < 26; i++) {
            cnt[i] = 0;
        }

        while(scan.hasNext()) {
            String str = scan.next();
            String[] s = str.split("");

            for(int i = 0; i < s.length; i++) {
                byte[] S = s[i].getBytes();

                if(S[0] != 45) {
                    if(65 <= S[0] && S[0] <= 90) {
                        S[0] += 32;
                    }
                    if(97 <= S[0] && S[0] <= 122) {
                        cnt[S[0] - 97] += 1;
                    }
                }
            }
        }
        for(int i = 0; i < 26; i++) {
            System.out.println((char)(i + 97) + " : " + cnt[i]);
        }
    }
}


Measured memory_bytes: 27248
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

#pragma GCC optimize("Ofast")

using namespace std;

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

    ll n, d, a;
    cin >> n >> d >> a;

    vector<pair<int, ll>> arr(n);

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].first >> arr[i].second;
    }

    sort(arr.begin(), arr.end(), [](auto a, auto b) {
        return a.first < b.first;
    });
    queue<pair<ll, ll>> q;
    ll curr = 0;
    ll ans = 0;

    for (int i = 0; i < n; i++)
    {

        while (!q.empty() and arr[i].first - 2 * d > q.front().first)
        {
            curr -= q.front().second;
            q.pop();
        }
        arr[i].second -= curr;

        if (arr[i].second <= 0)
            continue;

        ll req = arr[i].second / a;
        if (arr[i].second % a != 0)
            req++;

        int j = i;
        ans += req;
        int f = 0;
        ll diff = req * a;

        q.push({arr[i].first, diff});
        curr += diff;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
import java.io.*;

class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s=br.readLine();
        String p=br.readLine();
    	boolean m=false;
    	for(int i=0;i<s.length();i++){
        	if(s.charAt(i)==p.charAt(0)){
        		if(p.length()>1){
            		int k=i+1;
            		for(int j=1;j<p.length();j++){
        				if(k>=s.length()) k=0;
            			if(s.charAt(k)==p.charAt(j)){
            				m=true;
            				k++;
            			}else{
            				m=false;
            				break;
            			}
            		}
        		}else{
        			m=true;
        		}
        		if(m) break;
        	}
    	}
    	if(m){
    		System.out.println("Yes");
    	}else{
        	System.out.println("No");
    	}        
	}
}

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

int main() {
	string s;
    cin >> s;
    if(s == "Sunny"){
      cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy"){
      cout << "Rainy" << endl;
    }
    else{
      cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {

	int h, w; cin >> h >> w;

	vector<vector<int>> c(10, vector<int>(10, 0));

	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	for (int x = 0; x < 3; x++) {
		for (int i = 0; i < 10; i++) {//なんとかフロイド法だっけ？
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					if (c[j][i] > c[j][k] + c[k][i]) {
						c[j][i] = c[j][k] + c[k][i];
					}
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int x; cin >> x;
			if (x == -1) {

			}
			else {
				ans += c[x][1];
			}
		}
	}

	cout << ans << endl;



	return 0;
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	auto h = vector<int>(n);
	for(auto& i : h) cin >> i;
	sort(h.begin(), h.end());
	int ans = 1000000007;
	for(auto i = 0; i <= n - k; ++i){
		ans = min(ans, h[i + k - 1] - h[i]);
	}
	cout << ans << endl;
	return 0;
}

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

long dp[105][100005],v[100005];
int w[100005];

int def(int N,int W);
long max(long a,long b);

int main(void){
  int N,W,i;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  W=atoi(p);
  
  for(i=1;i<N+1;i++){
    fgets(str,sizeof(str),stdin);
    p=strtok(str," \n");
    w[i]=atoi(p);
    p=strtok(NULL," \n");
    v[i]=atoi(p);
  }
  
  def(N,W);
  
  printf("%ld\n",dp[N+1][W]);
  
  return 0;
}

int def(int N,int W){
  int i,j;
  
  for(i=1;i<N+2;i++){
    for(j=1;j<W+1;j++){
      if(j-w[i-1]<0){
        dp[i][j]=dp[i-1][j];
      }else{
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
      }
    }
  }
  
  return 0;
}

long max(long a,long b){
  if(a>=b){
    return a;
  }else{
    return b;
  }
}

Measured memory_bytes: 80128
from math import ceil
n = int(input())
cc = [0]*(n-1)
ss = [0]*(n-1)
ff = [0]*(n-1)
ans = [0]*n

for i in range(n-1):
    c,s,f = map(int,input().split())
    cc[i] = c
    ss[i] = s
    ff[i] = f   

for i in range(n-1):
    for j in range(i,n-1):
        x = max(0,ceil((ans[i]-ss[j])/ff[j]))
        ans[i] = ss[j] + x*ff[j] + cc[j]

for i in range(n):
    print(ans[i])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int x[100010];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,c){
		int d;
		cin>>d;
		x[d-1]++;
	}
	f(i,a){
		if(c-x[i]>=b)puts("No");
		else puts("Yes");
	}
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
using namespace std;
int v[100005];
long long sol[100005];
int ap[100005];
int main()
{
    int n,i,y=0,l=1;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i];
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
        {
            if(v[i]!=v[i+1])
            {
                if(l>=2)
                {
                    sol[++y]=v[i];
                    ap[y]=l;
                }
                l=0;
            }
            l++;
        }
    if(y==1 and ap[1]>=4)
    {
        cout<<sol[1]*sol[1]*1ll;
        return 0;
    }
    if(y>=2)
    {
        if(ap[y]>=4)
            cout<<sol[y]*sol[y]*1ll;
        else
            cout<<sol[y]*sol[y-1]*1ll;
        return 0;
    }
    cout<<0;
    return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
void counting_sort(int *in, int *out, int n) {
	int i, c[10001] = {0};

	for (i = 0; i < n; i++) {
		c[in[i]] += 1;
	}
	for (i = 1; i < 10001; i++) {
		c[i] += c[i-1];
	}
	for (i = n-1; i >= 0; i--) {
		out[c[in[i]]] = in[i];
		c[in[i]] -= 1;
	}
}

int main(void) {
	int n, *in, *out, i;
	const char *fmt = "%d";

	scanf("%d", &n);

	in = malloc(sizeof(int)*n);
	out = malloc(sizeof(int)*(n+1));
	for (i = 0; i < n; i++) {
		scanf("%d", in+i);
	}
	counting_sort(in, out, n);
	for (i = 1; i < n+1; i++) {
		printf(fmt, out[i]);
		fmt = " %d";
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 16280
#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 pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#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 pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#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 re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#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;


ll 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);
	fu(i,0,100){
		if((1LL<<i)-1>=n){
			v=i; break;
		}
	}
	pr((1LL<<(v))-1);
	
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	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();
	} 		
}

Measured memory_bytes: 256