akhauriyash/Code-Regression huggingface dataset:
#include <climits>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1<<30)-1+(1<<30);

struct SegmentTree {
private:
  int n;
  vector< pair<long long,long long> > node;//min,max
public:
  SegmentTree(int sz){
    n = 1;
    while(n < sz) n *= 2;
    node.resize(2*n-1,pair<long long,long long>(0,0));
  }
  void update(int idx, pair<long long,long long> p){
    idx += n-1;
    node[idx] = max(node[idx],p);
    while(idx > 0){
      idx = (idx-1)/2;
      node[idx] = max(node[2*idx+1],node[2*idx+2]);
    }
  }
  
  pair<long long,long long> get_max(int a, int b, int k=0, int l=0, int r=-1){
    if(r < 0) r = n;
    if(r <= a or b <= l) return {0,0};
    if(a <= l and r <= b) return node[k];
    pair<long long, long long> vl = get_max(a,b,2*k+1,l,(l+r)/2);
    pair<long long, long long> vr = get_max(a,b,2*k+2,(l+r)/2,r);
    return max(vl,vr);
  }
};

int main(){
  int M = 1e5+10;
  SegmentTree st(M);
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i){
    //cerr << i << " : " ;
    cin >> A[i];
    //cerr << A[i] << endl;
    pair<long long,long long> r = st.get_max(0,A[i]);
    //cerr << "get_max" << endl;
    ++r.first;
    r.second += A[i];
    st.update(A[i],r);
    //cerr << "update" << endl;
  }
  cout << st.get_max(0,M).second << endl;
  return 0;
}



