akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
    long long int n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    long long int k=n/(a+b);
    if(n%(a+b)<=a){
        printf("%lld",k*a+n%(a+b));
        return 0;
    }
    else
    {
        printf("%lld",k*a+a);
        return 0;
    }
    
}


Measured memory_bytes: 1700
k, a, b = map(int, input().split())

total = 1
cost = b/(a + 1)

if cost > 1:
    if k >= a - 1:
        n = (k - (a - 1)) // 2
        total += n * (b - a)
        total += k - 2 * n
    else:
        total += k
else:
    total += k

print(total)

Measured memory_bytes: 9196
from collections import Counter
N=int(input())
A=list(map(int, input().split()))
B=[0]
for i in range(N):
    B.append(A[i]+B[-1])
ct=0
Act=list(Counter(B).items())
for i in range(len(Act)):
    if Act[i][1]>1:
        ct+=Act[i][1]*(Act[i][1]-1)//2
print(ct)


Measured memory_bytes: 48240
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int fpw(int a, int b)
{
	int ans = 1;
	while(b)
	{
		if(b&1) ans = 1ll*ans*a%mod;
		a = 1ll*a*a%mod;
		b >>= 1;
	}
	return ans;
}
int main()
{
	int n; scanf("%d", &n);
	int ans = ((fpw(10, n) - 2*fpw(9, n))%mod + fpw(8, n))%mod;
	if(ans<0) ans += mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
double dp[301][301][301];
int n;

double solve(int a, int b, int c) {
    //cout<<a<<" "<<b<<" "<<c<<endl;
    
    if(a<0 || b<0 || c<0) return 0;
    
    if(a==0 && b==0 && c==0) return 0;
    
    if(dp[a][b][c]>0) return dp[a][b][c];
    
    double F = n + a*solve(a-1,b,c) + b*solve(a+1,b-1,c) + c*solve(a,b+1,c-1);
    
    F = F/(a+b+c);
    
    return dp[a][b][c] = F;
}

int main() 
{
    int x, a = 0, b = 0, c = 0;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> x;
        if(x==1) a++;
        else if(x==2) b++;
        else if(x==3) c++;
    }
    
    double ans = solve(a,b,c);
    
    cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

int dp[100006][3];
long long k;
const int M = 1000000007;
string S;
int main() {
	cin >> S;
	k = 1;
	for (int i = 1; i <= S.length(); i++){
		if (S[i-1] == 'A'){
			dp[i][0] = (dp[i-1][0] + k) % M;
			dp[i][1] = dp[i-1][1];
			dp[i][2] = dp[i-1][2];
		} else if (S[i-1] == 'B') {
			dp[i][0] = dp[i-1][0];
			dp[i][1] = (dp[i-1][1] + dp[i-1][0]) % M;
			dp[i][2] = dp[i-1][2];
		} else if (S[i-1] == 'C') {
			dp[i][0] = dp[i-1][0];
			dp[i][1] = dp[i-1][1];
			dp[i][2] = (dp[i-1][2] + dp[i-1][1]) % M;
		} else if (S[i-1] == '?') {
			dp[i][2] = (((dp[i-1][2] + dp[i-1][2]) % M + dp[i-1][2]) % M + dp[i-1][1]) % M;
			dp[i][1] = (((dp[i-1][1] + dp[i-1][1]) % M + dp[i-1][1]) % M + dp[i-1][0]) % M;
			dp[i][0] = (((2*dp[i-1][0]) % M + dp[i-1][0]) % M + k) % M;
			k = (k*3) % M;
		}
	}
	cout << dp[S.length()][2] << endl;
	return 0;
}

Measured memory_bytes: 1664
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
N = int(input())
A = [1 for _ in range(N)]
for i in range(2,N):
    A[i] = (i*A[i-1])%p
X = list(map(int,input().split()))
X.insert(0,0)
cnt = 0
for i in range(1,N):
    cnt = (cnt+((X[N]-X[i])*pow(i,p-2))%p)%p
print((cnt*A[N-1])%p)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll K;
    cin >> K;

    vector<bool> check(K, false);
    ll now = 7;
    ll cnt = 0;
    while(1){
        now %= K;
        if(now==0){
            cout << cnt+1 << endl;
            return 0;
        }
        if(check[now]){
            cout << -1 << endl;
            return 0;
        }
        check[now] = true;
        now = 10*now+7;
        cnt++;
    }

    return 0;
}

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

