akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  //cin>>tc;
  while (tc--)
  {
    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3652
from fractions import gcd
A, B, C, D = map(int, input().split())

def f(n, x, y):
    m = 0
    m += n // x
    m += n // y
    m -= n // (x // gcd(x, y) * y)
    return n - m

print(f(B, C, D) - f(A - 1, C, D))


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e5 + 9, M = 1e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, a;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a;
    arr[a] = i;
  }
  for (int i = 1; i <= n; ++i) {
    cout << arr[i] << ' ';
  }
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string.h>
using namespace std;
   
int main()
{
	int n, ts=0, hs=0;
	char t[100],h[100];
	cin >> n;
	while (n--) {
		cin >> t >> h;
		if (strcmp(t,h)>0)
			ts += 3;
		else if (strcmp(t,h)<0)
			hs += 3;
		else {
			ts += 1;
			hs += 1;
		}
	}
	cout << ts << ' ' << hs << endl;
	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

void insertionSort(int A[], int N) // N個の要素を含む0-オリジンの配列A
{   
	int v = 0;
	int i = 0;
	int j = 0;
	int k = 0;

	for (i = 1; i < N; i++) {
		for (k = 0; k < N-1; k++) {
			printf("%d ", A[k]);
		}
		printf("%d\n",A[k]);
		
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
	}
	
	for (k = 0; k < N-1; k++) {
		printf("%d ", A[k]);
	}
	printf("%d\n",A[k]);

}

void Input(int A[], int *N)
{
	int i = 0;
	int ret = 0;
	ret = scanf("%d", N);
	if ( ret == EOF ) {
	    printf("N ERROR\n");
	    return;
	}
	
	for (i = 0; i < (*N)-1; i++) {
		ret = scanf("%d", &A[i]);
		if ( ret == EOF ) {
			printf("A %d ERROR\n", i);
			return;
		}
	}
	ret = scanf("%d", &A[i]);
	if ( ret == EOF ) {
	    printf("A %d ERROR\n", i);
	    return;
	}

    
}


int main()
{
	int A[1000] = { 0 };
	int N = 0;
	
	Input(A, &N);
	
	insertionSort(A, N);
	
	return 0;
}


Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

// AtCoder
const i64 CYCLES_PER_SEC = 2800000000;

struct Timer {
	i64 start;
	Timer(){reset();}
	void reset(){start=getCycle();}
	inline double get(){return (double)(getCycle()-start)/CYCLES_PER_SEC;}
	inline i64 getCycle(){
		u32 low,high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((i64)low)|((i64)high<<32);
	}
};

Timer timer;


uint32_t xor128(){
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123;
  uint32_t t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

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

  int D;
  cin>>D;

  const int A = 26;
  vector<int> cs(A+1);
  for(int j=1;j<=A;j++) cin>>cs[j];

  vector s(D+1,vector<int>(A+1));
  for(int i=1;i<=D;i++)
    for(int j=1;j<=A;j++)
      cin>>s[i][j];

  vector<int> ts(D+1);
  {
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      vector<int> ss(A+1,0);
      for(int j=1;j<=A;j++)
        ss[j]=s[i][j]+cs[j]*(i-ls[j]);
      ts[i]=max_element(ss.begin()+1,ss.end())-ss.begin();

      ls[ts[i]]=i;
    }
  }

  auto calcScore=[&](vector<int> &ts)->int{
    int res=0;
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      res+=s[i][ts[i]];
      ls[ts[i]]=i;
      for(int j=1;j<=A;j++)
        res-=cs[j]*(i-ls[j]);
    }
    return res;
  };

  while(timer.get()<1.9){
    int d=xor128()%D+1;
    int q=xor128()%A+1;
    vector<int> us(ts);
    us[d]=q;
    if(calcScore(ts)<calcScore(us)) ts=us;
  }

  cerr<<calcScore(ts)<<newl;
  for(int i=1;i<=D;i++) cout<<ts[i]<<newl;
  return 0;
}


