akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// using namespace __gnu_pbds;
// #include <ext/pb_ds/assoc_container.hpp>
// typedef tree<int,null_type,less<int>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define sorts(v) sort(v.begin(),v.end())
#define sortg(v) sort(v.begin(),v.end(),greater<ll>())
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)

void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   rep(i,n)cin>>a[i];
//    sort(a,a+n);
   ll ans=0;
   rep(i,n-2){
      f(j,i+1,n-1){
           f(k,j+1,n)
           {
               if((a[i]+a[j]>a[k])&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]){
                   ans++;
                //    cout<<
               }
           }
       }
   }
   cout<<ans<<'\n';
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    if (n%2==1) {
        cout << "No" << endl;
        return 0;
    }
    int m = n/2;
    rep(i,m) {
        if (s[i]!=s[i+m]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll a1 = a * c;
    ll a2 = b * c;
    ll a3 = a * d;
    ll a4 = b * d;
    ll a12 = (a1 > a2) ? a1 : a2;
    ll a34 = (a3 > a4) ? a3 : a4;
    ll r = (a12 > a34) ? a12 : a34;

    cout << r << endl; 
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), V(N);
  for (int i=0; i<N; i++) {
    cin >> X[i];
    V[i]=X[i];
  }
  sort(V.begin(), V.end());
  for (int i=0; i<N; i++) {
    if (X[i]<V[N/2]) {
      cout << V[N/2] << endl;
    }
    else {
      cout << V[N/2-1] << endl;
    }
  }
}


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

def convert(ss):
    if ss == 0:
        return "S"
    else:
        return "W"


