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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<pair<int, int>> q;

  for (int i = 0; i < N; i++) {
    int card_num;
    cin >> card_num;
    q.push(make_pair(card_num, 1));
  }
  for (int i = 0; i < M; i++) {
    int card_num, number_of_sheet;
    cin >> number_of_sheet >> card_num;
    q.push(make_pair(card_num, number_of_sheet));
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    auto biggest_pair = q.top();
    q.pop();
    ans += biggest_pair.first;
    if (biggest_pair.second > 1) {
      biggest_pair.second--;
      q.push(biggest_pair);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2420
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const N = BigInt(input[0].split(" ")[0]);
    const K = BigInt(input[0].split(" ")[1]);
    if(N%K == 0){
        console.log(0)
        return
    } 

    let tmp = N % K
    if(Number(tmp) < Math.abs(Number(K-tmp))) console.log(Number(tmp))
    else console.log(Math.abs(Number(K-tmp)))

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29408
import java.util.*;

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

    public static int sumDigits(int n) {
        int res = 0;
        while (n > 0) {
            res += n % 10;
            n /= 10;
        }
        return res;
    }
}

Measured memory_bytes: 23764
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
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)]
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
for i in range(100):
    for j in range(100):
        if 4*i+7*j==n:
            print("Yes")
            sys.exit()
print("No")
    

Measured memory_bytes: 3440
"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);
const A = input[1].split(" ").map((val) => parseInt(val, 10));

let ans = 0;
let minuses = 0;

for (let i = 0; i < N; i++) {
  if (A[i] < 0) {
    minuses++;
    ans -= A[i];
  } else {
    ans += A[i];
  }
}


if (minuses % 2 === 1) {
  const minus = A.sort((a, b) => Math.abs(a) - Math.abs(b))[0];

  ans -= Math.abs(minus) * 2;
}

console.log(ans);


Measured memory_bytes: 29964
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const ll MOD = 1e9 + 7;

map<ll,ll> DP;

ll solve(ll x){
	if(DP.count(x)) return DP[x];

	ll ans = 0;
	
	if(x & 1){
		ans = (2*solve(x/2) + solve(x/2-1)) % MOD;
	}
	else ans = (2*solve(x/2-1) + solve(x/2)) % MOD;

	return DP[x] = ans;
}

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

	ll N;
	cin >> N;

	DP[0] = 1;
	DP[1] = 2;
	DP[2] = 4;

	cout << solve(N) << endl;

	return 0;
}


Measured memory_bytes: 3664
n = int(input())

xy = [list(map(int,input().split())) for _ in range(n)]

# print(xy)

import itertools
import numpy as np

def calc_distance(z1,z2):
    v1 = np.array(z1)
    v2 = np.array(z2)
    d = np.linalg.norm(v1-v2,2)
    return d


table = np.zeros((n,n))
for i in range(n):
    for j in range(n):
        if i==j:
            pass
        else:
            z1 = xy[i]
            z2 = xy[j]
            table[i,j] = calc_distance(z1,z2)
        
    
# print(table)

wa = 0
count = 0
for i in itertools.permutations(range(1,n+1)):
    # print(i)
    count += 1
    for j in range(len(i)-1):
        d = table[i[j]-1,i[j+1]-1]
        # print(d)
        wa += d

ans = wa/count
# print(wa)
# print(count)
print(ans)

Measured memory_bytes: 12388
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: int, B: int, C: int):
    if len(set([A,B,C])) == 2:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n, m, s1, s2, t;
    cin >> n >> s1 >> m >> s2 >> t;
    if (s1<=s2)
        cout << "NO" << endl;
    else
    {
        long long p=abs(n-m);
        long long s=s1-s2;
        long long c=p/s;
        if (p%s!=0)
            c+=1;
        if (c>t)
            cout << "NO" << endl;
        else
            cout << "YES" << endl;
    }
}





Measured memory_bytes: 3632
while True:
    n = int(input())
    if n==0: break
    edge = 0
    sq = 0
    past = []

    for i in range(n):
        nxt = int(input())
        if i==0:
            edge = nxt

        if i%2 == 0:
            if nxt == edge:
                sq += 1
            else:
                edge = nxt
                past.append(sq)
                sq = 1
        else:
            if nxt == edge:
                sq += 1
            else:
                edge = nxt
                sq += 1
                if len(past) != 0:
                    sq += past.pop()
    past.append(sq)

    answer = 0
    for i in range(len(past)):
        if edge == 0:
            answer += past[-i-1]
        edge = 1 - edge

    print(answer)

