akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)      //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++)    //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int n; cin >> n;
    string s,t ; cin >> s >> t;
    string ans;
    rep(i,n) {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(sc.nextInt());
        }

        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n - k + 1; i++) {
            int dist1 = Math.abs(x.get(i)) + Math.abs(x.get(i + k - 1) - x.get(i));
            int dist2 = Math.abs(x.get(i + k - 1)) + Math.abs(x.get(i + k - 1) - x.get(i));
            min = Math.min(min, Math.min(dist1,dist2));
        }
        System.out.println(min);
    }
}


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

int main()
{
    int a,b,k;
    scanf("%d%d%d",&a,&b,&k);
    int n=0;
    for(int i=min(a,b);i>=1;i--)
    {
        if(a%i==0&&b%i==0)
        {
            //printf("%d\n",i);
            n++;
        }

        if(n==k)
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define nl '\n'
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 200005;

int n,a[maxn],pos[maxn],dp[maxn],res;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        pos[a[i]] = i;
    }
    for(int i=1; i<=n; i++){
        if(i > 1 && pos[i-1] < pos[i]) dp[i] = dp[i-1]+1;
        else dp[i] = 1;
        res = max(res,dp[i]);
    }
    cout << n-res << nl;
}

Measured memory_bytes: 6020
#include <stdio.h>
int main()
{
  int W,H,r,x,y;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

  if(0<=x-r && W>=x+r)
  {
    if(0<=y-r && H>=y+r) printf("Yes\n");
    else printf("No\n");
  }

  else printf("No\n");

  return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

string A(string S){
    string T=S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='?') T[i]='a';
        else T[i]=S[i];
    }
    return T;
}

string Z(string S){
    string T=S;
    for(int i=0;i<S.size();i++){
        if(S[i]=='?') T[i]='z';
        else T[i]=S[i];
    }
    return T;
}

int main(){
    
    int N;cin>>N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    string T;cin>>T;
    int cnts=0,cntb=0,cnte=1;
    for(int i=0;i<N;i++){
        if(A(S[i])<T&&Z(S[i])<T) cntb++;
        else if(A(S[i])>T&&Z(S[i])>T) cnts++;
        else cnte++;
    }
    
    for(int i=0;i<cnte;i++){
        if(i) cout<<" ";
        cout<<cntb+i+1;
    }
    cout<<endl;
}


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

#define pi 3.14159265358979323846264338327950L
int main()
{
    long double a, b, h, m;
    cin >> a >> b >> h >> m;

    long double angle = pi * 2 * (( long double )h / 12.0 + (( long double )m / 60.0 ) / 12.0 - ( long double )m / 60.0 );

    long double ans = ( a * a + b * b ) - 2 * a * b * cosl( angle );

    printf( "%20.20Lf\n", sqrt( ans ));
    return 0;
}

Measured memory_bytes: 4056
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int X, K, Q;
  int r[100010];
  cin >> X;
  cin >> K;
  for(int i = 0; i < K; i++)  cin >> r[i];
  cin >> Q;
  r[K] = 1e9 + 1;

  int x, y, z;
  int t, a;
  int tim = 0, dir = 1, rin = 0;
  x = 0; y = X; z = 0;
  for(int i = 0; i < Q; i++){
    cin >> t >> a;
    while(1){
      int tt = min(r[rin], t);
      if(dir == 1){
        z = max(z-(tt - tim), -X);
        x = max(x, -z);
        y = max(x, y);
      }
      else{
        z = min(z+(tt - tim), X);
        y = min(y, X-z);
        x = min(x, y);
      }

      if(tt == r[rin]){
        tim = r[rin++];
        dir = 1 - dir;
      }
      if(tt == t){
        tim = t;
        break;
      }
    }
    if(a <= x) cout << max(0, min(x + z, X)) << endl;
    else if(a >= y) cout << max(0, min(y + z, X)) << endl;
    else  cout << max(0, min(a + z, X)) << endl;

    //cout << x << " " << y << " " << z << endl;
    //cout << dir << endl;

  }

  return 0;
}


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

