akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN=100050;
int a[MAXN],b[MAXN];

int main() {
	int N; scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",a+i);
	for(int i=0;i<N;i++) b[i]=a[i];
	sort(b,b+N);
	int ans=0;
	for(int i=0;i<N;i++) {
		int id=lower_bound(b,b+N,a[i])-b;
		if(id%2!=i%2) ans++;
	}
	assert(ans%2==0);
	ans/=2;
	printf("%d\n",ans);
	return 0;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int A, B, C, K;
  std::cin >> A >> B >> C >> K;

  if(K <= A) {
    std::cout << K << '\n';
    return 0;
  }

  if(K <= A + B) {
    std::cout << A << '\n';
    return 0;
  }

  std::cout << A - (K - (A + B)) << '\n';
}


Measured memory_bytes: 3636
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define yn(i) print((i)?"Yes":"No")
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}
// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

int main(){
  set<char> st;
  rep(i,26) st.insert('a'+i);
  string s; cin >>s;
  int n=s.size();
  rep(i,n) st.erase(s[i]);
  if(st.empty()){
    print("None");
  }else{
    print(*st.begin());
  }
}





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

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll m = x/d;
  ll ans = INF;
  if(m >= k) ans = x - k*d;
  else {
    ll c = (k+m)/2*2 - k;
    ans = min(abs(x-d*c),abs(x-d*(c+2)));
  }
  cout << ans << endl;
  return 0;
}


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

#define ll long long
#define ld long double
#define db double
#define str string
#define pb push_back
#define nl '\n'
#define X first
#define Y second
#define nimble ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define rall(v) rbegin(v),rend(v)
#define selp(a) for(auto i:a)cout<<i<<" ";cout<<nl;
#define mod(x,m) ((((x)%(m))+(m))%(m))
#define _sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(v) for(int i=0;i<_sz(v);i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
#define preci(x) fixed<<setprecision(x)
#define tc int tt=1;cin>>tt;while(tt--)
//ll MLG(ll n,ll b){ll a=0;while(n)a++,n/=b;return a-1;}

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

int inf=0x3f3f3f3f;
ll infl=0x3f3f3f3f3f3f3f3fLL;
ld infd=1.0/0.0;
const ll MOD=1e9+7;// 998244353 // = (119<<23)+1
const db pi=2*acos(0.0);

int ar1[4000+10];//1 to n
int ar2[4000+10];
int ar3[4000+10];

int main(){
    nimble
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n<3){
        cout<<0<<nl;
        return 0;
    }
    ll as=0;
    for(int i=0;i<n;i++){
        ar1[i+1]+=ar1[i];
        ar2[i+1]+=ar2[i];
        ar3[i+1]+=ar3[i];
        if(s[i]=='R'){
            ar1[i+1]=ar1[i]+1;
        }

        if(s[i]=='G'){
            ar2[i+1]=ar2[i]+1;
        }
        if(s[i]=='B'){
            ar3[i+1]=ar3[i]+1;
        }
    }
    string GG="RGB";
    for(int i=1;i<=n;i++){
        for(int k=i+2;k<=n;k++){
            if(s[i-1]!=s[k-1]){
                int q=0;
                while(q<3){
                    if(GG[q]!=s[i-1]&&GG[q]!=s[k-1]){
                        break;
                    }
                    q++;
                }
                char dd=GG[q];
                int war=0;
                if((i+k)%2==0){
                    int xx=(i+k)/2;
                    if(dd==s[xx-1])war=1;
                }
                if(dd=='R'){
                    as+=ar1[k]-ar1[i-1]-war;

                }
                else if(dd=='G'){
                    as+=ar2[k]-ar2[i-1]-war;
                }
                else as+=ar3[k]-ar3[i-1]-war;
            }
        }
    }
    cout<<as<<nl;
    return 0;
}


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

