akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define vl vector
#define inf LONG_MAX
#define gets getline
#define pb push_back
#define pf push_front
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define makestring(x) to_string(x)
#define endl "\n"
#define ss second
#define ff first
#define fast  ios_base::sync_with_stdio(false)
using namespace std;
vl<ll> divisor(ll n)
{
    vl<ll> v;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) 
        {
            if(n/i==i) v.pb(i);
            else
            {
                v.pb(i);
                v.pb(n/i);
            }
        }
    }
    return v;
}

bool isprime(int n)
{
    int i;
    for(i=2;i*i<=n;i++) if(n%i==0) return 0;
    return 1;
}

vl<ll> sieve()
{
    vl<ll> v(1000001);
    int i,j;
    for(i=0;i<1000001;i++) v[i]=1;
    for(i=2;i<=sqrt(1000001);i++) if(v[i]==1) for(j=i*i;j<=1000000;j+=i) v[j]=0;
    v[1]=0;
    return v;
}

string dectobi(ll n)
{
    string s;
    while(n>0)
    {
        if(n&1) s.pb('1');
        else s.pb('0');
        n>>=1;
    }
    reverse(all(s));
    return s;
}

ll power(ll a, ll b, ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b%2) res=(res*a)%m;
        a=(a*a)%m;
        b/=2;
    }
    return res%m;
}

int main()
{
    fast;
    ll c,d,e,sum=0,flag=0,j=0,i=1,count=0;
    ll x,y,o;
    set<char> se;
    ll n,m,t,k,l,r;
    string s;
    cin>>n>>s;
    for(i=0;i<n;i++) se.insert(s[i]);
    if(se.size()==1) 
    {
        cout<<"0";
        return 0;
    }
    for(i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            r=i;
            break;
        }
    }
    l=0;
    while(l<r)
    {
        if(s[l]=='W')
        {
            swap(s[l],s[r]);
            count++;
            while(s[r]!='R')
            {
                if(r==0) break;
                r--;
            }
        }
        l++;
    }
    //cout<<s<<endl;
    cout<<count;
}

Measured memory_bytes: 3780
#include <iostream>

using namespace std;

int main(){

    int n, y;
    cin >> n >> y;

    int ten_thousand = 10000;
    int thousand = 1000;
    int five_thousand = 5000;

    int t_thou = 0;
    int o_thou = 0;
    int f_thou = 0;


    for (int i = n; i >= 0; i--){
        for (int j = n - i; j >= 0; j--){
            for (int k = n - j - i; k >= 0; k--){
                // cout << " i : " << i << ", j : " << j << ", k : " << k << endl;
                if (i + j + k == n){
                    int res = (ten_thousand * i) + (five_thousand * j) + (thousand * k);
                    if (res == y){
                        cout  << i << " " << j << " " << k << endl;
                        return 0;
                    }
                }
            }
        }
    }

    cout  << -1 << " " << -1 << " " << -1 << endl;


    // i : 2, j : 6, k : 1


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 200100;
const int maxl = 27;
int n;
string s[maxn];

string curr;

bool occured[maxl];

class node {
public:
	int cnt[maxl];
	node *child[maxl];

	node() {
		for(int i=0;i<26;i++) {
			cnt[i] = 0;
			child[i] = NULL;
		}
	}

	void insert_word(int d) {
		if(d == sz(curr)) return;

		int ind = int(curr[d] - 'a');

		if(child[ind] == NULL) {
			child[ind] = new node();
		}

		child[ind]->insert_word(d + 1);

		if(!occured[ind]) {
			occured[ind] = true;
			cnt[ind]++;
		}
	}

	void dfs() {
		for(int i=0;i<26;i++) {
			if(child[i] == NULL) continue;
			child[i]->dfs();

			for(int j=0;j<26;j++) {
				cnt[j] += child[i]->cnt[j];
			}
		}
	}

	int query(int letter, int d) {
		if(d == sz(curr) - 1) return cnt[letter];

		int ind = int(curr[d] - 'a');
		return child[ind]->query(letter, d + 1);
	}
};

int main() {
	cin>>n;

	node *root = new node();

	for(int i=1;i<=n;i++) {
		cin>>s[i];
		reverse(s[i].begin(), s[i].end());

		memset(occured, false, sizeof(occured));
		curr = s[i];
		root->insert_word(0);
	}

	root->dfs();

	ll result = 0LL;
	for(int i=1;i<=n;i++) {
		int letter = int(s[i][sz(s[i]) - 1] - 'a');
		curr = s[i];
		//cout<<i<<": "<<root->query(letter, 0)<<"\n";
		result += 1LL * (root->query(letter,0) - 1);
	}
	cout<<result<<"\n";
}

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}
ll LCM(ll x, ll y){
	return x/GCD(x, y)*y;
}

