akhauriyash/Code-Regression huggingface dataset:
/*************************************************************************
    > File Name: B.cpp
    > Author: Drinkwater-cnyali
    > Created Time: 2017/7/29 20:26:58
************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std;

#define REP(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define DREP(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define mem(a, b) memset((a), b, sizeof(a))

int read()
{
	int sum = 0, fg = 1; char c = getchar();
	while(c < '0' || c > '9') { if (c == '-') fg = -1; c = getchar(); }
	while(c >= '0' && c <= '9') { sum = sum * 10 + c - '0'; c = getchar(); }
	return sum * fg;
}

int n;

int main()
{
	n = read();int k = 0;
	for(k = 0 ; (1<<k) <= n; ++k);
	cout<<(1<<(k-1))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!
typedef struct{
    char str[11]; ll p;
}data;
int main(void){
    ll N, M, ANS=0, NoName, idx=0;
    char a[11];
    data d[101];
    scanf("%lld", &N);
    rep(i, N){
        scanf("%s", a);
        NoName = 1;
        rep(j, idx){
            //同じstrが既に存在するか調べる
            if(strcmp(a, d[j].str)==0){//同じstrが見つかった
                d[j].p++;
                NoName = 0;
                break;
            }
        }
        if(NoName){//新たなstrを新規登録
            strcpy(d[idx].str, a);
            d[idx].p = 1;
            idx++;
        }
    }
    scanf("%lld", &M);
    rep(i, M){
        scanf("%s", a);
        rep(j, idx){
            if(strcmp(a, d[j].str)==0){//同じstrが見つかった
                d[j].p--;
                break;
            }
        }
    }
    //最大値を求める
    rep(i, idx) chmax(ANS, d[i].p);
    printf("%lld\n", ANS);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

const ll MOD = 998244353;
// const ll MOD = 1e9+7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  std::string s,t;
  std::cin>>s>>t;
  ll ans=2*n;
  rep(i,0,n){
    bool flag=true;
    rep(j,i,n){
      if(s[j]!=t[j-i]){
        flag=false;
        break;
      }
    }
    if(flag){
      ans-=(n-i);
      break;
    }
  }
  std::cout<<ans;
  return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop

def dijkstra(s, edge):
    '''
    始点sから各頂点への最短距離を求める
    '''
    d = [float("inf")] * n
    d[s] = 0
    used = [False] * n
    used[s] = True
    edgelist = []

    for e in edge[s]:
        heappush(edgelist, e)

    while edgelist:
        cost, v = heappop(edgelist)
        if used[v]:
            continue
        d[v] = cost
        used[v] = True
        for e in edge[v]:
            if not used[e[1]]:
                heappush(edgelist, [e[0] + d[v], e[1]])

    return d


def segfunc(x, y):
    '''
    問題に応じて返り値を設定
    '''
    return min(x, y)


def init(a):
    '''
    配列aで初期化
    '''
    for i in range(n):
        seg[i+num-1] = a[i]    
    for i in range(num-2, -1, -1) :
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])


def update(k, x):
    '''
    a[k]の値をxに更新
    '''
    k += num - 1
    seg[k] = x
    while k:
        k = (k - 1) // 2
        seg[k] = segfunc(seg[k*2+1], seg[k*2+2])


def query(p, q):
    '''
    [p, q)についてsegfuncを適用したものを返す
    '''
    if q <= p:
        return ide_ele
    
    p += num - 1
    q += num - 2
    res = ide_ele

    while q - p > 1:
        if p & 1 == 0:
            res = segfunc(res, seg[p])
        if q & 1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p // 2
        q = (q - 1) // 2
    
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(res, segfunc(seg[p], seg[q]))
    
    return res


n, m, s, t = map(int, input().split())

e1 = [[] for _ in range(n)]
e2 = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    e1[u-1].append([a, v-1])
    e1[v-1].append([a, u-1])
    e2[u-1].append([b, v-1])
    e2[v-1].append([b, u-1])

d1 = dijkstra(s-1, e1)
d2 = dijkstra(t-1, e2)
dist = [d1[i] + d2[i] for i in range(n)]

num = (2 ** len(bin(n - 1)) - 2)
ide_ele = float('inf')
seg = [ide_ele] * 2 * num
init(dist)

for i in range(n):
    print(10 ** 15 - query(i, n))

Measured memory_bytes: 201136
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

const int MX = 100010;
ll dp[MX], dp2[MX];
int s, t, deq[MX];

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, T; cin >> n;
	vi v(n + 2);
	cin >> v[n + 1] >> T;
	rep(i, n) cin >> v[i + 1];
	
	// dp[i] := best - 2 * next - cur
	// dp2[i] := best - cur
	dp[0] = -2ll * v[1];
	t = 1;
	ll min1 = 1e18;
	
	for(int i = 0, j = 0; i < n; i++){
		while(2ll * (v[i + 1] - v[j + 1]) > T){
			min1 = min(min1, dp[j]);
			if(s < t && deq[s] == j) s++;
			j++;
		}
		ll tmp = 3ll * v[i + 1] + min1;
		tmp = min(tmp, v[i + 1] + dp2[deq[s]] + T);
		if(i == n - 1){
			cout << tmp + v[n + 1] - v[n] << endl;
			return 0;
		}
		
		dp[i + 1] = tmp - 2ll * v[i + 2] - v[i + 1];
		dp2[i + 1] = tmp - v[i + 1];
		
		while(s < t && dp2[deq[t - 1]] >= dp2[i + 1]) t--;
		deq[t++] = i + 1;
	}
	
	return 0;
}

Measured memory_bytes: 2560
use io::*;
use std::collections::HashSet;
use std::*;

fn solve(N: i64, S: Vec<String>) {
    println!("{}", S.into_iter().collect::<HashSet<String>>().len());
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fn main() {
    let con = read_string();
    let mut scanner = Scanner::new(&con);
    let mut N: i64;
    N = scanner.next();
    let mut S: Vec<String> = vec![String::new(); (N) as usize];
    for i in 0..(N) as usize {
        S[i] = scanner.next();
    }
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(move || solve(N, S)).unwrap().join().unwrap();
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 21352
#include <stdio.h>
int main(){
	int n,q;
	int i,j;
	int min,max;
	scanf("%d %d",&n,&q);
	char s[200001];
	scanf("%s",s);
		char t[200001],d[200001];
	for(i=0;i<q;i++){
		scanf("\n%c %c",&t[i],&d[i]);
	}
	for(i=q-1,min=0,max=n-1;i>=0;i--){
		switch(d[i]){
		case 'R':
			if(t[i]==s[max]){
				max--;
			}
			if(min>0 && t[i]==s[min-1]){
				min--;
			}
			break;
		case 'L':
			if(t[i] ==s[min]){
				min++;
			}
			if(max < n-1 && t[i]==s[max+1]){
				max++;
			}
			break;
		}
	}
	printf("%d",max-min+1);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if ((a==1 && b==2) || (a==2 && b==1))
    printf("3\n");
    else if ((a==1 && b==3) || (a==3 && b==1))
    printf("2\n");
    else
    printf("1\n");
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    bool y = false;
    while (n) {
        int v = n % 10;
        n /= 10;
        if (v == 7)
            y = true;
    }
    if (y)
        cout << "Yes\n";
    else
        cout << "No\n";

}


Measured memory_bytes: 3640
#![allow(dead_code, unused_mut, unused_variables)]
use std::collections::VecDeque;
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::str::FromStr>(&mut self) -> T {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
            self.buf_str.clear();
        }
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!())
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::str::FromStr>(&'b mut self) -> IoIter<'a, 'b, T> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::str::FromStr> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
}
impl<'a, 'b, T: std::str::FromStr> Iterator for IoIter<'a, 'b, T> {
    type Item = T;
    fn next(&mut self) -> Option<T> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let n: usize = io.r();

    let mut count = vec![0usize; n];
    for ai in io.iter::<usize>().take(n - 1) {
        count[ai - 1] += 1;
    }
    for c in count {
        io.w(c);
    }
}


Measured memory_bytes: 15808
MOD = 10**9+7

N, K = map(int, input().split())
A = [i for i in range(N+1)]
S = [0]*(N+2)
for i in range(1,N+2):
    S[i] = S[i-1] + A[i-1]
C = [0 for i in range(N+1)]
for i in range(N+1): # i+1個とる場合
    mx = S[N+1] - S[N-i]
    mi = S[i+1] - S[0]
    #print(mx, mi)
    C[i] = mx - mi +1
#print(C)
ans = 0
for i in range(K-1, N+1):
    ans += C[i]
    ans %= MOD
print(ans)


Measured memory_bytes: 38128
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

typedef pair<int,int> pii;

int v[1000000+1];

int main(){
    int n,q;
    cin >> n >> q;

    priority_queue<pii> Q;
    while(q--){
        int ai,vi;
        scanf("%d %d",&ai,&vi);
        v[ai] += vi;
        Q.push(pii(v[ai],-ai));
        while(1){
            pii p = Q.top();
            if(v[-p.second] == p.first){
                printf("%d %d\n",-p.second, p.first);
                break;
            }
            Q.pop();
        }
    }
    return 0;
}

Measured memory_bytes: 6036
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static long cnt = 0;
	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream("./ALDS1_5_D-in19.txt"));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] s = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		
		mergeSort(s, 0, n);

		System.out.println(cnt);
	}
	public static void printArray(int[] s){
		for(int i = 0; i < s.length; ++i) {
			System.out.print(" " + s[i]);
		}
		System.out.println(": " + cnt);
	}
	public static void mergeSort(int[] s, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(s, left, mid);
			mergeSort(s, mid, right);
			merge(s, left, mid, right);
			//printArray(s);
		}
	}
	public static void merge(int[] s, int left, int mid, int right) {
		int[] s1 = Arrays.copyOfRange(s, left, mid + 1);
		int[] s2 = Arrays.copyOfRange(s, mid, right + 1);
		
		s1[mid - left] = Integer.MAX_VALUE;
		s2[right - mid] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; ++k) {
			if(s1[i] <= s2[j]){
				s[k] = s1[i];
				if(k < left + i){
					cnt += left + i - k;
				}
				i += 1;
				
			}else{
				s[k] = s2[j];
				if(k < mid + j){
					cnt += mid + j - k;
				}
				j += 1;
				
			}
		}
		
	}
	
}

Measured memory_bytes: 75116
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 

struct act{
    int a, b, c;
};

void solve(){   
    //clock_t time;
    int n; cin>>n;
    vvi v(n, vi(3));
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            cin>>v[i][j];
        }
    }
    vvi dp(n, vi(3));
    dp[0][0]=v[0][0];
    dp[0][1]=v[0][1];
    dp[0][2]=v[0][2];
    for(int i=1; i<n; i++){
        dp[i][0]=max(v[i][0]+dp[i-1][1], v[i][0]+dp[i-1][2]);
        dp[i][1]=max(v[i][1]+dp[i-1][0], v[i][1]+dp[i-1][2]);
        dp[i][2]=max(v[i][2]+dp[i-1][0], v[i][2]+dp[i-1][1]);
    }
    cout<<max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});
}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(9);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

Measured memory_bytes: 14216
import re
while 1:
    try:
        ss = re.split('[+=]', raw_input())
        for i in range(1 if any([len(s) >= 2 and s[0] == 'X' for s in ss]) else 0, 10):
            ns = [long(s.replace('X', str(i))) for s in ss]
            if ns[0] + ns[1] == ns[2]:
                print i
                break
        else:
            print 'NA'
    except EOFError:
        break

Measured memory_bytes: 4268
#include<bits/stdc++.h>
using namespace std;
const int maxn=100+10;
int n,arr[maxn],cnt=0;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(arr[j]<arr[minj]){
                minj=j;
            }
        }
        if(i!=minj){
            cnt++;
            swap(arr[i],arr[minj]);
        }
    }
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<arr[i];
    }
    cout<<"\n"<<cnt<<"\n";
}
/*
#include<bits/stdc++.h>
using namespace std;
const int maxn=100+10;
int n,arr[maxn],cnt=0;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    bool flag=1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=n-1;j>i;j--){
            if(arr[j-1]>arr[j]){
                flag=1;
                swap(arr[j],arr[j-1]);
                cnt++;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<arr[i];
    }
    cout<<"\n"<<cnt<<"\n";
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
const int maxn=100+10;
int n,arr[maxn];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i++){
        int v=arr[i];
        int j=i-1;
        while(j>=0&&arr[j]>v){
            arr[j+1]=arr[j];
            j--;
        }
        arr[j+1]=v;
        for(int i=0;i<n;i++){
            if(i) cout<<" "<<arr[i];
            else cout<<arr[i];
        }cout<<"\n";
    }
    return 0;
}
*/



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
long long n, a, b, ans = 0;

