akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

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

    //A[0]~A[N-1]に格納する
    long* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%ld",&A[i]);
    }

    long* sum;
    NEW(sum,N);
    sum[0]=A[0];
    for(int i=1;i<N;i++){
        sum[i]=sum[i-1]+A[i];
    }

    long ans=9999999999999999;
    for(int i=0;i<N-1;i++){
        ans=MIN(ans,labs((sum[N-1]-sum[i])-sum[i]));
    }
    printf("%ld\n",ans);

    return 0;
}

Measured memory_bytes: 3328
#https://atcoder.jp/contests/abc073/tasks/abc073_c
N = int(input())
N_Dict = {}
for i in range(N):
    moji = str(input())
    if moji in N_Dict:
        N_Dict.pop(moji)
    else:
        N_Dict[moji] = 1
print(len(N_Dict))

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

int main(){
  int a,b,i;
  char c[10000];
  cin>>a>>b;
  for(i=0;i<a*b;i++) cin>>c[i];
  for(i=0;i<b+2;i++) cout<<"#";
  cout<<endl;
  
  for(i=0;i<a;i++){
    cout<<"#";
    for(int j=i*b;j<i*b+b;j++){
      cout<<c[j];
    }
    cout<<"#"<<endl;
  }
  for(i=0;i<b+2;i++) cout<<"#";
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
AB = [LIST() for _ in range(N)]
AB.sort(key=lambda x:-x[0])

ans = 0
h = []

for day in range(1, M+1):
	while AB and AB[-1][0] == day:
		heappush(h, -AB.pop()[1])

	if h:
		ans -= heappop(h)

print(ans)


Measured memory_bytes: 34288
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int b,ans,c;
long long n,m;
int main()
{
	b=0;
	c=0;
	scanf("%lld",&n);
	m=n+1;
	while (n>9)
	{
		b++;
		n=n/10;
	}
    while (m>9)
	{
		c++;
		m=m/10;
	}
	if (b!=0)
	{
		ans=9*b+n-1;
	 	if (m!=n) ans+=1;
	}
	else ans=n;
	printf("%d",ans);
//	system("pause");
	return 0;
}


Measured memory_bytes: 256
class UnionFind:

    def __init__(self, n):
        self.par = []
        self.size = []
        for i in range(n):
            self.par.append(i)
            self.size.append(1)

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x]) #recurcive
            return self.par[x]

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

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.par[y] = x
        self.size[x] += self.size[y]

    def root_size(self, x):
        return self.size[self.root(x)]

n,m,k = map(int, input().split())
uf = UnionFind(n)
non = [set() for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    uf.unite(a-1,b-1) # a&b is friends
    non[a-1].add(b-1)
    non[b-1].add(a-1)

for i in range(k):
    c,d = map(int, input().split())
    if uf.same(c-1,d-1):
        non[c-1].add(d-1)
        non[d-1].add(c-1)

answer = []
for i in range(n):
    ans = uf.root_size(i)-len(non[i])-1
    answer.append(ans)

print(*answer)




Measured memory_bytes: 68496
n,m = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]

box = [1] * (n+1)
red = [0] * (n+1)
red[1] = 1
for x,y in xy:
    box[x] -= 1
    box[y] += 1
    if red[x] == 1: red[y] = 1
    if box[x] == 0: red[x] = 0
print(red.count(1))

Measured memory_bytes: 28592
#include <iostream>
#include <math.h>
#include <string.h>

#include <algorithm>

using namespace std;
int Dp[1000][1000];
int a[1000][1000];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
	{
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
//	for(int i=0;i<2;i++)
//	{
//		for(int j=0;j<n;j++)
//		{
//			printf("%d ",a[i][j]);
//		}
//		printf("\n");
//	}
	for(int i = 1;i <= 2;i++)
	{
		for(int j = 1;j <= n;j++)
		{
			Dp[i][j] = max(Dp[i-1][j] + a[i][j],Dp[i][j-1] + a[i][j]);
		}
	}
	printf("%d\n",Dp[2][n]);
	return 0;
}

