akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

typedef struct {
    int ty;
    int tx;
    int sharp;
} POINT;

POINT queue[10000000];
int head, tail;

void enq(POINT t)
{
    queue[tail++] = t;
    if (tail == 10000000){
        tail = 0;
    }
}

void deq(POINT *t)
{
    *t = queue[head++];
    if (head == 10000000){
        head = 0;
    }
}

int main(void)
{
    POINT temp, add;
    int ans;
    int i, j;
    int x, y;
    int mx, my;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    int cost[102][102];
    char map[102][103];
    
    while (1){
        scanf("%d%d", &x, &y);
        
        if (x + y == 0){
            break;
        }
        getchar();
        
        memset(map, '.', sizeof(map));
        
        for (i = 1; i <= y; i++){
            for (j = 1; j <= x; j++){
                scanf("%c", &map[i][j]);
                
                if (map[i][j] == '&'){
                    temp.tx = j;
                    temp.ty = i;
                }
            }
            getchar();
        }
        
        for (i = 0; i <= y + 1; i++){
            for (j = 0; j <= x + 1; j++){
                cost[i][j] = 100000;
            }
        }
        
        cost[temp.ty][temp.tx] = 0;
        temp.sharp = 0;
        head = tail = 0;
        enq(temp);
        ans = 100000;
        
        while (head != tail){
            deq(&temp);
            
            if (0 == temp.tx || 0 == temp.ty || x + 1 == temp.tx || y + 1 == temp.ty){
                ans = (ans > temp.sharp ? temp.sharp : ans);
                continue;
            }
            
            for (i = 0; i < 4; i++){
                mx = temp.tx + dx[i];
                my = temp.ty + dy[i];
                add = temp;
                if (cost[my][mx] > add.sharp){
                    if ((map[my][mx] == '.') && map[temp.ty][temp.tx] == '#'){
                        add.sharp++;
                    }
                    cost[my][mx] = add.sharp;
                    add.tx = mx;
                    add.ty = my;
                    enq(add);
                }
            }
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    int n;
    cin >> n;
    int d[1010] = {};
    rep(i, 0, n){
        int s, t;
        cin >> s >> t;
        d[s]++; d[t]--;
    }
    rep(i, 1, 1010){
        d[i] += d[i - 1];
    }
    bool f = true;
    rep(i, a, b){
        if(d[i] != 0) f = false;
    }
    cout << !f << endl;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    ll h; cin >> h;
    ll r = 0;
    while(h>1) { h/=2; r++; }
    ll ans = 1LL;
    rep(i, r+1) ans *= 2;
    ans--;
    cout << ans << endl;
    
    return 0;
}



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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

bool isOk(int v, int t) {
  if (v >= t) {
    return true;
  }
  return false;
}

bool hasRootToN(int v, vector<P> &ab, int n) {
  int ok = ab.size();
  int ng = -1;
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;
    if (isOk(ab[mid].first, v)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }
  while (ok < n && ab[ok].first == v) {
    if (ab[ok].second == n - 1) {
      return true;
    }
    ok++;
  }

  return false;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> ab(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    ab[i] = make_pair(a, b);
  }
  sort(ab.begin(), ab.end());
  bool ok = false;
  rep(i, m) {
    if (ab[i].first != 0) {
      break;
    }
    if (hasRootToN(ab[i].second, ab, n)) {
      ok = true;
    }
  }

  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE ") << endl;

  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.CodeFes2017QA
{
    class PalindromicMatrix
    {
        public static void Main()
        {
            var dic = new Dictionary<char, int>();
            for (var c = 'a'; c <= 'z'; ++c) dic.Add(c, 0);
            var hw = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_));
            var h = hw.First(); var w = hw.Last();
            for (var i = 0; i < h; ++i)
                foreach (var c in ReadLine().Trim())
                    dic[c]++;
            if (h % 2 == 0 && w % 2 == 0) {
                if (dic.All(_ => _.Value % 4 == 0)) WriteLine("Yes");
                else WriteLine("No");
            }else if (h % 2 == 1 && w % 2 == 1) {
                if (dic.Where(_ => _.Value % 2 == 1).Count() == 1 && dic.Where(_ => _.Value % 4 == 2).Count() * 2 <= h + w - 2) WriteLine("Yes");
                else WriteLine("No");
            }
            else {
                if (dic.All(_ => _.Value % 2 == 0) && dic.Where(_ => _.Value % 4 == 2).Count() * 2 <= (h % 2 == 0 ? h : w)) WriteLine("Yes");
                else WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int n, a;
int mymin = 0;
vector<int> cnt(9, 0);
 
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        int j = min(a / 400, 8);
        cnt[j]++;
        if (cnt[j] == 1 && j < 8)
            mymin++;
    }
    if (mymin == 0) cout << 1;
    else cout << mymin;
    cout << ' ' << mymin + cnt[8] << endl;
}

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

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

	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	//cout << s << " " << t << endl;

	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}


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

int main(){
  int n, k, cnt=0;
  cin >> n >> k;
  rep(i, n){
    int h;
    cin >> h;
    if(h>=k)cnt++;
  }

  cout << cnt << endl;

  return 0;
}

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

using Graph=vector<vector<int>>;

int main(){
  int N,M;
  cin >> N >> M;
  
  Graph G(N);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    G.at(A).push_back(B);
    G.at(B).push_back(A);
  }
  
  vector<int> dist(N,-1);
  vector<int> prev(N,-1);
  queue<int> q;
  q.push(0);
  dist.at(0)=0;
  while(!q.empty()){
    int P=q.front();
    q.pop();
    for(int a:G.at(P)){
      if(dist.at(a)==-1){
        dist.at(a)=dist.at(P)+1;
        prev.at(a)=P;
        q.push(a);
      }
    }
  }
  cout << "Yes" << endl;
  for(int i=1;i<N;i++){
    cout << prev.at(i)+1 << endl;
  }
}

Measured memory_bytes: 10648
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	Int N;
	cin >> N;

	string S;
	cin >> S;

	Int ans = 0;
	Int temp;
	/*vector<Int> x;
	vector<Int> y;*/
	for (Int i = 1; i < N; i++) {
		/*x.resize(26, 0LL);
		y.resize(26, 0LL);*/

		vector<Int> x(26);
		vector<Int> y(26);

		for (Int j = 0; j < i; j++) {
			x[S[j] - 'a']++;
		}
		for (Int j = i; j < N; j++) {
			y[S[j] - 'a']++;
		}

		DMP(x, y);

		temp = 0;
		for (Int j = 0; j < 26; j++) {
			if (x[j]&&y[j]) {
				temp++;
			}
		}

		ans = max(ans, temp);
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    rep(i,5){
        lli k;
        cin>>k;
        if(k==0){
            out(i+1);
            break;
        }
    }
}

Measured memory_bytes: 3580
def password(O: str, E: str)->str:
    ret = ''
    for i in range(len(E)*2):
        if i % 2:
            ret += E[i//2]
        else:
            ret += O[i//2]
    return ret + (O[-1] if len(E) < len(O) else '')


if __name__ == "__main__":
    O = input()
    E = input()
    ans = password(O, E)
    print(ans)


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

int main()
{
	int a,b,d,r ;
	double f ;

	cin >> a >> b ;

	d = a / b ;
	r = a % b ;
	f = (1.0 * (double)a) / (double)b ;

	cout << d << ' ' << r << ' ' << fixed << f <<endl; 

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b)
	{
		if(c<d)
		{
			printf("%d",a+c);
		}
		else
		{
			printf("%d",a+d);
		}
	}
	else
	{
		if(c<d)
		{
			printf("%d",b+c);
		}
		else
		{
			printf("%d",b+d);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fr(dt,i,a,b) for(dt i=a;i<b;i++)
#define f0(a,b) for(int i=a;i<b;i++)
#define fn(b,a) for(int i=b;i>a;i--)
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define ret return
#define pb push_back
#define pf push_front
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define UL9 1000000007
#define UL5 100007
#define INF 1e9+7
#define PI 3.1415926
#define SQ(a) (a)*(a)
#define fst first
#define scd second
typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef long long int lli;  //  e-18 to e18
int main(){
    fastIO();
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=(a+d-1)/d;
    int y=(c+b-1)/b;
    cout<<(x>=y?"Yes":"No")<<"\n";    
    ret 0; 
}                                                             

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;


constexpr double EPS = 1e-10;
using Point = complex<double>;
using Line  = pair<Point, Point>;
using Polygon = vector<Point>;
bool compare(const Point &a, const Point &b) { // x ascending order
    if(a.real() != b.real()) return a.real() < b.real();
    return a.imag() < b.imag();
};

double dot(Point p, Point q) { return (conj(p) * q).real(); }
double cross(Point p, Point q) { return (conj(p) * q).imag(); }

Polygon convex_hull(Polygon &ps) {
    sort(ps.begin(), ps.end(), compare);
    int n = (int)ps.size(), k = 0;
    Polygon res(n * 2);

    // use "< -EPS" if include corner or boundary, otherwise, use "< EPS"
    for(int i = 0; i < n; res[k++] = ps[i++]) 
        while(k >= 2 && cross(res[k-1] - res[k-2], ps[i] - res[k-1]) < -EPS) --k; 

    for(int i = n - 2, t = k+1; i >= 0; res[k++] = ps[i--])
        while(k >= t && cross(res[k-1] - res[k-2], ps[i] - res[k-1]) < -EPS) --k;

    res.resize(k - 1);
    return res;
}

double caliper(Polygon &ps) {
    ps = convex_hull(ps);
    int n = (int)ps.size();
    if(n == 2) {return abs(ps[0] - ps[1]);}
    
    int i = 0, j = 0;
    // j --> (x asc order) --> i
    for(int k=0; k < n; ++k) {
        if(compare(ps[i],ps[k])) i = k;
        if(compare(ps[k],ps[j])) j = k;
    }

    int si = i, sj = j;
    double res = 0.0;
    // rotate 180 degrees
    while(i != sj || j != si) {
        res = max(res, abs(ps[i] - ps[j]));
        if(cross(ps[(i + 1) % n] - ps[i], ps[(j + 1) % n] - ps[j]) < 0) {
            i = (i + 1) % n;
        } else {
            j = (j + 1) % n;
        }
    }

    return res;
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n; cin >> n;
    cout << fixed << setprecision(10);
    Polygon ps;
    for(int i=0; i < n; ++i) {
        double x,y;cin >> x >> y;
        ps.emplace_back(x,y);
    }
    cout << caliper(ps) << '\n';
    return 0;
}



Measured memory_bytes: 6864
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    string s;
    cin >> s;
    if ((s.front() == s.back()) ^ (s.size() % 2 == 0)) {
        cout << "Second"
             << "\n";
    } else {
        cout << "First"
             << "\n";
    }
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> odd(n / 2), even(n / 2);
    rep (i, n / 2) {
        cin >> odd[i];
        cin >> even[i];
    }

    vector<int> cnt1(200000), cnt2(200000);

    rep (i, n / 2) {
        cnt1[odd[i]]++;
        cnt2[even[i]]++;
    }

    auto max1 = max_element(all(cnt1));
    auto max_pos1 = distance(cnt1.begin(), max1);
    auto max2 = max_element(all(cnt2));
    auto max_pos2 = distance(cnt2.begin(), max2);
    sort(all(cnt1), greater<int>());
    sort(all(cnt2), greater<int>());

    if (max_pos1 != max_pos2)
        print(n - cnt1[0] - cnt2[0]);
    else {
        if (cnt1[0] + cnt2[1] < cnt1[1] + cnt2[0])
            print(n - cnt1[1] - cnt2[0]);
        else
            print(n - cnt1[0] - cnt2[1]);
    }

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"

using namespace std;

#define sp(x) cout<<setprecision(x);
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define lint long long
#define FOR(i,a,b) for(lint i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define yes "Yes"
#define no "No"
#define divs 1000000007
#define dive 1000000009

typedef pair<int, int> P;

lint ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
	string s; cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]) cout<<yes<<endl;
	else cout<<no<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#define ll long long
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 200000
#define INF 1e12

using namespace std;

ll n,k,q,ar[N],ans = INF;

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

    rep(i,0,n)
    {
        cin >> ar[i];
    }

    rep(i,0,n)
    {
        ll s = ar[i];
        multiset < ll > nums;
        multiset < ll > possible;

        rep(j,0,n)
        {
            if(ar[j] < s)
            {
                while(nums.size() >= k)
                {
                    possible.insert(*(nums.begin()));
                    nums.erase(nums.begin());
                }

                nums.clear();
            }
            else
                nums.insert(ar[j]);
        }

        while(nums.size() >= k)
        {
            possible.insert(*(nums.begin()));
            nums.erase(nums.begin());
        }

        nums.clear();

        ll mini = (possible.empty()) ? -1 : *(possible.begin());
        ll maxi = mini;

        rep(j,0,q)
        {
            if(possible.empty())
            {
                maxi = INF;
                break;
            }

            maxi = *(possible.begin());
            possible.erase(possible.begin());
        }

        ans=min(ans,maxi-mini);
    }

    cout << ans;

    return 0;
}



Measured memory_bytes: 384
import sys
from functools import reduce
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res


N = n_in()
A = l_in()

C = [0 for _ in range(N)]

for a in A:
    C[a-1] += 1

res = reduce(lambda memo, c: memo+c*(c-1)//2, C, 0)

for a in A:
    c = C[a-1]
    print(res - c*(c-1)//2 + (c-1)*(c-2)//2)



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in(), k = in();
    vint l = in(n);
    sort(ALL(l), greater<int>());
    int ans = accumulate(l.begin(), l.begin() + k, 0);
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime = get_sieve_of_eratosthenes_new(10**6)
for num in prime:
    if num >= X:
        print(num)
        break


Measured memory_bytes: 52460
#include <bits/stdc++.h>
using namespace std;
#define INF 100005
#define maxx 1000000000000

int n;
long long a[INF][3];
long long mem[INF][3];

long long rec(int level,int pre)
{
    if(level==n) return 0;
    if(mem[level][pre]!=-1) return mem[level][pre];
    long long now=0;
    if(pre==0)
    {
        now=max(now,max(a[level][0]+rec(level+1,1),a[level][0]+rec(level+1,2)));
    }else
    if(pre==1)
    {
        now=max(now,max(a[level][1]+rec(level+1,0),a[level][1]+rec(level+1,2)));
    }else
    if(pre==2)
    {
        now=max(now,max(a[level][2]+rec(level+1,0),a[level][2]+rec(level+1,1)));
    }
    return mem[level][pre]=now;
}

int main()
{
    memset(mem,-1,sizeof(mem));
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld%lld",&a[i][0],&a[i][1],&a[i][2]);
    }
    long long ans=max(rec(0,0),max(rec(0,1),rec(0,2)));
    printf("%lld\n",ans);
}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstring>
#include <vector>

using namespace std;

long long n , m , k ;

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

    long long t = n ;
    n = max((long long)0,n-k);
    k -= t ;    //还剩多少步
    if( k > 0 )
        m = max((long long)0,m-k);

    cout << n << " " << m << endl;

    return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
struct state {
	int sx, sy, cost;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int R, H[2], W[2], sx[2], sy[2], a[2][509][509], cnt[2], b[2][250009]; bool vis[509][509];
int dir[] = { 0, 1, 0, -1 };
int main() {
	while (scanf("%d", &R), R) {
		for (int i = 0; i < 2; i++) {
			scanf("%d%d%d%d", &W[i], &H[i], &sy[i], &sx[i]); sy[i]--, sx[i]--;
			for (int j = 0; j < H[i]; j++) {
				for (int k = 0; k < W[i]; k++) {
					scanf("%d", &a[i][j][k]);
					vis[j][k] = false;
				}
			}
			priority_queue<state> que; que.push(state{ sx[i], sy[i], -1 });
			vis[sx[i]][sy[i]] = true; cnt[i] = 1;
			while (!que.empty()) {
				state u = que.top(); que.pop();
				b[i][cnt[i]++] = a[i][u.sx][u.sy];
				for (int j = 0; j < 4; j++) {
					int tx = u.sx + dir[j], ty = u.sy + dir[j ^ 1];
					if (0 <= tx && tx < H[i] && 0 <= ty && ty < W[i] && !vis[tx][ty]) {
						a[i][tx][ty] = max(a[i][tx][ty], a[i][u.sx][u.sy]);
						vis[tx][ty] = true;
						que.push(state{ tx, ty, -a[i][tx][ty] });
					}
				}
			}
		}
		int ret = 2000000009;
		for (int i = 0; i <= H[0] * W[0]; i++) {
			int z = max(R - i, 0);
			if (z > H[1] * W[1]) continue;
			ret = min(ret, b[0][i] + b[1][z]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 7120
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CMitsui solver = new CMitsui();
        solver.solve(1, in, out);
        out.close();
    }

    static class CMitsui {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();
            int num = x / 100;
            int kosu = ((x % 100) + 4) / 5;
            out.println(num < kosu ? "0" : "1");
        }

    }
}



Measured memory_bytes: 23764
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define from1(obj) obj.begin() + 1, obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbp(p) cerr << #p << ":(" << p.first << ", " << p.second << ") "
#define dbpl(p) cerr << #p << ":(" << p.first << ", " << p.second << ")\n"
#define dbt3(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ") "
#define dbt3l(t3) cerr << #t3 << ":(" << get<0>(t3) << ", " << get<1>(t3) << ", " << get<2>(t3) << ")\n"
#define dbt4(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ") "
#define dbt4l(t4) cerr << #t4 << ":(" << get<0>(t4) << ", " << get<1>(t4) << ", " << get<2>(t4) << ", " << get<3>(t4) << ")\n"
#define dbv(vec) cerr << #vec << ":{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"
#define dbvv(vv) cerr << #vv << ":{\n"; for (auto vec : vv) { cerr << "{ "; for (auto e : vec) cerr << e << ", "; cerr << "}\n"; } cerr << "}\n"
#define dbm(map) cerr << #map << ":{ "; for (auto p : map) cerr << "(" << p.first << ", " << p.second << "), "; cerr << "}\n"
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>; using vl = vector<ll>; using vs = vector<string>; using vb = vector<bool>;
using vvi = vector<vi>; using vvl = vector<vl>; using vvb = vector<vb>;
using pii = pair<int, int>; using pil = pair<int, ll> ; using pll = pair<ll, ll>; using pli = pair<ll, int>;
using vpii = vector<pii>; using vpll = vector<pll>;
using ti3 = tuple<int, int, int>; using tl3 = tuple<ll, ll, ll>;
using ti4 = tuple<int, int, int, int>; using tl4 = tuple<ll, ll, ll, ll>;
using mii = map<int, int>; using mil = map<int, ll>; using mll = map<ll, ll>; using mli = map<ll, int>;

int main() {
	int A, B, C; cin >> A >> B >> C;
	int X, Y; cin >> X >> Y;
	int ans = 0;
	int m = min(X, Y);
	ans += m * min(A + B, 2 * C);
	X -= m; Y -= m;
	if (X) {
		ans += X * min(A, 2 * C);
	} else {
		ans += Y * min(B, 2 * C);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())


def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = list(set(table))
    return table


S = sorted(list(set(divisor(A)) & set(divisor(B))), reverse=True)
print(S[K - 1])

Measured memory_bytes: 3060
#include<iostream>

int main(){
    int a,b,c;
    std::cin>>a>>b>>c; 
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        int tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        int tmp=a;
        a=b;
        b=tmp;

    }
    std::cout<<a<<" "<<b<<" "<<c<<"\n";

}


Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
     double a;
    cin>>a;
    printf("%.17lf",2*pi*a);
    return 0;
}


Measured memory_bytes: 3728
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	K := NextInt()
	Q := NextInt()
	A := NextInts(Q)

	thre := Q - K + 1

	cnt := make([]int, N)
	for _, a := range A {
		cnt[a-1] = cnt[a-1] + 1
	}

	for _, c := range cnt {
		if c >= thre {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextInts(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt()
	}
	return a
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func Bounded(lower, n, upper int) int {
	return Min(upper, Max(lower, n))
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}


Measured memory_bytes: 4864
# -*- coding: utf-8 -*-
x1,y1,x2,y2 = input().split()
x1 = int(x1)
y1 = int(y1)
x2 = int(x2)
y2 = int(y2)

x3 = (y1 - y2) + x2
y3 = (x2 - x1) + y2
x4 = (y2 - y3) + x3
y4 = (x3 - x2) + y3

print(x3, y3, x4, y4)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;


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

    ll n;
    cin>>n;
    set<ll> s;
    for(ll i=0;i<n;++i){
        ll x;
        cin>>x;
        s.insert(x);
    }
    if(s.size()==n){cout<<"YES";}
    else{cout<<"NO";}

    return (0);
}


Measured memory_bytes: 9600
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>

using namespace std;

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

    int x,y,z,rec=0;
    for(int i=0;i<=a;++i){
        for(int j=0;j<=a;++j){
            x = i;
            y = j;
            z = b-x-y;
            if(z<=a && z>=0)++rec;
        }
    }
    cout<<rec;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back
 
using namespace std;

int main(){


    int a,b,c;
    cin >> a >> b >> c;

    int ans = c - (a - b);


    if(ans > 0){
        cout << ans <<endl;
    }else if(ans <= 0){
        cout << 0 <<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

const int mod = 1e9 + 7;

int pw(int x, int p) {
    int r = 1;
    while (p) {
        if (p & 1) r = (llong)r * x % mod;
        x = (llong)x * x % mod;
        p >>= 1;
    }
    return r;
}

int n;
int a[100001];
int fact[100001];
llong ks[100005];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = (llong)fact[i - 1] * i % mod;
    llong ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += (llong)a[i] * fact[n] % mod;
        ans %= mod;
        int p1 = i - 1, p2 = n - i;
        if (p1 < p2) swap(p1, p2);
        ks[1] += a[i] + a[i];
        ks[p2 + 1] -= a[i];
        ks[p1 + 1] -= a[i];
    }
    for (int i = 1; i < n; ++i) {
        ks[i] += ks[i - 1];
        ks[i] %= mod;
        if (ks[i] < 0) ks[i] += mod;
        ans += ks[i] * fact[n] % mod * pw(i + 1,mod - 2) % mod;
        ans %= mod;
    }
    printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

// template copied from others
namespace __output {
    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T, size_t SZ> void pr(const array<T,SZ>& x);
    template<class T> void pr(const vector<T>& x);
    template<class T> void pr(const set<T>& x);
    template<class T1, class T2> void pr(const map<T1,T2>& x);
 
    template<class T> void pr(const T& x) { cout << x; }
    template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
        pr(first); pr(rest...);
    }
 
    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.first,", ",x.second,"}");
    }
    template<class T, bool pretty = true> void prContain(const T& x) {
        if (pretty) pr("{");
        bool fst = 1; for (const auto& a: x) pr(!fst?pretty?", ":" ":"",a), fst = 0;
        if (pretty) pr("}");
    }
    template<class T> void pc(const T& x) { prContain<T, false>(x); pr("\n"); }
    template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
    template<class T> void pr(const vector<T>& x) { prContain(x); }
    template<class T> void pr(const set<T>& x) { prContain(x); }
    template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }
 
    void ps() { pr("\n"); }
    template<class Arg> void ps(const Arg& first) {
        pr(first); ps();
    }
    template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
        pr(first," "); ps(rest...);
    }
}
using namespace __output;

#ifdef DBG
    #define TRACE(x) x
#else
    #define TRACE(x)
#endif

#define p(x) TRACE(pr(x); cout << endl;)
#define __pn(x) pr(#x, " = ")
#define pd(...) TRACE(__pn((__VA_ARGS__)); ps(__VA_ARGS__); cout << flush;)

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

    int D, G;
    cin >> D >> G;

    int best = 0;
    vector<int> c(D);
    vector<int> z(D);
    for (int i = 0; i < D; ++i) {
        cin >> z[i] >> c[i];
        best += z[i];
    }

    for (int i = 0; i < (1 << D); ++i) {
        int get = 0;
        int use = 0;
        for (int j = 0; j < D; ++j) {
            if ((1 << j) & i) {
                get += z[j] * 100 * (j + 1) + c[j];
                use += z[j];
            }
        }

        for (int j = D - 1; j >= 0; --j) {
            if (get < G && ((1 << j) & i) == 0) {
                int take = min(z[j], ((G - get + 100 * (j + 1) - 1) / (100 * (j + 1))));
                use += take;
                get += take * 100 * (j + 1);
            }
        }

        best = min(best, use);
    }

    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    ll n, m;
    cin >> n >> m;
    if (n >= m / 2)
    {
        cout << m / 2 << endl;
    }
    else
    {
        cout << n + (m - 2 * n) / 4 << endl;
    }
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>X(N),A(N);
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  A=X;
  sort(A.begin(),A.end());

  int s=A[N/2-1];int t=A[N/2];//cout<<s<<t<<endl;
  for(int i=0;i<N;i++){
     if(X[i]<=s){cout<<t<<endl;}
     else{cout<<s<<endl;}
  }
  return 0;  
}

