akhauriyash/Code-Regression huggingface dataset:
/*
 　　　　　／＞　 フ
 　　　　　| 　_　 _|
 　 　　　／`ミ _x 彡
 　　 　 /　　　 　 |
 　　　 /　  ヽ　　 ?
 　／￣|　　 |　|　|
 　| (￣ヽ＿_ヽ_)_)
 　＼二つ
  */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int P = 1e9 + 7;
const int N = 400005;
char s[N];
int sum[N], f[N], a[N], m, n;
ll inv[N], fac[N], ans;
template <typename T>
inline void Add(T &x, T y) { x += y, x >= P && (x -= P, 0); }

inline ll C(int n, int m) {
    if (n < m || n < 0) return 0;
    return fac[n] * inv[m] % P * inv[n-m] % P;
}

namespace subtask {
    int main(int lim) {
        if (n & 1) return write(0), 0;
        int pre = 1;
        for (int i = 1;i <= m; i++) if (!a[i]) {
            if ((i - pre) & 1) Mn(lim, i - pre);
            pre = i + 1;
        }
        n >>= 1, lim = (lim + 1) >> 1;
        f[0] = sum[0] = 1;
        for (int i = 1;i <= n; i++) {
            f[i] = sum[i-1] - (i >= lim + 1 ? sum[i - lim - 1] : 0), Add(f[i], P);
            sum[i] = sum[i-1], Add(sum[i], f[i]);
        }
        for (int i = 1;i <= lim; i++)
            Add(ans, 1ll * f[n-i] * i * 2 % P);
        write(ans);
        return 0;
    }
}

int main() {
    read(n), read(m), scanf ("%s", s + 1);
    for (int i = 1;i <= m; i++) a[i] = s[i] == s[1];
    for (int i = 1;i <= m; i++)
        if (!a[i]) return subtask::main((i - 1) | 1);
    if (n == 1) return write(0), 0;
    inv[0] = inv[1] = fac[0] = fac[1] = 1;
    for (int i = 2;i <= n + 2; i++) 
        inv[i] = (P - P / i) * inv[P % i] % P;
    for (int i = 2;i <= n + 2; i++)
        inv[i] = inv[i-1] * inv[i] % P, fac[i] = fac[i-1] * i % P;
    for (int i = 0;i + i <= n; i++) 
        ans += C(n - i, i) + C(n - 2 - i, i);
    write(ans % P);
    return 0;
}


Measured memory_bytes: 7248
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n;
  	cin >> n;
  	vi t(n+1), x(n+1), y(n+1);
  	t[0] = x[0] = y[0] = 0;
  	rep(i,n) cin >> t[i+1] >> x[i+1] >> y[i+1];
  	rep(i,n){
    	int T = t[i+1]-t[i];
      	int X = abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
      	if(T-X<0 || (T-X)%2==1){
        	puts("No");
          	return;
        }
    }
  	puts("Yes");
  	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 1408
using System;
 
