akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<LL,LL>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
ll gcd(int a , int b){
	return b == 0 ? a : gcd(b , a%b);
}
int main(){
	int n;cin >> n;
	ll sum = 0;
	fo(i,1,n){
		fo(j,1,n){
			fo(k,1,n){
				sum += gcd(i,gcd(j,k));
			}
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3596
L = list(map(int, input().split()))
odd = L[0] % 2 + L[1] % 2 + L[2] % 2
if odd == 0 or odd == 3:
    ans = (max(L) * 3 - sum(L)) // 2
elif odd == 1:
    if max(L) % 2 == 1:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
else:
    if max(L) % 2 == 0:
        ans = (max(L) * 3 - (sum(L) + 2)) // 2 + 1
    else:
        ans = ((max(L) + 1) * 3 - (sum(L) + 2)) // 2 + 1
print(ans)


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

int n;
string s;
long long r,b,g;

int main(){
	cin>>n;
	cin>>s;
	for (int i=0;i<n;i++){
		if (s[i]=='R') r++;
		if (s[i]=='B') b++;
		if (s[i]=='G') g++;
	}
	long long res=r*b*g;
	for (int i=0;i<n;i++)
		for (int j=1;j<n;j++){
			if (i-j<0 || i+j>=n) break;
			if (s[i]!=s[i+j] && s[i]!=s[i-j] && s[i+j]!=s[i-j]) res--;
		}
	cout<<res<<endl;
	return 0;
}

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

int main(){
	int n,t,ans;
	string s="TLE";
	cin >> n >> t;
	int a[100],b[100];
	for(int i=0;i<n;i++){
		cin >> b[i] >> a[i];
	}
	ans=1001;
	for(int j=0;j<n;j++){
		if(t>=a[j]&&b[j]<ans){
			ans=b[j];
		}
	}
	if(ans==1001){
		cout << s;
	}
	else{
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define REP(i, x, n)	for(int i = x; i < n; ++i)
const int qq = 1e5 + 10;
LL t[qq];
LL n, c, k;
int main(){
	scanf("%lld%lld%lld", &n, &c, &k);
	for(int i = 1; i <= n; ++i)
		scanf("%lld", t + i);
	sort(t + 1, t + n + 1);
	int bus = 0;
	LL dis = t[1] + k;
	int people = 1;
	for(int i = 2; i <= n; ++i){
		if(people == c){
			++bus;
			people = 1;
			dis = t[i] + k;
			continue;
		}
		if(t[i] > dis){
			++bus;
			people = 1;
			dis = t[i] + k;
			continue;
		}
		++people;
	}
	if(people)	++bus;
	printf("%d\n", bus);
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>

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

  for (int t = 0; t < 6000; ++t) {
    bool awaken = (t % (a+b) <= a);
    if (!awaken) continue;
    if (t % 60 == c) return !printf("%d\n", t);
  }
  puts("-1");
}



Measured memory_bytes: 2752
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define fi first
//#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  n = n % 10;

  switch (n) {
  case 2:
  case 4:case 5:case 7:case 9:
    cout << "hon"; break;
  case 0:case 1:case 6:case 8:cout << "pon"; break;
  case 3:cout << "bon"; break;
  }
}
#endif


Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int ball[200000] = {0};
	int n, k, v = 0;
	ll ans = 0;
	cin >> n >> k;

	rep(i, 0, n) {
		int a;
		cin >> a;
		ball[a - 1]++;
	}

	sort(ball, ball + n);

	rep(i, 0, n) {
		if (ball[i] != 0)v++;
	}

	int i = 0;

	while (v > k) {
		if (ball[i] != 0) {
			v = v - 1;
			ans += ball[i];
		}
		i++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    long l;
    long i;
    long long sum=0;
    cin >>l;
    for(i=1;i<=l;i++){
        if((i%3!=0)&&(i%5!=0)){
            sum+=i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

vector<int> odd, even;
using Graph = vector<vector<int>>;

void dfs(const Graph &G, int v, int p, int d) { 
    if(d % 2 == 0)even.push_back(v);
    else odd.push_back(v);

	for (auto nv : G[v]) {
		if (nv == p)continue;
		dfs(G, nv, v, d+1);
	}
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    vector<int> ans(n), z, o, t;
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    REP(i, n){
        if(i % 3 == 0)z.push_back(i);
        if(i % 3 == 1)o.push_back(i);
        if(i % 3 == 2)t.push_back(i);
    }
    dfs(G, 0, -1, 0);
    int nowz = 0, nowo = 0, nowt = 0;
    if(odd.size() > even.size())swap(odd, even);
    if(z.size() >= odd.size()){
        rep(i, odd.size()){
            ans[odd[i]] = z[nowz];
            nowz++; 
        }
        rep(i, even.size()){
            if(nowz < z.size()){
                ans[even[i]] = z[nowz];
                nowz++;
            }
            else if(nowo < o.size()){
                ans[even[i]] = o[nowo];
                nowo++;
            }
            else{
                ans[even[i]] = t[nowt];
                nowt++;
            }
        }
    }
    else{
        rep(i, odd.size()){
            if(nowo < o.size()){
                ans[odd[i]] = o[nowo];
                nowo++;
            }
            else{
                ans[odd[i]] = z[nowz];
                nowz++;
            }
        }
        rep(i, even.size()){
            if(nowt < t.size()){
                ans[even[i]] = t[nowt];
                nowt++;
            }
            else{
                ans[even[i]] = z[nowz];
                nowz++;
            }
        }
    }
    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;
}   

Measured memory_bytes: 21144
import java.nio.Buffer;
import java.util.Scanner;
import java.util.Vector;

public class Main {
    public static Scanner r=new Scanner(System.in);
    public static void main(String[] args) {
        int n=r.nextInt();
        int []a=new int[n];
        int sum=0;
        for(int i=0;i<n;++i){
            a[i]=r.nextInt();
            sum^=a[i];
        }
        for(int i=0;i<n;++i){
            System.out.print((sum^a[i])+" ");
        }
    }
}


Measured memory_bytes: 63372
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const int mod=1e9+7;
int n,tot,lcm=1,a[10001],f[1000001];
bool vis[1000001];
inline int kuai(int p,int q,int mod) {int tot=1;for(;q;p=(ll)p*p%mod,q>>=1) if(q&1) tot=(ll)tot*p%mod;return tot;}
#define inc(x,y) x+=y,x>=mod?x-=mod:0
int main()
{
	ios::sync_with_stdio(false);
	cin>>n,vis[1]=true;
	for(res i=2;i<=1000000;++i) if(!vis[i])
	  for(res j=i<<1;j<=1000000;j+=i) vis[j]=true;
	for(res i=1;i<=n;++i) {
		cin>>a[i];int x=a[i],now=sqrt(a[i]);
		for(res j=2;j<=now;++j) if(!(x%j)) {
			int sum=0;
			while(!(x%j)) x/=j,++sum;
			chkmax(f[j],sum);
		}
		if(x>1) chkmax(f[x],1);
	}
	for(res i=1;i<=1000000;++i) if(f[i]) lcm=(ll)lcm*kuai(i,f[i],mod)%mod;
	for(res i=1;i<=n;++i) inc(tot,(ll)lcm*kuai(a[i],mod-2,mod)%mod);
	cout<<tot<<'\n';
	cout<<flush;
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 4736
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

// 重み付き木の直径を求める.
// (重みが与えられていない場合は, 全ての重みを1とする.)
//
// 頂点数をNとして、計算量は O(N).

const int MAX_V = 100001;

struct edge {
  int to, cost;
};
vector<edge> g[MAX_V];

pair<int, int> dfs(int idx, int parent) {
  pair<int, int> ret(0, idx);
  for (auto &e : g[idx]) {
    if (e.to == parent) {
      continue;
    }
    auto cost = dfs(e.to, idx);
    cost.first += e.cost;
    if (ret.first < cost.first) {
      ret = cost;
    }
  }
  return ret;
}

int tree_diameter() {
  auto p = dfs(0, -1);
  auto q = dfs(p.second, -1);
  return q.first;
}

int N;

// verify:
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A&lang=jp
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back(edge{t, w});
    g[t].push_back(edge{s, w});
  }

  int ans = tree_diameter();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 14904
n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(m):
	a[int(input())]=1


num=[1,1,2]


mod=1000000007

count=0
jud=1
ans=1
for i in range(n+1):
	
	if i>2:
		num.append(1)
		num[i]=(num[i-1]+num[i-2])%mod

	if(jud==0 and a[i]==1):
		print("0")
		break
	elif a[i]==1:
		ans=(ans%mod)*(num[count-1]%mod)
		count=0
		jud=0
	elif(i==n):
		count+=1
		ans=(ans%mod)*(num[count-1]%mod)
		print(ans%mod)
	else:
		jud=1
		count+=1



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

int main(void)
{
    int n, m;
    cin >> n >> m;
    if(n == m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int N,S,M;
inline void solve(){
  IN(N);
  M=N;
  while(M){
    S+=M%10;
    M/=10;
  }
  OUT(N%S==0?"Yes":"No");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
S = list(map(int, input().split()))
T = list(map(int, input().split()))
d = [[0 for i in range(M + 1)] for j in range(N + 1)]
mod = 1000000007

for i in range(1, N+1):
	sum = 0
	for j in range(1, M + 1):
		if S[i - 1] == T[j - 1]:
			sum += d[i - 1][j - 1] + 1
		d[i][j] = (d[i - 1][j] + sum) % mod
print((d[N][M] + 1)%mod)

Measured memory_bytes: 74716
# WA

n = gets.chomp.to_i

robs = Array.new

for i in 0..n-1 do 
  x, l = gets.chomp.split(" ").map(&:to_i)
  robs[i] = [x - l, x + l]
end
robs = robs.sort_by {|a| a[1]}
# p robs

ans = 0
e = -1000000001
for i in 0..n-1 do
  if e <= robs[i][0]
    e = robs[i][1]
    ans += 1
  end
end
puts ans

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

using namespace std;

int main() {
    const double btc_yen = 380000;

    int N;
    cin >> N;

    double sum = 0;
    for (int i = 0; i < N; ++i) {
        double x;
        cin >> x;

        string type;
        cin >> type;

        if (type == "JPY")
            sum += x;
        else
            sum += btc_yen * x;
    }

    cout << sum << '\n';
}


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

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  ll sum = 0;
  rep(i, n) {
    cin >> v.at(i);
    sum += v.at(i);
  }
  ll tmp = 0, i = -1;
  while (tmp*2 <= sum) {
    i++;
    tmp += v.at(i);
  }
  ll res1 = tmp - (sum-tmp), res2 = (sum-tmp+v.at(i)) - (tmp-v.at(i));
  cout << min(res1, res2) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
const int MAXN = 1000050;
int N, X[MAXN], Y[MAXN], o[MAXN], p[MAXN];
vector<pair<int, pi>> edges;
long long ans;
bool cmpx(int a, int b) {
    return X[a] < X[b];
}
bool cmpy(int a, int b) {
    return Y[a] < Y[b];
}
int par(int x) {
    if (p[x] == x) return x;
    return p[x] = par(p[x]);
}
int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) {
        scanf("%d%d", &X[i], &Y[i]);
        p[i] = i;
        o[i] = i;
    }
    sort(o, o+N, cmpx);
    for (int i = 1; i < N; ++i) {
        edges.emplace_back(X[o[i]] - X[o[i-1]], pi(o[i], o[i-1]));
    }
    sort(o, o+N, cmpy);
    for (int i = 1; i < N; ++i) {
        edges.emplace_back(Y[o[i]] - Y[o[i-1]], pi(o[i], o[i-1]));
    }
    
    sort(edges.begin(), edges.end());
    for (auto e:edges) {
        int a = e.second.first, b = e.second.second;
        if (par(a) == par(b)) continue;
        ans += e.first;
        p[par(a)] = par(b);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 15604
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int x,a,b;
  cin>>x>>a>>b;
  if(a>=b)cout<<"delicious"<<endl;
  else if(a+x>=b)cout<<"safe"<<endl;
  else cout<<"dangerous"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using lli = long long int;
using i64 = int64_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 x;
  cin >> x;
  i64 t = 0, s = 0;
  for (; s < x; ++t, s += t);
  cout << t << '\n';
  return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A < B * 2) {
    cout << 0 << endl;
  }
  
  if (A >= B * 2) {
    cout << A - B * 2 << endl;
  }
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
$N = trim(fgets(STDIN));
//list($A,$B,$C,$D) =  explode(" ",trim(fgets(STDIN)));
//$a =  explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$N;$i++) {
  list($A,$B)  =  explode(" ",trim(fgets(STDIN)));
  $l[]=array('N'=>$A,'LIMIT'=>$B);
}

foreach($l as $k=>$v) {
  $sort[$k]=$v['LIMIT'];
}
array_multisort($sort, SORT_ASC, $l);

$total=0;
foreach($l as $k=>$v) {
  $total += $v['N'];
  if ($total > $v['LIMIT']) {
    printf("No\n");
    exit;
  }
}
printf("Yes\n");


Measured memory_bytes: 129900
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

n, q = cin

ss = gets.chop.chars
ss.unshift("0")
ss.push("0")
ssi = [*(0..(ss.length-1))]

qs = []
q.times do
  t,d = gets.split
  qs << [t,d]
end

def exists?(ss, qs, i, e)
  qs.each do |q|
    i += (q[1] == "L") ? -1 : 1 if q[0] == ss[i]
    return false if i == e
  end
  true
end
    
l = ssi.bsearch_index{|i|exists?(ss, qs, i, 0)} - 1
r = ssi.bsearch_index{|i|!exists?(ss, qs, i, ss.length-1)}

puts [r-l-1,0].max

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

int main()
{

  string S;
  cin >> S;

  int cnt = 0;

  if (S[0] == 'A')
  {
    cnt++;
  }
  else
  {
    cout << "WA" << endl;
    exit(0);
  }

  int first_idx = 2, second_idx = S.size() - 2;
  int idx;
  for (int p = 0; p < S.size(); p++)
  {
    idx = S.find('C');
    if (idx <= first_idx & second_idx <= idx)
    {
      cnt++;
    }
    else if (idx <= second_idx & first_idx <= idx)
    {
      cnt++;
    } else {
      break;
    }
    S.erase(idx, 1);
  }

  if (cnt > 2 || cnt == 1)
  {
    cout << "WA" << endl;
    exit(0);
  }

  S.erase(0, 1);

  for (int i = 0; i < S.size(); i++) {
    if (islower(S[i])){
      cnt++;
    } else {
      cout << "WA"<< endl;
      exit(0);
    }
  }

  cout << "AC" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n;
int A[100];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; ++i) scanf("%d", A+i);
  int c = 0;
  for(int i = 0; i < n; ++i) c += !(i&1) && (A[i]&1);
  printf("%d\n", c);

  return 0;
}


Measured memory_bytes: 1728
# coding: utf-8
# Your code here!
N=int(input())
S=list(input())

all=len(S)
all_E=S.count("E")
all_W=S.count("W")
E=0
W=0

eva=10**12
ans=0
for index,item in enumerate(S):
    temp=W+all_E-E
    eva=min(eva,temp)
    if eva==temp:
        ans=index
    if item=="E":
        E+=1
    else:
        W+=1

temp=W+all_E-E
eva=min(eva,temp)

#print(ans)
print(eva)
    

Measured memory_bytes: 5920
#include <iostream>
using namespace std;
int main()
{
	long H;
	unsigned int N;
	cin >> H;
	cin >> N;
	int A[100000];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		H = H - A[i];
	}
	if (H <= 0) {
		cout << "Yes";
	}
	
	else {
		cout << "No";
	}
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#define _GLIBCXX_DEBUG

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define endl '\n'
#define fcout cout << fixed << setprecision(15)

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

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

using ll    = long long;
using ld    = long double;
using Pii   = pair<int, int>;
using Pll   = pair<ll, ll>;

constexpr int MOD       = (int)1e9 + 7;
constexpr int INF_int   = (int)(1 << 30);
constexpr ll INF_ll     = (ll)1e18 + 1;
constexpr ld PI         = 3.141592653589793L;

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*追加部分*/

#include <cstdint>

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

/*main関数*/

signed main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n; cin >> n;
    modint<MOD> a, b, c;
    a.a = b.a = c.a = 1;
    rep(i, n){
        a *= 10;
        b *= 9;
        c *= 8;
    }

    cout << (a - b*2 + c).a << endl;

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
//INF = 1 061 109 567 ; INF + INF = 2 122 219 134 ;
//LINF = 4 557 430 888 798 830 399 ; LINF + LINF = 9 114 861 777 597 660 798 ;
const int INF = 0x3f3f3f3f;     // -INF: 0xc0   abs(-INF) = INF + 1
const ll LINF = 0x3f3f3f3f3f3f3f3f;
/*}}}*/                         // zr, zm
const int MOD = (int)1e9+7;     // when MOD = 1e9+7, inv2 = 500000004
const int N = (int)2e5+7;
int lazy[N<<2],tree[N<<2];
#define ls rt << 1
#define rs rt << 1 | 1
#define lson l, m, ls
#define rson m+1, r, rs
void Add(int rt,int val) {
	lazy[rt] += val;
	tree[rt] += val;
}
void pushdown(int rt) {
	if(lazy[rt]) {
		Add(ls,lazy[rt]);
		Add(rs,lazy[rt]);
		lazy[rt] = 0;
	}
}
void update(int ql,int qr,int val,int l,int r,int rt) {
	if(ql <= l && qr >= r) {
		Add(rt,val);return;
	}
	pushdown(rt);
	int m = (l + r) >> 1;
	if(ql <= m) update(ql,qr,val,lson);
	if(m < qr) update(ql,qr,val,rson);
	tree[rt] = max(tree[ls],tree[rs]);
}
int query(int ql,int qr,int l,int r,int rt) {
	if(ql <= l && qr >= r) return tree[rt];
	pushdown(rt);
	int m = (l + r) >> 1;
	int res = 0;
	if(ql <= m) res = max(res,query(ql,qr,lson));
	if(m < qr) res = max(res,query(ql,qr,rson));
	return res;
}
pii p[N];
int main()
{
	int n,m;scanf("%d%d",&n,&m);
	rep(i,0,n) {
		scanf("%d%d",&p[i].fi,&p[i].se);
	}
	sort(p,p+n);
	int ans = 0;
	rep(i,1,m+2) {
		update(i,i,i-1,1,m+1,1);
	}
	for(int i = 0,j;i<n;i=j) {
		for(j = i;j < n && p[i].fi == p[j].fi;j++);
		per(k,i,j) {
			update(1,p[k].se,1,1,m+1,1);
		}
		ans = max(ans,query(1,m+1,1,m+1,1) - p[i].fi - m);
	}
	ans = max(ans,n - m);
	printf("%d\n",ans);
	return 0;
}

	


Measured memory_bytes: 7040
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if(s < t) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

a,b,t = inpl()
print(t//a*b)

Measured memory_bytes: 3948
package main

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

func SelectionSort(n int, as []int) {
	count := 0
	for i := 0; i < n; i++ {
		min := as[i]
		min_index := i
		for j := i + 1; j < n; j++ {
			if min > as[j] {
				min = as[j]
				min_index = j
			}
		}
		if min_index > i {
			a := as[min_index]
			as[min_index] = as[i]
			as[i] = a
			count = count + 1
		}
	}
	printArray(as)
	fmt.Println(count)
}

func printArray(as []int) {
	fmt.Println(strings.Trim(fmt.Sprint(as), "[]"))
}

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	as := []int{}
	for i := 0; i < n; i++ {
		x := nextInt(sc)
		as = append(as, x)
	}
	SelectionSort(n, as)
}



Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define ii pair <int , int>
#define is pair <int, string>
#define ic pair <int, char>
#define ll long long
#define mx 100000
#define sf scanf
#define sf(n) scanf("%d",&n)
#define pf printf
using namespace std;
vector <int> v;

/*int intConvert(string s){
    int n;
    stringstream geek(s);
    geek >> n;
    return n;
}*/

/*string strConvert(int n){
    string s;
    stringstream ss;
    ss << n;
    s=ss.str();
    return s;
}*/


int main(){
    int n=4;
    while(n--){
        int a;
        sf(a);
        v.push_back(a);
    }
    int a,b;
    sf(a),sf(b);
    int Max=max(a,b);

    sort(v.begin(),v.end());
    int sum=0;
    for(int i=3; i>=1; i--){
        sum+=v[i];
    }
    pf("%d\n",(sum+Max));

    return 0;
}



Measured memory_bytes: 3172
#include <iostream>

using namespace std;

int main() {
	int n;
	while (cin >> n&& n!=0) {
		int f[21][21] = {};

		for (int i = 0; i<n; i++) {
			int x, y;
			cin >> x >> y;
			f[y][x] = 1;
		}

		int x = 10, y = 10;
		int cnt = 0;

		int m;
		cin >> m;
		for (int i = 0; i<m; i++) {
			char dir;
			int step;
			cin >> dir >> step;
			while (step--) {
				if (dir == 'N') { y++; }
				else if (dir == 'S') { y--; }
				else if (dir == 'E') { x++; }
				else { x--; }

				if (f[y][x]) {
					f[y][x] = 0;
					cnt++;
				}
			}
		}

		if (cnt == n) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;




int main(){
	int n;
	cin>>n;
	ll a[n];
	rep(i,0,n) cin>>a[i];

	sort(a,a+n);

	ll l=a[n-1];
	if(l%2){
		ll midl=l/2;
		ll midr=l/2 +1;
		ll M=midl;
		ll k=0;

		for(int i=0;i<n-1;i++){
			//cout<<M<<endl;
			if(M>abs(midl-a[i])){
				M=abs(midl-a[i]);
				k=a[i];
			}
			if(M>abs(midr-a[i])){
				M=abs(midr-a[i]);
				k=a[i];
			}
		}

		cout<<l<<" "<<k<<endl;
	}else{
		ll mid=l/2;
		ll M=mid;
		ll k=0;
		for(int i=0;i<n-1;i++){
			//cout<<M<<endl;
			if(M>abs(mid-a[i])){
				M=abs(mid-a[i]);
				k=a[i];
			}
		}

		cout<<l<<" "<<k<<endl;
	}
}


Measured memory_bytes: 1024
<?php
$n = trim(fgets(STDIN));
$map = array();
$input=explode(' ',trim(fgets(STDIN)));
for($i=0;$i<$n;$i++) {
  if(isset($map[$input[$i]])) {
    $map[$input[$i]]++;
  } else {
    $map[$input[$i]] = 1;
  }
}

$ans = 0;
foreach($map as $num => $count) {
  if($num > $count) {
    $ans += $count;
  } else if($num < $count) {
    $ans += ($count - $num);
  }
}

echo $ans.PHP_EOL;

?>

Measured memory_bytes: 34212
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N; i++){
        cin >> vec.at(i);
    }
    std::sort(vec.begin(),vec.end());
    
    int ans = 0,i = 0;
    while(1){
        ans = ans + vec.at(N-i-1);
        i++;
        if(i == N){
            break;
        }
        ans = ans - vec.at(N-i-1);
        i++;
        if(i == N){
            break;
        }
    }
    cout << ans << endl;
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long				ll;
typedef pair<int,int >			pii;
template <class T>
using V = vector<T>;
#define SYNC					ios_base::sync_with_stdio(0);cin.tie(0);
#define rep(i,b)				for(int i=0;i<b;i++)
#define repn(i,n)				for(int i=1;i<=n;i++)
#define ALL(x)					(x).begin(),(x).end()
#define fi						first
#define se						second
#define pb						push_back
#define dzx						cerr<<"here";
const ll MOD=1e9+7,INF=9e18;
const int inf=2e9;
string s;
int l;
int sw[112345];
bool check(int x){
	if(x<=l/2)
		return true;
	int r = 2*x-l;
	int e = x-1;
	int s = l-x;
	if(sw[e]-sw[s])
		return false;
	return true;
}
int bs(int s,int e){
	if(s==e)
		return s;
	int mid = (s+e+1)/2;
	if(check(mid))
		return bs(mid,e);
	return bs(s,mid-1);
}
int main(){
	memset(sw,0,sizeof sw);
	cin>>s;
	l =(int) s.size();
	for(int i=0;i<(l-1);i++){
		sw[i+1] = (int)(s[i+1]!=s[i])+sw[i];
	}
	cout<<bs(l/2,l);
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  long long h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << '\n';
    return 0;
  }
  long long res = 0;
  res += ((w + 1) / 2) * ((h + 1) / 2);
  res += (w / 2) * (h / 2);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    ll n, k, tmp; cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> tmp;
        tmp--;
        a[i] = tmp;
    }
    set<ll> used;
    ll current_place = 0;
    vector<ll> history;
    while(used.count(current_place) == 0){
        used.insert(current_place);
        history.push_back(current_place);
        current_place = a[current_place];
    }
    history.push_back(current_place);
    used.insert(current_place);
    ll loop_start = INF, loop_end;
    rep(i, history.size()){
        if(history[i] == current_place){
            if(loop_start == INF) loop_start = i;
            else loop_end = i;
        }
    }
    if(k <= loop_start){
        current_place = 0;
        rep(i, k) current_place = a[current_place];
    }else{
        ll period = loop_end - loop_start;
        ll final_place = (k - loop_start) % period;
        current_place = 0;
        rep(i, final_place + loop_start) current_place = a[current_place];
    }
    cout << current_place + 1 << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(N, K - Q);

  for (int i = 0; i < Q; i++) {
    int a;
    cin >> a;
    A.at(a - 1)++;
  }

  for (int i = 0; i < N; i++) {
    cout << ((A.at(i) > 0) ? "Yes" : "No") << "\n";
  }
}

Measured memory_bytes: 1024
class Dice

  def initialize(surfaces)
    @surfaces = surfaces.dup 
  end

  def top
    @surfaces[0]
  end

  def front
    @surfaces[1]
  end

  def right
    @surfaces[2]
  end

  def N
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[1]
    @surfaces[1] = @surfaces[5]
    @surfaces[5] = @surfaces[4]
    @surfaces[4] = tmp
    self
  end

  def E
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[3]
    @surfaces[3] = @surfaces[5]
    @surfaces[5] = @surfaces[2]
    @surfaces[2] = tmp
    self
  end

  def S
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[4]
    @surfaces[4] = @surfaces[5]
    @surfaces[5] = @surfaces[1]
    @surfaces[1] = tmp
    self
  end

  def W
    tmp = @surfaces[0]
    @surfaces[0] = @surfaces[2]
    @surfaces[2] = @surfaces[5]
    @surfaces[5] = @surfaces[3]
    @surfaces[3] = tmp
    self
  end

  def adjust_front(front)
    4.times do
      self.N
      return if self.front == front
    end

    self.E
    adjust_front(front)
  end
end

n = gets.chomp.split.map(&:to_i)
gets.chomp.to_i.times do
  top, front = gets.chomp.split.map(&:to_i)
  dice = Dice.new(n)
  dice.adjust_front(front)

  4.times do
    dice.E
    break if dice.top == top
  end

  puts dice.right
end

Measured memory_bytes: 8728
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int MAXN = 2e5 + 10;
int L[MAXN] , R[MAXN] , K[MAXN] , H[MAXN];
int id1[MAXN] , id2[MAXN];
int n , cnt1 = 0 , cnt2 = 0;
priority_queue <pii , vector<pii> , greater<pii> > Q;

bool cmp1(int x , int y){
	return K[x] < K[y];
}
bool cmp2(int x , int y){
	return K[x] > K[y];
}

void solve(){
	ll ans = 0;
	scanf("%d" , &n);
	cnt1 = cnt2 = 0;
	for(int i = 1 ; i <= n ; ++ i){
		scanf("%d%d%d" , &K[i] , &L[i] , &R[i]);
		if(L[i] < R[i]){
			id2[++ cnt2] = i;
			ans += L[i];
			H[i] = R[i] - L[i];
		}
		else{
			id1[++ cnt1] = i;
			ans += R[i];
			H[i] = L[i] - R[i];
		}
	}	
	while((int)Q.size() > 0)
		Q.pop();
	sort(id1 + 1 , id1 + cnt1 + 1 , cmp1);
	sort(id2 + 1 , id2 + cnt2 + 1 , cmp2);
	for(int i = 1 ; i <= cnt1 ; ++ i){
		int j = i;
		while(j <= cnt1 && K[id1[i]] == K[id1[j]]){
			Q.push(make_pair(H[id1[j]] , id1[j]));
			ans += H[id1[j]];
			j ++;
		}
		while((int)Q.size() > K[id1[i]]){
			pii u = Q.top();
			ans -= u.first;
			Q.pop();
		}
		i = j - 1;
	}
	while((int)Q.size() > 0)
		Q.pop();
	for(int i = 1 ; i <= cnt2 ; ++ i){
		int j = i;
		while(j <= cnt2 && K[id2[i]] == K[id2[j]]){
			Q.push(make_pair(H[id2[j]] , id2[j]));
			ans += H[id2[j]];
			j ++;
		}
		while((int)Q.size() > n - K[id2[i]]){
			pii u = Q.top();
			ans -= u.first;
			Q.pop();
		}
		i = j - 1;
	}
	printf("%lld\n" , ans);
}

int main(){
	int T;
	scanf("%d" , &T);
	while(T --)
		solve();
	return 0;
}

Measured memory_bytes: 8284
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Myon{
    static void Main(string[] args){
        var myon = new Myon();
    }

    public Myon(){
        string S = Console.ReadLine();

        //0はじまり
        int count0 = 0;
        //1はじまり
        int count1 = 0;

        for(int i = 0;i < S.Length;i ++){
            if(S[i] == '0'){
                if(i % 2 == 0){
                    count1++;
                }else{
                    count0++;
                }


            }else{
                if(i % 2 == 0){
                    count0++;
                }else{
                    count1++;
                }
            }


        }

        Console.WriteLine(Math.Min(count0,count1));
    }
}

Measured memory_bytes: 13116
N,K = [int(i) for i in input().split()]

x = [int(i) for i in input().split()]

plus = [0]
minus = [0]

for x_ in x:
    if x_ < 0:
        minus.append(x_ * -1)
    if x_ > 0:
        plus.append(x_)
    if x_ == 0:
        K -= 1

plus.sort()
minus.sort()


ans = 10000000000

for i in range(len(plus)):
    if 0 <= K-i < len(minus):
        ans = min(ans,plus[i]*2 +minus[K-i])
for i in range(len(minus)):
    if 0 <= K-i < len(plus):
        ans = min(ans,minus[i]*2 +plus[K-i])
print(ans)


Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    cout <<  fixed << setprecision(20) << (double)sqrt((double)(A*cos(0.5*pi - 30*(H + M/60)*pi/180) - B*cos(0.5*pi - 6*M*pi/180))*(A*cos(0.5*pi - 30*(H + M/60)*pi/180) - B*cos(0.5*pi - 6*M*pi/180)) + (A*sin(0.5*pi - 30*(H + M/60)*pi/180) - B*sin(0.5*pi - 6*M*pi/180))*(A*sin(0.5*pi - 30*(H + M/60)*pi/180) - B*sin(0.5*pi - 6*M*pi/180))) << endl;
}


Measured memory_bytes: 4108
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, M;
string s[MAX_N], t[MAX_N];

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

  cin >> N;
  REP(i, N) cin >> s[i];
  cin >> M;
  REP(i, M) cin >> t[i];

  map<string, int> mp;
  REP(i, N) mp[s[i]]++;
  REP(i, M) mp[t[i]]--;

  int ans = 0;
  for (auto m : mp) {
    ans = max(ans, m.second);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.insert(n+1, 0)
kyori=0
for i in range(1,len(a)):
    kyori += abs(a[i]-a[i-1])
for i in range(1, len(a)-1):
    kyori2= kyori
    if a[i-1]<=a[i]<=a[i+1] or a[i-1]>=a[i]>=a[i+1]:
        print(kyori2)
    elif a[i-1]<a[i+1]<a[i] or a[i]<a[i+1]<a[i-1]:
        kyori2 = kyori2 -abs(a[i+1]-a[i])*2
        print(kyori2)
    else:
        kyori2 = kyori2-abs(a[i-1]-a[i])*2
        print(kyori2)

Measured memory_bytes: 13920
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int a = Integer.parseInt(sc.next());
		if(a > Integer.parseInt(sc.next())) a--;
		ou.println(a);
		ou.flush();
	}
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;

const int INF = 1e9;
const int MAX = 2500;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int> > cost(10, vector<int>(10));
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> cost[i][j];
        }
    }

    vector<vector<int> > list(h, vector<int>(w));    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> list[i][j];
        }
    }
    
    for (int k = 0; k < 10; k++) {
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    ll tmp = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (list[i][j] < 0) {
                continue;
            }
            tmp += cost[list[i][j]][1];
        }
    }
    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<ll> A(5, 0);
    rep(i, N) {
        string s;
        cin >> s;
        switch (s[0]) {
            case 'M':
                A[0]++;
                break;
            case 'A':
                A[1]++;
                break;
            case 'R':
                A[2]++;
                break;
            case 'C':
                A[3]++;
                break;
            case 'H':
                A[4]++;
                break;
            default:
                break;
        }
    }
    ll ans = A[0]*A[1]*(A[2]+A[3]+A[4]) + A[0]*A[2]*(A[3]+A[4]) + A[0]*A[3]*A[4] + A[1]*A[2]*(A[3]+A[4]) + A[1]*A[3]*A[4] + A[2]*A[3]*A[4];
    output(ans);
    return 0;
}


