akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

vector<int> divs[1000005];
int cnt[1000005];


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

    for (int i = 2; i <= 1000000; ++i) {
        for (int m = i; m <= 1000000; m += i) {
            divs[m].push_back(i);
        }
    }

    int N;
    cin >> N;
    vector<int> A(N);
    for (int& e : A) cin >> e;


    bool pair = 1;

    for (int i = 0; i < N; ++i) {
        for (int d : divs[A[i]]) {
            if (cnt[d] > 0) {
                pair = 0;
            }
            cnt[d]++;
        }
    }

    if (pair) {
        cout << "pairwise coprime" << endl;
    } else {
        for (int v = 1; v <= 1000000; ++v) {
            // cout << kv.first << " " << kv.second <<endl;
            if (cnt[v] == N) {
                cout << "not coprime" << endl;
                return 0;
            }
        }
        cout << "setwise coprime" << endl;
    }
}

Measured memory_bytes: 121564
import java.util.Scanner;

public class Main {

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

    private static void solve(Scanner in) {
        int a = in.nextInt(), b = in.nextInt();
        System.out.printf("%d %d %.5f\n", a / b, a % b, ((double) a / b));
    }
}

Measured memory_bytes: 26528
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
    string S;
    cin>>S;
    cout<<(S[2]==S[3]&&S[4]==S[5]?"Yes":"No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define long int64_t
 
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n;
    cin >> n;
    map<string, int> m;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long ans = 0;
    for(auto it : m)
        ans += 1LL * it.second * (it.second - 1) ;
    cout << ans/2;
    return 0;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++)
        cout<<'x';
    cout<<endl;
  

    return 0;   
}


 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<1000)
    {
        cout<<1000-n<<endl;
    }
    else
    {
        if(n%1000==0)
        {
            cout<<0<<endl;
        }
        else
        {
            int x=(n/1000)+1;
            int y=x*1000;
            cout<<y-n<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct State {
  int cost;
  int number;
  int x;
  int y;
  State() {;}
  State(int cost, int number, int x, int y) : cost(cost), number(number), x(x), y(y) {;}
  bool operator<(const State &rhs) const {
    return cost > rhs.cost;
  }
};

int h, w;
int gx, gy;
int maxnumber;
int field[110][110];
bool visit[2510][2510];
//int dist[2510][2510];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main() {
  while (scanf("%d %d", &w, &h), w|h) {
    MEMSET(field, 0);
    MEMSET(visit, false);
    //MEMSET(dist, 0x0f);
    maxnumber = 0;
    int sy, sx;
    REP(y, h) {
      REP(x, w) {
        char str[100];
        scanf("%s", str);
        if (str[0] == 'S') {
          sx = x; sy = y;
        } else if (str[0] == 'G') {
          gx = x; gy = y;
        } else if (str[0] != '.') {
          int num = atoi(str);
          maxnumber = max(maxnumber, num);
          field[y][x] = num;
        }
      }
    }
    field[gy][gx] = maxnumber + 1;

    queue<State> que;
    que.push(State(0, 1, sx, sy));
    while (!que.empty()) {
      State state = que.front();
      que.pop();
      if (visit[state.number][state.y * w + state.x]) { continue; }
      visit[state.number][state.y * w + state.x] = true;
      if (state.number >= maxnumber + 1 && state.y == gy && state.x == gx) {
        printf("%d\n", state.cost);
        goto end;
      }
      REP(dir, 4) {
        int nx = state.x + dx[dir];
        int ny = state.y + dy[dir];
        if (nx < 0 || nx >= w || ny < 0 || ny >= h) { continue; }
        //if (field[ny][nx] > state.number) { continue; }
        int nnumber = state.number;
        int ncost = state.cost + 1;
        if (field[ny][nx] == nnumber) {
          nnumber++;
        }
        que.push(State(ncost, nnumber, nx, ny));
      }
    }
end:;
  }
}

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

using namespace std;

#define li long long int

const int N 	= 1e3 + 5;
const li mod 	= 1e9 + 7;

int n, m;
char a[N][N];
li dp[N][N];

li go(int x, int y) {
	if (x > n or y > m or a[x][y] == '#') return 0;
	if (x == n and y == m) return 1;
	if (dp[x][y] != -1) return dp[x][y];
	li ans = go(x + 1, y) + go(x, y + 1);
	ans %= mod;
	return dp[x][y] = ans;
}

void solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
		}
	}
	memset(dp, -1, sizeof(dp));
	li ans = go(1, 1);
	cout << ans;
} 

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,t,z=0;
    cin>>n;
    t=n;
    while(n>0){n/=10;z++;}
    if(z==1)
    	cout<<t;
    else if(z==2)
    	cout<<9;
    else if(z==3)
    	cout<<t-90;
    else if(z==4)
    	cout<<909;
    else if(z==5)
    	cout<<t-9090;
    else
    	cout<<90909;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<int>A(N+1);
    vector<int>B(N);
    long long sum=0;
    for(int i=0;i<N+1;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    for(int i=0;i<N;i++){
        if(A[i]>=B[i]){
            sum+=B[i];
        }
        else{
            sum+=A[i];
            B[i]-=A[i];
            sum+=min(A[i+1],B[i]);
            A[i+1]-=min(A[i+1],B[i]);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>
 
 int d[50][50];
 int c[505][505];
 int theNum[5][50];
 
signed main(){
	
	int n,color; cin >> n>>color;
	
	rep(i,color)rep(j,color) cin>>d[i][j];
	rep(i,n)rep(j,n) cin>>c[i][j];
	rep(i,3)rep(j,color) theNum[i][j] = 0;
	rep(i,n)rep(j,n) theNum[(i+j)%3][c[i][j]-1]++;
	
	int ans = 1234567890123;
	rep(i,color)rep(j,color)if(i != j) rep(k,color) if(i!=k&&j!=k)
	{
		int cnt = 0;
		rep(l,color) cnt += theNum[0][l] * d[l][i];
		rep(l,color) cnt += theNum[1][l] * d[l][j];
		rep(l,color) cnt += theNum[2][l] * d[l][k];
		ans = min(ans,cnt);
		
	}
	
	
	
	cout << ans << endl;
	 
	
}

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

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

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

const int inf = 1e9;
const ll infL = (ll) 1e18;
const int N = 100005;
const ll mod = (ll) 1e9 + 7;
const ll mod2 = 998244353LL;

int D[10 * N];

void pre(){
	
	memset(D, 0, sizeof D);
	
	for(int i = 2; i <= 1e6; i++){
		for(int j = i; j <= 1e6; j = j + i)
			D[j]++;
	}
}
int32_t main(){
	fio;
	pre();
	int n;
	cin >> n;
	ll ans = 0;
	
	for(int i = 1; i < n; i++){
		ans += D[n - i] + 1;	
	}
	cout << ans << '\n';
    return 0;
}

/*

 */



Measured memory_bytes: 7544
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
 
   String a = sc.next();
   String b = sc.next();
   String c = sc.next();
 
   System.out.println(a.substring(0,1)+b.substring(1,2)+c.substring(2,3));
 }
}

Measured memory_bytes: 21332
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll n, ans = 1; ll a[114514], b[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)cin >> b[i];
	if (n == 1 && a[0] != b[0]) {
		puts("0");
		return 0;
	}
	for (int i = 1; i < n - 1; i++) {
		if (a[i] != a[i - 1] && b[i] != b[i + 1] && a[i] != b[i]) {
			puts("0");
			return 0;
		}
		if (a[i] == a[i - 1] && b[i] != b[i + 1] && b[i] > a[i]) {
			puts("0");
			return 0;
		}
		if (a[i] != a[i - 1] && b[i] == b[i + 1] && b[i] < a[i]) {
			puts("0");
			return 0;
		}
		if (a[i - 1] == a[i] && b[i] == b[i + 1]) {
			ans *= min(a[i], b[i]);
			ans %= 1000000007;
		}
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll a[15];
int main(){
    ll n;
    cin>>n;
    vector<int> p;
    while(n){
        n--;p.push_back(n%26);n/=26;
    }
    reverse(p.begin(),p.end());
        for(int i=0;i<p.size();i++){
            cout<<(char)(p[i]+'a');
        }cout<<endl;
}   

Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#define D 365
#define INF 1001001001
typedef long long ll;
ll calcSat(int *tmpt, int s[][26], int *c) {
	int last[26] = {0};
	ll tmpSat = 0;
	for (int i = 0; i < D; i++) {
		tmpSat += s[i][tmpt[i] - 1];
		last[tmpt[i] - 1] = i + 1;
		for (int j = 0; j < 26; j++) {
			tmpSat -= (c[j] * (i + 1 - last[j]));
		}
		/**
		printf("%lld\n", tmpSat);
		/**/
	}
	return tmpSat;
}
int main() {
	srand(628);
	scanf("%*d");
	int c[26], s[D][26];
	int t[D] = {0};
	ll bestSat = 0;
	for (int i = 0; i < 26; i++) {
		scanf("%d", &c[i]);
	}
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) {
			scanf("%d", &s[i][j]);
		}
	}
	/**/
	int last[26] = {0};
	for (int i = 0; i < D; i++) {
		ll bestNowSat = -INF;
		int bestType = 0;
		for (int j = 0; j < 26; j++) {
			ll tmpSat = 0;
			tmpSat += s[i][j];
			for (int k = 0; k < 26; k++) {
				if (k != j) {
					tmpSat -= (c[k] * (i + 1 - last[k]));
				}
			}
			if (bestNowSat < tmpSat) {
				bestNowSat = tmpSat;
				bestType = j;
			}
		}
		bestSat += bestNowSat;
		t[i] = bestType + 1;
		last[bestType] = i + 1;
	}

	for (int cnt = 0; cnt < 260100; cnt++) {
		int pos = rand() % D;
		int oldt = t[pos];
		t[pos] = rand() % 26 + 1;
		ll tmpSat = calcSat(t, s, c);
		if (tmpSat > bestSat) {
			bestSat = tmpSat;
		} else {
			t[pos] = oldt;
		}
	}
	// printf("%lld\n", bestSat);

	for (int i = 0; i < D; i++) {
		printf("%d\n", t[i]);
	}
	return 0;
}


