akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int a, b;
void solve()
{
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    cout << max(max(a - b, a + b), a * b) << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    int c=0;
    
    for (int i=0;i<N;i++){
        cin >> a.at(i);
    }
    for (int i=0;i<N;i++){
        cin >> b.at(i);
    }
    for (int i =0;i<N;i++){

        if (a.at(i)>b.at(i)){
            c+=a.at(i)-b.at(i);
            
        }
    
        
    }
    cout << c<< endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

using vci = vector<pair<char, int>>;

vci RLE(string s){
    vci ret;
    int ns = SZ(s);
    int cnt = 0;
    rep(i, ns){
        cnt++;
        if((i < ns-1 && s[i] != s[i+1]) || i == ns-1){
            ret.emplace_back(s[i], cnt);
            cnt = 0;
        }
    }
    return ret;
}


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    vci rl = RLE(s);
    ll ans = 0;
    rep(i, SZ(rl)){
        ans += rl[i].second-1;
    }
    ans += 2*k;
    chmin(ans, n-1);
    cout << ans << endl;
    return 0;
}

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

const int INF = 1e+9;
typedef pair<int, int> P;
typedef pair<int, P> pp;

int N, M;
vector<int> z;

int ans[50000];

int main() {
	for(int i = 0; i < 200; ++i){
		if(i * i <= 32768)
			z.push_back(i * i);
	}
	int sz = z.size();
	for(int i = 0; i < sz; ++i){
		if(z[i] * 4 > 32768)
			break;
		for(int j = i; j < sz; ++j){
			if(z[i] + z[j] * 3 > 32768)
				break;
			for(int k = j; k < sz; ++k){
				if(z[i] + z[j] + z[k] + z[k] > 32768)
					break;
				for(int l = k; l < sz; ++l){
					if(z[i] + z[j] + z[k] + z[l] > 32768)
						break;
					ans[z[i] + z[j] + z[k] + z[l]]++;
				}
			}
		}
	}
	while(cin >> N && N){
		printf("%d\n", ans[N]);
	}
	return 0;
}

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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll MOD = 1e9+7;
const ll INF = (ll)1<<62;