Measured memory_bytes: 4848
#include<stdio.h>

int main(void){
  char a[27];
  int i,j;
  scanf("%s",a);
  for(i=0;i<sizeof(a)-1;i++){
    for(j=i+1;j<sizeof(a) && a[j]!='\0';j++){
      if(a[i]==a[j]){
        printf("no\n");
        return 0;
      }
    }
  }
  printf("yes\n");
  return 0;
}

Measured memory_bytes: 128
s = input()
n = len(s)
k = int(input())

dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
    for b in range(k + 1):
        for c in range(2):
            nd = int(s[a])
            for d in range(10):
                na, nb, nc = a + 1, b, c
                if 0 != d:
                    nb += 1
                if nb > k:
                    break
                if nc == 0:
                    if d < nd:
                        nc = 1
                    if d > nd:
                        break
                dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))


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

int main(){
    int n, x, a, b, c, d;
    cin >> n;
    a = n / 1000;
    b = (n - a * 1000) / 100;
    c = (n - a * 1000 - b * 100) / 10;
    d = n - a * 1000 - b * 100 - c * 10;
    if (a == b && a == c || b == c && b == d ) {
        cout << "Yes" << endl;
    }
 /*   else if (x - y == 0) {
        cout << "Balanced" << endl;
    }*/
    else {
        cout << "No" << endl;
    }
}

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

