akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector< pair<int64_t,int64_t> > vp(N);
  for(int i=0;i<N;i++){
    int64_t A,B;
    cin >> A >> B;
    vp.at(i)=make_pair(B,A);
  }
  sort(vp.begin(),vp.end());
  int64_t t=0;
  for(int i=0;i<N;i++){
    t+=vp.at(i).second;
    if(t>vp.at(i).first){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <vector>
#include <stack>
#include <algorithm>
#include <string.h>
#include <set>
#include <cstdlib>
#include <iostream>
#include <bits/stdc++.h>
#define pii         pair<int,int> 
#define ll          long long int 
#define pr          pair<int,ll>
#define sl(n)       scanf("%lld",&n)
#define s(n)        scanf("%d",&n)
#define f(i,n)      for(int i=0;i<n;++i)
#define fo(i,n)     for(int i=1;i<=n;++i)
#define fnm(n,m)    for(ll i=n;i<m+1;++i)
#define pb          push_back
#define pf          printf
#define F           first
#define S           second
#define srt(v)      sort(v.begin(),v.end());
#define srtc(v,cmp) sort(v.begin(),v.end(),cmp);
#define srta(v,n)   sort(v,v+n);
const ll            LL_INF=0x3f3f3f3f3f3f;
const ll            MOD=1073741824;


using namespace std;


int T;
int n,we;
pr arr[105];
ll dp[100005][105];

ll gen(int i,int w){ 
    if(i == n)return 0;
    ll &ret = dp[w][i];
    if(~ret)return ret;
    ret = gen(i+1,w);
    if(w+arr[i].F<=we)ret = max(ret,gen(i+1,w+arr[i].F)+arr[i].S);
    return ret;
}

int main(){
    // pf("\t\t\t***************************************************************************\n\n");
    // pf("\t\t\t***************************************************************************\n\n");
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    memset(dp,-1,sizeof dp);
    s(n);
    s(we);
    
    f(i,n){
        s(arr[i].F);
        sl(arr[i].S);
    }
    
    pf("%lld\n",gen(0,0));
    return 0;
} 

Measured memory_bytes: 82304
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main() {
  ll n, k;
  cin>>n>>k;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i]; a[i]--;
  }
  int c = 0;
  ll cnt=1;
  ll ant=0;
  vector<int> memo(n,-1);
  memo[0] = 0;
  while(1){
    c = a[c];
    //cout << c <<endl;
    int u = 1;
    if(memo[c] != -1){
      u = 0;
      ant = cnt - memo[c];
    }
    if(u == 0){
      break;
    }
    memo[c] = cnt;
    cnt++;
  }
  int x = 0;
  if(k < cnt - ant){
    rep(i, k){
      x = a[x];
    }
  }else{
    k = k - (cnt - ant);
    //k = k-cnt+ant;
    k = k%ant;
      rep(i, k+cnt-ant){
      x = a[x];
    }
  }
  //cout << ant << " " << cnt << endl;
  cout << x+1 << endl;
  return 0;
}


Measured memory_bytes: 4844
N=int(input())
A=[0] + [int(i) for i  in input().split()] + [0]

x=0
cost=0
for i in range(1,N+2):
  cost+=abs(A[i]-x)
  x=A[i]

for i in range(1,N+1):
  if A[i-1]<=A[i]<=A[i+1] or A[i-1]>=A[i]>=A[i+1]:
    print(cost)
  else:
    print(cost-min(abs(A[i-1]-A[i]), abs(A[i+1]-A[i]))*2)


Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    double D;
    cin >> N >> D;
    vector<double> X(N),Y(N);
    rep(i,N) cin >> X[i] >> Y[i];
    int ans = 0;
    rep(i,N){
        double dis = X[i]*X[i]+Y[i]*Y[i];
        if(dis<=D*D) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6448
#include <iostream>

using namespace std;

int main(){
	int i, j, r, c, tmp, sum, sum2 = 0;
	cin >> r >> c;
	int mat[r+1][c+1];
	for(i = 0; i < r; i++){
		sum = 0;
		for(j = 0; j < c; j++){
			cin >> tmp;
			mat[i][j] = tmp;
			sum += tmp;
			cout << tmp << ' ';
		}
		cout << sum << endl;
	}

	for(j = 0; j < c; j++){
		sum = 0;
		for(i = 0; i < r; i++){
			sum += mat[i][j];
		}
		sum2 += sum;
		cout << sum << ' ';
	}
	cout << sum2 << endl;
}

Measured memory_bytes: 3100
n = int(input())
a = list(map(int, input().split()))
hai, tya, midori = 0, 0, 0
miz, ao, ki = 0, 0, 0
yanagi, aka, got = 0, 0, 0

for i in a:
  if i<=399:
    hai = 1
  elif i<=799:
    tya = 1
  elif i<=1199:
    midori = 1
  elif i <= 1599:
    miz = 1
  elif i <= 1999:
    ao = 1
  elif i <= 2399:
      ki = 1
  elif i <= 2799:
      yanagi = 1
  elif i <= 3199:
      aka = 1
  elif i <= 4800:
    got += 1
minn = hai+tya+midori+miz+ao+ki+yanagi+aka
maxx = minn+got
if minn==0:
    minn = 1
print(minn, maxx)

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


int main() {
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> x(n,pair<ll,ll>(0,0));
    rep(i,n){
        cin >> x[i].first >> x[i].second;
    }

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

    ll sum=0,sumM=0,save;
    rep(i,n){
        if(sum+x[i].second>m) {
            save=i;
            break;
        }
        else{
            sum+=x[i].second;
            sumM+=x[i].first*x[i].second;
        }
    }
    sumM+=(m-sum)*x[save].first;

    cout << sumM << endl;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))