class Program{
	public static void Main(){
		string s;
		float[] n = new float[8], m = new float[3];
		while((s = Console.ReadLine()) != null){
			n = Array.ConvertAll(s.Split(' '), float.Parse);
			m[0] = (n[4] - n[2]) * (n[7] - n[3]) - (n[5] - n[3]) * (n[6] - n[2]);
			m[1] = (n[0] - n[4]) * (n[7] - n[5]) - (n[1] - n[5]) * (n[6] - n[4]);
			m[2] = (n[2] - n[0]) * (n[7] - n[1]) - (n[3] - n[1]) * (n[6] - n[0]);
			Array.Sort(m);
			Console.WriteLine(m[0] > 0 || m[2] < 0 ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 9236
//============================================================================
// Name        : A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#define  rep(i,a) for(int i = 0; i < int(a); i++)
#include <vector>
using namespace std;

int main() {
	int K[101], k;

	vector<int> G[101];
	int N, M, x;
	while (true ) {
		cin >> N ;
		if (N == 0) break;
		rep(i, N) {
			G[i].clear();
		}
		rep(i,N) {
			cin >> M;
			rep(j,M) {
				cin >> x;
				G[i].push_back(x);
			}
		}
		cin >> k ;
		rep(i, k) cin >> K[i];
		int num = 0, vt;
		rep(i, N) {
			bool ok = true;
			rep(j, k) {
				bool flag = false;
				rep(z, G[i].size()) {
					if (G[i][z] == K[j]) {
						flag = true;
						break;
					}
				}
				if (!flag) {
					ok = false;
					break;
				}
			}

			if (ok) {
				num ++ ;
				vt = i;
	 		}
			}
		if (num != 1)
			cout << -1 << endl;
		else {
			cout << vt + 1 << endl;
		}
	}
	return 0;
}

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

int keta(long long x){
  int c = 0;
  while(x>0){
    x = x/10;
    c++;
  }
  return c;
}
int main(){
  long long N;
  cin >> N;
  long long ans = 9000000000000;
  long long d = sqrt(N);
  
  for(int i = 1;i<=d;i++){
    if(N%i != 0) continue;
    long long A = i;
    long long B = N/i;
    long long F = max(keta(A),keta(B));
    ans = min(ans,F);
  }
  cout << ans << endl;
 }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		// オリジナルのマス目をString型配列gridとする
		String[][] grid = new String[h][w];
		for(int i = 0; i < h; i++) {
			String s = sc.next();
			
			for(int n = 0; n < w; n++) {
				grid[i][n] = s.substring(n, n + 1);
			}
			
		}
		
		// #を1に.を0に変換し、新しいint型配列checkGridに格納する
		int[][] checkGrid = new int[h][w];
		for(int i = 0; i < h; i++) {
			
			for(int n = 0; n < w; n++) {
				if(grid[i][n].equals("#")) {
					checkGrid[i][n] = 1;
				}else {
					checkGrid[i][n] = 0;
				}
			}
		}
		
		/* 
		 * 行チェック
		 * 全てがドットであれば当該行の数をすべて足しても0
		 * 後の条件分岐のため合計が0＝取り除く行の番号をdelGyoに格納 
		 */
		int[] delGyo = new int[h];
		for(int i = 0; i < h; i++) {
			
			int gyoSum = 0;
			for(int n = 0; n < w; n++) {
				gyoSum += checkGrid[i][n];
				
			}
			
			if(gyoSum == 0) {
				delGyo[i] = 0;
			}else {
				delGyo[i] = 1;
			}
			
		}
		
		// 列チェック＝行チェック同様
		int[] delRetsu = new int[w];
		for(int i = 0; i < w; i++) {
			
			int retsuSum = 0;
			for(int n = 0; n < h; n++) {
				retsuSum += checkGrid[n][i];
				
			}
			
			if(retsuSum == 0) {
				delRetsu[i] = 0;
			}else {
				delRetsu[i] = 1;
			}
			
		}
		
		/*
		 * delGyoから、取り除く行であればcontinue
		 * 取り除く行でない場合はdelRetsuで取り除く列か調べる
		 * 両方をクリアしたものだけ表示する
		 */
		for(int i = 0; i < h; i++) {
			if(delGyo[i] == 0) {
				continue;
			}else {
				
				for(int n = 0; n < w; n++) {
					if(delRetsu[n] == 0) {
						continue;
					}else {
						System.out.print(grid[i][n]);
					}
					
				}
				
				System.out.println("");
			}
			
		}
	}

}


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

int main()
{
    int ans=0;
    string S,W;
    cin>>W;

    transform(W.begin(),W.end(),W.begin(),::tolower);

    while(cin>>S){

        if(S=="END_OF_TEXT")break;

        transform(S.begin(),S.end(),S.begin(),::tolower);

        if(W==S)ans++;

    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;
const int inf = TEN(18) * 3 + 10;

int N;
int A[16];
int saying[16][16];
int check[16];

signed main()
{
	cin >> N;

	memset(saying, -1, sizeof saying);

	rep(i, N) {
		cin >> A[i];

		rep(j, A[i]) {
			int x, y; cin >> x >> y;
			--x;
			saying[i][x] = y;
		}
	}

	int mx = 0;

	rep(S, (1 << N)) {
		memset(check, -1, sizeof check);
		bool f = true;
		int counter = 0;

		rep(i, N) {
			if (S >> i & 1) {
				counter++;

				rep(j, N) {
					if (saying[i][j] != -1) {
						if (saying[i][j] == 1) {
							if ((S >> j & 1) == 0) f = false;
							if (check[j] == -1) check[j] = saying[i][j];
							else if (check[j] != saying[i][j]) f = false;
						} else {
							if (S >> j & 1) f = false;
						}
					}
				}
			}
		}

		if (f) {
			chmax(mx, counter);
		}
	}

	cout << mx << endl;
}



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

int main(){
    ll n, a[5], m;
    cin >> n;
    for(int i = 0; i < 5; i++)
    {
        cin >> a[i];
        if(i==0) m=a[i];
        else m=min(m, a[i]);
    }
    cout << (n+m-1)/m-1+5 << endl;
    
}

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

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

  vector<lint> A(N);
  for(auto& elem : A) cin >> elem;
  set<lint> st(A.begin(), A.end());

  for(auto a : st) {
    for(int i=2; i*a<1123456; i++) {
      st.erase(i*a);
    }
  }

  map<lint, lint> mp;
  for(auto a : A) mp[a]++;
  for(auto [a, cnt] : mp) {
    if(cnt >= 2) st.erase(a);
  }

  cout << st.size() << endl;
}

Measured memory_bytes: 26556
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	string S;
	
	cin >> S;
	
	if (S.at(0) == '0' && S.at(1) != '0') {
		//MMYYの可能性あり(1桁月)
		if (S.at(2) == '0' && S.at(3) != '0') {
			cout << "AMBIGUOUS" << endl;
			return 0;
		} else if (S.at(2) == '1' && (S.at(3) >= '0' && S.at(3) <= '2')) {
			cout << "AMBIGUOUS" << endl;
			return 0;
		} else {
			cout << "MMYY" << endl;
		}
	} else if (S.at(0) == '1' && (S.at(1) >= '0' && S.at(1) <= '2')) {
		//MMYYの可能性あり(2桁月)
		if (S.at(2) == '0' && S.at(3) != '0') {
			cout << "AMBIGUOUS" << endl;
			return 0;
		} else if (S.at(2) == '1' && (S.at(3) >= '0' && S.at(3) <= '2')) {
			cout << "AMBIGUOUS" << endl;
			return 0;
		} else {
			cout << "MMYY" << endl;
		}
	} else {
		//MMではないのでYYMMかNA
		if (S.at(2) == '0' && S.at(3) != '0') {
			cout << "YYMM" << endl;
			return 0;
		} else if (S.at(2) == '1' && (S.at(3) >= '0' && S.at(3) <= '2')) {
			cout << "YYMM" << endl;
			return 0;
		} else {
			cout << "NA" << endl;
		}
	}

	return 0;
}


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

int main()
{
  int w, h, n;
  cin >> w >> h >> n;
  int i, j;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> a(n);
  vector<int> xcolor(w+1, 1);
  vector<int> ycolor(h+1, 1);
  for(i = 0; i < n; i++)
  {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  for(i = 0; i < n; i++)
  {
    if(a.at(i) == 1)
    {
      for(j = x.at(i)-1; j >= 0; j--)
      {
        xcolor.at(j) = 0;
      }
    }
    if(a.at(i) == 2)
    {
      for(j = x.at(i)+1; j <= w; j++)
      {
        xcolor.at(j) = 0;
      }
    }
    if(a.at(i) == 3)
    {
      for(j = y.at(i)-1; j >= 0; j--)
      {
        ycolor.at(j) = 0;
      }
    }
    if(a.at(i) == 4)
    {
      for(j = y.at(i)+1; j <= h; j++)
      {
        ycolor.at(j) = 0;
      }
    }
  }
  int xcount, ycount;
  xcount = 0;
  ycount = 0;
  for(i = 0; i <= w; i++)
  {
    if(xcolor.at(i) == 1)
    {
      xcount++;
    }
  }
  for(i = 0; i <= h; i++)
  {
    if(ycolor.at(i) == 1)
    {
      ycount++;
    }
  }
  if(xcount == 0)
  {
    xcount = 1;
  }
  if(ycount == 0)
  {
    ycount = 1;
  }
  cout << (xcount-1) * (ycount-1) << endl;
}

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

using namespace std;
int a[100001][4];
int dp[100001][4];

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=3;j++) cin>>a[i][j];
    }
    for(int j=1;j<=3;j++) {
        dp[1][j]=a[1][j];
    }
    for(int i=2;i<=n;i++) {
        for(int j=1;j<=3;j++) {
            for(int k=1;k<=3;k++) {
                if(k!=j) dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
            }
        }
    }
    int ans=0;
    for(int j=1;j<=3;j++) ans=max(ans,dp[n][j]);
    cout<<ans<<endl;
}


