akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

ll N;
bool ok(vector<ll> &A){
    rep(i, A.size()){
        if(A[i] >= N) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    
    ll ans = 0;
    while(!ok(A)){
        rep(i, N){
            ll add = A[i] / N;
//            cout << i << ":" << add << endl;
            A[i] %= N;
            ans += add;
            rep(j, N){
                if(i != j) A[j] += add;
            }
        }
//        voutput(A);
    }
    output(ans);
    
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);
            int c = int.Parse(str[2]);

            if(a == b && b == c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,X;
  cin >> K >> X;
  
  for (int i = 0; i < K*2-1; i++) {
    if (i == K*2-2){
      cout << X - K + 1 + i << endl;
    }
    else {
      cout << X - K + 1 + i << ' ';
    } 
  }
}
  

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    string str; cin>>str;
    int count=0,maximum=0;
    REP(i,0,str.size()) {
        if(str[i] == 'A' or str[i] == 'C' or str[i] == 'G' or str[i] == 'T') {
            count++;
            maximum = max(maximum,count);
        }
        else count=0;
    }

    cout<<maximum;
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
#include <iomanip>

using namespace std;
int MOD = 998244353;
const int mxN = 2e5 + 9;

int ar[mxN];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int R;
	cin >> R;
	double ans = 2*3.14159265358979323846*R;
	cout << fixed;
	cout << setprecision(10);
	cout << ans;


}


Measured memory_bytes: 3780
#include <stdio.h>
long long power(long long m, long long n)//long long じゃないと数が大きくなった時にあふれる
{
    if(n==1)
    return m;
    else if(n%2==0)
    return power(m*m%1000000007, n/2);
    else
    return power(m*m%1000000007, n/2)*m%1000000007;
}

int main(void)
{
    long long m, n;
    scanf("%lld %lld\n",&m,&n);
    printf("%lld\n",power(m,n));
    return 0;
}


Measured memory_bytes: 2104
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//幅優先探索のテンプレ.デフォルトではstartからの距離を返す.
//graphは隣接リスト.startは探索開始地点
vector<int> bfs(vector<vector<int>> &graph, int start){
	queue<int> todo;
	vector<int> dist(graph.size(),-1);
	dist[start] = 0;
	todo.push(start);
	while(!todo.empty()){
		int now = todo.front();
		todo.pop();
		for (int i=0;i<graph[now].size();i++){
			int nxt = graph[now][i];
			if (dist[nxt] != -1) continue;
			dist[nxt] = dist[now] + 1;
			todo.push(nxt);
		}
	}
	return dist;
}

int dif(vector<string> s,vector<string> t){
	int n = s.size();
	int res = 0;
	rep(i, n)
	{
		rep(j,n){
			if(s[i][j] != t[i][j])
				res++;
		}
	}
	return res;
}

vector<string> r(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[j][n - i - 1] = s[i][j];
		}
	}
	return temp;
}
vector<string> l(vector<string> s){
	int n = s.size();
	vector<string> temp(n, string(n, '0'));
	rep(i, n)
	{
		rep(j,n){
			temp[n-j-1][i] = s[i][j];
		}
	}
	return temp;
}

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<int> dp(k + 1, 0);
	rep2(i,1,k+1){
		rep(j,n){
			if(i - a[j]>= 0){
				if(dp[i-a[j]]==0){
					dp[i] = 1;
				}
			}
		}
	}
	if(dp[k])
		cout << "First" << endl;
	else
		cout << "Second" << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

int main() {
  ll n, q; cin >> n >> q;
  queue<P<string, ll>> que;
  REP(i, n) {
    string s; ll t; cin >> s >> t;
    que.push({s, t});
  }
  ll spent = 0;
  while (!que.empty()) {
    P<string, ll> qu = que.front(); que.pop();
    if (qu.second <= q) {
      cout << qu.first << ' ' << spent + qu.second << endl;
      spent += qu.second;
    } else {
      que.push({qu.first, qu.second-q});
      spent += q;
    }
  }
  return 0;
}



