akhauriyash/Code-Regression huggingface dataset:
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;
const int maxn = 45;
int s[maxn][maxn];
int dir[4][2] = {
	-1,0, 1,0, 0,-1, 0,1
};
int n, m;
int stx, sty, edx, edy;
int ansd;

inline bool judge(int x, int y) {
	return x<0 || x>=n || y<0 || y>=m;
}

void init() {
	rep(i, 0, n) {
		rep(j, 0, m) {
			if (s[i][j] == 2) {
				stx = i;
				sty = j;
				s[i][j] = 0;
			} else if (s[i][j] == 3) {
				edx = i;
				edy = j;
				s[i][j] = 0;
			}
		}
	}
}

void dfs(int dep, int x, int y) {
	if (dep >= ansd) return;
	if (x==edx && y==edy) {
		ansd = dep;
		return ;
	}
	
	int xx, yy;
	int flag;
	
	rep(i, 0, 4) {
		xx = x;
		yy = y;
		if (judge(xx+dir[i][0], yy+dir[i][1]) || s[xx+dir[i][0]][yy+dir[i][1]] == 1) continue;
		
		flag = 1;
		while (true) {
			if (judge(xx+dir[i][0], yy+dir[i][1])) {
				flag = 0;
				break;
			}
			
			if (s[xx+dir[i][0]][yy+dir[i][1]] == 1) {
				flag = -1;
				break;
			}
			
			xx += dir[i][0];
			yy += dir[i][1];
			
			if (xx==edx && yy==edy) {
				break;
			}
		}
		
		if (flag == 0) continue;
		
		if (flag == -1) {
			s[xx+dir[i][0]][yy+dir[i][1]] = 0;
		}
		
		dfs(dep+1, xx, yy);
		
		if (flag == -1) {
			s[xx+dir[i][0]][yy+dir[i][1]] = 1;
		}
	}
}

void solve() {
	init();
	ansd = 11;
	dfs(0, stx, sty);
	if (ansd == 11) ansd = -1;
	printf("%d\n", ansd);
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	while (scanf("%d %d", &m,&n)!=EOF && (n||m)) {
		rep(i, 0, n)
			rep(j, 0, m)
				scanf("%d", &s[i][j]);
		solve();
	}
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}

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

using namespace std;

