akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <functional>

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

const ll INF = (1LL<<31)-1;


template<class T, class Lazy> struct SegTree {
  private:
    int size;
    vector<T> v; vector<Lazy> lazy;
    vector<int> seg_size;
    using F = function<T(T,T)>;
    using G = function<Lazy(Lazy,Lazy)>;
    using H = function<T(T,Lazy,int)>;
    F f; G g; H h;
    T default_value; Lazy default_lazy;
  public:
    SegTree(int n, T default_value, Lazy default_lazy, F f, G g, H h)
      : default_value(default_value), default_lazy(default_lazy), f(f), g(g), h(h) {
      size = 1;
      while (size < n) size *= 2;

      v.resize(2 * size - 1, default_value);
      lazy.resize(4 * size - 1, default_lazy);
      seg_size.resize(2 * size - 1, 1);

      rep(i, size - 1) {
        int j = size - 2 - i;
        seg_size[j] = seg_size[2 * j + 1] + seg_size[2 * j + 2];
      }
    }
    void update(int index, T val) {
      index = index + size - 1;
      v[index] = val;
      while (index > 0) {
        index = (index - 1) / 2;
        v[index] = f(v[2 * index + 1], v[2 * index + 2]);
      }
    }
    void eval(int index) {
      v[index] = h(v[index], lazy[index], seg_size[index]);

      lazy[2 * index + 1] = g(lazy[index], lazy[2 * index + 1]);
      lazy[2 * index + 2] = g(lazy[index], lazy[2 * index + 2]);

      lazy[index] = default_lazy;
    }
    T query(int l, int r) { return query(l, r, 0, size, 0); }
    T query(int l, int r, int cur_l, int cur_r, int index) {
      // [l, r)に対するクエリ
      eval(index);
      if (cur_r <= l || r <= cur_l) return default_value;
      if (l <= cur_l && cur_r <= r) return v[index];

      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      return f(
          query(l, r, cur_l, mid, 2 * index + 1),
          query(l, r, mid, cur_r, 2 * index + 2));
    }
    void range_query(int l, int r, Lazy x) { range_query(l, r, x, 0, size, 0); }
    void range_query(int l, int r, Lazy x, int cur_l, int cur_r, int index) {
      // [l, r)に対して操作する

      eval(index);
      if (cur_r <= l || r <= cur_l) return;
      if (l <= cur_l && cur_r <= r) {
        lazy[index] = x;
        eval(index);
        return;
      }
      // 左右を見ていく
      int mid = (cur_l + cur_r) / 2;
      range_query(l, r, x, cur_l, mid, 2 * index + 1);
      range_query(l, r, x, mid, cur_r, 2 * index + 2);
      v[index] = f(v[2 * index + 1], v[2 * index + 2]);
    }
};


