akhauriyash/Code-Regression huggingface dataset:
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    for0(i,n) for(int i=0;i<n;i++)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    Sort(s) sort(s.begin(),s.end())
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long int
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int Pow (int a,int b)
{
    return powl(a,5)-powl(b,5);
}
int main()
{
MP;
	
    long n;
    cin>>n;
    for(int i=-120;i<120;i++){
        for(int j=-120;j<120;j++){
            if(n==Pow(i,j)){
                cout<<i<<" "<<j;
                End;
            }
        }
    }
    
End;
}


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

int main() {
  string s;
  cin >> s;
  bool k=0;
  string t="";
  for(int i=0; i<s.size(); i++) {
    if(!k && s[i]=='A') {
      t+=s[i];
      k=1;
    }
    if(k && s[i]=='Z') {
      t+=s[i];
      k=0;
    }
  }
  if(t.size() && t[t.size()-1]=='A') t=t.substr(0,t.size()-1);
  if(t.size()) cout << t << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <utility>
using namespace std;


int main(void){
	int x,y,n,k;
	char c;
	cin >> n >> k;
	int k2 = 2*k;
	vector<vector<int>> mas;
	mas.resize(k*6+1);

	for(int i = 0; i < k*6; ++i){
		mas[i].resize(k*6);
		for(int j = 0; j < k*6; ++j){
			mas[i][j] = 0;
		}
	}

	for(int i = 0; i < n; ++i){
		cin >> x >> y >> c;
		if(c == 'W')	y += k;
		x %= k2;
		y %= k2;
		for(int j = 0; j < 4; ++j){
			for(int l = 0; l < 4; ++l){
				if((j+l)%2==1)continue;
				mas[x+j*k][y+l*k]++;
				mas[x+j*k+k][y+l*k]--;
				mas[x+j*k][y+l*k+k]--;
				mas[x+j*k+k][y+l*k+k]++;
			}
		}
	}

	for(int i = 0.; i < k*6; ++i){
		for(int j = 1; j < k*6; ++j){
			mas[i][j] += mas[i][j-1];
		}
	}
	for(int i = 1.; i < k*6; ++i){
		for(int j = 0; j < k*6; ++j){
			mas[i][j] += mas[i-1][j];
		}
	}
	int ans = 0;
	for(int i = 1.; i < k*6; ++i){
		for(int j = 0; j < k*6; ++j){
			ans = max(ans, mas[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

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


int main()
{
  int x, y, z;
  cin >> x >> y >> z;
  int res = 0;
  int tmp = x;
  x -= z;
  for (int i = 0; i <= tmp + z; i++)
  {
    x -= (y + z);
    res++;
    if(x < y + z)
    {
      cout << res << endl;
      return 0;
    }
    // cout << i << endl;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    s = input().strip()
    mod = [0] * 2019

    tmp = 0
    ten = 10
    mod[tmp] += 1
    for i in range(len(s)-1, -1, -1):
        tmp = (tmp + ten * int(s[i])) % 2019
        ten = (ten * 10) % 2019
        mod[tmp] += 1
    ans = 0
    for i in range(2019):
        if mod[i] > 1:
            ans += (mod[i] * (mod[i] - 1)) // 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1LL << 30;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;


    cout << ((s.find("YAKI")==0)?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


p,q,r = map(int, input().split())

print(min(p+q, p+r, q+r))




Measured memory_bytes: 9108
#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;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e7 + 5, MOD = 998244353, SIZE = 2e7;//, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, m, i, j, k, z;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n >> m >> k)
	vll a(n + 1), b(m + 1);
	FOR(i, 1, n + 1)
	{
		in(a[i])
		a[i] += a[i - 1];
	}
	FOR(i, 1, m + 1)
	{
		in(b[i])
		b[i] += b[i - 1];
	}
	z = 0, i = 0, j = m;
	while (a[i] <= k && i <= n)
	{
		while (b[j] > k - a[i])
			--j;
		z = max(z, i + j);
		++i;
	}
	out(z)
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
    //ts
    solve();
    return 0;
}


Measured memory_bytes: 6332
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  multiset<int> S;
  S.insert(-1);
  S.insert(1e9+1);
  for(int i = 0; i < N; ++i){
    auto itr = (--S.lower_bound(A[i]));
    // cerr << A[i] << " " << *itr << endl;
    if(*itr != -1){
      S.erase(itr);
    }
    S.insert(A[i]);
  }
  // for(auto s : S){
  //   cerr << s << endl;
  // }
  cout << S.size()-2 << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    string S;
    cin >> S;

    bool c_found = false;
    for(char c: S){
        if(c_found){
            if(c == 'F'){
                cout << "Yes" << endl;
                return 0;
            }
        }else{
            if(c == 'C'){
                c_found = true;
            }
        }
    }
    cout << "No" << 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>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 60) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

class DK {
public:
	struct edge {
		int to;
		int cost;
	};

	int prev[200010];
	ll d[200010];
	int N;
	vector<edge> G[200010];//各頂点からの辺

	void dijkstra(int start) {
		fill(d, d + 200010, INF);
		d[start] = 0;
		fill(prev, prev + 200010, -1);

		priority_queue<P, vector<P>, greater<P>> que;
		que.push(P(0, start));

		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)continue;
			for (int i = 0; i < G[v].size(); i++) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					prev[e.to] = v;
					que.push(P(d[e.to], e.to));
				}
			}
		}
	}

	vector<int> get_path(int goal) {
		vector<int> path;
		for (int t = goal; t != -1; t = prev[t]) {
			path.push_back(t);
		}//このままでは逆順なのでひっくり返す
		reverse(ALL(path));
		return path;
	}
};

DK dk;

int n, m;

int main() {
	cin >> n >> m;
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dk.G[a].push_back({ b,1 });
		dk.G[b].push_back({ a,1 });
	}
	dk.dijkstra(0);
	if (dk.d[n - 1] <= 2)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 17256
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 5e5;

int n;

char s[MAXN + 5];
int a[MAXN + 5];

inline void input()
{
	scanf("%s", s), n = strlen(s) - 1;
	for(int i = 0; i <= n; ++i) a[i] = s[n - i] - '0';
}

inline void solve()
{
	int ans = 0, t = n;
	while(n >= 0)
	{
		++ans;

		int mx = 0;
		while(t >= 0 && a[t] >= mx) chkmax(mx, a[t--]);
		if(t < 0) break;

		++t;
		while(n >= t && a[n] < a[t]) a[n--] = 0;
		a[n--] = 0;

		++a[0];
		for(int i = 0; i <= n && a[i] >= 10; ++i)
		{
			++a[i + 1], a[i] %= 10;
			chkmax(t, i + 1);
		}
		while(a[n + 1] > 0) ++n;
		while(n >= 0 && a[n] == 0) --n;
	}
	printf("%d\n", ans);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 2688
N, W = gets.split.map(&:to_i)
items = (1..N).map { gets.split.map(&:to_i) }.sort_by {|v, w| - v.to_f / w }

def search(items, i, v_sum, w_sum, limit, best)
  return v_sum if i >= items.size
  return best if upper_bound(items, i, v_sum, w_sum, limit) <= best
  v, w = items[i]
  if (w_sum + w <= limit)
    best = [search(items, i + 1, v_sum + v, w_sum + w, limit, best), best].max
  end
  return [search(items, i + 1, v_sum, w_sum, limit, best), best].max
end

def upper_bound(items, i, v_sum, w_sum, limit)
  items[i..-1].each do |v, w|
    if w_sum + w <= limit
      w_sum += w
      v_sum += v
    else
      return v_sum + v.to_f * (limit - w_sum) / w
    end
  end
  v_sum
end

p search(items, 0, 0, 0, W, -Float::INFINITY)


Measured memory_bytes: 8872
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    int ans;
    ans = 0;
    for(int i=0; i<n; i++){
        cin >> vec[i];
        vec[i];
    }
    for(int i=0; i<n; i++){
        int tmp1 = vec[vec[i]-1];
        int tmp2 = i+1;
        if(tmp1 == tmp2){
            ans++;
        }
    }
    cout << ans/2 << endl;
}



Measured memory_bytes: 3776
package main

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

var sc = bufio.NewScanner((os.Stdin))

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	l := nextLine()
	i, e := strconv.Atoi(l)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, a := nextInt(), []int{}
	for i := 0; i < N; i++ {
		a = append(a, nextInt())
	}

	fmt.Printf("%d\n", ABC088B(a))
}

// ABC088B ...
func ABC088B(a []int) int {
	res := 0

	sort.Ints(a)
	for i := len(a) - 1; i >= 0; i -= 2 {
		res += a[i]
		if i != 0 {
			res -= a[i-1]
		}
	}

	return res
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define int 	long long int

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

	int sum=0,temp=n;

	while(temp){
		sum+=temp%10;
		temp=temp/10;
	}

	if(n%sum==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}




Measured memory_bytes: 3592
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
int a[105], b[105];

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<<1)+(x<<3)+ch-'0';
    return x*f;
}

void check(bool flag)
	{if (!flag) {puts("Impossible"); exit(0);}}

int main()
{
    int n=read();
    for (int i=1; i<=n; i++) 
		a[i]=read(), check(a[i]<=n), b[a[i]]++;
    sort(a+1, a+n+1); int d=a[n];
    if (d&1)
    {
    	int m=(d>>1)+1;
		check(a[1]==m); check(b[m]==2);
		for (int i=m+1; i<=d; i++) check(b[i]>=2);
		puts("Possible");
	}
	else
	{
		int m=d>>1;
		check(a[1]==m); check(b[m]==1);
		for (int i=m+1; i<=d; i++) check(b[i]>=2);
		puts("Possible");
	}
	return 0;
}


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

int main(){
	int a,b,c,s;
	while(cin>>a>>b>>c){
		int cnt=0;
		for(int i=1;i<=10;i++){
			if(i!=a&&i!=b&&i!=c&&a+b+i<=20)cnt++;
		}
		cout<<(2*cnt>=7?"YES":"NO")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
/****************************************

                 AOJ 0001

****************************************/

#include<stdio.h>

#define  NUM  10

int main(void)
{
  int i, j;
  int tall[NUM] = { 0 };

  for(i = 0; i < NUM; i++)
	scanf("%d", &tall[i]);

  for (i = 0; i < NUM-1; i++) {
	for (j = i+1; j < NUM; j++) {
	  if (tall[i] < tall[j]) {
		int tmp = tall[i];
		tall[i] = tall[j];
		tall[j] = tmp;
	  }
	}
  }

  for(i = 0; i < 3; i++)
	printf("%d\n", tall[i]);

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>

class capitalize {
public:
    capitalize();
    bool Run();

private:
    
    bool Input();
    bool Convert();
    void Show() const;

private:
    std::string m_lower;    // Lower case
    std::string m_upper;    // Upper case
};

capitalize::capitalize() : m_lower(""), m_upper("")
{

}

bool capitalize::Run()
{
    bool status = false;

    status = Input();
    if (!status) {
        return false;
    }
    status = Convert();
    if (!status) {
        return false;
    }
    Show();

    return true;
}

bool capitalize::Input()
{
    std::getline(std::cin, m_lower);
    if (0 == m_lower.size()) {
        return false;
    }
    return true;
}

bool capitalize::Convert()
{
    m_upper.resize(m_lower.size());
    std::transform(m_lower.begin(), m_lower.end(), m_upper.begin(), toupper);

    return true;
}

void capitalize::Show() const
{
    std::cout << m_upper << std::endl;
}

int main()
{
    capitalize test;
    test.Run();
}

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

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

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

	int N; cin >> N;

	cout << (N/2)*((N+1)/2) << endl;

	return 0;

}


Measured memory_bytes: 256
import java.util.*;

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

		int num = r * 100 + g * 10 + b;
		System.out.println(num % 4 == 0 ? "YES" : "NO");
	}
}

Measured memory_bytes: 20948
n, m  = map(int, input().split())
a = list(map(int, input().split()))

#総投票数を取得
total = 0 
for i in range(n):
    total += a[i]

deadline = total / (4*m)

#M個選べるのか判定
cnt = 0
for i in range(n):
    if a[i] >= deadline:
        cnt += 1

if cnt >= m:
    print("Yes")
else:
    print("No")


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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto&& i : a) {
		cin >> i;
	}
	sort(begin(a), end(a));
	if (n % 2) {
		long long ans1 = 0, ans2 = 0;
		swap(a[0], a[n / 2 - 1]);
		for (int i = 0; i < n / 2; i++) {
			ans1 += abs(a[i] - a[n / 2 + 1 + i]) + abs(a[i + 1] - a[n / 2 + 1 + i]);
		}
		swap(a[0], a[n / 2 - 1]);

		if (n / 2 + 1 < n) {
			swap(a[n / 2 + 1], a[n - 1]);
		}

		for (int i = 0; i < n / 2; i++) {
			ans2 += abs(a[i] - a[n / 2 + i]) + abs(a[i] - a[n / 2 + 1 + i]);
		}
		cout << max(ans1, ans2) << "\n";
	}
	else {
		swap(a[0], a[n / 2 - 1]);
		swap(a[n / 2], a[n - 1]);
		long long ans = abs(a[0] - a[n / 2]);
		for (int i = 1; i < n / 2; i++) {
			ans += abs(a[n / 2 + i - 1] - a[i]) + abs(a[n / 2 + i] - a[i]);
		}
		cout << ans << "\n";
	}
}


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


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