Measured memory_bytes: 3328
n = int(input())
pos = []
for _ in range(n):
    p = list(map(int, input().split()))
    pos.append(p)

ans = 0
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        dpos = [pos[i][0] - pos[j][0], pos[i][1] - pos[j][1]]
        cnt = 0
        for k in range(n):
            for l in range(n):
                if k == l:
                    continue
                tmp = [pos[k][0] - pos[l][0], pos[k][1] - pos[l][1]]
                if dpos[0] == tmp[0] and dpos[1] == tmp[1]:
                    cnt += 1
        ans = max(cnt, ans)

print(n-ans)


Measured memory_bytes: 44220
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int mxN=1e5+100;
vector<int>adj[mxN];
vector<int>dp(mxN,-1);
int recur(int u) {
    if(dp[u]!=-1) {
        return dp[u];
    }
    int mx=0;
    for(int v:adj[u]) {
        mx=max(mx,recur(v)+1);
    }
    return dp[u]=mx;
}
void add_edge(int u,int v) {
    adj[u].emplace_back(v);
}
int main(int argc, char const *argv[]) {

    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        u--,v--;
        add_edge(u,v);
    }
    int ans=0;
    for(int i=0;i<n;i++) {
        ans=max(ans,recur(i));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8192
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <numeric>
using namespace std;
#define MAX_N 400
#define MAX_S 100010

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; }
const long long INF = 1LL << 60;

// Input
int A, B, T;

int main() {
    cin >> A >> B >> T;

    cout << B * int((T + 0.5) / A)  << endl;
}

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

#define FOR(i,a,b) for(int (i) = (a);(i) < (int) (b);(i)++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;

int A [3];

