akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
constexpr long long mod=1e9+7;

signed main(){
    int N;cin>>N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long ans=LLONG_MAX;
    int sig[2]={1,-1};
    REP(j,2){ 
        long long sum=0;
        long long count=0;
        REP(i,N){
            sum+=A[i];
            if(i%2==0&&sig[j]*sum<=0){
                count+=llabs(sum-sig[j]*1);
                sum=sig[j]*1;
            }
            if(i%2==1&&sig[j]*sum>=0){
                count+=llabs(sum+sig[j]*1);
                sum=-1*sig[j];
            }
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
}

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

int main() {
	int a = 0;
	string S;
	cin >> S;
	for (int i = 0; i < 4; i++) {
		if (S[i] == '+') {
			a += 1;
		}
		else {
			if (S[i] == '-') {
				a -= 1;
			}
		}
	}
	cout << a << endl;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

string s;
ll k;
int main() {
    cin>>s;
    cin>>k;
    char ans;
    if(k==1){
        ans = s[0];
    }else if(k<s.size() && s[k-1]=='1'){
        ans = '1';
    }else{
        ans = '1';
        REP(i,s.size()){
            if(s[i] != '1'){
                ans = s[i];
                break;
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

sum = 0
for i in list:
  sum += i
average = sum // len(list)


ans1 = 0
ans2 = 0
ans3 = 0
ans4 = 0
ans5 = 0
for i in list:
  ans1 += (i-average+1)*(i-average+2)
  ans2 += (i-average+1)*(i-average+1)
  ans3 += (i-average)*(i-average)
  ans4 += (i-average-1)*(i-average-1)
  ans5 += (i-average-2)*(i-average-2)
answer = min(ans1,min(ans2,min(ans3,min(ans4,ans5))))
print(answer)

Measured memory_bytes: 3188
n = int(input())
s = list(input())
#ord65-90
ans=[]
for i in range(len(s)):
    ord_num = ord(s[i])+n
    if 90 < ord_num:
        ord_num = ord_num-26
    tmp="".join(chr(ord_num))
    ans.append(tmp)
print(*ans,sep="")




Measured memory_bytes: 4724
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int,int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
LP x[100000]; ll csum[100000]; ll c[100000]; ll sum[100000];
ll dif1[100000] = {};
int m; ll dat[399999];
void init(int m_) {
	m = 1;
	while (m < m_)m *= 2;
	rep(i, 2 * m - 1)dat[i] = INF;
}
void updat(int k,ll a) {
	k += m - 1; dat[k] = a;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
	}
}
ll query(int a, int b, int k, int l, int r) {
	if (r <= a || b <= l)return INF;
	if (a <= l && r <= b)return dat[k];
	else {
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
}
int main() {
	int n;
	ll l; cin >> n >> l; m = n - 1;
	rep(i, n) {
		ll a, b; cin >> a >> b;
		x[i] = { a - b,a };
	}
	rep(i, n) {
		cin >> c[i];
	}
	sort(x, x + n,greater<LP>());
	sum[0] = x[0].first;
	csum[0] = c[0];
	int chk = n;
	Rep(i, 1, n) {
		sum[i] = sum[i - 1] + x[i].first;
		if (x[i].first <= 0)chk = i;
		csum[i] = csum[i - 1] + c[i];
	}
	dif1[0] = sum[0] - csum[0];
	Rep(i,1, n) {
		dif1[i] = min(dif1[i - 1], sum[i] - csum[i]);
	}
	init(m);
    rep(i, n - 1) {
		updat(i,sum[i + 1] - csum[i]);
	}
	int out = (int)MOD;
	rep(i, n) {
		ll nx = x[i].first; ll ny = x[i].second;
		int loc = lower_bound(sum, sum + chk, l - ny) - sum;
		if (loc == chk)continue;
		if (loc < i) {
			if (dif1[loc]>0)out = min(out, 2 + loc);
		}
		else {
			loc = lower_bound(sum, sum + chk, l - ny + nx) - sum;
			if (loc == chk)continue;
			ll mi = query(i, loc, 0, 0, m);
			if (mi-nx>0)out = min(out, loc + 1);
		}
	}
	if (out == (int)MOD) {
		cout << -1 << endl;
	}
	else {
		cout << out << endl;
	}
	return 0;
}


Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
どこ通ればいいんだろう
最短というわけでもなさそう
45000ほどの道
補給回数で仮定してるーととるか
DPかな
つど最短とったとして、その先が詰むとかもあるか
通れない道
BFSかな
残り燃料と補給回数
いけそうなきがする
DFSよりBFSのほうが軽そう

まんたんでもいけないばあいあるか
WAぬけた。まだTLE･･･

あーBFSDFSは最悪N^Nなのか
ワーシャルフロイドで最短。N^3
最短わかったけどどういうるーとなのかわかんないな
復元用のデータか
1-2-3-4-5として1-5の最短ルートは
1-5=2
2-5=3
3-5=4
4-5=5
5-5=完

ああ、ゴールまでの最短ルートが通行できるとは限らないんだな
L=3
5-1
3-3-3-3-3
があったら5回補給ルートをとるべきか
Lをこえる長さのみちは通らないとする

なぜWA抜けぬ･･・

*/
ll N,M,L,oo=1e12;
vector<vector<ll>> Z,P;
void wf(){
  for(ll k=1; k<=N; k++){//中継地点だっけ
    for(ll i=1; i<=N; i++){//s
      if(i==k) continue;
      for(ll j=1; j<=N; j++){//g
        if(i==j || k==j) continue;
        ll now=Z[i][j], next=Z[i][k]+Z[k][j];
        if(now<=next) continue;
        Z[i][j]=next;
        P[i][j]=P[i][k];//経路保存
      }
    }
  }
}

int main(){
  cin>>N>>M>>L;
  Z.assign(N+1,vector<ll>(N+1,oo));
  P.assign(N+1,vector<ll>(N+1,0));
  //P初期化  
  for(ll i=1; i<=N; i++) for(ll j=1; j<=N; j++) P[i][j]=j;
  for(ll i=0; i<M; i++){
    ll a,b,c; cin>>a>>b>>c;
    if(c>L) continue;
    Z[a][b]=c;
    Z[b][a]=c;
  }
  wf();
  for(ll i=1; i<=N; i++) for(ll j=1; j<=N; j++) Z[i][j]=((Z[i][j]<=L)?1:oo);
  wf();
  ll Q; cin>>Q;
  for(ll i=0; i<Q; i++){
    ll s,t; cin>>s>>t;
    ll ans=(Z[s][t]>=oo)?-1:Z[s][t]-1;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1920
#include<string.h>

int main(void){
  char i[100];
  int a=0,b=0,c=0;
  scanf("%d",&a);
  scanf("%s",i);
  
  b=strlen(i);
  
  if(b>a){
    for(c=0;c<a;c++){
      printf("%c",i[c]);}
    printf("...\n");}
  else{
      printf("%s",i);}
    return 0;}

Measured memory_bytes: 1684
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut d = vec![0; 8];
    let mut t = 0;
    for i in a.into_iter() {
    if 1    <= i && i <= 399 {
        d[0]+=1;
    } else if 400  <= i && i <= 799  {
        d[1]+=1;

    } else if 800  <= i && i <= 1199 {

        d[2]+=1;

    } else if 1200 <= i && i <= 1599 {

        d[3]+=1;

    } else if 1600 <= i && i <= 1999 {

        d[4]+=1;

    } else if 2000 <= i && i <= 2399 {

        d[5]+=1;

    } else if 2400 <= i && i <= 2799 {

        d[6]+=1;

    } else if 2800 <= i && i <= 3199 {
        d[7]+=1;
    } else {
        t+=1;
    }

    }
    let mut ds = 0;
    for i in d.into_iter() {
        if i >= 1 {
            ds+=1;
        }
    }
    if t != 0 {
        if ds == 0 {
            println!("{} {}", 1, t);
        } else {
            println!("{} {}", ds, ds + t);
        }
    } else {
        println!("{} {}", ds, ds + t);
    }
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
    int n, x, l,i=0, d[100];
    cin >> n >> x;
   while(cin>>l){
       d[i+1] = d[i] + l;
       if(d[i+1]>x){break;}
       i++;
   }
    cout << i+1 << "\n";
    return 0;
}

Measured memory_bytes: 256
// -_-
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mod 1000000007
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long , long long> pll;
 
int main() 
{

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

    int h, w, d;
    cin >> h >> w >> d;
    map <int, pii> mp;
    int a[h+1][w+1], flag[1000000] = {}, vis[1000000] = {}, ans[1000000] = {};
    vi vec;

    fori(i, 1, h)
    {
    	fori(j, 1, w) 
    	{
    		cin >> a[i][j];
    		vec.pb(a[i][j]);
    		mp[a[i][j]] = {i, j};
    		flag[a[i][j]] = 1;
    	}
    }
    sort(vec.begin(), vec.end());

    fori(i, 0, vec.size()-1)
    {
    	if(vis[vec[i]] == 0)
    	{
    		vis[vec[i]] = 1;
    		int j = vec[i] + d;
    		int s = 0;
    		while(flag[j] == 1)
    		{
    			vis[j] = 1;
    			s = s + abs(mp[j-d].fi - mp[j].fi) + abs(mp[j-d].se - mp[j].se);
    			ans[j] = s;
    			j += d;
    			if(j > h*w) break;
    		}
     	}
    }

    int q, l, r;
    cin >> q;
    fori(i, 1, q)
    {
    	cin >> l >> r;
    	cout << ans[r] - ans[l] << endl;
    }

	return 0;
}


Measured memory_bytes: 20728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll x;
  cin >> x;
  ll ans = 0;
  double c = 100;
  while (c < x) {
    c = floor(c * 1.01);
    ans++;
  }
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;


int main() {
  lint n; cin >> n;
  lint a[n];
  bool flg = true;
  rep(i, n){
    cin >> a[i];
    if (a[i] % 2 == 1){
      flg = false;
      break;
    }
  }
  if (flg){
      cout << "second" << endl; 
    }
    else{
      cout << "first" << endl;
    }
}



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

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, i, j;
	scanf("%d", &N);
	char **s = (char **)malloc(sizeof(char *) * N);
	int *L = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		s[i] = (char *)malloc(sizeof(char) * 11);
		scanf("%s", s[i]);
		for(j = 0; s[i][j] != '\0'; j++);
		L[i] = j;
	}
	int count = 0, A = 0, B = 0, B_A = 0;
	for(i = 0; i < N; i++){
		for(j = 1; j < L[i]; j++){
			if(s[i][j - 1] == 'A' && s[i][j] == 'B'){
				count++;
			}
		}
		if(s[i][0] == 'B'){
			B++;
		}
		if(s[i][L[i] - 1] == 'A'){
			A++;
		}
		if(s[i][0] == 'B' && s[i][L[i] - 1] == 'A'){
			B_A++;
		}
	}
	if(A != B){
		printf("%d\n", count + min(A, B));
	}
	else if(A == 0){
		printf("%d\n", count);
	}
	else if(A == B_A){
		printf("%d\n", count + A - 1);
	}
	else{
		printf("%d\n", count + A);
	}
	return 0;
}

Measured memory_bytes: 640
class nCrMod():
    def __init__(self, mod):
        self.mod = mod
        self.fac = [1, 1]
        self.finv = [1, 1]
        self.inv = [0, 1]

    def prep(self, n):
        mod = self.mod
        f, fi = self.fac[-1], self.finv[-1]
        for i in range(len(self.fac), n + 1):
            fn = f * i % mod
            v = -self.inv[mod % i] * (mod // i) % mod
            fin = fi * v % mod
            f, fi = fn, fin
            self.fac.append(f)
            self.finv.append(fi)
            self.inv.append(v)

    def __call__(self, n, r):
        if len(self.fac) <= n:
            self.prep(n)
        return self.fac[n] * self.finv[r] * self.finv[n - r] % self.mod

def main():
    H, W, A, B = map(int, input().split())
    mod = 10 ** 9 + 7
    nCr = nCrMod(mod)
    r = 0
    a = H - A - 1
    for i in range(B, W):
        r = (r + nCr(a + i, i) * nCr(A - 1 + W - i - 1, W - i - 1)) % mod
    return r


print(main())


Measured memory_bytes: 25780
import java.util.Scanner;
class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if(a < b){
			System.out.println("a < b");
		}else if(a > b){
			System.out.println("a > b");
		}else{
				System.out.println("a == b");
		}
	}
}

Measured memory_bytes: 26404
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      ans += d[i] * d[j];
	}
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 256
///----> bismillahir rahmanir rahim <---- -- { ^ _ ^ }
///     { ^_^ }   { ^ _ ^ }
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;

//<--------------------------------------------typo section--------------------------------------------->
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
typedef priority_queue<int>piwi;
typedef queue<int>kiwi;
typedef map<int,int>mi;
typedef map<string,int>mis;
typedef multimap<int,int>muli;
typedef multimap<string,int>muls;
typedef multiset<int>si;

//<----------------------------------------------------Narcos----------------------------------------------->
#define endl "\n"
#define Y cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define sp " "
#define PB push_back
#define F first
#define S second
#define as(a) (a).begin(),(a).end()
#define ras(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define ki 1LL
#define MOD 1000000007
#define over return 0;
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define test int t;cin>>t;while(t--)


//<-----------------------------------------------------Const--------------------------------------------------->
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


//<--------------------------------------------------------------------------------------------------->
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

const long long MAX_SIZE = 1000001; vector<long long >isprime(MAX_SIZE , true); vector<long long >prime; vector<long long >SPF(MAX_SIZE); void manipulated_seive(int N) { isprime[0] = isprime[1] = false ; for (long long int i=2; i<N ; i++) { if (isprime[i]) { prime.push_back(i); SPF[i] = i; } for(int j=0;j < (int)prime.size() && i*prime[j] < N && prime[j] <= SPF[i]; j++) { isprime[i*prime[j]]=false; SPF[i*prime[j]] = prime[j] ; } } }
int man_seive(int n){ manipulated_seive(n); for(int i=0;i<prime.size() && prime[i]<=n;i++)
cout<<prime[i]<<endl;
}
ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

//continue;

//-----------------------------> YOUR JOURNEY STARTS HERE ------------------------------------>>

int main(){
    optimize();
  vii v;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
    int a;cin>>a;
    v.PB({a,i});
  }
  sort(v.begin(),v.end());
  for(auto e: v){
    cout<<e.second<<" ";
  }
  cout<<endl;

over
}


Measured memory_bytes: 19872
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <algorithm>
#include <queue>
using namespace std;
//for (int i = 0; i < N; i++){}
//for (int j = 0; j < M; j++){}

int main() {
    int A, B, T;
    cin >> A >> B >> T;


    int sums = 0;
    for (int i = 1; i <= T+0.5; i++){
        if(A*i <= T+0.5){
            sums += B;
        }else{
            break;
        }
    }
    cout << sums << endl;
}

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

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getkey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  long long key,i = 0,h;
  key = getkey(str);
  while(i < M){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(H[h][0] == '\0') return 0;
    i++;
  }
  return 0;
}

void insert(char str[]){
    long long key,i = 0,h;
    key = getkey(str);
    while(i < M){
      h = (h1(key) + i * h2(key)) % M;
      if(H[h][0] == '\0'){
        strcpy(H[h],str);
        break;
      }
      i++;
    }
}

int main(){
    int i, n, h, k = 0;
    char str[L], com[9], display[500000][4];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		      strcpy(display[k],"yes");
          k++;
	    } else {
		      strcpy(display[k],"no");
          k++;
	    }
	}
    }

    for(i = 0;i < k;i++){
      printf("%s\n",display[i]);
    }

    return 0;
}



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

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int nums = sc.nextInt();
        int sum = 0;
        int[] list = new int[nums];
        for(int i = 0; i < nums; i++){
            int num =  sc.nextInt();
            list[i]= num;
        }
        Arrays.sort(list);
        for(int k = 0; k < list.length; k++){
            int a = list[k];
            for (int i = k+1; i < list.length ; i++) {
                int b = list[i];
                for (int j = i+1; j < list.length; j++) {
                   int c = list[j];
                   if(c < a + b){
                       sum++;
                   }else{
                       break;
                   }
                }
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 26336
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s; cin >> s;
  bool ok = true;
  int n = s.size();
  REP(i, n / 2)if (s[i] != s[n - i - 1])ok = false;
  REP(i, n/4)if (s[i] != s[n / 2 - 1 - i])ok = false;
  REP(i, n / 4)if (s[i + n / 2 + 1] != s[n - i - 1])ok = false;
  if (ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "string"


int main()
{
	int n, tscore = 0, hscore = 0;
	std::string tcard, hcard;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> tcard >> hcard;
		if (tcard == hcard) {
			hscore++;
			tscore++;
		}
		else if (tcard < hcard)
			hscore += 3;
		else
			tscore += 3;
	}
	std::cout << tscore << " " << hscore << std::endl;
    return 0;
}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    rep(i, n) cout << a[i] << (i == n-1 ? '\n' : ' ');
}



Measured memory_bytes: 10732
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a[] = new int[7];
        int b[] = new int[7];
        int c[] = new int[7];
        for (int i = 0; i < 7; i++) {
            a[i] = scanner.nextInt();
            b[i] = scanner.nextInt();
            c[i] = a[i] - b[i];
        }
        for (int i = 0; i < 7; i++) {
            System.out.println(c[i]);
        }
    }
}