Measured memory_bytes: 6280
n = int(input())
s = input()
seed1 = ["S","W"]
ans = ["SS","SW","WS","WW"]
for i in s[1:]:
    for k,v in enumerate(ans):
        now = 0 if i == "o" else 1
        now = (now + seed1.index(v[-1]) + seed1.index(v[-2])) % 2
        if now:
            ans[k] += "W"
        else:
            ans[k] += "S"
now = 0 if s[0] == "x" else 1
for i in ans:  
    now2 = (now + seed1.index(i[-2]) + seed1.index(i[1]) + seed1.index(i[0])) % 2
    if (i[0] == i[-1]) and now2:
        print(i[:-1])
        exit()
print(-1)

Measured memory_bytes: 4040
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-01-22 16:47:46
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#include<vector>
int n,l;
void print(std::vector<int> v){ fr(i,1,v.size()-1) printf("%d %d\n",v[i-1],v[i]); }
int main()
{
	n=read(); l=1;
	if((n&(-n))==n){ printf("No\n"); return 0; }
	printf("Yes\n");
	while((l<<1)<=n) l<<=1;
	print({n,l,n-l,n+n,l+n,n-l+n});
	fr(i,1,n-l-1) print({i,i+l,l,i+n,i+l+n});
	for(int i=l-1;i-1>n-l;i-=2) print({i,i-1,1,i+n,i-1+n});
	if(!(n&1)) printf("%d %d\n%d %d\n",n-l+1,n-l,l+1,n-l+1+n);
	return 0;
}

Measured memory_bytes: 2560
N = int(input())
A = 1
B = 1
listA = []
listB = []
for i in range(N):
    # N = A + B
    A = i+1
    B = N - i -1
    listA.append(A)
    listB.append(B)
ans = []
for i in range(N-1):
    A = str(listA[i])
    if len(str(A)) == 1:
        sumA = int(A)
    elif len(str(A)) == 2:
        sumA = int(A[0]) + int(A[1])
    elif len(str(A)) == 3:
        sumA = int(A[0]) + int(A[1]) + int(A[2])
    elif len(str(A)) == 4:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3])
    elif len(str(A)) == 5:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3]) +int(A[4])
    elif len(str(A)) == 6:
        sumA = int(A[0]) + int(A[1]) + int(A[2]) + int(A[3]) +int(A[4]) + int(A[5])

    B = str(listB[i])
    if len(str(B)) == 1:
        sumB = int(B)
    elif len(str(B)) == 2:
        sumB = int(B[0])+ int(B[1])
    elif len(str(B)) == 3:
        sumB = int(B[0])+ int(B[1]) + int(B[2])
    elif len(str(B)) == 4:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3])
    elif len(str(B)) == 5:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3]) +int(B[4])
    elif len(str(B)) == 6:
        sumB = int(B[0])+ int(B[1]) + int(B[2]) + int(B[3]) +int(B[4])+ int(B[5])

    ans.append(sumA + sumB)

print(min(ans))

Measured memory_bytes: 11760
s = input()
n = len(s)
ma = n+1
mz = -1
for i in range(0 , n):
	if s[i]=='A':
		ma = min(ma, i)
	if s[i]=='Z':
		mz = max(mz, i)

if ma>mz:
	print(0)
else:
	print(mz-ma+1)

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

int main() {
  long A,V;cin>>A>>V;
  long B,W;cin>>B>>W;
  long T;cin>>T;
  long dist;
  bool can;
  if (V<=W) can=false;
  else{
    long catchup=V-W;
    if(A>B) dist=A-B;
    else dist=B-A;
    if(catchup*T>=dist) can=true;
    else can=false;
  }
  if(can) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}



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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);

