akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #define F first
    #define S second
    using namespace std;
    using ll = long long;
    typedef pair<int, int> P;
    ll Mod = 1000000007;
    int main() {
      string s;
      cin >> s;
      int N = s.size();
      vector<P> ans;
      int num = 0;
      vector<int> vec;
      if (s[N-1] == '1') {
        cout << -1 << endl;
        return 0;
      }
      if (s[0] == '0') {
        cout << -1 << endl;
        return 0;
      }
      for (int i = 0; i < N-1; i++) {
        if (s[i] != s[(N-2)-i]) {
          cout << -1 << endl;
          return 0;
        }
        if ((N/2) <= i) {
          break;
        }
        if (s[i] == '1') {
          vec.push_back(i+1);
        }
      }
      for (int i = 0; i < (int)vec.size(); i++) {
        ans.emplace_back(i+1,i+2);
      }
      num = (int)vec.size() + 2;
      for (int i = 1; i < (int)vec.size(); i++) {
        int d = vec[i] - vec[i-1];
        for (int j = 0; j < d-1; j++) {
          ans.emplace_back(i+1,num);
          num++;
        }
      }
      for (num; num <= N; num++) {
        ans.emplace_back((int)vec.size()+1,num);
      }
     
      for (int i = 0; i < (int)ans.size(); i++) {
        cout << ans[i].F << " " << ans[i].S << endl;
      }
      return 0;
    }

Measured memory_bytes: 4712
#include <iostream>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){

  int n;
  while(cin >> n){
    string st;
    set<string> s;
    rep(i,n){
      cin >> st; 
      s.insert(st);
    }
    int m,f=0;
    cin >> m;
    rep(i,m){
      cin >> st;
      if(s.count(st) == 0){
	cout << "Unknown " << st << endl;
      }
      else{
	if(f==0){
	  cout << "Opened by " << st << endl;
	  f=1;
	}
	else{
	  cout << "Closed by " << st << endl;
	  f=0;
	}
      }
    }
  }
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
    /* Dear Judge :i Tried Hard for Solving this problem
      please accept My solution I will remain grateful for that */
#define ON(x, k)    ((x)|(1<<(k)))
#define isOn(x, k)    ((x)&(1<<(k)))
//#define isOn(x, k)    ((x>>k)&1)
#define OFF(x, k)   ((x)&(~(1<<(k))))
#define TOGGLE(x, k)   ((x)^(1<<(k)))

    using namespace std ;
    int const c =1e4+5;
    int A[c];
     int main (){


    int n ;
    cin >> n ;
    if(n%2==0)
        cout << n;
    else
        cout << n*2;
   /* int n , d ;
    cin >> n >> d ;
    if(n<1)
     cout << d;
    else
    cout << d*pow(100,n);
     */return 0;
     }


Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        int num = scan.nextInt();
        char[] input1 = scan.next().toCharArray();
        char[] input2 = scan.next().toCharArray();
        
        // search
        int count = 0;
        int max = 0;
        for(int i = 0; i < num; i++){
            for(int j = 0; i + j < num; j++){
                if(input1[i+j] == input2[j]){
                    count++;
                } else {
                    break;
                }
            }
            if(count > max){
                max = count;
            }
            count = 0;
        }

        // answer
        System.out.println(num * 2 - max);
    }
}