int main() {
  int N, Q; cin >> N >> Q;
  SegTree<ll, ll> T(N, (1LL<<31)-1, -1,
      [](ll a, ll b) {return min(a, b);},
      [](ll a, ll b) {
      return a == -1 ? b : a;},
      [](ll a, ll lz, int size) {return lz == -1 ? a : lz;});

  rep(i, Q) {
    int q; cin >> q;
    int l, r; cin >> l >> r;
    if (q == 0) {
      ll x; cin >> x;
      T.range_query(l, r+1, x);
    } else {
      cout << T.query(l, r+1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 9980
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn c2i(c: char) -> i32 {
    c as i32 - 'a' as i32
}

fn main() {
    let n: usize = read();
    let mut letters = vec![vec![0;30];n];

    for i in 0..n{
        let s:Vec<char> = read::<String>().chars().collect();
        for c in s.into_iter(){
            letters[i][c2i(c) as usize] += 1;
        }
    }

    let mut ans: String = String::new();
    for i in 0..30{
        let mut min_c = 100;
        for j in 0..n{
            min_c = std::cmp::min(min_c,letters[j][i]);
        }
        for _ in 0..min_c{
            ans.push(('a' as u8 + i as u8) as char);
        }
    }

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


Measured memory_bytes: 2104
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		System.out.println(A <= 9 && B <= 9 ? A * B : -1);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

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

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

  int ans = 0;

  for(int b = 2; b < 33; b++){
    int tmp = b * b;
    while(tmp * b <= X){
      tmp *= b;
    }
    if(tmp <= X && tmp > ans) ans = tmp;
  }
  if(X == 1) cout << 1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <cmath>
#include <bitset>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <string>
#include <stack>
#include <cstring>
#include <sstream>

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int &x : p) cin >> x;
    nth_element(p.begin(), p.begin() + k - 1, p.end());
    cout << accumulate(p.begin(), p.begin() + k, 0);
}


Measured memory_bytes: 3620
N,M=list(map(int,input().split()))
ans=[]
if M==0:
  print(N)
  exit()
c=N
L=list(map(int,input().split()))
while True:
  if c not in L:
    ans.append(c)
    break
  else:
    c+=1
c=N
while True:
  if c not in L:
    ans.append(c)
    break
  else:
    c-=1
if abs(ans[0]-N)>=abs(ans[1]-N):
  print(ans[1])
elif abs(ans[0]-N)<abs(ans[1]-N):
  print(ans[0])
    

Measured memory_bytes: 62040
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        sc.close();

        int num = N*(N-1)/2 - (N/2);
        System.out.println(num);

        if(N%2 == 0){
            for(int i = 1; i <= N-1; i++){
                for(int j = i+1; j <= N; j++){
                    if(i+j != N+1){
                        System.out.println(i + " " + j);
                    }
                }
            }
        } else {
            for(int i = 1; i <= N-1; i++){
                for(int j = i+1; j <= N; j++){
                    if(i+j != N){
                        System.out.println(i + " " + j);
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 23892
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
//~ #pragma GCC target ("avx2")
//~ #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;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define shandom_ruffle random_shuffle

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int nax=1000*1007;

int n, k;

int tab[nax];

int dp[nax];

int czas;
int ost[nax];

int main()
{
	scanf("%d%d", &n, &k);
	for (int i=1; i<=n; i++)
		scanf("%d", &tab[i]);
	for (int i=1; i<=k; i++)
	{
		czas++;
		for (int j=1; j<=n; j++)
			if (tab[j]<=i)
				ost[dp[i-tab[j]]]=czas;
		while(ost[dp[i]]==czas)
			dp[i]++;
	}
	if (dp[k])
		printf("First\n");
	else
		printf("Second\n");
	return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
using namespace std;

const int MOD = 1e9 +7;

int main(){
    fly;
    
    int n=0, m=0;
    
    cin>>n>>m;
    
    vector<string>s(n);
    
    for(auto &i: s) cin>>i;
  	//for(int i = 0; i < n; ++i) cin>>s[i];
    
    vector<vector<unsigned long long> >a(n, vector<unsigned long long>(m, 0));
  
    a[0][0] = 1;
    for(unsigned long i = 0; i < n;++i) {
        for(unsigned long j = 0; j <m; ++j) {
          	if(s[i][j] == '#') continue;
            if(i != 0) a[i][j] += a[i-1][j];
          	a[i][j] %=MOD;
          	if(j != 0) a[i][j] += a[i][j-1];
          	a[i][j] %=MOD;
        }
    }
    cout<<a[n-1][m-1]<<endl;
    return 0;
}


Measured memory_bytes: 12144
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		final int N = scanner.nextInt();
		final int M = scanner.nextInt();
		final int K = scanner.nextInt();

		List<Integer>[] friendLists = new ArrayList[N];
		List<Integer>[] blockLists = new ArrayList[N];
		for (int i = 0; i < N; i++) {
			friendLists[i] = new ArrayList<Integer>();
			blockLists[i] = new ArrayList<Integer>();
		}
		int[] result = new int[N];

		int A, B;
		for (int i = 0; i < M; i++) {
			A = scanner.nextInt() - 1;
			B = scanner.nextInt() - 1;
			friendLists[A].add(B);
			friendLists[B].add(A);
			result[A]--;
			result[B]--;
		}
		for (int i = 0; i < K; i++) {
			A = scanner.nextInt() - 1;
			B = scanner.nextInt() - 1;
			blockLists[A].add(B);
			blockLists[B].add(A);
		}

		boolean[] visited = new boolean[N];

		int[] root = new int[N];
		int[] size = new int[N];

		for (int i = 0; i < N; i++) {
			if (!visited[i]) {
				DFS(friendLists, i, i, visited, root, size);
			}
		}

		for (int i = 0; i < N; i++) {
			result[i] += size[root[i]] - 1;
			for (int j : blockLists[i]) {
				if (i < j && root[i] == root[j]) {
					result[i]--;
					result[j]--;
				}
			}
		}

		for (int i = 0; i < N; i++) {
			System.out.print(result[i] + (i == N - 1 ? "\n" : " "));
		}

	}

	static int groupSize;

	static void DFS(List<Integer>[] graph, int rep, int vertex, boolean[] visited, int[] root, int[] size) {
		visited[vertex] = true;
		root[vertex] = rep;
		size[rep]++;
		graph[vertex].forEach(neighbor -> {
			if (!visited[neighbor]) {
				DFS(graph, rep, neighbor, visited, root, size);
			}
		});
	}

}


Measured memory_bytes: 175964
n, k = map(int, input().split())
h = list(map(int, input().split()))

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

for _ in range(k+2):
    h.append(f_inf)

dp = [f_inf]*(n+k)

dp[0] = 0

for i in range(1, n):
    for j in range(1, k+1):
        if i >= j:
            dp[i] = chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]))

print(dp[n-1])

Measured memory_bytes: 58080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			char[] s = in.nextString().toCharArray();

			int[] w = new int[n+1], e = new int[n+1];
			for (int i = 0; i < n; i++) {
				if (s[i] == 'E') {
					e[i+1]++;
				} else if (s[i] == 'W') {
					w[i+1]++;
				}
			}

			for (int i = 1; i < n+1; i++) {
				w[i] += w[i-1];
				e[i] += e[i-1];
			}

			long ans = Math.min(w[n-1]-w[0], e[n]-e[1]);
			for (int i = 1; i < n-1; i++) {
				ans = Math.min(ans, w[i-1]-w[0]+e[n]-e[i]);
			}

			out.println(ans);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int main() {
  string str;
  cin >> str;
  if(str.at(5)=='1'||str.at(6)=='5'||str.at(6)=='6'||str.at(6)=='7'
     ||str.at(6)=='8'||str.at(6)=='9'){
  	cout<<"TBD"<<endl;}
  	else{cout<<"Heisei"<<endl;}

}

Measured memory_bytes: 256
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,k=0,q=0,x=0;
    cin>>n>>k>>q;
    vector<int> v(n);
    vector<int> a(n,0);
    for(int i=0;i<n;++i)
    	{
    		v[i]=k;a[i]=0;
    	}
    for(int i=0;i<q;++i)
    {
    	cin>>x;
    	++a[x-1];
    }
    for(int i=0;i<n;++i)
    {
    	v[i]-=(q-a[i]);
    	//cout<<v[i]<<" ";
    }
    for(auto i: v)
    {
    	cout<<(i<=0?"No":"Yes")<<endl;
    }
}

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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

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

    map<string ,int > mp;
    int m(0);
    rep(i,n){
        string s;   cin >> s;
        mp[s]++;

        m = max(m,mp[s]);
    }

    for(auto a : mp){
        if(a.second==m){
            cout << a.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 19228
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;
#define intl long long
double sum(intl a){
	double sur=0;
	while(a>0){
		sur=sur+a%10;
		a=a/10;
	}
	return sur;
}
int main(){
	intl a=1,n;
	cin>>n;
	intl index=1;
	double r;
	while(n>0){
		r=index;
		if(r/sum(r)>(r+a)/sum(r+a)){
			index=index-a;
			a=a*10;
		}
		else{
			cout<<index<<endl;
			n--;
		}
		index=index+a;
	}
	return 0;
}

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


using namespace std;
int main() {
	char c[4];
	int ans = 0;
	lp(i, 4)
		cin >> c[i];
	lp(i, 4) {
		if (c[i] == '+')
			ans++;
		else
			ans--;
	}

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

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

int main()
{
	string s,s1="",s2="";
	getline(cin,s);
	int n;
	n=s.size();	
		
	s1=s;
	for (int i=0; i<n; i++)
	{
		s2 = s2 + s[n-1-i];
 	}
 	
	if (s1!=s2)
    {cout << "No"<<endl;
    return 0;}
    
	else
    {
		s1="";
		s2="";
	for(int i=0;i<(n-1)/2;i++)
		{
			s1=s1+s[i];
			s2=s2+s[(n-1)/2-i-1];
		}
	} 
	if (s1!=s2)
    {cout << "No"<< endl;
	return 0;}
	else
    {
		s1="";
		s2="";
	for(int i=(n+3)/2-1;i<n;i++)
		{
			s1+=s[i];
			s2+=s[n-i+(n+3)/2-1-1];
		}
	}
	if (s1!=s2)
    {cout << "No" << endl;
	return 0;}
	else
		cout<<"Yes";
		  
	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 rep0(i, b, s) for(int i=b;i<s;i++)
typedef long long ll;
 
int main(){
    ll A, B;
    cin >> A >> B;
    B++;
    ll C=A, D=B;
 
    vector<int> ans;
 
    int n = 0;
 
    while(pow(2, n+1) < B){
        n++;
    }
 
    int m = n;
 
    while(n >= 1){
        ll numA, numB;
        if (A >= pow(2, n)) {
            numA = A - pow(2,n);
            A -= pow(2, n);
        }
        else numA = 0;
 
        if (B >= pow(2, n)) {
            numB = B - pow(2,n);
            B -= pow(2, n);
        }
        else numB = 0;
 
        ans.push_back((numB+numA)%2);
        if (n==1) {
            numA = C/2;
            numB = D/2;
            ans.push_back((numB+numA)%2);
        }
 
        n--;
        
    }
 
    ll ans_num=0;

    if (m==0){
        if (D==1) cout << 0 << endl;
        else cout << 1 << endl;
    } 
    else{
        for(int i=0; i<=m; i++){
            ans_num += ans[i] * pow(2, m-i);
        }
 
        cout << ans_num << endl;
    }
 
    
 
}

Measured memory_bytes: 256
#include <cstdio>

const int MOD=1e9+7;

void addmod(int& x,int y){
  x=(x+y)%MOD;
}

char str[3005];
int dp[3005][3005];

int main(){
  int N;
  scanf("%d",&N);
  scanf("%s",str);
  dp[1][1]=1;
  for(int i=2;i<=N;i++){
    if(str[i-2]=='<'){
      for(int j=1;j<=i;j++){
	dp[i][j]=dp[i-1][j-1];
      }
    }else{
      for(int j=1;j<=i;j++){
	dp[i][j]=(dp[i-1][i-1]-dp[i-1][j-1]+MOD)%MOD;
      }
    }
    /*
    for(int j=0;j<=i;j++){
      printf("dp[%d][%d]=%d\n",i,j,dp[i][j]);
    }
    */
    for(int j=1;j<=i;j++){
      addmod(dp[i][j],dp[i][j-1]);
    }
  }
  printf("%d\n",dp[N][N]);
  return 0;
}


Measured memory_bytes: 34176
import java.util.Scanner; 
 
public class Main {
   public static void main(String[] args) {
     // ?¨??????\???????????????????????????????????????
     Scanner sc = new Scanner(System.in);
     int w = sc.nextInt();
     int n = sc.nextInt();
     int[] values = new int[w];
     for (int i = 0; i < values.length; i++) {
       values[i] = i + 1;
     }
     for (int i = 0; i < n; i++) {
       String str = sc.next();
       String[] ab = str.split(",");
       int a = Integer.parseInt(ab[0]) - 1;
       int b = Integer.parseInt(ab[1]) - 1;
       // a??¨b????????£???values??????????????????
       int swap;
       swap = values[a];
       values[a] = values[b];
       values[b] = swap;
     }
     // values??????????????????
       for(int i = 0; i < n; i++){
         System.out.println(values[i]);
       }
   }
} 

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vi a(n), b(n);
	vi fa(n+1), fb(n+1);
	M00(i, n) cin >> a[i];
	M00(i, n) cin >> b[i];
	M00(i, n) {
		fa[a[i]]++;
		fb[b[i]]++;
	}
	vi PA(n+1), PB(n+1);
	M00(i, n) {
		if(i == 0) PA[1] = fa[1];
		else PA[i+1] = PA[i] + fa[i+1];
	}
	M00(i, n) {
		if(i == 0) PB[1] = fb[1];
		else PB[i+1] = PB[i] + fb[i+1];
	}

	M00(i, n+1) {
		if(fa[i] + fb[i] > n) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	//HOW
	//adj[i] = stores pairs of (num, freq) of B that map to A's i;
	vi shift(n+1, 0);
	M00(i, n) {
		int lb = PB[i];
		int rb = PB[i+1]-1;
		int la = PA[i];
		int ra = PA[i+1]-1;
		if(rb < lb || ra < la) continue;
		
		pi ran = mp(la - rb + n, ra - lb + n);
		ran.f %= n;
		ran.s %= n;
		if(ran.f <= ran.s) {
			shift[ran.f]++;
			shift[ran.s+1]--;
		} else {
			shift[ran.f]++;
			shift[n]--;
			shift[0]++;
			shift[ran.s+1]--;
		}
	}
	int sum = 0;
	int ans;
	M00(i, n) {
		sum += shift[i];
		if(sum == 0) {
			ans = i;
		}
	}
	M00(i, n) {
		cout << b[(i - ans + n) % n] << " ";
	}
	cout << endl;
}


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

int main(){
    int N,M; cin >> N >> M;
    vector<int> X(M);
    for(int i=0;i<M;i++) cin >> X[i];
    sort(X.begin(),X.end());

    vector<int> gap(M-1);
    for(int i=0;i<M-1;i++) gap[i] = abs(X[i]-X[i+1]);
    sort(gap.begin(),gap.end());
    reverse(gap.begin(),gap.end());
    long long s=0;
    for(int i=N-1;i<M-1;i++) s+=gap[i];
    cout << s << endl;
}

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

using namespace std;

int main(){

  long long int a, b, x;
  cin>>a>>b>>x;

  long long int count=0;
  count=(b/x)-(a/x);

  if(a%x==0) count+=1;
  else if(a==0) count+=1;

  cout<<count<<endl;
}


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

using namespace std;
typedef long long ll;

template <int MD>
struct ModInt {
    typedef ModInt M;
    int v;
    ModInt(int _v = 0) : v(_v) {}
    M& operator += (const M &r) {
        if ((v += r.v) >= MD) v -= MD;
        return *this;
    }
    M& operator *= (const M &r) {
        v = ll(v) * r.v % MD;
        return *this;
    }
    M operator + (const M &r) const { return M(*this) += r; }
    M operator * (const M &r) const { return M(*this) *= r; }
};
typedef ModInt<1000000007> Mint;
typedef vector< vector<Mint> > Mat;

const int MN = 50;
int n;
ll m;
Mat a;

Mat matmul(const Mat &a, const Mat &b) {
    Mat c(n, vector<Mint>(n, 0));
    for (int i = 0; i < n; i++) {
        for (int k = 0; k < n; k++) {
            Mint t = a[i][k];
            for (int j = 0; j < n; j++) {
                c[i][j] += t * b[k][j];
            }
        }
    }
    return c;
}

int main() {
    cin >> n >> m;
    a = Mat(n, vector<Mint>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int x;
            cin >> x;
            a[i][j] = x;
        }
    }

    Mat res(n, vector<Mint>(n, 0));
    for (int i = 0; i < n; i++) res[i][i] = 1;
    while (m) {
        if (m & 1) res = matmul(res, a);
        a = matmul(a, a);
        m >>= 1;
    }

    Mint sm = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            sm += res[i][j];
        }
    }
    cout << sm.v << endl;
    return 0;
}

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

using namespace std;

int main()
{
  int score_of_Taro = 0, score_of_Hanako = 0;
  int n;

  cin >> n;
  cin.ignore();
  
  while (n--) {
    string str_Taro, str_Hanako;
    cin >> str_Taro >> str_Hanako;
    cin.ignore();
    if (str_Taro > str_Hanako) {
      score_of_Taro += 3;
    } else if (str_Taro < str_Hanako) {
      score_of_Hanako += 3;
    } else {
      score_of_Taro++;
      score_of_Hanako++;
    }
  }

  cout << score_of_Taro << " " << score_of_Hanako << endl;
}
      
    



Measured memory_bytes: 3204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int n = Convert.ToInt32(N);
            if (n % 1000 > 0)
            {
                Console.WriteLine(1000 - n % 1000);
            }
            else
                Console.WriteLine("0");

        }
    }
}