int main()
{
    int X, Y;

    cin >> X >> Y;

    int sum=0;

    switch(X)
    {
        case 1:
            sum = sum + 300000;
            break;
        case 2:
            sum = sum + 200000;
            break;
        case 3:
            sum = sum + 100000;
            break;
    }

    switch(Y)
    {
        case 1:
            sum = sum + 300000;
            break;
        case 2:
            sum = sum + 200000;
            break;
        case 3:
            sum = sum + 100000;
            break;
    }

    if(X == 1 && Y == 1)
    {
        sum = sum + 400000;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[100009][4];
int rec(int i,int j,int n,int a[][4])
{	
	int res;
	if(dp[i][j]>-1)
		return dp[i][j];
	if(i>n)
		return 0;
	if(j==1)
		dp[i][j]=max(a[i][j]+rec(i+1,j+1,n,a),a[i][j]+rec(i+1,j+2,n,a));
	 if(j==2)
		dp[i][j]=max(a[i][j]+rec(i+1,j-1,n,a),a[i][j]+rec(i+1,j+1,n,a));
	  if(j==3)
		dp[i][j]=max(a[i][j]+rec(i+1,j-2,n,a),a[i][j]+rec(i+1,j-1,n,a));
	return dp[i][j];

}

int main()
{
	
	int n,i,j;
	cin>>n;
	int a[n+1][4],res=0;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=3;j++)
		cin>>a[i][j];
	}
	for(j=1;j<=3;j++)
	{
		res=max(rec(1,j,n,a),res);
	}
	cout<<res<<endl;

}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int b[126];
	for (int a = 1; a < 126; a++) { b[a-1] = a * a; }
	int n, d,s=0;
	cin >> n >> d;
	vector<vector<int>>x(n, vector<int>(d, 0)); //l[n][d]
	for (int a = 0; a < n; a++) {
		for (int t = 0; t < d; t++) { cin >> x[a][t]; }
	}
	int l=0;
	for (int a = 0; a < n; a++) {
		for (int t = a+1; t < n; t++)
		{
			for (int q = 0; q < d; q++)
			{
				l+=(x[a][q] - x[t][q])* (x[a][q] - x[t][q]);
			}
			for (int q = 0; q < 126; q++)
			{
				if (l == b[q]) { s++; break; }
				else if (l < b[q]) { break; }
			}
			l = 0;
		}
	}
	cout << s;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.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;
}

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

    ll n_sub = 0;
    for (int i = 0; i < N - 1; i++) {
        ll u, v;
        cin >> u >> v;
        if (u > v) {
            swap(u, v);
        }
        n_sub += u * (N - v + 1);
    }

    ll n_vertices = 0;
    for (ll i = 1; i <= N; i++) {
        n_vertices += i * (N - i + 1);
    }

    // printf("n_vertices: %lld, n_sub: %lld, ans: %lld\n", n_vertices, n_sub, n_vertices - n_sub);
    cout << n_vertices - n_sub << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
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;}

int main(){
	ll n,k;
	cin >> n >> k;
	ll h[100010];
	REP(i,n) cin >> h[i];
	
	const ll INF = 1LL << 60;
	ll dp[100010];
	REP(i,100010) dp[i] = INF;
	
	dp[0] = 0;
	for(int i=1; i<n; ++i){
		for(int j=1; j<=k; ++j){
			if(i-j < 0) break;
			chmin(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
		}
	}
	
	cout << dp[n-1] << endl;
	
	return 0;
}

Measured memory_bytes: 5100
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

"""
k組ある，
ある組から見て，残りの(k-1)組と被りが1つずつあるから要素数はk-1

"""

def main():
    mod=10**9+7
    N=I()

    k=0
    for i in range(N+5):
        ii=i*(i-1)
        if ii==2*N:
            k=i
            break
    if k==0:
        print("No")
        exit()
    
    ans=[[]for _ in range(k)]
    now=1#配る数字
    import itertools
    
    for ite in itertools.combinations(range(k),2):
        i=ite[0]
        j=ite[1]
        ans[i].append(now)
        ans[j].append(now)
        now+=1
        
    print("Yes")
    print(k)
    for i in range(k):
        print(len(ans[i]),' '.join(map(str, ans[i])))
        
        
            
            
            
 
        

main()


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

int main()
{
	long long int i,n;
	vector <long long int> nums;
	cin >> n;
	for( i=1; i*i<=n; i++ ){
		if( n%i == 0 ){
			nums.push_back( (i-1) + ( (n/i)-1 ) );
		}
	}
	cout << nums.back() << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused_imports)]

