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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///


void _case()
{
    ll n;
    cin>>n;
    cout<<n*n*n el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


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

int main(){
    int i,res = 0;
    char s[3] = {-1};

    for( i = 0; i < 3; i++){
        cin >> s[i];
    }

    for( i = 0; i < 3; i++){
        if( s[i] == 0x31 ){
            res++;
        }
    }

    cout << res << "\n";
}

Measured memory_bytes: 256
N = gets.to_i
as = gets.split.map(&:to_i)

# 区間の和を使うので累積和を前計算
accum = as.dup
(N-1).times do |i|
    accum[i+1] += accum[i]
end

ans = 10**20

# 区間2つ+区間2つの境界を全探索
# [0, center] と [center+1, N-1] に分ける
(1..(N-3)).each do |center|
    sum_l = accum[center]
    sum_r = accum[N-1] - accum[center]
    parts = []

    # s1を半分に分ける。
    mid = (1..center).bsearch{|i| accum[i]*2 > sum_l}
    s11, s21 = accum[mid], accum[mid-1]
    s12, s22 = sum_l - s11, sum_l - s21
    if (s11 - s12).abs < (s21 - s22).abs
        parts.push(s11, s12)
    else
        parts.push(s21, s22)
    end

    # s2を半分に分ける
    mid = ((center+2)...N).bsearch{|i| (accum[i] - sum_l)*2 > sum_r}
    s11, s21 = accum[mid]-sum_l, accum[mid-1]-sum_l
    s12, s22 = sum_r - s11, sum_r - s21
    if (s11 - s12).abs < (s21 - s22).abs
        parts.push(s11, s12)
    else
        parts.push(s21, s22)
    end

    result = parts.max - parts.min
    ans = result if ans > result
end
puts ans

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

int main(){
    int n,m;
    int min=pow(10,8);
    int num;
    int dis=0;
    cin >> n >> m;

    vector<vector<int>>student(n,vector<int>(2));
    vector<vector<int>>point(m,vector<int>(2));

    for(int i = 0; i<n;i++){
        for(int j =0 ;j<2;j++){
            cin >> student.at(i).at(j);
        }
    }

  
 
    for(int i = 0; i<m;i++){
        for(int j =0 ;j<2;j++){
            cin >> point.at(i).at(j);
        }
    }

    for(int i=0;i<n;++i){
        min=abs(student.at(i).at(0)-point.at(0).at(0))+abs(student.at(i).at(1)-point.at(0).at(1));
        num=1;
        for(int j =1;j<m;++j){
            dis = abs(student.at(i).at(0)-point.at(j).at(0))+abs(student.at(i).at(1)-point.at(j).at(1));
            if(min>dis){
                min = dis;
                num = j + 1;
            }
        }
        cout <<  num << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

bool Check(std::string s) {
	if (s.substr(0, s.length() / 2) == s.substr(s.length() / 2)) return true;
	else return false;
}

int main(void) {
	int ans;
	std::string input;
	std::cin >> input;
	for (int i = 2;; i += 2) {
		if (Check(input.substr(0, input.length() - i))) {
			ans = input.length() - i;
			break;
		}
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<fstream>

#define rep(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005
#define pb push_back
#define MP make_pair

using namespace std;

int main(){
	lint a[SIZE],b[SIZE];
	lint n,ans=0;
	cin>>n;
	rep(i,0,n){
		cin>>a[i]>>b[i];
	}
	for(int i=n-1;i>=0;i--){
		if((a[i]+ans)%b[i]!=0){
			ans+=(b[i]-(a[i]+ans)%b[i]);
		}
	}
	cout<<ans;

return 0;
}

Measured memory_bytes: 2300
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "PP.hpp"
#define deb(x...) cerr << "[" << #x << "] = " << x << "\n";
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	string s;
	int k;
	cin >> n >> k >> s;
	s[k - 1] = tolower(s[k - 1]);
	cout << s << '\n';
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

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


class UnionFind {
    vector<int> uni;
    int n;
public:
    explicit UnionFind(int n) : uni(static_cast<u32>(n), -1) , n(n){};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        return true;
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind U(m);
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int k, a;
        cin >> k >> a;
        v.emplace_back(a-1);
        for (int j = 0; j < k - 1; ++j) {
            int b;
            scanf("%d", &b);
            U.unite(a-1, b-1);
            v.emplace_back(b-1);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    for (int i = 1; i < v.size(); ++i) {
        if(U.root(v[i]) != U.root(v[0])){
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}


Measured memory_bytes: 1276
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		long k = sc.nextLong();
		int max = arr.length;
	    char first = '1';
	    for (int i = 0; i < arr.length; i++) {
	        if (arr[i] != '1') {
	            max = i;
	            first = arr[i];
	            break;
	        }
	    }
	    if (max >= k) {
	        System.out.println(1);
	    } else {
	        System.out.println(first);
	    }
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    string s;
    cin >> s;
    if (s=="AAA"){
        cout << "No" << endl;
    }
    else if (s=="BBB"){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

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


Measured memory_bytes: 92416
#include<iostream>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	if(a==1) {
		a=14;
	}
	if(b==1){
		b=14;
	}
	if(a>b){
		cout<<"Alice"<<endl;
	}
	else if(a<b){
		cout<<"Bob"<<endl;
	}
	else if(a==b){
		cout<<"Draw"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include	<stdio.h>
int	main(void)
{
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(x-r<0 || y-r<0 || x+r>W || y+r>H){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	return	0;
}

Measured memory_bytes: 584
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

import re

def solve():
    S = input()

    # print(S)
    # print(re.split("(RL)", S))

    ans = [0 for _ in range(len(S))]
    idx = 0
    rcnt = 0
    lcnt = 0
    pre_rl_idx = -1
    for s in re.split('(RL)', S):
        if s == '':
            continue
        # print(idx, s)



        if s == 'R':
            rcnt += 1
            idx += 1
        elif s == 'L':
            ans[idx - 2] += 1
            idx += 1
        elif s == 'RL':
            ans[idx] += 1
            ans[idx + 1] += 1
            if rcnt > 0:
                r = rcnt // 2
                ans[idx] += r
                ans[idx + 1] += rcnt - r
            pre_rl_idx = idx
            idx += 2
            rcnt = 0
        else:
            for ss in s:
                if ss == 'R':
                    rcnt += 1
                    idx += 1
                elif ss == 'L':
                    lcnt += 1
                    idx += 1

            if lcnt > 0:
                r = lcnt // 2
                ans[pre_rl_idx + 1] += r
                ans[pre_rl_idx] += lcnt - r
                lcnt = 0
        # print(ans)
    # print(ans)
    print(' '.join(list(map(str, ans))))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 11212
#include <stdio.h>
#include <vector>
#include <algorithm>

#define TEST 0
typedef std::pair<int,int> pi;//first: value,second: weight

struct Pred
{
    bool operator()(const pi& f,const pi& s)//<
    {
        return f.second < s.second;
    }
};

int wmax[1001],cnt[1000];
void maxassign(int index,int value)
{
    if(wmax[index] < value)
        wmax[index]=value;
}
pi rec_check(const std::vector<pi> &data,int start,int remw)
{
     
}
int main(void)
{
    int ccount=1;
    int w,n;
    using namespace std;
    vector<pair<int,int> > data;
    while(scanf("%d%d",&w,&n)==2 && w!=0)
    {
        data.assign(n,std::pair<int,int>(0,0));
        for(int i=0;i<n;i++)
        {
            scanf("%d%*[,]%d",&data[i].first ,&data[i].second );
        }
        Pred pred;
        sort(data.begin(),data.end(),pred);
        printf("Case %d:\n",ccount);
        for(int i=0;i<1001;i++)
        {
            wmax[i]=-1;
        }
        wmax[0]=0;
#if TEST
        for(int i=0;i<n;i++)
        {
            printf("val=%d,wei=%d\n",data[i].first,data[i].second);
        }
#endif
        for(int i=0;i<n;i++)
        {
            //Now we think about treasure[i]
            for(int j=w-data[i].second;j>=0;j--)
            {
                if(wmax[j] != -1)
                    maxassign(j+data[i].second,wmax[j]+data[i].first);
            }
        }
        int max=-1;
        int ind=-1;
        for(int i=0;i<=w;i++)
        {
            if(max < wmax[i])
            {
                max=wmax[i];
                ind=i;
            }
        }
#if TEST
        for(int i=0;i<=w;i++)
        {
            if(wmax[i] != -1)
                printf("\nwmax[%d]=%d",i,wmax[i]);
        }
#endif
        printf("%d\n%d\n",max,ind);
        data.clear();
        ccount++;
    }
    return 0;
}

Measured memory_bytes: 0
import math as mt
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
#print(A)
S = 0
P2 = mt.floor(N/2 - 1)
if N % 2 == 0:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S += A[P2+1] - A[P2]
    print(S)
elif N % 2 == 1:
    for i in range(0,P2,1):
        S += 2 * (A[N-i-1] - A[i])
    S1 = A[N-P2-2] + A[N-P2-1] - 2 * A[P2]
    S2 = 2 * A[N-1-P2] - A[P2] - A[P2+1]
    if S1 >= S2:
        print(S1+S)
    else:
        print(S2+S)


Measured memory_bytes: 7528
#include <iostream>

int main()
{
    std::string s;
    uint64_t k;

    std::cin >> s >> k;

    uint64_t count = 0;
    char next = 0;
    for (auto& c : s) {
        if (c == '1') {
            count++;
        } else {
            next = c;
            break;
        }
    }

    if (k <= count) {
        std::cout << '1' << std::endl;
    } else {
        std::cout << next << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int d[33] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << d[k-1] << endl;
	return 0;
}


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

public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 32 * 1024 * 1024).start(); // 16MBスタックを確保して実行
    }

    public void run() {
        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        // String[] str = br.readLine().split(" ");
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] h = new int[n];
        boolean[] node = new boolean[n];
        Arrays.fill(node, true);
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }
        int result = 0;
        int x = 0;
        int y = 0;
        for (int i = 0; i < m; i++) {
            x = Integer.parseInt(sc.next()) - 1;
            y = Integer.parseInt(sc.next()) - 1;
            if (h[x] < h[y]) {
                node[x] = false;
            } else if (h[x] > h[y]) {
                node[y] = false;
            } else {
                node[x] = false;
                node[y] = false;
            }
        }
        sc.close();
        for (boolean s : node) {
            if (s) {
                result++;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 58908
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(vector<T> a){
    for (const auto& ai : a) cout << ai << " ";
    cout << endl;
}
vector<string> Yes = {"No", "Yes"};

int main(){
    INT(x, y, z);
    swap(x, y); swap(x, z);
    cout << x << " " << y << " " << z << endl;
}


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

#define L 3000

int dp[L + 5][L + 5];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= s.length(); i++) dp[i][0] = 0;
    for (int i = 0; i <= t.length(); i++) dp[0][i] = 0;
    for (int i = 1; i <= s.length(); i++) for (int j = 1; j <= t.length(); j++)
    {
        if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
        else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
    }
    int hi = s.length(), hj = t.length();
    string res = "";
    while (hi && hj)
    {
        if (s[hi - 1] == t[hj - 1])
        {
            res += s[hi - 1];
            hi--;
            hj--;
        }
        else if (dp[hi][hj - 1] >= dp[hi - 1][hj]) hj--;
        else hi--;
    }
    for (int i = res.length() - 1; i >= 0; i--) cout << res[i];
    cout << '\n';
    return(0);
}

Measured memory_bytes: 35456
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <math.h>
typedef long long ll;
const int MYINF = 1e9+7;

int n;
int s[1024];

double avg() {
        double ret = 0;
        int i;
        for (i = 0; i < n; i++) {
                ret += s[i];
        }
        return ret / n;
}

double sd() {
        int i;
        double m = avg(), ret = 0;

        for (i = 0; i < n; i++) {
                ret += (s[i] * 1.0 - m) * (s[i] * 1.0 - m);
        }

        return sqrt(ret / n);
}

int main(int argc, char **argv)
{
        int i;

        for (;;) {
                scanf("%d", &n);
                if (!n) break;
                for (i = 0; i < n; i++) {
                        scanf("%d", &s[i]);
                }
                printf("%lf\n", sd());
        }
        return 0;
}

Measured memory_bytes: 636
g = []

n = STDIN.gets.to_i
n.times.each {
  as = STDIN.gets.split(' ').map{|x| x.to_i }
  g[as[0]] = as.drop(2)
}

stack = []
mode = [] # nil: ????¨????, 1: ?¨??????????, 2: ??£??\?????¨????¨??????????
start_t = []
end_t = []

t = 0
for i in 1..n
  if mode[i] == nil
    t = t + 1
    v = i
    mode[v] = 1
    start_t[v] = t
    stack.push(v)
    while stack.size != 0
      t = t + 1
      adjacencies = g[v]
      has_yet = false
      for a in adjacencies
        if mode[a] == nil
          # ????¨????
          mode[a] = 1
          v = a
          start_t[v] = t
          stack.push(v)
          has_yet = true
          break
        end
      end
      if !has_yet
        # ??£??\??????????????¨??¨?¨??????????
        mode[v] = 2
        end_t[v] = t
        stack.pop
        v = stack.last
      end
    end
  end
end

for i in 1..n
  puts "#{i} #{start_t[i]} #{end_t[i]}"
end

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

int main()
{
    int h,w;
    while(cin>>h>>w)
    {
        if(h==0)return 0;
        REP(i,h)
        {
            REP(j,w)
            {
                if((i+j)%2==0)cout<<"#";
                if((i+j)%2==1)cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3072
#include <stdio.h>

int main(){
  char s[3];
  char t[3];
  scanf("%s", s);
  scanf("%s", t);
  int c = 0;
  for(int i = 0;i < 3;i++){
  	if(s[i] == t[i])c++;
  }
  printf("%d\n", c);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	long long int n;
	scanf("%lld",&n);
	long long int min_minus = 10000000001;
	long long int min_a,min_b,a,b;
	for(long long int i=1;i*i<=n;i++){
		if(n%i==0){
			a = (long long int)i;
			b = (long long int)n/i;
		}
	}
	int keta_a = log10((double)a);
	int keta_b = log10((double)b);

	printf("%d\n",max(keta_a+1,keta_b+1));
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;
const int maxn=100005;
typedef long long LL;
LL a[maxn],b[maxn];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n+1;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++){
        scanf("%lld",&b[i]);
    }
    LL ans=0;
    for(int i=1;i<=n;i++){
        if(b[i]<=a[i]){
            ans+=b[i];
        }
        else{
            ans+=a[i];
            if(b[i]-a[i]<=a[i+1]){
                ans+=(b[i]-a[i]);
                a[i+1]-=(b[i]-a[i]);
            }
            else{
                ans+=a[i+1];
                a[i+1]=0;
            }
        }
        //printf("%lld\n",ans);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void){
    int b1, b2, b3;
    //b1は「乗車券」の投入状態、b2は「特急券」の投入状態
    //b3は「乗車券・特急券」の投入状態

    cin >> b1 >> b2 >> b3;
    if(b1 == 1 && b2 == 0 && b3 ==0) cout << "Close" << endl;
    if(b1 == 0 && b2 == 1 && b3 ==0) cout << "Close" << endl;
    if(b1 == 1 && b2 == 1 && b3 ==0) cout << "Open" << endl;
    if(b1 == 0 && b2 == 0 && b3 ==1) cout << "Open" << endl;
    if(b1 == 0 && b2 == 0 && b3 ==0) cout << "Close" << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int a;
  cin >> a;
  map<int, int > m;
  int i = 2;
  int tmp = a;
  int tmp2;
  m[a] ++;
  // cout << m[a]<< endl;
  while(true){
    if(tmp%2 == 0){
      tmp2 = tmp/2;
    }else{
      tmp2 = 3*tmp + 1;
    }
    if(m.find(tmp2) == m.end()){
      m[tmp2] ++ ;
      i ++;
      tmp = tmp2;
    }else{
      break;
    }
  }
  cout << i << endl;
}


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    int rem = n % 1000;
    if(rem)rem = 1000 - rem;
    cout << rem << endl;


    return 0;
}


Measured memory_bytes: 3632
url = "https://atcoder.jp/contests/abc089/tasks/abc089_b"

def main():
    s = input()
    ame = list(input().split())
    ame = set(ame)
    ans = 'Four'
    if len(ame) == 3:
        ans = 'Three'
    print(ans)

if __name__ == '__main__':
    main()




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

const int MAX_N = 200005;
const int MAX_K = 21;
int N;
int vals[MAX_N];
std::map<int, int> bits;

void add(int v) {
	for (int k = 0; k < MAX_K; ++k)
		if (v & 1 << k) bits[k]++;
}

void remove(int v) {
	for (int k = 0; k < MAX_K; ++k)
		if (v & 1 << k) bits[k]--;
}

bool bad() {
	bool bad = false;
	for (int k = 0; k < MAX_K; ++k) {
		if (bits[k] > 1) bad = true;
	}
	return bad;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", vals + i);
	}
	long long sum = 0;
	int st = 0, en = 0;  // inclusive
	add(vals[0]);
	while (en < N) {
		if (bad()) {
			remove(vals[st]);
			st++;
		} else {
			long long curlen = en - st + 1;
			sum += curlen;
			en++;
			add(vals[en]);
		}
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> alis(n), blis(n);
    ll asum = 0, bsum = 0, count = 0;
    REP(i, 0, n){cin >> alis[i]; asum += alis[i];}
    REP(i, 0, n){cin >> blis[i]; bsum += blis[i];}
    REP(i, 0, n){
        if(alis[i] >= blis[i]){continue;}
        count += max((blis[i]-alis[i]-1)/2+1, 0LL);
    }
    if(count > bsum-asum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <queue>
#include <climits>
#include <numeric>
#include <cstring>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int N;
vector<vector<int> > S;
vector<int> V;
int memo[14][1 << 14];

int solve(int last, int flag){
  if(flag == (1 << N) - 1) return 0;
  if(memo[last][flag] != -1) return memo[last][flag];

  int ret = 1000000;
  REP(i,N) if((flag & (1 << i)) == 0){
    ret = min(ret, V[i] - (V[last] - S[last][i]) +
              solve(i, (flag | (1 << i))));
  }

  return memo[last][flag] = ret;
}

int sss(vector<string> &v){
 loop:
  REP(i,v.size()){
    REP(j,v.size()) if(i != j){
      if(string::npos != v[i].find(v[j])){
        v.erase(v.begin() + j);
        goto loop;
      }
    }
  }

  int n = v.size();
  vector<vector<int> > same(n, vector<int>(n));

  REP(i,n) REP(j,n){
    for(int ii = 0; ii <= v[i].size(); ii++){
      bool ok = true;
      for(int jj = 0; ii + jj < v[i].size() && jj < v[j].size(); jj++){
        if(v[i][ii + jj] != v[j][jj]){
          ok = false;
          break;
        }
      }
      if(ok){
        same[i][j] = ii;
        break;
      }
    }
  }

  int ans = INT_MAX;

  N = n;
  S = same;
  V = vector<int>(n); REP(i,n) V[i] = v[i].size();
  memset(memo, -1, sizeof(memo));

  REP(i,n){
    ans = min(ans, V[i] + solve(i, (1 << i)));
  }

  return ans;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    cout << sss(s) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    ll n, a, b;
    cin >> n >> a >> b;

    ll res = n / (a+b) * a;
    res += min(n % (a+b), a);
    cout << res << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long X=sc.nextLong();
        long now = 100L;
        for(int i=1; i<10000; i++){
            now += (now/100);
            if(now >= X){
                p(i);
                System.exit(0);
            }
        }
    }
    public static void p(Object o){
        System.out.println(o);
    }
}


Measured memory_bytes: 35864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>X(N);
	vector<int>Y(N);
	vector<int>H(N);
	rep(i, N) {
		cin >> X[i] >> Y[i] >> H[i];
	}
	int K;
	int h;
	int cnt = 0;
	rep(i, N) {
		if (H[i] != 0) {
			K = i;
			break;
		}
	}
	rep(i, 101) {
		rep(j, 101) {
			h = H[K] + abs(i - X[K]) + abs(j - Y[K]);
			rep(k, N) {
				if (H[k] != max(0, h - abs(i - X[k]) - abs(j - Y[k]))) {
					cnt++;
				}
			}
			if (cnt==0) {
				cout << i << ' ' << j << ' ' << h << endl;
			}
			cnt = 0;
		}
	}
}




Measured memory_bytes: 256
h,w = map(int, input().split())
S = [input() for _ in range(h)]
for r in range(h):
    l = ''
    for c in range(w):
        if S[r][c] == '#':
            l += '#'
        else:
            l += str(sum([x[max(0,c-1):min(c+2,w)].count('#') for x in S[max(0,r-1):min(r+2,h)]]))
    print(l)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 1;
    REP(i, N) {
        ll a;
        cin >> a;
        ll t = ans;
        ans *= a;
        if (ans > INF || (ans < t && a != 0)) {
            ans = -1;
        }
        if (ans < 0)
            ans = -1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
    long long N;
    cin >> N;
    long long valores[N], costos[N], maxim=0, i;
    for (i=0; i<N; i++) cin >> valores[i];
    for(i=0; i<N; i++) cin >> costos[i];
    for(i=0; i<N; i++)
    {
        if(valores[i]-costos[i]>0)
        {
            maxim=maxim+valores[i]-costos[i];
        }
    }
    cout << maxim << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
S = [input() for _ in range(N)]
a = 0
b = 0
ans = 0
aru = False
zenaru = True
for s in S:
    TB = (s[0] == 'B')
    TA = (s[-1] == 'A')
    ans += s.count('AB')
    if TB:
        b += 1
        aru = True
    if TA:
        a += 1
        aru = True
    if TA ^ TB:
        zenaru = False
if a == 0 or b == 0:
    print(ans)
    sys.exit()
print(ans + min(a, b) - zenaru)



Measured memory_bytes: 44888
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = 5;
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        int k = sc.nextInt();
        
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (array[j] - array[i] > k) ok = false;
            }
        }
        
        if (ok) {
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}


Measured memory_bytes: 22740
n, m = map(int, input().split())
h = list(map(int, input().split()))
min_ab = set()
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] <= h[b]:
        min_ab.add(a)
    if h[b] <= h[a]:
        min_ab.add(b)

print(n - len(min_ab))


Measured memory_bytes: 20036
use proconio::input;

fn main() {
  input! {
    s: String
  };

  let i = s.find('C').unwrap_or(s.len());
  let j = s.rfind('F').unwrap_or(0);
  if i < j {
    println!("Yes");
  } else {
    println!("No");
  }
}


Measured memory_bytes: 2140
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll cnt(n+1,0) ;
	for(int i=0;i<n;i++){
		ll a ; cin >> a ;
		cnt.at(a)++ ;
	}
	mysort(cnt) ; myrev(cnt) ;
	ll ans = 0 ;
	for(int i=k;i<n+1;i++) ans += cnt.at(i) ;
	cout << ans << endl ;
}


Measured memory_bytes: 1792
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL)
		h1 = setHeight(T[u].left) + 1;
	if (T[u].right != NIL)
		h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
	if (T[u].parent == NIL) return NIL;
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL)
		return T[T[u].parent].left;
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL)
		return T[T[u].parent].right;
	return NIL;
}

void print(int u) {
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);

	if (T[u].parent == NIL) {
		printf("root\n");
	}
	else if (T[u].left == NIL && T[u].right == NIL) {
		printf("leaf\n");
	}
	else {
		printf("internal node\n");
	}
}

int main() {
	int v, l, r, root = 0;
	scanf("%d", &n);

	for (int i = 0; i < n; ++i) T[i].parent = NIL;

	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}

	for (int i = 0; i < n; ++i) if (T[i].parent == NIL) root = i;

	setDepth(root, 0);
	setHeight(root);

	for (int i = 0; i < n; ++i) print(i);
}


Measured memory_bytes: 2764
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

ll gcd (ll x,ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
ll lcm (ll x,ll y) {
    return x/gcd(x, y)*y;
}

int main() {
    ll n;
    cin>>n;
    if(n%2==1) {
        cout<<0<<endl;
        return 0;
    }

    ll ans=0;
    ll d=10;
    while(d<=n) {
        ans+=(ll)(n/d);
        d*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n,x;
    cin >> n >> x;
    vector<int> pow(n);
    rep(i,n) cin >> pow.at(i);

    int r,s,m,ans;
    s = 0;
    m = pow.at(1);
    rep(i,n) m = min(m,pow.at(i));

    rep(i,n) s += pow.at(i);


    r = x-s;

    ans = n + r/m;

    cout << ans << endl;
}

     

Measured memory_bytes: 256
N,K=map(int,input().split())
p=list(map(int,input().split()))
q=[]
q.append(0)
for i in range(len(p)):
  q.append(q[-1]+p[i])
maxi=q[K]-q[0]
for i in range(1,N-K+1):
  sub=q[K+i]-q[i]
  if sub>=maxi:
    maxi=sub
print((maxi+K)/2)

Measured memory_bytes: 32204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

double a[102];
int main() {
	double n;
	cin>>n;
	double sum=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sum/=n;
	ll ans=0;
	double now=abs(sum-a[0]);
	for(ll i=0;i<n;i++){
		if(abs(sum-a[i])<now){
			now=abs(sum-a[i]);
			ans=i;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

long long int gcd( long long int a , long long int b ){
	long long int r;
	while((r = a % b)!=0){
		a = b;
		b = r;
	}
	return b;
}

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

int main(void){
	long long int a , b;
	while(scanf("%lld %lld" , &a , &b)!=EOF){
		printf("%lld %lld\n" , gcd(a,b) , lcm(a,b));
	}
	return 0;
}

Measured memory_bytes: 0
N,K=map(int,input().split())
h=[int(input()) for _ in range(N)]
h.sort()
ans=0
for i in range(N-K+1):
    if i==0:
        ans=h[i+K-1]-h[i]
    else:
        if ans>h[i+K-1]-h[i]:
            ans=h[i+K-1]-h[i]
print(ans)

Measured memory_bytes: 7384
def main():
    X, Y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    p.sort(reverse=True); q.sort(reverse=True); r.sort()

    p = p[:X]
    q = q[:Y]
    s = p + q
    s.sort()

    rtmp = r.pop()
    for i in range(len(s)):
        if s[i] < rtmp:
            s[i] = rtmp
            if len(r) == 0:
                break
            rtmp = r.pop()
        else:
            break
    ans = sum(s)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 29680
#include<bits/stdc++.h>
#include<cstdio>
//const int maxx 1e9 ;
#define ll long long
using namespace std ;

int main(){
    int d, t, s;
    cin>>d>>t>>s ;
    double tt = t*1.000000 ;
    double ttt =(d*1.0)/(s*1.0) ;
    //cout<<tt<<" "<<ttt<<endl ;
    if(tt>=ttt) cout<<"Yes"<<endl ;
    else cout<<"No"<<endl ;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, m;
  cin >> n >> m;
  
  vl white(n, 1), red(n);
  white[0] = 0;
  red[0] = 1;
  
  ll x, y;
  rep(_, m) {
    cin >> x >> y;
    x--; y--;
    
    if(red[x]) {
      red[x]--;
      red[y]++;
      red[y] += white[y];
      white[y] = 0;
    }
    
    if(white[x]) {
      white[x]--;
      if(red[y]) red[y]++;
      else white[y]++;
    }
  }
  
  ll ans=0;
  rep(i, n) if(red[i]) ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	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;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n, m, i, j, p[2222], ans = 1,sum[2222],sum2[2222],s[2222],t[2222];
	cin >> n >> m;
	for (i = 0; i < n; i++)
		cin >> s[i];
	for (i = 0; i < m; i++)
		cin >> t[i];
	for (i = 0; i < m; i++)
		sum[i] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			p[j] = 0;
		for (j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				if (j == 0)
					p[j]++;
				else
					p[j] = sum[j - 1];
			}
		}
		sum2[0] = p[0];
		for (j = 1; j < m; j++)
			sum2[j] = (sum2[j - 1] + p[j]) % M;
		for (j = 0; j < m; j++)
			sum[j] = (sum[j] + sum2[j]) % M;
	}
	ans = sum[m - 1];
	cout << ans << endl;
}

Measured memory_bytes: 5120
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    string s;
    cin>>s;

    if(s[0] == '7' ||s[1] == '7' || s[2] == '7')
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,x,m;
int l[11],r[11],s[11];
int ans;
vector<int> arr;
void dfs(vector<int> v){
  if(v.size()==n){
    for(int i=0;i<m;i++){
      int tmp=0;
      for(int j=l[i]-1;j<r[i];j++){
	tmp+=v[j];
      }
      if(tmp!=s[i]) return;
    }
    int res=0;
    for(int i=0;i<n;i++) res+=v[i];
    if(ans<res){
      ans=res;
      arr=v;
    }
    return;
  }
  for(int i=0;i<=x;i++){
    v.push_back(i);
    dfs(v);
    v.pop_back();
  }
}
signed main(){
  cin>>n>>x>>m;
  for(int i=0;i<m;i++) cin>>l[i]>>r[i]>>s[i];
  ans=-1;
  dfs(vector<int>(0));
  if(ans<0) cout<<ans<<endl;
  else for(int i=0;i<n;i++) cout<<arr[i]<<" \n"[i==n-1];
  return 0;
}

Measured memory_bytes: 3156
s=input()

t=len(s)

A=ord("A")
Z=ord("Z")
f=0
for a,i in enumerate(s):
    if a==0:
        if i!="A":
            print("WA")
            exit()
    elif a==1:
        if A<=ord(i)<=Z:
            print("WA")
            exit()
    elif a<t-1:
        if (i=="C" and f==1) or (A<=ord(i)<=Z and i!="C"):
            print("WA")
            exit()
        elif i=="C" and f==0:
            f=1
    else:
        if A<=ord(i)<=Z:
            print("WA")
            exit()
print("AC" if f==1 else "WA")

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

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end)for(int i=start;i<end;i++)
#define SORT(v) sort(v.begin(),v.end())
typedef long long ll;

int main()
{
    ll n,k,q,ans;
    cin>>n>>k;
    q=n/k;
    ans=min(n,min(abs(n-q*k),abs(n-(q+1)*k)));
    cout<<ans;

}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    C = list(input())
    rnum = 0
    for c in C:
        if c == "R":
            rnum += 1
    leftr = 0
    for c in C[:rnum]:
        if c == "R":
            leftr += 1
    print(rnum-leftr)
    

if '__main__' == __name__:
    resolve()


Measured memory_bytes: 11968
#include<stdio.h>

#define MAX 100
#define INFTY (1 << 21)



int R[MAX + 2];
int C[MAX+1][MAX+1];
int B[MAX+1][MAX+1]; 

int matrix_cost(int );



int main() {
    int i, n;
    scanf("%d\n", &n);
    for(i=1;i<=n;i++) {
        scanf("%d %d\n", &R[i], &R[i+1]);
    }
    
    printf("%d\n", matrix_cost(n));
    return 0;
}

int matrix_cost(int n){
    int i,j,k,cost;
    int SIZE = n;
    for (i=1;i<=n;i++) {
        for(j=1;j<=n;j++) {
            C[i][j] = INFTY;
        }
        C[i][i] = 0;
    }

    for(j=1;j<=SIZE-1;j++){
        for(i=1;i<=SIZE-j;i++){
            for(k=i+1;k<=i+j;k++){
                cost = C[i][k-1] + C[k][i+j] + R[i]*R[k]*R[i+j+1];
                if(cost<C[i][i+j]){
                    C[i][i+j] = cost;
                    B[i][i+j] = k;
                }
            }
        }
    }
    
    return C[1][SIZE];
}



Measured memory_bytes: 2108