Measured memory_bytes: 1764
N,M = map(int,input().split())
ks = []
for i in range(M):
    s = list(map(int,input().split()[1:]))
    ks.append(s)

ps = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    f = True
    for k, p in zip(ks,ps):
        o =  0
        for j in k:
            if (i >> j-1)&1:
                o += 1
        if o%2 != p:
            f = False
#        print(o)
    if f :
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    int N; cin >> N;
    int x[100],y[100],h[100];
    int cx,cy,H=-1;
    int outX,outY,outH;
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i] >> h[i];
        //何かしら基準を決める
        if(h[i]>=1){
            outX=x[i]; outY=y[i]; outH=h[i];
        }
    }
    int vv[3]={-1,-1,-1};
    for(int i=0;i<=100;i++){
        for(int j=0;j<=100;j++){//中心座標を全探索
            int tmp = max(outH+abs(outX-i)+abs(outY-j),0);
            bool f=true;
            for(int k=0;k<N;k++){
                if(h[k]>0 && tmp-h[k] != abs(x[k]-i)+abs(y[k]-j))
                    f=false;
                if(h[k]==0 && tmp > abs(x[k]-i)+abs(y[k]-j))
                    f=false;
            }
            if(f){
                vv[0]=i; vv[1]=j; vv[2]=tmp;
            }
        }
    }
    cout << vv[0] << " " << vv[1] << " " << vv[2] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
