akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("yx");
            WillReturn.Add("axy");
            //Yes
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("ratcode");
            WillReturn.Add("atlas");
            //Yes
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("cd");
            WillReturn.Add("abc");
            //No
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("w");
            WillReturn.Add("ww");
            //Yes
        }
        else if (InputPattern == "Input5") {
            WillReturn.Add("zzz");
            WillReturn.Add("zzz");
            //No
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        string S = InputList[0];
        string T = InputList[1];

        string MinS = new string(S.OrderBy(X => X).ToArray());
        string MaxT = new string(T.OrderByDescending(X => X).ToArray());

        Console.WriteLine(MinS.CompareTo(MaxT) < 0 ? "Yes" : "No");
    }
}


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

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

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int x,a,b,c;
  int y=0;
  scanf("%d %d %d",&a,&b,&c);
  for(x=a;x<=b;x++){
      if(c%x){
          
      }else{
          y=y+1;
      }
  }
  printf("%d\n",y);
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>

using namespace std;

int main(){
    string S;
    int a=0,b=0,c=0;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i]=='a')a++;
        if(S[i]=='b')b++;
        if(S[i]=='c')c++;
    }
    if(a > 0 && b > 0 && c > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;

void Calculate_Depth(vector<vector<int>>&edge, vector<int>&depth, int stnode) {
	depth[stnode] = 0;
	queue<int>Q;
	Q.push(stnode);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] > depth[cn] + 1) {
				depth[i] = depth[cn] + 1;
				Q.push(i);
			}
		}
	}
	return;
}

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

	cin >> N >> K;
	vector<vector<int>>edge(N);
	for (int i = 1; i < N; i++) {
		cin >> L >> R;
		L--;
		R--;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	vector<int>depth(N, MOD);
	vector<long long int>ans(N);
	Calculate_Depth(edge, depth, 0);
	while (K--) {
		cin >> L >> R;
		L--;
		ans[L] += R;
	}
	queue<int>Q;
	Q.push(0);
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		for (auto i : edge[cn]) {
			if (depth[i] < depth[cn])continue;
			ans[i] += ans[cn];
			Q.push(i);
		}
	}
	for (auto i : ans)cout << i << " ";
	cout << endl;
}


Measured memory_bytes: 17140
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


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


int main(){
    int n;
    cin>>n;
    vi a(n);
    int m=0;
    rep(i,n)cin>>a[i];

    sort(all(a));
    int s=a[n-1]/2;
    int it=lower_bound(all(a),s)-a.begin();
    if(it>0){
       if(a[it]-s>s-a[it-1])it--;
    }
    if(it==n-1)it--;
    cout<<a[n-1]<<" "<<a[it]<<endl;
    return 0;
}

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

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

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

    int h, w;
    cin >> h >> w;

    vector<vector<bool> > s(h, vector<bool>(w, false));
    REP(i, h) REP(j, w) {
        char tmp;
        cin >> tmp;
        if (tmp == '#')
            s[i][j] = true;
    }

    bool ans = true;
    REP(i, h) REP(j, w) {
        if (s[i][j]) {
            int sum = 0;
            REP(k, 4) {
                if (i + dx[k] >= 0 && i + dx[k] < h)
                    if (j + dy[k] >= 0 && j + dy[k] < w)
                        if ((s[i + dx[k]][j + dy[k]]))
                            sum++;
            }
            if (sum == 0) ans = false;
        }
    }

    if (ans) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ts = list(map(int,input().split()))
vs = list(map(int,input().split()))
 
maxv = [0]
for v,t in zip(vs,ts):
    maxv[-1] = min(maxv[-1], v)
    for ti in range(t*2):
        maxv.append(v)
T = len(maxv)
 
for i in range(T-1):
    maxv[i+1] = min(maxv[i+1], maxv[i] + 0.5)
 
maxv[-1] = 0
for i in reversed(range(T-1)):
    maxv[i] = min(maxv[i], maxv[i+1] + 0.5)
 
ans = 0.0
for i in range(T-1):
    ans += (maxv[i] + maxv[i+1]) * 0.25
print(ans)

Measured memory_bytes: 3500
//
//  main.cpp
//  quick_sort
//
//  Created by ???????????? on 2017/10/08.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>

using namespace std;

struct Card{
    char suit;
    int num;
};

void swap(Card *a, Card *b){
    Card temp = *a;
    *a = *b;
    *b = temp;
}