Measured memory_bytes: 26172
#!/usr/bin/env python3
import bisect
import heapq
import itertools
import math
import numpy as np
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n,m,x = MI()
li = LLI(n)
ans=[]
for bit in range(1<<n):
    money = 0
    understand_li = [0]*m
    b = True
    for i in range(n):
        if ((bit >> i) & 1):
            money += li[i][0]
            for j in range(m):
              understand_li[j] += li[i][j+1]
    for k in range(m):
        if understand_li[k] < x:
            b = False
    if b == True:
        ans.append(money)
if len(ans) == 0:
    print(-1)
else:
    print(min(ans))


Measured memory_bytes: 27288
#include <iostream>
#include <array>
#include <algorithm>

int main()
{
    int N;
    std::cin >> N;
    std::array<int, 101> D;
    for(int i = 0; i < N; i++)
    {
        std::cin >> D.at(i);
    }
    std::sort(D.begin(), D.begin() + N);
    int count = 1;
    int onaji = D.at(0);
    for(int i = 0; i < N; i++)
    {
        if(D.at(i) != onaji)
        {
            count++;
            onaji = D.at(i);
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 256
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN];

void solve(){
    cin>>n;
    ll ans=n/500*1000;
    n-=n/500*500;
    cout<<ans+n/5*5;
}



int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 256
N,M = [int(x) for x in input().split()]
ks = [[int(x) for x in input().split()] for _ in range(M)]
p = [int(x) for x in input().split()]
li = []

for i in ks:
    n = 0
    for j in i[1:]:
        n += 1<<(j-1)
    li.append(n)

cnt = 0

for i in range(1<<N):
    flag = True
    for ind,j in enumerate(li):
        if(bin(j&i)[2:].count(str(1))%2 == p[ind]):
            pass
        else:
            flag = False
    if(flag):
        cnt += 1
print(cnt)


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();

		String[] SArray = S.split("");
		ArrayList<String> SList = new ArrayList<>();
		ArrayList<String> SList2 = new ArrayList<>();
		ArrayList<String> SList3 = new ArrayList<>();

		for(int i = 0; i<SArray.length; i++) {
			SList.add(SArray[i]);
		}
		int a = SList.size();

		for(int i = 0; i<(SList.size()-1)/2; i++) {
			SList2.add(SList.get(i));
		}

		for(int i = (SList.size()+3)/2-1; i < a; i++){
			SList3.add(SList.get(i));
		}





		if(check1(SList)) {
			if(SList2.size()%2==1) {
				if(check1(SList2)) {
					if(SList3.size()%2==1) {
						if(check1(SList3)) {
							System.out.println("Yes");
						}else {
							System.out.println("No");
						}
					}else {
						if(check2(SList3)) {
							System.out.println("Yes");
						}else {
							System.out.println("No");
						}
					}
				}else {
					System.out.println("No");
				}
			}else {
				if(check2(SList2)) {
					if(SList3.size()%2==1) {
						if(check1(SList3)) {
							System.out.println("Yes");
						}else {
							System.out.println("No");
						}
					}else {
						if(check2(SList3)) {
							System.out.println("Yes");
						}else {
							System.out.println("No");
						}
					}
				}else {
					System.out.println("No");
				}
			}
		}else{
			System.out.println("No");
		};




	}

	public static boolean check1(ArrayList<String> a) {
		for(int i = 0 ; i<(a.size()-1)/2; i++) {
			if(a.get(i).equals(a.get(a.size()-i-1)) == false){
				return false;
			}
		}
		return true;
	}

	public static boolean check2(ArrayList<String> a ) {
		for(int i = 0; i<a.size()/2; i++) {
			if(a.get(i).equals(a.get(a.size()-i-1))==false) {
				return false;
			}
		}
		return true;
	}
}