// Input
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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque,BinaryHeap};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [i64; N*3],
    }
    let mut sum ;
    // 左側
    let mut bheap = BinaryHeap::<i64>::new();
    let mut lsum = vec![0;1];
    for i in 0..N{
        lsum[0] += A[i];
        bheap.push(-A[i]);
    }
    sum = lsum[0];
    for i in N..N*2{
        bheap.push(-A[i]);
        sum += A[i] + bheap.pop().unwrap();
        lsum.push(sum);
    }
    // 右側
    let mut bheap = BinaryHeap::<i64>::new();
    let mut rsum = vec![0;1];
    for i in 0..N{
        rsum[0] += A[N*3-1-i];
        bheap.push(A[N*3-1-i]);
    }
    sum = rsum[0];
    for i in N..N*2{
        bheap.push(A[N*3-1-i]);
        sum += A[N*3-1-i] - bheap.pop().unwrap();
        rsum.push(sum);
    }

    // 左 - 右
    let mut ans = -9999999999999999;
    for i in 0..N+1{
        ans = max(ans, lsum[i]-rsum[N-i]);
    }
    println!("{}",ans);
}

Measured memory_bytes: 14588
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 60
vector<int> g[N];
int n, m;

bool used[N];

int dfs(int u, int v, int w){
	if(u==v) return 0;
	used[u] = true;
	int res = 1;
	for(auto x: g[u]){
		if(used[x]) continue;
		if(w && x==v) continue;
		if(!dfs(x, v, 0)){
			res = 0;
			break;
		}
	}
	used[u] = false;
	return res;
}

int main(){
	cin>>n>>m;
	rep(i, m){
		int u, v;
		cin>>u>>v; u--; v--;
		g[u].pb(v);
		g[v].pb(u);
	}
	int res = 0;
	rep(i, n) for(auto j: g[i]) res += dfs(i, j, 1);
	cout<<res/2<<endl;
	return 0;
}


Measured memory_bytes: 256
// A.

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

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, b;
	cin >> n >> a >> b;
	int x = min(a, b);
	int y = max(0, a + b - n);
	cout << x << " " << y << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner input = new Scanner(System.in);
       
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        
        if(a+b==c || b+c==a || a+c==b)
           System.out.println("Yes");
        else
           System.out.println("No");
        
        
        
        
        
        
        
    }
}


Measured memory_bytes: 26956
from collections import Counter

N = int(input())
a = Counter(list(map(int, input().split())))
ak = list(a.keys())
av = list(a.values())
ans = 0

for i in range(len(ak)):
    if ak[i] > av[i]:
        ans += av[i]
    elif ak[i] < av[i]:
        ans += av[i] - ak[i]
    else:
        continue

print(ans)

Measured memory_bytes: 18676
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << "\n"; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "tmp.cpp"

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

  int n;
  cin >> n;
  vi p(n);
  REP(i, n) {
    int idx;
    cin >> idx;
    idx--;
    p[idx] = i;
  }

  int ans = 1, tmp = 1;
  REP(i, n - 1) {
    if (p[i] < p[i + 1])
      tmp++;
    else
      tmp = 1;
    chmax(ans, tmp);
  }
  cout << n - ans << endl;

  return 0;
}


Measured memory_bytes: 1024
def main():
  from sys import stdin
  from fractions import gcd
  n = int(stdin.readline())
  a = [int(z) for z in stdin.readline().split()]
  lcm = a[0]
  for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
  sm = 0
  for i in range(n):
    sm += lcm // a[i]
  print(sm % (10**9 + 7))

main()


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


ll num[sz];


int main()
{

    ll n,m,i,j,a,b;

    cin>>n>>m;

    while(m--)
    {
        cin>>a>>b;
        num[a]++;
        num[b]++;
    }

    for(i=1;i<=n;i++)cout<<num[i]<<endl;
    return 0;
}



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