int N;
vector<int> x, y, h;

int main() {
    scanf("%d", &N);
    x.resize(N), y.resize(N), h.resize(N);
    rep(i,N) scanf("%d%d%d", &x[i], &y[i], &h[i]);

int index;
rep(i,N) {
    if (h[i] > 0) {
        index = i;
        break;
    }
}

int ansx, ansy, ansh;
int flag;
rep(i,101){
    rep(j,101) {
        flag = 1;
        int temph = h[index] + abs(i - x[index]) + abs(j - y[index]);
        rep(k, N) {
            int temphk = max(temph - abs(i - x[k]) - abs(j - y[k]), 0);
            if (flag && temphk != h[k]) flag = 0;
        }
        if (flag) {
            ansx = i; ansy = j; ansh = temph;
            break;
        }
    }
    if (flag) break;
}

    printf("%d %d %d\n", ansx, ansy, ansh);
    return 0;
    
}

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

const long long MOD = 1000000007;
const long long MAX = 2000000;

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

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
int koushin(int c[26],int last[26],int used,int d,int kasan,int sum){
    int tm=last[used];
    last[used]=d;
    int sum_m=sum;
    for(int i=0;i<26;i++){
        sum_m-=c[i]*(d-last[i]);
    }
    last[used]=tm;
    sum_m+=kasan;
    return sum_m;
}

