akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};

using T=tuple<in,in,in>;

int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    string s;
    cin>>s;
    vector<in> r(0),g(0),b(0);
    rep(i,n){
        if(s[i]=='R') r.emplace_back(i);
        else if(s[i]=='G') g.emplace_back(i);
        else b.emplace_back(i);
    }
    vector<T> rgb(n);
    rgb[n-1]=T(0,0,0);
    for(in i=n-2;i>=0;i --){
        rgb[i]=rgb[i+1];
        if(s[i+1]=='R') get<0>(rgb[i]) ++;
        else if(s[i+1]=='G') get<1>(rgb[i]) ++;
        else get<2>(rgb[i]) ++;
    }
    in rn=r.size(),gn=g.size(),bn=b.size();
    in ans=0ll;
    rep(i,n){
        REP(j,i+1,n){
            in nok=2ll*j-i;
            if(s[i]==s[j]) continue;
            if(s[i]!='R'&&s[j]!='R'){
                ans +=get<0>(rgb[j]);
                if(nok<n && s[nok]=='R') ans --;
            }
            else if(s[i]!='G'&&s[j]!='G'){
                ans +=get<1>(rgb[j]);
                if(nok<n && s[nok]=='G') ans --;
            }
            else{
                ans +=get<2>(rgb[j]);
                if(nok<n && s[nok]=='B') ans --;
            }
        }
    }
    cout<<ans<<endl;
}
//./problem.exe

Measured memory_bytes: 3784
N, A, B, C = gets.strip.split.map(&:to_i)
T = [A, B, C]
L = N.times.map { gets.to_i }
INF = 10 ** 9
#puts L.inspect

def solve(index, a, b, c)
  if index == N
    if [a, b, c].min > 0
      return [(a-A), (b-B), (c-C)].map(&:abs).reduce(:+) - 30
    else
      return INF
    end
  end
  resn = solve(index + 1, a, b, c)
  resa = solve(index + 1, a + L[index], b, c) + 10
  resb = solve(index + 1, a, b + L[index], c) + 10
  resc = solve(index + 1, a, b, c + L[index]) + 10
  [resn, resa, resb, resc].min
end

puts solve(0, 0, 0, 0)


Measured memory_bytes: 1788
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
ll MOD = (ll)1e9 + 7;
const int N = 1e5+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int W = 0, B = 1;
vector<int> adj[N];
ll down[N], up[N];

ll down_dfs(int v, int par) {
    down[v] = 1;
    for (int u : adj[v]) {
        if (u == par) continue;
        down_dfs(u, v);
        down[v] = mult(down[v], add(1, down[u]));
    }
}

