akhauriyash/Code-Regression huggingface dataset:
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> y;
	for (int i = x; i <= y; i++) {
		string s = to_string(i);
		string w = s;
		reve(s);
		if (s == w)cnt++;
	}
	cout << cnt << rt;
	please AC;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[100]={0};

int main(int argc, char* argv[])
{
    scanf("%s", str);

    char str0[]="AKIHABARA";

    long i,j;
    for(i=0; i<(1<<9); i++) {
        if((i&(1<<1))&&(i&(1<<2))&&(i&(1<<3))&&(i&(1<<5))&&(i&(1<<7))) {
            char str1[100]={0};
            for(j=0; j<9; j++) {
                if(i & (1<<j)) {
                    char strtmp[4]={0};
                    sprintf(strtmp, "%c", str0[j]);
                    strcat(str1, strtmp);
                }
            }
            if(strcmp(str1, str)==0) {
                printf("YES\n"); return 0;
            }
        }
    }
    printf("NO\n");

    return 0;
}


Measured memory_bytes: 128
/// Thank you tanakh!!!
///  https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve(init: i64, buy: i64, monitor: i64, add: i64) -> bool {
    // monitor < init + add * x - buy * y < buy
    if init < buy || add < buy {
        false
    } else if buy <= monitor {
        true
    } else {
        let g = gcd(add, buy);
        let low = monitor - init;
        let high = buy - init;
        if high <= 0 {
            let (high, low) = (-low, -high);
            let x = (high - 1) / g * g;
            if x > low {
                false
            } else {
                true
            }
        } else {
            let x = (high - 1) / g * g;
            if x > low {
                false
            } else {
                true
            }
        }
    }
}

