akhauriyash/Code-Regression huggingface dataset:
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let n: i32 = sc.read();
    let k: i32 = sc.read();
    println!("{}", (0..n - 1).fold(k, |a, _| a * (k - 1)));
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vvl = vector<vector<ll>>;
using vl  = vector<ll>;
#define _GLIBCXX_DEBUG
#define acc_io cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
const ll MOD = 1000000007;
const double PI = acos(-1);  
//name[i]   -> vl  name(i)
//name[i][j]-> vvl name(i,vl(j))
//or-> ||
//map<int,int>mp

//ll n;
int h,w;
//ll ans;
signed main(){
	acc_io;
	cin>>h>>w;
	vector<string>s(h);
	rep(i,0,h) cin>>s.at(i);
	rep(i,0,h){
		rep(j,0,w){
			int cnt=0;
			if(s.at(i).at(j)=='.'){
				if(j-1>=0){
					if(i-1>=0){
						if(s.at(i-1).at(j-1)=='#') ++cnt;
					}
					if(s.at(i).at(j-1)=='#') ++cnt;
					if(i+1<h){
						if(s.at(i+1).at(j-1)=='#') ++cnt;
					}
				}
				if(j+1<w){
					if(i-1>=0){
						if(s.at(i-1).at(j+1)=='#') ++cnt;
					}
					if(s.at(i).at(j+1)=='#') ++cnt;
					if(i+1<h){
						if(s.at(i+1).at(j+1)=='#') ++cnt;
					}
				}
				if(i-1>=0){
					if(s.at(i-1).at(j)=='#') ++cnt;
				}
				if(i+1<h){
					if(s.at(i+1).at(j)=='#') ++cnt;
				}
				s.at(i).at(j)='0'+cnt;
			}
		}
	}
	rep(i,0,h) cout<<s.at(i)<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	/**
	 * 入力された数字を構成する数字の組み合わせ数を計算して出力する。
	 *
	 * @param args
	 */
	public static void main(String[] args) throws IOException {

		// 入力値をリストで受け取る
		List<Integer> inputList = readNumberList();

		// 必要な組み合わせ数のマップを作成する
		int maxInput = getMaxNumber(inputList);
		int[] countMap = createCombinationCountMap(maxInput);

		// 結果を出力する
		for (Integer input : inputList) {
			System.out.println(countMap[input]);
		}

	}

	/**
	 * 標準入力から数値を読んでリストとして返却する。
	 *
	 * @return 入力された数値のリスト
	 */
	protected static List<Integer> readNumberList() throws IOException {

		List<Integer> inputList = new ArrayList<Integer>();

		String line = null;
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		while((line = reader.readLine()) != null){
			inputList.add(Integer.parseInt(line));
		}

		if (reader != null) {
			reader.close();
		}

		return inputList;
	}

	/**
	 * 数値リストのうち最大の数値を取得する。
	 *
	 * @param inputList 数値リスト
	 * @return 数値リスト内の最大の数値
	 */
	protected static int getMaxNumber(List<Integer> inputList) {
		int maxInput = 0;
		for (Integer input : inputList) {
			if (maxInput < input) {
				maxInput = input;
			}
		}
		return maxInput;
	}

	/**
	 * 入力された数値を構成する4つの数字の組み合わせの数を求める。
	 *
	 * @param max 入力された数値の最大値
	 * @return 組み合わせの数
	 */
	protected static int[] createCombinationCountMap(int max) {

		// 最大値より要素が1大きい配列を用意する
		int[] countMap = new int[max + 1];

		// 全パターンを試し、マップに登録する
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						countMap[i + j + k + l]++;
					}
				}
			}
		}

		return countMap;
	}
}

Measured memory_bytes: 17068
#include <iostream>

using namespace std;