ll pref[N], suff[N];
ll up_dfs(int v, int par) {
    pref[-1] = 1;
    for (int i = 0; i < adj[v].size(); ++i) {
        pref[i] = pref[i-1];
        if (adj[v][i] != par) pref[i] = mult(pref[i], add(down[adj[v][i]], 1));
    }
    suff[adj[v].size()] = 1;
    for (int i = adj[v].size()-1; i >= 0; --i) {
        suff[i] = suff[i+1];
        if (adj[v][i] != par) suff[i] = mult(suff[i], add(down[adj[v][i]], 1));
    }
    for (int i = 0; i < adj[v].size(); ++i) {
        if (adj[v][i] == par) continue;
        up[adj[v][i]] = up[v];
        up[adj[v][i]] = mult(up[adj[v][i]], mult(pref[i-1], suff[i+1]));
        up[adj[v][i]] = add(up[adj[v][i]], 1);
    }
    for (int u : adj[v]) {
        if (u == par) continue;
        up_dfs(u, v);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n >> MOD;
    rep (i, 0, n-1) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    down_dfs(1, -1);
    up[1] = 1; //?
    up_dfs(1, -1);
    for (int v = 1; v <= n; ++v) cout << mult(down[v], up[v]) << endl;
    return 0;
}

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

int gcd(long long int m,long long int n){
	m=abs(m);
	n=abs(n);
	if(m*n==0){
		return max(m,n);
	}else {
		return gcd(min(m,n),max(m,n)%min(m,n));
	}
}

int main(){
	long long int a,b,c,d;
	long long int cd;
	long long int divc,divd,divcd;
	long long int ans;
	cin>>a>>b>>c>>d;
	cd=c*d/gcd(c,d);
	divc=b/c-(a-1)/c;
	divd=b/d-(a-1)/d;
	divcd=b/cd-(a-1)/cd;
	ans=(b-a+1)-(divc+divd-divcd);
	cout<<ans<<endl;
}

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

int main(int argc, const char * argv[]) {
    int A, B, C, D;
    cin >> A >> B;
    cin >> C >> D;
    int dist = min(B, D) - max(A, C);
    cout << max(dist, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int C[110][110];

int main() {
	int N, M;
	vector<pair<pii,int> > v;
	rep(i,110) {
		rep(j,110)
			C[i][j] = 1e9;
		C[i][i] = 0;
	}
	cin >> N >> M;
	v.resize(M);
	rep(i,M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		C[a][b] = C[b][a] = c;
		v[i].fi = pii(a,b);
		v[i].se = c;
	}
	rep(i,N)
		rep(j,N)
			rep(k,N)
				C[j][k] = min(C[j][k], C[j][i] + C[i][k]);
	int res = 0;
	rep(i,M)
		if(C[v[i].fi.fi][v[i].fi.se] < v[i].se) res++;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n,k;
  int sa;	//差
  scanf("%d%d",&n,&k);
  
  sa=n-k;
  if(k==1){
    printf("0");
  }
  else{
    printf("%d",sa);
  }
  
  
  
  return 0;
}


Measured memory_bytes: 128
N,A,B=map(int,input().split())
H=[int(input()) for i in range(N)]
L,R,M=0,10**9,0
A-=B
C=0
while L!=R:
  M=(L+R)//2
  C=0
  for i in range(N):
    C+=max(0,(H[i]-B*M+A-1)//A)
  if C>M:
    L=max(M,L+1)
  else:
    R=M
print(L)

Measured memory_bytes: 80748
#include<stdio.h>
void selectionSort(int *,int);
int cnt=0;
int main(){
  int N;
  int i;
  int A[101];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  selectionSort(A,N);
  printf("%d\n",cnt);
  return 0;
}

void selectionSort(int A[],int N){
  int i,j,minj,tmp;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[minj]>A[j]){
	minj=j;
      }
    }
    if(i!=minj) cnt++;
    tmp=A[i];
    A[i]=A[minj];
    A[minj]=tmp;
  }
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i!=N-1) printf(" ");
  }
  printf("\n");
}
  



Measured memory_bytes: 2144
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var N int
	fmt.Sscanf(scanner.Text(), "%d", &N)

	for i := N; i < 1000; i++ {
		if i%111 == 0 {
			fmt.Println(i)
			return
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n,k;
   cin>>n>>k;
   
   if(n>=k)
   {
        n = n%k;  
   }
   
        if(n<=(k/2))
        {
                cout<<n;
        }
        else
        {
                cout<<(k-n);
        }
}

 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m),b(m);
    vector< set<ll> > c(m);
    for(ll i=0;i<m;i++){
	cin>>a[i]>>b[i];
	for(ll j=0;j<b[i];j++){
	    ll tmp;
	    cin>>tmp;
	    tmp--;
	    c[i].insert( tmp );
	}
    }

    ll res = inf;
    vector<ll> dp( 1<<n , inf );
    dp[ (1<<n)-1 ] = 0;
    for(ll i=(1<<n)-1;i>0;i--){
	for(ll j=0;j<m;j++){
	    ll k = i;
	    for( auto it:c[j] ){
		k = k&(~(1<<it));
	    }
	    dp[k] = min( dp[k] , dp[i] + a[j] );
	}
    }
    if( dp[0] == inf ) cout<<-1<<endl;
    else cout<<dp[0]<<endl;

    return 0;
}


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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500005;

vector<int> adj[N];



bool ok1(string s)
{
  int x = (s[0]-'0')*10 + (s[1]-'0');
  return x>=1 and x <=12;
}

bool ok2(string s)
{
  int x = (s[2]-'0')*10 + (s[3]-'0');
  return x>=1 and x <=12;
}

int32_t main()
{




    string s;
    cin >> s;

    if(ok1(s) and ok2(s))
    {
      cout << "AMBIGUOUS";
    }
    else if(ok1(s))
    {
      cout << "MMYY";
    }
    else if(ok2(s))
    {
      cout << "YYMM";
    }
    else
    {
      cout << "NA";
    }











    return 0;
}

Measured memory_bytes: 11904
#include <stdio.h>
#include <stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  while(u!=NIL)
{
    if(k < u->key)
	{
	  u=u->left;
	}
    else if(k==u->key)
  {
    return u;
  }

    else
	{
	  u=u->right;
	}
}

return NIL;
  

}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL)
    {
      y=x;
      if(z->key < x->key)
	{
	  x=x->left;
	}
      else
	{
	  x=x->right;
	}
    }
  z->parent=y;

  if(y==NIL)
    {
      root=z;
    }
  else if(z->key < y->key)
    {
      y->left=z;
    }
  else
    {
      y->right=z;
    }
  




}