void Show_message(char button, int num)
{
  switch(button)
  {
    case '1':
      switch(num % 5)
      {
        case 1:
          cout << '.'; break;
        case 2:
          cout << ','; break;
        case 3:
          cout << '!'; break;
        case 4:
          cout << '?'; break;
        case 0:
          cout << ' '; break;
      }
      break;
    case '2':
      switch(num % 3)
      {
        case 1:
          cout << 'a'; break;
        case 2:
          cout << 'b'; break;
        case 0:
          cout << 'c'; break;
      }
      break;
    case '3':
      switch(num % 3)
      {
        case 1:
          cout << 'd'; break;
        case 2:
          cout << 'e'; break;
        case 0:
          cout << 'f'; break;
      }
      break;
    case '4':
      switch(num % 3)
      {
        case 1:
          cout << 'g'; break;
        case 2:
          cout << 'h'; break;
        case 0:
          cout << 'i'; break;
      }
      break;
    case '5':
      switch(num % 3)
      {
        case 1:
          cout << 'j'; break;
        case 2:
          cout << 'k'; break;
        case 0:
          cout << 'l'; break;
      }
      break;
    case '6':
      switch(num % 3)
      {
        case 1:
          cout << 'm'; break;
        case 2:
          cout << 'n'; break;
        case 0:
          cout << 'o'; break;
      }
      break;
    case '7':
      switch(num % 4)
      {
        case 1:
          cout << 'p'; break;
        case 2:
          cout << 'q'; break;
        case 3:
          cout << 'r'; break;
        case 0:
          cout << 's'; break;
      }
      break;
    case '8':
      switch(num % 3)
      {
        case 1:
          cout << 't'; break;
        case 2:
          cout << 'u'; break;
        case 0:
          cout << 'v'; break;
      }
      break;
    case '9':
      switch(num % 4)
      {
        case 1:
          cout << 'w'; break;
        case 2:
          cout << 'x'; break;
        case 3:
          cout << 'y'; break;
        case 0:
          cout << 'z'; break;
      }
      break;
  }
}

