akhauriyash/Code-Regression huggingface dataset:
// 問題URL
// https://atcoder.jp/contests/abc151/tasks/abc151_a

import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String x = scanner.next();

        char []alphabet = new char[26];
        //String alphabet = new char[26];
        char c = 'a';

        for (int i = 0; i < 26; i++){
            alphabet[i] = c++;
        }

        for (int j = 0; j < alphabet.length; j++) {
            if (alphabet[j] == x.charAt(0) && x.charAt(0) != 'z') {
                System.out.println(alphabet[j + 1]);
                break;
            }
        }

    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<ctime>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int x,y;
	scanf("%X%X",&x,&y);
	if (x>y) printf(">");
	else if (x<y) printf("<");
	else if(x=y) printf("=");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a == b && b == c){
		cout << "No";
		}
	else if(a != b && b != c && a != c){
		cout << "No";
		}
	else{
		cout << "Yes";
		}
		
	}


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

#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define ll long long
#define pb push_back
#define endl "\n"
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
//#endif
}

int main(){
	c_p_c();

	string s; cin >> s;
	if(s[2]==s[3] && s[4]==s[5]) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define sd second
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> d(n);
    for(int& i:d) cin>>i;
    sort(d.begin(),d.end());
    cout<<d[n/2]-d[n/2-1]<<endl;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  cin >> s;
  int count[26];
  int i;
  for(i=0;i<26;i++){
   count[i] = 0; 
  }
  for(i=0;i<(int)(s.length());i++){
    if(s[i]=='a') count[0]++;
    if(s[i]=='b') count[1]++;
    if(s[i]=='c') count[2]++;
    if(s[i]=='d') count[3]++;
    if(s[i]=='e') count[4]++;
    if(s[i]=='f') count[5]++;
    if(s[i]=='g') count[6]++;
    if(s[i]=='h') count[7]++;
    if(s[i]=='i') count[8]++;
    if(s[i]=='j') count[9]++;
    if(s[i]=='k') count[10]++;
    if(s[i]=='l') count[11]++;
    if(s[i]=='m') count[12]++;
    if(s[i]=='n') count[13]++;
    if(s[i]=='o') count[14]++;
    if(s[i]=='p') count[15]++;
    if(s[i]=='q') count[16]++;
    if(s[i]=='r') count[17]++;
    if(s[i]=='s') count[18]++;
    if(s[i]=='t') count[19]++;
    if(s[i]=='u') count[20]++;
    if(s[i]=='v') count[21]++;
    if(s[i]=='w') count[22]++;
    if(s[i]=='x') count[23]++;
    if(s[i]=='y') count[24]++;
    if(s[i]=='z') count[25]++;
  }
  bool flug = true;
  for(i=0;i<26;i++){
   if(count[i]%2 == 1) flug = false; 
  }
  if(flug==true) cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n = s.length();
    for(ll i = n/2-1;i >= 0;i--){
        if (s.substr(0,i) == s.substr(i,i)){
            PRINT(2*i);
            return 0;
        }
    }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

vector<vector<int>> to;

void solve() {
	int n;
	cin >> n;
	to.resize(n);
	vector<pii> v(n-1);
	rep(i,n-1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		v[i] = make_pair(a, b);
		to[a].push_back(b);
		to[b].push_back(a);
	}
	int mx = 0;
	rep(i,n) mx = max(mx, (int)to[i].size());
	map<pii, int> mp;
	queue<pair<pii, int>> q;
	int prev = 0;
	q.push(make_pair(make_pair(-1, 0), -1));
	while (!q.empty()) {
		auto p = q.front(); q.pop();
		int s = p.first.first;
		int t = p.first.second;
		int nc = p.second;
		for (int i = 0; i < (int)to[t].size(); i++) {
			if (to[t][i] == s) continue;
			++nc;
			nc %= mx;
			int nf = to[t][i];
			mp[make_pair(t, nf)] = nc;
			q.push(make_pair(make_pair(t, nf), nc));
		}
	}

	cout << mx << endl;
	rep(i,n - 1) {
		cout << mp[v[i]] + 1 << endl;
	}
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 15804
#include <iostream>

using namespace std;

int dp[18][18];

int main() {
    while (true) {
        for (int i = 0; i < 17; i++) {
            for (int j = 0; j < 17; j++) {
                dp[i][j] = 0;
            }
        }
        for (int i = 0; i < 18; i++) {
            for (int j = 0; j < 18; j++) {
                if (dp[i][j] != 0) {
                    cout << "hoge" << endl;
                }
            }
        }
        int a, b, n;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        cin >> n;
        for (int i = 0; i < n; i++) {
            int x, y;
            cin >> x >> y;
            dp[x - 1][y - 1] = -1;
        }
        for (int i = 0; i < a; i++) {
            for (int j = 0; j < b; j++) {
                if (dp[i][j] == -1) {
                    dp[i][j] = 0;
                } else if (i == 0 && j == 0) {
                    dp[i][j] = 1;
                } else if (i == 0) {
                    dp[i][j] = dp[i][j - 1];
                } else if (j == 0) {
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                }
            }
        }
        cout << dp[a - 1][b - 1] << endl;
    }
}

Measured memory_bytes: 3032
#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    while(a>=0 && c>=0)
    {
        c = c - b;
        if(c<=0)
        {
            printf("Yes");break;
        }
        a = a - d;
        if(a<=0)
        {
            printf("No");break;
        }

    }
    return 0;
}

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

int main()
{
    char s[4];
    int i;
    for(i=0; i<4; i++)
    {
        cin >> s[i];
    }

    for(i=0; i<3; i++)
    {
        if(s[i]==s[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;

    return 0;
}


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

int main(){
	long long  N,M,C,ans=0,count=0;
	cin >> N >> M >> C;
	long long B[M+10],A[N+10][M+10];
	for(int i=0; i<M; i++) cin >> B[i];
	for(int i=0; i<N; i++){
		for(int j=0; j<M; j++) cin >> A[i][j];
	}
	for(int i=0; i<N; i++){
		count=0;
		for(int j=0; j<M; j++){
			count+=A[i][j]*B[j];
		}
		if(count+C>0) ans+=1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007
 
int main(){
  
  ll A,B,N;
  cin >> A >> B >> N;
  
  if(N >= B){
    cout << ((B - 1) * A) / B << endl;
  }
  else{
    cout << (N * A) / B << endl;
  }
      
  
  return 0;
}


Measured memory_bytes: 3620
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
MAIN.
  ACCEPT N.
  ACCEPT LN.
  PERFORM N TIMES
      PERFORM VARYING j FROM cur BY 1  UNTIL LN(j:1) = SPACE
      END-PERFORM
      COMPUTE len = j - cur
      MOVE LN(cur:len) TO A
      IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
          AND FUNCTION MOD(A, 5) NOT = ZERO
          MOVE ZERO TO FLG
          EXIT PERFORM
      END-IF
      COMPUTE cur = j + 1
      ADD 1 TO i
  END-PERFORM.
  IF FLG = 1
      DISPLAY "APPROVED"
  ELSE
      DISPLAY "DENIED"
  END-IF.

MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

var l [][]int

func main() {
	scanner.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	h := make([]int, n)
	for i := range h {
		h[i] = nextInt()
	}
	a := make([]int, m)
	b := make([]int, m)
	l := make([][]int, n)
	for i := 0; i < m; i++ {
		a[i], b[i] = nextInt()-1, nextInt()-1
		l[a[i]] = append(l[a[i]], b[i])
		l[b[i]] = append(l[b[i]], a[i])
	}

	ans := 0
	for i := 0; i < n; i++ {
		flag := true
		for _, v := range l[i] {
			if h[i] <= h[v] {
				flag = false
				continue
			}
		}
		if flag {
			ans++
		}
	}
	fmt.Println(ans)
}

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, err := strconv.Atoi(next())
	if err != nil {
		fmt.Println(err)
	}
	return i
}


Measured memory_bytes: 13564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		int count = 0;
		for(int i=0;i<s.length()-1;i++){
			if(s.charAt(i) != s.charAt(i+1)){
				count++;
			}
		}
		System.out.println(count);
	}

}


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

int a[9];
int b[9];

int main(){
  for(int i=0;i<9;i++){
    cin>>a[i];
    b[i]=i+1;
  }
  
  int ans=0;
  do{
    bool flg=true;
    for(int i=0;i<9;i++)
      if(a[i]!=-1&&a[i]!=b[i])
        flg=false;

    if(flg){
      if( b[0] + b[1]*10+b[2] + b[3]*100+b[4]*10+b[5]
          == b[6]*100+b[7]*10+b[8] ) ans++;
    }
    
  }while( next_permutation(b,b+9) );
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] s = new String[n];
        for(int i=0; i<n; i++) {
            String si = in.next();
            s[i] = sortStr(si);
        }
        Arrays.sort(s);
        String prev = "";
        long c = 0;
        int dup = 0;
        for(int i=0; i<n; i++) {
            if(s[i].equals(prev)) {
                dup++;
                c += dup;
            }
            else {
                prev = s[i];
                dup = 0;
            }
        }
        System.out.println(c);
    }
    private static String sortStr(String s) {
        char[] c = s.toCharArray();
        Arrays.sort(c);
        String result = new String(c);
        return result;
    }
}


Measured memory_bytes: 52424
#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define INARR(h,w,x,y) (0 <= y && y < h && 0 <= x && x < w)
#define EQ(a,b) (abs(a - b) < 1e-10)
using namespace std;
constexpr int dx[4] = {0,1,0,-1};
constexpr int dy[4] = {1,0,-1,0};
constexpr long double pi = M_PI;
constexpr double EPS = 1e-10;
constexpr long MOD = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<bool> VB;
typedef vector<pr> VP;
typedef priority_queue<pr,vector<pr>,greater<pr>> pq;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K;
    cin >> N >> K;
    VI w(N);
    REP(i,N) cin >> w[i];
    
    long ng = 0;
    long ok = loINF;
    while (abs(ok - ng) > 1) {
        long mid = (ok + ng) / 2;
        long acc = 0;
        long cnt = 1;
        REP(i,N) {
            if (acc + w[i] <= mid) acc += w[i];
            else {
                cnt ++;
                if (mid < w[i]) {
                    cnt = loINF;
                    break;
                }
                acc = w[i];
            }
        }
        if (cnt <= K) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}



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

void solve(vector<int> T, vector<int> H){
    vector<pair<int, int>> answers;
    int sumT = accumulate(T.begin(), T.end(), 0);
    int sumH = accumulate(H.begin(), H.end(), 0);
    for(auto itrT = T.begin(); itrT != T.end(); ++itrT){
        for(auto itrH = H.begin(); itrH != H.end(); ++itrH){
            int t = *itrT;
            int h = *itrH;
            if(sumT - t + h == sumH - h + t) answers.push_back(make_pair(t, h));
        }
    }
    if(answers.empty()){
        cout << -1 << endl;
        return;
    }
    else{
        int th = 1e6;
        int min_index = 0;
        for(int i=0;i<answers.size();i++){
            int t = answers[i].first;
            int h = answers[i].second;
            if(th > t+h){
                min_index = i;
                th = t+h;
            }
        }
        cout << answers[min_index].first << ' ' << answers[min_index].second << endl;
        return;
    }
}

int main(){
    int n, m;
    while(true){
        vector<int> T;
        vector<int> H;
        cin >> n >> m;
        if(!(n || m)) break;
        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            T.push_back(tmp);
        }
        for(int j=0;j<m;j++){
            int tmp;
            cin >> tmp;
            H.push_back(tmp);
        }
        solve(T, H);
    }

    return 0;
}


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

