akhauriyash/Code-Regression huggingface dataset:
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 1005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'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> cap={'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'};





// Lets start ...




int main(){
    vector<int> primes;
    Sieve(primes);
    
    fast
    ll n;
    cin>>n;
    ll l[n],vis[1005];
    fi(i,0,n)cin>>l[i];
    fi(i,1,1005)vis[i]=0;
    ll q=0,z=0,gc=l[0];
    fi(i,1,n){
        gc=__gcd(gc,l[i]);
    }
    if(gc==1)z=1;
    mll mp;
    fi(i,0,n){
        fi(j,0,sz(primes)){
            if(l[i]%primes[j]==0){
                if(vis[primes[j]]){q=1;break;}
                else{vis[primes[j]]=1;
                    while(l[i]%primes[j]==0)l[i]/=primes[j];
                }
            }
            if(l[i]==1)break;
        }
        if(l[i]!=1){
            if(mp[l[i]])q=1;
            else mp[l[i]]++;
        }
        if(q==1)break;
    }
    if(q==0){
        cout<<"pairwise coprime";
    }
    else{
        if(z==1)cout<<"setwise coprime";
    
    else cout<<"not coprime";
    }
    

    return 0;
    }

// Done:)









Measured memory_bytes: 11476
#include<stdio.h>
int main()
{
    int i;
    int a[5];
    for(i=1; i<=5; i++){
        scanf("%d",&a[i]);
    }
    for(i=1; i<=5; i++){
        if(a[i]==0)
            printf("%d\n",i);
    }
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;

    vector<vector<char>> upper(50, vector<char>(100, '.'));
    vector<vector<char>> lower(50, vector<char>(100, '#'));
    int sx = 0, sy = 0;
    for(int i=0; i<b-1; i++){
        upper[sx][sy] = '#';
        sy += 2;
        if(sy == 100){
            sx += 2;
            sy = 0;
        }
    }
    sx = 49; sy = 0;
    for(int i=0; i<a-1; i++){
        lower[sx][sy] = '.';
        sy += 2;
        if(sy == 100){
            sx -= 2;
            sy = 0;
        }
    }

    cout << 100 << " " << 100 << endl;
    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            cout << upper[i][j];
        }cout << endl;
    }
    for(int i=0; i<50; i++){
        for(int j=0; j<100; j++){
            cout << lower[i][j];
        }cout << endl;
    }
    return 0;
}

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