int main()
{
	FOR(i,0,3){
		scanf("%d",&A [i]);
	}

	if(count(A,A + 3,5) == 2 && count(A,A + 3,7) == 1){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
#define foreach(ix,a) for(auto& (ix) : (a)
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,n)cin>>a[i];
  bool f =true;
  rep(i,n){
    if(a[i]%2==0){
      if(a[i]%5!=0&&a[i]%3!=0)f=false;
    }
  }
  if(f)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  
}

Measured memory_bytes: 256
mycode = '''
# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True

ctypedef long long LL
cdef LL MOD = 10**9 + 7
cdef LL N = int(input())
cdef LL ans = 1

cdef i
for i in range(2, N + 1):
    ans *= i
    ans %= MOD
print(ans)
'''
import sys
import os
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時 or コードテスト時
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


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

int n;
string a;
int main()
{
	int i;
	cin >> a;
	a = ' ' + a;
	for (i = 1; i < a.size() - 1; i++) {
		if (a[i] == a[i + 1]) {
			printf("%d %d", i, i + 1);
			return 0;
		}
		if (i + 2 < a.size() && a[i] == a[i + 2]) {
			printf("%d %d", i, i + 2);
			return 0;
		}
	}
	printf("-1 -1");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);

    for (auto & a : A) {
        cin >> a;
        --a;
    }

    vector<ll> S(n, -1);

    S[0] = 0;
    ll cur = 0;
    ll s = 0;
    for (ll i = 0; i < k; ++i) {
        cur = A[cur];
        ++s;
        if (S[cur] == -1) {
            S[cur] = s;
        } else {
            auto diff = s - S[cur];
            //cerr << "diff is " << diff << endl;
            //cerr << "s is " << s << endl;
            i = s + diff * ((k-s)/diff);
            //cerr << "new i is " <<  i << endl;
            for (; i < k; ++i) {
                cur = A[cur];
            }
            break;
        }
        //cerr << cur + 1<< endl;
    }
    cout << cur + 1<< endl;

}


Measured memory_bytes: 6428
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from fractions import gcd

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    
    if K > A[N-1]:
        print('IMPOSSIBLE')
    else:
        ans = 0
        for i in range(N):
            ans = gcd(ans,A[i])
            if ans == 1:
                print('POSSIBLE')
                exit()
        if (A[N-1]-K)%ans == 0:
            print('POSSIBLE')
        else:
            print('IMPOSSIBLE')


if __name__ == "__main__":
    main()


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

int K,A,B;

void solve(){
    cin>>K>>A>>B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            printf("OK");
            return ;
        }
    }
    printf("NG");
}

int main(){
    solve();
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
ll dp[1000006];
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int main(){
	 int n;
	 cin>>n;
	 if(n == 1){
	 	cout<<"0"<<endl;
	 }
	 else if(n == 2){
	 	cout<<"2"<<endl;
	 }
	 else{
	 	   
         ll ans = ((Mod(10 , n , mod)%mod)+ Mod(8 , n , mod)- (2*Mod(9 , n , mod))%mod + mod)%mod;
         cout<<ans<<endl;
	 }
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int w,h;

    cin >> w >> h;

    int cost[10][10] = {};

    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> cost[i][j];
        }
    }
    
    for(int k=0; k<10; k++){
        for(int i=0; i<10; i++){
            for(int j=0; j<10; j++){
                cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
            }
        }
    }

    int sum = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int num;
            cin >> num;

            if(num == -1)
                continue;
            
            sum += cost[num][1];
        }
    }

    cout << sum << endl;

    return 0;
}

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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

// lnt powmod(lnt a, lnt p, lnt m){
// 	lnt res = 1, tmp = a;
// 	while(p != 0){
// 		if(p % 2) res = (res*tmp) % m;
// 		tmp = (tmp*tmp) % m;
// 		p /= 2;
// 	}
// 	return res;
// }

lnt powmod(lnt a, lnt p, lnt m){
	if(p == 0) return 1;
	return powmod(a*a%m, p/2, m)*(p%2 ? a : 1) % m;
}

int main(){
	summon_tourist;

	lnt N; cin >> N;

	lnt c00 = 0, c01 = 0, c10 = 0;
	vector<plnt> X;
	map<plnt, lnt> mp;

	REP(i, N){
		lnt a, b; cin >> a >> b;
		if(a==0 and b==0) c00++;
		else if(a==0) c01++;
		else if(b==0) c10++;
		else X.eb(a, b);
	}

	for(plnt &p: X){
		lnt a = p.first, b = p.second;
		lnt g = GCD(abs(a), abs(b));
		a /= g; b /= g;
		if(a < 0){
			a*=-1; b*=-1;
		}
		mp[{a, b}]++;
		if(b < 0){
			lnt ta = -b, tb = a;
			a = ta; b = tb;
		}
		p = {a, b};
	}
	sort(ALL(X));
	X.erase(unique(ALL(X)), X.end());
	lnt ans = (powmod(2, c01, MOD) + powmod(2, c10, MOD) - 1 + MOD) % MOD;
	for(plnt p: X){
		lnt a = p.first, b = p.second;
		cerr << a << ' ' << b << ln;
		lnt A = b, B = -a;
		lnt c0 = mp[p], c1 = mp[{A, B}];
		ans = ans * ((powmod(2, c0, MOD) + powmod(2, c1, MOD) - 1 + MOD) % MOD) % MOD;
	}
	
	cout << (ans-1+c00+MOD) % MOD << ln;
}