struct Field {
  int n;
  char x[512][512];
  void read() {
    scanf("%d", &n);
    for(int i = 0; i < n; ++i) {
      scanf("%s", x[i]);
    }
  }
  void write() {
    printf("%d", n);
    for(int i = 0; i < n; ++i) {
      printf("%s\n", x[i]);
    }
  }
  int solve() {
    int res = 1000000000;
    if( empty() ) return -1;
    for(int r = 0; r < n; ++r) {
      res = std::min(res, f(r));
    }
    for(int c = 0; c < n; ++c) {
      res += g(c);
    }
    return res;
  }
  bool empty() {
    for(int i = 0; i < n; ++i) {
      for(int j = 0; j < n; ++j) {
        if( x[i][j] == '#' ) return false;
      }
    }
    return true;
  }
  int f(int i) {
    int res = 1;
    for(int k = 0; k < n; ++k) {
      if( x[k][i] == '#' ) {
        res = 0;
      }
    }
    for(int j = 0; j < n; ++j) {
      if( x[i][j] == '.' ) {
        res += 1;
      }
    }
    return res;
  }
  int g(int j) {
    for(int k = 0; k < n; ++k) {
      if( x[k][j] == '.' ) return 1;
    }
    return 0;
  }
};

int main() {
  Field field;
  field.read();
  int res = field.solve();
  printf("%d\n", res);

  
  return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	static long dist[][];
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int c[][] = new int[10][10];
		dist = new long[10][10];
		for(int i = 0; i < 10; i++) {
			Arrays.fill(dist[i], Integer.MAX_VALUE);
		}
		for(int i = 0; i < 10; i++) {
			for(int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
				dist[i][j] = c[i][j];
			}
		}
		int A[][] = new int[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		WarshallFloyd(10);
		
		int ans = 0;
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				if(A[i][j] != -1 && A[i][j] != 1) {
					ans += dist[A[i][j]][1];
				}
			}
		}
		
		System.out.println(ans);
	}
	
	static void WarshallFloyd(int N) {
		for(int k = 0; k < N; k++) {
			for(int i = 0; i < N; i++) {
				for(int j = 0; j < N; j++) {
					dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
	}
}


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

int main()
{
    int n;
    cin >> n;
    char ans, p;
    cin >> ans;
    for (int i = 1; i < n; i++)
    {
        cin >> p;
        if (ans == 'T' && p == 'F')
            ans = 'F';
        else
            ans = 'T';
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
using namespace std;

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


      int n,a;
      cin >>n>> a;
       int ans = n/a;
       if(n%a) ans++;
      cout << ans << '\n';

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);


class comb{
	vector<ll> f,fr;
	ll MOD_;
	public:
	//a^(p-1) = 1 (mod p)(p->Prime numbers)
	//a^(p-2) = a^(-1)
	ll calc(ll a,ll b,ll p){//a^(b) mod p   
		if(b==0)return 1;
		ll y = calc(a,b/2,p);y=(y*y)%p;
		if(b & 1) y = (y * a) % p;
		return y;
	}
	void init(ll n,ll mod){//input max_n
		MOD_ = mod;
		f.resize(n+1);
		fr.resize(n+1);
		f[0]=fr[0]=1;
		for(ll i=1;i<n+1;i++){
			f[i] = (f[i-1] * i) % mod;
		}
		fr[n] = calc(f[n],mod-2,mod);
		for(ll i=n-1;i>=0;i--){
			fr[i] = fr[i+1] * (i+1) % mod;
		}
	}
	ll nCr(ll n,ll r){
		if(n<0||r<0||n<r)return 0;
		return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
	}
};


int main(){
	ll r1,r2,c1,c2,ans=0;
	cin >> r1 >> c1 >> r2 >> c2;
	comb co;
	co.init(2000088,MOD);
	FOR(i,c1,c2+1){
		ans += co.nCr(i+r2+1,r2);
		ans %= MOD;
		ans += MOD - co.nCr(i+r1,r1-1);
		ans %= MOD;
	}
	cout << ans << endl;
}



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

int res;
const int d[10]={0,1,2,3,4,5,6,7,8,9};

void dfs(int now,int idx,int n,int sum,int s){
	if(now==n) {
		if(sum==s){
			res++;
                        return;
		}
	}
	if(idx<10){
		dfs(now,idx+1,n,sum,s);
		dfs(now+1,idx+1,n,sum+d[idx],s);
	}
}

int main(){
	int n,s;
	queue<int> que;
	while(cin>>n>>s,n||s){
		res=0;
		dfs(0,0,n,0,s);
		que.push(res);
	}

	while(que.size()){
		cout<<que.front()<<endl;
		que.pop();
	}

	return 0;
}

Measured memory_bytes: 1200
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    ll n,m;
    cin >> n >> m;
    rep(i,m){
        ll a;
        cin >> a;
        n -= a;
    }

    cout << (n < 0 ? -1 : n) << endl;
}

Measured memory_bytes: 3152
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	multiset<int> a, b;
	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);
		if (x < 0)
			a.insert(x);
		else
			b.insert(x);
	}
	vector<pair<int, int> > sol;
	if (b.empty()) {
		while (a.size() > 1) {
			int x = *--a.end();
			a.erase(--a.end());
			int y = *--a.end();
			a.erase(--a.end());
			sol.push_back({ x,y });
			a.insert({ x - y });
		}
	}
	else {
		if (a.empty() && b.size() > 1) {
			a.insert(*b.begin());
			b.erase(b.begin());
		}
		while (b.size() > 1) {
			int x = *a.begin();
			a.erase(a.begin());
			int y = *b.begin();
			b.erase(b.begin());
			sol.push_back({ x,y });
			a.insert(x - y);
		}
		while (b.size() + a.size() > 1) {
			int x = *b.begin();
			b.erase(b.begin());
			int y = *a.begin();
			a.erase(a.begin());
			sol.push_back({ x,y });
			b.insert(x - y);
		}
	}
	printf("%d\n", sol.back().first - sol.back().second);
	for (auto &x : sol)
		printf("%d %d\n", x.first, x.second);
	return 0;
}

Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    string ss = s.substr(0, n / 2);
    string sss = s.substr(n / 2);
    if (ss == sss) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


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