Measured memory_bytes: 2304
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio 
    int n , m ;
    cin >> n >> m ; 
    vector<int> v(n) ; 
    double sum = 0 ; 
    for(int i = 0; i < n; i++){
        cin >> v[i] ; 
        sum += v[i] ;
    }
    int item = 0 ; 
    double cur = 1.0 / (4 * m);
    for(int i = 0; i < n; i++){
        if ( v[i] / sum < cur ) continue ;
        item++ ; 
    }
    if ( item >= m ){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	string s;
	cin >> s;
	s.resize(3);
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3652
from collections import Counter
n = int(input())
target_ls = list(map(int, input().split()))
ans = sum(target_ls)

c = Counter(target_ls)
num_replace = int(input())
ans_ls = [0] * num_replace
for i in range(num_replace):
    before_value, after_value = map(int,input().split())
    before_times = c[before_value]
    c[after_value] += before_times
    c[before_value] = 0
    ans -= before_times * before_value
    ans += before_times * after_value 
    ans_ls[i] = ans
for i in range(num_replace):
    print(ans_ls[i])



Measured memory_bytes: 27064
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>
 
using namespace std;
typedef long long int ll;
 
#define C cout<<
#define E <<endl
#define CE cout<<endl
 
ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010];
bool r,ra,rb,rc[200010];
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc,vd,ve,vaa,vbb;
set<int> st;
 


template<typename MAIN> ostream & operator<<(ostream & osys,const vector<MAIN> target){ for(MAIN it:target)osys<<it<<" "; return osys; }

int main(){
    cin>>a>>b>>c;
    C max((ll)0,(b+c)-a) E;
}