Measured memory_bytes: 22612
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);/*cin.tie(0); cout.tie(0);*/
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000000

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}      
  private:
    bool first;
    string separator;
};
 
template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll n;
ll nac,konec;
ll massiv[MAXN];
ll rast=0;
int main(){
FAST_READ;
cin>>n;
cin>>nac;
massiv[1]=nac;
rast+=abs(massiv[1]);
ll pred=massiv[1];
for(ll i=2;i<n;i++)
{
  cin>>massiv[i];
  rast+=(abs(massiv[i]-pred));
  //debug(abs(massiv[i]-pred),pred,massiv[i]);
  pred=massiv[i];
}
cin>>konec;
rast+=(abs(pred-konec));
massiv[n]=konec;
rast+=abs(konec);
ll ns=rast;
//deb(ns);
for(ll i=1;i<=n;i++)
{
  ns=rast;
  ns-=(abs(massiv[i]-massiv[i+1]));
  ns-=(abs(massiv[i]-massiv[i-1]));
  ns+=(abs(massiv[i-1]-massiv[i+1]));
  cout<<ns<<endl;
}





return 0;
} 

Measured memory_bytes: 2048
#include<stdio.h>

int
main()
{
      int a[10], i, b[3], temp, j;
      
      for(i=0;i<10;i++)
      {
         scanf("%d", &a[i]);
      }
      for(i=0;i<10;i++)
      {
         for(j=0;j<10;j++)
         {
            if(a[j+1] > a[j] )
            {
               temp = a[j+1];
               a[j+1] = a[j];
               a[j] = temp;
            }
         }
      }
      for(i=0;i<3;i++)
      {
         printf("%d\n", a[i]);
      }

return 0;
}