Measured memory_bytes: 7580
H, W = map(int, input().split())
G = []
mod = 10**9+7
for _ in range(H):
    G.extend([1 if a == '#' else 0 for a in input().strip()])
dp = [0]*(H*W)
for i in range(W):
    if G[i]:
        break
    dp[i] = 1

for i in range(W, H*W):
    if not G[i]:
        if i % W:
            dp[i] = (dp[i-1] + dp[i-W]) % mod
        else:
            dp[i] = dp[i-W]

print(dp[-1])

Measured memory_bytes: 99584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
 
 
int main() {
   
   ll n,m,w;
   cin>>n>>m>>w;
    if(n>m){m=n;}
    ll temp=w/m;
    if(w%m>0)
    {
        temp++;
    }
    cout<<temp;
   
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;

int main(){
    double a,b;
    cin >> a >> b;
    cout << int(a/b) _ int(a)%int(b) << " ";
    printf("%.5f\n", a/b);
    // cout _ showpoint << a/b << "\n";

  return 0;
}





Measured memory_bytes: 3296
#include<iostream>
#include<cmath>
#define INF 1000000
#define N 9
using namespace std;

int d[N][N];
int ans[N];
//初期化
void init(){
  for(int i=0;i<N;i++){
      ans[i]=0;
    for(int j=0;j<N;j++){
      if(i==j) d[i][i]=0;
      else d[i][j]=INF;
    }
  }
}
void solve(int n){
  init();
  int a,b,t;
  //値代入
  for(int i=0;i<n;i++){
    cin>>a>>b>>t;
    d[a][b]=d[b][a]=t; //無向辺
  }
  //ワーシャルフロイド
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(d[i][j]==INF) continue;
      ans[i]+=d[i][j]; //距離の累積和
    }
  }
  int answer=INF,town;
  for(int i=0;i<N;i++){
    if(ans[i]!=0&&answer>ans[i]){
      answer=ans[i]; town=i;
    }
  }
  cout<<town<<" "<<answer<<"\n";

}
int main(){
  int n;
  cin>>n;
  while(n!=0){solve(n);cin>>n;}

}



