akhauriyash/Code-Regression huggingface dataset:
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int a[1010];
int main()
{
int n; 
cin >> n;
vector<long long> v;
for(int i=0; i<n; ++i) {
int a; cin >> a;
v.push_back(a);
}
int q; cin >> q; 
for(int i=0; i<q; ++i){
int b, e, t; cin >> b >> e >> t;

for(int i=0; i<e-b; ++i){
swap(v[b+i], v[t+i]);
}
} 
    for(int i=0; i<n; i++){
    if(i) cout << ' ';
    cout << v[i];
    }
    cout << endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://msdn.microsoft.com/library/3bstk3k5.aspx
//   http://www.cplusplus.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   http://www.boost.org/doc/



Measured memory_bytes: 3184
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
)

var sc = NewScanner()

func main() {
        n := sc.NextInt()
        minr := sc.NextInt()

        var (
                r   int
                max = int(-1*2e10 - 1)
        )
        for i := 1; i < n; i++ {
                r = sc.NextInt()
                diff := r - minr
                if max < diff {
                        max = diff
                }
                if minr > r {
                        minr = r
                }
        }
        fmt.Println(max)
}

type Scanner struct {
        sc *bufio.Scanner
}

func NewScanner() *Scanner {
        sc := bufio.NewScanner(os.Stdin)
        sc.Split(bufio.ScanWords)
        return &Scanner{sc}
}

func (sc *Scanner) NextInt() int {
        sc.sc.Scan()
        i, err := strconv.Atoi(sc.sc.Text())
        if err != nil {
                panic(err)
        }
        return i
}


Measured memory_bytes: 4100
#include <stdio.h>

