akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

def main():
    N = int(input())
    XY_list = []
    for i in range(N):
        XY_list.append(list(map(int, input().split())))

    rot_list = list(map(lambda xy: [xy[0] + xy[1], -xy[0] + xy[1]], XY_list))

    f = True
    p = rot_list[0][0] % 2
    for i in range(1, N):
        if rot_list[i][0] % 2 != p:
            f = False
            break

    if not f:
        print(-1)
    else:
        offset = 2 ** 31 - p
        m = 32 - p
        d = []
        if p == 0:
            d.append(1)
        for k in range(31):
            d.append(2 ** k)
        w = []
        for i in range(N):
            uv = rot_list[i]
            u, v = uv[0] + offset, uv[1] + offset
            s = ''
            if p == 0:
                s = 'D'
            for k in range(31):
                u //= 2
                v //= 2
                u1, v1 = u % 2, v % 2
                if u1 == 0 and v1 == 0:
                    s += 'D'
                elif u1 == 0 and v1 == 1:
                    s += 'L'
                elif u1 == 1 and v1 == 0:
                    s += 'R'
                elif u1 == 1 and v1 == 1:
                    s += 'U'
            w.append(s)

        print(m)
        s = ''
        for dv in d:
            s += ' ' + str(dv)
        print(s[1:])
        for i in range(N):
            print(w[i])


if __name__ == '__main__':
    main()



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

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

Measured memory_bytes: 3644
n = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(n):
    mini = i + a[i:].index(min(a[i:]))
    if mini != i:
        a[i], a[mini] = a[mini], a[i]
        count += 1

print(' '.join(map(str, a)))
print(count)



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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define inf (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outpossible(bool_val) cout << (bool_val ? "possible" : "impossible") << endl;
#define outpossible(bool_val) cout << (bool_val ? "possible" : "impossible") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int x;
    cin >> x;

    if(x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int h,w,i,j;
  char a[101][101];
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++)
    {
      scanf("%s",a[i]);
    }
  for(i=0;i<h;i++)
    {
      if(i==0)
	{
	  for(j=0;j<w+2;j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
      printf("#%s#\n",a[i]);
      if(i==h-1)
	{
	  for(j=0;j<w+2;j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	}
    }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;

int main() {
	int n;
	vector<int> a(4,0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s == "AC") {
			a.at(0)++;
		}
		else if (s == "WA") {
			a.at(1)++;
		}
		else if (s == "TLE") {
			a.at(2)++;
		}
		else {
			a.at(3)++;
		}
	}
	//string ans = "AC x " + a.at(0) +"\nWA x " + a.at(1) +"\nTLE x " + a.at(2) +"\nRE x " + a.at(3);
	printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a.at(0), a.at(1), a.at(2), a.at(3));
}


Measured memory_bytes: 3728
import sys
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int,sys.stdin.readline().split())))

dp = np.zeros(n, dtype=int)
dp[0] = 0
for i in range(1,n):
    x = max(i-k, 0)
    #dp[i] = min(d + abs(h[i]-hd) for d, hd in zip(dp[x:i], h[x:i]))
    dp[i] = (dp[x:i] + abs(h[i] - h[x:i])).min()
print(dp[-1])


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i=1; i*i<=n; i++) {
        if(n%i==0) {
            ret.pb(i);
            if(i*i!=n) {
                ret.pb(n/i);
            }
        }
    }
    sort(ALL(ret));
    return ret;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll a,b,k;
    cin>>a>>b>>k;
    Vec v = divisor(__gcd(a,b));
    ll ans = v[v.size()-k];
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  vector<long double> x(N);
  vector<string> u(N);
  rep(i,N)
  {
    cin >> x[i] >> u[i];
  }
  long double sum = 0;
  rep(i,N)
  {
    if(u[i]=="JPY")
    {
      sum += x[i];
    }
    else
    {
      sum += 380000 * x[i];
    }
    
  } 
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
const int MAXN=10;
const ll MOD=10;
ll _gcd(ll a,ll b){if(b==0)return a;return _gcd(b,a%b);}
ll gcd(ll a,ll b){a=abs(a),b=abs(b);if(a<b)swap(a,b);return _gcd(a,b);}
ll qpow(ll a,ll n){ll rt=1;while(n){if(n&1)rt=(rt*a)%MOD;a=a*a%MOD;n>>=1;}return rt;}
ll factor[MAXN];
void cal_factor(){factor[0]=1;for(int u=1;u<MAXN;u++){factor[u]=(factor[u-1]*u)%MOD;}}
ll C(ll n,ll k){return factor[n]*qpow(factor[n-k],MOD-2)%MOD*qpow(factor[k],MOD-2)%MOD;}
void solve(){
    int n;
    cin>>n;
    ll mmin[2],mmax[2];
    for(int u=0;u<n;u++){
        ll x,y;
        cin>>x>>y;
        if(u==0){
            mmin[0]=x+y,mmax[0]=x+y;
            mmin[1]=x-y,mmax[1]=x-y;
        }else {
            mmax[0]=max(mmax[0],x+y);
            mmin[0]=min(mmin[0],x+y);
            mmax[1]=max(mmax[1],x-y);
            mmin[1]=min(mmin[1],x-y);
        }
    }
    cout<<max(mmax[0]-mmin[0],mmax[1]-mmin[1])<<"\n";
}
// #define LOCAL
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
typedef long long ll;
/*
https://atcoder.jp/contests/abc043/tasks/abc043_a
*/
int main()
{
    int N;
    cin >> N;
    cout << N*(N+1)/2 << endl;
    return 0;
}

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