void inorder(Node u){

  if(u==NIL) return;
  inorder(u->left);
  
  printf(" %d",u->key);
  inorder(u->right);
 
}
void preorder(Node u){
  
  if(u==NIL) return;
  
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20436
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h) cin>>s[i];
    bool path[h][w]={};
    path[0][0]=true;
    int nj=0;
    rep(i,h){
        while(s[i][nj]=='#'){
            path[i][nj]=true;
            nj++;
        }
        nj--;
    }
    rep(i,h){
        rep(j,w){
            if((!path[i][j])&&(s[i][j]=='#')){
                cout<<"Impossible"<<endl;
                return 0;
            }
        }
    }
    cout<<"Possible"<<endl;
    return 0;
}


Measured memory_bytes: 896
N = int(input())
As = str(input()).split(' ')
a_s = [int(a) for a in As]

import numpy as np
a_s = np.array(a_s)
sum = 0
index = 0
for n in range(60):
  b = (a_s >> n) & 1
  x = np.count_nonzero(b)
  y = N - x
  ans = x * y
  for _ in range(n):
    ans *= 2
  sum += ans
  
print(sum%(10**9+7))

Measured memory_bytes: 50996
// -----------------------------------------------
// 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;

/// Print values to standard error if debug mode.
#[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()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[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()),*)
    }};
}

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

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

// g(x) = f(0, x)
fn g(x: i64) -> i64 {
    let mut z = {
        let r = x % 4;
        (if r == 1 || r == 2 { 1 } else { 0 })
    };
    let mut p = 2_i64;
    for h in 1..60 {
        let r = x % (p * 2);
        if r >= p && (r - p) % 2 == 0 {
            z |= p;
        }
        debug!((h, p, r, (r - p) % 2));
        p *= 2;
    }
    z
}

fn main() {
    let (A, B) = read!(i64, i64);
    println!("{}", if A == 0 { g(B) } else { g(A - 1) ^ g(B) })
}


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


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

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

int main() {
  int n;
  cin>>n;
  VI v(n);
  REP(i,n){
    cin >> v[i];
  }

  SORT(v);
  double ans=v[0];
  REP(i, n - 1) {
    ans = (ans + v[i + 1]) / 2;
  }

  ANS(ans);
  return 0;
}


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

template <class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    i64 inf = (i64)(1 << 40);
    vector<i64> dist(N + 10, inf);
    rep(i, 1, N + 1) rep(j, i, N + 1) {
        i64 d = min({abs(i - j), abs(i - X) + 1 + abs(j - Y), abs(i - Y) + 1 + abs(j - X)});
        dist[d]++;
    }
    rep(i, 1, N) {
        cout << dist[i] << "\n";
    }
}


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


int main() {
   int a, b;
  cin >> a >> b;
  if(a == b){
    string s;
    s = "";
    for(int i = 0; i < a; i ++){
      string A = to_string(a);
    s.insert(i,A);
    }
    cout << s;
  }
  if(a > b){
    string s;
    s = "";
    for(int i = 0; i < a; i ++){
     string A = to_string(b);
    s.insert(i,A);
    }
    cout << s;
  }
  if(a < b){
    string s;
    s = "";
    for(int i = 0; i < b; i ++){
     string A = to_string(a);
    s.insert(i,A);
    }
    cout << s;
  }
  return 0;
}

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

typedef struct node{
    int key;
    struct node *p, *l, *r;
}Node;

Node *tmp, *NIL;

void insert(int);
void inorder(Node *);
void preorder(Node *);
Node *find(Node *, int);