int main()
{
    int a, b, c;
    int i;
    int cnt = 0;

    scanf("%d %d %d", &a, &b, &c);

    for (i = 0; i <= b - a; i++)
    {
        if (c % (a + i) == 0)    cnt++;
    }
  
    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <functional>
#define N 101
#define INF 200000000
using namespace std;

int dist[N];
typedef pair<int,int> pii;

std::vector<pii> e1[N];
std::vector<pii> e2[N];

int main(void){
	int a,b,c,d;
	int n,m;
	while(cin>>n>>m,n||m){
		int dp[m+1][m+1];
		int dp1[m+1][m+1];
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++){
				if(i==j)dp[i][j]=0;
				else dp[i][j]=INF;
			}
		}
		for(int i=1;i<=m;i++){
			for(int j=1;j<=m;j++){
				if(i==j)dp1[i][j]=0;
				else dp1[i][j]=INF;
			}
		}
		for(int i=0;i<n;i++){
			cin>>a>>b>>c>>d;
			// e1[a].push_back(make_pair(c,b));
			// e2[a].push_back(make_pair(d,b));
			dp[b][a]=c;
			dp[a][b]=c;
			dp1[b][a]=d;
			dp1[a][b]=d;
		}

		for(int k=1;k<=m;k++){
			for(int u=1;u<=m;u++){
				for(int v=1;v<=m;v++){
					dp[u][v]=min(dp[u][v],dp[u][k]+dp[k][v]);
				}
			}
		}

		for(int k=1;k<=m;k++){
			for(int u=1;u<=m;u++){
				for(int v=1;v<=m;v++){
					dp1[u][v]=min(dp1[u][v],dp1[u][k]+dp1[k][v]);
				}
			}
		}

		int k;
		cin>>k;
		while(k--){
			cin>>a>>b>>c;
			if(c) cout<<dp1[a][b]<<endl;
			else cout<<dp[a][b]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3140
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

int32_t main() {
    fio
    int3(k,a,b)
    for (int i = a; i <=b; ++i) {
        if(i%k==0){
            cout <<"OK" << endl;
            return 0;
        }
    }
    cout << "NG"<<endl;

}






Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main() {
int n1;cin>>n1;
n1=n1%10;
 if(n1==3)
   cout<<"bon";
 else if(n1==0||n1==1||n1==6||n1==8)
   cout<<"pon";
 else
   cout<<"hon";
  
	return 0;
}

Measured memory_bytes: 3132
import collections
n=int(input())
a=list(map(int,input().split()))
q=int(input())
d=collections.Counter(a)
ans=sum(a)
for i in range(q):
  b,c=map(int,input().split())
  ans+=d[b]*(c-b)
  d[c]+=d[b]
  d[b]=0
  print(ans)

Measured memory_bytes: 24204
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+9;
string a[maxn];
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;++i){
        cin>>a[i];
        sort(a[i].begin(),a[i].end());
    }
    sort(a+1,a+n+1);
    long long ans=0,c=0;
    for(int i=2;i<=n+1;++i){
        if(a[i]==a[i-1])
            c++;
        else{
            ans+=c*(c+1)/2;
            c=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int compare(pair<ll,ll> &p1,pair<ll,ll> &p2)
{
	if(p1.first<p2.first)
	return 1;
	if(p1.first==p2.first)
	{
		if(p1.second<p2.second)
		return 1;
	}
	return 0;
}
ll hands(vector<pair<ll,ll>> &v)
{
	stack<pair<ll,ll>> s;
	for(auto itr : v)
	{
	   ll fir=itr.first,scnd=itr.second;
	   if(s.empty()==1)
	   s.push({fir,scnd});
	   else 
	   {
	       if(fir<s.top().second && scnd <= s.top().second)
	       {
	       	  s.pop();
	       	  s.push({fir,scnd});
	       }
	       else if(fir>=s.top().second)
	       s.push({fir,scnd});
	   }
	}
	return s.size();
}
int main()
{
	ll n,point,range;
	cin>>n;
	vector<pair<ll,ll>> v;
	for(int i=0;i<n;++i)
	{
		cin>>point>>range;
		v.push_back({point-range,point+range});
	}
	sort(v.begin(),v.end(),compare);
	ll count=hands(v);
	cout<<count;
	return 0;
}

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

using namespace std ;
string s , s2 ;

int l , l2 ;
const int MAXN = 3001 ;
int dp[MAXN][MAXN] ;

string co ;
void lcs()
{
    for (int i=0;i<=l;i++)
    {

        for (int j=0;j<=l2;j++)
        {
            if(i==0 || j==0)
            {

                dp[i][j] = 0 ;
            }
            else if(s[i-1]==s2[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);

        }
    }

    int x  = l  , y=  l2 ;
    bool track = true ;

    while(dp[x][y] !=0 )
    {
        int ma = max(dp[x-1][y-1],max(dp[x][y-1],dp[x-1][y]));
        if( ma< dp[x][y])
        {
            co += s[x-1] ;
            x-- ;
            y-- ;
        }

        else if(dp[x-1][y-1] == ma)
        {
            x-- ;
            y-- ;
        }
        else if (dp[x][y-1] == ma)
        {

            y--;
        }
        else if(dp[x-1][y] == ma)
        {
            x--;
        }

    }

}


int main()
{


    cin>> s>>s2 ;
    l = s.length() ;
    l2 = s2.length();

    lcs();
    reverse(co.begin(),co.end()) ;

    cout<<co ;



}


Measured memory_bytes: 35456
N, K = map(int,input().split())
h = [int(input()) for i in range(N)]

h.sort()

ans = h[-1] - h[0]

for i in range(N - K + 1):
  if h[i+K-1] - h[i] < ans:
    ans = h[i+K-1] - h[i]
    
print(ans)

Measured memory_bytes: 7384
#include <iostream>
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int main() {


    int n , m ;

    cin>>n>>m;


    int arr[n]={0};

    double total =0 ;
    for(int i=0; i<n ; i++)
    {
    cin>>arr[i];
    total+=arr[i];
    }

    //cout<<total<<endl;

    sort(arr,arr+n);

    double t = total/(1.0*4*m);

   
    int c =0;

    for(int i= n-1 ; i>=0; i--)
    {
        
       
        if(arr[i]>=t)
        c++;

        if(c>=m)
        {
            cout<<"Yes"<<endl;
            break;
        }

    }

    if(c<m)
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define fio ios::sync_with_stdio(false);cin.tie(0);
#define db double
#define mk make_pair
const double Pi=3.14159265;
const int N = 2e5+10;
const int M = 2e5+10;
const ull base=163;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const db eps=1e-8;
const db pi=acos(-1);
using namespace std;
int a[40];
int main(){
    fio;
    int n;
    cin>>n;
    for(int i = 1; i <= n; ++i){
        cin>>a[i];
    }
    int ans = 0;
    for(int j = 2; j <= n-1; ++j){
        if( (a[j-1]<a[j]&&a[j+1]>a[j])||(a[j-1]>a[j]&&a[j+1]<a[j]))ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int flag=0;
	v.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v[i]=temp;
        if(temp==1)
        flag=1;
    }
    if(!flag)
    {
        cout<<-1;return 0;
    }
    vll dp(n+10,0);
    for(int i=0;i<n;i++)
    {
        if(v[i]==1)
        {
            dp[1]=1;
        }
        else if(dp[v[i]-1]>0)
        dp[v[i]]=dp[v[i]-1]+1;
    }
    cout<<n-maxin(dp);
} 

Measured memory_bytes: 3328
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

signed main(void)
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ret = 0;
  REP(i, a+1) {
    REP(j, b+1) {
      REP(k, c+1) {
        if(x == i*500+j*100+k*50) {
          ret++;
        }
      }
    }
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define ALL(V) V.begin(),V.end()
template <typename T> using V = vector<T>;

const char base = 'A';

struct Solver {
    ll N;
    V<char> alp;
    V<string> vs;
    V<char> pre_alp;

    Solver() {}

    bool check(map<char, ll> &c2ll) {
        for(char c : pre_alp) if(c2ll[c] == 0) return false;
        return true;
    }

    template <typename T>
    void sort_and_uniq(V<T> &v) {
        sort(ALL(v));
        auto ite = unique(ALL(v));
        v.erase(ite, v.end());
    }

    bool solve() {
        cin >> N;
        if(!N) return false;
        vs.resize(N);
        V<ll> mul(26);
        for(ll i = 0; i < N; i++) {
            cin >> vs[i];
            if(vs[i].size() > 1) pre_alp.push_back(vs[i][0]);
            reverse(ALL(vs[i]));
            ll pow10 = 1;
            for(char c : vs[i]) {
                alp.push_back(c);
                mul[c - base] += (i < N - 1 ? 1 : -1) * pow10;
                pow10 *= 10;
            }
        }

        sort_and_uniq(alp);
        sort_and_uniq(pre_alp);
        V<ll> nlis(10);
        iota(ALL(nlis), 0);
        V<ll> id(26);
        for(ll i = 0; i < alp.size(); i++)  id[alp[i] - base] = i;

        ll ans = 0;

        do {
            bool ok = true;
            for(char c : pre_alp) {
                if(nlis[id[c - base]] == 0) ok = false;
            }
            if(!ok) continue;
            ll sum = 0;
            for(char c : alp) sum += mul[c - base] * nlis[id[c - base]];
            ans += sum == 0;
        } while(next_permutation(ALL(nlis)));

        for(ll i = 1; i <= 10 - alp.size(); i++) ans /= i;
        cout << ans << endl;
        return true;
    }
};

int main() {
    while(Solver().solve());
    return 0;
}



Measured memory_bytes: 3020
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;

int n;

int main()
{
    cin>>n;
    if (n==25)
        cout<<"Christmas";
    if (n==24)
        cout<<"Christmas Eve";
    if (n==23)
        cout<<"Christmas Eve Eve";
    if (n==22)
        cout<<"Christmas Eve Eve Eve";
    cout<<endl;

    return 0;
}


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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 100000
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back

using namespace std;
typedef long long ll;

int tc;


void solve(){

    ll x,y,ans;
    cin>>x;
    y=x/500;
    ans=y*1000;
    x-=(y*500);
    ans += (x/5)*5;
    cout<<ans<<endl;
}

int main()
{

    _fastIO;


    //cin>>tc; while(tc--)
    solve();

    return 0;
}


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

using namespace std;

int main(){
    string str; cin >> str;
    if(str == "SUN") cout << 7;
    else if(str == "MON") cout << 6;
    else if(str == "TUE") cout << 5;
    else if(str == "WED") cout << 4;
    else if(str == "THU") cout << 3;
    else if(str == "FRI") cout << 2;
    else if(str == "SAT") cout << 1;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(void){
	int n;
	long a, max=-1000000, min=1000000, sum=0;

	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		scanf(" %ld", &a);
		if(a>max) max = a;
		if(a<min) min = a;
		sum+=a;
	}

	printf("%ld %ld %ld\n", min, max, sum);

	return 0;
}


Measured memory_bytes: 2700
N = int(input())
S = [list(map(int, list(input()))) for _ in range(N)]
#print("S:", S)

INF = 10 ** 15

AB = []
for i in range(N):
  for j in range(i + 1, N):
    if S[i][j]:
      AB.append((i, j))
#print("AB:", AB)

for i in range(N):
  for j in range(N):
    if S[i][j] == 0  and i != j:
      S[i][j] = INF

for k in range(N):
  for i in range(N):
    for j in range(N):
      S[i][j] = min(S[i][j], S[i][k] + S[k][j])
#print("S:", S)

answer = -2
for i in range(N):
  flag = 1
  for A, B in AB:
    if abs(S[i][A] - S[i][B]) != 1:
      flag = 0
      break
  if flag:
    answer = max(answer, max(S[i]))

print(answer + 1)

Measured memory_bytes: 44508
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

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

int main() {

	int N;
	cin >> N;

	vector<lint> A(N + 1);
	for (int i = 0; i <= N; i++) cin >> A[i];

	// if N not 0 B_0 = 1
	// B_(i-1) <= A_i + B_i <= 2*B_(i-1)
	// B_N=0
	vector<lint> B(N + 1, LINF);
	B[0] = 1;
	for (int i = 1; i <= N; i++) {
		chmin(B[i], 2 * B[i - 1] - A[i]);
	}

	lint sum = 0;
	for (int i = N; i >= 0; i--) {
		chmin(B[i], sum);
		sum += A[i];
	}

	lint ans = 0;
	if (any_of(B.begin(), B.end(), [](auto b) { return b < 0; }) || A[0] != 0 && N != 0 || A[0] != 1 && N == 0) {
		ans = -1;
	}
	else {
		ans = accumulate(A.begin(), A.end(), 0LL) + accumulate(B.begin(), B.end(), 0LL);
	}

	cout << ans << "\n";

	return 0;
}



Measured memory_bytes: 4740
#include<iostream>
using namespace std;
int main()
{
    int N, T;
    cin>>N>>T;
    int c[110], t[110];
    int res =0;
    int min =10000;
    for(int i=0;i<N;++i)
    {
        cin>>c[i]>>t[i];
    }
    for(int i=0;i<N;++i)
    {
        if(t[i]<=T)
        {
            if(c[i]<=min)
            {
                min =c[i];
            }
        }
    }
    if(min>1000)
    {
        cout<<"TLE"<<endl;
    }else
    {
        cout<<min<<endl;
    }
}

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

int main(){

	int cnt_b, cnt_w;
	char c[3][3];
	
	while(cin >> c[0][0]){
		if(c[0][0] == '0') break;
		
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(i != 0 || j != 0){
					cin >> c[i][j];
				}
			}
		}
		
	
		if(c[0][0] == c[1][1] && c[1][1] == c[2][2] ||
			 c[2][0] == c[1][1] && c[1][1] == c[0][2]){
			if(c[1][1] != '+') cout << c[1][1] << endl;
			else cout << "NA" << endl;
		}
		else {
			for(int i=0; i<3; i++){
				if(c[i][0] == c[i][1] && c[i][1] == c[i][2] || 
					 c[0][i] == c[1][i] && c[1][i] == c[2][i]){
					if(c[i][i] != '+'){
						cout << c[i][i] << endl;
						break;
					}
				}
				if(i == 2) cout << "NA" << endl;
			}
		}
		
	}

	return 0;

}

Measured memory_bytes: 1136
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define em emplace_back
#define pi pair<int,int>
#define si second
#define fi first
// new include starts here.
#define endl '\n'
#define vi vector <int>
#define vii vector <pair<int,int>>
#define __s(x) cout<<#x<<"-> "; cout<<"{ ";F(x){cout<<it<<" ";}cout<<" }";cout<<endl;
#define _s(x) cout<<#x<<"-> "<<x<<endl;
#define _sp(x) cout<<#x<<"-> "<<x.fi<<" "<<x.si<<endl;
#define __sp(x) cout<<#x<<"-> "; cout<<"{ "<<endl;F(x){cout<<it.fi<<" "<<it.si<<endl;}cout<<" }";cout<<endl;
#define inf numeric_limits<int > :: max();
#define fit(it,y) for(auto it=y.begin(); it!=y.end();it++)
#define all(x) x.begin(),x.end()
// new includes end here .
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("/home/adarsh/Desktop/codes/input", "r", stdin); //freopen("/home/adarsh/Desktop/codes/output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

#define TRACE
#ifdef TRACE
#define _v(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define _v(...)
#endif

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=(p(a,b/2)); if(b%2==0)return (t*t); else return ((a)*(t*t)); } 

//---------------------------------------------------------------------------------------------------------------------------------------------

signed main(){
 
	#ifndef ONLINE_JUDGE
	FILEIO
	#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----


	int x1, x2, x3, x4, x5;
	cin>>x1>>x2 >>x3>> x4>>x5;
	if(x1==0){
		cout<<1<<endl;
		return 0;
	}
	if(x2==0){
		cout<<2<<endl;
		return 0;
	}
	if(x3==0){
		cout<<3<<endl;
		return 0;
	}
	if(x4==0){
		cout<<4<<endl;
		return 0;
	}
	cout<<5<<endl;

	
	return 0;
}   

Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	int a[7];
	rep(i, 7)cin >> a[i];
	int ans = 0;
	if (a[0] && a[3] && a[4] && 2 <= (a[0] % 2) + (a[3] % 2) + (a[4] % 2)) {
		ans += 6;
		a[0]--;
		a[3]--;
		a[4]--;
	}
	ans += (a[0] / 2) * 4;
	ans += a[1] * 2;
	ans += (a[3] / 2) * 4;
	ans += (a[4] / 2) * 4;

	cout << ans / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int H, W;
char s[52][52];
int dh[4] = {-1, 0, 1, 0};
int dw[4] = {0, 1, 0, -1}; 

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

    cin >> H >> W;
    rep(i, H){
      rep(j, W) cin >> s[i][j];
    }
    rep(i, H){
      rep(j, W){
        if (s[i][j] == '.') continue;
        bool flag = true;
        rep(l, 4){
          if (i==0 && l==0) continue;
          if (j==W-1 && l==1) continue;
          if (i==H-1 && l==2) continue;
          if (j==0 && l==3) continue;
          if (s[i+dh[l]][j+dw[l]] == '#') {
            flag = false;
          };
        }
        if (flag){
          cout << "No" << endl;
          return 0;
        }
      }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
S = list(S)
S.reverse()

dp = [[0]*13 for _ in range(N + 1)]
dp[0][0] = 1
mod = 10**9+7
pow10 = 1
for i in range(1, N + 1):
    if S[i-1] == "?":
        for j in range(13):
            for k in range(10):
                dp[i][(j + k*pow10) % 13] += dp[i-1][j]
    else:
        for j in range(13):
            dp[i][(j+int(S[i-1])*pow10) % 13] = dp[i-1][j]
    pow10 = (pow10 * 10) % 13
    for j in range(13):
        dp[i][j] %= mod

print(dp[N][5])

Measured memory_bytes: 64760
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int X=0,Y=0;
    cin>>n;
    bool can=true;
    int T=0;
    while(n--)
    {
        int t,x,y;
        cin>>t>>x>>y;
        int dist=abs(X-x)+abs(Y-y);
        if (!(dist<=t-T && dist%2==(t-T)%2))
            can=false;
    }
    if (can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i] - 1;
    }
    cout << sum << endl;
    return 0;
}

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

int main(){
    int x, y;
    cin >> x >> y;

    if (x > y) {
        cout << "a > b" << endl;
    } else if (x < y) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <unordered_map>
#include <map>
#include <bitset>
#include <string>
#include <cstring>

#define pb push_back
#define mp make_pair
#define l(x) x << 1
#define r(x) x << 1 | 1
#define scan(x) do {while((x=getchar())<'0') ; for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0') ; } while(0)
char _;
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<float, float> pff;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

int N, A, B, h[100005];

bool dead(int t) {
    ll u = 0;
    for (int i = 0; i < N; i++) {
        u += ceil(max(h[i] - 1ll * t * B, 0ll) * 1.0 / (A - B));
    }
    return u <= t;
}

int main() {
    scanf("%d %d %d", &N, &A, &B);
    for (int i = 0; i < N; i++) {
        scanf("%d", &h[i]);
    }
    int lo = 1, hi = 1 << 30, mid = (lo + hi) >> 1;
    while (lo <= hi) {
        if (dead(mid)) {
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
        mid = (lo + hi) >> 1;
    }
    printf("%d\n", lo);
}


Measured memory_bytes: 640
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin >> n;
	cout << !n << endl;
	return 0;	
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    int a[n];rep(i,0,n)cin>>a[i];
    int ma[n];
    int ma2[n];
    ma[0]=a[0];
    ma2[n-1]=a[n-1];
    rep(i,1,n)ma[i]=max(ma[i-1],a[i]);
    rrep(i,n-2,0)ma2[i]=max(ma2[i+1],a[i]);
    rep(i,0,n){
        if(i==0)cout<<ma2[1]<<endl;
        else if(i==n-1)cout<<ma[n-2]<<endl;
        else cout<<max(ma[i-1],ma2[i+1])<<endl;
    }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pair<int,int>>

vector<ll> val, weights;
vector<vector<ll>> mem;
ll n, w;
ll solve(int i, int j){
    if (i<0)
        return 0;
    if (mem[i][j]!=-1)
        return mem[i][j];
    ll x = -1, y = -1;
    x = solve(i-1,j);
    if (j >= weights[i])
        y = solve(i-1,j-weights[i])+val[i];
    mem[i][j] = max(x, y);
    return mem[i][j];
}

int main(){
    ios::sync_with_stdio(0);
    cin >> n >> w;
    val.resize(n);
    weights.resize(n);
    mem.assign(n, vector<ll>(w+1,-1));
    for (int i = 0 ; i < n ; ++i)
        cin >> weights[i] >> val[i];
    cout << solve(n-1, w);
    return 0;
}


Measured memory_bytes: 79488
# input
n, k = (int(i) for i in input().split())
s = input()


# first, end: '1'
def make_chain(l):
    chn = []
    prev = '1'
    chn.append(0)
    for elem in l:
        if elem != prev:
            chn.append(1)
        else:
            chn[-1] += 1
        prev = elem
    if not l[-1] == '1':
        chn.append(0)
    return chn

chn = make_chain(s)

chn_sums = []
sum_len = 2 * k + 1
chn_sum = sum(chn[:sum_len])
chn_sums.append(chn_sum)
for i in range(0, len(chn) - sum_len, 2):
    # drop prev 1st and 2nd, append next 1st ad 2nd
    chn_sum = chn_sum - chn[i] - chn[i+1] + chn[i+sum_len] + chn[i+sum_len+1]
    chn_sums.append(chn_sum)


print(max(chn_sums))


Measured memory_bytes: 5404
//安利少歌
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 510, mod = 998244353;
int n,a[N],b[N],S;

inline int power(int a,int b){
	int ret=1;
	for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
	return ret;
}

int fac[N],ifac[N];
inline void init(){
	fac[0]=1;
	For(i,1,500) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[500]=power(fac[500],mod-2);
	Dow(i,499,0) ifac[i]=1ll*(i+1)*ifac[i+1]%mod;
}

int dp[N][N],Pow[N];
inline void solve(){
	dp[0][0]=mod-1;
	For(i,1,n) Dow(j,S-a[i],0) Dow(k,500,0) if (dp[j][k]){
		Pow[0]=1;
		FOR(l,1,b[i]) Pow[l]=1ll*Pow[l-1]*a[i]%mod;
		FOR(l,0,b[i]) if (k+l<=500){
			dp[j+a[i]][k+l]=(dp[j+a[i]][k+l]-1ll*Pow[l]*dp[j][k]%mod*ifac[l]%mod+mod)%mod;
		}
	}
}

int main(){
	n=read();
	For(i,1,n) a[i]=read(),b[i]=read(),S+=a[i];
	init(),solve();
	int ans=0;
	For(i,1,S){
		int inv=1ll*ifac[i]*fac[i-1]%mod,tmp=1ll*S*inv%mod;
		assert(inv==power(i,mod-2));
		For(j,0,500) ans=(ans+1ll*dp[i][j]*fac[j]%mod*tmp%mod*power(inv,j))%mod;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 4564
#include<cmath>
#include<iostream>
using namespace std;
#define lint long long int

int main(){
    lint N;
    lint count = 0;

    cin >> N;
    lint sqrtN = (lint)sqrt(N)+1;

    for(lint m=2;m<sqrtN;m++){
        if(N/m == N%m){
            count += m;
        }
    }

    for(lint a=1;a<=sqrtN;a++){
        if(N%a == 0){
            lint m = N/a - 1;
            if(m >= sqrtN){
                count += m;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;
 
bool isMM(string x){
    if(x=="00")return false;
    if(x[0]=='0')return true;
    else{
        if(x=="10"||x=="11"||x=="12")return true;
        else return false;
    }
}
signed main(){
    string s;
    cin>>s;

    bool flag0=false,flag1=false;

    if(isMM(s.substr(0,2)))flag0=true;

    if(isMM(s.substr(2,2)))flag1=true;

    if(flag0 && flag1){
        cout<<"AMBIGUOUS"<<endl;
    }else if(!flag0 && !flag1){
        cout<<"NA"<<endl;
    }else if(flag0){
        cout<<"MMYY"<<endl;
    }else{
        cout<<"YYMM"<<endl;
    }


 
}

Measured memory_bytes: 256
import math
from decimal import Decimal
a,b = map(str,input().split())
a = Decimal(a)
b =Decimal(b)
# print('{:.020f}'.format(b))
# print(b)
# b *=100
# b = int(b)
# print(math.floor(a*b/100))
# c = a%10000
# e = math.floor(a / 10000)

# print(int(e*b*10000+c*b))

# c = b-int(b)
# for 
# d = int(b)
# s = a*d+c*a
print(int(math.floor(a*b)))

Measured memory_bytes: 10084
#include<bits/stdc++.h>
#include<utility>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

#define pb push_back
#define PI acos(-1.0)
#define MAX 10000007 //1e7+7
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define __FastIO  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll arr[100005],brr[100005];
vector<ll>V,V1;
/*------------------------------------------------------*/
void solve(ll n){

}
int main(){
  __FastIO;
  ll N,i,j,Test,M,A,B,C,X,Y,Z;
  string s,s1;
  //cin>>Test;
  while(cin>>s){
    cin>>s1;
    ll cnt=0;
    for(i=0;i<s.size();i++){
      if(s[i]==s1[i]){
        cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100005],sum[100005],n,m,ans;
long long check(long long x){
    long long res=0;
    for(int i=1;i<=n;i++){
        int k=lower_bound(a+1,a+1+n,x-a[i])-a-1;
        res+=n-k;
    }
    return res;
}
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    long long l=0,r=200001,res=0;
    while(r>=l){
        long long mid=(l+r)/2;
        if(check(mid)>=m) l=mid+1;
        else r=mid-1; 
    }
    for(int i=1;i<=n;i++){
        int k=lower_bound(a+1,a+1+n,l-1-a[i])-a-1;
        res+=n-k;
        ans+=sum[n]-sum[k]+(n-k)*a[i];
    }
    ans+=(m-res)*(l-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int n,m;
	cin>>n>>m;
	map<int,int> mp;
	map<int,bool> ms;
	ll ans=0;
	ll acs=0;
	while(m--){
		int x;
		string s;
		cin>>x>>s;
		if(s=="AC" && ms[x]==false){
			ans+=mp[x];
			acs++;
			ms[x]=true;
		}
		else if(s=="WA"){
			mp[x]++;
		}
	}
	cout<<acs<<" "<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main()
{
  int a;
  cin >> a ;
  for(int i=9;i>0;i--)
    if(a%i==0){
      a/=i;
      break;
    }
  if(a>=1&&a<=9) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) (x).begin(),(x).end()
#define int ll

#define pt pair<int, int>
#define x first
#define y second

ld dist(pt a, pt b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

bool check(string s) {
	auto t = s;
	reverse(all(t));
	return s == t;
}
#define int ll
void solve() {
	map<int, int> cnt;
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a) {
		cin >> i;
		cnt[i]++;
	}
	int ans = 0;
	for (auto i : cnt) ans += i.second * (i.second - 1) / 2;
	for (auto i : a) {
		cout << ans - cnt[i] * (cnt[i] - 1) / 2 + (cnt[i] - 1) * (cnt[i] - 2) / 2 << endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout.precision(20);
	int t;
	//cin >> t;
	t = 1;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		int n, x, t;
		cin >> n >> x >> t;
		if(cin.fail()) break;
		int ans=(n+x-1)/x*t;
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3596
#include "iostream"

using namespace std;

int main() {


	int a[4] = { 0 };
	int b[4] = { 0 };

	int i;
	int num[5] = { 0 };

	for (i = 1; i < 4; i++) {
		cin >> a[i] >> b[i];

		if (a[i] == 1) num[1]++;
		if (a[i] == 2) num[2]++;
		if (a[i] == 3) num[3]++;
		if (a[i] == 4) num[4]++;
		if (b[i] == 1) num[1]++;
		if (b[i] == 2) num[2]++;
		if (b[i] == 3) num[3]++;
		if (b[i] == 4) num[4]++;

	}

	for (i = 1; i <= 4; i++) {

		if (num[i] > 2) {
			cout << "NO";
			break;
		}

		if(i==4)cout << "YES";
		
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    string s,t;
    cin>>s>>t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n+1,vector<int>(m+1));
    REPN(i,n-1,0) {
        REPN(j,m-1,0) {
            if(s[i]==t[j]) dp[i][j] = 1 + dp[i+1][j+1];
            else dp[i][j] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    string ans = "";
    int x = 0, y = 0;
    while(x<n && y<m) {
        if(s[x]==t[y]) ans += s[x], x++, y++;
        else if(dp[x][y]==dp[x+1][y]) x++;
        else y++;
    }
    cout<<ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 35584
a,b,c,d = map(int, input().split())
cnt1 = 0
cnt2 = 0

while True:
  cnt1 += 1
  c -= b
  if c <= 0:
    break

while True:
  cnt2 += 1
  a -= d
  if a <= 0:
    break
  
if cnt2 < cnt1:
  print("No")
else:
  print("Yes")

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

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <memory>
#include <algorithm>

typedef long long ll;

using namespace std;

class COneQuadrillionAndOneDalmatians {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll a;
	    in >> a;
	    string s = "";
	    while(a > 0) {
	        a -= 1;
	        int r = a % 26;
	        char b = r + 'a';
	        a /= 26;
	        s = b + s;
	    }
	    out << s << endl;
	}
};


int main() {
	COneQuadrillionAndOneDalmatians solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
double pi = acos(-1.0);
const double EPS=1e-9;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define t() ll tt;cin>>tt;while(tt--) 


#define MOD 1000000007


int main()
{
    fastio;
    ll i,j,n,m;
    char x;
    cin>>n>>m;
    vector<vector<ll>>dp(n,vector<ll>(m,0));
    dp[0][0]=1;
    for(i=0;i<n;i++)
    for(j=0;j<m;j++)
    {
        cin>>x;
        if(x=='#') dp[i][j]=0;
        else{
            if(j>0) dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
            if(i>0) dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
        }
    }
    cout<<dp[n-1][m-1];


}

Measured memory_bytes: 11080
#include<stdio.h>

int main(){
  int H,W,i,j;

  while(1){
    scanf("%d %d",&H,&W);
    
	if(H == 0 && W == 0) break;
    
	for(i = 0; i < H; i++){
	  if(i % 2 == 0){
		for(j = 0; j < W; j++)
		  if(j % 2 == 0) printf("#");
		  else printf(".");
	  }else{
	    for(j = 0; j < W; j++)
	      if(j % 2 == 0) printf(".");
		  else printf("#");
	  }
	   printf("\n");
    }
	printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, f[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) {
        int u, v;
        cin >> u >> v;
        f[i] = (u == v);
    }
    FOR(i,3,n)
        if (f[i] && f[i-1] && f[i-2]) {
            cout << "Yes";
            return 0;
        }
    cout << "No";
    return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int t, x;
    cin >> t >> x;

    cout << (double)t / x << '\n';
    return 0;
}


Measured memory_bytes: 3724
def is_odd_binomial(n, m):
    return ((~n) & m) == 0


N = int(input())
a = list(map(lambda x: int(x) - 1, input()))

parity = sum(a[i] for i in range(N) if is_odd_binomial(N - 1, i))
if parity % 2 == 1:
    ans = 1
elif 1 in a:
    ans = 0
elif parity % 4 == 2:
    ans = 2
else:
    ans = 0

print(ans)


Measured memory_bytes: 13696
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> X(N);
	rep(i, N) {
		cin >> X.at(i);
	}
	ll an = 0;
	rep(i, N - 1) {
		an += min(A * (X.at(i + 1) - X.at(i)), B);
	}
	cout << an << endl;


}


Measured memory_bytes: 4032
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> A(100050,0);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    A[a]++;
  }
  int ans=0;
  for(int i=1; i<100000; i++){
    ans = max(ans, A[i-1]+A[i]+A[i+1]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;

string komoji(string& befo) {
  string komo;
  transform(befo.begin(), befo.end(), befo.begin(), ::tolower);
  return befo;
}

int main() {
  string target;
  bool loop = true;
  cin >> target;
  target = komoji(target);
  int counter = 0;
  while (loop) {
    string line;
    getline(cin, line);
    if (line == "END_OF_TEXT") {
      loop = false;
      continue;
    }
    line = komoji(line);
    istringstream iss(line);
    string factor;

    while (getline(iss, factor, ' ')) {
      if (factor == target) {
        counter++;
      }
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 1212
#include<iostream>
using namespace std;int n[100],x,k[100],m,c,i,j,l;
int main(){cin>>m>>c;for(i=0;i<c;i++){cin>>k[i];}
for(i=0;i<c;i++){x=0;for(j=1;j<=m;j++){cin>>l;if(l!=k[i]){x++;}else{n[j]++;}}n[k[i]]+=x;}
for(i=1;i<=m;i++){cout<<n[i]<<endl;}}

Measured memory_bytes: 1164