akhauriyash/Code-Regression huggingface dataset:
/*  -*- coding: utf-8 -*-
 *
 * 3100.cc: Strange Plants
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x, a, b, n;
  scanf("%d%d%d%d", &x, &a, &b, &n);

  for (int i = 0; i < n; i++) {
    char s[16];
    scanf("%s", s);

    if (s[0] == 'n') x = max(0, x + a);
    else if (s[0] == 't') x = max(0, x + b);
    else x = 0;
  }

  printf("%d\n", x);
  return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 500030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;


int main()
{
	ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	double l;
	cin>>l;
	double x=0.0000;
	double a=0,b=0,c=0;
	a=b=c=(double)(l/(3.00));
   if(l-=(a+b+c));
   if(l)
   {
   	 x=(double)(l/(3.000));
   }
   //cout<<x<<endl;
   double A=a+x;
   b+=x;
   c+=x;
double ans=double(a*b*c);
cout<<fixed<<setprecision(12)<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
// #include <bits/stdc++.h>
#define ll long long
#define INF 1LL << 60
using namespace std;

int N;
ll x;
int a[2010];
int b[2010];

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

  ll ans = INF;

  for (int k = 0; k < N; ++k)
  {
    ll tmp = k * x;
    for (int i = 0; i < N; ++i)
    {
      b[i] = min(b[i], a[(i - k + N) % N]);
      tmp += b[i];
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

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

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a,b;
	cin>>a>>b;
	if(a>=13)cout<<b;
	else if(a<13&&a>=6)cout<<b/2;
	else cout<<0;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3576
import java.util.*;
import javax.lang.model.util.ElementScanner6;

public class Main {

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

        // 入力
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        // 処理
        String out = "APPROVED";
        for (int i = 0; i < n; i++) {
            if (a[i] % 2 == 0) {
                if (!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
                    out = "DENIED";
                    break;
                }
            }
        }

        // 出力
        System.out.println(out);
    }

}

Measured memory_bytes: 23764
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
//max_element

int X, N;
int P[101];

signed main()
{
	cin >> X >> N;
	REP(i, N) cin >> P[i];

	int ans = 0;
	int min_diff = INT_MAX;

	for (int i = 0; i <= 101; i++)
	{
		int mi = 0;
		bool v = true;
		for (int j = 0; j < N; j++)
		{
			if (P[j] == i)
			{
				v = false;
			}
		}
		if (v)
		{
			int diff = abs(X - i);
			if (min_diff > diff)
			{
				min_diff = diff;
				ans = i;
			}
		}
	}

	cout << ans << endl;
}



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

using namespace std;

#define endl '\n'

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

struct disjoint_sets{
	
	vector<ll> sum;
	vector<int> pi, sz, bad;
	
	disjoint_sets(int n, vector<ll> vals) : sum(n), pi(n), sz(n), bad(n){
		for(int i = 0; i < n; i++){
			pi[i] = i;
			sz[i] = 1;
			sum[i] = vals[i];
		}
	}
	
	int root(int x){
		return x == pi[x] ? x : root(pi[x]);
	}
	
	bool merge(int a, int b){
		a = root(a);
		b = root(b);
		
		if(a == b)
			return false;
		
		if(sz[a] > sz[b])
			swap(a, b);
		
		bad[b] += bad[a];
		sum[b] += sum[a];
		sz[b] += sz[a];
		pi[a] = b;
		return true;
	}
	
};

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	vector<ll> x(n);
	
	for(int i = 0; i < n; i++)
		cin >> x[i];
	
	disjoint_sets ds(n, x);

	vector<pair<ll, pii>> edges(m);
	for(int i = 0; i < m; i++){
		int a, b;
		ll c;
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = {c, {a, b}};
	}
	
	sort(edges.begin(), edges.end());
	
	for(auto &e : edges){
		int a = e.second.first;
		int b = e.second.second;
		ll w = e.first;
		
		if(ds.merge(a, b)){
			int r = ds.root(a);
			
			if(ds.sum[r] >= w)
				ds.bad[r] = 0;
			else
				ds.bad[r]++;
		}
		else{
			int r = ds.root(a);
			if(ds.sum[r] < w)
				ds.bad[r]++;
		}
	}
	
	int ans = 0;
	set<int> R;
	for(int i = 0; i < n; i++)
		R.insert(ds.root(i));
	
	for(auto &r : R)
		ans += ds.bad[r];
	
	cout << ans << endl;

	return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb push_back
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD= 1e9+7 ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}

bool compare(string a, string b){
	if(a.length()==b.length())
		return a<b;
	return a.length()<b.length();
}

int main()
{
    fast;
    int t;
    t = 1;
    //~ cin>>t;
    
    while(t--){
		ll n;
		cin>>n;
		ll sum = (n*(n+1))/2;
		
		ll threes = n/3;
		threes = 3*((threes*(threes+1))/2);
		ll fives = n/5;
		fives = 5*((fives*(fives+1))/2);
		ll gcd = n/15;
		gcd = 15*((gcd * (gcd+1))/2);
		//~ error(sum, threes, fives, gcd);
		ll ans = sum - threes - fives +gcd;
		cout<<ans;
	}
    
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

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

  set<i64> st[30];

  auto num = [](i64 c) { return (i64)(c) - 'a'; };

  i64 n = s.size();
  i64 m = t.size();
  vector<i64> A(n), B(m);
  rep(i,0,n) A[i] = num(s[i]);
  rep(i,0,m) B[i] = num(t[i]);

  rep(i,0,n) {
    st[A[i]].insert(i);
    st[A[i]].insert(i + n);
  }

  i64 ans = 0;
  i64 now = 0;

  rep(i,0,m) {
    i64 b = B[i];
    auto iter = st[b].lower_bound(now);
    if(iter == st[b].end()) {
      cout << -1 << endl;
      return 0;
    }
    now = *iter + 1;
    while(now >= n) {
      now -= n;
      ans += n;
    }
  }

  cout << ans + now << endl;
}


Measured memory_bytes: 11392
from sys import stdin
from itertools import accumulate


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    A1 = [A[0]]
    for i in range(1, N):
        A1.append(A1[-1] ^ A[i])
    A2 = list(accumulate(A))
    l = 0
    r = 1
    tmp1 = A1[0]
    tmp2 = A2[0]
    count = 0
    while True:
        if (l == N - 1) and (r == N):
            count += 1
            break

        if (r != N) and (tmp1 ^ A[r + 1 - 1] == tmp2 + A[r + 1 - 1]):
            if tmp1 == tmp2:
                count += 1
            r += 1
            tmp1 = tmp1 ^ A[r - 1]
            tmp2 = tmp2 + A[r - 1]
            continue
        else:
            if tmp1 == tmp2:
                count += (r - l - 1)
            tmp1 = tmp1 ^ A[l]
            tmp2 = tmp2 - A[l]
            l += 1

    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28648
function main()
  
  check = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
  
  K = parse(Int,readline())
  
  println(check[K])
  
end

main()

Measured memory_bytes: 161960
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i, v in enumerate(a):
    x -= v
    if x < 0:
        ans = i
        break
    if x == 0:
        ans = i+1
        break
    if i == n-1:
        ans = i+1
if x > 0:
    ans -= 1
print(ans)

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

using namespace std;


int main(){
	int n;
	double x1,x2,x3,y1,y2,y3,ox,oy,r;
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		ox=((y2-y1)*((y3*y3-y1*y1)+(x3*x3-x1*x1))-(y3-y1)*((y2*y2-y1*y1)+(x2*x2-x1*x1)))/
				(2*((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1)));
		if(y2 != y1){
			oy=(2*(x1-x2)*ox+(y2*y2-y1*y1)+(x2*x2-x1*x1))/(2*(y2-y1));
		}else{
			oy=(2*(x1-x3)*ox+(y3*y3-y1*y1)+(x3*x3-x1*x1))/(2*(y3-y1));
		}

		r = sqrt((ox-x1)*(ox-x1)+(oy-y1)*(oy-y1));
		printf("%.3lf %.3lf %.3lf\n",ox,oy,r);
	}
    return 0;
}

Measured memory_bytes: 2636
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> a(n),b(n,0),c(n,0);
    REP(i,n) cin >> a[i];
    REPP(i,n-1) REP(j,i) {
        b[i] += (a[j]>a[i]);
    }
    REP(i,n) REP(j,n) {
        c[i] += (a[j]>a[i]);
    }
    ll ans = 0;
    REP(i,n) {
        ans += k * b[i]+k*(k-1)/2%MOD*c[i]%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin

N,*datas = [int(i) for i in stdin.readlines()]
now_max = max(datas[1:])
max_index = datas.index(now_max)
diff = now_max - datas[0]

for i in range(1,N-1):
    if i == max_index:
        now_max = max(datas[i+1:])
        max_index = datas.index(now_max,i+1)
    new_diff = now_max - datas[i]
    if diff < new_diff:
        diff = new_diff

print(diff)


Measured memory_bytes: 27836
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int N;
int h[100];

int watering(int l, int r, int x){
    if(l > r){
        return 0;
    }
    int mi = INT32_MAX, mi_index = -1;
    for(int i = l; i <= r; i++){
        if(h[i] < mi){
            mi = h[i];
            mi_index = i;
        }
    }
    int res = mi - x;
    res += watering(l, mi_index-1, mi);
    res += watering(mi_index+1, r, mi);
    return res;
}


int main(int argc, char *argv[]){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    cout << watering(0, N-1, 0) << endl;


    return 0;

}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
min = 100000000
for i in range(n):
	tmp = t-h[i]*0.006
	if abs(a-tmp) < min:
		min = abs(a-tmp)
		idx = i
print(idx+1)

Measured memory_bytes: 38416
p = 10 ** 9 + 7
def main():
    s = input()[::-1]
    mod = 13
    dp = [[0] * 13 for _ in range(len(s) + 1)]
    dp[0][0] = 1

    for i in range(len(s)):
        if s[i] == "?":
            for j in range(10):
                d = j * pow(10, i, mod)
                for k in range(13):
                    dp[i + 1][(k + d) % mod] += dp[i][k]
                    dp[i + 1][(k + d) % mod] %= p
        else:
            d = int(s[i]) * pow(10, i, mod)
            for k in range(13):
                dp[i + 1][(k + d) % mod] += dp[i][k]
    print(dp[-1][5])
if __name__ == '__main__':
    main()

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

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

    vector<int> ans(n, 0);

    for (int i = 0; i < n - 1; ++i) {
        ans[a[i] - 1] += 1;
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int solve() {
  int H, W;
  cin >> H >> W;
  vector<string> G(H);
  rep(i, 0, H) cin >> G[i];
  using P = pair<int, int>;
  queue<P> Q;
  vector<vector<int>> used(H,vector<int>(W));
  rep(i, 0, H) rep(j, 0, W) {
    if(G[i][j] == '#') {
      Q.push(P(i, j));
      used[i][j] = 1;
    }
  }
  int ans = 0;
  while(!Q.empty()) {
    P cur = Q.front(); Q.pop();
    int y = cur.first, x = cur.second;
    ans = used[y][x] - 1;
    rep(i, 0, 4) {
      int ny = y + dy[i], nx = x + dx[i];
      if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
      if(used[ny][nx]) continue;
      if(G[ny][nx] == '.') {
        Q.push(P(ny, nx));
        used[ny][nx] = used[y][x] + 1;
      }
    }
  }
  return ans;
}

int main() {
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 13456
#include<bits/stdc++.h>
#include<cmath>
#define PB push_back
#define REP(i,a,b) for(int i=a; i<b; i++)
typedef long long ll;
using namespace std;
int main(){
	const ll con=1000000007;
	ios::sync_with_stdio(false);
	cin.tie(0);
	int tt;
	cin>>tt;
	if(tt>=30) cout<<"Yes";
	else cout<<"No";
	
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

const double pi = 3.141592653589793;
// -------------------------------------------------------
int X, N;
int p[200];
set<int> ps;

int main() {
  //
  cin >> X >> N;
  rep(i, 0, N) {
    cin >> p[i];
    ps.insert(p[i]);
  }

  rep(i, 0, 1000) {
    int num1 = X - i;
    if (ps.count(num1) != 1) {
      cout << num1 << endl;
      return 0;
    }
    int num2 = X + i;
    if (ps.count(num2) != 1) {
      cout << num2 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int sx = scanner.nextInt();
        int sy = scanner.nextInt();
        int tx = scanner.nextInt();
        int ty = scanner.nextInt();
        StringBuilder sb = new StringBuilder();
        appendRoute(sb, ty - sy, "U");
        appendRoute(sb, tx - sx, "R");
        appendRoute(sb, ty - sy, "D");
        appendRoute(sb, tx - sx, "L");
        sb.append("L");
        appendRoute(sb, ty - sy + 1, "U");
        appendRoute(sb, tx - sx + 1, "R");
        sb.append("D");
        sb.append("R");
        appendRoute(sb, ty - sy + 1, "D");
        appendRoute(sb, tx - sx + 1, "L");
        sb.append("U");
        System.out.println(sb.toString());
    }
    private static void appendRoute(StringBuilder sb, int num, String r) {
        for (int i = 0; i < num; i++) {
            sb.append(r);
        }
    }

}

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

using namespace std;
using ll = long long;

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main() {
    ll n;
    cin >> n;
    map<string, ll> s;
    for(int i = 0; i < n; i++) {
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        s[tmp]++;
    }
    ll ans = 0;
    for (auto _s : s) if (_s.second > 1) ans += nCr(_s.second, 2) ;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> P;
constexpr ll mod = 1000000007;
int main() {
	int a, b;
	cin >> a >> b;
	if (a != b)
		cout << max(a, b) * 2 - 1;
	else
		cout << a * 2;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;
const ll MOD = 998244353;


ll dp[3005][9005] = {};
int main(){
	ios_base::sync_with_stdio(false);
	ll N, S, ans=0;
	ll A[3005];

	cin >> N >> S;
	rep(i,N) cin >> A[i];

	rep(i,N){
		dp[i+1][A[i]] += i+1;
		rep(j,3005) dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD;
		rep(j,3005) dp[i+1][j+A[i]] = (dp[i+1][j+A[i]] + dp[i][j]) % MOD;
		if(S > A[i]) ans = (ans + dp[i][S-A[i]] * (N-i)) % MOD;
		if(S == A[i]) ans = (ans + (ll)(i+1) * (ll)(N-i)) % MOD;
	}

	// rep(k,3){
		// rep(i,N+1) cout << dp[i][S] << " "; cout << endl;
	// }
	//
	// rep(i,N) ans += dp[i+1][S][2];

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main() {
  int n, a[111], x;
  cin >> n >> x;
  int s = 0, ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s <= x) ++ans;
    cin >> a[i];
    s += a[i];
  }
  if (s <= x) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<map>
#include<vector>
#include<algorithm>
#include <stdio.h>
#include<set>
#include<string>
#include<math.h>
#include<cmath>
#include<iomanip>
#include<queue>
#include<stack>
#define ll long long
using namespace std;
long double pi = 3.14159265358979323846;
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);



int main()
{
	long double a, b, c; cin >> a >> b >> c;
	if (a + b + 2 * sqrt(a) * sqrt(b) < c)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mo 998244353
#define N 200005
using namespace std;
char s[N];
int f[N][3][3];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	if (n==2){
		printf("%d\n",1+(s[1]!=s[2]));
		return 0;
	}
	if (n==3){
		if (s[1]==s[2]&&s[2]==s[3]) puts("1");//3
		else if (s[1]==s[2]||s[2]==s[3]) puts("6");//12
		else if (s[1]==s[3]) puts("7");//6
		else puts("3");//6
		return 0;
	}
	int fl=1;
	for (int i=1;i<n;i++)
		if (s[i]!=s[i+1]) fl=0;
	if (fl){
		puts("1");
		return 0;
	}
	int ans=power(3,n-1);
	int v=0;
	for (int i=1;i<=n;i++)
		v=(v+s[i]-'a')%3;
	for (int i=0;i<3;i++)
		f[1][i][i]=1;
	for (int i=2;i<=n;i++)
		for (int j=0;j<3;j++)
			for (int k=0;k<3;k++)
				for (int l=0;l<3;l++)
					if (k!=l)
						f[i][(j+l)%3][l]=(f[i][(j+l)%3][l]+f[i-1][j][k])%mo;
	for (int i=0;i<3;i++)
		ans=(ans+mo-f[n][v][i])%mo;
	fl=1;
	for (int i=1;i<n;i++)
		if (s[i]==s[i+1]) fl=0;
	printf("%d\n",(ans+fl)%mo);
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
typedef long long ll;
using namespace std;

const int MAXN = 1e5+5;
const int MOD = 1e9+7;

int main()
{
    int n, cnt = 1, num, mini;
    scanf("%d", &n);
    scanf("%d", &num);
    mini = num;
    while (--n)
    {
        scanf("%d", &num);
        if (num <= mini)
        {
            cnt++;
            mini = num;
        }
    }
    printf("%d\n", cnt);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
// const int MOD = 1e9 + 7;

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    vector<int> ans;
    for (int i = A; i <= B && i < A + K; i++) {
        ans.push_back(i);
    }
    for (int i = B; i >= A + K && i > B - K; i--) {
        ans.push_back(i);
    }
    sort(ALL(ans));
    for (auto i : ans) {
        cout << i << "\n";
    }
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0: break
    sa = sb = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            sa += a
            sb += b
        elif a > b: sa += a+b
        else:       sb += a+b
    print(sa, sb)


Measured memory_bytes: 5612
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        new Main().solve(System.in, System.out);
    }

    public void solve(InputStream in, PrintStream out) {
        Scanner sc = new Scanner(in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int r = sc.nextInt();
        int s = sc.nextInt();
        int p = sc.nextInt();
        int[] point = {r, s, p};
        char[] t = sc.next().toCharArray();
        char[] h = "spr".toCharArray();

        long res = 0;
        for(int i=0; i<k; i++) {
            int[] prev = {0, 0, 0};
            for(int j=0; i+j*k<n; j++) {
                int pos = i+j*k;
                int[] next = new int[3];
                for(int l=0; l<3; l++) {
                    for (int q = 0; q < 3; q++) {
                        if (l == q) continue;
                        if (t[pos] == h[q]) {
                            next[q] = Math.max(next[q], prev[l] + point[q]);
                        } else {
                            next[q] = Math.max(next[q], prev[l]);
                        }
                    }
                }
                prev = next;
            }
            Arrays.sort(prev);
            res += prev[2];
        }
        out.println(res);
    }
}


Measured memory_bytes: 31056
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int N;
int size[2];
string num[3];

int main() {
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> num[0];
		cin >> num[1];

		size[0] = num[0].size();
		size[1] = num[1].size();
		if (size[0] > 80 || size[1] > 80) cout << "overflow" << endl;
		else {
			int sum = 0;
			bool kuriage = false;
			bool overflow = false;
			num[2] = "";
			for (int j = 0; j < 81; j++) {
				if (j == 80 && kuriage) {
					overflow = true;
					break;
				}
				if (j >= size[0] && j >= size[1] && !kuriage) break;
				
				if (kuriage) sum = 1;
				else sum = 0;
				
				if (j < size[0]) {
					sum += num[0][size[0] - j - 1] - '0';
				}
				if (j < size[1]) {
					sum += num[1][size[1] - j - 1] - '0';
				}
				
				if (sum >= 10) {
					sum -= 10;
					kuriage = true;
				} else kuriage = false;

				num[2] = (char)('0' + sum) + num[2];
			}
			if (overflow) cout << "overflow" << endl;
			else cout << num[2] << endl;
		}
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1216
N, Y = map(int, input().split())

for i in range(N + 1):
	y10 = N - i
	for j in range(i + 1):
		y5 = i - j
		y1 = j
		if Y == sum([y10 * 10000, y5 * 5000, y1 * 1000]):
			print(y10, y5, y1)
			exit()
else:
	print(-1, -1, -1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
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; }

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
typedef long long ll;
const int mod = 1e9 + 7;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> connect(m);
  vector<int> p(m);
  for (int i = 0; i < m; i++)
  {
    int k; cin >> k;
    connect[i].resize(k);
    for (int j = 0; j < k; j++)
    {
      cin >> connect[i][j];
      connect[i][j]--;
    }
  }

  for (int  i = 0; i < m; i++) cin >> p[i];
  
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) //2^n通り試す
  {
    bool ok = true; //光る？
    for(int j = 0; j < m; j++)
    {
      int count = 0;
      for(int id: connect[j]){
        if((i >> id) & 1) count++; //繋がっているものの中でonの個数
      }
      count %= 2;
      if(count != p[j]) ok = false;
    }
    if(ok == 1) ans++; 
  }
  
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    int N;
    cin >> N;
 
    int a, b, c;
    a = N / 100; N %= 100;
    b = N / 10;
    c = N % 10;

    if (N % 100 == 0){
        for (int i = 0; i < 3; i++){
            cout << a;
        }
    cout << "\n";
    return 0;
    }
 
    if (((a >= b) && (a >= c)) || (a >= b) && (b >= c)){
        for (int i = 0; i < 3; i++){
            cout << a;
        }
    }else{
        for (int i = 0; i < 3; i++){
            cout << a + 1;
        }
    }
    cout << "\n";
}

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

int main(){
	string a,b;
	vector<pair<int,int> > time;
	int n,h,m,s,ret;
	int t1,t2;
	int tt[3600*24+1];//??
	
	while(cin >> n && n){
		time.clear();
		ret = 0;
		for(int i=0;i<3600*24;i++)tt[i]=0;
		for(int i=0;i<n;i++){
			cin >> a >> b;
			sscanf(a.c_str(),"%d:%d:%d",&h,&m,&s);
			t1 = h*3600+m*60+s;
			sscanf(b.c_str(),"%d:%d:%d",&h,&m,&s);
			t2 = h*3600+m*60+s;
			for(int k=t1;k<t2;k++){
				tt[k]++;
				ret = max(ret,tt[k]);
			}
		}
		cout << ret << endl;
			
	}
}
	

Measured memory_bytes: 1304
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAX = 10000000;

int sol(int x)
{
	int sum = 0, kai;

	for(int i = 1; i <= x; i++)
	{
		sum += i;

		if (sum >= x)
		{
			kai = i;
			return kai;
		}
	}

	return 0;
}

int main()
{
	int n,num,i,fin,a[MAX/2] = {0};

	cin >> n;

	num = n;
	i = 0;

	while(1)
	{
		a[i] = sol(num);

		num -= a[i];
		if (num == 0)
		{
			fin = i;
			break;
		}
		i++;
	}

	

	for(int j = fin; j >= 0 ; j--)
	{
		cout << a[j] <<endl;
	}


	return 0;
}

Measured memory_bytes: 19840
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, M = sc.nextInt()
    val A = Array.fill(M)(sc.nextInt())
    val MatchOf = Array(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)

    // i本のマッチ棒を使って作れる整数の中で最大のもの
    // 整数の中で最大のものは, 大きい数順に並べることになる
    // 明らかに, 既に付いている先頭の文字列よりも小さいものが来た場合
    // 最大になることはないので捨てる
    val dp = Array.fill(N+1)("")

    var i = 0
    while (i < M) {
      val matches = MatchOf(A(i))
      if (matches <= N) {
        dp(matches) = "" + A(i)
      }
      i += 1
    }

    def insert(str: String, value: Int): String = {
      var idx = str.indexOf(value)
      if (idx != -1) {
        str.substring(0, idx) + value + str.substring(idx)
      } else if (value >= str.head.toString.toInt) value + str
      else str + value
    }

    i = 1
    while (i <= N) {
      if (dp(i).nonEmpty) {
        var j = 0
        while (j < M) {
          val matches = MatchOf(A(j))
          if (i + matches <= N) {
            val newValue = insert(dp(i), A(j))
            if (dp(i + matches).nonEmpty) {
              if (newValue.length == dp(i + matches).length) {
                if (newValue > dp(i + matches))
                  dp(i + matches) = newValue
              } else if (newValue.length > dp(i + matches).length) {
                dp(i + matches) = newValue
              }
            } else {
              dp(i + matches) = newValue
            }
          }
          j += 1
        }
      }
      i += 1
    }

    println(dp(N))
  }

}

Measured memory_bytes: 171280
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 1e5+5;
int q;
char S[N],T[N];
int s[N]={},t[N]={};

int main() {	
	scanf("%s%s%d",S,T,&q);
	int ls = strlen(S), lt = strlen(T);
	for(int i = 1; i <= ls; ++i) s[i] = s[i-1] + ((S[i-1]=='A')?1:2);
	for(int i = 1; i <= lt; ++i) t[i] = t[i-1] + ((T[i-1]=='A')?1:2);
	while(q--) {
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if((s[b]-s[a-1]-t[d]+t[c-1]) % 3) printf("NO\n");
		else printf("YES\n");
	}
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	int sum=0;
	scanf("%d%d%d",&a,&b,&c);
	int max=a;
	if(b>max) max=b;
	if(c>max) max=c;
	sum=a+b+c+9*max;
	printf("%d",sum);
	return 0;
}

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

int main(){
   int A, B, M;
   std::cin >> A >> B >> M;
   std::vector<int> a(A);
   std::vector<int> b(B);
   std::vector<std::pair<std::pair<int, int>, int>> t(M);
   for (int i=0; i<A; i++){
      std::cin >> a.at(i);
   }
   for (int j=0; j<B; j++){
      std::cin >> b.at(j);
   }
   for (int k=0; k<M; k++){
      int x, y, c;
      std::cin >> x >> y >> c;
      std::pair<int, int> p = {x, y};
      std::pair<std::pair<int, int>, int> pp = {p, c};
      t.at(k) = pp;
   }
   auto min_iter_a = std::min_element(a.begin(), a.end());
   auto min_index_a = std::distance(a.begin(), min_iter_a);
   auto min_iter_b = std::min_element(b.begin(), b.end());
   auto min_index_b = std::distance(b.begin(), min_iter_b);
   int min = a.at(min_index_a) + b.at(min_index_b);
   std::cerr << min << std::endl;

   for (auto x : t){
      int tmp = a.at(x.first.first-1) + b.at(x.first.second-1) - x.second;
      min = std::min(tmp, min);
   }
   std::cout << min << std::endl;
}


Measured memory_bytes: 5112
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

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

#define EPS 1e-9

using namespace std;

int main(){

unsigned int a,b;
while(true){
cin >> a >> b;
if(cin.fail()) break;

int c=1;
double s=a+b;
while(1){
s/=10;
if(s<1) break;
c++;
}

cout << c << endl;

}

return 0;
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		java.util.Scanner sin = new java.util.Scanner(System.in);
		int S = sin.nextInt();
		int a,b,c,h,m,s;
		if(0 <= S && S < 86400){
			h = S / 3600;
			a = S % 3600;
			m = a / 60;
			s = a % 60;
			System.out.println(h + ":" + m + ":" + s);
		}
	}
}


Measured memory_bytes: 26364
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

const int Maxn = 100;

int N, M;
vector<int> G[Maxn + 5][Maxn + 5];
int match[Maxn + 5];
bool vis[Maxn + 5], A[Maxn + 5][Maxn + 5];
int mat[Maxn + 5][Maxn + 5];

bool DFS(int u) {
	for(int v = 1; v <= N; v++)
		if(A[u][v] && !vis[v]) {
			vis[v] = true;
			if(!match[v] || DFS(match[v])) {
				match[v] = u;
				return true;
			}
		}
	return false;
}

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &M);
	for(int i = 1; i <= N; i++)
		for(int j = 1; j <= M; j++) {
			int x;
			scanf("%d", &x);
			G[i][(x - 1) / M + 1].push_back(x);
		}
	for(int i = 1; i <= M; i++) {
		for(int j = 1; j <= N; j++)
			for(int k = 1; k <= N; k++)
				A[j][k] = !(G[j][k].empty());
		memset(match, 0, sizeof match);
		for(int j = 1; j <= N; j++) {
			memset(vis, false, sizeof vis);
			DFS(j);
		}
		for(int j = 1; j <= N; j++) {
			int k = match[j];
			mat[k][i] = G[k][j].back();
			G[k][j].pop_back();
		}
	}
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= M; j++)
			printf("%d ", mat[i][j]);
		puts("");
	}
	for(int i = 1; i <= M; i++)
		for(int j = 1; j <= N; j++)
			for(int k = j + 1; k <= N; k++)
				if(mat[j][i] > mat[k][i])
					swap(mat[j][i], mat[k][i]);
	for(int i = 1; i <= N; i++) {
		for(int j = 1; j <= M; j++)
			printf("%d ", mat[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
            if(0 < i) w[i] += w[i-1];
        }
        int tmp = Integer.MAX_VALUE;
        for (int i = 0; i < n-1; i++) {
            if(Math.abs(w[n-1] - w[i] *2) < tmp) tmp = Math.abs(w[n-1] - w[i] *2);
        }
        System.out.println(tmp);
        sc.close();

    }

}


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

struct node{
    node *left;
    node *right;
    int cost;
    node() : left(nullptr),right(nullptr),cost(-1){};
};

void treebuild(string &s,node* r,int x,int y){
    if(y<=x+1)return ;
    int cnt =0;
    int tmp=0;
    for(int i=x;i<=y;i++){
        if(s[i]=='('){
            cnt++;
        }else if(s[i]==')'){
            cnt--;
        }
        if(cnt==0){
            tmp = i;
            break;
        }
    }
    int num = 0;
    int tmp2;
    for(int i = tmp+2;i<=y;i++){
        if(s[i]>='0'&&s[i]<='9'){
            num *= 10;
            num += s[i]-'0';
        }else{
            tmp2 = i+1;
            break;
        }
    }
    r->cost = num;
    if(x+1<=tmp-1){
        node* ss = new node();
        r->left = ss;
        treebuild(s,ss,x+1,tmp-1);
    
    }
    if(tmp2+1<=y-1){
        node* tt = new node();
        r->right = tt;
        treebuild(s,tt,tmp2+1,y-1);
    }
    return ;
}

void treecreate(node* ra,node* rb,node* rc){
    rc->cost = ra->cost+rb->cost;
    if(ra->left!=nullptr&&rb->left!=nullptr){
        node *ss = new node();
        rc->left= ss;
        treecreate(ra->left,rb->left,rc->left);
    }
    if(ra->right!=nullptr&&rb->right!=nullptr){
        node *tt = new node();
        rc->right= tt;
        treecreate(ra->right,rb->right,rc->right);
    }
}

string answer(node* r){
    string ans;
    if(r->left!=nullptr){
        ans = "("+answer(r->left)+")";
    }else{
        ans ="()";
    }
    ans +="["+to_string(r->cost)+"]";
    if(r->right!=nullptr){
        ans += "("+answer(r->right)+")";
    }else{
        ans +="()";
    }
    return ans;
}
int main(){
    string A,B;
    cin >> A >> B;
    node* ra = new node();
    node* rb = new node();
    node* rc = new node();
    int n = A.size()-1;
    int m = B.size()-1;
    treebuild(A,ra,0,n);
    treebuild(B,rb,0,m);
    treecreate(ra,rb,rc);
    cout << answer(rc) << endl;
    return 0;
}


Measured memory_bytes: 3296
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = list(A)
    print(*a, sep=' ')
    insertionSort(a, N)

def insertionSort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(*a, sep=' ')

main()

Measured memory_bytes: 8004
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool prime[1000006];
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}

int main() {
    // O(MlogM)
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end()); // 不要だが時間計測のため
    rep(i, N) prime[A[i]] = 1;
    ll g = A[0];
    rep(i, N) g = gcd(g, A[i]);
    if (g != 1) {
        puts("not coprime");
        return 0;
    }
    for (int i = 2; i < 1000006; i++) {
        int temp = 0;
        for (int j = i; j < 1000006; j += i) {
            if (prime[j]) temp++;            
        }
        if (temp >= 2) {
            puts("setwise coprime");
            return 0;
        }
    }
    puts("pairwise coprime");
    return 0;
}


Measured memory_bytes: 8172
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,k,q;
    scanf("%d%d%d", &n, &k, &q);

    vector<int> a(n,k-q);
    int i;
    for(i=0; i<q; i++) {
        int tmp;
        scanf("%d", &tmp); tmp--;
        a[tmp]++;
    }
    for(i=0; i<n; i++) {
        if(a[i]>0) printf("Yes\n");
        else printf("No\n");
    }

    return 0;
}

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

int main() {
	int h,w;
	cin >> h >> w;
	vector<vector<string>> s(h,vector<string>(w,""));
	int tt=-1,yk=-1;
	for(int i = 0;i < h;i++)
	{
		for(int j = 0;j < w;j++)
		{
			cin >> s.at(i).at(j);
			if(s.at(i).at(j) == "snuke")
			{
				tt = i;
				yk = j;
				break;
			}
			if(tt >= 0)
			{
				break;
			}
		}
	}
	tt++;
	char ykk = 'A' + yk;
	cout << ykk << tt <<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){for(int n,k,a[100000],s,M,i;std::cin>>n>>k,n;printf("%d\n",M)){for(i=s=0;i<n;i++<k&&(M=s+=a[i-1]))std::cin>>a[i];for(i=k;i<n;M<s&&(M=s))s+=a[i]-a[i++-k];}}

Measured memory_bytes: 1080
#include<bits/stdc++.h>
using namespace std;
int  main (){
  int x,a,b;
  cin>>x;
  a=x%10;
  b=x/10;
  if(a==9||b==9){
    cout<<"Yes"<<"\n";
    return(0);
  }
  cout<<"No"<<"\n";
  

  return(0);
}

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

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

template <typename T> std::vector<std::pair<T, T>> prime_factor(T n) {
  std::vector<std::pair<T, T>> res;
  for (T k = 2; k * k <= n; ++k) {
    T num = 0;
    while (n % k == 0)
      n /= k, ++num;
    if (num != 0)
      res.push_back(std::make_pair(k, num));
  }
  if (n != 1)
    res.push_back(std::make_pair(n, 1));
  return res;
}

int main() {
  long long A;
  long long B;
  std::cin >> A >> B;

  long long v = gcd(A, B);
  auto primes = prime_factor(v);
  std::cout << primes.size() + 1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int MAX = 50 + 10;
const int MAXN = 2500 + 10;

long long dp[MAX][MAXN];
int rec[MAX];

int main(){

  int n, avg;
  scanf("%d %d", &n, &avg);

  for(int i = 0 ; i < n ; i++){
    scanf("%d", &rec[i]);
  }

  dp[0][0] = 1LL;

  int nowsum = 0;

  for(int i = 0 ; i < n ; i++){
    for(int j = i ; j >= 0 ; j--){
      for(int k = nowsum ; k >= 0 ; k--) if(dp[j][k]) {
        dp[j+1][k+rec[i]] += dp[j][k];
      }
    }
    nowsum += rec[i];
  }
  
  long long ans = 0;
  for(int i = 1 ; i <= n ; i++){
    ans += dp[i][avg*i];
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 640
package main

import (
    "fmt"
)

func main() {
    var s string
	fmt.Scan(&s)
	if !isPalindrome(s){
		fmt.Println("No")
		return
	}
	if !isPalindrome(s[ : (len(s)-1)/2 ]){
		fmt.Println("No")
		return
	}
	if !isPalindrome(s[ ((len(s)+3)/2)-1 : ]){
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")
	return
}

func reverse(s string) string {
    rs := []rune(s)
    for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
        rs[i], rs[j] = rs[j], rs[i]
    }
    return string(rs)
}
func isPalindrome(s string) bool {
	if s == reverse(s){
		return true
	}else{
		return false
	}
}

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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    int n; cin >> n;
    int a = 0, b = 0, c = 0, d = 0;

    while (n--)
    {
        string s; cin >> s;

        if (s == "AC")
            ++a;
        if (s == "WA")
            ++b;
        if (s == "TLE")
            ++c;
        if (s == "RE")
            ++d;
    }

    cout << "AC" << " x " << a << '\n';
    cout << "WA" << " x " << b << '\n';
    cout << "TLE" << " x " << c << '\n';
    cout << "RE" << " x " << d << '\n';

    return 0;
}

void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}

Measured memory_bytes: 3536
from collections import deque

n = int(input())
d = deque()
a = [int(x) for x in input().split()]
a = sorted(a)

i = a.pop()
d.append(i)

ans = 0
while a:
    arrive = a.pop()
    get_ease = d.popleft()
    ans += get_ease
    d.append(arrive)
    d.append(arrive)
    #print("a: ", a)
    #print("deque: ", d)
print(ans)


Measured memory_bytes: 96876
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
  ll n;
  vector<ll> x = {};
  cin >> n;

  for (auto i = 0; i < n; i++)
  {
    ll xx;
    cin >> xx;
    x.push_back(xx);
  }

  ll cur_min = 100000000000;
  for (auto i = 0; i <= 100; i++)
  {
    auto sum = 0;
    for (auto j = 0; j < n; j++)
    {
      auto diff = abs(x[j] - i);
      sum += diff * diff;
    }
    if (cur_min > sum)
    {
      cur_min = sum;
    }
  }

  cout << cur_min << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0] == s[1] && s[1] == s[2] || s[1] == s[2] && s[2] == s[3])cout << "Yes";
    else cout << "No";
}  

Measured memory_bytes: 256
fn swap<T: Clone>(series: &mut Vec<T>, i: usize, j: usize) {
    let tmp = series[i].clone();
    series[i] = series[j].clone();
    series[j] = tmp;
}

fn partition<T: Ord + Clone + std::fmt::Debug>(series: &mut Vec<T>, p: usize, r: usize) -> usize {
    let x = series[r].clone();
    let mut i = p;
    for j in p..r {
        if series[j] <= x {
            swap(series, i, j);
            i += 1;
        }
    }
    swap(series, i, r);
    return i;
}

fn main() {
    let input = read_string();
    let input = input.lines().collect::<Vec<_>>();
    let n: usize = input[0].parse().unwrap();
    let r = n - 1;
    let mut series = input[1].split_whitespace().map(|e| e.parse().unwrap()).collect::<Vec<u32>>();

    let q = partition(&mut series, 0, r);

    let small = series[0..q].iter().map(|e| format!("{}", e)).collect::<Vec<String>>().join(" ");
    let large = series[q+1..r+1].iter().map(|e| format!("{}", e)).collect::<Vec<String>>().join(" ");
    println!("{} [{}] {}", small, series[q], large);
}

fn read_string() -> String {
    use std::io::Read;

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    return buf;
}



Measured memory_bytes: 9116
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n % p == 0:
      n //= p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)

Measured memory_bytes: 9228