using namespace std;

int main (void) {
  int R;
  cin >> R;
  if ( R < 1200 )
    cout << "ABC" << endl;
  else if ( R < 2800 )
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
  return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++) 
    cin >> p.at(i) >> c.at(i);
  int min = 0;
  for (int i = 0; i < D; i++) {
    min += p.at(i);
  }
  for (int tmp = 0; tmp < (1 << D); tmp++) {
    bitset<10> s(tmp);
    int count = 0, point = 0;
    for (int i = 0; i < D; i++) {
      if (s.test(i)) {
        count += p.at(i);
        point += p.at(i) * (i + 1) * 100 + c.at(i);
      }
    }
    if (point >= G) {
      if (min > count) {
        min = count;
      }
    }
    else {
      int n;
      for (int i = D - 1; i >= 0; i--) {
        if (!s.test(i)) {
          n = i;
          break;
        }
      }
	  for (int i = 0; i < p.at(n); i++) {
        point += (n + 1) * 100;
        count++;
        if (point >= G) {
          if (min > count)
            min = count;
          break;
        }
      }
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 3476
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

vector<int> v[N];

int in[N]; //in[node] tells the no. of incoming edges to node

int visit[N],dis[N],ans;

void dfs(int node)
{
    visit[node]=1;
    
    for(int it:v[node])
    {
        dis[it]=max(dis[it],dis[node]+1);
        
        in[it]--;
        
        if(in[it]==0)
        dfs(it);
    }
    
    ans=max(ans,dis[node]);
}

int main()                  
{
    int n,m;
    
    scn(n);  scn(m);
    
    while(m--)
    {
        int a,b;
        
        scn(a); scn(b);
        
        in[b]++;
        
        v[a].pb(b);
    }
    
    rep(i,1,n+1)
    if(!visit[i] and in[i]==0)
    dfs(i);
    
    pri(ans);
    
} 

Measured memory_bytes: 9984
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000003
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}
vector<int> sieve(ll n){//get primes up to n<=1e6 and the numbers can be handled up to 1e12
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}

*/

int main()
{
    int n,ans=0;
    cin>>n;

    int a[n], b[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++)
        ans+=max(0, a[i]-b[i]);
    cout<<ans;

//        cout<<"Case "<<qq<<": ";
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

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

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

constexpr int MAX = 110000;
ll fac[MAX], finv[MAX], inv[MAX];



int main() {
    int n, m; cin >> n >> m;
    vector<ll> x(n), y(m);
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    ll xsum = 0;
    rep(i, n-1) {
        xsum += (x[i+1] - x[i]) * (i+1) % MOD * (n-i-1) % MOD;
        xsum %= MOD;
    }
    ll ysum = 0;
    rep(i, m-1) {
        ysum += (y[i+1] - y[i]) * (i+1) % MOD * (m-i-1) % MOD;
        ysum %= MOD;
    }

    ll ans = xsum * ysum % MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)

int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int dxx[]={1,1,0,-1,-1,-1,0,1};
int dyy[]={0,-1,-1,-1,0,1,1,1};
bool inside(int x,int y,int w,int h){
  return (x>=0 && y>=0 && x<w && y<h);}
typedef long long ll;
typedef pair<int,int> pii;


int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  char s[5];
  int a=0;
  cin >>s;
  if(s[0]=='1') a+=900;
  else a+=100;
  if(s[1]=='1') a+=90;
  else a+=10;
  if(s[2]=='1') a+=9;
  else a+=1;
  cout <<a <<endl;


  

  return 0;
}


Measured memory_bytes: 256
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define INF 9223372036854777ll
#define pb push_back
using namespace std;
ll n;
void add_se(ll &a,ll b){
    a+=b;
    if(a>=mod)
    a-=mod;
}
ll mul(ll a,ll b){
    return ((ll)a*b)%mod;
}
struct M{
    vector<vector<ll>> t;
    M(){
        t.resize(n,vector<ll>(n));
    }
    M operator* (M &b){
        M c=M();
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<n;k++){
                    add_se(c.t[i][k],mul(t[i][j],b.t[j][k]));
                }
            }
        }
        return c;
    }
};
void solve(){
    
    ll k;
    ll res=0;
    cin>>n>>k;
    vector<vector<ll>> v(n,vector<ll>(n));
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    cin>>v[i][j];
    M ans=M();
    for(int i=0;i<n;i++)
    ans.t[i][i]=1;
    M m=M();
    m.t=v;
    while(k){
        if(k&1)
        ans=ans*m;
        m=m*m;
        k/=2;
    }
    for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    {
        add_se(res,ans.t[i][j]);
    }
    cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

const int crit = 300000000;

int main(){
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  vector<int> v(n,crit),w(n,crit);
  rep(i,n)v[i]+= i,w[i] += n-i-1;
  int cnt = 1;
  vector<int> sv(n+1,0),sw(n+1,0);
  for(int i = 1;i < n;i++){
    if(a[i-1] < a[i]){
      sv[a[i]] += cnt;
      sw[a[i]] += cnt;
      sw[n] -= cnt;
      cnt++;
    }else{
      sw[a[i]] += cnt;
      sv[a[i]] += cnt;
      sv[0] -= cnt;
      cnt++;
    }
  }
  rep(i,n)sv[i+1] += sv[i];
  for(int i = n;i > 0;i--)sw[i-1] += sw[i];
  rep(i,n)cout << v[i]+sv[i+1] << " ";
  cout << "\n";
  rep(i,n)cout << w[i]+sw[i+1] << " ";
  cout << "\n";



  return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
long long edge[110][110];
long long dist[105][105];

//status unsloved




int main(){


    int V,E;
    cin>>V>>E;
    rep(i,V)rep(k,V)edge[i][k]=INF;

    rep(i,E){
        int s,t;
        long long d;
        cin>>s>>t>>d;
        edge[s][t]=d;
    }
    //ワーシャルフロイド 法
        //中継点を通って最短経路を構築する
    rep(l,3){
        rep(i,V){
            rep(j,V){
                rep(k,V){
                    if(edge[i][j]!=INF && edge[j][k]!=INF){
                    edge[i][k]=min(edge[i][k],edge[i][j]+edge[j][k]);
                    }
                }
            }
        }
    }
    //負の閉路の検出
    rep(i,V){
        if(edge[i][i]<0){
            cout<<"NEGATIVE CYCLE"<<endl;;
            return 0;
        }
    }

    rep(i,V){
        rep(k,V){
            if(i==k){
                cout<<"0";
            }
            else if(edge[i][k]==INF)cout<<"INF";

            else{
            cout<<edge[i][k];
            }
            if(k!=V-1)cout<<" ";
            else cout<<endl;
        }
        //if(i!=V-1)cout<<endl;
    }
    

    return 0;

}
/*
0 1 3 4 
INF 0 2 3 
INF INF 0 1 
INF INF 7 0 

0 1 3 4
INF 0 2 3
INF INF 0 1
INF INF 7 0
*/



Measured memory_bytes: 3184
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000000000;
double pi=3.141592653589793;
//setprecision(20) <<

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

class Point{
public:
	long long x;
	long long y;
	long long dis;
	Point(long long _x,long long _y,long long _dis){
		x=_x;
		y=_y;
		dis=_dis;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	double a,b,x;
	cin>>a>>b>>x;
	double s=x/a;
	if(s<=a*b/2){
		double a_=s*2/b;
		double d=sqrt(a_*a_+b*b);
		double data=a_/d;
		double ans=acos(a_/d);
		ans=ans*180/pi;
		cout<<setprecision(20) <<ans<<endl;
	}else{
		double b_=2*s/a-b;
		b_=b-b_;
		double d=sqrt(a*a+b_*b_);
		double data=a/d;
		double ans=acos(data);
		ans=ans*180/pi;
		cout<<setprecision(20) <<ans<<endl;
	}
}


Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] brick = new int[num];
        for(int i = 0; i < num; i++){
            brick[i] = sc.nextInt();
        }
        int currentnumber = 1;
        int count = 0;
        
        boolean check = false;

        
        for(int a:brick){
            if(a == 1){
                check = true;
            }
        }
        
        if(!check){
            System.out.println(-1);
            System.exit(0);
        }
        
        for(int i = 0; i < brick.length; i++){
            if(brick[i] != currentnumber){
                count++;
            }else{
                currentnumber++;
            }
        }
        System.out.println(count);
        
    }
}

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