Measured memory_bytes: 17640
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H.sort(reverse=True)
    cnt = 0
    ans = 0
    for h in H:
        if cnt < K:
            cnt += 1
        else:
            ans += h
    print(ans)


if __name__ == "__main__":
    main()

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

vector <long long> positions;

void solution(){
	long long res = 0;
	for(long long i = 0; i < positions.size(); i++){
		res += positions[i];
	}
	cout << res << endl;
}

int main(){
	string s;
	cin >> s;

	long long counter = 0; 
	for(long long i = 0; i < s.size(); i++){
		if(s[i] == 'B') counter++;
		else positions.push_back(counter);
	}

	solution();
}

Measured memory_bytes: 5140
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ff first
#define mp make_pair
#define dd second
#define pp pair<int,int>
#define N 100005
using namespace std;

int x,y;

int check(int w, int s) {
    if(w >= x) w++;
    int po_prawej = s+1-w+1;
    if(w < x) po_prawej--;
    int yy = po_prawej;
    if(yy >= y) yy++;
    return (x*y) > (yy)*w;
}

bool test(int s) {
    int temp = (s+2)/2;
    for(int i = 0; i < 4 and i+temp <= s; ++i) {
        if(not check(i+temp, s)) return false;
    }
    for(int i = 0; i < 4 and temp-i >= 1; ++i) {
        if(not check(temp-i, s)) return false;
    }
    return  true;
}