int main()
{
    // 入力
    int N; 
    int K;
    std::cin >> N >> K;
    std::vector<int> h(N);
    for (int i = 0; i < N; i++) std::cin >> h[i];

    // 問題を解く
    std::vector<int> cost(N, INT_MAX);
    cost[0] = 0;
    cost[1] = abs(h[1] - h[0]);

    // 3つ以上あるとき
    for (int i = 2; i < N; i++)
    {
        // もらうDP:  コストが最も小さいものを採用
        for (int k = 1; k <= K; k++)
        {
            if (i - k < 0) continue;
            int k_step_cost = cost[i-k] + abs(h[i] - h[i-k]);
            cost[i] = std::min(cost[i], k_step_cost);
        }
    }

    std::cout << cost[N-1] << std::endl;

    return 0;
}


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

int main(){
    int n;cin>>n;
    for(int i=1;i<=9;i++){
        if(n%i==0){
            if(n/i>=1&&n/i<=9){
                cout<<"Yes\n";
                exit(0);
            }
        }
    }
    cout<<"No\n";
    return 0;
}

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

vector <pair <long long, long long> > prime_factorize(long long N){
    vector <pair <long long, long long> > res;
    for(long long a=2; a*a <= N; a++){//a<=N^0.5まで試す
        if(N % a != 0) continue;//素因数でないなら次のforループ
        long long ex = 0;//指数
        while(N % a == 0){
            ex ++;
            N /= a;
        }
        res.push_back({a,ex});//結果を格納{素因数,指数}
    }
    if(N != 1) res.push_back({N,1});//最後が1でなければ素因数
    return res;
}

int main(){
    long long n;
    cin >> n;
    auto table = prime_factorize(n);
    int ans = 0;
    for(int i=0; i<table.size(); i++){
        int tmp=table[i].second;
        for(int j=0; j<40; j++){
            if((j*(j+1)<=2*tmp) && (2*tmp < (j+1)*(j+2))){
                ans += j;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int N = 300;

char ch[N+5]; int f[N+5][N+5][N+5], k, n;

void work() {
    scanf("%s%d", ch+1, &k); n = strlen(ch+1);
    for (int i = 1; i <= n; i++) f[i][i][0] = 1;
    for (int l = 1; l <= n; l++)
    for (int i = 1; i+l <= n; i++)
        for (int p = 0, j = i+l; p <= k; p++) {
        f[i][j][p] = max(f[i+1][j][p], f[i][j-1][p]);
        if (ch[i] == ch[j]) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p]+2);
        if (p) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p-1]+2);
        }
    int ans = 0;
    for (int i = 0; i <= k; i++) ans = max(ans, f[1][n][i]);
    printf("%d\n", ans);
}
int main() {work(); return 0; }
/*
最后的lcs中l<r的部分确定下来，l>r的部分肯定是跟前者对称的（如果有更优的话那前面一部分肯定也会选更优的） 
*/

Measured memory_bytes: 110464
import sys
import numpy as np


if __name__ == "__main__":
    N = int(raw_input())
    scores = [int(raw_input()) for i in range(N)]
    scores.sort()
    # tasks = np.array(tasks)

    # print(
    found = False
    var = sum(scores)
    if var %10 != 0:
        print var
        found = True
        # return 0
    else:
        for s in scores:
            if s % 10 != 0:
                print var - s
                found = True
                break
    if not found:
        print 0


Measured memory_bytes: 10528
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    counta=0
    countb=0
    countab=0
    ans=0
    for i in range(n):
        s=SI()
        if s[-1]=="A":
            if s[0]=="B":
                countab+=1
            else:
                counta+=1
        else:
            if s[0]=="B":
                countb+=1
        for i in range(len(s)-1):
            if s[i]=="A" and s[i+1]=="B":
                ans+=1
    if counta>0 and countb>0:
        ans+=countab+1
        counta-=1
        countb-=1
        ans+=min(counta,countb)
    elif counta>0:
        ans+=countab
    elif countb>0:
        ans+=countab
    else:
        ans+=max(0,countab-1)
    print(ans)
                

            
        








if __name__=="__main__":
    main()


Measured memory_bytes: 9372
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B; char op; cin >> A >> op >> B;
    int ans = 0;
    if(op=='+') ans = A+B;
    if(op=='-') ans = A-B;
    cout << ans;
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF=1e9,MOD=1e9+7;
int mh[4]={1,0,-1,0},mw[4]={0,1,0,-1};

int main(){
    string s;
    int a,b,c,d,e;
    int n,k,ans=0;
    cin>>n>>k;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    rep(i,n){
        if(h[i]>=k)ans++;
    }
    cout<<ans<<endl;
}



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

int main()
{
    int N;
    cin >> N;
    int fac2 = 0, fac4 = 0, fr = 0;
    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp % 4 == 0)
            fac4++;
        else if (tmp % 2 == 0)
            fac2++;
        else
            fr++;
    }
    int mfac4 = N - fac4 * 2;
    if (fac4 >= (fr + fac2) - 1)
        cout << "Yes" << endl;
    else if (mfac4 < fac2 / 2)
    {
        cout << "Yes" << endl;
    }
    else if (fac2 == mfac4)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<utility>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;