int num(int a, int b, int n);

int main(void)
{
    int a,b,n;
    int s,i;
    
    while (scanf("%d %d %d", &a, &b, &n) != EOF){
        s = 0;
        a %= b;
        for (i = 0; a > 0 && i < n; i++){
            a *= 10;
            s += a / b;
            a %= b;
        }
        printf("%d\n", s);
    }

    return (0);
}



Measured memory_bytes: 2048
#include <stdio.h>

int main() {
	int h, w;
	int i, j;
	while (1) {
		scanf("%d %d ", &h, &w);
		if (h == 0 && w == 0)break;
		for (i = 0; i<h; i++) {
			for (j = 0; j<w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

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

int dist[10][10];

int main(){
  int n, d;
  cin >> n >> d;
  for(int i=0; i<n; i++){
    for(int j=0; j<d; j++){
      cin >> dist[i][j];
    }
  }
  int count =0;
  for(int i=0; i<n-1; i++){
    for(int j=i+1; j<n; j++){
      int len = 0;
      for(int k=0; k<d; k++){
        len += (dist[j][k]-dist[i][k])*(dist[j][k]-dist[i][k]);
      }
      if(ceil(sqrt(len))==floor(sqrt(len))) count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
    var s string
    fmt.Scanln(&s)
    for i, c := range s {
        if (i % 2 == 0 && c == 'L') || (i % 2 == 1 && c == 'R') {
            fmt.Println("No")
            return
        }
    }
    fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

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

    string S;
    cin >> S;
    vector<bool> F(128);

    int N = S.size();
    int A = 0;
    rep(i, N - 1) A |= S[i] < S[i + 1];

    if (N == 26)
    {
        if (!A)
            cout << -1 << endl;
        else
        {
            string T = S;
            next_permutation(all(S));
            rep(i, N)
            {
                cout << S[i];
                if (S[i] != T[i])
                    break;
            }
            cout << endl;
        }
    }
    else
    {
        rep(i, N)
        {
            F[S[i]] = 1;
        }
        for (char c = 'a'; c <= 'z'; ++c)
            if (!F[c])
            {
                S += c;
                cout << S << endl;
                break;
            }
    }
}


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

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

  int x;
  cin >> x;
  cout << x * x * x << endl;
  return 0;
}



Measured memory_bytes: 3208
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            
            Array.Sort(nums);
            
            Console.WriteLine(Math.Abs(nums[nums.Count()-1]-nums[0]));
        }
    }
}

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

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

fn is_prime_number(n: u32) -> bool {
    let max = (n as f32).sqrt() as u32 + 1;

    for i in 2..max {
        if n % i == 0 {
            return false;
        }
    }
    return true;
}

fn main() {
    let n = read();

    let input_array: Vec<u32> = (0..n).map(|_| read::<u32>()).collect();

    let mut cnt = 0;
    for v in input_array {
        cnt = if is_prime_number(v) { cnt + 1 } else { cnt };
    }

    println!("{}", cnt)
}



Measured memory_bytes: 5048
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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

	char S[1300010];
	char S2[200000];
	fread(S, 1, 1300010, stdin);

	int saidai = strlen(S);
	int L = -1;
	int R = min(int(strlen(S)) - 2, 99999);
	while (L + 1 < R) {
		int H = (L + R) / 2;
		if (S[H] >= 'a' && S[H + 1] >= 'a') L = H;
		else R = H;
	}
	int N = R + 1;
	char* ci = S + N + 1;
	char ct;
	int Q = 0;
	while ((ct = *ci++) >= '0') Q = Q * 10 + ct - '0';
	char* smae = S2, * sato = S2 + Q;

	bool gyaku = 0;
	rep(i, Q) {
		if (*ci == '1') {
			ci += 2;
			gyaku = !gyaku;
		}
		else {
			ci += 2;
			bool f = *ci - '1';
			ci += 2;
			if (f ^ gyaku) *--sato = *ci;
			else *smae++ = *ci;
			ci += 2;
		}
	}

	auto kato = S2 + Q - sato;
	auto kmae = smae - S2;

	if (gyaku) {
		reverse(S, S + N);
		fwrite(sato, 1, kato, stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, kmae, stdout);
	}
	else {
		reverse(S2, S2 + Q);
		fwrite(S2 + Q - kmae, 1, kmae, stdout);
		fwrite(S, 1, N, stdout);
		fwrite(S2, 1, kato, stdout);
	}

	Would you please return 0;
}

Measured memory_bytes: 1920
def main():
    S = input()
    mae = int(S[:2])
    ushiro = int(S[2:])
    if (mae == 0 or mae > 12) and (ushiro == 0 or ushiro > 12): print('NA')
    elif (mae == 0 or mae > 12): print('YYMM')
    elif (ushiro == 0 or ushiro > 12): print('MMYY')
    else: print('AMBIGUOUS')



if __name__ == '__main__':
    main()


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

struct Lowlink {
  vector<vector<int>> &g;
  vector<int> used, ord, low;
  vector<int> articulation;
  vector<P> bridge;

  Lowlink(vector<vector<int>>& g) : g(g) {}

  int dfs(int idx, int k, int par) {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];
    bool is_articulation = false;
    int cnt = 0;
    for(auto &to : g[idx]) {
      if(!used[to]) {
        cnt++;
        k = dfs(to,k,idx);
        low[idx] = min(low[idx],low[to]);
        if(par != -1 && low[to] >= ord[idx]) is_articulation = true;
        if(ord[idx] < low[to]) bridge.push_back(P(low[idx],ord[to]));
      } else if(to != par) {
        low[idx] = min(low[idx],ord[to]);
      }
    }
    if(par == -1 && cnt > 1) is_articulation = true;
    if(is_articulation) articulation.push_back(idx);
    return k;
  }

  void build() {
    used.assign(g.size(),0);
    ord.assign(g.size(),0);
    low.assign(g.size(),0);
    int k = 0;
    rep(i,g.size()) {
      if(!used[i]) k = dfs(i,k,-1);
    }
  }
};