int partition(Card cards[], int p, int r){
    int x = cards[r].num;
    int i = p - 1;
    for(int j = p; j < r; j ++){
        if(cards[j].num <= x){
            i++;
            swap(cards[i], cards[j]);
        }
    }
    swap(cards[i+1], cards[r]);
    return i+1;
}

void quick_sort(Card cards[], int p, int r){
    if (p < r){
        int q = partition(cards, p, r);
        quick_sort(cards, p, q-1);
        quick_sort(cards, q+1, r);
    }
}

void merge(Card S[], int left, int mid, int right){
    int i, j, k, n1, n2;
    n1 = mid - left;
    n2 = right - mid;
    Card L[n1+1], R[n2+1];
    for (i = 0; i < n1; i++){
        L[i] = S[left+i];
        
    }
    for (i = 0; i < n2; i++){
        R[i] = S[mid+i];
    }
    L[n1].num = INT_MAX;
    R[n2].num = INT_MAX;
    
    
    i = 0;
    j = 0;
    
    for( k = left; k < right; k++ ){
        if(L[i].num <= R[j].num){
            
            S[k] = L[i];
            i++;
        }
        else{
            S[k] = R[j];
            j++;
        }
    }
}


void merge_sort(Card S[], int left, int right){
    if (left+1 < right){
        int mid = (left + right)/2;
        merge_sort(S, left, mid);
        merge_sort(S, mid, right);
        merge(S, left, mid, right);
    }
}

int main(int argc, const char * argv[]) {
    int n, i;
    scanf("%d", &n);
    Card cards[n], copy[n];
    for(i = 0; i < n; i++){
        scanf("%s %d", &cards[i].suit, &cards[i].num);
        copy[i] = cards[i];
    }
    quick_sort(cards, 0, n - 1);
    merge_sort(copy,  0, n );
    
    int is_stable = 1;
    for(i = 0; i < n; i++){
        if(copy[i].suit!=cards[i].suit)is_stable = 0;
    }
    if(is_stable)cout << "Stable" <<endl;
    else cout << "Not stable" << endl;
    
    
    for(i = 0; i < n; i++){
        cout << cards[i].suit << " " << cards[i].num << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5472
#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;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	double n, k;
	cin >> n >> k;

	vector<int> a(n);
	cin >> a;
	
	cout << ceil(max(n - k, 0.0) / (k - 1)) + 1 << endl;
}


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

int main() {
    int len=0;
    cin >> len;
    int *var = new int[len];
    for(int i=0;i<len;i++){
        cin >> var[i];
    }
    int flag=0;//符合条件的数量
    for(int i=1;i<len-1;i++){
        int tmp[3];
        tmp[0] = var[i-1];
        tmp[1] = var[i];
        tmp[2] = var[i+1];
        sort(tmp,tmp+3);
        if(tmp[1] == var[i]){
            flag++;
        }
    }
    cout<<flag;
    return 0;
}

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

const int N = 2005;

int a[N][N], cnt[N][N], r[N][N], c[N][N];
char s[N];

int main(){
	int n, m, q, x1, y1, x2, y2, numv, nume;
	scanf("%d %d %d",&n,&m,&q);
	memset(cnt, 0, sizeof(cnt));
	memset(r, 0, sizeof(r));
	memset(c, 0, sizeof(c));
	for (int i = 1; i <= n; i++){
		scanf("%s", s + 1);
		for (int j = 1; j <= m; j++){
			cnt[i][j] = a[i][j] = s[j] - '0';
			if (j > 1 && a[i][j] && a[i][j - 1]) r[i][j] = 1;
		}
	}
	for (int j = 1; j <= m; j++){
		for (int i = 2; i <= n; i++){
			if (a[i][j] && a[i - 1][j]) c[i][j] = 1;
		}
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cnt[i][j] += cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1];
			r[i][j] += r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1];
			c[i][j] += c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1];
		}
	}
	for (int i = 1; i <= q; i++){
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		numv = cnt[x2][y2] - cnt[x2][y1 - 1] - cnt[x1 - 1][y2] + cnt[x1 - 1][y1 - 1];
		nume = r[x2][y2] - r[x2][y1] - r[x1 - 1][y2] + r[x1 - 1][y1];
		nume += c[x2][y2] - c[x2][y1 - 1] - c[x1][y2] + c[x1][y1 - 1];
		printf("%d\n", numv - nume);
	}
	return 0;
}