int main()
{
  int m, i, k;
  char c[1000];
  Node *judge;
  
  scanf("%d", &m);
  
  for( i = 0 ; i < m ; i++ ){
    scanf("%s", c);
    if( strcmp(c, "find") == 0 ){
      scanf("%d", &k);
      judge = find(tmp, k);
      if( judge != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if( strcmp(c, "insert") == 0 ){
      scanf("%d", &k);
      insert(k);
    }
    else if( strcmp(c, "print") == 0 ){
      inorder(tmp);
      printf("\n");
      preorder(tmp);
      printf("\n");
    }
  }
  
  return 0;
}

void insert(int k){
  Node *y = NIL;
  Node *x = tmp;
  Node *z;
  
  z = malloc(sizeof(Node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  
  while( x != NIL ){
    y = x;
    if( z->key < x->key ) x = x->l;
    else x = x->r;
  }
  
  z->p = y;
  if( y == NIL ) tmp = z;
  else if( z->key < y->key ) {
    y->l = z;
  } else y->r = z;
  
}

void inorder(Node *u){
  if( u == NIL ) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}

Node *find(Node *x, int k)
{
  while( x != NIL && k != x->key ){
    if( k < x->key ) x = x->l;
    else x = x->r;
  }
  
  return x;
}

Measured memory_bytes: 19364
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  int k;
  cin >> s >> k;
  rep(i, s.size()) {
    if (('z'-s[i]+1)%26 <= k) {
      k -= ('z'-s[i]+1)%26;
      s[i] = 'a';
    }
  }
  s.back() = 'a'+(s.back()-'a'+k)%26;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int dp[3005][3005];

void lcs(string a,string b,int m,int n)
{

    for(int i=0; i<=m; i++)
    {
        for(int j=0; j<=n; j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(a[i-1]==b[j-1])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans= " ";
    ll i, j;
    i = m;
    j = n;
    while(i>0 and j>0)
    {
        if(a[i-1]==b[j-1])
        {
            ans=a[i-1]+ans;
            i--;
            j--;
        }
        else
        {
            if(dp[i-1][j]>=dp[i][j-1])
                i--;
            else
                j--;
        }
    }
    cout<<ans<<endl;
}

int main()
{
    string a, b;
    cin>>a>>b;
    ll m=a.size();
    ll n=b.size();
    lcs(a,b,m,n);

    return 0;
}


Measured memory_bytes: 38876
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
    int N;
    string s, t;
    cin >> N >> s >> t;

    int cnt = N;

    for(int i=0;i<N;i++){
      bool flag = true;
      for(int j=i;j<N;j++){
        if(s[j]!=t[j-i]){
          flag = false;
          cnt--;
          break;
        }
      }
      if(flag){
          cout << 2*N-cnt <<endl;
          return 0;
      }
    }
    cout << 2*N <<endl;

  	return 0;
}


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

int main () {
  long long N;
  cin >> N;
  long long M = 1;
  
  for (long long i = 2; i <= sqrt(N); i++) {
    if (N % i == 0){
      M = i;
    }
  }
  
  long long L = max(M,N/M);
  int count = 0;
  for (int i = 0; i < 11; i++) {
    count++;
    if (L / 10 == 0){
      cout << count << endl;
      return 0;
    }
    L /= 10;
  }    
}
   

Measured memory_bytes: 3664
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		for(int i=0; i<(1<<3); i++){
			StringBuffer str = new StringBuffer();
			str.append(c[0]);
			int cal = Character.getNumericValue(c[0]);
			for(int j=0; j<3;j++){
				if ((1 & i>>j) == 1){
					str.append("+");
					cal += Character.getNumericValue(c[j+1]);
				}else{
					str.append("-");
					cal -= Character.getNumericValue(c[j+1]);
				}
				str.append(c[j+1]);
			}
			if(cal == 7){
				System.out.println(str.toString() + "=7");
				break;
			}
		}

		sc.close();
	}


}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;

int main() {
    string s,ans="";
    cin>>s;
    if(s.size()==2){
        cout<<s;
    }
    else{
        reverse(s.begin(),s.end());
        cout<<s;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, A[312345];
ll mod = 1000000007;

ll inverse(ll a, ll m) {
	if ((a = (a % m)) == 1) return 1;
	return ((1 - m * inverse(m % a, a)) / a % m);
}

int main() {

	cin >> N;
	rep(i, N) cin >> A[i];

	ll sum = 0;
	rep(i, N) {
		sum += A[i];
		sum %= mod;
	}

	vector<ll> counter(60);
	rep(b, 60) {
		rep(i, N) {
			if ((A[i] >> b) & 1) counter[b]++;
		}
	}
	ll ans = (sum * N) % mod;
	rep(i, N) {
		vector<ll> bts;
		rep(b, 60) {
			if ((A[i] >> b) & 1)
				bts.push_back(b);
		}

		for (auto b : bts) {
			ans += ((1ll << b) % mod) * (N - 2 * counter[b]);
			ans %= mod;
		}

	}

	cout << (((ans * inverse(2, mod)) % mod) + mod) % mod << endl;

	return 0;
}

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

int main(){
  int tmp;
  unordered_set<int> x;
  for (int i = 0; i < 3; i++) {
    scanf("%d",&tmp);
    x.emplace(tmp);
  }
  printf("%d\n",(int)x.size());
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<int> S(M), C(M);
    for(int i = 0; i < M; i++){
        cin >> S[i] >> C[i];
    }
    int i, l;
    if(N == 1){i=0;l=9;}
    else if(N == 2){i = 10;l=99;}
    else {i = 100;l=999;}

    for(;i <= l; i++){
        int d1, d2, d3;
        if(N == 3) {d3 = i/100; d2=(i-d3*100)/10; d1 = i%10;}
        else if(N == 2){d2 = i/10; d1 = i%10;}
        else d1 = i%10;
        vector<int> V;
        if(N == 3) V = {0, d3, d2, d1};
        else if(N == 2) V = {0, d2, d1};
        else V = {0, d1};
        bool flag = true;
        for(int j = 0; j < M; j++){
            if(V[S[j]] != C[j]) {flag = false; break;}
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{ 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long k = sc.nextInt();
		long res = a;
		if(k <= a)
			System.out.println(k);
		else if(k <= a + b)
			System.out.println(a);
		else {
			res -= (k - a - b);
			System.out.println(res); 
		}
    }
}

Measured memory_bytes: 35520
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int h, w, n; cin >> h >> w >> n;
	VVI v(h, VI(w,0));
	int x, y;
	REP(i,n){
		cin >> x >> y;
		x--; y--;
		cin >> v[x][y];
	}
	ll dp[3100][3100][3]={0};
	REP(i,h){
		REP(j,w){
			REP(k,3){
				ll up=0;
				REP(l,3)
					up=max(up,dp[i][j][l]);
				if(k==0){
					if(j>0)
						dp[i+1][j][k]=max(up+v[i][j],dp[i+1][j-1][k]);
					else
						dp[i+1][j][k]=up+v[i][j];
				}
				else if(j>0)
					dp[i+1][j][k]=max(dp[i+1][j-1][k-1]+v[i][j],dp[i+1][j-1][k]);
			}
		}
	}
	ll ans=0;
	REP(i,3)
		ans=max(ans,dp[h][w-1][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 298816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int x=n;
  for(int i=n; ; i+=2){
    if(x%2==0 && x%n==0){
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int num[] = new int[n];
        Arrays.fill(num, 0);
        for (int i = 0; i < n; i++) {
            int a = in.nextInt() - 1;
            num[a]++;
        }
        Arrays.sort(num);
        int m = -1;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (num[i] == 0) {
                continue;
            }
            
            if (m == -1) {
                m = n - i;
            }

            if (m <= k) {
                break;
            }

            if (m > k) {
                ans += num[i];
                m--;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 60448
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		long ans  = 1;
		for(int i = 0; i < n ;i++) {
			long t = sc.nextLong();
			ans = lcm(t,ans);	
		}
		
		System.out.println(ans);
		
	}
	
	static long gcd(long a , long b) {
		
		long temp = a % b;
		if(temp == 0) {
			return b;
		}
		return gcd(b ,temp);
	}
	
	static long lcm(long a , long b) {
		
		long d = gcd(a,b);
		
		return (a / d * b) ;
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
#include<bitset>
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int a,b;
    cin>>a>>b;
    if(a<=9 and b<=9) cout<<a*b;
    else cout<<-1;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    //cin>>t;
    while(t--) solve();
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        int[][] arr = new int[3][n];
        label:
        for(int i = 0; i < 3; i++) {
            for(int j = 0; j < n; j++) {
                if(i == 2 && j == n-1) break label;
                arr[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n - 1; i++)
            ans += arr[1][arr[0][i] - 1]
                    + (arr[0][i + 1] - arr[0][i] == 1 ? arr[2][arr[0][i] - 1] : 0);
        ans += arr[1][arr[0][n-1] - 1];
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
from collections import deque

N=int(input())
h=list(map(int,input().strip().split()))

cnt=0
l=deque([h])
bot=deque([0])
while len(l)>0:
    tmp=l.popleft()
    b=bot.popleft()
    cnt+=min(tmp)-b
    g=deque([n for n in range(len(tmp)) if tmp[n]==min(tmp)])
    g.appendleft(-1)
    g.append(N)
    
    for i in range(1,len(g)):
        if len(tmp[g[i-1]+1:g[i]])>0:
            l.append(tmp[g[i-1]+1:g[i]])
            bot.append(min(tmp))

print(cnt)

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n-1);
  vector<int> b(n-1);
  vector<int> c(n);
  vector<int> count(n, 0);
  int i, j;
  for(i = 0; i < n-1; i++)
  {
    cin >> a.at(i) >> b.at(i);
  }
  for(i = 0; i < n; i++)
  {
    cin >> c.at(i);
  }
  vector<int> depth(n, 0);
  bool update;
  for(i = 0; i < n; i++)
  {
    update = false;
    for(j = 0; j < n; j++)
    {
      count.at(j) = 0;
    }
    for(j = 0; j < n-1; j++)
    {
      if(depth.at(a.at(j)-1) == i && depth.at(b.at(j)-1) == i)
      {
        count.at(a.at(j)-1)++;
        count.at(b.at(j)-1)++;
      }
    }
    for(j = 0; j < n; j++)
    {
      if(count.at(j) > 1)
      {
        depth.at(j) = i+1;
        update = true;
      }
    }
    if(!update) break;
  }
  vector<pair<int, int> > p(n);
  for(i = 0; i < n; i++)
  {
    p.at(i) = make_pair(depth.at(i), i);
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  vector<int> p2(n);
  for(i = 0; i < n; i++)
  {
    p2.at(p.at(i).second) = c.at(i);
  }
  int sum = 0;
  int max = 0;
  for(i = 0; i < n; i++)
  {
    sum += c.at(i);
    if(c.at(i) > max) max = c.at(i);
  }
  int ans = sum - max;
  cout << ans << endl;
  for(i = 0; i < n; i++)
  {
    cout << p2.at(i);
    if(i != n-1) cout << ' ';
  }
  cout << endl;
}

Measured memory_bytes: 640
(defun f (a ll)
  (if (= a 0)
      (if (and (< (first ll) (second ll))
               (< (second ll) (third ll)))
          ll nil)
      (or (f (1- a) `(,(* 2 (first ll)) ,(second ll) ,(third ll)))
          (f (1- a) `(,(first ll) ,(* 2 (second ll)) ,(third ll)))
          (f (1- a) `(,(first ll) ,(second ll) ,(* 2 (third ll)))))))


(let* ((n (list (read) (read) (read)))
       (m (read)))
  (if (f m n)
      (princ "Yes")
      (princ "No")))


Measured memory_bytes: 24364
#include<stdio.h>
char a[2000000],b[2000000];
void str(void){
  int c,i,sw=0,j;
  char cp;
  j=0;
  sw=0;
  // printf("point1\n");
  for(i=0;a[i]!='\0';i++){
    if(sw==0){
      cp=a[i];
      c=1;
      sw=1;
      continue;
    }
    else{
      // printf("point2\n");
      if(cp==a[i]){
	c++;
      }
      else{
	if(c>=100){
	  b[j]=c/100+'0';
	  c%=100;
	  j++;
	}
	if(c>=10){
	  b[j]=c/10+'0';
	  c%=10;
	  j++;
	}
	b[j]=c+'0';
	j++;
	b[j]=cp;
	j++;
	sw=0;
	i--;
	//	printf("point3 %c%c%c\n",b[0],b[1],b[2]);//
      }
    }
  }
  if(sw==1){
    // printf("point4\n");

    if(c>=100){
      b[j]=c/100+'0';
      c%=100;
      j++;
    }
    if(c>=10){
      b[j]=c/10+'0';
      c%=10;
      j++;
    }
    b[j]=c+'0';
    j++;
    b[j]=cp;
    j++;
    sw=0;
    i--;
    //   printf("point3 %c%c%c\n",b[0],b[1],b[2]);//
  }
  b[j]='\0';
  return;
}

int main(){
  int i,n,j;
 
  while(1){
    for(i=0;i<2000000;i++){
      a[i]=b[i]=0;
    }
  
    scanf("%d",&n);
    if(n==0)break;
    scanf("%s",a);
    for(i=0;i<n;i++){
      str();
      // printf("%c%c%c\n",b[0],b[1],b[2]);//
      for(j=0;b[j]!='\0';j++){
	a[j]=b[j];
      }
      a[j]='\0';
    }
    for(i=0;a[i]!='\0';i++){
      printf("%c",a[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	map<int, bool> m;
	rep(i, n){
		int a;
		cin >> a;
		m[a] ^= 1;
	}
	int ans = 0;
	for(auto p : m){
		if(p.second == true) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
N = int(input())
v = list(map(int,input().split()))
s = 0.0
for i in range(N-1):
	t = (0.5)**(i+1)
	u = max(v)
	s = s + t*float(u)
	v.remove(u)

s = s + ((0.5)**(N-1))*v[0]

print(s)

Measured memory_bytes: 3060
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a1 = new int[n];
        Arrays.setAll(a1, i -> Integer.parseInt(sc.next()));
        int[] a2 = new int[n];
        Arrays.setAll(a2, i -> Integer.parseInt(sc.next()));

        // 主処理
        int[][] dp = new int[2][n];

        dp[0][0] = a1[0];
        for (int i = 1; i < n; i++) {
            dp[0][i] = dp[0][i - 1] + a1[i];
        }

        dp[1][0] = dp[0][0] + a2[0];
        for (int i = 1; i < n; i++) {
            dp[1][i] = Math.max(dp[0][i] + a2[i], dp[1][i - 1] + a2[i]);
        }

        int result = dp[1][n - 1];

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 30036
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n, u, v; cin >> n >> u >> v; --u; --v;
  vector<vector<int> > graph(n);
  REP(_, n - 1) {
    int a, b; cin >> a >> b; --a; --b;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  vector<int> dist_u(n, -1), dist_v(n, -1);
  dist_u[u] = dist_v[v] = 0;
  queue<int> que;
  que.emplace(u);
  while (!que.empty()) {
    int now = que.front(); que.pop();
    for (int e : graph[now]) {
      if (dist_u[e] == -1) {
        dist_u[e] = dist_u[now] + 1;
        que.emplace(e);
      }
    }
  }
  que.emplace(v);
  while (!que.empty()) {
    int now = que.front(); que.pop();
    for (int e : graph[now]) {
      if (dist_v[e] == -1) {
        dist_v[e] = dist_v[now] + 1;
        que.emplace(e);
      }
    }
  }
  int ans = 0;
  REP(i, n) {
    if (graph[i].size() == 1 && dist_u[i] < dist_v[i]) {
      ans = max(ans, dist_v[i] - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6656
#include <stdio.h>
 
int main()
{
    int i, n;
    long int a, min = 1000000, max = -1000000, sum = 0;
 
    scanf("%d", &n);
 
    for (i = 1; i <= n; i++)
    {
        scanf("%ld", &a);
        if (a < min)
            min = a;
        if (a > max)
            max = a;
        sum += a;
    }
    printf("%ld %ld %ld\n", min, max, sum);
    return 0;
}

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

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

int visited[100010];
map<int,int> mp;
vector<vector<int> > group;

void dfs(int v, int labelnum, vector<vector<int> >& frien) {
	if(visited[v] != 1e9) return;
	//cout << "visited:" << v << " labelnum:" << labelnum << endl;
	visited[v] = labelnum;
	mp[labelnum]++;
	//group[labelnum].pb(v);
	//for(auto k : frien[v]) cout << k << " ";
	//cout << endl;
	for(auto k : frien[v]) {
		dfs(k, labelnum, frien);
	}
}

int main() {
	int n,m,k;
	cin >> n >> m >> k;
	vector<vector<int> > frien(n, vector<int>());
	vector<pii> frien2(m), block(k);
	int a,b,c,d;
	group = vector<vector<int> >(n, vector<int>());
	rep(i,m) {
		cin >> a >> b;
		a--;b--;
		frien[a].pb(b);
		frien[b].pb(a);
		frien2[i] = pii(a,b);
	}
	rep(i,k) {
		cin >> c >> d;
		c--;d--;
		block[i] = pii(c,d);
	}
	rep(i,n) visited[i] = 1e9;
	int count=0;
	rep(i,n) {
		if(visited[i] > count) {
			dfs(i,count,frien);
			++count;
		}
	}
	vector<int> ans(n);
	rep(i,n) {
		int groupOfMe = visited[i];
		ans[i] = mp[groupOfMe] - 1;
	}

	/*rep(i,n) {
		cout << mp[visited[i]];
		if(i == n-1) cout << endl;
		else cout << " ";
	}*/
	rep(i,m) {
		if(visited[frien2[i].fi] == visited[frien2[i].se]) {
			//cout << frien2[i].fi << " " << frien2[i].se << endl;
			ans[frien2[i].fi]--;
			ans[frien2[i].se]--;
		}
	}
	rep(i,k) {
		if(visited[block[i].fi] == visited[block[i].se]) {
			ans[block[i].fi]--;
			ans[block[i].se]--;
		}
	}
	rep(i,n) {
		cout << ans[i];
		if(i == n-1) cout << endl;
		else cout << " ";
	}


  return 0;
}


Measured memory_bytes: 13440
#include <stdio.h>

int func(int a, int b) {
  if ( b % a == 0 ) {
    return a+b;
  } else {
    return b-a;
  }
}

int main() {
  int a, b;

  scanf("%d %d", &a, &b);
  printf("%d\n", func(a, b));

  return 0;
}

Measured memory_bytes: 128
it = lambda: list(map(int, input().strip().split()))

def solve():
    N = int(input())
    A = it()
    if N == 1:
        return 0
        
    A.sort(reverse=True)

    ans = A[0]
    n = N - 2
    i = 1
    while n > 0:
        if n >= 2:
            ans += 2 * A[i]
            n -= 2
        else:
            ans += A[i]
            n -= 1
        i += 1
    return ans


if __name__ == '__main__':
    print(solve())

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


int main(){

	int n;
	string str;
	while (cin >> str){
		if (str == "-"){
			break;
		}
		cin >> n;
		for (int i = 0,h; i < n; i++){
			cin >> h;
			string cat = str.substr(0, h);
			str.erase(0, h);
			str += cat;
		}
		cout << str << endl;


	}

}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    cin >> t;
    vector<lli> v;
    lli u = t / 1000;
    if (t % 1000)
    {
        u += 1;
    }
    cout << u * 1000 - t << endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main{
  public static void main (String[] args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if(S.length() < 3) {
      System.out.println(S);
    }else{
      StringBuilder ans = new StringBuilder(S);
      S = ans.reverse().toString();
      System.out.println(S);
    }
  }
}

Measured memory_bytes: 35644
# coding: utf-8

A, B, C, X, Y = map(int, input().split(" "))


n = 10 ** 10
min_a = min_b = min_c = 10**10
max_ab = 0
for ab in range(0, 2*max(X, Y) + 2, 2):
    a = max(X - ab//2, 0)
    b = max(Y - ab//2, 0)
    n = min(n, a*A + b*B + ab*C)

print(n)


Measured memory_bytes: 9180
n,a,b,c,d = map(int,input().split())
s = input()


if s[c-1] =='#':
    print('No')
    exit(0)
if s[c-1] =='#':
    print('No')
    exit(0)
for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
for i in range(a,c-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
if c>d:
    flag = False
    for i in range(b-2,d-1):
        if s[i:i+3]=='...':
            flag = True
            break
    if not flag:
        print("No")
        exit(0)
    else:
        print("Yes")
else:
    print("Yes")


Measured memory_bytes: 3572
#include<stdio.h>
int main(){
    int a,b,c,d;
    int s[100];
    int t[100];
    int count=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(int i=0;i<100;i++){
        if((a<=i)&&(i<b)){
            s[i]=1;
        }else{
            s[i]=0;
        }
    }
    for(int i=0;i<100;i++){
        if((c<=i)&&(i<d)){
            t[i]=1;
        }else{
            t[i]=0;
        }
    }
    for(int i=0;i<100;i++){
            if((s[i]==1)&&(t[i]==1)){
                count=count+1;
            }else{

            }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  if(a%10==3)
    cout<<"bon";
  else if(a%10==0||a%10==1||a%10==6||a%10==8)
    cout<<"pon";
  else
    cout<<"hon";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(auto&& e: p) 
  {
    cin>>e;
  }
  sort(p.begin(), p.end());
  int ans=0;
  for (int i = 0; i < k; ++i)
  {
    ans+=p[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

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

	if((a != b || b != c || c != a) &&
		(a == b || b == c || c == a)) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
	var s = input.split("\n")[1];
	var max = 0;
	for(var i=0; i<s.length; i++){
		var a = sortMarge(s.substring(0,i+1));
		var b = sortMarge(s.substring(i+1,s.length));
		var count = 0;
		for(var j=0;j<a.length;j++){
			if(b.indexOf(a[j]) > -1){
				count++;
			}
		}
		if(max < count){
			max = count;
		}
	}
	console.log(max);
	return ;
}
function sortMarge(arg){
	var mySet = new Set();
	for(var i=0;i<arg.length;i++){
		mySet.add(arg[i]);
	}
	var array = [];
	mySet.forEach(function(value){
		array.push(value);
	})
	array.sort();
	var ret = "";
	array.forEach(function(value){
		ret+=value;
	})
	return ret;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9780
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();
    let n : u64 = iter.next().unwrap().parse().unwrap();
    let a : u64 = iter.map(|s| s.parse().unwrap()).min().unwrap();
    println!("{}", (n - 1) / a + 5);
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

template <class T>
bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    } else {
        return false;
    }
}
template <class T>
bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    } else {
        return false;
    }
}

template <class T>
void dump_vec(const vector<T> &v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------
template <class Op>
void calc(stack<int> &st, Op op) {
    auto r = st.top();
    st.pop();
    auto l = st.top();
    st.pop();
    auto c = op(l, r);
    st.push(c);
}

signed main() {
    string s;
    stack<int> st;
    while (cin >> s) {
        if (s == "+") {
            calc(st, [](int x, int y) { return x + y; });
        } else if (s == "-") {
            calc(st, [](int x, int y) { return x - y; });
        } else if (s == "*") {
            calc(st, [](int x, int y) { return x * y; });
        } else {
            auto a = stoi(s);
            st.push(a);
        }
    }
    cout << st.top() << "\n";
}



Measured memory_bytes: 3236