Measured memory_bytes: 600
#include<iostream>
int main(void){
    int n,m;
    std::cin>>n>>m;
    int A[n][m]={};
    int b[m]={};
    int c[n]={};
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            std::cin>>A[i][j];
        }
    }
    for(i=0;i<m;i++)
         std::cin>>b[i];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            c[i]+=A[i][j]*b[j];
        }
        std::cout<<c[i]<<std::endl;
    }
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
#define int long long
#define All(v) (v.begin(),v.end())
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}
signed main(){
	string s;
	cin>>s;
	if(s=="ani")puts("square1001");
	else puts("e869120");
	return 0;
}




Measured memory_bytes: 3148
#include<iostream>
#include<cstdio>
#include<queue>
const int N=1005,INF=1e9;
int d[N][N];
int n,m;
char s[N][N];
typedef std::pair<int,int> P;
const int fx[4]={0,0,1,-1};
const int fy[4]={1,-1,0,0};
int main() {
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    int ans=0;
    std::queue<P> q;
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) {
        if(s[i][j]=='.') d[i][j]=INF;
        else d[i][j]=0,q.push(P(i,j));
    }
    while(!q.empty()) {
        P c=q.front();q.pop();
        for(int i=0;i<4;i++) {
            int x=c.first+fx[i],y=c.second+fy[i];
            if(x<1||x>n||y<1||y>m||d[x][y]<=d[c.first][c.second]+1) continue;
            d[x][y]=d[c.first][c.second]+1;
            q.push(P(x,y));
        }
    }
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) ans=std::max(ans,d[i][j]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 13328
import math
A, B, H, M = map(int, input().split()) 

rad_h = ( H/12 + M/(12*60) ) *( 2 * math.pi)
rad_m = ( M/60 )* ( 2 * math.pi)

rad = abs(rad_h - rad_m)

r = math.sqrt( A*A + B*B -2*A*B*math.cos(rad) )

print(r)


Measured memory_bytes: 62532
d = gets.to_i
d.times do |i|
    n = gets.to_i
    a = Array.new(n).map { Array.new(n, 0) }
    a.map! {|r| [9] + r + [9]}
    a.unshift [9] * (n + 2)
    a<< [9] * (n + 2)
    y = n
    x = 1
    dy = -1
    dx = 0
    loop do
        a[y][x] = 1
        if a[y + dy][x + dx] == 0
            a[y + dx][x - dy] = 9
            y += dy
            x += dx
        else
            dy, dx = dx, -dy
            if a[y + dy][x + dx] == 0
                a[y - dx][x + dy] = 9
                y += dy
                x += dx
            else
                break
            end
        end
    end
    a[1..-2].each do |r|
        puts r[1..-2].map {|x| x == 1 ? '#' : ' '} * ''
    end
    puts if i < d - 1
end



Measured memory_bytes: 7368
#include<stdio.h>

int main(void){

    int a,b,c,z;

    scanf("%d %d %d",&a,&b,&c);

    if(a>b){
       z=a;
       a=b;
       b=z;
    }
    if(b>c){
       z=b;
       b=c;
       c=z;
    }
    if(a>b){
       z=a;
       a=b;
       b=z;
     }

    printf("%d %d %d\n",a,b,c);

    return 0;

}

Measured memory_bytes: 1816
#include <bits/stdc++.h>
#define ll long long
#define MOD 998244353LL

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if(u < 0) u += m;
  return u;
}