def solve(N: int, s: str):
    animals = [0]*N
    ## 0 がひつじ 1が狼を表す
    init = [(0,1),(1,0),(0,0),(1,1)]

    for first,second in init:
        animals[0] = first
        animals[1] = second

        for j in range(1,N):
            ## 最後にたどり着いたとき
            if j == N-1:
                if animals[j] == 0:
                    if s[j] == "o":
                        if animals[j-1] != animals[0]:
                            break
                    else:
                       if animals[j-1] == animals[0]:
                            break
                elif animals[j] == 1:
                    if s[j] == "o":
                        if animals[j-1] == animals[0]:
                            break
                    else:
                       if animals[j-1] != animals[0]:
                            break

                if animals[0] == 0:
                    if s[0] == "o":
                        if animals[N-1] != animals[1]:
                            break
                    else:
                       if animals[N-1] == animals[1]:
                            break
                elif animals[0] == 1:
                    if s[0] == "o":
                        if animals[N-1] == animals[1]:
                            break
                    else:
                       if animals[N-1] != animals[1]:
                            break
                
                print(''.join(list(map(convert,animals))))
                return

            if animals[j] == 0:
                if s[j] == "o":
                    animals[j+1] = animals[j-1]
                else:
                    animals[j+1] = 1^animals[j-1]
            elif animals[j] == 1:
                if s[j] == "o":
                    animals[j+1] = 1^animals[j-1]
                else:
                    animals[j+1] = animals[j-1]    

    print(-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(N, s)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5108
let s = stdin.ReadLine()

let check1 = s |> Seq.distinct |> Seq.length |> (=) 2
let check2 = Seq.filter ((=) s.[0]) s |> Seq.length |> (=) 2

if check1 && check2 then "Yes" else "No"
|> printfn "%s"


Measured memory_bytes: 14940
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long
#define ld double
#define ull unsigned long long
#define PI pair < int, int > 

const int N = 1e6 + 123;
const int M = 123;
const ld Pi = acos(-1);
const ll Inf = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int Sz = 501;
const int MOD = 1e9 + 7;

void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
int mult(int a, int b) {
  return 1ll * a * b % mod;
}
int sum(int a, int b) {
  add(a, b);
  return a;
}

int n, a[N], l, r, ans[N];

void solve() {
  cin >> n;
  for (int i = 1;i <= n;i++) {
    cin >> a[i];
  }
  l = 1, r = n;
  reverse(a + 1, a + n + 1);
  for (int i = 1;i <= n;i++) {
    if (i & 1) ans[l++] = a[i];
    else ans[r--] = a[i];
  }
  for (int i = 1;i <= n;i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}

int main() {
  #ifdef wws
   freopen("in", "r", stdin);
  // freopen("out", "w", stdout);
  #endif 
  ios_base::sync_with_stdio(0);
  int tt = 1; 
  while(tt--) solve();
  return 0;
}

Measured memory_bytes: 7040
var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function (line) {
  var i,cnt=0;
  var a = line.split(' ');
  var c = parseInt(a[0],10);
  var d = parseInt(a[1],10);
  var e = parseInt(a[2],10);
  for(i=c;i<=d;i++){
    if(e%i==0)
      cnt = cnt + 1;
  }
  console.log(cnt);
  process.exit();
});
process.stdin.on('end', function () {
});

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

int main(void){
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    A[n - 1] /= 2;
    int ans = 0;
    for (int i = 0; i < n; i++) ans += A[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, Q;
	cin >> N >> Q;

	string s;
	cin >> s;

	vector<vector<Int>> lr(Q, vector<Int>(2, 0));
	for (Int i = 0; i < Q; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> lr[i][j];
			lr[i][j]--;//0Indexed
		}
	}

	//配列acの作成
	vector<Int> ac(N, 0);
	for (Int i = 0; i < N-1; i++) {
		if (i == 0) {
			if (s[0] == 'A' && s[1] == 'C') {
				ac[0] = 1;
				continue;
			}
			else continue;
		}

		else if (s[i] == 'A') {
			if (s[i + 1] == 'C') {
				ac[i] = ac[i - 1] + 1;
				continue;
			}
			else {
				ac[i] = ac[i - 1];
				continue;
			}
		}
		
		//else {
			ac[i] = ac[i - 1];
			continue;
		//}
	}
	ac[N - 1] = ac[N - 2];

	//解の出力
	Int ans = 0;
	for (Int i = 0; i < Q; i++) {
		if (lr[i][0] == 0) {//区間の左端が0番目の場合
			ans = ac[lr[i][1]];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
			continue;
		}

		else {
			ans = ac[lr[i][1]] - ac[lr[i][0] - 1];
			if ((lr[i][1] != N - 1) && (s[lr[i][1] + 1] == 'C') && (s[lr[i][1]] == 'A')) {
				ans = max(0LL, ans - 1);
			}
			printf("%lld\n", ans);
		}
	}

}




Measured memory_bytes: 7248
N = int(input())
P = [int(input()) for i in range(N)]


ans = 0
p = max(P)
last = 1
for i, v in enumerate(P):
    if v == p and last == 1:
        ans += int(v / 2)
        last -= 1
    else:
        ans += v


print(ans)

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

using namespace std;

template< typename T >
struct SkewHeap
{
  struct Node
  {
    T key, lazy;
    Node *l, *r;
  } *root = nullptr;
  bool rev;

  SkewHeap(bool rev = false) : rev(rev) {}

  Node *propagate(Node *t)
  {
    if(t->lazy != 0) {
      if(t->l) t->l->lazy += t->lazy;
      if(t->r) t->r->lazy += t->lazy;
      t->key += t->lazy;
      t->lazy = 0;
    }
    return t;
  }

  Node *merge(Node *x, Node *y)
  {
    if(!x || !y) return x ? x : y;
    propagate(x), propagate(y);
    if((x->key > y->key) ^ rev) swap(x, y);
    x->r = merge(y, x->r);
    swap(x->l, x->r);
    return x;
  }

  Node *push(const T &key)
  {
    auto t = new Node({key, 0, nullptr, nullptr});
    root = merge(root, t);
  }

  T top()
  {
    return propagate(root)->key;
  }

  void pop()
  {
    propagate(root);
    auto *temp = root;
    root = merge(root->l, root->r);
    delete temp;
  }

  bool empty() const
  {
    return !root;
  }

  void add(const T &lazy)
  {
    if(root) {
      root->lazy += lazy;
      propagate(root);
    }
  }

  void merge(SkewHeap< T > &p)
  {
    root = merge(root, p.root);
  }
};

int main()
{
  char buff[100];
  int key;

  SkewHeap< int > que(true);
  for(;;) {
    scanf("%s", buff);
    if(buff[0] == 'e' && buff[1] == 'n') break;
    if(buff[0] == 'i') {
      scanf("%d", &key);
      que.push(key);
    } else {
      printf("%d\n", que.top());
      que.pop();
    }
  }
}


Measured memory_bytes: 34376
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

use std::collections::HashSet;

fn main() {
    input! {
        A: u64,
        B: u64,
        C: u64,
    }

    let mut N = A;
    let mut set = HashSet::new();
    while (N < 10000000000000) {
        let R = N % B;
        if set.contains(&R) {
            println!("NO");
            std::process::exit(0);
        }
        if R == C {
            println!("YES");
            std::process::exit(0);
        }
        set.insert(R);

        N = N + A;
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	// mahakal();fast;

	int n;
    scanf("%d",&n);
    int vector[n];
    for(int i=0;i<n;i++){
        scanf("%d",&vector[i]);
    }
    int small=n+1;
    int count=0;
    for(int i=0;i<n;i++){
        small=min(small,vector[i]);
        if(small==vector[i]){
            count++;
        }
    }
    printf("%d",count);
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
cur = a[0]
ans += b[cur-1]
for i in range(1,n):
  pre,cur = cur,a[i]
  if cur == pre+1:
    ans += b[cur-1] + c[cur-2]
  else:
    ans += b[cur-1]
print(ans)

Measured memory_bytes: 3064
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int h, w;
string s[200];
int d[200][200];

int main(){
  cin >> h >> w;
  rep(i, h) cin >> s[i];
  int sx, sy;
  rep(i, h) rep(j, w) if (s[i][j] == '%') sx = i, sy = j;
  fill_n(*d, 200 * 200, inf);
  queue<pair<int, int>> q;
  d[sx][sy] = 0;
  q.emplace(sx, sy);
  while (q.size()){
    int x, y;
    tie(x, y) = q.front(), q.pop();
    rep(i, 4){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (s[nx][ny] == '#') continue;
      if (d[nx][ny] > d[x][y] + 1){
        d[nx][ny] = d[x][y] + 1;
        q.emplace(nx, ny);
      }
    }
  }
  int a, b = inf;
  rep(i, h) rep(j, w){
    if (s[i][j] == '@') a = d[i][j];
    if (s[i][j] == '$') chmin(b, d[i][j]);
  }
  cout << (a < b ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3392
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MP make_pair
#define fi first
#define se second 
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=2010;
struct node{
	int to,next;
};node edge[N*2];
int graph[N],tot;
int fa[N],father[N][17],dep[N];
int a[N],b[N],lca[N];
int f[N][2],c[N];
int ans[N];int vis[N];
vector<int> vec[N];
int n,m;int ANS;

void addedge(int i,int x,int y){
	edge[i].to=y;edge[i].next=graph[x];graph[x]=i;
}

int LCA(int x,int y){
	if(dep[x]<dep[y])	swap(x,y);
	int i,delta=dep[x]-dep[y];
	rep(i,0,15)	if(1<<i&delta)	x=father[x][i];
	if(x==y)	return x;
	for(i=15;i>=0;i--)	if(father[x][i]!=father[y][i])	{x=father[x][i];y=father[y][i];}
	return father[x][0];
}

void dfs(int x){
	int i,y;
	for(i=graph[x];i;i=edge[i].next){
		y=edge[i].to;
		if(y==fa[x])	continue;
		fa[y]=x;father[y][0]=x;dep[y]=dep[x]+1;
		dfs(y);
	}
}

void add(int x,int y,int id){
	while(x!=y)	{c[x]++;vec[x].pb(id);x=fa[x];}
}

void modify(int i,int ty){
	int x,y;
	x=a[i];y=lca[i];
	while(x!=y){c[x]--;f[x][0^ty]++;x=fa[x];}
	x=b[i];y=lca[i];
	while(x!=y){c[x]--;f[x][1^ty]++;x=fa[x];}
}


void solve(int id){
	int opt1,opt2,x,y,i,now;
	opt1=f[id][0]?1:0;
	rep(i,0,(int)vec[id].size()-1){
		now=vec[id][i];
		if(vis[now])	continue;
		break;
	}
	x=a[now];y=lca[now];opt2=1;
	while(x!=y){
		if(x==id) {opt2=0;break;}
		x=fa[x];
	}
	opt1^=opt2;
	ans[now]=opt1;vis[now]=1;
	modify(now,opt1);
}				

bool check(){
	int i;
	rep(i,1,n)	if(c[i]==1&&(!f[i][0]||!f[i][1])){
		solve(i);
		return true;
	}
	return false;
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i,j,x,y;
	scanf("%d%d",&n,&m);
	rep(i,1,n-1){
		scanf("%d%d",&x,&y);
		tot++;addedge(tot,x,y);
		tot++;addedge(tot,y,x);
	}
	dfs(1);
	rep(j,1,15)	rep(i,1,n)	father[i][j]=father[father[i][j-1]][j-1];
	rep(i,1,m){
		scanf("%d%d",&a[i],&b[i]);
		lca[i]=LCA(a[i],b[i]);
		add(a[i],lca[i],i);
		add(b[i],lca[i],i);
	}
	rep(i,1,n)	ANS+=min(c[i],2);
	printf("%d\n",ANS);
	rep(i,1,n)	if(c[i]<2)	c[i]=0;
	rep(i,1,m)	if(!vis[i]){
		ans[i]=0;vis[i]=1;
		modify(i,0);
		while(check());
	}
	rep(i,1,m){
		if(ans[i])	printf("%d %d\n",b[i],a[i]);
		else printf("%d %d\n",a[i],b[i]);
	}
	return 0;
}























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

count = 0
for i in range(n-1) :
  if i == 0: continue
  if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i+1] < p[i] and p[i] < p[i-1]) :
    count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){
	if(y<h && y>=0 && x<w && x>=0) return true;
	return false;
}


const int inf = 1e9;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,ma,mb;cin >> n >> ma >> mb;
	vector<int> a(n),b(n),c(n);
	rep(i,n) cin >> a.at(i) >> b.at(i) >> c.at(i);
	vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(410, vector<int>(410, inf)));
	dp[0][0][0] = 0;
	rep(i,n){
		rep(j,401){
			rep(k,401){
				if(j - a.at(i) >= 0 && k - b.at(i) >= 0){
					dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - a.at(i)][k - b.at(i)] + c.at(i));
				}
				dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	int ans = inf;
	for(int i = ma, j = mb; i <= 400 && j <= 400; i += ma, j += mb){
		ans = min(ans, dp[n][i][j]);
	}
	if(ans == inf) cout << -1 << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 28544
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int x = sc.nextInt();
        if (a <= x && a + b >= x) {
            System.out.println("YES");
            return;
        }
        System.out.println("NO");
    }

}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N); F0R(i, N) cin >> arr[i];

	map<int, int> occ;
	F0R(i, N) occ[arr[i]]++;
	
	ll total = 0;
	for (pii data : occ) {
		total += 1LL * data.second * (data.second - 1) / 2;
	}

	for (int x : arr) {
		print(total - 1LL * occ[x] * (occ[x] - 1) / 2 + 1LL * (occ[x] - 1) * (occ[x] - 2) / 2);
	}
}