int main(){
	int n, k;
	vector<ll> h;
	cin>>n>>k;
	h.assign(n, 0);
	for(int i=0;i<n;i++)
		cin>>h[i];
	sort(h.rbegin(), h.rend());
	ll ans = 0;
	for(int i=k;i<n;i++)
		ans += h[i];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int s;
	int h;
	int m;
	
	scanf("%d",&s);
	h=s/3600;
	m=(s-h*3600)/60;
	s=(s-h*3600-m*60);
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
int inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =223372036854775807;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define M_PI 3.1415926
LL A[200005]={};
int main()
{
    LL a,b;
    while(cin>>a>>b){
      for(int i=0;i<a;i++){
        cin>>A[i];
      }
      int l=0;
      LL now=0;
      LL ans=0;
      LL tmp=0;
      A[a]=ll;
      for(int r=0;r<a;r++){
        now=A[r];
        now+=b;
        if(now>A[r+1]){
            tmp=A[r+1]-A[l];
        }
             else{
                ans+=tmp+b;
                l=r+1;
                tmp=0;
             }
      }
        cout<<ans<<endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

#define mem(a) memset(a,0,sizeof(a))
#define inf 0x7ffffff

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    while(cin>>n)
    {
        int flag=1;
        set<string> word;
        string str;
        char e;
        cin>>str;
        e=str[str.size()-1];
        word.insert(str);
        for(int i=2;i<=n;i++)
        {
            cin>>str;
            if(e!=str[0])
            {
                flag=0;
                //break;
            }
            e=str[str.size()-1];
            if(!word.insert(str).second)
            {
                flag=0;
                //break;
            }
        }
        if(flag)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int> (n));
  vector<int> p(m);
  for(int i = 0; i < m; i++){
    cin >> k.at(i);
    for(int j = 0; j < k.at(i); j++) cin >> s.at(i).at(j);
  }
  for(int i = 0; i < m; i++) cin >> p.at(i);
  
  int ans = 0;
  for(int bit = 0; bit < (1 << n); bit++){
    int ok = 1;
    for(int i = 0; i < m; i++){
      int cnt = 0;
      for(int j = 0; j < k.at(i); j++){
        int t = s.at(i).at(j) - 1;
        if(1 & (bit >> t)) cnt++;
      }
      if(cnt % 2 != p.at(i)) ok = 0;
    }
    ans += ok;
  }
  
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101
#define INFTY -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int G[MAX][MAX],d[MAX],color[MAX],n,Q[MAX],head,tail;

void enqueue(int x){
  Q[tail++]=x;
}

int  dequeue(){
  return Q[head++];
}


void bfs(int s){
  int i;
  for(i=1;i<=n;i++){
    d[i]=INFTY;
  }
  d[s]=0;
  color[s]=GRAY;
  enqueue(s);

  while(head!=tail){
    int u=dequeue(),v;
    for(v=1;v<=n;v++){
      if(G[u][v]==1){
      if(color[v]==WHITE){
        color[v]=GRAY;
        d[v]=d[u]+1;
        enqueue(v);
      }
    }
  }
      color[u]=BLACK;
  }
}


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

  for(i=0;i<n;i++){
	scanf("%d %d",&u,&k);
	for(j=0;j<k;j++){
  	int v;
  	scanf("%d",&v);
  	G[u][v]=1;
	}
  }
  bfs(1);
  for(i=1;i<=n;i++){
	printf("%d %d\n",i,d[i]);
  }
  return 0;
}



Measured memory_bytes: 2104
N = int(input())
S = []
for i in range(N):
  S.append(input())

ac = wa = tle = re = 0
for s in S:
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  elif s == 'RE':
    re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 16316
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int N,X,T;
    
    cin >> N >> X >> T;
    
    if (N%X==0){
        cout << (N/X)*T << endl;
    }
    else {
        cout << (N/X+1)*T << endl;
    }
}


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

int main(void){
  int w,h;
  while(cin>>h>>w,w||h){
    int minh=150,minw=150;
    for(int i=150;i>0;--i){
      for(int j=150;j>i;--j){
        if(i*i+j*j>w*w+h*h || (i*i+j*j==w*w+h*h && h<i)){
          if(i*i+j*j<minw*minw+minh*minh || (i*i+j*j==minw*minw+minh*minh && minh>i)){
            minh=i;minw=j;
          }
        }
      }
    }
    cout<<minh<<" "<<minw<<endl;
  }
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
    x += y;
    if( x >= m )
        x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
    x -= y;
    if( x < 0 )
        x += m;
}

ll divisors( ll n )
{
    int cnt = 0;
    ll ans = 1;
    while( n % 2 == 0 )
    {
        cnt++;
        n /= 2;
    }
    if( cnt > 0 )
        ans = ans * ( 1 + cnt );

    for(ll i=3;i*i<=n;i+=2)
    {
        cnt = 0;
        while( n % i == 0 )
        {
            cnt++;
            n /= i;
        }
        if( cnt > 0 )
            ans = ans * ( 1 + cnt );
    }
    if( n > 1 )
        ans = 2 * ans;

    return ans;
}

int main() 
{
    fastio();

    ll n;
    cin>>n;

    ll ans = divisors(n-1);

    for(ll k=2;k*k<=n;k++)
    {
        ll temp = n;
        while( temp % k == 0 )
            temp /= k;
        if( temp % k == 1 && (n-1) % k != 0 )
            ans++;
    }
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 256
/*  ex7_3
    Y_Aizaki  */

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

int main(void){
    int row, col;
    // 行数、列数
    char **matrix;
    // マス目入力を受け取る配列（動的）

    scanf("%d%d", &row, &col);

    // マス目入力を受け取る配列（動的）
    matrix = (char**)calloc(row, sizeof(char*));
    if (matrix == NULL){
        exit(1);
    }
    for (int i = 0; i < row; i++){
        matrix[i] = (char*)calloc(col, sizeof(char));
        if (matrix[i] == NULL){
            exit(1);
        }
    }

    int answer[row][col];
    // VLA
    // matrixの要素を標準出力するか、判断する

    // answerの初期化
    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            answer[i][j] = 0;
        }
    }

    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            // matrixに'.','#'を入力するループ
            scanf(" %c", &matrix[i][j]);
        }
    }

    for (int i = 0; i < row; i++){
        // 列ごとに見るループ

        for (int j = 0; j < col; j++){
            if (matrix[i][j] == '#'){
            break;
            }

            if (j == col-1){
                for (int x = 0; x < col; x++){
                    answer[i][x] = 1;
                }
            }
        }
    }

    for (int j = 0; j < col; j++){
        // 行ごとに見るループ

        for (int i = 0; i < row; i++){
            if (matrix[i][j] == '#'){
                break;
            }
            if (i == row-1){
                for (int x = 0; x < row; x++){
                    answer[x][j] = 1;
                }
            }
        } 
    }

    for (int i = 0; i < row; i++){
        int newline = 0;
        // 改行判定

        for (int j = 0; j < col; j++){
            // 出力するループ

            if (answer[i][j] == 0){
                printf("%c", matrix[i][j]);
                newline = 1;
            }

            if (j == col-1 && newline == 1){
                putchar('\n');
            }   
        }
    }

    for (int i = 0; i < row; i++){
        free(matrix[i]);
    }
    free(matrix);
    
    return 0;
}