int main(int argc, char *argv[])
{
  for(;;) {
    int h, w, c;
    cin >> h >> w >> c;
    if(h == 0) break;
    int fld[64];
    for(int i = 0; i < 8; i++) {
      for(int j = 0; j < 8; j++) {
        if(i < h && j < w) {
          int p;
          cin >> p;
          fld[i*8+j] = p;
        } else {
          fld[i*8+j] = 0;
        }
      }
    }
    auto switching = [w,h](int d, int *f) {
        bool visited[64];
        for(int i = 0; i < 64; i++) visited[i] = false;
        visited[0] = true;
        vector<int> st;
        st.push_back(0);
        int di[] = {-1, 0, 1, 0};
        int dj[] = {0, 1, 0, -1};
        while(st.size()>0) {
          int q = st.back();
          st.pop_back();
          int i = q / 8;
          int j = q % 8;
          for(int k = 0; k < 4; k++) {
            int ii = i + di[k];
            int jj = j + dj[k];
            int qq = ii * 8 + jj;
            if(ii >= 0 && jj >= 0 && ii < h && jj < w && f[qq] == f[0] && !visited[qq]) {
              visited[qq] = true;
              st.push_back(qq);
            }
          }
        }
        int cnt = 0;
        for(int i = 0; i < 64; i++) {
          if(visited[i]) {
            f[i] = d;
            cnt++;
          }
        }
        return cnt;
    };
    auto print = [w,h](const int *f) {
      for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
          cout << f[i*8+j] << " ";
        }
        cout << endl;
      }
    };
    int mx = 0;
    std::function<void(const int*, int)> trying = [c,w,h,&mx,&trying,&switching,&print](const int *f, int did) {
      //cout << "--" << did << endl;
      //print(f);
      //cout << endl;
      if(did == 4) {
        if(f[0] == c) return; // no change X(
        int ff[64];
        for(int i = 0; i < 64; i++) ff[i] = f[i];
        switching(c, ff);
        int cnt = switching(9, ff);
        //print(ff);
        //cout << "cnt = " << cnt << endl;
        //cout << endl;
        if(mx < cnt) mx = cnt;
      } else {
        for(int d = 1; d <= 6; d++) {
          if(f[0] != d) {
            int ff[64];
            for(int i = 0; i < 64; i++) ff[i] = f[i];
            switching(d, ff);
            trying(ff, did+1);
          }
        }
      }
    };
    trying(fld, 0);
    cout << mx << endl;
  }
  return 0;
}

Measured memory_bytes: 3140
n=int(input())
l=list(map(int,input().split()))
#print(l)
x=[]
for i in range(1,n):
    a = sum(l[0:i])
    b = sum(l[i:n])
#    print(a,b)
    x.append(abs(a-b))
