akhauriyash/Code-Regression huggingface dataset:
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0006&lang=jp*/

#include <iostream>

using namespace std;

int main(){
    string str;
    cin>>str;
    string::reverse_iterator rt=str.rbegin();
    while(rt!=str.rend()){
        cout<<*rt++;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(void) {

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

	if (a < b)
		printf("a < b\n");
	else if(a == b)
		printf("a == b\n");
	else 
		printf("a > b\n");

	return 0;
}


Measured memory_bytes: 2684
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      l: usize,
      r: usize,
      d: usize
   }
   let mut ans = r / d;
   ans -= (l - 1) / d;
   println!("{}", ans);
}


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

int m, n;
int isPrime(int x, int y){
	int sq = x * x + y * y;
	int d1 = x * m + y * n;
	int d2 = x * n - y * m;
	
	return ((d1 % sq == 0) && (d2 % sq == 0));
}

int main(){
	int dataset;
	cin >> dataset;
	while(dataset--){
		cin >> m >> n;
		int cnt = 0;
		for(int x = 0; x * x <= m * m + n * n; x++){
			for(int y = 0; x * x + y * y <= m * m + n * n; y++){
				if(x == 0 && y == 0) continue;
				cnt += isPrime(x, y);
				if(x != 0) cnt += isPrime(-x, y);
				if(y != 0) cnt += isPrime(x, -y);
				if(x != 0 && y != 0) cnt += isPrime(-x, -y);

			}
		}
		if(cnt > 8){
			cout << "C" << endl;
		}else{
			cout << "P" << endl;
		}
	}
}

Measured memory_bytes: 3056
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        aa: [usize; n],
    }

    let max_a = aa.iter().copied().max().unwrap();
    let mut g = aa[0];

    for i in 1..n {
        g = gcd(g, aa[i]);
    }
    if k > max_a || k % g != 0 {
        println!("IMPOSSIBLE");
    } else {
        println!("POSSIBLE");
    }

}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main()
{	
int n;    
int A[100100];	
vector<long long> v;
cin >> n;	
for(int i=0;i<n;i++)
{		
cin >> A[i];	
}	
sort(A,A+n);
reverse(A,A+n);	
for(int i=1;i<n;i++)
{		
if(A[i-1]==A[i])
{			
v.push_back(A[i]);
i++;		
}		
if(v.size()==2)
{			
cout << v[0]*v[1] << endl;			
return 0;		
}	
}		
cout << 0 << endl;	
return 0;
}





Measured memory_bytes: 640
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int res = 6;
	int a, b;
	cin >> a >> b;

	ce(res-a-b)
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int main()
{

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int east[n + 1];
    east[0] = 0;

    for (int i=1; i<=n; i++) {
        east[i] = east[i-1] + (s[i-1] == 'W' ? 1 : 0);
    }

    int west[n+1];
    west[n-1] = 0;

    for (int i=n-2; i>=0; i--) {
        west[i] = west[i+1] + (s[i+1] == 'E' ? 1 : 0);
    }

    int best = 1000000000;
    for (int i=0; i<n; i++) {

        int person = i;
        int left = east[i];
        int right = west[i];

        best = min(best, left + right);
    }

    cout << best << endl;
    return 0;
}


Measured memory_bytes: 2964
a,b,c = map(int,input().split())
l = []
for i in range(c):
  d = a+i
  e = b-i
  if d<=b and a<=e:
    l.append(a+i)
    l.append(b-i)
l = sorted(set(l))
for i in l:
  print(i)

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

