akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <ctime>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SS stringstream
#define DBG1(a) rep(_X,sz(a)){printf("%d ",a[_X]);}puts("");
#define DBG2(a) rep(_X,sz(a)){rep(_Y,sz(a[_X]))printf("%d ",a[_X][_Y]);puts("");}
#define bitcount(b) __builtin_popcount(b)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)

#define delete(a,n) a.erase(remove(all(a),n),a.end())
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
template<typename T> void operator>>(vector<T>& a, int b) {while(b--)if(!a.empty())a.pop_back();}
bool isprime(int n){ if(n<2)return false;  for(int i=2;i*i<=n;i++)if(n%i==0)return false;  return true;} 
ll b_pow(ll x,ll n){return n ? b_pow(x*x,n/2)*(n%2?x:1) : 1ll;}
string itos(int n){stringstream ss;ss << n;return ss.str();}


string name[10];
int w[10];
int s[10];

vector<int> answer,current;
int used[10];
int n;
int sum = 0;
double jushin = 0 , curr = 0;
int dfs(int x){
	int chksum = 0;
	for(int i = current.size() - 1 ; i >= 0 ; i--){
		if( chksum > s[current[i]] ) return 0;
		chksum += w[current[i]];
	}
	
	if( current.size() == n ) {
		if( jushin < curr ){
			answer = current;
			curr = jushin;
		}
		return 0;
	}
	for(int i = 0 ; i < n ; i++){
		if( !used[i] ){
			used[i] = true;
			current.push_back(i);
			jushin += x * w[i];
			dfs(x+1);
			jushin -= x * w[i];
			current.pop_back();
			used[i] = false;
		}
	}
}
int main(){
	while(cin >> n && n){
		for(int i = 0 ; i < n ; i++){
			cin >> name[i] >> w[i] >> s[i];
		}
		curr = 1e9;
		answer.clear();
		dfs(1);
		for(int i = 0 ; i < n ; i++){
			cout << name[answer[i]] << endl;
		}
	}
}