int main()
{
    int D;
    int c[26];
    int last[26];
    for(int i=0;i<26;i++){
        last[i]=0;
    }
    cin>>D;
    pair<int,int>s[D][26];
    for(int i=0;i<26;i++){
        cin>>c[i];
    }
    for(int i=0;i<D;i++){
        for(int j=0;j<26;j++){
            int tmp;
            cin>>tmp;
            s[i][j]=make_pair(tmp,j+1);
        }
    }
    int sum=0;
    vector<int>anss;
    random_device seed_gen;
    mt19937 engine(seed_gen());
    int tmpp_sum;
    for(int i=0;i<D;i++){
        clock_t start = clock(); 
        clock_t end = clock(); 
        int y=engine()%26;
        if(y==0){
            y=26;
        }
        int mae=last[y];
        int tmp_sum=koushin(c,last,y,i+1,s[D][y].first,sum);
        bool first=true;
        int number=y;
        while(end-start<1000){
        int x= engine()%26;
        if(x==0){
            x=26;
        }
        int maee=last[x];
        tmpp_sum=koushin(c,last,x,i+1,s[i][x].first,sum);
        if(first){
            if(tmp_sum>tmpp_sum){
                number=y;
            }else{
                number=x;
                tmp_sum=tmpp_sum;
            }
            first=false;


        }else{
            if(tmpp_sum>tmp_sum){
                number=x;
                tmp_sum=tmpp_sum;
            }

        }
        end=clock();
        
        }
        sum=tmp_sum;
        anss.push_back(number);


    }
    for(int i=0;i<D;i++){
        cout<<anss[i]<<endl;
    }

    


    
    

}


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

