akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

ll dp[101010][3] = {};

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

    string S;
    cin >> S;

    ll N = S.size();

    ll now = 1;
    dp[0][0] = 0;
    REP(i, N){
    	if(S[i]=='A'){
    		dp[i+1][0] = dp[i][0] + now;
    		dp[i+1][0] %= mod;

    		dp[i+1][1] = dp[i][1];
    		dp[i+1][2] = dp[i][2];
    	}
    	if(S[i]=='B'){
    		dp[i+1][0] = dp[i][0];

    		dp[i+1][1] = dp[i][1] + dp[i][0];
    		dp[i+1][1] %= mod;

    		dp[i+1][2] = dp[i][2];
    	}
    	if(S[i]=='C'){
    		dp[i+1][0] = dp[i][0];

    		dp[i+1][1] = dp[i][1];

    		dp[i+1][2] = dp[i][2] + dp[i][1];
    		dp[i+1][2] %= mod;
    	}
    	if(S[i]=='?'){
    		dp[i+1][0] = 3*dp[i][0] + now;
    		dp[i+1][0] %= mod;

    		dp[i+1][1] = 3*dp[i][1] + dp[i][0];
    		dp[i+1][1] %= mod;

    		dp[i+1][2] = 3*dp[i][2] + dp[i][1];
    		dp[i+1][2] %= mod;

    		now *= 3;
    		now %= mod;	
    	}
    }

    cout << dp[N][2] << endl;

    /*
    REP(i, 3){
    	REP(j, N+1){
    		cout << dp[j][i] << " ";
    	}
    	cout << endl;
    }
    */

    return 0;
}

Measured memory_bytes: 2896
ori = input()
n = int(input())

for i in range(n):
    order = input().split()
    a,b = map(int, order[1:3])
    
    if order[0] == "print":
        print(ori[a:b+1])
    elif order[0] == "reverse":
        tmp=ori[a:b+1]
        ori = ori[:a]+tmp[::-1]+ori[b+1:]
    else:
        ori = ori[:a] + order[3] + ori[b+1:]


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

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int N,K;
  cin >> N >> K;
  int a[N];
  cin >> a[0];
  int ma;
  ma=a[0];
  for(int i=1;i<N;i++){
    cin >> a[i];
    if(a[i]>ma)ma=a[i];
    a[i]=euclidean_gcd(a[i-1],a[i]);
  }
  if(K%a[N-1]==0 && ma>=K) cout << "POSSIBLE";
  else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 640
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

l, k = map(int, raw_input().split())
DP1 = [0] * 200
DP2 = [1] + [0] * 200

for i in range(1, l + 1):
    DP1[i] = DP2[i - 1]
    DP2[i] = DP1[i - 1]
    if i >= k:
        DP1[i] += DP2[i - k]
print sum(DP1)


Measured memory_bytes: 6168
#include<iostream>
#define M 2001
#define N 1001

using namespace std;

typedef long long lli;