ll fact[200001];
ll C(ll n, ll r) {
  if(n < r) return 0;
  return fact[n] * modinv(fact[r]) % MOD * modinv(fact[n - r]) % MOD;
}
ll H(ll n, ll r) { return C(n + r - 1, r); }

int main() {
  fact[0] = 1;
  for(int i = 1; i < 200001; i++) fact[i] = fact[i - 1] * i % MOD;
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  vector<ll> dp(n + 1);
  dp[1] = m;
  ll o = 0;
  if(k == n - 1) o += m;
  for(int i = 1; i < n; i++) {
    dp[i + 1] = dp[i] * (m - 1) % MOD;
    if(i + 1 >= n - k) o = (o + dp[i + 1] * H(i + 1, n - i - 1) % MOD) % MOD;
  }
  printf("%lld\n", o);
}

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



void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}

int gcd(int a,int b){
  if(a<b){
    swap(&a,&b);
  }

  if(b==0){
    return a;
  }

  int r=a%b;
  while(r!=0){
    a = b;
    b = r;
    r = (a%b);
  }

  return b;
}

/* クイックソート */
int dn(const void*a,const void*b){return*(int*)b-*(int*)a;}


long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  long int n;
  scanf("%ld",&n);

  long int ans=0;
  long int m=0;

  for(int i=0;i<n;i++){
    long int now;
    scanf("%ld",&now);

    if(now>m){
      m=now;
    }
    else{
      ans+=(m-now);
    }
  }

  printf("%ld\n",ans);

  return 0;
}