fn main() {
    input!(t: usize, abcd: [(i64, i64, i64, i64); t]);

    for &(init, buy, monitor, add) in abcd.iter() {
        if solve(init, buy, monitor, add) {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
int w,h,n;
int xma,xmi,yma,ymi;
signed main() {
	cin>>w>>h>>n;
	xma=w,yma=h;
	rep(i,n){
		int x,y,a;
		cin>>x>>y>>a;
		if(a==1)xmi=max(xmi,x);
		else if(a==2)xma=min(x,xma);
		else if(a==3)ymi=max(ymi,y);
		else yma=min(y,yma);
	}
	//cout<<xma<<" "<<xmi<<" "<<yma<<" "<<ymi<<endl;
	if(xma-xmi<=0||yma-ymi<=0)cout<<0<<endl;
	else cout<<max((int)0,(xma-xmi)*(yma-ymi))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin >> n;

	vector<int64_t> vals(n);
	for (auto& val : vals) {
		cin >> val;
	}
	sort(vals.begin(), vals.end());

	list<int64_t> process(vals.begin(), vals.end());

	std::vector<pair<int64_t, int64_t>> seq;

	auto it = process.begin();
	it++;
	auto last = process.end();
	last--;
	while (it != last) {
		//cout << *it << endl;
		if (*it < 0) {
			seq.push_back({ process.back(), *it });
			process.back() -= *it;
			//cout << "back : " << process.back() << endl;
		}
		else {
			seq.push_back({ process.front(), *it });
			process.front() -= *it;
			//cout << "front : " << process.front() << endl;
		}
		it = process.erase(it);
	}
	seq.push_back({ process.back(), process.front() });

	cout << process.back() - process.front() << endl;
	for (auto& elem : seq) {
		cout << elem.first << " " << elem.second << endl;
	}

	return 0;
}

Measured memory_bytes: 7536
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
void dfs(int src,vector<int> adj[],bool visited[],int arr[],int dp[],int val)
{
	if(visited[src])
	   return ;
	else
	{
		val+=dp[src];
		arr[src]=val;
		visited[src]=true;
		for(int x:adj[src])
		    dfs(x,adj,visited,arr,dp,val);
	}
}
int32_t main()
{
	int n,q;
	scanf("%lld%lld",&n,&q);
	int dp[n+1]={0};
	int arr[n+1]={0};
	vector<int> adj[n+1];
	int j;
	for(j=0;j<n-1;j++)
	{
		int u,v;
		scanf("%lld%lld",&u,&v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(j=0;j<q;j++)
	{
		int x,y;
		scanf("%lld",&x);
		scanf("%lld",&y);
		dp[x]+=y;
	}
	int val=0;
	bool visited[n+1]={false};
	dfs(1,adj,visited,arr,dp,val);
	for(j=1;j<=n;j++)
	{
		printf("%lld ",arr[j]);
	}
	printf("\n");
}


Measured memory_bytes: 32256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double t,a;
  cin>>n>>t>>a;
  double h[1000];
  double diff=1e9+7;
  int mem;
  for(int i=0;i<n;i++){
    cin>>h[i];
    if(diff>abs(a-(t-h[i]*0.006))){
      diff=abs(a-(t-h[i]*0.006));
      mem=i;
    }
  }
  cout<<mem+1<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N,M,X,Y; cin>>N>>M>>X>>Y;
  vector<ll> x(N);
  vector<ll> y(M);
	rep(i,N) cin>>x[i];
     rep(i,M) cin>>y[i];
  x.pb(X);
  y.pb(Y);
 	sort(x.bg,x.ed);
  sort(y.bg,y.ed);
  if(x[N]<y[0]) cout<<"No War";
  else cout<<"War";
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long n,i,a[100000];
	long long sum,x=0,f=0;
	scanf("%lld",&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(a[i]==0){
			f=2;
		}
	}
	if(f==2) printf("0\n");
	else {
		sum=a[0];
		for(i=1;i<n;i++){
			x=1000000000000000000/a[i];
			if(sum>x){
				f=1;
				break;
			}
			else{
				sum*=a[i];
			}
		}
		if(f==1) printf("-1\n");
		else printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2480
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c)
{
    stack<int> S;
    S.push(r);
    color[r] = c;
    while (!S.empty())
    {
        int u = S.top();
        S.pop();
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            if (color[v] == NIL)
            {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; i++)
    {
        color[i] = NIL;
    }
    for (int u = 0; u < n; u++)
    {
        if (color[u] == NIL)
        {
            dfs(u, id++);
        }
    }
}

int main()
{
    int s, t, m, q;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();

    cin >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> s >> t;
        if (color[s] == color[t])
        {
            cout << "yes" << endl;
        }
        else
        {
            cout << "no" << endl;
        }
    }
    return 0;
}


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

int main()
{
  vector<int> a(2);
  int t;
  for(int i=0;i<3;i++)
  {
    cin>>t;
    if(t==5)
      a[0]++;
    if(t==7)
      a[1]++;
  }
  if(a[0]==2&&a[1]==1)
    cout<<"YES\n";
  else
    cout<<"NO\n";
 return 0;
}
  

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int N;
    int64_t A, B;
    cin >> N >> A >> B;
    vector<int64_t> X(N);
    for(int i=0; i<N; i++) {
        cin >> X[i];
    }

    int64_t ans = 0;
    for(int i=1; i<N; i++) {
        ans += min((X[i]-X[i-1])*A, B);
    }

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


Measured memory_bytes: 1024
import sys
from collections import Counter

input = sys.stdin.readline

def main():
    N = int(input())
    
    count = Counter()
    
    for i in range(1, N+1):
        s = str(i)
        count[(s[0], s[-1])] += 1
        
    ans = 0
    
    for i in range(1, N+1):
        s = str(i)
        ans += count[(s[-1], s[0])]
        
    print(ans)
if __name__ == '__main__':
    main()    


Measured memory_bytes: 3316
#include <iostream>

int main() {
  int a[3],b[3],d[4];
  for(int i = 0; i < 4; ++i) d[i] = 0;
  for(int i = 0; i < 3; ++i) {
    std::cin >> a[i] >> b[i];
    d[a[i]-1]++;
    d[b[i]-1]++;
  }
  int odd = 0;
  for(int i =0; i < 4; ++i) {
    if(d[i] % 2 != 0) odd++;
  }
  if (odd == 0 || odd == 2) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second)return a.second < b.second;
    else return a.first < b.first;
}


void solve(long long N){
    int ans=0;
    for(int i=1; i <=N; i++){
        int cnt=0;
        if(i%2==0)continue;
        for(int j=1; j<=N; j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll x, a;
    cin >> x >> a;
    if(x < a){
        cout << 0 << endl;
    }else{
        cout << 10 << endl;
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> mat;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define mset(a,x) memset(a,x,sizeof(a))
#define FASTIO cin.tie(0),ios::sync_with_stdio(0)

int n, ma, mb;
const int INF = 114514810;

int main() {
    cin >> n >> ma >> mb;
    static int a[44], b[44], c[44];
    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    static int dp[44][444][444];
    rep(i, 44) rep(j, 444) rep(k, 444) dp[i][j][k] = INF;

    dp[0][0][0] = 0;
    rep(i, n) rep(ca, 444) rep(cb, 444) {
        dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
        dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
    }

    int res = INF;
    FOR(ca, 1, 444) FOR(cb, 1, 444) {
        if (ca * mb == cb * ma)
            res = min(res, dp[n][ca][cb]);
    }

    cout << (res == INF ? -1 : res) << endl;


    return 0;
}

Measured memory_bytes: 34304
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <vector>
#include <string>

using ll = long long;

using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<bool> used(n, false);
    for (int i = 0; i < k; ++i) {
        int d;
        cin >> d;
        for (int j = 0; j < d; ++j) {
            int val;
            cin >> val;
            used[val - 1] = true;
        }
    }
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            ++sum;
        }
    }
    cout << sum << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    solve();
}


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


int main() {

    int k;
    cin>>k;

    queue<long long int> lunlun;
    for (int i=1; i<=9; i++){
        lunlun.push(i);
    }

    for (int i=1; i<k; i++){
        long long int x = lunlun.front();
        lunlun.pop();
        if (x%10==0){
            lunlun.push(x*10+x%10);
            lunlun.push(x*10+x%10+1);
        }
        else if (x%10==9){
            lunlun.push(x*10+x%10-1);
            lunlun.push(x*10+x%10);
        }
        else {
            lunlun.push(x*10+x%10-1);
            lunlun.push(x*10+x%10);
            lunlun.push(x*10+x%10+1);
        }
    }
    cout<<lunlun.front();
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

ll modpower(ll x, ll y) {
	if (y == 0)
		return 1;
	ll p = modpower(x, y / 2) % mod;
	p = (p * p) % mod;
	return y & 1 ? (x * p) % mod: p;
}

vl dp;
ll n, k;

ll rec(int i) {
    if (dp[i] != -1)
        return dp[i];
    ll ans = modpower(i, n);
    for (ll j = 2;j <= i;j++) {
        if (i/j > 0) {
            ans = (ans - rec(i/j) + mod) % mod;
		}
		else
			break;
	}
    return dp[i] = ans;
}

int main() {
	fast_io;
	cin >> n >> k;
	dp.assign(k + 1, -1);
	dp[0] = 0;
	ll ans = 0;
	for (ll i = 1;i <= k;i++) {
		ans = (ans + i * rec(k / i)) % mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3904
#coding:utf-8


str = gets.chomp.split(',').map(&:to_i) 
while str != nil do
	dis,speed = str[0,10], str[10,2]
	length = dis.inject {|sum,n| sum+n}
	time = (length.to_f/(speed[0]+speed[1]).to_f).to_f
	loc = time * speed[0]
	pos = 0
	#print "time:#{time}\n"
	#print "loc:#{loc}\n"

	0.upto(9) {|i|
		loc -= dis[i]
		if loc < 0 then
			pos = i+1
			break
		elsif loc==0 then
			pos = i+1
			break
		end
	}
	puts pos
	#puts 

	str = nil	
	line = gets
	str = line.chomp.split(',').map(&:to_i)  if line != nil
end

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll N; cin>>N;
  cout<<N/3;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N,A,B;
    cin >> N >> A >> B;

    ll tmp = N/(A+B);
    if( B == 0 ) cout << N << endl;
    else if( A == 0 ) cout << 0 << endl;
    else if( N%(A+B) <= A )
    {
        cout << tmp * A + N%(A+B) << endl;
    }
    else cout << tmp * A + A << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int data[7];
void N(){int x=data[5];data[5]=data[1];data[1]=data[2];data[2]=data[6];data[6]=x;}
void S(){int x=data[5];data[5]=data[6];data[6]=data[2];data[2]=data[1];data[1]=x;}
void E(){int x=data[3];data[3]=data[1];data[1]=data[4];data[4]=data[6];data[6]=x;}
void W(){int x=data[4];data[4]=data[1];data[1]=data[3];data[3]=data[6];data[6]=x;}
int main(){
  string com;
  for(int i=1;i<=6;++i)cin>>data[i];
  getline(cin,com);
  getline(cin,com);
  for(auto ch:com){
    if(ch=='N')N();
    if(ch=='S')S();
    if(ch=='E')E();
    if(ch=='W')W();
  }
  cout<<data[1]<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;

int main(){
    int N, K; cin >> N >> K;
    vector<int> p(N);
    rep(i,N) cin >> p[i];

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

    int ans = 0;
    rep(i,K){
        ans += p[i];
    }

    cout << ans << endl;
   
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

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 round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int x,t;
    scanf("%d%d",&x,&t);
    printf("%d\n",max(x-t,0));
    return 0;
}

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

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}
	
	long pow(long a,long n) {
		return n!=0?pow(a*a,n/2)*(n%2==1?a:1):1;
	}
	
	int[] f(long a) {
		int[] ret=new int[2];
		while (a%2==0) {
			ret[0]++;
			a/=2;
		}
		while (a%5==0) {
			ret[1]++;
			a/=5;
		}
		ret[0]=Math.min(ret[0], 9);
		ret[1]=Math.min(ret[1], 9);
		return ret;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		long[][][][] cnt=new long[10][10][10][10];
		for (int i=0;i<N;++i) {
			String str=sc.next();
			String[] strs=str.split("\\.");
			int c=strs.length==1?0:strs[1].length();
			long A=Long.valueOf(strs[0]+(strs.length==1?"":strs[1]));
			long num=A;
			long den=pow(10,c);
			long gcd=gcd(num,den);
			num/=gcd;
			den/=gcd;
			int[] p=f(num);
			int[] q=f(den);
			cnt[p[0]][p[1]][q[0]][q[1]]++;
		}
		
		long ans=0;
		for (int i=0;i<10;++i) {
			for (int j=0;j<10;++j) {
				for (int k=0;k<10;++k) {
					for (int l=0;l<10;++l) {
						if (cnt[i][j][k][l]==0) continue;
						for (int i2=k;i2<10;++i2) {
							for (int j2=l;j2<10;++j2) {
								for (int k2=0;k2<=i;++k2) {
									for (int l2=0;l2<=j;++l2) {
										if (cnt[i2][j2][k2][l2]==0) continue;
										if (i==i2&&j==j2&&k==k2&&l==l2) continue;
										ans+=cnt[i][j][k][l]*cnt[i2][j2][k2][l2];
									}
								}
							}
						}
					}
				}
			}
		}
		
		ans/=2;
		for (int i=0;i<10;++i) {
			for (int j=0;j<10;++j) {
				long d=cnt[i][j][0][0];
				if (d==0) continue;
				ans+=d*(d-1)/2;
			}
		}
		
		System.out.println(ans);
		
	}	
	
	

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}


Measured memory_bytes: 60944
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  int N, Q;
  cin >> N >> Q;
  string str;
  cin >> str;

  // 累積和
  vector<int> s(N+1, 0);
  rep(i, N) {
    if (i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
    else s[i+1] = s[i];
  }

  for (int q = 0; q < Q; ++q) {
    int l, r;
    cin >> l >> r;
    --l;
    --r;
    cout << s[r] - s[l] << endl;
  }

  return 0;
}

Measured memory_bytes: 3820
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.AISing
{
    class C
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var count = new int[n + 1];
            var nsqrt = (int)Math.Sqrt(n);
            var square = Enumerable.Range(0, 2 * nsqrt + 1).Select(x => x * x).ToArray();

            for (int x = 1; x <= nsqrt; x++)
            {
                for (int y = 1; y <= nsqrt; y++)
                {
                    for (int z = 1; z <= nsqrt; z++)
                    {
                        var a = square[x + y] + square[y + z] + square[z + x];
                        if (2 * n < a || a % 2 == 1)
                            break;
                        count[a/2]++;
                    }
                }
            }
            for (int i = 1; i <= n; i++)
                Console.WriteLine(count[i]);
        }
    }
}


Measured memory_bytes: 28244
import numpy as np
def main():
    N = int(input())
    T, A = map(int, input().split())
    H = list(map(int, input().split()))
    for i in range(N):
        H[i] = T- H[i] * 0.006
    
    print(np.abs(np.asarray(H) - A).argmin()+1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 12492
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
ll nums[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N) cin>>nums[i];
    
    ll sum=0, l=0, cnt=0;
    rep(r,N){
        while(sum&nums[r]) sum-=nums[l++];
        sum+=nums[r];
        cnt+=(r-l)+1;
    }
    cout1(cnt)
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

const int OpeSize = 15;

struct data{
  char ope,dir;
};

vector<data> V[OpeSize];

void input(){

  for(int i = 0; i < OpeSize; i++) V[i].clear();

  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    char d;
    int num;
    cin >> d;
    cin >> num;
    while(num--){
      char ope;
      cin >> ope;
      V[i].push_back((data){ope,d});
    }
  }
}

bool isVar(const string& s){
  if(s.length() != 1) return false;
  return 'a' <= s[0] && s[0] <= 'z';
}

string rmPara(string s){
  if(s[0] != '(' || s[s.length()-1] != ')') return s;

  int p = 0;
  for(int i = 0; i < (int)s.length()-1; i++){
    if(s[i] == '(') p++;
    if(s[i] == ')') p--;
    if(p == 0) return s;
  }
  return s.substr(1,s.length()-2);
}

bool match(const vector<data>& v, const char c){
  for(int i = 0; i < (int)v.size(); i++)
    if(v[i].ope == c) return true;
  return false;
}

int find(const vector<data>& v, const string& s){
  int p = 0;

  if(v[0].dir == 'L'){
    for(int i = s.length()-1; i >= 0; i--){
      if(s[i] == '(') p++;
      if(s[i] == ')') p--;
      if(p == 0 && match(v,s[i])) return i;
    }
  }else{
    for(int i = 0; i < (int)s.length(); i++){
      if(s[i] == '(') p++;
      if(s[i] == ')') p--;
      if(p == 0 && match(v,s[i])) return i;
    }
  }
  return -1;
}

string parse(string s){

  s = rmPara(s);
 
  if(isVar(s)){
    return s;
  }else{
    //Expr Op Expr
    
    for(int i = 0; i < OpeSize; i++){
      if(V[i].empty()) continue;
      int pos = find(V[i],s);
      if(pos != -1){
	return "(" + parse(s.substr(0,pos)) + s[pos]  + parse(s.substr(pos+1)) + ")";
      }
    }
  }
  return parse(s);
}

int main(){
  
  int T;
  cin >> T;
  while(T--){
    input();
    int N;
    cin >> N;
    while(N--){
      string s;
      cin >> s;
      cout << parse(s) << endl;
    }
    if(T > 0) cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
<?php
$k=trim(fgets(STDIN));
$a=array(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);
echo $a[$k-1];


Measured memory_bytes: 4856
#
# abc071 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """6
3 1 2 4 2 1"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 3 4"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10
3 3 3 3 4 4 4 5 5 5"""
        output = """20"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)
    l1 = l2 = 0
    for i in range(1, N):
        if l1 == 0:
            if A[i] == A[i-1]:
                l1 = A[i-1]
        else:
            if i < N-1 and A[i+1] == A[i]:
                l2 = A[i]
                break

    print(l1*l2)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 27824
//赤ペン先生

#include<bits/stdc++.h>

using namespace std;

signed main(){
    
    int N,answer = 0;
    cin>>N;
    
    vector<int> A,B,C;
    
    for(int i = 0; i < N ;i++ ){
        int num;
        cin >> num;
        A.push_back(num);
    }
    for(int i = 0; i < N ;i++ ){
        int num;
        cin >> num;
        B.push_back(num);
        answer += num;
    }
    for(int i = 0; i < N-1 ;i++ ){
        int num;
        cin >> num;
        C.push_back(num);
    }
    
    for(int i = 0; i< N ; i++){
        
        if( A[i+1] - A[i] == 1) {
            int t = C[A[i]-1] ;
            answer += t ;
        }
    }
    
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 100 * 1000 + 7;

ll dp[MX];
int a[MX];

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 2; i <= n; i++) {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        if (i > 2) {
            dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
        }
    }
    cout << dp[n] << "\n";
    return 0;
}



Measured memory_bytes: 1408
s=list(map(int,input()))
c=0
cnt=[0]*2019
cnt[0]+=1
for k in range(len(s)-1,-1,-1):
	c=(c+s[k]*pow(10,len(s)-1-k,2019))%2019
	cnt[c]+=1
print(sum(x*(x-1)//2 for x in cnt))

Measured memory_bytes: 85076
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> a(n),cnt(100005);
   for(int i=0;i<n;i++){
       cin>>a[i];
       cnt[a[i]]++;
   }
   int sum=0;
   for(int i=0;i<100005;i++){
       if(cnt[i]>1)sum+=cnt[i]-1;
   }
   int ans;
   if(sum%2==0)ans=n-sum;
   else ans=n-sum-1;
   cout<<ans<<endl;

}

   


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define DEBUGM(d,n,m,i,j) printf("DEBUGM :\n"); rep(i,n){ rep(j,m) if(inf==d[i][j]) printf("inf "); else printf("%d ", d[i][j]); printf("\n");} printf("DEBUGM END LINE\n")

typedef long long ll;

const ll INF =1LL << 62;
const int inf =1 << 29;

int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int lc=0,rc=0;
    rep(i,n){
        if(s[i] == '('){
            lc++;
        }else if(s[i] == ')'){
            if(lc>0) lc--;
            else rc++;
        }
    }
    rep(i,rc) putchar('(');
    cout << s;
    rep(i,lc) putchar(')');
    putchar('\n');
    
    return 0;
}

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

s2=s/2
cnt=0
for i,k in zip(a,range(len(a))):
    cnt+=i
    if cnt>s/2:
        break
my2=True
if cnt-a[k]<s-cnt:#小さいほう
    res=0
    my=True
    b=cnt
else:
    res=0
    my=True
    b=s-cnt+a[k]

c=s-b
if s-(c*2)==b-c:
    print(int(b-c))
else:
    print(0)

Measured memory_bytes: 87888
#include<bits/stdc++.h>
using namespace std;
#define maxn 250010
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,m,a[maxn],cnt[maxn],ans[maxn],pos[maxn];
int main()
{
	read(n);
	m=n*n;
	for(int i=1;i<=n;i++)
	{
		read(a[i]);
		if(ans[a[i]])
		{
			puts("No");
			return 0;
		}
		cnt[a[i]]=i;
		ans[a[i]]=i;
		pos[a[i]]=i;
	}
	for(int i=1;i<=m;i++)
	{
		cnt[i]+=cnt[i-1];
		if(cnt[i]>i)
		{
			puts("No");
			return 0;
		}
	}
	int p=1;
	for(int i=1;i<=m;i++)
	{
		if(pos[i])
		{
			for(int s=ans[i]-1;s;s--)
			{
				while(ans[p])
					p+=1;
				if(p>i)
				{
					puts("No");
					return 0;
				}
				ans[p]=ans[i];
			}
		}
	}
	p=m;
	for(int i=m;i>=1;i--)
	{
		if(pos[i])
		{
			for(int s=n-ans[i];s;s--)
			{
				while(ans[p])
					p-=1;
				if(p<i)
				{
					puts("No");
					return 0;
				}
				ans[p]=ans[i];
			}
		}
	}
	puts("Yes");
	for(int i=1;i<=m;i++)
		printf("%d ",ans[i]);
    return 0;
}


Measured memory_bytes: 3840
/*
If you want to shine like a sun, first burn like a sun.
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf 9e18
#define minf -9e18
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
*/
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    ll val = 0;
    ll k;
    forn(i,0,n)
    {
    	cin>>k;

    	if(k == (val+1))
    	{
    		val++;
    	}
    }

    if(val)
    {
    	cout<<n-val;
    }
    else
    {
    	cout<<-1;
    }








    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
 using namespace std;
 const int maxn=1e5+10;
 typedef long long ll;
 int fa[maxn],siz[maxn];
 vector<int> a[maxn],b[maxn];
 int find(int x){return (x==fa[x])?x:fa[x]=find(fa[x]);}
 int main()
 {
 	int n,m,k,u,v;
 	scanf("%d%d%d",&n,&m,&k);
 	for(int i=1;i<=n;i++){
 		fa[i]=i;
 		siz[i]=1;
	 }
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		int f1=find(u),f2=find(v);
		if(f1!=f2){
			siz[f1]+=siz[f2];
			fa[f2]=f1;
		}
		a[u].push_back(v);
		a[v].push_back(u); 
	}
	for(int i=1;i<=k;i++){
		scanf("%d%d",&u,&v);
		b[u].push_back(v);
		b[v].push_back(u);
	} 
	for(int i=1;i<=n;i++){
		int ans=siz[find(i)]-1;
		ans-=a[i].size();
		for(int j=0;j<b[i].size();j++){
			if(find(i)==find(b[i][j]))
				ans--;
		}	
		cout<<ans<<" ";
	}
	return 0;
 }

Measured memory_bytes: 13176
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Text;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            int K = cin.NextInt();
            int[] p = cin.ArrayInt(N);
            int ans = 0;

            Array.Sort(p);
            for(int i = 0; i < K; i++)
            {
                ans += p[i];
            }
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}



Measured memory_bytes: 27908
/* Author rumoisen */
/* created 2018/11/08 */

#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <iostream>

using namespace std;
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no(){cout<<"No"<<endl;exit(0);}
void yes(){cout<<"Yes"<<endl;exit(0);}
void No(){cout<<"NO"<<endl;exit(0);}
void Yes(){cout<<"YES"<<endl;exit(0);}

using namespace std;

int main(void)
{
    string s;
    cin>>s;
    int ans=0;
    if(s[0]=='1') ans++;
    if(s[1]=='1') ans++;
    if(s[2]=='1') ans++;
    cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 256
import java.util.Scanner; 

public class Main {

	public static void main(String[] args) {
		String num;
		int res = 0;
		
		Scanner scanner = new Scanner(System.in);
		num = scanner.next();
		int[] array = new int[100000000];
		for(int i = 0; i < num.length(); i++) {
			array[i] = num.charAt(i)-48;
			res += array[i];
		}
		int valor = Integer.parseInt(num);
		if(valor % res == 0) {
			System.out.println("Yes");
		}else
			System.out.println("No");
	}
}


Measured memory_bytes: 417876
#include<iostream>

using namespace std;

int cal_money(int money, int coin_N[])
{
	int coins[6] = { 1,5,10,50,100,500 };
	int okay = 0;

	for (int i = 5; i>=0; i--)
	{
		for (; coin_N[i]>0; coin_N[i]--)
		{
			money -= coins[i];
			if (money == 0)
				{okay = 1; break;}
		}
	}

	return okay;

}

int main(void)
{
	int coin_N[6];
	int okay;

	for (int i = 0; i<6; i++)
		cin >> coin_N[i];

	okay = cal_money(1000, coin_N);

	cout << okay << endl;

	return 0;
}

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

int main()
{
    int x;
    cin >> x;
    int k = 1;
    for (int i = 1800; i >= 400; i -= 200, ++k)
    {
        if (x >= i)
        {
            cout << k << endl;
            return 0;
        }
    }
}

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

int main(){
    int n,x;cin>>n>>x;
    int m[1000],sum=0,Min=1001;
    for(int i=0;i<n;i++){
        cin>>m[i];
        sum+=m[i];
        Min=min(Min,m[i]);
    }
    int ans=n+(x-sum)/Min;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())
T, A =map(int,input().split())
H = list(map(int,input().split()))
ans = 0
absT = 100000
for i in range(N):
    if abs(T-H[i]*0.006-A)<=absT:
        absT = abs(T-H[i]*0.006-A)
        ans = i+1
print(ans)

Measured memory_bytes: 3060