Measured memory_bytes: 1692
;; A - Beginner

(let ((n (read))  ; 参加回数
      (r (read))) ; 表示レーティング
  ; r = x - 100 × (10 - n) if n < 10 else x
  (princ (if (< n 10) (+ r (* 100 (- 10 n))) r)))


Measured memory_bytes: 11232
n = int(input())
a = list(map(int,input().split()))
x = []
asum = sum(a)
ad = 0

for i in range(1,n,2):
    ad += 2 * a[i]

x.append((asum - ad))

for i in range(n-1):
    x.append(2*a[i]-x[i])

print(' '.join(map(str,x)))

Measured memory_bytes: 19148
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
int main() {
  int n, t[86400 + 1];
  while (cin >> n, n) {
    memset(t, 0, sizeof(t));
    int H1, H2, M1, M2, S1, S2;
    for (int i = 0; i < n; i++) {
      scanf("%d:%d:%d %d:%d:%d", &H1, &M1, &S1, &H2, &M2, &S2);
      t[H1 * 3600 + M1 * 60 + S1]++;
      t[H2 * 3600 + M2 * 60 + S2]--;
    }
    int ans = 0;
    for (int i = 1; i <= 86400; i++)
      t[i] += t[i - 1];
    cout << *max_element(t, t + 86400) << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int a,b,c;
    cin >> a >> b >> c;
    if(c <= a)cout << 0 << endl;
    else if(a+b < c)cout << "NA" << endl;
    else cout << c-a << endl;
}



Measured memory_bytes: 3092
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    N = ii()
    a = list(mi())
    mean = sum(a)/N

    m = min((abs(a[i]-mean), i) for i in range(N))
    print(m[1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 26848
N = int(input())
List = []
for i in range(N):
    List.append([int(a) for a in input().split()])

temp = []

for j in range(N):
    if List[j][2] > 0:
        ind = j
        break

for cx in range(101):
    for cy in range(101):
        H = List[ind][2] + abs(List[ind][0]-cx) + abs(List[ind][1]-cy)
        temp.append([cx,cy,H])
        
for k in range(len(temp)):
    num = 0
    for l in range(N):
        if List[l][2] == max(temp[k][2]-abs(List[l][0]-temp[k][0])-abs(List[l][1]-temp[k][1]),0):
            num += 1
        else:
            break
    if num == N:
        ans = k
        break
    
print("{} {} {}".format(temp[ans][0],temp[ans][1],temp[ans][2]))

Measured memory_bytes: 4460
#include<iostream>
#include<cstdio>
#include<set>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
int a[maxn],pre[maxn],pdx[maxn];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        pre[i]=pre[i-1]^a[i];
    }
    for(int i=n;i>=1;i--){
        pdx[i]=pdx[i+1]^a[i];
    }
    for(int i=1;i<=n;i++){
        printf ("%d ",pre[i-1]^pdx[i+1]);
    }


}



Measured memory_bytes: 5544
s=input()

from collections import Counter

c =dict(Counter(s))

if len(c)==1 and c[s[0]]>1:
    print('NO')
    exit(0)

if len(c)==2 and sum(list(c.values()))>2:
    print('NO')
    exit(0)

under_value = 10**18

#出現回数の最小値を探す
for _,Value in c.items():
    under_value = min(under_value,Value)
#それぞれの出現回数から引く（セット分）
for key,_ in c.items():
    c[key]-=under_value
    
f = 0
flg=0
for i,j in c.items():
    if j!=0:
        flg+=1
    f+=j
ans='YES'
if len(c)==3 and f>=3 and flg==2:
    ans='NO'
elif len(c)==3 and f>=2 and flg==1:
    ans='NO'
print(ans)




Measured memory_bytes: 9400
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define xx first
#define yy second
#define LL long long
#define MP make_pair
#define INF 0x3f3f3f3f
#define lson l, m, rt << 1
#define rson m + 1, r, rt << 1|1
#define CLR(a, b) memset(a, b, sizeof(a))

using namespace std;

const int maxn = 100100;

map<int, int> mp;
int a[maxn];

int main()
{
    int n, m;
    while(scanf("%d%d", &n, &m) != EOF)
    {
        mp.clear();
        for(int i = 0; i < n; i ++)
        {
            scanf("%d", &a[i]);
        }
        for(int i = n - 1; i >= 0; i --)
        {
            if(m == 0 || mp.count(a[i])) continue;
            printf("%d\n", a[i]);
            mp[a[i]] = 1; m --;
        }
    }
    return 0;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

int a[112345];

int main()
{
    int n;
    cin >> n;
    REP(i, n)
    {
        int c;
        cin >> c;
        c != 0 && a[c - 1]++;
        a[c]++;
        a[c + 1]++;
    }
    cout << *max_element(a, a + 112344) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
ll n,m;
cin>>n>>m;
ll ans=0;
for(ll i=0;i<n;i++)
{
    ll u,v;
    cin>>u>>v;
    ll d=ceil(sqrt(u*u+v*v));
    if(d<=m)
    ans++;
}
cout<<ans<<endl;

}



   
      
    
        



Measured memory_bytes: 3716
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int A = sc.nextInt();
		final int B = sc.nextInt();

		int N = (B - 1) / (A -1);
		if ( (B - 1) % (A - 1) > 0) {
			N++;
		}
		out.println(N);
	}
}


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

