akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    t = I()
    aa = [LI() for _ in range(t)]
    rr = []
    for a,b,c,d in aa:
        if a < b or d < b:
            rr.append('No')
            continue
        if c >= b:
            rr.append('Yes')
            continue
        g = fractions.gcd(b, d)
        if g == 1:
            if b - c > 1:
                rr.append('No')
            else:
                rr.append('Yes')
            continue
        t = (a + d - c) % g
        if t == 0:
            t = g
        if b - c - t > 0:
            rr.append('No')
        else:
            rr.append('Yes')

    return '\n'.join(rr)




print(main())


Measured memory_bytes: 5456
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1);
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 25;

int n;
int c[N], v[N];

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> v[i];
	}
	for (int i = 1; i <= n; i ++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int i = 1; i <= n; i ++) {
		ans += max(v[i] - c[i], 0);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
vals=input().split(' ')
N=int(vals[0])
A=int(vals[1])
B=int(vals[2])

total=0

number=1
while number<=N:
  subtotal=0
  for n in str(number):
    subtotal+=int(n)
  if A<= subtotal & subtotal <= B:
    total+=number
  number+=1

print(total)

Measured memory_bytes: 3064
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String S = scan.next();
        String T = scan.next();

        int ans = Integer.MAX_VALUE;
        int maxPattern = S.length() - T.length() + 1;
        for(int i = 0; i < maxPattern; i++) {
            int diff = T.length();
            for(int j = 0; j < T.length(); j++) {
                if(S.charAt(i+j) == T.charAt(j))
                    diff--;
            }
            ans = Math.min(ans, diff);
        }

        os.println(ans);

    }
}

Measured memory_bytes: 27028
#include <iostream>
#include <vector>
#include <string>
int main(){
    std::string s;
    std::cin >> s;
    int len;
    int cnt = 0;
    len = s.length();
    for(int i=0; i<len; ++i){
        std::string a;
        a = s.substr(i, 1);
        if(a == "x"){
            cnt ++;
        }
    }
    if(cnt >= 8){
        std::cout << "NO" << std::endl;
    }else{
        std::cout << "YES" << std::endl;
    }
    return 0;
}

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

int n, m, q, s1[2010][2010], s2[2010][2010], s3[2010][2010];
char s[2010][2010];

int main() {
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 1; i <= n; i++) {
        scanf("%s", s[i] + 1);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < m; j++) {
            s1[i][j] = s1[i][j - 1] + s1[i - 1][j] - s1[i - 1][j - 1];
            if (s[i][j] == '1' && s[i][j + 1] == '1') s1[i][j]++;
        }
    }
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            s2[i][j] = s2[i][j - 1] + s2[i - 1][j] - s2[i - 1][j - 1];
            if (s[i][j] == '1' && s[i + 1][j] == '1') s2[i][j]++;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            s3[i][j] = s3[i][j - 1] + s3[i - 1][j] - s3[i - 1][j - 1];
            if (s[i][j] == '1') s3[i][j]++;
        }
    }
    auto get = [&](auto sum, int x1, int y1, int x2, int y2) {
        return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
    };
    for (int i = 1, x1, y1, x2, y2; i <= q; i++) {
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        int t1 = get(s1, x1, y1, x2, y2 - 1);
        int t2 = get(s2, x1, y1, x2 - 1, y2);
        int t3 = get(s3, x1, y1, x2, y2);
        printf("%d\n", t3 - t1 - t2);
    }
    return 0;
}

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

using namespace std;

int main() {
  //変数の定義
  long long num, ans=0, x;
  int length;
  vector<int> vec;
  
  //入力を受け取る
  cin >> num;
  
  double a = sqrt(num); 
  for(long i=1;i<=a;i++){ //numの平方根まででループを止める
    if(num%i==0){
      x = i + num/i - 2;
      if(ans==0){
        ans = x;
      }
      if(x<ans){
        ans = x;
     }
   }
  }
 
  //出力
  cout << ans << endl;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int ans = 0;
  ans += max(0, n * (n - 1) / 2) + max(0, m * (m - 1) / 2);
  cout << ans << endl;
  return 0;
}


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