int main(){
	int A, B;
	cin >> A >> B;
	rep(i, 1009) {
		if ((int)((i + 1) * 0.08) == A && (int)((i + 1) * 0.1) == B) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    ll N,A,B;
    cin >> N >> A >> B;
    if(A > B || (B - A >= 1 && N == 1)){
        cout << 0 << endl;
        return 0;
    }
    cout << max(0LL, (N-2) * (B-A)) + 1<< endl;
}

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

signed main() {
	string s;
	cin >> s;
	
	if (s.substr(5, 2) <= "04") {
		if (s.substr(8, 2) <= "30") {
			cout << "Heisei" << endl;
		}
		else {
			cout << "TBD" << endl;
		}
	}
	else {
		cout << "TBD" << endl;
	}
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  r pic S9(08).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1 a2.

        COMPUTE r = a1 - a2 - a2

        IF r < 0 THEN
          display "0"
        ELSE
          MOVE FUNCTION TRIM(r) to disp
          DISPLAY disp
        END-IF


       STOP RUN.


Measured memory_bytes: 764
n=int(input())
a=[int(input())for _ in[0]*n]
for i in range(4):
 for j in range(n-1,i,-1):
  if a[i]>a[j]:a[i],a[j]=a[j],a[i]
p=[]
for i in range(3):
 for d in a[i+1:4]:
  c=a[i]
  p+=[int(f'{c}{d}'),int(f'{d}{c}')]
print(sorted(p)[2])


Measured memory_bytes: 5988
// g++ -std=gnu++1y -O2 -I/opt/boost/gcc/include -L/opt/boost/gcc/lib -o ./a.out ./X.cpp & a.out //
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    int n; cin >> n;
    
    vector<int> h;
    
    for(int i = 0; i < n; i++)
    {
		int x; cin >> x;
		
		h.pb(x);
	}
	
	map<int, int> m;
	ll ans = 0;
	
	for(int i = 0; i < n; i++)
	{
		m[i+h[i]]++;
		ans+=m[i-h[i]];
	}
	
	cout << ans << '\n';
	
    
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  for(int i = 0; i < 3; i++){    
    if(N % 10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3652
#include<iostream>
    #include<vector>
    #include<algorithm>
    #include<set>
    #include<map>
    #include<queue>
    #include<cmath>
    #include<iomanip>
    #include<cstring>
    #define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair<int,int>
    #define ll long long
    #define pll pair<ll,ll>
    #define rep(i,n) for(int i=0;i<n;i++)
    #define repd(i,n) for(int i=n-1;i>=0;i--)
    #define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define inf 1e9+1
    #define inf1 1e18+1
    #define mod 1000000007
    #define pie 3.14159265358979323846
    #define N 1000005
    #define mid(l,r) l+(r-l)/2
    using namespace std;
    int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
    int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
    void mad(ll &a,ll b){a=(a+b)%mod;if(a<0)a+=mod;}
    ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
    void solve(){
    	ll l,r;
    	cin>>l>>r;
    	ll pro=1e18;
    	for(ll int i=l;i<=min(l+2018,r);i++){
    		for(ll int j=i+1;j<=min(l+2018,r);j++){
    			pro=min(pro,(ll)((i*j)%2019));
    		}
    	}
    	cout<<pro;
    }
    int main()
    {
    	waste;
    	int t;
    	//cin>>t;
    	t=1;
    	while(t--){
    		solve();
    	}
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll p[20],c[20];
signed main(){
	ll d,g;cin>>d>>g;
	rep(i,d){
		cin>>p[i]>>c[i];
	}
	ll Min=INT_MAX;
	rep(i,1<<d){
		ll cnt=0;
		ll sum=0;
		rep(j,d){
			if(i>>j&1){
				cnt+=p[j];
				sum+=p[j]*100*(j+1)+c[j];
			}
		}
		for(int j=d-1;j>=0;j--){
			if(i>>j&1)continue;
			int a=p[j];
			while(sum<g&&a){
				a--;
				sum+=100*(j+1);
				cnt++;
			}
		}
		if(sum>=g)Min=min(Min,cnt);
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  COMinit();
  ll n, k;
  cin >> n >> k;

  vector<ll> mods(min(k, n) + 1, 0);

  for (auto mod = 0; mod <= min(k, n); mod++)
  {
    mods[mod] = mod == 0 ? (n - mod) / k : (n - mod) / k + 1;
  }

  ll cnt = mods[0] * mods[0] * mods[0];
  if (k % 2 == 0 && k / 2 <= n)
  {
    cnt += mods[k / 2] * mods[k / 2] * mods[k / 2];
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


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


int main(){
  int n;
  cin >> n;
  vector<long long> v(n);
  rep(i, 0, n){
    cin >> v[i];
  }
  sort(all(v));

  deque<long long> d;
  d.push_front(v[0]);

  int r = n-1;
  int l = 1;
  while(r >= l){
    d.push_front(v[r]);
    r--;
    if(r < l) break;
    d.push_back(v[r]);
    r--;
    if(r < l) break;
    d.push_front(v[l]);
    l++;
    if(r < l) break;
    d.push_back(v[l]);
    l++;
  }
  // for (auto it: d){
  //   cout << it << " ";
  // }
  // cout << endl;
  long long ans = 0;
  for (int i=0; i<n-1; i++){
    ans += abs(d[i] - d[i+1]);
  }

  d.erase(all(d));
  // for (auto it: d){
  //   cout << it << endl;
  // }
  d.push_front(v[n-1]);

  r = n-2;
  l = 0;
  while(r >= l){
    d.push_front(v[l]);
    l++;
    if(r < l) break;
    d.push_back(v[l]);
    l++;
    if(r <l) break;
    d.push_front(v[r]);
    r--;
    if(r < l) break;
    d.push_back(v[r]);
    r--;
  }
  // for (auto it: d){
  //   cout << it << " ";
  // }
  // cout << endl;
  long long ans2 = 0;
  for (int i=0; i<n-1; i++){
    ans2 += abs(d[i] - d[i+1]);
  }
  cout << max(ans, ans2) << endl;
}


Measured memory_bytes: 1920
import java.util.*;

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


Measured memory_bytes: 48708
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string S = Console.ReadLine ();
            int ans = 0;
            int count = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
                {
                    count++;
                }
                else
                {
                    ans = Max (ans, count);
                    count = 0;
                }

                if (i == S.Length - 1) ans = Max (ans, count);
            }
            Console.WriteLine (ans);
        }
    }

    class MyLibrary
    {
        public static int GCD (int a, int b)
        {
            if (a % b == 0) return b;
            return GCD (b, a % b);
        }
    }
}

Measured memory_bytes: 25944
import java.io.*;
import java.util.*;
import java.math.*;

class Main {
    static FastReader r = new FastReader();
    static PrintWriter p = new PrintWriter(new BufferedOutputStream(System.out), true);
    public static void main(String[] args) {
        int h = r.nextInt(), w = r.nextInt();
        final int n = 10;
        int[][] price = new int[n][n];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                price[i][j] = r.nextInt();
        
        //Floyd Warshall
        for (int k = 0; k < n; ++k)
            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    price[i][j] = Math.min(price[i][j], price[i][k] + price[k][j]); 

        long count = 0;
        for (int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) {
                int a;
                if ((a = r.nextInt()) == -1)
                    continue;
                count += price[a][1];
            }
        outln(count);
    }
    static Object out(Object o) {
        return out(o, true);
    }
    static Object out(Object o, boolean autoFlush) {
        p.print(o);
        if (autoFlush)
            p.flush();
        return o;
    }
    static Object outln(Object o) {
        p.println(o);
        return o;
    }
    static void outln() {
        p.println();
    }
    static class FastReader {
        BufferedReader br; 
        StringTokenizer st; 
        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in)); 
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException e) {
                    e.printStackTrace(); 
                }
            }
            return st.nextToken(); 
        }
        char nextChar() {
            try {
                return (char)br.read();
            } catch (IOException e) {
                return '\0';
            }
        }
        int nextInt() {
            return Integer.parseInt(next()); 
        }
        long nextLong() {
            return Long.parseLong(next()); 
        }
        double nextDouble() {
            return Double.parseDouble(next()); 
        }
        float nextFloat() {
            return Float.parseFloat(next()); 
        }
        String nextLine() {
            try {
                return br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace();
                return "";
            }
        }
        void close() {
            try {
                br.close();
            } catch (Exception e) {}
        }
    }
}