using namespace std;

string Sp, T;

int N, M;

int CHECK(void) {
	if (N < M) { return -1; }

	for (int i =N-M; i >=0; i--) {
		bool sign = true;
		for (int j = 0; j < M; j++) {
			if (Sp[i+j] == '?') { continue; }
			if (Sp[i + j] != T[j]) { sign = false; break; }
		}
		if (sign) { return i; }
	}
	return -1;
}

int main(void) {

	cin >> Sp >> T;

	N = (int)Sp.size();
	M = (int) T.size();

	int I = CHECK();

	if (I == -1) { cout << "UNRESTORABLE" << endl; }
	else {
		for (int i = 0; i < I; i++) {
			if (Sp[i] == '?') { cout << "a"; }
			else { cout << Sp[i]; }
		}
		cout << T ;
		for (int i = I + M; i < N; i++) {
			if (Sp[i] == '?') { cout << "a"; }
			else { cout << Sp[i]; }
		}
		cout << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define reset(X) memset(X, 0, sizeof(X))
using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif

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

	ll n;
	cin >> n;
	ll cnt[100005];
	reset(cnt);
	ll sum = 0;
	for (ll i = 1; i <= n; i++)
	{
		ll x;
		cin >> x;
		cnt[x]++;
		sum += x;
	}
	ll q;
	cin >> q;
	while (q--)
	{
		ll b, c;
		cin >> b >> c;
		sum += cnt[b] * (c - b);
		cnt[c] += cnt[b];
		cnt[b] = 0;
		cout << sum << endl;
	}
}



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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 2005, M = 26, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    char a, b;  cin >> a >> b;
    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D'))
        cout << 'H';
    else
        cout << 'D';
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  
  vector <long long> num_mod(k, n / k);
  for (int i = n / k * k + 1; i <= n; ++i) {
    num_mod[i % k]++;
  }
  
  long long ans = 0;
  // (a, b, c) s.t. a+b=0 and b+c=0 and c+a=0
  for (int a = 0; a < k; ++a) {
    int b = a == 0 ? a : k - a;
    int c = b == 0 ? b : k - b;
    if ((c + a) % k == 0) {
      ans += num_mod[a] * num_mod[b] * num_mod[c];
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4756
# input
n, k = list(map(int, input().split()))
s = input()

# solve

##. number of consecutive 0 groups and 1 groups
##. ex:
##.  s = '11101010110011'
##.       0: 0, 0, 0, 00
##.       1: 111, 1, 1, 11, 11
##.  zeros = [1, 1, 1, 2]
##.  ones = [3, 1, 1, 2, 2]
##.   (always count the edges of s as 1)
zeros = []
ones = []
_c = '1'
count = 0
for c in s:
	if _c == c:
		count += 1
	else:
		if _c == '0':
			zeros.append(count)
		else:
			ones.append(count)
		_c = c
		count = 1

if c == '0':
	zeros.append(count)
	ones.append(0)
else:
	ones.append(count)

if len(zeros) <= k:
	## flip all 0's
	ans = len(s)
else:
  ## flip k consecutive zero groups
  ans = 0

  i = 0
  _ans = sum(zeros[i:i+k]) + sum(ones[i:i+k+1])
  ans = _ans

  i = 1
  while i + k <= len(zeros):
#	  _ans = sum(zeros[i:i+k]) + sum(ones[i:i+k+1])
	  _ans += zeros[i+k-1] - zeros[i-1] + ones[i+k] - ones[i-1]
	  ans = max(ans, _ans)
	  i += 1

print(ans)

Measured memory_bytes: 4356
//https://atcoder.jp/contests/abc161/tasks/abc161_c
//C - Replacing Integer
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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 main() {
  ll N, K; cin>>N>>K;
  ll tmp=N%K;
  ll tmp1=abs(tmp-K);
  ll ans=min(tmp,tmp1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

#include <bits/stdc++.h>


using namespace std;


#define LL  long long
#define ll long long
#define LD double
#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int const N = 2e5 + 5;


int main() {
    HabdModeActive
    int n1, n2, n3;
    cin >> n1 >> n2 >> n3;
    if (n1 > n2)
        swap(n1, n2);
    if (n1 > n3)
        swap(n1, n3);
    if (n2 > n3)
        swap(n2, n3);

    cout<<n3 - n1;
    return 0;
}


Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

const ll MOD = 1000000007;

ll intpow(ll a, ll n) {
  if (n == 0) return 1;
  ll x = intpow(a, n/2);
  x = (x * x) % MOD;
  if (n&1) x = (x * a) % MOD;
  return x;
}

ll com(ll n, ll a) {
  ll x = 1, y = 1;
  loop(i,0,a) {
    x = (x * (n-i)) % MOD;
    y = (y * (i+1)) % MOD;
  }
  
  return (x * intpow(y, MOD-2)) % MOD;
}

int main() {
  ll n, a, b; cin >> n >> a >> b;
  ll ans = intpow(2, n);
  ans -= 1;
  ans -= com(n, a);
  if (ans < 0) ans += MOD;
  ans -= com(n, b);
  if (ans < 0) ans += MOD;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include<set>
#include<vector>
#include<string>
#include<iterator>
#include<iomanip>
#include<cmath>
#include<map>
#include<string.h>
#include<algorithm>

using namespace std;
void ll(){
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);
}

int main() {

	ll();
	
	int x, y,ave=0;
	cin >> x >> y;
	ave = (2 * y) - x;
	cout << ave << endl;

}

Measured memory_bytes: 3588
from sys import stdin
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
CD = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1], reverse=True)
CD.sort()
ans = 0

for i, red in enumerate(AB):
    for j, blue in enumerate(CD):
        if red[0] < blue[0] and red[1] < blue[1]:
            ans += 1
            CD.pop(j)
            break
print(ans)

Measured memory_bytes: 3064
from functools import reduce

N=int(input())
*A,=map(int,input().split())
mod = 10**9+7

def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a%b)

def lcm(a,b):
  return a*b//gcd(a,b)

LCM = reduce(lcm,A)%mod

print(sum([LCM*pow(A[i],-1,mod)%mod for i in range(N)])%mod)

Measured memory_bytes: 10436
#include<bits/stdc++.h>
using namespace std;
#define intl long long int 

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,j,n,m;
	cin>>n>>m;
	vector<intl> ar(n);
	intl tot=0;
	for(i=0;i<n;i++){
		cin>>ar[i];
		tot+=ar[i];
	}
	j=tot;
	intl k=(4*m);
	intl j1;
	if(j%k==0){
		j1=j/k;
		j1--;
	}
	else{
		j1=j/k;
	}
	intl count1=0;
	for(i=0;i<n;i++){
		if(ar[i]>j1){
			count1++;
		}
	}
	if(count1>=m){
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int N;
vector<int> A;
vv<int> tree;

vv<int> dp;
vector<int> B;
vector<int> ans;

void dfs(int v, int p) {
    int low = -1, high = N + 1;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (A[v] > dp[mid].back()) low = mid;
        else high = mid;
    }
    B[v] = high;

    dp[B[v]].push_back(A[v]);

    low = -1, high = N + 1;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (INT32_MAX > dp[mid].back()) low = mid;
        else high = mid;
    }
    ans[v] = high;

    for (int u : tree[v]) {
        if (u == p) continue;
        dfs(u, v);
    }

    dp[B[v]].pop_back();
}

int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    tree.resize(N);
    rep(i, N - 1) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }

    dp.resize(N + 1, { INT32_MAX });
    B.resize(N);
    ans.resize(N);

    dfs(0, -1);

    for (int x : ans) write(x);
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int nxt = 1, ans = 0;
  rep(i,n) {
    if (nxt == a[i]) {
      ++nxt;
    } else {
      ++ans;
    }
  }
  if (ans == n) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