int main() {
    ll N,pnt(0),ans(0);
    string S;
    cin>>N>>S;
    for (int i(0);i<S.size();i++){
      if (S[i]=='D')pnt-=1;
      else pnt+=1;
      ans=max(ans,pnt);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>

using namespace std;
int main()
{
	while (true){
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}

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

int main(){
            int i,j;
           int ans = 0;
            string s,t;
            cin >> s>> t;
           for(i=0;i<s.size();i++){
                    if(s[i]==t[i]){
                    }else{
                            t[i] = s[i];
                            ans++;
                      }
            }
	    cout << ans<<endl;
            return 0;
}

Measured memory_bytes: 3912
#include <iostream>
#define N_MAX 100
using namespace std;

int N,A,B,i,j,k;
int a[N_MAX];
int num[N_MAX] = {0};
int ans=0;
int r,g,b;

int main(){
  cin >> A >> B;
  ans = (A+B)/2;
  if((A+B) % 2 != 0) ans++;
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;


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

    int ans=0;

    vector<int> d[10];
    for(int i=0;i<N;i++){
        int x=S.at(i)-'0';
        d[x].push_back(i);
    }

    for(int i=0;i<10;i++){
        if(d[i].size()>0){
            int I=d[i].at(0);
            for(int j=0;j<10;j++){
                if(d[j].size()>0){
                    auto itr=upper_bound(d[j].begin(),d[j].end(),I);
                    if(itr!=d[j].end()){
                        int J=*itr;
                        for(int k=0;k<10;k++){
                            if(d[k].size()>0){
                            if(d[k].at(d[k].size()-1)>J) {
                                //cout<<I<<' '<<J<<' '<<d[k].at(d[k].size()-1)<<' '<<100*i+10*j+k<<endl;
                                ans++;
                            }
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

pub fn prime_factorize<T: PrimInt + NumAssign>(mut n: T) -> Vec<(T, T)> {
    let mut res: Vec<(T, T)> = Vec::new();
    let mut i: T = one::<T>().signed_shl(1);
    while i * i <= n {
        if n % i == zero() {
            let mut ex = zero::<T>();
            while n % i == zero() {
                ex += one();
                n = n / i;
            }
            res.push((i, ex));
        }
        i += one();
    }
    if n != one() {
        res.push((n, one()))
    }
    res
}


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        k: usize,
    }

    let mut x = 7 % k;
    
    let mut ans: isize = -1;

    for i in 1..=k {
        if x == 0 {
            ans = i as isize;
            break;
        }

        x = (10 * x + 7) % k;
    }
    println!("{}", ans)
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2160
from collections import defaultdict

n, m = map(int, input().split())
t = [tuple(map(int, input().split())) for _ in range(m)]

#各ノードの根（-1はそのノードが根）
follow = [-1]*n
#（自分を含む）連結している数
num_follower = [1]*n

def root_index_of(A):
    r = A
    while follow[r] > -1:
        r = follow[r]
    return r

def connected(A,B):
    return root_index_of(A) == root_index_of(B)

now = 0
def connect(A,B):
    global now
    rA = root_index_of(A)
    rB = root_index_of(B)
    if rA == rB:
        return
    now += num_follower[rA]*num_follower[rB]
    if num_follower[rA] < num_follower[rB]:
        follow[rA] = rB
        follow[A] = rB
        num_follower[rB] += num_follower[rA]
    else:
        follow[rB] = rA
        follow[B] = rA
        num_follower[rA] += num_follower[rB]


c = n*(n-1)//2
ans = [c]
for i in range(m-1, 0, -1):
    a, b = t[i]
    connect(a-1, b-1)
    ans.append(c-now)
for i in range(m-1, -1, -1):
    print(ans[i])



Measured memory_bytes: 24956
N = int(input())
AB = [list(map(int,input().split())) for _ in [0]*(N-1)]
M = int(input())
UV = [list(map(int,input().split())) for _ in [0]*M]

E = [[] for _ in [0]*N]
for a,b in AB:
    a-=1
    b-=1
    E[a].append(b)
    E[b].append(a)

P = [-1]*N
P[0] = 0
q = [0]
while q:
    i = q.pop()
    for j in E[i]:
        if P[j]!=-1: continue
        P[j] = i
        q.append(j)
P[0] = -1

def dist_bfs(N,E,start):
    d = [-1]*N
    d[start] = 0
    q = [start]
    while q:
        qq = []
        for i in q:
            di = d[i]
            for j in E[i]:
                if d[j]!=-1:continue
                d[j] = di+1
                q.append(j)
        q = qq
    return d

path = []
for u,v in UV:
    u -= 1
    v -= 1
    tmp = []
    d = dist_bfs(N,E,u)
    q = [v]
    while q:
        i = q.pop()
        di = d[i]
        for j in E[i]:
            if d[j] == di-1:
                q.append(j)
                if P[i]==j:
                    tmp.append(i)
                else:
                    tmp.append(j)
    path.append(set(tmp))

ans = 2**(N-1)
for i in range(1,2**M):
    tmp = set(range(1,N))
    cnt = 0
    for j in range(M):
        if (i>>j)&1==0:continue
        cnt += 1
        tmp -= path[j]
    ans += ((-1)**cnt) * (2**(len(tmp)))
print(ans)

Measured memory_bytes: 44604
/*
 * 17-05-20_ARC074_D.cpp
 *
 *  Created on: 2017/05/20
 *      Author: ryoma
 */

#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<limits.h>

using namespace std;

typedef long long ll;

int N;
ll a[3 * 100010];
int main() {
	cin >> N;
	for (int i = 0; i < 3 * N; i++) {
		cin >> a[i];
	}
	ll val1[100010],val2[ 100010];
	priority_queue<int> que1;
	ll sum = 0;
	for(int i=0;i<N;i++){
		que1.push(-a[i]);
		sum += a[i];
	}
	val1[0]  = sum;
	for(int i=0;i<N;i++){
		sum += a[N+i];
		que1.push(-a[N+i]);
		sum += que1.top();
		que1.pop();
		val1[i+1] = sum;
	}
	priority_queue<int> que2;
	sum = 0;
	for(int i=0;i<N;i++)
	{
		que2.push(a[2*N+i]);
		sum += a[2*N+i];
	}
	val2[N] = sum;
	for(int i=N-1;i>=0;i--){
		sum += a[N+i];
		que2.push(a[N+i]);
		sum -= que2.top();
		que2.pop();
		val2[i] = sum;
	}
	ll ans = LLONG_MIN;
	for(int i=0;i<=N;i++){
		ans = max(ans,val1[i]-val2[i]);
	}
	cout << ans <<endl;
	return 0;
}



Measured memory_bytes: 5112
import sys
import re

l = sys.stdin.readline()
l = int(l)
out = []
def x(stri,l,depth):
  str = 'abcdefghij'
  use = 0
  for i in range(0,l-depth+1):
    if( use == 1):
      break
    cdepth = depth
    cstri = stri
    if ( str[i] not in cstri):
      use = 1
    cstri += str[i] 
    cdepth -= 1
    if( cdepth == 0):
	out.append(cstri)
    else:
	x(cstri,l,cdepth)


stri = 'a'
if( l == 1):
 print stri
 exit(0)
x(stri,l,l-1)

count = 0
for i in out:
  print i


sys.stdout.flush()


Measured memory_bytes: 10344
use proconio::input;

fn main(){
    input!{
        x:i32,
        a:i32,
        b:i32
    }
    let da = x-a;
    let db = x-b;
    if da.abs() < db.abs(){
        println!("A")
    }else{
        println!("B")
    }


}


Measured memory_bytes: 2044
//#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<deque>
#include<map>
#include<set>
#include<queue>
#include<optional>
#include<assert.h>
#include<tuple>

using namespace std;

static vector<int64_t> the_last(1004, INT64_MIN);
static vector<int> came_from(1004);
vector<int> elements;

int64_t solve_without_deleting(const int rhs){
	int tmp = rhs - 2;
	while (tmp >= 0) {
		if (the_last[tmp] + elements[rhs] > the_last[rhs]) {
			came_from[rhs] = tmp;
			the_last[rhs] = the_last[tmp] + elements[rhs];
		}
		tmp -= 2;
	}
	return the_last[rhs];
}



void solve() {
	int n;
	cin >> n;
	elements.resize(n);
	for (size_t i = 0; i < elements.size(); ++i) {
		cin >> elements[i];
		the_last[i] = elements[i];
		came_from[i] = i;
	}
	int64_t max_result = INT64_MIN;
	int ind = 0;
	for (size_t i = 1; i < elements.size(); ++i) {
		int64_t res = solve_without_deleting(i);
		if (res > max_result) {
			max_result = res;
			ind = i;
		}
	}
	vector<int> way;
	while (came_from[ind] != ind) {
		way.push_back(ind);
		ind = came_from[ind];
	}
	way.push_back(ind);
	
	sort(way.begin(), way.end());
	vector<int> to_delete;
	for (size_t i = elements.size(); i > way.back() + 1; --i) {
		to_delete.push_back(i);
	}
	for (size_t i = 0; i < way.front(); ++i) {
		to_delete.push_back(1);
	}
	for (size_t i = 1; i < way.size(); ++i) {
		for (size_t j = 1; j < (way[i] - way[i - 1]) / 2; ++j) {
			to_delete.push_back(3);
		}
		to_delete.push_back(2);
	}
	cout << max_result << "\n";
	cout << to_delete.size() << "\n";
	for (int i : to_delete) {
		cout << i << "\n";
	}
	return;
}


int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)solve();
	return 0;
}

Measured memory_bytes: 3700
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()[:-1].decode()

    ans = 0
    result = [False] * n
    for i in range(n):
        if k <= i and t[i] == t[i - k] and result[i - k]:
            continue
        if t[i] == 'r':
            ans += p
        elif t[i] == 's':
            ans += r
        elif t[i] == 'p':
            ans += s
        result[i] = True

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 42224
#include <stdio.h>
 
int main(void){

	int m; 
	int f;
	int r;

	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if((m==-1)&&(f==-1)&&(r==-1)){
			break;
	}

	if((m!=-1)&&(f!=-1)){
		if((m+f)>=80){
			printf("A\n");
	}

	else if((m+f)>=65){
		printf("B\n");
	}

	else if(((m+f)>=50)||(r>=50)){
		printf("C\n");
	}

	else if((m+f)>=30){
		printf("D\n");
	}

		else{
			printf("F\n");
		}
	}
		else{
			printf("F\n");
		}
    }

	return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let nm = read_vec::<i64>();
    let (n,m) = (nm[0],nm[1]);
    let abn:Vec<Vec<i64>> = read_vec2(n as u32);
    let cdn:Vec<Vec<i64>> = read_vec2(m as u32);
    let ans = abn.iter().fold(Vec::new(),|mut y,x| {
        let mut calc = cdn.iter().enumerate().map(|(i,cd)| (i as u64+1,(x[0] - cd[0]).abs() + (x[1] -cd[1]).abs()))
            .collect::<Vec<(u64,i64)>>();
        calc.sort_by_key(|k| k.1);
        y.push(calc[0].0);
        y
    });
    for i in &ans{
        println!("{}",i);
    }

} 

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


void maxHeapify(vector<int>& A, int i, int H) {
	int l=2*i;
	int r=2*i+1;
	int largest=i;

	if(l<=H && A[i]<A[l]) {
		largest = l;
	}

	if(r<=H && A[largest]<A[r]) {
		largest = r;
	}

	if(largest!=i) {
		swap(A[i],A[largest]);
		maxHeapify(A,largest,H);
	}

	return;
}

int main() {
	int n;
	int H=0;
	int i;
	vector<int> A;
	string cmd;

	A.push_back(-1);

	cin >> cmd;
	while(cmd!="end") {
		if(cmd=="insert") {
			++H;
			cin >> n;
			A.push_back(n);
			i=H;
			while(i/2!=0) {
				if(A[i]>A[i/2]) {
					swap(A[i],A[i/2]);
				}
				i=i/2;
			}
		} else if(cmd=="extract") {
			cout << A[1] << endl;
			A[1]=A[H];
			--H;
			A.pop_back();
			maxHeapify(A,1,H);
		}
		cin >> cmd;
	}
	return 0;
}

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

int n,m,dp[2][3010][2],Ans;
const int mo=1e9+7;

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i,fk=0;
	scanf("%d%d",&n,&m);
	dp[fk][0][1]=1;
	for (i=1;i<=n;i++)
		dp[fk][i][0]=1;
	while (m--)
	{
		memset(dp[fk^1],0,sizeof(dp[fk]));
		for (i=0;i<=n;i++)
		{
			if (i!=0)
			{
				(dp[fk^1][i-1][1]+=dp[fk][i][1])%=mo;
				(dp[fk^1][i-1][i==1]+=dp[fk][i][0])%=mo;
				(dp[fk^1][i][1]+=dp[fk][i][1])%=mo;
				(dp[fk^1][i][i==1]+=dp[fk][i][0])%=mo;
			}
			if (i!=n)
			{
				(dp[fk^1][i+1][1]+=dp[fk][i][1])%=mo;
				(dp[fk^1][i+1][0]+=dp[fk][i][0])%=mo;
				(dp[fk^1][i][1]+=dp[fk][i][1])%=mo;
				(dp[fk^1][i][0]+=dp[fk][i][0])%=mo;
			}
		}
		fk^=1;
	}
	for (i=0;i<=n;i++)
		(Ans+=dp[fk][i][1])%=mo;
	printf("%d\n",Ans);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define vc vector;

const int INF = 100000000;

using namespace std;

void p(int x) {
	cout << x << endl;
}

void pp(string s) {
	cout << s << endl;
}

int main() {
	while (1) {
		int count = 0,arrcnt=0;
		bool alljudge = true;
		int n, a, b, c, x,xx;
		cin >> n >> a >> b >> c >> x;
		if (n == 0 && a == 0 && b == 0 && c == 0 && x == 0)break;
		
		vector<pair<int,bool>> v(n);
		rep(i, 0, n) {
			cin >> v[i].first;
			v[i].second = false;
		}
		rep(i, 0, 10001) {
			if (x == v[arrcnt].first && v[arrcnt].second == false) {
				v[arrcnt].second = true;
				arrcnt++;
			}
			
			if (arrcnt == n) {
				cout << count << endl;
				alljudge = false;
				break;
			}

			x = (a*x + b) % c;
			count++;
		}

		if(alljudge) cout << -1 << endl;



	}

	return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)

using namespace std;

int main() {
  int K, S;
  cin >> K >> S;
  int Ans = 0;
  REP(i, min(S + 1, K + 1)) {
    if (S - i > 2 * K)
      continue;
    else if (S - i <= K) {
      Ans += (S - i + 1);
    } else
      Ans += (K + 1) - abs(S - i - K);
  }
  cout << Ans << endl;
  return 0;
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> ans;
    FOR(i,1,k+1){
      REP(j,s.size()-i+1){
        ans.push_back(s.substr(j,i));
      }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    cout << ans[k-1] << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll;
//No change above here

const ll maxi = 302;
ll mod = (1e9 + 7);

//function for power
ll power(ll x, ll n) {
	ll res = 1;
	x %= mod;
	while (n) {
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

ll sum_digits(ll n)
{
	ll ret = 0;
	while (n)
	{
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll dir[4][2] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll p, q;
bool valid(ll i, ll j) { return i >= 1 && i <= p && j >= 1 && j <= q; }

//declare needed things here



int main()
{
	IOS;
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> a(n + 1, 0);
	vector<ll> b(m + 1, 0);
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		a[i] += a[i - 1];
	}
	for (int i = 1; i <= m; ++i)
	{
		cin >> b[i];
		b[i] += b[i - 1];
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i)
	{
		ll find = k - a[i];
		if (find < 0)
			break;
		auto it = upper_bound(b.begin(), b.end(), find);
		int cur = it - b.begin() + i-1;
		ans = max(ans, cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6364