import collections
c = collections.Counter(A)
B=list(c.values())
ans=0
for k in range(len(B)):
    ans+=B[k]*(B[k]-1)/2
for i in range(N):
  anser=ans
  anser=anser+1-c[A[i]]
  print(int(anser))

Measured memory_bytes: 83916
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int w, a, b;
	cin >> w >> a >> b;
	if(a > b) swap(a, b);
	cout << max(0, b - a - w) << endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int n, k;
  n=S.size();
  k=0;
  for (int i=0; i<n-1; i++) {
    if (S.at(i)=='A' && S.at(i+1)=='C') {
      k=k+1;
    }
  }
  if (k>=1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3604
input = raw_input
range = xrange
n, m = map(int,input().split())
MOD = 10**9+7

dp = [[0]*(n) for i in range(n+1)]
dp[1][0] = 1
for i in range(m):
    new = [[0]*(n) for i in range(n+1)]
    for j in range(1, n+1):
        for k in range(n-j+1):
            pv = dp[j][k]
            if k != n-j: new[j][k+1] = (new[j][k+1] + pv * (n-j-k)) % MOD
            new[j][k] = (new[j][k] + pv * k) % MOD
            new[j+k][0] = (new[j+k][0] + pv * j) % MOD
    dp = new
print(dp[n][0])

Measured memory_bytes: 60060
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        long n = scan.nextLong(),
             a = scan.nextLong(),
             b = scan.nextLong(),
             c = n % (a + b);
        System.out.println(
        	(n / (a + b)) * a + (c <= a ? c: a)
        );
    }
}

Measured memory_bytes: 25172
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int tmpColorA;
		int tmpColorB;
		int tmpColorC;
		int count = 0;
		Integer colorA = 0;
		Integer colorB = 0;
		Integer colorC = 0;
		List <Integer> colorKind = new ArrayList<Integer>();
		List <Integer> colorKindTmp = new ArrayList<Integer>();

		/* ペンキの種類を入力 */
		tmpColorA = scanner.nextInt();
		tmpColorB = scanner.nextInt();
		tmpColorC = scanner.nextInt();
		colorA = Integer.valueOf(tmpColorA);
		colorB = Integer.valueOf(tmpColorB);
		colorC = Integer.valueOf(tmpColorC);

		colorKindTmp.add(colorA);
		colorKindTmp.add(colorB);
		colorKindTmp.add(colorC);


		/* 買ったことがない色の種類の場合 */
		for (int i = 0; i < colorKindTmp.size(); i++) {
			if (!colorKind.contains(colorKindTmp.get(i))) {
				/* 買ったペンキの種類をリストに入れる */
				colorKind.add(colorKindTmp.get(i));
				count ++;
			}

		}

		/* 何種類買ったか表示する */
		System.out.println(count);

	}

}


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

using namespace std;

bool imos(vector<int> v){
  for(int i=0;i<v.size()-1;i++){
    if(v[i]==0)return false;
    v[i+1]+=v[i];
  }
  return true;
}

int main(){
  int N,W,H;
  cin>>N>>W>>H;
  vector<int> v(H+1),h(W+1);
  while(N--){
    int x,y,w;
    cin>>x>>y>>w;
    v[max(0,y-w)]++;
    v[min(H,y+w)]--;
    h[max(0,x-w)]++;
    h[min(W,x+w)]--;
  }
  cout<<((imos(v)||imos(h))?"Yes":"No")<<endl;
}
  

Measured memory_bytes: 2584
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

//input


int main(){
    double n,m,d;
    cin >> n >> m >> d;
    double ans = (m-1);
    if(d!=0)ans *= 2;
    ans /= n;
    ans /= n;
    ans *= n-d;
    printf("%.10lf",ans);
    return 0;
}



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