vector<string> split(string in, char sp = ' '){
	vector<string> ret;
	stringstream ss(in);
	string s;
	while(getline(ss, s, sp)){
		ret.emplace_back(s);
	}
	return ret;
}

int main(){
	string in;
	while(getline(cin,in)){
		vector<double> st;
		vector<string> v = split(in);

		for(auto s : v){
			if(s.size() == 1 and not isdigit(s.front())){
				double b = st.back(); st.pop_back();
				double a = st.back(); st.pop_back();
				switch (s[0]) {
					case '+':
						st.emplace_back(a + b);
						break;
					case '-':
						st.emplace_back(a - b);
						break;
					case '*':
						st.emplace_back(a * b);
						break;
					case '/':
						st.emplace_back(a / b);
						break;
				}
			}else{
				st.emplace_back(stod(s));
			}
		}
		cout << fixed << setprecision(7) << st.front() << endl;
	}
}



Measured memory_bytes: 3256
#![allow(unused)]

use proconio::{input, fastout};
use proconio::marker::{Chars, Usize1};

fn count_ones(n: usize) -> usize {
    return (0..64).filter(|i| (n & (1usize << i)) == 1usize).count();
}

fn count_blacks(cells: &Vec<Vec<char>>, iset: usize, jset: usize) -> usize {
    let h = cells.len();
    let w = cells[0].len();

    let mut cells = cells.clone();

    for i in 0..h {
        if (iset & (1 << i)) != 0 {
            for j in 0..w {
                cells[i][j] = 'X';
            }
        }
    }
    for j in 0..w {
        if (jset & (1 << j)) != 0 {
            for i in 0..h {
                cells[i][j] = 'X';
            }
        }
    }
    return cells.iter()
        .flat_map(|row| row.iter())
        .filter(|&&c| c == '#')
        .count();
}