int main()
{
	scanf("%lld%lld%lld", &n, &a, &b);
	ans += n / (a + b) * a;
	ans += min(n - n / (a + b) * (a + b), a);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <utility>

int main() {
	std::map<std::pair<int, int>, int> loveMap;
	int n;
	std::cin >> n;

	for (int i = 0; i < n; ++i) {
		int a;
		std::cin >> a;
		++loveMap[std::minmax(a - 1, i)];
	}

	std::cout
		<< std::count_if(
			loveMap.begin(),
			loveMap.end(),
			[](auto&& p) { return p.second >= 2; })
		<< std::endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <stdio.h>
using namespace std;
const int NMAX = 2e5 + 10;

typedef long long ll;
int a[NMAX],pre[NMAX],b[NMAX];
int cnt;

int main(int argc, char const *argv[])
{
	int n;
	ll k;
	scanf("%d%lld",&n,&k);
	for(register int i = 1;i <= n;i++)	scanf("%d",a+i);
	int root = 1;
	while(k && !pre[a[root]])
	{
		root = a[root];
		b[++cnt] = root;
		pre[root] = cnt;
		k--;
	}
	if(!k)
		printf("%d\n",b[cnt] );
	else
	{
		// [pre[a[root]],cnt]
		int cyctime = cnt - pre[a[root]] + 1;
		int pos = k%cyctime == 0?cyctime:k%cyctime;
		printf("%d\n",b[pre[a[root]]+pos-1]);
	}
	return 0;
}

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

using lli = long long int;

using namespace std;

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

    std::vector<lli> H(N);
    for_each(H.begin(), H.end(), [](auto &x) { cin >> x; });

    std::vector<lli> dp(N, 0);
    for (lli i = 0; i < N - 1; ++i) {
        if (H[i + 1] <= H[i]) {
            dp[i + 1] = dp[i] + 1;
        } else {
            dp[i + 1] = 0;
        }
    }

    cout << *std::max_element(dp.begin(), dp.end()) << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
int n,a[MAXN];
map <int,int> mp;
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		if (mp.find(a[i])!=mp.end()) {printf("NO\n");return 0;}
		mp[a[i]]=1;
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 10368
#include<iostream>
#include<math.h> 
#include<stdio.h>
using namespace std; 
int main(){ int n; cin >> n; 
while(n!=0){ int i; double s[1000]={},sum=0,a=0; 
for(i=0;i<n;i++){ cin >> s[i];
sum+=s[i]; 
} 
for(i=0;i<n;i++){ a+=((sum/n)-s[i])*((sum/n)-s[i])/n;
} 
printf("%.5f\n",sqrt(a)); cin >> n;
} 
return 0; 
    
} 


Measured memory_bytes: 3296
def print_list(array, N):
    for i in range(N):
        if i == N-1:
            print(array[i])
        else:
            print(array[i], end=" ")
            
def stable_sort(array_a, array, N):
    for i in range(N-1):
        stable = "yes"
        if array[i][1] == array[i+1][1]:
            index_1 = array.index(array[i])
            index_2 = array.index(array[i+1])
            index_a1 = array_a.index(array[i])
            index_a2 = array_a.index(array[i+1])
            #print(index_1, index_2, index_a1, index_a2)
            if not(index_1 < index_2\
            and index_a1 < index_a2):
                stable = "no"
                break
    if stable == "yes":
        print("Stable")
    else:
        print("Not stable")
            
N = int(input())
a = input().split()
b = [s for s in a]
for i in range(N-1):
    for j in range(N-1, i, -1):
        if b[j][1] < b[j-1][1]:
            t = b[j]
            b[j] = b[j-1]
            b[j-1] = t
print_list(b, N)
stable_sort(a, b, N)

c = [s for s in a]
for i in range(N-1):
    min_i = c[i][1]
    change = "no"
    for j in range(i+1, N):
        if min_i > c[j][1]:
            min_i = c[j][1]
            index = c.index(c[j])
            change = "ok"
    if change == "ok":
        t = c[i]
        c[i] = c[index]
        c[index] = t
print_list(c, N)
stable_sort(a, c, N)

Measured memory_bytes: 7852
#include<iostream>
#include<algorithm>
#include<vector>
typedef long long int ll;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int N;
int sum = 0;
bool judge = true;

int main(void) {
	pair<int, int> a[200001];
	cin >> N;
	rep(i, 0, N)cin >> a[i].second >> a[i].first;
	sort(a, a + N);
	rep(i, 0, N) {
		sum += a[i].second;
		if (sum > a[i].first) {
			judge = false;
			break;
		}
	}

	if (judge == true)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int32_t main()
{
    int n,k;
    cin>>n>>k;
    int h[n+1]={};
    while(k--)
    {
        int d;
        cin>>d;
        int a[d],i;
        for(i=0;i<d;i++)
        {
            cin>>a[i];
            h[a[i]]=1;
        }
    }
    int i,ans=0;
    for(i=1;i<=n;i++)
    {
        if(h[i]!=1)
        ans++;
    }
    cout<<ans<<endl;



    

}


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

int main(){

  int a,b,c;
  int sum1=0,sum2=0;
  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(a*a+b*b==c*c)sum1++;
    else  if(a==b)sum2++;
  }

  cout << sum1 << endl << sum2 << endl;

  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll  a,b; cin>>a>>b;  
  
    if(a>=10 || b>=10)
  cout<< -1 <<endl;
else cout<<a*b<<endl;
}

Measured memory_bytes: 256
N=int(input())
matchNums=input().split(" ")
matchNums=list(map(int, matchNums))
plus_flgs=[-1]

if len(matchNums)==1:
    print("Yes")
    
else:
    check_array=[]
    check_array_all=[]
    
    for i in range(len(matchNums)-1):
        check_array.append((matchNums[i+1] - matchNums[i]))
    
#     for i in range(len(check_array)-1):
#         check_array_all.append((check_array[i+1] + check_array[i]))
    #プラスとプラスの間を足す
    #プラスのinedex取得
    for i,val in enumerate(check_array):
        if val > 0:
            plus_flgs.append(i)
    
    # 最後がマイナスで終わるとき対策
    plus_flgs.append(len(check_array))
#     print(plus_flgs)
#     print(check_array)
    for i in range(len(plus_flgs)-1):
        check_array_all.append(sum(check_array[plus_flgs[i]+1: plus_flgs[i+1]]))
#     print(check_array_all)
    # プラスとプラスの間の和が-2の物があったらＮＧ
    if min(check_array_all)<-1:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 15760
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
  int n; cin >> n;
  cout << n * n << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int abs(int z,int y){
    int ans;
    if(z<y) ans=y-z;
    else ans=z-y;
    return ans;
}
int main(void){
    int x,a,b;
    int c,d;
    cin>>x>>a>>b;
    c=abs(x,a);
    d=abs(x,b);
    if(c<d) cout<<'A';
    else cout<<'B';
    return 0;
}


Measured memory_bytes: 256
X,N=list(map(int,input().split()))
if N==0:
  print(X)
else:
  p_list=list(map(int,input().split()))
  not_p_list=[]
  for i in range(-105,105):
    if i not in p_list:
      not_p_list.append(i)

  nN=len(not_p_list)
  abs_list=[]
  for i in range(nN):
    temp=not_p_list[i]-X
    abs_list.append(abs(temp))

  abs_list.sort()    
  if abs_list[0]==0:
    print(X)
  else:
    ans=abs_list[0]
    for i in range(nN):
      if not_p_list[i]==X-ans:
        print(X-ans)
        break
      elif not_p_list[i]==X+ans:
        print(X+ans)
        break


Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int a[4];
	int i,j;
	for(i=0;i<4;i++){
		cin>>a[i];
	}
	for(i=0;i<4;i++){
		for(j=3;j>i;j--){
			if(a[i]>a[j]){
				swap(a[i],a[j]);
			}
		}
	}
	if(a[0]==a[1]&&a[2]==a[3]){
		cout<<"yes"<<endl;
	}
	else{
		cout<<"no"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3072
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, M;
    cin >> N >> M;

    priority_queue<ll> q;
    REP(i, N) {
        ll a; cin >> a;
        q.push(a);
    }

    REP(i, M) {
        if (q.empty()) break;

        ll a = q.top(); q.pop();
        a /= 2;
        if(a > 0) q.push(a);
    }

    ll s = 0;
    while(!q.empty()) s += q.top(), q.pop();

    print(s);
}


Measured memory_bytes: 4248
#include<iostream>
#include<string>
using namespace std;
int main(void){
string s;cin >> s;
int n;
if(s == "SUN") n = 7;
else if(s == "MON") n = 6;
else if(s == "TUE") n = 5;
else if(s == "WED") n = 4;
else if(s == "THU") n = 3;
else if(s == "FRI") n = 2;
else if(s == "SAT") n = 1;

cout << n << "\n";
}

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

int main(){
  int N,i;
  cin>>N;
  int a[N];
  for(i=0;i<N;i++) cin>>a[i];
  ll l=0,r=0,temp=a[0],ans=0;
  while(l<N){
	while(!(temp&a[r+1])&&r<N-1) {
		r+=1;
		temp+=a[r];
	}
	ans+=r-l+1;
	temp-=a[l];
	l+=1;
  }	
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  vector<long long>T(N);
  for(int X=0;X<N;X++){
    cin>>T[X];
  }
  long long U=1000000000;
  sort(T.begin(),T.end());
  for(int X=0;X<=N-K;X++){
    if(T[X+K-1]-T[X]<U){
      U=T[X+K-1]-T[X];
    }
  }
  cout<<U<<endl;
}

Measured memory_bytes: 4032
a = int(input())

if a==2:
    print(2)
elif a==3:
    print(3)

elif a%2==0:
    k=0
    a-=1
    while k==0:
        a+=2
        count=0
        for i in range(2,a//2 + 1):
            if a%i!=0:
                count+=1
        if count==a//2 - 1:
            k=1
    print(a)
elif a%2!=0:
    k=0
    a-=2
    while k==0:
        a+=2
        count=0
        for i in range(2,a//2 + 1):
            if a%i!=0:
                count+=1
        if count==a//2 - 1:
            k=1
    print(a)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

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



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k;
	cin >> n >> k;
	hm <int, int> kek;
	fr (i, k) {
		int d;
		cin >> d;
		fr (j, d) {
			int x;
			cin >> x;
			++kek[x];
		}
	}
	cout << n - sz (kek);







}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    if(n == 0) break;
    set<int> s;
    vary(int,v,5,0);
    v[0] = n;
    s.insert(n);
    REP(i,1,5){
      cin >> v[i];
      s.insert(v[i]);
    }
    rep(i,5){
      if(s.size() != 2){
        cout << 3 << endl;
      }
      else{
        if((v[i] == 2 && *s.begin() == 1) || (v[i] == 3 && *s.begin() == 2) || (v[i] == 1 && (*(++s.begin())== 3))){
          cout << 2 << endl;
        }
        else cout << 1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3136
import collections
n,m = map(int,input().split())
h = []
for i in range(n):
  h[len(h):len(h)] = list(map(int,input().split()))[1:]
ans = 0
count = collections.Counter(h)
for v in count.values():
  if v == n:
    ans += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int a = 0;
  while(A > 0 && C > 0) {
    if (a == 0) {
      C -= B;
      a = 1;
    } else {
      A -= D;
      a = 0;
    }
  }
  if (A <= 0) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 3652
// https://beta.atcoder.jp/contests/abc070

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

void print_yes_no(bool cond, string yes = "YES", string no = "NO") { cout << (cond ? yes : no) << endl; }

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    print_yes_no((100 * r + 10 * g + b) % 4 == 0);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define pi 3.141592653589
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)
#define pii pair<int,int>
using namespace std;

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

bool bit[10] = {};

void to_nisin(int n) {
	int sp = 0;
	while (1) {
		bit[sp] = n % 2;
		n /= 2;
		if (!n)break;
		sp++;
	}
}

int main() {

	string s;
	ll si,sum=0;

	cin >> s;
	si = s.size();
	rep(i, 0, pow(2,si-1)) {
		to_nisin(i);
		ll tmp = 0;
		rep(j, 0, si-1) {
			if (bit[j]) {
				tmp += s[j]-'0';
				sum += tmp;
				tmp = 0;
			}
			else {
				tmp += s[j]-'0';
				tmp *= 10;
			}
		}
		tmp += s[si-1] - '0';
		sum += tmp;
	}
	cout << sum << endl;


	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    int n, m;
    
    cin >> n >> m;
    
    int vec[m][n];
    int mat[m];
    int ans[n];
    
    for(int i=0; i < n; i++){
        for(int j=0; j < m; j++){
            cin >> vec[j][i];
        }
    }
    for(int i=0; i < m; i++){
        cin >> mat[i];
    }
    
    for(int i=0; i < n; i++){
        ans[i] = 0;
        for(int j=0; j < m; j++){
            ans[i] += vec[j][i]*mat[j];
        }
    }
    
    for(int i=0; i < n; i++){
        cout << ans[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    
    
    double N, M;
    long long sum = 0;
    
    
    cin >> N >> M;
    vector<double> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
    }
    
    
    
    double miman = sum / (4 * M);
    
    int ans = M;
    for(int i = 0; i < N; i++){
        if(A[i] >= miman){
            ans--;
        }
    }
    
    if(ans <= 0){
        cout << "Yes" << endl;
        return 0;
    }

    else cout << "No" << endl;
}





Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  char b;
  cin >> b;
  switch(b){
      case 'A':
      b='T';
      break;
      case 'T':
      b='A';
      break;
      case 'C':
      b='G';
      break;
      case 'G':
      b='C';
      break;
  }
  cout << b << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter


def main():
  n, *lst = map(int, sys.stdin.read().split())
  lst = sorted(Counter(lst).items())
  l = len(lst)
  mod = 10 ** 9 + 7
  if n % 2:
    for i in range(l):
      if not i:
        if lst[i][0] or lst[i][1] != 1:
          print(0)
          quit()
      elif lst[i][0] != i * 2 or lst[i][1] != 2:
        print(0)
        quit()
  else:
    for i in range(l):
      if lst[i][0] != i * 2 + 1 or lst[i][1] != 2:
        print(0)
        quit()
  print((1 << (n >> 1)) % mod)


if __name__ == '__main__':
  main()

Measured memory_bytes: 15840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DIslandsWar solver = new DIslandsWar();
        solver.solve(1, in, out);
        out.close();
    }

    static class DIslandsWar {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            DIslandsWar.Tuple[] operations = new DIslandsWar.Tuple[2 * m];
            for (int i = 0; i < m; i++) {
                int a = in.nextInt(), b = in.nextInt();
                operations[i * 2] = new DIslandsWar.Tuple(a, 1, i);
                operations[i * 2 + 1] = new DIslandsWar.Tuple(b, 0, i);
            }
            Arrays.sort(operations, Comparator.comparingInt(DIslandsWar.Tuple::getPos).thenComparingInt(DIslandsWar.Tuple::getType));

            int res = 0;
            boolean[] deleted = new boolean[100001];
            int left = 0;
            for (int i = 0; i < 2 * m; i++) {
                if (operations[i].type == 0) {
                    if (!deleted[operations[i].i]) {

                        ++res;
                        for (; left <= i; left++) {
                            if (operations[left].type == 1) {
                                deleted[operations[left].i] = true;
                            }
                        }
                    }
                }
            }
            out.println(res);
        }

        private static class Tuple {
            int pos;
            int type;
            int i;

            private Tuple(int pos, int type, int i) {
                this.pos = pos;
                this.type = type;
                this.i = i;
            }

            public int getPos() {
                return pos;
            }

            public int getType() {
                return type;
            }

        }

    }
}



Measured memory_bytes: 97568
import java.util.*;

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

    String[] S = new String[ H ];
    for(int i = 0 ; i < H ; i ++){
      S[ i ] = sc.next();
    }
    for( int i = 0 ; i < 2 * H ; i ++ ){
      System.out.println( S[ i / 2 ] );
    }
  }
}