Measured memory_bytes: 25684
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2, 3), 6)

    def test_2(self):
        self.assertEqual(think(123, 456), 18696)

    def test_3(self):
        self.assertEqual(think(100000, 99999), 9999900000)


def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    return lcm(a, b)


def write(result):
    print(result)


def lcm(a, b):
    return (a * b) // gcd(a, b)


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if a % b == 0:
        return b
    return gcd(b, a % b)


if __name__ == '__main__':
    # unittest.main()
    solve()


Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FR(i,a,b) for(int i=a; i<b; ++i)
#define BR(i,a,b) for(int i=(b-1); i>=0; --i)
#define FA(i,a) for(auto i : a)
#define PB emplace_back
#define trace(x) cerr<<#x<<":"<<x<<'\n';
#define trace2(a,n) { cerr<<#a<<" = "; FR(_,0,n) cerr << a[_] << ' '; cerr <<'\n'; }


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

	vector<int> a(3);
	for(int i=0; i<3; ++i){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	cout<<a[2]*10 + a[1] + a[0] <<'\n';

	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N;
string s[100000];
vector<int> path;

bool dfs(int n, int a, int b, int c) {
    if (a < 0 || b < 0 || c < 0) return false;
    if (n == N) return true;

    if (s[n] == "AB") {
        path.push_back(0);
        if (dfs(n + 1, a + 1, b - 1, c)) return true;
        path.pop_back();

        path.push_back(1);
        if (dfs(n + 1, a - 1, b + 1, c)) return true;
        path.pop_back();
    } 
    else if (s[n] == "AC") {
        path.push_back(0);
        if (dfs(n + 1, a + 1, b, c - 1)) return true;
        path.pop_back();

        path.push_back(2);
        if (dfs(n + 1, a - 1, b, c + 1)) return true;
        path.pop_back();
    }
    else {
        path.push_back(1);
        if (dfs(n + 1, a, b + 1, c - 1)) return true;
        path.pop_back();

        path.push_back(2);
        if (dfs(n + 1, a, b - 1, c + 1)) return true;
        path.pop_back();
    }
    return false;
}

int main() {
    int A, B, C;
    cin >> N >> A >> B >> C;
    REP(i, N) cin >> s[i];
    if (!dfs(0, A, B, C)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    string ABC = "ABC";
    for (int p : path) cout << ABC[p] << endl;
    return 0;
}

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

int main() {
    int n,y;
    cin >> n >> y;
    int a= -1, b = -1, c = -1;
    for (int i = 0; i < n + 1; i++) {
        for (int j = 0; j < n - i + 1; j++) {
            int n_d = n - i - j;
            int total = 10000 * i + 5000 * j + 1000 * n_d;
            if (total == y) {
                a = i;
                b = j;
                c = n_d;
            }
        }
    }
    cout << a << ' ' << b << ' ' << c << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(a +b / 2);
    }
}

Measured memory_bytes: 21716
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
      
        static void Main(string[] args)
        {
            
            string[] str = Console.ReadLine().Split(' ');
            long N = long.Parse(str[0]);
            long K = long.Parse(str[1]);

            long[] data = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            long L_cost = 0;
            long R_cost = 0;
            long ans_cost = long.MaxValue;

            long l = 0;
            long r = K - 1;

            for(long i = r; i < N; i++)
            {
                L_cost = Math.Abs(data[l]) + Math.Abs(data[l] - data[r]);
                R_cost = Math.Abs(data[r]) + Math.Abs(data[l] - data[r]);
                long tmp = Math.Min(L_cost, R_cost);
                if (ans_cost > tmp) ans_cost = tmp;
                l++;
                r++;
            }

            Console.WriteLine(ans_cost);

        }
    }
}