#[fastout]
fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        cells: [Chars; h],
    }

    let mut ans = (0usize..2usize.pow(h as u32))
        .flat_map(|iset| {
            let iset = iset.clone();
            (0usize..2usize.pow(w as u32)).map(move |jset| (iset.clone(), jset))
        })
        .filter(|&(iset, jset)| count_blacks(&cells, iset, jset) == k)
        .count();

    println!("{}", ans);
}


Measured memory_bytes: 2204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//=================================================================
// Begginer Contest 115 D

uint64_t getpattynum(vector<uint64_t>& layer, vector<uint64_t>& patty, uint64_t N, uint64_t X){
    if(N==0){
        return (X>0 ? 1 : 0);
    }else if(X<=1+layer[N-1]){
        return getpattynum(layer, patty, N-1, (X>=1 ? X-1 : 0));
    }else{
        return patty[N-1]+1+getpattynum(layer, patty, N-1, X-layer[N-1]-2);
    }
}

int main(){
    uint64_t N,X;
    cin >> N >> X;
    vector<uint64_t> layer(N+1,1);
    vector<uint64_t> patty(N+1,1);
    uint64_t ans;

    for(int i=1;i<N+1;i++){
        layer[i] = layer[i-1]*2+3;
        patty[i] = patty[i-1]*2+1;
    }

    cout << getpattynum(layer,patty,N,X) << endl;

    return 0;
}


Measured memory_bytes: 256
require "bigdecimal"
require "bigdecimal/util"

def gi() gets.to_i end
def gs() gets.chomp end
def gmi() gets.split.map(&:to_i) end
def gms() gets.split.map(&:chomp) end
def YesNo1(bool, yes="Yes", no="No") puts (bool ? yes : no) end
def YESNO2(bool, yes="YES", no="NO") puts (bool ? yes : no) end

def comb(n,k)
  return nil if k > n
  result = 1
  1.upto() do |d|
    result *= n
    result /= d
    n -= 1
  end
  result
end

