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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	vi b(n), ans;
	rep(i, n) cin >> b[i];
	rep(i, n){
		for(int j=b.size()-1; j>=0; j--){
			if (j+1 == b[j]){
				ans.pb(j+1);
				b.erase(b.begin()+j);
				break;
			}
		}
	}
	if (ans.size() == n){
		for(auto itr=ans.rbegin(); itr!=ans.rend(); itr++)
			cout << (*itr) << "\n";
	}else{
		cout << "-1\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long a,x;
    cin>>x>>a;
    if (x<a)
    {
    	cout<<0<<endl;
	}
	else
	{
		cout<<10<<endl;
	}
}

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

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

    int sum = 0;
    int mn = 100000;
    int val = 0;
    rep(i, 0, n) {
	sum += i + l;
	if(mn > abs(i + l)) {
	    mn = abs(i + l);
	    val = i + l;
	}
    }

    co << sum - val << en;
  
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s,t;

int main(){
  ll a,b,k; cin >> a >> b >> k;
  if(a <= k){
    cout << 0 << " " << max((ll)0,b-(k-a)) << "\n";
  }else{
    cout << a-k << " " << b << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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


    int n, m;
    cin >> n >> m;

    int ans;
    ans = (1900 * m + 100 * (n-m));
    REP(i, m){
        ans *= 2;
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, d;
    cin >> n >> d;
    int p[n][d];
    forn(i, 0, n) {
        forn(j, 0, d) {
            cin >> p[i][j];
        }
    }
    
    int ans = 0;
    forn(i, 0, n) {
        forn(j, i+1, n) {
            int sum = 0;
            forn(k, 0, d) {
                sum += (p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
            }
            int sq = sqrt(sum);
            if (sq*sq == sum) ans++;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

class Data
{
private:
    string name;
    int value;

public:
    Data() : name(""), value(0) {}
    Data(const string& s, int n) : name(s), value(n) {}
public:
    string GetName() const { return name; }
    int GetValue() const { return value; }
    void SetName(const string& _name) { name = _name; }
    void SetValue(int _value) { value = _value; }
};

class MyQueue
{
private:
    Data* list;
    int size;
    int topIdx;
    int lastIdx;

public:
    MyQueue();

    ~MyQueue();

public:
    void enqueue(Data& _data);
    Data dequeue();

    bool isEnd();
};

MyQueue::MyQueue()
    : topIdx(0)
    , lastIdx(0)
{
    list = new Data[200000];
}

MyQueue::~MyQueue()
{
    delete[] list;
}

void MyQueue::enqueue(Data& _data)
{
    list[lastIdx++] = _data;
}

Data MyQueue::dequeue()
{
    return list[topIdx++];
}

bool MyQueue::isEnd()
{
    if (topIdx == lastIdx)
        return true;

    return false;
}

int main()
{
    int size, q, val;
    string key;
    int quon = 0;
    
    cin >> size >> q;
    MyQueue myqueue;
    for (int i = 0; i < size; i++) {
        cin >> key >> val;
        Data t(key, val);
        myqueue.enqueue(t);
    }

    while (!myqueue.isEnd()) {
        Data t = myqueue.dequeue();
        int tval = t.GetValue();
        if (tval <= q) {
            quon += tval;
            cout << t.GetName() << " " << quon << "\n";
        }
        else {
            quon += q;
            tval -= q;
            t.SetValue(tval);
            myqueue.enqueue(t);
        }
    }

    return 0;
}


Measured memory_bytes: 8256
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {  // O( log(a) )
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }  // O( log(a) )
bool isPrime(ll n) {                                  // O( sqrt(n) )
  bool flag = true;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) flag = false;
  }
  return flag;
}
vector<pair<ll, ll>> primeFac(ll n) {  // O( sqrt(n) )
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  int zembu = 0;
  for (auto &ai : a) {
    zembu ^= ai;
  }

  for (int i = 0; i < n; i++) {
    cout << (a.at(i) ^ zembu);
    if (i != n - 1)
      cout << " ";
    else
      cout << endl;
  }
}

Measured memory_bytes: 4324
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] letters = scanner.nextLine().toCharArray();
		int len = letters.length;
		if (len%2==0) {
			len = len - 2;
		}else{
			len = len - 1;
		}
		
		for (int i = 0; i < letters.length/2-1; i++) {
			char[] c1 = Arrays.copyOfRange(letters, 0, len/2);
			char[] c2 = Arrays.copyOfRange(letters, len/2, len);
			
			if (String.valueOf(c1).equals(String.valueOf(c2))) {
				break;
			}
			len = len - 2;
		}
		System.out.println(len);
		
		scanner.close();
	}
	
}


Measured memory_bytes: 23380
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, l;
    cin >> n >> l;
    vector<int> v(n);
    ll s = 0;
    for (int i = 0; i < n; ++i) {
        v[i] = l+i;
        s += v[i];
    }
    ll ans = 0, k = INF<ll>;
    for (int i = 0; i < n; ++i) {
        if(abs(v[i]) < k){
            k = abs(v[i]);
            ans = s-v[i];
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define ll long long

int prime[3000000],nPrime;

int mark[10000002],c[10000002];

int main()
{
    long long int  n=10000000;

     int limit = sqrt(n*1.0)+2;

    mark[1]=1;

    for(int i=4; i<=n; i+=2)
        mark[i]=1;


    prime[nPrime++]=2;

    for(int i=3; i<=n; i+=2)
    {
        if(!mark[i])
        {
            prime[nPrime++]=i;

            if(i<=limit)
            {
                for(int j=i*i ; j<=n; j+=i*2)
                {
                    mark[j]=1;
                }
            }
        }
    }

    int j=0;


    long long int sum = 0;

    for(int i=2; i<=n; i++)
    {
        if(mark[i]==0)
            {
                c[j]=i;
                if(i<2000000)
                    sum += i;
                j++;
            }
    }

    //cout << sum << endl;

    ll n1;

    cin >> n1;

    for(ll i=n1; ; i++)
    {
        if(mark[i]==0)
        {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int  getChar(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i <  strlen(str); i++) {
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0 ) return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str)  == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++) {
		H[i][0] = '\0';
	}
	scanf("%d", &n);
	for (i = 0; i  < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		} else  {
			if (find(str)) {
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
	return 0;
}



Measured memory_bytes: 17072
#![allow(unused_imports)]

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

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

fn main() {
    input!{
        n: usize,
        s: usize,
        v: [usize; n]
    }
    let d = 998244353;
    let mut dp = vec![vec![0; 3001]; n + 1];
    dp[0][0] = 1;
    for i in 0..n {
        for j in 0..3001 {
            dp[i + 1][j] = 2 * dp[i][j] % d;
            if j >= v[i] {
                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j - v[i]]) % d;
            }
        }
    }
    println!("{}", dp[n][s]);
}


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


void solve(std::string S, std::string T){
    long long ans = 0;
    rep(i,S.size()){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) cin >> S[i];
    vector<vector<int>> cntV(H, vector<int>(W)), cntH(H, vector<int>(W));
    for (int y = 0; y < H; y++) {
        int cnt = 0;
        int l = 0;
        for (int x = 0; x <= W; x++) {
            if (x == W || S[y][x] == '#') {
                for (int k = l; k < x; k++) {
                    cntH[y][k] = cnt;
                }
                cnt = 0;
                l = x + 1;
            } else {
                cnt++;
            }
        }
    }
    for (int x = 0; x < W; x++) {
        int cnt = 0;
        int t = 0;
        for (int y = 0; y <= H; y++) {
            if (y == H || S[y][x] == '#') {
                for (int k = t; k < y; k++) {
                    cntV[k][x] = cnt;
                }
                cnt = 0;
                t = y + 1;
            } else {
                cnt++;
            }
        }
    }
    int ans = INT_MIN;
    for (int x = 0; x < W; x++) {
        for (int y = 0; y < H; y++) {
            ans = max(ans, cntV[y][x] + cntH[y][x] - 1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 42256
#include<stdio.h>

int main(){
int n,k,x,y;
scanf("%d",&n);
scanf("%d",&k);
scanf("%d",&x);
scanf("%d",&y);
if(n<k){
    printf("%d", x*n);
}
else{
    printf("%d", (x*k)+(y*(n-k)));
}

}


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

typedef long long int ll;
using namespace std;

int main() {
	int N, M;
	while(1) {
		cin >> N >> M;
		if (N == 0 && M == 0) break;
		vector<ll> P(N);
		vector<ll> Ps;
		Ps.push_back(0);
		for(int i = 0; i < N; i++) {
			cin >> P[i];
			Ps.push_back(P[i]);
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				Ps.push_back(P[i] + P[j]);
			}
		}
		sort(Ps.begin(), Ps.end());

		ll ans = 0;
		for (int i = 0; i < Ps.size(); i++) {
			if (Ps[i] > M) break;
			int k = std::upper_bound(Ps.begin(), Ps.end(), M - Ps[i]) - 1 - Ps.begin();
			ans = max(ans, Ps[i] + Ps[k]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 18888
fun main(args: Array<String>) {
    val a = readLine()!!.toCharArray().map { it.toString() }.map { it.toInt() }
    for (i in 0 until (1 shl 3)) {
        val op = Array(3) { "" }
        var ans = a[0]
        for (j in 0 until 3) {
            if (i.shr(j).and(1) == 1) {
                op[j] = "+"
                ans += a[j + 1]
            } else {
                op[j] = "-"
                ans -= a[j + 1]
            }
        }
        if (ans == 7) {
            println("${a[0]}${op[0]}${a[1]}${op[1]}${a[2]}${op[2]}${a[3]}=7")
            break
        }
    }
}

Measured memory_bytes: 33784
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef  long long int lo;
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define inf (lo)1e9;
#define FOR for(lo i = 0 ; i < n ; i++)
#define FORV for(lo i = 0 ; i < (lo)v.size() ; i++)
#define ii pair<lo,lo>
#define iii pair<lo, pair<lo,lo> >
lo a,b,c,d,e,n,m,k,t,h,x,y,a1[100005],a2[100005];
char c1,c2,c3,c4;
string s1,s2,s3,s4;
double d1,d2,d3;
vector <char> v, v2;
map <lo,lo> mp1;
map <string,lo> mp2;
set <lo> stt;
queue <lo> q;
priority_queue <lo> pq;
lo vis [10000];
int main() {
    // freopen("gir.gir", "r", stdin);
    // freopen("cik.cik", "w", stdout);
    cin >> n;
    cin >> s1 >> s2;
    lo mx = 0;
    for(lo i = 0 ; i < n ; i++){
        x = 0;
        if(s1[i] == s2[0]){
            k = i;
            t = 0;
            while(k < n){
                if(s1[k] != s2[t]){
                    x = 0;
                    break;
                }
                x++;
                k++;
                t++;
            }
        }
        mx = max(mx, x);
    }
    cout << 2*n - mx << endl;
    return 0;
}
// c b a
// c d e

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

int main () {

    string S;
    cin >> S;

    string ans = "No";
    for (int i = 0; i < S.size() - 1; i++) {
        if (S[i] == 'A' && S[i+1] == 'C') ans = "Yes";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*/
//vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  int64_t  n;
  cin >>n;
  int64_t sum=0;
  for(int i=1;i<=n;i++){
    if(i%3==0 || i%5==0){
    }
    else {
     sum += i; 
    }
  }
  cout << sum <<endl;
  
} 


Measured memory_bytes: 3624
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {
  ll L, R;
  cin >> L >> R;

  ll l = L % 2019;
  ll r = l + (R - L);
  if (R - L >= 2019) {
    r = l + 2019;
  }

  ll ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i + 1; j <= r; j++) {
      ans = min(ans, i * j % 2019);
    }
  }
  cout << ans << endl;
}


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

typedef long long ll;

int MOD=1000000007;


int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> ans(N+1,true); 
    for(ll i=0;i<M;i++){ 
        int a; 
        cin>>a; 
        ans[a]=false; 
    }

    vector<long long int>dp(N+1); 
        dp[0]=1; 
        for(ll i=0; i<N; i++){ 
               for(ll j=i+1; j<=min(N,i+2); j++){ 
                    if(ans[j]){ 
                        dp[j]+=dp[i]; 
                        dp[j]%=MOD; 
                    } 
                } 
            }
            cout<<dp[N]<<endl; 
}


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

#define ONLINE_JUDGE
#define ll long long
#define PI 3.14159265359
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb(a) push_back(a)

//////////// Solution /////////////////////////////////

const int MAX = 1e5+1;

void solve() {
	int n;
	cin >> n;
	int a[MAX];
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = 1e9;
	int last = -1;
	while (true) {
		int mn = 1e9+1;
		int forb = -1;
		for (int i = 0; i < n; ++i) {
			if (a[i] != 0) {
				if (mn > a[i]) {
					mn = a[i];
					forb = i;
				}
			}
		}
		ans = min(ans,mn);
		for (int i = 0; i < n; ++i) {
			if (i == forb) continue;
			a[i] %= mn;
		}
		if (last == forb) {
			break;
		}
		last = forb;
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	int height[100010];
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&height[i]);
	}
	bool good [100010];
	memset(good,true , sizeof good);
	for(int i = 0; i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(height[a]>=height[b])
		{
			good[b] = false;
		}
		if(!(height[a]>height[b])) good[a] = false;
		// cout<<a<<" "<<good[a]<<" "<<b<<" "<<good[b]<<endl;

	}
	int ans=0;
	for(int i=1;i<=n;i++) if(good[i]) ans++;
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 4172
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int k,a,b;
    cin>>k>>a>>b;
    bool flag = false;
    rep(i,a,b+1){
        if(i%k == 0)flag = true;
    }
    if(flag)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    
    return 0;
}


Measured memory_bytes: 3636
#ifdef DEBUG
#include "utils.cpp"
#endif
#include <bits/stdc++.h>


using namespace std;
using ll = int64_t;
#define int int64_t

 
/* ==== declarations ====== */
// functions
void solve();
void getInput();
 
// global variables
int N;
vector<vector<int>> C;
vector<vector<bool>> O;
vector<pair<int, int>> operations;

/* ======================== */
void getInput() {
    cin>>N;
    operations = vector<pair<int, int>>(N*N);
    for(int i=0; i<N*N; ++i) {
        int num;
        cin>>num;
        // operations[num-1] = {i/N, i%N};
        num--;
        operations[i] = {num/N, num%N};
    }

    O = vector<vector<bool>>(N, vector<bool>(N, true));
    C = vector<vector<int>>(N, vector<int>(N, 0));


    for(int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            int a = min(i, N-1-i);
            int b = min(j, N-1-j);
            C[i][j] = min(a, b);
        }
    }
}
 
void updateNeighbors(pair<int, int> pos) {
    vector<int> ret;
    queue<pair<int, int>> que;
    que.push(pos);
    // int cost = C[pos.first][pos.second];
    // print("update: ", pos, "cost: ", cost);
    // 
    // vector<vector<bool>> visit(N, vector<bool>(N, false));
    while(!que.empty()) {
        auto op = que.front();
        que.pop();
        // if(visit[op.first][op.second]) continue;
        

        bool isVac = !O[op.first][op.second];
        int cost = C[op.first][op.second];


        vector<int> dx = {1, -1, 0, 0};
        vector<int> dy = {0, 0, 1, -1};
        
        for (int i=0; i<4; ++i) {
            int x = op.first + dx[i];
            int y = op.second + dy[i];
            if (x<0 or y<0 or x>=N or y>=N) continue;

            // if(op.first == 1 and op.second == 0) {
            //     print("try: ", x, y);
            //     print(C[x][y], cost, isVac);
            // }

            if (isVac) {
                if (C[x][y] > cost) {
                    C[x][y] = cost;
                    que.push({x, y});
                }

            } else {
                if (C[x][y] > cost + 1) {
                    C[x][y] = cost + 1;
                    que.push({x, y});
                }
            }

            
        }
        
    }
    
}
 
void solve() {
    int ans = 0;
    for(auto op: operations) {
        ans += C[op.first][op.second];
        O[op.first][op.second] = false;


        // print("====================================");
        updateNeighbors(op);
        
        // print(op);
        // print(C);
        // print(O);

    }
    cout<<ans<<endl;
}
 
 
 
signed main(){
    getInput();
    solve();
    return 0;
}

Measured memory_bytes: 9360
/******
author :- Mahmoud Tarek.
*******/

#include<bits/stdc++.h>

using namespace std ;

#define rg register
#define dbg(v) cerr << #v << " " << v ;
typedef long long ll ;

int main() {

    int a, b, c ;
    cin >> a >> b >> c ;
    set<int> k ;
    k.insert(a) ;
    k.insert(b) ;
    k.insert(c) ;

    if(k.size() == 2){
        cout << "Yes\n" ;
    } else cout << "No\n" ;

}

/*
 Empty set of troubles.
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;



int main(){
    ll N;cin>>N;
    map<ll,ll> m;
    rep(i,0,N){
        int a;
        cin>>a;
        m[a]++;
    }
    int cn=0;
    for(auto i:m){
        if(i.second%2==0)cn++;
    }
    if(cn%2==1)cout<<m.size()-1<<endl;
    else cout<<m.size()<<endl;
}







Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll N, A;
    cin >> N >> A;
    if (N%500 <= A) cout << "Yes\n";
    else cout << "No\n";
}


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

long long int vis[200005],dp[200005];
vector<long long int> v[200005];

long long int dfs(long long int src)
{
    vis[src] = 1;
    dp[src] = 0;
    // cout<<"src = "<<src<<endl;
    for(long long int i=0;i<v[src].size();i++)
    {
        if(vis[v[src][i]]!=1)
        {
            dp[src] = max(dp[src],1+dfs(v[src][i]));
        }
        else
        {
            dp[src] = max(dp[src],1+dp[v[src][i]]);
        }
        
    }
    return dp[src];
}
int main()
{
    long long int n,m,i,a,b,mx=0;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
    }
    for(i=1;i<=n;i++)
    {
        vis[i] = 0;
    }
    for(i=1;i<=n;i++)
    {
        if(vis[i] == 0)
        {
            dfs(i);
        }
    }
    for(i=1;i<=n;i++)
    mx = max(mx,dp[i]);
    cout<<mx<<endl;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

ll N,A,B;
VI h(1e5+10);

bool enough(ll t){
  ll cnt = 0;
  rep(i,N){
    cnt += max( ((h[i] - B*t) + (A-B-1)) / (A-B),0LL);
  }
  //cout << "t:" << t << "cnt: " << cnt << endl;
  return (cnt<=t)?true:false;
}

int main(){

  cin >> N >> A >> B;

  rep(i,N){
    cin >> h[i];
  }

  ll high = 1e9, low  = 0, mid;

  rep(i,log2(1e10)){
    mid = ( high + low )/2;
    if(enough(mid)){high = mid; /*cout << "Yes" << endl;*/}
    else low = mid;;
  }
  cout << high << endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
typedef long long ll;
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> v;
    v = divisor(M);
    for(int i=v.size()-1;i>=0;i--){
        if(M-N*v[i]>=0&&(M-N*v[i])%v[i]==0){
            cout << v[i] << endl;
            break;
        }
    }
    

}

Measured memory_bytes: 256
N, K = map(int, input().split())

ans = 0

for n in range(1, N+1):
    if n >= K:
        ans += 1.0
    else:
        tmp  = 1.0
        while n < K:
            tmp /= 2
            n   *= 2
        ans += tmp

ans /= N

print(ans)


Measured memory_bytes: 2940
unittest
{
	assert( [ "1817181712114" ].parse.expand.solve == 3 );
	assert( [ "14282668646" ].parse.expand.solve == 2 );
	assert( [ "2119" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.map!( ( a ) => ( a - '0' ).to!( long ) ).array;
	return tuple( s );
}

const M = 2019L;

auto solve( long[] s )
{
	long[ long ] cs;
	cs[ 0 ]++;
	{
		auto r = 0L;
		foreach_reverse( i, d; s )
		{
			r = ( r + solve2( d, s.length.signed - i ) ) % M;
			cs[ r ]++;
		}
	}
	
	auto ans = 0L;
	foreach( r, c; cs )
	{
		ans += c * ( c - 1 ) / 2;
	}
	return ans;
}

long solve2( long d, long c )
{
	static rs = [ 1L ];
	if( rs.length <= c )
	{
		auto cc = rs.length.signed;
		rs.length = c + 1;
		foreach( i; cc .. rs.length.signed )
		{
			rs[ i ] = rs[ i - 1 ] * 10 % M;
		}
	}
	return ( d * rs[ c ] ) % M;
}


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

using namespace std;

const int MAX = 1001;
const int INF = (1<<20);
typedef pair<int,int> P;
typedef pair<int,P> PP;

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
char grid[MAX][MAX];
int cost[MAX][MAX];
int H,W,N;
vector<PP> V;
P f,t;

void init(){
  for(int i = 1; i <= H; i++)
    for(int j = 1; j <= W; j++)
      cost[i][j] = INF;

}

void input(){
  for(int i = 1; i <= H; i++)
    for(int j = 1; j <= W; j++){
      cin >> grid[i][j];
      PP pp;

      if(grid[i][j] == 'S' || '0' <= grid[i][j] && grid[i][j] <= '9'){
	if(grid[i][j] == 'S') pp.first = 0;
	else pp.first = grid[i][j] - '0';
	
	pp.second = P(i,j);
	V.push_back(pp);
      }
    }
}


bool isIn(P p){
  return 0 < p.first && p.first<= H && 0 < p.second && p.second <= W;
}
void solve(P p){

  int n = cost[p.first][p.second];

  for(int i = 0; i < 4; i++){
    P next = p;
    next.first += dy[i];
    next.second += dx[i];
    if(grid[next.first][next.second] != 'X' && cost[next.first][next.second] > n+1 && isIn(next)){
	cost[next.first][next.second] = n+1;
	if(next != t) solve(next);
    }
  }
}

P find(int n){
  for(int i = 0; i < V.size(); i++)
    if(V[i].first == n) return V[i].second;

}

int main(){

  cin >> H >> W >> N;

  input();
  sort(V.begin(),V.end());
  
  int ans = 0;
 
  for(int i = 1; i <= N; i++){
    init();
    f = find(i-1), t = find(i);
    cost[f.first][f.second] = 0;
    solve(f);
    ans += cost[t.first][t.second]; 
  }

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

Measured memory_bytes: 12788
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  for (int i=0; i<N; i++) cin >> L[i];
  sort(L.begin(), L.end());
  ll res = 0;
  for (int i=N-1; i>=0; i--) {
    // 各L[i]が最大の辺長となる三角形が作れるか
    for (int j=0; j<i; j++) {
      for (int k=j+1; k<i; k++) {
        if (L[j]+L[k]>L[i]) {
          if (L[i]!=L[j]&&L[j]!=L[k]&&L[k]!=L[i]) res++;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
}

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

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

	if( a == b )
	{
		cout << a * 2 << endl;
	}
	else
	{
		cout << max( a, b ) * 2 - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int n = sc.nextInt();
        String s = sc.next();

        if ( n%2 == 0) {
            String fi = s.substring( 0, n/2 );
            String se = s.substring( n/2 , n);
            if (fi.equals(se)){
                System.out.println("Yes");
            }
            else{
                System.out.println("No");
            }
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35688
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
        String[] s2 = sc.nextLine().split(" ");
        String[] s3 = sc.nextLine().split(" ");
        int x = getInt(s1[2]);
        int y = getInt(s1[3]);
        List<String> list1 = Arrays.asList(s2);
        List<String> list2 = Arrays.asList(s3);
        Collections.sort(list1, Comparator.comparingInt(one -> Integer.parseInt(String.valueOf(one))));
        Collections.sort(list2, Comparator.comparingInt(one -> Integer.parseInt(String.valueOf(one))));
        int xMax = getInt(list1.get(list1.size() -1));
        int yMin = getInt(list2.get(0));
        boolean territoryFlag = xMax >= yMin ? true : false;
        boolean borderOver = xMax >= y || yMin <= x ? true : false;
        String warFlag = territoryFlag || borderOver ? "War" : "No War";
        println(warFlag);
    }
    static long getLong(String val) {return Long.parseLong(val);}
    static int getInt(String val) {
        return Integer.parseInt(val);
    }

    static void println(String val){System.out.println(val);};
    static void println(int val){System.out.println(val);};
    static void println(long val){System.out.println(val);};
    static void println(Object val){System.out.println(val);};
}

Measured memory_bytes: 28628
#include<stdio.h>
#include<stdlib.h>

int m[3][3];
int copy[3][3];

void input(void){
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d",&m[i][j]);
        }
    }
}
void output(void){
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            printf("%3d",m[i][j]);
            puts("");
        }
    }
}
void cp(int a[3][3],int b[3][3]){
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            a[i][j] = b[i][j];
        }
    }
}
int calc(void){
    int i,sum = 0;
    for(i=0;i<9;i++){
        int a = m[i/3][i%3];
        if(a){
            a--;
            sum += abs(i/3 - a/3)+abs(i%3 - a%3);
        }
    }
    return sum;
}
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

void swap(int *a, int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}
int in(int a,int b){
    return 0<=a&&a<3&&0<=b&&b<3;
}
int df(int a,int b,int p,int d,const int lim){
    int i , h=calc();
    if(h == 0)return d;
    if(d+h > lim)return -1;
    
    for(i=0;i<4;i++){
        int x= a+dx[i],y=b+dy[i];
        int res;
        if(~p && i == (p+2)%4)continue;
        if(!in(x,y))continue;
        swap(&m[b][a],&m[y][x]);
        res = df(x,y,i,d+1,lim);
        if(~res)return res;
        swap(&m[b][a],&m[y][x]);
    }
    return -1;
}

void empty(int *a, int *b){
    int i,j;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(!m[i][j]){
                *a = j;
                *b = i;
                return;
            }
        }
    }
}
int s(void){
    int a,b,lim,x;
    empty(&a,&b);
    for(lim = 0;lim < 50;lim++){
        cp(copy,m);
        if((x = df(a,b,-1,0,lim)) != -1)return x;
        cp(m,copy);
    }
    return -1;
}
int main(){
    input();
    printf("%d\n",s());
    
    return 0;
}



Measured memory_bytes: 2108
//AUTHOR : TIRTH JARSANIA
//COLLEGE : DAIICT

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

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define bp __builtin_popcountll
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define pii pair<ll,ll>
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<pii,vector<pii>,greater<pii> > 
#define maxQueue priority_queue<pii> 
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

int main()
{
    FAST;
    ll n;
    cin >> n;
    cout << ( (n*(n+1))/2 - n );
}

Measured memory_bytes: 256
A = [list(map(int, input().split())) for k in range(3)]
n = int(input())
B = [int(input()) for b in range(n)]
#print(A, B)

for k in range(n):
    for i in range(3):
        for j in range(3):
            if B[k] == A[i][j]:
                A[i][j] = 0

J_0 = A[0][0] + A[1][0] + A[2][0]
J_1 = A[0][1] + A[1][1] + A[2][1]
J_2 = A[0][2] + A[1][2] + A[2][2]
nana1 = A[0][0] + A[1][1] + A[2][2]
nana2 = A[0][2] + A[1][1] + A[2][0]
if sum(A[0]) == 0 or sum(A[1]) == 0 or sum(A[2]) == 0:
    print("Yes")
elif J_0 == 0 or J_1 == 0 or J_2 == 0:
    print("Yes")
elif nana1 == 0 or nana2 == 0:
    print("Yes")
else:
    print("No")

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

int main(){
  int N,M,X;
  cin>>N>>M>>X;
  int j=0;
  for(int i=0;i<M;i++){
    int k;
    cin>>k;
    if(k>X)
      break;
    j++;
  }
  cout<<min(j,M-j)<<endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    optimize_cin();

    int A, B, C;
    cin >> A >> B >> C;

    cout << (A*B*C == 5*7*5 ? "YES" : "NO") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i=0; i<(int)(n); ++i)
int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

const int N_MAX = 1e5+1;
const int M_MAX = 1e5+1;

bool judge(int a, int n) {

}

int main() {
  int N, M; cin >> N >> M;
  vector<P> m;

  ll a, b;
  REP(i, M){
    cin >> b >> a;
    m.emplace_back(make_pair(a, b));
  } 
  sort(m.begin(), m.end());
  ll now = 0;
  int ans=0;
  REP(i, M){
    if(m[i].second > now){
      now = m[i].first-1;
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
LL d[101];
LL dfs(LL x,LL y);

LL check(LL x, LL y, LL a, LL e){
	if((y&a)!=0)return 0;
	if(d[x]<e)return 0;
	LL ans=0;
	y+=a;
	d[x]-=e;
	ans=dfs(x+1,y);
	d[x]+=e;
	y-=a;
	return ans;
}

LL dfs(LL x, LL y){
	LL ans=0;
	//cout<<x<<"aa"<<y<<endl;
	if(y==7)return 1;
	if(x>100)return 0;
	/*
	if((y%2==0)&&(d[x]>=2)){
		d[x]-=3;
		y+=1;
		ans+=dfs(x+1,y);
		y-=1;
		d[x]+=3;
	}
	if(y/4==0&&(d[x]>=4)){
		d[x]-=5;
		y+=4;
		ans+=dfs(x+1,y);
		y-=4;
		d[x]+=5;
	}else if(y/2==2 && d[x]>=4){
		d[x]-=5;
		y+=2;
		ans+=dfs(x+1,y);
		y-=2;
		d[x]+=5;
	}
	if(y==0&&d[x]>=74){
		d[x]
		ans+=
	}
	*/
	ans+=check(x,y,1,2);
	ans+=check(x,y,4,4);
	if(y>=4){
		ans+=check(x,y,2,4);
	}
	ans+=check(x,y,6,24);
	//ans+=check(x,y,5,14);
	//ans+=check(x,y,3,14);
	ans+=check(x,y,3,14);
	ans+=check(x,y,7,74);
	ans+=dfs(x+1,y);
	//cout<<x<<" "<<y<<" "<<ans<<endl;
	return ans;
}

int main(){
	
	cin>>N;
	REP(i,N){
		int X=i+1;
		REP(j,X){
			if(j==0)continue;
			while(X%(j+1)==0){
				X/=(j+1);
				d[j+1]++;
			}
		}
	}
	LL ans=dfs(0,0);
	
	/*
	LL a=0;
	LL b=0;
	REP(i,N+1){
		a+=d[i]/3;
		b+=d[i]/5;
	}
	LL dif=a-b;
	LL ans=0;
	ans+=max(LL(0),dif*(dif-1)*(dif-2)/6);
	ans+=max(LL(0),a*(b-1)*(b-2)/6);
	
	//LL ans=max(0,b*(b-1)*(a-2)/6);
	cout<<ans<<endl;
	
	
	REP(i,100){
		cout<<d[i]<<endl;
	}
	*/
	cout<<ans<<endl;
	
	//cout<<(3&5)<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

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

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt n;
    string s;
    cin >> n >> s;
    intt a = 0, b = 0;
    string ans = "" ;
    for (intt i = 0; i < n; i++) {
        if (s[i] == ')')
            a --;
        else
            a ++;
        if (a < 0)
            ans += '(', a = 0;
    }
    ans += s;
    for (intt i = 1; i <= a; i++)
        ans += ')';
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
K,A,B=map(int,input().split())
if(B-A<=2):
    print(K+1)
elif(A>=K):
    print(K+1)
else:
    count=K-A+1
    yaru=int(count/2)
    if(count%2):
        print(A+yaru*(B-A)+1)
    else:
        print(A+yaru*(B-A))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define itrep(at)	for(auto it=at.begin();it!=at.end();it++)
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e10

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> n >> k;
    lli dp[n+1];
    rep(i,0,n+1)	dp[i]=0;
    for(i=0;i<k;i++){
    	cin >> d;
    	while(d--){
    		cin >> a;
    		dp[a]++;
		}
	}
	for(i=1;i<=n;i++){
		if(dp[i]==0)	ans++;
	}
	cout<<ans;
    
    
}













int main()
{
	long long int t=1,c=1;
	//scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */


Measured memory_bytes: 3632
N = int(input())
Ls,L = [],[]
for i in range(N):
    A = int(input())
    if A==0:
        Ls.append(L)
        L = []
    else:
        L.append(A)
Ls.append(L)
out = 0
for L in Ls:
    out += sum(L)//2
print(out)


Measured memory_bytes: 77476
#include <stdio.h>

int main(void){
    int n,a,b,i=0,j=0,k=0;
    scanf("%d %d %d",&n,&a,&b);
    char s[n+1];
    scanf("%s",s);
    while(s[i]!='\0'){
        if(s[i]=='a'){
            if(j<a+b){
                printf("Yes\n");
                j++;
            }
            else{
                printf("No\n");
            }
        }
        else if(s[i]=='b'){
            if(j<a+b&&k<b){
                printf("Yes\n");
                j++;
                k++;
            }
            else{
                printf("No\n");
            }
        }
        else{
            printf("No\n");
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;

int main()
{
  int N, cnt = 0;
  cin >> N;
  rep(i, 26) rep(j, 15) if (i * 4 + j * 7 == N) cnt++;
  cout << (cnt ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
while 1:
    n=int(raw_input())
    if n==0:break
    card=range(1,2*n+1)
    taro=[int(raw_input()) for _ in xrange(n)]
    hanako=[]
    for i in xrange(1,2*n+1):
        if not i in taro:
            hanako.append(i)
    taro.sort()
    hanako.sort()
    now=0
    while 1:
        for i in xrange(len(taro)):
            t=taro[i]
            if now<t:
                now=t
                del taro[i]
                break
        else:
            now=0
        if len(taro)==0:break
        for i in xrange(len(hanako)):
            h=hanako[i]
            if now<h:
                now=h
                del hanako[i]
                break
        else:
            now=0
        if len(hanako)==0:break
    print(len(hanako))
    print(len(taro))

Measured memory_bytes: 6304