Measured memory_bytes: 1732
// 152 B - Comparing Strings 2020/01/19

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int a, b;
    cin >> a >> b;
    string s1,s2;
    rep(i ,b){
        s1+=to_string(a);
    }
    rep(i ,a){
        s2+=to_string(b);
    }
    if(s1 >= s2) cout << s2;
    else cout << s1;
    cout << endl;
}

Measured memory_bytes: 256
a, b, x = gets.split.map(&:to_f)
s = 2.0 * x / (b * a)
if s > a
  p Math.atan(2.0 * (b * a * a - x) / (a * a * a)) * 180 / Math::PI
else
  p Math.atan(b * b * a / (2.0 * x)) * 180 / Math::PI
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define debug1(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout << #x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define pb push_back
#define mp make_pair
#define f first
#define s second

typedef long long ll;
using namespace std;

void readFile() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

ll binpow(ll a,ll b) {    // a^b
    if(b==0) return 1;
    long long res = binpow(a,b/2);
    if(b%2)
        return res*res*a;
    else
        return res*res;
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int l=0,r=n-1;
    int ans{};
    for(;l<r;) {
        if(s[l]=='W' && s[r]=='R') {
            ans++;l++;r--;
        }
        else if(s[l]=='R')
            l++;
        else if(s[r]=='W')
            r--;
    }
    cout << ans << endl;
    return 0;
}


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

void fnInsertionSort(vector<int> &rvnSort, int nGap, int &rnSortCnt)
{
  for (int nSorting = nGap; nSorting < rvnSort.size() ; nSorting++)
  {
    int nTrg = rvnSort[nSorting];
    int nSorted = nSorting - nGap;

    while (nSorted >= 0         &&
           nTrg < rvnSort[nSorted])
    {
      rvnSort[nSorted + nGap] = rvnSort[nSorted];
      nSorted -= nGap;

      rnSortCnt++;
    }
    rvnSort[nSorted + nGap] = nTrg;
  }
}

void fnShellSort(vector<int> &rvnSort, vector<int> &rvnGap, int &rnSortCnt)
{
  for (int nGap = 1; nGap <= rvnSort.size(); nGap = 3 * nGap + 1)
    rvnGap.push_back(nGap);
  
  for (int i = rvnGap.size() - 1; i >= 0; i--)
    fnInsertionSort(rvnSort, rvnGap[i], rnSortCnt);
}

void fnOutput(const vector<int> &cnrvnSort, const vector<int> &cnrvnGap, int nSortCnt)
{
  cout << cnrvnGap.size() << endl;

  for (int i = cnrvnGap.size() - 1; i >= 0; i--)
  {
    if (i != cnrvnGap.size() - 1) cout << " ";
    cout << cnrvnGap[i];
  }
  cout << endl;

  cout << nSortCnt << endl;

  for (int i = 0; i < cnrvnSort.size(); i++)
    cout << cnrvnSort[i] << endl;
}

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

  vector<int> vnSort;
  vector<int> vnGap;
  int nSortCnt = 0;
  int nMaxSiz;
  
  cin >> nMaxSiz;
  for (int i = 0; i < nMaxSiz; i++)
  {
    int nNum;
    cin >> nNum;
    vnSort.push_back(nNum);
  }

  fnShellSort(vnSort, vnGap, nSortCnt);
  fnOutput(vnSort, vnGap, nSortCnt);

  return 0;
}

