akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>

int main() {
  int n, r;
  int min = INT_MAX;
  int diff = INT_MIN;
  
  scanf("%d", &n);

  for (int i=0; i<n; i++) {
    scanf("%d", &r);

    if (r - min > diff) {
      diff = r - min;
    }
    if (r < min) {
      min = r;
    }
  }
  
  printf("%d\n", diff);
  
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> B(N - 1);
    for(int i = 0; i < N - 1; i++) cin >> B[i];
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        if(i == 0) {
            ans += B[0];
        }else if(i == N - 1){
            ans += B[N - 2];
        }else{
            ans += min(B[i - 1], B[i]);
        }
    }
    cout << ans << endl;
    cin >> N;
    return 0;
}

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

void solve(long long N, std::vector<long long> a) {
    ll ans = 0;
    rep(i, N) {
        if (a[i] % 2 == 1 && (i + 1) % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll choose2(ll n) {
    return n * (n - 1) / 2;
}

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) A[i] --;
    vector<int> Am(N, 0);
    rep(i,N) Am[A[i]] += 1;
    ll sum = 0;
    rep(i,N) sum += choose2(Am[i]);
    rep(i,N) {
        // ll ret = sum - (Am[A[i]] - 1);
        ll ret = sum;
        ret -= choose2(Am[A[i]]);
        ret += choose2(Am[A[i]] - 1);
        cout << ret << endl;
    }
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N;
int main(){
  int Alice=0,Bob=0;
  int turn=0;
  int num;
  cin>>N;
  vector<int> v;
  for(int i=0;i<N;i++) {
    cin>>num;
    v.push_back(num);
  }
  sort(v.begin(),v.end(),greater<int>());
  for(auto itr=v.begin();itr!=v.end();++itr){
    if(turn==0){
      Alice+=*itr;
      turn=1;
    }else{
      Bob+=*itr;
      turn=0;
    }
  }
  cout<<Alice-Bob<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int h = scan.nextInt();
        int w = scan.nextInt();
        System.out.println(H*W-h*W-w*H+h*w);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a) (a).begin(), (a).end()

using namespace std;

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

    cout << "ABC" << N << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        double target = scanner.nextDouble();
    //    long start = System.currentTimeMillis(); 
        long ans = calc(target);
    //    long end = System.currentTimeMillis(); 
    //    long time = end - start;
        System.out.println(ans );
    //    System.out.println(time +"ms");
    }
    
    /**
     * @param target
     * @return
     */
    public static  long calc(double target){
        long targetNum = (long)target;
        long divNum = 0;
        long sumNum = 0;
        divNum = (long) Math.sqrt(target);
        for (long i = divNum; i > 0; i--) 
        {
            if (targetNum % i == 0 ) 
            {
                divNum = i;
                break;
            }
        }
        sumNum = (targetNum / divNum) + divNum -2;
        return sumNum;
    }
}

Measured memory_bytes: 25044
#include<iostream>
using namespace std;
int main(){

	int n,i,x[100],h;
	cin>>n;

	for(i=0;i<n;i++)
	{
		cin>>x[i];
	}
	for(h=n-1;h>0;h+=-1)
	{
		cout<<x[h]<<" ";
		
	}
	cout<<x[0];
	cout<<endl;



	return 0;
}


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

int s[21][41];
int main(void){
    int r, n, xl, xr, h;
    while(cin >> r >> n && r) {
        rep(i, 41) rep(j, 41) s[i][j] = 0;
        rep(i, n) {
            cin >> xl >> xr >> h;
            for(int y=0; y<h; ++y) {
                for(int x=xl+20; x<xr+20; ++x) {
                    s[y][x] = 1;
                }
            }
        }
        /*for(int y=20; y>=0; --y) {
            rep(x, 41) cout << s[y][x];
            cout << endl;
        }*/
        double mint = numeric_limits<double>::max();
        rep(y, 21) {
            for(int x=-r+20; x<r+20; ++x) {
                if(s[y][x] == 0) {
                    double t;
                    if(x<20) t = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-19.0, 2.0));
                    else t = (double) y+r-sqrt(pow((double)r,2.0)-pow(x-20.0, 2.0));
                    mint = min(mint, t);
                }
            }
        }
        cout << fixed << setprecision(4) << mint << endl;
    }
}

Measured memory_bytes: 1240
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)