int main(void)
{
  int n;
  cin >> n;
  char buf_ch;
  cin >> noskipws;
  cin >> buf_ch;
  for (int i = 0; i < n; ++i)
  {
    while (true)
    {
      cin >> buf_ch;
      if (buf_ch == '\n') break;
      if (buf_ch == '0') continue;

      int sum = 1;
      char button = buf_ch;
      while (true)
      {
        cin >> buf_ch;
        if (buf_ch == '0')
        {
          Show_message(button, sum);
          break;
        }
        else
        {
          ++sum;
        }
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
// 問題の URL を書いておく
// 

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <bitset>
#include <numeric>
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;

//#define ENABLE_PRINT

template<typename T>
T Input()
{
    T v;
    cin >> v;
    return v;
}

template<typename T>
vector<T> InputVector(int n)
{
    vector<T> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    return v;
}

template<typename T>
void InputArray(T* begin, int n)
{
    for(int i = 0; i < n; ++i)
    {
        cin >> begin[i];
    }
}

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

int main(int argc, const char* argv[])
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double radA = (60 * h + m) * 2 * M_PI / 720;
    double radB = m * 2 * M_PI / 60;
    auto diff = abs(radA - radB);
    auto rad = diff > M_PI ? 2 * M_PI - diff : diff;
    auto l2 = (a * a) + (b * b) + (-2 * a * b * cos(rad));
    auto ans = sqrt(l2);
    cout << std::fixed << std::setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;
import java.text.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        new Main().run();
    }

    void run() {

        int q = sc.nextInt();
        int[][] arr = new int[q][2];
        int[] cnt = new int[100010];
        boolean[] flag = new boolean[100010];
        for (int i=0; i<q; i++) {
            arr[i][0] = sc.nextInt();
            arr[i][1] = sc.nextInt();
        }

//        System.out.println(eratosthenes(100002));

        List<Integer> primes = eratosthenes(100002);

//        System.out.println(primes.size());

        for (Integer t: primes) {
            if ( (t+1) % 2 != 0) continue;
            if (primes.contains((t+1) / 2)) flag[t] = true;
        }
        flag[2] = false;
        for (int i=1; i<cnt.length; i++) {
            if (flag[i]) {
                cnt[i] = cnt[i-1] + 1;
            } else {
                cnt[i] = cnt[i-1];
            }
        }

//        System.out.println(Arrays.toString(flag));
//        System.out.println(Arrays.toString(cnt));

        StringBuilder sb = new StringBuilder();

        for (int i=0; i<q; i++) {
            int l = arr[i][0];
            int r = arr[i][1];
            sb.append(cnt[r] - cnt[l-1] + "\n");
        }

        System.out.println(sb.toString());

    }

    List<Integer> eratosthenes(int n) {
        boolean[] flag = new boolean[n+1];
        int sqrt = (int)Math.sqrt(n);

        for (int i=2; i<=sqrt; i++) {
            if (!flag[i]) {
                for (int j=i*2; j<=n; j+=i) {
                    flag[j] = true;
                }
            }
        }

        List<Integer> list = new ArrayList<>();
        for (int i=2; i<=n; i++) {
            if (!flag[i]) list.add(i);
        }
        return list;

    }


}


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

int main()
{
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int num1,num2;
      num1 = tx-sx;
	  num2 = ty-sy;
	  for(int i = 0;i<num2;i++)
	  cout<<'U';
		
	  	
      for(int i =0;i<num1;i++)
	  
	   cout<<'R';
	  	
	  
	  for(int i =0;i<num2;i++)
	  
	    cout<<'D';
			
	 for(int i =0;i<num1;i++)
	  
	   
	   
	   cout<<'L';
	   
	  cout<<'L';
	 for(int i =0;i<num2;i++)
	  
	    cout<<'U';
			
	  
	   cout<<'U';
	   for(int i =0;i<num1;i++)
	  
	   cout<<'R';
	  	
	 
	   cout<<'R';
	   cout<<'D';
	   cout<<'R';
	   for(int i=0;i<num2;i++)
	  
	    cout<<'D';
		
	  cout<<'D';
	  for(int i=0;i<num1;i++)
	   
	   cout<<'L';
	   
	 
	  cout<<'L';
	  cout<<'U';
	  
	   return 0;
	}
	
	


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll n,c,t;
  cin>>n>>c>>t;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(all(a));
  int re=0;
  int cnt=0,mn=-MOD;
  for(int x:a){
    if(mn+t<x || cnt==c){
      ++re;
      mn=x;
      cnt=1;
    }else{
      ++cnt;
    }
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
// 125

using namespace std;

const int INF = (int) 1e9;
const int MAXN = (int) 1e5;

vector <int> g[MAXN + 1];

int cst[MAXN + 1];

bool viz[MAXN + 1];

int mn, id;

void dfs(int nod) {
    viz[nod] = 1;
    if(mn > cst[nod]) {
        mn = cst[nod];
        id = nod;
    }
    for(auto it : g[nod]) {
        if(viz[it] == 0)
            dfs(it);
    }
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, n, m, x, y;
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for(i = 1; i <= n; i++) {
        cin >> cst[i];
    }
    for(i = 1; i <= m; i++) {
        cin >> x >> y;
        x++;
        y++;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int cnt = 0;
    ll ans = 0;
    for(i = 1; i <= n; i++) {
        if(viz[i] == 0) {
            mn = INF;
            dfs(i);
            ans += mn;
            cst[id] = -1;
            cnt++;
        }
    }
    if(2 * (cnt - 1) > n) {
        cout << "Impossible";
        return 0;
    }
    sort(cst + 1, cst + n + 1);
    int need = 2 * (cnt - 1);
    for(i = 1; i <= n && need > 0; i++) {
        if(cst[i] > -1) {
            ans += cst[i];
            need--;
        }
        else
            need--;
    }
    if(cnt == 1)
        ans = 0;
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 6272
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	int n;
	int sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		sum+=i;
	printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
if sum(a) % (N * (N + 1) // 2):
  print("NO")
  exit(0)
f = 0
m = sum(a) // (N * (N + 1) // 2)
c = 0
for i in range(N):
  if m - d[i] < 0 or (m - d[i]) % N:
    f = 0
    break
  c += (m - d[i]) // N
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m
if f:
  print("YES")
else: print("NO")

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

void main_()
{
    int A, B;
    cin >> A >> B;
    int found_price = -1;

    for (int price = 1;; ++price) {
        int tax_8per = price * 8 / 100;
        int tax_10per = price * 10 / 100;
        if (A == tax_8per && B == tax_10per) {
            found_price = price;
            break;
        }
        if (tax_8per > A || tax_10per > B) {
            break;
        }
    }

    cout << found_price << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main(int argc, char *argv[]) {
	int X = 0;
	std::cin >> X;

	int max_exp = INT_MIN;
	double exp = 0;
	for (int b = 1; b <= 1000; b++) {
		for (int p = 2; p <= 10; p++) {
			exp = std::pow(b, p);
			if (exp <= X && exp <= 1000 && max_exp <= exp) {
				max_exp = exp;
			}
			if (exp >= X || max_exp >= X) {
				break;
			}
		}
	}
	std::cout << max_exp << std::endl;
	return 0;
}


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

typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
const double INF = 1e9;

bool compX(const Point a, const Point b) {
    return (a.X!=b.X ? a.X<b.X : a.Y<b.Y);
}

bool compY(const Point a, const Point b) {
    return a.Y<b.Y;
}

double closestPair(VP &a,int l,int r) {
    if(r-l<=1) return INF;
    int m = (l+r)/2;
    double x = a[m].X;
    double d = min(closestPair(a,l,m),closestPair(a,m,r));
    inplace_merge(a.begin()+l,a.begin()+m,a.begin()+r,compY);
    
    VP b;
    for(int i=l;i<r;i++){
        if(abs(a[i].X - x)>=d)continue;
        for(int j=b.size()-1;j>=0;j--){
            if((a[i]-b[j]).Y>=d)break;
            d = min(d,abs(a[i]-b[j]));
        }
        b.push_back(a[i]);
    }
    return d;
}

int main(void){
    int n;
    cin>>n;
    VP ps(n);
    rep(i,n){
        double x,y;
        cin>>x>>y;
        ps[i] = Point(x,y);
    }
    sort(all(ps),compX);
    printf("%.9f\n",closestPair(ps,0,n));
    return 0;
}

Measured memory_bytes: 7696
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,ii,jj;
  while(cin>>n>>ii>>jj,n){
    int k=n;
    ii--;jj--;
    vector<int> v;
    for(int i=0;i<n;i++){
      k--;
      //cout<<i<<":"<<(1LL<<k)<<" "<<ii<<endl;
      if(ii<(1LL<<k)){
	ii=(1LL<<k)-1LL-ii;
	v.push_back(1LL);
      }else{
	ii=ii-(1LL<<k);
	v.push_back(0);
      }
      //cout<<v[i]<<" "<<ii<<endl;;
    }
    //cout<<endl;
    reverse(v.begin(),v.end());
    k=n;
    string ans;
    for(int i=0;i<n;i++){
      k--;
      //cout<<i<<":"<<(1LL<<k)<<" "<<jj<<endl;
      if(jj<(1LL<<k)){
	if(v[i]){
	  jj=(1LL<<k)-1LL-jj;
	  ans+="L";
	}else{
	  ans+="R";
	}
      }else{
	if(v[i]){
	  jj-=(1LL<<k);
	  jj=(1LL<<k)-1LL-jj;
	  ans+="R";
	}else{
	  jj-=(1LL<<k);
	  ans+="L";
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
  int N; cin>>N;
  int sum=0;
  
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    sum+=a.at(i);
  }
  
  int x=sum/N;
  int y=sum%N;
  if(2*y>N){
    x++;
  }
  
  int cost=0;
  for(int i=0;i<N;i++){
    cost+=(a.at(i)-x)*(a.at(i)-x);
  }
  
  cout<<cost<<endl;
}

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

int main()
{ 
  int x, y, z ;
  cin >> x >> y >> z ;
  int64_t calcu = 0 ;
  int count = 0 ;
  while(calcu + z + y < x)
  {
    
    calcu += z + y ;
    if(calcu + z > x)
    {
      break ;
    }
    //cout << calcu << endl ;
    count++ ;
  }
  cout << count << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    string ans = a + b >= c ? "Yes" : "No";
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << v[0] + v[1] << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(0, n):
  ans = ans + b[a[i] - 1]
  if i != 0 and a[i] == a[i-1] + 1:
    ans = ans + c[a[i-1] - 1]
print(ans)


Measured memory_bytes: 3060
#include <iostream>
typedef long long ll;

using namespace std;


int main(){
    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    ll val, s;
    s = (D-C) * (N-1) + 1;
    //cout << s << endl; 
    val = A-C*(N-1);
    //cout << val << endl;
    //cout << val + (C+D) * N <<  endl;
    for(int i = 0; i < N; i++){
        if(val >= B && val - B < s){
            cout << "YES" << endl;
            return 0;
        }
        val += D+C;
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let mut S: Vec<char> = read::<String>().chars().collect();
    let T: Vec<char> = read::<String>().chars().collect();

    let mut ans = "UNRESTORABLE".to_string();

    if S.len() >= T.len() {
        for i in (0..S.len() - T.len() + 1).rev() {
            if S[i..i + T.len()]
                .iter()
                .zip(T.iter())
                .all(|(s, t)| s == t || *s == '?')
            {
                for (s, t) in S[i..i + T.len()].iter_mut().zip(T.iter()) {
                    *s = *t;
                }
                ans = S.iter().map(|x| if *x == '?' { 'a' } else { *x }).collect();
                break;
            }
        }
    }

    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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


ll recur(ll n){

	if(n==1)
		return 1 ;

	ll l=recur(n/2) ;

	return 2*l+1 ; 

}

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

	ll ans=recur(n) ;		
	cout<<ans ;

}

int main(){
	
	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;
 
int main () 
{
    string s,t;
    cin >> s >> t;
    int longest=0;
    int n = s.length();
    int m = t.length();
    for(int i=0;i<=n-m;i++)
    {
        int curr=0,temp=i;
        for(int j=0;j<m;j++)
        {
            if(s[temp]==t[j])
                curr++;
            temp++;
            //cout << s[i] << " " << t[j] << "\n";
        }
        longest=max(longest,curr);
    }
    //cout << m << longest << "\n";
    cout << m-longest;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    char x[1010][1010];

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

    char a[1010][1010], b[1010][1010];
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(x[i][j] == '#'){
                a[i][j] = b[i][j] = '#';
            }else{
                if(j == 0){
                    a[i][j] = '#';
                    b[i][j]= '.';
                }else if(j == w-1){
                    a[i][j] = '.';
                    b[i][j] = '#';
                }else{
                    if(i % 2 == 0){
                        a[i][j] = '#';
                        b[i][j] = '.';
                    }else{
                        a[i][j] = '.';
                        b[i][j] = '#';
                    }
                }
            }
        }
    }

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << a[i][j];
        }
        cout << endl;
    }

    cout << endl;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            cout << b[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
import java.math.*;
import java.io.*;
 
class Main {
	static final int INF = 2 << 29;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++) {
			list.add(sc.nextInt() * 60 + sc.nextInt());
		}
		int m = sc.nextInt();
		for(int i = 0; i < m; i++) {
			list.add(sc.nextInt() * 60 + sc.nextInt());
		}
		Collections.sort(list);
		int past = list.get(0);
		int tmp = list.get(0);
		int h = tmp/60;
		tmp -= h*60;
		System.out.print(h + ":" + ((tmp < 10)?"0":"") + tmp);
		
		for(int i = 1; i < list.size(); i++) {
			if(list.get(i) == past) continue;
			past = list.get(i);
			tmp = list.get(i);
			h = tmp/60;
			tmp -= h*60;
			System.out.print(" " + h + ":" + ((tmp < 10)?"0":"") + tmp);
		}
		System.out.println();
		

	}
}
             
        

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

using namespace std;
using ll = long long;


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);

    int R = 1;
    for(int i = 1; i < n; i++) {
        if(s[i] == 'R')R++;
        else {
            int j = i;
            while(s[j] == 'L' && j < n)j++;
            int L = j - i;
            ans[i - 1] += (L) / 2;
            ans[i - 1] += (R + 1) / 2;
            ans[i] += (L + 1)/ 2;
            ans[i] += R / 2;
            //cerr << i << " : " << j << "R : " << R << "L :" << L << endl;
            i = j;
            R = 1;
        }
    }
    for(int i = 0; i < n; i++)cout << ans[i] << " ";

}

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

def main():
    na = list(map(int, input().split()))
    N, M = na[0], na[1]
    A = list(map(int, input().split()))

    r = 0
    t = 0
    d = {}
    d[0] = 1
    for i in range(N):
        t += A[i]
        t %= M
        if t in d:
            d[t] = d[t] + 1
        else:
            d[t] = 1

    for v in d.values():
        r += int(v * (v - 1) / 2)


    print(r)


if __name__ == '__main__':
    main()



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

int main() {
  long long n,dig,num,all = 0;
  int i;
  cin >> n;
  n--;
  for(i = 1;;i++){
    all+= (long long)pow(26,i);
    if(n < all)break;
  }
  all -= (long long)pow(26,i);
  dig = i;
  if(n >= 26)n -= all;

  vector<int> name(dig,0);
  for(i = 0;i < dig;i++){
    num = n % 26;
    name[(dig - 1) - i] = num;
    n /= 26;
  }

  for(i = 0;i < dig;i++){
    cout << (char)(name[i] + 'a'); 
  }
  cout << endl;
}


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n, x;
int a[MAXN];
bool used[MAXN];

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d%d", &n, &x );
}

void work ()
{
	// main work
	
	if ( n == 2 ){
		if ( x == 2 ) printf ( "Yes\n1\n2\n3\n" );
		else printf ( "No\n" );
		return;
	}
	
	if ( x == 1 || x == 2 * n - 1 ){
		printf ( "No\n" );
		return;
	}
	
	if ( x < 2 * n - 2 ){
		a[n] = x;
		a[n-1] = x - 1, a[n-2] = x + 1, a[n+1] = x + 2;
		used[x-1] = used[x] = used[x+1] = used[x+2] = true;
	}else if ( x == 2 * n - 2 ){
		a[n] = x;
		a[n-1] = x + 1, a[n-2] = x - 1, a[n+1] = x - 2;
		used[x-2] = used[x-1] = used[x] = used[x+1] = true;
	}
	
	printf ( "Yes\n" );
	int nc = 0;
	lpi ( i, 1, 2 * n - 1 ){
		if ( a[i] ) continue;
		++nc;
		while ( used[nc] ) ++nc;
		a[i] = nc;
	}
	lpi ( i, 1, 2 * n - 1 ) printf ( "%d\n", a[i] );
}

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

const int MAXN = 300+10;
int Keep[MAXN][MAXN];
bool vis[MAXN];
int cnt[MAXN];
int main()
{
    int N,M;
    scanf("%d%d",&N,&M);
    for(int i=1;i<=N;i++)
        for(int j=1;j<=M;j++)
            scanf("%d",&Keep[i][j]);
    for(int i=1;i<=M;i++) vis[i]=true;
    int Rem=M;
    int Maxm,ans=100000;
    while(Rem)
    {
        memset(cnt,0,sizeof cnt);
        for(int i=1;i<=N;i++)
            for(int j=1;j<=M;j++)
            {
                if(vis[Keep[i][j]])
                {
                    cnt[Keep[i][j]]++;
                    break;
                }
            }
        Maxm=-1;
        for(int i=1;i<=M;i++)   if(vis[i])  Maxm=(Maxm==-1)?(i):((cnt[i]>cnt[Maxm])?(i):Maxm);
        ans=min(cnt[Maxm],ans);
        vis[Maxm]=false;
        Rem--;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
using ll = int64_t;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(auto& i : a) cin >> i;
    if(any_of(a.begin(), a.end(), [](ll x){ return !x; })) return !puts("0");
    int128_t s = 1;
    for(auto& i : a){
        s *= i;
        if(s > 1'000'000'000'000'000'000) return !puts("-1");
    }
    cout << s << endl;
}

Measured memory_bytes: 3996
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  std::string S, T;
  std::cin >> S;
  std::cin >> T;
  int A, B;
  scanf("%d",&A);
  scanf("%d",&B);
  std::string U;
  std::cin >> U;
  if (S==U){
    printf("%d %d\n", A-1, B);
  } else if (T==U) {
    printf("%d %d\n", A, B-1);
  }
  return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
for i in range(N+1):
	# 現在i*Mだけ黒。1列ボタンを押すと黒はi消えN-i増える
	# あと求めたい黒の数
	a = K - i*M
	if a == 0:
		print("Yes")
		exit()
	# いま作成可能な1列あたりの黒
	b = N - 2*i
	if b != 0:
		if a%b == 0 and a*b > 0 and a//b < M:
			print("Yes")
			exit()
		
print("No")

Measured memory_bytes: 9000
Scanf.scanf "%2d%2d" @@ fun n1 n2 ->
  let yymm = 1 <= n2 && n2 <= 12 in
  print_endline @@
    if 1 <= n1 && n1 <= 12 then
      if yymm then "AMBIGUOUS"
      else "MMYY"
    else if yymm then "YYMM"
    else "NA"

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int N;
   cin >> N;
   string S;
   cin >> S;
   int count=0;
   for(int i=0;i<N-2;i++){
       if((S.at(i)=='A')&&(S.at(i+1)=='B')&&(S.at(i+2)=='C')){
           count++;
       }
   }
   cout << count << endl;
}


Measured memory_bytes: 3588
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC131
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
 const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__




void solve(void){
  
  int N, L;
    
  cin >> N >> L;
  
  vector<int> T(N);
  
  int sum=0;
  int ans=0;
  
  int mint=INF;
  
  REP2(i,1,N+1){
    T[i-1]=L+i-1;
    sum += T[i-1];
  }
  
  REP(i,N){
    if(mint>abs(sum-(sum-T[i]))){
      mint = abs(sum-(sum-T[i]));
      ans=sum-T[i];
    }
  }
  
  cout << ans << endl;
  
  return;
}

#define TESTCASES 1

int main(int argc, const char * argv[]) {


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

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define df 0

const double pi=acos(-1.0);

bool foword(double dx,double dy,int x,int y){
  return dx*x+dy*y>0;
}

long int norm(long int x,long int y){
  return x*x+y*y;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >> n;
  pair<int,int> engs[n];
  for(auto& eng:engs){
    cin >> eng.first >> eng.second;
  }
  long int max_d=0;
  for(int i=0;i<4000;i++){
    double dx=cos(pi*i/2000),dy=sin(pi*i/2000);
    long int x=0,y=0,temp=0;
    for(auto& eng:engs){
      if(foword(dx,dy,eng.first,eng.second)){
	x+=eng.first;
	y+=eng.second;
	temp=norm(x,y);
	if(max_d<temp){
	  max_d=temp;
	}
      }
    }
  }
  printf("%.15lf",sqrt(max_d));
}

/// confirm df==0 ///

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc;
	public void run(){
		sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			int n = sc.nextInt();
			if(n != 0){
				calc(n);
			}
			else{
				break;
			}
		}
	}
	public void calc(int n){
		HashMap<String, String[]> groups = new HashMap<String, String[]>();
		HashMap<String, Integer> members = new HashMap<String, Integer>();
		
		int count = 0;
		String first = "";
		
		for(int i = 0; i < n; i++){
			String line = sc.next();
			String lines = line.substring(0, line.length()-1);
			String[] g = lines.split(":");
			String group = g[0];
			String[] member = g[1].split(",");
			if(i == 0) first = group;
			
			groups.put(group, member);
		}
		
		ArrayList<String> list = new ArrayList<String>();
		list.add(first);
		
		while(list.size() != 0){
			String group = list.get(0);
			list.remove(0);
			String[] member = groups.get(group);
			for(int i = 0; i < member.length; i++){
				String m = member[i];
				if(groups.containsKey(m)) {
					list.add(m);
				}
				else if(!members.containsKey(m)){
					members.put(m, 1);
					count++;
				}
			}
			groups.put(group, new String[]{});
		}
		System.out.println(count);
	}
	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 43368
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
char S[1000010],T[1000010],nT[1000010];
int pT[1000010],st[1000010];
int f[1000010],g[1000010];
int que[1000010],hd,tl,tag;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=0;
	scanf("%s",S+1);scanf("%s",T+1);
	for(int l=1,r;l<=n;l=r+1){
		r=l;while(T[r+1]==T[l])++r;
		nT[++m]=T[l],pT[m]=l;
	}
	f[n+1]=m+1;
	for(int i=n;i;--i){
		f[i]=f[i+1];
		if(S[i]==nT[f[i]-1]&&i<=pT[f[i]-1])--f[i];
	}
	if(f[1]!=1)return puts("-1"),0;
	bool flg=1;
	for(int i=1;i<=n;++i)if(S[i]!=T[i])flg=0;
	if(flg)return puts("0"),0;
	int ans=0;
	int o=0;
	for(int i=1;i<=n;++i)if(f[i]!=f[i+1])st[++o]=i;
	for(int i=m;i;--i){
		--tag;
		que[tl++]=st[i]-tag;
		while((hd^tl)&&pT[i]<=que[hd]+tag)++hd;
		ans=std::max(ans,tl-hd);
	}
	printf("%d\n",ans+1);
	return 0;
}


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

int main()
{
    int64_t N;
    cin >> N;

    if (N & 1)
    {
        cout << 0 << endl;
        return 0;
    }

    int64_t res = 0;
    int64_t p = 10;
    while (N / p > 0)
    {
        res += N / p;
        p *= 5;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
from bisect import bisect_left as bisect
def resolve():
    n=int(input())
    S=input()
    C=[[] for _ in range(10)]
    for i,s in enumerate(S):
        C[int(s)].append(i)

    ans=0
    for i in range(1000):
        i=str(i)
        i=i.zfill(3)
        now=0
        flag=True
        for d in i:
            d=int(d)
            j=bisect(C[d],now)
            if(j==len(C[d])):
                flag=False
                break
            now=C[d][j]+1
        ans+=flag
    print(ans)
resolve()

Measured memory_bytes: 42860
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N,M;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>M;
	int32_t npow = 1;
	for (int32_t i = 0; i < N; i++)
	{
		npow *= 2;
	}
	if (N == 0) {
		if (M == 0) {
			out << "0 0" << endl;
		}
		else {
			out << "-1" << endl;
		}
		return 0;
	}
	if (N == 1) {
		if (M == 0) {
			out << "0 0 1 1" << endl;
		}
		else {
			out << "-1" << endl;
		}
		return 0;
	}

	if (npow-1 < M) {
		out << "-1" << endl;
		return 0;
	}

	out << M;
	for (int32_t i = 0; i < npow; i++)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << ' ' << M;
	for (int32_t i = npow-1; i >= 0; --i)
	{
		if (i == M) { continue; }
		out << ' ' << i;
	}
	out << endl;

	return 0;
}
#endif


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int64 gcd(int64 a, int64 b) { return b? gcd(b,a%b):a; };
int64 lcm(int64 a, int64 b) { return a/gcd(a,b)*b; };

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

    bool ans = true;
    int64 l = lcm(n,m);
    map<int64, char> x;
    for (int64 i=0; i<n; i++) {
        x[i*(l/n)] = s[i];
    }

    for (int64 i=0; i<m; i++) {
        int index = i * (l/m);
        if (x[index] && x[index] != t[i])
            ans = false;
        x[index] = t[i];
    }

    cout << (ans? l : -1 ) << endl;
}


Measured memory_bytes: 10880
#include<stdio.h>
int main(){

	double i, k, x, y;
	double a, b, c, d, e, f;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
		x = (e*c-b*f)/(a*e-b*d);
		y = (-d*c+a*f)/(a*e-b*d);;
		if(x == -0)
			x =0;
		if(y == -0)
			y=0;
		printf("%.3lf %.3lf\n", x, y);
	}
	return 0;
}

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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const int N = 12;
string p, res;
int q[11] = {2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6};

int check(int d, int k) {
  int res = 0;
  p[k] = d+'0';
  REP(i,N-1) res += (int)(p[i]-'0')*q[i];
  res %= 11;
  res = (res<=1) ? 0 : 11-res;
  return res;
}

int main() {
  reverse(q, q+11);
  cin >> p;
  int k;
  REP(i,N) {
    if (p[i]=='?') {
      k = i;
      break;
    }
  }

  int res_d = 0;
  int cnt = 0;
  REP(d,10) {
//    if (k==0) continue;
    if (check(d, k)==p[11]-'0') {
      res = p;
      res[k] = '0'+d;
//cout << res << endl;
//cout << d << endl;
      res_d = d;
      cnt++;
    }
  }

  if (cnt>1) cout << "MULTIPLE" << endl;
  else cout<< res_d << endl;

  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
char s1[100005];
char s2[5];
char s3[600005];
char c[200005];
int a[200005];
int b[200005];
int main()
{
	scanf("%s",s1);
	int len=strlen(s1);
	int n;
	int num=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==1)
		{
			num++;
		}
		else
		{
			scanf("%d",&b[i]);
			scanf("%s",s2);
			c[i]=s2[0];
		}
	}
	int l=300001;
	int r=l+len-1;
	if(num%2==0)
	{
		for(int i=0;i<len;i++)
		{
			s3[i+l]=s1[i];
		}
	}
	else
	{
		for(int i=0;i<len;i++)
		{
			s3[i+l]=s1[len-1-i];
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			num--;
		}
		else
		{
			if(b[i]==1)
			{
				if(num%2==0)
				{
					l--;
					s3[l]=c[i];
				}
				else
				{
					r++;
					s3[r]=c[i];
				}
			}
			else
			{
				if(num%2==0)
				{
					r++;
					s3[r]=c[i];
				}
				else
				{
					l--;
					s3[l]=c[i];
				}
			}
		}
	}
	r++;
	s3[r]='\0';
	puts(&(s3[l]));
	return 0;
}


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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    int a, b, c;
    vector<int> topping;
    n = in();
    a = in();
    b = in();
    c = in();
    rep(i, n) topping.push_back(in());
    sort(topping.begin(), topping.end(), greater<int>());
    int total_cost = a;
    int total_calory = c;
    double best = (double)c / a;
    rep(i, n){
        total_cost += b;
        total_calory += topping[i];
        if (best + 1e-8 < (double)total_calory / total_cost){
            best = (double)total_calory / total_cost;
        }
        else {
            break;
        }
    }
    printf("%.lf\n", floor(best));
    return (0);
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;

    vector<pii> ans;
    REP(i,1,n){
        REP(j,i+1,n+1){
            if(i == j) continue;
            if(n & 1){
                if(i+j == n) continue;
            }else{
                if(i+j == n+1) continue;
            }
            ans.emplace_back(i,j);
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans){
        cout << p.fi << " " << p.se << endl;
    }
    return 0;
}

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

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    long a, b, c;
    scanf("%ld %ld %ld", &a, &b, &c);

    long max = MAX(MAX(a,b),c);
    long tmp = (max-a)+(max-b)+(max-c);
    if(tmp%2==0) {
        printf("%ld\n", tmp/2);
    }
    else {
        printf("%ld\n", (tmp+3)/2);
    }

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
    vector<int>d(N);
  for(int i=0;i<N;i++)
    cin>>d.at(i);
  sort(d.begin(),d.end());
  cout<<d.at(N/2)-d.at(N/2-1)<<endl;

return 0;
}

Measured memory_bytes: 640