int main()
{
    int N;
    char S[110],i;
    scanf("%d",&N);
    scanf("%s",S);
    if(strlen(S)%2==1)
        printf("No");
    else
    {
        for(i=0;i<strlen(S)/2;i++)
        {
            if(S[i]!=S[i+strlen(S)/2])
            {
                printf("No");
                return 0;
            }
        }
         printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ERedScarf {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        vector<int> a(N);
        REP(i, N) {
            cin >> a[i];
        }

        vector<int> res(N);
        int sum = 0;
        for (int i = 0; i < N; i +=2) {
            sum ^= (a[i] ^ a[i+1]);
        }
        REP(i, N) {
            cout << (sum ^ a[i]) << " ";
        }
        cout << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ERedScarf solver;
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

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

    long long int r = (n / (a+b)) * a;

    if((n % (a+b)) < a){
        r += n % (a+b);
    }else{
        r += a;
    }
    cout << r << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        List<String> list = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
        System.out.println(7 - list.indexOf(s));

        sc.close();
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#define MAXN 2048
#define MAXM 4194304
using namespace std;
inline int read()
{
	int x=0,t=1,c;
	while(!isdigit(c=getchar()))if(c=='-')t=-1;
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*t;
}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int n,A[MAXN];
bool edge[MAXN][MAXN];
int first[MAXN],targ[MAXN],nxt[MAXN],lead[MAXN],cnte=1;
void AddEdge(int u,int v)
{
	lead[v]++;targ[cnte]=v;nxt[cnte]=first[u];first[u]=cnte++;
}
int deep[MAXN];
void Search(int x=0,int depth=1)
{
	//printf("%d %d\n",x,depth);
	deep[x]=depth;
	for(int i=1;i<=n;i++)
		if(edge[x][i])
			if(!deep[i])
			{
				Search(i,depth+1);
				AddEdge(x,i);
			}
}
int main()
{
	n=read();
	A[0]=0;
	for(int i=1;i<=n;i++)A[i]=read();
	sort(A,A+1+n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				if(gcd(A[i],A[j])!=1)
					edge[i][j]=1;
	for(int i=1;i<=n;i++)
		edge[0][i]=1;
	Search();
	priority_queue<int> PQ;
	PQ.push(0);
	while(!PQ.empty())
	{
		int x=PQ.top();PQ.pop();
		if(x)printf("%d ",A[x]);
		for(int i=first[x];i;i=nxt[i])
		{
			lead[targ[i]]--;
			if(!lead[targ[i]])PQ.push(targ[i]);
		}
	}
}

Measured memory_bytes: 4608
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let abcd = input!(String);
    let numbers = abcd.chars().map(|x| x as i32 - '0' as i32).collect::<Vec<i32>>();

    for i in 0..2_i64.pow(3) {
        let mut answer = numbers[0];
        let mut operator: Vec<char> = Vec::with_capacity(3);
        for j in 0..3 {
            if i & (1 << j) > 0 {
                answer += numbers[j+1];
                operator.push('+');
            } else {
                answer -= numbers[j+1];
                operator.push('-');
            }
        }

        if answer == 7 {
            for k in 0..3 {
                if k != 2 {
                    print!("{}{}", numbers[k], operator[k]);
                } else {
                    println!("{}{}{}=7", numbers[k], operator[k], numbers[k+1]);
                }
            }
            return;
        }
    }
}

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

int main(){
    using namespace std;
    using tuplis = array<int, 3>;
    const int sq = 1024;
    
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for(int& i : c){
        cin >> i;
        i--;
    }
    vector<tuplis> query(q);
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--;
        query[i] = {l, r, i};
    }
    sort(query.begin(), query.end(), [&](const tuplis& a, const tuplis& b){ if(a[0] / sq == b[0] / sq) return a[1] < b[1]; return a[0] < b[0]; });
    vector<int> ans(q);
    vector<int> cnt(n);
    int types = 0, L = 0, R = 0;
    for(auto [l, r, i] : query){
        while(L < l){
            cnt[c[L]]--;
            types -= !cnt[c[L]];
            L++;
        }
        while(L > l){
            L--;
            types += !cnt[c[L]];
            cnt[c[L]]++;
        }
        while(R > r){
            R--;
            cnt[c[R]]--;
            types -= !cnt[c[R]];
        }
        while(R < r){
            types += !cnt[c[R]];
            cnt[c[R]]++;
            R++;
        }
        ans[i] = types;
    }
    for(int i : ans) cout << i << ' ';
}

Measured memory_bytes: 15452
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n;
  cin >> n;
  lli a;
  cin >> a;
  lli c = 0;
  fore (i,0,n - 1){
    lli b;
    cin >> b;
    if (a > b){
      c+=abs(a-b);
    }
    else{
      a = b;
    }
  }
  cout << c << ENDL;
  return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str[];
        int n,x,count;
        StringBuilder sb = new StringBuilder();
        while(true){
            str = br.readLine().split(" ");
            n = Integer.parseInt(str[0]);
            x = Integer.parseInt(str[1]);
            if(n==0 && x==0) break;
            count = 0;
            for(int i=1;i<=n-2;i++){
                for(int j=i+1;j<=n-1;j++){
                    int k = x - i - j;
                    if(j < k && k <= n) count++;
                }
            }
            sb.append(count).append("\n");
        }
        System.out.print(sb);
    }
}

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