Measured memory_bytes: 8320
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	while(scan.hasNext()){
	    int n = Integer.parseInt(scan.nextLine());
	    if (n == 0) {
		break;
	    }
	    String[] input = scan.nextLine().split(" ");
	    int[] s = new int[n];
	    int count = 0;
	    for (int i = 0; i < n; i++) {
		s[i] = Integer.parseInt(input[i]);
		count += s[i];
	    }
	    double m = (double)count / n;
	    double sigma = 0;
	    for (int i = 0; i < n; i++) {
		sigma += (s[i] - m) * (s[i] - m);
	    }
	    double a = Math.sqrt(sigma / n);
	    System.out.println(a);
	}	
    }
}

Measured memory_bytes: 28548
N = input()
n = int(N)
keta = len(N)
ans = 0
if keta == 1:
    ans = n
elif keta % 2 == 0:
    for i in range(1, keta, 2):
        ans += 9 * (10 ** (i-1))
else:
    for i in range(1, keta - 1, 2):
        ans += 9 * (10 ** (i - 1))
    ans += (n - 10**(keta-1)) + 1
print(ans)

Measured memory_bytes: 38384
#include  <iostream>
using namespace std;
int main(){
    int n, m, sum, dig;
    cin >> n;
    m = n;
    sum = 0;
    while(m){
        dig = m % 10;
        sum = sum + dig;
        m = m / 10;
    }
    if (n % sum) {cout << "No" << endl;}
    else{cout << "Yes" << endl;}
}

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