Measured memory_bytes: 35940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner scanner = new Scanner(System.in);
        String X = scanner.next();
        String Y = scanner.next();
        int x = X.codePointAt(0);
        int y = Y.codePointAt(0);
        System.out.println(hikaku(x,y));
    }
    public static String hikaku(int x, int y){
        if(x < y){
            return("<");
        }
        if(x > y){
            return(">");
        }
        if(x == y){
            return("=");
        }
        return("error");
    }

}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < int(n); i++)
#define rep1(i,n) for (int i = 1; i <= int(n); i++)
#define repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#define YesNo(c) ((c) ? "Yes" : "No")
#ifdef LOCAL
#define dump(x) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] " << #x " = " << (x) << endl;
#else
#define dump(x)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.fst << ", " << p.snd << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.fst >> p.snd; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
////////////////////////////////

int n;
string s;
vector<int> v;

int dfs(int k) {
    if (k < n) {
        int sum = 0;
        v[k] = 0; sum += dfs(k+1);
        v[k] = 1; sum += dfs(k+1);
        return sum;
    }
    string a,b;
    rep (i,n) (v[i] ? a : b).push_back(s[n+i]);
    reverse(all(a)); reverse(all(b));
    
    int dp[20][20] = {}; // dp[i+1][j+1] : a[0..i], b[0..j]
    if (!a.empty() && a[0] == s[0]) dp[1][0] = 1;
    if (!b.empty() && b[0] == s[0]) dp[0][1] = 1;
    rep (i,a.size()) if (a[i] == s[i]) dp[i+1][0] += dp[i][0];
    rep (j,b.size()) if (b[j] == s[j]) dp[0][j+1] += dp[0][j];
    rep (i,a.size()) rep (j,b.size()) {
        if (a[i] == s[(i+1)+(j+1)-1]) dp[i+1][j+1] += dp[i][j+1];
        if (b[j] == s[(i+1)+(j+1)-1]) dp[i+1][j+1] += dp[i+1][j];
    }
    return dp[a.size()][b.size()];
}