Measured memory_bytes: 3080
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    char A[10],B[10];
    cin>>A>>B;
    if(A[0]==B[2]&&A[1]==B[1]&&A[2]==B[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}//C[1][1]==C[2][3]&&C[1][2]==C[2][2]&&C[1][3]==C[2][1]

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

//-------------------------------------------------------------------\\

int main()
{
    char c; cin>>c;
    if(c>='A' and c<='Z') cout<<'A';
    else cout<<'a';
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()

int main() {
 ll A,B,m;
  cin>>A>>B>>m;
  vector<ll> a(A); vector<ll> b(B); vector<ll> discount(m);
rep(i,A) cin>>a[i];
rep(i,B) cin>>b[i];
 ll x,y,c;
rep(i,m) {
  cin>>x>>y>>c;
  discount[i]+=a[x-1]+b[y-1]-c;
}
sort(all(a));
sort(all(b));
ll ans1=a[0]+b[0];
ll ans2=200000;
  rep(i,m){
    if(discount[i]<ans2) ans2=discount[i];
  }
cout<<min(ans1,ans2)<<endl;    
 return 0; 
}


Measured memory_bytes: 2560
def dsf(i,sum,count,nokori):
    global ans
    # 階層が最下層になった時
    if i == d:
        #sumは絶対答えではない
        if sum < g:
            use = max(nokori)
            n = min(pc[use - 1][0],-(-(g - sum) // (100 * use)))
            count += n
            sum += n * use * 100



        # sumは答えになる可能性あり
        if sum >= g:
            ans = min(ans,count)
    else:
        #問題を解かないパターン
        dsf(i+1,sum,count,nokori)
        #問題を解くパターン(階層、合計+最大のボーナス、現在の合計の数+最大の数、残りの問題を管理)
        dsf(i + 1,sum + pc[i][0] * (i + 1) * 100 + pc[i][1],count + pc[i][0],nokori - {i + 1})
# 解く問題ととかない問題
d,g = map(int,input().split())
pc = [list(map(int,input().split())) for i in range(d)]
ans = float('inf')

#階層、合計、現在の合計の数、残りの問題を管理
dsf(0,0,0,set(range(1,d + 1)))
print(ans)

Measured memory_bytes: 9120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int fir[26],las[26],n,i,j,tmp,ans=-INF;
	string s;
	fill(fir,fir+26,INF);
	fill(las,las+26,-INF);
	cin >> n;
	cin >> s;
	for(i=0; i<n; ++i){
		fir[s[i]-'a'] = min(fir[s[i]-'a'],i);
		las[s[i]-'a'] = max(las[s[i]-'a'],i);
	}
	for(i=1; i<n; ++i){
		tmp = 0;
		for(j=0; j<26; ++j){
			if(fir[j]<i && las[j]>=i){
				++tmp;
			}
		}
		ans = max(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

r, g, b, n = map(int, input().split())



cnt = 0
for i in range(int(n/r) + 1):
    for j in range(int((n-r*i)/g) + 1):

        if (n - (r*i + g*j))%b==0 and n - (r*i + g*j) >= 0:
            cnt += 1
print(cnt)

Measured memory_bytes: 40556
// È¥°É£¡Æ¤¿¨Çð! °ÑAC´ø»ØÀ´£¡
//      ¤Ø¡¡¡¡¡¡¡¡¡¡£¯|
// ¡¡¡¡/£Ü7¡¡¡¡¡¡ ¡Ï£ß/
// ¡¡ /¡¡©¦¡¡¡¡ £¯¡¡£¯								AC		AC		AC		AC
//    ©¦¡¡Z £ß,£¼¡¡£¯¡¡¡¡ /`©c						AC		AC		AC		AC
//    ©¦¡¡¡¡¡¡¡¡¡¡©c¡¡¡¡ /¡¡¡¡¡µ					AC		AC		AC		AC
// ¡¡Y¡¡¡¡¡¡¡¡¡¡`¡¡ /¡¡¡¡/  /						AC		AC		AC		AC
// ¡¡Øé¡ñ¡¡.¡¡¡ñ¡¡¡¡¡´¡¡/¡¡/						AC		AC		AC		AC
// ¡¡()¡¡ ¤Ø¡¡¡¡¡¡¡¡|¡¡£Ü¡´							AC		AC		AC		AC
// ¡¡¡¡>- ._¡¡ ¥£¡¡ ©¦ £¯£¯							AC		AC		AC		AC
// ¡¡ / ¤Ø¡¡¡¡ /¡¡/£¼| £Ü£Ü							AC		AC		AC		AC
// ¡¡ ©c_/¡¡¡¡(_£¯¡¡ ©¦£¯£¯							AC		AC		AC		AC
// ¡¡¡¡ 7¡¡¡¡¡¡¡¡¡¡¡¡¡¡|£¯							AC		AC		AC		AC
// ¡¡¡¡ £¾¨Dr£þ£þ`-¨D£ß/							AC		AC		AC		AC
//**************************************Accepted*****************************************//

#include<bits/stdc++.h>

#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define Unique(x) x.erase(unique(all(x)),x.end());

using namespace std;

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

const int Days[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};

inline int read()
{
	#define gc getchar
	int ans=0;
	bool f=1;
	char ch=gc();
	
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	
	while(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
	
	return f?ans:-ans;
	
	#undef gc
}

typedef long long ll;

int L[200010],R[200010];
int n,k,c;
char s[200010]; 
bool ans[200010];

int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	
	cin>>n>>k>>c;c++;
	cin>>(s+1);
	
	L[0]=1-c;for(int i=1;i<=k;i++){L[i]=L[i-1]+c;while(s[L[i]]=='x')L[i]++;}
	R[k+1]=c+n;for(int i=k;i>=1;i--){R[i]=R[i+1]-c;while(s[R[i]]=='x')R[i]--;}
	
	int p=0ll;bool flag=0;
	for(int i=1;i<=k;i++){if(L[i]==R[i])flag=ans[L[i]];p=max(p,L[i]-c);while(p+1<R[i]+c)ans[++p]=1;if(L[i]==R[i])ans[L[i]]=flag;}
	for(int i=1;i<=n;i++)if(!ans[i]&&s[i]=='o')cout<<i<<endl;
	
	//printf("Time used = %.12f",(double)(clock())/CLOCKS_PER_SEC);
	return 0;
}

/*  GOD BLESS  */


Measured memory_bytes: 3456
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main()
{
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int ans = min(B,D) - max(A,C);
    if(ans <= 0)
        cout << 0 << endl;
    else
        cout << ans << endl;

    return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const ll inf = 3e18 + 5;

const int MAXN = 1 << 19;
int N = 400000;
int seg[2 * MAXN], A[MAXN];
typedef vector<vi> vvi;

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

    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int p = 0;
    int a[] = {0, 0, 0};
    while(a[p]<s[p].size()){
        a[p]++;
        p=s[p][a[p]-1]-'a';
    }
    cout << char(p+'A');
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<map>
#include<list>
#include<vector>
#include<unordered_map>
using namespace std;

signed main() {
	int a, b, c; cin >> a >> b >> c;
	cout << min({ a + b, b + c, a + c }) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
vector<int> A;
int ct = 0;

void func(int num,bool pm){
    if(num == N){ ct += pm; return; }                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
    
    func(num + 1, pm || ((A[num] + 1) % 2 == 0));
    func(num + 1, pm || ((A[num]) % 2 == 0));
    func(num + 1, pm || ((A[num] - 1) % 2 == 0));
}


int main(){
    cin >> N;
    A.assign(N,int());
    rep(i,N) cin >> A[i];
    func(0,0);
    pr(ct);
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d[] = new int[n];
		for (int i = 0; i < n; i++)
			d[i] = scan.nextInt();

		scan.close();
		int s = 0;
		for (int a = 0; a < n; a++) {
			for (int b = a + 1; b < n; b++) {
				s = s + d[a] * d[b];
			}
		}
		System.out.print(s);
	}
}

Measured memory_bytes: 21844
def dfs(i,Str,res):
    if i==3:
        if res == 7:
            print(Str+"=7")
            exit()
        return

    dfs(i+1,Str+'+'+S[i+1],res+int(S[i+1]))
    dfs(i+1,Str+'-'+S[i+1],res-int(S[i+1]))

S=input()
dfs(0,S[0],int(S[0]))

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

using namespace std;

typedef long long ll;

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

	int n, m;
	cin >> n >> m;

	int l = 1;
	int r = (m + 1) / 2 * 2;
	rep(i, (m + 1) / 2){
		cout << l << " " << r << "\n";
		l++; r--;
	}
	
	l = (m + 1) / 2 * 2 + 1;
	r = 2 * m + 1;
	rep(i, m / 2){
		cout << l << " " << r << "\n";
		l++; r--;
	}

}


Measured memory_bytes: 3644
/* 
 * File:   main.c
 * Author: s1252005
 *
 * Created on July 27, 2018, 12:09 PM
 */

#include <stdio.h>
#include <stdlib.h> 
int matrix[8][8];  
int coldf[8], rowdf[8];
int dpos[15],dneg[15];
void recursive(int i);
void printboard();
int main(int argc, char** argv) {
   

    int number;
    scanf("%d", &number);
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            matrix[i][j]=0;
        }
    }
    for(int i=0;i<8;i++)
    {
        coldf[i]=0;
        rowdf[i]=0;
    }
    for(int i=0;i<15;i++)
    {
        dpos[i] = 0;
        dneg[i] = 0;
    }
    int row ,col;
    for(int i=0;i<number;i++)
    {
        scanf("%d %d",&row,&col);
        matrix[row][col] =1;
    }
     recursive(0);

    return (EXIT_SUCCESS);
}


void recursive(int i)
{
  int j;

  if(i == 8)
  {
    printboard();
    return;
  }

  for(j=0;j<8;j++){
    if(coldf[j]==1 || dpos[i+j]==1|| dneg[i-j+7]==1)
        continue;
    rowdf[i] =j;
    coldf[j] = dpos[i+j] = dneg[i-j+7] = 1;
    recursive(i+1);
    rowdf[i] = coldf[j] = dpos[i+j] = dneg[i-j+7] = 0;
  }
}


void printboard()
{
  int i,j;

  for(i=0;i<8;i++)
    for(j=0;j<8;j++)
      if(matrix[i][j] == 1){
	if(rowdf[i] != j)
            return;
      }
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      if(rowdf[i] == j)
          printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2108
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"

const ll MOD = 1000000007;

ll f[1000006];

ll ncr(ll n, ll r){
    if(n < r) return 0;
    ll den = (f[n - r] * f[r]) % MOD;
    return (f[n] * power(den, MOD - 2)) % MOD;
}
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    f[0] = f[1] = 1;
    repp(i, 2, 1000000) f[i] = (f[i - 1] * i) % MOD;

    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for(auto &i : v) cin >> i;
    sort(all(v));

    ll res = 0;
    rep(i, 0, n){
        res += ncr(i, k - 1) * v[i] + MOD;
        res -= ncr(n - i - 1, k - 1) * v[i] + MOD;
        res = (res + MOD) % MOD;
    }

    cout << res;
}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

using namespace std;

int x[666][666];
int main()
{
	int n, d[2];
	cin >> n >> d[0] >> d[1];
	for (int i = 0; i < 2; i++) {
		int e = 0;
		for (; !(d[i] & 1); e++)
			d[i] >>= 1;
		for (int j = 0; j < n * 2; j++) {
			for (int k = 0; k < n * 2; k++)
				if ((j + k - e % 2 * k) >> e / 2 & 1)
					x[j][k] |= i + 1;
		}
	}
	int c[4] = {};
	for (int j = 0; j < n * 2; j++)
		for (int k = 0; k < n * 2; k++)
			c[x[j][k]]++;
	int m = 0;
	for (int i = 0; i < 4; i++)
		if (c[i] > c[m]) m = i;
	int i = 0;
	for (int j = 0; j < n * 2; j++) {
		for (int k = 0; k < n * 2; k++) {
			if (x[j][k] != m)
				continue;
			if (i++ >= n * n)
				goto pnz;
			cout << j << ' ' << k << '\n';
		}
	}
pnz:
	cout << flush;
	return 0;
}


Measured memory_bytes: 2432
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 998244353;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

int inv[301010];
int ncr[301010];

int main() {

	//freopen("input.txt", "r", stdin);

	int n, a, b; ll k;
	ni(n); nii(a, b); scanf("%lld", &k);
	inv[1] = 1;
	for (int i = 2; i <= n; i++)inv[i] = mul(mod - mod / i, inv[mod%i]);
	ncr[0] = 1;
	for (int i = 1; i <= n; i++) {
		ncr[i] = mul(ncr[i-1], inv[i]);
		ncr[i] = mul(ncr[i], n - i + 1);
	}
	int ans = 0;
	for (int x = 0; x <= n; x++) {
		if (k < 1LL*a*x)break;
		else if ((k - 1LL*a*x) % b != 0)continue;
		ll y = (k - 1LL*a*x) / b;
		if (y > n)continue;
		ans += mul(ncr[x], ncr[y]);
		if (ans >= mod)ans -= mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
// #define mp make_pair
#define endl '\n'
 
int main() {
    int n;
    cin >> n;
    vl a(n+1);
    vl b(n);
    rep(i,n+1){
        cin >> a[i];
    }
    rep(i,n){
        cin >> b[i];
    }

    vl c(n+1);
    rep(i,n+1){
        c[i] = 0;
    }

    rrep(i,n){
        if(b[i] <= a[i+1]){
            c[i+1] += b[i];
        }
        else{
            c[i+1] += a[i+1];
            b[i] -= a[i+1];
            if(a[i] >= b[i]){
                c[i] += b[i];
                a[i] -= b[i];
            }
            else{
                c[i] += a[i];
                a[i] = 0;
            }
        }
    }
    
    ll sum = 0;
    rep(i,n+1){
        sum += c[i];
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int M, D;
  cin >> M >> D;
  
  int count = 0;
  for( int i = 1; i <= M; i++ ){
    for( int j = 10; j <= D; j++ ){
      int A = j%10;
      int B = j/10;
      if( i == A*B && A >= 2 && B >= 2 ){
        count++;
      }
    }
  }
  cout << count << endl;
  
  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;

int main(void){
  string S;cin >> S;
  ll K; cin >> K;
  K--;
  int i;REP(i,S.length()){
    if(S[i]=='1'&&i<K)continue;
    cout << S[i] << endl;
    break;
  }
  return 0;
}


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

int main() {
    uint64_t n;
    cin >> n;
    vector<uint64_t > result;
    for (uint64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            result.push_back(i);
            if (i != 1 && i * i != n) {
                result.push_back(n/i);
            }
        }
    }
    result.push_back(n);
    sort(result.begin(), result.end());
    auto s = result.size();
    if (s % 2 == 1) {
        cout << (result[s/2] - 1) + (result[s/2] - 1) << endl;
    }
    else {
        cout << (result[s/2-1] - 1) + (result[s/2] - 1) << endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
using namespace std;
int a[25];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	for(int i=2;i<n;i++)
		if((a[i-1]>a[i]&&a[i+1]<a[i])||(a[i-1]<a[i]&&a[i+1]>a[i]))
			cnt++;
	printf("%d\n",cnt);
	return 0;
}

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

struct data{
    int a, b, c;
    data(int _a, int _b, int _c) : a(_a), b(_b), c(_c) {}
};

int main(){
    int a, b, c;
    while(cin >> a >> b >> c){
        if(a + b + c == 0)  break;

        int da[a], db[b], dc[c];
        for(int i = 0; i < a; i++) da[i] = 0;
        for(int i = 0; i < b; i++) db[i] = 0;
        for(int i = 0; i < c; i++) dc[i] = 0;

        vector<data> fault;
        
        int n;
        cin >> n;

        while(n-- > 0){
            int i, j, k, r;
            cin >> i >> j >> k >> r;
            if(r == 0)  fault.push_back(data(i,j,k));
            else        da[i-1] = db[j-a-1] = dc[k-a-b-1] = 1;
        }

        bool update = true;
        while(update){
            update = false;
            for(data d : fault){
                if(da[d.a-1] > 1 || db[d.b-a-1] > 1 || dc[d.c-a-b-1] > 1)
                   continue;
                if(da[d.a-1] + db[d.b-a-1] + dc[d.c-a-b-1] == 2){
                    update = true;
                    if(da[d.a-1] == 1 && db[d.b-a-1] == 1)         dc[d.c-a-b-1] = 2;
                    else if(db[d.b-a-1] == 1 && dc[d.c-a-b-1] == 1)    da[d.a-1] = 2;
                    else if(dc[d.c-a-b-1] == 1 && da[d.a-1] == 1)    db[d.b-a-1] = 2;
                }
            }
        }

        for(int i = 0; i < a; i++)  cout << 2-da[i] << endl;
        for(int i = 0; i < b; i++)  cout << 2-db[i] << endl;
        for(int i = 0; i < c; i++)  cout << 2-dc[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    string S,T;
    cin >> S >> T;
    int cnt = 0;
    for(int i=0 ;i<3;i++){
        if(S[i] == T[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

int main(){
  int x;
  cin >> x;
  int max = 1;
  for(int i = 2; i < sqrt(x)+1; i++){
    int temp = i;
    for(int p = 2;; p++){
      temp = temp * i;
      if(temp > x){
        temp = temp / i;
        break;
      }
    }
    if(temp>max){
      max = temp;
    }
  }
  cout << max << endl;
  return 0;
}


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

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

    int l = 0, r = N;
    string sl, sr;

    cout << 0 << endl;
    cin >> sl;

    if(sl == "Vacant") return 0;
    sr = sl;
    for(int i=1; i<20; i++){
        int m = (r + l) / 2;
        string sm;

        cout << m << endl;
        cin >> sm;

        if(sm == "Vacant") return 0;
        if( ((m-l)%2==0 && sm!=sl) || ((m-l)%2==1 && sm==sl) ){
            r = m;
            sr = sm;
        }else{
            l = m;
            sl = sm;
        }
    }
    return 0;
}


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

const int N=2e5+5;
vector<int> t[N],t2[N];
int dep[N],dep2[N];
int fa[N],fa2[N];
int n,A,B;
typedef pair<int,int> edge;
edge e[N];
inline void dfs2(int x,int pre){
	fa2[x]=pre;
	for(size_t i=0;i<t2[x].size();i++){
		int v=t2[x][i];if(v==pre)continue;
		dep2[v]=dep2[x]+1;
		dfs2(v,x);
	}
}

bool mark[N];
bool endless;
int ans=0;
inline void dfs(int x,int pre){
	if(dep[x]<dep2[x]){
		if(mark[x]) endless=1;
		ans=max(ans,2*dep2[x]);
	}
	else return;
	for(size_t i=0;i< t[x].size();i++){
		int v=t[x][i];if(v==pre)continue;
		dep[v]=dep[x]+1;
		dfs(v,x);
	}
}

int main()
{
	scanf("%d%d%d",&n,&A,&B);
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		t[u].push_back(v),t[v].push_back(u);
		e[i]=edge(u,v);
	}
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		t2[u].push_back(v),t2[v].push_back(u);
	}
	dfs2(B,0);
	for(int i=1;i<n;i++){
		int u=e[i].first,v=e[i].second;
//		cout<<u<<' '<<v<<" "<<dep2[u]<<" "<<dep2[v]<<" "<<fa2[u]<<endl;
		if((fa2[fa2[u]]==v)||(fa2[fa2[v]]==u)||(fa2[u]==fa2[v]&&fa2[u]!=0)||fa2[u]==v||fa2[v]==u){
			continue;
		}else{
//			cout<<"why"<<endl;
			mark[u]=mark[v]=1;
		}
	}
	dfs(A,0);
	printf("%d\n",endless?-1:ans);
}

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

int main() 
{
  int a, b;
  cin >> a >> b;
  int count = 0;
  for(int i = a; i <= b; i++)
  {
    int x = i / 1000;
    int y = i % 100;
    int z = (y % 10 * 10) + (y / 10);
    if(x == z)
    {
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define NL endl
#define pi 2.0*acos(0.0)
#define INTM 1e18
#define mod 1e9+7
#define FOR(i,j,n)    for(ull i=j;i<n;i++)
#define RFOR(i,j,n)    for(ll i=j;i>=n;i--)

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;

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

    ll t,n;
    cin>>t>>n;
    if(n>=t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<vector<int>> dishes(n, vector<int>(2));
    for (int i = 0; i < n; i++)cin >> dishes[i][0] >> dishes[i][1];
    sort(dishes.begin(), dishes.end());

    vector<int> dp(6010, -1145141919);
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = t - 1; j >= 0; j--) {
            dp[j + dishes[i][0]] = max(dp[j + dishes[i][0]], dp[j] + dishes[i][1]);
        }
    }

    int ret = 0;
    for (auto x:dp)ret = max(ret, x);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Linq;
using static System.Math;

class D
{
	static void Main() => Console.WriteLine(string.Join("\n", new int[int.Parse(Console.ReadLine())].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Select(x => Find(x[0], x[1]))));

	static double Find(long a, long b)
	{
		for (long r = 0, t, c = 2 * (long)Floor(Sqrt(a * b)); ; r = t, c++)
			if ((t = Try(a, b, c)) < r) return r;
	}

	// l: x + y = c
	static long Try(long a, long b, long c) => c % 2 == 0 ?
		c * c / 4 <= a * b ? c - 2 - (a != b && c * c / 4 == a * b ? 1 : 0) : -1 :
		c / 2 * (c / 2 + 1) < a * b ? c - 2 : -1;
}


Measured memory_bytes: 11348
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val sc = new java.util.Scanner(System.in)

  val N, Q = sc.nextInt()
  var edges: Array[ArrayBuffer[Int]] = Array.fill(N+1)(ArrayBuffer())
  var counters: Array[Long] = Array.fill(N+1)(0)

  (1 to N-1).foreach { _ =>
    val a, b = sc.nextInt()
    edges(a).append(b)
    edges(b).append(a)
  }

  (1 to Q).foreach{ q =>
    val p, x = sc.nextInt()
    counters(p) += x
  }

  def dfs(root: Int): Unit = {
    val stack = new scala.collection.mutable.Stack[Int]
    var visited = Array.fill(N+1)(false)
    var count = counters(root)
    visited(root) = true
    stack.push(root)
    while(!stack.isEmpty) {
      val v = stack.pop()
      count = counters(v)

      val children = edges(v)
      children.foreach{ c =>
        if(visited(c) == false) {
          visited(c) = true
          counters(c) += count
          stack.push(c)
        }
      }
    }
  }
  dfs(1)

  print(counters.drop(1).mkString(" "))
}

Measured memory_bytes: 152048
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	
      	if(b-a == c-b){
        	System.out.println("YES");
        }else{
			System.out.println("NO");
        }
    }
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define lsb(x) ((x) & -(x))
using namespace std;

multiset <int> s;

int main()
{
	int n;
	cin >> n;
	vector <int> v(n);

	for (auto & i : v)
		cin >> i;

	sort(v.rbegin(), v.rend());

	int ans = 0;

	for (auto i : v) {
		bool ok = 0;
		for (long long p = 1; p <= 2000000000; p *= 2) {
			if (p >= i && s.find(p - i) != s.end()) {
				s.erase(s.find(p - i));
				ans++;
				ok = 1;
				break;
			}
		}
		if (!ok)
			s.insert(i);
	}

	cout << ans << '\n';

	return 0;
}


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

int main(){
	ll n;
	cin >> n;
	ll tmp = n;
	int s(0);
	while(tmp >= 1){
		s += tmp%10;
		tmp /= 10;
	}
	if(n % s == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
}

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

int main(){
  int N,count=0;
  string S;
  cin >> N >> S;
  for(int i=0;i<N-2;i++){
    if(S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n=gets.chomp.to_i
a1_arr=gets.chomp.split(" ").map(&:to_i)
a2_arr=gets.chomp.split(" ").map(&:to_i)

max = 0
n.times do |i|
  count = (a1_arr[0..i] + a2_arr[i..-1]).inject(&:+)
  max = count if count > max
end

puts max






Measured memory_bytes: 3836
#include <iostream>
#include <string.h>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,b,i;
    long long int pa,pb,t;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d%d",&a,&b);
        if(i==0)
        {
            pa=a;
            pb=b;
        }
        else
        {
            if(a>=pa&&b>=pb)
            {
                pa=a*1ll;
                pb=b*1ll;
            }
            else if(a<pa||b<pb)
            {
                if((pa/a)>(pb/b))
                {
                    if(pa%a==0)
                    {
                        t=pa/a;
                        pa=t*a*1ll;
                        pb=t*b*1ll;
                    }
                    else
                    {
                        t=pa/a;
                        pa=t*a*1ll+a;
                        pb=t*b*1ll+b;
                    }
                }
                else
                {
                    if(pb%b==0)
                    {
                        t=pb/b;
                        pa=t*a*1ll;
                        pb=t*b*1ll;
                    }
                    else
                    {
                        t=pb/b;
                        pa=t*a*1ll+a;
                        pb=t*b*1ll+b;
                    }
                }
            }

        }
    }
    printf("%lld",pa+pb);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<long long> A;
  for(int i=0; i<N; i++){
    long long in;
    cin >> in;
    A.push_back(in);
  }
  sort(A.begin(), A.end());
  vector<long long>::iterator it = A.begin();
  int ret = 0;
  while(it < A.end()){
    long long tmp = *it;
    int num = 0;
    while(*it == tmp && it < A.end()){
      it++;
      num++;
    }
    if(num < tmp){
      ret += num;
    } else {
      ret += num - tmp;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,K;
  cin >>N >>K;
  
  int sum=0;
  for(int i; i<N; i++){
    int x;
    cin >>x;
    
    int dis_a,dis_b;
    dis_a = x;
    dis_b = K-x;
    
    if(dis_a > dis_b){
      sum += dis_b*2;
    }
    else{
      sum += dis_a*2;
    }
  }
  cout << sum <<endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int N;
	double ans = 0;
	cin >> N;

	float x[11] = {};
	string u[11] = {};

	for(int i = 0; i < N; i++){
		cin >> x[i] >> u[i];

		if(u[i] == "JPY"){
			ans +=x[i];
		}
		else{
			ans += x[i] * 380000.0;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int seito[30];
	int i, j;
	int hozon[30] = {0};
	
	for (i = 0; i < 28; i++){
		scanf("%d", &seito[i]);
	}
	
	for (i = 1; i <= 30; i++){
		for (j = 0; j < 30; j++){
			if (i == seito[j]){
				hozon[seito[j] - 1]++;
			}
		}
	}
	
	for (i = 0; i < 30; i++){
		if (hozon[i] != 1){
			printf("%d\n", i + 1);
		}
	}
	
	return (0);
}

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

#define vi vector<int>
#define pb push_back

const int limit = 100010;
using edge = struct {
    int to;
    ll cost;
};
vector<edge> tree[limit]; 
ll costs[limit];


void dfs(int now,int past,ll cost){
    costs[now] = cost;
    for (auto &e : tree[now]){
        if(e.to == past)continue;
        dfs(e.to, now, e.cost+cost);
    }
}

int main() {
    int n;
    cin >> n;
    rep(i,n-1){
        int a, b, c;
        cin >> a >> b >> c;
        tree[a].pb({b,c});
        tree[b].pb({a,c});
    }
     int q,k;
     cin >> q >> k;

     dfs(k,0,0);
     rep(i,q){
         int x,y;
         cin >> x >> y;
         cout << costs[x]+costs[y] << endl;
     }
    return 0;
}

Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

void solve() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	while (k && a >= b) {
		b <<= 1;
		k--;
	}
	while (k && b >= c) {
		c <<= 1;
		k--;
	}
	if (a < b && b < c)
		cout << "Yes";
	else
		cout << "No";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << endl;
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
string s, t;
const int MAXN = 3010;
ll dp[MAXN][MAXN];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//memset(p, -1, sizeof(p));
	cin >> s >> t;
	int n = s.sz, m = t.sz;
	for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }
    string ans = "";
    while(n > 0 && m > 0) {
        if(s[n - 1] == t[m - 1]) ans += s[n - 1], n--, m--;
        else if(dp[n][m] == dp[n - 1][m]) n--;
        else m--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
long long hh(int n){
  if(n==1) return 0;
  return hh(n-1)+n-1;
}
int main(){
  int n;
  cin>>n;
  vector<string> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    sort(a[i].begin(),a[i].end());
    
  }
  sort(a.begin(),a.end());
  a.push_back("####");
  long long ans=0;
  int cut=1;
  for(int i=0;i<n;i++){
    if(a[i]==a[i+1]){
      cut++;
    }
    else if(a[i]!=a[i+1]){
      ans+=hh(cut);
      cut=1;

    }
  }
  cout<<ans<<endl;
}
         


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

bool isPrime(int n){
	for(int i = 2; i <= sqrt(n); ++i){
		if(n % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;

	vi primeTbl;
	for(int i = 2; i <= 55555; i++)
		if(isPrime(i) && i % 5 == 1) primeTbl.push_back(i);

	rep(i, n){
		cout << primeTbl[i];
		if(i != n-1) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256