Measured memory_bytes: 3720
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  cout << a[n - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <thread>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n, m, dp[310][310][310], ans = INF;
int main() {
	REP(i, 310) REP(j, 310) REP(k, 310)dp[i][j][k] = INF;
	cin >> n >> m;
	vector<ll> s(n + 2);
	dp[0][0][0] = 0;
	REPO(i, n)cin >> s[i];
	REPO(i, n + 1) {
		REP(j, m + 1) {
			REP(k, i) {
				//使う場合
				dp[i][j][i] = min(dp[i][j][i], dp[i - 1][j][k] + max(0ll, s[k] - s[i]));
				//使わない場合
				if(i != n + 1) dp[i][j + 1][k] = min(dp[i][j + 1][k], dp[i - 1][j][k]);
			}
		}
	}
	REP(i, m + 1) {
		REP(j, n + 2) {
			ans = min(ans, dp[n + 1][i][j]);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int as, bs, cs;
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	as = sa.size();
	bs = sb.size();
	cs = sc.size();
	
	int a = 0, b=0, c=0;
	char next = 'a';
	
	while(true){
		//cout << a << " " << b << " " << c << endl;
		if(next == 'a'){
			if(a == as) break;
			next = sa[a];
			++a;
		}
		else if(next == 'b'){
			if(b == bs) break;
			next = sb[b];
			++b;
		}
		else{
			if(c == cs) break;
			next = sc[c];
			++c;
		}
	}
	
	if(next == 'a') cout << 'A';
	else if(next == 'b') cout << 'B';
	else cout << 'C';

}


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


int main() {
	int A,B,C,D;
	D=0;
	cin>>A>>B;
	for(int i=0;i<B;i++){
		cin>>C;
		D+=C;
	}
	if(A>=D){
		cout<<A-D<<endl;
	}
	else{
		cout<<"-1"<<endl;
	}
	

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;

int main() {
  string w;
  cin >> w;
  map<char, int> W;
  int n = w.size();
  
  for (int i = 0; i < n; i++) {
    if (W.count(w[i])) {
      W.at(w[i])++;
    }
    else {
      W[w[i]] = 1;
    }
  }
  bool ans = true;
  for (auto p : W) {
    auto v = p.second;
    if (v % 2 != 0) {
      ans = false;
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

    

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

using namespace std;

const int N = (int)1e5 + 7;

int a[N], b[N];
int n;

main() {
	scanf("%d", &n);
	vector <int> vec[2];
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		vec[i % 2].push_back(a[i]);
	}                
	sort(vec[0].begin(), vec[0].end());
	sort(vec[1].begin(), vec[1].end());
	vector <pair<int, int>> V[2];
	for (int i = 0; i < vec[0].size(); i++) {
		b[i] = 1;
		if (i > 0 && vec[0][i - 1] == vec[0][i]) {
			b[i] = b[i - 1] + 1;
		}            
		if (i + 1 == vec[0].size() || vec[0][i] != vec[0][i + 1]) {
			V[0].push_back({b[i], vec[0][i]});
		}
	}           
	for (int i = 0; i < vec[1].size(); i++) {
		b[i] = 1;
		if (i > 0 && vec[1][i - 1] == vec[1][i]) {
			b[i] = b[i - 1] + 1;
		}
		if (i + 1 == vec[1].size() || vec[1][i] != vec[1][i + 1]) {
			V[1].push_back({b[i], vec[1][i]});
		}
	}
	sort(V[0].begin(), V[0].end());
	sort(V[1].begin(), V[1].end());
	reverse(V[0].begin(), V[0].end());
	reverse(V[1].begin(), V[1].end());
	int ans = 1e9;     
	for (int i = 0; i < min(3, (int)V[0].size()); i++) {
		for (int j = 0; j < min(3, (int)V[1].size()); j++) {
			if (V[0][i].second == V[1][j].second) continue;
			ans = min(ans, n - V[0][i].first - V[1][j].first);
		}
	}
	if (ans == 1e9) ans = n / 2;
	cout << ans;
}


Measured memory_bytes: 2424
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    double dx=0,dy=0;
    int a,tem,ax,ay;
    double x=90;
 
    while(scanf("%d,%d",&a,&tem)){
        if(a==0&&tem==0) break;
        dx += a*cos(x*M_PI/180);
        dy += a*sin(x*M_PI/180);
        x-=tem;
    }
    ax=dx;
    ay=dy;
    printf("%d\n%d\n",ax,ay);
    return 0;
}

Measured memory_bytes: 604
N= int(input())
potential_plans = [list(map(int,input().split())) for i in range(N)]
dp = [[0]*3 for i in range(N)]

dp[0][0] = potential_plans[0][0]
dp[0][1] = potential_plans[0][1]
dp[0][2] = potential_plans[0][2]

for i in range(1,N):
  dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + potential_plans[i][0]
  dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + potential_plans[i][1]
  dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + potential_plans[i][2]

ans = max(dp[N-1][0],dp[N-1][1],dp[N-1][2])
print(ans)

Measured memory_bytes: 47384
import std.stdio, std.algorithm, std.string, std.conv, std.range;
 
void main(){
    string line;
    while(line = readln.chomp, line.length){
        auto d = line.to!int;
        int s;
        for(int x = 0; x < 600; x += d){
            s += x * x * d;
        }
        //s = reduce!((a, b) => a + b * b * d)(0, iota(d, 600, d));
        s.writeln;
    }
}

Measured memory_bytes: 972
#include<bits/stdc++.h>
using namespace std;
int n;
int k;
int p[100];
long long memo[101][4][4];
int solve(int idx,int t1,int t2){
  if(idx==n) return 1;
  if(memo[idx][t1][t2]!=-1) return memo[idx][t1][t2];
  if(p[idx]>0){
    if(t1==t2 && t2==p[idx]){
      return 0;
    }else{
      return solve(idx+1,t2,p[idx])%10000;
    }
  }else{
    long long res=0;
    for(int i=1;i<=3;i++){
      if(t1==t2 && t2==i) continue;
      res+=solve(idx+1,t2,i)%10000;
    }
    return memo[idx][t1][t2]=res%10000;
  }
}
int main(){
  cin>>n>>k;
  memset(p,-1,sizeof(p));
  memset(memo,-1,sizeof(memo));
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    p[a-1]=b;
  }
  cout<<solve(0,0,0)<<endl;
}

Measured memory_bytes: 1188
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>
#include <list>

using namespace std;

int main(void) {

    string s;
    cin >> s;
    cout << s.substr(0,3) << endl;








	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
    int a,b,c;
    int num, count, sum;
    int i,j,k;
    int ansi=-1, ansj=-1, ansk=-1;

    scanf("%d %d", &count, &num);

    for(i=0; i<=count; i++){
        for(j=0; j<=(count-i); j++){
            k = count - i - j;
            sum = i*10000 + j*5000 + k*1000;
            if(sum == num){
                break;
            }
        }
        if(sum == num){
            ansi = i;
            ansj = j;
            ansk = k;
            break;
        }
    }
    printf("%d %d %d", ansi, ansj, ansk);

    return 0;
}

Measured memory_bytes: 128
N=int(input())

A,B=map(int,input().split())
P=list(map(int,input().split()))

P.sort()

a=[]
b=[]
c=[]
for i in range(N):
    if P[i]<=A:
        a.append(P[i])
    elif P[i]<=B:
        b.append(P[i])
    else:
        c.append(P[i])
print(min(len(a),len(b),len(c)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	int x;
	cin >> x;
	int n = 0;
	while (x > 0)
		x -= ++n;
	cout << n;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int h,w,x,y;

bool c(int a,int b){
	return a>=0&&b>=0&&a<h&&b<w;
}

main(){
	cin>>h>>w;
	char f[h][w];
	rep(i,h)rep(j,w)cin>>f[i][j];
	/*if(f[0][0]!='#'){
		dump("");
	}*/
	//00akuiaru
	f[0][0]='.';
	while(1){
		if(f[y][x+1]=='#'&&c(y,x+1)){
			x++;f[y][x]='.';	
		}else if(f[y+1][x]=='#'&&c(y+1,x)){
			y++;f[y][x]='.';
		}else break;
	}
	rep(i,h)rep(j,w){
		if(f[i][j]=='#'){
			dump("Impossible");
			return 0;
		}
	}
	dump("Possible");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;
char str[MAXN];
int dp[2200];

int main()
{
	int i, j;
	scanf("%s", str);
	int n = 0;
	while (str[n] != 0) ++n;
	int cur = 0;
	int pow10 = 1;
	ll ans = 0LL;
	dp[cur]++;
	for (i = n - 1; i >= 0; --i) {
		cur += ((str[i] - '0')* pow10);
		cur %= 2019;
		pow10 = (10*pow10)%2019;
		ans += (ll)dp[cur];
		dp[cur]++;
	}
	printf("%lld", ans);
	return 0;
}

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

int c[33], s[444][33];
int sco(int t, const vector<int> &v) {
    int r = 0, l = 0, d = v.size();
    for(int i = 0; i < d; i++)
        if(v[i] == t)
            r += s[i][t] - c[t] * (i + 1 - l) * (i - l) / 2, l = i + 1;
    r -= c[t] * (d + 1 - l) * (d - l) / 2;
    return r;
}
int main() {
    auto ti = clock();
    int d;
    cin >> d;
    for(int i = 0; i < 26; i++)
        cin >> c[i];
    for(int i = 0; i < d; i++)
        for(int j = 0; j < 26; j++)
            cin >> s[i][j];
    vector<int> ss, tt;
    int M = -1e9;
    for(int a = 10; a < 16; a++) {
        for(int b = 0; b < 4; b++) {
            for(int z = 5; z < 16; z++) {
                int r = 0, l[33] = {};
                ss.clear();
                for(int i = 0; i < d; i++) {
                    auto m = 0.;
                    int t = 0;
                    for(int j = 0; j < 26; j++) {
                        double p = s[i][j];
                        p += c[j] * (i + 1 - l[j]) * .4 * a;
                        for(int k = 1; k < z; k++)
                            if(i + k < d)
                                p -= s[i + k][j] * (z - k) * .05 / z * b;
                        if(p > m)
                            m = p, t = j;
                    }
                    ss.push_back(t);
                    r -= c[t] * (i + 1 - l[t]) * (i - l[t]) / 2;
                    l[t] = i + 1;
                    r += s[i][t];
                }
                for(int j = 0; j < 26; j++)
                    r -= c[j] * (d + 1 - l[j]) * (d - l[j]) / 2;
                if(r > M)
                    M = r, tt.swap(ss);
            }
        }
    }
    int S = 0;
    for(int j = 0; j < 26; j++)
        S += sco(j, tt);
    assert(S == M);
    random_device rd;
    mt19937 mt(rd());
    uniform_int_distribution<> rc(0, 25), r0(0, d - 1), r2(1, 6);
    for(int cn = 0;
        cn < 100 || (cn = 0, (clock() - ti + 0.) / CLOCKS_PER_SEC < 1.9);
        cn++) {
        auto uu = tt;
        int x0 = r0(mt), xc = rc(mt);
        uu[x0] = xc;
        if(int y =
               sco(tt[x0], uu) + sco(xc, uu) - sco(tt[x0], tt) - sco(xc, tt);
           y > 0) {
            tt.swap(uu);
            M += y;
        }
        uu = tt;
        int x2 = r2(mt);
        uniform_int_distribution<> r1(0, d - 1 - x2);
        int x1 = r1(mt);
        x2 += x1;
        swap(uu[x1], uu[x2]);
        if(int y = sco(tt[x1], uu) + sco(tt[x2], uu) - sco(tt[x1], tt) -
                   sco(tt[x2], tt);
           y > 0) {
            tt.swap(uu);
            M += y;
        }
    }
    S = 0;
    for(int j = 0; j < 26; j++)
        S += sco(j, tt);
    assert(S == M);
    for(int i : tt)
        cout << i + 1 << '\n';
    cerr << M << endl;
    return 0;
}


Measured memory_bytes: 3712
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()



int main() {
	map<char, int> mp;
	string w;
	cin >> w;
	for (int i = 0; i < w.size(); i++) {
		mp[w[i]]++;
	}
	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->second % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 
public class Main{
    public static int count = 0;
    public static void main(String[] args) throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        int max = 0;
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i<n ; i++ ) {
            a[i] = sc.nextInt();
            max = Math.max(max,a[i]);
        }
 
        countingSort(a,b,max);
        sb.append(b[0]);
        for (int i = 1; i<n ; i++ ) {
            sb.append(" ").append(b[i]);
        }
 
        System.out.println(sb);
    }
 
 
    public static void countingSort(int[] a,int[] b,int max){
        int[] c = new int[max+1];
 
        for (int j = 0; j<a.length ; j++ ) {
            c[a[j]]++;
        }
 
        for (int i = 1; i<=max ; i++ ) {
            c[i] = c[i] + c[i-1];
        }
 
        for (int j = a.length-1; j>=0 ; j-- ) {
            b[c[a[j]]-1] = a[j];
            c[a[j]]--;
        }
 
 
    }
}

Measured memory_bytes: 516480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X[] = new int[N];
		int a = 0;
		double b = 0;

		for (int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
			a += X[i];
		}
		double aa=a;
		double NN=N;
		sc.close();
		double A = Math.round(aa / NN);

		for (int i = 0; i < N; i++) {
			b += Math.pow((X[i] - A), 2);
		}
		int c = (int) b;
		System.out.println(c);
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(10)<<fixed;
	int n, m;
	pll ab[114514];
	cin>>n>>m;
	REP(i, n){
		cin>>ab[i].first>>ab[i].second;
	}
	sort(ab, ab+n);
	ll ans=0, cnt=0;
	REP(i, n){
		if(cnt+ab[i].second<m){
			ans+=ab[i].first*ab[i].second;
			cnt+=ab[i].second;
		}
		else{
			ans+=ab[i].first*(m-cnt);
			break;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2048
#python3
from math import floor
from math import sqrt
INF = int(1e13)
def main():
    n = int(input())
    ans = INF
    for i in range(1, floor(sqrt(n))+1):
        if n%i == 0:
            ans = min(ans, i+n//i-2)
    print(ans)
main()

Measured memory_bytes: 3064
n = int(input())
pl = list(map(float,input().split()))

# dp[i][j] i回目でj回表がでる確率
dp = [[0 for j in range(n+1)] for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    for j in range(n):
        dp[i+1][j+1] += pl[i] * dp[i][j]
        dp[i+1][j] += (1-pl[i]) * dp[i][j]

def ceil(a, b):
   return a // b + (a % b > 0)
print(sum(dp[-1][ceil(n,2):]))

Measured memory_bytes: 257544
N, A, B, C = map(int, input().split())
take = [int(input()) for _ in range(N)]


def dfs(n, a, b, c):
    if n == N:
        return abs(A - a) + abs(B - b) + abs(C - c) - 30 if min(a, b, c) > 0 else 10 ** 9
    ret0 = dfs(n + 1, a, b, c)
    ret1 = dfs(n + 1, a + take[n], b, c) + 10
    ret2 = dfs(n + 1, a, b + take[n], c) + 10
    ret3 = dfs(n + 1, a, b, c + take[n]) + 10
    return min(ret0, ret1, ret2, ret3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MAX_N 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, a[MAX_N+5], f[MAX_N+5];
int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i]);
	f[2] = abs(a[2]-a[1]);
	for (int i = 3; i <= n; i++)
		f[i] = min(f[i-1]+abs(a[i]-a[i-1]), f[i-2]+abs(a[i]-a[i-2]));
	return printf("%d\n", f[n]), 0;
}


Measured memory_bytes: 1024
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=collections.Counter(a)
values,counts=zip(*a.most_common())
l=len(values)
ans=0
i=0
while l>k:
  ans=ans+counts[len(values)-i-1]
  i=i+1
  l=l-1

print(ans)

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

using namespace std;
using ll = long long;

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

    for (int i = 1; i < 4; i++){
        if (S[i] == S[i-1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;

}


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

long long k;
int n,now=1,a[223456][60];
int d(int now,int k){
  a[now][k]||(a[now][k]=d(d(now,k-1),k-1));
  return a[now][k];
}

int main(){
  cin>>n>>k;
  for(int i=1;i<=n;i++)cin>>a[i][0];
  for(int i=0;i<60;i++)if((k>>i)&1)now=d(now,i);
  cout<<now<<endl;
}


Measured memory_bytes: 50508
#include <iostream>

using namespace std;

int main()
{
	// 入力
	int X, A;
	cin >> X >> A;
	
	int answer = 0;
	if (X >= A)
	{
		answer = 10;
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
aa, bb, cc = a, b, c
p = 0
q = 1
k = int(input())

for i in range(1,k + 2):
    a, b, c = aa, bb, cc
    b = b * (2 ** (k - i + 1))
    c = c * (2 ** (i - 1))
    if c <= 0:
        c = cc
    if b <= 0:
        b = bb
    if a < b and b < c:
        p += 1

if p != 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <sstream>

using namespace std;
const long long P = 1000000007;
const long long INF = 1LL << 60;

int main() {
  long long x;
  cin >> x;
  int ans;
  long long over = 0;
  for(int i = 0; i <= 100000; i++) {
    if(i*(i+1) >= 2*x) {
      ans = i;
      break;
    }
  }
  cout << ans + over << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll n,ans = 0;
	cin >> n;
	vc a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n-1;i++) {
		if(a[i]=='W' and a[i+1]=='R')
			ans++;
	}
	if(ans) {
		ans = 0;
		ll a1 = 0, a2 = 0;
		vc b(n);
		for(int i=0;i<n;i++) b[i] = a[i];
		sort(b.begin(), b.end());
		for(int i=0;i<n;i++) {if(a[i]>b[i]) a1++; if(a[i]<b[i]) a2++;}
		ans = max(a1, a2);
	}
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    //cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 3720
n=int(input())
a=[]
a=list(map(int,input().split()))
ave=sum(a)/n
if ave<int(ave)+0.5:
  ave=int(ave)
else:
  ave=int(ave)+1
ans=0
for i in range(n):
  ans+=(a[i]-ave)**2
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fix(n) cout<<fixed<<setprecision(n)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
using namespace std;
typedef long long ll;
const ll mod=1000000007;
double pi=3.1415926535;

int main(){
  int a,b,c,n,x,ans=0;
  cin>>a>>b>>c>>n;
  rep(i,0,n/a+1){
    rep(j,0,n/b+1){
      x=n-a*i-j*b;
      if(x%c==0 && x>=0) ans++;
    }
  }
  co(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long A,B,K;
    cin >> A >> B >> K;
    for(int i=A;i<=B;i++){
        if(i<A+K)   cout << i << endl;
        else if(i>B-K)  cout << i << endl;
    }
    return 0;
}

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

int main(){

  int n, m, a[100], b, sum[100]={}, x;

  cin>>n>>m;

  for(int i=0;i<m;i++) cin>>a[i];

  for(int i=0;i<m;i++){
    x=0;
    for(int j=0;j<n;j++){
      cin>>b;
      if(a[i]==b) sum[j]++;
      else x++;
    }
    sum[a[i]-1]+=x;
  }

  for(int i=0;i<n;i++) cout<<sum[i]<<endl;

  return 0;
}

Measured memory_bytes: 3080
#include <stdio.h>
 
int main() {
  int N;
  int result = 0;
  scanf("%d",&N);
  char S[N];
  scanf("%s",S);
  for(int i=0;i<N-2;i++) {
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') {
      result++;
    }
  }
  printf("%d",result);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    llint n;
    cin >> n;
    vector<llint> v(n);
    REP(i,n){
        cin >> v[i];
    }
    vector<vector<llint>> dp(n + 1, vector<llint>(n + 1, 0));
    FOR(length,1,n+1){
        REP(l,n-length+1){
            llint r = l + length;
            dp[l][r] = max(v[l] - dp[l + 1][r], v[r-1] - dp[l][r - 1]);
        }
    }
    cout << dp[0][n] << endl;

    return 0;
}


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

#define ll long long
#define mod 1000000007

int main() {
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
    ll dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(ll i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b[i];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+c[i];
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0 ;
}


Measured memory_bytes: 4992
// ABC99-C
#include <bits/stdc++.h>
#define endl "\n"
#define _GLIBCXX_DEBUG //配列外参照エラー表示,gcc依存
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int n;
    cin>>n;
    vector<int> coin={1};
    int num=6;
    while(num<=n){
        coin.emplace_back(num);
        num*=6;
    }
    num=9;
    while(num<=n){
        coin.emplace_back(num);
        num*=9;
    }
    int kind=coin.size();
    vector<vector<int>> dp(kind+10,vector<int>(n+10,n+10));
    for(int i=0;i<=kind;i++) dp[i][0]=0;
    for(int i=1;i<=kind;i++){
        for(int j=1;j<=n;j++){
            if(0<=j-coin[i-1]) dp[i][j]=min(dp[i][j-coin[i-1]]+1,dp[i-1][j]);
            else dp[i][j]=min(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[kind][n]<<endl;
    //cout<<coin<<endl;
    //cout<<dp<<endl;
    return 0;
}

Measured memory_bytes: 9216
N, K, Q = map(int, input().split())
A = []
for i in range(Q):
  A.append(int(input()))
import collections
c = collections.Counter(A)

for i in range(N):
  p = c.get(i+1, 0)
  if p > Q-K:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 11944
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

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 { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n, m;
  cin >> n >> m;
  vb ok(n + 1, true);
  vector<mint> dp(n + 2, 0);
  rep(i, m) {
    ll a;
    cin >> a;
    ok[a] = false;
  }
  dp[0] = 1;
  rep(i, n) {
    if(ok[i + 1]) dp[i + 1] += dp[i];
    if(ok[i + 2]) dp[i + 2] += dp[i];
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 3984
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define ri register int
#define il inline
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end() 
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define per(i,a,b) for(ri i=(a);i>=(b);--i)
#define ls (x<<1)
#define rs (x<<1|1)
#define mid (l+r>>1)
#define db(x) cout << "#x:" << x << endl
#define dd() cout << "Out put!\n"
const int mod=1e9+7,eps=1e-6,pi=acos(-1.0),maxn=1000010;
const int inf=0x7f7f7f7f7f7f7f7f;
using namespace std;
int a[maxn],b[maxn],c[maxn];
string s; 
signed main()
{
	int t=1;
//	cin >> t;
	while(t--)
	{
		int a,b,c,d,e;
		cin >> a >> b >> c >> d >> e;
		int sum = a*60+b;
		int ans = c*60+d;
		
		cout << abs(sum-ans)-e;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)
 
int main() {
  int n; cin >> n;
  vector<int> x(n);
  vector<int> c(n);
  REP(i,n) cin >> x[i];
  REP(i,n) c[i] = x[i];
  sort(x.begin(), x.end());
  int l = x[n/2-1], r = x[n/2];
  REP(i,n) {
    if (c[i] < l) cout << r << endl;
    else if (c[i] > r) cout << l << endl;
    else if (c[i] == l) cout << r << endl;
    else if (c[i] == r) cout << l << endl;
  }
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(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() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    int l = s.size() - 1;
    if(s[0] == s[l]) {
        if(l % 2 == 0) cout << "Second";
        else cout << "First";

    } else {
        if(l % 2 == 0) cout << "First";
        else cout << "Second";

    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(){
    double eps = 1e-10;
    double xa, xb, xc, xd, ya, yb, yc, yd;
    double s1, s2, s3, s4;
    
    while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF){
        s1 = fabs((xb - xa)*(yc - ya) - (yb - ya)*(xc - xa));
        s2 = fabs((xc - xa)*(yd - ya) - (yc - ya)*(xd - xa));
        s3 = fabs((xb - xa)*(yd - ya) - (yb - ya)*(xd - xa));
        s4 = fabs((xc - xb)*(yd - yb) - (yc - yb)*(xd - xb));
        
        if(fabs(s1 - s2 - s3 - s4) < eps) printf("NO\n");
        else if(fabs(s2 - s1 - s3 - s4) < eps) printf("NO\n");
        else if(fabs(s3 - s1 - s2 - s4) < eps) printf("NO\n");
        else if(fabs(s4 - s1 - s2 - s3) < eps) printf("NO\n");
        else printf("YES\n");
    }
    
    return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
int a[600000],s[600000];
ll dp[600000][2];
ll dp2[2000000][2];
ll c2[2000000];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%d",&a[i]);
		s[i+1]=s[i]^a[i];
	}
	if(s[n]!=0){
		int x=s[n];
		dp[1][1]=1;
		for(int i=1;i<n;i++)rep(j,2){
			if(j==0){
				(dp[i+1][j]+=dp[i][j])%=MOD;
				if(s[i]==0){
					(dp[i+1][!j]+=dp[i][j])%=MOD;
				}
			}
			else{
				(dp[i+1][j]+=dp[i][j])%=MOD;
				if(s[i]==x){
					(dp[i+1][!j]+=dp[i][j])%=MOD;
				}
			}
		}
		cout<<dp[n][1]<<endl;
	}
	else{
		ll ans=0;
		//all 0
		int cnt=0;
		for(int i=1;i<n;i++){
			if(s[i]==0)cnt++;
		}
		ans+=ppow(2,cnt);
		for(int i=1;i<(1<<20);i++){
			dp2[i][1]=1;
		}
		ll c1=0;
		for(int i=1;i<n;i++){
			if(s[i]){
				if(c1>c2[s[i]]){
					(dp2[s[i]][1]+=dp2[s[i]][0]*(c1-c2[s[i]])%MOD)%=MOD;
					c2[s[i]]=c1;
				}
				(dp2[s[i]][0]+=dp2[s[i]][1])%=MOD;
			}
			else c1++;
		}
		for(int i=1;i<(1<<20);i++){
			(ans+=dp2[i][0])%=MOD;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 34176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n, q;
int A[100100], m;

bool solve(int i, int m) {
	if (m == 0)return true;
	if (i >= n)return false;
	bool res = solve(i + 1, m) || solve(i + 1, m - A[i]);
	return res;
}

int main() {
	cin >> n;
	rep(i, n)cin >> A[i];
	cin >> q;
	rep(i, q) {
		int m;
		cin >> m;
		if (solve(0, m))cout << "yes" << endl;
		else cout << "no" << endl;
	}
}

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

int main(){
  int n;
  int a[200010];
  int b[200010];
  cin >> n;

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

  int l = 0, r = n-1;

  for(int i = 0;i < n;i++){
    if(i % 2 == 0){
      b[l] = a[n-i-1];
      l++;
    }else{
      b[r] = a[n-i-1];
      r--;
    }
  }

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

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

int main() {
	int flag = false;
	int N;
	cin >> N;
	int *a = new int[N];
	for (int i = 0; i < N; i++)
		cin >> a[i];

	int count4 = 0, count2 = 0, count1 = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] % 4 == 0)
			count4++;
		else if (a[i] % 2 == 0)
			count2++;
		else
			count1++;
	}

	if (count2 > 0) {
		if (count4 >= count1)
			flag = true;
	}
	else {
		if (count4 >= count1 - 1)
			flag = true;
	}

	if (flag)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
#define INF 999999999
#define int64 long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}

typedef pair<int64, int64> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first <= secondElof.first;
}

int main(){
    int64 N, M;
    cin >> N >> M;
    int64 A[100001], B[100001];
    pair<int64, int64> p[100001];
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    sort(p+1, p+N+1); //rep(i, 2) cout << p[i].first << endl;
    int64 ans = 0;
    rep(i, N){
        if(p[i].second < M){
            ans += p[i].first * p[i].second;
            M -= p[i].second;
        }
        else{
            ans += p[i].first * M;
            M = 0;
        }
        if(M == 0) break;
    }
    cout << ans;
    return 0;
}

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

#define N_MAX 65000

int qsc_uint(const void* x,const void* y) {
	unsigned int a=*((const unsigned int*)x);
	unsigned int b=*((const unsigned int*)y);
	if(a>b)return 1;
	if(a<b)return -1;
	return 0;
}

int main(void) {
	unsigned int n;
	while(scanf("%u",&n)==1 && n>0) {
		unsigned int plen_sum=0;
		static unsigned int jlen[N_MAX];
		unsigned int max=0;
		unsigned int i;
		for(i=0;i<n;i++) {
			unsigned int plen;
			scanf("%u",&plen);
			plen_sum+=plen;
		}
		for(i=0;i<n-1;i++) {
			scanf("%u",&jlen[i]);
			plen_sum+=jlen[i];
		}
		qsort(jlen,n-1,sizeof(jlen[0]),qsc_uint);
		for(i=1;i<=n;i++) {
			if(i*plen_sum>max)max=i*plen_sum;
			if(i<n)plen_sum-=jlen[i-1];
		}
		printf("%u\n",max);
	}
	return 0;
}

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

int main(){
  int N,M;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
  }
  cin >> M;
  vector<string> t(M);
  for(int i=0;i<M;i++){
    cin >> t.at(i);
  }
  int max=0;
  for(int i=0;i<N;i++){
    int tmp=1;
    for(int j=i+1;j<N;j++){
      if(s.at(i)==s.at(j)){
        tmp++;
      }
    }
    for(int k=0;k<M;k++){
      if(s.at(i)==t.at(k)){
        tmp--;
      }
    }
    if(tmp>max){
      max=tmp;
    }
  }
  cout << max << endl;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int M = 200009;
int m;
int d[M], c[M];

pair<int, int> digs(int num) {
    if(num < 10) return {num, 0};
    int ret = 0;
    while(num) {
        ret += num%10;
        num /= 10;
    }
    pair<int, int> rec = digs(ret);
    return {rec.first, 1 + rec.second};
}

pair<int, int> red(int dig, int ct) {
    if(ct == 0) return {0, 0};
    if(ct%2) {
        pair<int, int> tmp = red(dig, ct-1);
        pair<int, int> nxt = digs(tmp.first + dig);
        return {nxt.first, tmp.second + nxt.second + 1};
    } else {
        pair<int, int> tmp = red(dig, ct/2);
        pair<int, int> nxt = digs(tmp.first*2);
        return {nxt.first, tmp.second*2 + nxt.second};
    }
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> m;
    for(int i = 0; i < m; ++i) cin >> d[i] >> c[i];

    int ans = 0, cur = 0;
    for(int i = 0; i < m; ++i) {
        pair<int, int> x = red(d[i], c[i]);
        ans += x.second;
        cur += x.first;
        pair<int, int> tmp = digs(cur);
        ans += tmp.second;
        cur = tmp.first;
    }

    cout << ans-1 << endl;
    
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9)cout << "hon" << endl;
  else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8)cout << "pon" << endl;
  else if(N % 10 == 3) cout << "bon" << endl;
}

Measured memory_bytes: 3592
import java.util.*;
class Main{
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int n=scn.nextInt();
        int[] side=new int[n];
        int max=-1;
        int num=-1;
        for(int i=0;i<n;i++){
            side[i]=scn.nextInt();
            if(side[i]>max){ 
                max=side[i];
                num=i;
            }
        }   
        int total=0;
        for(int i=0;i<n;i++){
            if(i!=num) total+=side[i];
        }
        if(total>max){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 22728