int main() {
  int n, m, u, v;
  cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i,m) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  Lowlink llink(g);
  llink.build();
  sort(llink.articulation.begin(),llink.articulation.end());
  for(auto x : llink.articulation) cout << x << endl;
}


Measured memory_bytes: 4552
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
ll mod = 1e9 + 7;


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

	string s, t, u;
	cin >> s >> t >> u;
	//cout << s[0] << t[t.size() - 1] << t[0] << u[u.size() - 1] << endl;
	if (s[s.size() - 1] == t[0] && t[t.size() - 1] == u[0])
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> alive(N+1);
    for(int i=0; i<=N; i++) {
        alive.at(i) = 1;
    }
    vector<int> a(M);
    for(int j=0; j<M; j++) {
        cin >> a.at(j);
        alive.at(a.at(j)) = 0;
    }
    vector<long long int> dp(N+1);
    dp.at(0) = 1;
    dp.at(1) = alive.at(1);
    for(int i=2; i<=N; i++) {
        dp.at(i) = alive.at(i) * (dp.at(i-1) + dp.at(i-2)) % 1'000'000'007;
    }
    cout << dp.at(N) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int editDistance(string x,string y){
  int n=x.length(),m=y.length();
  vector<vector<int> > dp(n+1,vector<int>(m+1,INTINF));
  for(int i=0;i<=n;i++) dp[i][0]=i;
  for(int i=0;i<=m;i++) dp[0][i]=i;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
      dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
      dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(x[i-1]!=y[j-1]));
    }
  }
  return dp[n][m];
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//

    //--------------//


    // input
    cout << fixed << setprecision(10); 
    string x,y;
    cin >> x >> y;

    cout << editDistance(x, y) << endl;
    
    return 0;
}