Measured memory_bytes: 22880
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string o, e;
  cin >> o >> e;
  string ans = "";
  int siz = max(o.length(), e.length());
  rep(i,siz) {
    if (i < (int)o.length()) ans += o[i];
    if (i < (int)e.length()) ans += e[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# 2019/09/01
# AtCoder Beginner Contest 139 - B

# Input
a, b = map(int,input().split())

# Calc
sum_s = 1
cnt = 0
while(sum_s < b):
    sum_s = sum_s + (a - 1)
    cnt = cnt + 1

ans = cnt

# Output
print(ans)


Measured memory_bytes: 2940
def solve(n, m, x_list):
    if n >= m:
        return 0

    # time O(M log(M))
    x_list.sort()

    # time O(M)
    diff_list = []
    for key in range(m - 1):
        diff = x_list[key + 1] - x_list[key]
        diff_list.append(diff)

    # time O(M log(M))
    diff_list.sort(reverse=True)

    return sum(diff_list[n-1:])


def main():
    n, m = map(int, input().split())
    x_list = list(map(int, input().split()))

    ans = solve(n, m, x_list)
    print(ans)


main()


Measured memory_bytes: 13968
import sys
#import copy
#import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    # input
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if i%3 != 0 and i%5 != 0:
            ans += i

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#include <iostream>
using namespace std;
int n, s, d, r;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &s, &d); r = 0;
		while (s != d) {
			for (int j = 30; j >= 0; j--) {
				if (abs(s) % (1 << j) == 0 && s + (1 << j) <= d) {
					s += (1 << j), r++; break;
				}
			}
		}
		printf("%d\n", r);
	}
	return 0;
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long int sum=0;
    for(long long int i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            continue;
        }
        else
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 1e5 + 10;

int m, d;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> m >> d;

	int ans = 0;

	for (int j = 1; j <= m; j++)
	for (int i = 22; i <= d; i++) {
		if (i % 10 == 1) continue;
		if ((i % 10) * (i / 10) == j) {
			ans++;
		}
	}

	cout << ans << endl;
 
	return 0;
}

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

