akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>;
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
#include<cassert>
#include<deque>
using namespace std;
inline char find1(string a)
{
	return a[0]+'A'-'a';
}
int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	cout << find1(a) << find1(b) << find1(c);
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRT(v) sort(v.begin(),v.end())

typedef long long ll;
typedef tuple<int,int,bool> Tb;


int atcoder(){
    //入力
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    REP(i,n) cin >> a[i] >> b[i] >> c[i];
    int dp[110000][3];
    REP(i,3) dp[0][i] = 0;
    
    //処理
    for(int i=1; i<=n; ++i){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i-1];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i-1];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i-1];
    }

    //出力
    cout << max(max(dp[n][0],dp[n][1]),dp[n][2]) << ENT;
    return 0;
}

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


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		solve(sc,out);

		out.flush();
	}

	public static void solve(FastScanner sc, PrintWriter out) {
		String s = sc.nextLine();
		String[] split = s.split(" ");
		
		out.println(split[0].charAt(0) + "" + split[1].charAt(0) + "" + split[2].charAt(0));
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}

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

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }

    public Pair<V, K> swap() {
    	return new Pair<V, K>(getValue(), getKey());
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
vector<int>v;
int main()
{
    int n, sz=1;
    cin>>n;
    int x;
    cin>>x;
    v.pb(x);
    for(int i=1; i<n; i++)
    {
        //int x;
        cin>>x;
        if(x<=v[sz-1])
        {
            v.pb(x);
            sz++;
            continue;
        }
        int st=0, end=sz-1;
        while(st<end)
        {
            int mid=(st+end)/2;
            if(v[mid]>=x) st=mid+1;
            else end=mid;
        }
        v[st]=x;
    }
    cout<<v.size()<<endl;
    return 0;
}


Measured memory_bytes: 892
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))

#define N 1000000000//10の9乗
void swap(int *a, int *b)
{
  int temp;
  temp = *a;*a = *b;*b = temp;
}
int main(void)
{
  int M1,M2;
  int D1, D2;
  scanf("%d %d", &M1,&D1);
  scanf("%d %d", &M2,&D2);

  if (M1 != M2) {
    printf("1\n" );
  }else printf("0\n" );
  return 0;
}


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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int n, res = 0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i < 1e6; ++i){
        for(int j = 1; j < 1e6; ++j){
            if(i * j >= n) break;
            else ++res;
        }
    }
    cout << res;
    return 0;
}

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

int main(void)
{
    int n,p,cnt=0;
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> p;
        if(i!=p)
            cnt++;
    }
    if(cnt==0 || cnt==2)
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long N,X,P,Q;
vector<long long> A;

