akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //int N = Integer.parseInt(scan.next());
        int N = Integer.parseInt(scan.next());
        int T = Integer.parseInt(scan.next());
        int A = Integer.parseInt(scan.next());
        int[] h = new int[N];
        double[] ave = new double[N];
        double[] delta = new double[N];
        double tmp = 1000;
        int out=-1;
        for(int i = 0;i<N;i++){
            h[i] = Integer.parseInt(scan.next());
            ave[i] = T-(h[i]*0.006);
        }
        for(int i = 0;i<N;i++){
            delta[i] = Math.abs(A-ave[i]);
            if(tmp>=delta[i]){
                tmp = delta[i];
                out = i;
            }
        }
        System.out.println(out+1);
    }
}

Measured memory_bytes: 23380
//Simple Calculator

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "

using p = pair<ll,string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int a,b;cin>>a>>b;
    if(a*b>0){
        if(a<b){
            cout<<b-a<<nnn;
        }else{
            cout<<a-b+2<<nnn;
        }
    }else if((a==0&&b<0)||(b==0&&a>0)){
        cout<<abs(b-a)+1<<nnn;
    }else{
        cout<<min(abs(a-b),abs(-a-b)+1)<<nnn;
    }
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()

I=[0]

for i in range(n-1):
    if s[i]!=s[i+1]:
        I.append(i+1)
        
r=len(I)

for _ in range(10**6):
        I.append(n)

X=[]

for i in range(r):
    if s[I[i]]=='0':
        X.append(I[i+2*k]-I[i])
    else:
        X.append(I[i+2*k+1]-I[i])

print(max(X))
    

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

using namespace std;

int N,M,X;
int A[105];

int main(){

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

cin>>N>>M>>X;

for(int i=0; i<M; i++) cin>>A[i];

int cost1=0,cost2=0;
for(int i=0; i<M; i++){
  if(A[i]<X) cost1++;
  if(A[i]>X) cost2++;
}

cout<<min(cost1,cost2)<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define u unsigned
#define me(a,x) memset(a,x,sizeof(a))
#define sf scanf
#define pf printf
const int mod=1e9+7;
using namespace std;
char a[200005];
int main()
{
	int n,i,sum=0,ci=0;
	sf("%d",&n);
	sf("%s",&a);
	for(i=0;i<n;i++){
		if(a[i]=='R'){
			sum++;
		}
	}
	for(i=0;i<sum;i++){
		if(a[i]=='W'){
			ci++;
		}
	}
	pf("%d\n",ci);
	return 0;
}


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

int main()
{
    ll n, k;
    cin >> n >> k;
    priority_queue<ll> que;
    rep(i, n){
        ll a;
        cin >> a;
        que.push(a);
    }
    rep(i, k){
        ll a = que.top();
        que.pop();
    }
    ll ans = 0;
    for(int i = 0; i < n-k; i++){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    system("pause");
}

Measured memory_bytes: 2420
#include <stdio.h>
int main(void)
{
    int n,i;
    double s;
    scanf("%d",&n);
    
    
    s = 0.0;
    for(i=1;i<=n;i++){
        if((i % 3 != 0) && (i % 5 != 0))
        s = s + (double)i;
    }
    printf("%.0lf",s);
    return 0;
}

Measured memory_bytes: 1732
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

x,y=map(int,input().split())
if (x+y)%3!=0 or min(x,y)<(x+y)/3:
    print(0)
    exit()
n=(x+y)//3
r=(n-abs(x-y))//2
mod=10**9+7
a = cmb(n,r)
print(a%mod)

Measured memory_bytes: 102028
#include <bits/stdc++.h>
using namespace std;
#define rep0(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rep1(i,n) for(long long i=1;i<=(long long)(n);i++)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main() {
    ll N;
    cin>>N;
    vector<ll> A(N),s;
    rep0(i,N){cin>>A[i];}
    sort(all(A));
    reverse(all(A));
    
    
    rep0(i,N-1){if(A[i]==A[i+1]){s.push_back(A[i]); i++;}}
    
    if(s.size()>=2){cout<<s[0]*s[1]<<endl;}
  else{cout<<0<<endl;}
    
}


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

int main() {
  int N, M; cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < M; i++) cin >> B.at(i);
  for (int j = 0; j < N-M+1; j++) {
    for (int i = 0; i < N-M+1; i++) {
      bool match = true;
      for (int y = 0; y < M; y++) {
        for (int x = 0; x < M; x++) {
          if (A.at(j+y).at(i+x) != B.at(y).at(x)) match = false;
        }
      }
      if (match) { cout << "Yes" << endl; return 0; }
    }
  }
  cout << "No" << endl;
}

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