int main(){
  int n,s=0;
  cin >> n;
  vector<int> v(n),c(n);
  for(int i=0;i<n;i++)
    cin >> v[i];
  for(int i=0;i<n;i++)
    cin >> c[i];
  for(int i=0;i<n;i++){
  	if(v[i]-c[i]>=0)
      s+=v[i]-c[i];
  }
  cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    string s;
    cin >> s;
    deque<char> q;
    Int n = (Int)s.size();
    for (Int i = 0; i < n; i++) q.push_back(s[i]);
    Int res = 0;
    while (q.size() > 1) {
        if (q.front() == q.back()) {
            q.pop_back();
            q.pop_front();
        }
        else if (q.front() == 'x') {
            res++;
            q.pop_front();
        }
        else if (q.back() == 'x') {
            res++;
            q.pop_back();
        }
        else {
            dump(-1);
            return 0;
        }
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 512
H, W = gets.chomp.split(" ").map(&:to_i)
C = gets.chomp.split(" ").map(&:to_i)
D = gets.chomp.split(" ").map(&:to_i)
S = [Array.new(W+4, -2), Array.new(W+4, -2)]
H.times{
  S << [-2, -2] + gets.chomp.chars.map{|s| s=='#' ? -2 : -1} + [-2, -2]
}
S << Array.new(W+4, -2)
S << Array.new(W+4, -2)

def add_lst(c, r, stp, lst)
  (S[c][r] = stp; lst << [c, r]) if S[c][r] == -1
end

WP = (-2..2).to_a.product((-2..2).to_a).select{|c, r| c.abs+r.abs > 1}
idx,stp, nxt = 0, 0, []
add_lst(C[0]+1, C[1]+1, stp, nxt)

until nxt.empty? do
  while nxt.size > idx do
    c, r = nxt[idx]
    add_lst(c, r+1, stp, nxt)
    add_lst(c, r-1, stp, nxt)
    add_lst(c+1, r, stp, nxt)
    add_lst(c-1, r, stp, nxt)
    idx += 1
  end
  wrp = []
  stp += 1
  nxt.each{|c, r|
    WP.each{|i, j| add_lst(c+i, r+j, stp, wrp)}
  }
  idx, nxt = 0, wrp
end

puts S[D[0]+1][D[1]+1]


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

int main() {
  int A, B, C;
  cin >> A >> B;

  C = (A * B) % 2;
  
  if (C != 0) {
    cout << "Odd" << endl;
  }
  	else {
      cout << "Even" << endl;
    }

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
vector<int> G1[MAXN+5],G2[MAXN+5],G3[MAXN+5];
vector<int> need;
int tot1[MAXN+5],tot2[MAXN+5];
int col[MAXN+5],N;
int sta[MAXN+5],t;
void DFS1(int u)
{
	for(int i=0;i<(int)G1[u].size();i++)
	{
		int v=G1[u][i];
		DFS1(v);
	}
	if(tot1[u])	sta[++t]=u;
	while(t>=2)
	{
		G3[sta[t]].push_back(sta[t-1]);
		G3[sta[t-1]].push_back(sta[t]);
		t-=2;
	}
}
void DFS2(int u)
{
	for(int i=0;i<(int)G2[u].size();i++)
	{
		int v=G2[u][i];
		DFS2(v);
	}
	if(tot2[u])	sta[++t]=u;
	while(t>=2)
	{
		G3[sta[t]].push_back(sta[t-1]);
		G3[sta[t-1]].push_back(sta[t]);
		t-=2;
	}
}
void DFS3(int u)
{
	for(int i=0;i<(int)G3[u].size();i++)
	{
		int v=G3[u][i];
		if(col[v]!=-1)	continue;
		if(col[u]==1)	col[v]=2;
		else			col[v]=1;
		DFS3(v);
	}
}
int main()
{
	scanf("%d",&N);
	int f,rt1,rt2;
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&f);
		if(f==-1)	rt1=i;
		else		tot1[f]^=1,G1[f].push_back(i);
	}
	for(int i=1;i<=N;i++)
	{
		scanf("%d",&f);
		if(f==-1)	rt2=i;
		else		tot2[f]^=1,G2[f].push_back(i);
	}
	for(int i=1;i<=N;i++)
	{
		tot1[i]^=1,tot2[i]^=1;
		if(tot1[i]!=tot2[i])
		{
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}
	printf("POSSIBLE\n");
	t=0;
	DFS1(rt1);
	t=0;
	DFS2(rt2);
	memset(col,-1,sizeof(col));
	for(int i=1;i<=N;i++)
		if(col[i]==-1)
		{
			col[i]=1;
			DFS3(i);
		}
	for(int i=1;i<=N;i++)
		if(tot1[i]==0)
			printf("0 ");
		else if(col[i]==1)
			printf("1 ");
		else
			printf("-1 ");
	printf("\n");
	return 0;
}

Measured memory_bytes: 17408
S=raw_input()
l=len(S)

mod=10**9+7

all_strings=1
a=0
ab=0
abc=0

for i,s in enumerate(S):
	if s =="A":
		a+=all_strings
	elif s=="B":
		ab+=a
	elif s=="C":
		abc+=ab
	elif s=="?":
		abc*=3
		abc+=ab
		ab*=3
		ab+=a
		a*=3
		a+=all_strings
	if s == "?":
		all_strings*=3

	all_strings%=mod
	a%=mod
	ab%=mod
	abc%=mod

print abc



Measured memory_bytes: 32620
n=int(input())
a=[]
for i in range(n):
    aa=int(input())
    a.append(aa)
from collections import deque
a.sort()
a=deque(a)

omi=a.popleft()
oma=a.pop()
ans=abs(oma-omi)
ret=True

while len(a)>1:
    mi=a.popleft()
    ma=a.pop()

    if ret:
        mi,ma=ma,mi

    ans+=abs(omi-mi)+abs(oma-ma)
    omi,oma=mi,ma
    ret = not ret

if len(a)==1:
    aa=a.pop()
    ans+=max(abs(omi-aa),abs(oma-aa))

print(ans)

Measured memory_bytes: 13636
class Node(object):
    def __init__(self, num, prv = None, nxt = None):
        self.num = num
        self.prv = prv
        self.nxt = nxt


class DoublyLinkedList(object):
    def __init__(self):
        self.start = self.last = None

    def insert(self, num):
        new_elem = Node(num)

        if self.start is None:
            self.start = self.last = new_elem
        else:
            new_elem.nxt = self.start
            self.start.prv = new_elem
            self.start = new_elem

    def delete_num(self, target):
        it = self.start
        while it is not None:
            if it.num == target:
                if it.prv is None and it.nxt is None:
                    self.start = self.last = None
                else:
                    if it.prv is not None:
                        it.prv.nxt = it.nxt
                    else:
                        self.start = self.start.nxt

                    if it.nxt is not None:
                        it.nxt.prv = it.prv
                    else:
                        self.last = self.last.prv
                break
            it = it.nxt

    def delete_start(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.start.nxt.prv = None
            self.start = self.start.nxt

    def delete_last(self):
        if self.start is self.last:
            self.start = self.last = None
        else:
            self.last.prv.nxt = None
            self.last = self.last.prv

    def get_content(self):
        ret = []
        it = self.start

        while it is not None:
            ret.append(it.num)
            it = it.nxt

        return ' '.join(ret)


def _main():
    from sys import stdin

    n = int(input())

    lst = DoublyLinkedList()
    
    for _ in range(n):
        cmd = stdin.readline().strip().split()
        if cmd[0] == 'insert':
            lst.insert(cmd[1])
        elif cmd[0] == 'delete':
            lst.delete_num(cmd[1])
        elif cmd[0] == 'deleteFirst':
            lst.delete_start()
        elif cmd[0] == 'deleteLast':
            lst.delete_last()

    print(lst.get_content())


if __name__ == '__main__':
    _main()

Measured memory_bytes: 229124
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn print_graph(graph: &Vec<Vec<bool>>){
    for i in 0..graph.len(){
        println!("{:?}", graph[i]);
    }
    
}

fn main(){
    let line: Vec<usize> = read_as_vec();
    let (n, k) = (line[0], line[1]);

    let mut graph: Vec<Vec<bool>> = vec![vec![false;n];n];

    for i in 1..n{
        graph[0][i] = true;
        graph[i][0] = true;
    }

    //print_graph(&graph);

    let mut num_of_pairs = (n-1)*(n-2)/2;

    if num_of_pairs < k{
        println!("-1");
        return;
    }

    for i in 1..n{
        for j in i+1..n{
            if num_of_pairs == k{
                break;
            }
            graph[i][j] = true;
            graph[j][i] = true;
            num_of_pairs -= 1;
        }
    }
    //print_graph(&graph);
    println!("{}", n-1 + ((n-1)*(n-2)/2-num_of_pairs));
    for i in 0..n{
        for j in i+1..n{
            if graph[i][j]{
                println!("{} {}", i+1, j+1);
            }
        }
    }
} 


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s[0] != 'A'){
    cout << "WA\n";
    return 0;
  }
  int32 idx = -1;
  FOR(i,2,s.size()-1){
    if('A' <= s[i] && s[i] <= 'Z'){
      idx = i;
      break;
    }
  }
  if(idx == -1){
    cout << "WA\n";
    return 0;
  }
  FOR(i,1,s.size()){
    if(i == idx)continue;
    if('A' <= s[i] && s[i] <= 'Z'){
      cout << "WA\n";
      return 0;
    }
  }
  cout << "AC\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main() {
  Cin(int, n, a, b);
  Cins(int, n, p);

  int n1 = 0, n2 = 0, n3 = 0;
  for (auto e : p) {
    if (e <= a) n1++;
    if (a + 1 <= e && e <= b) n2++;
    if (b + 1 <= e) n3++;
  }

  cout << min({n1, n2, n3}) << endl;
}

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

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
alpha = Hash.new { |h, k| h[k] = [] }
len = s.length
for i in 0..len-1
  alpha[s[i]].push(i)
end

now = -1
re = 0
len2 = t.length
for i in 0..len2-1
  if alpha[t[i]].empty?
    puts -1
    exit
  end
  while true do
    if now < alpha[t[i]][0]
      now = alpha[t[i]][0]
      break
    else
      tmp = alpha[t[i]].bsearch {|x| x > now  }
      if tmp == nil
        now = -1
        re += 1
      else
        now = tmp
        break
      end
    end
  end
end

puts len * re + now + 1

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e17+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int a, b, n;
    cin >> a >> b >> n;
    int r = min(b-1, n);
    cout << r*a/b << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

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

string s;
bool ans;

int main(){
	cin>>s;
	int len = s.length();
	for(int i=0;i<len;i++)
	  for(int j=i;j<len;j++){
	  	 if(s[i] == 'C' && s[j] == 'F')
	  	    ans = 1;
	  }
	if(ans == 1)  printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a= sc.nextInt();
    int b= sc.nextInt();
    int c=(a+b)%24;
    System.out.println(c);
  }
}

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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
ll inf = 1e18;
ll tmp = 0;