int main(){
  cin >> N >> X;
  A.assign(N+10,0);
  for (long long i=1;i<=N;i++)
    cin >> A[i];
  sort(&A[1],&A[N+1]);
  P=0;Q=0;
  for (long long i=1;i<=N;i++){
    if (Q+A[i]<=X){
      P++;Q+=A[i];
    }else {break;}
  }
  if (Q!=X && P==N)P--;
  cout << P << endl;
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=2e5+5;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	ll e=0ll,v=0ll;
	for(int i=0; i<n-1; i++){
		int u,v; cin >> u >> v;
		if(u>v)swap(u,v);
		e += ll(u)*(n-v+1);
	}
	for(int i=1; i<=n; i++){
		v += ll(i)*(i+1)/2ll;
	}
	cout << v-e << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;

    	for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i+j)%2 ==1) {
					cout << ".";
				}
				else {
					cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>

using namespace std;

int main(void){

    int n, k, q;

    cin >> n >> k >> q;

    vector<int> A(n);

    for(int i = 0;i < n;i++){
        A[i] = k - q;
    }

    for(int i = 0;i < q;i++){
        int x;
        cin >> x;

        A[x-1]++;
    }


    for(int i = 0;i < n;i++){
        if(A[i] <= 0){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
x, y, z, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

Q = []
Q.append([A[0]+B[0]+C[0], 0, 0, 0])
M = {(0, 0, 0):True}

def search():
    global Q
    q = Q.pop()
    a = q[1]
    b = q[2]
    c = q[3]
    if a+1 < x and (a+1, b, c) not in M:
        Q.append([A[a+1]+B[b]+C[c], a+1, b, c])
        M[(a+1, b, c)] = True
    if b+1 < y and (a, b+1, c) not in M:
        Q.append([A[a]+B[b+1]+C[c], a, b+1, c])
        M[(a, b+1, c)] = True
    if c+1 < z and (a, b, c+1) not in M:
        Q.append([A[a]+B[b]+C[c+1], a, b, c+1])
        M[(a, b, c+1)] = True
    Q.sort()
    return q[0]

for _ in range(k):
    print(search())

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

int main(){
  int n, m; cin >> n >> m;
  vector<priority_queue<int>> q(m);
  for (int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    if (a <= m){
      a--;
      q.at(a).push(b);
    }
  }
  priority_queue<pair<int, int>> Q;
  int64_t ans = 0;
  for (int i = 0; i < m; i++){
    if (q.at(i).size()){
      Q.push(make_pair(q.at(i).top(), i));
    }
    if (Q.size()){
      pair<int, int> p = Q.top();
      Q.pop();
      ans += p.first;
      int j = p.second;
      q.at(j).pop();
      if (q.at(j).size()){
        Q.push(make_pair(q.at(j).top(), j));
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Aug  2 21:13:28 JST 2020
 **/

signed main() {
    Int x;
    std::cin >> x;
    std::cout << (x >= 30 ? "Yes" : "No") << std::endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    
    int chash = 0;
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        int result = 0;
        int A,B = 0;
        cin >> A >> B;
        chash = T[A-1];
        T[A-1] = B;
        for (int i = 0; i < N; i++) {
            result += T[i];
        }
        T[A-1] = chash;
        cout << result << endl;
    }
}

Measured memory_bytes: 256
import bisect

n=int(input())
a=[int(i) for i in input().split()]
a.sort()
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
c.sort()
#print(n,a,b,c)

ans=0
for j in range(n):
    aa=bisect.bisect_left(a, b[j])
    bb=bisect.bisect_right(c, b[j])
    ans+=aa*(n-bb)

print(ans)

Measured memory_bytes: 23232
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		// N, P, Qの入力
		int N = sc.nextInt();
		int K = sc.nextInt();
		int Q = sc.nextInt();
		
		// 各自の得点を格納する配列
		int[] points = new int[N];
		
		// 各自に最初の持ち点を付与（あらかじめQを引いておく）
		Arrays.fill(points, K-Q);
		
		// 正解者にポイントを加算
		for (int i = 0; i < Q; i++) {
			points[sc.nextInt()-1]++;
		}
		
		// 結果を出力
		for (int i = 0; i < N; i++) {
			if (points[i] > 0)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}


Measured memory_bytes: 56924
number = str(input())[::-1]
remainderDictionary = {0: 1}
digitDictionary = {'1':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9}

sum = 0
x = 1
for i in number:
  x = (x * 10) % 2019
  sum = (sum + digitDictionary[i] * x) % 2019 
  remainderValue = remainderDictionary.get(sum,0) + 1
  remainderDictionary[sum] = remainderValue
     
ans = 0
for i in remainderDictionary:
  value = remainderDictionary[i]
  if value > 1:
    ans += value * (value - 1) // 2 # N C 2
print(ans)

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

def square(n):

  right = n
  left = 0

  while(right - left > 1):

    middle = (right + left) // 2

    if (middle ** 2) < n:
      left = middle 
    if (middle ** 2) > n:
      right = middle 
    if (middle ** 2) == n:
      break

  if middle**2 == n:
    return(middle)

  if middle**2 != n:
    return(left)

i = 0
j = 0
res = 0

for k in range(1, square(n) + 1):
  if n % k == 0:
    i = k
    j = n // k

res = i + j - 2
print(res)

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main(){
char a;
  cin>>a;
  if(a=='A')
    cout<<'T'<<endl;
  if(a=='T')
    cout<<'A'<<endl;
  if(a=='C')
    cout<<'G'<<endl;
  if(a=='G')
    cout<<'C'<<endl;
  return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;




int main() {
	

	int n;
	cin >> n;
	VI a(n);
	REP(i, n)cin >> a[i];
	int ans = 0;
	int h = a[0];
	int cnt = 0;
	FOR(i, 1, n) {
		if (a[i] <= h) {
			cnt++;
		}
		else cnt = 0;
		ans = max(ans, cnt);
		h = a[i];
	}
	ans = max(ans, cnt);
	cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,m;
int iomap[505][505];
vector<pair<int,int> > s,e;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>iomap[i][j];
	for(int i=0;i<n;i++)
		for(int j=0;j<m-1;j++)
		{
			if(iomap[i][j]%2==0)
				continue;
			--iomap[i][j];
			++iomap[i][j+1];
			s.push_back(make_pair(i+1,j+1));
			e.push_back(make_pair(i+1,j+2));
		}
	int j=m-1;
	for(int i=0;i<n-1;i++)
	{
		if(iomap[i][j]%2==0)
			continue;
		--iomap[i][j];
		++iomap[i+1][j];
		s.push_back(make_pair(i+1,j+1));
		e.push_back(make_pair(i+2,j+1));
	}
	cout<<s.size()<<endl;
	for(int i=0;i<s.size();i++)
		cout<<s[i].first<<' '<<s[i].second<<' '<<e[i].first<<' '<<e[i].second<<endl;
	return 0;
}

Measured memory_bytes: 5228
#include <stdio.h>
#include <stdbool.h>
#include <string.h>

#define CHK(ch) ((ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') ? true : false)

int main(void)
{
    char str[12]; scanf("%s", str);
    int len1 = 0, len2 = 0, n = strlen(str), i;
    bool pos = false;
    for(i = 0; i < n; ++i) {
        if(pos) {
            if(CHK(str[i])) { ++len1; }
            else { break; }
        }
        else {
            if(CHK(str[i])) { ++len1; pos = true; }
        }
    }
    
    if(i < n) {
        pos = false;
        for( ; i < n; ++i) {
            if(pos) {
                if(CHK(str[i])) { ++len2; }
                else { len1 = ((len1 < len2) ? len2 : len1 ); pos = false; len2 = 0;}
            }
            else {
                if(CHK(str[i])) { ++len2; pos = true; }
            }
        }
    }
    
    //printf("len1 : %d len2 : %d i : %d\n", len1, len2, i);
    printf("%d\n", (len1 < len2) ? len2 : len1);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;

int main() {
  IN(N); IN(M);

  vector<int> count(N, 0);
  REP(i, M) {
    IN(a); IN(b);
    ++count[a-1];
    ++count[b-1];
  }
  REP(i, N) {
    cout << count[i] << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
 using namespace std;
 
 int main(){
   int h, m, s;
   cin >> s;

   h = s / 3600; s %= 3600;
   m = s / 60; s %= 60;

   cout << h << ":" << m << ":" << s << endl;

   return 0;
 }


Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
#include <list>
#include <deque>
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; }
// const int MOD = 1000000007;
// const ll INF = 1LL << 60;

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 main()
{
    ll N,K;
    cin >> N >> K;
    vector<pair<ll,ll> > ab(N);
    for(int i = 0; i < N; i++) cin >> ab[i].first >> ab[i].second;
    sort(ab.begin(),ab.end());
    ll count = 0;
    for(int i = 0; i < N; i++)
    {
        count += ab[i].second;
        if (count >= K){
            cout << ab[i].first << endl;
            return 0;
        }
    }
}

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

int abc116_b(){
    //入力
    int s,ans;
    bool flag = true;
    cin >> s;
    vector<int> v;
    v.push_back(s);
    
    //処理
    for(int i=0 ; flag ; ++i){
        if(v[i]%2){
            int a = 3*v[i]+1;
            v.push_back(a);
        }else{
            int a = v[i]/2;
            v.push_back(a);
        }
        for(int j=0 ; j<i+1 ; ++j){
            if(v[j]==v[i+1]){
                flag = false;
                ans = i+2;
                break;
            }
        }
    }
    
    //出力
    cout << ans << endl;
    return 0;
}

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


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

int main(){
	char d[9];
	string m[8]={"012","345","678","036","147","258","048","246"};
	int f;
	while(cin>>d[0],d[0]!='0'){
		for(int i=1;i<=8;i++)cin>>d[i];
		f=1;
		for(int i=0;i<8;i++){
			if(d[m[i][0]-'0']==d[m[i][1]-'0']&&d[m[i][1]-'0']==d[m[i][2]-'0']&&f&&d[m[i][0]-'0']!='+'){
				f=0;
				cout<<d[m[i][0]-'0']<<endl;
			}
			
		}
		if(f)cout<<"NA"<<endl;
	}
	
	
}


Measured memory_bytes: 1188
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		String S = stdIn.next();
		char[] c = S.toCharArray();
		boolean[][] flag = new boolean[10][11];
		boolean[] count = new boolean[1000];
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 11; j++) {
				flag[i][j]=false;
			}
		}
		int ans = 0;
		
		for(int i = 0; i < N-2; i++) {
			if(!flag[c[i]-48][10]) {
				flag[c[i]-48][10]=true;
				for(int j = i+1; j < N-1; j++) {
					if(!flag[c[i]-48][c[j]-48]) {
						flag[c[i]-48][c[j]-48]=true;
						for(int k = j+1; k < N; k++) {
							int temp = (c[i]-48)*100+(c[j]-48)*10+(c[k]-48);
							count[temp]=true;
						}
					}
				}
			}
		}
		
		for(int i = 0; i < 1000; i++) {
			if(count[i]) ans++;
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 24276
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<int>> cs(3, vector<int>(3)); cin >> cs;
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            for(int k = 0; k <= 100; k++){
                int a = cs[0][0] - i,
                    b = cs[0][1] - i,
                    c = cs[0][2] - i;
                bool ok = true;
                if(a + j != cs[1][0] ||
                   b + j != cs[1][1] ||
                   c + j != cs[1][2] ||
                   a + k != cs[2][0] ||
                   b + k != cs[2][1] ||
                   c + k != cs[2][2]){
                    ok = false;
                }
                if(ok){
                    cout << "Yes" << '\n';
                    return 0;
                }
            }
        }
    }
    cout << "No" << '\n';
}


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

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    a[i]=l+1;
  }
  long long m=1000000007;
  int b[n];
  for(int i=0;i<n+1;i++)b[i]=0;
  long long dp[100010];
    dp[0]=1;
  b[0]=3;
  for(int i=1;i<n+1;i++){
    dp[i]=(dp[i-1]*b[a[i-1]-1])%m;
    b[a[i-1]]++;
    b[a[i-1]-1]--;
  }
  cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		String s=sc.next();
		String t=sc.next();

		for(int i=0;i<s.length();i++){
			if(s.charAt(i)!=t.charAt(i)){
				System.out.println("No");
				System.exit(0);
			};
		}
		
		
		System.out.println("Yes");
		
		
	}

}


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

int main(){
	char x,y;
	scanf(" %c %c",&x,&y);
	if(x>y) printf(">\n");
	else if(x<y) printf("<\n");
	else printf("=\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int K=19;
LL d,ans=0,nowans;
LL Abs(LL x) {
    return (x<0)?(-x):x;
}
void dfs(LL r,LL l,LL nowd,LL sum) {
    if (r<l) {
	if (nowd==0)
	    nowans+=sum;
	return;
    }
    LL nowx=r-l;
    if (nowx==0) {
	if (l==1) dfs(r/10,l*10,nowd,sum*9);
	else dfs(r/10,l*10,nowd,sum*10);
	return;
    }
    if (nowd>=0) {
	LL kx=nowd/nowx;
	if (kx>9) return;
	if (l==1) dfs(r/10,l*10,nowd-kx*nowx,sum*(9-kx));
	else dfs(r/10,l*10,nowd-kx*nowx,sum*(10-kx));
	if (kx>8) return;
	if (l==1) dfs(r/10,l*10,nowd-(kx+1)*nowx,sum*(8-kx));
	else dfs(r/10,l*10,nowd-(kx+1)*nowx,sum*(9-kx));
	return;
    }
    LL kx=Abs(nowd)/nowx;
    if (kx>9) return;
    if (l==1) dfs(r/10,l*10,nowd+kx*nowx,sum*(9-kx));
    else dfs(r/10,l*10,nowd+kx*nowx,sum*(10-kx));
    if (kx>8) return;
    if (l==1) dfs(r/10,l*10,nowd+(kx+1)*nowx,sum*(8-kx));
    else dfs(r/10,l*10,nowd+(kx+1)*nowx,sum*(9-kx));
}
LL work(int len) {
    nowans=0;
    LL now=1;
    for (int i=1;i<=len-1;i++) now=now*10;
    dfs(now,1,d,1);
    return nowans;
}
int main() {
    scanf("%lld",&d);
    for (int i=1;i<=K;i++)
	ans+=work(i);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
vector<int> x;
string s;
string ans = "Left";
int main(){
  int N,A,B;
  int ans = 0;

  cin >>N>>A>>B;

  for (int i = 1 ;i <=N;i++){
    int wa = 0, t = i;
    while(t>0){
      wa +=  t%10;
      t = t/10;
    }
    if(A<=wa && B>=wa){
      ans += i;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;
// using namespace std;

int gcd(int u, int v)
{
   int r;
   while (0 != v)
   {
      r = u % v;
      u = v;
      v = r;
   }
   return u;
}

void Main()
{
   int N, i;
   std::cin >> N;
   std::vector<int> A(N);
   for (auto &v : A)
      std::cin >> v;
   std::vector<int> L(N);
   std::vector<int> R(N);
   if (N == 2)
   {
      if (A[0] > A[1])
         std::cout << A[0] << std::endl;
      else
         std::cout << A[1] << std::endl;
      return;
   }
   L[0] = 0;
   R[N - 1] = 0;
   for (i = 1; i < N; i++)
      L[i] = gcd(L[i - 1], A[i - 1]);
   for (i = N - 2; i >= 0; i--)
      R[i] = gcd(R[i + 1], A[i + 1]);
   int max = 1, l;
   for (i = 0; i < N; i++)
   {
      l = gcd(L[i], R[i]);
      if (l > max)
         max = l;
   }
   std::cout << max << std::endl;
}

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


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

int main(){
	int n,k,cnt=1;
	cin>>n>>k;
	for(int i=0; i<n; i++){
		if(2*cnt>cnt+k)cnt=cnt+k;
		else cnt=cnt*2;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[1000001];
set<pii> st;

signed main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n){
        st.insert(make_pair(0, i));
    }
    rep(i, 0, q){
        int a, v;
        cin >> a >> v;
        a--;
        st.erase(st.find(make_pair(d[a], a)));
        d[a] -= v;
        st.insert(make_pair(d[a], a));
        set<pii>::iterator it = st.begin();
        cout << it->se + 1 << " " << -it->fi << endl;
    }
}

Measured memory_bytes: 51976
#include <iostream>

using namespace std;

int main() {
    int n, h, w;
    cin >> n >> h >> w;

    int res = 0;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;

        if (a >= h && b >= w) {
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
#include <ext/numeric>
using namespace std; using __gnu_cxx::power;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1; const double eps = 1e-6, ldeps = 1e-9;
struct Dbg { static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1,Dbg&>::type operator<<(const C &x) {os<<x; return *this;}
template<class C> Dbg &dump(C b, C e) {
    for (struct{C i;int j;} i={(*this<<"\n[",b),0}; i.i!=e and i.j<26; i.i++, i.j++) *this<<", "+2*(i.i==b)<<*i.i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<!is_same<C, const char>::value, Dbg&>::type operator<<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator<<(const pair<B, C> &x) {return *this<<'{'<<x.first<<", "<<x.second<<'}';}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(#args), args), dbg << endl
#define cbug(a, args...) if (a) bug(args);
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 200005;

char t[mxn];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    cin >> t;
    int n = sl(t);
    for (int i = n-1; i >= 0; i--) {
        if (t[i] == '?') t[i] = 'D';
    }
    cout << t << '\n';
}

Measured memory_bytes: 3844
N, Y = map(int,input().split())
x, y, z = -1, -1, -1
k = 0
for i in range(N+1):
    for j in range(0,N-i+1):
        k = N - i - j
        if 10000*i + 5000*j + 1000*k == Y :
            x, y, z = i, j, k
            break
print(x, y, z)        

Measured memory_bytes: 9044
/*alurquiza*/
//https://matcomgrader.com/problem/9623/dictionary-search/
//Segment Tree + binary search
#include <bits/stdc++.h>

using namespace::std;


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

	// freopen("milkvisits.in","r",stdin);
	// freopen("milkvisits.out","w",stdout);

	int N,K;
	cin >> N >> K;

	int cont = 0;
	while(N){
		N /= K;
		cont++;
	}

	cout << cont << '\n';

	return 0;
}

//g++ -std=c++11 -Wall DS.cpp -o main

Measured memory_bytes: 256
//https://www.codechef.com/viewsolution/12529101
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long double ld;
typedef pair <ld, int> ldi;

const int Maxn = 150;
const ld pi = acos(-1.0l);

int n, m;
ld x[Maxn], y[Maxn];
vector <ldi> seq;

ld Fix(ld x)
{
	while (x < -pi) x += 2 * pi;
	while (x > pi) x -= 2 * pi;
	return x;
}

void Insert(ld l, ld r)
{
	l = Fix(l); r = Fix(r);
	if (l <= r) {
		seq.push_back(ldi(l, -1));
		seq.push_back(ldi(r, 1));
	} else {
		seq.push_back(ldi(l, -1));
		seq.push_back(ldi(pi, 1));
		seq.push_back(ldi(-pi, -1));
		seq.push_back(ldi(r, 1));
	}
}

ld Len(ld ax, ld ay) { return sqrt(ax * ax + ay * ay); }

bool Check(int from, ld r)
{
	seq.clear();
	for (int i = 0; i < n; i++) {
		ld d = Len(x[i] - x[from], y[i] - y[from]);
		if (d < 1e-6) Insert(-pi, pi);
		else if (d <= 2 * r) {
			ld ang = atan2(ld(y[i] - y[from]), ld(x[i] - x[from]));
			ld alpha = acos(d / (2 * r));
			Insert(ang - alpha, ang + alpha);
		}
	}
	sort(seq.begin(), seq.end());
	int st = 0;
	for (int i = 0; i < seq.size(); i++) {
		st += -seq[i].second;
		if (st >= m) return true;
	}
	return false;
}

bool Ok(ld r)
{
	for (int i = 0; i < n; i++)
		if (Check(i, r)) return true;
	return false;
}

int main() 
{
	scanf("%d", &n);
  	m = n;
	for (int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	ld l = 0.0, r = 3000;
	for (int i = 0; i < 50; i++) {
		ld m = (l + r) / 2.0l;
		if (Ok(m)) r = m;
		else l = m;
	}
	printf("%.9lf\n", double(r));
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
num=0
while True:
    sum=0
    for i in range(n):
        if a[i]%2==0:
            sum+=1
    if sum==n:
        num+=1
        for i in range(n):
            a[i]/=2
    else:
        break
print(num)


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

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
    int N,M,sum_gu,sum_ki;
    cin >> N >> M;
    sum_gu = nCr(N,2);
    sum_ki = nCr(M,2);

    cout << sum_gu + sum_ki << endl;
    
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second
#define pi 2*acos(0)
#define PI 3.14159265358979323846264338

typedef long long ll;
typedef pair < int , int > pii;
typedef pair < ll , ll > pll;
const int N = 100010;

inline int in() {int x; scanf("%d",&x); return x;}
inline ll lin() {ll x; scanf("%lld",&x); return x;}

int fx[]={1,-1,0,0};
int fy[]={0,0,-1,1};

int inp[N + N];
int ans[N + N];

int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> inp[i];
    }
    for(int i = n / 2 + 1, j = 1; i <= n; i++, j += 2){
        ans[i] = inp[j];
    }
    for(int i = n / 2, j = 2; i >= 1; i--, j += 2){
        ans[i] = inp[j];
    }
    if(n & 1){
        int lo = 1, hi = n;
        while(lo < hi){
            swap(ans[lo], ans[hi]);
            lo++; hi--;
        }
    }
    for(int i = 1; i <= n; i++){
        cout << ans[i] << " ";
    }
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll ans_n, ans_w, ans_h;
    ll n, w; 
    for(n=1;n<=3500;n++) {
        for(w=1;w<=3500;w++) {
            ll bunbo = 4*n*w - N*n - N*w;
            ll bunshi = N*n*w;
            if(bunbo > 0 && bunshi%bunbo == 0) {
                ans_h=bunshi/bunbo;
                ans_n = n;
                ans_w = w;
                break;
            }
        }
    }
    cout << ans_h << " " << ans_n << " " << ans_w << endl;
}


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

int a[2001][2001];

int main() {
  int sx, sy, tx, ty;
  cin>>sx>>sy>>tx>>ty;
  for (int i=0; i<tx-sx; i++) {
    cout<<"R";
  }
  for (int i=0; i<ty-sy; i++) {
    cout<<"U";
  }
  cout<<"R";
  for (int i=0; i<=ty-sy; i++) {
    cout<<"D";
  }
  for (int i=0; i<=tx-sx; i++) {
    cout<<"L";
  }
  cout<<"U";
  for (int i=0; i<ty-sy; i++) {
    cout<<"U";
  }
  for (int i=0; i<tx-sx; i++) {
    cout<<"R";
  }
  cout<<"U";
  for (int i=0; i<=tx-sx; i++) {
    cout<<"L";
  }
  for (int i=0; i<=ty-sy; i++) {
    cout<<"D";
  }
  cout<<"R";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
 
void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}
 
int main(){
  ll N;
  cin>>N;
  vector<ll> A;
  rep(i,N){
    ll a;
    cin>>a;
    A.push_back(a);
  }
  
  ll ma1=0;
  rep(i,N){
    ll b=A[i];
    ma1=max(ma1,b);
  }
  vector<ll> B;
  B=A;
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
 
  bool ok=true;
  if(B[0]!=B[N-1]) {
    ok=false;
    if(B[0]==B[1]) ok=true;
  }
  
  if(ok){
    rep(i,N){
      cout<<ma1<<endl;
    }
  }
  else{
    ll ma2=0;
    rep(i,N){
      if(A[i]==ma1) continue;
      else{
        ll b=A[i];
        ma2=max(ma2,b);
      }
    }
    rep(i,N){
    if(A[i]==ma1) cout<<ma2<<endl;
    else cout<<ma1<<endl;
    }
  }
}
   

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    string s;
    cin>>s;
    deque<char> d;
    rep(i,s.size())d.push_back(s[i]);
    ll q;
    cin>>q;
    bool state=false;
    rep(j,q){
        ll t;
        cin>>t;
        if(t==1){
            state^=true;
        }
        else if(t==2){
            int tmp;
            char c;
            cin>>tmp>>c;
            if(tmp==1){
                if(state)d.push_back(c);
                else d.push_front(c);
            }
            else if(tmp==2){
                if(state)d.push_front(c);
                else d.push_back(c);
            }
        }
    }
    if(state)for(auto itr=d.rbegin();itr!=d.rend();itr++){
        cout<<*itr;
    }
    else for(auto itr=d.begin();itr!=d.end();itr++){
        cout<<*itr;
    }
    cout<<endl;
    return 0;
}




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

int N;
string S;

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

    int cnt_b = 0;

    rep(i, N){
        if (S[i] == 'B') cnt_b++;
    }

    if (N-cnt_b > cnt_b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int t[10000];
    for(int i=0; i<N-1; i++) cin >> t[i];

    int dp[2][5001][2] = {}; //N,Aさんの長さ,今どっち？
    for(int i=0; i<=N/2; i++){
        dp[0][i][0] = 1<<28;
        dp[0][i][1] = 1<<28;
        dp[1][i][0] = 1<<28;
        dp[1][i][1] = 1<<28;
    }
    dp[1][1][0] = 0;
    //必ずAから選ぶ
    for(int i=0; i<N-1; i++){
        for(int j=1; j<=N/2; j++){
            dp[i%2][j][0] = min(dp[(i+1)%2][j-1][0], dp[(i+1)%2][j-1][1]+t[i]);
            dp[i%2][j][1] = min(dp[(i+1)%2][j][1], dp[(i+1)%2][j][0]+t[i]);
            //cout << min(dp[i%2][j][0], dp[i%2][j][1]) << " ";
            //cout << dp[(i+1)%2][j-1][0] << " " << dp[(i+1)%2][j-1][1]+t[i] << " " << dp[(i+1)%2][j][1] << " " << dp[(i+1)%2][j][0]+t[i] << endl;
        }
        //cout << endl;
    }
    cout << min(dp[0][N/2][0], dp[0][N/2][1]) << endl;
    
    return 0;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <math.h>
int main(){
	long long n,ans=0,min=1000000000000;
	scanf("%lld",&n);
	for (int i = 1; i <= sqrt(n); i++) {
		if(n%i==0){
			ans=(i-1)+(n/i-1);
			if(min>ans){
				min=ans;
			}
		}
	}
	printf("%lld\n", min);
	return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<map<int, int>> vm(m);
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        vm[x%m][x]++;
    }
    vector<int> rem(m, 0), all(m, 0);
    for (int i = 0; i < m; i++) {
        for (auto &iter: vm[i]) {
            all[i] += iter.second;
            rem[i] += iter.second % 2; 
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (i * 2 > m) break;
        if (i == 0 || i * 2 == m) {
            ans += all[i] / 2;
        } else {
            int maxi = 0;
            for (int j = 0; j <= min(all[i], all[m-i]); j++) {
                auto rest = [&](int x) { return min(all[x] - rem[x], all[x] - j) / 2; };
                maxi = max(maxi, j + rest(i) + rest(m-i));
            }
            ans += maxi;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 10368
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
			
		int c = 1;
		int cnt = 0;
		while(c < b) {
			c += a -1;
			cnt++;
		}
		
		System.out.println(cnt);

	}
}

Measured memory_bytes: 22612
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

Asum=[0]
for i in A:
  if Asum[-1]+i>K:break
  Asum.append(Asum[-1]+i)
import numpy as np
Asum=np.array(Asum)
Bsum=[0]
for i in B:
  if Bsum[-1]+i>K:break
  Bsum.append(Bsum[-1]+i)
Bsum=np.array(Bsum)

maxval=len(Asum)-1

tmp=0
lenB=len(Bsum)
lenA=len(Asum)
for i in range(lenA):
  if lenA-1-i+lenB<maxval:break
  for j in range(lenB):
    j=tmp+j
    if Asum[-i-1]+Bsum[j]>K:
      maxval=max(maxval,len(Asum)-1-i+j-1)
      tmp=j
      break
    elif j==lenB-1:
      maxval=max(maxval,lenA-1-i+j)
      break
print(maxval)


Measured memory_bytes: 53716
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin>>s;

    int min=1000;

    for (int i=0;i<s.size()-2;i++) {
        int x=abs(753-((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')));
        if(x<min){
                min=x;
        }
    }
    cout <<min<<endl;
}


Measured memory_bytes: 256
#include<iostream>                                         
#include<stdio.h>                                          
#include<iomanip>                                          
using namespace std;                                       
                                                           
int main(){                                                
                                                           
  int a,b;                                                 
                                                           
  cin >> a >> b;                                           
                                                           
  cout << a/b << " " << a%b << " " << fixed << setprecisio\
n(6) << (double)a/b << endl;                               
                                                           
  return 0;                                                
                                                           
}

Measured memory_bytes: 3280
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
#define MAX 10000
#define INFTY 1<<22
#define WHITE 0
#define GRAY 1
#define BLACK 2

// 重み付き有向グラフの隣接リスト
vector<pair<int,int> > adj[MAX];

void dijkstra(int n){
    priority_queue<pair<int,int> >pq;
    // weight[v]に始点sからvまでの最短コストを保存する
    int weight[MAX];
    // 訪問状態を記録
    int color[MAX];
    // 1.初期化
    for(int i = 0;i < n;++i){
        weight[i] = INFTY;
        color[i] = WHITE;
    }
    
    // 始点
    weight[0] = 0;
    color[0] = GRAY;
    pq.push(make_pair(0,0));
    
    while(!pq.empty()){
        pair<int,int> first = pq.top();
        pq.pop();
        // 頂点
        int u = first.second;
        color[u] = BLACK;
        
        // 最短値を取りだして、最短でなければ飛ばす
        if(weight[u] < first.first * -1) continue;
        
        for(int i = 0;i < adj[u].size();++i){
            int v = adj[u][i].first;
            if(color[v] == BLACK)continue;
            if(weight[v] > weight[u] + adj[u][i].second){
                weight[v] = weight[u] + adj[u][i].second;
                // priority_queueはデフォルトで大きい値を優先するので-にする
                pq.push(make_pair(weight[v] * -1, v));
                color[v] = GRAY;
            }
        }
    }
    
    // 出力
    for(int i = 0;i < n;++i){
        cout << i << " " << ( weight[i] == INFTY ? -1 : weight[i] ) << endl;
    }
}

int main(){
    int n,k,c,u,v;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> u >> k;
        for(int j = 0;j < k;++j){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra(n);
    return 0;
}



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

int main() {

	ll n,m;
	cin>>n>>m;
	int x;
	for(int i=0;i<m;++i) {
        cin>>x;
        n -= x;
	}
	if(n < 0) cout<<"-1";
	else cout<<n;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N), L(N), R(N);
  REP(i, N) cin >> A[i];
  L[0] = A[0];
  R[N - 1] = A[N - 1];
  FOR(i, 1, N) {
    L[i] = gcd(L[i - 1], A[i]);
    R[N - 1 - i] = gcd(R[N - i], A[N - 1 - i]);
  }
  ll ans = max(R[1], L[N - 2]);
  FOR(i, 1, N - 1) { ans = max(ans, gcd(L[i - 1], R[i + 1])); }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000007

int main(){

    ll n,k;
    cin >> n >> k;

    ll ans = 1;
    
    for(int i = 0;i < n-1;i++){
        ans*=(k-1);
    }
    ans*=k;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  cout << s[0] << s.size() - 2 << s.back() << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3560
n, m = map(int, input().split())
ps = [list(map(str, input().split())) for _ in range(m)]

#print(ps)
str_l = ['WA'] * n
#print(str_l)
int_l = [0] * n

num = 0
ac = 0
for pp, s in ps:
    p = int(pp)-1
    if s == 'AC':
        str_l[p] = 'AC'
    else:
        if str_l[p] != 'AC':
            int_l[p] += 1

for i in range(n):
    if str_l[i] == 'AC':
        num += int_l[i]
        ac += 1

print(ac, num)


Measured memory_bytes: 69592
package main

import "fmt"

func main() {
	// Code for A - Good Integer
	var S string
	fmt.Scanf("%s", &S)

	if (S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1832
import java.util.*;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String T = sc.next();
    String S = sc.next();
    String R ="";
    for(int i =0;i<N;i++){
      R+=T.substring(i,i+1) + S.substring(i,i+1);
    }
    System.out.println(R);
  }
}

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

int main() {

  int N=0;
  int nums[200];
  cin >> N;

  for(int i=0;i<N;i++){
    cin >> nums[i];
  }
  int count=0;
  while(1){
    for(int i=0;i<N;i++){
      if(nums[i]%2==1 || nums[i]==0){
        cout << count << endl;
        return 0;
      } else nums[i] /= 2;
    }
    count++;
  }
}

Measured memory_bytes: 256