akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char s1[51];
    char s2[51];
    scanf("%s",s1);
    scanf("%s",s2);
   int x=strlen(s1)+strlen(s2);
    int i=0,j=0,k;
    for(k=1;k<=x;k++){
          if(k%2==1){
          printf("%c",s1[i]);i++;
        }
        else{
             printf("%c",s2[j]);j++;}
    }
     cout<<endl;


}

Measured memory_bytes: 256
#include <iostream>

int main() {

  int A;
  int B;

  std::cin >> A >> B;
  if (A == 1) {
    A = 14;
  }
  if (B == 1) {
    B = 14;
  }

  if (A > B) {
    std::cout << "Alice" << std::endl;
  } else if (A < B) {
    std::cout << "Bob" << std::endl;
  } else {
    std::cout << "Draw" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int i=1;
    while(true){
        if(i%A==0 & i%B==C){
            cout << "YES" << endl;
            return 0;
        }
        if(i > 5050){
            cout << "NO" << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007

ll gcd(ll a, ll b) {
	if (a < b)return gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}


int main(){
	ll A, B, C, D; cin >> A >> B >> C >> D;
	ll cd = gcd(C, D);
	ll o = cd;
	o *= (C / cd); o *= (D / cd);

	//1<=target<=B
	ll n1 = B / C;
	ll n2 = B / D;
	ll n3 = B / (o);
	ll ans1 = n1 + n2 - n3;
	//1<=target<A
	ll x1 = (A%C==0) ? A/C - 1: A/C;
	ll x2 = (A%D==0) ? A/D - 1: A/D;
	ll x3 = (A%(o)==0) ? A/(o) - 1: A/(o);
	ll ans2 = x1 + x2 - x3;
	print(B - A + 1 - (ans1 - ans2));




	return 0;
}

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

using namespace std;

bool is_palindrome(string s) {
    int i = 0;
    int j = s.length() - 1;
    while (i < j) {
        if (s[i] != s[j]) return false;
        i++;
        j--;
    }
    return true;
}

int main() {

    string s;
    cin >> s;
    bool flag = 1;
    int n = s.length();
    bool ok = is_palindrome(s);
    if (!ok) flag = 0;
    ok = is_palindrome(s.substr(0, (n - 1) / 2));
    if (!ok) flag = 0;
    ok = is_palindrome(s.substr(((n + 3) / 2 - 1), (n - ((n + 3) / 2 - 1))));

    if (!ok) flag = 0;
    if (flag) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

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

using namespace std;

const long long inf = 1e18;

int main() {
	long long n, x;

	cin >> n >> x;

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	vector<vector<long long>> min_costs(n, vector<long long>(n, inf));
	for (int i = 0; i < n; i++) {
		min_costs[0][i] = a[i];
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < n; j++) {
			min_costs[i][j] = min(min_costs[i-1][j], 1LL * a[(j - i + n) % n]);
		}
	}

	long long ans = inf;
	for (int i = 0; i < n; i++) {
		long long score = (long long) x * i;
		for (int j = 0; j < n; j++) {
			score += min_costs[i][j];
		}
		ans = min(ans, score);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    string n; cin >> n;
    if (n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3600
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/


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



int main()
{
    int q=1;
   // cin>>q;
    while(q--)
    {
        int n,k; 
        cin>>n>>k;
        int a[n+1];
        for(int i=1; i<=n; i++)
    cin>>a[i];
  int dp[n+1];
  dp[1]=0;
  dp[2]=abs(a[2]-a[1]);
  
   for(int i=3; i<=n; i++)
   dp[i]=INT_MAX;
   
  for(int i=3; i<=n; i++)
  for(int j=1; j<i&&j<=k; j++)
    dp[i]=min(dp[i],(abs(a[i]-a[i-j])+dp[i-j]));
    
  cout<<dp[n];
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)

int main(void) 
{
	vector<int> dp(100001, 0);
	int N; cin >> N;
	vector<int> h(N); rep(i, 0, N)cin >> h[i];
	dp[2] = abs(h[1] - h[0]);
	rep(i, 3, N + 1) {
		dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i - 2]), dp[i - 2] + abs(h[i - 1] - h[i - 3]));
	}
	cout << dp[N] << endl;
}


Measured memory_bytes: 1024
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);

            int ans = (a * c) > b ? b / a : c;
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
S = input()
T = input()

def strshape(s):
    d = {}
    ret = []
    idx = 0
    for ch in s:
        if ch not in d:
            d[ch] = idx
            idx += 1
        ret.append(d[ch])
    return ret

if strshape(S) == strshape(T):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 6832
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>


int main() {
	int p, q, r; std::cin >> p >> q >> r;
	std::cout << p + q + r - std::max({ p, q, r }) << std::endl;
}


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

typedef long long ll;

class UnionFindTree{
  public:
    int size;
    vector< int > parent;
    vector< int > rank;
    vector< int > sizes;

    UnionFindTree(int n):
      size(n), parent(n, -1), rank(n, 0), sizes(n, 1){}

    int root(int x){
      return ((parent[x] < 0) ?
          x : parent[x] = root(parent[x]));
    }

    int get_size(int v){
      return sizes[root(v)];
    }

    bool unite(int x, int y){
      int rx = root(x), ry = root(y);
      if(rx == ry){
        return false;
      }
      if(rank[rx] < rank[ry]){
        parent[rx] = ry;
        sizes[ry] += sizes[rx];
      }
      else{
        parent[ry] = rx;
        sizes[rx] += sizes[ry];
      }
      if(rank[rx] == rank[ry]){
        ++rank[rx];
      }
      --size;
      return true;
    }

    bool same(int x, int y){
      return root(x) == root(y);
    }
};

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

  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }

  ll ans[m];
  UnionFindTree uft(n);
  ll sum = (ll)n * (n - 1) / 2;
  for(int i = m - 1; i >= 0; i--){
    ans[i] = sum;
    if(!uft.same(a[i], b[i])){
      ll ca = uft.get_size(a[i]);
      ll cb = uft.get_size(b[i]);
      uft.unite(a[i], b[i]);
      sum -= ca * cb;
    }
  }

  string buf;
  for(int i = 0; i < m; i++){
    buf += to_string(ans[i]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> a(m);
    vector<uint64_t> c(m);
    for (auto i : irange(0L, m)) {
        int64_t b;
        cin >> a[i] >> b;

        for (auto _ : irange(0L, b)) {
            int64_t cc;
            cin >> cc;
            --cc;
            c[i] |= (1uL << cc);
        }
    }

    vector<int64_t> dp(1uL << n, numeric_limits<int64_t>::max());
    dp[0] = 0;
    for (auto i : irange(0uL, 1uL << n)) {
        if (dp[i] == numeric_limits<int64_t>::max()) {
            continue;
        }
        for (auto key : irange(0L, m)) {
            auto next_key = (i | c[key]);
            dp[next_key] = min(dp[next_key], dp[i] + a[key]);
        }
    }

    if (dp[(1uL << n) - 1] == numeric_limits<int64_t>::max()) {
        cout << -1 << endl;
    } else {
        cout << dp[(1uL << n) - 1] << endl;
    }
}

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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n;
    int a[n],b[n],c[n-1];
    rep(i,0,n-1) cin>>a[i];
    rep(i,0,n-1) cin>>b[i];
    rep(i,0,n-2) cin>>c[i];
    rep(i,0,n-1){
        ans+=b[i];
        if(a[i]+1==a[i+1]&&i<n-1){
            ans+=c[a[i]-1];
        }
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);

int ubound(vector<long long>&v, long long b){
	int s = 0, e = v.size() - 1;
	int l = v.size();
	int m;
	while(e - s > 1){
		m = (s + e) / 2;
		if(v[m] <= b){
			s = m;
		}
		else{
			e = m;
		}
	}
	if(v[max(s - 1, 0)] > b) return max(s - 1, 0);
	else if(v[s] > b) return s;
	else if(v[min(s + 1, l - 1)] > b) return min(s + 1, l - 1);
	else return v.size();
}

long long N, C ,K;
vector<long long> T;
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> C >> K;
	for(int i=0; i<N; i++){
		long long t;
		cin >> t;
		T.push_back(t);
	}
	sort(T.begin(), T.end());

	long long ans = 0;
	long long s = T[0];
	int spos = 0;
	auto its = T.begin();
	while(its != T.end()){
		long long e = s + K;
		int epos = ubound(T, e);
		auto ite = upper_bound(T.begin() + spos, T.end(), e);
		ans++;
		if(epos - spos <= C){
			spos = epos;
			s = T[spos];
			its = ite;
		}
		else{
			spos = spos + C ;
			s = T[spos];
			its = T.begin() + spos;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4272
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ans = 0;
    ll t = max(0LL,x/11 - 5);
    ans  = 2*t;
    ll y = t*11;
    ll cur = 0;
    while(true){
        if(y >= x)break;
        if(cur%2 == 0){
            ans++;
            y+=6;
        }else{
            ans++;
            y+=5;
        }
        cur++;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

int n;
cin >> n;
int checker = 0;

int num;

for(int i=0;i<n;i++){
	cin >> num;
	if(num%2==0){
		if(num%3!=0 && num%5!=0){
		checker++;
		break;
		}
		
	}
}
if(checker==0)
cout << "APPROVED\n";
else
cout << "DENIED\n";

return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
  ll h = 0;
  ll w = 0;
  cin >> h >> w;
  ll result = 0;
  if(h == 1 || w == 1) {
    result = 1;
  } else if(h % 2 == 1 && w % 2 == 1) {
    result = (h * w + 1) >> 1;
  } else {
    result = (h * w) >> 1;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

func main() {
	s := next()
	fmt.Println(strings.Replace(s, "2017", "2018", 1))
}


// -------- Library --------
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	v, _ := strconv.Atoi(next())
	return v
}

func nextIntArray(size int) []int {
	res := make([]int, size)
	for i := 0; i < size; i++ {
		res[i] = nextInt()
	}
	return res
}

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

int main() {
    long long A, B, C; cin >> A >> B >> C;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
    else cout << min({A*B, B*C, C*A}) << endl;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let mut n = get!(i64);
    if n == 0 {
        println!("0");
        return;
    }
    let mut i = 1;
    let mut s = Vec::new();
    while n != 0 {
        if n % 2_i64.pow(i) != 0 {
            s.push('1');
            n -= (-2_i64).pow(i - 1);
        } else {
            s.push('0');
        }
        //n = n >> 1;
        i += 1;
    }
    s.reverse();
    let mut ans = String::new();
    for i in 0..s.len() {
        ans.push(s[i])
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950
#define print(a, n, m)     for (ll i = n; i < m; i++) {  cout << a[i] << " "; }  cout << endl
#define con continue

bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool isPerfectSquare(ll x) {   
  long double sr = sqrt(x); 
  return ((sr - floor(sr)) == 0); 
} 
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss < b.ss;
    return (a.ff > b.ff); 
}
//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////

void solve()
{
    
    ll n,m;
    cin>>n>>m;

    cout<<n*m;


    return;
}
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 3600
implicit none

integer :: n
character(100000) :: s
integer :: i, j, R, L, i_begin, nblock
integer, allocatable :: n_R(:), n_L(:)
logical :: flg_RL, flg_space

read *, s
n = len_trim(s)

allocate(n_R(n))
allocate(n_L(n))

flg_RL = .false.
i_begin = 1
nblock = 1

do i = 1, n-1
   if (.not. flg_RL) then
      if (s(i:i) == 'R' .and. s(i+1:i+1) == 'L') then
         n_R(nblock) = i - i_begin
         flg_RL = .true.
      endif
   else
      if (s(i+1:i+1) == 'R') then
         n_L(nblock) = i - i_begin - n_R(nblock) - 1
         i_begin = i + 1
         nblock = nblock + 1
         flg_RL = .false.
      endif
   endif
enddo

n_L(nblock) = n - i_begin - n_R(nblock) - 1

flg_space = .false.

do i = 1, nblock
   if (flg_space) then
      write(6,'(a)',advance='no') ' '
   endif

   do j = 1, n_R(i)
      write(6,'(a)',advance='no') '0 '
   enddo

   R = 1
   L = 1
   if (mod(n_R(i),2) == 0) then
      R = R + n_R(i) / 2
      L = L + n_R(i) / 2
   else
      R = R + n_R(i) / 2
      L = L + n_R(i) / 2 + 1
   endif

   if (mod(n_L(i),2) == 0) then
      R = R + n_L(i) / 2
      L = L + n_L(i) / 2
   else
      R = R + n_L(i) / 2 + 1
      L = L + n_L(i) / 2
   endif

   write(6,'(i0,1x,i0)', advance='no') R, L

   do j = 1, n_L(i)
      write(6,'(a)',advance='no') ' 0'
   enddo
   
   flg_space = .true.
enddo

write(6, '(a)') ''
stop
end

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i]>>b[i];
    reverse(begin(a),end(a));
    reverse(begin(b),end(b));
    ll ans=0;
    //cout_vec(a);
    rep(i,n){
      a[i]+=ans;
      if(a[i]%b[i]==0) continue;
      ll ret=0;
      if(a[i]<=b[i]) ret=b[i]-a[i];
      else ret=b[i]-a[i]%b[i];
      a[i]+=ret;
      ans+=ret;
      //cout<<ans<<endl;
    }
    //cout_vec(a);
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class Diameter
{
public:
  int nv;
  vector<vector<pair<int,int>>> adj;
  Diameter(){}
  Diameter( int nv ) : nv( nv )
  {
    adj.resize( nv );
  }
  void setAdj( int u, int v, int w );
  void longestPath( int &s, int &t, int &l );
  void dfs( vector<bool>& visited, vector<int>& d, int s );
};

void Diameter::setAdj( int u, int v, int w )
{
  adj[u].push_back( make_pair( v, w ) );
  adj[v].push_back( make_pair( u, w ) );
  return;
}

void Diameter::dfs( vector<bool>& visited, vector<int>& d, int s )
{
  for ( auto it = adj[s].begin(); it != adj[s].end(); ++it )
    {
      int t = (*it).first;
      int w = (*it).second;
      if ( ! visited[t] )
        {
          d[t] = d[s] + w;
          visited[t] = true;
          dfs( visited, d, t );
        }
    }
}

void Diameter::longestPath( int &s,  int &t, int &l )
{
  const int infty = -2147483648;
  vector<bool> visited( nv, false );
  vector<int> d( nv, infty );

  d[s] = 0;
  visited[s] = true;

  dfs( visited, d, s );
  
  l = infty;
  
  for ( auto i = 0; i < nv; ++i )
    {
      if ( d[i] > l )
        {
          l = d[i];
          t = i;
        }
    }
}

int main()
{
  int n;
  cin >> n;
  
  Diameter d( n );

  for ( auto i = 0; i < n - 1; ++i )
    {
      int u, v, w;
      cin >> u >> v >> w;
  
      d.setAdj( u, v, w );
    }

  int x, y, l;
  
  x = 0;
  
  d.longestPath( x, y, l );
  d.longestPath( y, x, l );
  
  cout << l << endl;
  
  return 0;
}

Measured memory_bytes: 14724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<ll>
#define pb push_back
#define ff first
#define ss second
#define inf 2e18
#define ull unsigned long long
#define pi acos(-1.0)
#define mod 1000000007
#define lop0(n) for(ll i=0;i<n;i++)
#define lopj(n) for(ll j=0;j<n;j++)
#define lop1(n) for(ll i=1;i<=n;i++)
#define all(v) v.begin(),v.end()
ll Set(ll N,ll pos){ return N=N | (1LL<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1LL<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1LL<<pos)); }
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll dp[2005];
ll solve(ll n)
{
    if(n==0) return 1;
    if(n<=2) return 0;
    if(n>=3 and n<=5) return 1;

    if(dp[n]!=-1) return dp[n];
    ll ans=0;
    for(ll i=3;i<=n;i++)
    {
        ans+=mod;
        ans%=mod;
        ans+=solve(n-i);
    }
    return dp[n]=ans%mod;
}
main()
{
    memset(dp,-1,sizeof dp);
    ll n;
    cin>>n;
    cout<<solve(n);

}


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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] nums = new int[n];
		
		for (int i = 0; i < nums.length; i++) {
			nums[i] = scanner.nextInt();
		}
		Arrays.sort(nums);
		int ans = nums[nums.length-1] - nums[0];
		System.out.println(ans);
		
		scanner.close();
	}

}


Measured memory_bytes: 23124
a= input().split()
N = int(a[0])
W = int(a[1])
wv_list = []
max_value = 0

#価値と重さのやつをリストにしてる
for i in range(N):
  b = input().split()
  w = int(b[0])
  v = int(b[1])
  max_value += v

  wv_list.append([w, v])

#初期化
#とりあえず、全部最大になるように
inf=float('inf')
n_list = [[inf for i in range(max_value + 1)] for j in range(N)]

#最初のアイテムに関して、重みを適切な価値のところにいれている
n_list[0][wv_list[0][1]] = wv_list[0][0]

for i in range(1, N):
  # 今まで全く選んでなかった場合に、i番目のアイテムを選んだ時
  n_list[i][wv_list[i][1]] = wv_list[i][0]
  for j in range(max_value):

    s = j + wv_list[i][1]
    #アイテムを選んだらこうなりますよってのを更新
    if s <= max_value:
      n_list[i][s] = min(n_list[i - 1][j] + wv_list[i][0], n_list[i][s])

    #選ばんかったらこうなりますよってのを更新？
    n_list[i][j] = min(n_list[i - 1][j], n_list[i][j])
  
for i in range(1, max_value):

  if n_list[-1][-i] <= W:
    print(max_value - i + 1)
    break

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

int main()
{
	int n;
	cin >> n;
	map<string, bool> T;
	for (int i = 0; i < n; i++)
	{
		char str[10];
		char C[13];
		cin >> str >> C;
		if (str[0] == 'i')
		{
			T[string(C)] = true;
		}
		else
		{
			if (T.find(C) != T.end())
			{
				cout << "yes" << endl;
			}
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 33308
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  // a b c
  int p, q, r;
  cin >> p >> q >> r;
  int ans = 1e9;
  ans = min(ans, p + q);
  ans = min(ans, q + r);
  ans = min(ans, p + r);
  cout << ans << endl;
}





Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int n, a, b, c, h[100005], h2;
  int mid, low, high, flg, max, x, x2, i;
  scanf("%d %d %d", &n, &a, &b);

  c = a-b;
  max = -1;
  for(i = 0; i < n; i++){
    scanf("%d", &h[i]);
    if(max < h[i]) max = h[i];
  }
  low = 1;
  high = max/b+1;  //爆発はhigh回以下
  while(low <= high){
    mid = (low + high)/2; //2分探索したいので中央値を定める
    flg = 1;
    x = mid;
    for(i = 0; i < n; i++){
      h2 = h[i]-b*mid;
      if(h2 > 0){
	x2 = h2/c;  //追加ダメージの回数
	if(h2 % c != 0) x2++;
	x -= x2;    /*xは中央値で追加ダメージの回数の総数がxを越えたら爆発はx以上必要*/
	if(x<0){   
	  flg = 0;
	  break;
	}
      }
    }
    /*追加ダメージの回数がxより大きいのでx回よりも爆発回数は多くなる*/
    if(flg != 1) low = mid+1; 
    else high = mid-1;
  }
  printf("%d\n", low);
  return 0;
} 

Measured memory_bytes: 640
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip())

N = I()
S = LS()

ans = 1
for i in range(N-1):
    if S[i] != S[i+1]:
        ans += 1

print(ans)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    double ans = 0;
    rep(i,n){
        double x;
        string u;
        cin >>x >>u;

        if(u == "BTC") x *= 380000;
        ans += x;
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    vec l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));

    if (accumulate(l.begin(), l.end()-1, 0) > l[n-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin

S = stdin.readline().rstrip()

ans = "AC"

if S[0] != 'A':
    ans = "WA"

C_count = 0
for i in range(2,len(S)-1):
    if S[i] == 'C':
        C_count += 1

if C_count != 1:
    ans = "WA"

U_count = 0
for i in range(len(S)):
    if S[i].isupper():
        U_count += 1

if U_count != 2:
    ans = "WA"

print(ans)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/05/26  Problem: ABC 128 D / Link: http://abc128.contest.atcoder.jp/tasks/abc128_d  ----- */


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

	int N, K; cin >> N >> K;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	LL ans = 0LL;
	FOR(k, 1, K + 1) {
		// k回とる
		int modosu = K - k; // 戻せる回数// 全部見る

		FOR(L, 0, k + 1) {
			int R = k - L;
			// k = L + R
			// 交わるときに注意
			VI use(N, 0);
			priority_queue<LL, VL, greater<LL>>minq;
			LL subsum = 0;
			FOR(i, 0, min(L, N)) {
				use[i] = 1;
				minq.push(a[i]);
				subsum += a[i];
			}
			FOR(revi, 0, min(R, N)) {
				int i = N - 1 - revi;
				if (use[i])continue;
				minq.push(a[i]);
				subsum += a[i];
			}

			// 戻す
			LL sum = 0;
			ans = max(ans, subsum);
			FOR(i, 0, modosu) {
				if (SZ(minq)) {
					LL v = minq.top(); minq.pop();
					subsum -= v;
					ans = max(ans, subsum);
				}
			}

			ans = max(ans, sum);
		}
	}


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
#define INF 2<<29

int main(){
  int a,b,k,cnt=0;
  scanf("%d %d %d",&a,&b,&k);
  for(int i=100;i>0;i--){
    if(a%i==0&&b%i==0){
      cnt++;
    }
    if(cnt==k){
      printf("%d\n",i);
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
N, Y = gets.split.map(&:to_i)
0.upto(N) do |n1|
    0.upto(N-n1) do |n2|
        if Y < 10000 * n1 + 5000 * n2 + 1000 * (N-n1-n2)
            next 
        elsif Y == 10000 * n1 + 5000 * n2 + 1000 * (N-n1-n2)
            print("#{n1} #{n2} #{N-n1-n2}")
            exit
        end
    end
end
print("-1 -1 -1")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
int N, K;
int A[2010];
int a[2010], b[2010];
bool dbg = false;
void solve()
{
    FOR(i, 0, N)
    {
        FOR(j, 0, N)
        {
            if (A[i] > A[j]) {
                a[i]++;
            }
            if (A[i] > A[j] && i < j) {
                b[i]++;
            }
        }
    }
    FOR(i, 0, N)
    {
        // cout << a[i] << " " << b[i] << endl;
    }
    int ans = 0;
    FOR(i, 0, N)
    {
        int t;
        t = ((K * (K - 1)) / 2) % MOD;
        ans += a[i] * t;
        ans %= MOD;
        ans += b[i] * K;
        ans %= MOD;
    }
    ans += MOD;
    ans %= MOD;
    cout << ans << endl;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    FOR(i, 0, N)
    cin >> A[i];
    solve();
    return 0;
}



Measured memory_bytes: 256
import * as fs from 'fs';

const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).split('\n');

const [a, b] = input[0].split(' ').map((x) => +x);
const t = Math.max(a - b, a + b, a * b);

console.log(t === -0 ? 0 : t);


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll x,y;
    ll ans=0;
    cin >> x >>y;
    while(x<=y){
        ans++;
        x*=2;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
A, B = map(int, input().split())

cnt = 0
for num in range(A, B + 1):
    num = str(num)
    kaibun = True
    for i in range(len(num) // 2):
        if num[i] != num[-i - 1]:
            kaibun = False
            break
    if kaibun:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
typedef long long ll;
int n,f;
ll a[1000010],b[1000010];
ll ans=0;
bool check(ll sum,ll k)
{
  f=1;
  for (int i=n;i>=1;i--)
  {
    if (a[f]*b[i]<=sum)
	{
		f++;
		continue;
	}
    if ((a[f]-sum/b[i])>k) 
		return false;
    k-=a[f]-sum/b[i];
    f++;
  }
  return true;
}
int main()
{
  	ll j;
  	scanf("%d%lld",&n,&j);
  	for (int i=1;i<=n;i++) 
 		scanf("%lld",&a[i]);
  	for (int i=1;i<=n;i++) 
  		scanf("%lld",&b[i]);
	sort(a+1,a+1+n);
	sort(b+1,b+1+n);
 	ll l=0,r=0;
  	r=b[n]*a[n];
  	ans=r;
  	while (l<=r)
  	{	
      	ll mid=(l+r)/2;
      	if (check(mid,j)) 
	  	{
	  	ans=mid;
	 	 r=mid-1;
	  	}
      	else 
	  	l=mid+1;
  	}
  	printf("%lld\n",ans);
  	return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    cout<<"ABC"<<n<<endl;
    return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N, K;
    cin >> N >> K;
    int a[N];
    rep(i, 0, N) cin >> a[i];

    bool dp[K + 1];
    dp[0] = false;

    rep(i, 1, K + 1) {
        map<bool, int> m;
        bool flag = false;
        rep(j, 0, N) {
            if(i - a[j] >= 0) {
                m[dp[i - a[j]]]++;
                flag = true;
            }
        }

        if(flag) {
            if(m[false] == 0) dp[i] = false;
            else if(m[true] == 0) dp[i] = true;
            else dp[i] = true;
        } else dp[i] = false;
    }

    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;

}


Measured memory_bytes: 384
package main

import "fmt"

func KagamiMochi(N int, d []int) int{
	check := make(map[int]bool)
	for i := 0; i < N; i++ {
		if _, ok := check[d[i]]; !ok{
			check[d[i]] = true
		}
	}
	return len(check)
}

func main() {
	var N, num int
	d := []int{}
	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&num)
		d = append(d, num)
	}
	mochi := KagamiMochi(N, d)
	fmt.Println(mochi)
}

Measured memory_bytes: 512
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
    }
    int ans=ceil(double(N-1)/(K-1));
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	ll n, a, b, x, px;
	cin >> n >> a >> b >> px;
	ll res = 0;
	REP(i, n - 1) {
		cin >> x;
		res += min(a * (x - px), b);
		px = x;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using namespace std;
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

signed main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    int n;
    int sum = 0;
    for (int i=0; i<10; ++i) {
        cin >> n;
        sum += n;
    }
    outl(sum);
}




Measured memory_bytes: 3120
//
//AtCoder Beginner Contest 042
//C
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

const double PI = 3.14159265358979323846;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> dislike(10, 0);
    REP(i, k) {
        int d;
        cin >> d;
        dislike[d]=1;
    }

    int likeMin = -1;
    REP(i, 10) {
        if (dislike[i]==0){
            likeMin = i;
            break;
        }
    }
    vector<int> ans(10010, -1);

    int over = -1;
    int nn = n;
    int pos = 0;
    while(nn>0){
        ans[pos]=nn%10;
        if (dislike[nn%10] == 1) over = pos;
        nn /= 10;
        pos++;
    }
    
    if (over == -1) {
        cout << n << endl;
        return 0;
    }

    REP(i, over) ans[i]=likeMin;
    FOR(i, over, pos){
        int like = -1;
        FOR(j, ans[i], 9){
            if (dislike[j]==0){
                like = j;
                break;
            }
        }
        if (like == -1){
            ans[i]=likeMin;
            if (ans[i+1]==-1) ans[i+1] = 1;
            else ans[i+1]++;
        }else{
            ans[i]=like;
            break;
        }
    }

    string sans = "";
    REP(i, ans.size()){
        if (ans[i]==-1) break;
        else sans = to_string(ans[i]) + sans;
    }
    cout << sans << endl;
    return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<string> e;
    string s;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        e.emplace_back(s);
    }
    int cnt=0,tans=1e9;
    vector<int> t;
    for(char i='a';i<='z';i++){
        for(int j=0;j<n;j++) {
            for (int k = 0; k < e[j].size(); k++) {
                if (e[j][k] == i) {
                    cnt++;
                }
            }
            tans = min(tans, cnt);
            cnt = 0;
        }
        t.push_back(tans);
        tans=1e9;
    }
    int cnt2=0;
    for(char i='a';i<='z';i++){
        for(int j=0;j<t[cnt2];j++){
            cout << i;
        }
        cnt2++;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 110;
const int MAXK = 510;

int a, b, c, d;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> a >> b >> c >> d;
    cout << (b - d) * (a - c);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<ll> a(N);
    REP(i,N) cin>>a[i];
    ll ans=0;
    sort(All(a));
    map<ll,int> mp;
    REP(i,N) if(a[i]==a[i+1]){
        mp[a[i]]++;
        i++;
    }
    auto it=mp.rbegin();
    if(it==mp.rend()){
        cout<<0<<endl;
        return 0;
    }
    if(it->second>=2) ans=(it->first)*(it->first);
    else{
        ll tmp=it->first;
        it++;
        if(it!=mp.rend()){
            ans=tmp*(it->first);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3584
n=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            x=str(i)+str(j)+str(k)
            p=S.find(x[0])
            q=S.find(x[1],p+1)
            r=S.find(x[2],q+1)
            if p!=-1 and q!=-1 and r!=-1:
                ans+=1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,k,p[200005];
double each[200005],now,ans;
int main(){
    scanf("%d%d",&n,&k);
    for(register int i=1;i<=n;++i){
        scanf("%d",&p[i]);
    }
    for(register int i=1;i<k;++i){
        each[i]=(double)(1+p[i])*p[i]/2.0/p[i];
        now+=each[i];
    }
    for(register int i=k;i<=n;++i){
        each[i]=(double)(1+p[i])*p[i]/2.0/p[i];
        ans=max(ans,now);
        now+=each[i];
        now-=each[i-k];
    }
    ans=max(ans,now);
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    int k=1;
    char s[100],t[100],a[100];
    scanf("%s",s);
    scanf("%s",a);
    sort (s,s+strlen(s));
    sort (a,a+strlen(a));
    for (int ni=0;ni<strlen(a);ni++) t[ni]=a[strlen(a)-ni-1];
    for (int ni=0;ni<strlen(a)||ni<strlen(s);ni++)
    {
        if (s[ni]<t[ni]) {printf("Yes");k=0;break;}
         else if (s[ni]>t[ni]) {printf("No");k=0;break;}
    }
    if (k==1) printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
ll k;
cin >> k;
ll ans=0;
for(ll i=1;i<=k;i++){
    for(ll j=1;j<=k;j++){
        for(ll p=1;p<=k;p++){
            ll gc=gcd(gcd(i,j),p);
                ans+=gc;
        }
    }
}
cout << ans << endl;
}


Measured memory_bytes: 3624
n=int(input())
l=list(map(int, input().split()))
# n=5
# l=[4,2,5,1,3]
count=0

import heapq

tmp=l[0]
for i in range(1,len(l)+1):
    if tmp>=l[i-1]:
        count+=1
        tmp=l[i-1]
    
    
print(count)

Measured memory_bytes: 75344
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100009],dp[100009];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=1;i<=n;i++)
cin>>a[i];
a[0]=1e10;
for(ll i=2;i<=n;i++)
dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
cout<<dp[n];
return 0;
}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  if(a+b<n)ans=0;
  else ans=a+b-n;
  cout<<min(a,b)<<" "<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
N,K=map(int,input().split())
#1行で複数入力
input_list=list(map(int,input().split()))

#数列全体で自分より小さい数がいくつあるか
all_value = {i:0 for i in input_list}
for i in set(input_list):
    for j in input_list:
        if i> j:
            all_value[i]+=1

            
first_value = {i:0 for i in range(len(input_list))}

for i in range(len(input_list)-1):
    for j in range(i,len(input_list)):
        if input_list[i]>input_list[j]:
            first_value[i]+=1


# all_valueが公差
# first_valueがしょこう

count=0
for pos,i in enumerate(input_list):
    count += first_value[pos]*K+all_value[i]*(K-1)*K//2

print(count%(10**9+7))

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  string s;
  cin>>s;
  int co=0;
  if(s.size()%2&&(s[s.size()/2]=='('||s[s.size()/2]==')'))co++;
  rep(i,s.size()/2){
    char a=s[i],b=s[s.size()-i-1];
    if(a==b){
      if(a=='w'||a=='i');
      else co++;
    }else{
      if(a=='('&&b==')');
      else if(a==')'&&b=='(');
      else co++;
    }
  }
  cout<<co<<endl;
}

Measured memory_bytes: 1184