Measured memory_bytes: 64640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n; 
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	int ans = inf;
	for (int i = -100; i <= 100; ++i) {
		int tmp = 0;
		rep(j, n) tmp += (i - a[j]) * (i - a[j]);
		mins(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


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

ll ans[20001], ans2[20001];

int main(){
	int n;
	cin >> n;
	for (int i=1; i<=n; i++){
		ans[i]=i*50000, ans2[i]=(n-i)*50000;
	}
	int x;
	for (int i=1; i<=n; i++){
		cin >> x;
		ans2[x]+=i;
	}
	for (int i=1; i<n; i++) cout << ans[i] << " ";
	cout << ans[n] << "\n";
	for (int i=1; i<n; i++) cout << ans2[i] << " ";
	cout << ans2[n] << "\n";
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int m;
    int i;
    int j;
    int count;
    int max;
    
    cin >> n;
    vector<string> blue(n);
    i = -1;
    while (++i < n)
        cin >> blue.at(i);
    cin >> m;
    vector<string> red(m);
    i = -1;
    while (++i < m)
        cin >> red.at(i);
    max = 0;
    i = -1;
    while (++i < n)
    {
        count = 1;
        j = i;
        while (++j < n)
        {
            if (blue.at(i) == blue.at(j))
                count++;
        }
        j = -1;
        while (++j < m)
        {
            if (blue.at(i) == red.at(j))
                count--;
        }
        if (max < count)
            max = count;
    }
    cout << max << endl;
}


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

long long N, A[1 << 18], S;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) { cin >> A[i]; S += A[i]; }
	sort(A, A + N);

	if (S == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	if (N % 3 != 0) {
		cout << "No" << endl;
		return 0;
	}

	for (int t = 0; t < 3; t++) {
		for (int i = 0; i < (N / 3) - 1; i++) {
			int v = t * (N / 3) + i;
			if (A[v] != A[v + 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	int w[3] = { A[0], A[N / 3], A[2 * N / 3] };
	sort(w, w + 3);

	do {
		if (w[0] == (w[1] ^ w[2]) && w[1] == (w[2] ^ w[0]) && w[2] == (w[0] ^ w[1])) {
			cout << "Yes" << endl;
			return 0;
		}
	} while (next_permutation(w, w + 3));

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;


 
int main(){
    ll n,m; cin >> n >> m;
    vvl kagi(m);
    vl kagicost(m);
    rep(i,m){
        ll a,b; cin >> a >> b;
        rep(j,b){
            ll c; cin >> c; c--;
            kagi[i].push_back(c);
        }
        kagicost[i] = a;
    }
    vl dp(1<<(n+1),INF);
    dp[0] = 0;
    for(ll bit=0; bit<(1<<n); bit++){
        rep(i,m){
            ll s = 0;
            for(auto j : kagi[i]){
                if(bit & (1<<j)) continue;
                else s += (1<<j);
            }
            dp[bit+s] = min(dp[bit+s], dp[bit] + kagicost[i]);
        }
    }
    if(dp[(1<<n)-1] != INF) cout << dp[(1<<n)-1] << endl;
    else puts("-1");
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    lint ret = 0;
    for (lint i = 1; i <= n; ++i) {
        if (i % 3 != 0 && i % 5 != 0)
            ret += i;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(){
  int a[101],n,x,d,i;
  scanf("%d%d%d",&n,&d,&x);
  for(i=0;i<n;i++){
      scanf("%d",&a[i]);
  }
  x+=n;
  for(i=0;i<n;i++){
      x+=(d-1)/a[i];
  }
  printf("%d",x);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    static int count = 0;
    public static void main(String... args){
        Scanner scan = new Scanner(System.in);


        while(true){
            int n = scan.nextInt();
            int s = scan.nextInt();
            if(n == 0 && s == 0)break;
            count = 0;
            sum(n, s, 0, 0);
            System.out.println(count);
        }

        scan.close();
    }

    static void sum(int n ,int s, int w, int nsum){
        if(n == 1){
            for(int i = w;i <= 10-n;i++){
                if(i + nsum == s)count++;
            }
            return;
        }
        for(int i = w;i <= 10-n;i++){
            nsum += i;
            sum(n-1, s, i+1, nsum);
            nsum -= i;
        }
    }
}


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

#define ll long long
#define MAX 300005
#define pp pair<int,int>
#define pb push_back
#define mod 10

using namespace std;
/*
 * author: Kruti_20
 */
ll power(ll x, ll y);

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll dp[MAX][3];
int a[MAX], b[MAX], c[MAX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];
    for (int i = 1; i <= n; i++) {
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

Measured memory_bytes: 5120
N, M = list(map(int, input().split()))
A = {}
B = [0] * N
for i in range(N):
    A[i], B[i] = list(map(int, input().split()))
A = sorted(A.items(), key=lambda x:x[1])

ans = 0

for i in range(N):
    if M > B[A[i][0]]:
        ans += A[i][1] * B[A[i][0]]
        M -= B[A[i][0]]
    else:
        ans += A[i][1] * M
        break;
print(ans)


Measured memory_bytes: 28128
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);

		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int sum = 0;
			for(int r = 0; r < (n / 4); r++) {
				int input = stdIn.nextInt();
				sum += input;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 18292
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  int N; cin >> N;
  ll a[N], b[N];
  FOR(i,0,N) {
    a[i] = (i + 1) * 30000;
    b[i] = 1000000000 - a[i];
  }
  FOR(i,0,N) {
    ll p; cin >> p;
    p--;
    a[p] -= N - i;
  }
  FOR(i,0,N) printf("%lld%c",a[i],i==N-1?'\n':' ');
  FOR(i,0,N) printf("%lld%c",b[i],i==N-1?'\n':' ');
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_H 100
#define MAX_W 8
#define MOD 1000000007

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int H, W, K;
llong dp[MAX_H + 1][MAX_W];

llong fib[MAX_W + 1];
//1 -> Kの経路に関係ない横線の数
llong dummy_paths(int n) {
    return fib[n];
}

llong solve() {
    dp[0][0] = 1;

    for(int h = 1; h <= H; ++h) {
        for(int w = 0; w < W; ++w) {
            
            dp[h][w] += dp[h - 1][w] * dummy_paths(w) * dummy_paths(W - 1 - w);
            dp[h][w] %= MOD;

            if(w != 0) {
                dp[h][w] += dp[h - 1][w - 1] * dummy_paths(w - 1) * dummy_paths(W - 1 - w);
                dp[h][w] %= MOD;
            }
            if(w != W - 1) {
                dp[h][w] += dp[h - 1][w + 1] * dummy_paths(w) * dummy_paths(W - 2 - w);
                dp[h][w] %= MOD;
            }

        }
    }

    return dp[H][K - 1];
}

int main(int argc, char **argv) {
    cin >> H >> W >> K;

    fib[0] = fib[1] = 1;
    for(int i = 2; i <= MAX_W; ++i)
        fib[i] = fib[i - 1] + fib[i - 2];

    cout << solve() << endl;
}

Measured memory_bytes: 256
/*
 * Author : Sadi
 * Thu 02/07/2020
 * 19:51:28.70
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n;
    cin >> n;
    if(n == 1) {
        cout << "Hello World" << endl;
    }
    else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}


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

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 5e5 + 5, MOD = 1e9 + 7;
int p[N];
ll prod[N], sum[N];
int h;

void add(ll x, ll &y) {
    x += y;
    if (x >= MOD)
        x -= MOD;
}

ll ans = 0;

void solve(int v, int lvl = 1) {
    if (lvl == h) {
        prod[v] = v;
    }
    else {
        solve(v * 2, lvl + 1);
        solve(v * 2 + 1, lvl + 1);

        int ct = (1 << (h - lvl - 1)),
            start_left = v * 2 * ct,
            start_right = (v * 2 + 1) * ct;

        for (int i = 0; i < ct; i++) {
            int x = p[start_left + i - (1 << (h - 1))] - 1 + (1 << (h - 1));

            ll cur_prod = prod[start_left + i] * v % MOD;

            while (x > 1) {
                cur_prod = cur_prod * x % MOD;
                sum[x] = (sum[x] + cur_prod * (x / 2)) % MOD;
                x /= 2;
            }
        }

        // ll gaga = 0;

        for (int i = 0; i < ct; i++) {
            int x = p[start_right + i - (1 << (h - 1))] - 1 + (1 << (h - 1));

            ll cur_prod = prod[start_right + i];

            while (x > 1) {
                cur_prod = cur_prod * x % MOD;
                ans = (ans + sum[x ^ 1] * cur_prod) % MOD;
                // gaga = (gaga + sum[x ^ 1] * cur_prod) % MOD;
                x /= 2;
            }
        }

        // cout << v << " " << gaga << "\n";

        for (int i = 0; i < ct; i++) {
            int x = p[start_left + i - (1 << (h - 1))] - 1 + (1 << (h - 1));

            while (x > 1) {
                sum[x] = 0;
                x /= 2;
            }
        }

        for (int i = 0; i < ct * 2; i++) {
            prod[start_left + i] = prod[start_left + i] * v % MOD;
        }
    }
}

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

    
    cin >> h;

    int n = (1 << h);

    for (int i = 0; i < (1 << (h - 1)); i++) {
        cin >> p[i];
    }

    solve(1);

    cout << ans << "\n";

	return 0;
}

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

int K, power = 1;
double  sum = 0, ab = 0, N;

int main()
{
    cin >> N >> K;

    for(int i = N; i >= 1; i--)
    {
        if(i >= K)
        {
            ab++;
            continue;
        }

        while(1)
        {
            int temp = i * pow(2, power);
            if(temp >= K)
            {
                //cout << "i = " << i << endl;
                //cout << "temp = " << temp << endl;
                sum += 1 / (N * pow(2, power));
                //cout << "1 / " << (N * pow(2, power)) << endl;
                break;
            }
            power++;
        }
    }

    //cout << "ab = " << ab << endl;
    //cout << "ab / N = " << ab / N  << endl;
    sum = (ab / N) + sum;
    cout << fixed;
    cout << setprecision(15) << sum << endl;
    return 0;
}

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


int main(void){
	int n;
	int h[100000];
	int i;

	int f;

	f = 0;

	scanf("%d",&n);
	scanf("%d",&h[0]);

	for(i=1;i<n;i++){
		scanf("%d",&h[i]);
	}

	for(i=n-1;i>0;i--){
		if(h[i-1] - h[i] >= 2){
			f = 1;
		}else if(h[i-1] - h[i] == 1){
			h[i-1]--;
		}
	}


	if( f == 1){
		printf("No\n");
	}else{
		printf("Yes\n");
	}


	return 0;
}


Measured memory_bytes: 512
function Main(input) {

    input = input.split("\n");
    tmp = input[0].split(" ");
	
    const N = parseInt(tmp[0]);
    const D = parseInt(tmp[1]);
    let j = 0;

    for (let i = 1 ; i < (N+1) ; i++){
        tmp2 = input[i].split(" ");

        let X = tmp2[0];
        let Y = tmp2[1];
        let d = Math.sqrt(X*X + Y*Y);

        if (D >= d) {
            j++;
        }
    }
    console.log( '%d', j);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 62748
n = int(input())
x=[0]*n
y=[0]*n
h=[0]*n

for i in range(n):
    q,w,e = map(int, input().split())
    x[i]=q
    y[i]=w
    h[i]=e

for i in range(n):
    if h[i]>0:
        ii = i
    
        
ran = list(range(0,n))
ran.remove(ii)

for cx in range(101):
    for cy in range(101):
        hight = abs(cx-x[ii]) + abs(cy-y[ii]) + h[ii]        
        flag=1
        for i in ran:
            if max(hight - (abs(cx-x[i]) + abs(cy-y[i])), 0) != h[i]:
                flag=0
        if flag==1:
            print("{} {} {}".format(cx, cy, hight))

Measured memory_bytes: 3064
#include<iostream>
#include <climits>
#include<vector>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	int res = 0;
	for (int i = 0;i < N;i++) {
		int minj = i;
		for (int j = i + 1;j < N;j++) {
			if (A[minj] > A[j]) {
				minj = j;
			}
		}
		if (i != minj) {
			int tmp = A[i];
			A[i] = A[minj];
			A[minj] = tmp;
			res++;
		}
	}
	REP(i, N) {
		if (i < N - 1) cout << A[i] << " ";
		else cout << A[i] << "\n";
	}
	cout << res << "\n";

	return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int main(void)
{
	int n;
	int l,s;
	int i,j,temp;
	int keta[4];
	int cnt;
	
	scanf("%d",&n);
	
	while(n!=0000){
		if(n%1111==0){
			printf("NA\n");
		}
		else {
			cnt=0;	
			while(n!=6174){	
				for(i=0;i<4;i++){
					keta[i]=n%10;
					n=n/10;
				}
				for(i=0;i<3;i++){
					for(j=i+1;j<4;j++){
						if(keta[i]<keta[j]){
							temp=keta[i];
							keta[i]=keta[j];
							keta[j]=temp;
						}
					}
				}
				l=keta[0]*1000+keta[1]*100+keta[2]*10+keta[3];

				for(i=0;i<3;i++){
					for(j=i+1;j<4;j++){
						if(keta[i]>keta[j]){
							temp=keta[i];
							keta[i]=keta[j];
							keta[j]=temp;
						}
					}
				}
				s=keta[0]*1000+keta[1]*100+keta[2]*10+keta[3];
				n=l-s;
				cnt++;
			}
	printf("%d\n",cnt);
		}
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxd = 105;
long double ans;
int a[maxd],n;
int main()
{
	// freopen("a.in","r",stdin);
	// freopen("k.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&a[i]);
		ans += 1.0 / a[i];
	}
	printf("%.10Lf",1.0/ans);
	return 0;
}

Measured memory_bytes: 128
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int[] p;
    int i, j, res;

    n = sc.nextInt();
    p = new int[30];
    j = 0;
    res = n;

    for(;n != 1;){
      for(i = 2;i * i <= n;i++){
        if(n % i == 0){
          p[j] = i;
          if(j > 0 && p[j] == p[j - 1]){
          }else j++;
          n = n / i;
          break;
        }
      }
      if(i * i > n){
        p[j] = n;
        if(j > 0 && p[j] == p[j - 1]){
        }else j++;
        break;
      }
    }

    for(i = 0;i < j;i++)res = res / p[i] * (p[i] - 1);
    
    out.println(res);

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

Measured memory_bytes: 17352
h,w,k = map(int, input().split())
mod = 1000000000+7

dp = [[0]*w for _ in range(h+1)]

dp[0][0] = 1

onerow_t = [0]*(w-1) # i番目の横棒があるような1行の線の引き方の場合の数
onerow_sum = 0

for i in range(1<<(w-1)):
    tf = [None]*(w-1)
    valid = True
    for d in range(w-1):
        if (i>>d)&1 != 0:
            tf[d] = True
        if d>0 and tf[d-1] and tf[d]:
            valid = False
            break
    # print(bin(i), tf, valid)
    if valid:
        onerow_sum += 1
        for d in range(w-1):
            if tf[d]:
                onerow_t[d] += 1

for i in range(1,h+1):
    for j in range(w):
        tmp = onerow_sum
        if 0<=j-1:
            dp[i][j] += onerow_t[j-1]*dp[i-1][j-1]
            tmp -= onerow_t[j-1]
        if j+1<w:
            dp[i][j] += onerow_t[j]*dp[i-1][j+1]
            tmp -= onerow_t[j]
        # print('i,j,tmp',i,j,tmp)
        dp[i][j] += tmp*dp[i-1][j]
        dp[i][j] = dp[i][j]%mod

# print(onerow_t)
# print(dp)
print(dp[h][k-1])

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll X; cin >> X;
  repr(a,-200,200) repr(b,-200,200) {
    if (pow(a,5)-pow(b,5)==X) {
      cout << a << " " << b << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
using namespace std;
int m,n;
int main()
{
    cin>>m>>n;
    if(m*10000<n)
	{
        cout<<"-1 -1 -1"<<endl;
        return 0;
    }
    if(m*1000>n)
	{
        cout<<"-1 -1 -1"<<endl;
        return 0;
    }
    if(n%1000!=0)
	{
        cout<<"-1 -1 -1";
        return 0;
    }
    for(int i=0;i<=m;i++)
    	for(int j=0;j<=m;j++)
    		for(int k=0;k<=m,i+j+k<=m;k++)
	       {
	            if(i+j+k==m && i*1000+j*5000+k*10000==n)
	            {
	                cout<<k<<" "<<j<<" "<<i<<endl;
	                return 0;   
	            }
	       }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
def main():
    n, m = map(int, input().split())
    A_array = list(map(int, input().split()))
    
    tmp_A_array = [x for x in A_array if x >= sum(A_array)/(4*m)]
    
    # print(sum(A_array)/(4*m), tmp_A_array, m, sep="\n")
    if len(tmp_A_array) >= m:
        print("Yes")
    else:
        print("No")
    
main()


Measured memory_bytes: 9164
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    #first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    first_input = input().split(" ")
    second_input = input().split(" ")

    S = first_input[0]
    T = second_input[0]

    if S==T[:-1]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()


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

using namespace std;

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin>>n>>k;
	int ans=1;
	REP(i, n){
		ans<<1<ans+k ? ans<<=1 : ans+=k;
	}
	cout<<ans<<'\n';
	return 0;
}


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

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

    int now = 0, c = 0;
    for(;;){
        if(now == 1){
            cout << c << endl;
            break;
        }

        if(c >= n){
            cout << -1 << endl;
            break;
        }
        
        c++;
        now = a[now];
    }
}

Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;

const int MAXN = 1e5+5;
const int INF = 0x3f3f3f3f;
int high[MAXN];
int dp[MAXN];//跳到石头编号为i的最小花费
int n;

int main() {

    cin>>n;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        cin>>high[i];

    dp[1]=0;
    dp[2]=abs(high[2]-high[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-1]+abs(high[i-1]-high[i]),dp[i-2]+abs(high[i-2]-high[i]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


/*
--------------------------------------------

	type

--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;

/*
--------------------------------------------

	container

--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

/*
--------------------------------------------

	repetition

--------------------------------------------
*/
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

/*
--------------------------------------------

	constant

--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

/*

	Optimizer

*/
//#pragma GCC optimize("Ofast")

int main(int argc, char const *argv[]) {
  /* code */
  int A,B,C;
  cin >> A >> B >> C;

  for (int i = 1; i <= B; i++) {
    if((A*i)%B == C) {
      cout << "YES\n";
      return 0;
    }
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

ll keta(ll n) {
    ll e = 0;
    while (n != 0) {
        e += n % 10;
        n /= 10;
    }
    return e;
}

int main() {
    ll a, b;
    cin >> a >> b;
    if (a * b % 2 == 0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3628
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	string s;
	cin>>s;
	int sum = 0;

	for(int i = 0 ; i < s.length() ; i++){
		sum += s[i] - 48 ;
	}
	
	if(sum % 9 == 0 ) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

Measured memory_bytes: 3720
#include<stdio.h>

typedef struct{
  int have;
  int link[101];
  int flag;
}Tree;

void input(int);
void shokika(int);
void shori(int);

Tree data[101];
int fl[101], sum = 0;

int main(){

  int n, i, j;;

  scanf("%d",&n);

  input(n);
  shokika(n);
  for(i = 1; i < n; i++)shori(n);

  printf("%d\n",sum);



  return 0;
}
void shori(int n)
{
  int i, j, min = 2001, temp, x;

  for(i = 1; fl[i] != -1; i++)
  {
    x = fl[i];
    for(j = 1; j <= n; j++)
    {
      if(data[x].link[j] != -1 && data[j].flag == 0)
      {
        if(min > data[x].link[j])
        {
          min = data[x].link[j];
          temp = j;
        }
      }
    }
  }
  //printf("%d\n",temp);
  sum += min;
  data[temp].flag = 1;
  fl[i] = temp;
}

void shokika(int n)
{
  int i;

  fl[1] = 1;
  for(i = 2; i <= n; i++)fl[i] = -1;
  data[1].flag = 1, data[1].have = 0;
  for(i = 2; i <= n; i++)data[i].flag = 0, data[i].have = 0;
}

void input(int n)
{
  int i, j;
  for(i = 1; i <= n; i++)
  {
    for(j = 1; j <= n; j++)
    {
      scanf("%d",&data[i].link[j]);
      data[j].have++;
    }
  }
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MD=int(1e9)+7;

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	string L;
	cin>>L;
	
	vector<int> p3(sz(L));
	p3[0]=1;
	rep(i,1,sz(L)) p3[i]=int(3ll*p3[i-1] % MD);
	
	int pre=1;
	int res=0;
	rep(i,0,sz(L)) {
		if (L[i]=='1') {
			res=(res+int(ll(pre)*p3[sz(L)-i-1] % MD)) % MD;
			pre=(2*pre) % MD;
		}
	}
	
	res=(res+pre) % MD;
	
	cout<<res<<"\n";
}


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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

vector<vector<int>> G;
vector<bool> used;


int dfs(int v) {
    int res = 1;
    used[v] = 1;
    for (auto to : G[v]) {
        if (!used[to]) {
            res += dfs(to);
        }
    }
    return res;
}

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n, m;
    cin >> n >> m;

    used.resize(n);
    G.resize(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].PB(b);
        G[b].PB(a);
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = max(ans, dfs(i));
    }

    cout << ans;
    return 0;
} 


Measured memory_bytes: 23432
function main(input) {
  var temp = input.split('\n');
  var n = temp[0];
  var arr = temp[1].split(' ').map(Number);
  var max = Math.max.apply(null, arr);
  var min = Math.min.apply(null, arr);
  var sum = 0;
  for (var i = 0; i < n; i++)
    sum += arr[i]
  console.log(min+' '+max+' '+sum);
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 19220
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/05/20 22:47:54
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll n,k; cin>>n>>k;
  vector<int> A(n); for (auto& a:A) cin>>a;

  auto put_ans = [&](int i, ll sum) {
    set<int> Sx;
    vector<int> S;
    for (; sum < k*n; i++, sum++) {
      auto x = A[i%n];
      if (Sx.count(x) == 0) {
        S.push_back(x);
        Sx.insert(x);
      } else {
        while (Sx.count(x)) {
          Sx.erase(S.back());
          S.pop_back();
        }
      }
    }
    for (auto s:S) {
      cout << s << " ";
    }
    cout << endl;
  };

  if (k == 1) {

    put_ans(0, 0);

  } else {

    vector<pair<int,ll>> nxt(n);
    map<int,int> lst;
    for (int i = 0; i < n; i++) {
      auto a = A[i];
      if (lst.count(a) == 0) {
        lst[a] = i;
        nxt[i] = {(i + 1) % n, n + 1};
      } else {
        nxt[i] = {nxt[lst[a]].first, nxt[lst[a]].second - (i - lst[a])};
        nxt[lst[a]] = {(i + 1) % n, i + 1 - lst[a]};
        lst[a] = i;
      }
    }

    constexpr int LOGNK = 60;
    vector<vector<pair<int,ll>>> dbl(LOGNK, vector<pair<int,ll>>(n, {-1,-1}));
    for (int i = 0; i < n; i++) {
      dbl[0][i] = nxt[i];
    }
    for (int j = 1; j < LOGNK; j++) {
      for (int i = 0; i < n; i++) {
        auto fst = dbl[j-1][i];
        if (fst.first == -1)
          continue;
        auto scd = dbl[j-1][fst.first];
        if (scd.first == -1 or fst.second + scd.second > k*n) {
          continue;
        }
        dbl[j][i] = {scd.first,
                     fst.second + scd.second};
      }
    }

    int i = 0;
    ll sum = 0;
    for (int j = LOGNK-1; j >= 0; j--) {
      auto [t, s] = dbl[j][i];
      if (t == -1 or sum + s > k*n)
        continue;
      i = t;
      sum += s;
    }
    put_ans(i, sum);

  }

  return 0;
}


Measured memory_bytes: 211824
N,M=map(int,input().split())
student=[]
for i in range(0,N):
     a,b=map(int,input().split())
     student.append((a,b))

checkpoint=[]
for i in range(0,M):
    c,d=map(int,input().split())
    checkpoint.append((c,d))

for i in range(0,N):
    a,b=student[i]
    ans=10**20
    anscheck=0
    for j in range(0,M):
        c,d=checkpoint[j]
        if ans>abs(a-c)+abs(b-d):
            anscheck=j
            ans=abs(a-c)+abs(b-d)

    print(anscheck+1)

Measured memory_bytes: 39536
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
#define times(n,i) for(int i=0;i<n;i++)
int main(){
    int n,ch,i;
    scanf("%d",&n);
    vector<int> x(n),y(n),h(n);
    times(n,i)scanf("%d%d%d",&x[i],&y[i],&h[i]);
    //times(i,n)printf("x:%d y:%d h:%d\n",x[i],y[i],h[i]);
    for(i=0;i<n;i++)if(h[i]!=0)break;
    times(101,cy){
        times(101,cx){
            bool flg=true;
            ch=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
            times(n,j){
                if(h[j]!=max(ch-abs(x[j]-cx)-abs(y[j]-cy),0)){
                    flg=false;
                    break;
                }
            }
            if(flg){
                printf("%d %d %d\n",cx,cy,ch);
                return 0;
            }
        }
    }
}

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

vector<int> v[15];
int p[20];

int N,M;
int main () {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int k;
        cin >> k;
        for(int j=0; j<k; j++) {
            int x;
            cin >> x;
            x--;
            v[i].push_back(x);
        }
    }
    for(int i=0; i<M; i++) cin >> p[i];

    int ans = 0;
    for(int i=0; i<(1<<N); i++) {
        bool ok = true;
        for(int j=0; j<M; j++) {
            int cnt = 0;
            for(int k : v[j]) {
                if(i & (1<<k) ) cnt++;
            }
            if(cnt % 2 != p[j]) ok = false;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    string S;
    cin >> N >> S;
    
    auto id = [](char c){
        if(c=='R') return 0;
        if(c=='G') return 1;
        if(c=='B') return 2;
    };

    vvec<ll> sum(N+1,vec<ll>(3));
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            sum[i+1][j] = sum[i][j]+(id(S[i])==j);
        }
    }
    ll ans = 0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
        if(S[i]==S[j]) continue;
        set<int> s;
        s.insert(id(S[i]));
        s.insert(id(S[j]));
        for(int k=0;k<3;k++) if(!s.count(k)){
            ans += sum[N][k]-sum[j+1][k];
            if(0<=2*j-i && 2*j-i<N && id(S[2*j-i])==k) ans--;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3760