akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#define MOD1 1000000007
inline void inp( long long int  &n ){n=0;int ch=getchar();int sign=1;while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}while( ch >= '0' && ch <= '9' )n = (n<<3)+(n<<1) + ch-'0', ch=getchar();n=n*sign;}
//#define pi acos(-1)
#define pii pair<int,int>
#define vii vector<pii>
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define ll  long long int
#define LL long long int
#define loop2(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,x,y) for(ll i = (x) ; i <= (y) ; ++i)
#define MIN(a,b) (a) < (b) ? (a) : (b)
#define MAX(a,b) (a) > (b) ? (a) : (b)
#define ABS(a) (a) > 0 ? (a) : -(a)
#define rep1(i,a,n) for(i=a;i<(n);i++)
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl
#define EPS 1e-9
#define ld long double
using namespace std;
// JAI SHREE KRISHNA

// 1.25H Dude!!! 1.25 H

//!!!C***


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll arr[3];
    loop(i, 3)
    {
        cin>>arr[i];
    }
    sort(arr,arr+3);
    if(arr[2]%2==0)
    {
        cout<<"0";
    }
    else{
        cout<<arr[1]*arr[0];
    }
    
    
   

    
    return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
mi = 2018
break_loop = False
for i in range(R-L):
  for j in range(R-L):
    mi = min(mi,(L+i)*(L+j+1)%2019)
    if mi == 0:
       break_loop = True
       break
  if break_loop:
    break
print(mi)

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

int main() {
  int N,M,X,a=1,Z=2000000;
  cin>>N>>M>>X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  for(int i=0;i<N;i++){
    cin>>C.at(i);
    a*=2;
    for(int j=0;j<M;j++){
      cin>>A.at(i).at(j);
    }
  }
  for(int i=0;i<a;i++){
    int D=i;
    int E=0;
    vector<int> q(M);
    for(int j=0;j<N;j++){
      if(D%2==1){
        for(int k=0;k<M;k++){
          q.at(k)+=A.at(j).at(k);
        }
        E+=C.at(j);
      }
      D/=2;
    }
    int G=0;
    for(int j=0;j<M;j++){
      if(q.at(j)<X){
        G++;
        break;
      }
    }
    if(G==0){
      Z=min(Z,E);
    }
  }
  if(Z==2000000){
    cout<<"-1"<<endl;
  }
  else{
    cout<<Z<<endl;
  }
}





Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


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

	int n;
	cin >> n;
	int *a = new int[n];
	bool *q = new bool[n] {false};
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int count = 0;
	int index = 0;
	while (q[index] == false)
	{
		if (a[index] == 2)
		{
			cout << count + 1 << '\n';
			return 0;
		}

		q[index] = true;
		index = a[index] - 1;
		count++;
	}

	cout << "-1" << '\n';

	return 0;
}


/*

*/

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