int main(void){

    int a, b, c, d;

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

    if(abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  H[0]--;
  rep(i, N-1) {
    if (H[i] < H[i+1]) {
      H[i+1]--;
    } else if (H[i] == H[i+1]) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}

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

using namespace std;

#define MAX_N 30
int dp[MAX_N + 1];
bool checked[MAX_N + 1];
//??\???

int count(int n) {
  if ( n == 1 ) return 1;
  if ( n == 2 ) return 2;
  if ( n == 3 ) return 4;

  if(checked[n] == true){
    return dp[n];
  } else {
    int res = count(n-1) + count(n-2) + count(n-3);
    dp[n] = res;
    return res;
  }

}

int main() {
  ios::sync_with_stdio(false);

  int n, years;
  while(cin >> n) {
    if (n==0) break;
    int c = count(n);
    years = ( c / 3650 ) + (c % 3650 == 0 ? 0 : 1);
    cout << years << endl;
  }

  return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl

const int inf = 1000000000;//10^9


int main(){
  string S,C;
  //string T="T";
  int N,Q,F;
  string M, U;
  int count;

  cin >> S >> N;
  rep(i,N){
    cin >>Q;
    if(Q==1){
      count++;
    }else{
      cin >>F>>C;
      if((F==1&&count%2==0)||(F==2&&count%2==1)){
        M=C+M;
      }else{
        U=U+C;
      }
    }
  }
  S=M+S+U;
  if(count%2==1){
    reverse(S.begin(), S.end());
  }
  //int posT;
  //posT=T.find_first_of('T');
  //T.replace(posT, 1, S);
  print(S);
  return 0;
}


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

int main() {
    int N;
    cin>>N;
    vector<long> A;
    long tmp;
    for(int i=0;i<N;++i){
        cin>>tmp;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end());
    vector<long> sumA;
    sumA.push_back(A[0]);
    int ans = 1;
    for(int i=1;i<N;++i){
        sumA.push_back(sumA[i-1] + A[i]);
    }

    for(int i=0;i<N-1;++i){
        if(sumA[i]*2 < A[i+1]) ans = 1;
        else ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2548
#include <stdio.h>
int main(){
	int h, w, i, j;
	while(1){
	scanf("%d %d", &h, &w);
	if (h ==0 && w == 0){
		break;
	}
	for (i = 1; i <= h; i++){
		for (j = 1; j <= w; j++)
			if (i == 1 || i == h||j==1||j==w){
			printf("#");
			}
			else{
				printf(".");
			}
			printf("\n");
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
N,K=map(int,input().split())
D=[]
SUN=[i for i in range(1,N+1)]
for i in range(K):
    D.append(int(input()))
    A=list(map(int,input().split()))
    for j in A:
        if j in SUN:
            SUN.remove(j)

print(len(SUN))

Measured memory_bytes: 9184
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const long long N = 1e9 + 7;
typedef long long ll;
map <char,int> ma;
int main()
{
	int n, k,num = 1;
	cin >> n >> k;
	while(n >= k)
    {
        n /= k;
        num++;
    }
    cout << num << endl;

	return 0;
}


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

int dp[101][76];

int main(){
    int N;
    cin >> N;
    map<int, int> prime_division;
    for(int i=2; i<=N; i++){
        int n = i;
        for(int p=2; p<=n; p++){
            while(n % p == 0){
                prime_division[p]++;
                n /= p;
            }
        }
    }

    vector<int> nums;
    for(auto p : prime_division) nums.push_back(p.second);
    int len = nums.size();

    vector<int> div75 = {1, 3, 5, 15, 25, 75};

    dp[0][1] = 1;
    for(int i=0; i<len; i++){
        for(auto d1 : div75){
            for(auto d2 : div75){
                if(d1*d2 <= 75 && nums[i]+1 >= d2){
                    dp[i+1][d1*d2] += dp[i][d1];
                }
            }
        }
    }
    cout << dp[len][75] << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n_money, y_yen = map(int, input().split())
    # money
    a, b, c = 10000, 5000, 1000
    for x in range(n_money+1):
        for y in range(n_money-x+1):
            z = n_money - x - y
            money = a * x + b * y + c * z
            if money == y_yen:
                print(f'{x} {y} {z}')
                return 0
    print('-1 -1 -1')


if __name__ == '__main__':
    main()

Measured memory_bytes: 64436
from fractions import gcd
a,b,c,d = map(int, input().split())
if a % c == 0:
    div_c = b//c - a//c +1
else:
    div_c = b//c - a//c 
if a % d == 0:
    div_d = b//d - a//d + 1
else:
    div_d = b//d - a//d
x = c*d // gcd(c,d)
if a % x == 0:
    div_cd = b//x - a//x + 1
else:
    div_cd = b//x - a//x
print(b-a+1 - div_c -div_d + div_cd)

Measured memory_bytes: 5048
use proconio::{input,fastout};

#[fastout]
fn main() {
  input!{n: usize};
  // 求めるだけなら、他の番号を全てXORすればOK
  // 単純にやるとO(N^2)
  // 全部のXORを取ってしまって、最後にそれぞれのXORを取ると復旧できる?
  input!{a: [usize; n]};
  // fold_first使いたさ(nightly API...)
  let a_0 = a[0];
  let total = a.iter().skip(1).fold(a_0, |acc, x| acc ^ x);
  eprintln!("{}", total);
  
  print!("{}", total ^ a_0);
  for v in a.iter().skip(1) {
    print!(" {}", total ^ (*v));
  }
  println!("");
}

Measured memory_bytes: 6340
import sys

input = sys.stdin.readline
n = int(input())
a_list = list(map(int, input().split()))
new_list = []
cnt = 0
for a in a_list:
    if a < 0:
        cnt += 1
        a = -a
    new_list.append(a)
if cnt%2 == 0:
    print(sum(new_list))
else:
    print(sum(new_list)-min(new_list)*2)


Measured memory_bytes: 14332
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
  int N , K;
  cin>>N>>K;
  double ans=0;
  for(int i=1;i<=N;i++){
    double p=1.0/N;
    for(int j=i;j<K;j*=2){
      p/=2;
    }
      ans+=p;
  }
  cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=2e5+5;

int n;
int a[N], pref[N], bit[2][N];

void update(int i, int idx, int val)
{
	idx+=1e5+1;
	while(idx<N)
	{
		bit[i][idx]+=val;
		idx+=(idx&-idx);
	}
}

int query(int i, int idx)
{
	idx+=1e5+1;
	int ans=0;
	while(idx>0)
	{
		ans+=bit[i][idx];
		idx-=(idx&-idx);
	}
	return ans;
}

int work(int k)
{
	int ans=0;
	memset(bit, 0, sizeof(bit));
	update(0, 0, 1);
	for(int i=1;i<=n;i++)
	{
		pref[i]=pref[i-1] + ((a[i]>=k)?1:-1);
		ans+=query(!(i%2), pref[i]) + query((i%2), pref[i]);
		update(i%2, pref[i], 1);
	}
	return ans;
}

int check(int k)
{
	int get=work(1) - work(k);
	int total=n * (n+1)/2;
	if(get>total/2 + 1)
		return -1;
	get=work(k+1);
	if(get>total - (total/2 + 1))
		return 1;
	return 0;
}

int binsearch(int lo, int hi)
{
	while(lo<hi)
	{
		int mid=(lo+hi)/2;
		if(check(mid)==-1)
			hi=mid-1;
		else if(check(mid)==1)
			lo=mid+1;
		else
			hi=mid;
	}
	return lo;
}

int32_t main()
{
	IOS;
	set<int> s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
	}
	int ans=binsearch(1, 1e9);
	ans=*s.lower_bound(ans);
	cout<<ans;
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;

int main()
{		
	
    
    IOS
    string s,t;
    cin>>s>>t;
    s="$"+s;
    t="$"+t;
    ll dp[3005][3005];
    for(ll i=0;i<s.size();i++)
    {
        for(ll j=0;j<t.size();j++)
        {   
            if(i==0||j==0)
            {
                dp[i][j]=0;
                continue;
            }
            if(s[i]==t[j])
            {
                dp[i][j]=(dp[i-1][j-1])+1;
              
                //trace(dp[i][j]);
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
          
            }
        }
    }
    ll i=s.size()-1;ll j=t.size()-1;
    string ans="";
    while(i>0&&j>0)
    {
        if(s[i]==t[j])
        {
            ans+=(s[i]);
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        {
            i--;
        }
        else
            j--;
    }
    reverse(ans.begin(),ans.end());

    cout<<ans<<endl;


}


Measured memory_bytes: 70784
//  Author : Amit Kumar 

#include <iostream>
#include <algorithm> 
#include <string> 
#include <sstream>
#include <fstream>
#include <iomanip> 
#include <chrono> 
#include <numeric> 
#include <utility>
#include <functional>

#include <bitset>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <deque>
#include <list>


#include <climits>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdio>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace std::chrono;
//  using namespace placeholders;
using namespace __gnu_pbds;
template<typename TypeInfo>
using new_set = tree< 
/* ob.order_of_key(element) -> number of element strictly less than element
 * *ob.find_by_order(n) ->  nth element in increasing order
 */
         TypeInfo ,
         null_type ,
         less<TypeInfo> ,
         rb_tree_tag ,
         tree_order_statistics_node_update 
 > ;

void show_me() { cerr << endl; }
 
template <typename HEAD, typename... TAIL>
void show_me(HEAD H, TAIL... T) {
  cerr << " " << (H);
  show_me(T...);
}
 
#ifdef HELL_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "]:", show_me(__VA_ARGS__)
#else
#define show(...) 0
#endif
 
template<typename A, typename B>
ostream& operator<<(ostream&out, const pair<A, B>&p){
    out << p.first << ' ' << p.second ;
    return out;
}

template<typename A, typename B>
istream& operator>>(istream&in, pair<A, B>&p){
    in >> p.first >> p.second ;
    return in;
}

template<typename A> 
istream& operator>>(istream&in, vector<A>&vec){
    for(auto&itr:vec){
        in >> itr;
    }
    return in;
}

template<typename A>
ostream& operator<<(ostream&out,const vector<A>&vec){
    for(auto&itr:vec){
        out << itr <<' '; // VVV 
    }
    return out;
}

const int MAXM = (int)1e5+100;
const int MAXN = (int)1e5+100;
const int MOD  = (int)1e9+7;




signed main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    ios::sync_with_stdio(false); // FLUSH THE STREAM IF USING puts / printf / scanf/
    cin.tie(nullptr);            //
    cout.tie(nullptr);           //
#ifdef HELL_JUDGE
    auto INITIAL_TIME = high_resolution_clock::now();
#endif 

    int x; cin >> x; 
    for(int i=1;;++i){
        if((x*i)%360==0){
            cout << i << '\n'; 
            return 0;
        }
    }

#ifdef HELL_JUDGE
    auto FINAL_TIME = high_resolution_clock::now();
    cout << "Time : "
         << duration_cast<milliseconds>(FINAL_TIME-INITIAL_TIME).count() 
         << " ms" << '\n'; 
#endif 
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int N, X, x;

int get_dist(int a, int b) {
  if (a >= b) return a - b;
  else return b - a;
}

template <typename T>
T gcd(T a, T b) {
  if (a < 0) a = -a;
  if (b < 0) b = -b;
  while(b != 0) {
    a %= b;
    if (a == 0) return b;
    b %= a;
  }
  return a;
}

int main() {
  scanf("%d%d", &N, &X);

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &x);
    int dist = get_dist(X, x);
    if (i == 0) ans = 0;
    ans = gcd(ans, dist);
  }
  
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int need=1;
	int cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]==need){
			cnt++;
			need++;
		}
	}
	if(cnt==0){
		cout<<"-1"<<endl;
	}
	else
		cout<<n-cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 5208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

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())

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

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string l;
    cin >> l;

    ll dp[112345][2];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;

    for (int i = 1; i <= l.size(); i++)
    {
        if (l[i - 1] == '0')
        {
            (dp[i][0] += dp[i - 1][0]) %= MOD;
            (dp[i][1] += dp[i - 1][1] * 3) %= MOD;
        }
        else
        {
            (dp[i][0] += dp[i - 1][0] * 2) %= MOD;
            (dp[i][1] += dp[i - 1][1] * 3) %= MOD;
            (dp[i][1] += dp[i - 1][0]) %= MOD;
        }
    }

    cout << ((dp[l.size()][0] + dp[l.size()][1]) % MOD) << endl;

    return 0;
}

Measured memory_bytes: 2256
import java.io.BufferedReader
import java.util.*
import kotlin.math.max

fun main() = abc175e()

@OptIn(ExperimentalStdlibApi::class)
fun abc175e() = SimpleFastIOWithToken_abc175e().exec {
    val (rows, cols, k) = List(3) { readInt() }
    val items = List(k) { List(3) { readInt() } }

    val grid = Array(rows) { LongArray(cols) }
    items.forEach { (r, c, v) -> grid[r - 1][c - 1] = v.toLong() }

    val dp = Array(rows + 1) { Array(cols + 1) { LongArray(4) } }

    for (y in 0 until rows) for (x in 0 until cols) {
        for (take in 2 downTo 0) {
            dp[y][x][take + 1] = max(dp[y][x][take + 1], dp[y][x][take] + grid[y][x])
        }

        for (take in 0..3) {
            dp[y + 1][x][0] = max(dp[y + 1][x][0], dp[y][x][take])
            dp[y][x + 1][take] = max(dp[y][x + 1][take], dp[y][x][take])
        }
    }

    val answer = dp[rows - 1][cols - 1].max()!!

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc175e(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc175e.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const int mod = 1e9+7;
const ll INF = 1e9;
const int MAX = 1e5;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n; // 変数
int act[MAX][3]; // i日目の活動がxのとき得る幸福度
int dp[MAX][3]; // i日目に活動xをしたときの幸福度の総和の最大値

int rec(int i, int to) {
    if (dp[i][to] != 0) return dp[i][to];
    if (i == 0) return dp[i][to] = act[i][to];
    int r = 0;
    rep(ye, 3) {
        if (ye == to) continue;
        r = max(r, rec(i-1, ye) + act[i][to]);
    }
    return dp[i][to] = r;
}

int main() {
// input
    cin >> n;
    rep(i, n) {
        rep(j, 3) {
            cin >> act[i][j];
        }
    }
// solve
    int ans = 0;
    rep(to, 3) {
        ans = max(ans, rec(n-1, to));
    }
// output
    cout << ans << "\n";
}

Measured memory_bytes: 13788
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();	
		ArrayList<Integer> alist = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			x=Math.abs(m-x);
				alist.add(x);		
		}
		 int tmp;
		 int x;
		 int y=alist.get(0);
		 for (int i = 0; i < n; i++) {
			 x=alist.get(i);		 
	     while ((tmp = x % y) != 0) {
	            x = y;
	            y = tmp;
	        }
		 }
		 System.out.print(y);
	}
}

Measured memory_bytes: 62972
// https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_a

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

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

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  string S;
  cin >> S;

  string res = S.substr(0, 3);
  cout << res << "\n";
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define M_PI 3.14159265358979323846

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int main()
{
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    
    int N;
    cin >> N;
    if(N<=10) {cout << "Yes" << endl; return 0;}
    FOR(i,2,10) if(N%i==0 & N/i<10) {cout << "Yes" << endl; return 0;}
    cout << "No" << endl; return 0;
}


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

int main(void){
  int i,a,out,base,point;
  char event[8];

  scanf("%d",&a);

  for(i=0;i<a;i++){
    point=0;
    base=0;
    out=0;
    while(1){

      scanf("%s",event);
      
      if(!strcmp(event,"OUT")){
	out++;
	if(out==3)break;
      }

      if(!strcmp(event,"HIT")){
	if(base<3)base++;
	else {
	  point++;
	}
      }
      
      if(!strcmp(event,"HOMERUN")){
	point+=base+1;
	base=0;
      }

    }
    printf("%d\n",point);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    string s; cin >> s;

    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (s == "Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
wa = sum(a)
for i in range(n):
    surplus = b[i] - min(a[i], b[i])
    a[i] -= min(a[i], b[i])
    a[i + 1] -= min(surplus, a[i + 1])
    
print(wa - sum(a))

Measured memory_bytes: 19156
n,m,k = map(int,input().split())
x = m*n
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
ss = cmb(x,k)
s = (ss*k*(k-1))//2
r = 10**9 +7
av = (((m**3-m) *n**2)//6 + ((n**3-n)*m**2)//6)%r
d = (x*(x-1))//2
print(int(((av*s)//d)%r))

Measured memory_bytes: 11512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;
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 (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i, h) {
        rep(j, w) {
            if ((i < b && j < a) || (i >= b && j >= a))
                cout << 1;
            else
                cout << 0;
        }
        cout << endl;
    }
}


Measured memory_bytes: 1280
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //get three input
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if((b - a) == (c - b)) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23508
#include<cstdio>
char s[101];
main(){
	scanf("%s",s);
	for(int i=0;s[i];++i)
		if(s[i]=='C')
			for(int j=i+1;s[j];++j)
				if(s[j]=='F')
					return puts("Yes"),0;
	puts("No");
}

Measured memory_bytes: 128
A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input())

count = 0

for i in range(A+1):
    tmp = X
    tmp -= 500*i
    a_tmp = tmp
    for j in range(B+1):
        tmp = a_tmp
        tmp -= 100*j
        b_tmp = tmp
        for k in range(C+1):
            tmp = b_tmp
            tmp -= 50*k
            
            if tmp == 0:
                count += 1
                
print(count)


Measured memory_bytes: 3188
A, B, C, X, Y = map(int, input().split())

ans = A * X + B * Y

t = max(X, Y)

for i in range(2, (t+1)*2, 2):
    if (X - i//2) < 0:
        ans = min(ans, C * i + B * (Y - i//2))
    elif (Y - i//2) < 0:
        ans = min(ans, C * i + A * (X - i//2))
    else:
        ans = min(ans, C * i + A * (X - i//2) + B * (Y - i//2))

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;cin>>test;while(test--)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_output(v) for(auto it=v.begin();it!=v.end();it++){if(it!=v.begin())cout<<" ";cout<<*it;}cout<<endl;
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;

int main(){
    int n,p=0,m=0,ans=1;
    cin>>n;
    vector<ll> vec(n);
    vec_input(vec);
    for(int i=1;i<n;i++){
        if(vec[i]>vec[i-1]){
            p=1;
            if(m){
                cerr<<i<<" ";
                ans++;
                p=0;
                m=0;
            }
        }else if(vec[i]<vec[i-1]){
            m=1;
            if(p){
                cerr<<i<<" ";
                ans++;
                p=0;
                m=0;
            }
        }
    }
    cerr<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    vector<queue<ll>> a(n);
    rep(i, n) {
        rep(j, n - 1) {
            ll tmp;
            cin >> tmp;
            a[i].push(tmp - 1);
        }
    }
    set<ll> check;
    rep(i, n) check.insert(i);
    bool upd = true;
    ll ans = 0;
    set<ll> emp;
    while(upd) {
        upd = false;
        set<ll> next;
        for(auto &x : check) {
            if (a[x].empty()) continue;
            ll u = a[x].front();
            if (a[u].empty()) continue;
            ll v = a[u].front();
            if ((v == x) && (next.count(x) == 0) && (next.count(u) == 0)) {
                next.insert(x);
                next.insert(u);
                a[x].pop();
                if (a[x].empty()) emp.insert(x);
                a[u].pop();
                if (a[u].empty()) emp.insert(u);
                upd = true;
            }
        }
        if ((!upd) && (sz(emp) != n)) {
            cout << -1 << endl;
            return 0;
        }
        check = next;
        ans++;
        if (sz(emp) == n) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define N 1009
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
 
LL fun(LL n, LL m)
{
    if((m / 2) < n) return  m / 2;
    LL ans = n;
    m = m - n * 2;
    ans = ans + m / 4;
    return ans;
}
 
 
int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    LL ans = fun(n, m);
    printf("%lld\n", ans);
    return 0;
}

 

Measured memory_bytes: 256
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _parent(i) {
  return ~ ~(i / 2);
}
function _right(i) {
  return 2 * i + 1;
}
function _left(i) {
  return 2 * i;
}

var BinaryHeap = (function () {
  function BinaryHeap(comp) {
    _classCallCheck(this, BinaryHeap);

    this.comp = comp || function (a, b) {
      return a < b;
    };
    this.collection = [];
  }

  _createClass(BinaryHeap, [{
    key: "from",
    value: function from(array) {
      this.collection = array;
      for (var i = ~ ~(array.length / 2); i >= 0; --i) this.heapify(this.collection, i);
      return this;
    }
  }, {
    key: "toArray",
    value: function toArray() {
      return this.collection.sort(this.comp);
    }
  }, {
    key: "heapify",
    value: function heapify(arr, i) {
      var l = _left(i);
      var r = _right(i);
      var largest;

      if (l < arr.length && this.comp(arr[i], arr[l])) largest = l;else largest = i;
      if (r < arr.length && this.comp(arr[largest], arr[r])) largest = r;

      if (largest !== i) {
        var t = arr[i];
        arr[i] = arr[largest];
        arr[largest] = t;
        return this.heapify(arr, largest);
      }
    }
  }, {
    key: "push",
    value: function push(value) {
      this.collection.push(value);
      var arr = this.collection;
      for (var i = arr.length - 1; i > 0 && this.comp(arr[_parent(i)], arr[i]); i = _parent(i)) {
        var tmp = arr[i];
        arr[i] = arr[_parent(i)];
        arr[_parent(i)] = tmp;
      }
      return this;
    }
  }, {
    key: "top",
    value: function top() {
      return this.collection[0];
    }
  }, {
    key: "pop",
    value: function pop() {
      var ret = this.collection[0];
      if (1 < this.collection.length) {
        this.collection[0] = this.collection.pop();
        this.heapify(this.collection, 0);
      } else {
        this.collection.pop();
      }
      return ret;
    }
  }]);

  return BinaryHeap;
})();


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');

(function solve(lines){
  var pq = new BinaryHeap();
  lines.forEach(function(line){
    words = line.split(" ");
    if(words[0] === "insert"){
      pq.push(parseInt(words[1]));
    }else if(words[0] === "extract"){
      console.log(pq.pop());
    }
  });
})(lines);

Measured memory_bytes: 162032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

ll dp[111][5][5][5];

int main(){
  int N; cin>>N;
  dp[0][0][0][0]=1;
  rep(i,N) rep(j,5) rep(k,5) rep(l,5){
    rep(m,4) (dp[i+1][k][l][m+1]+=dp[i][j][k][l])%=MOD;
    if((j==1&&k==3)||(j==1&&l==3)||(k==3&&l==1)||(k==1&&l==3)){
      (dp[i+1][k][l][2]+=MOD-dp[i][j][k][l])%=MOD;
    }
    if(k==1&&l==2){
      (dp[i+1][k][l][3]+=MOD-dp[i][j][k][l])%=MOD;
    }
  }
  ll ans=0;
  rep(i,4) rep(j,4) rep(k,4) (ans+=dp[N][i+1][j+1][k+1])%=MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>
#include <limits.h>

int M[101][101], P[101], length;

void matricChainOrder() {
    int n, i, j , k, l, q;
    n = length;
    for (i = 1; i <= n; i++) {
        M[i][i] = 0;
    }
    for (l = 2; l <= n; l++) {
        for (i = 1; i <= n - l + 1; i++) {
            j = i + l - 1;
            M[i][j] = INT_MAX;
            for (k = i; k <= j - 1; k++) {
                q = M[i][k] + M[k + 1][j] + P[i - 1] * P[k] * P[j];
                M[i][j] = M[i][j] < q ? M[i][j] : q;
            }
        }
    }
}

int main(void){
    int n, i, a, b;
    
    scanf("%d", &n);
    
    for (i = 1; i <= n; i++) {
        scanf("%d %d", &a, &b);
        if (i == 1) P[0] = a;
        P[i] = b;
    }

    length = n;
    
    matricChainOrder();
    
    printf("%d\n", M[1][n]);
    
    return 0;
}




Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,x;
    cin >> n >> d >> x;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=1;i<d+1;i++){
        for(int j=0;j<n;j++){
            if(a[j]==1)x++;
            else if(i%a[j]==1)x++;
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long int sum = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        if (!(i % 3 == 0 || i % 5 == 0))
        {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

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

int N;

int main(void){
  while(cin >> N && N != 0){
    vector<pair<int, int> > block(200, pair<int, int>(0, 0));
    int top = 0, bottom = 0, left = 0, right = 0;
    block[0] = pair<int, int>(0, 0);
    for(int i = 1; i < N; i++){
      int n, d;
      cin >> n >> d;
      pair<int, int> nb = block[n];
      if(d == 0){
        block[i] = pair<int, int>(nb.first - 1, nb.second);
        if(block[i].first < left) left = block[i].first;
      }else if(d == 1){
        block[i] = pair<int, int>(nb.first, nb.second - 1);
        if(block[i].second < bottom) bottom = block[i].second;
      }else if(d == 2){
        block[i] = pair<int, int>(nb.first + 1, nb.second);
        if(block[i].first > right) right = block[i].first;
      }else if(d == 3){
        block[i] = pair<int, int>(nb.first, nb.second + 1);
        if(block[i].second > top) top = block[i].second;
      }
    }
    cout << (right - left) + 1 << " " << (top - bottom) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
import Control.Applicative ((<$>))
import Control.Monad (unless)

main :: IO ()
main = do
  s <- getLine
  unless (s == ".") $ do
    putStrLn $ solve s
    main

solve :: String -> String
solve s = f [] s
  where f st [] = if null st then "yes" else "no"
        f st ('(':rs) = f ('(': st) rs
        f st ('[':rs) = f ('[': st) rs
        f (x:xs) (')':rs) = if x == '(' then f xs rs else "no"
        f (x:xs) (']':rs) = if x == '[' then f xs rs else "no"
        f [] (')':rs) = "no"
        f [] (']':rs) = "no"
        f st (_:rs) = f st rs



Measured memory_bytes: 4056
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>
#include<queue>
#include<bitset>

using namespace std;

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

	vector<vector<int>> A(N, vector<int>(2));

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 2; ++j) {
			cin >> A.at(i).at(j);
		}
	}

	bool ans = false;

	for (int i = 0; i < N - 2; ++i) {
		if (A.at(i).at(0) == A.at(i).at(1) && A.at(i + 1).at(0) == A.at(i + 1).at(1) && A.at(i + 2).at(0) == A.at(i + 2).at(1)) {
			ans = true;
		}
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<math.h>
#include <string.h>
using namespace std;
int main(){
	long long int i,j,m,n,r,l;
	while(cin>>n){
		long long int sum=0,count=0;
		i=n/11;
		j=n%11;
		if(j<=6&&j!=0){
			count=1;
		}
		if(j>6){
			count=2;
		}
		cout<<count+2*i<<endl;
 	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int countt(int a[],int b,int c){
    int p = 0;
    for(int i = 0;i<b;i++){
        if(a[i] == c){
            p++;
        }
    }
    return p;
}
int main(){
    int n,m,k;
    cin >> n >> m;
    int check[m];
    int tem[m];
    for (int i = 0;i<m;i++){
        check[i] = 0;
        tem[i] = 0;
    }
    for(int i = 0;i<n;i++){
        cin >> k;
        for(int j = 0;j<k;j++){
            cin >> tem[j];
        }
        for(int j = 0;j<m;j++){
            check[j] = check[j] + countt(tem,m,j+1);
        }
        for(int j = 0;j<m;j++){
            tem[j] = 0;
        }
    }
    cout << countt(check,m,n) << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    map<string, int> mp;
    for (int i=0; i<N; ++i) {
        string s;
        cin >> s;
        ++mp[s];
    }

    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3660