int main(){
	int N, i, j, f;
	scanf("%d", &N);
	char *s = (char *)malloc(sizeof(char) * (N + 1));
	char *t = (char *)malloc(sizeof(char) * (N + 1));
	scanf("%s", s);
	scanf("%s", t);
	for(i = 0; i < N; i++){
		f = 1;
		for(j = 0; i + j < N; j++){
			if(s[i + j] != t[j]){
				f = 0;
				break;
			}
		}
		if(f == 1){
			break;
		}
	}
	printf("%d\n", i + N);
/*	for(j = 0; j < i; j++){
		printf("%c", s[j]);
	}
	printf("%s\n", t);
*/	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  rep(i, s.size()){
    mp[s[i]] = mp[s[i]] + 1;
  }

  bool f = true;
  auto begin = mp.begin(), end = mp.end();
  for (auto iter = begin; iter != end; iter++) {
      if(iter->second % 2 == 1) f = false;
    }
  if(f) cout << "Yes" << ln;
  else cout << "No" << ln;
}


Measured memory_bytes: 256
n,k = map(int, raw_input().split(' '))
r,s,p = map(int, raw_input().split(' '))
seq = raw_input()


dp = [[0,0,0] for _ in range(len(seq))]
"""
	0 rock
	1 paper
	2 scisor
"""