main() {
    ios_base::sync_with_stdio(false);
    //freopen("test2", "r", stdin);
    int q; cin >> q;
    while(q--) {
        cin >> x >> y;
        if(y < x) swap(x,y);
        int l = 0;
        int r = 2e9;
       // cout << "test " << test(4) << endl;
        while (r - l > 4) {
            int s = (l + r) / 2;
            if (test(s)) {
                l = s;
            } else {
                r = s;
            }
        }
        for (int i = r; i >= l; --i) {
            if (test(i)) {
                cout << i << "\n";
                break;
            }
        }
    }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll a, b, k;

    cin >> a >> b >> k;

    if (k <= a){
        a -= k;
    } else if (k <= a+b){
        b -= (k-a);
        a = 0;
    } else {
        a = 0;
        b = 0;
    }

    cout << setprecision(20) << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=509;
	int n,A[N][N],f[N][N],sum[N][N],g[N][N];
	int main(){
		n=read<int>();
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++) if(i^j)
				A[i][j]=read<int>();

		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++) sum[i][j]=A[i][j]+sum[i][j-1],g[i][j]=(i>=j?A[i][j]:0)+g[i][j-1];
		for(int j=1;j<=n;j++)
			for(int i=1;i<=n;i++) sum[i][j]+=sum[i-1][j],g[i][j]+=g[i-1][j];
	
		for(int i=1;i<=n;i++) f[0][i]=g[i][i];
		int ans=0;
		for(int i=2;i<=n;i++){
			for(int j=0;j<i;j++)
				for(int k=j+1;k<i;k++){
					f[k][i]=max(f[k][i],f[j][k]+sum[k][i]-sum[k][k]+sum[i][k]-sum[i][j]-sum[k][k]+sum[k][j]+g[i][i]+g[k][k]-g[i][k]-g[k][i]);
					if(i==n) ans=max(ans,f[k][i]);
				}
		}
		printf("%lld\n",sum[n][n]-ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 11712
import Control.Monad

main = do
    n <- readLn
    ss <- map (toTuple . words) <$> replicateM n getLine
    print $ sum $ map toJPY ss

toTuple :: [String] -> (Double, String)
toTuple (n:t:xs) = (read n, t)

toJPY :: (Double, String) -> Double
toJPY (n, t)
    | t == "BTC" = n * 380000.0
    | t == "JPY" = n

Measured memory_bytes: 636
#include <stdio.h>
#include<string.h>

int main() {
    int N=0;
	char s[99]={"\0"};
	char *ptr;
	char f[99]={"\0"};
	char b[99]={"\0"};
	scanf("%d", &N);
	scanf("%s", s);
	
	ptr = s;
	int k=0;
	do{
		/*printf("%c", s[k]);*/
		k++;
	}while(s[k]!='\0');
	putchar('\n');
	
	int ans=0;
	int max=0;
	for (int x=0;x<=strlen(s)-2;x++){
		ans=0;
	    int i=0;
	    do {
			f[i]=ptr[i];
			i++;
		} while( i<=x);
		/*printf("f=%s\n", f);*/
	
		int j=0;
		do {
			b[j]=ptr[j+x+1];
			j++;
		} while(s[j+x]!='\0');
		/*printf("b=%s\n", b);*/
		
		int ans=0;
		int temp=0;
		for(int y=0; y<=strlen(f)-1;y++ ) {
			temp=0;
			for(int z=0; z<=strlen(b)-1;z++) {
				/*printf("f[%d]=%c b[%d]=%c\n",y,f[y],z,b[z]);*/
				if (f[y]==b[z]) {
					/*printf("OK");*/
					temp=1;
					for(int zz=0;zz<y;zz++) {
						if (f[zz]==f[y]) temp=0;
					}
			    }
			}
			
			if (temp==1) ans++;
		}
		if(max<=ans) max=ans;
		
	}
	printf("%d", max);
	return(0);
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int gcd(int x,int y)
{
	if(x==0) return y;
	return gcd(y%x,x);
}
int lcm(int x, int y)
{
	return (x * y / gcd(x, y));
}
 
signed main(){
	IOS();
	cin>>N>>K;
	if((N-1)*(N-2)/2<K){
		cout<<-1<<endl;
		return 0;
	}
	K=(N-1)*(N-2)/2-K;
	vector<pair<int,int>>ans;
	rep(i,1,N){
		ans.push_back({0,i});
	}
	rep(i,1,N){
		rep(j,i+1,N){
			if(K<=0)continue;
			ans.push_back({i,j});
			K--;
		}
	}
	cout<<ans.size()<<endl;
	for(auto e:ans){
		cout<<e.fi+1<<" "<<e.se+1<<endl;
	}
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

const int N = 100010;
const int mod = 998244353;

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        int d1 = a.ss - a.ff, d2 = b.ss - b.ff;
        return ((d1 > d2) || (d1 == d2 && a.ff < b.ff));
    }
};

vector<int> g[N];
int visited[N] = {};

void dfs(int v) {
    visited[v] = 1;
    for (int k : g[v]) {
        if (!visited[k])
            dfs(k);
    }
}

int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

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

    int u, v;
    for (int i = 0; i < m; ++i)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

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

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

Measured memory_bytes: 11076
# -*- coding: utf-8 -*-
"""
B - fLIP
https://atcoder.jp/contests/code-festival-2017-quala/tasks/code_festival_2017_quala_b

"""
import sys


def solve(N, M, K):
    if K%N == 0 or K%M == 0:
        return 'Yes'
    for y in range(N+1):
        for x in range(M+1):
            if x * y + (N - y) * (M - x) == K:
                return 'Yes'
    return 'No'


def main(args):
    N, M, K = map(int, input().split())
    ans = solve(N, M, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
	ll n;
	cin>>n;
	V<ll> a(n+1,0);
	for(ll i=1;i<=105;i++){
		for(ll j=1;j<=105;j++){
			for(ll k=1;k<=105;k++){
				ll d=i*i+j*j+k*k;
				d+=i*j+j*k+k*i;
				if(d>n)continue;
				a[d]++;
			}
		}
	}
	for(int i=1;i<=n;i++)cout<<a[i]<<"\n";
}


Measured memory_bytes: 3700
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
  
    int res = 0;
    bool bAlice = true;
    rep(i, 0, N) {
      res += (bAlice ? a[i] : -a[i]);
      bAlice = !bAlice;
    }
  
    cout << res << endl;
}