int main()
{
    int N;
    std::map<int, int> A; // number, id

    std::cin >> N;
    for(int i=1; i<=N; i++){
        int Ai;
        std::cin >> Ai;
        A.insert(std::make_pair(Ai, i));
    }

    for(int i=1; i<=N; i++){
        std::cout << A.at(i);
        if(i!=N){ std::cout << " "; }
    }

    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 5504
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  string s,t;
  cin >> s >> t;
  cout << t + s << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	ulong ai, ao, at, aj, al, as, az;
	{
		ulong[] tmp = readln.chomp.split.map!(to!ulong).array;
		ai = tmp[0], ao = tmp[1], at = tmp[2], aj = tmp[3],
		al = tmp[4], as = tmp[5], az = tmp[6];
		}
	
	ulong ans;
	
	ans += ao;
	
	if(min(ai, aj, al) == 0){
		ans += 2 * (ai / 2) + 2 * (aj / 2) + 2 * (al / 2);
		}
	else{
		if(ai % 2 == aj % 2 && aj % 2 == al % 2){
			ans += ai + aj + al;
			}
		else{
			ans += ai + aj + al - 1;
			}
		}
	
	ans.writeln;
	}

/*
T, S, Z は捨てる
O はそのまま使うしかない
J, L, I は自分を2個セットで使うか、または3個で使う

使い方は2つ。
・3個でとれるところまでとり、残りを2個セットで使う
・上記より1つ少なくとり、残りを2個セットで使う

min(ai, aj, al) == 0 のとき
各自でがんばるしかない
ans = 2 * (ai / 2) + 2 * (aj / 2) + 2 * (al / 2)

その他のとき
高々1個残しにできる

if(ai % 2 == aj % 2 && aj % 2 == al % 2)
		ans = ai + aj + al
else
		ans = ai + aj + al - 1


*/

Measured memory_bytes: 256
#pragma GCC opimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
int n, a, b;
inline ll fpow(int x, int k) {
	ll ret = 1, base = x;
	while(k) {
		if(k & 1) ret = ret * base % mod;
		base = base * base % mod;
		k >>= 1;
	}
	return ret;
}
inline ll C(ll n,ll m){
    if(n < m) return 0;
    if(m > n - m) m = n - m;
    ll a = 1, b = 1;
    for(int i = 0; i < m; ++i) {
        a = (a * (n - i)) % mod;
        b = (b * (i + 1)) % mod;
    }
    return a * fpow(b, mod - 2) % mod;
}
inline ll Lucas(ll n, ll m){
    if(!m) return 1;
    return Lucas(n/mod, m/mod) * C(n%mod,m%mod)%mod;
}
const int maxn = 2e5 + 5;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> a >> b;
	ll ans = fpow(2, n) - 1;
	ans = (ans - Lucas(n, a) - Lucas(n, b)) % mod;
	cout << (ans + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 256
//苦手 解説AC
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll sum=0;
    //負の数が奇数かのflag
    bool flag = false;
    rep(i,n) {
        int input;
        cin >> input;
        if(input<0) flag = 1-flag;
        a[i] = abs(input);
        sum+=abs(input);
    }
    sort(a.begin(),a.end());
    if(!flag)
        cout << sum << endl;
    else
        cout << sum-2*a[0] << endl;
	return 0;
}

Measured memory_bytes: 3968
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int>::reverse_iterator rit; for(rit=s.rbegin();rit!=s.rend();rit++)
#include <vector>
#include <stack>
#include <cmath>
#include <utility>
#include <sstream>
#include <string>
#define mod 1000000007
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
const db eps=1e-6;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+5;
using namespace std;

