akhauriyash/Code-Regression huggingface dataset:
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 200;
bool mark[MAXN];
int main(){
	ios_base::sync_with_stdio(NULL);cin.tie(nullptr);cout.tie(nullptr);
        int n , k , d , in , ans = 0;
        cin >> n >> k;
        for(int i = 0 ; i < k ; i++){
                cin >> d;
                for(int j = 0 ; j < d ; j++){
                        cin >> in;
                        mark[in] = 1;
                }
        }
        for(int i = 1 ; i <= n ; i++)
                if(!mark[i]) ans++;
        cout << ans << '\n';
}


Measured memory_bytes: 3636
def LinearSearch1(S, n, t):
    for i in range(n):
        if S[i] == t:
            return i
            break
    else:
        return -1

"""
def LinearSearch2(S, n, t):
    S.append(t)
    i = 0

    while S[i] != t:
        i += 1

    S.pop()
    if i == n:
        return -1
    else:
        return i
"""

n = int(input())
S = [int(s) for s in input().split()]

q = int(input())
T = {int(t) for t in input().split()}

ans = sum(LinearSearch1(S, n, t) >= 0 for t in T)

print(ans)

Measured memory_bytes: 8560
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
using namespace std;

int main(void)
{	
	char w[11] = "\0";
	cin >> w;
	
	int cnt = 0;
	while (1) {
		char buf[1001] = "\0";
		cin >> buf;
		if (strcmp(buf, "END_OF_TEXT") == 0) break;
		for (int i = 0; buf[i] != '\0'; i++) {
			buf[i] = tolower(buf[i]);
		}
		if (strcmp(buf, w) == 0) cnt++;
	}
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(int argc, char** argv) {
  int n, k;
  cin >> n >> k;
  int h[n];
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
  }
  
  int required = n - k;
  if (required <= 0) {
    cout << "0\n";
    return 0;
  }
  
  partial_sort(&h[0], &h[k], &h[n], greater<int>());
  long long total = 0;
  for (int i = k; i < n; ++i) {
    total += h[i];
  }
  cout << total << "\n";
  return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = (long long)1e9 + 7; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	vector<int> d;
	int N;
	
	cin>>N;
	
	d.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>d[i];
	}
	
	sort(d.begin(), d.end());
	
	cout<<d[N/2] - d[N/2 - 1]<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

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; }