for i in range(len(dp)):
	if i - k < 0:
		dp[i][0] = r if seq[i]  == 's' else 0
		dp[i][1] = s if seq[i]  == 'p' else 0
		dp[i][2] = p if seq[i]  == 'r' else 0
	elif i - k >=0:
		dp[i][0] = max(dp[i- k][1], dp[i-k][2]) + 	(r if seq[i]  == 's' else 0)
		dp[i][1] = max(dp[i- k][0], dp[i-k][2]) + 	(s if seq[i]  == 'p' else 0)
		dp[i][2] = max(dp[i- k][0], dp[i-k][1]) + 	(p if seq[i]  == 'r' else 0)

cumul = 0
seen = set([])
for j in range(len(dp)-1, -1, -1):
	#print j % k
	if (j % k) not in seen:
		seen.add(j % k)
		cumul += max(dp[j])
	else:
		break

print cumul


Measured memory_bytes: 51100
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n,x,a[100000],i,b[100000];
cin>>n>>x;
for(i=0;i<n;i++)
cin>>a[i];

b[0]=0;

for(i=1;i<n+1;i++)
b[i]=b[i-1]+a[i-1];

long long int count=0;

for(i=0;i<n+1;i++)
{
if(b[i]<=x)
count++;
}
cout<<count<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>