int n,m,ans,x;
vector<int > v;
vector<int> ::iterator it;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		if(v.empty()){
			v.push_back(x);
		}else{
			it=upper_bound(v.begin(),v.end(),x,greater<int >());
			if(it==v.end()){
				v.push_back(x);
			}else{
				*it=x;
			}
		}
	}
	printf("%d\n",v.size());
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int n, hp,a[114514],b[114514],c,count = 0;
	cin >> n >> hp;
	REP(i, n) cin >> a[i] >> b[i];
	sort(a, a + n, greater<int>());
	c = a[0];
	sort(b, b + n, greater<int>());
	REP(i, n) {
		if (b[i] <= c or hp <= 0) break;
		else {
			count++;
			hp -= b[i];
		}
	}
	if (hp > 0) count += (hp + c - 1) / c;
	cout << count << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	
	int x,i;
	
	i=0;
	
	for(;;)
	{
		scanf("%d",&x);
		
		if(x==0)
		{break;}
		
		i++;
		
	printf("Case %d: %d\n",i,x);
	}
	return 0;
}


Measured memory_bytes: 2568
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	s;

	cin >> s;
	n = s.size();
	vector<ll> A(n+1, -1);
	a = 0;
	for(i=0;i<n;i++) {
		if (s[i]=='<') A[i] = a++;
		else a = 0;
	}
	a = 0;
	for(i=n-1;i>=0;i--) {
		if (s[i]=='>') A[i+1] = a++;
		else a = 0;
	}
	if (A[0]==-1) A[0] = A[1]+1;
	if (A[n]==-1) A[n] = A[n-1]+1;
	for(i=1;i<n;i++) {
		if (A[i]==-1) A[i] = max(A[i-1],A[i+1]) + 1;
	}
	for(i=0;i<=n;i++) {
		ans += A[i];
	}
 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4740
k,n = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)
abs_arr = []

# 各ルートの距離を算出
(n-1).times do |i|
  abs_arr << (arr[i+1] - arr[i]).abs
end
# 一周をまたぐ最後のルートを別途追加
abs_arr << k - arr[-1] + arr[0]

# 円上にある「1つを除いた」全てのルートを通らなければならない <=> 1つだけ取り除ける
# 最長のルートを取り除いた合計を算出

abs_arr.sort!
puts abs_arr[0..-2].inject(&:+)

Measured memory_bytes: 19200
n = int(input())
l=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
l.sort()
flg = [0 for _ in range(n+1)]
ans = [0 for _ in range(n)]
#print(l)
t=0
count=0
for i in range(n-1):
    a,b,c=l[i]
    if t!=a:
        t=a
        count=1
    if flg[a]==count:
        count+=1
    flg[b]=count
    ans[c]=count
    count+=1
    #print(flg,ans)
print(max(flg))
for i in range(1,n):
    print(ans[i])

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

using namespace std;

typedef vector< vector<int> > Graph;

int n, m;
bool g[10][10];

int dp[260][10];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a][b] = true;
		g[b][a] = true;
	}	

	dp[1][0] = 1;
	for (int i = 1; i < (1 << n) - 1; i++) {
		for (int j = 0; j < n; j++) {
			if (i & (1 << j)) continue;
			for (int k = 0; k < n; k++) {
				if (i & (1 << k)) {
					if (!g[j][k]) continue;
					dp[i | (1 << j)][j] += dp[i][k];
				}
			}
		}
	}

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

Measured memory_bytes: 256
n = gets.chomp.to_i
r, b = [], []
n.times do
    r << gets.chomp.split.map(&:to_i)
end
n.times do
    b << gets.chomp.split.map(&:to_i)
end
b.sort! {|a,b| a[0] <=> b[0]}
r.sort! {|a,b| a[1] <=> b[1]}
r.reverse!

ans = 0
0.upto(n-1) do |i|
    0.upto(r.size-1) do |j|
        if b[i][0] > r[j][0] && b[i][1] > r[j][1]
            ans += 1
            r.delete_at(j)
            break
        end
    end
end
puts ans