Measured memory_bytes: 256
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var n, k int

func main() {
	sc.Split(bufio.ScanWords)
	n, k = nextInt(), nextInt()

	e := make([]float64, n)
	for i := 0; i < n; i++ {
		p := nextInt()
		pf := float64(p)
		if i == 0 {
			e[i] = pf * (pf + 1) / (2 * pf)
			continue
		}
		e[i] = e[i-1] + pf*(pf+1)/(2*pf)
	}

	//fmt.Println(e)
	ans := e[k-1]
	for i := k; i < n; i++ {
		ans = maxFloat64(ans, e[i]-e[i-k])
	}

	fmt.Println(ans)
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void){
	long w,h,temp,i;
	long long ans=0;
	cin >> w >> h;
	vector <pair<long,bool>> vec;
	for(i=0;i<w;i++){
		cin >> temp;
		vec.push_back( make_pair(temp,true) );
	}
	for(i=0;i<h;i++){
		cin >> temp;
		vec.push_back( make_pair(temp,false) );
	}
	sort(vec.begin(),vec.end());
	for(i=0;i<vec.size();i++){
		if(vec[i].second){
			ans+=(h+1)*vec[i].first;
			w--;
		}else{
			ans+=(w+1)*vec[i].first;
			h--;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4464
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int r,g,b;
	cin>>r>>b>>g;
	int tmp=b*10+g;
	if(tmp%4) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
	return 0;
}

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


int main () {
	string a;
	int ans=0;
	cin >> a;


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

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	// S := nextString()
	// T := nextString()
	var S, T string
	fmt.Scan(&S)
	fmt.Scan(&T)
	bs := []byte(S)
	ts := []byte(T)
	smap := map[byte]int{}
	for i := 0; i < len(bs); i++ {
		if bs[i] != ts[i] {
			a := bs[i]
			b := ts[i]
			if smap[a] != 0 || smap[b] != 0 {
				fmt.Println("No")
				return
			}
			for j := 0; j < len(bs); j++ {
				if bs[j] == a {
					bs[j] = b
				} else if bs[j] == b {
					bs[j] = a
				}
			}
		}
		smap[bs[i]]++
	}
	for i := 0; i < len(bs); i++ {
		if bs[i] != ts[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[i].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 3712
import java.util.Scanner;

public class Main {
	static int[][] bingo = new int[3][3];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				bingo[i][j] = Integer.parseInt(sc.next());
			}
		}
		int n = Integer.parseInt(sc.next());
		for (int i = 0; i < n; i++) {
			int ball = Integer.parseInt(sc.next());
			check(ball);
		}

		if (isBingo()) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

	private static boolean isBingo() {
		// 縦、横
		for (int i = 0; i < 3; i++) {
			if (bingo[i][0] == -1 && bingo[i][1] == -1 && bingo[i][2] == -1) {
				return true;
			}
			if (bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1) {
				return true;
			}
		}

		// ナナメ
		if (bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1) {
			return true;
		}
		if (bingo[2][0] == -1 && bingo[1][1] == -1 && bingo[0][2] == -1) {
			return true;
		}
		return false;
	}

	static void check(int num) {
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (num == bingo[i][j]) {
					bingo[i][j] = -1; // 穴
				}
			}
		}
	}

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(int argc, char *argv[])
{
  int debt = 100000;
  int n;
  int i;
  int remainder;

  scanf("%d", &n);

  for(i = 0; i < n; i++)
    {
      debt *= 1.05;
      if((remainder = debt % 1000) != 0)
	debt += 1000 - remainder;
    }
    
  printf("%d\n", debt);

  return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, vector<int> a) {
    long long  first = 0;
    long long second = 0;
    long long tmp;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        tmp = a.back();
        a.pop_back();
        if (tmp == a.back()) {
            if (first == 0) {
                first = tmp;
            } else {
                second = tmp;
                break;
            }
            a.pop_back();
        }
    }
    std::cout << first * second << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n;

    gettimeofday(&start,NULL);

    std::cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    solve(n, a);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;
typedef long long ll;

int main()
{
    string s;
    int sum = 0;
    cin >> s;
    for(int i = 0; i < s.length()-1; i++){
        if(s[i] != s[i+1]) sum++;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 512
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let t: String = scan(tokens);
    let mut pos = vec![Vec::new(); 26];
    for (i, b) in s.bytes().enumerate() {
        pos[b as usize - b'a' as usize].push(i + 1);
    }
    let mut cur = 0;
    let mut wrap = 0;
    for b in t.bytes() {
        let p = &pos[b as usize - b'a' as usize];
        if p.is_empty() {
            println!("-1");
            return;
        }
        if let Some(tmp) = min_more_than(cur, p) {
            cur = tmp;
        } else {
            wrap += 1;
            cur = p[0];
        }
    }
    println!("{}", wrap * s.len() + cur);
}

fn min_more_than(x: usize, v: &[usize]) -> Option<usize> {
    if v.is_empty() {
        return None;
    }
    if v[0] > x {
        return Some(v[0]);
    }
    let mut a: usize = 0;
    let mut b: usize = v.len();
    while a + 1 < b {
        let c = (a + b) / 2;
        if v[c] <= x {
            a = c;
        } else {
            b = c;
        }
    }
    if b == v.len() {
        None
    } else {
        Some(v[b])
    }
}


Measured memory_bytes: 6396
#include<stdio.h>
#include<string.h>

typedef long long ll;			//ld.
typedef unsigned long long ull;	//llu.


int main(){
	int l,r,d;
	scanf("%d %d %d",&l,&r,&d);
	int sum  = 0;
	for(int i=l;i<=r;i++){
		if(i%d==0)
			sum+=1;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 1720
#include <cstdio>
#include <map>
#include <algorithm>

typedef long long LL;

const int N = 100010;

struct A {
    int x, y;
    A(int x = 0, int y = 0) {
        this->x = x;
        this->y = y;
    }
    bool operator < (const A &d) const {
        if(x == d.x) {
            return y < d.y;
        }
        return x < d.x;
    }
    bool operator == (const A &d) const {
        return x == d.x && y == d.y;
    }
}a[N * 9];

std::map<A, int> mp;

int ans[10];

int main() {
    int m, n, k;
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 1, x, y; i <= k; i++) {
        scanf("%d%d", &x, &y);
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(x + j > n || y + k > m || x + j < 3 || y + k < 3) {
                    continue;
                }
                mp[A(x + j, y + k)]++;
            }
        }
    }
    std::map<A, int>::iterator it = mp.begin();
    int tot = 0;
    for(; it != mp.end(); it++) {
        tot++;
        ans[it->second]++;
    }
    printf("%lld\n", 1ll * (m - 2) * (n - 2) - 1ll * tot);
    for(int i = 1; i <= 9; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 63488
H, W = map(int, input().split())
fields = [['.'] * (W+2)] + [['.'] + list(input()) + ['.'] for _ in range(H)] + [['.'] * (W+2)]

for i in range(1, H+1):
  for j in range(1, W+1):
    if fields[i][j] == '#':
      continue
    else:
      mine_cnt = 0
      for row in [-1, 0, 1]:
        for column in [-1, 0, 1]:
          if fields[i+row][j+column] == '#':
            mine_cnt += 1
      fields[i][j] = str(mine_cnt)
for i in range(1 , H+1):
  row = ''.join(fields[i][1:W+1])
  print(row)

  


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { printf("ERROR%d!\n",num); }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int S, W;
    cin >> S >> W;
    if(S<=W) cout << "unsafe" << endl;
    else cout << "safe" << endl; 

}

Measured memory_bytes: 3640