constexpr int M = 1000003;

long long modexp(int x, long long e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int modinv(int a, int m) {
    int x = m, y = a, p = 1, q = 0, r = 0, s = 1;
    while (y != 0) {
        int u = x / y;
        int x0 = y; y = x - y * u; x = x0;
        int r0 = p - r * u, s0 = q - s * u;
        p = r; r = r0; q = s; s = s0;
    }
    return q < 0 ? q + m : q;
}

int main() {
    int q; cin >> q;
    int fact[M] = {};
    fact[0] = 1;
    for (int i = 1; i < M; i++) fact[i] = (long long)fact[i-1] * i % M;
    while (q--) {
        int x, d, n; cin >> x >> d >> n;
        if (d == 0) {
            cout << modexp(x, n, M) << endl;
        } else if (x == 0) {
            cout << "0\n";
        } else {
            int k = (long long)x * modinv(d, M) % M;
            if (k + n - 1 >= M) cout << 0 << endl;
            else
                cout << modexp(d, n, M) * fact[k+n-1] % M * modinv(fact[k-1], M) % M << endl;
        }
    }
}


Measured memory_bytes: 4736
# abc109_b.py
# https://atcoder.jp/contests/abc109/tasks/abc109_b

# B - Shiritori /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 高橋くんは今日も 1人でしりとりの練習をしています。
# しりとりとは以下のルールで遊ばれるゲームです。
#     はじめ、好きな単語を発言する
#     以降、次の条件を満たす単語を発言することを繰り返す
#         その単語はまだ発言していない単語である
#         その単語の先頭の文字は直前に発言した単語の末尾の文字と一致する
# 高橋くんは、10秒間にできるだけ多くの単語を発言する練習をしています。
# 高橋くんが発言した単語の個数 Nと i 番目に発言した単語 Wiが与えられるので、
# どの発言もしりとりのルールを守っていたかを判定してください。

# 制約
#     Nは 2≤N≤100を満たす整数である
#     Wiは英小文字からなる長さ 1 以上 10以下の文字列である

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# W1
# W2
# :
# WN

# 出力
# 高橋くんのどの発言もしりとりのルールを守っていたなら Yes、そうでなければ No を出力せよ。

# 入力例 1
# 4
# hoge
# english
# hoge
# enigma

# 出力例 1
# No

# hoge が複数回発言されているのでしりとりのルールを守っていません。

# 入力例 2
# 9
# basic
# c
# cpp
# php
# python
# nadesico
# ocaml
# lua
# assembly

# 出力例 2
# Yes

# 入力例 3
# 8
# a
# aa
# aaa
# aaaa
# aaaaa
# aaaaaa
# aaa
# aaaaaaa

# 出力例 3
# No

# 入力例 4
# 3
# abc
# arc
# agc

# 出力例 4
# No


def calculation(lines):
    N = int(lines[0])
    # A, B = list(map(int, lines[0].split()))
    last_letter = lines[1][0]
    values = list()
    for i in range(1, N+1):
        line = lines[i]
        if line[0] != last_letter:
            return ['No']
        last_letter = line[-1:]
        if line in values:
            return ['No']
        values.append(line)
    return ['Yes']


# 引数を取得
def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4', 'hoge', 'english', 'hoge', 'enigma']
        lines_export = ['No']
    if pattern == 2:
        lines_input = ['9', 'basic', 'c', 'cpp', 'php', 'python', 'nadesico', 'ocaml', 'lua', 'assembly']
        lines_export = ['Yes']
    if pattern == 3:
        lines_input = ['8', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaa', 'aaaaaaa']
        lines_export = ['No']
    if pattern == 4:
        lines_input = ['3', 'abc', 'arc', 'agc']
        lines_export = ['No']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 8776
use proconio::input;

fn main() {
    input!(n: usize, a: [i32; n]);
    let x = a.iter().copied().max().unwrap();
    let y = a
        .iter()
        .copied()
        .filter(|&y| y != x)
        .min_by_key(|&y| (2 * y - x).abs())
        .unwrap();
    println!("{} {}", x, y);
}


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

c = [10 ** 5 + 1] * n
c[0] = 0
c[1] = abs(h[1] - h[0])

for i in range(2, n):
    h1 = c[i - 1] + abs(h[i] - h[i - 1])
    h2 = c[i - 2] + abs(h[i] - h[i - 2])
    c[i] = h1 if h1 < h2 else h2

print(c[-1])


Measured memory_bytes: 13980
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define ret return 0
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int NUM = 2e5 + 5;
int main(){
    ios
    int num_tests=1; 
    //cin>>num_tests;
    while(num_tests-->0){
        int n,d; cin>>n>>d;
        vector<vector<int>> a(n,vector<int>(d,0));
        for(int i=0;i<n;i++)
            for(int j=0;j<d;j++)
                cin>>a[i][j];
        int ans = 0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                if(i!=j){
                    long double dist = 0.0;
                    for(int k=0;k<d;k++) dist+=abs(a[i][k]-a[j][k])*abs(a[i][k]-a[j][k]);
                    dist = sqrt(dist);
                    ll new_dist = dist;
                    if(new_dist==dist) ans++;
                }
            }
        }
        cout<<ans;
    }   
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int H,W;
    int i,j;

    while(1){
        scanf("%d %d",&H,&W);
        
        if(H == 0 && W == 0){
            break;
        }else{
           
           for(i = 0; i < H; i++){
                for(j = 0; j < W; j++){
                    printf("#");
               }                            //end H
                printf("\n");
            } 
               printf("\n");                //end W

        }                                   //end if


    }                                       //end while

    return 0;
}