int main() {
    while(true){
    int t;
    cin >> t;
    if (t==0) break;
    for (int o=0;o<t;o++){
    vector<int> a(2),b(2),c(2),d(2);

    rep(k,2){
        cin >> a.at(k) >> b.at(k) >> c.at(k) >> d.at(k);
    }
    int aa=a.at(0),bb=b.at(0),cc=c.at(0),dd=d.at(0);
    rep(i,1){
        int al,bl,cl,dl;
        al=aa*a.at(i+1)-bb*b.at(i+1)-cc*c.at(i+1)-dd*d.at(i+1);
        bl=aa*b.at(i+1)+bb*a.at(i+1)+cc*d.at(i+1)-dd*c.at(i+1);
        cl=aa*c.at(i+1)-bb*d.at(i+1)+cc*a.at(i+1)+dd*b.at(i+1);
        dl=aa*d.at(i+1)+bb*c.at(i+1)-cc*b.at(i+1)+dd*a.at(i+1);
        aa=al;bb=bl;cc=cl;dd=dl;
    }
  cout << aa << " " << bb << " " << cc << " " << dd << endl;
    }
    }
}


Measured memory_bytes: 3092
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
    
N = int(input())
lst = list(map(int, input().split(' ')))

v = sorted(lst)[-1]

for x in lst:
    v = gcd(v, x)
    
print(v)