def perm(n,k)
  return nil if k > n
  result = 1
  k.times do
    result *= n
    n -= 1
  end
  result
end

def kaibun(str)
  str == str.reverse
end

#####

wordCount = {}

n = gi
n.times do
  word = gs
  if wordCount[word] != nil
    wordCount[word] = wordCount[word] + 1
  else
    wordCount[word] = 1
  end
end

m = gi
m.times do
  word = gs
  if wordCount[word] != nil
    wordCount[word] = wordCount[word] - 1
  else
    wordCount[word] = -1
  end
end

res = wordCount.values.max
if res > 0
  puts res
else
  puts 0
end

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,sum=0;
    vector<int> A(60);
    vector<int> B(60);
    vector<int> C(60);

    cin >> N;
    for (int a = 1; a < N+1; a++){
        cin >> A.at(a) ;
    }
   for (int a = 1; a < N+1; a++){
        cin >> B.at(a) ;
    }
   for (int a = 1; a < N+1; a++){
        cin >> C.at(a) ;
    }
    sum+= B.at(A.at(1));

    for(int b = 2; b < N + 1; b++){
        sum += B.at(A.at(b));
        if(A.at(b)-1==A.at(b-1)){
            sum += C.at(A.at(b - 1));

        }

    }

    cout<<sum<<endl;
}


Measured memory_bytes: 256
function main(input) {
    var input = input.trim().split("\n");
    var st = input[0].split(" ");
    var ab = input[1].split(" ");
    var u = input[2];

    if (u === st[0]) {
        ab[0] --;
    } else {
        ab[1] --;
    }
    console.log(ab[0] + " " + ab[1])
}

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


Measured memory_bytes: 21956
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

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

    cout << (((n-m)*100+m*1900))*pow(2,m) << ENT;
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    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();
		int h[] = new int[n];
		int t = sc.nextInt();
		int a = sc.nextInt();
		double abs = 200;
		int ans = 0;
		double tmp;

		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
			tmp = Math.abs(a - (t - h[i]*0.006));
			if (i == 0) {
				abs = tmp;
				ans = 1;
			}else if (abs > tmp) {
				abs = tmp;
				ans = i + 1;
			}
		}
		sc.close();
		System.out.println(ans);

	}

}


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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    ll n, m, tmp;
    cin >> n >> m;
    priority_queue<int> Q;
    for(int i = 0; i < n; i++) {
        cin >> tmp;
        Q.push(tmp);
    }
    for(int i = 0; i < m; i++) {
        int x = Q.top(); Q.pop();
        Q.push(x / 2);
    }
    ll result = 0;
    while(Q.size()) {
        result += Q.top();
        Q.pop();
    }
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 892
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
N = parse(readline())
P = []
for i in 1:N
    p = parse(readline())
    push!(P,p)
end

sort!(P)

P[N] = P[N] ÷ 2

println(sum(P))

Measured memory_bytes: 162640
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var M = one[1];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = {
      child : new Set(),
      parent : new Set(),
      from : null,
    };
  }
  for(var i = 0; i < N - 1 + M; i++){
    var tmp = nextIntArray();
    list[tmp[0] - 1].child.add(tmp[1] - 1);
    list[tmp[1] - 1].parent.add(tmp[0] - 1);
  }
  for(var i = 0; i < N; i++){
    if(list[i].parent.size == 0){
      bfs(i);
      break;
    }
  }
  var output = new Array(N);
  for(var i = 0; i < N; i++){
    output[i] = list[i].from;
    if(output[i] == null){
      output[i] = 0;
    }
  }
  myout(myconv(output,9));
  
  function bfs(index){
    var ok = [];
    var queue = [index];    
    while(queue.length > 0){
      var parent = queue.shift();
      ok.push(parent);
      var child = Array.from(list[parent].child);
      for(var i = 0; i < child.length; i++){
        list[parent].child.delete(child[i]);
        list[child[i]].parent.delete(parent);
        if(list[child[i]].parent.size == 0){
          list[child[i]].from = parent + 1;
          queue.push(child[i]);
        }
      }
    }
    //myerr(ok);
    //myerr(list);
  }
}