Measured memory_bytes: 6708
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   int P = sc.nextInt();
   
   int pieces = 3*A+P;
 
   int pie = pieces/2;
   
   System.out.println(pie);
   
   
 }
}

Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main()
{
    int N;
    long long number;
    cin >> N;

    if(N == 0){
        number = 2;
    }
    if(N == 1)
    {
        number = 1;
    }

    else if(N == 2)
    {
        number = 3;
    }

    else
    {
        long long l0 = 2, l1 = 1;

        for(int i = 3; i <= N+1; i++)
        {
            number = l1 + l0;
            l0 = l1;
            l1 = number;
        }

    }

    cout << number;

    return 0;
}


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



int main(){
    int N;
    cin >> N;
    std::vector<int> seq(N);
    for(int i=0; i < N; i++){
        cin >> seq.at(i);
    }
    int cnt = 0;
    for(int i=0; i < N; i++){
        if(seq.at(i)!=i+1){
            cnt ++;
        }
    }
    if(cnt == 0 || cnt == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;


}


Measured memory_bytes: 256
x = input()
s = list(x)
x = int(x)

if len(s) < 3:
    print(0)
else:
    xx = int(s[-2]+s[-1])
    num_item = xx//5
    if xx%5 != 0:
        num_item += 1
    
    hun = int(''.join(s[0:-2]))
    if hun < num_item:
        print(0)
    else:
        print(1)

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

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    for(auto &e : S) cin >> e;
    auto f = [&](auto &&f, int bit, int pos) -> int {
        if(pos == H - 1) {
            int res = __builtin_popcount(bit);
            int N = res + 1;
            vector<int> cnt(N);
            for(int j = 0; j < W; ++j) {
                int tmp = 0, now = 0;
                for(int i = 0; i < H; ++i) {
                    cnt[now] += S[i][j] == '1';
                    tmp += S[i][j] == '1';
                    if(tmp > K) return H + W;
                    if(bit & (1 << i)) now++, tmp = 0;
                }
                if(*max_element(cnt.begin(), cnt.end()) > K) {
                    cnt.assign(N, 0), res++, j--;
                }
            }
            return res;
        } else {
            return min(f(f, bit, pos + 1), f(f, bit | (1 << pos), pos + 1));
        }
    };
    cout << f(f, 0, 0) << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

public class Main {
	public static int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int m = parseInt(sc.next());
		ArrayList<Long> al = new ArrayList<>();
		long sum = 0;
		long a = 0;
		for(i=0;i<n;i++) {
			a = parseInt(sc.next());
			sum += a;
			al.add(a);
		}
		sc.close();
		Collections.sort(al, Comparator.reverseOrder());
		Long[] at = al.toArray(new Long[al.size()]);
		ArrayList<Long> dif = new ArrayList<>();
		for (i = 1; i <= 31; i++) {
			long tmp=0;
			long tmp2=0;
			for (j = 0; j < at.length; j++) {
				tmp2 = at[j] >> 1;
				tmp = at[j] - tmp2;
				if(tmp == 0) break;
				at[j] = tmp2;
				dif.add(tmp);
			}
			if(j==0) break;
		}
		Collections.sort(dif, Comparator.reverseOrder());
		long dsum = 0;
		for (i = 0; i < Math.min(m, dif.size()); i++) {
			dsum += dif.get(i);
		}
		out.println(sum - dsum);
	}
}