#define int long long

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (a > 0 && c > 0)
    {
        c -= b;
        if (c <= 0)
        {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0)
        {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

int A,B;
scanf("%d%d",&A,&B);

int C = A+B;
int D = A-B;
int E = A*B;

if(C <= D){
if(D <= E){
printf("%d\n", E);
}else{
printf("%d\n", D);
}
}else{
if(C <= E){
printf("%d\n", E);
}else{
printf("%d\n", C);
}
}
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        int x = a * 10 + b + c;
        int y = a + b * 10 + c;
        int z = a + b + c * 10;

        System.out.println(Math.max(Math.max(x, y), z));
    }
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  cout<<(n+1)/2<<endl;
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = int(1e9+7)
fans = 0
for x in range(k, n + 2):
    mm = (k-1) * k / 2
    # sum of least values
    minv = (((x-1) * x) % mod * pow(2, mod-2, mod)) % mod
    # sum of most values
    maxv = ((n * (n+1)) % mod * pow(2, mod-2, mod)) % mod
    # sum upto n-k
    mmm = (((n-x) * (n-x+1)) % mod * pow(2, mod-2, mod)) % mod
    maxv = maxv - mmm
    while maxv < 0:
        maxv += mod
    fans = (fans + maxv - (minv-1))%mod
while fans < 0:
    fans += mod
print(fans)


Measured memory_bytes: 68432
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N,M;
    cin>>N>>M;
    priority_queue<int> Q;
    rep(i,N){
        int A;
        cin>>A;
        Q.push(A);
    }
    rep(i,M){
        int B = Q.top();Q.pop();
        B /= 2;
        Q.push(B);
    }
    ll ans = 0;
    while(!(Q.empty())){
        int C = Q.top();
        Q.pop();
        ans += C;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 892
#!/usr/bin/env ruby
# frozen_string_literal: true
n = gets.to_i
w = gets.split.map(&:to_i)
sum = w.inject(:+)
min = sum
diff = 0
(0...n-1).each do |i|
  diff += w[i]
  min = (diff-(sum-diff)).abs if (diff - (sum - diff)).abs < min
end
puts min



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

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<bool> v(n+1,true);
		for(int i=2; i<=sqrt(n); i++){
			if(v[i]){
				for(int j=2; i*j<=n;j++){
						v[i*j]=false;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i])
				cnt++;
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

	private static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int k = sc.nextInt(), s = sc.nextInt();
		int ans = 0;
		for (int i = 0; i <= k; i++) {
			for (int j = 0; j <= k; j++) {
				int tmp = s - (i + j);
				if (0 <= tmp && tmp <= k) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}

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

int gcd(int a, int b){
    if(a < b) swap(a, b);
    return (a % b ? gcd(b, a % b) : b);
}

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

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

    vector<int> L(n), R(n);
    L[0] = A[0];
    R[n - 1] = A[n - 1];
    for(int i = 0; i < n - 1; i++){
        if(i == 0) L[i + 1] = gcd(A[i], A[i + 1]);
        else L[i + 1] = gcd(L[i], A[i + 1]);
    }

    for(int i = n - 1; i >= 1; i--){
        if(i == n - 1) R[i - 1] = gcd(A[i], A[i - 1]);
        else R[i - 1] = gcd(R[i], A[i - 1]);
    }

    int maxi = 1;
    for(int i = 0; i < n; i++){
        if(i == 0){
            maxi = max(maxi, R[i + 1]);
        }else if(i == n - 1){
            maxi = max(maxi, L[i - 1]);
        }else{
            maxi = max(maxi, gcd(L[i - 1], R[i + 1]));
        }
    }

    cout << maxi << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int max(int a,int b){return (a>b ? a:b);}
int min(int a,int b){return (a<b ? a:b);}

int compare_int(const void *a, const void *b){return *(int*)a - *(int*)b;}
//これは昇べきの順のソート

//int compare_int(const void *a, const void *b){return *(int*)b - *(int*)a;}
//これは降べきの順のソート

//qsort(配列, 長さ, sizeof(int), compare_int);

double BS(int array[],int len,int target);

//////////////////////////////////////////

long long A,B;
long long fA,fB;

long long HW(long long a,long long b){
    long long a2 = 1,b2 = 1,m;
    long long s,s1 = 0,s2 = 0;
    while(a2 <= a){
        a2 *= 2;
        s1++;
    }
    while(b2 <= b){
        b2 *= 2;
        s2++;
    }
    s = max(s1,s2);

    a2 = a;
    b2 = b;
    int ra,rb;
    long long hw = 0;
    m = 1;
    for(int i = 0;i < s;i++){
        ra = a2 % 2;
        rb = b2 % 2;
        if((ra - rb) != 0){
            hw += m;
        }
        m *= 2;
        a2 /= 2;
        b2 /= 2;
    }
    return hw;
}

int main(){
    scanf("%lld%lld",&A,&B);

    int amariA = A % 4;
    long long a = A - amariA;
    long long haitaA = 0;
    
    for(int i = 0;i < amariA;i++){
        haitaA = HW(haitaA,a+i);
    }

    B = B+1;
    int amariB = B % 4;
    long long b = B - amariB;
    long long haitaB = 0;
    
    for(int i = 0;i < amariB;i++){
        haitaB = HW(haitaB,b+i);
    }

    //printf("%lld %lld\n",haitaA,haitaB);
    printf("%lld\n",HW(haitaA,haitaB));
    
    
    return 0;
}



///////////////////////////////////////////


double BS(int array[],int len,int target){ //(配列,長さ,見つける値)
    int low,mid,high;

    low = 0;
    high = len-1;

    int mark;

    while(low <= high){
        mid = (low + high) / 2;
        if(array[mid] == target){
            mark = 0;
            break;
        }else if(array[mid] < target){
            low = mid + 1;
            mark = 1;
        }else{
            high = mid - 1;
            mark = -1;
        }
    }
    if(mark == 0){
        return mid; //配列の何番目か（０から）
    }else if(mark == 1){
        return (double)mid + 0.5;//なかったらどこのあいだか
    }else{
        return (double)mid - 0.5;
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
}

bool UnionFind::same(int x, int y) {
    return root(x) == root(y);
}

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}


struct UF{
    vector<int> par;

    UF(int N):par(N){
        for(int i=0;i<N;i++) par[i] = i;
    }

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

    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx == ry) return;
        else{
            par[rx]=ry;
            return;
        }
    }

    bool same(int x,int y){
        int rx=root(x);
        int ry=root(y);
        return rx == ry;
    }
};



int main() {
    int n , m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<int> a(n);
    for (int i = 0 ; i < n;i++){
        cin >> a.at(i);
        a.at(i)--;
    }

    for (int i = 0 ; i < m;i++){
        int x, y;
        cin >> x >> y;
        uf.marge(x-1,y-1);
    }

    int cnt = 0;
    for (int i = 0 ;i < n ; i++){
        if (uf.same(i,a.at(i))) cnt++;
    }
    cout << cnt << endl;
}










Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>

int main(){
	int n,b,f,r,v,d[4][3][10]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		d[b-1][f-1][r-1]+=v;
 	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				printf(" %d",d[i][j][k]);
			}
			printf("\n");
		}
		if(i!=3){
			for(int l=0;l<20;l++){
				printf("#");
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, d;
	cin >> n >> d;
	cout << ceil((double)n/(d*2+1)) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    long long int a,b;
    cin>>a>>b;
    if((a+b)%2==1)
        cout<<"IMPOSSIBLE"<<endl;
    else
        cout<<(a+b)/2<<endl;






    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func r() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := r()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = r() - 1
	}

	var nowIdx int
	var ct int
	for {
		nextIdx := a[nowIdx]

		if ct >= n {
			ct = -1
			break
		}

		if nowIdx == 1 {
			break
		}

		nowIdx = nextIdx
		ct++
	}
	fmt.Println(ct)
}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long


/* dp[i+1][j] = (i+2)*aj + max{dp[i, k] | 1 <= j - k <= M} */
ll dp[305][100005];    /* dp[i][j]: i(0-indexed)番目にj(0-indexed)を選んだ時の得点の最大値 */

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
        dp[0][i] = a[i];
    }
    REP(i, k-1) {
        deque<ll> deq;
        /* スライド最大値でmaxを更新 */
        REPN(j, i, n) {
            int top_idx = max(0, j + 1 - m);
            /* 範囲外を除去 */
            if(!deq.empty() && deq.front() < top_idx) {
                deq.pop_front();
            }
            /* 後ろから見ていって対称より小さいものをpop */
            while(!deq.empty() && dp[i][deq.back()] < dp[i][j]) {
                deq.pop_back();
            }
            deq.push_back(j);
            dp[i+1][j+1] = dp[i][deq.front()] + a[j+1] * (i+2);
        }
    }

    ll ans = 0;
    REP(i, n) {
        ans = max(ans, dp[k-1][i]);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 236544
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	ll N; cin >> N;
	for (ll i = 1; i <= 3500; i++) {
		for (ll j = 1; j <=i; j++) {
			ll a = N * i * j;
			ll b = 4 * i * j - N * i - N * j;
			if (b>0 && a % b == 0) {
				cout << i << " " << j << " " << a / b << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
using namespace std;
int n,x,y,par[li],dep[li],vis[li];
set<int> s[li];
pair<int,int> B[li];
vector<int> v[li];
void dfs(int node,int ata){
	par[node]=ata;
	dep[node]=(ata!=-1?dep[ata]+1:1);
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata) continue;
		dfs(go,node);
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
		s[x].insert(y);
		s[y].insert(x);
	}
	dfs(1,-1);
	for(int i=1;i<=n;i++){
		B[i]=mp(dep[i],i);
	}
	sort(B+1,B+n+1,greater< pair<int,int> >());
	for(int i=1;i<=n;i++){
		int ind=B[i].se;
		if(vis[ind]==1) continue;
		int baba=par[ind];
		if((int)s[baba].size()>2){
			//printf("%d\n",ind);
			printf("First\n");
			return 0;
		}
		if((int)s[baba].size()==0 && vis[ind]==0){
			printf("First\n");
			return 0;
		}
		//printf("debug - >> %d\n",ind);
		int bb=par[baba];
		vis[ind]=1;
		vis[baba]=1;
		s[baba].erase(ind);
		s[ind].erase(baba);
		s[bb].erase(baba);
	}
	printf("Second\n");
	return 0;
}


Measured memory_bytes: 21888
# -*- coding:utf-8 -*-
X = list(input())
stack = []
for tmp in X:
    if tmp == 'T' and (len(stack) == 0 or stack[len(stack)-1] == 'T'):
        stack.append(tmp)
    elif tmp == 'T' and stack[len(stack)-1] == 'S':
        stack.pop()
    else:
        stack.append(tmp)
print(len(stack))

Measured memory_bytes: 6436
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const double pi=acos(-1);

int a,ans=-1;
map<int,int> m;

int main(){
	while(cin>>a) m[a]++;
	for(map<int,int>::iterator it=m.begin();it!=m.end();it++) ans=max(ans,it->second);
	for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
		if(ans==it->second) cout<<it->first<<endl;
	}
}

Measured memory_bytes: 1196
import math

a, b, h, m = map(int, input().split())
x = a*(math.cos(math.radians(30*h+0.5*m)))-b*(math.cos(math.radians(6*m)))
y = a*(math.sin(math.radians(30*h+0.5*m)))-b*(math.sin(math.radians(6*m)))
ans = math.sqrt(x**2+y**2)
print(ans)

Measured memory_bytes: 62364
#include <bits/stdc++.h>
#include <iostream>
#include <string>

#define f(i,n) for(int i = 0; i < n; i++)
#define fll(i,n) for(long long int i = 0; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define inf INT_MAX
#define pb push_back
#define all(x) x.begin(),x.end()
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
#define ans(x) cout<<x<<endl;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define mem(x,i) memset(x,i,sizeof x)

#define cin_vi(v,n) f(i,n){int temp;cin>>temp;v.pb(temp);}
#define cin_vll(v,n) fll(i,n){ll temp;cin>>temp;v.pb(temp);}
#define sort_desc(a) sort(a.begin(), a.end(), greater<int>());
#define sort_desc_ll(a) sort(a.begin(), a.end(), greater<long long int>());

using namespace std;

int main () {
	
	fast;

	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vll r,g,n,ans;
	cin_vll(r,a);
	cin_vll(g,b);
	cin_vll(n,c);
	// fll(i,r.size()){debug(r[i]);}
	// fll(i,g.size()){debug(g[i]);}
	// fll(i,n.size()){debug(n[i]);}

	sort_desc_ll(r);
	sort_desc_ll(g);
	sort_desc_ll(n);

	fll(i,x){ans.pb(r[i]);}
	fll(i,y){ans.pb(g[i]);}
	fll(i,x+y){if(i>=n.size()) break;ans.pb(n[i]);}

	sort_desc_ll(ans);
	// fll(i,ans.size()){debug(ans[i]);}
	ll sum=0;
	fll(i,x+y){sum+=ans[i];}
	ans(sum);

	return 0;
}

Measured memory_bytes: 8688
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;


int main(){
    cout << fixed << setprecision(10);
    
    double L;
    cin >> L;
    cout << pow(L / 3.0, 3.0);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (int argc, const char * argv[]) {
    float value;
	double y,t;
	int n;
	
	while (scanf("%f", &value) != EOF) {
		t = 0.0;
		n = 0;
		
		t = value/9.8;
		y = 4.9 * t*t;
		n = (y + 5)/5;
		
		printf("%d\n", n+1);
	}
	
    return 0;
}

Measured memory_bytes: 0
rot = {
    "North": (1,5,2,3,0,4),
    "East" : (3,1,0,5,4,2),
    "West" : (2,1,5,0,4,3),
    "South": (4,0,2,3,5,1),
    "Right": (0,2,4,1,3,5),
    "Left" : (0,3,1,4,2,5)
}
while 1:
    n = int(raw_input())
    if not n:
        break
    dice = [1,2,3,4,5,6]
    ans = 0
    for i in xrange(n):
        r = rot[raw_input()]
        dice = [dice[r[i]] for i in xrange(6)]
        ans += dice[0]
    print ans+1

Measured memory_bytes: 4240
using System;
 
namespace Sample
{
  class Sample
  {
    static void Main()
    {
      int N = int.Parse(Console.ReadLine());
      int H = int.Parse(Console.ReadLine());
      int W = int.Parse(Console.ReadLine());

      int ans= ((N+1)-H) * ((N+1)-W); //掲示板の大きさ

      Console.WriteLine(ans);

    }
  }
}

Measured memory_bytes: 11092
#include <iostream>

#ifdef _MSC_VER
#define getchar_unlocked _getchar_nolock
#endif

#define ll long long

int * vec;
ll ans = 0;
int n;
int * per;
ll * r;
ll * l;

void read_int_unlocked(int * out)
{
	static int c;
	*out = 0;
	c = getchar_unlocked();
	for (; '0' <= c && c <= '9'; c = getchar_unlocked())
		*out = (*out) * 10 + c - '0';
}

int main()
{
	read_int_unlocked(&n);
	vec = new int[n];
	int * start = vec;
	int * end = vec + n;
	for (int * i = start; i < end; i++)
		read_int_unlocked(i);
	
	per = new int[n];
	for (int * i = start; i < start + n; i++)
		*(per + (*i) - 1) = i - vec;

	r = new ll[n];
	for (auto i = r; i < r + n; i++)
		*i = 0;
	l = new ll[n];
	for (auto i = l; i < l + n; i++)
		*i = 0;

	int vsp, right, left;
	for (auto i = per; i < per + n - 1; i++)
	{
		vsp = *i;
		right = vsp + r[vsp] + 1;
		left = vsp - l[vsp] - 1;
		if (left == -1)
		{
			ans += vec[vsp] * ((r[right] + 1) * (1 + l[vsp]));
			l[right] = right;
		}
		else if (right == n)
		{
			ans += vec[vsp] * ((l[left] + 1) * (1 + r[vsp]));
			r[left] = n - left - 1;
		}
		else
		{
			ans += vec[vsp] * ((l[vsp] + 1) * (r[right] + 1) + (r[vsp] + 1) * (l[left] + 1));
			r[left] = l[right] = r[vsp] + l[vsp] + 1;
		}
	}

	std::cout << ans;
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll ans=0;
    ll n;cin >>n;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    sort(all(a));
    reverse(all(a));
    for (int i = 0; i < n; ++i) {
        if(i%2==0)ans+=a[i];
        else ans-=a[i];
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let hs = read_vec::<u32>();

    let mut max_count = 0;
    let mut tmp_count = 0;
    for i in 0..n-1 {
        if hs[i+1] <= hs[i] {
            tmp_count += 1;
        } else {
            if tmp_count >= max_count {
                max_count = tmp_count;
            }
            tmp_count = 0;
        }
    }

    if tmp_count >= max_count {
        max_count = tmp_count;
    }

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


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (1LL << 60);
vector<vector<pair<int64_t, bool>>> Graph(110, vector<pair<int64_t, bool>>(110, {INF, 0}));

void init()
{
  for (int i = 0; i < 110; i++)
  {
    for (int j = 0; j < 110; j++)
    {
      if (i == j)
      {
        Graph[i][j].first = 0;
      }
    }
  }
}

int main()
{
  init();
  int64_t N, M, a, b, c, ans = 0;
  cin >> N >> M;
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b >> c;
    Graph[a - 1][b - 1] = {c, 1};
    Graph[b - 1][a - 1] = {c, 1};
  }
  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        if (Graph[i][j].first > Graph[i][k].first + Graph[k][j].first)
        {
          Graph[i][j].first = Graph[i][k].first + Graph[k][j].first;
          if (Graph[i][j].second)
          {
            ans++;
            Graph[i][j].second = 0;
          }
        }
      }
    }
  }
  cout << ans / 2 << endl;
}