#print(x)
print(min(x))

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main(){
	int w,h;
	char c;
	cin >> w >> h >> c;
	for(int y=0;y<h;y++){
		for(int x=0;x<w;x++){
			if( (y==0||y==h-1)&&(x==0||x==w-1) )printf("+");
			else if(y==0||y==h-1)printf("-");
			else if(x==0||x==w-1)printf("|");
			else if(x==(w-1)/2&&y==(h-1)/2)printf("%c",c);
			else printf(".");
			if(x==w-1)printf("\n");
		}
	}
	
	
	
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
int a[125252];

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,n)a[i]=s[i]=='g'?0:1;
  int g=0,p=0;
  int ans = 0;
  REP(i,n){
    if(p+1<=g){
      ans+=1-a[i];
      p++;
    }else{
      ans-=a[i];
      g++;
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

#define Mod 1000000007

int main(void){
	long long i,j,a=1,b=1;

  long long n,k;

  scanf("%lld%lld",&n,&k);

  long long c[2001][2001];
  for(i=0;i<=2000;i++){
    c[i][0]=1;
    c[i][i]=1;
  }

  for(i=2;i<=2000;i++){
    for(j=1;j<i;j++){
      c[i][j]=(c[i-1][j-1]+c[i-1][j])%Mod;
    }
  }

  for(i=1;i<=k;i++){
    if(i<=n-k+1){
      a=c[n-k+1][i];
      b=c[k-1][i-1];
      printf("%lld\n",(a*b)%Mod);
    }else{
      printf("0\n");
    }
  }

	return 0;
}


Measured memory_bytes: 31360
A=int(input())
B=int(input())
C=int(input())
X=int(input())
x=X/50

count=0

for a in range(A+1):
    for b in range(B+1):
        r=x-a*10-b*2
        if r>=0 and r<=C:
            count+=1
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int count=0;
   int len = s.length();
   for(int i=0; i<len; i++)
   {
       if(s[i]=='o'){count++;}
   }
   cout<<700+count*100;
}

Measured memory_bytes: 3624
fn main() {
    let (x, y, _a, _b, _c) = {
        let tmp = read_vec::<usize>();
        (tmp[0], tmp[1], tmp[2], tmp[3], tmp[4])
    };
    let mut ps: Vec<i64> = read_vec();
    let mut qs: Vec<i64> = read_vec();
    let mut rs: Vec<i64> = read_vec();

    ps.sort_by(|a, b| b.cmp(a));
    qs.sort_by(|a, b| b.cmp(a));

    let mut apples = {
        let mut reds: Vec<i64> = ps.into_iter().take(x).collect();
        let mut greens = qs.into_iter().take(y).collect();
        reds.append(&mut greens);
        reds.append(&mut rs);
        reds
    };

    apples.sort_by(|a, b| b.cmp(a));

    println!("{}", apples.iter().take(x + y).sum::<i64>());
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 13560
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<unordered_map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a;
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << 6 - a-b;
	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
ans = 0
for n in range(a, b+1):
    s = str(n)
    l = len(s)
    ok = True
    for i in range(l):
        if s[i] != s[l-1-i]:
            ok = False
            break
    if ok:
        ans += 1
print(ans)

Measured memory_bytes: 3060
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	char letter; 
	cin >> letter; 
	
	if('A' <= letter && letter <= 'Z')
		cout << "A" << endl; 
	else 
		cout << "a" << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to; T cost;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template <typename T>
vector<T> dijkstra(int s,vector<vector<edge<T>>> &G){
    auto n = G.size();
    vector<T> d(n, INF<T>);
    priority_queue<pair<T, int>,vector<pair<T, int>>,greater<>> Q;
    d[s] = 0;
    Q.emplace(0, s);
    while(!Q.empty()){
        T cost; int i;
        tie(cost, i) = Q.top(); Q.pop();
        if(d[i] < cost) continue;
        for (auto &&e : G[i]) {
            auto cost2 = cost + e.cost;
            if(d[e.to] <= cost2) continue;
            d[e.to] = cost2;
            Q.emplace(d[e.to], e.to);
        }
    }
    return d;
}

int main() {
    int n, m;
    while(cin >> n >> m, n){
        vector<vector<edge<int>>> G(n);
        for (int i = 0; i < m; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            G[a].emplace_back(b, c);
            G[b].emplace_back(a, c);
        }
        auto d1 = dijkstra(0, G), d2 = dijkstra(n-1, G);
        int ans = INF<int>;
        for (int i = 0; i < n; ++i) {
            for (auto &&j : G[i]) {
                for (auto &&k : G[i]) {
                    ans = min(ans, d1[j.to]+d2[k.to]);
                }
            }
        }
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

  int how[1000][1000]={},small[1000][1000]={};
  int a[1000],b[1000],n,m,i,j;

  cin>>n>>m;

  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<m;i++) cin>>b[i];
  for(i=0;i<m;i++)  how[0][i]=a[0]*b[i];
  small[0][0]=how[0][0];
  for(i=1;i<m;i++) small[0][i]=min(how[0][i],small[0][i-1]);

  for(i=1;i<n;i++){
    for(j=i;j<m;j++){
      how[i][j]=small[i-1][j-1]+a[i]*b[j];
      if(i==j) small[i][j]=how[i][j];
      if(i!=j) small[i][j]=min(how[i][j],small[i][j-1]);
    }
  }

  //  for(i=0;i<n;i++){
  //    for(j=0;j<m;j++) cout<<how[i][j]<<" ";
  //    cout<<endl;
  //  }
  vector <int> aaa;
  for(i=n-1;i<m;i++) aaa.push_back(small[n-1][i]);
  sort(aaa.begin(),aaa.end());

  cout<<aaa[0]<<endl;

  return 0;

}

Measured memory_bytes: 10892
/*******************************************
*    Template created by Danel Batyrbek    *
*    All rights reserved 2018 (lol)        *
********************************************/

#include <bits/stdc++.h>

#define fr first
#define sc second
#define mkp make_pair
#define lrb lower_bound
#define upb upper_bound
#define pb emplace_back
#define ins insert
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define speed_up ios_base :: sync_with_stdio(0);cin.tie(0)
#define skip continue
#define left(x) x << 1
#define rght(x) x << 1 | 1
#define forn(x, y, z) for(int x = y; x <= z; ++ x)
#define for1(x, y, z) for(int x = y; x >= z; -- x)
#define fname ""

using namespace std;

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

const int N = 2e5 + 10;
const int INF = 2e9 + 10;
const int mod = 1e9 + 7;
const ll LINF = 4e18 + 10;

string s;
int ans, k, now, prv, dp[301][301][301];
int main(){
#ifdef DANEL
	freopen("in", "r", stdin);
#else
	if(fname != ""){
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	}
#endif
	cin >> s;
	cin >> k;
	int n = s.size();
	for(int len = 1; len <= n; ++ len){
		for(int l = 0; l < n - len + 1; ++ l){
			int r = l + len - 1;
			if(len == 1){
				dp[l][r][0] = 1;
				skip;
			}
			for(int change = 0; change <= k; ++ change){
				dp[l][r][change] = dp[l + 1][r - 1][change];
				if(s[l] == s[r]){
					dp[l][r][change] = max(dp[l][r][change], dp[l + 1][r - 1][change] + 2);
				} else {
					dp[l][r][change] = max(dp[l][r][change], max(dp[l + 1][r][change], dp[l][r - 1][change]));
					if(change > 0) dp[l][r][change] = max(dp[l][r][change], dp[l + 1][r - 1][change - 1] + 2);
				}
			}
		}
	}
	forn(change, 0, k){
		ans = max(ans, dp[0][n - 1][change]);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 106752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;

int main() {
    cin >> n;
    int ans = inf;
    for (int i = 1; i <= n-1; i++) {
        int x = i, y = n-i;
        int cnt = 0;
        while (x) { cnt += x%10; x /= 10; }
        while (y) { cnt += y%10; y /= 10; }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m,f,b,a,c,d;
	scanf("%d %d %d",&m,&f,&b);
	if(m>b){
		a=0;
		printf("%d\n",a);
	}
	else if(m<b){
		c=b-m;
	if(f>=c){
		printf("%d\n",c);
	}
	else{
		printf("NA\n");
	}
	}
	return 0;
}


Measured memory_bytes: 2040
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> P(N);
  REP(i, N) cin >> P[i];

  vector<int> Q(N);
  REP(i, N) cin >> Q[i];

  vector<int> vec(N);
  REP(i, N) vec[i] = i+1;

  int cnt = 0;
  int A, B;
  do{
    bool flag = true;
    REP(i, N) if(P[i] != vec[i]) flag = false;
    if(flag) A = cnt;

    flag = true;
    REP(i, N) if(Q[i] != vec[i]) flag = false;
    if(flag) B = cnt;

    cnt++;
  }while(next_permutation(ALL(vec)));

  cout << abs(A-B) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAX=1<<17;
const int INF=0x3f3f3f3f;
int N,p[2*MAX],seg[2][2*MAX],invp[2*MAX],ans[2*MAX],anscnt;
int build(int *arr,int x){
    if(x>=MAX) {
        if(x-MAX<N/2) return arr[x];
        return INF;
    }
    return arr[x]=min(build(arr,x*2),build(arr,x*2+1));
}
int find_min(int *arr,int x,int y,int a,int b,int p){
    if(x<=a&&b<=y) return arr[p];
    if(x>=b||y<=a) return INF;
    return min(find_min(arr,x,y,a,(a+b)/2,2*p),find_min(arr,x,y,(a+b)/2,b,2*p+1));
}
struct range{
    int x,y;
    int r_min1,r_min2,r_idx1,r_idx2;
    void r_gen(int a,int b){
        x=a,y=b;
        if(a>=b) return;
        r_min1=find_min(seg[x%2],x/2,y/2,0,MAX,1);
        r_idx1=invp[r_min1];
        //printf("%d %d %d %d %d %d\n",x,y,r_min1,r_idx1,(r_idx1+1)/2,(y+1)/2);
        r_min2=find_min(seg[!(x%2)],(r_idx1+1)/2,(y+1)/2,0,MAX,1);
        r_idx2=invp[r_min2];
    }
    bool operator<(const range &a)const{
        return r_min1>a.r_min1;
    }
};
priority_queue<range> atl;
int main(){
    range tmp;
    scanf("%d",&N);
    for(int i=0;i<N;i++) scanf("%d",&p[i]),invp[p[i]]=i;
    for(int i=0;i<N;i++) seg[i%2][MAX+i/2]=p[i];
    build(seg[0],1),build(seg[1],1);
    tmp.r_gen(0,N);
    atl.push(tmp);
    while(!atl.empty()){
        range t=atl.top();
        atl.pop();
        if(t.y>t.x){
            ans[anscnt++]=t.r_min1;
            ans[anscnt++]=t.r_min2;
            tmp.r_gen(t.x,t.r_idx1); atl.push(tmp);
            tmp.r_gen(t.r_idx1+1,t.r_idx2); atl.push(tmp);
            tmp.r_gen(t.r_idx2+1,t.y); atl.push(tmp);
        }
    }
    for(int i=0;i<N;i++) printf("%d ",ans[i]);
    printf("\n");
}


Measured memory_bytes: 8944
s = input()
t = input()
n,m = len(s),len(t)
ans = 10**4
for i in range(n-m+1):
    c = 0
    for j in range(m):
        if t[j] != s[i+j]:
            c += 1
    ans = min(ans,c)
print(ans)

Measured memory_bytes: 9020
x = int(input())
a = 1
flag = True
while flag:
  upper = a**5-x
  b = a
  while True:
    if b**5 == upper:
      flag = False
      a -= 1
      break
    if b**5<upper:
      break
    b -= 1
  a += 1
print(a,b)

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

int main() {
	string S;
	cin >> S;

	int n = S.size();

	vector<int> digits(n);

	for(int i = 0; i < n; ++i) digits[i] = S[i] - '0';


	long long ans = 0;

	// 式は全部で2のn-1乗個ある
	for(int b = 0; b < (1 << n-1); ++b) {
		// まだansに足していない数
		long long num = digits[0];

		for(int i = 1; i < n; ++i) {
			if(b & (1 << i-1)) {
				// i桁目の前に'+'があった
				ans += num;
				num = 0;
			} else {
				// ない
				num *= 10;
			}
			num += digits[i];
		}

		// 右端の数
		ans += num;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
int main() {
  int n, m;
  ll f = 0, sum = 0;
  cin >> n >> m;
  double num[n];
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    sum = sum + num[i];
  }
  for (int j = 0; j < n; j++) {
    if ((double)(sum) / (4 * m) <= num[j]) {
      // cout << num[j];
      f++;
    }
  }
  if (f >= m) cout << "Yes";
  if (f < m) cout << "No";

  return 0;
}

// g++ lo.cpp
// ./a.exe
// g++ -o つくりたいふぁいるめい　もとのふぁいる.cpp
/*
for (int i = 0; i < n - 2; i++) {
  for (int j = i + 1; j < n - 1; j++) {
    int k = 2 * j - i;*/


Measured memory_bytes: 256
import sys
N = int(input())
scores = [0]*(N*100+1)
scores[0] = 1

for _ in range(N):
    a = int(input())
    for i in reversed(range(len(scores))):
        if scores[i]>0 and 0<i+a<=N*100:
            scores[i+a] += 1
            
for i in reversed(range(len(scores))):
    if scores[i] and i % 10 != 0:
        print(i)
        sys.exit()
            
print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
int main()
{
  using namespace std;
  int n;
  while(cin>>n){
    if(n==1){
      int num;
      cin>>num;
      cout<<num;
      continue;}
    vector<int> vec(n);
    for(int i=0;i<n-1;i++) cin>>vec[i];
    for(int i=1;i<n-1;i++) vec[n-1]+=min(vec[i-1],vec[i]);
    vec[n-1]+=vec[0];
    vec[n-1]+=vec[n-2];
    cout<<vec[n-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n;
  map<string, int> items;
  string s;
  cin >> n;
  REP(i, n) {
    cin >> s;
    items[s] = 1;
  }

  cout << items.size() << endl;

  return 0;
}


Measured memory_bytes: 19256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
#define MAXN 20
int n,p[MAXN+5],cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&p[i]);
	for(int i=2;i<n;i++)
	if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1]))
	cnt++;
	printf("%d",cnt);
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    vl a(n);
    ll sum[n+1];
    sum[0]=0;
    rep(i,n){
        cin>>a[i];
    }
    sort(all(a));
    rep(i,n){
        sum[i+1]=sum[i]+a[i];
    }
    if(n%2==0){
        ll ans=(sum[n]-sum[n/2]*2)*2;
        cout<<ans-a[n/2]+a[n/2-1]<<endl;
    }
    else{
        ll ans1=(sum[n]-sum[(n-1)/2+1]*2)*2;
        ans1+=a[(n-1)/2]+a[(n-1)/2-1];
        ll ans2=(sum[n]-sum[(n-1)/2]*2)*2;
        ans2-=a[(n-1)/2]+a[(n-1)/2+1];
        cout<<max(ans1,ans2)<<endl;
    }
}

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

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[0] != s[2] && s[2] == s[3]) 
    cout << "Yes" << endl;
  else if (s[0] == s[2] && s[0] != s[1] && s[1] == s[3]) 
    cout << "Yes" << endl;
  else if (s[0] == s[3] && s[0] != s[1] && s[1] == s[2]) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main()
{
    int n,m;
    cin >> n >> m;
    int penalty[n];
    int flag[n];
    for (int i=0;i<=n-1;i++)
    {
        flag[i]=0;
        penalty[i]=0;
    }

    for (int i=0;i<=m-1;i++)
    {
        int alpha;
        char beta[2];
        cin >> alpha >> beta[0] >> beta[1];

        if (beta[0]=='A')
        {
            // the answer is correct
            flag[alpha-1]=1;
        }
        else
        {
            // the answer is wrong
            if (flag[alpha-1]==0)
            {
                penalty[alpha-1]++;
            }
        }
    }

    int correct=0;
    int wrong=0;
    for (int i=0;i<=n-1;i++)
    {
        if (flag[i]==1)
        {
            correct++;
            wrong=wrong+penalty[i];
        }
    }

    cout << correct << " " << wrong << endl;
    return 0;
}

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

int main(){
    long long n, all, not_0, not_9, not_0_9;
    cin >> n;
    all = 1;
    not_0 = 1;
    not_0_9 = 1;
    const long long mod = 1000000007;
    
    for (int i=0; i<n; i++){
        all = all * 10 % mod;
        not_0 = not_0 * 9 % mod;
        not_0_9 = not_0_9 * 8 % mod;
    }
    not_9 = not_0;
    
    long long ans = (all - not_0 - not_9 + not_0_9)%mod;
    ans = (ans + mod) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n + 1);
    vector<int> ll(n + 1);
    vector<int> rr(n + 1);
    FOR(i, 0, n) {
        if(s[i] == '<') {
            ll[i + 1] = ll[i] + 1;
        } else {
            ll[i + 1] = 0;
        }
    }
    for(int i = n - 1; i >= 0; i--) {
        if(s[i] == '>') {
            rr[i] = rr[i + 1] + 1;
        } else {
            rr[i] = 0;
        }
    }

    long long ans = 0;
    rep(i, n + 1) { ans += max(rr[i], ll[i]); }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6788
#include <stdio.h>
int main(void)
{
  int n, p, d1, d2, max, maxp;
  int i;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    max = 0; maxp = 0;
    for (i = 0; i < n; i++) {
      scanf("%d%d%d", &p, &d1, &d2);
      if (max < d1 + d2) {
	max = d1 + d2;
	maxp = p;
      }
    }
    printf("%d %d\n", maxp, max);
  }
  return 0;
}

    
      

Measured memory_bytes: 600
H, W, K = map(int, input().split())
s = [input() for i in range(H)]

n = [s[i].count('#') for i in range(H)]
ans = []
initial_row = H
k = 1
for i in range(H):
    if n[i] == 0:
        if i > initial_row:
            ans.append(ans[-1])
        else:
            ans.append([0] * W)
    else:
        if initial_row == H:
            initial_row = i
        row = []
        first_in_row = True
        for j in range(W):
            if s[i][j] == '.':
                row.append(k)
            else:
                if first_in_row:
                    first_in_row = False
                else:
                    k += 1
                row.append(k)
        ans.append(row)
        k += 1
for i in range(initial_row):
    ans[i] = ans[initial_row]

for i in range(H):
    print(' '.join([str(aij) for aij in ans[i]]))


Measured memory_bytes: 7284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll x = 1;
    rep(i, N){
        if(x < K){
            x *= 2;
        }else{
            x += K;
        }
    }

    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

#define INF 20000000
typedef struct Edge edge;

struct Edge{
  int src,dst,weight;
  Edge(int start,int end,int cost) :
	src(start),dst(end),weight(cost) {}
};

bool operator < (const edge &e,const edge &f){
  return (e.weight != f.weight) ? (e.weight > f.weight) : (e.src != f.src) ? (e.src < f.src) : (e.dst < f.dst);
}

typedef vector<edge> Edges;

vector<int> dijkstra(Edges,int);

int main(int argc,char* argv[]){
  int n,v,k,dst,weight;
  Edges es;
  vector<int> vec;

  cin >> n;
  for(int i = 0;i < n;i++){
	cin>> v >> k;
	vec.push_back(v);
	for(int j = 0;j < k;j++){
	  cin >> dst >> weight;
	  edge e(i,dst,weight);
	  es.push_back(e);
	}
  }

  vector<int> dist = dijkstra(es,n);

  for(int i = 0;i < n;i++)
	printf("%d %d\n",vec[i],dist[i]);
  return 0;
}

vector<int> dijkstra(Edges es,int n){
  vector<int> dist(n);
  priority_queue<edge> que;
  Edges l[n];
  dist.assign(n,INF);
  dist[0] = 0;

  for(int i = 0;i < (int)es.size();i++){
	edge e = es[i];
	l[e.src].push_back(e);
  }

  for(int i = 0;i < (int)l[0].size();i++)
	que.push(l[0][i]);

  while(!que.empty()){
	edge e = que.top();
	que.pop();
	if(dist[e.dst] > dist[e.src] + e.weight){
	  dist[e.dst] = dist[e.src] + e.weight;

	  for(int i = 0;i < (int)l[e.dst].size();i++)
		que.push(l[e.dst][i]);
	}
  }

  return dist;
}

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

const int L = 8;

void solve() {
	string a;
	cin >> a;
	int x = 0, y = 0;
	for (int i = 0; i < 3; ++i)	{
		x += a[i] == 'A';
		y += a[i] == 'B';
	}
	if (x == 1 or y == 1) cout << "Yes" << '\n';
	else cout << "No" << '\n';	
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	return 0;
}

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

typedef long long i64;
#define put(n) cout<<(n)<<"\n"
#define FOR(i,num,N) for(int(i)=(num);(i)<(N);(i)++)
#define RFOR(i,num,N) for(int (i)=(num);(i)>(N);(i)--)
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()

int main(){
    int ans  = 1e9;

    int D,G;
    cin>>D>>G;

    vector<int> P(D);
    vector<int> C(D);
    FOR(i,0,D) cin>>P[i]>>C[i];
    
    for(int bit=0;bit<(1<<D);++bit){
        int count = 0;
        int point = 0;
        for(int i=0;i<D;++i){
            if(bit & (1<<i)){
                count += P[i];
                point += P[i]*(i+1)*100 + C[i];
            }
        }
        for(int i = D-1;i >= 0;--i){
            int p = P[i];
            while(!(bit & (1<<i)) && p > 0 && point < G){
                ++count;
                --p;
                point += (i+1)*100;
            }
        }
        ans = min(ans,count);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  char s,str[1001],tmp[]="w kstnhmyr",temp[]="aiueo";
  int i,j,l,x,y;
  scanf("%s",str);
  l=strlen(str);
  for(i=0;i<l;i+=2){
    x=str[i]-'0';
    s=str[i+1];
    if(x==0&&s=='U')printf("nn");
    else {
      if(x!=1) printf("%c",tmp[x]);
      if(s=='T')y=0;
      else if(s=='L')y=1;
      else if(s=='U')y=2;
      else if(s=='R')y=3;
      else y=4;
      printf("%c",temp[y]);
    }
  }
  puts("");
  return 0;
}

Measured memory_bytes: 536
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-12;
const double INF = 1e12;


int main(){
	int n;
	stack<int>st;
	vector<int>res;
	while(cin>>n){
		if(n!=0)st.push(n);
		else{
			res.PB(st.top());
			st.pop();
		}
	}
	REP(i,SZ(res))cout<<res[i]<<endl;
	return 0;
}

Measured memory_bytes: 1220
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    long d=sc.nextLong();
    int count=0;
    for(int i=0;i<n;i++)
    {
    	long x=sc.nextLong();
    	long y=sc.nextLong();
    	long z=x*x+y*y;
    	double p=Math.sqrt(z);
    	if(p<=d)
    	{
    		count++;
    	}
    	
    }
    System.out.println(count);
  }

}