vector <ll> vec[N];
pair <ll ,ll> p[N];
bool vst[N];

void dfs(int v){
    vst[v] = true;
    tmp ++;
    for(int i = 0 ; i < vec[v].size(); i ++){
        if(!vst[vec[v][i]]){
            dfs(vec[v][i]);
        }
    }
}

int main(){

    Fast;

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

    for(int i = 0 ; i < m; i ++){
        cin >> p[i].F >> p[i].S;
    }
    sort(p , p + m);

    int x = p[0].F , y = p[0].S;
    vec[p[0].F].pb(p[0].S);
    vec[p[0].S].pb(p[0].F);

    for(int i = 1; i < m ;i ++){
        if((x == p[i].F && y == p[i].S) || (x == p[i].S && y == p[i].F));
        else{
            x = p[i].F;
            y = p[i].S;
            vec[x].pb(y);
            vec[y].pb(x);
        }
    }

    ll ans = 0;

    for(int i = 1; i <= n ;i ++){
        if(!vst[i]){
            dfs(i);
            ans = max(ans , tmp);
            tmp = 0;
        }
    }

    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 24072
n, m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]
ans = 0
for i in range(1, m+1):
    cnt = 0
    for j in range(n):
        if i in a[j][1:]:
            cnt += 1
    if cnt == n:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <cstdio>  