Measured memory_bytes: 3728
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        
        int m = sc.nextInt();
        int f = sc.nextInt();
        int r = sc.nextInt();
        
        while (m != -1 || f != -1 || r != -1) {
            if (m == -1 || f == -1) {
                System.out.println("F");
            }
            else if (m + f >= 80) {
                System.out.println("A");
            }
            else if (m + f >= 65 && m + f < 80) {
                System.out.println("B");
            }
            else if (m + f >= 50 && m + f < 65) {
                System.out.println("C");
            }
            else if (m + f >= 30 && m + f < 50) {
                if (r >= 50) {
                    System.out.println("C");
                }
                else {
                    System.out.println("D");
                }
            }
            else if (m + f < 30) {
                System.out.println("F");
            }
            
            m = sc.nextInt();
            f = sc.nextInt();
            r = sc.nextInt();
        }
    }
}

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

int main() {
	int n,sum=1;
	int i=0;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n;i++) {
		cin >> vec.at(i);
	}
	sort(vec.begin(), vec.end());
	reverse(vec.begin(), vec.end());
	for (int i = 0; i <n-1; i++) {


		if (vec.at(i) != vec.at(i + 1)) {
			sum++;
		}
	}
	cout << sum<< endl;


	//system("pause");
}


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
//using P = pair<double, double>;
using edge = struct {int to; ll cost;};

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()