int main(void) {
	char S[5];

	scanf("%s", S);

	int32_t score = 0;
	for (uint32_t idx = 0; idx < 4; idx++) {
		score += S[idx] == '+' ? 1 : -1;
	}

	printf("%"PRId32, score);

	return 0;
}


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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int n, m;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  cin >> m;
  vector<int> b(m);
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  vector<int> v;
  set_intersection(begin(a), end(a), begin(b), end(b), inserter(v, end(v)));
  for(int i = 0; i < v.size(); i++){
    cout << v[i] << "\n";
  }
  return 0;
}



Measured memory_bytes: 4680
n = int(input())

adj_mat = [[0 for i in range(n + 1)] for j in range(n)]

for i in range(n):
    listed_input = list(map(int, input().split()))
    for j in listed_input[2:]:
        adj_mat[i][j] = 1

for adj_list in adj_mat:
    print(*adj_list[1:])

Measured memory_bytes: 8508
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


ans = 0


for i in range(1, 1 + N, 2):
    temp = factorization(i)
    num = 1
    # print(i, temp)
    for x in temp:
        num = num * (x[1] + 1)

        if num == 8:
            ans += 1


print(ans)

Measured memory_bytes: 81912
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int tmp = sc.nextInt();
                a[tmp - 1]++;
            }
        }
        sc.close();

        int ans = 0;
        for (int i = 0; i < m; i++) {
            if (a[i] == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define sz 100005
using namespace std;

char a[sz];

int main()
{


    FASTIO
    ll n,k;
    cin >> n >> k;
    for(ll i=1;i<=n;i++)
    cin >> a[i];

    ll l,r;
    l=r=0;
    for(ll i=1;i<n;i++)
    {
      if(a[i]=='L' && a[i+1] == 'L')l++;
      if(a[i]=='R' && a[i+1] == 'R')r++;
    }
    vector <ll> L,R;
    for(ll i=1;i<=n;i++)
    {
      char x = a[i];

      ll st = i;

      while( i <= n && x == a[i] )
      {

        i++;


      }
      i--;
      if(i == n && st == 1 )
      {if(x == 'L')
        R.pb(0);
      else
      L.pb(0);
      break;
    }
    if(i == n || st == 1)
    {
      if(x == 'L')
        R.pb(1);
      else
      L.pb(1);

    }
    else
    {
      if(x == 'L')
        R.pb(1+1);
      else
      L.pb(1+1);
    }

    }
    sort(all(L));
    sort(all(R));
    reverse(all(L));
    reverse(all(R));

    ll szz = L.size();
    ll prel = l;
    ll prer = r;

    for(ll i=0;i<min(k,szz);i++)
    {
      l+=L[i];
    }
    szz = R.size();
    for(ll i=0;i<min(k,szz);i++)
    {
      r+=R[i];
    }

    cout<<max(l+prer,r+prel);




return 0;
}


Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  int n,k;
  int dp[100005],h[100005];
  
  cin >> n >> k;
  for(int i=0; i<n; i++) cin >> h[i];
  
  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  
  for(int i=2; i<n; i++){
    dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    for(int j=2; j<=k; j++){
      if(i - j < 0) break;
      dp[i] = min(dp[i-j] + abs(h[i] - h[i-j]), dp[i]);
    }
  }
  
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		for (var i = a[1] - a[0] + 1; i < a[1] + a[0];) Console.Write($"{i++} ");
	}
}