Measured memory_bytes: 23380
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg.slice(1, N + 1);
    
    const alphabets = "abcdefghijklmnopqrstuvwxyz".split("");
    
    let answer = [];
    
    for(let i in alphabets) {
        let contains = Infinity;
        
        for(let j in S) {
            let cnt = S[j].split("").filter(n=>n===alphabets[i]).length;
            
            if(cnt > 0) {
                contains = Math.min(cnt, contains);
            } else {
                contains = 0;
                break;
            }
        }
        
        for(let j=0; j<contains; j++) {
            answer.push(alphabets[i]);   
        }
    }
    
    console.log(answer.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7820
#include<stdio.h>

 int main(){
  int a;
  int b;
  int c;
  scanf("%d %d %d", &a, &b, &c);
  
  int n;
  n = a;
  if(b > n){
  n = b;
  }
  if(c > n){
  n = c;
  }
  printf("%d",a + b + c - n);
  return 0;
  }

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

using pll = pair<long long, long long>;
int main() {
    int N;
    long long M;
    cin >> N >> M;
    vector<pll> v(N);
    for (int i = 0; i < N; ++i) cin >> v[i].first >> v[i].second;
    sort(v.begin(), v.end());

    long long res = 0;
    for (int i = 0; i < N && M > 0; ++i) {
        res += v[i].first * min(M, v[i].second);
        M -= min(M, v[i].second);
    }
    cout << res << endl;
}

Measured memory_bytes: 4788
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
int main()
{
	ll n,m,i,j,t=0,ans;
	cin >> m >> n;
	
	char ch[m][n];
    ll arr[m][n];
    
	arr[0][0]=0;
	
    for(i=0;i<m;i++)
    for(j=0;j<n;j++)
	cin >> ch[i][j];
	
	i=1;
	
	while(ch[i][0]!='#' && i<m)
	arr[i++][0]=1;
	while(i<m)
	arr[i++][0]=0;
	
	j=1;
	while(ch[0][j]!='#' && j<n)
	arr[0][j++]=1;
	while(j<n)
	arr[0][j++]=0;
	
	for(i=1;i<m;i++)
	{
	for(j=1;j<n;j++)
	{
	  if(ch[i][j]=='#')
	  arr[i][j]=0;
	  else
	  arr[i][j]=(arr[i-1][j]%M+arr[i][j-1]%M)%M;
    }
   }
    t=arr[m-1][n-1];
    t=t%M;
    cout<<t;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int fx = 0;
  
  for (int keta = 10; keta <= 100000000; keta *= 10) {
    fx += (N % keta) / (keta / 10) ;
  }
  
  int h = N % fx;
  
  if (h == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  } 
    
}

Measured memory_bytes: 256
import math

def get_input():
    depth = int(input())
    return depth


def koch_curve(p1, p2):
    dp=[(p2[0]-p1[0])/3, (p2[1]-p1[1])/3]
    
    point3=[p1[0]+dp[0], p1[1] + dp[1]]
    point5=[p1[0]+dp[0]*2, p1[1] + dp[1]*2]

    rad60 = math.pi/3
    dp2 = [dp[0]*math.cos(rad60)-dp[1]*math.sin(rad60), 
           dp[0]*math.sin(rad60)+dp[1]*math.cos(rad60)]
    

    point4=[point3[0]+dp2[0], point3[1] + dp2[1]]

    return ([point3, point4, point5])



def rec_koch_curve(pl, depth, target):
    if (target <= depth) :
        return
    
    for i in range(len(pl)-1)[::-1]:
        tplist = koch_curve(pl[i] , pl[i+1])
        for p in tplist[::-1]:
            pl.insert(i+1, p)

    rec_koch_curve(pl, depth+1, target)

def print_curve(pl):
    for p in pl:
        print(p[0],p[1],sep=" ")

pl = [[0,0],[100,0]]
rec_koch_curve(pl, 0, get_input())
print_curve(pl)


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


// 素因数が何乗かをmapで返却する
map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

void solve() {
    ll n; cin >> n;
    auto pf = prime_factor(n);

    cout << n << ": ";
    int tmp = 0;
    for(auto a: pf){
        tmp++;
        rep(i, a.second){
            cout << a.first;
            if(i == a.second-1 && tmp == pf.size()) cout << endl;
            else cout << " ";
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}



Measured memory_bytes: 7312
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
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 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);


void add_edge(VVI& graph, int u, int v){
  graph[u].push_back(v);
  graph[v].push_back(u);
}

bool dfs(VVI& biG, VI& match, int v, vector<bool>& used){
  used[v] = true;
  for(int i=0;i<biG[v].size();++i){
	int u = biG[v][i], w = match[u];
	if(w < 0 || (!used[w] && dfs(biG, match, w, used))){
	  match[v] = u;
	  match[u] = v;
	  return true;
	}
  }
  return false;
}

int bipartite_matching(VVI& biG, VI& match){
  int res = 0;
  int V = SZ(biG);
  fill(ALL(match), -1);
  for(int v=0;v<V;++v){
	if(match[v] < 0){
	  vector<bool> used(V, false);
	  if(dfs(biG, match, v, used))
		++res;
	}
  }
  return res;
}

int gcd(int x, int y){
  if(y == 0) return x;
  return gcd(y, x%y);
}

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

  int M,N;
  while(cin>>M>>N,M){
	VI b(M), r(N);
	REP(i,M) cin >> b[i];
	REP(i,N) cin >> r[i];

	VVI biG(M+N);
	for(int i=0;i<M;++i)
	  for(int j=0;j<N;++j)
		if(gcd(b[i], r[j]) > 1)
		  add_edge(biG, i, j+M);
	
	VI match(M+N);
	cout << bipartite_matching(biG, match) << endl;
  }

  return 0;
}

Measured memory_bytes: 2728
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int N, cnt = 0;
        Scanner scanner = new Scanner(System.in);

        List<Integer> numbers = new ArrayList<>();
        N = Integer.parseInt(scanner.next());

        for (int i = 0; i < N; i++) {
            numbers.add(Integer.parseInt(scanner.next()));
        }

        numbers.sort(Comparator.reverseOrder());

        for (int i = 0; i < numbers.size(); i++) {
            if (i % 2 == 0) {
                cnt += numbers.get(i);
            } else {
                cnt -= numbers.get(i);
            }
        }

        System.out.println(cnt);
    }
}


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