Measured memory_bytes: 1788
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int x, a, b; cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i <= (n); ++i)
using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.size();

  int ans = 0;
  rep(i, floor(N / 2)) if (S.at(i) != S.at(N - i - 1)) ans++;

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


Measured memory_bytes: 256
INF = 1e9
n = int(input())
s = list(input())
sum_1 = [0]*(n+1)
for i in range(n):
    if s[i]=="E":
        sum_1[i+1] = sum_1[i]+1
    else:
        sum_1[i+1] = sum_1[i]

ans = INF
for i in range(n):
    a = i-sum_1[i] + sum_1[n]-sum_1[i+1]
    ans = min(ans, a)
print(ans)

Measured memory_bytes: 17464
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define maxn 10100
int main()
{
    string s;
    int sum;
    while(cin>>s)
    {
        sum=0;
        for(int i=0;i<s.size();i++)
            if(s[i]=='1') sum++;

        cout<<sum<<endl;
    }
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

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

	vi a(n);
	rep(i, 0, n) cin >> a[i];

	vi b(m), c(m);
	rep(i, 0, m) cin >> b[i] >> c[i];

	map<int, int> ma;
	rep(i, 0, n) ma[a[i]]++;
	rep(i, 0, m) ma[c[i]] += b[i];

	int ans = 0, cnt = 0;
	for(auto i = ma.rbegin(); i != ma.rend(); i++){
		if(cnt + i->second <= n){
			cnt += i->second;	
			ans += i->first * i->second;
			if(cnt == n) break;
		}else{
			int t = n - cnt;
			cnt = n;
			ans += i->first * t;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
string dir = "RDLU";
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll w,h;
    vector<P> edges;
    cin >> w >> h;
    REP(i,w){
        ll p;
        cin >> p;
        edges.push_back({p,0});
    }
    REP(i,h){
        ll q;
        cin >> q;
        edges.push_back({q,1});
    }
    sort(ALL(edges));
    ll ans = 0;
    for(auto e : edges){
        ans += e.first*(e.second?w+1:h+1);
        if(e.second)h--;
        else w--; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6256
def get_section_arr(X):
    return [(X[i+1]-X[i]) for i in range(len(X)-1) ]
if __name__ == "__main__":
    N,M = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    section_arr = get_section_arr(X)
    section_arr.sort(reverse=True)
    print((X[-1]-X[0]) - (sum(section_arr[:N-1])))


Measured memory_bytes: 20544
package main

import "fmt"

func main(){
	n := 5
	a := make([]int,n)
	for i:=0 ; i<n ; i++ {
		fmt.Scan(&a[i])
	}
	for i:=0 ; i<n ; i++ {
		if a[i] == 0 {
			fmt.Println(i+1)
		}
	}
}


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

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

    int cou = 0;
    while(1){
        if(n == 0){
            break;
        }

        n /= k;
        cou++;
    }

    cout << cou << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const double PI=3.14159265358979323846;
ll dp;

int main(){
   ll n,m,d,ans=0,h[101010];
   bool f[101010]={};
   cin>>n>>m;
   rep(i,m){
      cin>>d;
      rep(j,d){
         ll a;
         cin>>a;
         f[a]=1;
      }

   }
   
   rep(i,n){
      if(f[i+1]==0)ans++;
   }
   cout<<ans<<endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const ll inf = 1e9;

const string YES = "Yes";
const string NO = "No";

void solve()
{
  ll N;
  scanf("%lld",&N);
  for (int i=0; i<=N; i+=4) {
    if ((N-i)%7==0) {
      cout << YES << endl;
      return;
    }
  }
  cout << NO << endl;
}

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


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

int main()
{
	long long *dp[60][60];
	for(int i=0; i<60; i++)
		for(int j=0; j<60; j++)
		{
			dp[i][j] = new long long[3000];
		}

	int N; std::cin >> N;
	int A; std::cin >> A;
	std::vector<int> x(N);
	for(auto &z: x) std::cin >> z;
	
	for(int i=0; i<N; i++)
		for(int j=0; j<=N; j++)
			for(int k=0; k<=N*A; k++)
			{
				dp[i][j][k] = 0;
			}
	dp[0][1][x[0]] = 1;
	for(int i=0; i<N; i++) dp[i][0][0] = 1;

	for(int i=1; i<N; i++)
		for(int j=1; j<=i+1; j++)
			for(int k=0; k<=N*A; k++)
			{
				if(k-x[i] >= 0) dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]];
				else dp[i][j][k] = dp[i-1][j][k];
			}

	long long ans = 0;
	for(int n=1; n<=N; n++)
	{
		ans += dp[N-1][n][n*A];
	}
	std::cout << ans << std::endl;
	for(int i=0; i<60; i++)
		for(int j=0; j<60; j++)
		{
			delete[] dp[i][j];
		}

	return 0;
}

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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000

typedef long long ll;
typedef pair<ll,ll> P;

char mp[55][55];
ll dist[3000];
vector<vector<int> > G(3000);
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};

int main()
{
	int w,h;cin >> h >> w;
	int cou = 0;
	
	REP(i,3000)dist[i] = INF;
	REP(i,h)REP(j,w)
	{
		cin >> mp[i][j];
		if(mp[i][j] == '#')cou++;
	}
	
	REP(i,h)REP(j,w)
	{
		if(mp[i][j] == '#')continue;
		REP(k,4)
		{
			int tmpx = j + dx[k];
			int tmpy = i + dy[k];
			if(tmpx < 0 || tmpx >= w || tmpy < 0 || tmpy >= h)continue;
			
			if(mp[i][j] == mp[tmpy][tmpx])
			{
				G[w*i + j].PB(w*tmpy + tmpx);
			}
		}
	}
	
	/*
	REP(i,w*h)
	{
		cout << G[i].size() << endl;
	}
	*/
	
	priority_queue<P,vector<P>,greater<P> > pq;
	
	dist[0] = 0;
	pq.push(MP(0,0));
	
	while(!pq.empty())
	{
		P p = pq.top();pq.pop();
		if(p.FI > dist[p.SE])continue;
		
		int node = p.SE;
		int kyo = p.FI;
		REP(i,G[node].size())
		{
			if(dist[G[node][i]] > dist[node] + 1)
			{
				dist[G[node][i]] = dist[node] + 1;
				pq.push(MP(dist[G[node][i]],G[node][i]));
			}
		}
	}
	
	//SHOW1d(dist,w*h);
	
	if(dist[w*h-1] == INF)
	{
		cout << -1 << endl;
		return 0;
	}
	else
	{
		//cout << w*h << ' ' << dist[w*h-1] << ' ' << cou << endl;
		cout << w*h - dist[w*h-1] - cou - 1 << endl;
	}
		
	
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		//var n=sc.I;
		var s=sc.Ia;

		Console.WriteLine("{0}",s[0]<s[1]?0:10);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}
	public int[] Ia3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2(int b){return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}
	public long[] La3(int a,int b){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(int a,int b,int c,int d){return Array.ConvertAll(((a!=0?b.ToString()+" ":"")+Console.ReadLine()+(c!=0?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>=k){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct base
{
    ll c[65];
    bool insert(ll x)
    {
        for(int i=62;i>=0;i--)
            if(x&(1ll<<i))
                if(!c[i]){c[i]=x;return 1;}
                else x^=c[i];
        return 0;
    }
}b;
string str;
ll a[205];
int main()
{
    int _;
    scanf("%d",&_);
    while(_--)
    {
        memset(b.c,0,sizeof(b.c));
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
        cin>>str;
        for(int i=n;i>=1;i--)
        {
            if(str[i-1]=='0')b.insert(a[i]);
            else if(b.insert(a[i])){puts("1");goto nxt;}
        }
        puts("0");
        nxt:;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  ll X; cin>>X;
  ll ans=1000*(X/500)+5*((X%500)/5);
  cout<<ans<<endl;
}

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

int main() {
  int X, Y;
  int count = 0;
  cin >> X >> Y;
  for (int i = 0; i <= X; i++)
  {
    for (int j = 0; j <= X; j++)
    {
      if (i * 4 + j * 2 == Y && i + j == X)
      {
        count++;
        cout << "Yes" << endl;
      }
    }
  }
  if (count == 0)
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3568
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.Stream;

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

        if (a <= 8 && b <= 8){
            System.out.println("Yay!");
        } else {
            System.out.println(":(");
        }
    }
}

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

int main() {
	int x,y,ans=0,i;
	cin >> x >> y;
	if(y%2==0 && x*2<=y && x*4>=y){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624