int main()
{
  	int A,B,C,X,Y,i,j,k,sum;
  	cin>>A>>B>>C>>X>>Y;
  	int min_sum=A*X+B*Y;
  	for(k=0;k<=max(X,Y);k++)
	{
    	i=max(0,X-k);
    	j=max(0,Y-k);
    	sum=A*i+B*j+2*C*k;
    	if(min_sum > sum)
			min_sum=sum;
  	} 
  	cout<<min_sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 262144

int N;
int POW[20];
int table[SIZE];

int main(){

	POW[0] = 1;
	for(int i = 1; i < 20; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	for(int i = 0; i < POW[N]; i++){

		scanf("%d",&table[i]);
	}

	sort(table,table+POW[N]);

	vector<int> S;
	S.push_back(table[POW[N]-1]);

	table[POW[N]-1] = -1;

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

		vector<int> work = S;
		sort(work.begin(),work.end());

		for(int k = POW[N]-1; k >= 0; k--){
			if(table[k] == -1)continue;

			if(work.back() <= table[k])continue;

			work.pop_back();
			S.push_back(table[k]);
			table[k] = -1;

			if(work.size() == 0)break;
		}

		if(work.size() > 0){

			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 5868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)1e18

struct data {
  ll a, b, c;
};

ll n, m, p;
ll dist[2600];
vector<data> edge;

void bell() {
  for(int i = 0; i < m; ++i) {
    data now = edge[i];
    if(dist[now.a] != inf && dist[now.b] > dist[now.a] + now.c) {
      dist[now.b] = dist[now.a] + now.c;
    }
  }
  return ;
}

bool ch() {
  bool ch = false;
  for(int i = 0; i < m; ++i) {
    data now = edge[i];
    if(dist[now.a] != inf &&dist[now.b] > dist[now.a] + now.c) {
      if(now.b == n - 1) ch = true;
      dist[now.b] = -inf;
    }
  }
  return ch;
}

ll solve() {
  for(int i = 0; i < n; ++i) dist[i] = inf;
  dist[0] = 0;
  for(int i = 0; i < n - 1; ++i) bell();
  for(int i = 0; i < n; ++i) if(ch()) return -1;
  return max(-dist[n - 1], 0LL);
}

int main() {
  cin >> n >> m >> p;
  for(int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    edge.push_back({--a, --b, p - c});
  }
  cout << solve() << endl;
  return 0;
}




Measured memory_bytes: 576
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    vector<long long> a(3*N);
    for(int i=0;i<3*N;i++){ cin >> a[i];}
    sort(a.begin(), a.end());
    long long ans = 0;
    for(int i=0;i<N;i++){
        ans += a[3*N-2-i*2];
    }
    cout << ans << endl;
}




Measured memory_bytes: 2560
function main(input) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);

    var flows = args[1].split(' ');

    var ans = 'No';
    var max = 0;

    for (var i = 0; i < N; i++) {
        flows[i] = parseInt(flows[i]);
        if(max < flows[i]) {
            max = flows[i];
        }
    }

    var sum = 0;

    max_flag = true;

    for (var i = 0; i < N; i++) {
        if (max === flows[i] && max_flag === true) {
            // 何もしない
            max_flag = false;
        } else {
            sum += flows[i];
        }
    }

    if(max < sum) {
        ans = 'Yes';
    }

    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
//33
#include<iostream>

using namespace std;

int main(){
  for(int i=0;i<9;i++){
    char cn[16];
    int a,b;
    cin>>cn>>a>>b;
    cout<<cn<<' '<<a+b<<' '<<a*200+b*300<<endl;
  }
  return 0;
}

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

using namespace std;

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

  int n, a;
  cin >> n >> a;
  if (n % 500 <= a) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string S;
  cin >> S;
  bool ok = false;
  for (int i = 0; i < S.size(); i++)
    if (S[i] == '7')
      ok = true;
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;


	ll ans = 0;
	if ( (B - A) % 2 == 0 ){
		ans = (B - A) / 2;
	} else {
		if (A - 1 < N - B){
			ans = A + (B - A - 1) / 2;
		} else {
			ans = N - B + 1 + (B - A - 1) / 2;
		}
	}

	cout << ans << "\n";

	return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define INF             1e9
#define INFL            8e18
#define XX              first
#define YY              second
#define PB              push_back
#define MP              make_pair

#define NEWLINE         cerr << "\n";
#define HOISE           cerr << "hoise " << __LINE__ << "\n"
#define PAUSE           system("pause")
#define DEBUG(x)        cerr << #x << " = " << x << "\n"
#define READ            freopen("D:\\moidda CPP\\alu.txt", "r", stdin)
#define WRITE           freopen("D:\\moidda CPP\\vorta.txt", "w", stdout)
#define FASTIO          ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MASK(x)         for(int i = 0; i < 8; i++){ if(x&(1<<i)){ cout << i << " "; } } cout << endl;

typedef long long ll;
typedef pair<int, int > pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pff;

const int MAX = 30 + 10;
const int MAX_VALUE = 2e6 + 10;
const int MAXLOG = log2(MAX) + 2;
const int MOD = 10007;
const double PY = acos(-1.0);
const double EPS = 1E-9;

int32_t main()
{
#ifndef ONLINE_JUDGE
//    READ;
//    WRITE;
#endif

    FASTIO;

    int n;
    cin >> n;
    int d = n%10;
    if(d == 3) cout << "bon";
    else if(d == 0 or d == 1 or d==6 or d==8) cout << "pon";
    else cout << "hon";

    return 0;
}



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

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

    vector<int> w(n);
    vector<int> s(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
        sum += w[i];
        s[i] = sum;
    }

    int mn = __INT_MAX__;
    for (int i = 0; i < n; i++)
    {
        int d = s[i] - (sum - s[i]);
        if (d < 0)
        {
            d *= -1;
        }
        if (mn > d)
        {
            mn = d;
        }
    }

    cout << mn << endl;

    return 0;
}