Measured memory_bytes: 7316
#include<bits/stdc++.h>
using namespace std;
long modpow(long a,long n,long mod){
  long ans=1;
  while (n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n=n/2;
  }
  return ans; 
}
long modinv(long a,long mod){
  return modpow(a,mod-2,mod);
}
int main(){
  long x,y;cin>>x>>y;
  long a,b,ans,mod,memo;
  mod=1000000007;
  ans=1; memo=1;
  a=(2*x-y)/3; b=(2*y-x)/3;
   
  if( (x+y)%3!=0 || a<0 || b<0 ) cout<<0;
  
  else{   
    for(long i=1;i<=a+b;i++) ans=ans*i%mod;
    for(long i=1;i<=a;i++) memo=memo*i%mod;
    for(long i=1;i<=b;i++) memo=memo*i%mod;    
    memo=modinv(memo,mod);
    cout<<ans*memo%mod;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;


int main() {
    ll n;
    cin >> n;
    ll num = 1;

    for(ll i = 1; i * i <= n; i++) {
        if (n % i == 0) num = i;
    }

    cout << num + n / num - 2 << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = listOf(0) + nextIntList() + listOf(0) + listOf(0)
    val D = IntArray(N + 2)
    var total = 0
    for (i in 1..N + 1) {
        val d = Math.abs(A[i] - A[i - 1])
        D[i] = D[i] - d + Math.abs(A[i + 1] - A[i - 1])
        D[i - 1] -= d
        total += d
    }
    for (i in 1..N) {
        println(total + D[i])
    }
}

Measured memory_bytes: 56524
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define ll long long
#define int long long

using namespace std;

const int mod = 1e9+7;

int n,m;
int f[1001][1001];
char a[1001][1001];
main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin>>a[i][j];
    f[1][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(a[i][j]=='.') f[i][j]=(f[i][j]+f[i][j-1]+f[i-1][j])%mod;
    cout<<f[n][m]%mod;
}



Measured memory_bytes: 9088
#include<stdio.h>
int main(void){
	
	int H,W,i,l;
	
	while(1){
		
		scanf("%d %d",&H,&W);
		
		if(H==0&&W==0){
			break;
		}
		
		for(l=1;l<=H;l++){
			
			for(i=1;i<=W;i++){
				
				if(l==1||l==H){
					printf("#");
				}
				else if(i==1||i==W){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,ans,a[233333],b[233333];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)cin>>a[i],a[i]+=a[i-1];
	for(int i=1;i<=m;i++)cin>>b[i],b[i]+=b[i-1];
	for(int i=0;i<=n;i++){
		if(a[i]>k)break;
		while(m>0&&b[m]+a[i]>k)m--;
		ans=max(ans,i+m);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6776
#include<bits/stdc++.h>
  
using namespace std;
  
#define rep(i, n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back

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

	rep(i,n){
		string s;
		set<string> st;

		cin>>s;

		repi(i,1,s.size()){
			string a,b,c,d;
			a=s.substr(0,i);
			b=s.substr(i,s.size());

			st.insert(a+b);
			st.insert(b+a);

			reverse(a.begin(),a.end());
			st.insert(a+b);
			st.insert(b+a);

			reverse(a.begin(),a.end());
			reverse(b.begin(),b.end());
			st.insert(a+b);
			st.insert(b+a);

			reverse(a.begin(),a.end());
			st.insert(a+b);
			st.insert(b+a);

		}
		cout<<st.size()<<endl;

	}
}

Measured memory_bytes: 3224
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int h = Integer.parseInt(st.nextToken());
 		int w = Integer.parseInt(st.nextToken());
 		int k = Integer.parseInt(st.nextToken());
 		char[][] array = new char[h][w];
 		int black = 0;
 		for(int i = 0;i<h;i++){
 			String a = bf.readLine().trim();
 			for(int j = 0;j<w;j++){
 				array[i][j] = a.charAt(j);
 				if (array[i][j] == '#')
 					black++;
 			}
 		}
 		int count = 0;
 		for(int i = 0;i<(int)(Math.pow(2, h));i++){
 			for(int j = 0;j<(int)(Math.pow(2, w));j++){
 	 			String a = Integer.toBinaryString(i);
 	 			String b = Integer.toBinaryString(j);
 	 			int blackhere = 0;
 	 			for(int ks=0;ks<a.length();ks++){ 	 		
 	 				if (a.charAt(a.length()-1-ks) == '1'){
 	 					for(int ky = 0;ky<w;ky++){
 	 						if (array[h-1-ks][ky] == '#')
 	 							blackhere++;
 	 					}
 	 				}
 	 			}
 	 			for(int ks=0;ks<b.length();ks++){ 	 		
 	 				if (b.charAt(b.length()-1-ks) == '1'){
 	 					for(int ky = 0;ky<h;ky++){
 	 						if (array[ky][w-1-ks] == '#')
 	 							blackhere++;
 	 					}
 	 				}
 	 			}
 	 			
 	 			for(int ks =0;ks<a.length();ks++){
 	 				for(int ky = 0;ky<b.length();ky++){
 	 					if (a.charAt(a.length()-1-ks) == '1' && b.charAt(b.length()-1-ky) == '1' && array[h-1-ks][w-1-ky] == '#')
 	 						blackhere--;
 	 				}
 	 			}
 	 			if (black - blackhere == k){
 	 				count++;
 	 			}
 			}
 		}
 		
 		
 		out.println(count);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 29544
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag,ans,W,H;
	sum = 0;
	flag = 0;
	cin >> W >> H;
	vector<ll>P(W);
	vector<ll>Q(H);
	vector<pair<ll,char>>A(W + H);
	ll  I, J;
	I= 0;
	J = 0;
	REP(i, 0, W) {
		cin >> P[i];
		A[i].first = P[i];
		A[i].second = 'i';
	}
	REP(i, 0, H) {
		cin >> Q[i];
		A[i+W].first = Q[i];
		A[i+W].second = 'j';
	}
	sort(A.begin(), A.end());
	i = 0;
	REP(i, 0, W + H) {
		if (A[i].second == 'i') {
			sum += A[i].first*(H + 1 - J);
			I++;
		}
		else {
			sum += A[i].first*(W + 1 - I);
			J++;

		}
	}
	output(sum);
	

	return 0;
}



Measured memory_bytes: 4992
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
#include<ext/pb_ds/priority_queue.hpp>
using namespace std;

const int T = 17;
const int maxn = 1E5 + 10;
typedef pair <int,int> pr;

int n,m,fa[maxn][T],sum[maxn],Fa[maxn],du[maxn],L[maxn];
bool vis[maxn],rt[maxn];

pr p[maxn];
queue <int> Q;
vector <int> v[maxn];

#define fr first
#define sc second
#define mp(a,b) (make_pair((a),(b)))

inline int getfa(int k) {return k == Fa[k] ? k : Fa[k] = getfa(Fa[k]);}

inline int LCA(int p,int q)
{
	if (L[p] < L[q]) swap(p,q);
	for (int i = T - 1; i >= 0; i--)
		if (L[p] - (1 << i) >= L[q]) p = fa[p][i];
	if (p == q) return p;
	for (int i = T - 1; i >= 0; i--)
		if (fa[p][i] != fa[q][i]) p = fa[p][i],q = fa[q][i];
	return fa[p][0];
}

inline void Dfs(int x)
{
	vis[x] = 1;
	for (int i = 1; i < T; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
	for (int i = 0; i < v[x].size(); i++)
	{
		int to = v[x][i]; if (vis[to]) continue;
		++du[x]; L[to] = L[x] + 1; fa[to][0] = x; Dfs(to);
	}
}

int main()
{
	#ifdef DMC
		freopen("DMC.txt","r",stdin);
	#endif
	
	cin >> n >> m;
	for (int i = 1; i <= n; i++) Fa[i] = i;
	for (int i = 1; i <= m; i++)
	{
		int x,y; scanf("%d%d",&x,&y);
		int fx = getfa(x),fy = getfa(y); p[i] = mp(x,y);
		if (fx == fy) continue; Fa[fx] = fy;
		v[x].push_back(y); v[y].push_back(x);
	}
	for (int i = 1; i <= n; i++) if (!vis[i]) rt[i] = L[i] = 1,Dfs(i);
	for (int i = 1; i <= m; i++)
	{
		int lca = LCA(p[i].fr,p[i].sc);
		++sum[p[i].fr]; ++sum[p[i].sc]; sum[lca] -= 2;
	}
	for (int i = 1; i <= n; i++) if (!du[i] && !rt[i]) Q.push(i);
	while (!Q.empty())
	{
		int k = Q.front(); Q.pop(); if (rt[k]) continue;
		if (sum[k] & 1) {puts("NO"); return 0;}
		--du[fa[k][0]]; sum[fa[k][0]] += sum[k];
		if (!du[fa[k][0]]) Q.push(fa[k][0]);
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main(void){
    // Here your code !
  int n,num,i,j;
  int card[4][13]={ 0 };
  char ch;
  cin>>n;
  for( i=0;i<n;i++){
      cin>>ch>>num;
      switch(ch){
            case 'S':
            card[0][num-1]++;
            break;
            
           case 'H':
            card[1][num-1]++;
            break;
            
            case 'C':
            card[2][num-1]++;
            break;
            
            case 'D':
            card[3][num-1]++;
            break;
      }
  }

for ( i = 0; i <4; i++ ){
  for(j=0;j<13;j++){
            if(card[i][j]==0){
                switch(i){
                case 0:
                    ch='S';
                    break;
                case 1:
                    ch='H';
                    break;
                case 2:
                    ch='C';
                    break;
                case 3:
                    ch='D';
                    break;
                }
                cout<<ch<<' '<<j+1<<endl;
            }
            }
    }
 return 0;
 
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)



int main(){
	LL L; int N; cin >> L >> N;	
	vector<LL> X(N+1),SL(N+1),SR(N+2);
	SL[0] = 0;
	X[0] = 0;
	repp(i,0,N){
		cin >> X[i+1];
		SL[i+1] = SL[i] + X[i+1];
	}
	SR[N+1] = 0;
	repm(i,N,0) SR[i] = SR[i+1] + L - X[i];
	LL ans = 0;
	repp(b,0,N+1){
		LL z = SL[b] + SR[b+1];
		if(b > 0){
			if(b <= N-b){
				ans = max(ans,z+SL[b-1]+SR[b+1]-2*SR[N+1-(N-b-b)]);
			} else {
				ans = max(ans,z+SL[b-1]+SR[b+1]-2*SL[b-(N-b)-1]);
			}
		}
		if(b < N){
			if(b >= N-b){
				ans = max(ans,z+SL[b]+SR[b+2]-2*SL[b-(N-b)]);
			} else {
				ans = max(ans,z+SL[b]+SR[b+2]-2*SR[N+1-(N-b-b)+1]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

    //for
    #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
  int N;
  cin >> N;
  vector<ll>A(N);
  REP(i, N) cin >> A[i];
  vector<ll>sum(N + 1, 0);
  REP(i, N){
    sum[i + 1] += sum[i];
    sum[i + 1] += A[i];
  }
  ll ans = sum[N];
  for(int i = 1; i <= N; i++){
    ll tmp = abs((sum[N] - sum[i]) - sum[i]);
    ans = min(ans, tmp);
  }
 print(ans);
  }

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

#s[i][0] に曲名, s[i][1]に時間
s = [input().split() for i in range(N)]
X = input()
sleep_time = 0

for i in range(N):
  s[i][1] = int(s[i][1])
  if s[i][0] == X:
    I = i

for i in range(I + 1, N):
  sleep_time += s[i][1]

print(sleep_time)


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

typedef long long ll;
typedef pair < int , int > Pi;
typedef pair < ll , ll > Pl;

const int INF = (1 << 30) - 1;
const ll LLINF = 1LL << 60;

int main()
{
    int N;
    int A[105], B[105];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    for(int i = 1; i < N; i++) A[i] += A[i - 1];
    for(int i = N - 2; i >= 0; i--) B[i] += B[i + 1];
    int maxv = 0;
    for(int i = 0; i < N; i++) {
        maxv = max(maxv, A[i] + B[i]);
    }
    cout << maxv << endl;
    return (0);
}

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

int main()
{
	int a[10];
	for (int i = 0; i != 10; ++i)
		cin >> a[i];
	sort(begin(a), end(a));
	for (int i = 9; i >= 7; --i)
		cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 1172
// 2015/05/19 Tazoe

#include <iostream>
using namespace std;

bool isprime(int x)
{
	if(x==2)
		return true;

	if(x<2 || x%2==0)
		return false;

	for(int i=3; i*i<=x; i+=2){
		if(x%i==0)
			return false;
	}

	return true;
}

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

	int cnt = 0;

	for(int i=0; i<n; i++){
		int x;
		cin >> x;

		if(isprime(x)){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1164
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    map<int, int> m;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        m[a]++;
    }

    int size_n = m.size();
    int even_n = 0;
    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->second % 2 == 0) even_n++;
    }

    if (even_n % 2 == 1) {
        cout << size_n - 1 << endl;
    } else {
        cout << size_n << endl;
    }

    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define Maxn 300007
#define modp 998244353
int n,a[Maxn],b[Maxn],c[Maxn];
int tag[Maxn],g[Maxn];
char s[Maxn];
int main()
{
    scanf("%d",&n);
    scanf("%s",s+1);
    int cnt1=0,cnt2=0,cnt3=0;
    for (int i=1;i<=3*n;i++)
        if (s[i]=='R') a[++cnt1]=i;
        else if (s[i]=='G') b[++cnt2]=i;
        else c[++cnt3]=i;
    memset(tag,0,sizeof(tag));
    for (int i=1;i<=n;i++)
    {
        int tmp;
        if (a[i]<b[i]&&a[i]<c[i]) tag[a[i]]=1,g[a[i]]=1,tmp=1;
        if (b[i]<a[i]&&b[i]<c[i]) tag[b[i]]=1,g[b[i]]=2,tmp=2;
        if (c[i]<a[i]&&c[i]<b[i]) tag[c[i]]=1,g[c[i]]=3,tmp=3;
        if (a[i]>b[i]&&a[i]>c[i]) tag[a[i]]=-1,g[a[i]]=tmp;
        if (b[i]>a[i]&&b[i]>c[i]) tag[b[i]]=-1,g[b[i]]=tmp;
        if (c[i]>a[i]&&c[i]>b[i]) tag[c[i]]=-1,g[c[i]]=tmp;
        if (tag[a[i]]==0) g[a[i]]=tmp;
        if (tag[b[i]]==0) g[b[i]]=tmp;
        if (tag[c[i]]==0) g[c[i]]=tmp;
    }
    int ans=1;
    cnt1=0,cnt2=0,cnt3=0;
    int tot1=0,tot2=0,tot3=0;
    for (int i=1;i<=3*n;i++)
        if (tag[i]==1) 
        {
            if (g[i]==1) ++tot1;
            else if (g[i]==2) ++tot2;
            else ++tot3;
        }
        else if (tag[i]==-1)
        {
            if (s[i]=='R') ans=(1LL*ans*cnt1)%modp,--cnt1;
            else if (s[i]=='G') ans=(1LL*ans*cnt2)%modp,--cnt2;
            else ans=(1LL*ans*cnt3)%modp,--cnt3;
        }
        else
        {
            if (g[i]==1) ans=(1LL*ans*tot1)%modp,--tot1;
            else if (g[i]==2) ans=(1LL*ans*tot2)%modp,--tot2;
            else ans=(1LL*ans*tot3)%modp,--tot3;
            int tmp=g[i];
            if (s[i]=='R') tmp+=1;
            else if (s[i]=='G') tmp+=2;
            else tmp+=3;
            tmp=6-tmp;
            if (tmp==1) ++cnt1;
            else if (tmp==2) ++cnt2;
            else ++cnt3;
        }
    for (int i=1;i<=n;i++)
        ans=(1LL*ans*i)%modp;
    printf("%d\n",ans);
    return 0;
}

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 2e3 + 5;

int C[N][N];

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	C[0][0] = 1;
	for (int i = 1; i < N; i++) {
		C[i][0] = C[i][i] = 1;
		for (int j = 1; j < i; j++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
	}

	int n, k; cin >> n >> k;
	for (int i = 1; i <= k; i++) cout << 1LL * C[k - 1][i - 1] * C[n - k + 1][i] % MOD << endl;

	return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>

//#include <set>
//#include <unordered_map>
//#include <stack>

using namespace std;

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

#define max_n 100

string S;

int main() {

	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size() - i; i++) {
		if (S.at(i) != S.at(S.size() - i - 1))ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import math
N=int(input())

def era(n):
  prime=[]
  furui=list(range(2,n+1))
  while furui[0]<math.sqrt(n):
    prime.append(furui[0])
    furui=[i for i in furui if i%furui[0]!=0]
  return prime+furui

furui=era(10**6+7)
minfac=list(range(10**6+8))
for i in furui:
  for j in range(i,(10**6+7)//i+1):
    if minfac[i*j]==i*j:
      minfac[i*j]=i

ans=0   
for i in range(1,N):
  temp=1
  temp2=1
  l=1
  while i != 1:
    if minfac[i]!=l:
      temp*=temp2
      temp2=2
    else:
      temp2+=1
    l=minfac[i]
    i//=l
  temp*=temp2
  ans+=temp
print(ans)

Measured memory_bytes: 168484
N, A = map(int, input().split())
X = list(map(int, input().split()))
X.insert(0, 0)
dp = [[[0 for _ in range(N+1)] for _ in range(N+1)] for _ in range(sum(X)+1)]

dp[0][0][0] = 1
for i in range(sum(X) + 1):
    for j in range(1, N + 1):
        for k in range(N + 1):
            if i - X[j] >= 0 and k >= 1:
                dp[i][j][k] = dp[i][j - 1][k] + dp[i - X[j]][j - 1][k - 1]
            else:
                dp[i][j][k] = dp[i][j - 1][k]
                
res = 0

for k in range(1, N + 1):
    if A * k <= sum(X):
        res += dp[A*k][N][k]
                
print(res)

Measured memory_bytes: 113244
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;



int main()
{
    size_t N;
    std::cin >> N;

    std::unordered_map<int64_t, int64_t> A;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A[t] = A[t] + 1;
    }

    size_t count = 0;
    for (auto a: A) {
        auto k = a.first;
        auto v = a.second;

        count += (k <= v) ? (v - k) : v;
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 4260
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,tmp,ans=0;
  priority_queue<ll,vector<ll>> que;
  cin >> n >> m;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    que.push(a[i]);
  }
  for(int i=0;i<m;i++){
    tmp = que.top();
    que.pop();
    tmp/=2;
    que.push(tmp);
  }
  for(int i=0;i<n;i++){
    ans+=que.top();
    que.pop();
  }
  cout << ans << endl;
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

const int nax = 2e5 + 2;
int sizes[nax];
int id[nax];

int find(int u) {
    if(id[u] == u) return u;
    else return id[u] = find(id[u]);
}

void unify(int u, int v) {
    int a = find(u);
    int b = find(v);
    if(a != b) {
        if(sizes[a] < sizes[b]) swap(a,b);
        sizes[a] += sizes[b];
        id[b] = a;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        sizes[i] = 1;
        id[i] = i;
    }
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        unify(u, v);
    }
    int ans = -1;
    for(int i = 1; i <= n; i++) {
        ans = max(sizes[i], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5176
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	
        Scanner sc = new Scanner(System.in);
        int n, i;
        int[] x, y;
        double p1 = 0, p2 = 0, p3 = 0, max = 0;
        
        n = sc.nextInt();
        x = new int[n];
        y = new int[n];
        for(i = 0; i < n; i++) {
        	x[i] = sc.nextInt();
        }
        for(i = 0; i < n; i++) {
        	y[i] = sc.nextInt();
        }
        
        for(i = 0; i < n; i++) {
        	p1 += Math.abs(x[i] - y[i]);
        	p2 += (x[i] - y[i]) * (x[i] - y[i]);
        	p3 += Math.abs(x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]);
        	if(max < Math.abs(x[i] - y[i])) {
        		max = Math.abs(x[i] - y[i]);
        	}
        }
        
        System.out.println(p1);
        System.out.println(Math.sqrt(p2));
        System.out.println(Math.cbrt(p3));
        System.out.println(max);
        
    }
}


Measured memory_bytes: 26636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

class camel {
    public:
    ll k, add;
    camel (ll _k, ll _a) : k(_k), add(_a) {} 
};

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

    ll T;
    cin >> T;
    while (T--) {
        ll N;
        cin >> N;
        vec K(N), L(N), R(N);
        vector<camel> left, right;

        ll ans = 0;
        Rep (i, N) {
            cin >> K[i] >> L[i] >> R[i];
            if (L[i] > R[i]) {
                ans += R[i];
                left.push_back(camel(K[i], L[i]-R[i]));
            } else {
                ans += L[i];
                right.push_back(camel(N-K[i], R[i]-L[i]));
            }
        }

        auto camel_comp = [] (camel a, camel b) -> bool {
            return a.k < b.k;
        };
        
        sort(left.begin(), left.end(), camel_comp);
        sort(right.begin(), right.end(), camel_comp);

        priority_queue<ll, vec, greater<ll>> pq;
        ll tmp = 1;
        for (auto e : left) {
            pq.push(e.add);
            if (e.k < tmp) {
                pq.pop();
                tmp--;
            }
            tmp++;
        }
        while (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
        tmp = 1;
        for (auto e : right) {
            // cout << e.k << " " << e.add << "\n";
            pq.push(e.add);
            if (e.k < tmp) {
                pq.pop();
                tmp--;
            }
            tmp++;
        }
        while (pq.size()) {
            ans += pq.top();
            pq.pop();
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 12908
#include <bits/stdc++.h>
using namespace std;
int a[100002];
long long dp[100002][3];
char s[2];
int main(){
    int n;
    scanf("%d", &n);
    scanf("%d", &a[1]);

    for(int i=1;i<=n;i++) dp[i][0] = dp[i][1] = dp[i][2] = -1e14;
    dp[1][0] = a[1];

    for(int i=2;i<=n;i++){
        scanf("%s", s);
        scanf("%d", &a[i]);
        if(s[0] == '-'){
            dp[i][0] = max(dp[i-1][0] - a[i], dp[i-1][1] + a[i]);
            dp[i][1] = max(dp[i-1][0] - a[i], max(dp[i-1][1] + a[i], dp[i-1][2] - a[i]));
            dp[i][2] = max(dp[i-1][2] - a[i], dp[i-1][1] + a[i]);
        }
        else{
            dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] + a[i]);
            dp[i][1] = max(dp[i-1][1] - a[i], dp[i-1][2] + a[i]);
            dp[i][2] = dp[i-1][2] + a[i];
        }
    }   
    printf("%lld\n", max(max(dp[n][0], dp[n][1]), dp[n][2]));
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int N;
void func(string s, int size, char maxi){
  if(size == N){  cout << s << endl;  return;  }
  for(char c = 'a' ; c <= maxi + 1 ; c++)
    func(s+c, size + 1, max(maxi, c));
}
int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    cin >> N;
    func("a", 1, 'a');
   	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    cout << 3*n*n << endl;
}



Measured memory_bytes: 256
public class Main {public static void main(String[] args) {java.util.Scanner c=new java.util.Scanner(System.in);int k=c.nextInt(),s=c.nextInt();System.out.println(java.util.stream.IntStream.range(0,k+1).map(x->s-x+1-Math.min(s-x+1,Math.max(0,(s-x-k)*2))).sum());}}

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

int f(int n) {
    int t = sqrt(n);
    int count = 0;
    for (int i = 1; i <= t; i++) {
        for (int j = i; j <= t; j++) {
            for (int k = j; k <= t; k++) {
                if ((i*i+j*j+k*k+i*j+j*k+k*i) == n) {
                    if (i==j && j==k && k==i) {
                        count++;
                    }
                    else if (i!=j && j!=k && k!=i) {
                        count+=6;
                    }
                    else {
                        count+=3;
                    }
                }
            }
        }
    }rep(j,t) rep(k,t) {

    }
    return count;
}

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

    rep(i,n) {
        cout << f(i+1) << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
fun main(args: Array<String>) {
    // Your code here!
    var x = readLine()!!.toLong()
    var cnt = 0
    var num = 100L    

    while(num < x){

        num = num + (num * 0.01).toLong()
        
        if(num >= x){
            cnt += 1
            break
        }
        cnt += 1
    }
    
    println(cnt)
}


Measured memory_bytes: 34400
// Problem : D - Wizard in Maze
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀🌙｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 🚶ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int h,w;
int sx,sy;
int dsx,dsy;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
char a[1010][1010];
bool valid(int x,int y)
{
	if(x>=0 && y>=0 && x<h && y<w && a[x][y]=='.')
		return true;
	return false;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	cin>>h>>w>>sx>>sy>>dsx>>dsy;
	sx--;
	sy--;
	dsx--;
	dsy--;
	int path[h][w];
	loop(i,h)
		loop(j,w)
		{
			cin>>a[i][j];
			path[i][j]=INT_MAX;
		}
	
	deque<pi> q;
	q.pb({sx,sy});
	path[sx][sy]=0;
	while(!q.empty())
	{
		pi S=q.front();
		q.pop_front();
		int x=S.f;
		int y=S.s;
		loop(i,4)
		{
			if(valid(x+dx[i],y+dy[i]) && path[x+dx[i]][y+dy[i]]>path[x][y])
			{
				q.push_front({x+dx[i],y+dy[i]});
				path[x+dx[i]][y+dy[i]]=path[x][y];
			}
		}
	
		for(int i=x-2;i<x+3;i++)
			for(int j=y-2;j<y+3;j++)
			{
				int X=i;
				int Y=j;
				if(valid(X,Y) && path[X][Y]>path[x][y]+1)
				{
					q.pb({X,Y});
					path[X][Y]=1+path[x][y];
				}
			}
	}
	if(path[dsx][dsy]==INT_MAX)
	cout<<-1;
	else
	cout<<path[dsx][dsy];
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;

int main(){
int r;
  cin>>r;
  cout<<r*r<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

ll gcd(ll a, ll b){
	return b?gcd(b, a%b):a;
}

string func(){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	if(b>d)return "No";
	if(a<b)return "No";
	if(c>=b)return "Yes";
	ll gc = gcd(b, d);
	a -= (a-c-1)/gc*gc;
	if(a<b)return "No";
	return "Yes";
}

int main(){
	int t;
	cin >> t;
	rep(i, t){
		cout << func() << endl;
	}
	return 0;
}



Measured memory_bytes: 256
x, y = map(int, input().split())

if 0 <= x and 0 <= y:
    if x <= y:
        print(y - x)
    else:
        # b
        # a (x - y)
        # b
        print(2 + (x - y) - (y == 0))
elif x < 0 and y < 0:
    if x <= y:
        print(abs(y - x))
    else:
        print(2 + abs(x - y))
else:
    print(abs(abs(x) - abs(y)) + 1 - (y == 0))


Measured memory_bytes: 3060
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

result = []
for i in range(n):
    result.extend([i+1 for _ in range(a[i])])
for i in range(h):
    out_put = result[w*i:w*(i+1)]
    if i%2==0:
        print(" ".join(list(map(str, out_put))))
    else:
        print(" ".join(list(map(str, out_put[::-1]))))

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

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

    int ans = 0;
    int rest = K;
    if(rest > A){
        rest -= A;
        ans += A;
    }else{
        cout << rest << endl;
        return 0;
    }

    if(rest > B){
        rest -= B;
    }else{
        cout << ans << endl;
        return 0;
    }

    ans -= rest;
    printf("%d\n", ans);

    return 0;
}


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

int main(){
  int x, y;
  cin >> x >> y;
  if (x > y){
    cout << "a > b\n";
  }
  else if (x < y){
    cout << "a < b\n";
  }
  else{
    cout << "a == b\n";
  }

  return 0;
}

Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int i,j,k,l;
	int cnt;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		cnt=0;
		for(i=0;i<=9;i++){
			for(j=0;j<=9;j++){
				for(k=0;k<=9;k++){
					for(l=0;l<=9;l++){
						if(n==i+j+k+l)	cnt++;
					}
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }

    let mut max = 0;
    let mut max_i = 0;
    let mut sum = 0;
    for i in 0..n {
        sum += p[i];
        if max <= p[i] {
            max = p[i];
            max_i = i;
        }
    }
    sum -= p[max_i];
    sum += p[max_i] / 2;
    println!("{}", sum);
}

Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**7)

def main():
    N, M = map(int, input().split())
    V = [[] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        V[a - 1].append(b - 1)
    C = [0] * N
    def dfs(n):
        if C[n] == 2:
            return False
        if C[n] == 1:
            return True
        C[n] = 1
        for i in V[n]:
            if dfs(i):
                return True
        C[n] = 2
        return False
    for i in range(N):
        if dfs(i):
            return 0
    return -1
print(main())


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
template<class Z> Z rng(Z a, Z b) {
  static mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<Z>(a, b - 1)(mt);
}

struct RollingHash {
  static constexpr uint64_t P0 = 4e9 + 7;
  static constexpr uint64_t P1 = 4e9 + 9;
  static uint64_t B0;
  static uint64_t B1;
  static vector<uint64_t> powB0;
  static vector<uint64_t> powB1;
  const int n;
  vector<uint64_t> h0;
  vector<uint64_t> h1;
  template<class Itr> RollingHash(Itr first, Itr last) : n(distance(first, last)), h0(n + 1), h1(n + 1) {
    for (int i = 0; i < n; ++i, ++first) {
      h0[i + 1] = (h0[i] * B0 + *first) % P0;
      h1[i + 1] = (h1[i] * B1 + *first) % P1;
    }
    while (powB0.size() <= n) {
      powB0.push_back(powB0.back() * B0 % P0);
      powB1.push_back(powB1.back() * B1 % P1);
    }
  }
  uint64_t get0(int l, int r) { return (h0[r] + (P0 - h0[l]) * powB0[r - l]) % P0; }
  uint64_t get1(int l, int r) { return (h1[r] + (P1 - h1[l]) * powB1[r - l]) % P1; }
  bool eq(int l0, int r0, int l1, int r1) {
    return get0(l0, r0) == get0(l1, r1) and get1(l0, r0) == get1(l1, r1);
  }
  template<class Itr> static uint64_t get0(Itr first, Itr last) {
    uint64_t res = 0;
    while (first != last) {
      res = (res * B0 + *first++) % P0;
    }
    return res;
  }
  template<class Itr> static uint64_t get1(Itr first, Itr last) {
    uint64_t res = 0;
    while (first != last) {
      res = (res * B1 + *first++) % P1;
    }
    return res;
  }
};
uint64_t RollingHash::B0 = rng<unsigned>(1, RollingHash::P0);
uint64_t RollingHash::B1 = rng<unsigned>(1, RollingHash::P1);
vector<uint64_t> RollingHash::powB0{1};
vector<uint64_t> RollingHash::powB1{1};


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    RollingHash RHS(S.begin(), S.end());
    set<l_l> st;
    int l = 0;
    int r = 1;
    while(M--) {
        string q;
        cin >> q;
        if(q == "R++") r++;
        if(q == "R--") r--;
        if(q == "L++") l++;
        if(q == "L--") l--;
        ll one = RHS.get0(l, r);
        ll two = RHS.get1(l, r);
        st.insert({one, two});
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 31116
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    _ <- B.getLine
    as <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    let b1 = length [x | x <- as, odd x]
        b4 = length [x | x <- as, x `mod` 4 == 0]
        b2 = length as - b1 - b4
    putStrLn $ if b2 == 0
                then if b1 <= b4 + 1 then "Yes" else "No"
                else if b1 <= b4     then "Yes" else "No"


Measured memory_bytes: 15484
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a[10];
	cin >> a[0];
	if(a[0]=='a'||a[0]=='i'||a[0]=='u'||a[0]=='e'||a[0]=='o'){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//18:08~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	int A,B;cin>>A>>B;
	cout<<(B+A-3)/(A-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <set>
#include <map>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int s;
    cin >> s;
//    vector<int> vec(N);
//    REP(i, N) cin >> vec[i];
    
    // calculation
    if (s == 1 || s == 2 || s == 4) {
        cout << 4 << "\n";
        return 0;
    }
    
    int n = 2;
    while (true) {
        // code
        if (s%2 == 0) {
            s /= 2;
        } else {
            s = 3*s + 1;
        }
        
        if (s == 4) {
            cout << n + 3 << "\n";
            return 0;
        }
        n++;
    }
    
    return 0;
}


Measured memory_bytes: 256
def toPuzzle(str)
  a,b,c,d,e,f,g,h=str.split("")
  return [[a,b,c,d],[e,f,g,h]]
end
  goal = "01234567"
  hash = Hash.new(nil)
  hash[goal]=0
  q = Array.new
  q << goal
  loop do
    str = q.shift
    if str.nil?
      break
    end
    tmp =  str.split("").index("0")
    x = tmp%4
    y = tmp<4 ? 0 : 1
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    0.upto(3) do |i|
      nx = x + dx[i]
      ny = y + dy[i]
      if nx>=0 && nx < 4 && ny>=0 && ny<2
        tmp = toPuzzle(str)
        tmp[ny][nx],tmp[y][x] = tmp[y][x],tmp[ny][nx]
        nstr = tmp.flatten.join
        next if hash[nstr]
        hash[nstr]=hash[str]+1
        q<<nstr
      end
    end
  end
  while gets
  puts hash[$_.chomp.split.join]
  end

Measured memory_bytes: 13748
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  long long int H;
  cin >> H;
  
  long long int dmax = 0;
  long long int p = 1;
  while ((H/p) > 0) {
    dmax++;
    p = p * 2;
  }
  
  cout << p - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 256