Measured memory_bytes: 572
A, B, K = map(int, input().split())

A_th = B+1 if A+K > B+1 else A+K
A_l = list(range(A, A_th, 1))
#print(A_l)

B_th = B-K+1 if B-K > A-1 else A
B_l = list(range(B_th, B+1, 1))
#print(B_l)

X_l = sorted(set(A_l + B_l))

for x in X_l:
  print(x)

Measured memory_bytes: 38256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		String op = "+-";
		int a = Integer.parseInt(sc.next().trim());
		if (op.indexOf(sc.next().trim())==0) {
			int b = Integer.parseInt(sc.next().trim());
			System.out.println(a+b);
		} else {
			int b = Integer.parseInt(sc.next().trim());
			System.out.println(a-b);
		} 
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35736
#include<iostream>

const int MOD = 1000000000 + 7;

const int A = 0;
const int C = 1;
const int G = 2;
const int T = 3;

using namespace std;
typedef long long ll;

ll dp[4][4][4][105];
int main()
{
    int n;
    cin >> n;
    dp[T][T][T][0] = 1;
    for (int pos = 0; pos < n; pos++)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    for (int l = 0; l < 4; l++)
                    {
                        if(j==A&&k==G&&l==C)
                            continue;
                        if(j==A&&k==C&&l==G)
                            continue;
                        if(j==G&&k==A&&l==C)
                            continue;
                        if(i==A&&k==G&&l==C)
                            continue;
                        if(i==A&&j==G&&l==C)
                            continue;
                        dp[j][k][l][pos + 1] += dp[i][j][k][pos];
                        dp[j][k][l][pos + 1] %= MOD;
                    }
                }
                
            }
            
        }
        
    }
    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                ans += dp[i][j][k][n];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//14
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

