akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include<iomanip>
#include<functional>
using namespace std;
typedef long long ll;


long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}


int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (a % 2 == 0 && b%2==0 && c%2==0) {
        if (a == b && b == c) {
            cout << -1 << endl;
            return 0;
        }
        int cnt = 0;
        while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
            int bufa = a / 2,bufb = b/2,bufc = c/2;
            a = bufb + bufc;
            b = bufa + bufc;
            c = bufa + bufb;
            cnt++;
        }
        cout << cnt << endl;
        return 0;
    }
    else  cout << 0 << endl;
}


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

int main(void)
{
    long long n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    vector<bool> visitedflug(n, false);
    vector<int> visited(n, 0);
    int t=0, l = 0, m = 0, o = 0;

    while(visitedflug.at(l) == false){
        visited.at(t)=l;
        t++;
        visitedflug.at(l)=true;
        l=a.at(l)-1;
        m++;
    }
    int i=0;
    while(visited.at(i)!=l){
        o++;
        i++;
    }
    if(k < m){
        cout << visited.at(k)+1 << endl;
    }else{
        k-=o;
        k%=m-o;
        cout << visited.at(o+k)+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4844
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

signed main(void) {
    int n,m,d;
    cin >> n >> m >> d;
    vs s(n);
    rep(i,n) cin >> s[i];
    int ans = 0;
    rep(i,n)rep(j,m){
        if(j+d <= m){
            bool c = true;
            rep(k,d)if(s[i][j+k] == '#') c = false;
            if(c) ans++;
        }
        if(i+d <= n){
            bool c = true;
            rep(k,d)if(s[i+k][j] == '#') c = false;
            if(c) ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3204
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[100][100], b[100],c[100];
    int i, j, n, m;
    
    scanf("%d %d", &n, &m);
    
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(j=0; j<m; j++){
        scanf("%d", &b[j]);
    }
    for(i=0; i<n; i++){
        c[i]=0;
        for(j=0; j<m; j++){
            c[i] += a[i][j]*b[j];
        }
    }
    for(i=0; i<n; i++){
        printf("%d\n", c[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
using System;
using System.Collections.Generic;

class ALDS1_13_A {
    Stack<int[]> qpos = new Stack<int[]>();
    List<int> vacant;
    int[] idx;
    bool[] used;
    
    void combination(int m=0)
    {
        if (m==idx.Length) {
            char[] board = new char[64];
            for (int i=0; i<64; i++)  board[i] = '.';
            foreach (int[] ii in qpos)  board[ii[0]] = 'Q';
            for (int j=0; j<8; j++) {
                for (int i=0; i<8; i++)  Console.Write(board[j*8+i]);
                Console.WriteLine();
            }
        } else {
            for (int i=0; i<vacant.Count; i++) {
                if (m>0 && idx[m-1]<i)  continue;
                if (used[i])  continue;
                idx[m] = i;
                int q = vacant[i];
                int x = q%8;
                int y = q/8;
                foreach (int[] qq in qpos) {
                    if (x==qq[0]%8 || y==qq[0]/8)  goto next;
                    if (y==x+qq[1] || y==-x+qq[2]) goto next;
                }
                used[i]=true;
                qpos.Push(new int[] {q, y-x, y+x});
                combination(m+1);
                qpos.Pop();
                used[i]=false;
              next:
                ;
            }
        }
    }
    
    void run() {
        int nump = int.Parse(Console.ReadLine());
        idx = new int[8-nump];

        vacant = new List<int>();
        for (int i=0; i<64; i++)  vacant.Add(i);
        
        for (int k=0; k<nump; k++) {
            string[] str = Console.ReadLine().Split();
            int j = int.Parse(str[0]);
            int i = int.Parse(str[1]);
            qpos.Push(new int[] {j*8+i, j-i, j+i});
            for (int x=0; x<8; x++) {
                if (vacant.Contains(j*8+x)) vacant.Remove(j*8+x);
                if (vacant.Contains(x*8+i)) vacant.Remove(x*8+i);
                if (vacant.Contains(8*(j-i+x)+x)) vacant.Remove(8*(j-i+x)+x);
                if (vacant.Contains(8*(j+i-x)+x)) vacant.Remove(8*(j+i-x)+x);
            }
        }

        used = new bool[vacant.Count];
        for (int i=0; i<vacant.Count; i++) used[i]=false;
        combination();
    }

    static void Main()
    {
        ALDS1_13_A a = new ALDS1_13_A();
        a.run();
    }
}



Measured memory_bytes: 18372
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007;
#define INF 1000000000000000001;
#define ll long long
vector<vector<int>>g;
vector<pair<int,int>>wg[12345];

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin>>n;
  cin>>s;
  if(n<3200)
  cout<<"red"<<endl;
  else
  cout<<s<<endl;



  return 0;
}


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

using namespace std;
using ll = long long;

const int N = 2e5 + 5;

struct Data {
    int l, r;
} id[N];

int a[N];

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        id[i].l = i + a[i];
        id[i].r = i - a[i];

    }
    ll cnt = 0;
    map<int, int> f;
    for (int i = n; i >= 1; i--) {
        cnt += 1LL * f[id[i].l];
        ++f[id[i].r];
    }
    cout << cnt << '\n';
}

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

const int maxn = 105;
int n, s[maxn];

int main(){
	cin >> n;
	for(int i = 0; i<n; i++) cin >> s[i];
	int min_no_multiplo = 200;
	int sum = 0;
	for(int i = 0; i<n; i++){
		sum += s[i];
		if (s[i] % 10 > 0)
			min_no_multiplo = min(min_no_multiplo, s[i]);
	}
	if (sum % 10 > 0) cout << sum;
	else if (min_no_multiplo < 200) cout << sum-min_no_multiplo;
	else cout << 0;
	cout << '\n';
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<pair<pair<string,int>,int>> X(N);
  for(int i=0; i<N; i++){
    string s;
    int p;
    cin >> s ;
    cin >> p;
    X[i] = make_pair(make_pair(s,-p),i);//点数は高い順で並べたいので負の符号をつけておく
  }
  
  sort(X.begin(), X.end());
  
  for(int i=0; i<N; i++){
    cout << X[i].second+1 << endl;
  }
  
  
}



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

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[2001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

void add_BIT(long long BIT[], int n, int i, int k)
{
	while (i <= n) {
		BIT[i] += k;
		i += (i & -i);
	}
}

long long sum_BIT(long long BIT[], int r)
{
	long long sum = 0;
	while (r > 0) {
		sum += BIT[r];
		r -= (r & -r);
	}
	return sum;
}

int N, A[2001], flag[2001] = {};
long long BIT[2][2001] = {};
data d[2001];

long long recursion(int k, int l, int r)
{
	if (l == r) return (long long)A[d[k].id] * abs(d[k].id - l);
	
	long long ans, tmp[2] = {(long long)A[d[k].id] * abs(d[k].id - l), (long long)A[d[k].id] * abs(d[k].id - r)};
	flag[d[k].id] = 1;
	add_BIT(BIT[0], N, d[k].id, -(d[k].key));
	add_BIT(BIT[1], N, N - d[k].id + 1, -(d[k].key));
	if (tmp[0] > tmp[1]) {
		ans = recursion(k - 1, l + 1, r) + tmp[0];
		if (tmp[0] - sum_BIT(BIT[1], N - d[k].id) < tmp[1] - sum_BIT(BIT[0], d[k].id - 1) * 99 / 100) {
			tmp[1] += recursion(k - 1, l, r - 1);
			if (tmp[1] > ans) ans = tmp[1];
		}
	} else {
		ans = recursion(k - 1, l, r - 1) + tmp[1];
		if (tmp[0] - sum_BIT(BIT[1], N - d[k].id) * 99 / 100 > tmp[1] - sum_BIT(BIT[0], d[k].id - 1)) {
			tmp[0] += recursion(k - 1, l + 1, r);
			if (tmp[0] > ans) ans = tmp[0];
		}
	}
	flag[d[k].id] = 0;
	add_BIT(BIT[0], N, d[k].id, d[k].key);
	add_BIT(BIT[1], N, N - d[k].id + 1, d[k].key);
	return ans;
}

int main()
{
	int i;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= N; i++) {
		add_BIT(BIT[0], N, i, A[i]);
		add_BIT(BIT[1], N, N - i + 1, A[i]);
	}
	for (i = 0; i < N; i++) {
		d[i].key = A[i+1];
		d[i].id = i + 1;
	}
	merge_sort(d, N);
	
	printf("%lld\n", recursion(N - 1, 1, N));
	fflush(stdout);
	return 0;
}

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

typedef long long ll;

template <class T>
void printArray(vector<T> arr) {
	for (T a: arr) cout << a << " ";
	cout << '\n';
}

void printVerdict(bool verdict) {
	cout << (verdict ? "YES": "NO") << '\n';
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x, n, ret = -1;
	cin >> x >> n;
	set<int> p;
	for (int i = 0; i <n; i++) {
		int temp; cin >> temp;
		p.insert(temp);
	}
	int left = x, right = x;
	while (ret == -1) {
		if (p.find(left) == p.end()) ret = left;
		else if (p.find(right) == p.end()) ret = right;
		
		left--;
		right++;
	}
	cout << ret << '\n';
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
const ll INF=99999999999999999;
ll a,b,c,d,e,f,ans=0;
int main(){
    ll n,x;
    cin>>n>>x;
    ll dp[201][100001];
    vl s;
    rep(i,n){
        cin>>a;
        s.push_back(a);
    }

    rep(i,x+1){
        rep(j,n+1){
            dp[j][i]=0;
        }
    }

    sort(s.begin(),s.end());
    reverse(s.begin(),s.end());
    dp[0][x]=1;

    rep(i,n){
        rep(j,x+1){
            dp[i+1][j%s[i]]+=dp[i][j];
            dp[i+1][j%s[i]]=dp[i+1][j%s[i]]%1000000007;
            dp[i+1][j]+=dp[i][j]*(n-i-1);
            dp[i+1][j]=dp[i+1][j]%1000000007;
        }
    }

    rep(i,x+1){
        ans=(ans+i*dp[n][i])%1000000007;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 157312
#include <bits/stdc++.h>
using i64 = long long;

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

int main() {
    i64 a, b, c, d;
    std::cin >> a >> b >> c >> d;
    i64 g = gcd(c, d);
    auto f = [&](auto n) {
        return n - n / c - n / d + n / (c / g * d);
    };
    std::cout << f(b) - f(a - 1) << std::endl;

    return 0;
}


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

int main(){
 int a,b,c,buf;
 cin >> a >> b >> c;
 if(a>b){
  buf=a;
  a=b;
  b=buf;
 }
 if(b>c){
  buf=b;
  b=c;
  c=buf;
 }
 if(a>b){
  buf=a;
  a=b;
  b=buf;
 }
 cout << a << " " << b << " " << c << endl;
} 
 




Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define CYES cout << "Yes" \
                  << "\n";
#define CNO cout << "No" \
                 << "\n";
#define CFS           \
    cin.tie(nullptr); \
    ios::sync_with_stdio(false);
#define CST(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
const int IINF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const string MM = " ";

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v(n, -1);
    for (size_t i = 0; i < m; i++)
    {
        int s, c;
        cin >> s >> c;
        if (v[s - 1] != -1)
        {
            if (v[s - 1] == c)
            {
                continue;
            }
            else
            {
                cout << -1 << "\n";
                return 0;
            }
        }
        else
        {
            v[s - 1] = c;
        }
    }
    if (v[0] == 0)
    {
        if (n != 1)
        {
            cout << -1 << "\n";
            return 0;
        }
    }
    for (size_t i = 0; i < n; i++)
    {
        if (v[i] == -1 && i == 0 && n != 1)
        {
            cout << 1;
        }
        else if (v[i] == -1)
        {
            cout << 0;
        }
        else
        {
            cout << v[i];
        }
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=1<<30; 
int main()
{
    cin>>s;
    for(int i=1;i<s.length();i++)
        if(s[i]!=s[i-1])
            ans=min(ans,max(i,int(s.length())-i)); 
    cout<<min(ans,int(s.length()))<<endl;
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<utility>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<list>
#include<set>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define F first
#define S second
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
struct XY
{
	int x;
	int y;
};
int in()
{
	int x;
	cin >> x;
	return x;
}

/*
(char)'1' - (int)48 = (int)1;
　1111181
*/
////////////////////////////////////////////////////




int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		set<string> ans;
		string a;
		cin >> a;
		for (int i = 1; i < a.size(); i++)
		{
			string b, c;
			for (int l = 0; l < i; l++)b += a[l];
			for (int l = i; l < a.size(); l++)c += a[l];
			
			ans.insert(b + c);
			ans.insert(c + b);
			reverse(b.begin(), b.end());
			ans.insert(b + c);
			ans.insert(c + b);
			reverse(c.begin(), c.end());
			ans.insert(b + c);
			ans.insert(c + b);
			reverse(b.begin(), b.end());
			ans.insert(b + c);
			ans.insert(c + b);

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

}

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

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

    vector<int> d(n);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        if(a == 1) d[b-1] += 1;
        if(b == n) d[a-1] += 1;
    }
    sort(d.begin(),d.end());
    if(d[n-1] == 2) cout << "POSSIBLE" << endl;
    if(d[n-1] != 2) cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while( scan.hasNextInt() ) {
			int num = scan.nextInt();
			
			int cnt = 0;
			for(int i = 0; i <= 9; i++) {
				for(int j = 0; j <= 9; j++) {
					for(int k = 0; k <= 9; k++) {
							for(int l = 0; l <= 9; l++) {
								if(i+j+k+l == num) {
									cnt++;
								}
							}
					}
				}
			}
			
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 17028
# coding: utf-8
# Your code here!

import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
#a = [int(i) for i in readline().split()]
#n = int(input())


#n,*a = [int(i) for i in read().split()]

n,m = [int(i) for i in readline().split()]
sc = [[int(i) for i in readline().split()] for _ in range(m)]

#C = [str(sc[i][1]) for i in range(m)]
#S = [sc[i][0] for i in range(m)]

for i in range(m):
    sc[i][1] = str(sc[i][1])
    sc[i][0] -= 1


def keta(x):
    if x==0: x += 1
    c = 0
    while x:
        x //= 10
        c += 1
    return c

ans = -1
for i in range(10000000):
    k = keta(i)
    if k > n: break
    elif k == n:
        s = str(i)
        for ss,cc in sc:
            if s[ss] != cc:
                break
        else:
            ans = i
            break

print(ans)







Measured memory_bytes: 3064
// inputに入力データ全体が入る
function Main(input) {

	input = input.split(" ");
	
	const H = parseInt(input[0], 10);
	const A = parseInt(input[1], 10);
  
	var answer = Math.ceil(H / A); 
  	
	//出力
   console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;

int n;
int a[100005][2];
bool u[100005][2];
int cnt00,cnt01,cnt10,cnt11;
ll ans,ans2;
multiset<int> use,unuse,t;
set<int> s;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //I can't do this without STL(STL to-do lot).
    //lmao
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i][0]>>a[i][1];
        t.insert(a[i][0]);
        t.insert(a[i][1]);
    }
    for(multiset<int>::iterator it=t.begin();it!=t.end();it++){
        if(use.size()<n){
            use.insert(*it);
            ans+=*it;
        }else{
            unuse.insert(*it);
        }
    }
    t=use;
    for(int i=1;i<=n;i++){
        if(t.find(a[i][0])!=t.end()){
            u[i][0]=true;
            t.erase(t.find(a[i][0]));
        }
        if(t.find(a[i][1])!=t.end()){
            u[i][1]=true;
            t.erase(t.find(a[i][1]));
        }
        if(!u[i][0]&&!u[i][1])cnt00++;
        if(!u[i][0]&&u[i][1])cnt01++;
        if(u[i][0]&&!u[i][1])cnt10++;
        if(u[i][0]&&u[i][1])cnt11++;
    }
    if(cnt00||cnt11||cnt01==n||cnt10==n){
        cout<<ans<<endl;
        return 0;
    }
    ans2=1e18;
    for(int i=1;i<=n;i++){
        if(u[i][0]){
            multiset<int>::iterator it=unuse.begin();
            if(a[i][1]==*it)it++;
            ans2=min(ans2,ans+*it-a[i][0]);
        }else{
            multiset<int>::iterator it=unuse.begin();
            if(a[i][0]==*it)it++;
            ans2=min(ans2,ans+*it-a[i][1]);
        }
    }
    cout<<ans2<<endl;

    return 0;
}

Measured memory_bytes: 19968
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int min = 1000;
    int sum = 0;
    
    for(int i = 0; i < n; i++){
      int num = sc.nextInt();
      min = Math.min(min, num);
      sum += num;
    }
    System.out.println(n + (x - sum)/min);
  }
}

Measured memory_bytes: 21844
//
//  ALDS1_2_B_SelectionSort.cpp
//  test
//
//  Created by Sajor on 2019/3/21.
//  Copyright © 2019年 Sajor. All rights reserved.
//

#include <iostream>
using namespace std;
#define MAX_N 105

void print(int a[], int n){
    for(int i=0; i<n; i++){
        if (i>0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

int selectionSort(int *a, int n){
    int count = 0, mini_n;
    
    for(int i=0; i<n; i++){
        mini_n = i;
        for(int j=i; j<n; j++){
            if(a[j] < a[mini_n])
                mini_n = j;
        }
        if (mini_n != i){
            a[mini_n] ^= a[i];
            a[i] ^= a[mini_n];
            a[mini_n] ^= a[i];
            count++;
        }
    }
    
    return count;
}

int main()
{
    int N, a[MAX_N];
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> a[i];
    }
    int c = selectionSort(a, N);
    print(a, N);
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main(){
    int n,t,ci,ti,i,c=1001;
    cin >> n >> t;
    for(i=0;i<n;i++){
        cin >> ci >> ti;
        if(ti<=t && ci<c)
            c=ci;
    }
    if(c<1001)
        cout << c << endl;
    else
        cout << "TLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int A, B;
	cin >> A >> B;
	
	string str;
	cin >> str;
	
	bool flag = true;
	
	for(int i = 0; i < str.size(); i++){
		if(i == A){
			if(str[i] != '-'){
				flag = false;
			}
		}else if(str[i] < '0' || str[i] > '9'){
			flag = false;
		}
	}
	
	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) {
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

int main() {
	int n, i;
	cin >> n;
	vector<int> a(n + 1);
	vector<int> b(n + 1);
	for (i = 0; i <= n; i++) {
		b[i] = 0;
	}
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		b[a[i]]++;
	}
	if (n % 2 != 0 && b[0] != 1) {
		cout << 0 << endl;
		return 0;
	}

	if (n % 2 == 0) {
		for (i = 1; i <= n/2; i++) {
			if (b[(2 * i) - 1] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	} else {
		for (i = 1; i <= n/2; i++) {
			if (b[2 * i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	ll ans = 1;
	if (n % 2 == 0) {
		for (i = 1; i <= (n/2); i++) {
			ans *= 2;
			ans %= DIV;
		}
	} else {
		for (i = 1; i <= ((n - 1)/2); i++) {
			ans *= 2;
			ans %= DIV;
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    if ((a*b) % 2) == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <ctime>
#include <climits>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    while (n --) {
        vector<vector<int>> m(5, vector<int>(5, 0));
        for (int i=0; i<5; ++i) {
            for (int j=0; j<5; ++j) {
                cin >> m[i][j];
            }
        }

        int ans = 0;
        for (int y1=0; y1<5; ++y1) for (int y2=y1; y2<5; ++y2) {
            for (int x1=0; x1<5; ++x1) for (int x2=x1; x2<5; ++x2) {
                bool ok = true;
                for (int i=y1; i<=y2; ++i) {
                    for (int j=x1; j<=x2; ++j) {
                        if (m[i][j] == 0) {
                            ok = false;
                            goto jump;
                        }
                    }
                }
                if (ok) {
                    ans = max(ans, (y2 - y1 + 1) * (x2 - x1 + 1));
                }
jump:;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    rep(i, x + 1) {
        int t = x - i;
        int s = x - t;
        if((2 * t) + (4 * s) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector> 
#include <cstring>

using namespace std;

const int MAXL = 200005;

string str1, str2;
int freqA[MAXL], freqB[MAXL];
int letnum[27];

int main() {
    cin >> str1;
    cin >> str2;
    vector<int> pos;
    
    if (str1.size() != str2.size()) {
        cout << "No" << endl;
        return 0;
    }
    
    memset(letnum, 0, sizeof(letnum));
    for (int i = 0;i < str1.size();i ++) {
        letnum[str1[i] - 'a'] ++;
    }
    memset(freqA, 0, sizeof(freqA));
    for (int i = 0;i < 26;i ++) {
        if (letnum[i]) {
           freqA[letnum[i]] ++;
           pos.push_back(letnum[i]);
        }
    }
    
    memset(letnum, 0, sizeof(letnum));
    for (int i = 0;i < str2.size();i ++) {
        letnum[str2[i] - 'a'] ++;
    }
    memset(freqB, 0, sizeof(freqB));
    for (int i = 0;i < 26;i ++) 
        if (letnum[i]) 
           freqB[letnum[i]] ++;
    
    for (int i = 0;i < pos.size();i ++)
        if (freqA[pos[i]] != freqB[pos[i]]) {
           cout << "No" << endl;
           return 0;
        }
    cout << "Yes" << endl;
    return 0;
} 


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(), l.end());
    ll ans = 0;
    rep(i,n) for(int j = i+1; j < n; j++){
        auto itr = lower_bound(l.begin(), l.end(), l[i]+l[j]);
        ans += itr - l.begin() - 1 - j;
    }
    cout << ans << endl;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int> >v;
    f(n){
        int a, b;
        cin >> a >> b;
        v.pb({a-b,b+a});
    }
    sort(v.begin(),v.end(),[](pair<int,int>a,pair<int,int>b){
        return a.S < b.S;
    });
    int last = -1e9;
    int ans = 0;
    for(auto i:v){
        if(i.F >= last){
            last = i.S;
            ans++;
        }
    }
    cout << ans << '\n';
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<int> vec(3);
	for (int i = 0; i < 3; i++) {
    	cin >> vec[i]; 
    }
	sort(vec.begin(), vec.end());
	cout << (vec[0] * vec[1]) / 2 << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdio>
using namespace std;
const int MAX=100005;
vector<int> G[MAX];
bool vis[MAX];
int group[MAX];
int n,m,number=0;
void dfs(int u){
	group[u]=number;
	vis[u]=1;
	for(unsigned int i=0;i<G[u].size();i++){
		if(!vis[G[u][i]])dfs(G[u][i]);
	}
}
int main(){
	int q;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=0;i<n;i++){
			if(!vis[i]){
				dfs(i);
				number++;
			}
		}
	cin>>q;
	for(int i=0;i<q;i++){
		int u,v;
		cin>>u>>v;
		printf("%s\n",((group[u]==group[v])?"yes":"no"));
	}
}


Measured memory_bytes: 12184
#include <iostream>

using namespace std;

int main(void) {
    int a, b;
    cin>>a>>b;

    int cnt = 0;
    for (int i=a; i<=b; ++i) {
        string s = to_string(i);
        int len = s.size();
        
        bool ok = true;
        for (int j=0; j<len; ++j) {
            if (s[j] != s[len-1-j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using namespace std;

int main()
{
	const vector<int> ls = {64, 32, 16, 8, 4, 2, 1};

	int s;
	cin >> s;

	for (int i = 0;; i++)
	{
		if(ls[i] <= s)
		{
			cout << ls[i] << endl;
			return 0;
		}
	}
}


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int max = 0;
  int tot = 0;
  for(int i = 0;i<n;++i){
  	char c = s[i];
    if(c=='I')tot++;
    else if(c=='D')tot--;
    
    if(tot>max)max=tot;
  }
  cout << max << endl;
  return 0;
}

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

using namespace std;

int main(void)
{

	int n, d,t1= 0,count =0;
	vector<vector<int> > x;

	cin >> n  >> d;
	x.resize(n);
	for(int i = 0; i< n; i++){
		x[i].resize(d);
		for(int j=0;j<d;j++){
			cin >> x[i][j];
		}
	}
	for(int j = 0; j< n; j++){
		for(int i = 0;i<j;i++){
			for(int k = 0;k<d;k++){
				t1 += (int)pow(x[j][k]-x[i][k],2.0);
			}
			if(sqrt(t1)== floor(sqrt(t1))) count++;
			t1 = 0;
		}
	}
	cout << count << endl;
	return 0;
}


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

int D,G,p[100],c[100],bit,ans=1e9,sum,cost;



int main(void){
    cin >> D >> G;
    G/=100;
    rep(i,D){
        cin >> p[i] >> c[i];
        c[i]/=100;
    }
    rep(i,1<<D){
        sum = 0;cost =0;
        for(int j=0;j<D;j++){
            bit = (i >> j)&1;
            if(bit){
                sum += p[j];
                cost +=p[j]*(j+1) + c[j]; 
            }
        }
        
        if(cost>=G)ans = min(ans,sum);

        for(int j =0;j<D;j++){
            bit = (i >> j)&1;
            if(!bit){
                for(int k=1;k<p[j];k++){
                    cost +=k*(j+1);
                    sum += k;
                    if(cost>=G)ans = min(ans,sum);
                    cost -=k*(j+1);
                    sum -=k;
                }
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
void input(){
    fast_io();
    cin >> N >> M;
}

vector< ll > divisor(ll n) {
  vector< ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret),greater<ll>());
  return (ret);
}

int solve(){
    auto div = divisor(M);
    for(auto d:div){
        if(M>=N*d) {cout << d << endl; return 0;}
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
int main(void){
  int n,i,x;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    x=i;
    if ( x % 3 == 0 ){
      printf(" %d",i);
    }else{
      do{
        if ( x % 10 == 3 ){
          printf(" %d",i);
          x=0;
        }
        x /= 10;
      }while( x );
    }
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;
ll mod=1e6+3;

int main(){
   int n;cin>>n;
   vector<int> v(n),s(n);
   for(int i=0;i<n;i++)cin>>v[i];
   s[0]=v[0];
   for(int i=1;i<n;i++)s[i]=s[i-1]+v[i];
   int sum=s[n-1];
   int ans=1e5;
   for(int i=0;i<n;i++)ans=min(ans,abs(sum-2*s[i]));
   cout<<ans;
   
   
}


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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
const double PI = 3.141592653589793238;

int main()
{
	FASTIO;
        ll i,j,k,x,y,z,n,a,b,c,c1=0,c2=0,flag=0,sum=0;
        char ch;
        cin>>ch;
        if(ch>='A' &&ch<='Z')
            cout<<"A";
        else
            cout<<"a";
        nl;


}


Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop();

int top,O[1000];

int main ()
{
  int x,y;
  top=0;
  char o[100];

  while(scanf("%s",o)!=EOF)
    {
      if(o[0]=='+')
	{
	  x=pop();
	  y=pop();
	  push(x+y);
	}
      else if(o[0]=='-')
	{
	  y=pop();
	  x=pop();
	  push(x-y);
	}
      else if(o[0]=='*')
	{
	  x=pop();
	  y=pop();
	  push(x*y);
	}
      else
	{
	  push(atoi(o));
	}
    }
  printf("%d\n",pop());

  return 0;
}

void push(int x)
{
  O[++top]=x;
}

int pop()
{
  top--;
  return O[top+1];
}




Measured memory_bytes: 2108
#include<stdio.h>
int main()
{
  int A1,A2,A3,wa;
  scanf("%d%d%d",&A1,&A2,&A3);
  wa=A1+A2+A3;
  if(wa>=22){
    printf("bust");
  }
  else{
    printf("win");
  }
}


Measured memory_bytes: 128
import java.util.*;
class Main{
  public static void main(String args[]){
    int kigen,n;   
    Scanner sc = new Scanner(System.in);
    kigen=sc.nextInt();
    n=sc.nextInt();
    for(int i=0;i<n;i++){
      kigen-=sc.nextInt();
    }
    if(kigen<-1)kigen=-1;
    System.out.println(kigen);
  }
}

Measured memory_bytes: 39568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int A, B; cin >> A >> B;
	if ((B - 1) % (A - 1) == 0)cout << (B - 1) / (A - 1) << endl;
	else {
		cout << (B - 1) / (A - 1) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>

using namespace std;

const int DIV = 1000000007;

int main(int argc, char *argv[]) {
#ifdef VLAD_LOCAL
    ifstream in("in.txt");
#else
    istream &in = cin;
#endif
    int n;
    in >> n;
    vector<int64_t> a(n + 2);
    for (int i = 0; i <= n; i++)
        in >> a[i];
    a[n + 1] = 0;
    vector<int64_t> b(n + 2);
    if (a[0] > 1) {
        printf("-1");
        return 0;
    }
    vector<int64_t> s(n + 2);
    s[n + 1] = 0;
    for (int i = n; i >= 0; i--)
        s[i] = s[i + 1] + a[i];
    b[0] = 1 - a[0];
    int64_t count = 1;
    for (int i = 1; i <= n; i++) {
        int64_t bmin = max((int64_t)0, b[i - 1] - a[i]);
        int64_t bmax = min(s[i + 1], 2*b[i - 1] - a[i]);
        if (bmin > bmax) {
            count = -1;
            break;
        }
        b[i] = bmax;
        count += a[i] + b[i];
    }
    printf("%lld", count);
	return 0;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<char> color(N);
  for(int i = 0;i < N;i++){
    cin >> color[i];
  }
  
  int count = 0;
  for(int i = 0;i < N;i++){
    if(color[i] == 'Y'){
      count++;
    }
  }
  if(count == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i, n){
    int in;
    cin >> in;
    q.push(in);
  }
  rep(i, m){
    int now = q.top(); q.pop();
    now /= 2;
    q.push(now);
  }
  ll ans = 0;
  while(!q.empty()){
    ans += q.top();
    q.pop();
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    cout << n*n*n;
    return 0;
}


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

int main() {
   int n;
   cin >> n;
   vector<int> w(n);
   rep(i, n) cin >> w[i];

   vector<int> t(n + 1);
   rep(i, n) t[i + 1] = t[i] + w[i];
   int ans = INF;
   rep(i, n - 1) {
      int s1 = t[i + 1];
      int s2 = t[n] - t[i + 1];
      ans = min(ans, abs(s1 - s2));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main(){
 int N;cin>>N;
  string S;cin>>S;
  ll r=0,b=0,g=0;
  rep(i,N){
    if(S[i]=='G'){g+=1;}
    else if(S[i]=='R'){r++;}
    else {b++;}
  }
ll all=g*b*r;
  ll div=0;
 for(int i=1;i<=N-2;i++){
   for(int j=1;j<=min(i,(N-1-i));j++){
     if(S[i]!=S[i+j]&&S[i]!=S[i-j]&&S[i-j]!=S[i+j]){
       div++;
     }
   }
 }
cout<<all-div<<endl;
 }

           
































	
	





	
	


	


	


		






Measured memory_bytes: 3572
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int X, Y;

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

  if (abs(X - Y) > 1) {
    cout << "Alice" << endl;
  } else {
    cout << "Brown" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long count = 0;
//
		for(int i=1 ; i<=n ; i++) {
			if(i%3==0 || i%5==0) {
				continue;
			}
			else {
				count += i;
			}
		}
		System.out.println(count);
	}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i], a[i]--;
	
	ll res = 0;
	FOR(i,0,n) if (a[i] > i && a[a[i]] == i) res++;
	cout << res << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
const int maxn = 100005;
const int maxm = 250005;
const int mod =  10009;
const int inf = 1e9 + 7;
//head
struct Node {
    int p;
    int t;
}nd[maxn];
int n, m, q[maxn];
vector<int> v[maxn];
int main() {
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; ++i) {
        scanf("%d%d", &nd[i].p, &nd[i].t);
        v[nd[i].p].pb(nd[i].t);
    }
    for(int i = 1; i <= n; ++i) sort(all(v[i]));
    for(int i = 0; i < m; ++i) {
        //printf("q = %d\n", q[i]);
        int P =  nd[i].p, T = nd[i].t;
        int q = lower_bound(all(v[P]), T)-v[P].begin()+1;
        printf("%06d%06d\n", nd[i].p, q);
    }
    return 0;
}


Measured memory_bytes: 7808
// 科目選択

#include <iostream>
using namespace std;

int main() {
    int total = 0;
    int mini = 100;
    int tmp;

    for (int i = 0; i < 4; i++) {
        cin >> tmp;
        total += tmp;
        if (tmp < mini) mini = tmp;
    }
    total -= mini;

    mini = 100;
    for (int i = 0; i < 2; i++) {
        cin >> tmp;
        total += tmp;
        if (tmp < mini) mini = tmp;
    }
    total -= mini;

    cout << total << "\n";
    return 0;
}


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

int main() {
	int n, x;
	int64_t a[100001];
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	a[n] = 0;
	int64_t c = 0;
	for (int i = 1; i < n; i++) {
		while (a[i - 1] + a[i] > x) {
			int64_t d;
			if (a[i] > 0 && a[i] + a[i + 1] > x) {
				d = min(a[i], min(a[i - 1] + a[i] - x, a[i] + a[i + 1] - x));
				a[i] -= d;
			} else {
				d = a[i - 1] + a[i] - x;
				a[i - 1] -= d;
			}
			c += d;
		}
		/*
		for (int i = 0; i < n; i++) {
			cout << a[i] << ' ';
		}
		cout << endl;
		*/
	}
	cout << c << endl;
	return 0;
}


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

using namespace std;

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

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

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

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

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

int n,k;
vi h;
vl dp;

//参考→https://qiita.com/drken/items/dc53c683d6de8aeacf5a
ll rec(int i){

    if(dp[i] < LLONG_MAX) return dp[i];
    if(i==0) return 0;

    ll ret = LLONG_MAX;
    FOR(j,1,k+1){
        if(j>i) break;
        chmin(ret, rec(i-j) + abs(h[i-j]-h[i]));
    }
    dp[i] = ret;

    return ret;
}

int main() {
    cin>>n>>k;
    h.resize(n);
    REP(i,n) cin>>h[i];

    dp.resize(n);
    REP(i,n) dp[i] = LLONG_MAX;

    dp[0] = 0;
    cout << rec(n-1) << endl;

    //DEBUG_VEC(dp);
    return 0;
}

Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 300005;
int n,k;
int main(){
	scanf("%d%d", &k, &n);
	if(~k&1) rep(i,n) printf("%d%c", i?k:k/2,i<n-1?' ':'\n');
	else{
		int d[MX] = {}, e = n-1;
		fill(d,d+n,k/2+1);
		rep(i,n/2){
			d[e]--;
			if(!d[e]) e--;
			else if(e < n-1) for(;e < n-1; e++) d[e+1] = k;
		}
		rep(i,e+1) printf("%d%c", d[i],i<e?' ':'\n');
	}
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int n, m[100], x, count = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++){
		cin >> m[i];
		x -= m[i];
		count++;
	}
	sort(m, m + n);
	for (; x >= m[0];x -= m[0]){
		count++;
	}
	cout << count << endl;
}



Measured memory_bytes: 256