akhauriyash/Code-Regression huggingface dataset:
N,Q = map(int,input().split())
AB = [[] for _ in range(N-1)]
for n in range(N-1):
    AB[n] = list(map(int,input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int,input().split()))
graph = [[] for _ in range(N+1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N+1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N+1)
from collections import deque
Q  = deque([1])
while Q:
    q = Q.popleft()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print(*val[1:])


Measured memory_bytes: 133036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		int[] A = new int[n];
		for(int i=0; i<n; i++) {
			A[i] = sc.nextInt();
		}
		
		int cnt = 0;
		int d = 2;
		ArrayList<Integer> G = new ArrayList<Integer>();
		while(n/d != 0) {
			G.add(n/d);
			d *= 2;
		}
		if(G.size() == 0){
			G.add(1);
		}
		int m = G.size();
		for(int i=0; i<m; i++) {
			cnt += insertionSort(A, n, G.get(i));
		}
		
		System.out.println(m);
		
		for(int i=0; i<m; i++) {
			System.out.print(G.get(i));
			if(i != m-1) {
				System.out.print(" ");
			}
		}
		System.out.println();
		
		System.out.println(cnt);
		
		for(int i=0; i<n; i++) {
			System.out.println(A[i]);
		}
	}
	
	static int insertionSort(int[] A, int n, int g){
		int cnt = 0;
		for(int i=g; i<n; i++) {
			int v = A[i];
			int j = i - g;
			while(j >= 0 && A[j] > v) {
				A[j+g] = A[j];
				j = j - g;
				cnt++;
			}
			A[j+g] = v;
		}
		return cnt;
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 117064
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;

typedef long long ll;

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

char S[10][1000];
bool flag[10];
int H, W, K;

#define INF 100000

int search(int len)
{
    if (len == H - 1) {
        int count = 0;
        REP(i, H - 1) if (flag[i]) count++;

        int sum[H];
        REP(i, H) sum[i] = 0;

        REP(i, W) {
            int t = 0;
            int a[H];
            REP(j, H) a[j] = 0;
            if (S[0][i] == '1') a[t]++;
            FOR(j, 1, H) {
                if (flag[j - 1]) t++;
                if (S[j][i] == '1') a[t]++;
            }

            REP(j, H) {
                if (a[j] > K) {
                    return INF;
                }
                if (sum[j] + a[j] > K) {
                    count++;
                    REP(k, H) sum[k] = 0;
                }
            }
            REP(j, H) sum[j] += a[j];
        }
        return count;
    }
    else {
        flag[len] = true;
        int tCount = search(len + 1);
        flag[len] = false;
        int fCount = search(len + 1);
        return min(tCount, fCount);
    }
}

int main(int argc, char **argv)
{
    cin >> H >> W >> K;
    REP(i, H) REP(j, W) cin >> S[i][j];

    REP(i, 10) flag[i] = false;
    int count = search(0);
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
function main(input) {
  var args = input.split('\n');
  var N = parseInt(args[0],10);
  var H = parseInt(args[1],10);
  var W = parseInt(args[2],10);
  var h = N - H + 1;
  var w = N - W + 1;
  console.log(h * w);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
n, m, x = map(int, input().split())
a = list(list(map(int, input().split())) for _ in range(n))

#print(n, m, x, a)

#0b00・・・０~0b111・・・１を全部作成
cost_abl = []
cost_lis = []
abl_lis = []
for i in range(1 << n):
    cost = 0
    abl_sum = [0] * m
    #print(abl_sum)
    #abl_1, abl_2, abl_3 = 0, 0 ,0
    for j in range (len(a)):
        mask = 1 << j
        if i & mask:
            cost += a[j][0]
            for k in range(m):
                abl_sum[k] += a[j][k + 1]
            # abl_1 +=  a[j][1]
            # abl_2 += a[j][2]
            # abl_3 += a[j][3]
    cost_lis.append(cost)
    abl_lis.append(abl_sum)
    #print(bin(i))
#print(cost_lis, abl_lis)

cost_new_lis = []
for i in range(len(abl_lis)):
    if min(abl_lis[i]) >= x:
        cost_new_lis.append(cost_lis[i])
    else:
        pass
#print(cost_new_lis)

if cost_new_lis == []:
    print(-1)
else:
    print(min(cost_new_lis))


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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		//scan.useDelimiter(",|?\n");
		int w=scan.nextInt();
		int n=scan.nextInt();
		String input;
		int a,b;
		int[] ans=new int[w];
		for(int i=0;i<w;i++){
			ans[i]=i+1;
		}
		//scan.useDelimiter(",|?\n");-----How!?!?!?
		for(int i=0;i<n;i++){
			input = scan.next();
			a=Integer.parseInt(input.substring(0,input.indexOf(",")));
			//System.out.println(a);
			b=Integer.parseInt(input.substring(input.indexOf(",")+1,input.length()));
			//System.out.println(b);
			a-=1;
			b-=1;
			int temp=ans[a];
			ans[a]=ans[b];
			ans[b]=temp;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 25968
package main

import (
	"fmt"
)

// type graph [][]int

func main() {
	var N int
	fmt.Scan(&N)

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

	for i := 2; i <= N; i++ {
		ai := 0
		fmt.Scan(&ai)
		// graph1[ai] = append(graph1[ai], i)
		graph1[ai]++

	}
	// fmt.Println(graph1)
	for i := 1; i <= N; i++ {
		fmt.Println(graph1[i])
	}
}


Measured memory_bytes: 6492
#include <iostream>
#include <queue>
#include <string>
using namespace std;

typedef struct _Process
{
    string name;
    int time;
} Process;

int main(){
    int n, q;
    queue<Process> queue, complete;
    
    cin >> n >> q;

    for(int i = 0; i < n; i++){
        string name;
        int time;
        cin >> name >> time;
        Process p = {name, time};
        queue.push(p);
    }

    int process_time = 0;

    while(!queue.empty()){
        Process working = queue.front();
        queue.pop();
        if (working.time - q > 0){
            process_time += q;
            working.time = working.time - q;
            queue.push(working);
        } else {
            process_time += working.time;
            cout << working.name << " " << process_time << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);
// LIS(longest increasing subsequence)
// http://even-eko.hatenablog.com/entry/2013/09/05/215236
int dp[100005];
int lis(vector<ll> &a) {
    int n = a.size();
    fill(dp, dp + n, INF);
    for (int i = 0; i < n; ++i) {
        *upper_bound(dp, dp + n, a[i]) = a[i];
    }
    return lower_bound(dp, dp + n, INF) - dp;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    reverse(all(a));
    int ans = lis(a);
    out(ans);
}


Measured memory_bytes: 1408
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s; cin >> s;
	rep(i, s.size()) cout << "x";
	cout << endl;
}

Measured memory_bytes: 768
N = int(input())
S = input()

max_num = 0
for i in range(N):
    # print(i)
    count = 0
    left = S[:i]
    right = S[i:]
    # print(left)
    # print(right)

    left_uni = list(set(left))
    right_uni = list(set(right))
    # print(left_uni)
    # print(right_uni)

    for l in left_uni:
        if l in right_uni:
            count += 1

    # print(count)

    if count > max_num:
        max_num = count

# print("===")
print(max_num)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
    int t;
    cin>>t;
    int ans=t+t*t+t*t*t;
    cout<<ans<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int res=0;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size();i++) res+=int(a[i]!=b[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String game = sc.nextLine();
		int reqMoves = 0;
		if (game.length() > 1) {
			for (int i = 0; i < game.length() - 1; i++) {
				if (game.charAt(i) != game.charAt(i + 1)) {
					reqMoves++;
				}
			}
		}
		System.out.println(reqMoves);
	}
}


Measured memory_bytes: 26292
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string S;
	cin>>S;
	int l=(int)S.length();
	rep(i,l-8)cout<<S[i];
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
        if(i == 0 || i == h-1){
      for(j=0;j<w;j++){
	cout << "#";
      }
      cout << endl;
        }
        else{
            cout << "#";
            for(j=0;j<w-2;j++){
                cout << ".";
            }
            cout << "#" << endl;
            
        }
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}


Measured memory_bytes: 3016
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int sum=0,max=0,curr;
    for(int i=0;i<n;i++){
        cin >> curr;
        sum += curr;
        if(max < curr){
            max = curr;
        }
    }
    cout << sum-max/2;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int ans = 1e9;
  rep(i,0,s.size()-t.size()+1){
    int tmp = 0;
    rep(j,0,t.size()) if(s[i+j] != t[j]) tmp++;
    ans = min(ans,tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h> 
#include <boost/math/common_factor.hpp> 

using namespace std;
using ll = long long;

int main() 
{ 
    ll a,b;
    cin>>a>>b;
	cout << boost::math::lcm(a,b)<<"\n"; 
	return 0; 
} 


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

using ll = long long;
using namespace std;

int main() {
  unsigned int n, m, k;
  cin >> n >> m >> k;
  vector<ll> as(n + 1, 0);
  vector<ll> bs(m + 1, 0);
  ll a, b;
  rep(i, n) {
    cin >> a;
    as[i + 1] = as[i] + a; 
  }
  rep(i, m) {
    cin >> b;
    bs[i + 1] = bs[i] + b;
  }
  ll count = 0;
  ll i,j;
  j = m;
  for (i = 0; i < n + 1; i++) {
    if (as[i] > k) {
      break;
    }
    while(bs[j] > k - as[i]) {
      j -= 1;
    } 
    count = max(count, i + j);
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 6340
import java.util.*;
import java.io.*;
 
public class Main {
  public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int N = s.nextInt();
	int[] count = new int[N+1];
	for(int x = 1; x <= 100; x++){
		for(int y = 1; y <= 100; y++){
			for(int z = 1; z <= 100; z++){
				if(x*x+y*y+z*z+x*y+y*z+z*x>N) break;
				count[x*x+y*y+z*z+x*y+y*z+z*x]++;
			}
		}
	}
	for(int x = 1; x <= N; x++){
		System.out.println(count[x]);
	}

    
  }
}

Measured memory_bytes: 39164
#include <stdio.h>

#define LIMIT 500000

int front = LIMIT, back = LIMIT;
int data[LIMIT * 2];

int main(void) {
	int q, i;
	if (scanf("%d", &q) != 1) return 1;
	for (i = 0; i < q; i++) {
		int query, p1, p2;
		if (scanf("%d%d", &query, &p1) != 2) return 1;
		if (query == 0 && scanf("%d", &p2) != 1) return 1;
		switch (query) {
			case 0:
				if (p1 == 0) data[--front] = p2; else data[back++] = p2;
				break;
			case 1:
				printf("%d\n", data[front + p1]);
				break;
			case 2:
				if (p1 == 0) front++; else back--;
				break;
		}
	}
	return 0;
}



Measured memory_bytes: 3268
n,m=map(int,input().split())
A=[0]*n
B=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        A[b-1]=1
    if b==n:
        B[a-1]=1

ans="IMPOSSIBLE"
for i in range(n):
    if A[i]==1 and B[i]==1:
        ans="POSSIBLE"
        break
print(ans)

Measured memory_bytes: 6132
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

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

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/

/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  /*string n;
  cin >> n;
  int ch = 0;
  rep(i, 3){
    if(n.at(i)=='7'){
      cout << "Yes" << endl;
      ch = 1;
      break;
    }
  } 
  if(ch==0) cout << "No" << endl;*/
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i, n){
    if((i+1)%15==0) A[i]=0;
    else if((i+1)%5==0) A[i] = 0;
    else if((i+1)%3==0) A[i] = 0;
    else A[i] = i+1;
  }
  int64_t sum=0;
  rep(i, n) sum += A[i];
  cout << sum << endl;

}



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

n = int(input())
a = []
b = []


res = 0

for i in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)

def f(a,b):
    c = []
    d = []
    judge = True

    cnt = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            judge = False
    if judge:
        return cnt,c,d
    
    for i in range(len(a)):
        if a[i] <= b[i]:
            cnt += b[i]
        else:
            c.append(a[i])
            d.append(b[i])
    if len(c) == 1 or max(d) == 0:
        return cnt,[],[]
    else:
        mi = min(d)
        flag = True
        pl_flag = True
        for i in range(len(c)):
            if d[i] == mi and flag:
                c[i] = d[i] + 1
                flag = False
            else:
                if pl_flag and d[i] > 0:
                    c[i] = d[i]-1
                    pl_flag = False
                else:
                    c[i] = d[i]
        return cnt,c,d

while True:
    plus,a,b = f(a,b)
    res += plus
    if a == []:
        print(res)
        break

Measured memory_bytes: 42716
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2020;
using bset = bitset<maxn>;
bool dpl[maxn][maxn], dpr[maxn][maxn];
bset beat[maxn], beatl[maxn], beatr[maxn], pl[maxn];
int main(){
	int n; cin >> n;
	for(int i = 1; i < n; i++){
		for(int j = 0; j < i; j++){
			char c; cin >> c;
			if(c == '1') beat[i][j] = 1;
			else beat[j][i] = 1;
		}
	}
	for(int i = 1; i <= n; i++){
		pl[i] = pl[i - 1];
		pl[i].set(i - 1);
	}
	for(int i = 0; i < n; i++) dpl[i][i] = 1, dpr[i][i] = 1, beatl[i][i] = 1, beatr[i][i] = 1;
	for(int i = 2; i <= n; i++){
		for(int j = 0; j + i - 1 < n; j++){
			int from = j, to = j + i - 1;
			bset fr = beatr[from + 1];
			bset bk = beatl[to];
			bset now = beat[from];
			now &= fr;
			now &= bk;
			if(now.any()){
				dpl[from][to] = 1;
				beatl[to][from] = 1;
			}
		}
		for(int j = n - 1; j - i + 1 >= 0; j--){
			int from = j, to = j - i + 1;
			bset fr = beatr[to];
			bset bk = beatl[from - 1];
			bset now = beat[from];
			now &= bk;
			now &= fr;
			if(now.any()){		
				dpr[from][to] = 1;
				beatr[to][from] = 1;
			}
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) if(dpr[i][0] && dpl[i][n - 1]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10240
import java.util.*;
import java.io.PrintWriter;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		StringBuilder s=new StringBuilder(sc.next());
		int n=s.length();
		if(s.substring(0,n/2).equals((new StringBuilder(s.substring((n+1)/2,n))).reverse().toString())){
			if(s.substring(0,(n-1)/4).equals((new StringBuilder(s.substring(((n-1)/2+1)/2,(n-1)/2))).reverse().toString())){
			if(s.substring((n+3)/2-1,(1+n-(n+3)/2)/2+(n+3)/2-1).equals((new StringBuilder(s.substring((2+n-(n+3)/2)/2+(n+3)/2-1,n))).reverse().toString())){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define DUMBER using
#define EVERY namespace
#define DAY std
DUMBER EVERY DAY;
#define el '\n'
typedef long long ll;
ll sum[100005];
int freq[100005];
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<ll,ll> > ar;
  for (int i = 1; i <= n; i++) {
    int tipe; ll val;
    cin >> tipe >> val;
    ar.push_back({val, tipe});
  }
  sort(ar.rbegin(), ar.rend());
  ll tmp = 0;
  int cnt_awal = 0;
  for (int i = 0; i < k; i++) {
    tmp += ar[i].first;
    if (freq[ar[i].second] == 0) cnt_awal++;
    freq[ar[i].second]++;
  }
  sum[cnt_awal] = tmp;
  int lo = k-1, hi = k;
  int cnt = cnt_awal;
  while (lo >= 0 && hi < n && cnt < k) {
    if (freq[ar[hi].second] == 0) {
      freq[ar[hi].second]++;
      for (int i = lo; i >= 0; i--) {
        if (freq[ar[i].second] > 1) {
          freq[ar[i].second]--; // remove
          cnt++;
          sum[cnt] = sum[cnt-1]-ar[i].first+ar[hi].first;
          lo = i-1;
          break;
        }
      }
    }
    hi++;
  }
  ll ans = -69;
  for (ll sz = cnt_awal; sz <= cnt; sz++) {
    ans = max(ans, sum[sz]+(sz*sz));
  }
  cout << ans << el;
  return 0;
}

Measured memory_bytes: 2420
hishi = 0
tyou = 0
while input = gets do
  a,b,c = input.chop.split(",").map{|n| n.to_i}
  if a == b then
    hishi += 1
  elsif a**2 + b**2 == c**2 then
    tyou += 1
  end
end
puts tyou,hishi



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

int main() {
  
  int N; cin >> N;
  
  map<int64_t, int> plan, problemSet;
  
  for (int i = 0; i < N; i++) {
    int64_t D; cin >> D;
    plan[D]++;
  }
  
  int M; cin >> M;
  
  for (int i = 0; i < M; i++) {
    int64_t T; cin >> T;
    problemSet[T]++;
  }
  
  for (auto p : problemSet) {
    
    int tmp = p.first;
    
    if (plan[tmp] < p.second) { cout << "NO" << endl; return 0; }
    
  }
  
  cout << "YES" << endl;
  
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, k);
    vector<pii> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i].fir;
        data[i].sec = i;
    }
        
    int p = -1;
    vi ans;
    rep(_, k+1) {
        sort(all(data));
        reverse(all(data));
        int np = -1;
        rep(i, n) {
            if (p != data[i].sec) {
                data[i].fir--;
                ans.pb(data[i].sec);
                np = data[i].sec;
            }
        }
        p = np;
    }

    rep(i, n) {
        if (data[i].fir < 0) {
            std::cout << -1 << std::endl;
            return 0;
        }
    }

    std::cout << ans.size() << std::endl;
    rep(i, ans.size()) {
        cout << ans[i]+1 << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
fn main() {
    let n = read::<usize>();
    let v = read_vec::<usize>();
    let mut ret = 0;
    for i in 0..n-1 {
        for j in i+1..n {
            ret += v[i] * v[j];
        }
    }
    println!("{}", ret);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int N, K;
	cin >> N >> K;
	double ans = 0.0;
	for (int i = 1; i <= N; i++) {
		int num = i;
		double sum = 1.0 / N;
		while (num < K) {
			sum /= 2.0;
			num *= 2;
		}
		ans += sum;
	}
	printf("%.10f\n", ans);
}


Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;long ans=0;
  vector<long>A(N),B(N),C(N),R1(N),R2(N);
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
  for(int i=0;i<N;i++)cin>>C[i];
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  long l=0;
  for(int i=0;i<N;i++){
    while(l<N&&A[l]<B[i])l++;
    R1[i]=l;
  }
  l=0;
  for(int i=0;i<N;i++){
    while(l<N&&B[i]>=C[l])l++;
    R2[i]=N-l;
  }
  for(int i=0;i<N;i++)ans+=R1[i]*R2[i];
  cout<<ans;
}

Measured memory_bytes: 4224
n, m = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def sum(a, n):
    sum_a = 0
    for i in range(0, n):
        sum_a += i * a[i] - (n-1-i) * a[i]
    return sum_a

sum_x = sum(x,n)
sum_y = sum(y,m)

s = sum_x * sum_y % (10**9 + 7)

print(s)

Measured memory_bytes: 19648
import java.io.*;

class Main{
  public static void main (String[] args) throws IOException{
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
    String strnum = r.readLine();
    String[] arr = strnum.split(" ");
    int a = Integer.parseInt(arr[0]);
    int b = Integer.parseInt(arr[1]);
    System.out.println((a * b) + " " +(a*2 + b*2));
  }
}

Measured memory_bytes: 24264
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int a;cin>>a;
  string s; cin>>s;
  if(a>=3200){
    cout<<s<<endl;
  }else{
    cout<<"red"<<endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = {1, -1, 0, 0};
ll dy[] = { 0,0,1,-1 };
ll W, H;
ll cnt;
char field[100][100];
void dfs(ll y, ll x) {
	field[y][x] = '#';
	for (ll k = 0; k < 4; k++) {
		ll ny = y + dy[k];
		ll nx = x + dx[k];
		if (ny >= 0 && ny <H && nx >= 0 && nx < W) {
			if (field[ny][nx] == '.')
			{
				cnt++;
				dfs(ny, nx);
			}
		}
	}
	return;
}
int main() {
	while (cin >> W >> H) {
		if (W == 0 && H == 0) { break; }
		cnt = 1;
		for (ll i = 0; i < H; i++) {
			cin >> field[i];
		}
		for (ll i = 0; i < H; i++) {
			for (ll j = 0; j < W; j++) {
				if (field[i][j] == '@') {
					dfs(i, j);
				}
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3084
//ABC

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s,t;cin>>s;
    int ans=0,a=0;
    rep(i,0,s.size()){
        if(i<s.size()-1)if(s[i]=='B'&&s[i+1]=='C'){
            t.pb('D');
            i++;
        }
        else t.pb(s[i]);
    }
    rep(i,0,t.size()){
        if(t[i]=='A')a++;
        else if(t[i]=='D')ans+=a;
        else a=0;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3920
# Settings
mod = 10**9+7


# Preparation
def inv(a, mod):
    r = [1, 0, a]
    w = [0, 1, mod]
    while w[2] != 1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = w
        w = r_new
    x, y = w[0], w[1]    # a*x+y*mod = 1
    return (mod+x % mod) % mod


max_num = 5*10**5+2  # 10**6 にしたほうがよい?
fact = [0 for _ in range(max_num)]
ifact = [0 for _ in range(max_num)]

fact[0] = fact[1] = 1
ifact[0] = ifact[1] = 1

for i in range(2, max_num):
    fact[i] = fact[i-1] * i % mod

ifact[max_num-1] = inv(fact[max_num-1], mod)

for i in range(2, max_num):
    ifact[max_num-i] = (ifact[max_num-i+1] * (max_num-i+1)) % mod


def comb(x, y):
    if x < 0 or y < 0 or x < y:
        return 0
    else:
        return fact[x] * ifact[y] * ifact[x-y] % mod


# Code
def solve():
    tmp = 0
    for i in range(1, n+1):
        tmp2 = comb(n, i) * fact[m-i] * ifact[m-n]
        tmp2 %= mod
        tmp += (-1)**(i-1)*tmp2

    tmp = fact[m]*ifact[m-n] - tmp
    tmp %= mod

    ans = tmp*fact[m]*ifact[m-n]
    ans %= mod

    return ans


if __name__ == "__main__":
    n, m = map(int, input().split())
    print(solve())


Measured memory_bytes: 153776
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } 
int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int>B(M);
  rep0(i,M)cin >> B[i];
  int temp = 0;
  int ans = 0;
  int subans = 0;
  int solve = 0;
  rep0(i,N){
    rep0(j,M){
      cin >> temp;
      ans  = temp * B[j];
      subans += ans;
    }
    subans += C;
    if(subans > 0)solve++;
    ans = 0;
    subans = 0;
  }
  cout << solve << endl;
  return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut pair = vec![];
    for i in 0..n {
        pair.push((a[i], i));
    }
    pair.sort();

    for i in 0..n-1 {
        print!("{} ", pair[i].1+1);
    }
    println!("{}", pair[n-1].1+1);
}


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

int main(){
	int n,l;
	cin >> n >> l;
	string s,temp;
	vector<string> v(n);
	for(int i=0;i<n;i++){
		cin >> temp;
		v[i] = temp;
	}
	sort(v.begin(), v.end());
	for(string x: v){
		cout << x;
	}
	
	
	
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n,m,x;
  cin>>n>>m>>x;
  int sum=0;
  int inf=0;
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    if(a<x) inf++;
    sum++;
  }
  cout<<min(sum-inf,inf)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MaxN 200002
#define x first
#define y second
using namespace std;

char res[MaxN+1];
char s[MaxN+1];
int st[256], dr[256], ap[256], good[256], best[256];
pair<int, int> endpoint[MaxN+1];
int dp[8000][26];
int N, M;

int main(){

    int i, j, remain, let, curr, nxt, ok = 0, bucket = 0;

    scanf("%s", s);
    N = strlen(s);

    for(i = N; i >= 1; --i) s[i] = s[i-1];
    for(i = 1; i <= N; i = j)
    {
        remain = 26;
        for(let = 'a'; let <= 'z'; ++let) ap[let] = 0;
        for(j = i; j <= N && remain; ++j)
            if(++ap[ s[j] ] == 1) --remain;

        endpoint[++bucket] = {i, j - 1};
        if(j > N && remain){
            ok = 1;
            for(let = 'a'; let <= 'z'; ++let)
            if(!ap[let]) best[let] = 1;
        }
    }

    for(let = 'a'; let <= 'z'; ++let)
        if(best[let] == ok) good[let] = bucket - ok;

    if(bucket == 1 && ok == 1)
        for(let = 'a'; let <= 'z'; ++let)
        if(!ap[let]){
            printf("%c", let);
            return 0;
        }

    for(i = bucket - ok; i >= 1; --i)
    {
        for(let = 'a'; let <= 'z'; ++let) ap[let] = 0;
        for(j = endpoint[i].x; j <= endpoint[i].y; ++j){
            dr[ s[j] ] = j;
            if(++ap[ s[j] ] == 1) st[ s[j] ] = j;
        }

        for(let = 'a'; let <= 'z'; ++let)
        if(st[let] > 0)
        {
            for(nxt = 'a'; nxt <= 'z'; ++nxt)
            if(st[let] >= dr[nxt] && good[nxt] == i){
                dp[i][let-'a'] = nxt;
                best[let] = (1 << 30) + i;
                break;
            }
        }

        for(let = 'a'; let <= 'z'; ++let)
            if(best[let] == (1 << 30) + i) good[let] = i - 1;
    }

    for(let = 'a'; let <= 'z'; ++let)
    if(dp[1][let-'a']){
        res[M++] = let;
        curr = dp[1][let-'a'];
        break;
    }

    for(i = 2; i <= bucket; ++i){
        res[M++] = curr;
        curr = dp[i][curr-'a'];
    }

    if(!ok) res[M++] = 'a';
    printf("%s", res);


return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve(){
	int n,m;
	cin>>n>>m;
	VI h(n+1);
	rep(i,1,n+1)cin>>h[i];
	vector<set<int> > road(n+1);
	rep(i,0,m){
		int x,y;
		cin>>x>>y;
		road[x].insert(y);
		road[y].insert(x);
	} 
	VI vis(n+1,0);
	int ans = n;
	set<int> no;
	rep(i,1,n+1){
		if(!vis[i]){
			queue<int> q;
			q.push(i);
			while(!q.empty()){
				int m = q.size();
				rep(j,0,m){
					int v = q.front();
					vis[v] = 1;
					q.pop();
					for(auto u:road[v]){
						if(h[v]<=h[u])//v不是
						{
							//cout<<v;
							//cout<<"FF"<<endl;
							no.insert(v);
							break;
						}else{
							vis[u]=1;//u不是 
							//cout<<u<<"FF"<<endl;
							no.insert(u);
						}
					}
				}
			}
		}
	}
	cout<<n-sz(no);
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






Measured memory_bytes: 20584
crd_num = gets(chomp:true).to_i

ary = []
ary = gets().split.map(&:chars)

def stable_sort(n, ary)

  def bubble_sort(n, ary)
    flag = 1
    i = 1
    while flag == 1
      flag = 0
      (n-1).downto(i) do | num |
        if ary[num][1] < ary[num-1][1]
          ary[num], ary[num-1] = ary[num-1], ary[num]
          flag = 1
        end
      end
      i += 1
    end
    ary.map(&:join).join(" ")
  end

  def selection_sort(n, ary)
    n.times do |fix|
      min = fix
      (fix...n).each do |srh|
        if ary[min][1] > ary[srh][1]
          min = srh 
        end
      end
      unless fix == min
        ary[fix], ary[min] = ary[min], ary[fix]
      end
    end
    ary.map(&:join).join(" ")
  end

  ary1 = ary.dup
  b_sort = bubble_sort(n, ary)
  s_sort = selection_sort(n, ary1)

  puts b_sort
  puts "Stable"
  puts s_sort
  puts b_sort == s_sort ? "Stable" : "Not stable"

end

stable_sort(crd_num, ary)


Measured memory_bytes: 6884
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while (true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0){
                break;
            }
            for (int i = 0; i < h; i++){
                for (int j =0; j < w; j++){
                    System.out.print("#");
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 35088
#include <stdio.h>
#include <math.h>
#include<stdio.h>
#define M_PI 3.14159265358979323846
int main(){
  double a,b;
 
  scanf("%lf", &a);//
  
  printf("%.6f %.6f\n", M_PI*a*a,M_PI*2.0*a);
  return 0;
}



Measured memory_bytes: 2704
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   



      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
        ll a,b;
        cin>>a>>b;
        cout<<6-a-b;
         

      }
      






}

Measured memory_bytes: 256
n = int(input())
a = sorted(int(input()) for _ in range(n))
if n == 2:
    print(abs(a[0] - a[1]))
elif n%2 == 1:
    r1 = a[n//2] + a[n//2+1] + sum(a[n//2+2:])*2 - sum(a[:n//2])*2
    r2 = sum(a[n//2+1:])*2 - sum(a[:n//2-1])*2 - a[n//2-1] - a[n//2]
    print(max(r1, r2))
else:
    r1 = sum(a[n//2+1:])*2 + a[n//2] - sum(a[:n//2-1])*2 - a[n//2-1]
    print(r1)

Measured memory_bytes: 7504
#include <bits/stdc++.h>
using namespace std ;
typedef long double ld ;
const double delta = 0.9993 ;
ld x[ 60 ] , y[ 60 ] ;
int n ;
ld ans = 100000 , Ans = 100000 ;
ld sumx , sumy ;
ld t ;
inline ld dis ( ld x1 , ld y1 , ld x2 , ld y2 ) {
	return sqrt ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ;
}
inline ld dist ( ld sumx , ld sumy ) {
	ld mindist = 0 ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		mindist = max ( mindist , dis ( x[ i ] , y[ i ] , sumx , sumy ) ) ;
	}
	return mindist ;
}
inline void SA () {
	t = 200000000 ;
	while ( t > 1e-14 ) {
		ld a = ( rand () * 2 - RAND_MAX ) * t , b = ( rand () * 2 - RAND_MAX ) * t ;
		ld tmp = dist ( sumx + a , sumy + b ) ;
		/*if ( t <= 1000 ) */
		if ( ans - tmp > 0 ) {
			sumx += a ;
			sumy += b ;
			ans = tmp ;
			Ans = min ( ans , Ans ) ;
		}
		else if ( exp ( ( tmp - ans ) / t ) < ( ld ) rand () / RAND_MAX ) {
			sumx += a ;
			sumy += b ;
			ans = tmp ;
		}
		//printf ( "%.18Lf %.18Lf %.18Lf %.18Lf \n " , sumx , sumy , tmp , Ans ) ;
		t *= delta ;
	}
}
signed main () {
	srand ( time ( 0 ) ) ;
	cin >> n ;
	for ( int i = 1 ; i <= n ; i ++ ) {
		cin >> x[ i ] >> y[ i ] ;
		sumx += x[ i ] ; sumy += y[ i ] ;
	}
	sumx /= n ; sumy /= n ;
	for ( int i = 1 ; i <= 20 ; i ++ ) SA () ;
	printf ( "%.18Lf" , Ans ) ;
	return 0 ;
}


Measured memory_bytes: 384
N, = map(int, raw_input().split())
a = map(int, raw_input().split())
mi = 0
ma = abs(a[0])
for i in range(1,N):
  if abs(a[i])>ma:
    ma = abs(a[i])
    mi = i
print 2*N
if a[mi]>=0:
  print mi+1, N
  print mi+1, N
  for i in range(N-1):
    print N, i+1
    print N, N
else:
  print mi+1, 1
  print mi+1, 1
  for i in range(N-1, 0, -1):
    print 1, i+1
    print 1, 1

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

using namespace std;

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

    int n;
    cin >> n;
    int arr[n];
    long long ans = 0;
    map<int, int> mp;

    for (int i = 0; i < n; i++)
        cin >> arr[i], mp[i - arr[i]]++;
    for (int i = 0; i < n; i++)
        ans += mp[arr[i] + i], mp[i - arr[i]]--;

    cout << ans << "\n";

    return 0;
}

/*
j - i = a[i] + a[j]
a[i] + i = j - a[j]
*/

Measured memory_bytes: 21356
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define INF (1 << 30)

vector<pair<int, int> > v;



int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		v.push_back(make_pair(x - l, x + l));
	}
	sort(v.begin(), v.end());
	int cur = -INF;
	int ret = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i].first >= cur) {
			ret++;
			cur = v[i].second;
		} else if (v[i].second < cur) {
			cur = v[i].second;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 4304
#include<stdio.h>

int main(){

int N,A,B,ans=0;
scanf("%d%d%d",&N,&A,&B);
if (N==10000&&A>=1)
{
  ans += 10000;
  N = 9999;
}

for (int i = 0; i < 10; i++){
  for (int j = 0; j < 10; j++){
    for (int k = 0; k < 10; k++){
      for (int l = 0; l < 10; l++){
        if (N<i*1000+j*100+k*10+l){  goto loop_break;}
        
        int check = i + j + k + l;

        if (A<=check&&check<=B){  ans+=(i*1000+j*100+k*10+l);}
      }
    }
  }
}

loop_break:
printf("%d",ans);
return 0;

}

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

 

int main() {
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    string point = T;
    ll ans = 0;
    rep(i,N) {
        if(i - K >= 0 && point.at(i) == point.at(i-K)) point.at(i) = 0;
        if (point.at(i) == 'r') ans += P;
        if (point.at(i) == 's') ans += R;
        if (point.at(i) == 'p') ans += S;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3848
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>


using namespace std;

int main()
{
	int a[10005],n=10005,i;
	for( i=0;i<n;i++)
		{
			cin>>a[i];
	if(a[i]==0)
		break;
	}
	for( int k=0;k<i;k++)
		{
			cout<<"Case "<<k+1<<": "<<a[k]<<endl;

	
	}
	


}

Measured memory_bytes: 3032
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll s=n*k/(__gcd(n,k));
    cout<<s<<endl;
}

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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

int32_t main() {
	FAST_IO;
	
	int n;
	cin >> n;
	
	int h[n];
	for (int& x: h) cin >> x;
	
	vi dp(n);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	
	for (int i = 2; i <= n; i++) {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	
	cout << dp[n-1] << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


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

using namespace std;

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

	int ans = 0;

	for (int i = 1; i <= N; i += 2) {
		int divisor = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				divisor++;
			}
		}
		if (divisor == 8) {
			ans++;
		}
	}

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


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

// VJUDGE

const int N = 100 * 1001, M = 110;
int n, a[N], k;
bool dp[N];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i <= k; i++) {
		bool win = false;
		for (int j = 0; j < n; j++) {
			if (a[j] <= i && !dp[i - a[j]])
				win = true;
		}
		if (win)
			dp[i] = true;
	}
	cout << (dp[k] ? "First\n" : "Second\n");
}


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

int main() {
  uint32_t N = 0;
  std::cin >> N;
  std::vector<uint32_t> A1(N);
  std::cin >> A1[0];
  for (size_t i = 1; i < N; i++) {
    std::cin >> A1[i];
    A1[i] += A1[i - 1];
  }

  std::vector<uint32_t> A2(N);
  for (size_t i = 0; i < N; i++) std::cin >> A2[i];
  for (size_t i = N - 1; i > 0; i--) A2[i - 1] += A2[i];

  uint32_t max = 0;
  for (size_t i = 0; i < N; i++) {
    if (A1[i] + A2[i] > max) max = A1[i] + A2[i];
  }
  std::cout << max << std::endl;
  return 0;
}

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

int main(){
    int n;
    while(cin >> n && n){
        vector<int> a(n,0);
        for(int i=0; i<n; ++i){
            cin >> a[i];
        }
        // ????????£?¶??????????????????§??£?¶???????dp??¨?????????
        vector<int> dp(n,0);
        dp[0] = a[0];
        int max = dp[0];
        for(int i=1; i<n; ++i){
            if(dp[i-1]>0){
                dp[i] = dp[i-1] + a[i];
            } else {
                dp[i] = a[i];
            }
            if(max<dp[i]){
                max = dp[i];
            }
        }
        cout << max << endl;
    }
}

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

int main(){
	int n;
  	cin >> n;
  long long int a[n],b[n+1],ans=LLONG_MAX;
  b[0]=0;
  	for(int i=0;i<n;i++){
      cin >>a[i];
      b[i+1]=b[i]+a[i];
      //cerr<<b[i+1]<<endl;
    }
  for(int i=0;i<n-1;i++){
    ans=min(ans,abs(b[n]-2*b[i+1]));
    cerr<<b[i+1]<<ans<<endl;
  }
  cout << ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
    int N;
    int L[10];
    int Lmax;
    int s;
    int i;

    scanf("%d\n",&N);

    for(i=0;i<N;i++){
        if(i==N-1){
            scanf("%d\n",&L[i]);
        }
        else{
            scanf("%d ",&L[i]);
        }
    }

    Lmax=0;
    s=0;

    for(i=0;i<N;i++){
        s=s+L[i];

        if(L[i]>Lmax){
            Lmax=L[i];
        }
    }
    s=s-Lmax;

    if(Lmax<s){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}

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

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

  int n, m;
  cin >> n >> m;

  int l = 1, r = n / 2;
  while (m > 0 && l < r) {
    cout << l << ' ' << r << '\n';
    ++l;
    --r;
    --m;
  }

  l = n / 2 + 1; r = n - (n % 2 == 0);
  while (m > 0 && l < r) {
    cout << l << ' ' << r << '\n';
    ++l;
    --r;
    --m;
  }
}

Measured memory_bytes: 3652