int main(){
	int a, b, area, length;
	area = a * b;
	length = (a + b)*2;
	
	cin >> a >> b;

        area = a * b;
	length = (a + b)*2;

	cout << area << " " << length << endl;
	return 0;
	
}

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
/* #pragma GCC target ("avx2") */
/* #pragma GCC optimize("Ofast") */
/* #pragma GCC optimize("unroll-loops") */
/* #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") */
#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;
template <typename T, typename cmp=less<T>>
using ordered_set=tree<T,null_type,cmp,rb_tree_tag,tree_order_statistics_node_update>;
template<typename K, typename V, typename cmp=less<K>>
using ordered_map=tree<K, V, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
using ll = long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax = 1000*1007;
#define ar array
#define len(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define tT template<typename T
#define tV typename V
#define ins inline string
#ifdef LOCAL
tT>ins to_string(T& t);
ins to_string(string s) {return '"' + s + '"';}
ins to_string(char c){string res="'";res.push_back(c);return res+"'";}
ins to_string(const char* s) {return to_string((string)s);}
ins to_string(char* s) {return to_string((string)s);}
template <size_t N>ins to_string(bitset<N> v) {string res="";for(size_t i = 0; i < N; i++){
res += static_cast<char>('0' + v[i]);}return res;}
ins to_string(bool b) {return (b ? "true" : "false");}
tT,tV>ins to_string(pair<T, V>& p){return "("+ to_string(p.first)+", "+to_string(p.second)+")";}
tT>ins to_string(T& v){string res="{";for(auto& i:v){res+=to_string(i)+',';} return res+'}';}
#define log(...) cerr<< "[" << #__VA_ARGS__ << " : "<< to_string(__VA_ARGS__) << "]"<<endl
#else
#define log(...) 0x30
#endif

vector<int> h;
int dp[100000+7];

int solve(int N){
    /* if(N==0) return; */
    if(N == 1) return 0;
    if(N == 2) return abs(h[0] - h[1]);
    if(dp[N] != -1) return dp[N];
    return dp[N] = min(abs(h[N-1]-h[N-2]) + solve(N-1), abs(h[N-1]-h[N-3])+solve(N-2));
}

inline void test_case(){
    memset(dp, -1, sizeof dp);
    int N;
    cin>>N;
    h.resize(N);
    for(int& i : h) cin>>i;
    cout<<solve(N)<<"\n";
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt;
    tt=  1;
    for(int qq=1; qq<=tt; qq++){
        /* cout<<"Case #"<<qq<<": "; */
        test_case();
    }
}   



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll infl = 1ll<<60;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x;
    cin>>x;
    vector<bool> p(1000050,true);
    for(int i=2;i*i<=1000000;++i)if(p[i]){
        for(int j=2;j*i<=1000000;j++)p[i*j] = false;
    }
    p[0] = false;p[1] = false;
    
    for(int i=x;i<=1000000;++i)if(p[i]){cout << i << endl;break;}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C;
  int X;
  cin >> A >> B >> C;
  
  X = A + B + C;
  
  if (X >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> P(N+1),C(N+1);
  for(int i = 1;i <= N;i++)cin >> P[i];
  for(int i = 1;i <= N;i++)cin >> C[i];
  vector<vector<ll>> score(N+10,vector<ll> (N+10,0));
  vector<vector<ll>> count(2,vector<ll> (N+1,0));
  for(int i = 1;i <= N;i++){
    ll cur = i;
    for(int j = 1;j <= N;j++){
      score[j][i] = score[j-1][i] + C[P[cur]];
      cur = P[cur];
      if(cur == i){
        count[0][i] = j;
        count[1][i] = score[j][i];
      }
    }
  }
/*
  rep(i,N+1){
    rep(j,N+1){
      cout << score[i][j] << " ";
    }
    cout << endl;
  }
  */

  ll ans = (-1)*INFL;
  for(int i = 1;i <= N;i++){
    for(int j = 1;j <= N;j++){
      ll a = count[0][j],b = count[1][j];
      if(i > a)continue;
      if(i > K)continue;
      ll res = score[i][j];
      if(b > 0)res += ((K-i)/a)*b;
      if(res > ans){
        ans = res;
        a = i;
        b = j;
      }
    }
  }
  //cout << ans << " " << a << " " << b << endl;
  cout << ans << endl;

  return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);

  int N,K;
  cin >> N >> K;
  cout << N - K + 1 << endl;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 510;