//�G���g�X�e�l�X���
vector<int> estora(vector<int> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
vector<ll> fac(ll n, vector<ll> num) {
    ll kazu = n;
    for (int i = 2; i <= n; i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1)
        num[n]++;
    return num;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return num;
}
const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    string s;
    cin >> s;
    int ans = 0;
    rep(i, s.size()) {
        ans += s[i] - '0';
    }
    if (ans % 9 == 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll N;

struct SegmentTree {
  vector<pair<ll, ll> > Tree[20];

  void init() {
    for(ll i=0;i<20;++i) {
      Tree[i].resize((1<<i));
      for(ll j=0;j<Tree[i].size();++j) Tree[i][j] = mp(N-2, big);
    }
  }

  void eval(ll pos1, ll pos2) {
    if(Tree[pos1][pos2].se==big) return;
    if(pos1+1<20) {
      Tree[pos1+1][2*pos2].se = min(Tree[pos1+1][2*pos2].se, Tree[pos1][pos2].se);
      Tree[pos1+1][2*pos2+1].se = min(Tree[pos1+1][2*pos2+1].se, Tree[pos1][pos2].se);
    }
    Tree[pos1][pos2].fi = min(Tree[pos1][pos2].fi, Tree[pos1][pos2].se);
    Tree[pos1][pos2].se = big;
    return;
  }

  void update(ll ql, ll qr, ll x, ll pos1=0, ll pos2=0, ll sl=0, ll sr=(1<<19)) {
    eval(pos1, pos2);
    if(qr<=sl || sr<=ql) return;
    if(ql<=sl && sr<=qr) {
      Tree[pos1][pos2].se = min(Tree[pos1][pos2].se, x);
      eval(pos1, pos2);
      return;
    }
    update(ql, qr, x, pos1+1, 2*pos2, sl, (sl+sr)/2);
    update(ql, qr, x, pos1+1, 2*pos2+1, (sl+sr)/2, sr);
    Tree[pos1][pos2].fi = min(Tree[pos1+1][2*pos2].fi, Tree[pos1+1][2*pos2+1].fi);
    return;
  }

  ll find(ll ql, ll qr, ll pos1=0, ll pos2=0, ll sl=0, ll sr=(1<<19)) {
    eval(pos1, pos2);
    if(sr<=ql || qr<=sl) return big;
    if(ql<=sl && sr<=qr) return Tree[pos1][pos2].fi;
    return min(find(ql, qr, pos1+1, 2*pos2, sl, (sl+sr)/2), find(ql, qr, pos1+1, 2*pos2+1, (sl+sr)/2, sr));
  }
};

int main() {
  ll Q;
  cin>>N>>Q;
  SegmentTree seg1, seg2;
  seg1.init();
  seg2.init();
  ll ans = 0;
  ll query, x;
  ll tmp;
  for(ll i=0;i<Q;++i) {
    cin>>query>>x;
    x -= 2;
    if(query==1) {
      tmp = seg1.find(x, x+1);
      ans += tmp;
      seg2.update(0, tmp, x);
    }
    else {
      tmp = seg2.find(x, x+1);
      ans += tmp;
      seg1.update(0, tmp, x);
    }
  }
  cout<<(N-2)*(N-2)-ans<<endl;
}



Measured memory_bytes: 35948
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [u64; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1

fn main() {
    input! {
        n: usize, q: usize,
        s: chars,
        t: [(usize,usize); q]
    }
    let mut sum = vec![0;200000];
    for (i,_) in s.iter().enumerate() {
        if i >= 1 { sum[i] += sum[i-1]; }
        if i >= 1 && s[i-1] == 'A' && s[i] == 'C' { sum[i] += 1; }
    }
    for (l,r) in t { println!("{}", sum[r-1]-sum[l-1]); }
}

Measured memory_bytes: 6908
class UnionFind():
    def __init__(self,n):
        # 子：親のid
        # 親：-サイズ（<0）
        self.d = [-1] * n
    
    # xの親を探す
    def find(self, x):
        if(self.d[x] < 0):
            # x自身が親
            return x
        else:
            # 親のidを格納
            self.d[x] = self.find(self.d[x])
            return self.d[x]
        
    # x,yを結合
    def unite(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if(x!=y):
            # yの方がサイズが大きい場合
            if(self.d[x] > self.d[y]):
                # サイズの結合・親のidの格納
                self.d[y] += self.d[x]
                self.d[x] = y
            else:
                self.d[x] += self.d[y]
                self.d[y] = x
    
    # 連結成分のサイズを返す
    def size(self, x):
        if(self.d[x] < 0):
            return -self.d[x]
        else:
            return -self.d[self.find(x)]
    
    # 親が同じならTrue
    def same(self,x,y):
        return (self.find(x) == self.find(y))


N, M, K = map(int, input().split())
ut_f = UnionFind(N)
ut_b = UnionFind(N)
ab = []
cd = [] 
for i in range(M):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    ut_f.unite(a,b)
    ab.append((a,b))
for j in range(K):
    c,d = map(int, input().split())
    c -= 1
    d -= 1
    ut_b.unite(c,d)
    cd.append((c,d))

ans = [0] * N
for i in range(N):
    ans[i] = ut_f.size(i) - 1

# 友達を引く
for a,b in ab:
    if(ut_f.same(a,b)):
        ans[a] -= 1
        ans[b] -= 1

# ブロック関係を引く
for c,d in cd:
    # 友達に関する同じ連結成分内だったら、友達候補から外す
    if(ut_f.same(c,d)):
        ans[c] -= 1
        ans[d] -= 1
print(*ans)

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

struct UnionFind{
    vector<int> par, rank;
    UnionFind(int s) {
        par.resize(s);
        rank.resize(s, 0);
        for(int i = 0; i < s; ++i) par[i] = i;
    }
    int root(int x) {
        return par[x] == x ? x : par[x] = root(par[x]);
    }
    bool same(int x, int y) { return root(x) == root(y); }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
};

const int MAX_N = 100100;
int Friend[MAX_N], Group[MAX_N];
int N, M, K;

int main()
{
    scanf("%d %d %d", &N, &M, &K);
    UnionFind List(MAX_N);
    for(int i = 0; i < M; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        List.unite(a,b);
        ++Friend[a], ++Friend[b];
    }
    for(int i = 0; i < N; ++i) {
        List.root(i);
    }
    for(int i = 0; i < N; ++i) {
        ++Group[List.par[i]];
    }
    for(int i = 0; i < N; ++i) {
        Group[i] = Group[List.par[i]];
    }
    for(int i = 0; i < K; ++i) {
        int c, d;
        scanf("%d %d", &c, &d);
        --c, --d;
        if(List.same(c,d)) {
            ++Friend[c], ++Friend[d];
        }
    }
    for(int i = 0; i < N; ++i) {
        printf("%d ", Group[i] - 1 - Friend[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s, t;
  cin >> s >> t;

  int n = s.size();
  int m = t.size();
  int ma = 0;
  rep(i, n-m+1){
    int cnt = 0;
    rep(j, m){
      if(s[i+j] == t[j]) cnt++;
    }
    chmax(ma, cnt);
  }

  cout << m - ma << endl;

  return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
A = deque(list(input()))
num, tmp, ans = 0, 0, 0

for i in range(len(A)):
    tmp = A.popleft()
    if num == 0 and tmp == 'A':
        num = 1
    elif num == 1 and tmp == 'B':
        num = 2
    elif num == 1 and tmp == 'A':
        pass
    elif num == 2 and tmp == 'C':
        num = 0
        ans += 1
    else:
        num = 0
print(ans)

Measured memory_bytes: 3444
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int p = sc.nextInt();
      int avg = n / p;
      System.out.println(Math.abs(n - avg * p) == 0 ? 0 : 1);
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
            int start = a[i];
            int counter = 0;
            while (start % 2 == 0) {
                counter++;
                start /= 2;
            }
            sum += counter;
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 34536
# coding: utf-8
# Your code here!

N = int(input())

count_AB = 0
count_last_A = 0
count_first_B = 0
count_both = 0
for i in range(N):
    s = input().rstrip()
    
    count_AB += len(s.split('AB')) - 1
    
    if s[0] == 'B' and s[-1] == 'A':
        count_both += 1
    elif s[0] == 'B':
        count_first_B += 1
    elif s[-1] == 'A' :
        count_last_A += 1
        
max_AB = max(count_last_A, count_first_B)
min_AB = max(count_last_A, count_first_B)

temp = 0
if count_both > 0:
    temp += count_both - 1
    count_both = 1
    
    if max_AB > 0:
        temp += 1
        count_both = 0
        max_AB -= 1
        min_AB += 1
        
if count_both == 0:
    temp += min(count_last_A, count_first_B)
    
print(count_AB + temp)
    




Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int x;
  
  scanf("%d", &x);
  
  if (400 <= x && x <= 599) {
	printf("8");
  } else if (600 <= x && x <= 799) {
    printf("7");
  } else if (800 <= x && x <= 999) {
    printf("6");
  } else if (1000 <= x && x <= 1199) {
    printf("5");
  } else if (1200 <= x && x <= 1399) {
    printf("4");
  } else if (1400 <= x && x <= 1599) {
    printf("3");
  } else if (1600 <= x && x <= 1799) {
    printf("2");
  } else if (1800 <= x && x <= 1999) {
    printf("1");
  }
  
  return 0;
}

Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
#include<algorithm>
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b); 
}
int main() {
	ll n,m;
	cin>>n>>m;
	ll ch[100010];	ll cnt2[100010];
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		x/=2;
		ll sum=0;
		while(x%2==0){
			sum++;
			x/=2;
		}		cnt2[i]=sum;
		ch[i]=x;
	}
	ll sum2=cnt2[0];
	for(ll i=0;i<n-1;i++){
		if(cnt2[i]!=cnt2[i+1]){
			cout << 0;
			return 0;
		}
		sum2=max(sum2,cnt2[i+1]);
	}
	for(ll i=0;i<sum2;i++){
		m/=2;
	}
	ll lcm=ch[0];
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		ll gcd=dep(max(lcm,now),min(lcm,now));
		lcm=lcm/gcd*now;
		if(lcm>m){
			cout << 0;
			return 0;
		}
	}

//	cout << gcd<<endl;
//	cout << GCD<<endl;

	cout <<(m/lcm-1)/2+1;
	// your code goes here
	return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;

struct UnionFind {
private:
	vector< int > data;
	
public:
	UnionFind(int _size) : data(_size, -1) {}
	
	bool unite(int _x, int _y) {
		_x = root(_x); _y = root(_y);
		if (_x != _y) data[_x] += data[_y]; data[_y] = _x;
		return _x != _y;
	}
	
	bool same(int _x, int _y) { return root(_x) == root(_y); }
	
	int root(int _x) { return data[_x] < 0 ? _x : data[_x] = root(data[_x]); }
	
	int size(int _x) { return -data[root(_x)]; }
};

int N, Q, p[100010];
char q[100010];
int mark[100010], v[100010];
lint anc[100010];

void solve() {
	UnionFind uf(N+1);
	
	for_(i,1,N) if (!mark[i]) uf.unite(p[i], i);
	
	lint ans = 0;
	
	for_rev(i,Q-1,0) {
		if (q[i] == 'M') {
			--mark[ v[i] ];
			if (!mark[ v[i] ]) uf.unite(p[ v[i] ], v[i]);
		} else {
			ans += uf.root(v[i]);
		}
	}
	
	cout << ans << endl;
}

int main() {
	while (scanf("%d %d", &N, &Q), N) {
		++N;
		for_(i,2,N) {
			scanf("%d", &p[i]);
		}
		
		minit(mark, 0);
		mark[1] = 1;
		
		for_(i,0,Q) {
			scanf("%s %d", &q[i], &v[i]);
			if (q[i] == 'M') ++mark[ v[i] ];
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 2888
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> t(n), a(n), vt(n, -1), va(n, -1), mx(n, 1<<30);
	for(int i = 0; i < n; i++) cin >> t[i];
	for(int i = 0; i < n; i++) cin >> a[i];
	vt[0] = t[0];
	int lst = 0;
	for(int i = 1; i < n; i++){
		if(t[i] > t[lst]){
			vt[i] = t[i];
			lst = i;
		}
	}
	va[n - 1] = a[n - 1];
	lst = n - 1;
	for(int i = n - 2; i >= 0; i--){
		if(a[i] > a[lst]){
			va[i] = a[i];
			lst = i;
		}
	}
	for(int i = 0; i < n; i++){
		if(va[i] != -1 && vt[i] != -1 && va[i] != vt[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	for(int i = 0; i < n; ){
		int j = i + 1;
		while(j < n && vt[j] == -1){
			mx[j] = min(mx[j], vt[i]);
			j++;
		}
		i = j;
	}
	for(int i = n - 1; i >= 0; ){
		int j = i - 1;
		while(j >= 0 && va[j] == -1){
			mx[j] = min(mx[j], va[i]);
			j--;
		}
		i = j;
	}
	for(int i = 0; i < n; i++){
		if(va[i] != -1 && va[i] > mx[i]){
			cout << 0 << endl;
			return 0;
		}
		if(vt[i] != -1 && vt[i] > mx[i]){
			cout << 0 << endl;
			return 0;
		}
	}
	const int mod = 1'000'000'007;
	auto mul = [&](long long a, long long b){
		return a * b % mod;
	};
	int ans = 1;
	for(int i = 0; i < n; i++) if(va[i] == -1 && vt[i] == -1) ans = mul(ans, mx[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2176
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    char[] t = br.readLine().toCharArray();
    
    int result = 0;
    int temp = 0;
    for (char c : t){
      if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
        temp++;
        if (result < temp) result = temp;
      } else {
        temp = 0;
      }
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <deque>
#define int long long 
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define rep(i,start,end) for(int i=start;i<end;i++)
#define per(i,start,end) for (int i=end-1;i>=start;i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define vp vector<pair<int,int>>
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
const int N = 1e5;
using namespace std;

void solve()
{
	int pos, zero, neg, k;
	cin >> pos >> zero >> neg >> k;
	int s = 0;
	if (k <= pos)
	{
		s += k;
		cout << s << "\n";
		return;
	}
	s += pos;
	if (k <= pos + zero)
	{
		cout << s << "\n";
		return;
	}
	int rem = k - (pos + zero);
	s -= rem;
	cout << s << "\n";
	
		




}
int32_t main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	fast_io;
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>

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

#if 0
  std::vector<int> T(N), V(N);
  int tsum=0;
  for (int &t: T) {
    scanf("%d", &t);
    tsum += t;
    t = tsum;
  }
  for (int &v: V) scanf("%d", &v);
#endif

  std::vector<int> T{0}, V;
  int tsum=0;
  for (int i=0; i<N; ++i) {
    int t;
    scanf("%d", &t);
    tsum += t;
    T.emplace_back(tsum);
  }

  for (int i=0; i<N; ++i) {
    int v;
    scanf("%d", &v);
    V.emplace_back(v);
  }

  T.emplace_back(T.back());
  V.emplace_back(0);

#if 0
  for (int i=0; i<=N; ++i)
    fprintf(stderr, "%d%c", T[i], i<N? ' ':'\n');

  for (int i=0; i<=N; ++i)
    fprintf(stderr, "%d%c", V[i], i<N? ' ':'\n');
#endif
  double res=0.0;
  int v=0;
  int ti=0;
  for (int t=0; t<tsum; ++t) {
    int ceil=V[ti];
    int nextv=v+1;
    //fprintf(stderr, "%d ceil: %d\n", t, ceil);

    if (T[ti+1] == t+1) ++ti;
    res += v;

    //fprintf(stderr, "%d: (%d=T[%d])\n", t, T[ti], ti);
    for (int i=ti; i<=N; ++i) {
      if (T[i] <= t) continue;
      //fprintf(stderr, "V[%d] = %d\n", i, V[i]+T[i]-(t+1));
      nextv = std::min(nextv, V[i]+T[i]-(t+1));
    }

    nextv = std::min(nextv, ceil);

    //fprintf(stderr, "%d: %d -> %d\n", t, v, nextv);
    if (v == nextv) {
      if (v < ceil) {
        res += 0.25;
      } else if (v == ceil) {
        res += 0.0;
      } else {
        //fprintf(stderr, "%d -> %d\n", v, nextv);
        return 1;
      }
    } else if (v < nextv) {
      res += 0.5;
    } else if (v > nextv) {
      res -= 0.5;
    }

    v = nextv;
  }

  printf("%.16f\n", res);
  return 0;
}


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

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

    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

A,B=LI()
print(max(A+B, A-B, A*B))


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

int main(){
//srandom((unsigned long)time(NULL));

int a,b,t;
cin>>a>>b>>t;

cout<<b*(t/a)<<endl;



return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdio>
#define sort(i) sort(i.begin(),i.end())
using namespace std;

signed main() {
	int a[2001]{};
	for (int b = 0; b < 1001; b++) {
		for (int c = 0; c < 1001; c++) {
			a[b + c]++;
		}
	}
	int b[4001]{};
	for (int c = 0; c < 2001; c++) {
		for (int d = 0; d < 2001; d++) {
			b[c + d] += a[c] * a[d];
		}
	}
	int s;
	while (cin >> s) {
		cout << b[s] << endl;
	}
}

Measured memory_bytes: 3084
d,g = map(int,input().split())
l = list(list(map(int,input().split())) for i in range(d))
ans = 10**7


for bit in range(1<<d):
  count = 0
  sum =0
  nokori = set(range(1,d+1))
  
  for j in range(d):
    if bit&(1<<j):
      count += l[d-j-1][0]
      sum += l[d-j-1][0]*100*(d-j)+l[d-j-1][1]
      nokori.discard(d-j)
      
      
  if sum<g:
    use = max(nokori)
    n = min(l[use-1][0]-1,-(-(g-sum)//(100*use)))
    count += n
    sum += 100*(use)*n
     
  if sum>=g:
    ans = min(ans,count)
  
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T, typename U>
void chmin(T &t, const U &u)
{
   if (t > u)
      t = u;
}
template <typename T, typename U>
void chmax(T &t, const U &u)
{
   if (t < u)
      t = u;
}
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
   T res = 1;
   for (; n; n >>= 1)
   {
      if (n & 1)
         res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
   string s;
   cin >> s;
   if (s.back() == '1' || s[0] == '0')
   {
      cout << -1 << endl;
      return 0;
   }

   int n = siz(s);

   for (int i = 0; i <= n - 2 - i; i++)
   {
      if (s[i] != s[n - 2 - i])
      {
         cout << -1 << endl;
         return 0;
      }
   }

   int p=2,c=2;
   cout<<1<<" "<<2<<endl;
   for (int i = 0; i < n-2; i++)
   {
      if (s[i] == '1')
      {
         p=c;
         c++;
         cout<<p<<" "<<c<<endl;
      }else{
         c++;
         cout<<p<<" "<<c<<endl;
      }
   }
}


Measured memory_bytes: 1664
import java.util.*;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    char[] c = s.toCharArray();
    boolean t = true;

    if (n%2 != 0) {
      t = false;
    }


      for (int i = 0 ; i < n/2 ; i++ ) {
        if (c[i] != c[i+n/2]) {
          t = false;
        }
      }


    if (t) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var N = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int A = N[0];
            int B = N[1];

            if (A > 12) {
                Console.WriteLine(B);
            }else if(A<=12 && A >= 6)
            {
                Console.WriteLine(B/2);
            }
            else
            {
                Console.WriteLine(0);
            }
            


        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
unsigned int table[2048 * 2048];
 
void sort(unsigned int* array, int size) {
    unsigned int* tmp;
    int i, j;
 
    if(size > 1) {
        sort(array, size / 2);
        sort(array + size / 2, size - size / 2);
    }
 
    tmp = malloc(sizeof(unsigned int) * size);
    for(i = 0, j = 0; i < size / 2 && j < size - size / 2;) {
        if(array[i] > array[size / 2 + j]) {
            tmp[i + j] = array[i];
            i++;
        }
 
        else {
            tmp[i + j] = array[size / 2 + j];
            j++;
        }
    }
 
    for(; i < size / 2; i++)
        tmp[i + j] = array[i];
    for(; j < size - size / 2; j++)
        tmp[i + j] = array[size / 2 + j];
 
    memcpy(array, tmp, sizeof(unsigned int) * size);
    free(tmp);
}
 
int main(void) {
    int N, M;
    int h[2048], w[2048];
    int count;
    int ans;
 
    int i, j;
 
    while(1) {
        ans = 0;
        scanf("%d %d", &N, &M);
        if(N == 0 && M == 0)
            break;
        for(i = 0; i < N; i++)
            scanf("%d", &h[i]);
        for(i = 0; i < M; i++)
            scanf("%d", &w[i]);
 
        for(i = 0; i < N - 1; i++)
            h[i + 1] += h[i];
        for(j = 0; j < M - 1; j++)
            w[j + 1] += w[j];
 
        h[N] = w[M] = 0;
        for(i = 0; i < N + 1; i++) {
            for(j = 0; j < M + 1; j++) {
                table[i * (M + 1) + j] = h[i] + w[j];
            }
        }
        sort(table, (N + 1) * (M + 1));
 
        for(i = 0, count = 0; i < (N + 1) * (M + 1); i++) {
            if(table[i] == table[i + 1])
                count++;
            else {
                ans += count * (count + 1) / 2;
                count = 0;
            }
        }
 
        printf("%d\n", ans);
    }
 
    return 0;
}

Measured memory_bytes: 23800
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;
long long x;
int main(){
	ios::sync_with_stdio(false);
	cin>>x;
	long long y=x/11;
	long long z=x%11;
	long long ans=0;
	ans+=2*y;
	if (z>0) ans++;
	if(z>6) ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int a[100000];
int b[100000];

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

    sort(a, a + n);
    for (int i = 0; i < n; ++i)
        b[i] = abs(n - i - i - 1);
    sort(b, b + n);
    for (int i = 0; i < n; ++i)
        if (b[i] != a[i])
            return cout << 0, 0;
    cout << pwr(2, n / 2);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);

int gcd(int x, int y) {
  if(x < y) swap(x,y);
  if(x % y == 0) return y;
  return gcd(y, x%y);
}

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

  long sum = 0;
  for(int a = 1; a <= k; a++) {
    for(int b = 1; b <= k; b++) {
      for(int c = 1; c <= k; c++) {
        sum += gcd(gcd(a,b),c);
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

int main(){
  ll h,w,n; cin >> h >> w >> n;
  map<pii,itn> mp;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    a--; b--;
    for(int j=a-1;j<=a+1;j++){
      for(int k=b-1;k<=b+1;k++){
        mp[pii(j,k)]++;
      }
    }
  }
  map<int,int> ans;
  ll sum=0;
  for(auto v:mp){
    if(1<=v.fi.fi&&v.fi.fi<=h-2&&1<=v.fi.se&&v.fi.se<=w-2){
      ans[v.se]++;
      sum++;
    }
  }
  cout << (h-2)*(w-2)-sum << endl;
  rep1(i,9){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 59812
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
a,b = map(int,input().split())

ans = 0
concentnum = 1
while concentnum <b:
    concentnum = concentnum -1 +a
    ans += 1

print(ans)
# print("{:.10f}".format(ans))


Measured memory_bytes: 2940
#include <stdio.h>

int c[30],cnt;

int main() {
	char S[11];
	scanf("%s", S);
	int s = (S[0] - '0') * 1000 + (S[1] - '0') * 100 + (S[2] - '0') * 10 + (S[3] - '0');
	if (s == 2019) {
		s = (S[5] - '0') * 10 + (S[6] - '0');
		if (s <= 4) {
			printf("Heisei\n");
			return 0;
		}
	}
	printf("TBD\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void)
{
    long long int n, k;
    cin >> n >> k;
    long long int a, b;
    a = n % k;
    if (n > k)
    {
        if (k > (2 * a))
        {
            b = abs(a - k);
            if (a < b)
            {
                cout << a << endl;
            }
            else
            {
                cout << b << endl;
            }
        }
      else {
        cout <<k-a<<endl; }
    }
    else
    {
        if (n < (k - n))
        {
            cout << n << endl;
        }
        else
        {
            cout << k - n << endl;
        }
    }
}

Measured memory_bytes: 256
s = gets.chomp.split('')

def kaibun?(s)
  if s.size == 1
    return true
  end
left = s.slice!(0..(((s.size) / 2) - 1))
mid = s.slice!(0) if (left.size + s.size).odd?
right = s

# p left
# p mid
# p right
left == right.reverse
end

if kaibun?(s.dup) && kaibun?(s.slice!(0..(((s.size) / 2) - 1)))
  s.slice!(0)
  if kaibun?(s)
    puts 'Yes'
  else
    puts 'No'
  end
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#if defined(__GNUC__)
#pragma GCC optimize ("Ofast")
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 100010, LOG=20;

ll n, s, x, y, t, a, b, ans;
vector<ll> D;

ll f(ll b){
	if (b<2) return 0;
	ll res=0;
	for (ll tmp=n; tmp; tmp/=b) res+=tmp%b;
	return res;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>s;
	for (ll i=2; i*i<=n; i++) if (f(i)==s) kill(i)
	
	for (ll d=1; d*d<=n-s; d++) if ((n-s)%d==0){
		D.pb(d);
		if (d*d!=n-s) D.pb((n-s)/d);
	}
	sort(all(D));
	for (ll B:D) if (f(B+1)==s) kill(B+1)
	if (s==n) kill(n+1)
	kill(-1)
	
	return 0;
}
/*
      ___           ___                            ___           ___           ___           ___           ___           ___
     /\  \         /\__\      ___                 /\  \         /\__\         /\  \         /\__\         /\  \         /\__\      ___
    /::\  \       /:/  /     /\  \               /::\  \       /:/  /        /::\  \       /:/  /        /::\  \       /:/  /     /\  \
   /:/\:\  \     /:/  /      \:\  \             /:/\ \  \     /:/__/        /:/\:\  \     /:/__/        /:/\:\  \     /:/  /      \:\  \
  /::\~\:\  \   /:/  /       /::\__\           _\:\~\ \  \   /::\  \ ___   /::\~\:\  \   /::\  \ ___   /::\~\:\  \   /:/  /       /::\__\
 /:/\:\ \:\__\ /:/__/     __/:/\/__/          /\ \:\ \ \__\ /:/\:\  /\__\ /:/\:\ \:\__\ /:/\:\  /\__\ /:/\:\ \:\__\ /:/__/     __/:/\/__/
 \/__\:\/:/  / \:\  \    /\/:/  /             \:\ \:\ \/__/ \/__\:\/:/  / \/__\:\/:/  / \/__\:\/:/  / \/__\:\/:/  / \:\  \    /\/:/  /
      \::/  /   \:\  \   \::/__/               \:\ \:\__\        \::/  /       \::/  /       \::/  /       \::/  /   \:\  \   \::/__/
      /:/  /     \:\  \   \:\__\                \:\/:/  /        /:/  /        /:/  /        /:/  /        /:/  /     \:\  \   \:\__\
     /:/  /       \:\__\   \/__/                 \::/  /        /:/  /        /:/  /        /:/  /        /:/  /       \:\__\   \/__/
     \/__/         \/__/                          \/__/         \/__/         \/__/         \/__/         \/__/         \/__/
*/


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

using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;

ll n, m;
ll a[MAXN], b[MAXN];

ll sz[MAXN], parent[MAXN];

void init() {
  for (int i=0;i<MAXN;i++) {
    parent[i] = i;
    sz[i] = 1LL;
  }
}

ll find(ll x) {
  while (parent[x] != x) {
    x = parent[x] = parent[parent[x]];
  }
  return x;
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return;
  }
  if (sz[x] < sz[y]) {
    swap(x, y);
  }
  sz[x] += sz[y];
  parent[y] = x;
}

bool same(ll x, ll y) {
  return find(x) == find(y);
}

ll size(ll x) {
  return sz[find(x)];
}

void solve() {
  vector<ll> ans;
  init();
  ll sum = n * (n - 1) / 2;
  for (int i=m-1;i>=0;i--) {
    ans.push_back(sum);
    if (!same(a[i], b[i])) {
      ll sizeA = size(a[i]);
      ll sizeB = size(b[i]);
      sum -= ((sizeA + sizeB) * (sizeA + sizeB - 1) - sizeA * (sizeA - 1) - sizeB * (sizeB - 1)) / 2;
      unite(a[i], b[i]);
    }
  }
  for (int i=0;i<m;i++) {
    cout << ans.back() << endl;
    ans.pop_back();
  }
}

int main() {
  cin >> n >> m;
  for (int i=0;i<m;i++) {
    cin >> a[i] >> b[i];
  }
  solve();
}


Measured memory_bytes: 5364
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int whole = sc.nextInt();
        int houses = sc.nextInt();
        List<Integer> houseList = new ArrayList<>();
        for(int i = 1;i <= houses;i++){
            houseList.add(sc.nextInt());
        }

	    int result = execute(whole,houses,houseList);
        System.out.println(result);
    }

    public static int execute(int whole,int houseSize, List<Integer> houseList){
        int lastDistance = whole - houseList.get(houseList.size() - 1);
        List<Integer> distanceList = new ArrayList<>();
        for(int i = 0;i < houseSize;i++){
            int beforeHounse = houseList.get(i);
            int next = i + 1;
            if(next == houseSize){
                next = 0;
            }
            int afterHouse = houseList.get(next);
            int distance = afterHouse - beforeHounse;
            if(distance < 0){
                distance += whole;
            }
            distanceList.add(distance);
        }
        int result = 0;
        int maxDistance = 0;
        for(Integer distance : distanceList){
            result = result + distance;
            maxDistance = Math.max(maxDistance,distance);
        }
        result = result - maxDistance;
        return result;
    }
}


Measured memory_bytes: 88480
s=input()
p=input()
spattern=[]
spattern.append(s)
pat=len(s)
plen=len(p)
flg=0
for i in range(1,pat):
    temp = spattern[i-1][1:] + spattern[i-1][0]
    spattern.append(temp)
for i, line in enumerate(spattern):
    for j in range(pat-plen+1):
        if line[j:j+plen] == p:
            flg = 1
            break
    if flg == 1:
        break
if flg == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
import java.util.*;

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

    int n = sc.nextInt();

    int a = 0;
    for (int i = 1; i <= n; i++) {
      a += i;
    }
    
    System.out.println(a);
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
#define INF 1<<30

int dp[1<<26];

int main(){
    fill_n(dp, 1<<26, INF);

    string s;
    cin >> s;
    int N = s.size();
    int bt = 0;
    for(int i=0; i<N; i++){
        int x = s[i] - 'a';
        bt ^= 1<<x;
        if(__builtin_popcount(bt)<=1){
            dp[bt] = 1;
            continue;
        }
        for(int j=0; j<26; j++)
            dp[bt] = min(dp[bt], dp[bt ^ (1<<j)] + 1);
    }
    cout << dp[bt] << endl;
    return 0;
}

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

int main(){

    int N;
    cin >> N;

    if(100 <= N && N <= 111) cout << 111 << endl;
    else if(111 < N && N <= 222) cout << 222 << endl;
    else if(222 < N && N <= 333) cout << 333 << endl;
    else if(333 < N && N <= 444) cout << 444 << endl;
    else if(444 < N && N <= 555) cout << 555 << endl;
    else if(555 < N && N <= 666) cout << 666 << endl;
    else if(666 < N && N <= 777) cout << 777 << endl;
    else if(777 < N && N <= 888) cout << 888 << endl;
    else if(888 < N && N <= 999) cout << 999 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

#define X 2
#define Y 0
using namespace std;

int main(){
    int sx,tx,sy,ty;
    int dis_x,dis_y;
    cin >> sx >> sy >> tx >> ty;
    dis_x = tx - sx;
    dis_y = ty - sy;
    char code[5] = "UDRL";
    bool code_x,code_y;
    int i;
    code_x = 0;
    code_y = 0;
    for(i=0;i<dis_x;i++){
        cout << "R";
    }
    for(i=0;i<dis_y;i++){
        cout << "U";
    }
    for(i=0;i< dis_x;i++){
        cout << "L";
    }
    for(i=0;i< dis_y;i++){
        cout << "D";
    }
    
    cout << "D";
    for(i=0;i<dis_x+1;i++){
        cout << "R";
    }
    for(i=0;i<dis_y+1;i++){
        cout << "U";
    }
    cout << "L";
    
    cout << "U";
    for(i=0;i<dis_x+1;i++){
        cout << "L";
    }
    for(i=0;i<dis_y+1;i++){
        cout << "D";
    }
    cout << "R";
    
    cout << endl;
}


Measured memory_bytes: 256
import math 
x = int(input())
# x = 10**15
xi = math.floor(x/5.5)
# print(xi)
for i in range(xi,10000000000000000000000000000):
    # print(6*i - math.floor(i/2))
    if(x <= 6*i-math.floor(i/2)):
        xa = i
        break

print(xa)


Measured memory_bytes: 9048
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;

int dp[2002][2002];
short cnt[4002][2][2002], a[4002], col[4002], idx[2][2002];
int n;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < 2*n; i++){
        char c;
        cin >> c >> a[i];
        col[i] = c=='B' ? 0 : 1;
        idx[col[i]][a[i]] = i;
    }
    memset(cnt, 0, sizeof cnt);
    for(int i = 2*n - 1; i >= 0; i--){
        for(int j = 0; j < i; j++){
            cnt[j][col[i]][a[i]] = 1;
        }
    }
    for(int i = 0; i < 2*n; i++){
        for(int k = 0; k < 2; k++){
            for(int j = 1; j <= n; j++){
                cnt[i][k][j] += cnt[i][k][j-1];
            }
        }
    }
    memset(dp, 0x3f, sizeof dp);
    dp[0][0] = 0;
    for(int i = 0; i <= n; i++){ //black
        for(int j = 0; j <= n; j++){ //white
            //moving either B i+1 or W j+1 to index i+j
            int blackPrev = cnt[idx[0][i+1]][1][j] + cnt[idx[0][i+1]][0][i];
            dp[i+1][j] = min(dp[i+1][j], dp[i][j] + idx[0][i+1] - (i + j) + blackPrev);
            int whitePrev = cnt[idx[1][j+1]][1][j] + cnt[idx[1][j+1]][0][i];
            dp[i][j+1] = min(dp[i][j+1], dp[i][j] + idx[1][j+1] - (i + j) + whitePrev);
        }
    }
    cout << dp[n][n];
}

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

using namespace std;

pair<int, int> max1(map<int, int> m) {
  int i = -1, v = -1;
  for (auto kv: m) {
    if (v <= kv.second) {
      i = kv.first;
      v = kv.second;
    }
  }
  return pair<int, int>(i, v);
}

pair<int, int> max2(map<int, int> m) {
  int i1 = -1, v1 = -1, i2 = -1, v2 = -1;
  for (auto kv: m) {
    if (v1 <= kv.second) {
      i2 = i1;
      v2 = v1;
      i1 = kv.first;
      v1 = kv.second;
    } else if (v2 <= kv.second) {
      i2 = kv.first;
      v2 = kv.second;
    }
  }
  return pair<int, int>(i2, v2);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  map<int, int> e, o;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) e[v[i]]++;
    else o[v[i]]++;
  }
  n /= 2;
  auto em1 = max1(e), om1 = max1(o);
  if (em1.first != om1.first) {
    cout << (n - em1.second) + (n - om1.second) << endl;
    return 0;
  } else {
    auto em2 = max2(e), om2 = max2(o);
    if (em2.first == -1 && om2.first == -1) {
      cout << n << endl;
      return 0;
    } else {
      if (em2.second > om2.second) {
        cout << (n - em2.second) + (n - om1.second) << endl;
      } else {
        cout << (n - em1.second) + (n - om2.second) << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 7680
#include<stdio.h>

int main(){

	int a,b,d,r;
	double f;
	
	scanf("%d %d\n",&a,&b);
	
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;

	printf("%d %d %lf\n",d,r,f);
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int p,q,r; cin >> p >> q >> r;
    
    cout << min(p+q, r+min(p,q)) << endl;
}

Measured memory_bytes: 256