Measured memory_bytes: 13396
using System; 
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] s = Console.ReadLine().Select(x => x - '0').ToArray();

        long res = 0;
        int max = Convert.ToInt32(Math.Pow(2, s.Length - 1));
        for (int i = 0; i < max; i++)
        {
            bool[] bitmask = Convert.ToString(i, 2).PadLeft(s.Length - 1, '0').Select(x => x == '1').ToArray();
            long num = s[0];
            for (int j = 1; j < s.Length; j++)
            {
                if (bitmask[j - 1])
                {
                    res += num;
                    num = s[j];
                }
                else
                {
                    num = num * 10 + s[j];
                }
            }
            res += num;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int c[1000100] = {};
int f[1000100] = {};

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		c[a[i]]++;
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	
	for (int i = 0; i < a.size(); i++) {
		for (int j = a[i]; j < 1000100; j += a[i]) {
			f[j] += c[a[i]];
		}
	}

	int ans = 0;
	for (int i = 0; i < a.size(); i++) {
		if (f[a[i]] == 1) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vi h(n);
    rep(i,n){
        cin>>h[i];
    }
    ll ans = 0;
    ll count = 0;
    for(int i=1; i< n ; i++){
        if(h[i] <= h[i-1]){
            count++;
        } else {
            count = 0;
        }
        ans = max(ans, count);
    }
    cout<<ans<<endl;

    timer();
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main(){
	int n,a,d[4][14]={0};
	char c;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%s %d",&c,&a);
		//printf(" c%c a%d\n",c,a);
		if(c=='S') d[0][a]=1;
		else if(c=='H') d[1][a]=1;
		else if(c=='C') d[2][a]=1;
		else if(c=='D') d[3][a]=1;
 	}
	for(int i=0;i<4;i++){
		for(int j=1;j<=13;j++){
			if(d[i][j]==0){
				if(i==0) c='S';
				else if(i==1) c='H';
				else if(i==2) c='C';
				else if(i==3) c='D';
				printf("%c %d\n",c,j);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
#include <vector>
using namespace std;

int P[100001];

int root (int i) {
  if (P[i] == i) {
    return i;  
  }  
  P[i] = root(P[i]);
  return P[i];
}

void unite (int i, int j) {
  // iにjをくっつける
  P[root(j)] = root(i);  
}

int main () {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i <= n; i++) {
    P[i] = i;  
  }
  int p[n + 1];
  p[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> p[i + 1];  
  }
  for (int i = 0; i < m; i++) {
    int s, ss;
    cin >> s >> ss;
    unite(s, ss);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (root(i) == root(p[i])) {
      ans++;  
    }  
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n{};
	string s="";
	cin>>n>>s;
	int p{};
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			i+=2;
			p++;
		}
		else {
			continue;
		}
		
	}
	cout<<p;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin>>s;
int n=s.length()-1;
if(s[n]=='2' || s[n]=='4' || s[n]=='5' || s[n]=='7' || s[n]=='9')
{
cout<<"hon";
}
else if(s[n]=='0' || s[n]=='1' || s[n]=='6' || s[n]=='8' )
{
cout<<"pon";
}
else if(s[n]=='3')
{
cout<<"bon";
}
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll X;
  cin>>X;
  rep(i,6000) rep(j,6000){
    ll A=(i-3000)*(i-3000)*(i-3000)*(i-3000)*(i-3000);
    ll B=(j-3000)*(j-3000)*(j-3000)*(j-3000)*(j-3000);
    if(A-B==X){
      cout<<i-3000<<" "<<j-3000<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <typeinfo>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;
 
 
int main(){
  string s;
  int n=0, result=0;
  cin >> s;
  for(int i = 0;i<(int)(s.length());i++){
    n = (int)(s[i])-'0';
    result=(result + n)%9;
  }
  
  if(result==0){
  	cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
 
  
}


Measured memory_bytes: 3716
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, a: "List[int]"):
    ans = [0] * N
    for i in range(N):
        if(a[i]%4 == 0):
            ans[i] = 4
        elif(a[i]%2 == 0):
            ans[i] = 2
        else:
            ans[i] = 1

    if(ans.count(1) > ans.count(4)+1):
        print(NO)
    else:
        if(ans.count(1) == ans.count(4)+1):
            if(ans.count(2) == 0):
                print(YES)
            else:
                print(NO)
        else:
            print(YES)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

const char A = 0;
const char B = 1;
const char C = 2;

// 0022
int main() {
  long long n;
  cin >> n;

  vector<ll> a(n);
  vector<ll> b(n);
  vector<ll> c(n);

  for (long long i = 0; i < n; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i);
  }

  vector<vector<ll>> dp(n, vector<ll>(3, 0));

  dp.at(0).at(A) = a.at(0);
  dp.at(0).at(B) = b.at(0);
  dp.at(0).at(C) = c.at(0);

  for (long long i = 1; i < n; i++) {
    dp.at(i).at(A) =
        max(dp.at(i - 1).at(B) + a.at(i), dp.at(i - 1).at(C) + a.at(i));
    dp.at(i).at(B) =
        max(dp.at(i - 1).at(A) + b.at(i), dp.at(i - 1).at(C) + b.at(i));
    dp.at(i).at(C) =
        max(dp.at(i - 1).at(A) + c.at(i), dp.at(i - 1).at(B) + c.at(i));
  }

  cout << max(max(dp.at(n - 1).at(A), dp.at(n - 1).at(B)), dp.at(n - 1).at(C))
       << endl;
}


Measured memory_bytes: 11144
#include <cstdio>
using namespace std;
bool solve() {
    int X;
    scanf("%d%*c", &X);
    if (X >= 2000) return true;
    int n = X / 100;
    return 100 * n <= X && X <= 105 * n;
}
int main() {
    printf("%d\n", solve());
}


Measured memory_bytes: 128
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [usize; n],
    }

    l.sort();

    let mut ans = 0;
    for i in 0..n {
        for j in (i + 1)..n {
            for k in (j + 1)..n {
                // if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
                //     ans += 1;
                // }
                if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
                    continue;
                }
                if l[k] < l[i] + l[j] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i] {
                    ans += 1;
                }
            }
        }
    }

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


Measured memory_bytes: 2144
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef vector<vector<int> > Mat;
const int inf = 1e9;

int dfs(int pos, int g, int amount, vector<bool> &used, Mat &adj, Mat &flow){
    if(pos == g) return amount;
    if(used[pos]) return -1;
    used[pos] = true;
    
    for(int i=0; i<(int)adj.size(); i++){
        if(adj[pos][i] > 0){
            int ret = dfs(i, g, min(amount, adj[pos][i]), used, adj, flow);
            if(ret > 0){
                adj[pos][i] -= ret;
                adj[i][pos] += ret;
                flow[pos][i] += ret;
                flow[i][pos] -= ret;
                return ret;
            }
        }
    }
    return -1;
}

Mat solve(int s, int g, Mat adj){
    int n = adj.size();
    Mat ret(n, vector<int>(n, 0));
    while(1){
        vector<bool> used(n, false);
        if(dfs(s, g, inf, used, adj, ret) == -1) break;
    }
    return ret;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> s(m), d(m);
    Mat adj(n+1, vector<int>(n+1, 0));
    for(int i=0; i<m; i++){
        cin >> s[i] >> d[i];
        adj[s[i]][d[i]]++;
        adj[d[i]][s[i]]++;
    }
    int x,y;
    cin >> x >> y;

    Mat flow = solve(x, y, adj);
    int mflow = 0;
    for(int i=1; i<=n; i++){
        mflow += flow[i][y];
    }
    cout << mflow << endl;
    
    vector<int> rev;
    for(int i=0; i<m; i++){
        bool f = false;
        if(flow[s[i]][d[i]] > 0) f = true;
        if(flow[d[i]][s[i]] > 0 && flow[d[i]][s[i]] == adj[s[i]][d[i]]){
            f = true;
            swap(s[i], d[i]);
            rev.push_back(i+1);
        }
        if(f){
            flow[s[i]][d[i]]--;
            flow[d[i]][s[i]]++;
            adj[s[i]][d[i]]--;
            adj[d[i]][s[i]]--;
        }
    }
    cout << rev.size() << endl;
    for(int i=0; i<(int)rev.size(); i++){
        cout << rev[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll t[1000];
ll a[1000];

int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>t[i]>>a[i];
	
	for(int i=1;i<n;i++)
	{
		ll tt=t[i];
		ll aa=a[i];
		//逆転の解消
		ll mul=max(t[i-1]/t[i]+(t[i-1]%t[i]>0),a[i-1]/a[i]+(a[i-1]%a[i]>0));
		//cerr<<mul<<endl;
		t[i]*=mul;
		a[i]*=mul;
		/*
		//得票数を求める
		while(t[i]<t[i-1] && a[i]<a[i-1])
		{
			t[i]+=tt;
			a[i]+=aa;
		}*/
	}
	ans=t[n-1]+a[n-1];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
 
using namespace std;
 
int main() {
    int n;
    cin >> n;
    map<int,int> mp1;
    map<int,int> mp2;

    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (i % 2 == 0) {
            mp1[x]++;
        } else {
            mp2[x]++;
        }
    }

    vector<pair<int,int>> v1;
    vector<pair<int,int>> v2;

    for (auto &p: mp1) {
        v1.push_back( {p.second, p.first} );
    }
    for (auto &p: mp2) {
        v2.push_back( {p.second, p.first} );
    }
    if (v1.size() == 1) {
        v1.push_back( {0, -1} );
    }
    if (v2.size() == 1) {
        v2.push_back( {0, -1} );
    }
    sort(v1.begin(), v1.end());
    reverse(v1.begin(), v1.end());
    
    sort(v2.begin(), v2.end());
    reverse(v2.begin(), v2.end());

    if (v1[0].second != v2[0].second) {
        cout << n - v1[0].first - v2[0].first << endl;
    } else {
        cout << n - max(v1[0].first + v2[1].first, v1[1].first + v2[0].first) << endl;
    }

    return 0;
}

Measured memory_bytes: 6136
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int H, W, h, w; cin >> H >> W >> h >> w;

  cout << (H*W - (h*W + w*H) + h*w);
}


Measured memory_bytes: 256
n = int(input())
h = [list(map(int, input().split())) for _ in range(n)]

x, y, z = 0, 0, 0
for a, b, c in h:
    x, y, z = max(y,z) + a, max(x,z) + b, max(x,y) + c

print(max(x, y, z))

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

int main() {
	int r, d, x[11];
	cin >> r >> d >> x[0];
	for (int i = 1; i <= 10; i++) {
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>
#include<tuple>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

int main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	int su = a - 1;
	int hu = b - 1;
	while (1) {
		if (hu == d - 1) {
			break;
		}
		hu++;
		if (s[hu] == '#') {
			hu++;
			if (s[hu] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	while (1) {
		if (su == c - 1) {
			break;
		}
		su++;
		if (s[su] == '#') {
			su++;
			if (s[su] == '#') {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	if (su < hu) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		for (int i = b-2; i < d-1; i++) {
			if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
				cout << "Yes" << endl;
				return 0;
			}
		}

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

Measured memory_bytes: 3752
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		if(a<=8&&b<=8){
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}

	}
}

Measured memory_bytes: 21844
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

#include <bits/stdc++.h>
using namespace std;

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

signed main()
{
  ios::sync_with_stdio(false);
  int K;
  while (cin >> K, K){
    int sum = 0;
    REP(i, K * (K - 1) / 2){
      int c;
      cin >> c;
      sum += c;
    }
    print(sum / (K - 1));
  }

  return (0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for (auto& i : a) { cin >> i; }
    int m = n / 2;
    if (n % 2 > 0) {
        for (int i = 0, j = 0; j < n; ++j) {
            b[m + i] = a[j];
            if (i >= 0) { ++i; }
            i *= -1;
        }
        
        for (int i = 0; i < n - 1; ++i) {
            cout << b[n - i - 1] << " ";
        }
        cout << b[0] << endl;
    } else {
        for (int i = 0, j = 0; j < n; ++j) {
            b[m + i] = a[j];
            if (i >= 0) { ++i; }
            i *= -1;
        }
        
        for (int i = 0; i < n - 1; ++i) {
            cout << b[i] << " ";
        }
        cout << b[n - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define vi vector <int>
#define endl "\n"
#define f(n) for(int i=0;i<n;i++)
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define gcd __gcd
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define setBits(x) __builtin_popcountll(x)
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define N 100005
#define mod 1000000007
int solve()
{
	int n,m;
	cin>>n>>m;
	vector<vector<char>>v(n,vector<char>(m));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>v[i][j];
		}
	}	
	vector<vector<int> > dp(n,vector<int> (m));
	dp[0][0]=1;
	for(int i=1;i<n;i++)
	{
		if(v[i][0]=='#')
		{
			dp[i][0]=0;
		}
		else
		{
			dp[i][0]=dp[i-1][0];
		}
	}
	for(int j=1;j<m;j++)
	{
		if(v[0][j]=='#')
		{
			dp[0][j]=0;
		}
		else
			dp[0][j]=dp[0][j-1];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<m;j++)
		{
			if(v[i][j]=='#')
			{
				dp[i][j]=0;
			}
			else
			{
				dp[i][j]=dp[i-1][j]+dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	return dp[n-1][m-1];
}
signed main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
    	//cout<<"Case #"<<i<<": ";
    	cout<<solve()<<endl;
    	//cout<<endl;
    }
    return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  ll a,b;
  cin >> a >> b;
  string u;
  cin >> u;

  if(u == s)a--;
  else b--;
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define P(type,x,y) fprintf(stdout,#x" %"#type"\n",x*100/y)
 
int main() {
    int h, m, M, lunch, dinner, midnight, n, cl, cd, cm;
     
    for (; fscanf(stdin, "%d", &n), n != 0; ) {
        lunch = dinner = midnight = cl = cd = cm = 0;
        while (n--) {
            fscanf(stdin, "%d%*c%d%d", &h, &m, &M);
            if (m > M) M += 60;
            if (11 <= h&&h < 15) { cl++; if(M - m <= 8)lunch++;}
            else if (18 <= h&&h < 21) { cd++; if (M - m <= 8)dinner++; }
            else if (h < 2 || 21 <= h) { cm++; if (M - m <= 8)midnight++; }
        }
        if (cl) P(d,lunch,cl);
        else puts("lunch no guest");
        if (cd) P(d, dinner,cd);
        else puts("dinner no guest");
        if (cm) P(d, midnight,cm);
        else puts("midnight no guest");
    }
    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int count = 0;
    int check = 0;

    for(int i = 1; i <= N; i++){
        count = 0;
        if(i % 2 != 0){
            for(int j = 1; j <= i; j++){
                if(i % j == 0)
                        count++;
            }
        }
        if(count == 8)
            check++;
    }
    cout << check << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char t[10][10];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

void rec(int x, int y){
  int i, j;
  int nx, ny;

  if(t[y][x] == '0') return;
  if(x < 0 || 8 <= x || y < 0 || 8 <= y) return;

  t[y][x] = '0';

  for(i = 0; i < 4; i++){
    for(j = 1; j <= 3; j++){
      nx = x + j * dx[i];
      ny = y + j * dy[i];
      rec(nx, ny);
    }
  }
}

int main(void){
  int i, j;
  int T, DATA;
  int sx, sy;
  scanf("%d", &T);

  for(DATA = 1; DATA <= T; DATA++){
    printf("Data %d:\n", DATA);
    for(i = 0; i < 8; i++){
      scanf("%s", t[i]);
    }
    scanf("%d%d", &sx, &sy);
    sx--;
    sy--;
    rec(sx, sy);

    for(i = 0; i < 8; i++){
      printf("%s\n", t[i]);
    }
  }

  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
using namespace std;
using LL = long long;

LL gcd(LL a, LL b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}
int main(){
    LL N;
    cin >> N;
    vector<LL>  a(N), le(N), ri(N);
    for(int i = 0;i < N;i++)    cin >> a[i];
    LL d = a[0];
    le[0] = d;
    for(int i = 1;i < N;i++){
        LL dd = gcd(d, a[i]);
        le[i] = dd;
        d = dd;
    }
    d = a[N-1];
    ri[N-1] = d;
    for(int i = N-2;i >= 0;i--){
        LL dd = gcd(d, a[i]);
        ri[i] = dd;
        d = dd;
    }
    LL ans = 1;
    for(int i = 0;i < N;i++){
        if(i == 0)  ans = max(ri[1], ans);
        else if(i == N-1)   ans = max(ans, le[N-2]);
        else    ans = max(gcd(le[i-1], ri[i+1]), ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
n,x=map(int,input().split())

def func(m,y):
  if y==0:return 0
  ret=0
  t=4*pow(2,m)-3
  if y>=t-1:
    ret=pow(2,m+1)-1
  elif y==(t-1)//2:
    ret=pow(2,m)-1
  elif y==(t-1)//2+1:
    ret=pow(2,m)
  elif y>(t-1)//2+1:
    ret=pow(2,m)
    ret+=func(m-1,y-(t-1)//2-1)
  else:
    ret=func(m-1,y-1)
  return ret

print(func(n,x))

Measured memory_bytes: 9016
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> p(a);
	vector<int> q(b);
	vector<int> r(c);
	for (int i = 0; i < a; i++){
		cin >> p[i];
	}
	for (int i = 0; i < b; i++){
		cin >> q[i];
	}
	for (int i = 0; i < c; i++){
		cin >> r[i];
	}

	sort(p.begin(), p.end(), greater<int>());
	sort(q.begin(), q.end(), greater<int>());

	for (int i = 0; i < x; i++){
		r.push_back(p[i]);
	}
	for (int i = 0; i < y; i++){
		r.push_back(q[i]);
	}
	sort(r.begin(), r.end(), greater<int>());
	ll ans = 0;
	for (int i = 0; i < x+y; i++){
		ans += r[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2552
from enum import Enum
from queue import Queue
import collections
import numpy as np


import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N = int(input())
A = list(map(int,input().split()))
Rain = [0]*N
for i in range(N):
        Rain[0] += A[i]*(-1)**i
for i in range(1,N):
    Rain[i] = 2*A[i-1] - Rain[i-1]

print(*Rain)


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

 
public class  Main{
	public static void main(String[] args) throws Exception{
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int n=sc.nextInt(),k=sc.nextInt();
		int[]in=sc.takearr(n);
		long[]pref=new long[n+1];
		pref[1]=in[0];
		for(int i=2;i<=n;i++)pref[i]=pref[i-1]+in[i-1];
		pref[0]=0;
		HashMap<Long, Long>map=new HashMap<Long, Long>();
		map.put(0l, 1l);
		long ans=0;
		for(int i=1;i<=n;i++) {
			long cur=(pref[i]-i+k+k)%k;
			if(i-k>=0) {
				int j=i-k;
				long remove=(pref[j]-j+k+k)%k;
				map.put(remove, map.get(remove)-1);
			}
			ans+=map.getOrDefault(cur, 0l);
			map.put(cur, map.getOrDefault(cur, 0l)+1);
		}
		pw.println(ans);
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 61116
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int P[20];
void Calc(){
	int N = rei();
	for(int i=0;i<N;i++){
		P[i] = rei();
	}
	int ans = 0;
	for(int i=1;i<N-1;i++){
		if(P[i] > P[i-1] && P[i] < P[i+1]){
			ans++;
		}
		if(P[i] < P[i-1] && P[i] > P[i+1]){
			ans++;
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
dp = [0]*(n+1)
dp[0] = 1
mod = 10**9 + 7
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
for i in range(2,n+1):
  if i in a:
    continue
  else:
    dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[-1] % mod)


Measured memory_bytes: 50140
// BEGINNING WITH NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
// ATCODER BEGINNERS PROBLEMS
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.flush();
     vector<int> v;
    int x;
    for(int i=0;i<3;i++)
    {
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    int num = v[2]*10 + v[1];
    num += v[0];
    cout<<num;
    return 0;
    // Bye Bye 2019
}




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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N=in(),K=in();

	vector<ll> Neg,Pos;
	REP(i,N){
		ll V=in();
		if(V<0) Neg.push_back(-V);
		else if(V>0) Pos.push_back(V);
		else K--;
	}
	sort(ALL(Neg));

	ll minD=1LL<<60;
	int NS=Neg.size(),PS=Pos.size();
	int NN=min(NS,K),PN=K-NN;
	while(NN>=0 && PN<=PS){
		ll ND = NN>0? Neg[NN-1]:0;
		ll PD = PN>0? Pos[PN-1]:0;
		minD = min({minD,2LL*ND+PD,ND+2LL*PD});
		NN--;
		PN++;
	}
	
	out(minD);
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    struct map{
        string name;
        int score;
        int index;
    };
    vector<map> gb;
    for(int i=0;i<N;i++){
        string s;
        int p;
        cin >> s >> p;
        gb.push_back({s, p, i+1});
    }
    sort(gb.begin(), gb.end(), [](const map& x, const map& y) { return x.name < y.name;});
    int left = 0;
    int right = 0;
    vector<map> gba;
    for(int i=0;i<N;i++){
        if(gb.at(left).name == gb.at(i).name){
            gba.push_back({gb.at(i).name, gb.at(i).score, gb.at(i).index});
        }
        else{
            sort(gba.begin(), gba.end(), [](const map& x, const map& y) { return x.score > y.score;});
            for(auto j = gba.begin(); j != gba.end(); j++){
                cout << j->index << endl;    
            }
            gba.clear();
            gba.shrink_to_fit();
            gba.push_back({gb.at(i).name, gb.at(i).score, gb.at(i).index});
            left = i;
        }
    }
    sort(gba.begin(), gba.end(), [](const map& x, const map& y) { return x.score > y.score;});
    for(auto j = gba.begin(); j != gba.end(); j++){
        cout << j->index << endl;    
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  int N,D;
  cin >>N>>D;
  int ans=0;
  int judge;
  double X[N][D];
  rep(i, N){
  rep(j, D){
  cin >> X[i][j];
  }
  }
  double dis;
    rep(i, N-1){
      rep2(i2, i+1, N){
        dis =0;
        rep(j, D){
          dis += (X[i][j]-X[i2][j])*(X[i][j]-X[i2][j]);
  }
        dis = sqrt(dis);
        judge =round(dis);
        if(dis==judge)
          ans++;
  }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	rank := make([]int, 8+1)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		rank[checkRank(tmp)]++
	}
	sum := 0
	for i := 0; i < 8; i++ {
		if rank[i] > 0 {
			sum++
		}
	}
	minNum := int(math.Max(float64(1), float64(sum)))
	maxNum := sum + rank[8]
	fmt.Printf("%d %d\n", minNum, maxNum)

}

func checkRank(num int) int {
	if num >= 8*400 {
		return 8
	}
	return num / 400
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    map<ll, ll> a;
    for(int i = 0; i < N; ++i) {
        ll temp;
        cin >> temp;
        a[temp] += 1;
    }
    ll ret = 0;
    for(auto pair : a) {
        if(pair.second >= pair.first){
            ret += pair.second - pair.first;
        }
        else {
            ret += pair.second;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 6272
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int N, M, K;
vector<int> G[MAX_N + 5];
vector<int> B[MAX_N + 5];
int ans[MAX_N + 5];
map<P, bool> blocked;

int parN[MAX_N + 5];
int par[MAX_N + 5];
int rnk[MAX_N + 5];

void init(int n) { REP(i, n) par[i] = i, rnk[i] = 0, parN[i] = 1; }

int find(int x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (rnk[x] < rnk[y]) {
    par[x] = y;
    int temp = parN[x];
    parN[x] += parN[y];
    parN[y] += temp;
  } else {
    par[y] = x;
    int temp = parN[y];
    parN[y] += parN[x];
    parN[x] += temp;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

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

bool contains(int v, int x) {
  // 直近の友達ではない
  return std::find(G[v].begin(), G[v].end(), x) != G[v].end();
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M >> K;
  init(N);

  int a, b;
  REP(i, M) {
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
    unite(a, b);
  }

  int c, d;
  REP(i, K) {
    cin >> c >> d;
    c--, d--;
    B[c].push_back(d);
    B[d].push_back(c);
    blocked[P(c, d)] = true;
    blocked[P(d, c)] = true;
  }

  REP(i, N) {
    if (i) cout << " ";
    int ans = max((parN[find(i)] - 1) - (int)G[i].size(), 0);
    // ブロックされた人たちを削除する
    REP(j, B[i].size()) {
      if (same(i, B[i][j])) ans = max(ans - 1, 0);
    }
    cout << ans;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 25464
k = gets.to_i
for i in 1..[9,k].min
  puts i
end
s = 9
(k-9).times do
  ans = []
  (Math.log10(s).floor+2).times do |i|
    ans << ((s+10**i-1)/10**i+1).ceil*(10**i)-1
  end
  s = ans.sort.sort_by{|i|i.to_f/i.to_s.split("").map(&:to_i).inject(:+)}[1]
  p s
end

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

using pii = pair<int, int>;

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

    int n, m;
    cin >> n >> m;
	priority_queue<pii, vector<pii>, greater<pii>> q;
	while (n--) {
		int x;
		cin >> x;
		q.emplace(x, 1);
	}
	while (m--) {
		int b, c;
		cin >> b >> c;
		int i = b;
		while (i && q.top().first < c) {
			auto& p = q.top();
			if (i < p.second) {
				const_cast<pii&>(p).second -= i;
				i = 0;
			}
			else {
				i -= p.second;
				q.pop();

			}
		}
		if (i < b) {
			q.emplace(c, b - i);
		}

	}
	long long s = 0;
	while (!q.empty()) {
		auto& p = q.top();
		s += (long long) p.first * p.second;
		q.pop();
	}

	cout << s << '\n';

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define deb(x)  cout << #x << ' ' << x << endl;
#define mod 1000000007
#define all(n)      (n).begin(), (n).end()
#define ll long long
#define ull unsigned long long int
void solve() {
    double d,t,s; cin >> d >> t >> s;
    if((d/s ) <= t){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    //Starts here , 
    //Machayenge!	
    
        solve();
    // }
    return 0;
            
}

Measured memory_bytes: 3736
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

ll expo(int x, int n){
    if (n == 0)
        return 1;
    ll val = expo(x,n/2);
    int M = 1e9 + 7;
    val = (val*val)%M;
    if (n%2!=0)
        val = (val*x)%M;
    return val;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int M = 1e9 + 7;
    ll val1 = expo(10,n);
    ll val2 = expo(9,n);
    ll val3 = expo(8,n);
    val1 = (val1+val3)%M;
    val2 = (val2*2)%M;
    ll ans = (val1 - val2 + M)%M;
    cout << ans << "\n";
}



Measured memory_bytes: 3608
h, w, a, b = map(int, input().split())

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)

if h % 2 == 0:
    m = int(h/2)
else:
    m = int(h/2) + 1

for i in range(m):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if i != int(h/2):
                ans[2*i+1][j] = 1 - ans[2*i+1][j]
                
for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()
        



    










 

 


                                        




    




        


    







        



Measured memory_bytes: 14324
a,b,c,d=map(int,input().split())
big=-99999999999999999999999999999999999999999
if a*c>a*d:
    big=a*c
else:
    big=a*d

if b*c>big:
    big=b*c
if b*d>big:
    big=b*d

print(big)

Measured memory_bytes: 61872