int a[maxn][maxn];

void solve(int l, int r, int now) {
	if (l == r) return ;
	int m = (l + r) / 2;
	solve(l, m, now + 1);
	solve(m + 1, r, now + 1);

	for (int k = l; k <= m; ++k) {
		for (int t = m + 1; t <= r; ++t) {
			a[k][t] = now;
		}
	}
}

int main() {
	int N; cin >> N;
	solve(0, N-1, 1);
	rep(i, N-1) {
		for (int j = i + 1; j < N; ++j) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

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

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

    int che[4] = {0, 0, 0, 0};
    int k[4] = {1, 9, 7, 4};
    int flag = 0;
    for(int i = 0; i < 4; i++){
        flag = 0;
        for(int j = 0; j < 4; j++){
            if(a[i] == k[j] && che[j] == 0){
                flag = 1;
                che[j] = 1;
            }
        }

        if(flag == 0){
            break;
        }
    }

    if(flag == 0){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3600
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll modpow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll N;
P e[200010];
vector<P> pp,mm,pm,mp;
struct E
{
    ll A,B,C,D;
};

map<P,E> ptoE;
ll aZero,bZero;
int main(){
    cin>>N;
    ll ansPlus=0;
    for(ll i=0;i<N;i++){
        ll a,b;cin>>a>>b;
        if(a==0 || b==0){
            if(a==0 && b==0){
                ansPlus++;
            }else if(a==0){
                aZero++;
            }else{
                bZero++;
            }
            continue;
        }
        e[i]=P(a/gcd(abs(a),abs(b)),b/gcd(abs(a),abs(b)));
        if(a>0){
            if(b>0)pp.push_back(e[i]);
            if(b<0)pm.push_back(e[i]);
        }else{
            if(b>0)mp.push_back(e[i]);
            else mm.push_back(e[i]);
        }
    }
    for(auto p:pp){
        ptoE[p].A++;
    }
    for(auto p:pm){
        ptoE[P(-p.second,p.first)].B++;
    }
    for(auto p:mp){
        ptoE[P(p.second,-p.first)].C++;
    }
    for(auto p:mm){
        ptoE[P(-p.first,-p.second)].D++;
    }
    ll ans=1;
    for(auto p:ptoE){
        ll A=p.second.A,B=p.second.B;
        ll C=p.second.C,D=p.second.D;
        ans=ans*(modpow(2,(A+D)%MOD,MOD)+modpow(2,(B+C)%MOD,MOD)-1)%MOD;
    }
    ans=ans*((modpow(2,aZero,MOD)+modpow(2,bZero,MOD)-1)%MOD)%MOD;
    cout<<(ans+ansPlus-1+MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 27996
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける

bool flag[1050000];
const int INF = 1001001001;
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };

int main() {
	string s;
	cin >> s;
	int n=s.length();
	int ans = 0;
	for (int i = 0;i < n - 1;++i) {
		if (s[i] == s[i + 1]) {
			ans++;
			if (s[i + 1] == '0')s[i + 1] = '1';
			else s[i + 1] = '0';
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main(){
  char S[27];
  scanf("%s",S);
  int l=strlen(S);
  for(int i=0;i<l;i++){
    S[l]=S[i];
    int k=i;
    while(1){
      k++;
      if(k==l) break;
      if(S[i]==S[k]){
        printf("no\n");
        return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
      
        int length = A - 2 * B;
        if (length < 0) {
          System.out.println(0); 
        } else {
          System.out.println(length); 
        }
        
        
    }
}

Measured memory_bytes: 23124
from collections import defaultdict

N = int(input())
D = defaultdict(int)
for i in range(N):
    D[input()] += 1

sorted_D = sorted(D.items(), key=lambda x:x[1], reverse=True)

num = max(D.values())
ans = []
for key, value in sorted_D:
    if value == num:
        ans.append(key)
    else:
        break
ans.sort()
for i in ans:
    print(i)


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

#define DEF_ELM_MAX 200

static int top;
static int S[DEF_ELM_MAX];

void initialize( void )
{
	top = 0;
}

void push(int x)
{
	if(top == DEF_ELM_MAX-1) {
		//	overflow
		return;
	}
	S[top++] = x;
}

int pop( void )
{
	if(top == 0) {
		//	underflow
		return -1;
	}
	return S[--top];
}

////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	char pStr[100];
	int ans = 0;
	int iwork;
	int a;
	int b;
//
	while (scanf("%s", pStr) != EOF ) {
		switch (pStr[0]) {
		case '+':
			b = pop();
			a = pop();
			push(a+b);
			break;
		case '-':
			b = pop();
			a = pop();
			push(a-b);
			break;
		case '*':
			a = pop();
			b = pop();
			push(a*b);
			break;
		default:
			iwork = atoi(pStr);
			push(iwork);
			break;
		}
	}

	printf("%d\n", pop());
	
	return 0;
}

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

r1=[set() for _ in range(26)]
r2=[set() for _ in range(26)]
for s,t in zip(S,T):
  r1[ord(t)-ord('a')].add(s)
  r2[ord(s)-ord('a')].add(t)
  
flag=True
for ind,outd in zip(r1,r2):
  n_in=len(ind)
  n_out=len(outd)
  if n_in>=2 or n_out>=2:
    flag=False
    break
print('Yes') if flag else print('No')

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

struct UnionFind{
    vector<int> v;
    UnionFind(int n){ v.assign(n,-1); }
    int  find(int x){ return v[x]<0? x:v[x]=find(v[x]); }
    void unite(int x,int y){
        x=find(x),y=find(y); if(x==y) return;
        if(v[x]>v[y]) swap(x,y); v[x]+=v[y],v[y]=x;
    }
    int  size(int x){ return -v[find(x)]; }
    bool same(int x,int y){ return find(x)==find(y); }
    bool root(int x){ return v[x]<0; }
};

signed main()
{
    int N,M; cin>>N>>M;
    vector<vector<int> > a(M,vector<int>());
    for(int i=0;i<N;i++){
        int k; cin>>k;
        while(k--){
            int l; cin>>l; l--;
            a[l].push_back(i);
        }
    }

    UnionFind tree(N);
    for(int i=0;i<M;i++){
        for(int j=0;j<(int)a[i].size()-1;j++){
            tree.unite(a[i][j],a[i][j+1]);
        }
    }
    if(tree.size(0)==N){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

ll a,b;

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

   int k=0;
   while(b>(k)*(a-1)+1){
    ++k;
   }
   cout << k;
  return 0;
}


Measured memory_bytes: 256
def resolve():
    N = list(input())
    lenN = len(N)
    K = int(input())
    dp = [[[None, None] for _ in range(K+1)] for __ in range(lenN)]

    def rec(i, k, smaller):
        if k==0:
            return 1
        if i>=lenN:
            return 0
        
        if dp[i][k][int(smaller)] is not None:
            return dp[i][k][int(smaller)]
        
        ret = 0
        if smaller:
            ret += rec(i+1, k, True)
            ret += rec(i+1, k-1, True) * 9
        else:
            if N[i] == "0":
                ret += rec(i+1, k, False)
            else:
                ret += rec(i+1, k, True) # 次も0を選ぶ
                ret += rec(i+1, k-1, True) * (int(N[i]) - 1) # 0 < ?? < N[i]
                ret += rec(i+1, k-1, False) # N[i]を選ぶ、真にsmallerとは限らないのでまだFalse
        
        dp[i][k][int(smaller)] = ret
        return ret

    print(rec(0, K, False))
    
    
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 62752
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i) = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  ll n;cin>>n;
  vector<ll> a;

  for(ll i = 1;i*i <= n;++i){
    if(n%i==0){
      a.pb(i);
      if(i != n/i)a.pb(n/i);
    }
  }

  ll ans = 0;
  for(auto&&m : a){
    m--;
    if(m && n/m==n%m)ans+=m;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>//sort(昇順)
#include<string>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<cmath>
#include<limits>
#include<map>


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

using namespace std;

int main(){
	int a,b,c,d;
	cin >> a;
	b = a/1000;c = (a%1000)/100; d = (a%100)/10; a = a%10;
	
	     if(b+c+d+a == 7)cout << b << "+" << c << "+" << d << "+" << a << "=7" << endl;
	else if(b+c+d-a == 7)cout << b << "+" << c << "+" << d << "-" << a << "=7" << endl;
	else if(b+c-d-a == 7)cout << b << "+" << c << "-" << d << "-" << a << "=7" << endl;
	else if(b+c-d+a == 7)cout << b << "+" << c << "-" << d << "+" << a << "=7" << endl;
	else if(b-c-d-a == 7)cout << b << "-" << c << "-" << d << "-" << a << "=7" << endl;
	else if(b-c-d+a == 7)cout << b << "-" << c << "-" << d << "+" << a << "=7" << endl;
	else if(b-c+d+a == 7)cout << b << "-" << c << "+" << d << "+" << a << "=7" << endl;
	else if(b-c+d-a == 7)cout << b << "-" << c << "+" << d << "-" << a << "=7" << endl;


return 0;}





Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
#define LEN 1000000

typedef struct{
	char name[10];
	int t;
}QUEUE;

QUEUE queue[LEN];
int head,tail;

void enqueue(QUEUE x){
	queue[tail] = x;
	tail = (tail+1)%LEN;	//????????°????????????????????????????????§???????¶???????????????????
}

QUEUE dequeue(){
	QUEUE x = queue[head];
	head = (head+1)%LEN;
	return x;
}

int main(int argc, char const *argv[])
{
	int n,quantum;
	int total_time=0;
	QUEUE output;	//????????¨

	cin >> n;
	cin >> quantum;

	head=0;	tail=n;

	for (int i = 0; i < n; ++i)	//queue?????????????????\???
	{
	 	cin >> queue[i].name;
	 	cin >> queue[i].t;
	}

	while(head != tail)	//?????£????????¨head=tail
	{
		output=dequeue();

		if (output.t <= quantum)
		{
			total_time += output.t;
			cout << output.name << " " << total_time << endl;
		}
		else
		{
			output.t -= quantum;
			total_time += quantum;
			enqueue(output);
		}
	}
	return 0;
}

Measured memory_bytes: 5980
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;
    int sumt = 0,sumh = 0;
    int t[111],h[111];
    for(int i=0;i<n;i++){
      cin >> t[i];
      sumt += t[i];
    }
    for(int i=0;i<m;i++){
      cin >> h[i];
      sumh += h[i];
    }
    int minn = 100000;
    int anst=-1,ansh=-1;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	int nt = sumt - t[i] + h[j];
	int nh = sumh + t[i] - h[j];
	if(nt == nh && minn > t[i] + h[j]){
	  anst = t[i];
	  ansh = h[j];
	  minn = t[i] + h[j];
	}
      }
    }
    if(anst == -1 && ansh == -1) cout << "-1" << endl;
    else cout << anst << " " << ansh << endl;
  }
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <limits>
#include <vector>
#include <algorithm>
#include <functional>

typedef long long lint;

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
lint* array(lint x) {
	lint *array = new lint[x];
	return array;
};
lint** array2(lint x, lint y) {
	lint **array = new lint*[x];
	rep(i, x)array[i] = new lint[y];
	return array;
}
int main() {
	while (true) {
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		int count = 0;
		repi(i,1,n+1)repi(j, i+1, n+1)repi(k, j+1, n+1) {
			if (i + j + k == x)count++;
		}
		cout << count << "\n";
	}
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){
 
  vector <string> a,b;
  string tmp;
  int n,i;
 
  cin>>n;
  for(i=0;i<n;i++){
    cin>>tmp;
    a.push_back(tmp);
  }
  b.assign(a.begin(),a.end());
  for(i=0;i<n-1;i++) for(int j=n-2;j!=i-1;j--) if(a[j][1]>a[j+1][1]) swap(a[j],a[j+1]);
  for(i=0;i<n-1;i++) cout<<a[i]<<" ";
  cout<<a[n-1]<<endl<<"Stable"<<endl;
 
  for(i=0;i<n-1;i++){
    int now,minnum=101;
    for(int j=i;j<n;j++) if(minnum>b[j].at(1)-'0'){
        now=j;
        minnum=b[j].at(1)-'0';
      }
    if(i!=now)  swap(b[i],b[now]);
  }
 
  for(i=0;i<n-1;i++) cout<<b[i]<<" ";
  cout<<b[n-1]<<endl;
  if(a==b) cout<<"Stable"<<endl;
  else cout<<"Not stable"<<endl;
 
  return 0;
 
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define pb          emplace_back
#define fi          first
#define se          second
#define show(...)   fprintf(stderr, __VA_ARGS__ )
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i<(n); ++i)
#define ALL(x) x.begin(), x.end()
template<class A, class B>inline bool chmax(A &a, B b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, B b){return b<a ? a=b,1 : 0;}
inline bool inside(int x, int y, int W, int H) { return x>=0 && y>=0 && x<W && y<H; }
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
constexpr int       INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int dx[] = {1, 0, -1, 0};
constexpr int dy[] = {0, 1, 0, -1};

/*
map<int, ll> mp[55];
int slv(int idx, int minx, int miny, int maxx, int maxy, int S)
{

}
*/

int N, K;
ll x[55], y[55];

int countRectInnerPoint(ll minX, ll minY, ll maxX, ll maxY)
{
    int cnt = 0;
    rep(i, N) {
        if (x[i] >= minX
                && x[i] <= maxX
                && y[i] >= minY
                && y[i] <= maxY) {

            ++cnt;
        }
    }
    return cnt;
}


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

    ll minX, minY, maxX, maxY;

    cin >> N >> K;

    rep(i, N) {
        cin >> x[i] >> y[i];
    }

    ll ans = LINF;

    // i,k = x   j,l = y
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            for (int k=i+1; k<N; ++k) {
                for (int l=j+1; l<N; ++l) {
                    minX = min(x[i], x[k]);
                    maxX = max(x[i], x[k]);
                    minY = min(y[j], y[l]);
                    maxY = max(y[j], y[l]);
                    if (countRectInnerPoint(minX, minY, maxX, maxY) >= K) {
                        ans = min(ans, (maxX-minX) * (maxY - minY));
                    }
                }
            }
        }
    }

    outl(ans);

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  string s,t;cin>>s>>t;
  string ans;
  for(int i=0;i<n;i++){
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<endl;
}

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

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
#define GETIN2MACRO(_1, _2, NAME, ...) NAME
#define GETIN3MACRO(_1, _2, _3, NAME, ...) NAME
#define GETIN4MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define GETIN5MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME
#define GETIN6MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
#define GETIN7MACRO(_1, _2, _3, _4, _5, _6, _7, NAME, ...) NAME
#define INPUT1(n) \
  ll n;           \
  cin >> n
#define INPUT2(a, b) \
  ll a, b;           \
  cin >> a >> b
#define INPUT3(n, a, b) \
  ll n, a, b;           \
  cin >> n >> a >> b
#define INPUT4(n, m, a, b) \
  ll n, m, a, b;           \
  cin >> n >> m >> a >> b
#define INPUT(...)                                         \
  GETIN4MACRO(__VA_ARGS__, INPUT4, INPUT3, INPUT2, INPUT1) \
  (__VA_ARGS__)
#define INPUTARR(n, a) \
  ll a[n];             \
  REP(i, n) { cin >> a[i]; }
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

// search max depth
ll dfs(vector<vector<ll>>& tree, ll parent, ll now, ll depth) {
  ll d = depth;
  for (auto i : tree[now]) {
    if (i == parent) continue;
    d = max(d, dfs(tree, now, i, depth + 1));
  }
  return d;
}

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

void solve() {
  DEBUG("SOLVE START");

  //solve
  INPUT(n);
  string s;
  cin>>s;
  ll ans=0;
  REP(i,n-2){
    DEBUG(s.substr(i,3));
    if(s.substr(i,3)=="ABC"){
      ans++;
    }
  }
  PRINT(ans);

  return;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}

Vec fac, finv;

ll PowMod(ll a, ll n){
    if(n == 1) return a;
    if(n%2 == 0) return PowMod(a*a%MOD, n/2);
    return a*PowMod(a*a%MOD, n/2)%MOD;
}

ll combi(ll n, ll k){
    if(k>n) return 0;
    return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int main() {
    int n;
    double ans=0;
    R n;
    rep(i, n){
        double x;
        string u;
        R x >> u;
        if (u == "BTC")x *= 380000;
        ans += x;
    }
    co(ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String a = "";
		String t1 = "";
		String t2 = "";
		if(N%2==1) {
			a = "No";
		}else {
			for(int i=0; i<N/2; i++) {
				t1 += S.charAt(i);
			}
			for(int i=N/2; i<N; i++) {
				t2 += S.charAt(i);
			}
			if(t1.equals(t2)) {
				a = "Yes";
			}else {
				a = "No";
			}
		}
		sc.close();
		System.out.println(a);
	}

}

Measured memory_bytes: 21844
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if A + B <= K:
        print("0 0")
    elif A > K:
        print(str(A-K) + " " + str(B))
    else:
        print("0 " + str(A + B - K ))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//    ____       ____                 _           
//   |  _ \ _ __|  _ \  ___ _ __   __| |_ __ ___  
//   | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ 
//   | |_| | |_ | |_| |  __/ | | | (_| | | | (_) |
//   |____/|_(_)|____/ \___|_| |_|\__,_|_|  \___/ 
//                                                

 
#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 db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define f first
#define s second
#define pb push_back
#define ll long long

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ll LLOO = 1e18+7;
const ll OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;



int main()
{
	
	int x,y,a,b,c;
	scanf("%d %d %d %d %d",&x,&y,&a,&b,&c);
	vector<pair<int,int> > vec;
	rep(i,a)
	{
		int x;
		scanf("%d",&x);
		vec.pb({x,1});
	}
	rep(i,b)
	{
		int x;
		scanf("%d",&x);
		vec.pb({x,2});
	}
	rep(i,c)
	{
		int x;
		scanf("%d",&x);
		vec.pb({x,0});
	}
	
	sort(vec.begin(),vec.end(),greater<pair<int,int> >());
	
	int eaten = 0;
	ll ans = 0;
	for(auto p:vec)
	{
		if (eaten >= x+y) break;
		if (p.s == 1 && x > 0) {x--;ans += p.f;}
		if (p.s == 2 && y > 0) {y--;ans += p.f;}
		if (p.s == 0) {eaten++;ans += p.f;}
	}
	
	printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 6512
#include <iostream>
using namespace std;
int main () {
  int A[4][3][10];
  int n;
  int b, f, r, v;
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
    A[i][j][k] = 0;
      }
    }
  }
 
  cin >> n;
  for (int i = 0; i<n; i++) {
    cin >> b >> f >> r >> v;
    if ((b > 0) && (b < 5) && (f > 0) && (f < 4) && (r > 0) && (r < 11)) {
      A[b-1][f-1][r-1] += v;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
    cout << " " << A[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
 
  return 0;
}

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mxx=3001;

int id[mxx][mxx];
bool vis[mxx][mxx];
string grid[mxx];
map<int,int> ans;
int num;int a,b,x,y,n,m;
map<int,set<int> > adj;

bool in(int i,int j)
{
  if(i<0 || j<0 || i>=n || j>=m)return false;
  return true;
}

void dfs(int i,int j)
{
     vis[i][j]=true;
     id[i][j]=num;
     if(in(i+1,j) && grid[i+1][j]=='.' && !vis[i+1][j])dfs(i+1,j);
     if(in(i-1,j) && grid[i-1][j]=='.' && !vis[i-1][j])dfs(i-1,j);
     if(in(i,j+1) && grid[i][j+1]=='.' && !vis[i][j+1])dfs(i,j+1);
     if(in(i,j-1) && grid[i][j-1]=='.' && !vis[i][j-1])dfs(i,j-1);
}

int main()
{
    fast

    cin>>n>>m>>a>>b>>x>>y;
    a--;b--;x--;y--;
    for(int i=0;i<n;i++)cin>>grid[i];

    if(grid[x][y]=='#'){cout<<-1;return 0;}
    memset(vis,false,sizeof vis);
     num=0;
    for(int i=0;i<n;i++)
    {
       for(int j=0;j<m;j++)
       {
          if(grid[i][j]=='.' && !vis[i][j])
           {num++; dfs(i,j);}
       }
    }

    for(int i=0;i<n;i++)
    {
       for(int j=0;j<m;j++)
       {
          if(grid[i][j]=='#')continue;
          for(int k=-2;k<=2;k++)
          {
             for(int t=-2;t<=2;t++)
             {   
                if(abs(t)+abs(k)<=1)continue;
                if(in(i+k,j+t) && grid[i+k][j+t]=='.' && id[i+k][j+t]!=id[i][j])
                {
                   adj[id[i+k][j+t]].insert(id[i][j]);
                   adj[id[i][j]].insert(id[i+k][j+t]);
                }
             }
          }
       }
    }

    queue<pair<int,int> > q;
    q.push({id[x][y],0});
    ans[id[x][y]]=0;
    while(!q.empty())
    {
        pair<int,int> cur=q.front();
        q.pop();
        for(auto x:adj[cur.first])
        {
            if(!ans.count(x))
            {
               ans[x]=cur.second+1;
               q.push({x,cur.second+1});
            }
        }
    }
     if(!ans.count(id[a][b]))cout<<-1;
     else cout<<ans[id[a][b]];    
}

Measured memory_bytes: 56444