int main () {
    int n, x, t;
    cin >> n >> x >> t;
    if (n % x == 0) {
        cout << (n / x) * t << endl;
    } else {
        cout << (n / x) * t + t << endl;
    }
    return(0);
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 100000000000
#define mod 1000000007
#define pll pair<long,long>
#define se second
#define fi first
#define pb push_back
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;


int main()
{
			ios_base::sync_with_stdio(false);
			cin.tie(NULL);
			ll n;
			cin>>n;
			vector<ll> v(n);
			ll maxn=0,idn=-1,idp=-1,maxp=0;
			for(ll i=0;i<n;i++)
				{cin>>v[i];
				 if(v[i]>0 && v[i]>=maxp)
				 {
					 maxp=v[i];
					 idp=i;
				 }
				 else if(v[i]<0 && v[i]<maxn)
				 {
					 maxn=v[i];
					 idn=i;
				 }
				 else if(v[i]==0)
				 {
					 if(idp==-1)
						idp=i;
					if(idn==-1)
						idn=i;
				 }
					
				}
			vector<pll> ans;
			for(ll i=0;i<n;i++)
			{
				if(abs(maxn)>maxp)
				{
					ans.pb({idn,i});
					v[i]+=maxn;
				}
				else
				{
					ans.pb({idp,i});
					v[i]+=maxp;
				}
				
			}
			if(abs(maxn)>maxp)
			{
				for(ll i=n-2;i>=0;i--)
					ans.pb({i+1,i});
			}
			else
			{
				for(ll i=1;i<n;i++)
				{
					ans.pb({i-1,i});
				}
			}
			cout<<ans.size()<<endl;
			for(auto i:ans)
			{
				cout<<i.fi+1<<" "<<i.se+1<<endl;
			}
			
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
#define MAXN 1000000007
 
 
int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll d=a-b;
	ll e=b-c;
	ll f=a-c;

	if ((d==0) or(e==0) or(f==0)) {
		if ((d==0) and(e==0) and(f==0)) {
			cout<<"No";
		}
		else {
			cout<<"Yes";

		}
	}
	else {
		cout<<"No";
	}
}
	

Measured memory_bytes: 3596
"RPN using stack for AOJ ALDS1_3_A: Stack"

# coding: utf-8


def rpn(exp):
    """
    rpn calculation
    >>> rpn(['1', '2', '+', '3', '4', '-', '*'])
    -3
    """

    stack = []
    for elem in exp:
        if elem == '+':
            stack.append(int(stack.pop()) + int(stack.pop()))
        elif elem == '-':
            stack.append(-int(stack.pop()) + int(stack.pop()))
        elif elem == '*':
            stack.append(int(stack.pop()) * int(stack.pop()))
        elif elem == '/':
            stack.append(int(stack.pop()) / int(stack.pop()))
        else:
            stack.append(elem)

    print(stack.pop())


def main():
    "main function"

    exp = list(input().split(' '))
    rpn(exp)

if __name__ == '__main__':
    # import doctest
    # doctest.testmod()

    main()

Measured memory_bytes: 7708
#include <bits/stdc++.h>
#define endl '\n'
#define _ ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

int main() {_
    int n, a, q, b1, b2, delta;
    long long sum=0;
    map<int, int> as;
    map<int, int>::iterator iter;

    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        sum += a;

        iter = as.find(a);
        if(iter == as.end())
            as[a] = 1;
        else
            as[a] += 1;

    }
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> b1 >> b2;

        delta = (b2-b1) * as[b1];

        as[b2] += as[b1];
        as[b1] = 0;

        sum += delta;
        cout << sum << endl;
    }

    return 0;
}


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

const int N = 5010;

int A[N], B[N]; char s[N];

inline void process(int t[], int n) {
    t[1] = s[1] == '1';
    for (int i = 2; i <= n; i++) t[i] = s[i] != s[i - 1];
}