Measured memory_bytes: 14252
#include<iostream>
using namespace std;
int main(){
    int n,s;
	cin>>n>>s;
    if(s % 1000 != 0) {
        printf("-1 -1 -1\n");
    } else {
        s /= 1000;
        for(int i = 0;i <= 2000;i++) {
            for(int j = 0;j <= 1000;j++) {
                if(i + j*5 > s) {
                    continue;
                }
                if( ((s - (i + j*5)) % 10 == 0 ) ) {
                    if(i + j + ((s - (i + j*5))/10) == n) {
                        printf("%d %d %d\n",((s - (i + j*5))/10),j,i);
                        return 0;
                    }
                }
            }
        }
        printf("-1 -1 -1\n");
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    mn = min(C)
    mx = max(C)
    if mx - mn < 0 or 1 < mx - mn:
        print("No")
        return
    elif mx - mn == 0:
        if mx == N - 1:
            neccessary = N
        else:
            neccessary = mx * 2
    elif mx - mn == 1:
        single = C[mn]
        if mx <= single:
            print("No")
            return
        neccessary = single + (mx - single) * 2
    if neccessary <= N:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61548
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(){
	int n;
	int sum=0;
	cin>>n;
	int copy=n;
	while(n!=0){
		sum=sum+n%10;
		n=n/10;
	}
	if(copy%sum==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

	vector<int> Rs(26, -1), Rt(26, - 1);

	for (int i = 0; i < S.length(); i++) {
		if (Rs[S[i] - 97] == -1) {
			Rs[S[i] - 97] = T[i];
		}
		else if (Rs[S[i] - 97] != T[i]) {
			cout << "No";
			return 0;
		}
	}

	for (int i = 0; i < T.length(); i++) {
		if (Rt[T[i] - 97] == -1) {
			Rt[T[i] - 97] = S[i];
		}
		else if (Rt[T[i] - 97] != S[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;
int main() 
{
    int n, i;
    cin>>n;
    vector<int> h(n);
    for(i=0;i<n;i++) {
        cin>>h[i];
    }
    vector<int> dp(n, -1);
    dp[0]=0;
    for(i=0;i<n;i++) {
        if(i+1<n && dp[i+1]==-1) {
            dp[i+1] = dp[i] + abs(h[i+1]-h[i]);
        }
        else if(i+1<n && dp[i+1]!=-1) {
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
        }
        if(i+2<n && dp[i+2]==-1) {
            dp[i+2] = dp[i] + abs(h[i+2]-h[i]);
        }
        else if(i+2<n && dp[i+2]!=-1) {
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
return 0;
}

Measured memory_bytes: 4032
//B 0 or 1 Swap
#include<bits/stdc++.h>
using namespace std;

int main()
{
  int n,count;
  cin>>n;
  count=0;
  vector<int> vec(n);
  for(int i=0;i<n;i++)
  {
    cin>>vec.at(i);
  }
  for(int i=0;i<n;i++)
  {
    if(vec.at(i)!=i+1)
    {
      count++;
    }
  }
  if(count==0||count==2)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


string s;

int main(){
	cin >> s;
	ll cnt = 0;
	int n = s.size();
	for(int i = 0; i < n; i++){
		if(s[i] == 'W') cnt++;
	}
	ll a = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'W') cnt--;
		else{
			a += cnt;
		}
	}
	cout << a << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int p=0,f=1; char c=getchar();
	while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar();}
	while(c>='0'&&c<='9'){ p=(p<<3)+(p<<1)+(c^48); c=getchar();}
	return f*p;
}
int ans1,ans2,minn;
bool z[100001];
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='1') z[i+1]=1;
		else z[i+1]=0;
	for(int i=1;i<=s.size();i++){
		if(z[i]==i%2) ans1++;
		else ans2++;
	}
	minn=min(ans1,ans2);
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string p;
    cin >> p;

    p == s ? a-- : b--;
    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll mod =1e9+7;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=	(a*a)%mod;b>>=1;}return (res%mod);}
const int N = 2e5 + 5 ;

ll arr[N];
void solve(){
	ll n;
	cin>>n;
	memset( arr,0,sizeof ( arr));
	ll s=0;
	for ( ll i=0;i<n;i++){
		ll aa;
		cin>>aa;
		s+=aa;
		arr[aa]++;
	}
	ll q;
	cin>>q;
	while ( q--){
		ll aa,bb;
		cin>>aa>>bb;
		s-=arr[aa]*aa;
		s+=bb*arr[aa];
		arr[bb]+=arr[aa];
		arr[aa]=0;
		cout<<s<<'\n';
	}


}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
//	/*
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
// */
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
 
#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)
 
ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}
 
int main()
{
  ll a[2];
  cin >> a[0] >> a[1];
  if (a[0] + a[1] <= 9){
    cout << a[0] + a[1] << endl;
  }else{
    cout << "error" << endl;
  }
  return 0;
}


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

int main() {
    int64_t a, b, n;
    cin >> a >> b >> n;
    int64_t x = min(b-1,n);
    int64_t ans = (a*x)/b-a*(x/b);
    
    cout << ans << endl;
}


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

int main(){
    char A;
    cin >> A;
    if (A >= 'a')
        cout << 'a' << endl;
    else
        cout << 'A' << endl;
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
M,F=10**9+7,[1]
for i in range(m): F+=[-~i*F[i]%M]
print(sum((-1)**k*F[m-k]*pow(F[k]*F[n-k]*F[m-n]**2,-1,M) for k in range(n+1))*F[n]*F[m]%M)

Measured memory_bytes: 28872
//Don't give up too easy bhai
#pragma GCC optimize("-O3")
 
#include<bits/stdc++.h>
using namespace std;

#define int long long int
#define double long double
#define inf 1e18

typedef pair<int,int> pii;
 
#define forall(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define vi vector<int>
#define vd vector<double>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007
#define br cout<<"\n"
#define whatis(x) cerr << "var "<<#x << " ==> " << x<<"\n"
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define T int __t;cin>>__t;while(__t--)

void solve()
{
    
}

signed main()
{
    fast;

    int x;cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


void oneCase () {
   int n;
   cin >> n;
   vector<int> p(2 * n, 1);
   for (int d = 2; d < n; ++d) {
       if (p[d] == 0) {
           continue;
       }
       auto cur = 2 * d;
       while (cur < 2 * n) {
           p[cur] = 0;
           cur += d;
       }
   }
   while (p[n] == 0) {
       ++n;
   }
   cout << n << "\n";
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

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

#define mem(a,n) memset(a,n,sizeof(a))
#define memc(a,b) memcpy(a,b,sizeof(b))
#define rep(i,a,n) for(int i=a;i<n;i++) ///[a,n)
#define pb push_back
#define mkp make_pair
#define mkt make_tuple
#define IO ios::sync_with_stdio(false)
#define fre freopen("in.txt","r",stdin)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1.0);
const double E=2.718281828459045;
const double eps=1e-8;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int MOD=1e3;
const int N=1e2+5;
const ll maxn=2e5+5;
const int dir[4][2]= {-1,0,1,0,0,-1,0,1};
ll a[maxn],b[maxn],n;

void Sort(ll *a, ll md)
{
    int pos = n;
    for (int i = 0; i < n; i ++)
    {
        if (pos == n && a[i] >= md)
            pos = i;
        a[i] = a[i] & (md - 1);
    }
    inplace_merge(a, a + pos, a + n);
}
bool solve(ll limit)
{
    ll ans = 0;
    int that = n - 1;
    for (int i = 0; i < n; i ++)
    {
        while (that >= 0 && a[i] + b[that] >= limit)
            that --;
        ans += n - 1 - that;
    }
    return ans & 1;
}
inline ll Scan()
{
    ll r = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9') {r = r * 10 + ch - '0';ch = getchar();}
    return r * f;
}

inline void Print(ll x)
{
    if(x<0){x=-x;putchar('-');}
    if(x>9) Print(x/10);
    putchar(x%10+'0');
}
int main()
{
    n=Scan();
    rep(i,0,n) a[i]=Scan();
    rep(i,0,n) b[i]=Scan();
    sort(a,a+n);
    sort(b,b+n);
    ll ans = 0;
    for(int i=61; i>=0; i--)
    {
        Sort(a, 2LL<<i);
        Sort(b, 2LL<<i);
        ll res=solve(1LL<<i)^solve(2LL<<i) ^solve(3LL<<i);
        ans|=res<<i;
    }
    Print(ans);
    return 0;
}


Measured memory_bytes: 4212
#include <stdio.h>

int main(){

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

  if(x<y){
    r=x;
    x=y;
    y=r;
  }

  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }

  printf("%d\n",x);

  return 0;
}
    



Measured memory_bytes: 2104
#include<stdio.h>

int main(void)
{
  int N, i, p[10], memory, answer;
  scanf("%d", &N);

  scanf("%d", &p[0]);
  answer += p[0];
  memory = p[0];

  for(i = 1; i < N; i ++){
    scanf("%d", &p[i]);
    answer += p[i];
    if(p[i] > memory){
      memory = p[i];
    }
  }

  printf("%d", answer - memory / 2);

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,char> p2;
void solve(){
	ll n,k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll i=0;i<n;i++)
	cin>>v[i];
	sort(v.begin(),v.end());
	ll res=0;
	for(ll i=0;i<k;i++)
	res+=v[i];
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


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

using namespace std;

int solve(const std::vector<int>& as) {
  int ret = 0;
  auto itr = as.begin();
  while (itr != as.end()) {
    auto nextItr = std::upper_bound(itr, as.end(), *itr);
    ret += ((nextItr - itr) % 2);
    itr = nextItr;
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::sort(as.begin(), as.end());
  std::cout << solve(as) << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#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 pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, DP[3], DP2[3];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n){
    int a, b, c;
    cin >> a >> b >> c;
    Fill(DP2, 0);
    maxs(DP2[0], DP[1]+a);
    maxs(DP2[0], DP[2]+a);

    maxs(DP2[1], DP[0]+b);
    maxs(DP2[1], DP[2]+b);

    maxs(DP2[2], DP[0]+c);
    maxs(DP2[2], DP[1]+c);
    swap(DP, DP2);
  }
  int ans = 0;
  FOR(i, 0, 3) maxs(ans, DP[i]);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    ll n,k; cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i], --a[i];
    vector<vector<int>> nxt(70, vector<int>(n));
    rep(i,n) nxt[0][i] = a[i];

    for (int i = 1; i < 70; ++i) {
        rep(j,n) {
            nxt[i][j] = nxt[i-1][nxt[i-1][j]];
        }
    }

    auto bit_encode = [](ll k) {
        string ret;
        while (k > 0) {
            ret.push_back((k%2)+'0');
            k/=2;
        }
        return ret;
    };

    string s = bit_encode(k);
    int cur = 0;
    rep(i,s.length()) {
        if (s[i]=='1') cur = nxt[i][cur];
    }

    cout << ++cur << '\n';
    return 0;
}

Measured memory_bytes: 59756
#include <iostream>
#define inf (1LL<<60)
#define nmax 100005
using namespace std;
long long dp[nmax];

int main()
{
    int i, n, w, we, va;
    cin >> n >> w;

    for (i = 1; i <= n; i++) {
        cin >> we >> va;
        for (int j = w; j >= we; j--)
            dp[j] = max(dp[j], dp[j - we] + va);
    }
    cout << dp[w] << '\n';
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

struct edge{
    int to;
    int cost;
};

int main(){
    int n, m, p;
    cin >> n >> m >> p;
    int A[5000], B[5000], C[5000];
    vector<edge> G[5000];
    for(int i = 0; i < m; i++){
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        C[i] = p - C[i];
        G[B[i]].pb({A[i], C[i]});
    }
    int used[5000] = {0};
    queue<int> que;
    que.push(n-1);
    used[n-1] = 1;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int i = 0; i < G[v].size(); i++){
            int nv = G[v][i].to;
            if(used[nv]) continue;
            used[nv] = 1;
            que.push(nv);
        }
    }
    // for(int i = 0; i < n; i++) cout << used[i] << " ";
    // cout << endl;
    ll d[5000];
    for(int i = 0; i < 5000; i++) d[i] = LINF;
    d[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(d[A[j]] == LINF || d[B[j]] <= d[A[j]] + C[j]) continue;
            d[B[j]] = d[A[j]] + C[j];
            if(i == n-1 && used[B[j]]){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << max(0LL, -d[n-1]) << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    reverse(a.begin(), a.end());
    vector<int> v(n, INF);
    for (int i = 0; i < n; ++i) {
        *upper_bound(v.begin(), v.end(), a[i]) = a[i];
    }
    cout << lower_bound(v.begin(), v.end(), INF) - v.begin() << endl;
}

Measured memory_bytes: 1152
N = int(input())
L = [input() for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0
for i in L:
    if i == "AC":
        AC += 1
    elif i == "WA":
        WA += 1
    elif i == "TLE":
        TLE += 1
    elif i == "RE":
        RE += 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


Measured memory_bytes: 16316
#include <bits/stdc++.h>
#define LL long long
#define FOR(i,c) for(__typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define F first
#define S second
using namespace std;

const LL mod = 1e9 + 7;

template<typename T> T gcd(T a, T b) { return b == 0?a: gcd(b, a % b); }
template<typename T> T LCM(T a, T b) { return a*(b/gcd(a, b)); }
template<typename T> T expo(T base, T e, T mod) { T res = 1;
  while(e > 0) { if(e&1) res = res * base % mod; base = base * base % mod; e >>= 1; }
  return res;
}
template<typename T, typename S> T expo(T b, S e){if(e <= 1)return e == 0?1: b;\
	return (e&1) == 0?expo((b*b), e>>1): (b*expo((b*b), e>>1));}
template<typename T, typename S> T modinv(T a, S mod) { return expo(a, mod-2, mod); }
template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<class T> std::ostream& operator<<(std::ostream &os, const std::vector<T> &t) {
	os<<"["; FOR(it,t) { if(it != t.begin()) os<<", "; os<<*it; } os<<"]";
	return os;
}

const int MAXN = 103;
string arr[53];
int cnt[30];

int main() {
  ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	for(auto &c: arr[0]) {
		cnt[c - 'a']++;
	}
	for(int i = 1; i < n; i++) {
		int temp[30] = {0};
		for(auto &c: arr[i]) {
			temp[c - 'a']++;
		}
		for(int i = 0; i < 30; i++) {
			cnt[i] = min(cnt[i], temp[i]);
		}
	}
	for(int i = 0; i < 26; i++) {
		while(cnt[i] > 0) {
			cout << char(i + 'a');
			cnt[i]--;
		}
	}
	cout << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <complex>
#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>
#include <set>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "Sunny") cout << "Cloudy";
    if (s == "Cloudy") cout << "Rainy";
    if (s == "Rainy") cout << "Sunny";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  private static final long MOD = 998244353;
  private static long FACT[];
  private static long IFACT[];

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    long K = sc.nextLong();
    solve(N, A, B, K);
  }

  private static void solve(int N, int A, int B, long K) {
    FACT = new long[N+1];
    IFACT = new long[N+1];
    FACT[0] = 1;
    IFACT[0] = 1;
    for (int i=1; i<=N; i++) {
      FACT[i] = FACT[i-1] * i % MOD;
      IFACT[i] = inv(FACT[i]);
    }

    long ans = 0;
    for (int numA=0; numA<=N; numA++) {
      long rem = K - (long)A*numA;
      if (rem < 0) {
        break;
      }
      int numB = (int)(rem/B);
      if ((long)A*numA+(long)B*numB == K && numB <= N) {
        ans = (ans + comb(N, numA) * comb(N, numB))%MOD;
      }
    }
    System.out.println(ans);
  }

  private static long comb(int n, int r) {
    if (n < 0 || r < 0 || n < r) {
      return 0;
    }
    if (r > n/2) {
      r = n - r;
    }
    return FACT[n]*IFACT[n-r]%MOD*IFACT[r]%MOD;
  }

  private static long inv(long a) {
    long b = MOD;
    long p = 1, q = 0;
    while (b > 0) {
      long c = a / b;
      long d;
      d = a;
      a = b;
      b = d % b;
      d = p;
      p = q;
      q = d - c * q;
    }
    return p < 0 ? p + MOD : p;
  }
}


Measured memory_bytes: 25940
s = input()
h1, m1, h2, m2, k = s.split(' ')

h = int(h1) - int(h2)
m = 0
if int(m1) >= int(m2):
    m = int(m1) - int(m2)
else:
    h = h -1
    m = 60 + int(m1) - int(m2)
    
t = abs(h * 60 + m) - int(k)

print(t)

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! nを-2で割ったあまりと商を計算
ll div(ll n)
{
    n = -1 * (n / abs(n)) * (abs(n - (abs(n) % 2))) / 2;
    return n;
}

int main()
{
    ll N;
    cin >> N;
    if (N == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    vector<int> t;
    while (N != 0)
    {
        t.push_back(abs(N) % 2);
        N = div(N);
    }

    std::reverse(t.begin(), t.end());
    REP(i, t.size())
    {
        cout << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
void main()
{
    long n = rdElem;
    long[] a = rdRow;
    long[] b = rdRow;

    long[] c = iota(n).array;
    long[] d = iota(n).array;
    zip(a, c).sort!((x, y) => x[0] < y[0]);
    zip(b, d).sort!((x, y) => x[0] < y[0]);

    foreach (x, y; zip(a, b))
    {
        if (x > y)
        {
            "No".writeln;
            return;
        }
    }

    foreach (x, y; zip(a[1..n], b[0..n-1]))
    {
        if (x <= y)
        {
            "Yes".writeln;
            return;
        }
    }

    long[] e = new long[n];
    foreach (x, y; zip(c, d))
    {
        e[x] = y;
    }

    long cnt;
    void dfs(long x)
    {
        long y = e[x];
        ++cnt;
        if (!y) return;
        dfs(y);
    }

    dfs(0L);

    writeln(cnt < n ? "Yes" : "No");
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 11280
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// ll dp[100010][3]; // dp[i][j]: i日目までで、i日目でj番目を選んだ時のマキシマムザ幸福
int main() {
    int N;
    cin >> N;
    int abc[N][3];
    rep(i, N) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
    ll dp[100010][3]; // dp[i][j]: i日目までで、i日目でj番目を選んだ時のマキシマムザ幸福
    rep(i, 100010){
        rep(j, 3) dp[i][j] = 0;
    }
    rep(i, N){
        rep(j, 3) {
            rep(k, 3){
                if (j==k) continue;
                chmax(dp[i+1][k], dp[i][j] + abc[i][k]);
            }
        }
    }
    ll ans = 0;
    rep(i, 3) chmax(ans, dp[N][i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3712
import java.util.Scanner;

class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int H = scanner.nextInt();
            int W = scanner.nextInt();
            if (H == 0) {
                break;
            }
            for (int i = 0; i < H; i++) {
                if (i % 2 == 0) {
                    System.out.print("#");
                }else {
                    System.out.print(".");
                }

                for (int j = 1; j < W; j++) {
                    if (i % 2 == 0) {
                        if (j % 2 == 0) {
                            System.out.print("#");
                        } else {
                            System.out.print(".");
                        }
                    } else {
                        if (j % 2 == 0) {
                            System.out.print(".");
                        } else {
                            System.out.print("#");
                        }
                    }

                }
                System.out.println();
            }
            System.out.println();
        }
    }
}


Measured memory_bytes: 34820
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder
{
    class Program
    {
        static int N;
        static List<int> A;
        static List<int> B;
        static List<int> C;
        static Queue<Altar> altars = new Queue<Altar>();

        static void Main(string[] args)
        {
            //コンソールの設定を変更
            Console.SetIn(new StreamReader(Console.OpenStandardInput(1048576),
                                           Console.InputEncoding, false, 1048576));

            //[summary]C - Snuke Festival
            N = int.Parse(Console.ReadLine());
            A = ReadLine();
            B = ReadLine();
            C = ReadLine();

            GetLowerAltars();
                       
            Console.WriteLine(CountCombis());
        }

        static void GetLowerAltars()
        {
            //下部の祭壇のパーツをキューに格納
            var que = new Queue<int>();

            foreach (var Ci in C)
            {
                que.Enqueue(Ci);
            }

            long count = N;

            foreach (var Bi in B)
            {
                while (que.Count > 0)
                {
                    int Ci = que.Peek();

                    if (Ci <= Bi)
                    {
                        que.Dequeue();
                        count--;
                    }
                    else
                    {
                        break;
                    }
                }

                altars.Enqueue(new Altar(Bi, count));
            }
        }

        static long CountCombis()
        {
            long count = altars.Sum(x => x.Count);
            long sum = 0;

            foreach (var Ai in A)
            {
                while (altars.Count > 0)
                {
                    var altar = altars.Peek();

                    if (altar.Size <= Ai)
                    {
                        altars.Dequeue();
                        count -= altar.Count;
                    }
                    else
                    {
                        break;
                    }
                }

                sum += count;
            }

            return sum;
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).OrderBy(x => x).ToList();
        }
    }

    struct Altar
    {
        public int Size { set; get; }
        public long Count { set; get; }

        public Altar(int size, long count)
        {
            Size = size;
            Count = count;
        }
    }
}

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

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

  double ans = 0;
  for (int i = 0; i < n; i++){
    double a;
    cin >> a;
    ans += 1.0 / a;
  }

  ans = 1 / ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::Read;
use std::io::{stdout, BufWriter, Write};
use std::cmp::min;

use std::collections::HashMap;

fn get_ans(x: i64) {
    //println!("{}", x);
    for i in 0..4096 {
        for j in -4096..4096 {
            let a = i as i64;
            let b = j as i64;
            if a.pow(5) - b.pow(5) == x {
                //println!("{} = {} {}",x, a, b);
                println!("{} {}",a, b);
                return;
            }
        }
    }
    //println!("{} :Not found", x);
}
 
fn main() {
    let mut buf = String::new();
    
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
 
    std::io::stdin().read_to_string(&mut buf).unwrap();
 
    let mut iter = buf.split_whitespace();
 
    let x: i64 = iter.next().unwrap().parse().unwrap();
    
    get_ans(x);
    /*
    for i in 1..1_000 {
        get_ans(i);
    }
    */
}

Measured memory_bytes: 2108
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

ll dp[20001];

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> w(n),s(n),v(n);
    vector<pair<int,int> > z;
    int i;
    for(i=0; i<n; i++) {
        scanf("%d%d%d", &w[i], &s[i], &v[i]);
        z.push_back(make_pair(w[i]+s[i],i));
    }
    sort(z.begin(), z.end());

    int j;
    for(j=1; j<=20000; j++) {
        dp[j]=0;
    }

    for(i=0; i<n; i++) {
        int id=z[i].second;
        for(j=s[id]; j>=0; j--) {
           dp[j+w[id]]=MAX(dp[j+w[id]], dp[j]+v[id]);
        }
    }

    ll ans=0;
    for(j=20000; j>=0; j--) {
        ans=MAX(ans,dp[j]);
    }
    printf("%lld\n", ans);

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt = n;
    for(int i=0;i<n;i++){
        char s1 = s.at(i);
        if(i%2==0){ //奇数
            if(s1 == 'L'){
                n--;
            }
        }else{
            if(s1 == 'R'){
                n--;
            }
        }        
    }
    if(cnt==n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, 0, n) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int ans = 0;
    rep(i, 0, n) {
        if (d[i] != d[i + 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

void solve();

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

//////////////////////////////////////////////////
//////////////////////////////////////////////////

void solve() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k)cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def binsearch(l, r, pred):  # [l, r)
    assert l < r
    l -= 1
    while r - l > 1:
        m = (l + r) // 2
        if pred(m):
            r = m
        else:
            l = m
    return r

def solve(t1, t2, a1, a2, b1, b2):
    assert a1 != b1
    assert a2 != b2
    if a1 > b1:
        a1, b1 = b1, a1
        a2, b2 = b2, a2
    assert a1 < b1
    if a1 * t1 + a2 * t2 < b1 * t1 + b2 * t2:
        return 0
    elif a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2:
        return 'infinity'
    else:

        def f(k):
            x0 = (a1 * t1 + a2 * t2) * k
            y0 = (b1 * t1 + b2 * t2) * k
            x1 = x0 + a1 * t1
            y1 = y0 + b1 * t1
            x2 = x1 + a2 * t2
            y2 = y1 + b2 * t2
            if y0 <= x0 and x1 < y1 and y2 < x2:
                return 2
            elif y0 <= x0 and x1 < y1 and y2 <= x2:
                return 1
            elif y0 <= x0 and x1 == y1:
                return 1
            else:
                return 0
        def pred(k):
            return f(k) == 0
        k = binsearch(0, 10 ** 18, pred)
        return 2 * (k - 1) + f(k - 1) - 1

def main():
    t1, t2 = map(int, input().split())
    a1, a2 = map(int, input().split())
    b1, b2 = map(int, input().split())
    print(solve(t1, t2, a1, a2, b1, b2))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MX = 2155;
const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

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

char ispr[1 << 17];

int Sqrt(ll x) {
	int y = sqrt(x);
	while (1LL * y * y < x) y++;
	while (1LL * y * y > x) y--;
	if (1LL * y * y == x) return y;
	return -1;
}

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	vector<int> pr;
	map<ll, int> oo;
	for (int i = 2; i <= MX; i++) if (isPrime(i)) pr.push_back(i);
	for (int i = 2; i < 1 << 17; i++) {
		if (isPrime(i)) {
			ispr[i] = 1;
			oo[1LL * i * i] = 1;
		}
	}

	int n;
	while (cin >> n) {
		vector<ll> a(n);
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}

		int ans = 0;
		vector<vector<pair<int, int> > > mem(n);
		map<vector<pair<int, int> >, int> mp;
		set<vector<pair<int, int> > > used;
		for (int i = 0; i < n; i++) {
			int y = (int)pow(a[i], 1.0 / 3.0);
			while (1LL * y * y * y < a[i]) y++;
			while (1LL * y * y * y > a[i]) y--;
			if (1LL * y * y * y == a[i]) {
				if (ans == 0) ans++;
				continue;
			}

			ll x = a[i];
			vector<pair<int, int> > cur;
			for (int j = 0; j < (int)pr.size(); j++) {
				if (x % pr[j] == 0) {
					int cnt = 0;
					while (x % pr[j] == 0) {
						x /= pr[j];
						cnt++;
					}
					if (cnt % 3 != 0) cur.push_back(make_pair(pr[j], cnt % 3));
				}
			}
			if (x < 1e5 && ispr[x]) {
				cur.push_back(make_pair(x, 1)); 
				x = 1;
			}
			y = Sqrt(x);
			if (y != -1 && ispr[y]) {
				cur.push_back(make_pair(y, 2)); 
				x = 1;
			}

			if (x != 1) cur.push_back(make_pair(2e5 + i, 1));
			assert(!cur.empty());
			mem[i] = cur;
			mp[cur]++;
		}
		
		for (int i = 0; i < n; i++) {
			if (mem[i].empty()) continue;
			vector<pair<int, int> > cur = mem[i];
			if (used.find(cur) != used.end()) continue;
			vector<pair<int, int> > oth = cur;
			for (int j = 0; j < (int)oth.size(); j++) {
				oth[j].second = 3 - oth[j].second;
			}
			ans += max(mp[cur], mp[oth]);
			used.insert(cur);
			used.insert(oth);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 51584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string w[105];
    cin>>n;
    bool flag=true;
    for(int i=0;i<n;i++){
        cin>>w[i];
    }
    char co=w[0][w[0].size()-1];
    for(int i=1;i<n;i++){
        if(co!=w[i][0]) flag=false;
        co=w[i][w[i].size()-1];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(w[i]==w[j]) flag=false;
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
def main():
    N = int(input())
    P = [None] * N
    x0, y0, h0 = 0, 0, 0
    for i in range(N):
        x, y, h = map(int, input().split())
        if h != 0 and h0 == 0:
            x0, y0, h0 = x, y, h
        P[i] = (x, y, h)
    for i in range(101):
        for j in range(101):
            H = h0 + abs(i-x0) + abs(j-y0)
            for x, y, h in P:
                dist = abs(i-x) + abs(j-y)
                if (h > 0 and dist != H-h) or (h == 0 and dist < H):
                    break
            else:
                print(i, j, H)
                return


if __name__ == "__main__":
    main()


Measured memory_bytes: 41072
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define FOR(i, x, y) for(ll i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll expo(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return (base + MOD) % MOD;
    ll ans = expo(base, power / 2);
    ans = (ans * ans + MOD) % MOD;
    if (power % 2 == 1) ans = (ans * base + MOD) % MOD;
    return (ans + MOD) % MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    map<char, ll> cnt;
    cin >> n;
    FOR(i, 0, n) {
        char c;
        cin >> c;
        cnt[c]++;
    }

    ll ans = 1;
    for (auto& i : cnt) {
        ans = (ans * (i.second + 1)) % MOD;
    }
    cout << (ans - 1 + MOD) % MOD << '\n';
    return 0;
}

Measured memory_bytes: 256
# ABC161a


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    x, y, z = map(int, input().split())
    print(z, x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38468
import sys
input = sys.stdin.readline
n = int(input())
l = [int(_) for _ in input().split()]
count = 0
for i,s1 in enumerate(l):
  for j,s2 in enumerate(l[i+1:]):
    for s3 in l[i+j+2:]:
      # print(s1, s2, s3)
      if len(set([s1, s2, s3]))!=3:
        continue
      elif ((s1+s2)>s3)&((s1+s3)>s2)&((s2+s3)>s1):
        count += 1
print(count)

Measured memory_bytes: 9144