Measured memory_bytes: 256
import itertools
abc = list(map(int, input().split()))
K = int(input())
tmp = [i for i in range(K)]
ans = 'No'

for i in range(K + 1):
    for j in range(K + 1):
        for k in range(K + 1):
            if i + j + k == K:
                tmpabc = []
                tmplst = [i, j, k]
                for l in range(3):
                    tmpabc.append(abc[l] * (2 ** tmplst[l]))
                if tmpabc[0] < tmpabc[1] and tmpabc[1] < tmpabc[2]:
                    ans = 'Yes'
                    break

print(ans)

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100, cubeRoot = 3000;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
bool isP[cubeRoot * cubeRoot];
ll s[maxn], complement[maxn], dived[maxn];
vector<ll> primes[3];
map<ll, int> cnt;
set<ll> vis;

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

	fill(complement, complement + maxn, 1);
	memset(isP, true, sizeof(isP));
	isP[0] = isP[1] = false;
	for (int i = 2; i < cubeRoot * cubeRoot; i++)
		if (isP[i])
		{
			if (i < cubeRoot)
				primes[0].pb(i);
			else
				primes[1].pb(i), primes[2].pb((ll)i * i);
			for (int j = 2 * i; j < cubeRoot * cubeRoot; j += i)
				isP[j] = false;
		}

	//cerr << '#' << primes[0].size() << ' ' << primes[1].size() << endl;

	cin >> n;
	int ans = n;
	for (int i = 0; i < n; i++)
		cin >> s[i];

	ll tmp;
	for (int i = 0; i < n; i++)
	{
		dived[i] = s[i];
		for (ll j : primes[0])
		{
			tmp = j * j * j;
			while (s[i] % (tmp) == 0)
				s[i] /= tmp, dived[i] /= tmp;
			if (s[i] % (j * j) == 0)
			{
				dived[i] /= (j * j);
				complement[i] *= j;
			}
			else if (s[i] % j == 0)
			{
				dived[i] /= j;
				complement[i] *= j * j;
			}
		}
	}

	/* for (int i = 0; i < n; i++)
		cerr << '_' << s[i];
	cerr << endl;
	for (int i = 0; i < n; i++)
		cerr << '#' << complement[i];
	cerr << endl; */

	for (int i = 0; i < n; i++)
		cnt[s[i]]++;
	for (int i = 0; i < n; i++)
	{
		if (vis.find(s[i]) == vis.end())
		{
			//cerr << "HERE " << s[i] << ' ' << dived[i] << endl;
			if (dived[i] == 1)
			{
				//cerr << '@' << s[i] << ' ' << complement[i] << endl;
				ans -= min(cnt[s[i]], cnt[complement[i]]);
				vis.insert(s[i]);
				vis.insert(complement[i]);
			}
			else
			{
				if (*lower_bound(all(primes[2]), dived[i]) == dived[i])
				{
					int ind = lower_bound(all(primes[2]), dived[i]) - primes[2].begin();
					ans -= min(cnt[s[i]], cnt[complement[i] * primes[1][ind]]);
					vis.insert(s[i]);
					vis.insert(complement[i] * primes[1][ind]);
				}
				/*for (ll j : primes[1])
					if (s[i] % (j * j) == 0)
					{
						ans -= min(cnt[s[i]], cnt[complement[i] * j]);
						vis.insert(s[i]);
						vis.insert(cnt[complement[i] * j]);
						break;
					}*/
			}
		}
	}
	if (cnt[1])
		ans++;

	cout << ans << endl;
}



Measured memory_bytes: 35752
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    s = input()
    size = len(s)
    ans = 0
    for beg in range(size):
        for end in range(beg+1, size+1):
            if all('ACGT'.count(c) == 1 for c in s[beg:end]):
                ans = max(ans, end-beg)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 77372
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, K;
typedef pair<int, int> P;

signed main() {
    cin >> N >> K;

    vector<P> vp;
    REP(i, N) {
        P p;
        cin >> p.first >> p.second;
        vp.push_back(p);
    }
    sort(vp.begin(), vp.end());

    REP(i, N) {
        K -= vp[i].second;
        if (K <= 0) {
            cout << vp[i].first << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 2420