Measured memory_bytes: 384
import collections
 
n = int(input())
 
res = []
 
for _ in range(n):
  res.append(input())
 
c = collections.Counter(res)
aa = c.most_common()
 
ss = aa[0][1]
res2 = []
 
aa.sort()
for i in aa:
  if i[1] == ss:
    res2.append(i[0])
    print(i[0])

Measured memory_bytes: 47092
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class ABC
{
    //          int[] split = Console.ReadLine().Split().Select(int.Parse).ToArray();

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] d = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(d);
        int left = N / 2 - 1;
        int right = N / 2;
        int answer = d[right] - d[left];
        if (answer < 0) answer = 0;

        Console.WriteLine(answer);
    }




}

public class Pairc
{
    public int a;
    public int b;
    public Pairc() { }
    public Pairc(int a, int b)
    {
        this.a = a;
        this.b = b;
    }

}


Measured memory_bytes: 20064
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q, W, H, R, C, P;
string S;

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

    cin >> N >> P;
    cin >> S;

    vector<ll> A(N + 1, 0);
    vector<ll> B(N + 1, 1);
    REP(i, N) { B[i + 1] = B[i] * 10 % P; }

    if (P == 2 || P == 5) {
        ll ans = 0;
        for (int i = 0; i < N; i++) {
            ll t = (int)(S[i] - '0');
            if (t % P == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }

    RREP(i, N - 1) {
        ll t = (int)(S[i] - '0');
        A[i] = (t * B[N - 1 - i] % P + A[i + 1]) % P;
    }

    map<ll, ll> m;
    REP(i, N + 1) { m[A[i]]++; }
    ll ans = 0;
    for (auto p : m) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4100
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const ll MOD = 1000000000 + 7;

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main()
{
  int n, k;
  mint result = 0;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());

  combination c(n+5);

  for (int i = k-1; i < n; i++) {
    result += c(i,k-1) * a[i];
  }
  reverse(a.begin(), a.end());

  for (int i = k-1; i < n; i++) {
    result -= c(i,k-1) * a[i];
  }

  cout << result.x << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
long int gcd( long int m, long int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;

	while( m != n )
	{
		if ( m > n ){
      if(m%n==0){
        m = n;
      }
      else{
        m = m%n;
      }
    }
		else{
      if(n%m==0){
        n = m;
      }
      else{
        n = n%m;
      }
	  }
  }
	return m;
}

int main(){
  int n;
  cin>>n;
  long int a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  int g = 1;
  if(a[0]==1||a[1]==1){

    cout<<1;
    return 0;
  }
  g = gcd(a[0],a[1]);

  if(n>2){
    for(int i=2;i<n;++i){
        g = gcd(g,a[i]);
        if(g == 1){
          break;
        }
      }
    }
  cout<<g;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br =new BufferedReader(
            new InputStreamReader(System.in));
        StringBuffer str =new StringBuffer();
        int i=1;
        while(true){
            int data = Integer.parseInt(br.readLine());
            if(data==0)
                break;
            str.append("Case ").append(Integer.toString(i)).append(": ").append(Integer.toString(data)).append("\n");
i++;
        }
        System.out.print(str);
    }
}

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

int main(){
  long long n, m, l, b[100][100], a[100][100], c[100][100] = {};
  cin >> n >> m >> l;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0; i < m; i++){
    for(int j = 0; j < l; j++){
      cin >> b[i][j];
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      for(int k = 0; k < l; k++){
        c[i][k] += a[i][j] * b[j][k];
      }
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < l; j++){
      cout << (j == 0 ? "": " ") << c[i][j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin()nnd()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,f[100010]={}; cin>>n;
    rep(i,n){
        int a,b; cin>>a>>b;
        f[a]++,f[b+1]--;
    }
    int ans=0;
    rep(i,100005){
        f[i+1]+=f[i];
        if(f[i]>=i-1){
            ans=max(ans,i-1);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3492
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define swap(p,q){ll t=p;p=q;q=t;}
#define min(p,q)((p)<(q)?(p):(q))

ll p3[50];//p3[i]=3のi乗

ll f(ll a,ll b,ll c,ll d,int k){
	ll aa=a/p3[k],bb=b/p3[k];
	ll cc=c/p3[k],dd=d/p3[k];
	if(aa==cc&&bb==dd)return f(a,b,c,d,k-1);
	if(aa!=cc&&bb!=dd)return llabs(a-c)+llabs(b-d);
	
	if(bb==dd){
		swap(a,b);swap(aa,bb);
		swap(c,d);swap(cc,dd);
	}

	if(aa%3==1&&llabs(bb-dd)>1){
		ll loss=min(min(llabs((aa*p3[k]-1)-a),llabs((aa*p3[k]-1)-c)),//左に避ける
					min(llabs((aa+1)*p3[k]-a),llabs((aa+1)*p3[k]-c)) //右に避ける
				   );
		return llabs(a-c)+llabs(b-d)+loss*2;
	}
	if(k==0)return llabs(a-c)+llabs(b-d);
	return f(a,b,c,d,k-1);
}

int main(){
	p3[0]=1;
	for(int i=1;i<=30;i++)p3[i]=p3[i-1]*3;
	int q;
	scanf("%d",&q);
	while(q--){
		ll a,b,c,d;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		a--,b--,c--,d--;
		printf("%lld\n",f(a,b,c,d,29));
	}
}

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

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}

int a[MAX];

int main()
{
    int T, n;
//    cin >> T;
//    while(T--){
        read(n);
        int l = n, r = 0;
        for(int i = 1; i <= n; i++){
            read(a[i]);
            l = min(l, a[i]);
            r = max(r, a[i]);
        }
        if(r-l > 1) puts("No");
        else if(r == l+1){
            int cnt = 0;
            for(int i = 1; i <= n; i++){
                if(a[i] == l) cnt++;
            }
            if(cnt <= l && r <= cnt+(n-cnt)/2) puts("Yes");
            else puts("No");
        }
        else{
            if(l+1 == n) puts("Yes");
            else if(l*2 <= n) puts("Yes");
            else puts("No");
        }
//    }

    return 0;
}

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

using namespace std;

int main(void){
  
  string s;
  
  while(1){

    getline( cin, s );
    if ( s == "END OF INPUT" ) break;
    
    int cnt = 0;
    for ( int i = 0; i < s.size(); i++ ){
      if ( s[i] == ' ' ){
	cout << cnt;
	cnt = 0;
      }else cnt++;
    }
    cout << cnt << endl; 
  }
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;

int main() {
    cin >> a >> b >> c >> d;
    for (int i = 1; a > 0 && c > 0; i++) {
        if (i & 1) {
            c -= b;
            if (c <= 0) {
                cout << "Yes";
                return 0;
            }
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No";
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

template<class T>
void in(vector<T>& V) {
	for (auto itr = V.begin(); itr != V.end(); itr++)cin >> *itr;
	return;
}

template<class T>
void out(vector<T>& V) {
	for (T& itr : V)cout << itr << endl;
	return;
}

//空vectorを要素数NのsegTreeとしてzで初期化
template<class T>
void segTree_init(vector<T>& vec, int N, T z) {
	int RN = 1;
	while (RN < N)RN *= 2;
	vec.resize(2 * RN, z);
}

//vecをsegTreeとしてn番目をxに
template<class T>
void segTree_set(vector<T>& vec, int n, T x, function<T(T, T)> f, int k = -1) {
	int RN = (vec.size() + 1) / 2;
	if (k == -1) {
		k = n + RN;
		vec[k] = x;
		segTree_set(vec, n, x, f, k / 2);
	}
	else if (k != 0) {
		vec[k] = f(vec[2 * k], vec[2 * k + 1]);
		segTree_set(vec, n, x, f, k / 2);
	}
}

//vecがsegTreeの時の、n番目の要素
template<class T>
T segTree_at(vector<T>& vec, int n) {
	int RN = (vec.size()) / 2;
	return vec[RN + n];
}

//get [a,b]
template<class T>
T segTree_get(vector<T>& vec, int a, int b, function<T(T, T)> f, T e, int k = 1, int l = 0, int r = -1) {
	if (r == -1)r = vec.size() / 2 - 1;
	if (b < l || r < a)return e;
	else if (a <= l && r <= b)return vec[k];
	else return f(
		segTree_get(vec, a, b, f, e, 2 * k, l, (l + r) / 2),
		segTree_get(vec, a, b, f, e, 2 * k + 1, (l + r) / 2 + 1, r)
	);
}

int N, M;
typedef pair<int, int> pii;
vector<pii> A;
vector<int> seg;
function<int(int,int)> lambda = [](int a, int b) {
	return max(a, b);
};

int main() {
	cin >> N >> M;
	A.resize(N);
	for (int n = 0; n < N; n++) {
		int a, b;
		cin >> a >> b;
		A[n] = pii(a, b);
	}
	sort(A.begin(), A.end(), [](pii a,pii b) {
		return a.second > b.second;
	});
	segTree_init(seg, M, -1);
	for (int m = 0; m < M; m++) {
		segTree_set(seg, m, m, lambda);
	}
	int ans = 0;
	for (int n = 0; n < N; n++) {
		int latest = segTree_get(seg, 0, M - A[n].first, lambda, -1);
		if (latest == -1)continue;
		ans += A[n].second;
		segTree_set(seg, latest, -1, lambda);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2048
n = int(input())
cnt = 0
dd = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
  if dd[i][0]==dd[i][1]:
    cnt += 1
    if cnt >= 3:
      print('Yes')
      exit()
  else:
    cnt = 0
print('No')

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int i, A, min = 0;
  for( i = 0; i < N; i++){
    cin >> A;
    
    int count = 0;
    while(A % 2 == 0){
      A /= 2;
      count++;
    }
    if(count == 0)	 break;
    else if(i == 0 || count < min)	min = count;
    
  }
  cout << min << endl;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

int modpow(int a, int p) {
	if (p == 0)return 1;
	if (p % 2 == 0) {
		int halfP = p / 2;
		int half = modpow(a, halfP);
		return half * half%mod;
	}
	else {
		return a * modpow(a, p - 1) % mod;
	}
}

int calcComb(int a, int b) {
	if (b > a - b)return calcComb(a, a - b);
	int ansMul = 1;
	int ansDiv = 1;
	rep(i, b) {
		ansMul *= (a - i);
		ansDiv *= (i + 1);
		ansMul %= mod;
		ansDiv %= mod;
	}
	int ans = ansMul * modpow(ansDiv, mod - 2) % mod;
	return ans;
}


signed main(void) {
	int x, y;
	cin >> x >> y;
	if ((x + y) % 3 != 0) {
		print(0);
		return 0;
	}
	int a = (-x + 2 * y) / 3;
	int b = (2 * x - y) / 3;
	if (a < 0 || b < 0) {
		print(0);
		return 0;
	}
	int ret = calcComb(a + b, a)%mod;
	print(ret);
}


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

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

	auto count = [&](string str) {
		ll i = 0;
		ll size = str.size();
		ll count = 0;
		while (i < size) {
			ll j = i;
			ll len = 1;
			while (str[j] == str[j+1] && j < size-1) {
				len++;
				j++;
			}
			count += len / 2;
			i += len;
		}
		return count;
	};

	ll c = count(S);
	ll dc = count(S+S) - c;
	ll tc = count(S+S+S) - dc - c;

	if (c == dc)
		cout << c * K << endl;
	else if (c != dc && dc == tc) {
		cout << c + dc*(K-1) << endl;
	} else if (c != dc && dc != tc) {
		if (K % 2 == 0)
			cout << c*(K/2) + dc*(K/2) << endl;
		else
			cout << c*((K+1)/2) + dc*(K/2) << endl;
	}
}

Measured memory_bytes: 3632
X,K,D = map(int,input().split())

if K*D<abs(X):
  if X<0:
    print(abs(X+K*D))
  else:
    print(abs(X-K*D))
else:
  if X//D%2==0:
    if K%2==0:
      print(X%D)
    else:
      print(abs(D-X%D))
  else:
    if K%2==0:
      print(abs(D-X%D))
    else:
      print(X%D)

Measured memory_bytes: 9192
class Plot:

    def __init__(self, inp):
        self.x, self.y, self.h = inp


def plot_check(xyh, cx, cy, H):
    for i in xyh:
        if max(H - abs(i.x - cx) - abs(i.y - cy),0) != i.h:
            return False
    return True


def main():
    xyh = []
    kensa = 0
    N = int(input())
    for i in range(N):
        xyh.append(Plot(map(int, input().split())))
    for i in range(len(xyh)):
        if xyh[i].h > 0:
            kensa = i
            break
    for cxi in range(101):
        for cyi in range(101):
            H = abs(xyh[kensa].x - cxi) + abs(xyh[kensa].y - cyi) + xyh[kensa].h
            if plot_check(xyh, cxi, cyi, H):
                print(cxi, cyi, H)
                return


main()

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

long long n, a[200], ans;

int main(){
	ans=0;
	a[0]=1e9;
	cin >> n;
	for (int i=0;i<n-1;i++){
		long long b;
		cin >> b;
		a[i]=min(a[i],b);
		a[i+1]=b;
		ans+=a[i];
	}
	ans+=a[n-1];
	cout << ans << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  string s,s3;
  s.insert(s.begin(),b,a+'0');
  s3.insert(s3.begin(),a,b+'0');
if(s3<s){cout<<s3<<endl;}
else cout<<s<<endl;
return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;
 
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	public static void main(String[] args) {
	int A =sc.nextInt();
	int B =sc.nextInt();
	int ans=0;
	
	double AA=A/0.08;
	double BB=B/0.10;
	double AAA=(A+1)/0.08;
	double BBB=(B+1)/0.10;
	boolean a=true;
	//p("AA"+AA+"BB"+BB+"AAA"+AAA+"BBB"+BBB);
	//AA~AAAの間であり、BB~BBBの間である数を求める
	for(int i=1;i<=2000;i++) {
		if(AA<=i&&AAA>i&&BB<=i&&BBB>i) {
			System.out.println(i);
			a=false;
			break;
		}
	}
	
	if(a) {
		p(-1);
	}
	
	
	}
}

Measured memory_bytes: 22740
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    k = int(input())
    print("ACL" * k)

main()

Measured memory_bytes: 67076
n, m = map(int, input().split())
ls = []
for i in range(n):
    a, b = map(int, input().split())
    ls.append([a, b])
ls.sort()
price = 0

for i in ls:
    if i[1] >= m:
        price += i[0] * m
        m = 0
    else:
        price += i[0] * i[1]
        m -= i[1]

    if m == 0:
        break

print(price)



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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string n;
    cin >> n;
    REP(i,n.size()){
        if(n[i] == '1'){
            n[i] = '9';
        }else if(n[i] == '9'){
            n[i] = '1';
        }
    }
    cout << stoi(n) << endl;
	return 0;
}



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

sequence = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(sequence[k-1])

Measured memory_bytes: 3060
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	int V, Mod;
	List<int>[] es;
	void Solve()
	{
		var I = G;
		V = I[0];
		Mod = I[1];
		es = new List<int>[V];
		for (var u = 0; u < V; u++) es[u] = new List<int>();
		for (var e = 0; e < V - 1; e++)
		{
			I = G;
			es[I[0] - 1].Add(I[1] - 1);
			es[I[1] - 1].Add(I[0] - 1);
		}
		var dp0 = DFS0(0, -1);
		var dp1 = DFS1(0, dp0);
		for (var u = 0; u < V; u++) WriteLine(dp0[u] * (dp1[u] + 1) % Mod);
	}
	long[] DFS0(int u, int p)
	{
		var dp0 = new long[V];
		var st = new Stack<object>();
		st.Push(new A0 { u = u, p = p });
		while (st.Count > 0)
		{
			var f = st.Pop();
			if (f is A0)
			{
				var g = (A0)f;
				es[g.u].Remove(g.p);
				st.Push(g.u);
				foreach (var v in es[g.u]) st.Push(new A0 { u = v, p = g.u });
			}
			else
			{
				u = (int)f;
				dp0[u] = 1L;
				foreach (var v in es[u]) dp0[u] = dp0[u] * (dp0[v] + 1) % Mod;
			}
		}
		return dp0;
	}
	long[] DFS1(int u, long[] dp0)
	{
		var dp1 = new long[V];
		var st = new Stack<int>();
		st.Push(u);
		while (st.Count > 0)
		{
			u = st.Pop();
			var W = es[u].Count;
			var x = new long[W + 1];
			var y = new long[W + 1];
			x[0] = y[W] = 1;
			for (var i = 0; i < W; i++) x[i + 1] = x[i] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = W - 1; i >= 0; i--) y[i] = y[i + 1] * (dp0[es[u][i]] + 1) % Mod;
			for (var i = 0; i < W; i++) dp1[es[u][i]] = (dp1[u] + 1) * x[i] % Mod * y[i + 1] % Mod;
			x = y = null;
			foreach (var v in es[u]) st.Push(v);
		}
		return dp1;
	}
}
struct A0 { public int u, p; }


Measured memory_bytes: 37124
#include<iostream>
#include<string>
#include<algorithm>

using namespace  std;
 int main(){
    long long int n,k;
     long long int ans=0;
     long long int h[200005];
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> h[i];

    sort(h,h+n);
    for(int i=0;i<n-k;i++){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
 }

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long unsigned int
int main(void)
{
    int i, j, n;
    scanf("%d", &n);
    int k = 1;
    int count = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &j);
        if (j != k)
        {
            count++;
        }
        else
        {
            k++;
        }
    }
    if (count == n)
        count = 0xffffffff;
    printf("%d\n", count);
    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    deque<int> dq;
    for (int i = 0; i < n; i++) {
        string s;
        int v;
        cin >> s;
        if (s == "insert" || s == "delete") cin >> v;

        if (s == "insert") dq.push_front(v);
        if (s == "delete") {
            auto pos = find(dq.begin(), dq.end(), v);
            if (pos != dq.end()) {
                dq.erase(pos);
            }
        }
        if (s == "deleteFirst") dq.pop_front();
        if (s == "deleteLast") dq.pop_back();
    }

    vector<int> ans;
    for (auto x : dq) ans.push_back(x);

    for (size_t i = 0; i < ans.size(); i++) {
        if (i == ans.size() - 1) cout << ans[i] << "\n";
        else cout << ans[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 7116
s = input()

l, r = 0, len(s)-1
ans = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        ans += 1
    elif s[r] == "x":
        r -= 1
        ans += 1
    else:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 39664
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int p[60][100005],len[60],n;
void f(char x,int k){
	int s;
	if('a' <= x && x <= 'z') s = x - 'a' + 1;
	if('A' <= x && x <= 'Z') s = x - 'A' + 27;
	p[s][++len[s]] = k;
}
signed main(){
//	freopen("date.in","r",stdin);
//	freopen("date.out","w",stdout);
	cin >> a;
	n = strlen(a) - 1;
	for(int i = 0; i <= n; i++) f(a[i],i + 1);
	for(int i = 1; i <= 52; i++){
		for(int j = 2; j <= len[i]; j++){
			if(p[i][j] - p[i][j - 1] <= 2){
				printf("%d %d",p[i][j - 1],p[i][j]);
				return 0;
			}
		}
	}
	printf("-1 -1");
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,A,B,x=(ll)pow(2,29);
  cin >> N >> A >> B;
  A-=B;
  vector<ll> H(N);
  rep(i,N) cin >> H.at(i);
  sort(all(H));
  rep(i,29){
    auto k=upper_bound(all(H),x*B);
    if(k==H.end()){
      x-=(ll)pow(2,28-i);
    }else{
      auto y=k;
      ll w=0;
      while(y!=H.end()){
        ll z=*y;
        z-=x*B;
        w+=(z-1)/A+1;
        y++;
      }
      if(w<=x){
        x-=(ll)pow(2,28-i);
      }else{
        x+=(ll)pow(2,28-i);
      }
    }
  }
  auto k=upper_bound(all(H),x*B);
    if(k!=H.end()){
      auto y=k;
      ll w=0;
      while(y!=H.end()){
        ll z=*y;
        z-=x*B;
        w+=(z-1)/A+1;
        y++;
      }
      if(w>x){
        x++;
      }
    }
  cout << x << endl;
}

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

int main() {
  int a,b,x;
  cin >> a >> b ;
  if(b == 100){
    x = a*1000+b;
  }
  else if(10<=b){
    x = a*100 + b;
  }
  else {
    x = a*10+b;
  }
  
  bool y=true;
  int i = 0;
  while(i<=361){
    if(x == i*i){
      cout << "Yes" << endl;
      y = false;
      break;
    }
    i++;
  }
  
  if(y){
    cout << "No" << endl;
  }
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n;
    cin >> n;
    std::vector<int> a(n);
    std::vector<int> b(n);
    std::vector<int> c(n - 1);
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int out = 0;
    rep(i,n){
        cin >> b[i];
        out += b[i];
    }
    rep(i,n - 1){
        cin >> c[i];
    }
    for(int i = 0; i < n - 1; i++){
        if(a[i] + 1 == a[i + 1]){
            out += c[a[i]];
        }
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
 
int main(){
 
  int n, i;
  double x[100], y[100],s[100], max=0, d1=0, d2=0, d3=0,d22,d33;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%lf", &x[i]);
  for(i=0;i<n;i++) scanf("%lf", &y[i]);
 
  for(i=0;i<n;i++){
    s[i]=fabs(x[i]-y[i]);

    d1+=s[i];
    d2+=pow(s[i], 2);
    d3+=pow(s[i], 3);
    if(max<s[i]) max=s[i];
  }
  d22=pow(d2,0.5);
 d33=pow(d3,1.0/3);

  printf("%f\n%f\n%f\n%f\n", d1, d22, d33, max);
 
  return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define N 2005
#define M 15
using namespace std;

const double EPS = 1e-8;

// ????¬????
struct P3{
  double x,y,z;
  P3(double x=0, double y=0, double z=0):x(x),y(y),z(z){}
  P3 operator + (const P3 &a) const{ return P3(x+a.x, y+a.y, z+a.z); }
  P3 operator - (const P3 &a) const{ return P3(x-a.x, y-a.y, z-a.z); }
  P3 operator * (const double &c) const{ return P3(x*c, y*c, z*c); }
};

struct L3{
  P3 a,b;
};

double abs(P3 a){ return sqrt(a.x*a.x + a.y*a.y + a.z*a.z); }

double dot(P3 a, P3 b){ return a.x*b.x + a.y*b.y + a.z*b.z; }

// ????????¨???????????¢
double distSP(L3 S, P3 p){
  double a = dot(S.b - S.a, S.b - S.a);
  double b = dot(S.b - S.a, S.a - p);
  double c = dot(S.a - p, S.a - p);
  double t = -b / a;
  if(t < -EPS) return pow(abs(S.a - p),2);
  if(t > 1 + EPS) return pow(abs(S.b - p),2);
  return a * t * t + 2 * b * t + c;
}

double distPP(P3 a, P3 b){ return abs(a-b);}

int main(){
  
  while(1){
    
    int n, m, r;
    double sx[N],sy[N],sz[N],sr[N];
    double tx[M],ty[M],tz[M],tb[M];
    double ex,ey,ez;
    vector<int> ball[M];

    cin>>n>>m>>r;
    if(!n&&!m&&!r) break;

    for(int i=0;i<n;i++)
      cin>>sx[i]>>sy[i]>>sz[i]>>sr[i];
    
    for(int i=0;i<m;i++)
      cin>>tx[i]>>ty[i]>>tz[i]>>tb[i];

    cin>>ex>>ey>>ez;
    
    for(int i=0;i<m;i++){

      for(int j=0;j<n;j++){
	
	P3 p=P3(sx[j],sy[j],sz[j]);
	P3 a=P3(ex,ey,ez);
	P3 b=P3(tx[i],ty[i],tz[i]);
	
	if(distPP(a,p)<sr[j]&&distPP(b,p)<sr[j]) continue;
	
	if(sr[j]*sr[j]>EPS+distSP(L3{a,b},p)) ball[i].push_back(j);
	
      }
      
    }
    
    double ans=0;
    
    for(int i=0;i<(1<<m);i++){

      unordered_set<int> cnt;
      double sum=0;
      
      for(int j=0;j<m;j++){
	
	if(!(i&(1<<j))) continue;
	
	double X=tx[j]-ex;
	double Y=ty[j]-ey;
	double Z=tz[j]-ez;
	
	sum+=tb[j]/(X*X+Y*Y+Z*Z);
      }
      
      if(sum<ans) continue;
      
      for(int j=0;j<m;j++){
	
	if(!(i&(1<<j))) continue;
	
	for(int k=0;k<ball[j].size();k++) cnt.insert(ball[j][k]);
	
      }
      
      if(r>=cnt.size()) ans=max(ans,sum);
      
    }

    printf("%.5f\n",ans);
    
  }
  return 0;
}

Measured memory_bytes: 3372