Measured memory_bytes: 1224
def check(s):
    for i in range(len(s) // 2):
        if s[i] != s[-i - 1]:
            return False
    return True


def resolve():
    s = input()
    n = len(s)
    if check(s) and check(s[: (n - 1) // 2]) and check(s[(n + 3) // 2 - 1:]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    resolve()


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

int ce(int a, int b)
{
	return (a+b-1)/b;
}

int main()
{
	int n, x, t;
	scanf("%d%d%d", &n, &x, &t);
	printf("%d\n", ce(n, x)*t);
}

Measured memory_bytes: 3720
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int d,g;
    cin>>d>>g;
    vector<int> p(d),c(d);
    rep(i,0,d){
        cin>>p[i]>>c[i];
    }
    int ans=1e9;
    for(int i=0;i<(1<<d);i++){
        int sum=0,rest,num=0;
        for(int j=0;j<d;j++){
            if(i>>j&1){
                sum+=100*(j+1)*p[j]+c[j];
                num+=p[j];
            }
            else rest=j;
        }
        if(sum<g){
            int need=(g+(rest+1)*100-sum-1)/((rest+1)*100);
            if(need>=p[rest])continue;
            num+=need;
        }
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
using namespace std;
const int N=4e5+10;
queue<int> Q;
int n,m,d[N],head[N],cnt,fa[N];
struct edge{int next,to;}a[N];
void link(int x,int y) {a[++cnt]=(edge){head[x],y};head[x]=cnt;}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n+m-1;i++)
	{
		int x,y;scanf("%d%d",&x,&y);
		link(x,y);d[y]++;
	}
	for(int i=1;i<=n;i++) if(!d[i]) Q.push(i);
	while(!Q.empty())
	{
		int x=Q.front();Q.pop();
		for(int i=head[x];i;i=a[i].next)
		{
			int R=a[i].to;
			d[R]--;
			if(!d[R]) fa[R]=x,Q.push(R);
		}
	}
	for(int i=1;i<=n;i++) printf("%d\n",fa[i]);
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

struct node {
	bool done;
	vi to, dist;
	int id, from;
};

class Tree_Diameter {
private:
	vector<node> nodes;
public:
	int s, t, d;
	Tree_Diameter(vector<node> A) {
		nodes = A;
		Loop(i, nodes.size()) nodes[i].done = 0;
		nodes[0].from = -1;
		s = dfs(0).first;
		Loop(i, nodes.size()) nodes[i].done = 0;
		nodes[s].from = -1;
		P buf = dfs(s);
		t = buf.first;
		d = buf.second;
	}
	P dfs(int a) {
		if (nodes[a].done) {
			return{ a, -1 };
		}
		nodes[a].done = 1;
		P ret = { a,0 };  //leaf,distance
		Loop(i, nodes[a].to.size()) {
			int b = nodes[a].to[i];
			if (nodes[a].from == b) continue;
			nodes[b].from = a;
			P buf = dfs(b);
			if (buf.second == -1) return buf;
			buf.second += nodes[a].dist[i];
			if (buf.second > ret.second) ret = buf;
		}
		return ret;
	}
};

int main() {
	int n; cin >> n;
	vector<node> nodes(n);
	Loop(i, n) nodes[i] = { 0,{},{}, i, -1};
	Loop(i, n - 1) {
		int s, t, d;
		cin >> s >> t >> d;
		nodes[s].to.push_back(t);
		nodes[s].dist.push_back(d);
		nodes[t].to.push_back(s);
		nodes[t].dist.push_back(d);
	}
	Tree_Diameter td(nodes);
	cout << td.d << endl;
	return 0;
}

Measured memory_bytes: 44416
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=4e2,M=1e5;
int A[M+10],B[M+10];
bool vis[N+10],sub[N+10][N+10];
int main(){
	int n=read(),m=read(),Ans=0;
	for (int i=1;i<=m;i++)	A[i]=read(),B[i]=read();
	for (int i=1;i<=n;i++){
		sub[i][i]=1;
		for (int j=m;j;j--){
			bool x=sub[i][A[j]],y=sub[i][B[j]];
			if (x&&y)	vis[i]=1;
			else	if (x)	sub[i][B[j]]=1;
			else	if (y)	sub[i][A[j]]=1;
		}
	}
	for (int i=1;i<=n;i++){
		if (vis[i])	continue;
		for (int j=i+1;j<=n;j++){
			if (vis[j])	continue;
			bool flag=1;
			for (int k=1;k<=n;k++)	if (sub[i][k]&&sub[j][k])	flag=0;
			Ans+=flag;
		}
	}
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 1152
import math
k = int(input())

map_list = [[0 for i in range(k+1)]for j in range(k+1)]
for i in range(1,k+1):
    for j in range(1,k+1):
        map_list[i][j]=math.gcd(i,j)

ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd1 = map_list[i][j]
        for k in range(1,k+1):
            ans+=map_list[k][gcd1]
print(ans)

Measured memory_bytes: 9484
#include<bits/stdc++.h>
#define lli long long int

using namespace std;

int main(){
	int n, k;
	cin>>n>>k;
	lli a[n];
	for(int i = 0; i < n; i++) cin>>a[i];
	lli cost[n];
	fill(cost, cost + n, LLONG_MAX);
	cost[0] = 0;
	for(int i = 0; i < n-1; i++) {
		for(int j = 1; j <= k; j++) {
			if(i + j < n) {
				cost[i + j] = min(cost[i + j], cost[i] + abs(a[i] - a[i + j]));
			} else break;
		}
	}
	cout<<cost[n - 1];
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define ST first
#define ND second
#define ll long long
#define ld long double
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

const ll  INF = 1e9 + 9;
const ll  MOD = 1e9 + 7;
const long long LINF = (ll)1e18 + 3;
 
// secik.insert({x, t++});
// secik.erase(secik.lower_bound({x,-1}));
// *secik.find_by_order(x)).first << "\n";
// secik.order_of_key(x)
 
//random_device device;
//mt19937 gener(device());
//uniform_int_distribution<ll > gen(0,n-1);
//gen(gener); // generate random number

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

	int n; cin >> n;
	
	vector<ll> tab(n);
	
	for(int i = 0; i < n; i++) cin >> tab[i];
	
	ll xorr = 0;
	for(int i = 2; i < n; i++) xorr ^= tab[i];
	
	ll summ = tab[0] + tab[1]; 
	ll andd = (summ - xorr)/2;

	ll a = andd, b = andd;
	bool ok = true;
	for(ll i = 62; i >= 0; i--){
		if(andd & (1ll << i)){
			if(xorr & (1ll << i)){
				ok = false;
				break;
			} else {
				a |= (1ll << i);
				b |= (1ll << i);
			}
		} else {
			if(xorr & (1ll << i)){
				if((a | (1ll << i)) <= tab[0]) a |= (1ll << i);
				else b |= (1ll << i);
			}
		}
	}
	if(a + b != summ) ok = false;
	if(a == 0 || b == 0) ok = false;
	if(a > tab[0]) swap(a,b);
	if(!ok || a > tab[0]){
		cout << -1;
	} else {
		cout << tab[0] - a;
	}
	cout << "\n";
}

Measured memory_bytes: 3652
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

n = I()
ret = 0
for i in range(n + 1):
    if i % 3 == 0 or i % 5 == 0:
        continue
    else:
        ret += i

print(ret)

Measured memory_bytes: 77676
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

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

	string s;
	cin >> s;

	bool flag = true;
	for (int i=0;i<a;i++) {
	if (!('0'<=s[i] && s[i]<='9')){
	flag = false;
	}
	}

	if (s[a]!='-') {
	flag = false;
	}
	int len = a+b+1;

	for (int i=a+1;i<len;i++) {
        if(!('0'<=s[i] && s[i]<='9')){
	flag = false;
        }
        }

	if (flag) {
	cout << "Yes" << endl;
	}
	else {
	cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
    }
    std::sort(a.begin(), a.end(),
              [](const pair<int, int> &x, const pair<int, int> &y){return x.second < y.second;});
    int res = 0;
    int last = -1;
    for (auto p : a) {
        if (p.first <= last) {
            continue;
        }
        last = p.second - 1;
        res++;
    }
    cout << res << "\n";
    return 0;
}

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

#define FASTIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;

int main() {
	FASTIO
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	int i = 0, j = n - 1;
	while(i < j){
		while(i < n && s[i] == 'R')
			i++;
		while(j >= 0 && s[j] == 'W')
			j--;
		if(i < j && s[i] == 'W' && s[j] == 'R')
			ans++, swap(s[i++], s[j--]);

	}
	cout << ans << endl;
}

Measured memory_bytes: 3728
n , m = list(map(int,input().split()))
lll = []
iii = [0 for _ in range(m)]
ppp = [1 for _ in range(n)]
for i in range(m):
  p, y =list(map(int,input().split()))
  lll.append([i,p,y])
lll.sort(key=lambda x:x[2])
for i in range(m):
  p = lll[i][1]
  x = ppp[p-1]
  iii[lll[i][0]] = "{0:06d}".format(p) + "{0:06d}".format(x)
  ppp[p-1] += 1
for i in iii:
  print(i)

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

using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> v(N, 0);
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[a]++; v[b]++;
  }
  
  for (int i = 0; i < N; i++) {
    cout << v[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string table[] = { "AADINNUY", "AIZUNYAN" };
string d;

int main(){
	cin >> d;
	if (d.size() >= 8){
		REP(i, d.size() - 7){
			string s = d.substr(i, 8);
			sort(ALL(s));
			if (s == table[0]){
				REP(j, 8){
					d[i + j] = table[1][j];
				}
				i += 7;
			}
		}
	}
	cout << d << endl;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define     bit_1(a)       __builtin_popcount(a)
#define     ull            unsigned long long
#define     ll             long long
#define     pb             push_back
#define     pf             push_front
#define     mpr            make_pair
#define     ins            insert
#define     ff             first
#define     ss             second
#define     vi             vector<int>
#define     vl             vector<ll>
#define     vstr           vector<string>
#define     si             set<int>
#define     sl             set<ll>
#define     li             list<int>
#define     pii            pair<int,int>
#define     pll            pair<ll,ll>
#define     mii            map<int,int>
#define     mll            map<ll,ll>
#define     ma             INT_MAX
#define     mi             INT_MIN
#define     mod            1000000007
#define     pi             3.14159265359
#define     e              2.71828182846
#define     inf            1000000000000000LL
#define     all(x)         x.begin(), x.end()
#define     lb(a,b,c)      lower_bound(a,a+b,c)-a
#define     ub(a,b,c)      upper_bound(a,a+b,c)-a
#define     lbv(a,c)       lower_bound(all(a),c)-a.begin()
#define     ubv(a,c)       upper_bound(all(a),c)-a.begin()
#define     srt1(a,b)      sort(a,a+b)
#define     srt2(a,b)      sort(a,a+b,greater<int>())
#define     gcd(a,b)       __gcd(a,b)
#define     lcm(a,b)       (a*(b/gcd(a,b)))
#define     harmonic(n)    0.57721566490153286l+log(n)
#define     mem(a, b)      memset(a, b, sizeof(a))
#define     orderset1      tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define     orderset2      tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>

///s.lower_bound(a),s.upper_bound(a), for set
///nCr(x, y) = nCr(x-1, y-1) + nCr(x-1, y)
///factorial digit   ((n * log10(n / e) +log10(2 * pi * n) /2.0));
/// lcm(a,b)=a/gcd(a,b)*b (handle overflow)

bool sortinrev1(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second>b.second);
    else return (a.first > b.first);
}
bool sortinrev2(const pair<int,int>&a,const pair<int,int>&b)
{
    //return (a.first > b.first);
    if(a.first==b.first)return (a.second<b.second);
    else return (a.first > b.first);
}
int fx[]={1,-1,0,0};
int fy[]={0,0,1,-1};


int main()
{
    /*int t,n,x;
    cin>>n>>x>>t;
    if(n%x==0){
        cout<<(n/x)*t<<endl;
    }
    else cout<<((n/x)+1)*t<<endl;*/
    string str;
    ll sum=0;
    cin>>str;
    for(int i=0;i<str.size();i++){
        sum+=str[i]-'0';
    }
    if(sum%9LL==0)cout<<"Yes\n";
    else cout<<"No\n";
}



Measured memory_bytes: 3732
function Main(input) {
  input = input.split("\n");
  var length = parseInt(input[0]);
  input.shift();
  for(var i = 0; i < input.length; i++){
    input[i] = parseInt(input[i]);
  }
  var tmpInput = JSON.parse(JSON.stringify(input));
  tmpInput.sort(function(a,b){
  	return b - a;
  });
  var max1 = tmpInput[0];
  var max2 = tmpInput[1];
  var max1Index = input.indexOf(max1);
  //console.log("max1:" + max1Index);
  if(max2 == max1){
     //最大値が2回以上出てきている場合は、最大値をN回出力して終わり
    var output = "";
    for(var i = 0; i < length; i++){
      if(i == 0){
         output += max1;
      }else{
         output += "\n" + max1;
      }
    }
    console.log(output);
    return;
  }else{
    var output = "";
    for(var i = 0; i < length; i++){
      if(i != max1Index){
      	console.log(max1);
      }else{
        console.log(max2);
      }
    }
  }
  
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));


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

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

//------------------------------------------------
int main(){
  int n,d,w,answer;
  cin>>n>>d;
  w=0;
  answer=0;
  rep(i,0,n){
    w+=2*d+1;
    answer+=1;
    if(w>=n) break;
  }


  cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
 
using namespace std;
 
#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
typedef long long ll;
 
const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;
 
void solve() {
  string S;
  int Q;
  cin >> S >> Q;
  string head = "";
  string tail = "";
  int R = 0;
  for (int i = 0; i < Q; i++) {
    int T;
    cin >> T;
    if (T == 1) {
      R++;
      swap(head, tail);
    } else {
      int F;
      char C;
      cin >> F >> C;
      if (F == 1) {
        head += C;
      } else {
        tail += C;
      }
    }
  }
  reverse(all(head));
  if (R % 2 == 1) {
    reverse(all(S));
  }
  cout << head;
  cout << S;
  cout << tail << endl;
}
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);
 
  solve();
 
  return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
ll start;
ll ar[N], vis[N], nod;
vector<ll>graph[N], cyc;
void dfs(ll src)
{
    if(vis[src]){
        start = src;
        return;
    }
    vis[src] = 1;
    nod++;
    //cout << src << endl;
    for(auto adj: graph[src]){
        dfs(adj);
        if(start) return;
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    ll n, k, i;
    cin >> n >> k;
    for(i = 1; i <= n; i++){
        cin >> ar[i];
    }
    ll v = ar[1];
    if(k > n){
        graph[1].eb(v);
        for(i = 2; i <= n; i++){
            graph[v].eb(ar[v]);
            v = ar[v];
        }
        //graph[v].eb(ar[1]);
        dfs(1);
        memset(vis, 0, sizeof(vis));
            //cyc.eb(1);
            v = start;
            while(1){
                cyc.eb(v);
                vis[v] = 1;
                v = ar[v];
                if(vis[v]){
                    break;
                }
            }
            ll len = cyc.size();
            nod = nod-len;
            //k--;
            //if(start == ar[1]) nod = 0;
            //cout << len << " " << start << " " << nod << endl;
            k = (k-nod)%len;
            cout << cyc[k] << endl;
            return 0;
    }

    v = 1;
    while(k--){
        v = ar[v];
    }
    cout << v << endl;
}

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

using namespace std;


int MapData[11][11];
int Result[11];

void calculation(int maxNode) {
	for (int i = 0; i < maxNode; i++) {
		for (int j = 0; j < maxNode; j++) {
			Result[i] += MapData[i][j];
		}
	}
}

void findAllRoad(int maxNode) {
	for (int i = 0; i < maxNode; i++) {
		for (int j = 0; j < maxNode; j++) {
			for (int k = 0; k < maxNode; k++) {
				MapData[j][k] = min(MapData[j][k], MapData[j][i] + MapData[i][k]);
				if (j == k) {
					MapData[j][k] = 0;
				}
			}
		}
	}
}

void init() {
	for (int i = 0; i < 11; i++) {
		for (int j = 0; j < 11; j++) {
			MapData[i][j] = 9999;
		}
	}
	memset(Result, 0, sizeof(Result));
}

int main() {
	int n, a, b, c, minTotal, minNum, cnt;

	while (cin >> n, n) {
		init();
		cnt = -1;
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			MapData[a][b] = c;
			MapData[b][a] = c;
			cnt = max(cnt, a);
			cnt = max(cnt, b);
		}
		findAllRoad(cnt+1);
		calculation(cnt+1);

		minNum = -1;
		minTotal = INT_MAX;
		for (int i = 0; i < 11; i++) {
			if (Result[i] != 0 && Result[i] < minTotal) {
				minTotal = Result[i];
				minNum = i;
			}
		}
		cout << minNum << " " << minTotal << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include <cstring>
#include <cstdio>
using namespace std;
char ch[15];
int len;
long long ans;
void dfs(long long sum,long long cnt,int p){
	if(p==len){
		ans+=sum+cnt;
		return;
	}
	if(cnt!=0)dfs(sum+cnt,ch[p]-'0',p+1);
	dfs(sum,cnt*10+ch[p]-'0',p+1);
}
int main(){
	scanf("%s",ch);
	len=strlen(ch);
	dfs(0,0,0);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1672
def main():

    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    ex = [0]
    for x in p:
        ex.append(ex[-1] + (x+1)/2)

    ans = 0
    for i in range(k, n+1):
        ans = max(ans, ex[i] - ex[i-k])

    print(ans)

main()

Measured memory_bytes: 31992
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF (1 << 30) - 1
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
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;
}
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

string s;
ll k, ans, cnt;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> k;
  rep(i, 0, s.size()) {
    if (s[i] != '1' && i < k) {
      ans = s[i] - '0';
      break;
    } else
      ans = 1;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int a[10];
	
	int tmp = N;
	int SN = 0;
	for (int i = 0; i < 10; i++) {
		a[i] = tmp % 10;
		SN += a[i];
		tmp /= 10;
	}
	if (N % SN == 0)
		cout << "Yes"<< endl;
	else 
		cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
flag = False
if S[0] == "A":
    count = 0
    for i,j in enumerate(S[2:-1]):
        if j == "C":
            count+=1
            ind = i+2
    if count == 1:
        tmp = S[1:ind]+S[ind+1:]
        if tmp == tmp.lower():
            flag = True
            
if flag:
    print("AC")
else:
    print("WA")

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

using namespace std;

#define int long long 
#define F first 
#define S second 
#define pii pair<int,int> 
#define mpr make_pair

typedef long long ll;

const int maxn = 2e5+10;
const int mod = 1e9+7;
const ll inf = 1e18;

int n, m;
vector<int> g[maxn];

pii mx = {-inf,-inf};
void dfs(int v, int p = -1, int h = 0)
{
        if(h > mx.S) mx = {v,h};
        for(auto u : g[v])
                if(u != p)
                        dfs(u,v,h+1);
}

signed main()
{
        cin>> n;
        for(int i = 1, u, v; i < n; i++)
        {
                cin>> u >> v;
                g[u].push_back(v);
                g[v].push_back(u);
        }

        dfs(1);
        dfs(mx.F);
        if(mx.S % 3 == 1) cout<<"Second";
        else cout<<"First";
}















Measured memory_bytes: 23876
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n, su=0, i;
  cin >> n;
  int s[n];
  for(i=0; i<n; i++){
    cin >> s[i];
    su+=s[i];
  }
  sort(s, s+n);
  if(su%10!=0){
    cout << su << endl;
    return 0;
  }
  for(i=0; i<n; i++)
    if(s[i]%10!=0){
      cout << su-s[i] << endl;
      return 0;
    }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
from copy import deepcopy

n = int(input().strip())
a = list(input().split())
b = deepcopy(a)
counts = {}
tmp = b[0]
for elem in b:
    if elem in counts:
        counts[elem] += 1
    else:
        counts[elem] = 1
    if tmp != elem:
        tmp = elem
c = deepcopy(counts)
for k, v in counts.items():
    c[k] = v * (v - 1) // 2
su = sum(c.values())
for elem in a:
    print(su - c[elem] + ((counts[elem] - 1) * (counts[elem] - 2) // 2))


Measured memory_bytes: 124288
#include <iostream>
using namespace std;
bool k(int n)
{
    int sum=0,j;
    j=n;
    while(n)
    {
        sum=sum*10+n%10;
        n=n/10;
    }
    if(j==sum)
    return 1;
    else 
    return 0;
}
int count(int a,int b)
{
    int c=0;
    for(int i=a;i<=b;i++)
    {
       bool  p=k(i);
       if(p)
       c++;
    }
    return c;
}

int main() {
	// your code goes here
	int a,b,c;
	cin>>a>>b;
    c=count(a,b);
    cout<<c<<endl;
	return 0;
}


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

//SUN,MON,TUE,WED,THU,FRI,SAT
int main()
{
	string s;
	cin >> s;

	int ans;
	if(s == "SUN") ans = 7;
	if(s == "MON") ans = 6;
	if(s == "TUE") ans = 5;
	if(s == "WED") ans = 4;
	if(s == "THU") ans = 3;
	if(s == "FRI") ans = 2;
	if(s == "SAT") ans = 1;

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

Measured memory_bytes: 256
N,Q=map(int,input().split())
S=input()
a=[0]*N
for i in range(N-1):
  a[i+1]=a[i]+(1 if S[i:i+2]=="AC" else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(a[r-1]-a[l-1])


Measured memory_bytes: 9412
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a,b;
    string s;
    cin>>a>>b>>s;
    bool c;
    for (int i=0; i<s.size(); i++)
    {
        if (i==a) i++;
        c=(s[i]=='0' || s[i]=='1' || s[i]=='2' || s[i]=='3' || s[i]=='4' || s[i]=='5' || s[i]=='6' || s[i]=='7' || s[i]=='8' || s[i]=='9');
        if (c==false) break;
    }
    if (s[a]=='-' && c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

int main() {
    int dp[40];
    for (int i = 0; i < 40; i++) dp[i] = 0;
    dp[0] = 1;

    for (int i = 0; i < 30; i++) {
        dp[i + 1] += dp[i];
        dp[i + 2] += dp[i];
        dp[i + 3] += dp[i];
    }
    
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int cnt = dp[n];
        cout << (cnt + 10 * 365 - 1) / (10 * 365) << endl;
    }
    return 0;
}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
vll primeFactors(ll n)  
{   vll c; ll k=0;
    while (n % 2 == 0)  
    {   if(k==0)
        {c.pb(2);k++;}
        n = n/2;  
    }  
  
   
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {   ll x=0;
        while (n % i == 0)  
        {  if(x==0)
            {x++;c.pb(i);}
            n = n/i;  
        }  
       
    }  
  
     
    if (n > 2)  
        c.pb(n);
        return c;  
}  


int  main(){
  fastio;
  
  ll n,k;
  cin>>n>>k;
  vll ans1,ans2;
  ans1.pb(1);
  ans2.pb(1);
ans1=primeFactors(n);
ans2=primeFactors(k);
  ll i=0,j=0,ans=0;
  while(i<(ll)ans1.size()&&j<(ll)ans2.size())
  {
    if(ans1[i]<ans2[j])
        i++;
    else if(ans1[i]>ans2[j])
        j++;
    else
    {  ans++;
        i++;
        j++;
    }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int main(void) {
    int n, m;
    while (1) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        int sumn = 0, summ = 0;
        int t[n], h[m];
        for (int i = 0; i < n; i++) {
            cin >> t[i];
            sumn += t[i];
        }
        for (int i = 0; i < m; i++) {
            cin >> h[i];
            summ += h[i];
        }
        bool flag = false;
        int anst = INF, ansh = INF;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (sumn-t[i]+h[j] == summ-h[j]+t[i]) {
                    flag = true;
                    if (anst+ansh > h[j] + t[i]) {
                        anst = t[i], ansh = h[j];
                    }
                }
            }
        }
        if (!flag) cout << -1 << endl;
        else cout << anst << " " << ansh << endl;
    }
    return 0;
}

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

using namespace std;
using i64 = long long;
using f64 = double;

#define FOR(i, s, n) for (size_t i = (s); i < (size_t)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

template <typename T, typename U>
inline bool chmax(T &a, U b)
{
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b)
{
  return a > b ? (a = b, true) : false;
}

int main()
{
  i64 x;
  cin >> x;
  auto count = 0;
  for (i64 i = 100; i < x; i *= 1.01)
  {
    ++count;
  }

  cout << count;
  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
int a[310][310],n,m,b[310],c[310];
bool flag;
inline void clear(int p,int x){
	if(!flag)return;b[p]=-1;
	for(int i=1;i<=n;i++){
		int cnt=0;
		while(c[i]<=m&&b[a[i][c[i]]]==-1)c[i]++,cnt++;
		if(cnt==0)continue;
		if(c[i]>m){flag=0;return;}
		b[a[i][c[i]]]++;
		if(b[a[i][c[i]]]>x)clear(a[i][c[i]],x);
	}
}
inline bool check(int x){
	memset(b,0,sizeof b);
	flag=1;
	for(int i=1;i<=n;i++)c[i]=1;
	for(int i=1;i<=n;i++){
		while(c[i]<=m&&b[a[i][c[i]]]==-1)c[i]++;
		if(c[i]>m)return 0;
		if(c[i]==1)b[a[i][c[i]]]++;
		if(b[a[i][c[i]]]>x)clear(a[i][c[i]],x);
	}
	return flag;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)a[i][j]=read();
	int l=0,r=n,ans;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d",ans);
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    long long ans = 0;
    for(int s=0; s < (1 << (S.size()-1)); s++){
        string now = "";
        now += S[0];
        for(int i=0; i<S.size()-1; i++){
            // S[i] と S[i+1] の間に + を入れるか
            if(s & (1<<i)) now += "+";
            now += S[i+1];
        }
        long long sum=0;
        int pos=0;
        while(now.find("+", pos) != string::npos){
            int nextpos = now.find("+", pos);
            sum += stoll( now.substr(pos, nextpos - pos) );
            pos = nextpos+1;
        }
        sum += stoll( now.substr(pos) );
        ans += sum;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
check=sum([a<0 for a in A]) #the number of negative in A
if check%2==0:
    print(sum([abs(a) for a in A]))
else:
    dust=min([abs(a) for a in A])
    print(sum([abs(a) for a in A])-2*dust)

Measured memory_bytes: 14412
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N, W := ReadInt(), ReadInt()

	ws := make([]int, N+1)
	vs := make([]int, N+1)

	for i := 1; i <= N; i++ {
		ws[i], vs[i] = ReadInt(), ReadInt()
	}

	prev := make([]int, W+1)
	for i := 1; i <= N; i++ {
		next := make([]int, W+1)
		for w := 1; w <= W; w++ {
			next[w] = prev[w]
			if w-ws[i] >= 0 {
				next[w] = Max(next[w], prev[w-ws[i]]+vs[i])
			}

		}
		prev = next
	}
	fmt.Println(prev[W])
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 6900
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
#define REP(i, x, y) for(ll i = x; i < y; i++)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

struct unionFind {
    vector<int> data;
    unionFind(int size) : data(size, -1) {}
    
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if(data[y] < data[x]) {
                swap(x, y);
            }
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int root(int x) {
        return (data[x] < 0) ? x : data[x] = root(data[x]);
    }

    int rank(int x) {
        return -data[root(x)];
    }
};

ll colors;
//cost,from,toの順
vector<tiii> T;
vector<tiii> Krusans;

ll Kruskal(int n) {
    sort(T.begin(), T.end());
    ll ans = 0;
    ll num = 0;
    unionFind u(colors);
    int size = T.size();
    for (int i = 0; i < size; i++) {
        int cost = get<0>(T[i]);
        int from = get<1>(T[i]);
        int to = get<2>(T[i]);
        if (u.root(from) != u.root(to)) {
            u.unite(from, to);
            ans += cost;
            num++;
            tiii t = make_tuple(cost, from, to);
            Krusans.push_back(t);
        }
        if (num == n - 1) {
            break;
        }
    }
    if (num == n - 1) {
        return ans;
    } else {
        return llmax;
    }
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    ll c[N];
    ll cl = K;
    REP(i, 0, N) {
        cin >> c[i];
        if (c[i] == 0) {
            c[i] = cl;
            cl++;
        } else {
            c[i]--;
        }
    }
    colors = cl;
    REP(i, 0, M) {
        ll a, b, w;
        cin >> a >> b >> w;
        T.push_back(make_tuple(w, c[a - 1], c[b - 1]));
    }
    ll ans = Kruskal(K);
    if (ans == llmax) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


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

int main(void) {
	using namespace std;
	int N;
	vector<pair<int, int>> ABC;
	int t;
	cin >> N;
	for(int i = 0; i < N; ++i) {
		cin >> t;
		ABC.push_back(make_pair(t, 2));
	}
	for(int i = 0; i < N; ++i) {
		cin >> t;
		ABC.push_back(make_pair(t, 1));
	}
	for(int i = 0; i < N; ++i) {
		cin >> t;
		ABC.push_back(make_pair(t, 0));
	}
	sort(ABC.begin(), ABC.end());
	long long numA = 0;
	long long numAB = 0;
	long long numABC = 0;
	for(int i = 0; i < ABC.size(); ++i) {
		switch(ABC[i].second) {
			case 2:
				++numA;
				break;
			case 1:
				numAB += numA;
				break;
			case 0:
				numABC += numAB;
				break;
		}
	}
	cout << numABC << '\n';
	return 0;
}



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

 using namespace std;

 int main() {
   int N, L, i;
   cin >> N >> L;

   vector<string> S(N);
   for (i = 0; i < N; i++) cin >> S.at(i);

   sort(S.begin(), S.end());

   for (i = 0; i < N; i++) cout << S.at(i);
   cout << endl;
 }


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

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int, greater<int>> m;
    for (int i=0, ai; i<n; i++) {
        cin >> ai;
        m[ai]++;
    }
    int top = m.begin()->first, cnt=0;
    for (int i=top; i>=(top+1)/2; i--) {
        if ((i > top/2 && m[i] < 2) || (i == (top+1)/2 && m[i] > 2) || (i == top/2 && m[i] != 1)) {
            cnt = -1;
            break;
        }
        cnt += m[i];
    }
    cout << (cnt == n ? "Possible" : "Impossible") << '\n';
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
  long long ans = 1000000000000000;
  for(int i = 0; i <= 100000; ++i) {
    int sum = 2 * c * i + max(0, x-i) * a + max(0, y-i) * b;
    ans = min(ans, (ll)sum);
  }
  cout << ans << endl;

  return 0;
}

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

#define sz(a) (int)a.size()
#define re return
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define gr greater <int>

#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")

using namespace std;

typedef long long ll;
typedef string str;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;

///!!!<3<3<3<3<3!!!
void ProdamGaraje () {
   int n, ans = 0;
   cin >> n;
   for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= n; ++j)
         for (int k = 1; k <= n; ++k)
            ans += __gcd(i, __gcd(j, k));
   cout << ans;
}
///!!!<3<3<3<3<3!!!
int main () {
   //freopen ("input.txt", "r", stdin);
   //freopen ("output.txt", "w", stdout);
   ios::sync_with_stdio(0);
   cin.tie(0); cout.tie(0);
   int tt = 1;
   //cin >> tt;
   while (tt--)
      ProdamGaraje ();
}
///GOOOOOOSE!!!!
/*
     ▄▀▀▀▄
▄███▀░0░░░▌
    ▌░░░░░▐
    ▌░░░░░▐
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
     ▌▌ ▌▌
   ▄▄▌▌▄▌▌        */


Measured memory_bytes: 3648
from collections import defaultdict

def main():
    N = int(input())
    A = [[0 for _ in range(N - 1)] for _ in range(N)]

    for i in range(N):
        A[i] = [int(x) - 1 for x in input().split()]

    day = 0
    # 選手毎に明日の試合の有る/無しを1,0で管理
    M = defaultdict(int)
    # 全選手を試合有り(1)で初期化
    for i in range(N):
        M[i] += 1

    # 選手毎の次の対戦相手リスト
    W = [0] * N

    while M:
        day += 1
        # 選手毎に次の対戦相手のリストを作成
        for m in M:
            # 全試合が終った選手は-1にする
            W[m] = A[m].pop(0) if A[m] else -1

        # 明日の試合一覧を初期化
        _M = defaultdict(int)
        for m in M:
            # 選手が次の対戦相手と相思相愛なら
            if W[m] >= 0 and W[W[m]] == m:
                # 両方を明日は試合有りにする
                _M[m] += 1
                _M[W[m]] += 1

        M = _M

    if sum(W) != -N:
        print(-1)
    else:
        print(day - 1)
            

main()

Measured memory_bytes: 35948
//Code by : Abhishek Tiwari
//codechef.com/users/devil_within || hackerearth.com/@devil_within
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pii pair<int,int> 
#define ff first
#define ss second 
#define mod 1000000007
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
using namespace std;

/*******************************************************************************************/
/*******************************************************************************************/
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { 
    os<<"["; for(int i=0;i<v.size()-1; ++i)os<<v[i]<<", ";os<<v[v.size()-1]<<"]\n"; return os; 
} 
template <typename T> ostream& operator<<(ostream& os, const set<T>& v) { 
    os<<"{"; for(auto it : v) { os<<it; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const map<T, S>& v) { 
    os<<"{"; for(auto it:v){ os<<"("<<it.first<<" : "<<it.second<<")"; if(it!=*v.rbegin()) os<<", "; } os<<"}\n"; 
    return os; 
}
template <typename T, typename S> ostream& operator<<(ostream& os, const pair<T, S>& v) { 
    os<<"("; os<<v.first<<", "<< v.second<<")"; 
    return os; 
} 
/*******************************************************************************************/
/*******************************************************************************************/
int fpow(int x, int y, int p); 


int32_t main()  
{
#ifndef ONLINE_JUDGE
//freopen("input.txt" , "r" , stdin);freopen("output.txt" , "w" , stdout);freopen("error.txt" , "w" , stderr);
#endif
fio;
int tcases = 1;
//cin>>testcases;
for(int tcase = 1 ; tcase <= tcases ; ++tcase)
{
    int n , k; 
    cin>>n>>k;
    vector<int> a(n , mod);
    FOR(i , 0 , n) cin>>a[i];
    vector<int> dp(n , mod);
    dp[0] = 0;
    for(int i = 0 ; i < n;++i)
    {
        for(int j = i+1; j< min(i+k+1 , n); ++j)
        {
            dp[j] = min( dp[j] , abs(a[j]- a[i]) + dp[i]);
        }
    }    
    cout<<dp[n-1]<<endl;
    
    //cout<<"Case #"<<tcase<<": ";
}
return 0;
}



//Functions 

int fpow(int x, int y, int p) { 
    int res = 1; 
   x = x % p;  
   while (y > 0) { 
     if (y & 1) 
        res = (res * x) % p; 
     y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, ans = -9223372036854775807;
int main(){
    cin >> a >> b >> c >> d;
    ans = max(ans, b * d);
    ans = max(ans, b * c);
    ans = max(ans, a * d);
    ans = max(ans, a * c);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int N, M; cin >> N >> M;
    int res[N] = { 0 };
    for (int i = 0; i < M; i++)
    {
        int ai, bi; cin >> ai >> bi;
        res[ai-1]++;
        res[bi-1]++;
    }
    for (int i = 0; i < N; i++)
    {
        cout << res[i] << endl;
    }
	return 0;
}

Measured memory_bytes: 256