int32_t main() {
    cin >> n >> s;
    v.resize(n);
    cout << dfs(0) << endl;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	string S;cin>>S;
	int N=S.size();
	vint ans(N);

	int st=0;
	rep(i,N){
		if(S[i]=='R'){
			st=0;
			continue;
		}
		st++;
		if((st-1)&1)ans[i]=i-st;
		else ans[i]=i-st+1;
	}

	st=0;
	for(int i=N-1;i>=0;i--){
		if(S[i]=='L'){
			st=0;
			continue;
		}
		st++;
		if((st-1)&1)ans[i]=i+st;
		else ans[i]=i+st-1;
	}

	vint cnt(N);
	rep(i,N)cnt[ans[i]]++;
	rep(i,N){
		if(i)cout<<" ";
		cout<<cnt[i];
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 2176
#include <cstdio>
#include <cstdint>
#include <cctype>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>

int encode(int ch) {
  if (islower(ch)) return ch - 'a';
  if (isupper(ch)) return ch - 'A' + 26;
  assert(false);
}

int decode(int ch) {
  if (ch < 26) return ch + 'a';
  if (ch < 52) return ch - 26 + 'A';
  assert(false);
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<int> k(n);
  for (auto& ki: k) scanf("%d", &ki);

  char buf[128];
  scanf("%s", buf);
  std::string s = buf;

  for (size_t i = 0; i < s.length(); ++i) {
    int d = encode(s[i]);
    (d -= k[i % n]) %= 52;
    if (d < 0) d += 52;
    s[i] = decode(d);
  }

  printf("%s\n", s.c_str());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}
int last_digit(int n)
{
    int ans = 0;
    while (n != 0)
    {
        ans = n % 10;
        n /= 10;
    }
    return ans;
}
long long moduloMultiplication(long long a,
                               long long b,
                               long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    cn(a, n);
    ll sum = 0;
    for (auto i : a)
    {
        sum += i;
    }
    ll res = 0;
    for (int i = 0; i < n; i++)
    {
        sum -= a[i];
        res += moduloMultiplication(a[i], sum, MOD);
        res %= MOD;
    }
    cout << res << "\n";
}


Measured memory_bytes: 4052
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1] * (n + 1)
        self.rnk = [0] * (n + 1)
        
    def Find_root(self, x):
        if (self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_root(self.root[x])
            return self.root[x]
    
    def Unite(self, x, y):
        x = self.Find_root(x)
        y = self.Find_root(y)
        if (x == y):
            return
        elif (self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if (self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    
    def isSameGroup(self, x, y):
        return self.Find_root(x) == self.Find_root(y)
    
    def Count(self, x):
        return - self.root[self.Find_root(x)]
    
n, m = map(int, input().split())
p = [int(i) for i in input().split()]
union = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    union.Unite(x - 1, y - 1)
count = 0
for i, pp in enumerate(p):
    if union.Find_root(i) == union.Find_root(pp - 1):
        count += 1
print(count)

Measured memory_bytes: 14452
import collections
 
k = int(input())
 
li = [str(i) for i in range(1,10)]
st_li = li[:]
q = collections.deque(li)
count = 0
n = 10 ** 10
 
for i in range(1, n):
    a = q.popleft()
    num = int(a[-1])
    if num != 0:
        aa = a + str(num-1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    aa = a + str(num)
    st_li.append(aa)
    q.append(aa)
    count += 1
    if num != 9:
        aa = a + str(num+1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    if count > k+1:
        print(st_li[k - 1])
        exit(0)

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

namespace ARC097
{
    class C
    {
        static void Main(string[] args)
        {
            //input
            string s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());

            List<string> list = new List<string>();
            for (int i = 1; i <= 5; i++)
            {
                for (int j = 0; j < s.Length - i + 1; j++)
                {
                    string tmp = s.Substring(j, i);
                    list.Add(tmp);
                }

                list = list.Distinct().OrderBy(x => x).ToList();
            }
            //Console.WriteLine(string.Join(",", list));
            Console.WriteLine(list[K - 1]);
        }
    }
}


Measured memory_bytes: 18272
#include <bits/stdc++.h>
#define MAX 100005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define fi(a,b,c) for(int i=a;i<b;i=i+c)
#define fj(a,b,c) for(int j=a;j<b;j+=c)
using namespace std;
 
ll gcd(ll n1,ll n2) {
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent) {
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
ll max(ll a,ll b,ll c) {
	return max(a,max(b,c));
}
int max(int a,int b,int c) {
	return max(a,max(b,c));
}

int main()
{
	int a,b,c,d;
	sd(a);sd(b);sd(c);sd(d);
	fi(1,200,1){
		if(c-i*b<=0){
			printf("Yes");
			break;
		}else if(a-i*d<=0){
			printf("No");
			break;
		}
	}
}

Measured memory_bytes: 3828
def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
x = int(arr_data[0][1])

mindata=int(arr_data[1][0])
for i in range(1,1+n):
    x-=int(arr_data[i][0])
    
    mindata = int(arr_data[i][0]) if mindata > int(arr_data[i][0]) else  mindata
mysum=n

print(mysum + x //mindata)

Measured memory_bytes: 3192
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		int cut_k=(n-1)*(n-2)/2-k;

		if(cut_k<0)
		{
			printf("%d\n", -1);
			continue;
		}

		int m=n-1+cut_k;

		printf("%d\n", m);
		for(int i=2;i<=n;i++)
		{
			printf("%d %d\n", 1, i);
		}

		for(int i=2;i<n && cut_k>0;i++)
		{
			for(int j=i+1;j<=n && cut_k>0;j++)
			{
				printf("%d %d\n", i, j);
				cut_k--;
			}
		}
	}
	return 0;
}


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

int main() {
	int n, k; 
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        if (a[i] >= k)
            ans++;
    }
    printf("%d\n", ans);
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int ans = 0;
  int x = 0;
  
  REP(i, n) {
    if (s[i] == 'I')
      ++x;
    else
      --x;
    ans = max(ans, x);
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {

	ll n; cin >> n;
	ll x, y;
	for (ll i = 1; i * i <= n ; i++) {		
		if (n % i == 0) {
			ll j = n / i;
			x = i;
			y = j;
		}
	}	
	cout << x + y - 2 << endl;
	return 0;
}

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

using namespace std;

int main(){
  int K, X;
  cin>> K >> X;
  int maxi = 1000000;
  int  mini = -1000000;
  int left = X +1 - K;
  int right = X -1 + K;
  if(left < mini)
  left = mini ;
  if(right > maxi)
  right = maxi;
  for(int i=left;i<=right;i++){
  	cout<<i<<" "; 
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=100009;
int f[N],b[N],ara[N];
int main()
{
    int n,res;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>ara[i];
    f[0]=ara[0],b[n-1]=ara[n-1];
    for(int i=1;i<n;i++)
        f[i]=__gcd(ara[i],f[i-1]);

    for(int i=n-1;i>=0;i--)
        b[i]=__gcd(ara[i],b[i+1]);

    res=0;
    for(int i=0;i<n;i++)
    {
        if(i==0) res=b[1];
        if(i==(n-1))res=max(res,f[n-2]);
        res=max(res,__gcd(f[i-1],b[i+1]));
    }
    cout<<res<<endl;
    return 0;
}


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

#define ll long long
#define pli pair<ll, int>

template <typename T>
bool vmin(T& a, T b) {
	return (a > b) ? (a = b, true) : false;
}

const ll llf = 1e18;

ll n;
int T, A, B, C, D;

map<ll, ll> F;
vector<pair<int, int>> tr;

ll dfs(ll n) {
	if (n == 0) {
		return 0;
	} else if (n == 1) {
		return D;
	} else if (F.count(n)) {
		return F[n];
	}
	ll ret = llf;
	if (n <= ret / D) {
		ret = n * D;
	}
	for (auto t : tr) {
		int d = t.first;
		int c = t.second;
		ll nn = n / d * d;
		vmin(ret, dfs(nn / d) + (n - nn) * D + c);
		nn = (n + d - 1) / d * d;
		vmin(ret, dfs(nn / d) + (nn - n) * D + c);
	}
	return F[n] = ret;
}

void solve() {
	cin >> n >> A >> B >> C >> D;
	F.clear();
	tr = vector<pair<int, int>> {make_pair(2, A), make_pair(3, B), make_pair(5, C)};
	cout << dfs(n) << '\n';
}

int main() {
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}


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

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    
    if ( b - a + 1 <= k*2 ) {
        for ( int i = a; i <= b; i++ ) {
            cout << i << endl;
        }
    } else {
        for ( int i = a; i < a+k; i++ ) {
            cout << i << endl;
        }
        for ( int i = b-k+1; i <= b; i++ ) {
            cout << i << endl;
        }
    }
    
    return (0);
}

Measured memory_bytes: 3636
float l,r;
L[4],R[4];
C(float x){
	if(x<0.2)
		return 3;
	if(x<0.6)
		return 2;
	if(x<1.1)
		return 1;
	return 0;
}
main(i){
	for(;~scanf("%f%f",&l,&r);){
		L[C(l)]++;
		R[C(r)]++;
	}
	for(i=0;i<4;i++)
		printf("%d %d\n",L[i],R[i]);
	exit(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}

bool v[5050][5050];

bool ng(int r){
    if(r<0||r>=5050) return 1;
    else return 0;
}

int main(){
    int i,j;
    int n;
    while(1){
        cin>>n;
        if(n==0) break;
        memset(v,0,sizeof(v));
        int a[n][2];
        int ans=0;
        for(i=0;i<n;i++){
            cin>>a[i][0]>>a[i][1];
            v[a[i][0]][a[i][1]]=1;
        }
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                int x1=a[i][0];
                int y1=a[i][1];
                int x2=a[j][0];
                int y2=a[j][1];
                int x3=x2-y2+y1;
                int y3=y2+x2-x1;
                int x4=x1-y2+y1;
                int y4=y1+x2-x1;
                if(ng(x3)) continue;
                if(ng(x4)) continue;
                if(ng(y3)) continue;
                if(ng(y4)) continue;
                if(v[x3][y3]&&v[x4][y4]) ans=max(ans,(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
            }
        }
        cout<<ans<<endl;
    }

}


Measured memory_bytes: 27916
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  //input output template
  /*
  int N;
  cin >> N;
  cout << "Hello, world!" << endl;
  */
  /*
  int count_r=0;
  int count_g=0;
  int count_b=0;
  */
  
  int A;
  int X[100];
  
  int temp;
  cin >> A;
  for(int i=0; i<A; i++){
  	cin >> X[i];  
    if(X[i] > temp) temp = X[i];
  }
  
  int score;
  int lowscore=0;
  
  for(int P=1; P<=temp; P++){
  
   score = 0;
    
   for(int i=0; i<A; i++){
     
  
    score += (X[i] - P) * (X[i] - P); 
   }
   
   if(P==1) lowscore = score;
   if(lowscore > score) lowscore = score;
 
  }
  
  cout << lowscore << endl;  
  /*
  char str[4000];
  cin >> str;
  */
  
    

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <numeric>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<string> s;
  vector<int> t;
  for (int i = 0; i < N; i++) {
    string ts;
    int tt;
    cin >> ts >> tt;
    s.push_back(ts);
    t.push_back(tt);
  }
  int all = accumulate(t.begin(), t.end(), 0);
  string si;
  cin >> si;
  for (int i = 0; i < N; i++) {
    all -= t[i];
    if (si == s[i]) {
      break;
    }
  }
  cout << all << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main() {
	const int num = 1;
	int n = 0, k = 0;
	int f;
	std::cin >> n >> k;
	f = num;

	for (int i = 0; i<n; i++) {
		if (f + k <= f * 2) {
			f = f + k;
		}
		else {
			f = 2 * f;
		}
	}

	std::cout << f << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long int n;
  cin>>n;
  char a[1000000];
  int k=0;
  while(n){
    a[k]=(n-1)%26;
    n=(n-1)/26;
    k++;
  }
  for(int i=k-1;i>=0;i--){
    char ch=a[i]+97;
    printf("%c",ch);
  }
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,m; cin>>n>>m;
    ll ans=0;
    map<ll,ll> mp;
    rep(i,n){
        ll k; cin>>k;
        rep(j,k){
            ll a; cin>>a;
            mp[a]++;
        }
    }
    for(auto x:mp){
        if(x.second==n) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
using namespace std;
#define MAXN 100010
int a[MAXN], b[MAXN], c[MAXN];
int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &c[i]);
	}
	sort(a, a + N);
	sort(b, b + N);
	sort(c, c + N);
	long long ai=0, ci=0;
	long long sum = 0;
	for (int i = 0; i < N; i++)
	{
		while (a[ai] < b[i] && ai< N)
		{
			ai++;
		}
		while (c[ci] <= b[i] && ci<N)
		{
			ci++;
		}
		sum += ai*(N-ci);
	}
	printf("%lld\n", sum);
	return 0;
}


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

int main() {
  int N, K, s = 1;

  cin >> N >> K;
  while(N){
    if(s < K){
      s *= 2;
    }else{
      s += K;
    }
    N--;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
# AtCoder用のライブラリ
# 参照
# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7


# a ** n mod m
def mod_pow(a, n, m=10 ** 9 + 7):
    res = 1
    while n > 0:
        if n & 1 == 1:
            res = res * a % m
        a = a * a % m
        n >>= 1
    return res


# aの-1乗をmで割ったときの商を求める
def mod_inv(a, m=10 ** 9 + 7):
    b = m
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        c = a
        a = b
        b = c

        u -= t * v
        c = u
        u = v
        v = c
    u %= m
    return u


inv_fact_list = [1]
P_list = [1]


def combination(r):
    if r > len(inv_fact_list) - 1:
        _list_extend(r)
    return inv_fact_list[r] * P_list[r] % MOD


def _list_extend(needed):
    now = len(inv_fact_list)
    while now <= needed:
        P_list.append(P_list[-1] * (n - now + 1) % MOD)
        inv_fact_list.append(inv_fact_list[-1] * mod_inv(now) % MOD)
        now += 1


ans = (mod_pow(2, n) - combination(b) - combination(a) - 1) % MOD

print(ans)

Measured memory_bytes: 18936
# coding=utf-8

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

def merge(A, left, mid, right):
    global counter
    L = A[left:mid] + [inf]
    R = A[mid:right] + [inf]
    i = j = 0
    for k in range(left, right):
        if L[i] < R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
        counter += 1


n = int(input())
A = list(map(int, input().split()))
counter = 0
inf = float("inf")

mergeSort(A, 0, n)
print(*A)
print(counter)

Measured memory_bytes: 63696
#include <bits/stdc++.h>
long A,n,p,t,a[10000],L,D=1;std::string s;int main(){std::cin>>n>>p>>s;for(int i = n - 1; i >= 0 ; i--){L=s[i]-'0',t=(D*L+t)%p,D=(D*10)%p;A+=((10%p)!=0)?(t==0)+a[t]++:((L%p)==0)*(i+1);}std::cout<<A;}


Measured memory_bytes: 644
#include <iostream>
#include <algorithm>
#include <numeric>
#include <list>

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))



using namespace std;
typedef long long ll;

int main() {
    int n,k;
    cin >> n>> k;
    int hs[n];
    for (int i=0;i<n; i++){
        cin >> hs[i];
        // cout << hs[i] << endl;
    }
    if (k >= n) cout << 0 << endl;
    else {
        std::sort(hs, hs+SIZE_OF_ARRAY(hs));
        // cout << SIZE_OF_ARRAY(hs) << endl;
        ll s = accumulate(hs, hs + n-k, (ll) 0);
        cout << s << endl;
    }
}


Measured memory_bytes: 4376
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() {
    IOS;
    int a[3][3] = {}, n, b[3][3] = {}, c;
    for (int i = 0; i <3; i++){
        for (int j = 0; j <3; j++){
            cin >> a[i][j];
        }
    } 
    cin >> n;
    while (n--) {
        cin >> c;
        for (int i = 0; i <3; i++){
            for (int j = 0; j <3; j++){
                if (c == a[i][j]){
                    b[i][j] = 1;
                }
            }
        }   
    }
    if (b[0][0] && b[0][1] && b[0][2]) cout << "Yes";
    else if (b[1][0] && b[1][1] && b[1][2]) cout << "Yes";
    else if (b[2][0] && b[2][1] && b[2][2]) cout << "Yes";
    else if (b[0][0] && b[1][0] && b[2][0]) cout << "Yes";
    else if (b[0][1] && b[1][1] && b[2][1]) cout << "Yes";
    else if (b[0][2] && b[1][2] && b[2][2]) cout << "Yes";
    else if (b[0][0] && b[1][1] && b[2][2]) cout << "Yes";
    else if (b[2][0] && b[1][1] && b[0][2]) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3580