akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n;
	cin >> n;
	vector <int> A(n);
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	int ans = 1;
	int c = 1;
	for (int i = 1; i < n; i++)
	{
		if(A[i] <= A[i - 1])
		{
			c++;
			ans = max(ans, c);
		}
		else
		{
			c = 1;
		}
	}
	cout << ans - 1;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def sgined_area(v0, v1, v2):
    a1 = v1[0] - v0[0]
    a2 = v1[1] - v0[1]
    b1 = v2[0] - v0[0]
    b2 = v2[1] - v0[1]
    return a1*b2 - b1*a2


n = int(input())
vors = [[int(a) for a in input().split() ] for _ in range(n)]
vors.sort(key=lambda v: (v[1], v[0]))

over = [vors[0], vors[1]]

for v in vors[2:]:
    while len(over) > 1 and sgined_area(over[-2], over[-1], v) > 0:
        over.pop()
    over.append(v)
        
under = [vors[0], vors[1]]

for v in vors[2:]:
    while len(under) > 1 and sgined_area(under[-2], under[-1], v) < 0:
        under.pop()
    under.append(v)

print(len(over) + len(under) - 2)
for v in under[:-1]:
    print(v[0], v[1])

for v in reversed(over[1:]):
    print(v[0], v[1])
          

Measured memory_bytes: 33556
#include<stdio.h>
#include<string.h>
int main()
{
    char s[4];
    int len,i,flag=0;

    gets(s);

    len=strlen(s);

    for(i=0; i<len; i++)
    {
        if(s[i]==s[i+1])
        {
            flag=1;
        }
    }

    if(flag==1)
    {
        printf("Bad\n");
    }
    else
    {
        printf("Good\n");
    }

    return 0;
}


Measured memory_bytes: 128
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, M) = read!(usize, usize);

    let mut G = vec![vec![]; N];
    // let mut H = vec![vec![]; N];
    let mut deg = vec![0; N];

    for i in 0..(N + M - 1) {
        let (A, B) = read!(usize, usize);
        G[A - 1].push((i, B - 1));
        // H[B - 1].push(i);
        deg[B - 1] += 1;
    }

    let mut root = 0;
    for i in 0..N {
        if deg[i] == 0 {
            root = i;
            break;
        }
    }
    debug!(root);

    let mut Q = VecDeque::new();
    Q.push_back(root);
    // let mut acc = vec![false; N + M - 1];
    // let mut rej = vec![false; N + M - 1];
    let mut par = vec![0; N];

    while let Some(q) = Q.pop_front() {
        // debug!(q);
        for i in 0..G[q].len() {
            let (_, r) = G[q][i];
            // debug!((q, e, r, deg[r]));
            if deg[r] != 1 {
                // rej[e] = true;
                deg[r] -= 1;
                continue;
            }
            // acc[e] = true;
            par[r] = 1 + q;
            Q.push_back(r);
        }
    }

    for i in 0..N {
        println!("{}", par[i]);
    }
}


Measured memory_bytes: 15100
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; string s;
    cin >> n >> s;
    map<ll, ll> cnt;
    rep(i, n) cnt[s[i]-'0']++;
    set<ll> top, ans;
    cnt[s[0]-'0']--;
    top.insert(s[0]-'0');
    for(ll i=1; i<n-1; i++){
        ll mid = s[i]-'0';
        cnt[mid]--;
        for(auto &a: top){
            for(auto &c: cnt){
                if(c.second <= 0) continue;
                ans.insert(a*100+mid*10+c.first);
            }
        }
        top.insert(mid);
    }
    cout << ans.size() << endl;
}

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

