akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


int h, w;
char c[505][505];
bool ans[505][505];
signed main() {
	cin >> h >> w;
	rep(i, h)rep(j, w)cin >> c[i][j];
	rep(i, h) {
		rep(j, w) {
			if (i % 2 == 0 && j == 0)ans[i][j] = 1;
			else if (i % 2 && j < w - 1)ans[i][j] = 1;
		}
	}
	rep(i, h){
		rep(j, w) {
			if (c[i][j] == '#' || ans[i][j])cout << "#";
			else cout << ".";
		}cout << endl;
	}
	cout << endl;
	rep(i, h) {
		rep(j, w) {
			if (c[i][j] == '#' || !ans[i][j])cout << "#";
			else cout << ".";
		}cout << endl;
	}
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

int A,B,C = 0,c = 0;
string str_A;

int main(){
  cin >> A >> B;
  for(int i = A; i <= B; ++i){
    C = 0;
    str_A = to_string(i);

    rep(j,2) if(str_A[4-j] == str_A[j]) C++;
    if(C == 2) c++;
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const double pi = 3.14;
const ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	if(b==0) return a;

	else return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return (a*b)/gcd(a,b);
}
ll fastpower(ll base, ll exp, ll mod)
{
	ll ans = 1ll;

	while(exp)
	{
		if(exp&1)
		{
			ans = (ans%mod * base%mod)%mod;
		}
		exp/=2;
		base = (base%mod * base%mod)%mod;
	}
	return ans;
}
const int MAX = 1e5+9;
bool visited[MAX];
vector< int > adj[MAX+1];
void dfs(int node)
{
	visited[node] = true;

	for(auto u : adj[node])
	{
		if(!visited[u])
		{
			dfs(u);
		}
	}
}

int main() {
	// your code goes here
	
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe" <<'\n';
	else cout <<"safe" <<'\n';
	return 0;
	} 

Measured memory_bytes: 5968
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    int n;
    int color[100];
    cin>>n;
    int answer=0;
    for(int i=0;i<n;i++){
        scanf("%d",&color[i]);
    }
    for(int i=1;i<n;i++){
        if(color[i]==color[i-1]){
            answer++;
            color[i]=0;
        }
    }
    cout<<answer<<endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    vector<ll> y(m);
    rep(i,m) cin >> y[i];
    ll res;
    ll x_t = 0, y_t = 0;
    rep(i,n-1){
        ll len = (x[i+1] - x[i]) % MOD;
        ll num = (i+1) * (n - (i+1)) % MOD;
        x_t = (x_t + len * num) % MOD;
    }
    rep(i,m-1){
        ll len = (y[i+1] - y[i]) % MOD;
        ll num = (i+1) * (m - (i+1)) % MOD;
        y_t = (y_t + len * num) % MOD;
    }

    res = (x_t * y_t) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <list>
using namespace std;

int main(int argc, char *argv[])
{
  int commandNum = 0;
  list<int> li;

  string sCommand;
  int iSubCommand;
  cin >> commandNum;

  for (int i = 0; i  < commandNum; i++) {
    cin >> sCommand;
    if (sCommand == "insert") {
      cin >> iSubCommand;
      li.push_front(iSubCommand);
    }else if(sCommand == "delete"){
      cin >> iSubCommand;
      for (list<int>::iterator itr = li.begin(); itr != li.end(); itr++) {
	if (*itr == iSubCommand) {
	  li.erase(itr);
	  break;
	}
      }
    }else if(sCommand == "deleteFirst"){
      li.pop_front();
    }else if(sCommand == "deleteLast"){
      li.pop_back();
    }else{
      
    }
  }

  auto it = li.begin();
  for (; it != --li.end(); it++) {
    cout << *it << " ";
  }
  cout <<  *it << "\n";
  return 0;
}



Measured memory_bytes: 34400
import scala.io.StdIn._

object Main extends App {

  val n = readInt()
  val v = readLine().split(" ").map(_.toInt)
  val c = readLine().split(" ").map(_.toInt)

  def solve() = {
    (0 until n).foldLeft(0) { (acc, i) =>
      if(v(i)-c(i) > 0) acc + (v(i)-c(i)) else acc
    }
  }

  println(solve())

}



Measured memory_bytes: 54772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    double n,h;
    cin >> n >> h;
    vector<double> a(n),b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(),a.end(),greater<double>());
    sort(b.begin(),b.end(),greater<double>());
    int i = 0,cnt = 0;
    while(h > 0){
        if(b[i] > a[0]){
            h -= b[i];
            i++;
            cnt++;
        }else{
            cnt += ceil(h/a[0]);
            break;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e6+5;
string s;
vector<ll> v[N];
ll n;
ll a,b;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> a >> b;
  if((a+b)%2){
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << (a+b)/2 << endl;
}


Measured memory_bytes: 23680
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int dp[110][100010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W; cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        REP(j, 0, W) {
            dp[i + 1][j] = dp[i][j];
            if (j - w[i] < 0) continue;
            else dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }
    cout << dp[N][W] << endl;

    return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(10);
    /*start*/
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int l = x[0];
    int r = x[0];
    rep(i, n)
    {
        l = min(l, x[i]);
        r = max(r, x[i]);
    }
    int ans = 100000000;
    for (int i = l; i <= r; i++)
    {
        int sum = 0;
        rep(j, n) sum += (x[j] - i) * (x[j] - i);
        ans = min(ans, sum);
    }
    c(ans);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
readline = sys.stdin.readline

N, M = map(int, input().split())
*A, = map(int, input().split())
A.sort()

D = defaultdict(int)
for i in range(M):
    b, c = map(int, input().split())
    D[c] += b

cur = 0
for v, c in sorted(D.items(), reverse=1):
    while c > 0 and cur < N and A[cur] <= v:
        A[cur] = v
        cur += 1
        c -= 1
print(sum(A))

Measured memory_bytes: 27676
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e5+5;
typedef long long ll;

ll a,b,k;

int main(){
	scanf("%lld %lld %d",&a,&b,&k);
	ll sum=b-a+1;
	if(sum%2==0){
		if(sum/2<=k){
			for(ll i=a;i<=b;i++) printf("%lld\n",i);
		}
		else{
			for(ll i=a;i<=a+k-1;i++) printf("%lld\n",i);
			for(ll i=b-k+1;i<=b;i++) printf("%lld\n",i);
		}
	}
	if(sum%2==1){
		if(sum/2<k){
				for(ll i=a;i<=b;i++) printf("%lld\n",i);
		}
			else{
			for(ll i=a;i<=a+k-1;i++) printf("%lld\n",i);
			for(ll i=b-k+1;i<=b;i++) printf("%lld\n",i);
		}
	}
}

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

int main() {
  int a, b, c, d, e;
  cin >> a;
  b = (a-a%1000)/1000;
  c = (a%1000-a%100)/100;
  d = (a%100-a%10)/10;
  e = a%10;

  if ( (b == c) && (c == d)) {
    cout << "Yes" << endl;
  }
  
  else if ( (c == d) && (e == d)) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
// abc132d.cpp : Blue and Red Balls
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define oute(x) cout<<(x)<<endl

#define MAX 2001
ll fac[MAX], inv[MAX];

void init(int n){
  fac[0] = fac[1] = inv[1] = 1;
  upto(i,2,n+1,1){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
  }
}

int main(){
  int N,K; cin>>N>>K;
  int red = N-K, blue = K;
  init(red<blue? blue+1: red+1);
  ll ai = red + 1;
  oute(ai);
  upto(i,2,blue+1,1){
    ai = (ai *  (red-i+2) * (blue-i+1) % MOD) * (inv[i] * inv[i-1] % MOD) % MOD;
    oute(ai);
  }
}

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

#define mod 1000000007

#define rep(i, n) for(int i=0; i<n; ++i)

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll N, A[100100];
	ll count_0 = 0, count_n = 0, sum = 0, mini = 1000000000000;
	
	cin >> N;
	
	rep(i, N){
		cin >> A[i];
		if(A[i] == 0)
			count_0++;
		else if(A[i] < 0)
			count_n++;
		sum += abs(A[i]);
		mini = min(mini, abs(A[i]));
	}
	
	if(count_0 > 0 || count_n % 2 == 0)
		cout << sum;
	else
		cout << sum - 2 * mini;
	
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;

ll com[51][51];
void init(){
	com[0][0] = 1;
	for(int i = 0;i <= 49;i++){
		for(int j = 0;j <= i;j++){
			com[i+1][j] += com[i][j];
			com[i+1][j+1] += com[i][j];
		}
	}
}

ll comb(ll n,ll k){
	if(k > n)return 0;
	return com[n][k];
}
int main(){
	init();
	int n,a,b;
	cin >> n >> a >> b;
	vector<ll> v(n);

	for(int i = 0;i < n;i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end(),greater<ll>());

	ll mn = v[a-1];
	ll mn_cnt = 0;
	ll sum = 0;
	for(int i = 0;i < a;i++){
		sum += v[i];
		if(v[i] == mn)mn_cnt++;
	}

	double ave = (double)sum/a;
	printf("%lf\n",ave);

	if(v[0] == mn){
		ll cnt = 0;
		for(int i = 0;i < n;i++){
			if(v[i] == mn)cnt++;
		}
		ll ans = 0;
		for(ll i = a;i <= b;i++){
			ans += comb(cnt,i);
		}

		cout << ans << endl;
	}
	else{
		ll cnt = 0;
		for(int i = 0;i < n;i++){
			if(v[i] == mn)cnt++;
		}
		cout << comb(cnt,mn_cnt) << endl;
	}
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 22 2020 23:07:05 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int n;
    cin >> n;
    vector<tuple<string,int,int>> a;
    fori(i,n){
        string s;
        int p;
        cin >> s >> p;
        a.pb(make_tuple(s,-p,i));
    }
    sort(all(a));
    for(auto x:a){
        cout << get<2>(x)+1 << endl;
    }



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

void push(int );
int pop(void);
int S[100];
int top = 0;

int main(){
  int x,y;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop() + pop();
      push(x);
      
    }
    else if ( s[0] == '-' ){
      y = pop();
      x = pop() - y;
      push(x);

    }
    else if ( s[0] == '*' ){
      x = pop() * pop();
      push(x);
      
    }

    else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[1]);
  return 0;
}

void push(int x)
{
  if(top > 99) printf("??¨??????(?????????????????????)\n");
  top++;
  S[top] = x;
}

int pop()
{
  if(S[top] == 0) printf("??¨??????(??¢??????????????????)\n");
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
import java.io.*;
class Main{
public static void main(String[] args)throws IOException{
BufferedReader  br=new BufferedReader(new InputStreamReader(System.in));
String str=br.readLine();
int n=Integer.parseInt(str);
int[][][] residents=new int[4][3][10];
for(int i=0; i<n; i++){
String str2=br.readLine();
String[] data=str2.split(" ");
int b=Integer.parseInt(data[0])-1;
int f=Integer.parseInt(data[1])-1;
int r=Integer.parseInt(data[2])-1;
int v=Integer.parseInt(data[3]);
residents[b][f][r] += v;
}
for(int x=0;x<4;x++){
for(int y=0;y<3;y++){
for(int z=0;z<10;z++){
System.out.print(" "+residents[x][y][z]);
if(z==9) System.out.println();
if(x!=3 && y==2 && z==9) System.out.println("####################");
}
}
}
}
}

Measured memory_bytes: 24696
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
 ll N;
 cin>>N;
string S;
cin>>S;

ll mada=0;
ll owa =0;
for(ll i=0;i<N;i++){
  if(S[i]=='('){
    mada++;
  }
  if(S[i]==')'){
    if(mada>0){
      mada--;
    }
    else{
      owa++;
    }
  }
}

for(ll i=0;i<owa;i++){
  cout<<"(";
}
cout<<S;
for(ll i=0;i<mada;i++){
  cout<<")";
}
cout<<endl;

}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v.at(i);
  map<int, int> odd;
  map<int, int> even;
  for (int i = 0; i < n; i++){
    if(i % 2) odd[v.at(i)]++;
    else even[v.at(i)]++;
  }
  
  int odd_first = 0;
  int odd_second = 0;
  int odd_memo = 0;
  for (auto c : odd){
    int memo = c.first;
    int count = c.second;
    if (count > odd_first){
      odd_second = odd_first;
      odd_first = count;
      odd_memo = memo;
    }
    else if (count > odd_second){
      odd_second = count;
    }
  }
  
  int even_first = 0;
  int even_second = 0;
  int even_memo = 0;
  for (auto c : even){
    int memo = c.first;
    int count = c.second;
    if (count > even_first){
      even_second = even_first;
      even_first = count;
      even_memo = memo;
    }
    else if (count > even_second){
      even_second = count;
    }
  }
  
  if (odd_memo != even_memo){
    cout << n - odd_first - even_first << endl;
  }
  else{
    cout << n - max(odd_first + even_second, even_first + odd_second) << endl;
  }
  
}

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

int N, M;
vector<bool> col;
vector<int> val;

int main(void) {
	int x, y;

	cin >> N >> M;
	val.resize(N, 1);
	col.resize(N, false);
	col[0] = true;

	for (int i = 0; i < M; ++i) {
		cin >> x >> y;
		--x; --y;
		--val[x]; ++val[y];
		if (col[x]) col[y] = true;
		if (val[x] <= 0) col[x] = false;
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (col[i]) ++ans;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto X = RD;
	auto Y = RD;

	bool ans = inside(Y, X*2, X*4+1);
	ans &= Y % 2 == 0;

	writeln(ans ? "Yes" : "No");
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 2696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double x;
		String u;
		double sum = 0;
		double bit = 380000;
		for(int i = 0; i < n; ++i) {
			x = sc.nextDouble();
			u = sc.next();
			if(u.equals("BTC")) {
				double tmp = x * bit;
				sum += tmp;
			}
			else sum += (double)x;
		}
		sc.close();
		System.out.println(sum);
	}

}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   string s;
   cin>>s;
   
   ll cnt = 1;
   ll temp = 0;
   char curr = '.';
   for(ll i=0;i<n;i++)
   {
       if(curr!=s[i])
       {
           temp+=cnt-1;
           cnt = 1;
           curr = s[i];
       }
       
       else cnt++;
   }
   
   temp+=cnt-1;
   
   
   ll ans = min(n-1, temp+2*k);
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<ll,ll> P;
 
vector<P> D(ll n) {
  vector<P> v;
  for(ll i=2; i*i<=n; i++) {
    P p=P(0,i);
    while(n%i==0) {
      n/=i;
      p.F++;
    }
    if(p.F) v.push_back(p);
  }
  if(n>1) v.push_back(P(1,n));
  return v;
}
 
ll N(char c) {
  if(isdigit(c)) return c-'0';
  return (c-'A')+10;
}
 
ll C(string s,ll n) {
  ll x=0,y=1;
  for(int i=s.size()-1; i>=0; i--) {
    x+=N(s[i])*y;
    y*=n;
  }
  return x;
}
 
int main() {
  ll n;
  string s;
  while(cin >> n >> s && n) {
    vector<P> v=D(n);
    ll m=C(s,n),ans=1LL<<62;
    for(int i=0; i<v.size(); i++) {
      P p=v[i];
      ll z=0,x=p.S;
      while(1) {
        z+=m/x;
        if(x*p.S>m||x*p.S/p.S!=x) break;
        x*=p.S;
      }
      ans=min(ans,z/p.F);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3044
from sys import stdin
import numpy as np

A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
gcd = gcd(C,D)
A=A-1
A_C = A//C
A_D = A//D
A_CD = A//int(C*D/gcd)

B_C = B//C
B_D = B//D
B_CD = B//int(C*D/gcd)

ans = B-A-(B_C-A_C)-(B_D-A_D)+(B_CD-A_CD)
print(ans)


Measured memory_bytes: 12428
N = int(input())
a = [0]*N
b = [0]*N
for i in range(N):
    P = int(input()) - 1
    a[i] = P
    b[P] = i
c = 1
m = 1
for i in range(1,N):
    if b[i] > b[i-1]:
        c += 1
        if c > m:
            m = c
    else:
        c = 1
print(N-m)

Measured memory_bytes: 18804
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 10100000000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  string s;cin>>s;
  string ss = "Sunny", c = "Cloudy", r = "Rainy";
  if(s == ss){
    cout << c << endl;
  }else if(s == c){
    cout << r << endl;
  }else{
    cout << ss << endl;
  }
}



Measured memory_bytes: 764
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<100000;i++){
			
			int a = (int)(i * 0.08);
			int b = (int)(i * 0.10);
			if(A == a && B == b){
				Console.WriteLine(i);
				return;
			}
		}
		Console.WriteLine(-1);
		
		
	}
	int A,B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		String s=sc.next();
		int B=0;
		int R=0;
		for(int i=0; i<N; i++) {
			if(s.charAt(i)=='R') {
				R++;
			}
			else {
				B++;
			}
		}
		if(R>B) {
			pl("Yes");
		}
		else {
			pl("No");
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 22100
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

const int MAX_N = 107;
vector<int> primes;
std::map<int, int> cnt_primes;

int64 dp[MAX_N][MAX_N];

void solve() {
	int n;
	cin >> n;

	if(n == 1) {
		cout << "0\n";
		return;
	}

	for(int i = 2; i <= n; ++i) {
		int good = 1;

		for(int j = 2; j * j <= i; ++j) {
			if(i % j == 0) {
				good = 0;
				break;
			}
		}

		if(good) {
			primes.push_back(i);

			for(int j = n; j > 0; j /= i) {
				cnt_primes[i] += j / i;
			}
		}
	}

	dp[0][1] = 1;

	for(int i = 0; i < len(primes); ++i) {
		int p = primes[i];
		int mx_alpha = cnt_primes[p];

		for(int alpha = 0; alpha <= mx_alpha; ++alpha) {
			for(int j = 0; j < MAX_N; ++j) {
				int j2 = j * (alpha + 1);

				if(j2 >= MAX_N)
					break;

				dp[i + 1][j2] += dp[i][j];
			}
		}
	}

	int64 answ = dp[len(primes) - 1][75];
	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;


int main(){
    int N; cin >> N;
    set<int> st;
    for(int i=0; i<N; i++){
        int d; cin >> d;
        st.insert(d);
    }

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

Measured memory_bytes: 3636
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
A, B, C, D = map(int, input().split())
g = C * D // gcd(C, D)
def calc(N):
    return N - (N // C + N // D - N // g)
print(calc(B) - calc(A-1))


Measured memory_bytes: 2940
#200
S = input()
l = len(S)
l2 = (l-1)//2
l3 = (l+3)//2
judge = 1
for i in range(l):
    if S[i] != S[l-1-i]:
        judge = 0
for i in range(l2):
    if S[i] != S[l2-1-i]:
        judge = 0
    if S[l-1-i] != S[l3-1+i]:
        judge = 0

if judge == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;  
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0)
        {
            cout<<"No";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------
ll p_left[100010] = {};
ll p_right[100010] = {};
ll p_temp[100010] = {};

int main() {
    ll n,k;
    cin >> n >> k;
    ll left_num = 1;
    ll right_num = 1;
    rep(i, n) {
        ll temp;
        cin >> temp;
        if (temp == 0) {
            --k;
        } else if (temp > 0) {
            p_right[right_num++] = temp;
        } else {
            p_temp[left_num++] = temp;
        }
    }
    rep(i, left_num) {
        p_left[i] = abs(p_temp[left_num - i]);
    }
/*
    rep(i, n) {
        cout << p_right[i] << ", " << p_left[i] << endl;
    }
*/
    ll min_score = LLONG_MAX;
    rep(i, k + 1) {
        const ll right_index = k - i;
        if (left_num <= i || right_num <= right_index) {
            continue;
        }
        const ll bai = (i == 0 || right_index == 0) ? 1 : 2;
        //cout << i << "," << right_index << endl;
        ll t_score = (p_left[i] * bai) + p_right[right_index];
        if (t_score < min_score) {
            min_score = t_score;
        }
        //cout << t_score << endl;
        t_score = p_left[i] + (p_right[right_index] * bai);
        //cout << t_score << endl;
        if (t_score < min_score) {
            min_score = t_score;
        }
    }

    cout << min_score << endl;
    return 0;
}

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

long long calc(int X, int N){
    int a,d,n,l;
    a=X, d=X, n= N/X, l=N;
    long long ans = (long long)((long long)n*((long long)a + (long long)l)) / 2;
    return ans;
}

int main(void)
{
    int N;
    cin >> N;
    long long total=0;

    for (int i=1; i <= N; i++){
        total = total + calc(i , N/i * i);
    }

    cout << total << endl;
}


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

int main (){
    int n ;
    cin >> n ;
    int m = 100 ;

    for (int i = 0 ; i < n ; i ++){
        int a ;
        cin >> a;
        int count = 0 ;

        for (int j = 0 ; j < 100; j++){
            if (a%2 == 0 ){
                count ++;
                a /= 2;
            }
            else{
                break;
            }
        }
        if(m>count){
            m=count;
        }
    }
    cout <<m;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=610;
int n,m;
vector<int> g[maxn],h[maxn];
double dp[maxn],s,ans,tmp,delta;
double f[maxn][maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m); int x,y;
	for (int i=1;i<=m;i++) {
		read(x); read(y);
		g[x].push_back(y);
		h[y].push_back(x);
	}
	for (int i=n-1;i>=1;i--) {
		s=0;
		for (int j=0;j<g[i].size();j++)
			s+=dp[g[i][j]];
		dp[i]=s/g[i].size()+1;
	}
	for (int i=1;i<=n;i++) {
		f[i][i]=1;
		for (int u=i;u>=1;u--) {
			for (int j=0,v;j<h[u].size();j++) {
				v=h[u][j];
				f[i][v]+=f[i][u]/g[v].size();
			}
		}
	}
	ans=dp[1];
	for (x=1;x<n;x++) {
		if (g[x].size()==1) continue;
		for (int j2=0;j2<g[x].size();j2++) {
			y=g[x][j2];
			s=0;
			for (int j=0;j<g[x].size();j++)
				if (g[x][j]!=y) s+=dp[g[x][j]];
			delta=dp[x]-(s/(g[x].size()-1)+1);
			if (delta<=0) continue;
			ans=min(ans,dp[1]-delta*f[x][1]);
		}
	}
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<map>
#include<set>
using namespace std;int main(){string s;int n;map<string,set<int> >z;map<string, set<int> >::iterator q;set<int>::iterator x;while(cin>>s>>n)z[s].insert(n);for(q=z.begin();q!=z.end();){s=q++->first;cout<<s<<endl;for(x=z[s].begin(),n=0;x!=z[s].end();){if(n++)cout<<" ";cout<<*x++;}cout<<endl;}return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
void solve(){
	ll n;
	cin>>n;
	vector<ll> vec(n);
	for(int i=0;i<n;i++){
		cin>>vec[i];
	}
	ll ans = 0;
	ll mx = 0;
	for(int i=0;i<n;i++){
		if(mx>vec[i]){
			ans+= mx - vec[i];
		}
		else{
			mx = vec[i];
		}
	}
	cout<<ans<<endl;
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

Measured memory_bytes: 4720
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;

int N, a[200002];
int main(){
    scanf("%d", &N);
    for (int i = 1; i <= N; i++)scanf("%d", &a[i]);
    int nextnum = 1, numnum =0;
    for (int i = 1; i <= N; i++) {
        if(a[i] ==nextnum) nextnum++;
        else numnum++;
    }
    if(nextnum == 1) printf("-1\n");
    else printf("%d\n", numnum);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<string> v{"thu", "fri", "sat", "sun", "mon", "tue", "wed"};
    int n;
    cin >> n;
    cout << v[n%7] << "\n";
    return 0;
}


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

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

fn main() {
    let n = read();
    let mut v = Vec::new();
    for i in 0..n {
        v.push((read::<String>(), -read::<i32>(), i + 1));
    }
    v.sort();
    for (_, _, i) in v {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toInt)

  def f(ret:Double, num:Double):Double = {
    if(num >= k) ret
    else f(ret/2, num*2)
  }

  val dn = n.toDouble
  val ans = if (k == 1) 1
    else (1 to n)./: (0d)((acc, i) => acc + 1d / dn * f(1d, i))

  println(ans)
}

Measured memory_bytes: 29512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

	static long base=99731;
	static long mod=67280421310721l;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		try {
			int n=Integer.parseInt(br.readLine());
			String[] str=new String[2];
			HashSet<Long> set=new HashSet<>();
			for(int i=0;i<n;i++){
				str=br.readLine().split("\\s+");
				long hash=calc(str[1]);
				if(str[0].equals("insert")){
					set.add(hash);
				}
				else if(set.contains(hash)){
					System.out.println("yes");
				}
				else{
					System.out.println("no");
				}
			}
			
			
			
			
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	private static long calc(String string) {
		// TODO Auto-generated method stub
		long hash=0;
		for(int i=0;i<string.length();i++){
			int c=string.charAt(i);
			hash=(hash*base)%mod;
			hash+=c;
			hash=hash%mod;
		}
		return hash;
	}

}



Measured memory_bytes: 325272
#include<cstdio>
using namespace std;

int n;
char a[105];

int main()
{
    scanf("%d", &n);
    scanf("%s", &a);
    int l=0,r=0;
    for (int i=0;i<n;i++)
    {
        if (a[i] == '(') r++;
        else
        {
            if (r == 0) l++;
            else r--;
        }
    }
    for (int i = 1; i <= l; i++)
        printf("(");

    printf("%s", a);

    for (int i = 1; i <= r; i++)
        printf(")");

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int high[N];
  for(int i = 0; i < N; i++){
    scanf("%d", &high[i]);
  }
  
  int ans = N;
  for(int i = 1; i < N; i++){
    for(int j = 0; j < i; j++){
      if(high[i] < high[j]){
        ans--;
        break;
      }
    }
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
/*input
4 3
*/
#include<bits/stdc++.h>
#define int        long long
#define MOD        1000000007
#define MAX        100005
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define mii        map<int,int>
#define vi         vector<int>
#define ff         first
#define ss         second
#define T          int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi        unordered_map<int,int>
#define maxheap    priority_queue<int>
#define minheap    priority_queue<int,vector<int>,greater<int> >
#define inp(n)     for(int i=0;i<n;i++)
#define N          2000005
#define lb(v,val)  (lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (upper_bound(v.begin(),v.end(),val)-v.begin())
using namespace std;
using namespace std::chrono;


signed main(){
    int n,m;
    cin >> n >> m;
    int ans = (n*(n-1))/2 + (m*(m-1))/2;
    cout << ans << '\n';   
}



Measured memory_bytes: 256
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){

		int ans = 0;

		for(;sc.hasNextLine();){

			String buffer = sc.nextLine();

			int len = buffer.length();

			boolean ret = true;

			for(int i= 0; i < len;i++){

				if(buffer.charAt(i) != buffer.charAt(len-i-1)){

					ret = false;

				}

			}

			if(ret) ans++;

		}

		System.out.println(ans);

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, m;
	cin >> n >> m;	
 	long long dmax = -100000000, dmin = 100000000;
	long long l,r;
	for (int i = 0; i < m; ++i){
		cin >> l >> r;		
		dmax = max(dmax,l);
	 	dmin = min(dmin,r);
	}
	cout << (dmin - dmax  + 1 > 0 ? dmin - dmax + 1: 0);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  ll sum[n+1];
  sum[0]=0;
  rep(i,0,n) sum[i+1]=sum[i]+a[i];
  ll ans=1e14;
  rep(i,2,n-1){
    auto it=upper_bound(sum+1,sum+i,sum[i]/2);
    ll b,c;
    if(it-sum>=i){
      it--;
      b=*it;
      c=sum[i]-*it;
    }
    else if((it-sum)-1<=0){
      b=*it;
      c=sum[i]-*it;
    }
    else{
      b=*it;
      c=sum[i]-*it;
      it--;
      if(abs(b-c)>abs(*it-(sum[i]-*it))){
        b=*it;
        c=sum[i]-*it;
      }
    }
    
    auto et=upper_bound(sum+(i+1),sum+n,(sum[i]+sum[n])/2);
    ll d,e;
    if(et-sum>=n){
      et--;
      d=*et-sum[i];
      e=sum[n]-*et;
    }
    else if((et-sum)-1<=i){
      d=*et-sum[i];
      e=sum[n]-*et;
    }
    else{
      d=*et-sum[i];
      e=sum[n]-*et;
      et--;
      if(abs(d-e)>abs((*et-sum[i])-(sum[n]-*et))){
        d=*et-sum[i];
        e=sum[n]-*et;
      }
    }
    ll f[4]={b,c,d,e};
    sort(f,f+4);
    ans=min(ans,f[3]-f[0]);
  }
  cout<<ans<<endl;
}

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

int main() {
  int A, B, C;
  char op;
  cin >>A >>op >>B;
  
  if(op == '+'){
    C = A + B; 
  }
  if(op == '-'){
    C = A - B; 
  }
  
  cout << C;
  
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        char[] S = Console.ReadLine().ToArray();

        int R = 0, G = 0, B = 0;
        foreach (char i in S)
            switch (i)
            {
                case 'R': R++; break;
                case 'G': G++; break;
                case 'B': B++; break;
            }

        long ans = 0;
        for (int i = 0; i < N - 2; i++)
        {
            switch (S[i])
            {
                case 'R': R--; break;
                case 'G': G--; break;
                case 'B': B--; break;
            }
            int Rj = R, Gj = G, Bj = B;
            for (int j = i + 1; j < N - 1; j++)
            {
                switch (S[j])
                {
                    case 'R': Rj--; break;
                    case 'G': Gj--; break;
                    case 'B': Bj--; break;
                }
                if (S[i] != S[j])
                {
                    char dst = (char)('R' + 'G' + 'B' - S[i] - S[j]);
                    switch (dst)
                    {
                        case 'R': ans += Rj; break;
                        case 'G': ans += Gj; break;
                        case 'B': ans += Bj; break;
                    }
                    if (j + j - i < N && S[j + j - i] == dst)
                        ans--;
                }
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28008
import sys

# import bisect
# from collections import Counter, deque, defaultdict
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# from numba import jit
# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    r, d, x1 = list(map(int, readline().split()))

    xc = x1
    for i in range(10):
        xc = xc * r - d
        print(xc)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256