const int di[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dj[] = {0, -1, 0, 1, 1, -1, 1, -1};
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;

struct prime
{
  vector<bool> num;
  prime(int n) : num(n+1, true)
  {
    num[0] = false;
    num[1] = false;
    for(int i = 2; i <= n; i++) {
      if(num[i]) {
        for(int j = 2; i*j <= n; j++) num[i*j] = false;
      }
    }
  }
  bool isPrime(int x)
  {
    return num[x];
  }
};
struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }
    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

long long gcd(long long a, long long b)
{
  if (a < b)
    swap(a, b);
  while (true)
  {
    if (a % b == 0ll)
      break;
    ll _a = a;
    a = b;
    b = _a % b;
  }
  return b;
}

long long lcm(long long a, long long b)
{
  return (max(a, b) / gcd(a, b)) * min(a, b);
}

void solve()
{
  int n;
  cin >> n;
  if(n / 1000 >= 1) cout << "ABD" << "\n";
  else cout << "ABC" << "\n";
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import math
import sys

a = [1]*10000000
a[0] = a[1] = 0

for i in range(2,int(math.sqrt(2000000))):
    if a[i] == 1:
        for j in range(i+i,2000000,i):
            a[j] = 0

for i in range(1,2000000):
    a[i] += a[i-1]
    
for line in sys.stdin:
    print(a[int(line)])
    

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int> >;

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

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

int N;
vector<int> detect;
vector<int> finish;
int cnt = 1;

void dfs( const Graph& G, int s ){
    detect[s] = cnt++;
    for( auto nv : G[s] ){
        if( !detect[nv] ) dfs( G, nv );
    }
    finish[s] = cnt++;
}

signed main(){
    cin >> N;
    Graph G( N + 1 );
    detect.resize( N + 1 );
    finish.resize( N + 1 );
    REP( i, N ){
        int from, k;
        cin >> from >> k;
        REP( j, k ){
            int to; cin >> to;
            G[from].push_back( to );
        }
    }

    REPONE( i, N ){
        if( detect[i] ) continue;
        dfs( G, i );
    }

    REPONE( i, N ){
        cout << i << " " << detect[i] << " " << finish[i] << endl;
    }
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 2e5 + 10;
int n;
ll a[N];
struct node { ll a, b, v; };
stack< node > s;
ll ans = 0;

inline ll read() {
	ll s = 0, f = 1;
	char ch;
	for(; ch < '0' || ch > '9'; ch = getchar())	if(ch == '-')	f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar())	s = (s << 1) + (s << 3) + ch - '0';
	return s * f;
}

int main() {
	n = read();
	for(int i = 1; i <= n; ++i)	a[i] = read();
	node f, g;
	f.a = f.b = 1;
	f.v = a[1];
	s.push(f);
	for(int i = 2; i <= n; ++i) {
		g.a = g.b = 1;
		g.v = a[i];		
		while(!s.empty() && g.v <= s.top().v) {
			f = s.top();
			s.pop();
			if(!s.empty())	s.top().a += f.a;
			g.b += f.b;
			ans += f.a * f.b * f.v;
		}
		s.push(g);
	}
	while(!s.empty()) {
		f = s.top();
		s.pop();
		if(!s.empty())	s.top().a += f.a;
		ans += f.a * f.b * f.v;
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 6656
#include<stdio.h>
   int main(void){
       int x,i,n,cards[4][13]={0};
       char letter;
       scanf("%d",&n);
       for(i=0;i<n;i++){
          scanf(" %c %d",&letter,&x);
          if(letter=='S')
            cards[0][x-1]=1;
         else if(letter=='H')
           cards[1][x-1]=1;
         else if(letter=='C')
           cards[2][x-1]=1;
         else if(letter=='D')
           cards[3][x-1]=1;
      }
      for(i=0;i<13;i++){
         if(cards[0][i]==0)
           printf("%c %d\n",'S',i+1);
      }
      for(i=0;i<13;i++){
         if(cards[1][i]==0)
           printf("%c %d\n",'H',i+1);
      }
     for(i=0;i<13;i++){
        if(cards[2][i]==0)
           printf("%c %d\n",'C',i+1);
      }
      for(i=0;i<13;i++){
         if(cards[3][i]==0)
           printf("%c %d\n",'D',i+1);
     }
     return 0;
}


Measured memory_bytes: 2144
N, M = map(int, input().split())
edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to, dist = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, dist))
    edges[to].append((fr, -dist))

def isOk():
    visited = [False] * N
    INF = 10**18
    minDist = [INF] * N
    for s in range(N):
        if visited[s]:
            continue
        st = [(s, 0)]
        minDist[s] = 0
        visited[s] = True
        while st:
            now, dist = st.pop()

            for to, d in edges[now]:
                d += dist
                if visited[to]:
                    if minDist[to] != d:
                        return False
                else:
                    visited[to] = True
                    minDist[to] = d
                    st.append((to, d))
    return True

print('Yes' if isOk() else 'No')


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

int main(void) {
  int N;
  cin >> N;

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

  int ans = -1;
  int i = 1;
  for (int j = 1; j <= N; j++) {
    i = a[i - 1];
    if (i == 2) {
      ans = j;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int n, a;
vector<int> xs;

int64_t tbl[51][5000];

int64_t solve(int cur, int diff)
{
    if (cur == n) {
        return diff == 0 ? 1 : 0;
    }

    int64_t &ret = tbl[cur][diff + 2500];
    if (ret >= 0) return ret;

    ret = 0;
    ret += solve(cur + 1, diff + a - xs[cur]);
    ret += solve(cur + 1, diff);

    return ret;
}

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

    xs.resize(n);
    for (auto &x: xs) cin >> x;

    memset(tbl, -1, sizeof(tbl));

    cout << solve(0, 0) - 1 << endl;

    return 0;
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  int a, b; cin >> a >> b;
  if (a+b == 15) cout << '+' << endl;
  else if (a*b == 15) cout << '*' << endl;
  else cout << 'x' << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n = readInt()
a = readInts()

ans = 10*10
ans = 0
for i in a:
	if ans+1==i:
		ans+=1

if ans==0:
	print(-1)
else:
	print(n-ans)

Measured memory_bytes: 25372
l, c = map(int, input().split())
tbl = [[] for _ in range(l)]
li_sum = [0 for _ in range(c+1)]

for i in range(l):
  tblS = input()
  tbl[i] = list(map(int, tblS.split()))
  print(tblS, end = '')
  print(' ', sum(tbl[i]), sep = '')

  for j in range(c):
    li_sum[j] += tbl[i][j]
  li_sum[c] += sum(tbl[i])

print(' '.join(map(str, li_sum)))


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0;i < N;i++) {
   cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  int count = 0;
  
  for (int i = 0;i < N-1;i++) {
   if (vec.at(i) < vec.at(i+1)) {
    count+=1;
   }
  }
  
  cout << count + 1 << endl;
  
}

Measured memory_bytes: 256
/*
 * 6/14 8:54 ~@13:01
 * Accepted
 */
#include <iostream>
#include <algorithm>
#include <queue>
#define INF 1000000

using namespace std;

struct edge {
  int to, cost, dis;
};
typedef pair<int, int> P;

vector<edge> G[101];

// init

// input
int iN; // 0 <= N <= 100,000
int iM; // 1 <= P <= 100
int iL; // 1 <= P <= 100

// manage
int d[101][101];

// ú»
void init() {
}

// üÍ
bool input() {
  int i;
  edge e;
  int a, b, d, c;

  scanf("%d %d %d", &iN, &iM, &iL);
  if (iN == 0 && iM == 0 && iL == 0) return false;

  for (i = 0; i < iN; i++) {
    G[i].clear();
  }
  for (i = 0; i < iM; i++) {
    scanf("%d %d %d %d", &a, &b, &d, &c);
    e.cost = c;
    e.dis = d;
    e.to = b;
    G[a].push_back(e);
    e.to = a;
    G[b].push_back(e);
  }

  return true;
}

// 
void manage(){
  priority_queue<P, vector<P> , greater<P> > que;

  fill(d[0], d[0] + 101 * 101, INF);
  d[1][iL] = 0;
  que.push(P(0, 1 * 101 + iL));

  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second / 101;
    int c = p.second % 101;
    if (d[v][c] < p.first)
      continue;
    for (int i = 0; i < (int) G[v].size(); i++) {
      edge e = G[v][i];
      if (e.dis <= c && d[e.to][c - e.dis] > d[v][c]) {
        d[e.to][c - e.dis] = d[v][c];
        que.push(P(d[e.to][c - e.dis], e.to * 101 + (c - e.dis)));
      }
      if (d[e.to][c] > d[v][c] + e.cost) {
        d[e.to][c] = d[v][c] + e.cost;
        que.push(P(d[e.to][c], e.to * 101 + c));
      }
    }
  }
}

// oÍ
void output(){
  int i, out;
  out = d[iN][0];
  for (i = 1; i <= iL; i++) {
    out = min(out, d[iN][i]);
  }
  printf("%d\n", out);
}

// mizoSâ¤Ê
int main() {
  init(); // ú»
  while(1) {
    if (!input()) break; // üÍ + I¹»è
    manage(); // 
    output(); // oÍ
  }
  return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
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; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N; cin >> N;
  vector<ll> p(N), q(N); FOR(i,N){ cin >> p[i]; } FOR(i,N){ cin >> q[i]; }
  vector<ll> a(N); FOR(i,N){ a[i] = i+1; }
  
  //main
  ll cp, cq, count = 0;
  while(next_permutation(a.begin(),a.end())){
    count ++;
    FOR(i,N){ 
      if(p[i]!=a[i]){ goto endloop1; } 
    }
    cp = count;
    endloop1: ;
    FOR(i,N){ 
      if(q[i]!=a[i]){ goto endloop2; } 
    }
    cq = count;
    endloop2: ;
  }
  
  // output
  cout << abs(cp-cq) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int H, W, N;
        cin >> H >> W >> N;
        vector<vector<int> > kabe(H + 1);

        for (int i = 0; i < N; ++i) {
            int X, Y;
            cin >> X >> Y;
            kabe[X].push_back(Y);
//            kabe[X].insert(Y);
        }
        for (int i = 0; i < H + 1; ++i) {
            sort(all(kabe[i]));
        }

        int left = 1, right = 1;
        int x = 1;

        while (x < H) {
            if (upper_bound(all(kabe[x + 1]), right) - lower_bound(all(kabe[x + 1]), left) > 0) {
                break;
            }
            x++;
            //right + 1に壁はあるのか
            if (upper_bound(all(kabe[x]), right + 1) - lower_bound(all(kabe[x]), right + 1) > 0) {
            } else {
                right++;
            }
        }
        cout << x << endl;


    }
};


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

    Solve().solve();


    return 0;
}


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