int main(){
	int flag[30]={};
	for(int i=0;i<28;i++){
		int val;
		cin>>val;
		flag[val-1]=1;
	}
	for(int i=0;i<30;i++){
		if(flag[i]==0){
			cout<<i+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

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

	for i := 0; i <= n; i += 7 {
		if (n-i)%4 == 0 {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1768
#include <iostream>

#include <algorithm>
#include <cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;

int main() {


	int a, b,c;
	//----------------------
	LL n, X, Z,A,B,N,ans1,ans2,i,m,C,D;
	LL ans, count=0 ;
	bool f=true;
	string s;

	cin >> A>> B>> C>> D;
	if (A*B == C*D) {
	
		cout << A*B << endl;
	
	}
	else if (A*B > C*D) {
	
		cout << A*B << endl;

	}else cout << C*D << endl;
	

	
	

	

	//cout << s << endl;

	
	//------------------------
	//cin >> Z;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}

signed main() {
	string s;
	cin >> s;
	rep(i, (1 << 4)) {
		int bit[5];
		rep(j, 4) bit[j] = i / (1 << j) % 2;
		string now = "";
		rep(j, 4) {
			if (bit[j]) now += 'A';
			if (j == 0) now += "KIH";
			else if (j == 1) now += 'B';
			else if (j == 2) now += "R";
		}
		if (now == s) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s; int64_t k; cin>>s>>k;
	int i=0;
	while(i<s.size()&&s.at(i)=='1')++i;
	cout<<(k<=i?'1':s.at(i))<<"\n"s;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main(){
	int n,i;
	string s;
	bool flag=false;
	char x;
	cin>>n;
	cin>>s;
	mp[s]++;
	x=s[s.size()-1];
	for(i=2;i<=n;i++){
		cin>>s;
		map<string,int>::iterator it=mp.end();
		it--;
		if(mp.count(s)==0&&s[0]==x){
			mp[s]++;
			x=s[s.size()-1];
		}else{
			flag=true;
		}
	}
	if(flag){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n, l; cin >> n >> l;
  int sum = (l+l+n-1)*n/2, ans = INF;
  REP(i,n) {
    if (l+i < abs(sum-ans)) ans = sum - (l+i);
  }
  COUT(ans);
  return 0;
}

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

using namespace std;

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

    long long ans = (N/K)*(N/K)*(N/K);

    if(K % 2 == 0) {
        long long tmp = (N + (K/2)) / K;
        ans += tmp * tmp * tmp;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using lint = long long;
typedef pair<int,int> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Node{
    int no;
    int par;
    int dist=0;
    vector<Node*> child;
    void build(int i){
        no=i;
        par=i;dist=0;
    }
};
struct Tree{
    int n;
    vector<Node> node;
    Tree(int k){
        n=k;
        node.resize(n+1);
        for(int i=1;i<=n;++i){
            node[i].build(i);
        }
    }
    void input(int k){
        for(int i=0;i<k;++i){
            int a,b;cin>>a;b=i+2;
            node[a].child.push_back(&node[b]);
            node[b].child.push_back(&node[a]);
        }
    }
    void BFS(int s){
        rep1(i,n){
            node[i].build(i);
        }
        queue<Node> que;
        que.push(node[s]);
        while(!que.empty()){
            Node buf=que.front();que.pop();
            int num=buf.child.size();
            for(int i=0;i<num;++i){
                if(buf.child[i]->no!=buf.par){
                    buf.child[i]->par=buf.no;
                    //buf.child[i]->dist=buf.dist+1;
                    que.push(*buf.child[i]);
                }
            }
        }
    }
    void DFS(Node& node){
        if(node.child.size()==1&&node.par!=node.no){
            node.dist=1;
            return;
        }
        else{
            int num=node.child.size();
            vector<int> koho;
            for(int i=0;i<num;++i){
                if(node.child[i]->no!=node.par){
                    DFS(*node.child[i]);
                    koho.push_back(node.child[i]->dist);
                }
            }
            sort(koho.begin(),koho.end());
            num=koho.size();
            int nxt=-1;
            rep(i,num){
                nxt=max(nxt,koho[i]+num-i);
            }
            node.dist=nxt;
        }
    }
    void solve(){
        BFS(1);
        DFS(node[1]);
        cout<<node[1].dist-1<<"\n";
    }
};
signed main(){
    int n;cin>>n;
    Tree tree(n);
    tree.input(n-1);
    tree.solve();
    return 0;
}


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

using namespace std;

long long arr1[200005],arr2[200005];
map<long long,long long>mp;
queue<long long>Q;

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

    long long n,k,i,x,sum = 0,ans=0;
    arr1[0] = arr2[0] = 0;
    mp.insert({0,1});Q.push(0);
    cin>>n>>k;
    for(i=1;i<=n;i++){
        cin>>x;
        sum+=x;
        arr1[i] = sum%k;
        arr2[i] = i%k;
    }
    for(i=1;i<=n;i++){
        if((long long)Q.size() == k){
            mp[Q.front()]--;
            Q.pop();
        }
        x = arr1[i] - arr2[i];
        //cout<<x<<endl;
        if(x < 0)x += k;
        if(mp.find(x) != mp.end())ans += mp[x];
        mp[x]++;Q.push(x);
    }
    cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 17536
import sys
input = sys.stdin.readline
from operator import itemgetter
import heapq
n, k = map(int, input().split())
TD = sorted([list(map(int, input().split())) for _ in range(n)], reverse=True, key=itemgetter(1))
L = [[] for _ in range(n+1)]
P = []
a = 0
cnt = 0
F = [-float("inf")]*(n+1)
B = 0
for t, d in TD[:k]:
  if B>>t & 1:
    heapq.heappush(P, d)
  else:
    B |= 1 << t
    a += 1
  cnt += d
F[a] = cnt
for i in range(a, n):
  if len(P) == 0:
    break
  while k < n and B>>TD[k][0] & 1:
    k += 1
  if k == n:
    break
  t, d = TD[k]
  B |= 1 << t
  F[i+1] = F[i] - heapq.heappop(P) + d
ans = 0
for i in range(a, n+1):
  ans = max(ans, F[i] + i*i)
print(ans)

Measured memory_bytes: 36824
var std = process.stdin;
std.resume();
std.setEncoding('utf8');

std.on('data', function(chunk){
    var data = chunk.split(/\n/g);

    for (var i = 0; i < data.length; i++){
        var
            line = data[i].replace(/\n/, '').split(' ').map(Number),
            h = line[0],
            w = line[1];
        
        if(h === 0 && w === 0) {break;}
        draw(h, w);
        console.log();  //??????
    }
});

var draw = function(h, w) {
    for (var i = 0; i < h; i++) {
        var line = '';
        for (var j = 0; j < w; j++) {
            if((i + j) % 2 === 0){
                line += '#';
            }
            else {
                line += '.';
            }
        }
        console.log(line);
    }  
};

Measured memory_bytes: 18152
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, k, t, q, sum[111];
Pll a[1000];
struct Edge { LL cost,to; };
string str,ss;
long double distance(pair<long double, long double> x, Pll y) {
	return sqrt(pow(x.fir - y.fir, 2) + pow(x.sec - y.sec, 2));
}
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i].fir >> a[i].sec;
	}
	LL d = 1500000;
	rep(i, d) {
		pair<long double, long double> pos;
		int num = -1;
		long double r = 200000000000.0;
		pos.fir = cos(PI * 2* (i * 1.0) / (d*1.0)) *100000000000.0,
			pos.sec = sin(PI * 2 * (i * 1.0)/ (d*1.0)) * 100000000000.0;
		rep(j, n) {
			if (r > distance(pos, a[j])) {
				r = distance(pos, a[j]);
				num = j;
			}
		}
		sum[num]++;
	}
	rep(i, n) {
		printf("%.15f\n", sum[i] * 1.0 / (d + 0.0));
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
using namespace std;


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

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> a(m);

  rep(i, m){
    cin >> a[i];
  }
  int count = 0;
  int itr = 0;
  for(int i = 0; i != x; ++i){
    if(a[itr] == i){
      count++;
      itr++;
    }
  }

  int ans = min(count, (int)a.size() - count);
  cout << ans << endl;
}


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

int N;

int main() {
	cin >> N;
	bool three = true;
	for (int i = 0; i < N; i++) {
		string s;  
		cin >> s;
		if (s == "Y") three = false;
	}

	if (three) { 
		cout << "Three" << endl;
	} else {
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
s=input()
if s=='SUN':
  print(7)
elif s=='SAT':
  print(1)
elif s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)

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

using namespace std;
#define ll long long

int main() {
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k > 0){
        ans += min(a, k);
        k -= min(a, k);
    }
    if(k > 0) k -= b;
    if(k > 0) ans -= k;
	
	cout << ans;
	
	return 0;
}

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

using namespace std;

int n;
unsigned long long int res = 0;
vector<int> s;

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

    cin >> n;
    s.resize(n);
    for (int& i : s) cin >> i;
    for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) res += s[i] * s[j];
    cout << res << '\n';

    return 0;
}

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

int main()
{
 	ios_base::sync_with_stdio(false);
 	int L;
 	cin >> L;
 	int N = 20;
 	int M = 0;
 	string edges = "";
 	for(int i=19; i>=2; i--) {
 		edges += to_string(i) + " " + to_string(i+1) + " 0" + "\n";
 		edges += to_string(i) + " " + to_string(i+1) + " " + to_string((1<<(19-i))) + "\n";
 		M += 2;
 	}
 	int curr_paths = 0;
 	int i=20;
 	while(L != 0) {
 		int power = 1<<(21-i);
 		if(L%power != 0 or i==2) {
 			edges += "1 " + to_string(i) + " " + to_string(curr_paths) + "\n";
 			curr_paths += (power/2);
 			L -= (power/2);
 			M++;
 		} else {
 			i--;
 		}
 	}
 	cout << N << " " << M << "\n";
 	cout << edges;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,c[10],g,j,i;
	 while(1){
		scanf("%d",&n);
		 if(n==0)	break;
	 for(i=0;i<10;i++){
		c[i]=0;
	}			 
	for(i=0;i<n;i++){
			scanf("%d",&g);
			c[g]+=1;
	}
	for(i=0;i<10;i++){
		if(c[i]>0){
			for(j=0;j<c[i];j++){
				printf("*");
			}
		printf("\n");
		}
		else{
			printf("-\n");
		}
	}
  }
 return 0;
 }

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
typedef long long ll;
#define FOR(i,n) for(int i=0;i<n;i++)

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> h(n);
  for(int i=0;i<n;i++)cin >> h[i];
  vector<int> flag(n);
  for(int i=0;i<n;i++)flag[i] = 1;
  for(int i = 0;i<m;i++){
     int a,b;
     cin >> a >> b;
     if(h[a-1] > h[b-1]){
       flag[b-1] = 0;
     }
      else if(h[a-1]==h[b-1]){
        flag[a-1] = 0;flag[b-1] = 0;
      }
      else if(h[a-1] < h[b-1]){
        flag[a-1] = 0;
      }
  }

  int ans=0;
  for(int i=0;i<n;i++){
    if(flag[i] == 1)ans++;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 4052
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
num = 0
for i in range(N):
    left = min(A[i], B[i])
    num += left
    B[i] -= left
    right = min(A[i+1], B[i])
    num += right
    A[i+1] -= right
print(num)

Measured memory_bytes: 19648
#include <bits/stdc++.h>
#include<vector>
using namespace std;
 
int main() {
  int a,c=0;
  cin>>a;
  int b[a];
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  for(int i=0;i<a-1;i++){
    for(int o=i+1;o<a;o++){
      c+=b[i]*b[o];
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <limits>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <queue>

#define MAX 100009
#define INF 99999999
#define in(a,b)  ( (b).find(a) != (b).end())
#define clr(a,b) memset((a), (b), sizeof((a)))
#define pb       push_back
#define all(a)   a.begin(), a.end()  
#define mp       make_pair
#define ll	long long
#define fi	first
#define se second

const long double pi = 3.141592653589793238L;
const ll mod = 1e9 + 7;

/**
*
* @Author Lahia omar
*/

using namespace std;
void split(vector<string> &v, string cur) {
	istringstream iss(cur);
	copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(v));
}
int n;
vector<ll> tab, outL,outR;
void ff() {
	for (int i = outR.size() - 1; i >= 0; i--) {
		cout << outR[i] << ' ';
	}
	for (int i = 0; i < outL.size(); i++) {
		cout << outL[i] << ' ';
	}
}
void f() {
	for (int i = outL.size() - 1 ; i >= 0; i--) {
		cout << outL[i] << ' ';
	}
	for (int i = 0; i < outR.size(); i++) {
		cout << outR[i] << ' ';
	}
}
int main(int argc, char* argv[]) {
	cin >> n; tab.resize(n); 
	for (int i = 0; i < n; i++) cin >> tab[i];
	for (int i = 0; i < n; i++) {
		if (i % 2 != 0)
			outL.pb(tab[i]);
		else
			outR.pb(tab[i]);
	}
	if (n % 2 == 0) f();
	else ff();
	
	return 0;
}

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;

int main()
{
    cin>>s;
    Yes(!(s[0] == s[1] && s[0] == s[2]));

    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val scanner = Scanner(System.`in`)
    val a = scanner.nextInt()
    val b = scanner.nextInt()
    val doubleB = b * 2
    if (doubleB >= a) {
        println(0)
    } else {
        val result = a - doubleB
        println(result)
    }
}

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

#define int long long

#define MOD 1000000007

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

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

  sort(a, a+n);

  vector<int> vec;

  if(n % 2 == 0){
    for(int i = 0;i < n/2;i++){
      vec.push_back(i*2+1);
      vec.push_back(i*2+1);
    }
  }else{
    vec.push_back(0);
    for(int i = 0;i < n/2;i++){
      vec.push_back(i*2+2);
      vec.push_back(i*2+2);
    }
  }

  for(int i = 0;i < n;i++){
    if(a[i] != vec[i]){
      cout << 0 << endl;
      return 0;
    }
  }

  int ans = 1;
  for(int i = 0;i < n-1;i+=2){
    ans = (ans * 2) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
///const ll inf=1000000000000000000;
int main()
{
    int n;
    ll w;
    cin>>n>>w;
    ll val[n+1],wi[n+1],sum=0;
    for(int i=1;i<=n;++i)
    {
        cin>>wi[i]>>val[i];
        sum+=val[i];
    }
    vector<ll>dp(sum+1,1e18);
    dp[0]=0;
    for(ll i=1;i<=n;++i)
    {
        for(ll j=sum-val[i];j>=0;--j)
            {
                dp[j+val[i]]=min(dp[j+val[i]],wi[i]+dp[j]);
                ///cout<<dp[j+val[i]]<<' '<<j+val[i]<<endl;
            }
    }
    ll ans=-1;
    for(ll i=1;i<=sum;++i)
    {
        if(dp[i]<=w)
            ans=max(ans,i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int k = scan.nextInt();
		int c = 0;
		boolean notHave = false;
		ArrayList<ArrayList<Integer>> b_list = new ArrayList<ArrayList<Integer>>(n);
		int count_treat = 0;

		for(int i = 0;i < n;i++) {
			b_list.add(new ArrayList<Integer>());
		}

		for(int i = 0;i < (2 * k);i++) {
			if(i % 2 == 0) {
				c = scan.nextInt();
			}else {
				for(int j = 0;j < c;j++) {
					b_list.get(scan.nextInt() - 1).add(i);
				}
			}
		}

		for(int i = 0;i < n;i++) {
			if(b_list.get(i).size() == 0) {
				count_treat += 1;
			}
		}

		System.out.println(count_treat);
	}
}


Measured memory_bytes: 46448
#include<bits/stdc++.h>
using namespace std;
int n;
int ask(int x){
    if(x&1) return x+n;
    return x;
}
int main(){
    scanf("%d",&n);
    if(n<3) return printf("No\n"),0;
    int y=n,flag=0;
    while(y>1){
    flag|=y&1;
    y>>=1;
    }
    if(!flag) return printf("No\n"),0;
    printf("Yes\n");
    printf("%d %d\n",n+1,n+2);
    for(int i=2;i<n;i+=2){
    printf("%d %d\n",1,i);
    printf("%d %d\n",i,i+1);
    printf("%d %d\n",1,i+n+1);
    printf("%d %d\n",i+n,i+n+1);
    }
    if(n%2==0){
    for(int i=2;i<n;i++){
        if(((n^1^i)<n)){
        printf("%d %d\n",ask(i),n);
        printf("%d %d\n",ask(n^1^i),2*n);
        return 0;
        }
    }
    }
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=200010;

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

    ll n,m;
    cin>>n>>m;
    ll i1,i2;
    cin>>i1>>i2;
    --i1;--i2;
    ll t1,t2;
    cin>>t1>>t2;
    --t1;--t2;
    string s[n];
    for(ll i=0;i<n;++i){cin>>s[i];}
    vector<vector<int> > vis(n,vector<int>(m,0));

    vector<pi> ar;
    queue<pi> q;
    q.push(mp(i1,i2));
    vis[i1][i2]=1;
    ll ans=0;

    while(!q.empty()){
        ll x=q.front().first;
        ll y=q.front().second;
        ar.pb(mp(x,y));
        q.pop();
        int dx[]={1,0,-1,0};
        int dy[]={0,1,0,-1};
        for(int i=0;i<4;++i){
            ll xx=x+dx[i];
            ll yy=y+dy[i];
            if(xx>=0&&xx<n&&yy>=0&&yy<m&&vis[xx][yy]==0&&s[xx][yy]=='.'){
                vis[xx][yy]=1;
                q.push(mp(xx,yy));
            }
        }
    }

    if(vis[t1][t2]){
        cout<<ans;
        return 0;
    }

    while(ar.size()>0){
        ++ans;
        for(ll a=0;a<ar.size();++a){
            ll x=ar[a].first,y=ar[a].second;
            for(ll i=-2;i<=2;++i){
                for(ll j=-2;j<=2;++j){
                    ll xx=x+i;
                    ll yy=y+j;
                    if(xx>=0&&xx<n&&yy>=0&&yy<m&&vis[xx][yy]==0&&s[xx][yy]=='.'){
                        vis[xx][yy]=1;
                        q.push(mp(xx,yy));
                    }
                }
            }
        }
        ar.clear();
        while(!q.empty()){
            ll x=q.front().first;
            ll y=q.front().second;
            ar.pb(mp(x,y));
            q.pop();
            int dx[]={1,0,-1,0};
            int dy[]={0,1,0,-1};
            for(int i=0;i<4;++i){
                ll xx=x+dx[i];
                ll yy=y+dy[i];
                if(xx>=0&&xx<n&&yy>=0&&yy<m&&vis[xx][yy]==0&&s[xx][yy]=='.'){
                    vis[xx][yy]=1;
                    q.push(mp(xx,yy));
                }
            }
        }
        if(vis[t1][t2]==1){break;}
    }
    if(vis[t1][t2]==0){ans=-1;}
    cout<<ans;

    return (0);
}


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

const int N = 1e5 + 9;
 
int f[N][40];
long long s[N][40];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long k; cin >> k;
	int x, n; cin >> x >> n;
	for (int i = 0; i < n; i++) f[i][0] = 1LL * i * i % n;
	for (int i = 0; i < n; i++) s[i][0] = i;
	for (int k = 1; k < 40; k++) {
		for (int i = 0; i < n; i++) {
			f[i][k] = f[f[i][k - 1]][k - 1];
			s[i][k] = s[i][k - 1] + s[f[i][k - 1]][k - 1];
		}
	}
	int cur = x;
	long long sum = 0;
	for (int i = 0; i < 40; i++) {
		if (k >> i & 1) {
			sum += s[cur][i];
			cur = f[cur][i];
		}
	}
	cout << sum;
    return 0;
}

Measured memory_bytes: 50512
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    X = II()
    print(X//500*1000+X%500//5*5)

if __name__ == '__main__':
    main()

Measured memory_bytes: 66028
awk 'function abs(x){return x<0?-x:x}
function min(x,y){return x<y?x:y}
c++{
  for(i=1;i<=NF;++i)w+=$i
  a=w
  for(i=1;i<=NF;++i){w-=$i;v+=$i;a=min(a, abs(w-v))}
  print a
}'


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;}
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    while(1){
        string s1,s2;
        cin >> s1;
        if(s1==".")break;
        cin >> s2;
        int miss=0,pos1=0,pos2=0;
        bool in_const=false;

        while((pos1!=s1.size()) || (pos2!=s2.size())){
            //もし一方が終わったら？
            if(pos1==s1.size() || pos2==s2.size()){
                miss=2;
                break;
            } 
            //普通の処理
            if(!in_const){//constじゃない
                if(s1[pos1]!=s2[pos2]){
                    miss=2;
                    break;
                }
                if(s1[pos1]=='"') in_const=true;
            }else{//const
                if(s1[pos1]!=s2[pos2]){
                    miss++;
                    while(s1[pos1]!='"'){
                        pos1++;
                    }
                    while(s2[pos2]!='"'){
                        pos2++;
                    }
                    in_const=false;
                }
                if(s1[pos1]=='"') in_const=false;
            }
            /**
            p(pos1);
            p(pos2);
            p(in_const);
            **/
            pos1++;
            pos2++;
        }

        if(miss==1){
            p("CLOSE");
        }else if (miss>1){
            p("DIFFERENT");
        }else{
            p("IDENTICAL");
        }
    }
}


Measured memory_bytes: 3100
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<queue>
#include<stack>
#include<utility>
#include<vector>
using namespace std;

typedef long long lint;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0 ; i < n ; i++){
        cin >> p[i];
    }
    int ans = 0;
    bool flag = false;
    for(int i = 0 ; i < n ; i++){
        if(p[i] == i + 1 && !flag){
            ans++;
            flag = true;
            continue;
        }
        flag = false;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
<?php
fscanf(STDIN, "%d", $d);
if($d === 22){
    echo 'Christmas Eve Eve Eve';
}elseif($d === 23){
    echo 'Christmas Eve Eve';
}elseif($d === 24){
    echo 'Christmas Eve';
}elseif($d === 25){
    echo 'Christmas';
}
?>

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

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

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		while (true) {
			
			String s = br.readLine();
			if (s == null) break;
			String temp = "";
			
			while (s.length() != 1) {
				
				for (int i = 0; i < s.length() - 1; i++)
					temp += String.valueOf(((s.charAt(i) - '0') + (s.charAt(i + 1) - '0')) % 10);
				s = temp;
				temp = "";
				
			}
			
			ans.add(Integer.parseInt(s));
			
		}
		
		for (int a : ans) {
			System.out.println(a);
		}

	}

}

Measured memory_bytes: 9344
s = input()
f = 0
for i in range(len(s)):
    if i%2 == 0: # odd
        if s[i] == "R" or s[i] == "U" or s[i] == "D":
            continue
        else:
            f = 1
            break
    else:
        if s[i] == "L" or s[i] == "U" or s[i] == "D":
            continue
        else:
            f = 1
            break
if f == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef vector<int> vi;
typedef pair<int,int> ii;
vi v;
int n;

tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> t;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    map<int,int> mp;
    while(cin >> n)
    {
        v = vi(n); t.clear(); mp.clear();
        for(int i = 0; i < n; i++)
        {
            cin >> v[i];
            t.insert({v[i], mp[v[i]]});
            mp[v[i]]++;
        }

		mp.clear();
		for(int i = 0; i < n; i++)
		{
			t.erase({v[i], mp[v[i]]});
			cout << (*t.find_by_order((n-1)/2)).first << '\n'; 
			t.insert({v[i], mp[v[i]]});
			mp[v[i]]++;
		}
    }
    return 0;
}

Measured memory_bytes: 24576
#include <stdio.h>

char word[10+1];
char line[11+1];
char end[] = "END_OF_TEXT";

int equals(char *a, char *b) {
    int i = 0;
    while(1) {
        if(a[i] != b[i] && (a[i]-b[i])*(a[i]-b[i]) != ('a'-'A')*('a'-'A')) return 0;
        else if(a[i] == '\0') return 1;
        i++;
    }
}

int is_end(char *t) {
    int i = 0;
    while(1) {
        if(t[i] != end[i]) return 0;
        else if(t[i] == '\0') return 1;
        i++;
    }
}

int main(void) {

    int i = 0;
    while(1) {
        char c;
        scanf("%c", &c);
        if(c == ' ' || c == '\n') break;
        word[i++] = c;
    }
    word[i] = '\0';

    int count = 0;
    while(1) {
        i = 0;
        while(1) {
            if(i>=11) break;
            char c;
            scanf("%c", &c);
            if(c == ' ' || c == '\n') break;
            line[i++] = c;
        }
        line[i] = '\0';
//        printf("%s\n", line);
        if(is_end(line)) break;
        if(equals(word, line)) count++;
    }

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

    return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, K;
	cin >> H >> W >> K;
	--K;
	int dp[10];
	dp[0] = 1; dp[1] = 1;
	for(int i=2;i<=9;i++){
		dp[i] = dp[i-2] + dp[i-1];
	}
	int dp1[H+1][W]{};
	dp1[0][0] = 1;
	for(int i=1;i<=H;i++){
		for(int j=0;j<W;j++){
			if(j != 0){
				dp1[i][j] += dp1[i-1][j-1]*dp[j-1]*dp[W-1-j];
			}
			dp1[i][j] += dp1[i-1][j]*dp[j]*dp[W-1-j];
			if(j != W-1){
				dp1[i][j] += dp1[i-1][j+1]*dp[j]*dp[W-2-j];
			}
			dp1[i][j] %= MOD;
		}
	}
	cout << dp1[H][K] << endl;
}

Measured memory_bytes: 256
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
N,m,k = map(int,input().split())
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(k+1):
    ans += (pow(m-1,N-1-i,mod)*cmb(N-1,i,mod))% mod
    ans %= mod
print((m * ans)%mod)

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << '\n';
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  // ll N, K; cin >> N >> K;
  ll sx, sy; cin >> sx >> sy;
  ll tx, ty; cin >> tx >> ty;
  ll dx, dy;
  dx = tx - sx;
  dy = ty - sy;
  string ans;
  
  rep(i, dx) ans.push_back('R');
  rep(i, dy) ans.push_back('U');
  rep(i, dx) ans.push_back('L');
  rep(i, dy + 1) ans.push_back('D');
  rep(i, dx + 1) ans.push_back('R');
  rep(i, dy + 1) ans.push_back('U');
  ans.push_back('L');
  ans.push_back('U');
  rep(i, dx + 1) ans.push_back('L');
  rep(i, dy + 1) ans.push_back('D');
  ans.push_back('R');
  
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;

int main()
{
    int N = 0;
    int M = 0;
    cin >> N >> M;

    int P[100000] = {};
    int Y[100000] = {};
    vector<int> yd[100001];

    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        yd[P[i]].push_back(Y[i]);
    }

    for (int i = 0; i < N; i++) {
        sort(yd[i + 1].begin(), yd[i + 1].end());
    }

    for (int i = 0; i < M; i++) {
        int x;
        x = int(lower_bound(yd[P[i]].begin(), yd[P[i]].end(), Y[i]) - yd[P[i]].begin() + 1);
        printf("%012lld\n", (long long)P[i] * 1000000 + x);
    }
    return 0;
}


Measured memory_bytes: 7808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();//点の数
		int D = sc.nextInt();//距離
		//座標の取得
		int[] x =new int[N];
		int[] y =new int[N];
		for(int i=0;i<N;i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}
		//計算
		int check=0;
		double dis;
		for(int i=0;i<N;i++) {
			dis=Math.sqrt((double)x[i]*x[i]+(double)y[i]*y[i]);
			if(dis<=(double)D) {
				check++;
			}
		}
		System.out.println(check);
	}

}


Measured memory_bytes: 61916
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
vector <int > s;





int main()
{

	cin >> N;

	s.resize(N);
	int sum = 0;
	REP(i,N){
		cin >> s[i];
		sum += s[i];
	}

	if(sum % 10 != 0){
		cout << sum << endl;
		return 0;
	}else {
		sort(s.begin(),s.end());
		REP(i,N){
			if(s[i]%10 != 0){
				cout << sum - s[i] << endl;
				return 0;
			}
		}
		cout << 0 << endl;
	}


}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    char p[3];
    char t[3];
    int i;
    int ans=0;

    scanf("%s",p);
    scanf("%s",t);
    for(i=0;i<3;i++){
      //printf("%c%c\n",p[i],t[i]);
      if(p[i]==t[i]){

      ans++;
    }
    }
    printf("%d",ans);




    return 0;
}


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

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a > b)
		cout << b * c + (a - b)*d;
	if (a <= b)
		cout << a * c;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll dp[100005];
vector<ll> h(100002);

ll stair(ll i){
    if(dp[i] != -1){
        return dp[i];
    }
    return dp[i] = min(abs(h[i]-h[i-2])+stair(i-2),abs(h[i]-h[i-1])+stair(i-1));
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    h[0] = -MOD;
    REPP(i,1,n+1) cin >> h[i];
    REP(i,n+1) dp[i] = -1;
    if(h.size() > 1){
        dp[0] = MOD;
        dp[1] = 0;
        dp[2] = abs(h[2]-h[1]);
    }

    for(int i = 3; i < n+1;i++){
        stair(i);
        // dp[i] = min(abs(h[i]-h[i-2])+dp[i-2],abs(h[i]-h[i-1])+dp[i-1]);
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1792
open Queue
let ans, q, h, w, ss = Scanf.(scanf "%d %d" @@ fun h w -> ref 0, create (), h, w, Array.init h @@ fun _ -> scanf " %s" @@ fun s -> s)
let f sy sx = let ds, m = Array.make_matrix h w ~-1, ref 0 in push (sy, sx) q; ds.(sy).(sx) <- 0;
  while not @@ is_empty q do let y0, x0 = pop q in List.iter (fun (dy, dx) -> let y, x = y0 + dy, x0 + dx in if 0 <= y && y < h && 0 <= x && x < w && ds.(y).(x) = -1 && ss.(y).[x] = '.' then (push (y, x) q; ds.(y).(x) <- ds.(y0).(x0) + 1; m := max !m ds.(y).(x))) [-1, 0; 0, -1; 1, 0; 0, 1] done; !m
let _ = for sy = 0 to h - 1 do for sx = 0 to w - 1 do if ss.(sy).[sx] = '.' then ans := max !ans (f sy sx) done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 4608
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#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;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,h[202020];
vi adj[320020];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  

  
  int n,m;
  cin >> n >> m;
  for(int i=1;i<=n;i++){
    cin >> h[i];
  }
  for(int i=1;i<=m;i++){
    int x,y;
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
  }
  int ans = 0;
  for(int i=1;i<=n;i++){
    bool f = true;
    for(auto t:adj[i]){
      if(h[i]>h[t]);
      else f = false;
    }
    if(f)ans++;
  }
  cout << ans << endl;


return 0;
}
///....


Measured memory_bytes: 15428
#include<stdio.h>
#include <string.h>
struct Card{
  char suit[3];
  char value;
};
void bubble(struct Card[] ,int );
void selection(struct Card[],int);
void print(struct Card[] ,int );
int isStable(struct Card[] , struct Card[],int );



void bubble(struct Card A[],int N){
  int i,j;
  
  struct Card temp;
  for(i=0;i<N;i++){
    for(j=N-1;j>=i+1;j--){
      if(A[j].value<A[j-1].value){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
      }
    }
  }
}

void selection(struct Card A[],int N){
  int i,j,minj;
  struct Card temp;

  for(i=0;i<N;i++){
    minj=i;
    
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
    
    temp=A[i];
    A[i]=A[minj];
    A[minj]=temp;
  }
}

void print(struct Card A[],int N){
  int i;
  
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%s",A[i].suit);
  }
 
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[],int N){
  int i;
  
  for(i=0;i<N;i++){
    if(strcmp(C1[i].suit,C2[i].suit)!=0)return 0;
  }
  return 1;
}

int main(){
  struct Card C1[100],C2[100];
  int n;
  int i;
  char ch;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&C1[i].suit);
  }

  for(i=0;i<n;i++){
    C1[i].value=C1[i].suit[1];
    
    C2[i]=C1[i];
  }
  
  bubble(C1,n);
  selection(C2,n);

  print(C1,n);

  printf("Stable\n");
  print(C2,n);
  if( isStable(C1,C2,n)==1){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  return 0;
}

      



Measured memory_bytes: 2096