akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <tuple>
#include <stack>
#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>

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
bool canbuy(int n,vector<int> cost,int x,int money)
{
  if(n==0)
    if(money<0) return false;
    else return true;
  else
    return canbuy(n-1,cost,x/10,money-cost[x%10]);
}
void printn(int x,int n)
{
  if(n==0) return;
  else{
    printn(x/10,n-1);
    cout << x%10;
  }
  return;
}
int main(void)
{
  int n,m;
  cin >> n >> m;
  vector<int> cost;
  int costmin=1000;
  REP(i,10){
    int tmp;
    cin >> tmp;
    if(costmin>tmp) costmin=tmp;
    cost.PB(tmp);
  }
  if(m<costmin*n){
    cout << "NA" << endl;
    return 0;
  }
  int answer=0;
  for(;!canbuy(n,cost,answer,m);answer++);
  printn(answer,n);
  cout << endl;
  return 0;
}


Measured memory_bytes: 1216
import java.util.Scanner;

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

			long a = sc.nextInt();
			String s = sc.next();
			
			if ( a >= 3200 ) {
				System.out.println(s);
			}
			else {
				System.out.println("red");
			}
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, std::vector<long long> p) {
    ll m = 0, res = 0;
    rep(i, N) {
        res += p[i];
        m = max(m, p[i]);
    }
    res -= m / 2;
    cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> p(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

def kitai(x):
  return (1+int(x))/2

p = list(map(kitai, input().split()))

pre = psum = sum(p[0:k])

for i in range(1, n):
  if i+k > n:
    break
  pre = pre - p[i-1] + p[i+k-1]
  psum = max(psum, pre)

print(psum)


Measured memory_bytes: 23588
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int n;
	cin >> n;
	rep(i,n) {
		int a;
		cin >> a;
		if(a % 2 == 0) {
			if (a % 3 == 0 || a % 5 == 0) continue;
			else
			{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;

  return 0;
}


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

ll N, K, A[200005], F[200005];

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

    cin >> N >> K;

    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> F[i];

    sort(A, A + N);
    sort(F, F + N, greater<ll>());

    ll lo = 0, hi = 1e18 + 1;
    while(lo < hi) {
        ll mid = (lo + hi) / 2;
        ll train = K;
        for(int i = 0; i < N; i++) {
            if(A[i] * F[i] > mid) {
                train -= A[i] - mid/F[i];
            }
        }
        if(train < 0) lo = mid + 1;
        else hi = mid;
    }

    cout << lo << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n,m; cin>>n>>m;
    string s; cin>>s;
    
    int i = n,prev = n;
    bool flag = true;
    vector<int> ans;
    ans.push_back(n);

    while(i > 0){
        int idx = prev;

        prev--;
        while(prev+m >= i && prev >= 0){
            if(s[prev] == '0') idx = prev;
            prev--;
        }    
        prev++;

        if(idx == ans.back()){
            flag = false;
            break;
        }

        ans.push_back(idx);
        i = idx;
    }
    
    if(ans.back() != 0) flag = false;
    
    if(!flag) cout<<-1<<endl;
    else {
        reverse(ans.begin(),ans.end());
        for(int i=1;i<ans.size();i++){
            cout<<ans[i] - ans[i-1]<<" ";
        }
    }
}

signed main(){

    int t;
    t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 1528
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int n;
	long minimum = 1000000, maximum = -1000000, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		long a;
		cin >> a;
		minimum = min(a, minimum);
		maximum = max(a, maximum);
		sum += a;
	}
	cout << minimum << " " << maximum << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3108
import java.util.*;

class Main{
    public static void main(String args[]){
        int count = 0;
        String ans[] = {"No","Yes"};
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char a[] = new char[str.length()];
        for(int i = 0;i < str.length();i++){
            a[i] = str.charAt(i);
        }
        if(a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]){
            
        }else if(a[0]==a[1]&&a[2]==a[3]){
            count++;
        }else if(a[0]==a[2]&&a[1]==a[3]){
            count++;
        }else if(a[0]==a[3]&&a[1]==a[2]){
            count++;
        }
        System.out.print(ans[count]);
    }
}

Measured memory_bytes: 22868
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

int main() {
	int n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	vector<char>aite(n);
	for (int i = 0; i < n; i++) {
		cin >> aite.at(i);
	}
	vector<char>move(n);
	for (int i = 0; i < n; i++) {
		if (aite.at(i) == 'r') {
			move.at(i) = 'p';
		}
		else if (aite.at(i) == 's') {
			move.at(i) = 'r';
		}
		else if (aite.at(i) == 'p') {
			move.at(i) = 's';
		}
	}
	for (int i = k; i < n; i++) {
		if (move.at(i - k) == move.at(i)) {
			move.at(i) = 'a';
		}
	}
	long sum = 0;
	for (int i = 0; i < n; i++) {
		if (move.at(i) == 'r') {
			sum += r;
		}
		else if (move.at(i) == 's') {
			sum += s;
		}
		else if (move.at(i) == 'p') {
			sum += p;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string a[2],b;
string s[2][1001];
int p[2];
void dfs(int x){
  r(i,a[x].size()){
    if(a[x][i]=='"'){
      i++;s[x][p[x]]+='"';
      while(i<a[x].size()&&a[x][i]!='"')s[x][p[x]]+=a[x][i++];
      p[x]++;
    }else{
      while(i<a[x].size()&&a[x][i]!='"')s[x][p[x]]+=a[x][i++];
      p[x]++;
      i--;
    }
  }
}
main(){
  while(cin>>a[0],a[0]!="."){
    cin>>a[1];
    p[0]=p[1]=0;
    r(i,2)r(j,1001)s[i][j]="";
    r(i,2)dfs(i);
    if(p[0]!=p[1])cout<<"DIFFERENT"<<endl;
    else{
      int f1=0,f2=0;
      r(i,p[0])if(s[0][i]!=s[1][i]){
        if(s[0][i][0]=='"'&&s[1][i][0]=='"')f1++;
        else f2++;
      }
      if(f2||f1>1)cout<<"DIFFERENT"<<endl;
      else if(f1)cout<<"CLOSE"<<endl;
      else cout<<"IDENTICAL"<<endl;
    }
  }
}


Measured memory_bytes: 3188
n, m, l = map(int, input().split())
a = [];b = []
for _ in range(n):
    a.append(list(map(int, input().split())))
for _ in range(m):
    b.append(list(map(int, input().split())))

c = [[0]*l for _ in range(n)]
for i in range(n):
    for j in range(l):
        c[i][j] = sum(a[i][k] * b[k][j] for k in range(m))

for e in c:
    print(*e)


Measured memory_bytes: 6968
#include <iostream>
using namespace std;
 
int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (!n)
    {
      break;
    }
    int h[101];
    for (int i=0; i<=n; i++)
    {
      cin >> h[i];
    }
 
    int def[4] = { h[1]-h[0],
                   h[2]-h[1],
                   h[3]-h[2],
                   h[4]-h[3] };
 
    if (def[0]==def[1] && def[1]==def[2] && def[2]==def[3])
    {
      for (int i=5; i<=n; i++)
      {
    if (h[i]-h[i-1] != def[0])
    {
      cout << h[i] << endl;
      break;
    }
      }
    }
    else if (def[0] == def[3])
    {
      cout << h[2] << endl;
    }
    else if (def[1] == def[2])
    {
      if (def[2] == def[3])
      {
    cout << h[0] << endl;
      }
      else
      {
    cout << h[4] << endl;
      }
    }
    else
    {
      if ((def[0]+def[1])*2 == def[2]+def[3])
      {
    cout << h[1] << endl;
      }
      else
      {
    cout << h[3] << endl;
      }
    }
  }
 
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

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

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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    sort(v.begin(),v.end());
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int x = lower_bound(v.begin()+j+1,v.end(), v[i]+v[j]) - (v.begin()+j+1);
            ans += x;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();

		System.out.println(a1 + a2 + a3 <= 21 ? "win" : "bust");
	}
}

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

int main(){
  string s;
  int start, end;
  cin >> s;
  int N = s.length();
  for(int i=0;i<N; i++){
    if(s[i] == 'A'){
      start=i;
      break;
    }
  }
  for(int i=N-1; i>=0; i--){
    if(s[i] == 'Z'){
      end=i;
      break;
    }
  }
  cout << end-start+1 << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};

fn main() {
    input! {
        n: usize,
        ds: [i32; n],
        m: usize,
        ts: [i32; m],
    }
    let mut counter = HashMap::new();
    for d in ds { *(counter.entry(d).or_insert(0)) += 1; }
    for t in ts {
        let count = counter.entry(t).or_insert(0);
        if *count == 0 {
            println!("NO");
            return;
        }
        else { *count -= 1; }
    }
    println!("YES");
}


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

int main() {
  int n;
  cin>>n;
  vector<vector<P> > a(n);
  rep(i,0,n){
    int b;
    cin>>b;
    rep(j,0,b){
      int c,d;
      cin>>c>>d;
      a[i].push_back(P(c-1,d));
    }
  }
  int ans=0;
  for (int tmp = 0; tmp < (1 << 15); tmp++) {
    bitset<15> s(tmp);
    int cur=0;
    bool p=true;
    rep(i,0,n){
      if(s.test(i)){
        cur++;
        rep(j,0,a[i].size()){
          if(s.test(a[i][j].first)){
            if(a[i][j].second==0) p=false;
          }
          else{
            if(a[i][j].second==1) p=false;
          }
        }
      }
    }
    if(p) ans=max(ans,cur);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A; string B; cin >> A >> B;
  string b;
  for(auto i : B){
    if(i != '.'){
      b.push_back(i);
    }
  }
  ll BB = stoll(b);
  if(A == 0 || BB == 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = A*BB;
  string a = to_string(ans);
  int N = a.size();
  if(N <= 2){
    cout << 0 << endl;
  }else{
    REP(i, N-2){
      cout << a[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3720
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;





int main(){
    ll n,m;
    cin>>n>>m;
    if(m==0){cout<<n+1<<endl; return 0;}
    vector<pll> a(m);
    for(auto &I:a){cin>>I.F>>I.S;}
    sort(a.begin(),a.end());
    vector<pll> A;
    A.push_back(a[0]);
    for(int i=1;i<m;i++){
        if(a[i].S>A.back().S){A.push_back(a[i]);}
    }
    vector<vector<ll>> dp(A.size()+1,vector<ll>(A.size()+1,E));
    dp[0][0]=0;
    for(int i=1;i<=A.size();i++){
        for(int t=0;t<i;t++){
            dp[i][t]=dp[i-1][t];
        }
        for(int t=0;t<i;t++){
            dp[i][i]=min(dp[i][i],dp[i-1][t]+(A[i-1].S-A[t].F)*2);
        }
    }
    cout<<dp[A.size()][A.size()]+n+1<<endl;
    
    
    return 0;
}



Measured memory_bytes: 4968
#include <bits/stdc++.h>
//#include <tr1/unordered_map>
//#include"Bignum/bignum.h"
//#define big bignum
#define lowbit(x) (x & -x)
#define debug(x) (cout << "#x = " << (x) << endl)
#define Set(x, i) memset (x, i, sizeof(x))
#define R register
#define For(i, j, k) for(R int i = (j), ED = (k); i <= ED; ++i)
#define Rep(i, j, k) for(R int i = (j), ED = (k); i >= ED; --i)
#define Cross(i, j, k) for(R int i = (j); i; i = (k))
using namespace std;
typedef long long ll;
const ll N = 200011;
const ll INF = 5e16;

namespace IO {

    inline char gc() {
        static char buf[100000], *p1 = buf, *p2 = buf;
        return (p1 == p2) && (p2 = (p1 = buf) +
            fread(buf, 1, 100000, stdin), p1 == p2)? EOF: *p1++;
    }

    #define dd ch = getchar()
    inline ll read() {
        R ll x = 0; R int f = 0; R char dd;
        for (; !isdigit(ch); dd) f ^= (ch == '-');
        for (; isdigit(ch); dd)  x = x * 10 + (ch ^ 48);
        return f? -x: x;
    }
    #undef dd

    inline void write ( ll x ) {
        if (x < 0) x = -x, putchar('-');
        if (x > 9) write(x / 10); putchar(x % 10 | 48);
    }

    inline void wrn ( ll x ) { write(x), putchar(' '); }

    inline void wln ( ll x ) { write(x), putchar('\n'); }

    inline void wlnn ( ll x, ll y ) { wrn(x), wln(y); }

}

using IO::wln;
using IO::read;

namespace Cesare {
	
	char s[N], t[N];
	ll Ans, pos = 0, Vis[233];
	
	vector <ll> V[233];
	
	int main() {
		scanf("%s", s + 1);
		scanf("%s", t + 1);
		ll Lens = strlen(s + 1);
		ll Lent = strlen(t + 1);
		For ( i, 1, Lens ) Vis[s[i]] = 1;
		For ( i, 1, Lens ) V[s[i]].push_back(i);
		For ( i, 1, Lent ) if (!Vis[t[i]]) return puts("-1"), 0;
		For ( i, 1, Lent ) {
			ll Pos = upper_bound(V[t[i]].begin(), 
								V[t[i]].end(), pos) - V[t[i]].begin();
			if (Pos > V[t[i]].size() - 1) Ans += Lens, Pos = 0;
			pos = V[t[i]][Pos];
		} return wln(Ans + pos), 0;
	}
	
}

int main()
{
    return Cesare::main();
}

/*

*/







Measured memory_bytes: 1656
import sys
import math
from collections import deque


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s_at = input()[::-1]
s_bt = input()[::-1]
s_ct = input()[::-1]

s_a = deque()
s_b = deque()
s_c = deque()

for i in range(len(s_at)):
    s_a.append(s_at[i])

for i in range(len(s_bt)):
    s_b.append(s_bt[i])

for i in range(len(s_ct)):
    s_c.append(s_ct[i])

now = "a"

while True:
    if now == "a":
        if len(s_a) == 0:
            print("A")
            exit()
        now = s_a[-1]
        s_a.pop()
    elif now == "b":
        if len(s_b) == 0:
            print("B")
            exit()
        now = s_b[-1]
        s_b.pop()
    else:
        if len(s_c) == 0:
            print("C")
            exit()
        now = s_c[-1]
        s_c.pop()

Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int n,m;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	for(int i = 1,j = m;i < j;i++,j--){
		cout << i << " " << j << endl;
	}
	for(int i = m + 1,j = 2 * m + 1;i < j;i++,j--){
		cout << i << " " << j << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
# -*- coding: utf-8 -*-
from sys import stdin

# abcde

# axyze
# yxaze
# xaze

def mreplace(s, e, rep_str,v_str):
  replaced_str = v_str[:s] + rep_str + v_str[e + 1:]
  #print(replaced_str)#TODO delete
  return replaced_str

def mreverse(s, e, v_str):
  reversed_str = v_str[:s]+ v_str[s:e+1][::-1]+v_str[e+1:]
  #print(reversed_str)  #TODO delete
  return reversed_str


def mprint(s, e, v_str):
  print(v_str[s:e+1])


STR = stdin.readline().rstrip()
q = int(stdin.readline().rstrip())
for i in range(q):
  A = list(stdin.readline().split())
  if A[0] == "print":
    mprint(int(A[1]),int( A[2]), STR)
  elif A[0] == "replace":
    STR = mreplace(int(A[1]), int(A[2]), A[3], STR)
  elif A[0] == "reverse":
    STR = mreverse(int(A[1]), int(A[2]), STR)


Measured memory_bytes: 5628
#include <iostream>
#include <vector>
#include <sstream>

auto product (const std::vector <std::vector <long long>> & a , const std::vector <std::vector <long long>> & b) -> std::vector <std::vector <long long>>
{
    std::vector <std::vector <long long>> res (a.size () , std::vector <long long> (b[0].size () , 0));
    for (auto i = 0u; i < res.size (); ++ i)
    {
        for (auto j = 0u; j < res[0].size (); ++ j)
        {
            for (auto k = 0u; k < b.size (); ++ k)
            {
                res [i] [j] += a [i] [k] * b [k] [j];
            }
        }
    }
    return res;
}

template <typename T>
auto unwords (const T & xs) -> std::string
{
    auto begin = xs.begin ();
    auto end = xs.end ();
    std::ostringstream ss;
    for (auto ite = begin; ite != end; ++ ite)
    {
        ss << * ite;
        if (ite + 1 < end)
        {
            ss << ' ';
        }
    }
    return ss.str ();
}

template <typename F , typename T>
auto map (F f , const std::vector <T> & xs) -> std::vector <decltype (f (xs [0]))>
{
    std::vector <decltype (f (xs [0]))> res (xs.size ());
    for (auto i = 0u; i < xs.size (); ++ i)
    {
        res [i] = f (xs [i]);
    }
    return res;
}

struct
{
    template <typename T>
    auto operator () (T && x) -> std::string
    {
        std::ostringstream ss;
        ss << std::forward <T> (x);
        return ss.str ();
    }
} show;

auto main () -> int
{
    long long n , m , l;
    std::cin >> n >> m >> l;
    std::vector <std::vector <long long>> a (n , std::vector <long long> (m , 0));
    std::vector <std::vector <long long>> b (m , std::vector <long long> (l , 0));
    for (auto && lines : a)
    {
        for (auto && elem : lines)
        {
            std::cin >> elem;
        }
    }
    for (auto && lines : b)
    {
        for (auto && elem : lines)
        {
            std::cin >> elem;
        }
    }
    for (auto && lines : product (a , b))
    {
        std::cout << unwords (map (show , lines)) << std::endl;
    }
}

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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int> rs(n + 1);
  for (int i = 1; i <= n; i++) cin >> rs[i];

  vector<int> xs(n + 1);
  for (int k = n; k >= 1; k--) {
    int current = 0;
    for (int i = 2; i * k <= n; i++) {
      current += xs[i * k];
    }
    xs[k] = abs(current - rs[k]) % 2;
  }

  vector<int> answers;
  for (int i = 1; i <= n; i++) {
    if (xs[i] == 1) answers.push_back(i);
  }

  cout << answers.size() << endl;
  for (int i = 0; i < answers.size(); i++) {
    if (i > 0) cout << " ";
    cout << answers[i];
  }
  cout << endl;
}


Measured memory_bytes: 3192
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
    if (n + m + p + a + b == 0) break;
    --a, --b;
    vector<double> t(n);
    cin >> t;
    auto g = vectors(m, m, INF);
    while (p--) {
      int x, y, z;
      cin >> x >> y >> z;
      --x, --y;
      g[x][y] = g[y][x] = z;
    }
    auto dist = vectors(m, 1 << n, 1e9);
    using state = tuple<double, int, int>;
    priority_queue<state, vector<state>, greater<state>> q;
    dist[a][0] = 0;
    q.emplace(0, a, 0);
    while (q.size()) {
      double d;
      int v, used;
      tie(d, v, used) = q.top();
      q.pop();
      if (dist[v][used] < d) continue;
      rep(i, n) {
        if (used >> i & 1) continue;
        rep(u, m) {
          if (g[v][u] == 1e9) continue;
          if (cmin(dist[u][used | 1 << i], d + g[v][u] / t[i])) { //
            q.emplace(dist[u][used | 1 << i], u, used | 1 << i);
          }
        }
      }
    }
    double ans = *min_element(all(dist[b]));
    if (ans == 1e9) {
      cout << "Impossible" << endl;
    } else {
      cout << prec(32) << ans << endl;
    }
  }
}



Measured memory_bytes: 5312
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll h, w, x, y;
    cin >> h >> w >> x >> y;
    out((h-x)*(w-y));
    re0;
}

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

#ifdef __WIN32
#define LLFORMAT "I64"
#else
#define LLFORMAT "ll"
#endif

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	static constexpr int mod = 1e9 + 7;
	int n, m;
	cin >> n >> m;
	string s;
	cin >> s;
	if(s[0] == 'R') for (auto &c: s) c = 'R' + 'B' - c;
	bool flag_R = false;
	for (auto c: s) if(c == 'R') { flag_R = true; break; }
	if(flag_R) {
		int limit, i = 0, cnt = 0;
		while(i < m && s[i] == 'B') {
			++cnt;
			++i;
		}
		if(cnt & 1) limit = cnt;
		else limit = cnt + 1;
		while(i < m && s[i] == 'R') ++i;
		for(;;) {
			cnt = 0;
			while(i < m && s[i] == 'B') {
				++cnt;
				++i;
			}
			if(i == m) break;
			if(cnt & 1) limit = min(limit, cnt);
			while(i < m && s[i] == 'R') ++i;
		}
		vector<int> dp(n + 1, 0);
		dp[1] = 1;
		int sum = 1;
		for (int i = 3; i <= n; i += 2) {
			if(i - (limit + 2 + 1) > 0) sum = (sum - dp[i - (limit + 2 + 1)]) % mod;
			dp[i] = sum;
			sum = (sum + dp[i]) % mod;
		}
		if(n & 1) { cout << "0\n"; return 0; }
		int ans = 0;
		for (int i = 1; i <= n; i += 2) {
			int j = n - i;
			if(j && j <= limit) ans = ((long long) dp[i] * (j + 1) + ans) % mod;
		}
		cout << (ans + mod) % mod << endl;
	}
	else {
		vector<int> dp[2][2];
		for (int a = 0; a < 2; ++a) for (int b = 0; b < 2; ++b) dp[a][b].resize(n, 0);
		dp[0][0][0] = dp[1][1][0] = 1;
		int t;
		for (int i = 0; i < n - 1; ++i) for (int a = 0; a < 2; ++a) for (int b = 0; b < 2; ++b) if(t = dp[a][b][i]) {
			dp[a][0][i + 1] = (dp[a][0][i + 1] + t) % mod;
			if(!b) dp[a][1][i + 1] = (dp[a][1][i + 1] + t) % mod;
		}
		cout << (((dp[0][0][n - 1] + dp[0][1][n - 1]) % mod + dp[1][0][n - 1]) % mod + mod) % mod << endl;
	}
	return 0;
}


Measured memory_bytes: 3732
#include <iostream>

using namespace std;

int main()
{
	int num, n;  cin >> n;
	bool approved = true;
	while (n--)
	{
		cin >> num;

		if ((num & 1) == 0)
		{
			if (!(num % 3 == 0 or num % 5 == 0))
			{
				approved = false;
			}
		}

	}

	cout << (approved ? "APPROVED" : "DENIED");

	return 0;
}


Measured memory_bytes: 256
s = list(input())
a = []
for l in s:
	if l == '0':
		a.append('0')
	if l == '1':
		a.append('1')
	if l == 'B' and len(a) != 0:
		a.pop()
		
print(''.join(a)) if len(a) > 0 else print('')


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	sort(ALL(A), greater<ll>());
	vector<ll> tmp;
	tmp.push_back(A[0]);
	for (ll i = 1; i < N; ++i)
	{
		tmp.push_back(A[i]);
		tmp.push_back(A[i]);
	}

	auto it = tmp.begin();
	std::cout << accumulate(it, it+N-1, 0ll) << std::endl;
	return 0;
}


Measured memory_bytes: 8976
#include <cstdio>

int main(int argc, char *argv[]) {
	using namespace std;
	
	int rcv;
	
	while (EOF != fscanf(stdin, "%d", &rcv)) {
		int sum = 0;
		for (int i = rcv; i < 600; i+=rcv) {
			sum += i * i * rcv;
		}
		printf("%d\n", sum);
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
int m, a[20], n;

bool dfs( int v, int d ){
	if( v == m )	return true;
	if( v>m || d==n )		return false;
	bool ret = dfs(v+a[d], d+1);
	if(!ret)	ret = dfs(v, d+1);
	return ret;
}

int main(){
	int q;
	cin >> n;
	rep(i,n)	cin >> a[i];
	cin >> q;
	while(q--){
		cin >> m;
		cout << (dfs(0,0) ? "yes" : "no") << endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

int main() {
	
	int N, K;
	cin>>N>>K;
	vector<int> h(N);
	vector<int> dp(N);
	for (auto &x : h) {
		cin>>x;
	}
	
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2;i < N;++i) {
		int min_val = INT_MAX;
		for (int k = 1;k <= K && i-k > -1;++k) {
			min_val = min(dp[i-k] + abs(h[i-k] - h[i]), min_val);
		}
		dp[i] = min_val;
	}
	
	cout<<dp[N-1]<<endl;
}


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

int a[4]={0};
int main(void){
	for(int i=0; i<3; i++){
		int x, y;
		cin >> x >> y;
		a[x-1]++;
		a[y-1]++;
	}
	if(a[0]==0||a[1]==0||a[2]==0||a[3]==0||a[0]==3||a[1]==3||a[2]==3||a[3]==3) cout << "NO" << endl;
	else cout << "YES" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int n,j,k,i,fr[101],d,x,nr;
int main()
{
   cin>>n>>k;
   for(i=1;i<=k;i++)
   {
       cin>>d;
       for(j=1;j<=d;j++)
       {
           cin>>x;
           fr[x]=1;
       }
   }
   for(i=1;i<=n;i++)
    if(fr[i]==0)
    nr++;
   cout<<nr;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int n, a;

void solve(){
  cin >> n >> a;
  vector<int> x(n + 1);
  for(int i = 1; i <= n; i++){
    cin >> x[i];
  }
  vector<vector<vector<long long int> > > d(n + 1, vector<vector<long long int> >(n + 1, vector<long long int>(n * a + 1)));
  for(int i = 0; i <= n; i++){
    for(int j = 0; j <= n; j++){
      for(int k = 0; k <= n * a; k++){
        if(i == 0 && j == 0 && k == 0) d[i][j][k] = 1;
        else if(i >= 1 && k < x[i]) d[i][j][k] = d[i - 1][j][k];
        else if(i >= 1 && j >= 1 && k >= x[i]) d[i][j][k] = d[i - 1][j][k] + d[i - 1][j - 1][k - x[i]];
        else d[i][j][k] = 0;
      }
    }
  }
  unsigned long long int ans = 0;
  for(int j = 1; j <= n; j++){
    ans += d[n][j][j * a];
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 52224
import java.util.*;
class Main{
  public static void main(String args[]){
    boolean flag = true;
    int tmp;
    int count = 0;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int Array [] = new int[n];
    //input
    for(int i = 0; i<n; i++){
      Array[i] = sc.nextInt();
    }
    //bubblesort
    while(flag){
      flag = false;
      for(int j = n-1; j>0; j--){
        if(Array[j]<Array[j-1]){
          tmp = Array[j];
          Array[j] = Array[j-1];
          Array[j-1] = tmp;
          count++;
          flag = true;
        }
      }
    }
    for(int i = 0; i<n-1; i++)System.out.printf("%d ",Array[i]);
    System.out.println(Array[n-1]);
    System.out.println(count);
  }
}


Measured memory_bytes: 26536
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()
A = nn()

A.append(0)

money = 1000
stock = 0

last = N - 1
while A[last] <= A[last-1]:
    last -= 1 

#print(A, last)

for i in range(last):
    if A[i+1] > A[i]:
        stock += money // A[i]
        money = money % A[i]

    if A[i+1] < A[i]:
        money += A[i] * stock
        stock = 0

    #print(i, money, stock)

print(money+A[last]*stock)

Measured memory_bytes: 72864
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct UnionFind {
	vector<int> par;
	vector<int> tree_size;

	UnionFind(int n) {
		par.resize(n);
		tree_size.resize(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			tree_size[i] = 1;
		}
	}

	//??¨???????????????
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	//????????¨????±????????????????
	bool same(int a, int b) {
		return find(a) == find(b);
	}

	//a???????????¨??¨b???????????¨?????????
	void marge(int a, int b) {
		if (same(a, b)) return;

		tree_size[find(a)] += tree_size[find(b)];
		par[find(b)] = par[find(a)];
	}

	void show_info() {
		for (int i = 0; i < par.size(); i++) {
			cout << par[i] << "," << tree_size[i] << endl;
		}
		cout << endl;
	}

	//a???????????¨?????§??????
	int size(int a) {
		return tree_size[find(a)];
	}


};

auto comp = [](pair<pair<int, int>, int > a, pair<pair<int, int>, int > b) {return a.second > b.second; };
priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >, decltype(comp) > que(comp);
int N;
int kraskal() {
	int sum = 0;
	UnionFind tree = UnionFind(N);

	for (; tree.size(0) != N;) {
		//tree.show_info();
		while (tree.same(que.top().first.first, que.top().first.second))
			que.pop();

		tree.marge(que.top().first.first, que.top().first.second);
		sum += que.top().second;
	}

	return sum;
}

void q72() {
	int m;
	for (; cin >> N >> m;) {
		for (; !que.empty();) que.pop();

		for (int i = 0; i < m; i++) {
			int s, t, c;
			char tmp;
			cin >> s >> tmp >> t >> tmp >> c;
			que.push(make_pair(make_pair(s, t), c));
		}
		cout << kraskal() / 100 - N + 1 << endl;
	}
}

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

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

int tree[1000000];
int n = 300001;
void update(int l, int v){
	tree[l+n] = v;
	for(int i=l+n;i>0;i>>=1){
		tree[i>>1] = max(tree[i], tree[i^1]);
	}
}

int query(int l, int r){
	int res = 0;
	for(l+=n, r+=n; l<r; l>>=1, r>>=1){
		if(l&1) res = max(res, tree[l++]);
		if(r&1) res = max(res, tree[--r]);
	}
	return res;
}

#define ll long long
int main() {
	int s,k;
	cin>>s>>k;
	int a[s];
	for(int i=0;i<s;i++) cin>>a[i];
	memset(tree, 0,sizeof(tree));
	for(auto i: a){
		int c = query(max(0, i-k), min(i+k, 300000)+1);
		update(i, c+1);
	}
	cout<<query(0, n);
}

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

int main()
{
    long n, k;
	cin >> n >> k;
    vector<long> p(n);
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    long ans = 0;

    for(int j = 0; j < k; j++){
        ans += p[j];
    }

    cout << ans << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i <= n - m; i++) {
    for (int j = 0; j <= n - m; j++) {
      bool contains = true;
      for (int k = 0; k < m; k++) {
        for (int l = 0; l < m; l++) {
          if (a[i + k][j + l] != b[k][l]) {
            contains = false;
          }
        }
      }
      if (contains) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int H, W;
    cin >> H >> W;
    vector<string> v;
    v.push_back(string(W+2, '.'));
    for (int i = 0; i < H; i++) {
        string S;
        cin >> S;
        v.push_back('.'+S+'.');
    }
    v.push_back(string(W+2, '.'));
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (v[i][j] == '#') continue;
            v[i][j] = '0';
            int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
            for (int k = 0; k < 8; k++) {
                if (v[i+dx[k]][j+dy[k]] == '#') v[i][j]++;
            }
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << v[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<long long> num(n);
  unsigned long long ans = 1;
  bool over=0;
  for(int i=0; i<n; i++){
    long long temp;
    cin >> temp;
    num[i] = temp;
    if(temp==0){
      cout << 0 << endl;
      return 0;
    }
  }
  
  for(int i=0; i<n; i++){
    long long temp = ans;
    ans *= num[i];
    if(ans>1000000000000000000||temp!=ans/num[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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


int main() {
    int K;
    std::string S;
    std::cin >> K;
    std::cin >> S;

    if (S.length() <= K) {
        std::cout << S << std::endl;
    } else {
        std::cout << S.substr(0, K) << "..." << std::endl;
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> k >> n;
    int a[n],b[n];
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n-1;i++) b[i] = a[i+1]-a[i];
    b[n-1] = k-a[n-1]+a[0];
    sort(b,b+n);
    cout << k-b[n-1] << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

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

  cout << min(a * n, b) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
using namespace std;
const int MAXN = 300010;
int Numsets;
int Parent[MAXN], Rank[MAXN], Sizes[MAXN];

void initSet(int n){
    for(int i=0; i<n; i++){
        Parent[i] = i; Rank[i]=0; Sizes[i]=1;
    }
    Numsets = n;
}

int findSet(int i){
    return Parent[i]==i ? i : Parent[i] = findSet(Parent[i]);
}

bool isSameSet(int i, int j){
    return findSet(i) == findSet(j);
}

void unionSet(int i, int j){
    if(!isSameSet(i, j)){
        Numsets--;
        int x = findSet(i), y = findSet(j);
        if(Rank[x] > Rank[y]){
            Parent[y] = x; Sizes[x] += Sizes[y];
        }else{
            Parent[x] = y; Sizes[y] += Sizes[x];
            if(Rank[x] == Rank[y]) Rank[y]++;
        }
    }
}

int numDisjoinSets(){ return Numsets; }

int sizeOfSet(int i){ return Sizes[findSet(i)]; }
int main(){
    //fast;
    int n, m, a, b, ans = -1e9;
    cin >> n >> m;
    initSet(n);
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        a--, b--;
        unionSet(a, b);
    }
    for(int i = 0; i < n; i++)
        ans = max(ans, sizeOfSet(i));
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5908
#include <iostream>
#include <vector>
using namespace std;
using ll=long long;

int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<vector<ll>> cnt(3,vector<ll>(4010,0));
    vector<vector<int>> chr(3,vector<int>(4010,0));
    if(s[n-1]=='R')chr[0][n-1]=1;
    else if(s[n-1]=='G')chr[1][n-1]=1;
    else chr[2][n-1]=1;
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            chr[j][i]=chr[j][i+1];
        }
        if(s[i]=='R')chr[0][i]++;
        else if(s[i]=='G')chr[1][i]++;
        else chr[2][i]++;
    }
    ll ret=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n-1;j++){
            if('R'+'G'+'B'-s[i]-s[j]=='R'){
                ret+=chr[0][j+1];
                if(s[j+(j-i)]=='R')ret--;
            }else if('R'+'G'+'B'-s[i]-s[j]=='G'){
                ret+=chr[1][j+1];
                if(s[j+(j-i)]=='G')ret--;
            }else if('R'+'G'+'B'-s[i]-s[j]=='B'){
                ret+=chr[2][j+1];
                if(s[j+(j-i)]=='B')ret--;
            }
        }
    }
    cout<<ret<<endl;
}


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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

	const int max_days=196470;
	rep(i,n){
		int y,m,d;
		cin>>y>>m>>d;
		int year=1,month=1,day=1;
		int ans=0;
		for(year=1;year<y;year++)ans+=(year%3==0?20*10:20*10-5);
		for(month=1;month<m;month++){
			ans+=20;
			if(year%3!=0&&month%2==0) ans-=1;
		}
		for(day=1;day<d;day++)ans++;
		// cout<<year<<" "<<month<<" "<<day<<endl;
		cout<<max_days-ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3080
##C - Boxes and Candies
n,x = gets.chomp.split(" ").map(&:to_i); #一番上の行を取ってくる
a = gets.chomp.split(" ").map!{|i | i.to_i} 

unchi = 0

#最初だけ特別

st = a[0] + a[1] - x #最初2つから減らすべき数

if st > 0
  if a[1] >= st
    a[1] = a[1] - st
    unchi = unchi + st
  else
    a[1] = 0
    a[0] = a[0] - st + a[1]
    unchi = unchi + st
  end
end

#2つ目以降
for i in 1..n-2 do
  he =  a[i] + a[i + 1] - x
  if he > 0
    unchi = unchi + he
    a[i + 1] = a[i + 1] - he
  end
end

print unchi

Measured memory_bytes: 8844
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

N = int(input())
D = [int(input()) for i in range(N)]
D_uniq = []
for x in D:
    if x not in D_uniq:
        D_uniq.append(x)

print(len(D_uniq))


Measured memory_bytes: 12444
#include <iostream>
#include <cstdio>

int main(){
    int i,j;
    int h,w;

    for(;;){
        std::cin>>h>>w;

        if(h==0 && w==0){
            break;
        }
        else {
            for(i=1;i<=h;i++){

                for(j=1;j<=w;j++){
                    
                    if((i+j)%2==0){
                        printf("#");
                    }
                    else{
                        printf(".");
                    }
                    
                    if(j==w){
                        printf("\n");
                        break;
                    }
                }
            
            }
            printf("\n");
        }

    }
    return 0;
}


Measured memory_bytes: 3036
a,b,c=map(int, input().split())
count=0

if c>=b:
    count+=2*b
    c=c-b
    if c>a:
        count+=a
        c=c-a
        if c>0:
            count+=1
    else:
        count+=c
else:
    count+=c+b

print(count)

Measured memory_bytes: 3060