int main() {
  int n; cin >>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a.rbegin(),a.rend());
  for(int i=0;i<n;i++){
    if(b[i]!=a[0]){
      cout<<a[0]<<endl;
    }else{
      cout<<a[1]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include<stdio.h>

int main(){

	int  N, A, B, plan1, plan2;

	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);

	plan1 = A * N;
	plan2 = B;

	if (plan1 <= plan2) {
		printf("%d", plan1);
	}
	else {
		printf("%d", plan2);
	}
	

	return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int y){
  if(y%4)
    return 0;
  else if(y%100)
    return 1;
  else if(y%400)
    return 0;
  else
    return 1;
}
int main(){
  int i;
  int y1,m1,d1,y2,m2,d2,c;
  int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  for(;;){
    cin>>y1>>m1>>d1>>y2>>m2>>d2;
    if(y1==-1||m1==-1||d1==-1||y2==-1||m2==-1||d2==-1)
      break;
    c=0;
    if(y1==y2){
      if(m1==m2)
	c=d2-d1;
      else{
	c+=a[m1]-d1+1+(m1==2&&f(y1));
	c+=d2-1;
	for(i=m1+1;i<m2;i++)
	  c+=a[i]+(i==2&&f(y1));
      }
    }else{
      c+=a[m1]-d1+1+(m1==2&&f(y1));
      c+=d2-1;
      for(i=m1+1;i<13;i++)
	c+=a[i]+(i==2&&f(y1));
      for(i=1;i<m2;i++)
	c+=a[i]+(i==2&&f(y2));
      for(i=y1+1;i<y2;i++)
	c+=365+f(i);
    }
    cout<<c<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int* a = new int[n + 1];
	int* b = new int[n];				
	for (int i = 0; i < n+1; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	int z = b[0];
	long long ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (b[i] >= a[i])
		{
			ans += a[i];
			b[i] -= a[i];
			a[i] = 0;
		}
		else
		{
			ans += b[i];
			a[i] -= b[i];
			b[i] = 0;
		}

		if (b[i] >= a[i + 1])
		{
			ans += a[i + 1];
			b[i] -= a[i + 1];
			a[i + 1] = 0;
		}
		else
		{
			ans += b[i];
			a[i + 1] -= b[i];
			b[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;

int main(){

	int ans=0;
	int n;
	cin>>n;
	int p[n];
	for(int i=0;i<n;i++)cin>>p[i];

	int min=100000000;
	int count=0;
	for(int i=0;i<n;i++){
		if(p[i]<=min){
			min=p[i];
			count++;
		}
	}

	cout<<count;

	cout<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<bool> v(101, false);
  for (int i = 4; i <= 100; i += 4) {
    v[i] = true;
    for (int j = i; j <= 100; j += 7)
      v[j] = true;
  }
  for (int i = 7; i <= 100; i += 7) {
    v[i] = true;
    for (int j = i; j <= 100; j += 4)
      v[j] = true;
  }

  if (v[n])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  long long N,A,B,C;
  cin >> N >> A >> B;
  C = N%(A+B);
  if(A==0){
    cout << 0 <<endl;
  }
  else if(B==0){
    cout << N << endl;
  }
  else{
    if(C>=A){
      cout << (N/(A+B))*A+A << endl;
    }
    else{
      cout << (N/(A+B))*A+C << endl;
    }
  }
}


Measured memory_bytes: 256
#このプログラムはpypyじゃ通らない
import collections,math
s = input()
t = input()
#tを構成文字で、sにない文字があったらダメ。
#構成できるなら最大でもlen(t)個しかないから、10^100の連結は必要ない

#最も不足する文字を探す
ls = collections.Counter(s)
lt = collections.Counter(t)

time_dict ={}
tmp=0
max_time=0#一番少ないやつ
for t_key,t_val in lt.items():
    if t_key not in ls:#sの中にtの文字がない
        print(-1)
        exit()

#文字をカウントしていく
cnt = 0
tt = list(t[::-1])#指定したい文字へのアクセス時間を1にしたいので反転
idx=0
ss = s#ssは検索文字列
while tt!=[]:#ttが空っぽになったらおしまい
    next_t = tt.pop()#つぎに構成したい文字= next_t
    idx=ss.find(next_t)#検索文字列にnext_tがあるか
    if idx == -1:#ない
        cnt += len(ss)#検索文字列の長さを全部足す
        idx = s.find(next_t)#新たにsを検索文字列として探す
        ss = s[idx+1:]#next_t以降の文字列を次回の検索文字列をセット
        cnt += idx+1 #nex_tが見つかった文字までの長さ
    else:#ある
        cnt += idx+1 #文字長さを足す 
        ss = ss[idx+1:]#次回の検索文字列をセット
print(cnt)


Measured memory_bytes: 10360
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class AXorBattle {
public:

    vector<ll> zero;
    vector<ll> one;

    void hakidashi(ll a, vector<ll>& v) {
      sort(v.rbegin(), v.rend());

      for(const auto e: v) {
        ll tmp1 = a;
        ll cnt1 = 0;
        while(tmp1 > 0) {
          cnt1++;
          tmp1 /= 2;
        }

        ll tmp2 = e;
        ll cnt2 = 0;
        while(tmp2 > 0) {
          cnt2++;
          tmp2 /= 2;
        }

        if (cnt1 == cnt2) {
          a ^= e;
        }
      }
      if (a != 0) v.push_back(a);
    }

    bool check(ll b) {
      sort(zero.rbegin(), zero.rend());

      for(auto& e: zero) {
        ll tmp = b;
        ll cnt = 0;
        while(tmp > 0) {
          cnt++;
          tmp /= 2;
        }
        ll c = 0;
        ll tmp2 = e;
        while(tmp2 > 0) {
          c++;
          tmp2 /= 2;
        }
        if (cnt == c) {
          b ^= e;
          //e = 0;
        }
      }

      return (b==0);
    }

    void calc(istream& cin, ostream& cout) {
      int n; cin >> n;
      vector<ll> a(n);
      rep(i, n) {
        cin >> a[i];
      }
      string s; cin >> s;
      reverse(all(s));
      reverse(all(a));
      rep(i, n) {
        if (s[i] == '0') {
          hakidashi(a[i], zero);
        } else {
          hakidashi(a[i], one);
          for(auto e: one) {
            if (!check(e)) {
              cout << 1 << '\n';
              return;
            }
          }
        }
      }
      cout << 0 << '\n';


    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int t; cin >> t;
      while(t--) {
        calc(cin, cout);
        zero.clear();
        one.clear();
      }
    }
};

signed main() {
  AXorBattle solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int k, s; cin >> k >> s;
    int ans = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            int z = s - x - y;
            if (0 <= z && z <= k) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (int i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<int,int> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define sz(a) (ll)a.size()
#define endl '\n'
#define po(a,b) (ll)(pow(a,b)+0.5)
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
const ll M=1e17+7;
const int MX=2e5+5;

int main()
{  Fast
int n,mx;
cin>>n>>mx;
   int a,b;
   ll dp[MX];
   fr(i,0,MX)dp[i]=M;
   dp[0]=0; ll ans=0;
   fr(i,0,n)
   {   cin>>a>>b;
       frr(i,MX,1)
       {
           if(i-b>=0)dp[i]=min(dp[i],dp[i-b]+a);
           if(dp[i]<=mx)ans=max(ans,i);
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 5196
x, a, b = list(map(int, input().split()))
def MealDelivery(x, a, b):
    if abs(x -a) < abs(x -b):
        return 'A'
    elif abs(x -a) > abs(x -b):
        return 'B'
    else:
        return 'Even'
ans = MealDelivery(x, a, b)
print(ans)

Measured memory_bytes: 3060
//structured.cpp
#include<iostream>
using namespace std;

int main()
{
    int n,i,x;
    cin>>n;
    for ( i = 1; i <= n; i++)
    {
        x=i;
        if (x%3==0) 
        {
            cout<<" "<<i;
        }
        else
        {
            while (x>0)
            {
                if (x%10==3) 
                {
                    cout<<" "<<i;
                    break;
                }
                else
                {
                    x/=10;
                }
            }
        }
    }
    cout<<endl;
}


Measured memory_bytes: 3096
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (a, b) = readIntegerList()
    println(a * b)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 36448
let rewrite s =
  let s_as_bytes = Bytes.of_string s in
  let _ = Bytes.set s_as_bytes 3 '8' in
  Bytes.to_string s_as_bytes
  

let () =
  let s = Scanf.scanf "%s" (fun x -> x) in
  let ans = rewrite s in
  Printf.printf "%s\n" ans


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std; 
//Important observation about this question is, it's enough
//to know whether given subset of rabits either belong
//to any group or doesn't belong to any group, in that way
//you will have 2^n subsets (where 0 represents they donot
//belong to any group and 1 represents they belong to some
//group, keep in mind we don't care which group, because
//in the process of transition we would have considered
//the best way to group all those already grouped rabbits)
//going from 0 to 2^n-1, first we will have none of them
//belonging to any group, i.e 0 and we find all the subsets
//of rabbits not belonging to any group and update the 
//max of the current mask, which also contains all the already
//available rabbits. This works because if the current group
//of rabbits which were formed from non-grouped rabbits 
//is better than including both these and already grouped rabbits
//then we can just put those already grouped rabbits
//in different groups and their max score of the group
//they belong will be 0
//Time complexity : O(2^(2n)+2^(n)n^2)
//Source : Errichto's youtube stream
vector<long long> dp;
vector<long long> pre;
long long score_so_far;
void group(int i,const vector<int>& not_grouped,int mask,int cur_group){
    if(i==not_grouped.size()){
        dp[mask] = max(dp[mask],score_so_far+pre[cur_group]);
        return;
    }
    group(i+1,not_grouped,mask,cur_group);
    group(i+1,not_grouped,mask^(1<<not_grouped[i]),cur_group^(1<<not_grouped[i]));
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    dp.resize(1<<n,LONG_LONG_MIN);
    pre.resize(1<<n,0);
    for(int mask=0;mask<(1<<n);mask++){
        for(int i=0;i<n;i++){
            if(mask&(1<<i)){
                for(int j=i+1;j<n;j++){
                    if(mask&(1<<j)){
                        pre[mask]+=a[i][j];
                    }
                }
            }
        }
    }
    dp[0] = 0;
    for(int mask=0;mask<(1<<n);mask++){
        vector<int> not_grouped;
        for(int i=0;i<n;i++){
            if(!(mask&(1<<i))){
                not_grouped.push_back(i);
            }
        }
        score_so_far = dp[mask];
        group(0,not_grouped,mask,0);
    }
    cout<<dp[(1<<n)-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define pb push_back
#define mp make_pair
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a, b, k, n;
    cin>>a>>b>>k;
    int dm = a;
    a = max(a-k, 0ll);
    k = max(k-dm, 0ll);
    b = max(b-k, 0ll);
    cout<<a<<' '<<b;//<<' '<<k;
}

Measured memory_bytes: 256
// AOJ 2157: Dial Lock
// 2017.11.9 bal4u@uu

#include <stdio.h>
#include <string.h>

#define HASHSIZ 20011
long long hash[HASHSIZ+2], *hashend = hash+HASHSIZ;

int insert(long long n)
{
	long long *p = hash + n % HASHSIZ;
	while (*p) {
		if (*p == n) return 0;
		if (++p == hashend) p = hash;
	}
	*p = n;
	return 1;
}

#define QSIZE 15000
typedef struct { long long s; int k; } Q;
Q q[QSIZE+2]; int top, end;

long long s2x(char *s)
{
	long long x = 0;
	while (*s) x = (x << 4) | (*s++ & 0xf);
	return x;
}

int main()
{
	int n, i, k, d, ans;
	char ss[11], tt[11];
	long long s, t, x, mask;

	while (scanf("%d", &n) && n > 0) {
		memset(hash, 0, sizeof(hash));
		scanf("%s%s", ss, tt);
		s = s2x(ss), t = s2x(tt);
		q[0].s = s, q[0].k = 0; top = 0, end = 1; insert(s);
		ans = -1;
		while (top < end) {
			s = q[top].s, k = q[top++].k;
			if (s == t) { ans = k; break; }
			for (mask = 0xfLL << 4*(n-1), i = 0; (s&mask) == (t&mask); i++, mask >>= 4);
			d = (int)(((t&mask) - (s&mask)) >> 4*(n-i-1));
			if (d < 0) d += 10;
			for ( ; i < n; i++, mask >>= 4) {
				x = (s >> 4*(n-i-1)) & 0xf;
				x += d; if (x >= 10) x -= 10;
				s = (s & ~mask) | (x << 4*(n-i-1));
				if (insert(s)) q[end].s = s, q[end++].k = k+1;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2072
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    ll mx = a[0], ans = 0;
    for(int i = 1; i < n; i++){
        if(mx > a[i]) ans += mx - a[i];
        mx = max(mx, a[i]);
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 5136
#include<iostream>
#include<string>
#include<vector>
using namespace std;
class dice {
	int a;
public:
	void North(int *up, int *back, int *right, int *left, int *front, int *under) {
		int a;
		a = *up;
		*up = *back;
		*back = *under;
		*under = *front;
		*front = a;
	}
	void East(int *up, int *back, int *right, int *left, int *front, int *under) {
		a = *up;
		*up = *left;
		*left = *under;
		*under = *right;
		*right = a;
	}
	void West(int *up, int *back, int *right, int *left, int *front, int *under) {
		a = *up;
		*up = *right;
		*right = *under;
		*under = *left;
		*left = a;
	}
	void South(int *up, int *back, int *right, int *left, int *front, int *under) {
		a = *up;
		*up = *front;
		*front = *under;
		*under = *back;
		*back = a;
	}
	void Right(int *up, int *back, int *right, int *left, int *front, int *under) {
		a = *front;
		*front = *left;
		*left = *back;
		*back = *right;
		*right = a;
	}
	void Left(int *up, int *back, int *right, int *left, int *front, int *under) {
		a = *front;
		*front = *right;
		*right = *back;
		*back = *left;
		*left = a;

	}

};
int main() {
	int up = 1, back = 2, right = 3, left = 4, front = 5, under = 6;
	dice die;
	int n, sum ;
	string str;
	while (1) {
		cin >> n;
		if (n == 0) { break; }
		sum = 1;
		up = 1; back = 2; right = 3; left = 4; front = 5; under = 6;
		for (int i = 0; i < n; i++) {
			cin >> str;
			if (str == "North") {
				die.North(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
			else if (str == "East") {
				die.East(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
			else if (str == "West") {
				die.West(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
			else if (str == "South") {
				die.South(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
			else if (str == "Right") {
				die.Right(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
			else if (str == "Left") {
				die.Left(&up, &back, &right, &left, &front, &under);
				sum += up;
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3068
from collections import Counter
n = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
l = prime_factorize(n)
c = Counter(l)
l3 = []
for i in c.most_common():
    l3.append(i[1])
l2 = [i * (i + 1) // 2 for i in range(1, 10)]
ans = 0
for i in l3:
    for j in range(len(l2)):
        if l2[j] > i:
            ans += j
            break
print(ans)

Measured memory_bytes: 9472
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int h, w;
    cin >> h >> w;
    char field[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c;
            cin >> c;
            field[i][j] = c;
        }
    }
    int dx[8] = {-1,0,1,-1,1,-1,0,1};
    int dy[8] = {1,1,1,0,0,-1,-1,-1};
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(field[i][j] == '.'){
                int count = 0;
                for(int k = 0; k < 8; k++){
                    int index_i = i + dx[k];
                    int index_j = j + dy[k];
                    if(index_i >= 0 && index_i <= h-1 && index_j >= 0 && index_j <= w-1){
                        if(field[index_i][index_j] == '#'){
                            count++;
                        }
                    }
                }
                field[i][j] = '0' + count;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cout << field[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


int main() 
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if(x-r >= 0 && y-r >= 0 && y+r <= h && x+r <= w)
        cout << "Yes" << endl;
    else
        cout << "No" << endl; 
        
}


Measured memory_bytes: 3116
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int h = sc.nextInt();
    int a = sc.nextInt();
    int c;
    //char[] a = sc.nextLine().toCharArray();
    if(h % a == 0){
      c = h/a;
    }
    else{
      c = h/a + 1;
    }
    System.out.println(c);
  }
}

Measured memory_bytes: 23380
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	
	char a,b,c;
	cin>>a>>b>>c;
	if ( a ==b && b == c)
	{
	cout<<"No"<<endl;
	}
	else
	{
	cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
#define MAXN 105
int visl[26];
int visr[26];
char c[MAXN];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>c[i];
    int maxx=0;
    for(int i=0;i<n;i++)
    {
        int s=0;
        memset(visl,0,sizeof(visl));
        memset(visr,0,sizeof(visr));
        for(int j=0;j<=i;j++)
        {
            visl[c[j]-'a']=1;
        }
        for(int j=i+1;j<n;j++)
        {
            visr[c[j]-'a']=1;
        }
        for(int j=0;j<26;j++)
        {
            if(visl[j]==1&&visr[j]==1) s++;
        }
        if(s>maxx) maxx=s;
    }
    cout<<maxx<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
		
  	cout << (H-h) * (W-w) << endl;
    
  	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 n = sc.nextInt();
		
		String ans = "";
		switch (n % 10) {
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			ans = "hon";
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			ans = "pon";
			break;
		default:
			ans = "bon";
			break;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 27000
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n){
    int x;
    cin >> x;
    a[x-1] = i+1;
  };
  
  REP(i,n) cout << a[i] << " ";

  return 0;
}

Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	 string s;
	 cin >> s;
	 bool d = 1;
	 //bool b = 1;
	 int cnt = 0;
	 int n = (int)s.size();
	 for (int i = 0; i < n; ++i) {
		 if (i != 0 && s[i] != 'C') {
			 if (s[i] - 'a' >= 0 && s[i] - 'a' < 26) {
				 continue;
			 } else {
				 d = 0;
			 }
		 }
		 if (s[i] == 'C') {
			 cnt++;
		 }
	 }
	 int ap = 0;
	 for (int i = 2; i <= n - 2; ++i) {
		 if (s[i] == 'C') ap++;
	 }
	 if (s[0] == 'A' && ap == 1 && d && cnt == 1) {
		cout << "AC";
	}else {
		cout << "WA";
	}
		  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string s; cin >> s;
    
    string ans = "";
    
    for(int i = 0 ; i < s.size() ; i++){
        if(s[i] == '0')
            ans.push_back('0');
        
        else if(s[i] == '1')
            ans.push_back('1');
        
        else if(s[i] == 'B' && ans != "")
            ans.pop_back();
    }
    
    cout << ans << endl;
}

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

namespace AtCoder
{
    class Abc167F
    {
        struct Bracket
        {
            public long BraN;
            public long KetN;
        }

        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());

            long braN = 0;
            long ketN = 0;

            long m = 0;
            var bracket = new List<Bracket>();

            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine();
                m += s.Length;
                var x = new Bracket { BraN = 0, KetN = 0 };
                for (int j = 0; j < s.Length; j++)
                {
                    x.BraN += s[j] == '(' ? 1 : -1;
                    if (x.KetN > x.BraN)
                        x.KetN = x.BraN;
                }
                x.KetN = -x.KetN;
                x.BraN += x.KetN;
                if (x.BraN == 0)
                    ketN += x.KetN;
                else if (x.KetN == 0)
                    braN += x.BraN;
                else
                    bracket.Add(x);
            }

            var sorted = bracket.OrderBy(x => x.KetN).OrderByDescending(x => x.BraN - x.KetN);
            foreach (var item in sorted)
            {
                braN -= item.KetN;
                if (braN < 0)
                {
                    Console.WriteLine("No");
                    return;
                }
                braN += item.BraN;
            }
            Console.WriteLine(braN == ketN ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 51316
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	string S;
	int oneCnt=0,zeroCnt=0;
	cin >> S;
	for(const char& c : S){
		if(c=='0'){
			zeroCnt++;
		}else{
			oneCnt++;
		}
	}

	if(zeroCnt<oneCnt){
		cout << zeroCnt*2 << endl;
	}else{
		cout << oneCnt*2 << endl;
	}
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>

#define MAX 101
#define INF 2001
 
int A[MAX][MAX]; 

int MST(int n){
  int u, minv, i, max=0;
  int d[MAX], p[MAX], color[MAX];
  
  for(i=1 ; i<=n ; i++){
    d[i] = INF;
    p[i] = -1;
    color[i] = 0;
  }

  d[1] = 0;

  while(1){
    minv = INF;
    u = -1;
    for(i=1 ; i<=n ; i++){
      if(minv>d[i] && color[i]!=2){
	u = i;
	minv = d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u] = 2;
    for(i=1 ; i<=n ; i++){
      if(color[i]!=2 && A[u][i]!=-1){
	if(d[i]>A[u][i]){
	  d[i] = A[u][i];
	  p[i] = u;
	 
	}
      }
    }
  }
  for(i=1 ; i<=n ; i++){
    if(p[i] != -1)max = max + d[i];
  }
  return max;
}

int main(){
  int n, i, j, max=0;
  
  scanf("%d",&n);

  for(i=1 ; i<=n ; i++){
    for(j=1 ; j<=n ; j++){
      scanf("%d",&A[i][j]);
     
    }
  }

  
  
  max = MST(n);
  printf("%d\n",max);  
  
  return 0;
}



Measured memory_bytes: 2048
import java.util.*;
public class Main{
  
 public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
   String input = scanner.nextLine();
   int sum = 0;
   for(int x =0; x<input.length(); x++){
     sum = sum + Integer.parseInt(input.substring(x,x+1));
   }
   if(Integer.parseInt(input)%sum==0){
     System.out.println("Yes");
   }else{
     System.out.println("No");
   }
 }
  
}

Measured memory_bytes: 23124
#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<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;
const ll C=1000;




int main(){
    ll count=0;
    ll n,m;
    cin>>n>>m;
    vector<vector<ll>> e;
    vector<vector<ll>> a(n,vector<ll>(n,E));
    for(int i=0;i<n;i++){
        a[i][i]=0;
    }
    for(int i=0;i<m;i++){
        ll f,t,d;
        cin>>f>>t>>d;
        f--; t--;
        if(a[f][t]!=E){count++;}
        a[f][t]=min(a[f][t],d);
        a[t][f]=a[f][t];
    }
    for(int i=0;i<n;i++){
        for(int t=i+1;t<n;t++){
            if(a[i][t]==E){continue;}
            e.push_back({i,t,a[i][t]});
        }
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int t=0;t<n;t++){
                a[i][t]=min(a[i][t],a[i][k]+a[k][t]);
            }
        }
    }
    for(int i=0;i<e.size();i++){
        bool used=false;
        vector<ll> E=e[i];
        for(int t=0;t<n;t++){
            if(a[t][E[0]]+E[2]==a[t][E[1]]){used=true; break;}
        }
        if(!used){count++;}
    }
    cout<<count<<endl;
    
    
    return 0;
}

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

int main() {
  int s;
  cin >> s;
  cout << s / 100 + (s / 10  - (s / 100) * 10) + (s - (s / 100) * 100 - (s / 10  - (s / 100) * 10) * 10) << endl;
}


Measured memory_bytes: 3660
using System;

namespace UnityChan
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int a, b;

			string[] str = Console.ReadLine ().Split(' ');
			a = int.Parse (str[0]);
			b = int.Parse (str[1]);

			Console.WriteLine ("{0} {1}", a*b, 2*a+2*b);


		}
	}
}

Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;


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

  int n, k;
  cin >> n >> k;

  vector<long> a(n);
  fillLong(a, n);

  vector<long> b(n+1);
  b[0] = 0;
  rep(i, n) {
    b[i+1] = b[i] + a[i];
  }

  vector<long> c;

  rep(i, n) {
    for(int j = i+1; j<n+1; j++) {
      c.push_back(b[j] - b[i]);
    }
  }

  sortv(c);

  long res = 0;

  for(int i = 50; i >= 0; i--) {
    long l = lbv(c, 1L<<i);
    if (c.size() - l >= k) {
      c.erase(c.begin(), c.begin() + l);
      res += (1L<<i);
    }
    rep(j, c.size()) {
      c[j] &= ~(1L<<i);
    }
    sortv(c);
  }

  cout << res << endl;
}


Measured memory_bytes: 6260
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, m, k;
    cin >> n >> m >> k;
    if(k % n == 0 || k % m == 0){
        cout << "Yes\n";
        return 0;
    }
    for(int i = 1; i <= m; ++i){
        int foo = n * i;
        int add = m - 2 * i;
        for(int j = 1; j <= n; ++j){
            foo += add;
            if(foo == k){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    for(int i = 1; i <= n; ++i){
        int foo = m * i;
        int add = n - i * 2;
        for(int j = 1; j <= m; ++j){
            foo += add;
            if(foo == k){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR"){
        cout << 1 << endl;
    }else if(s=="SRR"||s=="RRS"){
        cout << 2 << endl;
    }else if(s=="SSS") {
        cout << 0 << endl;
    }else if(s=="RRR"){
        cout << 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll n; cin>>n;
	ll m[n+1]; for(ll i=0;i<=n;i++) cin>>m[i];
	ll h[n]; for(ll i=0;i<n;i++) cin>>h[i];
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll x=min(m[i],h[i]);
		h[i]-=x;
		m[i]-=x;
		ans+=x;
		x=min(m[i+1],h[i]);
		h[i]-=x;
		m[i+1]-=x;
		ans+=x;
	}
	cout<<ans;
}

Measured memory_bytes: 5164
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int H, W;
    cin >> H >> W;
    vector< vector<int> > c(10, vector<int>(10));
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            cin >> c[i][j];
        }
    }
    for(int k=0; k<10; k++) {
        for(int i=0; i<10; i++) {
            for(int j=0; j<10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    for(int h=0; h<H; h++) {
        for(int w=0; w<W; w++) {
            int A;
            cin >> A;
            if(A != -1) {
                ans += c[A][1];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n, a, b;
  long long k;
  map<int, long long> m;
  scanf("%d%lld", &n, &k);
  for(int i = 0; i < n; i++){
    scanf("%d%d", &a, &b);
    if(m.find(a) == m.end()) m[a] = b;
    else m[a] += b;
  }
  map<int, long long>::iterator it;
  for(it = m.begin(); it != m.end(); it++){
    pair<int, long long> p = *it;
    k -= p.second;
    if(k <= 0){
      printf("%d\n", p.first); 
      break;
    }
  }
}


Measured memory_bytes: 4224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		String result="";
		if(a==b) {
			result = "==";
		}else if(a>b){
			result = ">";
		}else {
			result = "<";
		}
		
		System.out.printf("a %S b%n",result);
	}

}



Measured memory_bytes: 26244
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  char str[10],com[13];
  map<string,bool> mp;
  cin >> n;
  rep(i,n){
    cin >> com >> str;
    if(com[0] == 'i') mp[string(str)] = true;
    else {
      if(mp[string(str)]) cout << "yes" << endl;
      else cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 47396
a,b,k = map(int, input().split())
if a+k-1 < b-k+1:
    for i in range(a,a+k):
        print(i)
    for i in range(b-k+1,b+1):
        print(i)
else:
    for i in range(a,b+1):
        print(i)

Measured memory_bytes: 3060
#include <stdio.h>
#include <limits.h>

typedef long long ll;

int a[2005];
int b[2005];
ll c[2005];
ll dist[1005];
int negative[1005];

int main(){

	int N,M;

	scanf("%d %d",&N,&M);

	int i,j;

	for(i=0;i<M;i++){
		scanf("%d %d %lld",&a[i],&b[i],&c[i]);
		a[i]--;
		b[i]--;
		c[i]=-c[i];
	}

	for(i=0;i<N;i++){
		dist[i]=LLONG_MAX;
	}
	dist[0]=0ll;

	for(i=0;i<N-1;i++){
		for(j=0;j<M;j++){
			if(dist[a[j]]==LLONG_MAX){continue;}
			if(dist[b[j]]>dist[a[j]]+c[j]){
				dist[b[j]]=dist[a[j]]+c[j];
			}
		}
	}

	ll ans=dist[N-1];

	for(i=0;i<N;i++){
		for(j=0;j<M;j++){
			if(dist[a[j]]==LLONG_MAX){continue;}
			if(dist[b[j]]>dist[a[j]]+c[j]){
				dist[b[j]]=dist[a[j]]+c[j];
				negative[b[j]]=1;
			}
			if(negative[a[j]]==1){
				negative[b[j]]=1;
			}
		}
	}

	if(negative[N-1]==1){
	printf("inf\n");
	}
	else{
	printf("%lld\n",-ans);
	}

	return 0;
}

Measured memory_bytes: 256
import sys
def maxHeapify(A, i):
    l = i * 2 + 1
    r = i * 2 + 2
    if l < n:
        largest = l
        if r < n and A[r] > A[l]:
            largest = r
        if A[largest] > A[i]:
            A[i], A[largest] = A[largest], A[i]
            maxHeapify(A, largest)
def insert(S, k):
    global n
    S[n] = k
    n += 1
    i = n - 1
    p = (i - 1) // 2
    while i > 0 and S[i] > S[p]:
        S[i], S[p] = S[p], S[i]
        i = p
        p = (i - 1) // 2
def extractMax(S):
    global n
    if n == 1:
        n -= 1
        return S[0]
    ans = S[0]
    n -= 1
    S[0] = S[n]
    i = 0
    while True:
        l = i * 2 + 1
        r = i * 2 + 2
        if l >= n:
            break
        largest = l
        if r < n and A[r] > A[l]:
            largest = r
        if A[largest] > A[i]:
            A[i], A[largest] = A[largest], A[i]
            i = largest
        else:
            break
    return ans
A = [0] * 2000000
S = []
n = 0
for s in sys.stdin:
    if s[2] == "s":
        insert(A, int(s[7:]))
    elif s[2] == "t":
        S.append(extractMax(A))
    else:
        break
print("\n".join(map(str, S)))



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

signed main(){
    int n,k;
    cin >> n >> k;
    int ans=1;
    int count=0;
    while(1){
        count++;
        ans*=k;
        if(ans>n) break;
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N = 0;
    int h[100];
    int ans = 0;
    int min = 0;
    int area_start = 0, area_end = 0;
    int flag = 0;

    //入力
    cin >> N;
    
    for(int i=0; i<N; i++){
        cin >> h[i];
    }
    
    //処理
    for(int i=0; i<N; i++){
        if(flag == 0 && h[i] > 0){
            flag = 1;
            area_start = i;
        }
        if(flag == 1 && ((h[i] == 0) || (i == N - 1))){
            if(h[i] == 0){ 
                area_end = i - 1;
            }
            else{ 
                area_end = i;
            }
            
            min = 999;
            for(int j=area_start; j<=area_end; j++){
                if(min > h[j] && h[j] != 0){
                    min = h[j];
                }
            }
            if(min == 999) break;
            for(int j=area_start; j<=area_end; j++){
                h[j] -= min;
            }
            ans += min;

            flag = 0;
            i = -1;
        }
    }

    //出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

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

const int MOD = 1000000007;

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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=c-(a-b);
	chmax(ans,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256