Measured memory_bytes: 22100
N, M = map(int, input().split())

if M == 0:
    alist = set()
else:
    alist = set(int(input()) for _ in range(M))

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 1 if 1 not in alist else 0

MOD = 10**9 + 7
for i in range(2, N + 1):
    if i in alist:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2]) % MOD

print(dp[N])


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,m;
vl a[e5];
ll ans;

int main(){
  cin >> n >> m;
  for(ll i = 0;i < n;i++){
    ll x;
    cin >> x;
    a[i] = vl({x, 1});
  }
  for(ll i = 0;i < m;i++){
    ll c,b;
    cin >> b >> c;
    a[n+i] = vl({c,b});
  }
  sort(a,a+n+m);
  ll k = n;
  ll i = n+m-1;
  while(k > 0){
    ans += a[i][0]*min(a[i][1],k);
    k -= a[i][1];
    i--;
  }
  cout << ans << endl;


}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int a, b;
    cin >> a >> b;

    string x(b, a + '0'), y(a, b + '0');

    if (x < y)
    {
        cout << x << endl;
    }
    else
    {
        cout << y << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(ll i=0; i<n; i++)
#define all(v) v.begin(), v.end()
#define vec vector

/*  <<bit全探索>>
 
    for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
        bitset<ビット数> s(tmp);
    }
*/
 
/*　<<stringで読み込んだ数列を一桁ずつint型へ変換>>
 
    string str;
    int N[桁数];
 
    cin >> str;
 
    for (int i = 0; i < 桁数; ++i) {
 
        N[i] = (int)(str[i] - '0');  //str[i]　はchar型なのでchar→intへ変換
 
        //cout << N[i] << endl;  //確認のため表示
    }
*/
 
typedef long long ll;

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


int main() { 

    int N, K;
    cin >> N >> K;
    
    vec<int> H(N, 0);

    rep(i, K){
        int d;
        cin >> d;
        rep(j, d){
            int A;
            cin >> A;
            H.at(A - 1) = 1;
        }
    }

    int cnt = 0;
    rep(i, N){
        if(H.at(i) == 0){
            cnt++;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
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;
}
const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
string vec[ 2 ][ 3002 ];

int main() {
	string s, t;
	cin >> s >> t;
	int s_l = s.size(), t_l = t.size();
	rep( i, 0, s_l ){
		int index = i & 1;
		int next = !index;
		rep( j, 0, t_l ){
			if (s[ i ] == t[ j ]){
				vec[ next ][ j + 1 ] = vec[ index ][ j ];
				vec[ next ][ j + 1 ]+=s[i];
			}
			else {
				if (vec[ index ][ j + 1 ].size() > vec[ next ][ j ].size())
					vec[ next ][ j + 1 ] = vec[ index ][ j + 1 ];
				else
					vec[ next ][ j + 1 ] = vec[ next ][ j ];
			}
		}
	}
	printf( "%s\n", vec[ s_l&1 ][ t_l ].c_str());
}


Measured memory_bytes: 16816
#include<stdio.h>
#define NIT -1

int depth(int );
void output(int );


typedef struct{
  int parent;
  int left;
  int right;
}vertex;

int child,mae;
int degree[100000],A[100000];
vertex Tree[100000];

main(){
  
  int i,j,n,id;
  
  scanf("%d",&n);
  
  for( i=0 ; i<n ; i++){
    Tree[i].parent = Tree[i].left = Tree[i].right = NIT;
  }
  for( i=0 ; i<n ; i++){
    scanf("%d",&id);
    scanf("%d",&degree[i]);
    
    for( j=0 ; j<degree[i] ; j++){
      scanf("%d",&child);
      
      if(j == 0){
	Tree[id].left = child;
	Tree[child].parent = id;
	mae = child;
      }
      
      else {
	Tree[mae].right = child;
	Tree[child].parent = id;
	mae = child;
      }
    }
  }
  
  for( i=0 ; i<n ; i++ ){
    A[i] = depth(i);
  }
  for( i=0 ; i<n ; i++ ){
    output(i);
  }
  return 0;
}

int depth(int i){
  int d =0;
  while(1){
    if(Tree[i].parent == NIT)
      break;
    d++;
    i = Tree[i].parent;
  }
  return d;
}


void output(int i){
  
  printf("node %d: parent = %d, depth = %d, ",i,Tree[i].parent,A[i]);
  
  if(Tree[i].left == NIT && Tree[i].parent != NIT){
    printf("leaf, [");
  }
  else if(Tree[i].parent == NIT){
    printf("root, [");
  }
  else{
    printf("internal node, [");
  }
  
  if(Tree[i].left != NIT){
    while(1){
      if(Tree[Tree[i].left].right == NIT){
	printf("%d",Tree[i].left);
	break;
      }
      else {
	printf("%d, ",Tree[i].left);
	Tree[i].left = Tree[Tree[i].left].right;
      }
    }
  }
  printf("]\n");
}

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

vector<int> g[100055];

int main() {
	int n;
	cin >> n;
	
	int k = 1;
	
	while (k * (k - 1) / 2 < n) k++;
	
	if (k * (k - 1) / 2 != n) {
		puts("No");
		return 0;
	}
	
	printf("Yes\n%d\n", k);
	
	int cnt = 0;
	
	for (int i = 0; i < k; i++) for (int j = i + 1; j < k; j++) {
		g[i].push_back(cnt);
		g[j].push_back(cnt++);
	}
	
	for (int i = 0; i < k; i++) {
		printf("%d", (int)g[i].size());
		
		for (auto u : g[i]) printf(" %d", u + 1);
		puts("");
	}
}


Measured memory_bytes: 4608
N, K = map(int, input().split())
a = [int(c) for c in input().split()]
f = [int(c) for c in input().split()]
a.sort()
f.sort(reverse=True)
def check(n):
  m = K
  for i in range(N):
    m -= max(0, a[i]-n//f[i])
    if m<0:
      return False
  return True
r = 0
l = a[-1]*f[0]
X = (l-r)//2+r
while not (check(X)^check(X+1)) :
  if check(X):
    l = l - (l-r)//2
  else:
    r = (l-r)//2 + r
  X = (l-r)//2+r
  if check(0):
    print(0)
    break
else:
  print(X+1)

Measured memory_bytes: 119500
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
#define MOD 100000007
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	ll n,m;
	cin >> n >> m;
	double kitaiti = 0,kakuritu = 1.0/pow(2,m),zikan = m*1900+(n-m)*100,
		zmemo = zikan,kmemo = pow(2,m),kmemo2 = pow(2,m)-1;
	
	rep(i,0,100000){
		//cout << kakuritu << " " << zmemo << endl;
		kitaiti += kakuritu*zmemo;
		kakuritu *= kmemo2/kmemo;
		zmemo += zikan;
	}
	
	
	cout << kitaiti << endl;
	
	
	return 0;
}

Measured memory_bytes: 256