int main()
{
    int n, cnt, div=0;
    cin>>n;
    for(int i=1; i<=n; i+=2)
    {
        cnt=0;
        for(int j=1; j<=i; j++)
        {
            if(i%j == 0) cnt++;
        }
        if(cnt ==8) div++;
    }
    cout<<div<<endl;
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashSet};

#[derive(Clone, Eq, PartialEq)]
struct Node {
    s: String,
    is_left: bool,
    cost: i64 
}

impl Ord for Node {
    fn cmp(&self, other: &Node) -> Ordering {
        other.cost.cmp(&self.cost)
    }
}
impl PartialOrd for Node {
    fn partial_cmp(&self, other: &Node) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn is_palindrome(lhs: &String, rhs: &String) -> bool {
    let (ln, rn) = (lhs.len(), rhs.len());
    let n = std::cmp::min(ln, rn);

    for i in 0..n {
        if lhs.chars().nth(i) != rhs.chars().nth(rn - i - 1) { return false; }
    }
    return true;
}

#[fastout]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        Item: [(String, i64); N],
    }

    let mut heap = BinaryHeap::new();

    for item in &Item {
        heap.push(Node { s: item.0.clone(), is_left: true, cost: item.1 });
    }

    let mut lhs = HashSet::new();
    let mut rhs = HashSet::new();

    let mut res = -1;
    
    while let Some(Node { s, is_left, cost}) = heap.pop() {
        // コスト最小順で見つかった最初のコストを採用して終了
        if is_palindrome(&s, &s) { res = cost; break; }

        // 残りの文字列が既出だったらスキップする
        let cache = if is_left { &mut lhs } else { &mut rhs };
        if cache.contains(&s) { continue; }

        cache.insert(s.clone());

        // 各文字列を少ない方向からくっつける
        for item in &Item {
            let ls = if is_left { &s } else { &item.0 };
            let rs = if is_left { &item.0 } else { &s };
            if !is_palindrome(&ls, &rs) { continue; }

            let ln = ls.len();
            let rn = rs.len();

            let ss = (if ln < rn { &rs[0..(rn - ln)] }
                              else       { &ls[rn..ln] }).to_string();

            heap.push(Node { s: ss.clone(), is_left: ln >= rn, cost: cost + item.1 });
        }
    }

    println!("{:?}", res);
}


Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int h,w,sum=0;
	char k[55][55];
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>k[i][j];
		}
	}
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			sum=0;
			if(k[i][j]!='#')
			{
				if(k[i+1][j]=='#') sum++;
				if(k[i+1][j-1]=='#') sum++;
				if(k[i+1][j+1]=='#') sum++;
				if(k[i-1][j]=='#') sum++;
				if(k[i-1][j-1]=='#') sum++;
				if(k[i-1][j+1]=='#') sum++;
				if(k[i][j-1]=='#') sum++;
				if(k[i][j+1]=='#') sum++;
				printf("%d",sum);
			}
			else
			{
				printf("#");
			}
			
		}
		printf("\n");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