using namespace std;

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

#define fs first
#define sc second

// int prev_node[110];
int d[110];
int N, M;
int dis[100][100];
vector<P> edge[100];

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+N, INT_MAX);

    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.sc;
        if(d[v] < p.fs) continue;
        for(int i = 0; i < edge[v].size(); i++){
            P e = edge[v][i];
            if(d[e.fs] > d[v] + e.sc){
                d[e.fs] = d[v] + e.sc;
                que.push(P(d[e.fs], e.fs));
            }
        }
    }
}


int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge[a].emplace_back(P(b, c));
        edge[b].emplace_back(P(a, c));
    }

    for(int i = 0; i < N; i++){
        dijkstra(i);
        for(int j = 0; j < N; j++){
            dis[i][j] = d[j];
        }
    }

    set<P> st;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < edge[i].size(); j++){
            for(int x = 0; x < N; x++){
                for(int y = 0; y < N; y++){
                    int min_dis = dis[x][y];
                    int cur_dis = dis[x][i] + edge[i][j].sc + dis[edge[i][j].fs][y];
                    if(min_dis == cur_dis){
                        st.insert(P(i, edge[i][j].fs));
                        st.insert(P(edge[i][j].fs, i));
                    }
                }
            }
        }
    }

    cout << (2*M - st.size()) / 2 << endl;

    return 0;
}

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

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

	sort(a,a+n);
	string ans = "YES";
	for (int i = 0; i < n; i++) {
		if (a[i] == a[i+1]) {
			ans = "NO";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void) {
  char s[101];
  scanf("%s", &s);

  for (int i = 0; s[i] != '\0'; i++) {
    if (i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R') {
      printf("No");
      return 0;
    }
  }

  printf("Yes");
  return 0;
}


Measured memory_bytes: 128