Measured memory_bytes: 112872
#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>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q;
ll A[100001];
ll B[100001];
ll ans;
string S;
ll K;
map<ll, ll> m;
char ansmap[102][102];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
int main() {
	ll A, B;
	cin >> A >> B;
	A--; B--;
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			if (i < 50)ansmap[i][j] = '.';
			else ansmap[i][j] = '#';
		}
	}
	rep(i, 0, 49) {
		if (B == 0)break;
		rep(j, 0, 100) {
			if (B == 0)break;
			if (i % 2==0 && j % 4==0) {
				ansmap[i][j] = '#';
				B--;
			}
			if (i % 2==1 && j % 4 == 2) {
				ansmap[i][j] = '#';
				B--;
			}
		}
	}
	rep(i, 51, 100) {
		if (A == 0)break;
		rep(j, 0, 100) {
			if (A == 0)break;
			if (i % 2==0 && j % 4==0) {
				ansmap[i][j] = '.';
				A--;
			}
			if (i % 2==1 && j % 4 == 2) {
				ansmap[i][j] = '.';
				A--;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	rep(i, 0, 100) {
		rep(j, 0, 100) {
			cout << ansmap[i][j];
		}
		cout << endl;
	}
	cin >> ans;
	return 0;
}

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

using namespace std;

struct City
{
  int index;
  int prefecture;
  int year;
  int index_in_prefecture;

  string id()
  {
    ostringstream ss;
    ss << setw(6) << setfill('0') << prefecture;
    ss << setw(6) << setfill('0') << index_in_prefecture;

    return ss.str();
  }

  string to_str()
  {
    return "index: " + to_string(index) + ", prefecture: " + to_string(prefecture) + ", year: " + to_string(year) + ", index_in_prefecture: " + to_string(index_in_prefecture);
  }

  bool operator<(const City &another) const
  {
    return year < another.year;
  }
};

int main(int argc, char **argv)
{
  int n, m;

  cin >> n >> m;
  
  vector<vector<City>> cities_in_prefectures(n);
  for (int i = 0; i < m; i++) {
    int p, y;

    cin >> p >> y;

    struct City c;
    c.index = i;
    c.prefecture = p;
    c.year = y;

    cities_in_prefectures.at(p-1).emplace_back(c);
  }

  vector<City> cities;
  for (int i = 0; i < n; i++)
  {
    vector<City> cities_in_prefecture = cities_in_prefectures.at(i);
    sort(cities_in_prefecture.begin(), cities_in_prefecture.end());
    for (int j = 0; j < int(cities_in_prefecture.size()); j++)
    {
      City city = cities_in_prefecture.at(j);
      city.index_in_prefecture = j+1;
      cities.emplace_back(city);
    }
  }
  sort(cities.begin(), cities.end(), [](const City &a, const City &b){
      return a.index < b.index;
      });

  for (int i = 0; i < m; i++)
  {
    cout << cities.at(i).id() << endl;
  }

  return 0;
}


Measured memory_bytes: 8816
#include <iostream>                                             
#include <vector>                                               
                                                                
using namespace std;                                            
                                                                
int main(void) {                                                
  int N, x;                                                     
  cin >> N;                                                     
  vector<int> A;                                                
  for (int i=0; i<N; i++) {                                     
    cin >> x;                                                   
    A.push_back(x);                                             
  }                                                             
   int v, i, j;                                                 
   for (i=0; i<A.size(); i++) {                                 
    v = A[i];                                                   
    j = i-1;                                                    
    while (j>=0 && A[j]>v) {                                    
      A[j+1] = A[j];                                            
      j--;                                                      
      A[j+1] = v;                                               
    }                                                           
    for (int k=0; k<A.size(); k++) {                            
      cout << (k==0?"":" ") << A[k] << flush;                   
    }                                                           
    cout << endl;                                               
    }                                                           
}                                                               
                                

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int A,B;
    cin >> A >> B;
    if(A == B){
        cout << "Draw" << endl;
    }else if (A == 1) {
        cout << "Alice" << endl;
    }else if(B == 1){
        cout << "Bob" << endl;
    }else if (A > B) {
        cout << "Alice" << endl;
    }else if(B > A){
        cout << "Bob" << endl;
    }
    return 0;
}

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

int main() {
    const int mod = 1000000007;
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> counter(26, 0);
    rep(i, n) {
        counter[s[i] - 'a']++;
    }
    ll ans = 1;
    rep(i, 26) {
        (ans *= counter[i] + 1) %= mod;
    }
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 512
class Unionfind:
    def __init__(self, n):
        self.d = [-1]*n
    
    def find(self, x):
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.find(self.d[x])
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x==y:
            return False
        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True
    
    def same(self, x, y):
        if self.find(x)==self.find(y):
            return True
        return False
    
    def size(self, x):
        return (-1) * self.d[self.find(x)]

N, M, K = map(int,input().split())
deg = [0]*N
uf = Unionfind(N)
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)
    #print(uf.d)

for i in range(K):
    a, b = map(int, input().split())
    #to[a] -= 1
    #to[b] -= 1
    if uf.same(a-1, b-1)==True:
        deg[a-1] += 1
        deg[b-1] += 1

for i in range(N):
    #print(i, uf.d[i])
    #print(i, uf.size(i))
    print(uf.size(i)-1-deg[i])

Measured memory_bytes: 9816