int main() {
  int A, B, a5, a4, a2, a1, c = 0;
  cin >> A >> B;
  for (; A <= B; A++) {
    a5 = A / 10000, a4 = A % 10000 / 1000, a2 = A % 100 / 10, a1 = A % 10;
    if (a5 == a1 && a4 == a2)
      c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int linearSearch(int );
int main(){
  int x,i,j;
  int cont=0;
  scanf("%d",&x);
  int n;
  n=x+1;
  int a[n];
  for(i=0;i<x;i++)scanf("%d",&a[i]);
  int y;
  scanf("%d",&y);
  int b[y];
  for(i=0;i<y;i++)scanf("%d",&b[i]);
  for(j=0;j<y;j++){
    i=0;
    while(i!=n){
      if(a[i]==b[j]){
	cont++;
	break;
      }
      i++;
    }
  }
  printf("%d\n",cont);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() 
{
      int n;
      cin>>n;
      ll arr[n];
      for(int i=0; i<n;i++)
      cin>>arr[i];
      ll dp[n][n];// starting and end point of the subarray
      memset(dp,0,sizeof(dp));
      for(int i=0; i<n; i++)
      {
        for(int j=0; j<n;j++)
        {
            if(i==j)
            dp[i][i]=arr[i];
            
        }
      }
       for(int i=n-1; i>=0; i--)
      {
        for(int j=i; j<n;j++)
        {
            if(i!=j)
            dp[i][j]=max(arr[i]-dp[i+1][j],arr[j]-dp[i][j-1]);
            
        }
      }
       cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 73976
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 数値
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long count = 0;
		if (a == 0 && b == 0) {
			System.out.println(count);
		} else {
			long kurikaesi = n / (a + b);
			count += kurikaesi * a;

			long amari = n % (a + b);
			if (a <= amari) {
				count += a;
			} else {
				count += amari;
			}

			System.out.println(count);

		}
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
    int a,b,t;
    int total=0;
    int i=1;
    scanf("%d %d %d",&a,&b,&t);
    while(a*i<=t+0.5){
        total+=b;
        i++;
    }
    printf("%d\n",total);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N 505

int n;
int a[N][N];
inline void dfs(int l,int r,int c)
{
	if(l+1>=r) return;
	int mid=l+r>>1;
	for(int i=l;i<=mid;i++)
	for(int j=mid+1;j<=r;j++)
		a[i][j]=c;
	dfs(l,mid,c+1);
	dfs(mid+1,r,c+1);
}
int main()
{
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	dfs(1,n,1);
	for(int i=1;i<=n;i++,cout<<'\n')
	for(int j=i+1;j<=n;j++)
		cout<<a[i][j]+1<<' ';
	
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n,h,w;
  cin>>n>>h>>w;
  int a[n], b[n];
  rep(i,n) cin>>a[i]>>b[i];
  int ans = 0;
  rep(i,n) {
    if(a[i] >= h && b[i] >= w) ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
    // 行と列で爆弾の数を管理
    int H, W, M;
    cin >> H >> W >> M;
    int col[W], row[H];
    set<P> bombs;
    memset(col, 0, sizeof(col));
    memset(row, 0, sizeof(row));
    int maxCol = 0;
    int maxRow = 0;
    rep(i, M) {
        int h, w;
        cin >> h >> w;
        --h; --w;
        row[h]++;
        col[w]++;
        bombs.insert(make_pair(h, w));
    }
    rep(i, H) maxRow = max(maxRow, row[i]);
    rep(i, W) maxCol = max(maxCol, col[i]);
    set<int> stCol;
    set<int> stRow;
    // 最大のもの
    rep(i, H) {
        if (row[i] == maxRow) stRow.insert(i);
    }
    rep(i, W) {
        if (col[i] == maxCol) stCol.insert(i);
    }
    int ans = maxCol + maxRow;
    // for (auto p : bombs) {
    //     int h = p.first;
    //     int w = p.second;
    //     int temp = col[w] + row[h] - 1;
    //     if (temp > ans) ans = temp;
    // }
    bool flag = false;
    for (int r : stRow) {
        for (int c : stCol) {
            if (bombs.find(make_pair(r, c)) == bombs.end()) {
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    if (!flag) ans--;
    cout << ans << '\n';    
    return 0;
}

Measured memory_bytes: 48120
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    s = gete()

    ans = 0
    for i in range(len(s) // 2):
        if s[i] != s[-1 - i]:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3444
# -*- coding: utf-8 -*-

n = int(input())

AB = 0
A = 0
B = 0
B_A = 0
for i in range(n):
    s = input()
    if s[0] == 'B' and s[-1] != 'A':
        B = B+1
    if s[0] != 'B' and s[-1] == 'A':
        A = A+1
    if s[0] == 'B' and s[-1] == 'A':
        B_A = B_A+1

    for j in range(len(s)-1):
        if s[j] == 'A' and s[j+1] == 'B':
            AB = AB + 1
ans = 0
if A>0:
    ans = B_A
    if B>0:
        ans = ans + 1
        if A-1>0 and B-1>0:
            ans = ans+min(A-1, B-1)

elif A == 0 and B_A>0:
    ans = B_A-1
    if B>0:
        ans = ans + 1
        if A-1>0 and B-1>0:
            ans = ans+min(A-1, B-1)

ans = ans + AB
print(ans)

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

int main(){
  vector<queue<char>> player(3);
  int turn=0;

  for(int i=0; i<3; ++i){
    string str;
    cin >> str;
    for(int j=0; j<str.length(); ++j){
      player[i].push(str[j]);
    }
  }

  while(1){
    int next = player[turn].front() - 'a';
    player[turn].pop();

    turn = next;

    if(player[next].empty()){
      break;
    }
  }

  cout << (char)('A' + turn) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
  fastIO;
  ll n,k;
  cin>>n>>k;
  string str;
  ll x,y,val,val1;
  x=n;
  y=k;
  while(x!=0)
  {
    val=x%y;
    str+=to_string(val);
    x/=y;
  }
  cout<<str.length()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;

    int cnt = 0;
    rep(i,0,N){
        string S;
        cin >> S;
        if(S == "A")cnt++;
        else cnt--;
        if(cnt < 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(cnt != 0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }

}


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

int n, num[4];

int main()
{
    scanf("%d", &n);
    for(int i = 1, a;i <= n;i++)
    {
        scanf("%d", &a);
        if(a % 4 == 0)
            num[2]++;
        else if(a % 2 == 0)
            num[1]++;
        else
            num[0]++;
    }
    if(!num[2])
    {
        if(num[0])
            puts("No");
        else
            puts("Yes");
        return 0;
    }
    if(num[1] == 0)
    {
        if(num[0] <= num[2] + 1)
            puts("Yes");
        else
            puts("No");
    }
    else
    {
        if(num[0] <= num[2])
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

		if (k == 1) {
			System.out.println(0);
		} else {
			System.out.println(n - k);
		}

	}

}


Measured memory_bytes: 23636
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;
const int MAX_M = 100050;

long long a[MAX_M], b[MAX_M];
int N, M;

int main(int argc, char **argv) {
    std::cin >> N >> M;

    for (int i = 1; i <= M; i++) {
        std::cin >> a[i] >> b[i];
    }

    std::vector<std::pair<int, int>> shiten, syuten;

    for (int i = 1; i <= M; i++) {
        //shiten.push_back(std::pair({a[i], b[i]}));
        syuten.push_back(std::pair<int, int>({b[i], a[i]}));
    }
    
    //std::sort(shiten.begin(), shiten.end());
    std::sort(syuten.begin(), syuten.end());

    int current_syuten = 0;
    int ret = 0;
    for (int i = 0; i < M; i++) {
        if (current_syuten <= syuten[i].second) {
            current_syuten = syuten[i].first;
            ret++;
            //std::cout << current_syuten << std::endl;
        }
    }
    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 2936
import sys

s = input()
C_count = 0

if s[0] == 'A' and s[2:-1].count('C') == 1:
    for i in range(1, len(s)):
        if s[i].isupper():
            if s[i] == 'C':
                C_count += 1
            else:
                print('WA')
                sys.exit()

if C_count != 1:
    print('WA')
    sys.exit()
else:
    print('AC')


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

int main() {
    int kids, sweets;
    int thresholds[101];
    
    cin >> kids >> sweets;
    
    for (int i = 0; i < kids; i++)
        cin >> thresholds[i];
    
    sort(thresholds, thresholds + kids);
    
    /*for (int i = 0; i  < kids; i++)
        cout << thresholds[i];
    cout << endl;*/
    
    int j = 0, counter = 0;
    while (j < kids && sweets >= thresholds[j]) {
        sweets -= thresholds[j];
        counter++;
        j++;
    }
    
    if (sweets > 0 && j == kids)
        counter--;
    
    cout << counter << "\n";
}


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

typedef long long ll;

//解説放送
class UnionFind{
  public:
  //親の番号を格納する、親だった場合には-(サイズ)
  ll parent[1000000];
  //作るときはparentの値をすべて-1にする
  //こうするとすべてバラバラになる
  UnionFind(ll n){
    for(int i=0;i<n;i++){
      parent[i]=-1;
    }
  }
  //aがどのグループに属しているか調べる
  ll root(ll a){
    if(parent[a]<0) return a;
    return parent[a]=root(parent[a]);
  }
  //自分のいるグループの頂点数を調べる
  ll size(ll a){
    return -parent[root(a)];//親を取ってきたい
  }
  //aとbをくっつける
  bool connect(ll a,ll b){
    a=root(a);
    b=root(b);
    if(a==b){
      return false;
    }
    if(size(a)<size(b)) swap(a,b);
    parent[a]+=parent[b];
    parent[b]=a;
    return true;
  }
};

int main(){
  ll n,m;
  cin >> n >> m;
  ll a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  ll ans[m];
  ans[m-1]=n*(n-1)/2;
  UnionFind Uni(n);
  for(int i=m-1;i>=1;i--){
    if(Uni.root(a[i])!=Uni.root(b[i])){
      ans[i-1]=ans[i]-Uni.size(a[i])*Uni.size(b[i]);
      Uni.connect(a[i],b[i]);
    }
    else{
      ans[i-1]=ans[i];
    }
  }
  for(int i=0;i<m;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 6016
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;
int nowarn;

int n, c1 = 0, c2 = 0, c4 = 0;

int main() {
	nowarn = scanf( "%d", &n );
	for( int i = 0; i < n; ++i ) {
		int x;
		nowarn = scanf( "%d", &x );
		if( x % 4 == 0 ) ++c4;
		else if( x % 2 == 0 ) ++c2;
		else ++c1;
	}
	int t = (c2 ? 0 : 1);
	puts( c1 <= c4 + t ? "Yes" : "No" );
	return 0;
}


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

const ll MAX = 1000000;
const ll MOD = 1000000007;

ll fac[MAX];

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

ll pow_kai(ll a,ll n){//aのn乗を計算します。
  ll x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a%MOD;
    }
    a = a*a%MOD;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    ll tmp=1;
    for(ll i=n;i>=n-k+1;i--) tmp = (tmp*i)%MOD;

    return (tmp * pow_kai(fac[k],MOD-2)) % MOD;
}


int main()
{
    ll A[3][3],bit[3][3],N;

    rep(i,3){
        rep(j,3){
            cin >> A[i][j];
        }
    }

    cin >> N;

    ll b[N];

    rep(i,N){
        cin >>b[i];
    }

    rep(i,3){
        rep(j,3){
            bit[i][j]=0;
            rep(k,N){
                if(A[i][j]==b[k]){
                    bit[i][j]=1;
                }
            }
        }
    }

    ll ans,ans2,ans3=0,ans4=0;

    rep(i,3){
        ans=0;
        if(bit[i][0]+bit[i][1]+bit[i][2]==3){
            ans=1;
            break;
        }
    }

    rep(j,3){
        ans2=0;
        if(bit[0][j]+bit[1][j]+bit[2][j]==3){
            ans2=1;
            break;
        }
    }

    if(bit[0][0]+bit[1][1]+bit[2][2]==3) ans3=1;
    if(bit[0][2]+bit[1][1]+bit[2][0]==3) ans4=1;

    if(ans==1 || ans2==1|| ans3==1 || ans4==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

 
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin >>a>>b>>c>>d>>e>>k;
    if(e-a>k||e-b>k||e-c>k||e-d>k||
    d-a>k||d-b>k||d-c>k||
    c-a>k||c-b>k||
    b-a>k) cout<<":("<<endl;
    else cout<<"Yay!"<<endl;

return 0;


}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (auto &e : x) {
    cin >> e;
  }
  sort(begin(x), end(x));
  vector<int> d(m - 1);
  for (int i = 0; i < m - 1; i++) {
    d[i] = x[i + 1] - x[i];
  }
  sort(begin(d), end(d));
  int r = 0;
  for (int i = 0; i < m - n; i++) {
    r += d[i];
  }
  cout << r << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){

	int n,i,j,k,d=0,c;
	char s[101];

	scanf("%d%s",&n,s);

	for(i=1;i<n-1;i++){
		char x[27]={},y[27]={};

		for(j=0;j<n;j++){
			if(j<i)
				x[s[j]-'a']=1;
			else
				y[s[j]-'a']=1;
		}
		c=0;
		for(k=0;k<27;k++){
			if(x[k]==y[k])
				c+=x[k];
		}
		if(c>d)
			d=c;
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 128
import Control.Applicative

main :: IO ()
main = solve <$> f >>= print
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> Int
solve [k, a, b]
  | a <= b = if a >= k then 1 else -1
  | otherwise = let i = (k - b + a - b - 1) `div` (a - b) in max 1 (2 * i - 1)


Measured memory_bytes: 3904
A, B, C, X, Y = [int(x) for x in input().split()]

def r(a, b, c, x, y):
    if x == 0 and y == 0:
        return 0
    if x == 0:
        return min(y*b, 2*y*c)
    if y == 0:
        return min(x*a, 2*x*c)
    if (a + b) / 2 < c:
        return a*x+b*y
    else:
        z = min(x, y) * 2
        x = x - z/2
        y = y - z/2
        return r(a, b, c, x, y) + z*c


print(int(r(A, B, C, X, Y)))

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

int main(){
int A,B,C,D;
  cin >> A >> B >> C >> D;
  
 if(A/D==C/B){
   if(A%D==0 && C%B!=0){
     cout << "No" << endl;
   }
   else{cout << "Yes" << endl;}
 }
  
  else if(A/D<C/B-1){
    cout << "No" << endl;
  }
  
  else if(A/D==C/B-1){
    if(C%B==0 && A%D!=0){
       cout << "Yes" << endl;
    }
    else{cout << "No" << endl;}
  }
  
  else{
    cout << "Yes" << endl;
  }
  
}




Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pi = pair<int, int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define all(c) c.begin(), c.end()

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int n;
	string s;
	cin >> n;
	cin >> s;
	int r = 0, g = 0, b = 0;
	for (auto c : s) {
		if (c == 'R') ++r;
		if (c == 'G') ++g;
		if (c == 'B') ++b;
	}
	ll total = 1ll * r * g * b;
	rep(i, n) {
		for (int j = i+1; j < n; ++j) {
			if (s[i] == s[j]) continue;
			int k = 2*j - i;
			if (k >= n) continue;
			if (s[k] == s[i] || s[k] == s[j]) continue;
			--total;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3616
n, m = map(int,input().split())
mod = 10**9+7
ans = 1
if abs(n-m) > 1:
  print(0)
  exit()
elif n==m:
  for i in range(1,n+1):
    ans *= i
    ans %= mod
  ans = pow(ans,2,mod)
  ans *= 2
  ans %= mod
else:
  for i in range(1,n+1):
    ans *= i
    ans %= mod
  for i in range(1,m+1):
    ans *= i
    ans %= mod
print(ans)

Measured memory_bytes: 3064
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N, K;
    cin >> N >> K;
    ll count = N / K;
    N = abs(N - K * count);
    while (1)
    {
        ll NN = abs(N - K);
        if (NN >= N)
        {
            break;
        }
        N = NN;
    }

    cout << N << endl;

    return;
}

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll D;
    cin >> D;
    vector<ll> c(27,0);
    for(ll i=0;i<26;++i)cin>>c[i+1];
    vector<vector<ll>> S(D+1, vector<ll>(27, 0));
    for(ll i=0;i<D;++i)
        for(ll j=0;j<26;++j)cin>>S[i+1][j+1];
    vector<ll> last(27,0);
    for(ll i=1;i<=D;++i){
        set<P> hoge;
        for(ll j=1;j<=26;++j){
            hoge.insert(P(S[i][j]+c[j]*20,j));
        }
        prt((*--hoge.end()).second);
    }fl

    return 0;
}



Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD=1e9+7;
ll dp[3005][3005];
int main(){
	int n;
	string s;
	cin>>n;
	cin>>s;
	dp[0][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=i;j++){
			if(s[i-1]=='<'){
				if(j) dp[i][j]=dp[i-1][j-1];
			}
			else{
				dp[i][j]=dp[i-1][i-1]-((j)?dp[i-1][j-1]:0);
				if(dp[i][j]<0) dp[i][j]+=MOD;
			}
//			cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
		}
		for(int j=1;j<=i;j++){
			dp[i][j]+=dp[i][j-1];
			if(dp[i][j]>=MOD) dp[i][j]-=MOD;
		}
	}
	cout<<dp[n-1][n-1];
}

Measured memory_bytes: 68992
#include<bits/stdc++.h>
using namespace std;
using LL = int64_t;
const int maxn=1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const LL LLINF=1e14;
const double pi=acos(-1.0);
bool prime[1010000];//prime是true的是素数
int ans[1000000];//ans从1开始是素数
void init_prim()
{
    memset(ans, 0, sizeof(ans));
    memset(prime, true, sizeof(prime));
    int num = 0;
    for (int i = 2; i <= maxn; i++){
        if (prime[i] == true){
            ans[++num] = i;
        }
        for (int j = 1; ((j <= num) && (i * ans[j] <= maxn)); j++){
            prime[i * ans[j]] = false;
            if (i % ans[j] == 0) break; //µã¾¦Ö®±Ê
        }
    }
    prime[0]=prime[1]=false;
}
vector<int>num;
vector<int>temp;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    init_prim();
    int n;
    cin>>n;
    for(int i=1;ans[i]<=55555;i++) {
        if(ans[i]%10==1) {
            cout<<ans[i]<<" ";
            n--;
            if(n==0) return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 5120
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
#define PII  pair<int, int> 
#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
using namespace std;

int n;

int Mod(int a, int b){
	if(a < 0 && a % b != 0){
		n = a / b + 1;
		return a - (a / b + 1) * b;
	}
	n = a / b;
	return a % b;
}

int main()
{
	char a[5] = {'0', '1'};
	vector<int> v;
	cin >> n;
	if(n == 0) return 0 * puts("0");
	while(n != 0)
		v.pb(Mod(n, -2));
	for(int i = v.size() - 1; i >= 0; i--)
		cout << a[v[i]];
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
  cin.tie(0);
  int a,b;
  cin >> a >> b;
  if((a+b)>(a-b)&&(a+b)>(a*b))
    cout << a+b<< endl;
  else if((a-b)>(a*b))
    cout<<a-b<< endl;
  else
    cout << a*b << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int nax = 305;
double p[nax][nax][nax], ev[nax][nax][nax];
// ev[a][b][c] - the expected number of operations so far to get to state (a,b,c)
// easier: p-bility of getting to this state at all

int main() {
    int n;
    scanf("%d", &n);
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        ++cnt[x];
    }
    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c >= 0; --c) {
        for(int b = n; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {
                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }
                // dp[a][b][c]
                
                double p_waste = (double) (n - (a + b + c)) / n;
                // p_waste + p_waste^2 + ... = S
                // 1 + S = S / p_waste
                double ev_waste = p_waste / (1 - p_waste) + 1;
                //debug() << imie(a) imie(b) imie(c) imie(ev_waste);
                ev[a][b][c] += ev_waste * p[a][b][c];
                
                // remove 1 -> dp[a-1][b][c]
                // we will eventually choose one of a+b+c
                if(a != 0) {
                    double p_go = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * p_go;
                    ev[a-1][b][c] += ev[a][b][c] * p_go;
                }
                
                // remove 2 -> dp[a+1][b-1][c]
                if(b != 0) {
                    double p_go = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * p_go;
                    ev[a+1][b-1][c] += ev[a][b][c] * p_go;
                }
                
                // remove 3
                if(c != 0) {
                    double p_go = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * p_go;
                    ev[a][b+1][c-1] += ev[a][b][c] * p_go;
                }
            }
        }
    }
    printf("%.10lf\n", ev[0][0][0]); // + cnt[1] + 2 * cnt[2] + 3 * cnt[3]);
}

Measured memory_bytes: 221332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int r = sc.nextInt();
        if(r <= x && x <= W-r && r <= y && y <= H-r){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 26324
#include <iostream>
#include <numeric>
#include <algorithm>
#include <vector>
#include <array>
#include <string>
#include <queue>
#include <cmath>
#include <iterator>
#include <math.h>
#include <cstdio>
#include <map>
#include <set>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

int main(void){
    //MARCH
    array<ulli,5> a = {};
    int roop;
    string stk;
    cin >> roop;
    for(int i=0;i<roop;i++){
        cin >> stk;
        switch(stk[0]){
            case 'M':
            a[0]++;
            break;
            case 'A':
            a[1]++;
            break;
            case 'R':
            a[2]++;
            break;
            case 'C':
            a[3]++;
            break;
            case 'H':
            a[4]++;
            break;
        }
    }
    ulli total =0;
    total += a[0]*a[1]*a[2];
    total += a[0]*a[1]*a[3];
    total += a[0]*a[1]*a[4];
    total += a[0]*a[2]*a[3];
    total += a[0]*a[2]*a[4];
    total += a[0]*a[3]*a[4];
    total += a[1]*a[2]*a[3];
    total += a[1]*a[2]*a[4];
    total += a[1]*a[3]*a[4];
    total += a[2]*a[3]*a[4];
    
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
s=gets
mae=s[0,2].to_i
usiro=s[2,2].to_i
if 0 < mae && mae < 13
    if 0 < usiro && usiro < 13
        puts "AMBIGUOUS"
    else
        puts "MMYY"
    end
else
    if 0 < usiro && usiro < 13
        puts "YYMM"
    else
        puts "NA"
    end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, cnt = 0;
    cin >> n;
    
    while(n) {
        if (n % 10 == 2) {
            cnt++;
        }
        
        n /= 10;
    }
    
    cout << cnt << endl;
    return 0;
}


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

int main() {
    long long N;
    cin >> N;
    long long X[N];
    for(int i=0;i<N;i++){
        cin >> X[i];
    }
     long long sum[100]={};
    for(int i=0;i<N;i++){
        sum[0]+=X[i]*X[i];
    }
 
long long ans=sum[0];
 
    for(int p=1;p<=99;p++){
       for(int i=0;i<N;i++){
           sum[p] +=(X[i]-p)*(X[i]-p);
       }
       if(sum[p-1]>sum[p])ans=sum[p];
    }
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct v
{
	int a;
	int c;
	int d;
	int e;
};
int main()
{
	v w[1000];
	int n,j,m, i, d1[4][11] = { 0 }, d2[4][11] = { 0 }, d3[4][11] = { 0 }, d4[4][11] = { 0 };
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> w[i].a >> w[i].c >> w[i].d >> w[i].e;
		if (w[i].a == 1)
		{
			d1[w[i].c][w[i].d] += w[i].e;
		}
		if (w[i].a == 2)
		{
			d2[w[i].c][w[i].d]+= w[i].e;
		}
		if (w[i].a == 3)
		{
			d3[w[i].c][w[i].d] += w[i].e;
		}
		if (w[i].a == 4)
		{
			d4[w[i].c][w[i].d] += w[i].e;
		}
	}
	for (m = 0; m < 4; m++)
	{
		if (m == 0)
		{
			for (i = 1; i <= 3; i++)
			{
				for (j = 1; j <= 10; j ++)
				{
					if (j != 10)
						cout << " "<<d1[i][j];
					else
						cout << " "<<d1[i][j] << endl;
				}
			}
			for (i = 0; i < 20; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		if (m == 1)
		{
			for (i = 1; i <= 3; i++)
			{
				for (j = 1; j <= 10; j ++)
				{
					if (j != 10)
						cout <<" "<< d2[i][j];
					else
						cout << " "<<d2[i][j] << endl;
				}
			}
			for (i = 0; i < 20; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		if (m == 2)
		{
			for (i = 1; i <= 3; i++)
			{
				for (j = 1; j <= 10; j++)
				{
					if (j != 10)
						cout << " "<<d3[i][j];
					else
						cout <<" "<< d3[i][j] << endl;
				}
			}
			for (i = 0; i < 20; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		if (m == 3)
		{
			for (i = 1; i <= 3; i++)
			{
				for (j = 1; j <= 10; j ++)
				{
					if (j != 10)
						cout << " "<<d4[i][j];
					else
						cout <<" "<< d4[i][j] << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3092
import java.util.*;

class Main{
	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	
      int n = sc.nextInt();
      int ans = 0;
      for(int i=1;i<=n;i++){
		ans += i;        
      }
      
      System.out.println(ans);
	}
}

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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

bool compare(pair<int, int> x, pair<int, int> y) {
    if (x.second != y.second) {
        return x.second < y.second;
    } else if (x.first != y.first) {
        return x.first < y.first;
    }
}

void solve() {
    int N;
    cin >> N;
    vector<pair<int, int>> D(N);
    REP(i, N) cin >> D[i].first >> D[i].second;
    ll total = 0;
    sort(D.begin(), D.end(), compare);
    bool ok = true;
    for (int i=0; i<N; ++i){
        total += D[i].first;
        if (total > D[i].second) ok = false;
    }
    if (ok) {
        print("Yes");
    } else {
        print("No");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 3328
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    K,X = MI()
    if 500*K >= X:
        print("Yes")
    else:
        print("No")
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <math.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

const ll mod = 998244353;
const ll INF = 1000000000000;
ll N, a[200010], b[200010], c[200010], d[200010], x[200010], y[200010], bit[200010], Y_Coordinates[200010], ans;
vector<ll> X_Order, Y_Order;
map<ll, ll> X_Compression, Y_Compression;

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return pow_mod(x, y - 1) * x % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= N)
	{
		bit[i] += x;
		i += i & -i;
	}
}

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> x[i] >> y[i];
		X_Order.push_back(x[i]);
		Y_Order.push_back(y[i]);
	}

	sort(X_Order.begin(), X_Order.end());
	sort(Y_Order.begin(), Y_Order.end());

	for (int i = 0; i < N; i++)
	{
		X_Compression[X_Order[i]] = i + 1;
		Y_Compression[Y_Order[i]] = i + 1;
	}

	for (int i = 1; i <= N; i++)
	{
		x[i] = X_Compression[x[i]];
		y[i] = Y_Compression[y[i]];
		Y_Coordinates[x[i]] = y[i];
	}

	for (int i = 1; i <= N; i++)
	{
		a[i] = sum(Y_Coordinates[i]);
		b[i] = i - 1 - a[i];
		add(Y_Coordinates[i], 1);
	}
	
	for (int i = 0; i <= N + 1; i++)
	{
		bit[i] = 0;
	}

	for (int i = N; i >= 1; i--)
	{
		c[i] = sum(Y_Coordinates[i]);
		d[i] = N - i - c[i];
		add(Y_Coordinates[i], 1);
	}

	for (int i = 1; i <= N; i++)
	{
		(ans += pow_mod(2, N) - 1) %= mod;
		(ans += mod - pow_mod(2, a[i] + b[i]) + 1) %= mod;
		(ans += mod - pow_mod(2, b[i] + d[i]) + 1) %= mod;
		(ans += mod - pow_mod(2, c[i] + d[i]) + 1) %= mod;
		(ans += mod - pow_mod(2, c[i] + a[i]) + 1) %= mod;
		(ans += pow_mod(2, a[i]) - 1) %= mod;
		(ans += pow_mod(2, b[i]) - 1) %= mod;
		(ans += pow_mod(2, c[i]) - 1) %= mod;
		(ans += pow_mod(2, d[i]) - 1) %= mod;
	}

	cout << ans << endl;

	int www;
	cin >> www;
}

Measured memory_bytes: 40932
#include <iostream>

using namespace std;

int main(){
  int n,i;
  long long T,ans=0;
  cin >> n >> T;
  long long t[n];
  cin >> t[0];
  ans=T;
  for(i=1;i<n;i++){
    cin >> t[i];
    if(t[i]-t[i-1]>T)ans+=T;
    else ans+=-t[i-1]+t[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int N, x;
  string S;
  cin >> N >> x >> S;
  S[x-1] += 0x20;
  cout << S << endl;
}

Measured memory_bytes: 256