int main(){
    ll n;
    int k, cnt = 0;
    cin >> n >> k;
    while(n > 0){
        n /= k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int mod = (int)1e9+7;
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[m+1];
        
        long ans = 1;
        for(int i=0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        for(int i=0; i<m; i++){
            b[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(a);
        Arrays.sort(b);
        
        int aidx = 0;
        int bidx = 0;
        
        for(int i=n*m; i>=1; i--){
            int at = a[n-aidx];
            int bt = b[m-bidx];
            
            long tmp = 1;
            
            if(at>i) tmp = 0;
            if(bt>i) tmp = 0;
            
            if(at==i && bt==i){
                //tmp = 1;
                aidx++;
                bidx++;
            }else if(at==i){
                tmp = bidx;
                aidx++;
            }else if(bt==i){
                tmp = aidx;
                bidx++;
            }else{
                tmp = aidx*bidx - (n*m-i);
                if(tmp<0) tmp = 0;
            }
            
            ans = ans*tmp%mod;
        }
        
        System.out.println(ans);
    }
}


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

int iCnt[ 30 ];

int main( int argc, char *argv[] )
{
int i;
char w[ 110 ];
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> w;

	i = 0;
	C = w[ i ];
	while( C != '\0' )
	{
		iCnt[ C - 'a' ]++;

		i++;
		C = w[ i ];
	}

	for( i = 0; i < 26; i++ )
	{
		if( iCnt[ i ] % 2 != 0 )
		{
			cout << "No" << endl;

			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}




Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
minus = sum([1 if x<0 else 0 for x in A])
if minus%2==1:
    absA = list(map(abs, A))
    mn = min(absA)
    print(sum(absA)-2*mn)
else:
    print(sum(map(abs, A)))

Measured memory_bytes: 14412
H,W = map(int,input().split())
ans = H*W
for h in range(1,H):
    w = W//2
    S = (h*W,(H-h)*w,(H-h)*(W-w))
    ans = min(ans,max(S)-min(S))
    h2 = (H-h)//2
    S = (h*W,h2*W,(H-h-h2)*W)
    ans = min(ans,max(S)-min(S))
for w in range(1,W):
    h = H//2
    S = (H*w,h*(W-w),(H-h)*(W-w))
    ans = min(ans,max(S)-min(S))
    w2 = (W-w)//2
    S = (H*w,H*w2,H*(W-w-w2))
    ans = min(ans,max(S)-min(S))
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  constexpr int MAX = 1000001;
  vector<int> A(N), sieve(MAX, 1);
  for (auto &a : A) {
    cin >> a;
  }

  sort(begin(A), end(A));

  for (auto &a : A) {
    if (sieve[a] == 1) {
      ++sieve[a];
      for (int i = 2; i * a < MAX; ++i) {
        sieve[i * a] = 0;
      }
    } else if (sieve[a] > 1) {
      sieve[a] = 0;
    }
  }

  cout << count_if(begin(A), end(A), [&](int a) { return sieve[a]; }) << endl;
}


Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll s,q,ans[10],sw[10],cnt;
vector<ll>ch[10];
void cal(){
	bool l=true;
	for(ll i=0;i<q;i++){
		ll num=0;
		for(ll j=0;j<ch[i].size();j++){
			if(sw[ch[i][j]]){
				num++;
			}
		}
		if(num%2!=ans[i]){
			l=false;
		}
	}
	if(l){
		cnt++;
	}
}
void dep(ll now){
	if(now==s){
		cal();
		return ;
	}
	sw[now]=0;dep(now+1);
	sw[now]=1;dep(now+1);
}
int main() {
	cin>>s>>q;
	for(ll i=0;i<q;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll x;
			cin>>x;
			x--;
			ch[i].push_back(x);
		}
	}
	for(ll i=0;i<q;i++){
		cin>>ans[i];
	}
	dep(0);
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
n=int(input())
alist=[]
import itertools
for i in range(3,10):
  blist=itertools.product(['3','5','7'], repeat=i)
  for j in blist:
    if '3' in j and '5' in j and '7' in j:
      alist.append(int(''.join(j)))
ans=0
for i in alist:
  if i<=n:
    ans+=1
print(ans)

Measured memory_bytes: 10128
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const long long  int INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	double result=0;
	cin>>N;
	VPLL xyps(N);

	REP(i, N){
	  PLL xyp;
	  cin >> xyp.first>>xyp.second;
	  xyps[i]=xyp;
	}
	ld sumD=0;
	ll cnt=0;
	SORT(xyps);
	do{
	  REP(i,SIZE(xyps)-1) {
	    ll j=i+1;
	    ld x=xyps[i].first - xyps[j].first;
	    ld y=xyps[i].second - xyps[j].second;
		ld dist = hypot(x,y);
		sumD+=dist;
	  }
	  cnt++;
	}while(next_permutation(ALL(xyps)));
	result=sumD/(ld)cnt;
	
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 512
#include <stdio.h>
 
using namespace std;
 
int main(){
    int r,c,sum,total_sum = 0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1];
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c+1; j++){
            table[i][j] = 0;
        }
    }
 
    for(int i = 0; i < r; i++){
        sum = 0;
        for(int j = 0; j < c; j++){
            scanf("%d",&table[i][j]);
            sum += table[i][j];
            table[r][j] += table[i][j];
        }
        table[i][c] = sum;
        total_sum += sum;
    }
    table[r][c] = total_sum;
 
    for(int i = 0; i < r+1; i++){
        for(int j = 0; j < c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}
 



Measured memory_bytes: 2800
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[s,e]+=1

b=a.cumsum(1)
b=np.flipud(b)
b=b.cumsum(0)
b=np.flipud(b)

for i in range(q):
  s,e=map(int,input().split())
  print(int(b[s,e]))

Measured memory_bytes: 18600
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h, w = LI()
a = [list(input()) for _ in range(h)]
dx,dy = [1,0],[0,1]
flag = True
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que = deque()
            que.append((i,j))
            a[i][j] = '.'
            while que:
                y,x = que.popleft()
                for k in range(2):
                    ny, nx = y + dy[k], x + dx[k]
                    if 0 <= ny < h and 0 <= nx < w:
                        if a[ny][nx] == '#':
                            que.append((ny,nx))
                            a[ny][nx] = '.'
                            break
            flag = False
            break
    if not flag:
        break


for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            print('Impossible')
            quit()
print('Possible')

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

int64_t lucas(int N, vector<int64_t> &memo) {
  if (memo.at(N - 1) != -1) return memo.at(N - 1);
  return memo.at(N - 1) = lucas(N - 1, memo) + lucas(N - 2, memo);
}

int main() {
  int N;
  cin >> N;
  vector<int64_t> memo(N + 1, -1);
  memo.at(0) = 2;
  memo.at(1) = 1;
  
  cout << lucas(N + 1, memo) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,ans;
int a[60],b[60];
map<int,map<int,int> >mm;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				ans=max(ans,++mm[a[i]-a[j]][b[i]-b[j]]);
	cout<<n-ans<<endl;
	return 0;
}


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

int main(){
  int N;
  cin>>N;
  std::vector<double> t(N),v(N);
  for(int i=0;i<N;i++)cin>>t[i];
  for(int i=0;i<N;i++)cin>>v[i];
  double ts=0;
  for(int i=0;i<N;i++)ts+=t[i];
  std::vector<double> lo(ts*2+1);
  for(double i=0;i<2*ts+1;i++)lo[i]=i/2;
  for(double i=0;i<2*ts+1;i++)lo[2*ts-i]=min(lo[i],i/2);
  double tnow=0;
  for(double i=0;i<N;i++){
    for(double j=0;j<2*ts+1;j++){
      if(j<tnow)lo[j]=min(lo[j],v[i]+(tnow-j)/2);
      if(j>=tnow&&j<=tnow+t[i]*2)lo[j]=min(lo[j],v[i]);
      if(j>tnow+t[i]*2)lo[j]=min(lo[j],v[i]+(j-tnow-t[i]*2)/2);
    }
    tnow+=t[i]*2;
  }
  double ans=0;
  for(double i=1;i<ts*2+1;i++)ans+=(lo[i]+lo[i-1])/4;
  //for(double i=0;i<ts*2+1;i++)cout<<lo[i]<<endl;
  cout<<fixed<<setprecision(12)<<ans<<endl;
}


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

#define    ll     long long int

const int N = 100005;
int ara[N];

int main( )
{
    int n, i, j, k, s = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        s += abs(ara[i] - ara[i - 1]);
    }
    s += abs(ara[i - 1]);
    ara[i] = 0;
    for (i = 1; i <= n; i++) {
        cout << (s - abs(ara[i] - ara[i - 1]) - abs(ara[i + 1] - ara[i]) + abs(ara[i + 1] - ara[i - 1])) << '\n';
    }
    return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define int long long int
#define sp(x) setprecision(x)
#define ceil(a,b)   (a+(b-1))/b
#define PI 3.141592653589793238462643383279502884

//#define sumup(x)	(x*(x+1))/2
using namespace std;

int sumup(int n)
{
	return (n*(n+1))/2;
}

int32_t main()
{
int n;
cin>>n;
set<int>st;
int arr[n];
for(int i=0;i<n;i++)
	{
	cin>>arr[i];
	st.insert(arr[i]);
	}
	if(st.size()==n)
		cout<<"YES";
	else
		cout<<"NO";

}


Measured memory_bytes: 11136
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;

int gcd(int a, int b) {
    while(b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int lcm(int a, int b) {
    return a * (b / gcd(a, b));
}

int dd(int m, int x, int y) {
    return m / x + m / y - m / lcm(x, y);
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (b - a + 1) - (dd(b, c, d) - dd(a - 1, c, d)) << endl;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 998244353
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }



signed main() {

	int N;
	cin >> N;
	vector<int> a(N);
	rep(i,N) cin >> a[i];
	
	vector<int> v;
	v.push_back(a[0]);

	for (int i = 1; i < N; i++) {

		auto it = upper_bound(v.begin(), v.end(), a[i], greater<int>());
		if (it == v.end())
			v.push_back(a[i]);
		else
			*it = a[i];
	}
	cout << v.size() << endl;

	return 0;
}

Measured memory_bytes: 2168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


/*
* Problem : Count Balls
* Acknowledgement : None
* Author : deathnaught_
* GitHub : www.github.com/DeathNaughT-GitHub
* Complexity : O(1)
*/

public class Main
{

    public static void main(String[] args) 
    {
        FastReader sc = new FastReader();

        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long sum = A + B;
        
        if (sum == 0) {
            System.out.println("0");
            return;
        }

        long rem = N / sum;
        long ans = rem * A;
        rem = N % sum;
        ans += rem > A ? A : rem;
        System.out.println(ans);
        
    }

    static class FastReader 
    { 

        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 

		boolean hasNext()
		{
		    return st == null ? false : true;
		}

        char nextChar()
        {
            return next().charAt(0);
        }
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 

        int[] nextArray(int rows)
        {
            int arr[] = new int[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextInt();
            return arr;
        }

        long[] nextLongArray(int rows)
        {
            long arr[] = new long[rows];            
            for (int i = 0; i < rows; i++)
            arr[i] = nextLong();
            return arr;
        }

        char[] nextCharArray(int rows)
        {
            char arr[] = new char[rows];
            for (int i = 0; i < rows; i++)
            arr[i] = next().charAt(0);
            return arr;
        }

        int[][] nextMatrix(int rows, int columns)
        {
            int mat[][] = new int[rows][columns];
            for (int i = 0; i < rows; i++)
            {
                for (int j = 0; j < columns; j++)
                {
                    mat[i][j] = nextInt();
                }
            }
            return mat;
        }
    } 

}

Measured memory_bytes: 22484
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int N=2e5+7;
ll n,k,a[N],b[N],c[N],po,ne;

bool check(ll x) {
	int p=ne;ll ret=0;
	for (int i=1;i<=ne;i++) {
		while (p>=1&&b[i]*b[p]<x) p--;
		ret+=p;
	}
	p=1;
	for (int i=po;i>=1;i--) {
		while (p<=po&&c[i]*c[p]<x) p++;
		ret+=po-p+1;
	}
	p=po;
	for (int i=1;i<=n;i++) if (a[i]*a[i]>=x) ret--;
	ret/=2;
	for (int i=ne;i>=1;i--) {
		while (p>=1&&b[i]*c[p]<x) p--;
		ret+=p;
	}
	return n*(n-1)/2-ret>=k;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++) if (a[i]<0) b[++ne]=a[i];else c[++po]=a[i];
	ll l=-1e18,r=1e18;
	while (l<r) {
		ll mid=(l+r) >> 1;
		if (check(mid)) r=mid;
		else l=mid+1;
	}
	printf("%lld\n",l-1);
	return 0;
}

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

const int MAXLEN = 3;

int main(int argc, const char **argv)
{
    char *contest = NULL;
    contest = (char *) malloc(MAXLEN);

    fscanf(stdin, "%s", contest);

    if ( strcmp(contest, "ABC") == 0 ) fprintf(stdout, "ARC\n");
    if ( strcmp(contest, "ARC") == 0 ) fprintf(stdout, "ABC\n");

    free(contest);
    return 0;
}

Measured memory_bytes: 2064
#include<iostream>
#include<stdio.h>//printf("%.*f\n",*********);
#include<vector>//s.erase(n),vector
#include<algorithm>//next_permutation
#include<set>
#include<string>//char('a'=32+'A')
//to_string,string,substr
#include<sstream>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>//min,max
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap

#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)//start==1
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)//end==1
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(a,n) rep(i,n)cin>>a[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//昇順
#define reve(s) reverse(s.begin(),s.end())//反転
#define please return
#define AC 0
#define rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define pi 3.1415926535897932384626//pi
#define nine 1000000000//10^9

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef vector<double> vdouble;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int KETA(int n) { //Sum of Each Digit
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

unsigned ND(unsigned num) {//Number of Digits
	return std::to_string(num).length();//outmax=10
}

bool KIBN(string s) {
	rep(i, s.size() / 2) {
		if (s[i] != s[s.size() - 1 - i])return false;
	}
	return true;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */

int a = 0, n = 0, x = 0, y = 0, ans = 0, cnt = 0, sum = 0;
string s="";

int main(void) {

	int n; string s;
	cin >> n >> s;
	rep(i, s.size()) {
		if (s[i] == 'R') {
			x++;
		}
		if (s[i] == 'B') {
			y++;
		}
	}
	Yes(x > y);

	please AC;
}
//参考：---;

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

int n;
char s[100][10];

int main() {
  scanf("%d", &n);
  int acounter = 0;
  bool ans = true;
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
    if (s[i][0] == 'A') acounter++;
    else {
      if (acounter > 0) acounter--;
      else ans = false;
    }
  }
  if (ans && acounter == 0) printf("YES\n");
  else printf("NO\n");
}



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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=1,sum=0;

    int x;
    cin >>x;

    for (int i = 2; i <= x; i++){
        int bp=i;

        while (1){
            bp*=i;

            if(bp<=x)ans = max((int)ans,bp);
            else break;
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,l;
  cin>>n>>l;
  vector<string> ss(n);
  cin>>ss.at(0);
  for(int i=1;i<n;i++){
    cin>>ss.at(i);
    for(int j=i;j>0;j--){
      if(ss.at(j).compare(ss.at(j-1))<0){swap(ss.at(j),ss.at(j-1));}
      else{break;}
    }
  }
  for(int i=0;i<n;i++){cout<<ss.at(i);}
}

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

int main(){
    char ans[13];
    int sub,bit[8] = {128,64,32,16,8,4,2,1};
    double dbit[4] = {0.5,0.25,0.125,0.0625};
    double n,dec;
    while(1){
        cin >> n;
        sub = n;
        dec = n - sub;
        if(n < 0.0) break;
        for(int i=0;i<8;i++){
            if(bit[i] <= n){
                n -= bit[i];
                ans[i] = '1';
            }
            else ans[i] = '0';
        }
        if(n >= 1){
            cout << "NA" << endl;
            continue;
        }
        ans[8] = '.';
        for(int i=0;i<4;i++){
            if(dec >= dbit[i]){
                dec -= dbit[i];
                ans[i+9] = '1';
            }
            else ans[i+9] = '0';
        }
        if(dec != 0.0){
            cout << "NA" << endl;
            continue;
        }
        cout << ans << endl;
    }
}

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

namespace Make_Purse_Light
{
    class Program
    {
        static int[] Coins = new int[] { 10, 50, 100, 500 };
        static bool flag = false;

        private static void Main(string[] args)
        {
            while (true)
            {
                // 会計金額
                int bill = int.Parse(Console.ReadLine());
                if (bill == 0) break;

                // 所持金
                int[] ownedCoins = Console.ReadLine().Trim().Split(' ').Select(i => int.Parse(i)).ToArray();
                // 所持枚数
                int ownedMoney = GetMoney(Coins, ownedCoins);

                // お釣り
                int changeMoney = ownedMoney - bill;
                // お釣り枚数
                int[] changeCoins = GetChange(changeMoney);

                // 支払い枚数
                int[] paymentCoins = GetPayment(ownedCoins, changeCoins);

                WriteLines(paymentCoins);
            }
        }

        private static int[] GetChange(int money)
        {
            int[] result = new int[Coins.Count()];
            for (int i = Coins.Count()-1; i >= 0; i--)
            {
                result[i] = money / Coins[i];
                money %= Coins[i];
            }
            return result;
        }

        private static void WriteLines(int[] paymentCoins)
        {
            if (flag) Console.WriteLine(); else flag = true;
            for (int i = 0; i < Coins.Count(); i++)
            {
                if (paymentCoins[i] > 0)
                {
                    Console.WriteLine("{0} {1}", Coins[i], paymentCoins[i]);
                }
            }
        }

        private static int GetMoney(int[] l1, int[] l2)
        {
            int result = 0;
            for (int i = 0; i < l1.Count(); i++)
            {
                result += l1[i] * l2[i];
            }
            return result;
        }


        private static int[] GetPayment(int[] l1, int[] l2)
        {
            int[] result = new int[Coins.Count()];
            for (int i = 0; i < l1.Count(); i++)
            {
                result[i] = (l1[i] - l2[i]);
            }
            return result;
        }
    }
}


Measured memory_bytes: 9732
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

vector<int> color;
vector<int> ans;

// dfs
void dfs(Graph &G, int v, int p = -1){
  for(int next_v : G[v]){
    if(next_v == p) continue;
    ans[next_v] += ans[v];
    dfs(G, next_v, v);
  }
}

int main(){
  int n, q; // n: 頂点の数 q: 操作の数
  cin >> n >> q;

  Graph G(n);
  int a, b;
  for(int i = 0; i < n-1; i++){
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  ans.resize(n);
  int p, x;
  for(int i = 0; i < q; i++){
    cin >> p >> x;
    p--;
    ans[p] += x;
  }

  dfs(G, 0);

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 26624
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

int main(){
  
  int cma = 0, lma = 0;
  string s, ans1, ans2;
  map<string, int> mp;
  map<string, int>::iterator it;
  
  while(cin >> s){
    cma = max(cma, ++mp[s]);
    lma = max(lma, (int)s.length());
  }
  
  for(it = mp.begin();it != mp.end();it++){
    if(it->second == cma) ans1 = it->first;
    if(it->first.length() == lma) ans2 = it->first;
  }
  
  cout << ans1 << " " << ans2 << endl;
  
  return 0;
}


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

typedef long long ll;
#define endl '\n'

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

Measured memory_bytes: 3592