Measured memory_bytes: 5680
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
















int main(){
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h){
        cin >> s[i];
    }
    vector<vector<ll>> dp(h, vector<ll>(w, INF));
    dp[0][0] = s[0][0] == '#';
    REP(i, h){
        REP(j, w){
            if(i < h - 1) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + (s[i][j] == '.' && s[i + 1][j] == '#'));
            if(j < w - 1) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + (s[i][j] == '.' && s[i][j + 1] == '#'));
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
d,n = map(int,input().split())
if d == 0:
    if n != 100:
        print(n)
    else:
        print(101)
elif d == 1:
    if n != 100:
        print(n*100)
    else:
        print(n*101)
else:
    if n != 100:
        print(n*10000)
    else:
        print(n*10100)


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

using namespace std;

int main(){
    long long int a;
    double b;
    long long int seki;
    cin>>a>>b;

    long long int c=((b+0.001)*100);
    seki=(a*c)/100;

    cout<<(long long int)(seki)<<endl;

}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
	int n;
	int a[10000];
	long int min = 1000000, max = -1000000, sum = 0;

	scanf("%d", &n);
	if (n == 0){
		printf("%ld %ld %ld\n", 0, 0, 0);
		return 0;
	}

	for (int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if (min > a[i])min = a[i];
		if (max < a[i])max = a[i];
		sum += a[i];
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}