int main(){
  int n, dp[M];
  for(int i=0; i<M; ++i) dp[i]=0;
  for(int i=0; i<N; ++i){
    for(int j=0; j<N; ++j) dp[i+j]++;
  }
  while(cin >> n){
    lli cnt=0;
    for(int ab=0; ab<M && ab<=n; ++ab){
      for(int c=0; c<N && ab+c<=n; ++c){
	if(n-ab-c<N) cnt+=dp[ab];
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;

#[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) =>
        (rl().parse::<$t>().unwrap());
    ($($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();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_end().to_owned()
}

fn main() {
    let (a, b, h, m) = read!(f64, f64, f64, f64);

    let ans2 = a * a + b * b - 2.0 * a * b * (((60.0 * h + m)/360.0 - m/30.0) * std::f64::consts::PI).cos();
    println!("{}", ans2.sqrt());
}


Measured memory_bytes: 3000
import copy
n = int(input())

word = [input() for _ in range(n)]
word2 = copy.deepcopy(word)
word2.append("koredeiinokasira...tukareta")
flag = 0

#文字が重複していないか
for index, q in enumerate(word):
    for index2, w in enumerate(word):
        
        
        if q == w:
            if index == index2:
                continue
            flag += 1
        
            

i = 0
for i in range(n-1):
    if word[i][-1] == word2[i+1][0]:
        flag += 0
    else:
        flag += 1


if flag != 0:
    print("No")
else:
    print("Yes")


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

static const int MAX = 1e5;

int main(){
    int n; cin>>n;
    vector<int> dic(MAX+1);

    for(int i=0; i<MAX+1; i++){
        dic[i] = 0;
    }

    for(int i=0; i<n; i++){
        int a;
        cin>>a;
        dic[a]++;
        if(a != MAX) dic[a+1]++;
        if(a != 0) dic[a-1]++;
    }

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

    cout<<dic[MAX]<<endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
  long long a , b , c , d ,n;
  cin>>a>>b>>c>>d>>n;
  b = min(b , a * 2);
  c = min(c , b * 2);
  d = min(d , c * 2);
  long long sum = 0;
  sum = n / 2 * d + n % 2 * c ;
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>

#define MAX_N 20
#define MAX_Q 200

int n;
int q;
  int A[MAX_N];

using namespace std;

// 0:true
// 1:false
int solve(int _res,int _num){

  if(_res == 0){
    return 0;
  }
  if(_num >= n){
    return 1;
  }

  if(solve(_res,_num+1) == 0 || solve(_res-A[_num],_num+1) == 0 ){
    return 0;
  }
  else {
    return 1;
  }
}

int main(){

  int i;
  int m;

  cin >> n;

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

  cin >> q;

  for(i = 0;i < q;i++){
    cin >> m;
    if(solve(m,0) == 0){
      cout << "yes" << endl;
    }
    else {
      cout << "no" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1156
N = int(input())
points = [list(map(int, input().split())) for i in range(N)]

dp = [[0]*3 for i in range(N)]
dp[0] = points[0]

for i in range(1, N):
    for j in range(3):
        dp[i][j] = points[i][j] + max(dp[i-1][k] for k in range(3) if k != j)

print(max(dp[-1]))


Measured memory_bytes: 48740
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>
#include <regex>
#include <queue>
#include <set>
#include <cassert>
using namespace std;
using ll = long long;
using plong = pair<ll,ll>;
ll MOD=998244353;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    ll K,N;
    cin>>K>>N;
    vector<ll> A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    ll res = A[N-1]-A[0];
    for(ll i=1;i<N;i++){
        res = min(res,K-A[i]+A[i-1]);
    }
    cout<<res<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


int32_t main(){
 fastio;
 int n;
 cin>>n;
 vector<ll> v(n);
 ll p=1;
 ll mx = (ll)1e18;
 for(int i=0;i<n;i++){
  cin>>v[i];
  if(v[i]==0){
    cout << 0 << endl;
    return 0;
  }
 }
 for(int i=0;i<n;i++){ 
  if(v[i] > mx/p){
    cout<<-1<<endl;
    return 0;
  }else p = 1LL*p*v[i];
  if(p>mx){
    cout<<-1<<endl;
    return 0;
  }
 }
 cout << p << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 1007;

int n, m, d;
PII ans[N][N];

int main()
{
    _upgrade
    cin >> n >> m >> d;
    for(int s = 0; s <= n + m - 2; s++)
    {
        for(int i = n - 1; i >= 0; i--)
        {
            int j = s - i;
            if(0 > j || j >= m) continue;
            ans[i][j].first = ((s / d) & 1);
        }
    }
    int rmn = 100001, rmx = -rmn;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            rmn = min(rmn, i - j), rmx = max(rmx, i - j);
    for(int r = rmx; r >= rmn; r--)
    {
        for(int i = 0; i <= n - 1; i++)
        {
            int j = i - r;
            if(0 > j || j >= m) continue;
            //ans[i][j].second = r;
            if(((r - rmn) / d) % 2 == 0) ans[i][j].second = 0;
            else ans[i][j].second = 1;
        }
    }

    /*
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cout << ans[i][j].first;
        }
        cout << "\n";
    }
    cout << "\n\n";
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            cout << ans[i][j].second;
        }
        cout << "\n";
    }
    cout << "\n\n";
    */
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++)
        {
            if(ans[i][j] == make_pair(0, 0)) cout << "R";
            if(ans[i][j] == make_pair(0, 1)) cout << "Y";
            if(ans[i][j] == make_pair(1, 0)) cout << "G";
            if(ans[i][j] == make_pair(1, 1)) cout << "B";
        }
        cout << "\n";
    }
	return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int a[m],b[m];
  for(int i=0;i<m;i++) cin>>a[i]>>b[i];
  int dp[n+1];
  int inf=1LL<<55LL;
  fill_n(dp,n+1,inf);
  dp[0]=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      if(a[j]<=i+1) dp[b[j]]=min(dp[b[j]],dp[i]+1);
  if(dp[n]==inf) cout<<"Impossible"<<endl;
  else cout<<dp[n]<<endl;
  return 0;
}



Measured memory_bytes: 3104
def main():
    n = int(input())
    b = list(map(int, input().split()))
    a = [None] * n
    for i in range(n):
        if i == 0:
            a[i] = b[i]
        elif i <= n-2:
            a[i] = min(b[i-1], b[i])
        else:
            a[i] = b[i-1]
    ans = sum(a)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=1<<20;

int n,k;
LL a[N],b[N];
bool used[N];

int main() {
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		a[i]+=a[i-1];
	}
	int m=0;
	for(int l=1;l<=n;l++) {
		for(int r=l;r<=n;r++) {
			b[m++]=a[r]-a[l-1];
		}
	}
	LL ans=0;
	for(int i=45;i>=0;i--) {
		int c=0;
		for(int j=0;j<m;j++) {
			if(used[j]) continue;
			if((b[j]>>i)&1) c++;
		}
		if(c>=k) {
			ans+=(1LL<<i);
			for(int j=0;j<m;j++) {
				if(!((b[j]>>i)&1)) used[j]=1;
			}
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 7936
#include<iostream>
    using namespace std;
    signed main(){
    int n,h[100005],dp[100005]={};
    cin >>n;
    for(int i=1;i<=n;i++){
    cin >> h[i];
    }
    dp[1]=0;
    for(int i=2;i<=n;i++){
    if(i != 2)
    dp[i]=min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    else
    dp[i]=abs(h[i]-h[i-1])+dp[i-1];
    }
    cout << dp[n] <<'\n';
     
    return(0);
    }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define pb emplace_back
#define fi first
#define se second
#define md 1000000007
#define gc getchar
#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 sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define br printf("\n");
#define PI 3.14159265359
 
 
typedef long long int ll;
typedef long double ld;
typedef priority_queue<int,vector<int>,greater<int> > spq; // min priority queue
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> o_set;
#define int long long int
 
struct ppair{
int fi,se;
ppair(int a,int b):fi(a),se(b){}
ppair():fi(0),se(0){}
};
inline bool cmp(const ppair &a,const ppair &b)
{
if(a.fi==b.fi)
	return a.se<b.se;
return a.fi<b.fi;
}
 
int pmod(int a, int m){
return (a%m + m)%m;
}
void sscan(string &s, const int MAX){
char a[MAX];
scanf("%s",a);
s = string(a);
}
int stringtoint(string s){
stringstream c(s);
int x = 0;
c>>x;
return x;}
 
template<typename T> T power(T a,T b,T m)
{
T ans = 1,p = a;
while(b)
{
	if(b&1)
		ans = (ans*p)%m;
	p = (p*p)%m;
	b>>=1;
}
return ans;
}
 
template<typename T> T gcd(T a,T b)
{
if(b==0)
	return a;
else
	return gcd(b,a%b);
}
template<typename T> T e_gcd(T a,T b,T &x,T &y)
{
if(b==0)
{
	x = 1,y = 0;
	return a;
}
T x1,y1;
T g = e_gcd(b,a%b,x1,y1);
x = y1;
y = x1-(a/b)*y1;
if(y<0)
{
	y+=a;
	x-=b;
}
return g;
}
template<typename T> T invmod(T a,T m)
{
T x,y,g;
g = e_gcd(m,a,x,y);
if(g!=1)
	return -1;
else
	return y;
}
 
inline void sc(int &x)
{
register int c = gc();
bool flag = false;
x = 0;
for(;((c<48 && c!=45) || c>57);c = gc());
if(c==45)
{
flag = true;
c = gc();
}
for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
if(flag)
x = x - (x<<1);
return;
}
inline void scll(ll &x)
{
register int c = gc();
bool flag = false;
x = 0;
for(;((c<48 && c!=45) || c>57);c = gc());
if(c==45)
{
flag = true;
c = gc();
}
for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
if(flag)
x = x - (x<<1);
return;
}
signed main()
{
//freopen("inputf.txt","r",stdin);
int n,a,b;
slld(n);slld(a);slld(b);
int d = abs(b-a);
if(d%2==0)
	cout<<"Alice";
else
	cout<<"Borys";
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  rep(i,N) cin >> A[i];
  rep(i,M) cin >> B[i];
  rep(y,N-M+1){
    rep(x,N-M+1){
      rep(yy,M){
        rep(xx,M){
          if(A[y+yy][x+xx]==B[yy][xx]){}
          else goto OUT;
        }
      }
      {cout << "Yes" << endl; return 0;}
      OUT:{}
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;


int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int maxi, mini;
    if(n > a + b)
    {
        mini = 0;
    }
    else
    {
        mini = a + b - n;
    }
    maxi = min(a, b);
    cout << maxi << " " << mini;

    return 0;

}


Measured memory_bytes: 256
#if 1
  #include <bits/stdc++.h>
#else
  #include "../../bits/stdc++.h"
#endif

#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))

using namespace std;

typedef pair<int, int> P;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

int n;
char s[34];

bool input(){
  cin>>s;
  if(s[0]=='#')return false;
  n = strlen(s);
  return true;
}

bool right(char c) {
  switch(c) {
    case 'y':case 'u':case 'i':case 'o':case'p':
    case 'h':case 'j':case 'k':case 'l':case 'n':case 'm':
    return true;
    break;
  }
  return false;
}

void solve(){
  int c=0;
  bool f=right(s[0]);
  FOR(i, 1, n) {
    if(f!=right(s[i])) {
      c++;
      f=!f;
    }
  }
  cout<<c<<endl;
}

int main(){
  cin.tie(0);
  
  while (input()){
      solve();
  }
  
  return 0;
}

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

int main(){
    int p,q,r;
    int n;
    int ans=0;

    cin >>p>>q>>r;
    ans = p+q+r;
    ans -= max(p,max(q,r));
    
    cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

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

	int sum = accumulate(A.begin(), A.end(), 0);
	double border = (double)sum / (4 * M);
	int pop = 0;

	for (int i = 0; i < N; i++) {
		if (A[i] >= border) {
			pop++;
		}
	}

	if (pop >= M) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int a, b, m; cin >> a >> b >> m;
  vector<int> aa(a);
  vector<int> bb(b);
  vector<int> x(m);
  vector<int> y(m);
  vector<int> c(m);
  for(int i=0; i<a; i++) cin >> aa[i];
  for(int i=0; i<b; i++) cin >> bb[i];
  int ans = *min_element(all(aa)) + *min_element(all(bb));
  for(int i=0; i<m; i++) {
    cin >> x[i] >> y[i] >> c[i];
    ans = min(ans, aa[x[i]-1] + bb[y[i]-1] - c[i]);
  }
  cout << ans << endl;
  
}

// EOF

Measured memory_bytes: 2176
N=int(input())
l=input().split()
T=int(l[0])
A=int(l[1])
H=list(map(int,input().split()))
min=1000000
index=10000
for i in range(N):
    #print(abs(A-(T-H[i]*0.006)))
    if abs(H[i]*0.006+A-T)<min:
        index = i
        #print(i)
        min=abs(H[i]*0.006+A-T)
        #print(int(abs(A-(T-H[i]*0.006))))

print(index+1)

Measured memory_bytes: 3064
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static int max;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String in = sc.next();
		boolean ok = true;
		boolean checkA = false;
		boolean checkB = false;
		boolean checkC = false;
		if(in.length() < 6) ok = false;
		else {
			for(int i = 0; i < in.length(); i++) {
				if(in.charAt(i) >= '0' && in.charAt(i) <= '9') {
					checkA = true;
				}
				if(in.charAt(i) >= 'a' && in.charAt(i) <= 'z') {
					checkB = true;
				}
				if(in.charAt(i) >= 'A' && in.charAt(i) <= 'Z') {
					checkC = true;
				}
			}
		}
		if(ok && checkA && checkB && checkC) {
			System.out.println("VALID");
		}
		else {
			System.out.println("INVALID");
		}
	}
}

Measured memory_bytes: 17328
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        memo := make(map[int]int)
        for i := range a {
                if n, ok := memo[a[i]]; ok {
                        if n > 1 {
                                memo[a[i]]--
                        } else {
                                delete(memo, a[i])
                        }
                } else {
                        memo[a[i]]++
                }
        }
        return len(memo)
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 8612
#include<bits/stdc++.h>
using namespace std;
string a;
int cnt,ans,sum;
int main(){
    cin>>a;
    for(int i=0;i<a.size();i++){
        if(a[i]=='S') ans++;
        else if(ans) cnt++;
        if(ans>=cnt){
            sum+=min(ans,cnt)*2;
            ans-=min(ans,cnt);
            cnt=0;
        }
    }
    cout<<a.size()-sum<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n, a;
    double s;
    cin >> n;
    s = 0;
    for (int i=0; i<n; i++) {
        cin >> a;
        s += 1 / (double)a;
    } 
    cout << 1 / s << endl;
    return 0;
}


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


int main() {
    long n,m;
    cin>>n>>m;
    long count=(n-2)*(m-2);
    if(n==1)count=m-2;
    if(m==1)count=n-2;
    if(n==1 && m==1 )count=1;
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Intervals on Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  ll vsum = 0;
  for (int i = 0; i < n; i++) vsum += (ll)(i + 1) * (n - i);

  ll esum = 0;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;

    if (u > v) swap(u, v);
    esum += (ll)(u + 1) * (n - v);
  }

  printf("%lld\n", vsum - esum);
  return 0;
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
// #define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define vpipii vector<pipii>
#define vpiipi vector<piipi>
#define pb push_back
#define pob pop_back
#define pii pair<int,int>
#define pipii pair<int,pii>
#define piipi pair<pii,int>
#define pld pair<long double,long double>
#define mod 1000000007
// #define mod 1000000009
// #define mod 163577857 
// #define mod 998244353
#define rep(i,n) for (int i = 0; i < n; i++)
#define repp(i,a,b) for(int i = a ; i<b ; i++)
#define reppr(i,a,b) for(int i = a-1 ; i>=b ; i--)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define ff first
#define ss second
#define pc putchar_unlocked
#define gc getchar_unlocked
#define inf 9223372036854775807
#define infn -9223372036854775807
#define pi 3.14159265358979323846
#define eps 0.0000000001
#define sp << " " <<
#define setprec(x) cout << fixed << setprecision(x);
#define REVERSE(a) reverse(all(a));
#define SORT(a) sort(all(a));
#define all(n) n.begin(),n.end()
 
//GCD and LCM
    int gcd (int a, int b) { return b ? gcd (b, a % b) : a; }
    int lcm (int a, int b) { return a / gcd(a, b) * b; }
 
//Modular Exponentiation
    int powmod(int x,int y) 
    { 
        if (y == 0) return 1; 
        int p = powmod(x, y/2) % mod; 
        p = (p * p) % mod;   
        return (y%2 == 0)? p : (x * p) % mod; 
    }
 
//Modular Inverse
    int inverse(int a) 
    { 
       return powmod(a,mod-2); 
    }

//Binomial Coefficients
    int fact[2000001], factinv[2000001] , coefficientflag = 0;
    void Util_nCr()
    {
        fact[0] = 1 , factinv[0] = 1;
        repp(i,1,2000001)
        {
            fact[i] = (fact[i-1] * i)%mod;
            factinv[i] = (factinv[i-1] * inverse(i))%mod;
        }
    }
    int nCr(int n , int r)
    {
        if(!coefficientflag) coefficientflag = 1 , Util_nCr();             
        return ((fact[n] * inverse(fact[n-r]) % mod * inverse(fact[r]))%mod) ;
    }

void solve();
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    // cin >> t; 
    rep(i,t)
    {
        // cout << "Case #" << i+1 << ": ";
        solve();
    }
}

void solve() 
{   
    int k;
    cin >> k;
    string s;
    cin >> s;
    int l = s.length();
    // int dp[k+s.length()+1][s.length()+1] = {};
    // dp[0][0] = 1;
    int ans = 0;
    repp(i,l-1,k+l)
    {
        int hi = i - l + 1;
        int lo = k+l-1 - i;
        ans = ans + nCr(i,l-1)*powmod(25,hi)%mod*powmod(26,lo);
        ans %= mod;
    }
    cout << ans << endl;



    // rep(i,k+s.length())
    //     rep(j,s.length()+1)
    //     {
    //         if(j==0)
    //             dp[i+1][j] = dp[i][j]*25;
    //         else if(j==s.length()-1)
    //             dp[i+1][j] = dp[i][j]*26 + dp[i][j-1];
    //         else
    //             dp[i+1][j] = dp[i][j]*25 + dp[i][j-1];
    //         dp[i+1][j]%=mod;
    //     }
    // cout << dp[k+s.length()][s.length()] << endl;
}     

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll P = 1000000007;
  ll ans = 1;
  for (int i = 0; i < n; i++) ans = (ans * (i + 1)) % P;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String s = scanner.next();

        int max = 0;
        String bef;
        String aft;

        for (int i = 0;i<a;i++) {
        	bef = s.substring(0, i+1);
        	aft = s.substring(i+1,s.length());
        	int cnt = 0;

        	String[] bef2 = bef.split("");
        	Set<String> hash_set = new HashSet<String>();
        	for(String tmp : bef2) {
        		hash_set.add(tmp);
        	}
        	for(String tmp : hash_set){
        		if(aft.contains(tmp)) {
        			cnt++;
        		}
        	}
        	if (cnt >= max) {
        		max = cnt;
        	}
        }
        System.out.println(max);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

int main()
{
    char x,y;
    scanf("%c %c",&x,&y);
    if(x=='D'&&y=='D')
        printf("H\n");
    else if(x=='D'&&y=='H')
        printf("D\n");
    else if(x=='H'&&y=='D')
        printf("D\n");
    else
        printf("H\n");
    return 0;
}


Measured memory_bytes: 128
import itertools


N = int(input())
ARR = []

for i in range(N):
    S = list(input())
    ARR.append(S)


def calculate(n,arr):
    brr = {
        "M":0,
        "A":0,
        "R":0,
        "C":0,
        "H":0,
    }

    for ar in arr:
        if ar[0] == "M":
            brr.__setitem__("M",brr.get("M") + 1)

        if ar[0] == "A":
            brr.__setitem__("A",brr.get("A") + 1)

        if ar[0] == "R":
            brr.__setitem__("R",brr.get("R") + 1)

        if ar[0] == "C":
            brr.__setitem__("C",brr.get("C") + 1)

        if ar[0] == "H":
            brr.__setitem__("H",brr.get("H") + 1)

    m = brr.values()

    ssk = []
    for k in m:
        ssk.append(k)


    result = []
    for ss in itertools.combinations(ssk,3):
        result.append(ss[0] * ss[1] * ss[2])


    print(sum(result))



calculate(N,ARR)


Measured memory_bytes: 20416
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,m,tot,head[N],nex[N],to[N],wi[N];
ll a[N][2],f[N];
bool uq,vis[N][2];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
ll uqans;
void dfs(int u,int st)
{
    vis[u][st]=true;
    if(vis[u][st^1])
    {
        if((a[u][1]-a[u][0])&1)
        {
            printf("0\n");exit(0);
        }
        ll ans=(a[u][1]-a[u][0])/2;
        if(ans<=0||uq&&uqans!=ans)
        {
            printf("0\n");exit(0);
        }
        uq=true;
        uqans=ans;
    }
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(vis[v][st^1])
        {
            if(wi[i]-a[u][st]!=a[v][st^1])
            {
                printf("0\n");
                exit(0);
            }
        }
        else
        {
            a[v][st^1]=wi[i]-a[u][st];
            dfs(v,st^1);
        }
    }
}
bool judge(int u,int ans)
{
    f[u]=ans;
    if(f[u]<=0) return false;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];
        if(f[v])
        {
            if(f[v]!=wi[i]-ans) return false;
        }
        else if(!judge(v,wi[i]-ans)) return false;
    }
    return true;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int u,v,w;scanf("%d%d%d",&u,&v,&w);
        add(u,v,w);add(v,u,w);
    }
    dfs(1,0);
    ll l=0,r=1e9+1;
    if(uq)
    {
        if(judge(1,uqans)) printf("1\n",0);
        else printf("0\n");
        return 0;
    }
    for(int i=1;i<=n;i++)
    {
        if(vis[i][0])
            l=max(l,-a[i][0]);
        else
            r=min(r,a[i][1]);
    }
    l++;r--;
    printf("%lld\n",max(0ll,r-l+1));
}


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

#define int long long

signed main(){
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans = a + b*5 + c*10 + d*50 + e*100 + f*500;
    if(ans >= 1000){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int N;
    long[][] A,B;



    public void solve() {
        N = nextInt();

        A = new long[N][N];
        B = new long[N][N];
        for(int i = 0;i < N;i++) {
            for(int j = 0;j < N;j++) {
                A[i][j] = nextInt();
                B[i][j] = A[i][j];
            }
        }

        for(int i = 0;i < N;i++) {
            for(int j = 0;j < N;j++) {
                for(int k = 0;k < N;k++) {
                    B[j][k] = Math.min(B[j][k],B[j][i] + B[i][k]);
                }
            }
        }

        for(int i = 0;i < N;i++) {
            for(int j = 0;j < N;j++) {
                if (A[i][j] != B[i][j]) {
                    out.println(-1);
                    return;
                }
            }
        }

        long ans = 0;
        for(int i = 0;i < N;i++) {
            for(int j = i+1;j < N;j++){
                ans += B[i][j];
                for(int k = 0;k < N;k++){
                    if (i == k || j == k)continue;

                    if (B[i][k] + B[k][j] == B[i][j]) {
                        ans -= B[i][j];
                        break;
                    }
                }
            }
        }



        out.println(ans);

    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

Measured memory_bytes: 35640
### constant

INF = 1 << 30

### main

loop do
  w, h = gets.split.map(&:to_i)
  break if (w | h) == 0

  wh = w * h
  edges = wh.times.map{wh.times.map{false}}
  nbrs = wh.times.map{[]}

  for y in (0...h)
    vls = gets.split.map(&:to_i)
    for x in (0...(w - 1))
      if vls[x] == 0
        i0 = y * w + x
        i1 = i0 + 1
        edges[i0][i1] = edges[i1][i0] = true
        nbrs[i0] << i1
        nbrs[i1] << i0
      end
    end

    if y < h - 1
      hls = gets.split.map(&:to_i)
      for x in (0...w)
        if hls[x] == 0
          i0 = y * w + x
          i1 = i0 + w
          edges[i0][i1] = edges[i1][i0] = true
          nbrs[i0] << i1
          nbrs[i1] << i0
        end
      end
    end
  end

  st = 0
  gl = wh - 1

  dists = wh.times.map{INF}
  dists[st] = 1
  q = [st]

  while ! q.empty?
    u = q.shift
    break if u == gl
    ud = dists[u]

    for v in nbrs[u]
      vd = dists[v]
      nvd = ud + 1
      if vd > nvd
        dists[v] = nvd
        q << v if vd >= INF
      end
    end
  end

  dg = dists[gl]
  puts dg >= INF ? 0 : dg
end

Measured memory_bytes: 15128
N = gets.to_i
A = gets.split(" ").map(&:to_i)
count, ans = 0, 0
min = 10**9 + 7

A.each do |a|
    count += 1 if a < 0
    min = a.abs if min > a.abs
    ans += a.abs
end

if count % 2 == 0 
    puts ans
else
    puts ans - 2 * min
end


Measured memory_bytes: 8580
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int,int> P;
struct edge{int to,cost;};

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



int main(){
    string N;
    while(cin >> N, N != "0000"){
        if(N=="0000"||N=="1111"||N=="2222"||N=="3333"||N=="4444"||N=="5555"||N=="6666"||N=="7777"||N=="8888"||N=="9999"){
            cout << "NA" << endl;
            continue;
        }else if(N=="6174"){
            cout << 0 << endl;
            continue;
        }
        vec Nv(4);
        for(int i=0;i<4;i++){
            Nv[i] = N[i]-'0';
        }
        int t = 0;
        while(1){
            t++;
            sort(Nv.begin(), Nv.end());
            int l=0, s=0, p=1;
            for(int i=0;i<4;i++){
                l += Nv[i]*p;
                s += Nv[i]*1000/p;
                p *= 10;
            }
            int sub = l - s;
            if(sub == 6174) break;
            p = 1000;
            for(int i=0;i<4;i++){
                Nv[i] = (sub/p)%10;
                p /= 10;
            }
        }
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_E 10000
#define MAX_V 100

int V,E;
int par[MAX_V],rank[MAX_V];
void init(){
  for(int i = 0 ; i < V ; i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);

  if(x == y) return;

  if(rank[x] < rank[y]){
    par[x] = y;
  }else{
    par[y] = x;

    if(rank[x] == rank[y]){
      rank[x]++;
    }
  }
}

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

struct edge{
  int u,v,cost;
};

bool comp(const edge &e1,const edge &e2){
  return e1.cost < e2.cost;
}

edge es[MAX_E];

int kruskal(){
  init();
  sort(es , es + E,comp);

  int res = 0;
  for(int i = 0 ; i < E ; i++){
    edge e = es[i];
    if(!same(e.u , e.v)){
      unite(e.u , e.v);
      res += e.cost;
    }
  }
  return res;
}

int main(){
  int a,b,c;
  while(scanf("%d %d" ,&V ,&E) ,(V | E)){
    for(int i = 0 ; i < E ; i++){
      scanf("%d %d %d" ,&a ,&b ,&c);
      es[i] = (edge){a,b,c};
    }
    printf("%d\n" ,kruskal());
  }

  return 0;
}

Measured memory_bytes: 1052
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
string a[4];
int main()
{
	ios::sync_with_stdio(false);
	cin>>a[1]>>a[2]>>a[3];
	cout<<a[1][0]<<a[2][0]<<a[3][0];
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ac=0,tle=0,wa=0,re=0;
int main()
{
    int t;
    cin>>t;
    string s;
    for(int i=0;i<t;i++)
    {
        cin>>s;
        if(s[0]=='A' && s[1]=='C'){
            ac++;
        }
        if(s[0]=='W' && s[1]=='A'){
            wa++;
        }
        if(s[0]=='T' && s[1]=='L' && s[2]=='E'){
            tle++;
        }
        if(s[0]=='R' && s[1]=='E'){
            re++;
        }
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}



Measured memory_bytes: 3632
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
vector<ll> v;
int m,n;
void dfs(ll k,int depth)
{
    v.push_back(k);
    if(depth>=10)
        return;
    dfs(k*10+k%10,depth+1);
    if(k%10)
        dfs(k*10+k%10-1,depth+1);
    if(k%10<9)
        dfs(k*10+k%10+1,depth+1);
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    for(int i=1; i<=9;++i)
        dfs(i,1);
    sort(v.begin(),v.end());
    cin>>n;
    cout<<v[n-1];
    return 0;
}


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

int main() {
  string str;
  int a, b, l, x;
  char c;
  while (getline(cin, str)) {
    x = 0;
    l = (int)str.size();
    for (int i=0; i<l; i++) {
      c = str.at(i);
      if (c == 'I') a = 1;
      else if (c == 'V') a = 5;
      else if (c == 'X') a = 10;
      else if (c == 'L') a = 50;
      else if (c == 'C') a = 100;
      else if (c == 'D') a = 500;
      else if (c == 'M') a = 1000;
      if (i) {
        if (b >= a) {
          x += b;
        } else {
          x -= b;
        }
      }
      b = a;
    }
    x += b;
    cout << x << endl;
  }
  return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,q;cin>>n>>k>>q;
  vector<int> arr(n+1);
  for(int i=0;i<q;++i){
    int curr;cin>>curr;
    arr[curr]++;
  }
  for(int i=1;i<=n;++i){
    if(arr[i]+k-q>0){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
let S = readLine()!.characters.map{String($0)}
var ans = S.count
for i in 0..<2 {
    var cnt = 0
    for j in 0..<S.count {
        if (j%2)^i != Int(S[j]) {
            cnt += 1
        }
    }
    ans = min(ans, cnt)
}
print(ans)

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

int main(){
    int x;
    int y;
    cin >> x >> y;
    for(int i=0; i<=x; i++){
        // if(y == 2 * i + 4 * (x - i) || y == 2 * (x - i) + 4 * i){
        if(y == 2 * i + 4 * (x - i)){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;
#define PI acos(-1.0)
#define EPS 1e-10
const ll INT = 1e16;
const ll MOD = 1e9 + 7;
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define rep(i,N) FOR(i, 0, N)
#define ALL(s) (s).begin(), (s).end()
#define EQ(a, b) (abs((a) - (b)) < EPS)
#define EQV(a, b) (EQ((a).reeal(), (b).real) && EQ((a).imag(), (b).imag()))
#define NIL -1

int n,m;
vector<int> s;

bool solve(int x){
    int l = 1, now = 0;
    rep(i,m-1){
        if(s[n-1] < l + x)return false;
        for(;now < n-1;now++){
            if(s[now+1] >= l+x)break;
            int a = max(1, x-abs(l-s[now]));
            int b = max(1, x-abs(l-s[now+1]));
            if(a > b)break;
        }
        //if(x == 5)cout << l << endl;
        l += max(1, x - abs(l-s[now]));
    }
    return true;
}

int main(){
    while(cin >> n >> m, n){
        s.resize(n);
        rep(i,n)cin >> s[i];
        int l = s[0], r = s[n-1];
        if(!solve(l)){
            cout << -1 << endl;
            continue;
        }
        while(r - l > 1){
            int mid = (r+l) / 2;
            if(solve(mid))l = mid;
            else r = mid;
        }
        cout << l << endl;
    }
}


Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
 
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
 
	long long int a;
	long double b;
	cin >> a >> b;
	long long int c = round(b*100);
  	cout << (a*c)/100 << endl;
	return 0;
}

Measured memory_bytes: 3800
package main

import (
	"fmt"
)

// how to run
// go run hoge.go
func main() {
	// var input = bufio.NewScanner(os.Stdin)
	var a, b int
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a <= 0 && 0 <= b {
		fmt.Println("Zero")
	} else if 0 < a {
		fmt.Println("Positive")
	} else {
		// a , b < 0 のものだけ
		minusCount := (-a) - (-b) + 1
		if minusCount%2 == 1 {
			fmt.Println("Negative")
		} else {
			fmt.Println("Positive")
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <climits>
using namespace  std;

#define llong long long

void fnInput(vector<int> &rvnSort)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  rvnSort.resize(nMaxSiz);
  for (int i = 0; i < nMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int> &rvnSort, llong &rnInvCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vnLeft, vnRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;
  
  vnLeft.resize(nLeftSiz + 1);
  vnRight.resize(nRightSiz + 1);
  for (int i = 0; i < nLeftSiz; i++)
    vnLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vnRight[i] = rvnSort[nMid + i];

  vnLeft[nLeftSiz] = INT_MAX;
  vnRight[nRightSiz] = INT_MAX;

  int i = 0, j = 0;
  for (int n = nLeft; n < nRight; n++)
    if (vnLeft[i] <= vnRight[j])
      rvnSort[n] = vnLeft[i++];
    else
    {
      rvnSort[n] = vnRight[j++];
      if (vnLeft[i] != INT_MAX)
        rnInvCnt += (nLeftSiz - i);
      else;
    }  
}

void fnMergeSort(vector<int> &rvnSort, llong &rnInvCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnInvCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnInvCnt, nMid, nRight);
    fnMerge(rvnSort, rnInvCnt, nLeft, nMid, nRight);
  }
}

void fnResult(llong nInvCnt)
{
  cout << nInvCnt << endl; 
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnSort;

  fnInput(vnSort);

  int nLeft = 0;
  int nRight = vnSort.size();
  llong nInvCnt = 0;
  fnMergeSort(vnSort, nInvCnt, nLeft, nRight);

  fnResult(nInvCnt);

  return 0;
}

Measured memory_bytes: 2576
def foo (s):
	ans = 0
	count = 0
	for i in s:
		if   (not count) and (i == 'E'):pass
		elif not count: count += 1
		elif i == 'E': count -= 1; ans += 1
		else: count += 1
	return ans

n = input()
s = input()

print(foo(s))

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

#define H 251

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

    int A[H];
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }

    for (int i = 1; i <=n; i++) {
        cout << "node " << i << ": ";
        cout << "key = " << A[i] << ", ";
        if (i / 2 >= 1) {
            cout << "parent key = " << A[i/2] << ", ";
        }
        if (2*i <= n) {
            cout << "left key = " << A[2*i] << ", ";
        }
        if (2*i + 1 <= n) {
            cout << "right key = " << A[2*i + 1] << ", ";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b;
cin>>a>>b;
if(a==b)cout<<"Draw";
else if (a==1)cout<<"Alice";
else if(b==1)cout<<"Bob";
else if (a>b)cout<<"Alice";
else if (a<b)cout<<"Bob";

return 0;
}





Measured memory_bytes: 256