int main()
{
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<ll> p, q, r;
  rep(i, a)
  {
    ll tmp;
    cin >> tmp;
    p.push_back(tmp);
  }

  rep(i, b)
  {
    ll tmp;
    cin >> tmp;
    q.push_back(tmp);
  }

  rep(i, c)
  {
    ll tmp;
    cin >> tmp;
    r.push_back(tmp);
  }

  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  sort(q.begin(), q.end());
  reverse(q.begin(), q.end());
  sort(r.begin(), r.end());
  reverse(r.begin(), r.end());

  vector<ll> merged;

  rep(i, x)
  {
    merged.push_back(p[i]);
  }

  rep(i, y)
  {
    merged.push_back(q[i]);
  }

  rep(i, r.size())
  {
    merged.push_back(r[i]);
  }

  sort(merged.begin(), merged.end());
  reverse(merged.begin(), merged.end());

  ll ans = 0;
  rep(i, x + y)
  {
    ans += merged[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8560
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

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

    vector<int> num(MAXSIZE);
    for(int i = 0; i < n; ++i){
        int d;
        cin >> d;
        num[d]++;
    }

    // sort(num.begin(), num.end());
    
    int sum = 0;
    int ans = 0;
    for(int i = 1; i < 100000 + 1; ++i){
        if(sum > n / 2){
            break;
        }

        sum += num[i];

        ans += (sum == n / 2);
    }

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

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int n, m, i, j, a[1000][1000] = { 0 }, b[1000] = {0}, ans[1000] = { 0 };
    
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for (i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }

    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            ans[i] = ans[i] + a[i][j] * b[j];
        }
    }

    for (i = 0; i < n; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 5736
#include<bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;
 
long long int mul(long long int ans, long long int x, long long int y){
    while (y){
        if (y%2){
            ans = (ans * x) % MOD;
        }
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}
 
long long int inv(long long int n){
    return mul(1, n, MOD-2);
}
 
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> prime(1000000, 0);
    for (int i=0; i<n; i++){
        int m = a[i];
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        prime[2] = max(prime[2], count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            prime[j] = max(prime[j], count);
        }
        prime[m] = max(prime[m], 1);
    }
 
    long long int lcm = 1;
    for (int i=2; i<prime.size(); i++){
        if (prime[i] != 0)  lcm = mul(lcm, i, prime[i]);
    }
 
    long long int ans = 0;
    for (int i=0; i<n; i++){
        long long m = a[i], _ans = lcm;
        int count = 0;
        while (m%2 == 0){
            m /= 2;
            count++;
        }
        _ans = mul(_ans, inv(2), count);
        for (int j=3; j*j<=m; j+=2){
            count = 0;
            while (m%j == 0){
                m /= j;
                count++;
            }
            if (count != 0)  _ans = mul(_ans, inv(j), count);
        }
        _ans = mul(_ans, inv(m), 1);
        ans += _ans;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
  int n, k;
  while (true) {
    cin >> n >> k;
    if (n == 0 && k == 0) return 0;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    set<string> s;
    do {
      string ans;
      rep(i, k) ans += a[i];
      s.insert(ans);
    } while (next_permutation(a.begin(), a.end()));

    cout << s.size() << endl;
  }
  return 0;
}



Measured memory_bytes: 3268
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    int w[n];
    rep(i,0,n-1) cin>>w[i];
    int min=10000000;
    int ans=0;
    int hoge=0; 
    rep(i,0,n-1){
        hoge += w[i];
        int sum=0;
        rep(j,i+1,n-1){
            sum += w[j];
        }
        if(min>abs(hoge-sum)){
            min = abs(hoge-sum);
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
vector<P> enum_divisors(long long N) {
    vector<P> res;
    for (long long i = 1; i * i <= N; ++i) {
      if (N % i == 0)
        res.push_back( pair(i, N/i) );
    }
    return res;
}

int main() {
  ll n; cin >> n;
  vector<P> p = enum_divisors(n);
  ll k = n+1;
  ll ans = k;
  
  rep(i, p.size()){
    if(k > p[i].first + p[i].second - 2)
      ans = p[i].first + p[i].second - 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3604
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val p = (1..n).map { readLine()!!.toInt() }
    val desc = p.sortedDescending()
    val sum = desc.first() / 2 + desc.filterIndexed { index, i -> index > 0 }.sum()
    println(sum)
}

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

N=int(input().rstrip('\n'))
dict = {'AC':0,'WA':0,'TLE':0,'RE':0}
for i in range(N):
  x = input().rstrip('\n')
  dict[x] += 1
res = '{} x {}'
print(res.format('AC',dict['AC']))
print(res.format('WA',dict['WA']))
print(res.format('TLE',dict['TLE']))
print(res.format('RE',dict['RE']))

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


int main()
{
	int i,len= 0;
	char str[21] = { 0 };

	scanf("%s", str);

	for (i = strlen(str); i >0;i--)
	{
		printf("%c",str[i-1]);
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const ll MOD=10000000007;

int main() {
  string a="Sunny",b="Cloudy",c="Rainy";
  string S;
  cin >> S;
  if (S==a){
    cout << b << endl;
  }
  else if (S==b){
    cout << c << endl;
  }
  else {
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> H(N); for (int& h : H) cin >> h;
    vector<int> cost(N, 1<<30);
    cost[0] = 0;
    for (int i = 0; i < N; i++) {
        if (i+1 < N) cost[i+1] = min(cost[i+1], cost[i] + abs(H[i] - H[i+1]));
        if (i+2 < N) cost[i+2] = min(cost[i+2], cost[i] + abs(H[i] - H[i+2]));
    }
    cout << cost[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

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

    string s, t; cin >> s >> t;
    int ss = s.length(), tt = t.length();
    bool ok = true;
    if (ss+1 != tt) ok = false;
    rep(i, ss) if (s[i]!=t[i]) ok = false;
    if (ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 3616
S = input()
T = input()
Ls = len(S)
Lt = len(T)
ans = 0
for i in range(Ls-Lt+1):
    count = 0
    for j in range(Lt):
        count += S[i+j] == T[j]
    ans = max(ans, count)
ans = Lt-ans
print(ans)


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
int main()
    {
    	cin.tie(0);
        ios::sync_with_stdio(0);
        string s,S;cin>>s;
    	for (int i = 0; s[i] ; ++i)
    	{
    		if(i%2==0){
    			S+=s[i];
    		}
    	}
        cout<<S;
    	return 0;
    }



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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
// const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto (i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec) for(auto (i) = (vec).end()-1;(i) != (vec).begin()-1;(i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


lli calcu(int k){
  if(k == 0) return 1;
  lli before = calcu(k / 2);
  before = (before * before) % MOD;
  return (k % 2 == 0) ? before : (before << 1) % MOD;
}

int main(void){
  int n, working_numb; cin >> n;
  vector<int> A(n);
  REP(i, n){
    cin >> working_numb;
    A.at(working_numb)++;
  }
  bool flag = false;
  if(n % 2 == 1){
    if(A.at(0) != 1) flag = true;
    for(int i = 2; i < n; i += 2) if(A.at(i) != 2) flag = true;
  }
  else for(int i = 1; i < n; i += 2) if(A.at(i) != 2) flag = true;
  if(flag) cout << "0\n";
  else cout << calcu(n / 2) << "\n";
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo for(int i=0;i<n;i++)
#define clear cin.clear();cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define loopSolve int t; cin>>t; while(t--){solve();}
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//INT_MAX         2,147,483,647                       <10^10
//U_INT_MAX       4,294,967,295                       <10^10
//LONG_LONG_MAX   9,223,372,036,854,775,807           <10^18
//U_LONG_LONG_MAX 18,446,744,073,709,551,615          <10^18
//ll power(int a, int b){
//    return (ll)(pow(a,b)+0.5);
//}

vector<int> gV(int n){
    vector<int> v(n);
    fo { cin>>v[i];  }
    return v;
}

int* gA(int n){
    int* arr = new int[n];
    fo cin>>arr[i];
    return arr;
}

void solve(){
    int red,green,blue,k;
    cin>>red>>green>>blue>>k;
    int op=0;
    while(op<k){
       if(red>=green){
        green*=2;
        op++;
       }else
            break;
    }
    while(op<k){
        if(green>=blue){
        blue*=2;
        op++;
       }else{
            break;
       }
    }
    if(blue>green && green>red){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


int main() {
	ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    //loopSolve;

	return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
using namespace std;
#define LL long long
const int MAXN=1005;
int n,m,ans;
struct sa{LL x,y,z;}s[MAXN];
LL pr(int x,int y,int z){
	LL ret=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<n;j++){
			LL w1=s[j].x*x+s[j].y*y+s[j].z*z;
			LL w2=s[j+1].x*x+s[j+1].y*y+s[j+1].z*z;
			if(w1<=w2)
				swap(s[j],s[j+1]);
		}
	for(int i=1;i<=m;i++)
		ret+=s[i].x*x+s[i].y*y+s[i].z*z;
	return ret;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld%lld",&s[i].x,&s[i].y,&s[i].z);
	printf("%lld\n",max(pr(1,1,1),max(pr(1,1,-1),max(pr(1,-1,1),max(pr(-1,1,1),max(pr(1,-1,-1),max(pr(-1,1,-1),max(pr(-1,-1,1),pr(-1,-1,-1)))))))));
}

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

int main() {
    vector<int> a(32);
    a[0]=1;a[1]= 1;a[2]= 1;a[3]= 2;a[4]= 1;
    a[5]= 2;a[6]= 1;a[7]= 5;a[8]= 2; a[9]=2;a[10]= 1;
    a[11]= 5;a[12]= 1;a[13]= 2;a[14]= 1;a[15]= 14;a[16]= 1;
    a[17]= 5;a[18]= 1;a[19]= 5;a[20]= 2;a[21]= 2;a[22]= 1;
    a[23]= 15;a[24]= 2;a[25]= 2;a[26]= 5;a[27]= 4;a[28]= 1;
    a[29]= 4;a[30]= 1;a[31]= 51;
    int k;
    cin >> k;
    cout << a[k-1] << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    int dp[n][2];
    dp[0][0]=0;
    dp[0][1]=0;
    dp[1][0]=abs(a[1]-a[0]);
    dp[1][1]=1e6;
    for(int i=2;i<n;i++)
    {
      dp[i][1]=min(dp[i-2][0],dp[i-2][1])+abs(a[i]-a[i-2]);
      dp[i][0]=min(dp[i-1][0],dp[i-1][1])+abs(a[i]-a[i-1]);
    }cout<<min(dp[n-1][0],dp[n-1][1]);
}


Measured memory_bytes: 1408
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));

$m_cnt = 0;
$z_cnt = 0;

for ($i = 0; $i < $n; ++$i) {
    if ($A[$i] === 0) {
        ++$z_cnt;
    } else if ($A[$i] < 0) {
        ++$m_cnt;
    }
}

$sum = 0;
if ($m_cnt % 2 === 0) {
    for ($i = 0; $i < $n; ++$i) {
        $sum += abs($A[$i]);
    }
} elseif ($m_cnt % 2 === 1 && $z_cnt !== 0) {
    for ($i = 0; $i < $n; ++$i) {
        $sum += abs($A[$i]);
    }
} else {
    $min = PHP_INT_MAX;
    for ($i = 0; $i < $n; ++$i) {
        $tmp = abs($A[$i]);
        $min = min($min, $tmp);
        $sum += $tmp;
    }

    $sum -= $min * 2;
}

echo $sum;


Measured memory_bytes: 16884
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back



      






int main(){

  ll n,m;
  cin>>n>>m;
  vector<ll> data(n);
  rep(i,n){
    ll tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  priority_queue<ll> cost;
  rep(i,n){
    cost.push(data.at(i));
  }
  
  rep(i,m){
    ll x=cost.top();
    cost.pop();
    cost.push(x/2);
  }
  
  ll answer=0;
  rep(i,n){
    ll x=cost.top();
    answer+=x;
    cost.pop();
  }
  
  cout<<answer<<endl;

}












Measured memory_bytes: 2168
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let m: i64 = read();
    let a = n / m;
    let b = n % m;
    if b != 0 {
        println!("{}", a + 1);
    } else {
        println!("{}", a);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 2305843009213693951
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define all1(i) begin(i),end(i)
#define GOODBYE do { cout << "-1" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll S;
    cin >> S;
    
    vector<ll> dp(S+1,0),dp_sum(S+1,0);
    
    REP(i,S+1){
        if(i<3)continue;
        
        dp[i] = (dp_sum[i-3]+1)%MOD;
        dp_sum[i] = (dp_sum[i-1]+dp[i])%MOD;
        
    }
    
    cout << dp[S] << endl;
    
    return 0;
}



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

using namespace std;
#define ll long long
#define ld long double

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    ll a, b, k;
    cin >> a >> b >> k;
    ll take1 = min(a, k);
    a -= take1;
    k -= take1;
    b -= min(b, k);
    cout << a << " " << b << '\n';
    return 0;
}



Measured memory_bytes: 256
fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val hh = readLine()!!.split(" ").map { it.toInt() }

    val towers = Array<MutableList<Int>>(n){ mutableListOf()}

    repeat(m) {
        val (a, b) = readLine()!!.split(" ").map { it.toInt()-1 }
        towers[a].add(hh[b])
        towers[b].add(hh[a])
    }

    var cnt = 0
    towers.forEachIndexed { idx, tList ->
        val myHeight = hh[idx]
        if (tList.count { it >= myHeight } == 0) cnt++
    }

    println(cnt)
}


Measured memory_bytes: 74712
#include<bits/stdc++.h>
#define ljh ioi_aker
#define yxy tourist
#define wlj ugly_and_slow
#define pmh legendary_grandmaster
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 2e6+1;
cs int mod = 998244353;
cs int inf = 1e17+1;
int fir[ff], nex[ff], to[ff], tot;
void add(int x, int y)
{
	if( x == y ) return;
	nex[++tot] = fir[x];
	fir[x] = tot;
	to[tot] = y;
}
int n, k, a[ff], s, su;
void init()
{
	cin >> n >> k;
	rep(i, 1, n)
		cin >> a[i], s += a[i];
	int pp = 4 * k;
	int lim = s / pp;
	if( s % pp != 0 ) lim++;
	rep(i, 1, n)
		if( a[i] >= lim ) su++;
	puts( su >= k ? "Yes" : "No" );
}
signed main()
{
	int T = 1;
//	cin >> T;
	while(T--) 
		init();
} 

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int a,b,c;
	scanf("%d%d%d", &a,&b,&c);
	
	if(a+b==c || a+c==b || b+c == a)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> s(n);
    rep(i,n) {
        int a;
        cin >> a;
        s[i] = pair<int,int>(a,i+1);
    }
    sort(s.begin(),s.end());
    rep(i,n) cout << s[i].second << " ";

    return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int used[2];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	string s;
	cin >> s;
	int n = s.size();
	int l = n - 1, r = 0, k = 1;
	while (r < n) {
		if (l <= r)
			used[s[l] - '0'] = 1, used[s[r] - '0'] = 1;
		if (used[0] && used[1])
			break;
		l--, r++, k++;
	}
	cout << k - 1;
}


Measured memory_bytes: 3680
l=list(map(int,list(input())))

for i in range(2**3):
    count=l[0]
    s=str(l[0])
    for j in range(3):
        if i&(2**j):
            count+=l[j+1]
            s=s+'+'+str(l[j+1])
        else:
            count-=l[j+1]
            s=s+'-'+str(l[j+1])
    if count==7:
        print(s+'=7')
        exit()





Measured memory_bytes: 3060
// AOJ 2621: Fox Observation
// 2017.11.26 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define HASHSIZ 800011
typedef struct { long long n; int w; } HASH;
HASH hash[HASHSIZ+3], *hashend = hash+HASHSIZ;

int ans;

void insert(int x, int y, int w)
{
	long long xy = ((long long)x << 32) + y;
	HASH *p = hash + xy % HASHSIZ;
	while (p->n) {
		if (p->n == xy) goto next;
		if (++p == hashend) p = hash;
	}
	p->n = xy;
next:
	p->w += w;
	if (p->w > ans) ans = p->w;
}

#define BASE 1000000000		// 10^9

char buf[35], *p;
int getint(void)
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, x, y, w;

	fgets(p=buf, 10, stdin), n = getint();
	ans = 0;
	for (i = 0; i < n; i++) {
		fgets(p=buf, 35, stdin);
		x = BASE + getint(), p++, y = BASE + getint(), p++, w = getint();
		insert(x  , y  , w);
		insert(x+1, y  , w);
		insert(x  , y+1, w);
		insert(x+1, y+1, w);
	}
	printf("%d / 1\n", ans);
	return 0;
}

Measured memory_bytes: 14352
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const ll INF = 1e10;


int a,b,c,d;
int main(){
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int a, b; cin >> a >> b;) {
		cout << a - b << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
#include <cstdio>
#include <string.h>
#include <iostream>

using namespace std;

int abs(int m){
	if(m > 0)
		return m;
	else
		return -m;
}

int main(void){
	int n, i, j, x, mn, d, dp[1 << 20];
	while(1){
		scanf("%d",&n);
		if(!n) break;
		memset(dp,-1,sizeof(dp));
		dp[0] = 0;
		for(i = 0;i < n;i++){
			scanf("%d",&x);
			for(j = 0;j < 1 << n;j++)
				if(dp[j] != -1) dp[j ^ (1 << i)] = dp[j] + x;
		}
		d = ~((1 << n) - 1);
		mn = 0x3FFFFFFF;
		for(i = 0;i < 1 << n;i++)
			mn = min(mn,abs(dp[i] - dp[(~i ^ d)]));
		printf("%d\n",mn);
	}
	return 0;
}

Measured memory_bytes: 5292
#include <iostream>

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;

  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= N - x; y++) {
      const int z = N - (x + y);
      const int sum = 10000 * x + 5000 * y + 1000 * z;
      if (sum == Y) {
        cout << x << ' ' << y << ' ' << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int cnt=0;
        bool flag=false;
        for(int i=0;i<n;i++){
            int a;cin>>a;
            flag|=(a>1);
            cnt+=(a>0);
        }

        if(!flag)cout<<"NA"<<endl;
        else cout<<cnt+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N;  cin>>N;
  ll x = 1;
  vector<int> a(N), b(N);
  rep(i,0,N){
    cin>>a[i]>>b[i];
  }
  rep(i,1,N){
    ll a2 = (x*a[i-1]+a[i]-1)/a[i];
    ll b2 = (x*b[i-1]+b[i]-1)/b[i];
    x = max(a2, b2);
  }
  cout << x*(a.back()+b.back()) << endl;
  return 0;
}


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


int main(){
	int n, m, i, a, b, l, u;
	cin >> n >> m;
	cin >> l >> u;
	for(i = 1; i < m; i++){
		cin >> a >> b;
		if(a > l){
			l = a;
		}
		if(b < u){
			u = b;
		}
	}
	if(u >= l){
		cout << u - l + 1;
	}
	else{
		cout << 0;
	}
	return 0;
}

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

long long calcGCD(long long x, long long y)
{
    if (x < y)
    {
        swap(x, y);
    }
    long long remain = x % y;
    while (remain != 0)
    {
        x = y;
        y = remain;
        remain = x % y;
    }
    return y;
}

long long calcLCM(long long x, long long y)
{
    if (x < y)
    {
        swap(x, y);
    }
    long long ret = x / calcGCD(x, y);
    return ret * y;
}

int main()
{
    int N, M;
    string S, T;
    cin >> N >> M >> S >> T;

    long long gcd = calcGCD(N, M);
    long long ans = calcLCM(N, M);
    for (int i = 0; i < gcd; i++)
    {
        if (S[i * (N / gcd)] != T[i * (M / gcd)])
        {
            ans = -1;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count=0;
  string s1,s2;
  cin>>s1>>s2;
  for(int i=0;i<3;i++)
    if(s1[i]==s2[i])
      count++;
  cout<<count<<endl;
  return 0;
}

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

#define F first
#define S second
#define int long long
#define inf 1000000000

using namespace std;

signed main(){
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++){
        cin >> p[i];
    }
    for (int i = 0; i < b; i++){
        cin >> q[i];
    }
    for (int i = 0; i < c; i++){
        cin >> r[i];
    }
    int ri = a-x, gi = b-y;
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    sort(r.begin(), r.end());
    int sum = 0;
    vector<int> res(0);
    for (int i = ri; i < a; i++){
        sum += p[i];
        res.push_back(p[i]);
    }
    for (int i = gi; i < b; i++){
        sum += q[i];
        res.push_back(q[i]);
    }
    sort(res.begin(), res.end());
    int ci = c-1, resi = 0;
    while (ci >= 0 && r[ci] > res[resi]){
        sum -= res[resi];
        sum += r[ci];
        ci--; resi++;
    }
    cout << sum << endl;
    return 0;
}























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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    int n, t;
    cin >> n >> t;
    int at;
    cin >> at;
    bool pushed = true;
    int tot = 0;

    fo(i, n - 1 ) {
        int a;
        cin >> a;
        if ( pushed ) {
            if ( a - at < t ) {
                tot += a - at;
                at = a;
            } else {
                tot += t;
                at = a;
            }
        } else pushed = true;
    }

    if ( pushed ) tot += t;

    cout << tot << endl;

    return 0;
}

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

#define f(i,a,b) for (int i = a; i < b; i++)
#define pb push_back

int main() {
int n,k; cin>>n>>k;
string s; cin>>s;
vector<pair<int,int>> res;
f(i,0,n) {
int j = i;
while (j < n && s[i] == s[j]) j++;
res.pb({j-i,s[i]-'0'});
i = j-1;
}
int sum = 0, num = 0, j = 0;
int ans = 0;
f(i,0,res.size()) {
while (j < res.size() && num+(res[j].second==0) <= k) {
num += res[j].second == 0;
sum += res[j].first;
j++;
}
ans = max(ans,sum);
if (res[i].second == 0) num--;
sum -= res[i].first;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1528
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int N,M,C;
long long B[maxm];

int main(){
	register int i,j,X,Ans=0;
	register long long Now;
	scanf("%d%d%d",&N,&M,&C);
	for(i=1;i<=M;i++) scanf("%lld",B+i);
	for(i=1;i<=N;i++){
		Now=C;
		for(j=1;j<=M;j++) scanf("%d",&X),Now+=X*B[j];
		Ans+=(Now>0);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = sorted([input() for _ in range(N)])

o = {}
for a in A:
    if a in o:
        o[a] += 1
    else:
        o[a] = 1

o_sorted = sorted(o.items(), key=lambda x:x[1], reverse=True)

max = 0
res = []
for o in o_sorted:
    if o[1] < max:
        break
    max = o[1]
    res.append(o[0])

for r in sorted(res):
    print(r)


Measured memory_bytes: 121372
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    n = int(input())
    h = list(map(int,input().split()))

    dp = [0]*n
    dp[1] = abs(h[1]-h[0])
    for i in range(1,n-1):
        dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))
    print(dp[n-1])
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 78420
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
 
int main(){
  int N ,ans;
  cin >> N ;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  rep(i,N) cin >> A.at(i);
  rep(i,N) cin >> B.at(i);
  rep(i,N-1) cin >> C.at(i);
  rep(i,N) ans += B.at(i) ;
  //cout << ans << endl; 
  rep(i,N-1) 
  {if( A.at(i) + 1 == A.at(i+1) ){
    //cout << A.at(i) <<' '<<C.at( A.at(i) - 1 ) << endl; //なぜかこの行を追加するとエラーが出る。
    ans += C.at( A.at(i) - 1 ) ;
  }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 256
// In God We Trust


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

# define INF 1 << 31 - 1
# define pb push_back
# define fi first
# define se second

vector<int> g[100100];


// CPP code for printing shortest path between 
// two vertices of unweighted graph 
#include <bits/stdc++.h> 
using namespace std; 

signed main(){
  int n, W;
  cin >> n >> W;
  int w[n], v[n];
  for (int i = 0; i < n ; i++)
    cin >> w[i] >> v[i];
  long long dp[n][100100];
  for (int i = 0; i < 100100; i++)
    dp[0][i] = INT_MAX;
  for (int j = 0; j <= v[0]; j++)
    dp[0][j] = w[0];
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    dp[i][0] = 0;
  
  for (int i = 1; i < n; i++)
    for (int j = 0; j < 100100; j++){
      dp[i][j] = dp[i - 1][j];
      if (v[i] >= j)
	dp[i][j] = min(dp[i][j], (long long)w[i]);
      else
	dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] +  w[i]);
    }
  for (int j = 0; j < 100100 ; j++)
    if (dp[n - 1][j] > W){
      cout << j - 1;
      break;
    }
  
    
}
	

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

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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<int> D;
    int cnt = 0;
    rep(i,N){
        int a,b;cin>>a>>b;
        if(a==b)cnt++;
        else cnt = 0;
        if(cnt>=3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a = 0, b = 0, c;
  cin >> N;
  vector<int> F(N), A(N / 2 + 1), B(N / 2);
  
  for(int i = 0; i < N; i++)
    cin >> F.at(i);
  
  sort(F.begin(), F.end());
  reverse(F.begin(), F.end());
  
  for(int i = 0, j = 0; i < N; i += 2, j++)
    A.at(j) = F.at(i);
  
  for(int i = 1, j = 0; i < N; i += 2, j++)
    B.at(j) = F.at(i);
  
  for(int i = 0; i < N / 2 + 1; i++)
    a += A.at(i);
  
  for(int i = 0; i < N / 2; i++)
    b += B.at(i);
  
  c = a - b;
  
  cout << c << endl;
}

Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define MOD (ll)(1e9 + 7)
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	cin >> n;
	set<string> st;
	fore(i, 0, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size();
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

Measured memory_bytes: 19156
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<sstream>
#include<cmath>
#include<climits>

int main(){
	int L;
	std::vector<long long int> A;
	std::vector<std::vector<long long int>> DP;

	std::cin >> L;

	DP = std::vector<std::vector<long long int>>(L, std::vector<long long int>(5, 0));

	for(int i=0;i<L;i++){
		long long int A_;
		std::cin >> A_;
		A.emplace_back(A_);
	}

	for(int j=0;j<5;j++){
		if(j%2==1) DP[0][j] = A[0]==0 ? 2 : A[0] % 2;
		else{
			if(j==2) DP[0][j] = A[0] % 2 == 0 ? 1 : 0;
			else DP[0][j] = A[0];
		}
	}

	for(int i=1;i<L;i++){
		long long int tmp=INT_MAX;
		for(int j=0;j<5;j++){
			if(tmp > DP[i-1][j]) tmp = DP[i-1][j];
			if(j%2==1) DP[i][j] = (A[i]==0 ? 2 : A[i] % 2) + tmp;
			else{
				if(j==2) DP[i][j] = (A[i] % 2 == 0 ? 1 : 0) + tmp;
				else DP[i][j] = A[i] + tmp;
			}
		}
	}

	std::cout << *std::min_element(DP.back().begin(), DP.back().end()) << std::endl;
	return 0;
}


Measured memory_bytes: 16632
# Coding is about expressing your feeling, and
# there is always a better way to express your feeling_feelme
import sys
import math
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output2.txt','w')
from sys import stdin,stdout
from collections import deque,defaultdict
from math import ceil,floor,inf,sqrt,factorial,gcd,log2
from copy import deepcopy
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
mod=int(1e9 + 7)

n=ii1()
dp=[0]*(n+1)
arr=iia()
a=list(zip(arr,range(1,n+1)))
a.sort()
for i in range(n):
    print(a[i][1],end=' ')
print()



Measured memory_bytes: 24788
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>



using ll = long long;


using namespace std;
int gcd(int a, int b) {
	if (a < b) {
		int t = a;
		a = b;
		b = t;
	}
	
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}

int factorial(ll n) {
	if (n > 0) {
		return n * factorial(n - 1);
	}
	else
		return 1;
}
int main()
{/*12日目*/
	int n, m; cin >> n >> m;
	vector<pair<int, int>> pp(m);
	for(int i=0;i<m;i++)
		 cin >> pp[i].first >> pp[i].second;
	for (int i = 0;i < 1000;i++) {
		int keta = 1;
		int ni = i / 10;
		vector<int> d(1, i % 10);
		while (ni) {
			d.push_back(ni % 10);
			ni /= 10;
			keta++;
		}
		if (keta != n) continue;
		reverse(d.begin(), d.end());
		bool ok = true;
		for (int i = 0;i < m;i++) {
			if (d[0, pp[i].first - 1] != pp[i].second)
				ok = false;
		}
		if (ok) {
			cout << i;
			return 0;
		}
    }
		cout << "-1";
}


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;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;


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


int main(){
  int A,P;
  cin >> A >> P;
  int B = A * 3;
  B = (B + P) / 2;
  cout << B << endl;
}


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

int main()
{
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int sum = 0;
  
  if (a >= k)
  {
    sum = k;
    cout << sum << endl;
    return 0;
  }
  else if (a + b >= k)
  {
    sum = a;
    cout << sum << endl;
    return 0;
  }
  else if (k - (a + b) <= c)
  {
    sum = a - (k - (a + b));
    cout << sum << endl;
    return 0;
  }
  else
  {
    sum = a - c;
    cout << sum << endl;
    return 0;
  }
} 

Measured memory_bytes: 3632
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long N, H; cin >> H >> N;
	vector<int> a(N), b(N);
	for (int i = 0; i < N; i++)cin >> a[i] >> b[i];
	vector<int> DP(H + 1, 1e9); DP[0] = 0;
	for (int i = 0; i <= H; i++) {
		for (int j = 0; j < N; j++) {
			int x = i + a[j];
			if (x > H)x = H;
			DP[x] = min(DP[i] + b[j],DP[x]);
		}
	}
	cout << DP[H] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define Q1 0
#define Q2 1



int main(void){
    int A=0,B=0,C=0;
    int count = 0;
    int STATE = 1;
    scanf("%d %d %d",&A,&B,&C);
    
    
    while(1){
       //printf("%d\n",STATE);
        //printf("%d %d %d\n",A,B,C);
        //printf("count=%d\n",count);
        if(STATE == Q2){
            if(C>0){
                C-=1;
                count++;
                STATE = Q1;
            }else if(C==0&&B>0){
                B-=1;
                count++;
                if(B==0){
                    break;
                }
            }else{
                break;
            }
        }else if(STATE == Q1){
            if(A>0){
                A -= 1;
                STATE = Q2;
            }else if(B>0){
                B-=1;
                count++;
                STATE = Q2;
            }else{
                break;
            }
       } 
    }
    printf("%d\n",count);
    return 0;






}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
const int MAX_N=105;
string str[MAX_N];
int H,W;
int r[MAX_N],c[MAX_N];
int main()
{
	cin>>H>>W;
	rep(i,0,H)
	{
		cin>>str[i];
		rep(j,0,W)
		{
			if(str[i][j]=='#')
			{
				r[i]++;
				c[j]++;
			}
		}
	}
	rep(i,0,H)
	{
		if(r[i]==0)continue;
		rep(j,0,W)
		{
			if(c[j]==0)continue;
			putchar(str[i][j]);
		}
		puts("");
	}
	return 0;
}



Measured memory_bytes: 256