int main() {
	ll n; cin >> n;
	ll num = 26;
	ll sum = 26;
	ll cnt = 1;
	while(sum<n){
		num *= 26;
		sum += num;
		cnt++;
	}
	sum -= num;
	ll dist = n-sum-1;
	vector<char> v;
	rep(i, 0, cnt){
		v.pb(char('a'+dist%26));
		dist /= 26;
	}
	reverse(v.begin(), v.end());
	for(auto vv: v){
		cout << vv;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int p=c-a;
  int q=d-b;
  double norm=p*p+q*q;
  int query;
  scanf("%d",&query);
  while(query--){
    int x,y;
    scanf("%d%d",&x,&y);
    x-=a;
    y-=b;
    double innerNorm=p*x+q*y;
    double xx=p*innerNorm/norm;
    double yy=q*innerNorm/norm;
    double ansX=a-x+2*xx;
    double ansY=b-y+2*yy;
    printf("%.9lf %.9lf\n",ansX,ansY);
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2100
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod1=1744000009,mod2=1744174457,H=1e6+7;
bool isstart[500005];
bool used[500005];
ll ans[500005]={0};
ll pow(ll x,ll y,ll mod){
  if(y==0) return 1;
  ll res=pow(x,y/2,mod);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll solve(vector<bool> vec){
  ll n=vec.size();
  for(int i=0;i<n;i++) vec.push_back(vec[i]);
  ll res=0,cnt=0;
  for(int i=0;i<n*2;i++){
    if(vec[i]) cnt++;
    else{
      res=max(res,cnt);
      cnt=0;
    }
  }
  return max(res,cnt);
}
int main(){
  string s,t;
  cin>>s>>t;
  ll sl=s.length();
  string ns=s;
  ll thash1=0,thash2=0;
  for(int i=0;i<t.length();i++){
    thash1+=(int)(t[i]);
    thash1*=H;
    thash1%=mod1;

    thash2+=(int)(t[i]);
    thash2*=H;
    thash2%=mod2;
  }
  while(ns.length()<=t.length()) ns+=s;
  ns+=s;
  ll shash1=0,shash2=0;
  for(int i=0;i<t.length();i++){
    shash1+=(int)(ns[i]);
    shash1*=H;
    shash1%=mod1;

    shash2+=(int)(ns[i]);
    shash2*=H;
    shash2%=mod2;
  }
  isstart[0]=(shash1==thash1&&shash2==thash2);
  ll mhash1=pow(H,t.length(),mod1),mhash2=pow(H,t.length(),mod2);
  for(int i=1;i<sl;i++){
    shash1-=(mhash1*(int)ns[i-1])%mod1;
    shash1+=mod1;
    shash1+=(int)(ns[i+t.length()-1]);
    shash1%=mod1;
    shash1*=H;
    shash1%=mod1;

    shash2-=(mhash2*(int)ns[i-1])%mod2;
    shash2+=mod2;
    shash2+=(int)(ns[i+t.length()-1]);
    shash2%=mod2;
    shash2*=H;
    shash2%=mod2;

    isstart[i]=(shash1==thash1&&shash2==thash2);
  }

  for(int i=0;i<sl;i++){
    used[i]=false;
  }
  ll ans=0;
  for(int i=0;i<sl;i++){
    if(!used[i]){
      used[i]=true;
      ll pos=i;
      vector<bool> cycle;
      cycle.push_back(isstart[i]);
      pos+=t.length();
      pos%=sl;
      while(!used[pos]){
        cycle.push_back(isstart[pos]);
        used[pos]=true;
        pos+=t.length();
        pos%=sl;
      }
      ll kans=solve(cycle);
      if(kans>=cycle.size()){
        cout<<"-1"<<endl;
        return 0;
      }
      ans=max(ans,kans);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 5812
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K-1] = char(S[K-1] - 'A' + 'a');
    cout << S << endl;
}


Measured memory_bytes: 3516
import sys
read = sys.stdin.buffer.read
input = sys.stdin.readline
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')

from itertools import permutations

#import numpy as np

def main():
	n,c=MI()
	D=[[0]*(c+1)]
	for _ in range(c):
		D.append([0]+LI())
	#print(D)
	
	C=[[0]*(n+1)]
	for _ in range(n):
		C.append([0]+LI())
	#print(C)
	
	li=[[0]*(c+1) for _ in range(3)]
	for i in range(1,n+1):
		for j in range(1,n+1):
			li[(i+j)%3][C[i][j]]+=1
	#print(li)
	
	ans=10**10
	
	for ii in permutations(range(1,c+1),3):
		ret=0
		#print(ii)
		for a in range(3):
			for b in range(1,c+1):
				#print(li[a][b],D[b][ii[a]])
				ret+=li[a][b]*D[b][ii[a]]
		#print(ans,ret)
		ans=min(ans,ret)
	print(ans)
	
	
	
	
	
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 43868
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    int ans = (A + B) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 3208
n,m=list(map(int,input().split()))
city=[]
for i in range(m):
    city.append(list(map(int,input().split()))+[i])
city.sort()
ans=[]
count=0
precity=city[0][0]
for i in city:
    if i[0]==precity:
        count+=1
    else:
        precity=i[0]
        count=1
    ans.append([i[2],str(i[0]).zfill(6)+str(count).zfill(6)])
ans.sort()
for i in ans:
    print(i[1])

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

#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;

#define sqr(a) ((a)*(a))
#define forn(i, n) for(int i = 0; i < (int)n; ++i)
#define rep(i, k, n) for(int i = (int)k; i <= (int)n; ++i)
#define nrof(i, n) for(int i = (int)n - 1; i >= 0; --i)
#define x first
#define y second
#define mp make_pair
#define sz(a) (int)(a.size())
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 1e6 + 9;
const int M = 2e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ll MOD = (ll) (1000000007);


void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    vector<ll> coords = {x % d, x % d + d, x % d - d, x % d - d * 2};
    ll ans = abs(x - k * d);
    for (ll w: coords) {
//        cout << w << endl;
        ll steps = (x - w) / d;
        if (steps <= k && (k - steps) % 2 == 0) {
//            cout << "ok" << endl;
            ans = min(ans, abs(w));
        }
    }
    cout << ans << endl;
}

int main() {
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3648
from bisect import bisect_right
import sys

n = int(input())

if n == 1:
    print(0)
    sys.exit()

x = [1]
for i in range(2, 100):
    x.append(x[-1] + i)

l = []
tmp = n
for i in range(2, int(n**0.5)+1):
    if tmp % i == 0:
        cnt = 0
        while tmp % i == 0:
            tmp //= i
            cnt += 1
        l.append([i, cnt])
if tmp != 1:
    l.append([tmp, 1])
if l == []:
    l.append([n, 1])

res = 0
for v, c in l:
    res += bisect_right(x, c)

print(res)

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

using namespace std;

int main() {
   ios_base :: sync_with_stdio(0);
   cin.tie(0) , cout.tie(0);
   long long a , b , k;
   cin >> a >> b >> k;
   long long delta1 = min(a , k);
   k -= delta1;
   a -= delta1;
   if (k != 0) {
      long long delta2 = min(b , k);
      b -= delta2;
      k -= delta2;
   }
   cout << a << " " << b << '\n';
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

int main()
{
	int N, n0=0, n1=0, n2=0, n3=0;
	long long int W, w, v, w1, vmax=0;
	multiset<long long int> v0, v1, v2, v3;
	long long int v0s[101],v1s[101],v2s[101],v3s[101];
	scanf("%d %lld", &N, &W);
	for(int i=0; i<N; i++){
		scanf("%lld %lld", &w, &v);
		if(i==0){
			w1=w;
			v0.insert(v);
			n0++;
		}else if(w==w1){
			v0.insert(v);
			n0++;
		}else if(w==w1+1){
			v1.insert(v);
			n1++;
		}else if(w==w1+2){
			v2.insert(v);
			n2++;
		}else{
			v3.insert(v);
			n3++;
		}
	}
	v0s[0]=0, v1s[0]=0, v2s[0]=0, v3s[0]=0;
	if(n0!=0){
	auto itr=v0.end();
	int k=0;
	while(itr!=v0.begin()){
		itr--;
		k++;
		v=*itr;
		v0s[k]=v0s[k-1]+v;
	}
	}
	if(n1!=0){
	auto itr=v1.end();
	int k=0;
	while(itr!=v1.begin()){
		itr--;
		k++;
		v=*itr;
		v1s[k]=v1s[k-1]+v;
	}
	}
	if(n2!=0){
	auto itr=v2.end();
	int k=0;
	while(itr!=v2.begin()){
		itr--;
		k++;
		v=*itr;
		v2s[k]=v2s[k-1]+v;
	}
	}
	if(n3!=0){
	auto itr=v3.end();
	int k=0;
	while(itr!=v3.begin()){
		itr--;
		k++;
		v=*itr;
		v3s[k]=v3s[k-1]+v;
	}
	}
	long long int x0;
	for(long long int x1=0; x1<=n1; x1++){
		for(long long int x2=0; x2<=n2; x2++){
			for(long long int x3=0; x3<=n3; x3++){
				if(x1*(w1+1)+x2*(w1+2)+x3*(w1+3)<=W){
					x0=(W-(x1*(w1+1)+x2*(w1+2)+x3*(w1+3)))/w1;
					if(x0>n0){
						x0=n0;
					}
					if(vmax<v0s[x0]+v1s[x1]+v2s[x2]+v3s[x3]){
						vmax=v0s[x0]+v1s[x1]+v2s[x2]+v3s[x3];
					}
				}
			}
		}
	}
	printf("%lld\n", vmax);

	return 0;
}

Measured memory_bytes: 256
N = int(input())

B = list(map(int,input().split()))

ans = []
for k in range(N):
    flag = 1
    for i in range(len(B)):
        j = len(B)-i-1
        if j+1 == B[j]:
            ans.insert(0,B[j])
            B.pop(j)
            flag = 0
            break
    if flag == 1:
        ans = -1
        break

if ans == -1:
    print(ans)
else:
    for a in ans:
        print(a)


Measured memory_bytes: 38896
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
A.append(0)

plan=[]
for i in range(N+1):
  plan.append(abs(A[i+1]-A[i]))

total=sum(plan)
for i in range(N):
  ans=total-plan[i]-plan[i+1]+abs(A[i+2]-A[i])
  print(ans)

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

int main()
{
    long int N, output_count,i_plus;
    int input[200000];
    int output[200000];
    int mem[200000]={};
    //int surplus[200000] = {};
    int ball;
    cin >> N;
    for(long int i=0; i<N; i++){
        cin >> input[i];
    }
    output_count = 0;
    for(long int i=N-1; i>=0; i--){
        i_plus = i+1;
        if(i_plus > N/2){
            if(input[i] == 1){
                output[output_count] = i+1;
                output_count++;
                mem[i] = 1;
            }
        }
        else{
            ball = input[i];
            for(long int j=1; j<=N+1; j++){
                if(i_plus*j>N){
                    break;
                }else if(mem[i_plus*j-1] == 1){
                    ball = !ball;
                }
            }
            if(ball == 1){
                output[output_count] = i+1;
                output_count++;
                mem[i] = 1;
            }
        }
    }
    cout << output_count << endl;
    for(long int i=0; i<output_count; i++){
        cout << output[i];
        if(i < output_count-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3072
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    if(s[i]==t[i]);
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;


return 0;
}
///....


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string a,b;
    cin>>a;
    cin>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
//~ #pragma GCC optimize("O3")
//~ #pragma GCC optimize("Ofast")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//~ #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

void yes()
{
  cout<<"Yes";
  exit(0);
}

int main()
{
	_upgrade
  int a, b, c;
  cin>>a>>b>>c;
  if(a == b && b == c)
    cout<<"Yes";
  else
    cout<<"No";


	return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;
typedef pair<int, int> PII;

int WA[10][50];

int main()
{
  int M, T, P, R;
  while (cin>>M>>T>>P>>R, M||T||P||R) {
    memset(WA, 0, sizeof(WA));
    vector<pair<PII, int>> score(T);
    for (int i=0; i<T; i++) {
      score[i].second = -(i+1);
    }

    for (int r=0; r<R; r++) {
      int m, t, p, j;
      cin>>m>>t>>p>>j;
      t--, p--;

      if (!j) {
        //cout << "Team = " << t << ", AC = " << score[t].first.first << endl;

        // AC
        score[t].first.first--;
        score[t].first.second += m + 20*WA[p][t];
      } else {
        // WA 
        WA[p][t]++;
      }
    }

    sort(score.begin(), score.end());
    for (int i=0; i<score.size(); i++) {
      if (i>0) {
        if (score[i].first.first == score[i-1].first.first && score[i].first.second == score[i-1].first.second) cout << "=";
        else cout << ",";
      }
      cout << -score[i].second;
    }
    cout << endl;
  } 
}

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

int main(){
  long long q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;
  
  if(2*q < h) h = 2*q;
  if(2*h < s) s = 2*h;
  if(2*s < d) d = 2*s;
  
  long long ans = 0;
  ans += n/2 * d + n%2 * s;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool st(int a,int b)
{
    return a>b;
}
main()
{ vector<int>ans;
    int a,b,k,tmp;
    cin>>a>>b>>k;
    tmp=__gcd(a,b);
    for(int i=1;i<=tmp;i++)
    {
        if(tmp%i==0)
        {
            ans.push_back(i);
        }
    }
    sort(ans.begin(),ans.end(),st);
    cout<<ans[k-1]<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

string numstring(int num){
  string s;
  for(int i=0; i<6; ++i){
    s += (char)('0'+ num%10);
    num /= 10;
  }
  reverse(s.begin(),s.end());
  return s;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<P>> city(n+1);
  for(int i=1; i<=m; ++i){
    int pi, yi;
    cin >> pi >> yi;
    city[pi].push_back(make_pair(yi,i));
  }
  vector<string> ans(m+1);
  for(int i=1; i<=n; ++i){
    if(city[i].size() == 0) continue;
    sort(city[i].begin(),city[i].end());
    
    string PFs = numstring(i);
    int citynum = 1;
    for(auto pj: city[i]){
      string Citys = numstring(citynum);
      ++citynum;
      ans[pj.second] = PFs + Citys;
    }
  }
  for(int i=1; i<=m; ++i){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 11744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int main() {
    int N; cin>>N;
    vector<int> a,b(N);
    for (int i = 0; i < N; ++i) {
        cin>>b[i];
    }

    for (int i = 0; i < N; ++i) {
        if(i+1<b[i]){
            cout<<-1<<endl;
            return 0;
        }
        a.insert(a.begin()+b[i]-1,b[i]);

    }

    for (auto i:a) {
        cout<<i<<endl;
    }

    return 0;
}


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

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

int main() {
  ll h,n;
  cin>>h>>n;
  vector<ll> w(n),v(n);
  rep(i,n) cin>>w[i]>>v[i];
  ll dp[h+1];
  rep(i,h+1) dp[i]=1e11;
  dp[0]=0;
  rep(i,n) rep(j,h+1) chmin(dp[min(j+w[i],h)],dp[j]+v[i]);
  cout<<dp[h]<<endl; 
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 998244353
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll h,w; cin >> h >> w;
    char s[h][w];
    rep(i,h) rep(j,w) cin >> s[i][j];
    char ans[h+2][w+2];
    rep(i,h+2){
        rep(j,w+2){
            if(i==0 || i==h+1){
                ans[i][j] = '#';
                continue;
            }
            if(j==0 || j==w+1) ans[i][j] = '#';
            else ans[i][j] = s[i-1][j-1];
        }
    }
    rep(i,h+2){
        rep(j,w+2) cout << ans[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a[5], roop1, roop2, tmp;

  for (roop1 = 0; roop1 < 5; roop1++) {
    scanf("%d", &a[roop1]);
  }

  for (roop1 = 0; roop1 < 5; roop1++) {
    for (roop2 = roop1 + 1; roop2 < 5; roop2++) {

      if (a[roop1] < a[roop2]) {
        tmp = a[roop1];
        a[roop1] = a[roop2];
        a[roop2] = tmp;
      } else {
      }

    }
  }

  printf("%d %d %d %d %d\n", a[0], a[1], a[2], a[3], a[4]);
  return 0;
}

Measured memory_bytes: 596
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var bb = ToIntArray(input.ReadLine(), n);

        Node no = null;
        foreach(var b in bb) {
            var node = new Node();
            node.v = b;
            node.prev = no;
            if(no != null) no.next = node;
            no = node;
        }

        Node last = no;

        var stack = new Stack<int>();

        for(int i=n; i>0; i--) {
            Node node = last;
            int j = i;
            while(node != null && node.v != j) {
                node = node.prev;
                j--;
            }

            if(node == null){
                return -1;
            }

            if (node.prev != null) node.prev.next = node.next;
            if (node.next != null) node.next.prev = node.prev;
            if (node.next == null) last = node.prev;

            stack.Push(j);
        };

        StringBuilder sb = new StringBuilder();
        while(stack.Any()) sb.AppendLine(stack.Pop().ToString());

        return sb;
    }


    class Node
    {
        public int v;
        public Node next;
        public Node prev;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VL primes(int n){
    vector<bool> a(n+1, 1);
    VL p;
    FOR(x,2,n){
        if (!a[x]) continue;
        p.push_back(x);
        for (int y = 2 * x; y <= n; y += x) a[y] = 0;
    }
    return p;
}

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

    VL p = primes(1e6);
    VL ans;
    for (int i = 0; i < p.size() && ans.size() < n; ++i){
        if (p[i] % 5 == 1) ans.push_back(p[i]);
    }
    for (ll x : ans) cout << x << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
           var num = long.Parse(Console.ReadLine()) ;
            var ans = num;
            if(ans % 2 == 0)
            {
                Console.WriteLine(ans.ToString());
            }
            else
            {
                Console.WriteLine((ans*2).ToString());

            }
        }
    }
}


Measured memory_bytes: 11220
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

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

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	string res = "NG";
	for (ll i = a; i <= b; i++)
	{
		if (i % k == 0)
		{
			res = "OK";
		}
	}

	println(res);
}

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

int main() {
  int s, a, b, c, x;
  cin >> s;
  // sの100の位
  a = s / 100;
  // sの10の位
  b = (s / 10) % 2;
  // sの1の位
  c = s % 2;
  x = a + b + c;
  cout << x << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
c = a * b
d = min(a, b)
j = 1
for i in range(2, d + 1):
    j += 1
    if a % j == 0 and b % j == 0:
        c //= j
        a //= j
        b //= j
        j = 1
print(c)

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

using namespace std;
typedef long long ll;
const int MAX = 1000010;
ll mod = 998244353;
vector<ll> gcd_trans(vector<ll> &v){
	int i,j,n = v.size();
	vector<bool> used(n,true);
	for(i=2;i<n;i++){
		if(!used[i]) continue;
		for(j=(n - 1)/i;j>=1;j--){
			used[j*i] = false;
			(v[j] += v[j*i]) %= mod;
		}
	}
	return v;
}

vector<ll> inv_gcd_trans(vector<ll> &v){
	int i,j,n = v.size();
	vector<bool> used(n,true);
	for(i=2;i<n;i++){
		if(!used[i]) continue;
		for(j=1;j*i<n;j++){
			used[j*i] = false;
			v[j] -= v[j*i];
			if(v[j]<0) v[j] += mod;
		}
	}
	return v;
}

ll inv[MAX],fact[MAX],fi[MAX];
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

vector<ll> a(MAX),b(MAX);
ll ans = 0;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
		(b[a[i]] += a[i]) %= mod;
	}
	vector<ll> c = gcd_trans(b);
	for(i=1;i<MAX;i++){
		(c[i] *= c[i]) %= mod;
	}
	vector<ll> b = inv_gcd_trans(c);
	for(i=0;i<n;i++){
		(b[a[i]] += (mod - (a[i]*a[i])%mod)) %= mod;
	}
	inverse();
	for(i=1;i<MAX;i++){
		(ans += b[i]*inv[i]%mod) %= mod;
	}
	(ans *= inv[2]) %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 55040
#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
//using arr = array;
using pi = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1<<18, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, a[maxn];
vi g[maxn];
ll dfs(ll v, ll p) {
	ll sm = 0, m = 0;
	for(auto &i : g[v]) {
		if(i == p) continue;
		ll t =  dfs(i, v);
		sm += t;
		m = max(m, t); 
	}
	if(g[v].size() == 1) return a[v];
	ll x = sm - a[v];
	if(x < 0 || x > sm-m || sm - 2*x < 0) {cout << "NO", exit(0);}
	return sm - 2*x;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int f, t, i = 1; i < n; i++) {
		cin >> f >> t;
		g[f].pb(t);
		g[t].pb(f);
	}
	if(n == 2) return cout << (a[1] == a[2] ? "YES" : "NO"), 0;
	int r = 1;
	while(g[r].size()<2) r++;
	cout << (dfs(r, r) ? "NO" : "YES");
}


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

int main(){
    ll N, W; cin >> N >> W;
    ll w[N+1], v[N+1];
    for (ll i=1; i<N+1; i++){
        cin >> w[i] >> v[i];
    }

    ll dp[N+1][W+1];
    for (ll i=0; i<=N; i++) dp[i][0] = 0;
    for (ll j=0; j<=W; j++) dp[0][j] = 0;

    for (ll i=1; i<N+1; i++){
        for (ll j=1; j<W+1; j++){
            if (j>=w[i]) dp[i][j] = max(v[i]+dp[i-1][j - w[i]], dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    cout <<  dp[N][W] << endl;

    return 0;
}

Measured memory_bytes: 79104
n,m=map(int,input().split())
ans=0
left=[]
right=[]
for i in range(m):
  l,r=map(int,input().split())
  left.append(l)
  right.append(r)
if min(right)-max(left)+1<0:
  ans=0
else:
  ans=min(right)-max(left)+1
print(ans)

Measured memory_bytes: 10996
N = gets.chomp.to_i
a = "abcdefghij"
b = Array.new(N,0)
c = Array.new(N,0)
n = 1
if N == 1
    puts "a"
    exit
end
while b[0] == 0
    m = 0
    while m < N
        x = b[m]
        print a[x]
        m += 1
    end
    puts
    b[-1] += 1
    if b[-1] > c[-1] + 1
        b[-1] = 0
        b[-2] += 1
        c[-1] = b[-2] > c[-1] ? b[-2] : c[-1]
        n = 2
        while b[-n] > c[-n] + 1
            l = n+1
            b[-n] = 0
            b[-l] += 1
            c[-n] = b[-l] > c[-n] ? b[-l] : c[-n]
            n += 1
        end
        n -= 2
        while n >= 1
            c[-n] = c[-n-1]
            n -= 1
        end
    end
end

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k)
    {
        cout << ":(" << endl;
        return 0;
    }
    cout << "Yay!";
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;


int main(void) {
   ll L,R;
   ll DIV = 2019;
   cin>>L>>R;
   if (L/DIV != R/DIV) {
      cout<<0<<endl;
      return 0;
   }
   L = L%DIV;
   R = R%DIV;
   ll ans = DIV * 10;
   for (ll i = L;i<=R;i++) {
      for (ll j = i+1;j<=R;j++) {
         ans = min(ans,(i*j)%DIV);
      }
   }
   cout<<ans<<endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
using namespace std;

int main(){
  string S;
  ll Q;
  cin>>S>>Q;
  vector<char> F,B;
  bool f=true;
  for(ll i=0;i<Q;i++){
    int a;
    cin>>a;
    if(a==1){
      if(f) f=false;
      else if(!f) f=true; 
    }else if(a==2){
      int b;
      cin>>b;
      char c;
      cin>>c;
      if(b==1){
        if(f) F.push_back(c);
        else B.push_back(c);
      }else if(b==2){
        if(f) B.push_back(c);
        else F.push_back(c);
      }
    }
  }
  if(!f) reverse(S.begin(),S.end());

  if(f){
    for(ll i=F.size()-1;i>=0;i--) cout<<F[i];
    cout<<S;
    for(ll i=0;i<B.size();i++) cout<<B[i];
    cout<<endl;
  }else{
    for(ll i=B.size()-1;i>=0;i--) cout<<B[i];
    cout<<S;
    for(ll i=0;i<F.size();i++) cout<<F[i];
    cout<<endl;
  }
}

Measured memory_bytes: 1024
import qualified Data.Map.Strict as Map

main = do
    [rows, columns] <- fmap (fmap read . words) getLine
    allLetters <- buildMap . concat <$> mapM (const getLine) [1..rows]
    let numFours = sum . fmap (`div` 4) $ allLetters
    let numPairs = sum . fmap (`div` 2) $ allLetters
    let neededFours = if rows > 1 && columns > 1 then ((rows * columns - (if odd rows then columns else 0) - (if odd columns then rows else 0) + (if odd rows && odd columns then 1 else 0)) `div` 4) else 0
    let neededColumnPairs = if odd rows then columns `div` 2 else 0
    let neededRowPairs = if odd columns then rows `div` 2 else 0
    let remainingPairs = numPairs - neededFours * 2
    if numFours >= neededFours && remainingPairs >= (neededColumnPairs + neededRowPairs) 
        then putStrLn "Yes" 
        else putStrLn "No"
    
buildMap = foldl (\m c -> Map.insertWith (+) c 1 m) Map.empty

Measured memory_bytes: 1404
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, m;
int a[100000];

int main(){
    I(n);
    rep(i,n) I(a[i]);
    int now = 0;
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(a[i] == a[i-1]) continue;
        if(a[i] > a[i-1]){
            if(now == -1){
                ans++;
                now = 0;
                continue;
            } else{
                now = 1;
            }
        } else{
            if(now == 1){
                ans++;
                now = 0;
                continue;
            } else{
                now = -1;
            }
        }
    }
    cout << ans << endl;
}
































Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

int main(){
	int a,b; cin >>a>>b;
	if(abs(a-b)%2){
		cout << "IMPOSSIBLE\n";
	}else{
		cout <<  (a+b)/2 << endl;
	}
}

Measured memory_bytes: 3612
# -*- coding: utf-8 -*-

s = list(str(input()))

a_start = 0
z_end = 0

# A の探索
for i in range(len(s)):
    if s[i] == 'A':
        a_start = i
        break

# Z の探索
for i in reversed(range(len(s))):
    if s[i] == 'Z':
        z_end = i
        break

print(len(s[a_start:z_end+1]))

Measured memory_bytes: 11928
#include <iostream>
using namespace std;
int dp[101][10001];

int main(void){
    // Your code here!
    int n,W,w[101],v[101];
    cin >> n >> W;
    for(int i=0;i<n;i++) cin >> v[i] >> w[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(j < w[i]) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j-w[i]] + v[i],dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 6988
#include <iostream>
// #include <cstdio>
#include<set>
#include<math.h>
#include<list>
#include<vector>
using namespace std;
 
int main(){
	long arr[10001];
	int n, m=0, ans=0;

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

	while(m < n){
		if (arr[m] % 2 == 0){
			arr[m] = arr[m] / 2;
			ans++;
		} else {
			m++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
//  cout.precision(15); cout << fixed;

typedef pair<ll, ll> P;

int main() {
  int n; cin >> n;
  vector<int> A(n); loop(i,0,n) cin >> A[i];
  int min_ = 2000, max_ = 0;
  for (auto a: A) {
    if (min_ > a) min_ = a;
    if (max_ < a) max_ = a;
  }
  cout << max_ - min_ << endl;
  return 0;
}


Measured memory_bytes: 3544
def readinput():
    w,h,x,y=map(int,input().split())
    return w,h,x,y

def main(w,h,x,y):
    s=w*h/2
    center=0
    if 2*x==w and 2*y==h:
        center=1
    return s,center

if __name__=='__main__':
    w,h,x,y=readinput()
    ans=main(w,h,x,y)
    print(ans[0],ans[1])


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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    auto canSolve = [&](int a, int b, int c, int d) {
        int sugar = (c * C) + (d * D);
        int water = (a * A * 100) + (b * B * 100);
        return water * E >= 100 * sugar;
    };

    auto concentration = [&](int a, int b, int c, int d) {
        int sugar = (c * C) + (d * D);
        int water = (a * A * 100) + (b * B * 100);
        return (100.0 * sugar) / (water + sugar);
    };

    double par = 0;
    int sugar = 0, sugar_water = 0;
    for (int a = 0; a * A * 100 <= F; a++) {
        int aw = a * A * 100;
        for (int b = 0; aw + (b * B * 100) <= F; b++) {
            int bw = b * B * 100;
            for (int c = 0; aw + bw + (c * C) <= F&& canSolve(a, b, c, 0); c++) {
                int cs = c * C;
                for (int d = 0; aw + bw + cs + (d * D) <= F&& canSolve(a, b, c, d); d++) {

                    double p = concentration(a, b, c, d);
                    if (p >= par) {
                        par = p;
                        sugar = (c * C) + (d * D);
                        sugar_water = (a * A * 100) + (b * B * 100) + (c * C) + (d * D);
                    }
                }
            };
        }
    }

    cout << sugar_water << ' ' << sugar << endl;

}


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

int N, K, a[200005];

signed main(){
  
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
    int num;
    cin>>num;
    a[num]++;
  }
  
  priority_queue<int,vector<int>,greater<int> > q;
  
  int cnt=0;
  
  for(int i=0;i<200005;i++)
    if(a[i]){
      cnt++;
      q.push(a[i]);
    }
  
  int ans=0;
  
  while(cnt>K){
    int p=q.top(); q.pop();
    ans+=p;
    cnt--;
  }
  
  cout<<ans<<endl;
  
  return 0;
}


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

int main()
{
    int N, K;
    std::vector<int> h;
    cin >> N >> K;
    for(int i=0; i<N; i++)
    {
        int x;
        cin >> x;
        h.push_back(x);
    }
    int count = 0;
    for(int i=0; i<h.size(); i++)
    {
        if (h[i]>=K) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 892
import math

def get_input():
    return int(input())

def max_profit(inputs):
  a = inputs[0]
  l = inputs[1:]
  r = 10 ** 10 * -1
  for i in l:
    p = i - a
    if p > r:
      r = p
    if i < a:
      a = i
  
  return r

n = get_input()
inputs = []
for _ in range(n):
  inputs.append(get_input())

# print(*inputs, sep=',')

print(max_profit(inputs))



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

#define ll long long
#define PB push_back
#define MP make_pair
#define PF push_front
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define ft first
#define sc second

#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(i, a, b, c) for(int i = (a); i <= (b); i += (c))
#define FORL(i, a, b) for(int i = (a); i < (b); i++)
#define ROF(i, a, b) for(int i = (a); i >= (b); i--)
#define ROFL(i, a, b) for(int i = (a); i > (b); i--)
#define LLFOR(i, a, b) for(ll i = (a); i <= (b); i++)
#define LLFORL(i, a, b) for(ll i = (a); i < (b); i++)
#define LLROF(i, a, b) for(ll i = (a); i >= (b); i--)
#define LLROFL(i, a, b) for(ll i = (a); i > (b); i--)


using namespace std;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;

const int mod = 1e9 + 7;
const double PI = acos(-1);

template<typename T>
T exp(T x,ll n){
    if(n == 0) return 1;
    if(n == 1) return x;
    if(n%2 == 0) return exp((x*x)%mod,n/2);
    if(n%2 == 1) return (x*exp((x*x)%mod,n/2))%mod;
}

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

     if((b>0) && (d>0)) cout << max(b*d, a*c);
     else if((b<0) && (d<0)) cout << a*c;
     else if((b==0) && (d==0)) cout << a*c;
     else if((b>0) && (d<0)){
        if(a > 0) cout << a*d;
        else cout << c*a;
     }
     else if((b<0) && (d>0)){
        if(c > 0) cout << b*c;
        else cout << a*c;
     }
     else if(((b==0) || (d==0)) && ((a>0) || (c>0)) && ((b>0) || (d>0))) cout << "0";
     else if(((b==0) || (d==0)) && ((a<0) || (c<0)) && ((b<0) || (d<0))) cout << a*c;

    return 0;
}


Measured memory_bytes: 3680