//g++ atcoder.cpp ; ./a.exe


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = Arrays.asList(br.readLine().split(" ")).stream().mapToInt(Integer::parseInt).toArray();
        Arrays.sort(arr);
        int result = 0;
        for (int i = 0; i < arr.length; i += 2) {
            result += arr[i];
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 14672
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string O, E;
    cin >> O >> E;
    if(O.size() != E.size()) {
        E.push_back('\n');
    }
    for(int i=0; i<O.size(); i++) {
        cout << O[i] << E[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
const ll inf = 1e9+9;
 
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
mt19937_64 gen (random_device{}());
ll rint(ll a, ll b) { // generate rand int in [a, b]
    return a + gen() % (b - a + 1);
}

const int N = 2e5+9;
const int B = 30;
bool oc[B];
int a[N];
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    int x = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        x ^= a[i];
        oc[__builtin_ctz(a[i])] = 1;
    }
    int ans = 0;
    for(int bit = B-1; bit >= 0; bit--) {
        if((x >> bit) & 1) {
            if(oc[bit] == 0) {
                ans = -1;
                break;
            }
            ans++;
            x ^= ((1 << bit)-1);
        }
    }
    cout << ans << "\n";





    return 0;
    
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
ll a[200001];
ll s[200001];
int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }
    rep(i,n){
        s[i] += a[i];
        s[i] += s[i-1];
    }
    ll mi = (1LL<<60);
    rep(i,n-1){
        mi = min(mi,abs(2*s[i]-s[n-1]));
    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 3328
#include "iostream"
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  bool check = false;
  while (2 * n <= m) {
    if (m % n == 0) {
      cout << m / n << endl;
      check = true;
      break;
    }
    n++;
  }
  if (check == false) {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
import sys 
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

N,M=map(int,input().split())
G= [[0]*(N+1) for _ in range(N+1)]
abc = [list(map(int,input().split())) for _ in range(M)]

for a, b, c in abc:
  G[a][b] = c
  G[b][a] = c

cost = floyd_warshall(csr_matrix(G))
cnt = 0
for a, b, c in abc:
  if cost[a][b] < c:
    cnt += 1
print(cnt)

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

#define MAX_N 200000

using namespace std;

int rez;

int n;
int a[MAX_N + 1];

struct elem
{
    int c, nr;
};

elem v[MAX_N + 1];

void readFile()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
}

bool pos(int nr)
{
    int k = 0;
    v[++ k] = {1, a[1]};
    for(int i = 2; i <= n; i ++)
    {
        if(a[i] > a[i - 1])
            v[++ k] = {1, a[i] - a[i - 1]};

        else
        {
            int del = 0;
            int loc = k;
            while(loc >= 1 && del < a[i - 1] - a[i])
            {
                del += v[loc].nr;
                loc --;
            }

            k = loc;

            if(del != a[i - 1] - a[i])
                v[++ k].nr = del - (a[i - 1] - a[i]);


            loc = k;
            del = 0;
            while(loc >= 1 && v[loc].c == nr)
            {
                del += v[loc].nr;
                loc --;
            }

            if(loc <= 0)
                return 0;

            if(v[loc].nr > 1)
            {
                v[loc].nr --;
                v[loc + 1] = {v[loc].c + 1, 1};
                k = loc + 1;
            }

            else
            {
                v[loc].c ++;
                v[loc].nr = 1;
                k = loc;
            }

            if(del > 0)
                v[++ k] = {1, del};
        }
    }

    return 1;
}

int cautBin()
{
    int i = 0;
    int pas = 1 << 17;
    while(pas != 0)
    {
        if(i + pas <= n && pos(i + pas) == 0)
            i += pas;

        pas >>= 1;
    }

    return i + 1;
}

void solve()
{
    rez = cautBin();
}

void printFile()
{
    cout << rez << "\n";
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=1000;
  cin >> n ;
  vi a(n+1),b(n,-1);
  REP(i,n) cin>>a[i];
  a[n]=a[n-1]-1;
  ll nowmax=9999;
  for(ll i=0;i<n;i++){
    if (a[i]>a[i+1]){
      b[i]=a[i];
      if (nowmax<a[i])
      {
        ans=(ans/nowmax)*a[i]+ans%nowmax;
      }
      nowmax=9999;
    }else{
      nowmax=min(nowmax,a[i]);
    }
  }


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

Measured memory_bytes: 3640
N = int(input())
dic = {}
for i in range(N):
    s = input()
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
M = int(input())
dic2 = {}
for i in range(M):
    s = input()
    if s in dic2:
        dic2[s] += 1
    else:
        dic2[s] = 1
ans = 0
for k,v in dic.items():
    tmp = v
    for k2,v2 in dic2.items():
        if k == k2:
            tmp -= v2
    ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  if(n==0) {
    cout << 0 << endl;
    return 0;
  }

  string s="";
  while(abs(n)>0){
    s+=to_string(abs(n)%2);

    if(n%2==-1) n=n/(-2)+1;
    else n/=-2;
  }

  reverse(all(s));

  cout << s << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

int padding(int n) {
  if (n % 10 == 0)
    return 0;
  return 10 - (n % 10);
}

int main(int argc, const char *argv[])
{
  int a[5], sum;
  int max = 0, maxi = 0;
  for (int i = 0; i < 5; i++)
    scanf("%d", &a[i]);
  for (int i = 0; i < 5; i++)
    if (max < padding(a[i])) {
      max = padding(a[i]);
      maxi = i;
    }
  for (int i = 0; i < 5; i++) {
    if (maxi == i)
      continue;
    eprintf("sum = %d, a[%d] = %d\n", sum, i, a[i]);
    sum += (a[i] + padding(a[i]));
  }
  sum += a[maxi];
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
from collections import deque
S=deque(input())
Q=int(input())
count = 0
for i in range(Q):
    q = list(input().split())
    #print(q)
    if q[0] == "1":
        count += 1
    else:
        if count%2 == 0:
            if q[1] == "1":
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if q[1] == "1":
                S.append(q[2])
            else:
                S.appendleft(q[2])
if count%2 != 0:
    S = reversed(S)
print("".join(S))


Measured memory_bytes: 97664
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
	long double n, m, d;
	cin >> n >> m >> d;
	long double x = (n - d);
	long double y = (d < 1 ? 1.0 : 2.0) * x / n;
	long double ans = (m - 1) * y / n;
	printf("%.7f\n", (double)ans);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);cout.tie(0);
	int l,r;
	int d;
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<endl; 
 	return 0;
}










Measured memory_bytes: 3580
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    var(int, N, K);
    vector<int> cnt(N);

    rep(i, 0, K) {
        var(int, d);
        rep(j, 0, d) {
            var(int, a);
            --a;
            cnt[a] += 1;
        }
    }

    print(count(all(cnt), 0));

    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
int n,ans;
string ss[1111];
int t[333][333];
int t2[333][333];
int m[633][633];
bool ok(int a,int b){
	//cerr<<"A";
	int cnt=0;
	rep(i,n){
		rep(j,n){
			if(t[(j+n-b)%n][(n+i-a)%n]!=t[(i+n-b)%n][(n+j-a)%n]){

			m[a][b]=0;
			
			rep(i,n){
				m[a+i][b+i]=0;
				if(a+i>=n||b+i>=n)break;
			}
			rep(i,n){
				m[a-i][b-i]=0;
				if(a-i<=0||b-i<=0)break;
			}
					
				return 0;

				}
			//if(cnt>=n*n/2)break;
			//cnt++;
		}
	}
	
	m[a][b]=1;
	
	rep(i,n){
		m[a+i][b+i]=1;
		if(a+i>=n||b+i>=n)break;
	}
	rep(i,n){
		m[a-i][b-i]=1;
		if(a-i<=0||b-i<=0)break;
	}
	return 1;
}


int main(){	
cin.tie(0);
ios::sync_with_stdio(false);
	cin>>n;
	string s;
	rep(i,n)rep(j,n)m[i][j]=-1;
	rep(i,n){
		cin>>s;
		rep(j,n){
			t[i][j]=(int)(s[j]-'a');
		}
	}

	rep(i,n){
		for(int j=0;j<n;j++){
			if(m[i][j]==0){continue;}
			else if(m[i][j]==1){ans++;continue;}
			if(ok(i,j))ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
#include<list>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//int型0~9を文字0~9に変換
char int_to_char(int c) {
	if (c == 0) return '0';
	if (c == 1) return '1';
	if (c == 2) return '2';
	if (c == 3) return '3';
	if (c == 4) return '4';
	if (c == 5) return '5';
	if (c == 6) return '6';
	if (c == 7) return '7';
	if (c == 8) return '8';
	if (c == 9) return '9';
	else return'x';
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}
//xとyのビットごとの排他的論理和
template<class T> T XOR(T x, T y)
{
	T n = 0;
	while (max(x, y) > pow(2, n)) n++;
	T ans=0;
	for (int i = 0; i <= n; i++)
	{
		T x1 = (x % (T)pow(2, i + 1)) / (T)pow(2, i);
		T y1 = (y % (T)pow(2, i + 1)) / (T)pow(2, i);
		if (x1 != y1) ans += (T)pow(2, i);
	}
	return ans;
}

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, t[50];
	string s[50], X;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> s[i] >> t[i];
	}
	cin >> X;

	int ans = 0;
	bool a = false;

	for (int i = 0; i < N; i++)
	{
		if (a) ans += t[i];

		if (s[i] == X) a = true;
	}

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

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

using namespace std;

int main()
{
  int n,m;
  
  vector<int> a;
  
  cin>>n>>m;
  
  int x;
  int sum=0;
  
  for(int i=0;i<m;i++)
  {
    cin>>x;
    
    a.push_back(x);
    
    sum+=a[i];
  }
  
  if((n-sum)>=0)
  {
    cout<<n-sum<<endl;
  }
  else
    cout<<-1<<endl;
  
  return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> d(k);
	for(int i = 0; i < k; i++){
		cin >> d[i];
	}

	for(int x = n; x < 100000; x++){
		int tmp = x;
		set<int> s;
		while(tmp!=0){
			s.insert(tmp%10);
			tmp /= 10;
		}
		bool flag = true;
		
		for(int i = 0; i < k; i++){
			if(s.count(d[i])) flag = false;
		}
		if(flag){
			cout << x << endl;
			break;
		}
	}
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  a=a-c;
  int ans=0;
  while(a>=b+c){
    a=a-b;
    a=a-c;
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef uint32_t u32;
typedef uint64_t u64;

std::vector<int> split(std::string str) {
  std::vector<int> res;
  int i = 0;
  while( i < (int)str.size() ) {
    if( str[i] == 'n' ) {
      res.push_back(0);
      i += 5;
    }
    else {
      res.push_back(1);
      i += 4;
    }
  }
  std::reverse(res.begin(), res.end());
  return res;
}

long pow(int x, int n) {
  int res = 1;
  for(int i = 0; i < n; ++i) {
    res *= x;
  }
  return res;
}

long gcd(long a, long b) {
  if( a < b ) std::swap(a, b);
  while( b != 0 ) {
    a %= b;
    std::swap(a, b);
  }
  return a;
}

class Rational {
public:
  Rational(long ain, long bin) : a_(ain), b_(bin) {}
  long a() const;
  long b() const;
  Rational operator + (const Rational& right);
  Rational operator - (const Rational& right);
private:
  long a_, b_;
};

long Rational::a() const {
  return a_;
}

long Rational::b() const {
  return b_;
}

Rational Rational::operator + (const Rational& right) {  
  long na = a_ * right.b() + b_ * right.a();
  long nb = b_ * right.b();
  long g = gcd(na, nb);
  na /= g; nb /= g;
  return Rational(na, nb);
}

Rational Rational::operator - (const Rational& right) {
  long na = a_ * right.b() - b_ * right.a();
  long nb = b_ * right.b();
  long g = gcd(na, nb);
  na /= g; nb /= g;
  return Rational(na, nb);
}

int main() {

  for(;;) {
    std::string str;
    std::cin >> str;
    if( str == "#" ) break;
    auto res = split(str);
    Rational a((res[0] == 0 ? 0 : 90), 1);
    for(int i = 1; i < (int)res.size(); ++i) {
      if( res[i] == 0 ) {
        a = a - Rational(90, pow(2, i));
      }
      else {
        a = a + Rational(90, pow(2, i));
      }
    }
    std::cout << a.a();
    if( a.b() != 1 ) std::cout << '/' << a.b();
    std::cout << std::endl;
  }
   
  return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
	int c;
	int cards[14], pairs[5];
	while( scanf("%d", &c )!=-1 ){
		memset( cards, 0, sizeof(cards) );
		memset( pairs, 0, sizeof(pairs) );
		cards[c]++;
		for( int i=0; i<4; i++ ){
			scanf(",%d",&c);
			cards[c]++;
		}
		for( int i=1; i<=13; i++ ){
			pairs[cards[i]]++;
		}
		if( pairs[4] ){
			cout << "four card" << endl;
		}else if( pairs[3] && pairs[2] ){
			cout << "full house" << endl;
		}else if( pairs[1] == 5 ){
			int i=1;
			for( ; i<=10; i++ ){
				if( cards[i] && cards[i+1] && cards[i+2] && cards[i+3] && cards[((i+3)%13)+1] ){
					cout << "straight" << endl;
					break;
				}
			}
			if( i>10 )
				cout << "null" << endl;
		}else if( pairs[3] ){
			cout << "three card" << endl;
		}else if( pairs[2] == 2 ){
			cout << "two pair" << endl;
		}else if( pairs[2] ){
			cout << "one pair" << endl;
		}else{
			cout << "null" << endl;
		}
	}
	return 0;
}

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

int main(){
    int n, k, q, tmp;
    cin >> n >> k >> q;
    int req_answer = q - k + 1;
    vector<int> hoge(n, 0);
    // for (int i = 0; i < hoge.size(); i++){
    //     cout << hoge[i] << endl;
    // }
    
    for (int i = 0; i < q; i++){
        cin >> tmp;
        hoge[tmp - 1] = hoge[tmp - 1] + 1;
    }

    // cout << "@" << endl;
    // for (int i = 0; i < hoge.size(); i++){
    //     cout << hoge[i] << endl;
    // }
    // cout << "re " << req_answer << endl;

    for (int i = 0; i < hoge.size(); i++){
        if(hoge[i] >= req_answer){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl
#warning do not forget to change size of N and M  and -01 to -02
typedef long long ll;
const ll MOD = 1e9 + 7;
const int N = 1e7 + 9, M = 1e5 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10;
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS; }
int main()
{
   
  ll a,b,c,d;
  scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  ll ans = max(a*b,c*d);
  printf("%lld",ans);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;
const long double PI = 3.141592653589793;
int main() {
  ll n;

  cin >> n;

  long double ans = 2 * n * PI;
  cout << setprecision(100)<<ans << endl;
  return 0;
}


Measured memory_bytes: 3764
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let (n, k) = read_touple::<usize>();
  let mut v = vec![];
  for _ in 0..k {
    let d: usize = read();
    let t: Vec<usize> = read_vec();
    v.push(t);
  }

  let mut count = vec![0; n];
  for t in &v {
    for &i in t {
      count[i-1] += 1;
    }
  }

  let mut ans = 0;
  for &i in &count {
    if i == 0 {
       ans += 1;
    }
  }

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


Measured memory_bytes: 2148
// abc174_f
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

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

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;



template <typename T>
struct RangeTree {
    int n;
    vector<vector<T>> dat;
    vector<T> val;

    explicit RangeTree(vector<T>& val_): val(val_) {
        n = 1;
        while (n < val.size()) n <<= 1;
        dat.assign(n << 1, vector<T>());

        build(0, 0, val.size());
    }

    void build(int k, int l, int r) {
        if (r-l == 1) {
            dat[k].emplace_back(val[l]);
        } else {
            int lch = 2*k+1, rch = 2*k+2;
            build(lch, l, (l+r)/2);
            build(rch, (l+r)/2, r);
            dat[k].resize(r-l);
            merge(dat[lch].begin(), dat[lch].end(), dat[rch].begin(), dat[rch].end(), dat[k].begin());
        }
    }

    int query(int i, int j, T x) {
        return query(i, j, x, 0, 0, val.size());
    }

    int query(int i, int j, T x, int k, int l, int r) {
        if (j <= l || r <= i) return 0;
        // x以下の要素の数
//        if (i <= l && r <= j) return upper_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        // x未満の要素の数
        if (i <= l && r <= j) return lower_bound(dat[k].begin(), dat[k].end(), x) - dat[k].begin();
        int lch = query(i, j, x, 2*k+1, l, (l+r)/2);
        int rch = query(i, j, x, 2*k+2, (l+r)/2, r);
        return lch+rch;
    }
};


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    cin >> N >> Q;
    vector<int> C(N);
    REP(i, N) {cin >> C[i]; C[i]--;}

    vector<int> last(N, N);
    vector<int> nxt(N);
    REP_REV(i, N){
        nxt[i] = last[C[i]];
        last[C[i]] = i;
    }

    // [l,r)で、r未満の要素の数を数える
    RangeTree<int> rt(nxt);

    REP(i, Q){
        int l, r;
        cin >> l >> r; l--;
        int ans = r - l - rt.query(l, r, r);
//        print(ans);
        printf("%d\n", ans);
    }


    return 0;
}


Measured memory_bytes: 98832
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int,int>
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define vi vector<int>
#define ld long double
#define ll long long
#define sh short int
#define pb push_back
#define mid (l+r)/2
#define S second
#define F first
using namespace std;
const int inf = 1e9*2;
const int mod = 1e9+7;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        s[i] = 'x';
    }
    cout<<s<<endl;
}


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

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

using namespace std;

int count_path(const vector<vector<int>>& path, uint32_t state, int n, int k, int p) {
	if (k == n) return 1;

	int ans = 0;
	for (auto next : path[p]) {
		if (state & (1 << next)) continue;

		ans += count_path(path, state + (1 << next), n, k + 1, next);
	}

	return ans;
}

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

	int ans = 0;

	try {
		vector<vector<int>> path(n + 1);
		for (int i = 0; i < m; i++) {
			int a, b; cin >> a >> b;
			path[a].push_back(b);
			path[b].push_back(a);
		}

		uint32_t init_state = 1 << 1;
		ans = count_path(path, init_state, n, 1, 1);
	}
	catch (exception&e) {
		cout << e.what() << endl;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	int x=0,y=0;
	for (int i=0;i<n;i++) cin >> s[i];
	for (int i=0;i<n;i++) {
		if (s[i]=='I') x+=1;
		else x-=1;
		if (x>y) y=x;
	}
	cout << y;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int i,n,u,p,x,k[5][14]={0},s[53];
    char t;
    scanf("%d",&n);
    for(i=1;i<=n;i+=1){
        scanf(" %c%d",&t,&s[i]);
        x=s[i];
        if(t=='S'){
            k[1][x]=1;
        }
        else if(t=='H'){
            k[2][x]=1;
        }
        else if(t=='C'){
            k[3][x]=1;
        }
        else if(t=='D'){
            k[4][x]=1;
        }
    }
    for(u=1;u<=4;u+=1){
        for(p=1;p<=13;p+=1){
            if(u==1){
                if(k[1][p]!=1){
                    printf("S %d\n",p);
                }
            }
            else if(u==2){
                if(k[2][p]!=1){
                    printf("H %d\n",p);
                }
            }
            else if(u==3){
                if(k[3][p]!=1){
                    printf("C %d\n",p);
                }
            }
            else if(u==4){
                if(k[4][p]!=1){
                    printf("D %d\n",p);
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string go("");
    string back("");

    rep (i, ty - sy)
    {
        go += 'U';
    }
    rep (i, tx - sx)
    {
        go += 'R';
    }
    rep (i, tx + ty - sx - sy)
    {
        back += (go[i] == 'U' ? 'D' : 'L');
    }

    cout << go + back + "LU" + go + "RDRD" + back + "LU" << "\n";
    return 0;
}



Measured memory_bytes: 256
t_before = 0
x_before = 0
y_before = 0
result = 'Yes'

N = int(input())
for i in range(N) :
  t, x, y = map(int, input().split())
  t_diff = abs(t - t_before)
  x_diff = abs(x - x_before)
  y_diff = abs(y - y_before)
  if (x_diff <= t_diff) and (y_diff <= t_diff) and ((t_diff - (x_diff + y_diff)) % 2 == 0) :
    t_before = t
    x_before = x
    y_before = y
  else :
    result = 'No'
    break
print(result)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
bool snt(int a){
    if (a<2) return false;
    if (a==2) return true;
    for (int i=2; i<= trunc(sqrt(a)); i++)
        if (a%i == 0) return false;
    return true;
}

int main(){
    int x;
    cin>>x;
    int i=x;
    while (snt(i) == false)
        i=i+1;
    cout<<i;
    return 0;
}

Measured memory_bytes: 256
# ?tc????   s
# coder     t

s = gets.chomp.freeze
t = gets.chomp.freeze

ans = nil

(s.length - t.length + 1).times do |i|
  can_include_t = true
  t.length.times do |j|
    next if s[i+j] == "?" || s[i+j] == t[j]
    can_include_t = false
    break
  end
  if can_include_t
    ans_temp = s.tr("?", "a")
    ans_temp[i, t.length] = t
    if !ans || ans > ans_temp
      ans = ans_temp
    end
  end
end

if ans
  puts ans
else
  puts "UNRESTORABLE"
end


Measured memory_bytes: 14368
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = n; i > 1; i--)
#define rep3(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    int n, k;
    int d = 0;
    int a, b, x;
    cin >> n >> k;
    rep(i, n) {
        cin >> x;
        a = 2 * x;
        b = 2 * (k - x);
        if (a <= b) {
            d += a;
        } else {
            d += b;
        }
    }
    cout << d << endl;
}


Measured memory_bytes: 256
def soinsuu(a):
    yy,j=[],2
    y=yy.append
    while(a>1):
        for i in range(j,int(a**0.5)+1):
            if a%i==0:
                y(i)
                a,j=a//i,i
                break
        else:
            y(a)
            break
    yy.sort()
    return yy

def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):return pow(n,mod-2,mod)
def nCr(n,r,mod=10**9+7):return inv_n(n_func(n-r,mod)*n_func(r,mod)%mod,mod)*n_func(n,mod)%mod


def main():
    mod=10**9+7
    from collections import Counter
    n,m=map(int,input().split())
    s=Counter(soinsuu(m))
    ans=1
    for i in s.values():
        ans=(ans*nCr(n+i-1,i))%mod
    print(ans)
    
if __name__ == '__main__':
	main()

Measured memory_bytes: 3316
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int[] x = new int[N];
		for (int i = 0; i < N; i++)
			x[i] = sc.nextInt();
		int[] y = new int[M];
		for (int i = 0; i < M; i++)
			y[i] = sc.nextInt();

		for (int Z = X + 1; Z <= Y; Z++) {
			boolean flag = true;
			for (int i = 0; i < N; i++) {
				if (x[i] >= Z)
					flag = false;
			}
			for (int j = 0; j < M; j++) {
				if (y[j] < Z)
					flag = false;
			}
			if (flag) {
				System.out.println("No War");
				return;
			}
		}
		System.out.println("War");

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 22612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <typeinfo>
#include <math.h>
#include <iomanip>
#include <limits>
#include <functional>

using namespace std;
using ll = long long;
const ll res = 1000000007;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

int main() {
	int n;
	cin >> n;
	
	if (n % 10 == 3)
		cout << "bon" << endl;
	else if (n % 10 == 0 or n % 10 == 1 or n % 10 == 6 or n % 10 == 8)
		cout << "pon" << endl;
	else
		cout << "hon" << endl;
}

Measured memory_bytes: 3624
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
    int n, i, j, e, sum = 0;
    int M[MAX][MAX];
    int d[MAX];         // 最小コスト
    int p[MAX];
    int x[MAX];         // visited-boolean
    int min = INFTY, k, u, v, c;

    scanf("%d", &n);
    for ( i = 0; i< n; i++ ){
        for ( j = 0; j < n; j++ ){
            M[i][j] = INFTY;
        }
    }

    for ( i = 0; i < n; i++ ){
        scanf("%d %d", &u, &k);
        for ( j = 0; j < k; j++ ){
            scanf("%d %d", &v, &c);
            M[u][v] = c;
        }
    }

    // 初期化
    for (i = 0; i < n; i++) {
        d[i] = INFTY;
        p[i] = -1;
        x[i] = 0;
    }
    d[0] = 0;   // aからaの距離は0

    while(1) {
        u = -1;
        min = INFTY;

        // d[u]が最小になるuを求める
        for(i = 0; i < n; i++){
            if(d[i] < min && x[i] == 0) {       // 最小コスト && 未訪
                u = i;      // 最小コストx[i]保存
                min = d[i];     //最小コスト保存
            }
        }

        if(u == -1) break;      //all訪問
        x[u] = 1;       // 訪問済

        for(i = 0; i < n; i++){
            if(M[u][i]+d[u] < d[i] && x[i] == 0){
                d[i] = M[u][i] + d[u];
                p[i] = u;   // 最短経路v保持
            }
        }
    }

    for(i = 0; i < n; i++){
        printf("%d %d\n", i, (d[i] == INFTY?-1:d[i]));
    }
    return 0;
}

Measured memory_bytes: 808