#include <cstring>  
#include <algorithm>  
#include <queue>  
#include <iostream>  
#include <string>  
#include <cmath>  
#include <vector>  
#include <set>  
#include <map>  
#include <bitset>  
#include <stack>  
using namespace std;  
  
#define REP(i,n) for ( int i=1; i<=int(n); i++ )    
#define MP make_pair  
#define PB push_back  
#define SZ(x) (int((x).size()))  
#define ALL(x) (x).begin(), (x).end()  
#define X first  
#define Y second  
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }  
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }  
  
typedef long long LL;  
typedef long double LD;  
const int INF = 0x3f3f3f3f;  
typedef pair<int, int> pii;

const int N = 1e6 + 10;
int a[N];
int main() {
	int n, x;
	cin >> n >> x;
	if(x == 1 || x == 2 * n - 1) puts("No");
	else {
		puts("Yes");
		for(int i = 0; i < 2 * n - 1; i ++) {
			int p = (n - 1 + i) % (2 * n - 1);
			a[p] = x;
			x = x % (2 * n - 1) + 1;
		}
		for(int i = 0; i < 2 * n - 1; i ++) printf("%d\n", a[i]);
	}
}


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

int N,A,B,C;
  vector<int>l(8);
  
int dfs(int k, int a, int b, int c){
 if(k==N){
   if(a>0 && b>0 && c>0){return abs(A-a)+abs(B-b)+abs(C-c)-30;}// a,b,cは合成済み(A-aが最小になるまでa=a+l[k]の加算を繰り返している)
   else{return 999999999;}// A-a,B-b,C-cの絶対値が最小になる値が、毎度の各合成コスト＋10と共にansに入る
   
 }  // kがNまで達したときにa,b,c>0であれば答えを返す。そうでないならエラー
 
 int ans=dfs(k+1, a, b, c);
   ans=min(ans, dfs(k+1, a+l[k], b, c)+10);// A-aがより小さくなるreturnがansに入る。
   ans=min(ans, dfs(k+1, a, b+l[k], c)+10);// 同様のことをB-b, C-cにもやり、その度に＋10がansに入る
   ans=min(ans, dfs(k+1, a, b, c+l[k])+10);// 一番最初のk=0における3つの各＋10は余計なので－30で引く
   return ans;
}
  