a,sums=list(map(int,input().split()))
if a*3==sums:
  print(1)
else:
  ret=0
  for x in range(a+1):
    if (sums-x <=2*a)&(sums>=x):
      for y in range(a+1):
        if (sums-x-y>=0)&(sums-x-y<=a):
          ret+=1
  print(ret)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pr printf
#define P push
#define PB push_back
#define F front
#define T top
#define MP make_pair
#define Fi first
#define Se second
using namespace std;
inline long long gcd(long long a,long long b){return b==0?a:gcd(b,a%b);}
inline long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
inline void read(long long &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
inline void read(int &x){
	char ch;
	do ch=getchar();while(ch<48||ch>57);
	x=0;while(ch<=57&&ch>=48){x=x*10+ch-48;ch=getchar();}
}
int i,j,k,n[3],m,q;
ll s[3][100010],t[100010];
ll Find1(int u,ll num){
	ll l=1,r=n[u],Mid,ans=1e10;
	while(l<=r){
		Mid=(l+r)/2;
		if(s[u][Mid]>=num)ans=s[u][Mid]-num,r=Mid-1;
		else l=Mid+1;
	}
	return ans;
}
ll Find2(int u,ll num){
	ll l=1,r=n[u],Mid,ans=1e10;
	while(l<=r){
		Mid=(l+r)/2;
		if(s[u][Mid]<=num)ans=num-s[u][Mid],l=Mid+1;
		else r=Mid-1;
	}
	return ans;
}
int main(){
	cin>>n[1]>>n[2]>>q;
	for(i=1;i<=n[1];i++)scanf("%lld",&s[1][i]);
	sort(s[1]+1,s[1]+1+n[1]);
	for(i=1;i<=n[2];i++)scanf("%lld",&s[2][i]);
	sort(s[2]+1,s[2]+1+n[2]);
	for(i=1;i<=q;i++){
		ll x,ans=0,tans=1e11;
		scanf("%lld",&x);
		{
			{
				ll y=Find1(1,x);
				ans=y;
				y=x+y;
				y=Find1(2,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find1(1,x);
				ans=y;
				y=x+y;
				y=Find2(2,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find2(1,x);
				ans=y;
				y=x-y;
				y=Find1(2,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find2(1,x);
				ans=y;
				y=x-y;
				y=Find2(2,y);
				ans+=y;
				tans=min(tans,ans);
			}
		};
		{
			{
				ll y=Find1(2,x);
				ans=y;
				y=x+y;
				y=Find1(1,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find1(2,x);
				ans=y;
				y=x+y;
				y=Find2(1,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find2(2,x);
				ans=y;
				y=x-y;
				y=Find1(1,y);
				ans+=y;
				tans=min(tans,ans);
			}{
				ll y=Find2(2,x);
				ans=y;
				y=x-y;
				y=Find2(1,y);
				ans+=y;
				tans=min(tans,ans);
			}
		};
		cout<<tans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n'
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
class MagicNumberThree
{

    public:
int countSubsequences(string s)
{

}

};


int main()
{
    int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
 int a,b;

 while(cin>>a>>b){
    string A[1024]={};
     int dis[105][105]={};

    for(int i=0;i<a;i++)
        cin>>A[i];

        int cnt=0;
    for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
            if(A[i][j]=='#')
                cnt++;
                dis[i][j]=inf;
        }
    }
dis[0][0]=0;
    queue<pair<int,int> >q;
    q.push(mp(0,0) );
    int ans=inf;
    while(!q.empty() ){
        pair<int,int>now=q.front();
        q.pop();
        for(int i=0;i<4;i++){
            int s1=now.F+dx[i],s2=now.S+dy[i];

            if(s1<0||s2<0||s1>=a||s2>=b||A[s1][s2]=='#')
                con;

            if(dis[s1][s2]>dis[now.F][now.S]+1){
                dis[s1][s2]=dis[now.F][now.S]+1;
                q.push(mp(s1,s2) );
            }
        }



    }
    if(dis[a-1][b-1]==inf)
        cout<<-1<<endl;
    else{
        cout<<a*b-cnt-dis[a-1][b-1]-1<<endl;
    }
 }

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [list(map(int, input().split())) for _ in range(M)]

BCs = sorted(BCs,reverse = True, key = lambda x: x[1])
As = sorted(As, key = lambda x:x)

#%%
A_ind = 0

for BC in BCs:
    count = BC[0]
    value = BC[1]
    
    for i in range(count):
        if As[A_ind] < value:
            As[A_ind] = value
            A_ind += 1
            if A_ind >= len(As):
                break
        else:
            break
        
    else:
        continue
    break

print(sum(As))

Measured memory_bytes: 106696
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  vector<pair<ll, pll>> v;
  rep(i, n)
  {
    ll a, b;
    cin >> a >> b;
    v.push_back(MP(a + b, MP(a, b)));
  }
  sort(all(v), greater<pair<ll, pll>>());
  ll ans = 0;
  rep(i, n)
  {
    ans += (i % 2 == 0 ? v[i].second.first : -v[i].second.second);
  }
  cout << ans << endl;
  return 0;
}


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

int mp1s(int n,int a,int b,int c,int l[]){
  
  int sum_mp1 = 3000;
  int new_sum_mp1;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
        
        if(i!=j&&i!=k&&j!=k){
          new_sum_mp1 = abs(a-l[i]) + abs(b-l[j]) + abs(c-l[k]);
          if(sum_mp1>new_sum_mp1) sum_mp1 = new_sum_mp1;
        }
        
      }
    }  
  }
  
  return sum_mp1;
  
}

int solution(int n,int a,int b,int c,int l[]){
  int solution_temp = mp1s(n, a, b, c, l);
  if(n>3){
    for(int i=0;i<n;i++){
       for(int j=0;j<i;j++){
         int l_[n-1];
         for(int k=0;k<n-1;k++){
           if(k>=i){
             l_[k] = l[k+1];
           }else if(k==j){
             l_[k] = l[i] + l[j];
           }else{
             l_[k] = l[k];
           }
         }
         int solution_temp2 = solution(n-1,a,b,c,l_);
         if(solution_temp > solution_temp2 + 10) solution_temp = solution_temp2 + 10;
         
      }
    }
  }
  return solution_temp;
}

int main(){
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int l[n];
  for(int i=0;i<n;i++){
    cin >> l[i];
  }

  cout << solution(n,a,b,c,l) << endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll dist[2005][2005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,x,y; cin>>n>>x>>y;
  x--,y--;
  
  rep(i,n){
    irep(j,i+1,n){
      dist[i][j]=dist[j][i]=abs(i-j);
    }
  }
  
  
  // rep(i,n) irep(j,i+1,n) cout<<dist[i][j]<<endl;
  
  rep(i,n) rep(j,n) dist[i][j]=min(dist[i][j],dist[i][x]+dist[y][j]+1);
  
  vll ans(n);
  rep(i,n) irep(j,i+1,n) ans[dist[i][j]]++;
  reps(i,n-1) cout<<ans[i]<<endl;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
int main() {
    int A, B;
    cin >> A >> B;
    if (A  - B * 2 > 0)
    {
        cout << A  - B * 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int suti(string s){
    int a = 0;
    int b;
    char c;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'm'&&i == 0){
            a += 1000;
        }
        else if(s[i] == 'c'&&i==0){
            a += 100;
        }
        else if(s[i] == 'x' && i == 0){
            a += 10;
        }
        else if(s[i] == 'i' && i==0){
            a += 1;
        }
        else if(s[i]=='m'){
            if('2'<=s[i-1]&&s[i-1]<='9'){
                c = s[i-1];
                b = c - '0';
                a += b*1000;
            }
            else{
                a += 1000;
            }
        }
        else if(s[i] == 'c'){
            if('2'<=s[i-1]&&s[i-1]<='9'){
                c = s[i-1];
                b = c - '0';
                a += b*100;
            }
            else{
                a += 100;
            }
        }
        else if(s[i] == 'x'){
            if('2'<=s[i-1]&&s[i-1]<='9'){
                c = s[i-1];
                b = c - '0';
                a += b*10;
            }
            else{
                a += 10;
            }
        }
        else if(s[i] == 'i'){
            if('2'<=s[i-1]&&s[i-1]<='9'){
                c = s[i-1];
                b = c - '0';
                a += b;
            }
            else {
                a += 1;
            }
        }
    }
    return a;
}

int main(){

    int n;
    cin >> n;
    int k;

    for(int i=0;i<n;i++){
        string s1,s2;
        cin >> s1 >> s2;
        //cout << s1 << " " << s2 << endl;
        int num1,num2;
        num1 = suti(s1);
        num2 = suti(s2);
        k = num1 + num2;
        if(k>=1000){
            if(k/1000==1){
                cout << "m";
            }
            else{
                cout << k/1000 << "m";
            }
        }
        k%=1000;
        if(k>=100){
            if(k/100==1){
                cout << "c";
            }
            else{
                cout << k/100 << "c";
            }
        }
        k%=100;
        if(k>=10){
            if(k/10==1){
                cout << "x";
            }
            else{
                cout << k/10 << "x";
            }
        }
        k%=10;
        if(k>=1){
            if(k==1){
                cout << "i" << endl;
            }
            else{
                cout << k << "i" << endl;
            }
        }
        else{
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3004
N = int(input())
MAX = 500
A = [[1],[1]] #size = 2
#A = [[1,2],[2,3],[3.1]]
size = 0
for i in range(1,MAX):
  if i*(i+1)//2 == N:
    size = i+1
    break
if size == 0:
  print("No")
  exit()
now = 2
while now < size:
  start = now*(now-1)//2+1
  last = [start+i for i in range(now)]
  for j in range(len(A)):
    A[j].append(last[j])
  A.append(last)
  now += 1
print("Yes")
print(len(A))
#ini = [len(A)-1]
for x in A:
  x.insert(0,len(A)-1)
  print(*x)

Measured memory_bytes: 71168
n,y=gets.chomp.split(" ").map { |e| e.to_i  }

for i in 0..n do
  for j in 0..n-i do
      if 10000*i + 5000*j + 1000*(n-j-i) == y
          printf("%d %d %d\n",i,j,n-j-i)
          exit
      end
  end
end

printf("%d %d %d\n",-1,-1,-1)

Measured memory_bytes: 1788
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=100010;

void solve(){
    int n;
    cin>>n;
    ll ans=0,req=1;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        if(x==req){
            req++;
        } else {
            ans++;
        }
    }
    if(req==1) cout<<"-1\n";
    else cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int N, Q;
	cin >> N >> Q;
	char S[N];
	for(int i=0; i<N; i++) cin >> S[i];
	int sum[N];
	sum[0] = 0;
	for(int i=1; i<N; i++){
		if(S[i-1] == 'A' && S[i] == 'C') sum[i] = sum[i-1] + 1;
		else sum[i] = sum[i-1];
	}
	for(int i=0; i<Q; i++){
		int l, r;
		cin >> l >> r;
		cout << sum[r-1] - sum[l-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n,c,k;	cin>>n>>c>>k;
	vector<int> t(n);
	for(int i=0;i<n;i++)	cin>>t[i];
	sort(t.begin(),t.end());
	int ret=1;
	int cnt=1;
	int end=t[0]+k;
	for(int i=1;i<n;i++){
		if(end<t[i]||cnt==c){
			ret++;
			cnt=0;
			end=t[i]+k;
		}
		cnt++;
	}
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 0

int n,m,z,h;
int edge[64][64];
int edge2[200][200];
vector<pair<int,int> > v;


/*
  vector<int> a, vector<int> b
  03:08 sec	2000 KB

  const vector<int>& a, const vector<int>& b
  */

vector<int> calc(const vector<int>& a, const vector<int>& b){
	vector<int> ret;
	rep(i,h){
		rep(j,h){
			int sum = 0;
			rep(k,h){
				sum |= a[i*h+k]*b[k*h+j];
			}
			ret.pb(sum);
		}
	}
	return ret;
}

vector<int> multi(vector<int>& matrix, int k){
	if( k==1 ) return matrix;

	vector<int> tmp = multi(matrix,k/2);
	if( k%2 ){
		return calc(matrix,calc(tmp,tmp));
	}else{
		return calc(tmp,tmp);
	}
}

int main(){

	while(scanf(" %d%d%d ",&n,&m,&z),n|m|z){
		rep(i,64)rep(j,64)edge[i][j]=0;
		rep(i,200)rep(j,200)edge2[i][j]=0;
		
		v.clear();
		rep(i,m){
			int s,d; scanf("%d%d",&s,&d);
			edge[s][d] = edge[d][s] = 1;
		}
		REP(i,1,n+1)edge[i][i]=1;
		
		REP(i,1,n+1){
			REP(j,1,n+1)if( edge[j][i]==1 ){
				v.pb(mp(i-1,j-1));
			}
		}

		rep(i,v.size()){
			rep(j,v.size()){
				if( v[i].first!=v[j].first && v[i].first==v[j].second && v[i].second!=v[j].first ){
					edge2[i][j] = 1;
				}
			}
		}
		h = v.size();
		vector<int> mat;
		rep(i,v.size()){
			rep(j,v.size()){
				mat.pb(edge2[i][j]);
			}
		}

#if DEB
		rep(i,v.size()){
			printf("(%d,%d)\n",v[i].first, v[i].second);
		}
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",mat[i*h+j]);
			}
			puts("");
		}
#endif

		
		vector<int> hoge = multi(mat,z);

#if DEB
		printf("z:%d\n",z);
		rep(i,v.size()){
			rep(j,v.size()){
				printf("%d ",hoge[h*i+j]);
			}
			puts("");
		}
#endif
		bool f = false;
		rep(i,v.size())if( v[i].first==n-1 ){
			if( hoge[i]>0 ){
				f = true;
				break;
			}
		}
		puts(f?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, m, k;
  cin >> n >> m >> k;

  rep(i, n+1) {
    rep(j, m+1) {
      if ((n-i)*j + (m-j)*i == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main() {
  string S;
  cin >> S;
  ll N = S.size() + 1;
  vector<vector<int>> num(2, vector<int>(N, 0));
  //numの一行目:自分の左に何個<が連続しているか
  for (int i = 1; i <= N-1; i++) {
    if (S[i-1] == '<') {
      num[0][i] = num[0][i-1] + 1;
    }
  }
  //numの二行目:自分の右に何個>が連続しているか
  for (int i = N-2; i >= 0; i--) {
    if (S[i] == '>') {
      num[1][i] = num[1][i+1] + 1;
    }
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += max(num[0][i], num[1][i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6788