Measured memory_bytes: 59204
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n ,x=0 ,max=0;
	scanf("%d",&n);
	char s[n];
	for(int i=0 ;i<n;){
	 cin>>s[i];
	 if(s[i]=='I') {
	 	++x;
	 	++i;
	 	
	 }
	 else if(s[i] =='D'){
	 	--x;
     	++i;
	 }
	 if(x>max)
	 max=x;
	}
	printf("%d",max);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    string s;
    cin >>  s;
    rep(i,0,s.size()) cout << "x";
    cout << endl;
    return 0;
}

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

int main () {
  int N ;
  cin >> N ;
  vector<int> line(N) ;
  
  for(int i = 0 ; i < N ; i++ ) {
    cin >> line[i] ;
  }
  
  int ookii = 0 ;
  
  for(int i = 0 ; i < N ; i++ ) {
    ookii = max(ookii,line[i]) ;
  }
  
  int pre = 0 ;
  
  for(int i = 0 ; i < N ; i++ ) pre += line[i] ;
  
  if( pre - ookii <= ookii) cout << "No" << endl ;
  else cout << "Yes" << endl ;
}

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

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

	long long ans = 0;
	int MaxNum = 0;
	for (int i = 0; i < N; i++)
	{
		//MaxNumを使い回すことで計算を抑える
		MaxNum = max(MaxNum, A[i]);
		int Bi = MaxNum;
		ans += Bi - A[i];
	}

	cout << ans << endl;
}




Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからbまで
#define P(x) cout<<x<<endl  //変数xを改行付きで出力
#define INF 1000000007  //最大値兼MOD
typedef long long ll;
using namespace std;
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; }
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
./a.exe
*/
string s;
cin>>s;
if(s == "Sunny")P("Cloudy");
else if(s == "Rainy")P("Sunny");
else P("Rainy");
return 0;
}


Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int A,B;cin>>A>>B;
    cout << A*B << endl;
    return 0;
}

Measured memory_bytes: 3636