Measured memory_bytes: 2780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;

namespace ConsoleApp112 {
    class Program {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] inputArr = input.Split(' ');

            int a = int.Parse(inputArr[0]);
            int b = int.Parse(inputArr[1]);

            int sum = 0;
            for (int i = 0; i < 2; i++)
            {
                if (a > b)
                {
                    sum += a;
                    a -= 1;
                }
                else
                {
                    sum += b;
                    b -= 1;
                }
            }
            Console.WriteLine(sum);
        }
    }
}

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

using namespace std;

int main(){
  int n, x, y;
  std::cin >> n >> x >> y;

  vector<vector<int> > graph(n);
  for(int idx = 1; idx < n; idx++){
    graph[idx - 1].push_back(idx);
    graph[idx].push_back(idx - 1);
  }
  graph[x - 1].push_back(y - 1);
  graph[y - 1].push_back(x - 1);

  vector<int> ans(n, 0);
  for(int idx = 0; idx < n; idx++){
    queue<int> todo;
    vector<bool> seen(n, false);
    seen[idx] = true;
    vector<int> dist(n, INT_MAX);
    dist[idx] = 0;
    for(int i = 0 ; i < graph[idx].size(); i++){
      todo.push(graph[idx][i]);
      dist[graph[idx][i]] = 1;
    }
    while(!todo.empty()){
      int vertec = todo.front();
      todo.pop();
      if(!seen[vertec]){
        seen[vertec] = true;
        for(int i = 0 ; i < graph[vertec].size(); i++){
          todo.push(graph[vertec][i]);
          if(dist[graph[vertec][i]] > dist[vertec] + 1){
            dist[graph[vertec][i]] = dist[vertec] + 1;
          }
        }
      }
    }
    for(int i = 0; i < n; i++){
      ans[dist[i]] += 1;
      // std::cerr << "from:" << idx << " to:" << i << " distance:" << dist[i] << '\n';
    }
    // std::cerr << '\n' << '\n';
  }
  for(int idx = 0; idx < n; idx++) ans[idx] /= 2;
  for(int idx = 1; idx < n; idx++){
    std::cout << ans[idx] << '\n';
  }
  return 0;
}


Measured memory_bytes: 384
N, D = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(N)]
c = 0
for i in range(N):
  for j in range(i+1, N):
    S = 0
    for p in range(D):
      S  += (m[i][p]-m[j][p])**2

    if (S**0.5-int(S**0.5)) == 0:
      c += 1
print(c)

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>

using namespace std;

struct CODE
{
	char before;
	char after;
};

int main(void)
{
	int n;
	
	while (scanf("%d", &n) * n != 0){
		vector<CODE> code;
		vector<char> str;
		
		while (n-- > 0){
			CODE c;
			scanf(" %c %c", &c.before, &c.after);
			code.push_back(c);
		}
		
		int m;
		scanf("%d", &m);
		while (m-- > 0){
			char c;
			
			scanf(" %c", &c);
			for (int i = 0; i < code.size(); i++){
				if (c == code[i].before){
					c = code[i].after;
					break;
				}
			}
			str.push_back(c);
		}
		for (int i = 0; i < str.size(); i++){
			putchar(str[i]);
		}
		puts("");
	}
	
	return 0;
}

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

int main () {
  char A[200] , B[200] ;
  scanf("%s",A) ;
  scanf("%s",B) ;
  sort(A,A+strlen(A)) ;
  sort(B,B+strlen(B)) ;
  reverse(B,B+strlen(B)) ;
  if(strcmp(A,B)<0) cout << "Yes" << endl ;
  else cout << "No" << endl ;
}

Measured memory_bytes: 256
n = int(input())
a = list(input().split(' '))
# print(n, a)
def doit(n,a):
  m = 1
  for i in range(n):
    m = m*int(a[i])
    if m > 1000000000000000000:
        for y in range(i+1, n):
            if a[y] == '0':
                return 0
        return -1
    elif m==0:
        return 0

#   if m > 1000000000000000000:
#     return -1
  return m
 
print(doit(n,a))


Measured memory_bytes: 19540