int main(){
  complex<double> p;
  double ang=0;
  for(double a,b;(cin>>a).ignore()>>b,a!=0||b!=0;){
    p+=polar(a,ang/180*acos(-1));
    ang+=b;
  }
  cout<<(int)p.imag()<<endl<<(int)p.real()<<endl;
  return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;



int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A[3]; rep(i, 3) cin >> A[i];
    int ans = 0;
    while(true){
        sort(A, A+3);
        if(A[0] == A[2]) break;
        if(A[2]-A[0] >= 2) A[0]+=2;
        else{
            A[0]+=1; A[1]+=1;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=10000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
#define pi acos(-1.0)
int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int main()
{
	int a=read(),b=read(),x=read(),rev=0;
	if (x*2<a*a*b)
	{
		double ans=atan2(1.0*a*b*b,2.0*x)*180/pi;
		printf("%0.8lf",ans);
	}
	else
	{
		x=a*a*b-x;
		double ang=2.0*x/a/a/a;
		double ans=atan2(2.0*x,1.0*a*a*a)*180/pi;
		printf("%0.8lf",ans);
	}
	return 0;
}


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

#define INF 100000000
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) (a.begin()),(a.end())
#define de cout << "debug" << endl;

int main(){
  string S;
  cin >> S;
  ll ans = 0;
  ll cnt = 0;
  REP(i,S.size()){
    if(S[i] == 'B'){
      cnt++;
    }
    else if(S[i] == 'W'){
      ans += cnt;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
//	freopen("a.in","r",stdin);
	char a;
	int i=0;
	while(scanf("%c",&a)==1){
		if(i==0)if(a=='C')i++;
		if(i==1)if(a=='F')i++;
	}
	if(i==2)cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#define ll long long
using namespace std;
char s[100010];
int read()
{
	int flag=1,x=0;char c=getchar();
	while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();	}
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
	return x*flag;
}
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	if(s[n]=='1'||s[1]=='0')
	{
		puts("-1");
		return 0;
	}
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[n-i]) 
		{
			puts("-1");
			return 0;
		}
	}
	cout<<1<<' '<<2<<'\n';
	int now=2;
	for(int i=2;i<n;i++)
	{
		cout<<now<<' '<<i+1<<'\n';
		if(s[i]=='1') now=i+1;
	}
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(ll i=L;i<R;i++)
#define f(n) rep(i,0,n)
#define pll pair<ll,ll>
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
#define sq(X) ((X)*(X))
#define PI 3.141592653589
const ll INF = 1e18l+10,N = 1e5+10,MAX = 2e5+10;

int main()
{
    SPEED
    int n,i,j;
    cin>>n;
    double p[n];
    double dp[n+1][n+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0] =1.0;
    f(n) {
        cin>>p[i];
        dp[0][i+1] = (1-p[i])*dp[0][i];
        for(j=1;j<=i+1;j++)
        dp[j][i+1] = p[i]*dp[j-1][i] + (1-p[i])*dp[j][i];
    }

    double ans = 0;
    for(i=n/2+1;i<=n;i++)ans+=dp[i][n];
    cout<<fixed<<setprecision(10)<<ans<<'\n';

}

Measured memory_bytes: 70656
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    string s = "";
    cin >> s;
    vector<int> r, l;
    int cnt = 1;
    for (int i=1; i<n; i++) {
        if (s.at(i) == s.at(i-1)) {
            cnt++;
        }
        else {
            if (s.at(i) == 'L') {
                r.push_back(cnt-1);
            }
            else {
                l.push_back(cnt-1);
            }
            cnt = 1;
        }
    }
    if (s.at(n-1) == 'L') {
        l.push_back(cnt-1);
    } 
    else {
        r.push_back(cnt-1);
    }
    int ans = 0;
    for (int a : r) {
        ans += a;
    }
    for (int a : l) {
        ans += a;
    }
    if (k >= min(r.size(), l.size())) {
        cout << n-1 << endl;
    }
    else if (r.size() < l.size()) {
        if (s.front() == s.back() && s.front() == 'R' && k == r.size()-1) {
            cout << ans + 2*k - 1 << endl;
        }
        else {
            cout << ans + 2*k << endl;
        }
    }
    else if (l.size() < r.size()) {
        if (s.front() == s.back() && s.front() == 'L' && k == l.size()-1) {
            cout << ans + 2*k - 1 << endl;
        }
        else {
            cout << ans + 2*k << endl;
        }
    }
    else {
        cout << ans + 2*k << endl;
    }
    return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

void Main(){
  int n,lr;
  cin>>n;
  int a[n];
  map<int ,int> mp;

  rep(i,0,n){cin>>a[i];}
  for(int i=0;i<n;i++){mp[a[i]]++;}
  int ans=0;
  for(auto p:mp){
    int x=p.first;
    int m=p.second;
    m<x ? ans+=m : ans+=m-x;
  }

  cout<<ans<<endl;
}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <vector>
#define LIM 1000000000

using namespace std;

int main(void) {
	int n,num;
	cin >> n;
	vector<int> R(n),nmin(n),nmax(n);
	for (int i = 0; i < n; ++i) {
		cin >> R[i];
	}
	for (int i = 0; i < n; ++i) {
		if (i == 0) {
			nmin[i] = R[i];
			nmax[n-i-1] = R[n-i-1];
		}
		else {
			nmin[i] = min(nmin[i-1],R[i]);
			nmax[n-i-1] = max(nmax[n-i],R[n-i-1]);
		}
	}
	int res = -LIM;
	for (int i = 0; i < n-1; ++i) {
		res = max(nmax[i+1]-nmin[i],res);
	}
	cout << res << endl;
	return 0;
}




Measured memory_bytes: 5204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if(s.equals(u)){
            a--;
        } else {
            b--;
        }
        System.out.println(a+" "+b);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    unsigned long ans = 1, next;
    int n;
    cin >> n;
    vector<unsigned long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a);

    if (a[0] == 0) {
        cout << 0 << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        next = ans * a[i];
        if (ans > next || next > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
        ans = next;
    }

    cout << ans << endl;
}


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

struct UnionFind{
  Int n;
  vector<Int> r,p;
  UnionFind(Int n):n(n),r(n,1),p(n){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    if(x==p[x]) return x;
    return p[x]=find(p[x]);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};


signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  while(cin>>n,n){
    UnionFind uf(n);
    vector<Int> a(n),x(n),b(n),y(n);
    for(Int i=0;i<n;i++){
      cin>>a[i]>>x[i]>>b[i]>>y[i];
      uf.unite(i,a[i]);
      uf.unite(i,b[i]);
    }
    vector<vector<Int> > v(n);
    for(Int i=0;i<n;i++){
      Int k=uf.find(i);
      v[k].emplace_back(x[i]);
      v[k].emplace_back(y[i]);
    }
    Int ans=1;
    for(Int i=0;i<n;i++){
      if(v[i].empty()) continue;
      auto &u=v[i];
      sort(u.rbegin(),u.rend());
      Int k=0;
      while(k<(Int)u.size()&&u[0]==u[k]) k++;
      k/=2;
      ans*=k;
      ans%=10007;
      //cout<<k<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3912
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

  long long sum = 0;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
    sum += v[i];
  }

  int mn = *min_element(v.begin(), v.end());
  int mx = *max_element(v.begin(), v.end());

  cout << mn << " " << mx << " " << sum << endl;
}


Measured memory_bytes: 3124
extern crate core;

use std::str::FromStr;
use std::fmt;

struct Istream {
    line: Vec<String>,
    position: usize
}
type Parse<T: FromStr> = Result<T, T::Err>;
impl Istream {
    fn new() -> Istream {
        Istream {line:vec![], position: 0}
    }
    fn read_word(&mut self) -> &String {
        if self.position == self.line.len() {
            let mut line= String::new();
            std::io::stdin().read_line(&mut line).ok();
            self.line = line.split_whitespace().map(|x|x.to_string()).collect();
            self.position = 0
        }
        let result = &self.line[self.position];
        self.position += 1;
        result
    }
    fn read(&mut self) -> String {
        self.read_word().to_string()
    }
    fn get<T: FromStr>(&mut self) -> T {self.read_word().parse().ok().unwrap()}
    fn read_usize(&mut self) -> usize {self.get()}
    fn read_int(&mut self) -> i32 {self.get()}
    fn read_long(&mut self) -> i64 {self.get()}
    fn read_double(&mut self) -> f64 {self.get()}
}
macro_rules! iterate {
    ($generator:expr; $count:expr; $typ:ty) => {{
        let mut vec = Vec::<$typ>::with_capacity($count);
        for i in 0 .. $count {
            vec.push($generator);
        }
        vec
    }}
}
macro_rules! yields {
    ($count:expr; $block:block) => {{
        let mut vec = Vec::with_capacity($count);
        for _ in 0 .. $count {
            vec.push($block);
        }
        vec
    }}
}

fn main() {
    let mut input = Istream::new();
    loop {
        let count = input.read_int();
        let upper_limit = input.read_int();
        if count == 0 && upper_limit == 0 {
            break
        }
        let (mut min_difficulty, mut min_time) = {
            let first = input.read_int();
            (first, upper_limit / first * first)
        };
        let mut duplicate = false;
        let mut current_suspect = 1;
        for i in 2..count {
            let difficulty = input.read_int();
            if min_time >= upper_limit / difficulty * difficulty {
                if min_time == upper_limit / difficulty * difficulty {
                    if min_difficulty > difficulty {
                        min_difficulty = difficulty;
                        duplicate = false;
                        current_suspect = i;
                    }else if min_difficulty == difficulty {
                        duplicate = true;
                    }
                }else {
                    min_time = upper_limit / difficulty * difficulty;
                    min_difficulty = difficulty;
                    duplicate = false;
                    current_suspect = i;
                }
            }
        }
        let hope = input.read_int();
        if duplicate || upper_limit / hope * hope < min_time || (upper_limit / hope * hope == min_time && min_difficulty >= hope) {
            println!("{}", count);
        }else {
            println!("{}", current_suspect);
        }
    }
}


Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int a[m];
    for(int i=0;i<m;i++)cin >> a[i];
    int sum = 0;
    for(int i=0;i<m;i++)sum += a[i];
    cout << max(-1,n-sum)<<endl;
}


Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
ll inf = 1000000000;
typedef pair<ll, ll> P;
ll h[100005];
int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	ll ans = 0;
	ll active = 0;
	for (int i = 0; i < n; i++) {
		if (active >= h[i]) {
			active = h[i];
		}
		else {
			ans += h[i] - active;
			active = h[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 5;
int n, a[N];

LL f(LL b) {
    //cout << b << endl;
    LL sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += abs(a[i] - b);
    }
    //printf("f(%lld) = %lld\n", b, sum);
    return sum;
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        a[i] -= i;
    }
    LL l = -2e9, r = 2e9, ans = 1e18;
    while(l <= r) {
        LL m1 = (l*2 + r)/3, m2 = (l + r*2)/3;
        LL f1 = f(m1), f2 = f(m2);
        if(f1 > f2) {
            ans = min(ans, f2);
            l = m1 + 1;
        }else {
            ans = min(ans, f1);
            r = m2 - 1;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
s = list(input())
t = list(input())
sn = len(s)
tn = len(t)
bag = []

for i in range(sn-tn+1):
  flag = True
  for j in range(tn):
    if s[i+j] == '?' or s[i+j] == t[j]:
      pass 
    else:
      flag = False 

  if flag:
    bag += [i]


if len(bag) == 0:
  print('UNRESTORABLE')
  exit()


def fill(ss, idx):
  for i in range(tn):
    ss[idx+i] = t[i]
  for i in range(sn):
    if ss[i] == '?':
      ss[i] = 'a'

  return ''.join(ss)

s_list = []
for idx in bag:
  ss = s[:]
  s_list += [str(fill(ss, idx))]

s_list.sort()
print(s_list[0])

Measured memory_bytes: 38512
#include <iostream>
#include <cstring>
#include <string.h>
using namespace std;

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

    for(int i = 0 ; i< s.length() ; i++)
    {
        int A = (int)s[i]-65;
        int newA = (A + n)%(26);

        newA= newA+65;

    s[i] =static_cast<char>(newA);
    }

    cout<<s<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end(), greater<>());
  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; ++i) {
    if (i % 2 == 0) {
      alice += a.at(i);
    } else {
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9+7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5 + 5)

void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;

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

    for(int i=0;i<m;i++)
    {
        cin>>b[i];
        if(i > 0)
            b[i] += b[i-1];
    }

    ll ans = 0;

    for(int i=0;i<n;i++)
    {
        if(a[i] > k)
            break;
        ll cur = i+1;
        ll inc = 0;
        ll st=0,en=m-1;
        while(st<=en)
        {
            ll mid = (st+en)/2;
            if(b[mid] <= k-a[i])
            {
                inc = mid+1;
                st = mid+1;
            }
            else
                en = mid-1;
        }

        cur += inc;
        ans = max(ans,cur);
    }

    ll st=0,en=m-1;
    while(st<=en)
    {
        ll mid = (st+en)/2;
        if(b[mid] <= k)
        {
            ans = max(ans,mid+1);
            st = mid+1;
        }
        else
            en = mid-1;
    }

    cout<<ans;

}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

using namespace std;

int h, w, d;
char field[51][51];
int dist[51][51];

int main() {
	const int INF = 1 << 29;
	cin >> h >> w;
	int white_count = 0;
	for (int i = 0;i < h;i++) {
		for (int j = 0; j < w;j++) {
			cin >> field[i][j];
			dist[i][j] = INF;
			if (field[i][j] == '.')
				white_count++;
		}
	}

	dist[0][0] = 0;
	queue<pair<int,int>> q;
	q.push({ 0,0 });
	while (q.size()) {
		int y = q.front().first;
		int x = q.front().second;
		q.pop();
		const int dy[] = { 0,1,0,-1 };
		const int dx[] = { 1,0,-1,0 };
		for (int i = 0;i < 4;i++) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if (ny >= 0 && nx >= 0 && ny < h&&nx < w&&dist[ny][nx] == INF && field[ny][nx] == '.') {
				dist[ny][nx] = dist[y][x] + 1;
				q.push({ ny,nx });
			}
		}
	}
	if (dist[h - 1][w - 1] == INF) {
		cout << -1 << endl;
	}
	else {
		cout << white_count - (dist[h - 1][w - 1]+1) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = n.times.map{gets.split.map(&:to_i)}
p a.reduce([1,1]){|x, y| [x.zip(y).map{|p, q| (p+q-1)/q}.max].map{|f| y.map{|r| f * r}}[0]}.reduce(:+)

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

int main() {
	int n, a, ans=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == 0 && a % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
h, w = map(int, input().split())
a = [input() for _ in range(h)]

cnt = [0]*(ord('z')-ord('a')+1)
for i in range(h):
    for j in range(w):
        cnt[ord(a[i][j])-ord('a')] += 1

f_num = 0
t_num = 0
for i in cnt:
    while i >= 4:
        i -= 4
        f_num += 1
    while i >= 2:
        i -=2
        t_num += 1

req_f = (h//2)*(w//2)
req_t = (h%2)*(w//2) + (w%2)*(h//2)

if req_f > f_num:
    print('No')
    exit()
f_num -= req_f
t_num += f_num*2
if req_t > t_num:
    print("No")
    exit()
print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=500500;
int n,m,k;
ll r,D,X;
int main()
{
	cin>>n>>m;
	if(n>=13)cout<<m<<endl;
	else if(n>=6)cout<<m/2<<endl;
	else cout<<0<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x,y;
char ch;
bool bj[5001][5001];
int main()
{
	cin>>x>>y;
	for(int i=1;i<=x;i++)
		for(int j=1;j<=y;j++)
		{
			cin>>ch;
			bj[i][j]=(ch=='#');
		}
	for(int i=1;i<=x;i++)
	{
		for(int j=1;j<=y;j++)
		{
			if(bj[i][j]==0) cout<<bj[i-1][j]+bj[i+1][j]+bj[i][j-1]+bj[i][j+1]+bj[i-1][j-1]+bj[i+1][j-1]+bj[i-1][j+1]+bj[i+1][j+1]; else cout<<'#';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 998244353
using namespace std;


int main(){
    int a,b;
    cin >> a >> b;
    if(a+b==15){
        cout<<"+"<<endl;
    }else if(a*b==15){
        cout<<"*"<<endl;
    }else{
        cout<<"x"<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
A, B, H, M = map(int, input().split())
theta = (H / 12) * 360 + (M / 60) * 30 - (M / 60) * 360
res = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta)))
print(res)

Measured memory_bytes: 62548
#include<iostream>
using namespace std;
int main(){
  int a[11];
  int temp;
  for(int i=0;i<10;i++){
    cin>>a[i];
  }
  for(int j=0;j<10;j++){
    for(int i=0;i<10-1-j;i++){
      if(a[i]<a[i+1]){
	temp=a[i];
	a[i]=a[i+1];
	a[i+1]=temp;
      }
    }
  }
  for(int i=0;i<3;i++){
    cout<<a[i]<<endl;
  }
  return(0);
}

Measured memory_bytes: 3100
#include <stdio.h>
#include <inttypes.h>

int main(){
    __int64_t a, b, c, d, z;
    
    scanf("%" PRId64, &a);
    scanf("%" PRId64, &b);
    scanf("%" PRId64, &c);
    scanf("%" PRId64, &d);
    
    z=a*c;
    if(z<a*d){
        z=a*d;
    }
    if(z<b*c){
        z=b*c;
    }
    if(z<b*d){
        z=b*d;
    }

    printf("%" PRId64 "\n", z);

    return 0;
}

Measured memory_bytes: 1704
N,T = map(int,input().split())
ct = [list(map(int,input().split())) for j in range(N)]
box = []
for i in range(N):
	if ct[i][1] <= T:
		box.append(ct[i])
if box ==[]:
	print("TLE")
else:
	box.sort(key=lambda x:x[0])
	print(box[0][0])
		

Measured memory_bytes: 9180
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int a, b;
	cin >> a >> b;

	if (a < b)
		cout << "a < b" << endl;
	if (a > b)
		cout << "a > b" << endl;
	if (a == b)
		cout << "a == b" << endl;

	return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

const int MAXN = 1000100;
const int MOD7 = 1000000007ll;
const int MOD9 = 1000000009ll;
const int INF = 2000000000;
const double EPS = 1e-9;
const double PI = 3.14159265358979;
const int dir_4r[] = { -1, 1, 0, 0 };
const int dir_4c[] = { 0, 0, -1, 1 };
const int dir_8r[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
const int dir_8c[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

map<int, int> val;

int main()
{
	int n, v, ans;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &v);
		val[v]++;
	}

	ans = 0;
	for (map<int, int>::iterator it = val.begin(); it != val.end(); it++)
		if ((it->second) & 1)
			ans++;
	printf("%d\n", ans);

	//system("pause");
	return 0;
}

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

/*
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")*/

#define I inline void 
#define S struct 
#define vi vector<int> 
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 1e5 + 7 , mod = 1e9 + 7 ; 
const int inf = N ; 
// How interesting!

int n ;

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        int x ;
        cin >> x ;
        cout<< (!x) ; 

        return 0 ; 
}

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

using namespace std;


int main() {
    long long a, b;
    cin >> a >> b;
    if (a <= 0 && b >= 0) {
        cout << "Zero" << endl;
    } else if (a > 0 || (b - a + 1) % 2 == 0) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256