int main(){
cin>>N>>A>>B>>C;
  for(int i=0; i<N; i++){
    cin>>l[i]; }
  
 cout<<dfs(0, 0, 0, 0); 
}

Measured memory_bytes: 256
#include<stdio.h>
#define RATE 1.05/*利子*/

int main()
{
	long int money=100000,kiri;/*借り入れ,商*/
	int n;/*経過期間*/
	int i;

	do
	{
		scanf("%d",&n);
	}while(n<=0 || 100<n);

	for(i=0;i<n;i++)
	{
		money *=1.05;
		kiri = money/1000;

		if(money%1000 !=0)
			money = kiri*1000+1000;
	}

	printf("%ld\n",money);

	return 0;
}

Measured memory_bytes: 592
from collections import defaultdict
from operator import itemgetter
N = int(input())

d = defaultdict(list)
for i in range(1,N+1):
    s, p = input().split()
    d[s].append((i, int(p)))

for k,vs in sorted(d.items(), key=itemgetter(0)):
    for i,p in sorted(vs, key=itemgetter(1), reverse=True):
        print(i)

Measured memory_bytes: 3316
#include<cstdio>
using  namespace std;
int  main () {
  int a, arr[108], max, jum=0;
  scanf("%d", &a);
  for(int i=0; i<a; i++){
  scanf("%d", &arr[i]);
  }
  max=arr[0];
  for(int i=0; i<a; i++) {
   if (max<=arr[i]){
    max=arr[i];
    jum++;
   }
  }
  printf("%d\n", jum);
}


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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

void include3(int x,const int &i);

void check_num(const int &i){
  int x = i;
  if(x % 3 == 0){
    cout << " " << i;
    return;
  }else{
    include3(x,i);
  }
}

void include3(int x,const int &i){
  if(x % 10 == 3){
    cout << " " << i;
    return;
  }
  x /= 10;

  if(x){
    include3(x,i);
  }
}




int main(){
  int i = 1,n;

  cin >> n;
  
  while(true){
    check_num(i);

    if( ++i > n){
      break;
    }
  }

  cout << endl;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define pob pop_back
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
int INF = 1e9 + 1;
int MOD = 1e9+7;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main(){
int n;
  cin >> n;
  if(n<1200){
cout <<"ABC";
  }
  else if(n<2800){
  cout << "ARC";
  }else{
  cout << "AGC";
  }
}

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

int main() {
  string S;
  cin >> S;
  bool b = false;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    b = true;
  }
  else if(S.at(1) == S.at(2) && S.at(2) == S.at(3)) {
    b = true;
  }
  if(b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

signed main() {

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    rep(i, n){
        cin >> h[i];
    }
    vector<vector<int>> graph(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    int ans = 0;
    rep(i, n){
        bool ok = true;
        for(int x : graph[i]){
            if(h[i] <= h[x]){
                ok = false;
                break;
            }
        }
        if(ok){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9804
import java.util.Scanner;

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

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  LL n;
  cin >> n;
  LL now=1;
  int ans=0;
  while(now<n){
    now*=3;
    ans++;
  }
  cout << ans << endl;
  return 0;
}



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

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

  for (int i = 0; i < S.size(); i++){
    if (S.at(i) == '/') S.at(i) = '-';
  }
  cout << (S > "2019-04-30" ? "TBD" : "Heisei") << endl;
}

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

int main()
{
  int d;
  cin >> d;
  if(d == 25)
  {
    cout << "Christmas" << endl;
  }
  else if(d == 24)
  {
    cout << "Christmas Eve" << endl;
  }
  else if(d == 23)
  {
    cout << "Christmas Eve Eve" << endl;
  }
  else if(d == 22)
  {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}

Measured memory_bytes: 256