Measured memory_bytes: 157836
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の標準入力
		int n = sc.nextInt();
		List<String> wordsList = new ArrayList<String>();
		Set<String> checkHash = new HashSet<String>();
		// 整数値の数だけ文字列を標準入力
		for(int i = 0; i < n; i++) {
			wordsList.add(sc.next());
			if(i >= 1) {
				// 文字列の先頭文字と1つ前の文字列の末尾文字を比較
				if(!(wordsList.get(i).substring(0, 1).equals(wordsList.get(i - 1).substring(wordsList.get(i - 1).length() - 1)))) {
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		// 重複している文字列が存在するか
		for(String str : wordsList) {
			if(checkHash.contains(str)) {
				System.out.println("No");
				System.exit(0);
			} else {
				checkHash.add(str);
			}
		}
		System.out.println("Yes");
		sc.close();
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

int main() 
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,b;
	cin>>a>>b;
	map<int,int> m;
	while(b--)
	{
		int n;
		cin>>n;
		
		forr(i,0,n)
		{
			int x;
			cin>>x;
			m[x]++;
		}
	}
	int ct=0,l=1;
	forr(i,0,a)
	{
		if(!m.count(l))
			ct++;
		l++;
	}
	cout<<ct;
	
	return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n, avg, min, max, s;
        while (true) {
            n = sc.nextInt();

            if (n == 0) break;

            avg = 0;
            min = 1001;
            max = -1;
            for (int i=0; i<n; i++) {
                s = sc.nextInt();
                avg += s;
                min = s < min ? s : min;
                max = s > max ? s : max;
            }
            avg = (avg-min-max) / (n-2);
            System.out.println(avg);
        }
    }
}

Measured memory_bytes: 28732
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 3010
#define SZ 1010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
int A[SIZE];
long long dp[SIZE][SIZE][2];
long long func(int lft,int rgt, int whose)
{
    if(lft > rgt)
        return 0;
    if(dp[lft][rgt][whose] != LLONG_MIN)
        return dp[lft][rgt][whose];
    long long fans;
    if(whose){
        fans = LLONG_MAX;
        fans = min(fans,-1*A[lft] + func(lft+1,rgt,1-whose));
        fans = min(fans,-1*A[rgt] + func(lft,rgt-1,1-whose));
    }
    else{
        fans = LLONG_MIN;
        fans = max(fans,A[lft] + func(lft+1,rgt,1-whose));
        fans = max(fans,A[rgt] + func(lft,rgt-1,1-whose));
    }
    dp[lft][rgt][whose] = fans;
    return fans;
}
int main()
{
    /* #ifndef ONLINE_JUDGE
    freopen(fi, "r", stdin);
    #endif */
    //freopen("route.in","r",stdin);
    //freopen("route.out","w",stdout);
    //cin.ignore();
    //cin.clear();
    boost;
    //cin.tie(0);
    //cout<<"Case "<<tt<<": ";
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    for(int i=0;i<SIZE;i++){
        for(int j=0;j<SIZE;j++){
            dp[i][j][0] = LLONG_MIN;
            dp[i][j][1] = LLONG_MIN;
        }
    }
    cout<<func(1,N,0)<<endl;
    return 0;
}

Measured memory_bytes: 142080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
const ll INF = 1e16;

void solver(int N, map<ll, ll> const &dict, ll &ans){

    for(auto p: dict){
        auto value = p.second;

        if(value%2 != 0) ++ans;
    }

    return;
}

int main(){

    int N;
    cin >> N;
    map<ll, ll> dict;
    for(int i = 0; i != N; ++i){
        int tmp;
        cin >> tmp;
        ++dict[tmp];
    }

    ll ans{};
    solver(N, dict, ans);

    cout << ans << endl;

    return 0;
}

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

int main(){
	int n,m;
	int cnt=0;
	int ttl_vote=0;
	cin>>n>>m;
	vector<int>a(n);

	rep(i,n){
		cin>>a[i];
		ttl_vote+=a[i];
	}

	rep(i,n){
		if(a[i]>=(float)ttl_vote/(4*m)){
			++cnt;
		}
	}

	if(cnt>=m){
		cout<<"Yes"<<flush;
	}
	else cout<<"No"<<flush;

	// cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  int n, m, x;
  cin >> n >> m >> x;

  int a[101] = {0};

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

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

  int cost0 = 0;
  for (int i = x; i > 0; --i) {
    cost0 += a[i];
  }

  cout << min(costN, cost0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    string n;
    cin >> n;
    string ans;
    ans = n[0];
    int h = n.size();
    ans += to_string(n.size()-2);
    ans += n[n.size()-1];
    pri(ans);

    return 0;
}



Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        ll n, k;
        cin >> n >> k;
        vector<ll> h(n);
        rep(i, n) cin >> h[i];

        ll dp[n + 1000];
        fill(dp, dp + n + 1000, inf);
        dp[0] = 0;
        rep(i, n) {
            repone(j, k) {
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
            }
        }
        cout << dp[n - 1] << endl;


        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

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;
}

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];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string X;
  cin >> X;

  int N = len(X);

  int ans = N;
  int Ss = 0;
  rep(i, N) {
    if (X[i] == 'S')
      Ss++;
    else {
      if (Ss > 0) {
        ans -= 2;
        Ss--;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int hi,a=10;
    vector<int> mou;
    while(a--)
    {
        cin>>hi;
        mou.push_back(hi);
    }
    sort(mou.rbegin(),mou.rend());
    for(int i=0;i<3;i++)
        cout<<mou[i]<<endl;
    return 0;
}

Measured memory_bytes: 1216
n = int(input())

for i in range(10 ** 5):
    if 2 * n == i ** 2 - i:
        k = i
        print('Yes', k, sep='\n')
        break
    elif 2 * n < i ** 2 - i:
        print('No')
        exit()

num, ans = 1, [[] for _ in range(k)]
for i in range(k):
    for j in range(i + 1, k):
        ans[i].append(num)
        ans[j].append(num)
        num += 1
    print(k - 1, *ans[i])


Measured memory_bytes: 76500