#define deb(x)        cerr << #x << " = " << x << "\n";
#define deb2(x, y)    cerr << #x << " = " << x << ", " << #y << " = " << y << "\n";
#define deb3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << "\n";

#define pb push_back
#define mp make_pair
#define F  first
#define S  second

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;  

const int INF = 1e9 + 5;

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j : {i + 1, i + 2}) {
            if (j < n) {      
                dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
            }
        }
    }
    cout << dp[n-1];
}

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

//  freopen ("in.txt", "r", stdin);
//  freopen ("err.txt", "w", stderr); 
//  freopen ("out.txt", "w", stdout);

    ll tc = 1;
    //cin >> tc;

    while(tc--) {
        solve();
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 3936
factors n =
  let loop_j n i j =
        if n `mod` i == 0 then
          loop_j (n `div` i) i (j + 1)
        else
          (n, j)
  in
    let loop_i n i =
          if i * i > n then
            if n == 1 then [] else [(n, 1)]
          else if n `mod` i == 0 then
            let (n', c) = loop_j (n `div` i) i 1
            in
              (i, c) : loop_i n' (i + 1)
          else
            loop_i n (i + 1)
    in
      loop_i n 2
  
merge [] _ = []
merge _ [] = []
merge (x:xs) (y:ys) =
  if fst x == fst y then
    x : merge xs ys
  else if x < y then
         merge xs (y:ys)
       else
         merge (x:xs) ys

main = do
  [a,b] <- map read . words <$> getLine
  let facta = factors a
  let factb = factors b 
  let ans = 1 + length (merge facta factb )
  putStrLn $ show ans
  


Measured memory_bytes: 1020