int main() {
    int n; scanf("%d", &n);
    scanf("%s", s + 1), process(A, n), scanf("%s", s + 1), process(B, n);
    int ct = 0, ct1 = 0, res = 1e9;
    vector<int> wkr, zjk;
    for (int i = 1; i <= n; i++) {
        if (B[i]) wkr.push_back(i), ct1++;
        if (A[i]) zjk.push_back(i), ct++;
    }
    for (int t = -ct / 2 * 2; t <= ct1; t += 2) {
        int tp = 0, tmp = 0, tp1 = 0;
        for (int i = 1; i <= t; i++) tmp += wkr[tp++] - 1;
        for (int i = 1; i <= -t; i++) tmp += zjk[tp1++] - 1;
        for (int i = tp; i < wkr.size(); i++) {
            if (tp1 >= zjk.size()) tmp += n + 1 - wkr[tp++];
            else tmp += abs(wkr[tp++] - zjk[tp1++]);
        }
        for (int i = tp1; i < zjk.size(); i++) tmp += n + 1 - zjk[tp1++];
        res = min(res, tmp);
    }
    
    printf("%d\n", res);
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  cout << fixed << setprecision(12);
  int a,b,x,y; cin>>a>>b>>x>>y;
  int l=max(a,x);
  int r=min(b,y);
  int res=max(0,r-l);
  cout<<res<<endl;
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;





int main(void) {
    ll N;
    cin >> N;
    vector<ll> b(N);
    ll i;
    
    for(i=0; i<N; i++) {
        cin >> b[i];
    }
    
    vector<ll> ans;
    
    for(ll k=0; k<N; k++) {
        for(i=b.size()-1; i>=0; i--) {
            if(b[i]==i+1) {
                ans.pb(b[i]);
                b.erase(b.begin()+i);
                break;
            }
        }
        
    }
    
    if(ans.size()==N) {
        for(i=N-1; i>=0; i--) pt(ans[i]);
    }else {
        pt(-1);
    }
    
    
    
}








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

using namespace std;

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


int main() {

#ifndef ONLINE_JUDGE
    //freopen("in.in", "r", stdin);
    //freopen("out.in", "w", stdout);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long lcm = C / __gcd(C, D) * D;
    long long len = B - A + 1;
    long long divC = B / C - (A - 1) / C;
    long long divD = B / D - (A - 1) / D;
    long long divl = B / lcm - (A - 1) / lcm;
    long long all = divC + divD - divl;
    cout << len - all << endl;


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main() {
	int a[9], i,j,k,l,m,n,ic,jc,kc,lc,mc,nc;
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8];
	ic = min({ a[0],a[3],a[6] });
	jc = min({ a[1],a[4],a[7] });
	kc = min({ a[2],a[5],a[8] });
	lc = min({ a[0],a[1],a[2] });
	mc = min({ a[3],a[4],a[5] });
	nc = min({ a[6],a[7],a[8] });
	for (i = 0;i <= ic;i++) {
		for (j = 0;j <= jc;j++) {
			for (k = 0;k <= kc;k++) {
				for (l = 0;l <=lc;l++) {
					for (m = 0;m <=mc;m++) {
						for (n = 0;n <=nc;n++) {
							if (a[0] == i + l&&a[1] == j + l) {
								if (a[2] == k + l&&a[3] == i + m) {
									if (a[4] == j + m&&a[5] == k + m) {
										if (a[6] == i + n&&a[7] == j + n&&a[8] == k + n) {
											cout << "Yes" << endl;
											return 0;
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define ll long long
using namespace std;
int n,a,b;
ll h[100010];
bool check(int x)
{
	int cnt=x;ll nw,tp;
	nw=(ll)x*b;
	for(int i=1;i<=n;i++)
	{
		if(h[i]<=nw)continue;
		else tp=h[i]-nw,cnt-=(tp/a)+(tp%a?1:0);
	}
	return cnt>=0;
}
main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	a-=b;
	for(int i=1;i<=n;i++)
		scanf("%lld",&h[i]);
	int l=1,r=1e9,mid,ans=1e9;
	while(l<=r)
	{
		mid=(l+r)>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _011_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nck = ReadInts();
            int n = nck[0];
            int c = nck[1];
            int k = nck[2];
            var ts = new int[n];
            for(int i = 0; i < n; i++)
            {
                ts[i] = ReadInt();
            }
            Array.Sort(ts);
            int cnt = 0;
            for(int i = 0; i < n;)
            {
                int limit = ts[i] + k;
                int rideCnt = 0;
                while (i < n && ts[i] <= limit && rideCnt < c)
                {
                    i++;
                    rideCnt++;
                }
                cnt++;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n;
int x, y;
int a[N];
int b[N];

inline bool check (int cur) {

	for (int i = 1; i <= n; i ++) {
		if (a[i] > cur * (ll)y) {
			b[i] = a[i] - cur * y;
		} else {
			b[i] = 0;
		}
	}
	int sum = 0;
	for (int i = 1; i <= n; i ++) {
		sum += (b[i] + x - 1) / x;
		if (sum > cur) return 0;
	}
	return 1;
}


int main () {
	SpeedForce;
	cin >> n >> x >> y;
	x -= y;

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

	int l = 0, r = *max_element(a + 1, a + n + 1) / y + 1;

	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (check(md)) r = md;
		else l = md;
	}

	cout << r << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 2688
H,W = map(int,input().split())
S = [input() for i in range(H)]
dy = [0,1,0,-1]
dx = [1,0,-1,0]
for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            continue
        if any(0<=y+dy[i]<H and 0<=x+dx[i]<W and S[y+dy[i]][x+dx[i]] == '#' for i in range(4)):
            continue
        print('No')
        exit()
print('Yes')    

Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007

int main() {
    int h;
    int n;
    vector<int> a;
    int tmp_a;
    cin >> h >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    for(int i=0; i<n; i++){
        h-=a[i];
    }
    if(h<=0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
int ah[210];
int aw[210];

int main(){
	while(1){
		ah[0]=0,aw[0]=0;
		cin>>n;
		if(n==0)break;
		for(int i=1;i<n;i++){
			int u,v;
			cin>>u;
			cin>>v;
			
			if(v==0){
				ah[i]=ah[u];
				aw[i]=aw[u]-1;
			}else if(v==1){
				ah[i]=ah[u]+1;
				aw[i]=aw[u];
			}else if(v==2){
				ah[i]=ah[u];
				aw[i]=aw[u]+1;
			}if(v==3){
				ah[i]=ah[u]-1;
				aw[i]=aw[u];
			}
		}
		int maxh=-INF,minh=INF;
		int maxw=-INF,minw=INF;
		for(int i=0;i<n;i++){
			maxh=max(maxh,ah[i]);
			minh=min(minh,ah[i]);
			maxw=max(maxw,aw[i]);
			minw=min(minw,aw[i]);
		}
		cout<<maxw-minw+1<<" "<<maxh-minh+1<<endl;
	}
	return 0;
}
	



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

using namespace std;
int n;

int main()
{
	cin>>n;
	int tmp=1;
	for(int i=1,x;i<=n;++i)
	{
		cin>>x;
		if(x==tmp) ++tmp;
	}
	if(tmp!=1) cout<<n-tmp+1<<endl;
	else cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

const ll MOD = 1000000007;
long long powmod(ll a,ll b){
  return b?powmod(a*a%MOD,b/2)*(b%2?a:1)%MOD:1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll mod = 1000000007;
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];

    vector<int> dif;
    rep(i,n-1) dif.push_back(v[i+1]-v[i]);

    ll num = 1;
    REP(i,1,n) {
        num *= i;
        num %= mod;
    }

    ll ans = 0;
    ll a = num;
    rep(i,n-1) {
        ans=(ans+((dif[i])*a)%MOD)%MOD;
        a=(a+num*powmod(i+2,MOD-2))%MOD;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 1276
fun main (args:Array<String>){
    val (a , b) = readLine()!!.split(" ").map(String::toInt)
    var stringA : String = ""
    var stringB : String = ""
    for(i in 1..b){
        stringA += a
    }
    for(i in 1..a){
        stringB += b
    }
    if(stringA < stringB) print(stringA)
    else print(stringB)
}

Measured memory_bytes: 36208
S=input()
judge=''
L=len(S)
for index in range(L):
    moji=S[index]
    if (moji=='A') or (moji=='G') or (moji=='T') or (moji=='C'):
        judge+='X'
    else:
        judge+='W'
#print(judge)
num_keeper=[]
num=0
for index in range(L):
    J=judge[index]
    if (index==0) and (J=='X'):
        num=1
    elif J=='W':
        num_keeper.append(num)
        num=0
    elif (index==L-1) and (J=='X'):
        num+=1
        num_keeper.append(num)
    else:
        num+=1
if len(num_keeper)==0:
    num_keeper.append(L)
print(max(num_keeper))

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		if((a + b) % 2 == 0)
			System.out.println((a + b)/2);
		else if ((a + b) % 2 == 1)
			System.out.println((a + b + 1) / 2);

	}

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    int x=0,y=0,now=0;
    REP(i,n){
        int t,p,q;
        cin>>t>>p>>q;
        if(abs(p-x)+abs(q-y)>t-now){
            cout<<"No"<<endl;
            return 0;
        }
        if((abs(p-x)+abs(q-y))%2!=(t-now)%2){
            cout<<"No"<<endl;
            return 0;
        }
        now=t;
        x=p;
        y=q;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, Y;
    cin >> N >> Y;
    rep(i, N+1){
        rep(j, N-i+1){
            if(10000*i+5000*j+1000*(N-i-j) == Y){
                cout << i << " " << j << " " << N-i-j;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1;
}

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

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

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

int zt(int a,int b){
  return max(a,b)-min(a,b);
}

int val(int a,int b){
  int z=zt(a,b);
  return z*(z-30)*(z-30);
}

int main(){
  int i,j,k,m,w,bm[16],bw[16];
  int dp[4096];
  while(scanf("%d%d",&m,&w),m!=0){
    for(i=0;i<4096;i++){
      dp[i]=0;
    }
    for(i=0;i<m;i++){scanf("%d",&bm[i]);}
    for(i=0;i<w;i++){
      scanf("%d",&bw[i]);
      for(j=(1<<m)-1;j>=0;j--){
        for(k=0;k<m;k++){
          if((j&(1<<k))!=0){continue;}
          dp[j|(1<<k)]=max(dp[j]+val(bw[i],bm[k]),dp[j|(1<<k)]);
        }
      }
    }
    printf("%d\n",dp[(1<<m)-1]);
  }
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll r;
    cin >> r;
    cout << 3 * r * r;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
	int n=0;
	cin>>n;
	int count=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		count+=b-a+1;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
while(1){
    fscanf(STDIN,"%d",$x);
    fscanf(STDIN,"%d",$y);
    if($x==0&&$y==0){
        break;
    }
    $z=sqrt($y*$y+($x/2)*($x/2));
    $z=($z*2+$x)*$x;
    echo $z."\n";
}
?>

Measured memory_bytes: 6568
# 順次計算するのでキャッシュしたら早くなる か？
@combi_cache = Hash::new{|h,k| h[k] = {}}

# aCb
def combi(a, b)
  return 0 if b<0 || a<b
  return @combi_cache[a][b] if @combi_cache[a][b]

  @combi_cache[a][b] = b == 0 ? 1 : combi(a, b - 1) * (a - b + 1) / b
end

# aをb個の1以上の整数に分ける場合の数
def count_how_to_split(a, b)
  # 単に組み合わせの数になる
  # 理由は、
  # 1. x < aをb-1個に分けると、あと(a-x)を足せばaになるので、b番目の数は一意に決まる
  # count_how_to_split(a, b) = sum (count_how_to_split(x, b-1)) | x=1..a-1
  # 2. = sum (count_how_to_split(x, b-1)) | x=1..a-2 + count_how_to_split(a-1, b-1)
  #    = count_how_to_split(a-1, b) + count_how_to_split(a-1, b-1)
  # 3. b=1なら1通りしかない
  # 4. a==bなら1通り(1+1+...+1)しかない
  # 5. a<bなら0通り
  # 6. 2-5を考慮すると、パスカルの三角形になる
  #
  #   b 1 2
  # a
  # 1   1
  # 2   1 1
  # 3   1 2 1
  # 3   1 3 3 1
  #
  # よって、結果は(a-1,b-1)の組み合わせの数と等しい

  return 1 if a == 0 && b == 0
  combi(a - 1, b - 1)
end


def count_positions(n,k,i)
  blue = k
  red = n - k
  count_how_to_split(blue,i) * #blueのパターンは1通り
    (count_how_to_split(red, i+1) + #redのパターンは両端が赤の場合
     count_how_to_split(red,i) * 2 + #どちらかの端のみ赤の場合
     count_how_to_split(red,i-1) # 両端青の場合
    ) % (10**9+7)
end

N,K = gets.chomp.split.map(&:to_i)
(1..K).each do |i|
  puts count_positions(N,K,i)
end

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

int main(void)
{
  char input;
  while (1) {
    scanf("%c", &input);
    if (input == '\n') break;
    if (islower(input)) printf("%c", toupper(input));
    else if (isupper(input)) printf("%c", tolower(input));
    else printf("%c", input);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1144
function main(input: string) {
  const S = input.split("\n")[1].split("").map(v => parseInt(v));
  const count = 0;
  for (let k100 = 0; k100 < 10; k100++) {
    for (let k10 = 0; k10 < 10; k10++) {
      for (let k1 = 0; k1 < 10; k1++) {
        const i = S.indexOf(k100);
        if (i !== -1) {
          const S2 = S.slice(i + 1);
          const ii = S2.indexOf(k10);
          if (ii !== -1) {
            const S3 = S2.slice(ii + 1);
            iii = S3.indexOf(k1);
            if (iii !== -1) {
              count++;
              continue;
            }
          }
        }
      }
    }
  }
  console.log(count);
}

main(
  require("fs")
    .readFileSync("/dev/stdin", "utf8")
    .trim()
);


Measured memory_bytes: 39568
def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    dp = [0] * n
    for i in range(1, n):
        j = max(0, i-k)
        dp[i] = min(x + abs(h[i] - y) for x, y in zip(dp[j:i], h[j:i]))

    print(dp[-1])
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20548
# -*- coding: utf-8 -*-
from itertools import combinations

def solve():
    N = int(input())
    m = 2*(N//2)+1
    res = str((N*(N-1))//2 - N//2) + '\n' + '\n'.join((' '.join(map(str, e)) for e in combinations(range(1,N+1), r=2) if sum(e)!=m))

    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack> 
#include <bitset>
#include <queue>
#include <assert.h>
#include <unordered_map>
using namespace std;

const double pi = acos(-1.0);
int main()
{
	double x, y, a, b;
	cin >> x >> y >> a >> b;
	double p = 6 * b / 180 * pi;
	double q = (30 * a + b / 2.0) / 180 * pi;
	double ang = min(fabs(p - q), 2 * pi - fabs(p - q));
	double ans = x * x + y * y - 2 * x * y * cos(ang);
    printf("%.20lf\n", sqrt(ans));
	return 0;
}



Measured memory_bytes: 3544
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
#define maxn 500500
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define dow(i,l,r) for(int i=r;i>=l;i--)
using namespace std;

int f[maxn],num[maxn],n,m,f2[maxn];
int main()
{
	scanf("%d %d",&n,&m);
	rep(i,0,n-1) scanf("%d",num+i);
	sort(num,num+n);
	int r=n-1;
	while (num[r]>=m) --r;
	f[0]=1;
//	rep(i,0,r) printf("%d %d\n",i,num[i]); 
	int sum=0,ans=0;
	memset(f,0,sizeof(f));
	f[0]=1;
	rep(i,0,r) 
		dow(j,num[i],m+num[i]-1)
			f[j]+=f[j-num[i]];
//	rep(j,1,m*2) printf("%d %d\n",j,f[j]);
	rep(i,m,m*2) sum+=f[i];
	rep(i,0,r) {
		rep(j,0,m*2) f2[j]=f[j];
		rep(j,num[i],m+num[i]-1)
			f2[j]-=f2[j-num[i]];
		int now=0;
		rep(j,m,m*2) now+=f2[j];
	//	rep(j,1,m*2) printf("%d %d\n",j,f2[j]);
	//	printf("%d %d\n",now,sum);
		if (now==sum) ++ans;
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 4096
//#pragma GCC optimize("trapv")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;
const int maxn = 2e6 + 55, mod = 1000000007;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s, t = "ABC";
	int n;cin>>n;
	cin >> s;
	int ans = 0;
	for(int i = 0; i + 2 < s.size(); i++) ans += s.substr(i, 3)==t;
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int N = 21;
int n, a[N][N], dp[1 << N];
int main()
{
    cin >> n;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> a[i][j];
    dp[0] = 1;
    for (int S = 1; S < (1 << n); ++S) {
        int i = __builtin_popcount(S) - 1;
        long long sum = 0;
        for (int j = 0; j < n; ++j)
            if ((S >> j & 1) && a[i][j])
                sum += dp[S ^ (1 << j)];
        dp[S] = sum % MOD;
    }
    cout << dp[(1 << n) - 1] << endl;
}



Measured memory_bytes: 8448
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

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

struct state {
	int x, y, t;
	state(int x, int y, int t) : x(x), y(y), t(t) {};
};

int main() {
	int H, W, N;
	cin >> H >> W >> N;

	vs field(H);
	REP(i, H) {
		cin >> field[i];
	}
	
	vector<pii> pos(N+1);
	int sx, sy;

	REP(i, H) {
		REP(j, W) {
			switch(field[i][j]) {
			case 'S':
				sx = j;
				sy = i;
				break;
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
				int a = field[i][j] - '0';
				pos[a] = make_pair(i, j);
				break;
			}
		}
	}

	queue<state> Q;
	int gx, gy;
	int ans = 0;
	REP(i, N) {
		queue<state> Q;
		if(i != 0) {
			sx = pos[i].second;
			sy = pos[i].first;
		}
		gx = pos[i+1].second;
		gy = pos[i+1].first;
		Q.push(state(sx, sy, 0));
		
		vvi table(H, vi(W, INT_MAX));
		while(!Q.empty()) {
			state st = Q.front();
			Q.pop();

			REP(d, 4) {
				int xx = st.x + dx[d];
				int yy = st.y + dy[d];

				if(0 <= xx && xx < W && 0 <= yy && yy < H) {
					if(xx == gx && yy == gy) {
						ans += st.t+1;
						goto next;
					} else {
						if(field[yy][xx] != 'X') {
							if(table[yy][xx] > st.t+1) {
								table[yy][xx] = st.t+1;
								Q.push(state(xx, yy, st.t+1));
							}
						}
					}
				}
			}
		}
		next:;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(long long i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
map<int,bool> alp(string s){
    map<int,bool> mp;
    bool fl;
    rep(i,alpha.size()){
        rep(j,s.size()){
            if(s[j] == alpha[i]){
                mp[i] = true;
                fl = false;
            }
        }
        if(fl){
            mp[i] = false;
        }
        fl = true;
    }
    return mp;
} 
map<char,int> alph(){
    map<char,int> mp;
    rep(i,alpha.size()){
        mp[alpha[i]] = i;
    }
    return mp;
}
int main(){
    string s;
    cin >> s;
    map<int,bool> mpp;
    map<char,int> mp;
    set<int> st;
    if(s.size() != 26){
        mpp = alp(s);
        cout << s;
        rep(i,26){
            if(!mpp[i]){
                cout << alpha[i] << endl;
                break;
            }
        }
    }
    else if(s != "zyxwvutsrqponmlkjihgfedcba"){
        mp = alph();
        for(int i = 24;i>=0;i--){
            st.insert(mp[s[i+1]]);
            auto itr = st.end();
            itr--;
            if(mp[s[i]] < *itr){
                rep(j,i){
                    cout << s[j];
                }
                for(auto itr = st.begin();itr!=st.end();itr++){
                    if(mp[s[i]] < *itr){
                        cout << alpha[*itr] << endl;
                        break;
                    }
                }
                break;
            }
        }
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,c=0;
  vector<int> p;
  cin>>n;
  p.resize(n);
  for(auto& x:p){
    cin>>x;
  }
  for(int i=1;i<=n;i++){
    if(i!=p[i-1])c++;
  }
  if(c==0||c==2){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
N=int(input())
said = set()
char = ""
flag = True
for i in range(N):
    word = input()
    if char != "" and word[0] != char:
        flag = False
    if word in said:
        flag = False
    said.add(word)
    char=word[len(word)-1]
if flag:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  int sum = 0;
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    cin >> m[i];
    sum += m[i];
    ans++;
  }
  sort(m.begin(), m.end());
  int remain = X - sum;
  ans += remain / m[0];
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
while true
    n = gets.to_i
    if n == 0
        break
    end
    a = Array.new(n).map{Array.new(4)}
    for k in 0..n-1 do
        t = gets.split.map(&:to_i)
        a[k][0] = t[0]
        a[k][1] = t[1]
        a[k][2] = t[2]
        a[k][3] = t[3]
    end

    #sort
    a.sort! do |p, q|
        (q[2] <=> p[2]).nonzero? ||
        (p[3] <=> q[3]).nonzero? ||
        (p[0] <=> q[0])
    end

   # p a

    #qualification
    h = Hash.new
    count = 0

    a.each do |k|
        if count < 10
            if h.member?(k[1])
                if h[k[1]] < 3
                    h[k[1]] = h[k[1]] + 1
                    puts k[0]
                    count += 1
                end
            else
                h[k[1]] = 1
                puts k[0]
                count += 1
            end
        elsif count < 20
            if h.member?(k[1])
                if h[k[1]] < 2
                    h[k[1]] = h[k[1]] + 1
                    puts k[0]
                    count += 1
                end
            else
                h[k[1]] = 1
                puts k[0]
                count += 1
            end
        elsif count < 26
            if !h.member?(k[1])
                puts k[0]
                h[k[1]] = 1
                count += 1
            end
        end
     #   p h
    end




end

Measured memory_bytes: 6140
import sys
from collections import deque
input = sys.stdin.readline

n=int(input())
L=deque(list(range(1,10)))
if n<=9:
    ans = L[n-1]
else:
    cnt = 9
    for i in range(1,n):
        c=L.popleft()
        
        if c%10!=0:
            L.append(c*10+(c%10)-1)
            cnt+=1
            if cnt>=n:
                break
        L.append(c*10+(c%10))
        cnt+=1
        if cnt>=n:
            break
        
        if c%10!=9:
            L.append(c*10+(c%10)+1)
            cnt+=1
            if cnt>=n:
                break
    ans = L[-1]
print(ans)


Measured memory_bytes: 74732
/*  HARD WORK FOREVER PAYS  */
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define turbo(){	\
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL); \
}
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
int main() 
{ 
	turbo();
	ll w,a,b;
	cin>>w>>a>>b;
	if(a<b){
		cout<<max((b-(a+w)),0LL)<<"\n";
	}
	else{
		cout<<max(a-(b+w),0LL)<<"\n";
	}
    return 0; 
} 

Measured memory_bytes: 256
#include<iostream>
#include<climits>
using namespace std;
#define ll long long 


int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    if(b>=0 && d>=0)
    {
        cout<<max(a*c,b*d)<<"\n";
    }
    else if(b>=0 && d<=0)
    {
        cout<<max(a*d,a*c)<<"\n";
    }
    else if(b<=0 && d>=0)
    {
        cout<<max(a*c,c*b)<<"\n";
    }
    else
    {
        cout<<a*c<<"\n";
    }
}

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


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int d,t,s;
    cin >> d>> t>>s ;
    double temp=d/(double)t;
    if(s >= temp){
        cout<< "Yes" << endl;
    }
    else
    {
        cout<< "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a; i < n; i++)
#define per(i,n,a) for (int i = n - 1; i >= a; i--)
using namespace std;

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC085C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var N = int.Parse(input[0]);
            var Y = int.Parse(input[1]);

            for (var x = N; x >= 0; x--)
            {
                for (var y = N - x; y >= 0; y--)
                {
                    var z = N - x - y;
                    if (10000 * x + 5000 * y + 1000 * z == Y)
                    {
                        Console.WriteLine($"{x} {y} {z}");
                        return;
                    }
                }
            }

            Console.WriteLine("-1 -1 -1");
        }
    }
}

Measured memory_bytes: 27388
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n), b(n);
    REP(i, n){
        cin >> a[i];
        b[i] = a[i];
    }
    VSORT(b);
    REP(i, n){
        if(a[i] == b[n - 1]) cout << b[n - 2] << endl;
        else cout << b[n - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

int main() {
    int n,m;
    cin >> n >> m;
    queue<int> que;
    vector<vector<int>> r(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a;--b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    que.push(0);
    vector<int> to(n,-1);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for (int j : r[v]){
            if(to[j]==-1) {
                to[j] = v;
                que.push(j);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1;i<n;i++){
        cout << to[i]+1 << endl;
    }
}


Measured memory_bytes: 9992
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long N, A, B, ans;    
	cin >> N >> A >> B;
    if(A>B) 
		cout << 0;
    else if(A==B)    
		cout << 1;
    else
	{
        if(N==1)    
			cout << 0;
        else if(N==2)   
			cout << 1;
        else
		{
            ans = B*(N-1)+A - A*(N-1) -B + 1;
            cout << ans;
        }
    }
}


Measured memory_bytes: 3540
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//template<typename A, size_t N, typename T>
//void Fill(A(&array)[N], const T &val) {
	//std::fill((T*)array, (T*)(array + N), val);
//}

//解法
void solve() {

	string S;
	cin >> S;

	if (S[0] == 'S') cout << "Cloudy";
	if (S[0] == 'C') cout << "Rainy";
	if (S[0] == 'R') cout << "Sunny";

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      a: usize, b: usize
    };
    let mut ans = String::new();
    let lg = if a > b { a } else { b };
    let sm = if a < b { a } else { b };

    for i in 0..lg {
        ans.push_str(&sm.to_string());
    }

    println!("{}", ans);
}


Measured memory_bytes: 2076
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	vector<vector<Int>> imos(30,vector<Int>(100010));

	Int N, C;
	cin >> N >> C;

	Int s, t, c;
	for (Int i = 0; i < N; i++) {
		cin >> s >> t >> c;
		
		//[s,t)であるが、録画開始に時間がかかることを考慮すると[s-1,t)にすればよい
		//しかし、上記手法だと開始時間がマイナスに振れる可能性があるので、時間を後ろに1だけずらして[s,t]であると考える（答えは同じになる）
		s--;
		c--;
		//tのみデクリメントしていないことに注意
		imos[c][s]++;
		imos[c][t]--;
	}

	for (Int c = 0; c < C; c++) {
		for (Int i = 1; i < 100010; i++) {
			imos[c][i] += imos[c][i - 1];
		}

		//同じチャンネル内で複数録画機が必要な状況は生じないため、2以上は1に戻す
		for (Int i = 0; i < 100010; i++) {
			if (imos[c][i])imos[c][i] = 1;
		}
	}

//各時間において使われている録画機の台数
	Int cnt;
	Int ans = 0;
	for (Int i = 0; i < 100010; i++) {
		cnt = 0;
		for (Int c = 0; c < C; c++) {
			if (imos[c][i])cnt++;
		}
		ans = max(ans, cnt);//最大値
	}

	cout << ans << "\n";

}


Measured memory_bytes: 24576
/**
*    author:  boutarou
*    created: 02.08.2020 21:04:02
**/

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

int main() {
    int k;
    cin >> k;
    vector<bool> visit(k, false);
    int now = 0;
    int ans = 0;
    while(1) {
        now = now * 10 + 7;
        now %= k;
        ans++;
        if (visit[now]) break;
        visit[now] = true;
        if (now == 0) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3696