akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

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

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

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N;
	cin >> N;
	vector<string> ss(N);
	rep(i,0,N) {
		cin >> ss[i];
	}
	using P = pair<ll, ll>;
	auto comp_sum = [](const P& lhs, const P& rhs){
		return lhs.first + lhs.second < rhs.first + rhs.second;
	};
	vector<P> poss;
	vector<P> negs;
	ll cnt = 0;
	rep(i,0,N) {
		string str = ss[i];
		ll x = 0;
		ll mn = x;
		rep(j,0,str.size()) {
			if (str[j] == '(') {
				cnt++;
				x++;
			} else {
				cnt--;
				x--;
			}
			chmin(mn, x);
		}
		P p = {mn, x-mn};
		if (x >= 0) {
			poss.push_back(p);
		} else {
			swap(p.first, p.second);
			p.first *= -1;
			p.second *= -1;
			negs.push_back(p);
		}
	}
	if (cnt != 0) {
		cout << "No" << endl;
		return 0;
	}
	rep(phase,0,2) {
		vector<P> pairs;
		if (phase == 0) {
			pairs = poss;
		} else {
			pairs = negs;
		}
		ll pairs_size = pairs.size();
		sort(pairs.begin(), pairs.end(), [](P lhs, P rhs){
			return lhs.first < rhs.first;
		});
		ll sum = 0;
		priority_queue<P, vector<P>, decltype(comp_sum)> queue(comp_sum);
		rep(i,0,pairs_size) {
			while (pairs.size() > 0 && pairs.back().first + sum >= 0) {
				queue.push(pairs.back());
				pairs.pop_back();
			}
			/*
			cout << "i: " << i << endl;
			cout << "pairs: ";
			for (P p : pairs) {
				cout << "(" << p.first << ", " << p.second << "), ";
			}
			*/
			if (queue.size() == 0) {
				cout << "No" << endl;
				return 0;
			}
			P top = queue.top();
			queue.pop();
			sum += top.first + top.second;
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 65500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <cassert>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
const int mod = int(1e9) + 7;
const long long infLL = 2e18;
const int MX = 2061;
int dp[MX][MX];
int main()
{
    //init();
    //cerr << delta << endl;
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    dp[0][n + 1] = 1;
    for(int i = 1; i < k; i++){
        for(int j = n - i + 1; j > 1; j--){
            if(j == n - i + 1) dp[i][j] = (dp[i - 1][j] + dp[i - 1][j + 1]) % mod; else
                            dp[i][j] = (dp[i - 1][j] + dp[i][j + 1]) % mod;
        }
    }
    int ans = 0;
    for(int j = 1; j <= n; j++){
        ans += dp[k - 1][j];
        ans %= mod;
    }
    if(k == 1) ans = 1;
    for(int i = 0; i < n - k - 1; i++){
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y,a,b,c,r,ans=0;cin>>x>>y>>a>>b>>c;
  lvector A(a,0),B(b,0),tot;
  rep(i,a) cin>>A[i];sort(ALL(A));rep(i,x) tot.emplace_back(A[a-1-i]);
  rep(i,b) cin>>B[i];sort(ALL(B));rep(i,y) tot.emplace_back(B[b-1-i]);
  rep(i,c) {cin>>r;tot.emplace_back(r);}
  sort(ALL(tot));
  ll l=x+y+c-1;
  rep(i,x+y) ans+=tot[l-i];
  print(ans);
  return 0;
}

Measured memory_bytes: 7664
#include<stdio.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
	long sum = 0;
	for(int i = 0; i < N; i++)
	{
		int j = 0;
		scanf("%d", &j);
		sum += j - 1;
	}
	printf("%ld\n", sum);
	return 0;
}

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

ll ans = 0;

const int N = 26;
ll x[N] = {},y[N] = {};

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

    for(int i = 0;i < s.size(); ++i){
        x[s[i] - 'a']++;
        y[t[i] - 'a']++;
    }

    sort(x,x+N);
    sort(y,y+N);

    for(int i = 0; i < N; ++i){
        if(x[i] != y[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    if (N == 1) {
      cout << 0 << endl;
    } else {
      cout << pow(10, N - 1) << endl;
    }
    return 0;
  }
  map<int, int> m;
  bool check = false;
  rep(i, M) {
    int s, c;
    cin >> s >> c;
    if (m.count(s)) {
      if (m.at(s) != c) {
        cout << -1 << endl;
        return 0;
      }
    } else if (N != 1 && s == 1) {
      if (c == 0) {
        cout << -1 << endl;
        return 0;
      } else {
        check = true;
        m[s] = c;
      }
    } else if (N == 1) {
      check = true;
      m[s] = c;
    } else {
      m[s] = c;
    }
  }
  if (!check) {
    m[1] = 1;
  }
  int ans = 0;
  for (auto x : m) {
    ans += pow(10, N - x.first) * x.second;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int flag = 0;
		for(int i = 0; i < s.length()-1; i++){
			if(s.substring(i,i+1).equals(s.substring(i+1,i+2))){
				flag = 1;
			}
		}
		System.out.print(flag == 1?"Bad":"Good");
	}
}


Measured memory_bytes: 22740
import math

def main():
	prime = [2, 3, 5, 7]
	for n in range(11, 100001):
		for p in prime:
			if n % p == 0:
				break
			if p > math.sqrt(n):
				prime.append(n)
				break
	sim = []
	j = 0
	for i in range(1, len(prime)):
		p = prime[i]
		q = int((p + 1) / 2)
		while q > prime[j]:
			j += 1
		else:
			if q == prime[j]:
				sim.append(p)
	sim.append(12345678)

	sim_n = [0]
	k = 0
	for s in range(1, 100001):
		if s == sim[k]:
			sim_n.append(sim_n[-1] + 1)
			k += 1
		else:
			sim_n.append(sim_n[-1])

	Q = int(input())
	for i in range(Q):
		l, r = [int(a) for a in input().split(" ")]
		print(sim_n[r] - sim_n[l - 1])

main()

Measured memory_bytes: 10276
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    def bfs(s,g,n):
        bfs_map = [-1 for i in range(n)]
        bfs_map[s] = 0
        q = deque()
        q.append(s)
        fin = False
        while q:
            x = q.popleft()
            for y in range(n):
                if c[x][y] > 0 and bfs_map[y] < 0:
                    bfs_map[y] = bfs_map[x]+1
                    if y == g:
                        fin = True
                        break
                    q.append(y)
            if fin:
                break

        if bfs_map[g] == -1:
            return [None,0]
        path = [None for i in range(bfs_map[g]+1)]
        m = float("inf")
        path[bfs_map[g]] = g
        y = g
        for i in range(bfs_map[g])[::-1]:
            for x in range(n+1):
                if c[x][y] > 0 and bfs_map[x] == bfs_map[y]-1:
                    path[i] = x
                    if c[x][y] < m:
                        m = c[x][y]
                    y = x
                    break
        return [path,m]

    def ford_fulkerson(s,g,c,n):
        while 1:
            p,m = bfs(s,g,n)
            if not m:break
            for i in range(len(p)-1):
                c[p[i]][p[i+1]] -= m
                c[p[i+1]][p[i]] += m
        return sum(c[g])

    n = I()
    r = LIR(n)
    b = LIR(n)
    c = [[0 for i in range(2*n+2)] for i in range(2*n+2)]
    for i in range(n):
        c[0][i+1] = 1
        for j in range(n):
            if r[i][0] < b[j][0] and r[i][1] < b[j][1]:
                c[i+1][n+j+1] = 1
    for j in range(n):
        c[n+j+1][2*n+1] = 1
    print(ford_fulkerson(0,2*n+1,c,2*n+2))
#D
def D():
    n = I()
    a = LI()
    b = LI()
    ans = 0
    p = 1
    for k in range(30):
        s = 0
        c = [b[i]%(p*2) for i in range(n)]
        a_ = [a[i]%(p*2) for i in range(n)]
        c.sort()
        a_.sort()
        l1,l2,l3 = 0,0,0
        y = float("inf")
        for x in a_[::-1]:
            if x != y:
                while l1 < n and c[l1] < p-x:l1 += 1
                while l2 < n and c[l2] < 2*p-x:l2 += 1
                while l3 < n and c[l3] < 3*p-x:l3 += 1
            s += n-l2-l1-l3
            y = x
        ans += (s%2)*p
        p *= 2
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 43252
#include <iostream>

void judge(int h, int w, std::string* arr, std::string* ans) {
  for(int y = 0; y < h; y++) {
    std::string s = arr[y];
    std::string r;
    for(int x = 0; x < w; x++) {
      if(s[x] == '.') {
        int n = 0;
        n += y != 0   && x != 0   && arr[y-1][x-1] == '#';
        n += y != 0               && arr[y-1][x] == '#';
        n += y != 0   && x != w-1 && arr[y-1][x+1] == '#';
        n +=             x != 0   && arr[y][x-1] == '#';
        n +=             x != w-1 && arr[y][x+1] == '#';
        n += y != h-1 && x != 0   && arr[y+1][x-1] == '#';
        n += y != h-1             && arr[y+1][x] == '#';
        n += y != h-1 && x != w-1 && arr[y+1][x+1] == '#';
        r += std::to_string(n);
      } else {
        r += "#";
      }
    }
    ans[y] = r;
  }
  return;
}

int main() {
  int h, w;
  std::cin >> h;
  std::cin >> w;
  std::string arr[h];
  for(int y = 0; y < h; y++) {
    std::cin >> arr[y];
  }
  std::string ans[h];
  judge(h, w, arr, ans);
  for(int y = 0; y < h; y++) {
    std::cout << ans[y] << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 233
typedef long long ll;
inline ll read(){
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,A,B,ans;
int flag;
char s[N];
int main(){
	flag=false;
	n=read();
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		int len=strlen(s+1);
		A+=s[len]=='A';
		B+=s[1]=='B';
		flag+=s[1]=='B'&&s[len]=='A';
		for(int j=1;j<len;++j){
			if(s[j]=='A'&&s[j+1]=='B')++ans;
		}
	}
	ans+=min(A,B);
	if(A==B&&flag==A&&A)--ans;
	printf("%d\n",ans);
	return 0;
}




Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

bool pairCompare(const pair<int, int>& firstElof, const pair<int, int>& secondElof) {
    return firstElof.first > secondElof.first;
}

int main(void) {
    int N, M;
    cin >> N >> M;

    vector<int> L(M);
    vector<int> R(M);
    for(int i=0;i<M;i++) {
        cin >> L.at(i) >> R.at(i);
    }

    sort(L.begin(), L.end());
    sort(R.begin(), R.end());

    int ans;
    ans = R.at(0) - L.at(M-1) + 1;
    if(ans < 0) ans = 0;

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;




int main(){
    ll n,m; cin >> n >> m;
    vector<vector<ll>> vec(n, vector<ll>(3,0));
    rep(i,n)rep(j,3)cin >> vec[i][j];

    ll res = 0;
    rep(i,(1 << 3)){
        priority_queue<ll> pq;
        priority_queue<ll> empty;
        rep(j,n){
            ll temp = 0;
            rep(k,3){
                if((i >> k) & 1) temp += vec[j][k];
                else temp -= vec[j][k];
            }
            pq.push(temp);
        }
        ll cal = 0;
        rep(j,m){
            cal += pq.top();pq.pop();
        }
        swap(pq, empty);
        res = max(res, cal);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(b % a == 0){
      System.out.println(a+b);
    }else{
      System.out.println(b-a);
    }
  }
}


Measured memory_bytes: 21844
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const [a,b,c] = n.split(' ').map(x=>Number(x));
        console.log(yakusu(a,b,c).length);
});

function yakusu(a,b,c){
    var result = [];
    for(var i=a; i<=b; i++) {
        if( (c%i == 0) ) {
            result.push(i);
        }  
    }
    return result;
}


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

using namespace std;

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long mx = -1e18;
  for(auto x : {a, b}) {
    for(auto y : {c, d}) {
      mx = max(mx, x * y);
    }
  }
  cout << mx << '\n';
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

typedef vector<pair<double,int> > Vp;

Vp a;

int main(){
	cout<<syosu(2);
	int p;
	double t;
	for(int i=0;i<24;i++){
		cin>>p>>t;
		a.push_back(pair<double,int>(t,p));
	}
	sort(a.begin(),a.begin()+8);
	sort(a.begin()+8,a.begin()+16);
	sort(a.begin()+16,a.end());
	cout<<a[0].second<<' '<<a[0].first<<endl;
	cout<<a[1].second<<' '<<a[1].first<<endl;
	cout<<a[8].second<<' '<<a[8].first<<endl;
	cout<<a[9].second<<' '<<a[9].first<<endl;
	cout<<a[16].second<<' '<<a[16].first<<endl;
	cout<<a[17].second<<' '<<a[17].first<<endl;
	a.erase(a.begin(),a.begin()+2);
	a.erase(a.begin()+6,a.begin()+8);
	a.erase(a.begin()+12,a.begin()+14);
	sort(a.begin(),a.end());
	cout<<a[0].second<<' '<<a[0].first<<endl;
	cout<<a[1].second<<' '<<a[1].first<<endl;
}

Measured memory_bytes: 1300
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            int sum =0;
            
            if(n == 0 && x == 0)
                break;
            
            	for(int i=1;i<=n;i++){
                    for(int j=i+1;j<=n;j++){
                        for(int k=j+1;k<=n;k++){
                          if(k != j &&  j != i && i != k){
                              if(i + j + k == x){
                                  sum++;
                              }
                          }
                        }
                    }
                }
            System.out.println(sum);
        }
        sc.close();
    }
}


Measured memory_bytes: 26712
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,a,b;
  pii p[100];
  rep(i,INF){  
    scanf("%d,%d",&a,&b);
    if(a==0 && b==0)break;
    p[i].first=b;
    p[i].second=a;
  }
  int m=i;
  sort(p,p+m);
  vi ans(105);
  ans[p[m-1].second]=1;
  for(i=m-2;i>=0;i--){
    if(p[i].first==p[i+1].first)ans[p[i].second]=ans[p[i+1].second];
    else ans[p[i].second]=ans[p[i+1].second]+1;
  }
  while(cin>>n) cout<<ans[n]<<endl;
}

Measured memory_bytes: 3132
Exp = ["+", "-", "*"]
def solve(num)
  num.permutation(4).to_a.each do |a, b, c, d| 
    Exp.repeated_permutation(3).to_a.each do |e, f, g|
      ["((#{a} #{e} #{b}) #{f}( #{c} #{g} #{d}))",
       "(( #{a} #{e}( #{b} #{f} #{c})) #{g} #{d})", 
       "( #{a} #{e}(( #{b} #{f} #{c}) #{g} #{d}))",
       "((( #{a} #{e} #{b}) #{f} #{c}) #{g} #{d})", 
       "( #{a} #{e}( #{b} #{f}( #{c} #{g} #{d})))"].each do |form|
        if eval(form) == 10
          puts form
          return true
        end
      end
    end
  end
  false
end
loop do
  num = gets.split
  break if num[0] == "0"
  p 0 unless solve(num)
end

Measured memory_bytes: 10112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846
#define pb push_back
const int N=10000000+13;
int prime[N];
void seive()
{
    for(int i=0;i<=N;i++)
        prime[i]=i;
    for(int i=2;i*i<=N;i++)
    {
        if(prime[i]==i)
        {
            for(int j=i*i;j<=N;j+=i)
                prime[j]=i;
        }
    }
}

void solve()
{
    seive();
    int n;cin>>n;
    ull ans=1;
    for(int i=2;i<=n;i++)
    {
        map<int,int> mp;
        int v=i;
        while(v>1)
        {
            mp[prime[v]]++;
            v/=prime[v];
        }
        int cnt=1;
        for(auto it:mp)
            cnt*=(it.second+1);
        ans+=cnt*i;
    }
    cout<<ans<<nl;
}

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

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


Measured memory_bytes: 81768
import std.stdio, std.array, std.conv, std.string;

void main() {
  string[] input = split(readln);
  int a = to!int(input[0]);
  int b = to!int(input[1]);

  string op;
  if (a == b) {
    op = "==";
  } else if (a < b) {
    op = "<";
  } else {
    op = ">";
  }

  // writef("%d %s %d\n", a, op, b);
  writef("a %s b\n", op);
}

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

int main(void){
    int N;cin >> N;
    int d[105];
    for (int i = 0; i < N; ++i){
        cin >> d[i];
    }
    int num[105] = {0};
    for (int i = 0; i < N; ++i){
        num[d[i]]++;
    }
    int res = 0;
    for (int i = 1; i <= 100; ++i){
        if (num[i] >= 1) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<string>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP_SIZE 10
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int main(){
    int a,b; cin >> a >> b;
    if(b%a == 0) cout << a+b << endl;
    else cout << b-a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  
  int N, M, C, i, j, Sum, Num;
  Num = 0;
  scanf("%d%d%d", &N, &M, &C);
  
  int A[N][M], B[M];
  
  for(i = 0; i < M; ++i){
    scanf("%d", &B[i]);
  }
  
  for(i = 0; i < N; ++i){
    Sum = 0;
    for(j = 0; j < M; ++j){
      scanf("%d", &A[i][j]);
      Sum += A[i][j] * B[j];
    }
    if(Sum + C > 0){
      ++Num;
    }
  }
  
  printf("%d\n", Num);
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}


int main(void) {
	char x1;
	while (cin >> x1) {
		if (x1 == '0') {
			break;
		}
		int sum = ctoi(x1);
		char xn;
		while ((xn = getchar()) != '\n') {
			sum += ctoi(xn);
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3052
n=int(input())
s=list(input())
d=[1]*26
g=ord("a")
for i in range(n):
    d[ord(s[i])-g]+=1
p=1
for i in range(26):
    if d[i]!=0:
        p*=d[i]
else:
    print((p-1)%(10**9+7))

Measured memory_bytes: 3956
import java.util.*;

public class Main {
    public static void main(String[] args){
  
  Scanner sc=new Scanner(System.in);
  while(true){
  int m= sc.nextInt();
  int n= sc.nextInt(); 
  int r= sc.nextInt();
  if(m==-1&&n==-1&&r==-1) break;
  
  if(m==-1||n==-1){
     System.out.println("F");
      
  }
     else if(m+n>=80){
         System.out.println("A");
     }
     else if(m+n>=65&&m+n<80){
         System.out.println("B");
     }
     else if(m+n>=50&&m+n<65){
         System.out.println("C");
     }
     else if(m+n>=30&&m+n<50){
         if(r>=50){
             System.out.println("C");
         }else{
             System.out.println("D");
             
         }
         
     }
  else if(m+n<30){
       System.out.println("F");
  }
  
 }
}}


Measured memory_bytes: 26288
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <ctype.h>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
//整形Shift + alt + f 
int a,b,n;
int main(){
    
    cin >> n;

    if(n==1){
        cout << "Hello World";
        return 0;
    }

    cin >> a >> b;
    cout << a+b;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,a,n) for(int i = a; i < (n); i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll; 

int main()
{
    int x, a;

    cin >> x >> a;

    if(x<a) { cout << 0 << endl; }
    else    { cout <<10 << endl; }
    
    return 0;
}


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

#define rep(i , a , b) for(register int i=(a);i<=(b);i++)
#define rop(i , a , b) for(register ll i=(a);i<(b);i++)
#define per(i , a , b) for(register ll i=(a);i>=(b);i--)
#define por(i , a , b) for(register ll i=(a);i>(b);i--)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int > pi;
template<class T>
inline void read (T &x) {
    x = 0;
    int sign = 1;
    char c = getchar ();
    while (c < '0' || c > '9') {
        if ( c == '-' ) sign = - 1;
        c = getchar ();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar ();
    }
    x = x * sign;
}
const int maxn = 1e5+10;
const int inf = int (1e9);
const ll INF = ll(1e18);
const double PI = acos (-1);
const int mod = 1e9+7;
const double eps = 1e-8;


int main(){
    ll a,b,x,y;
    read (a);read (b);
    a-=1;
    if (a%4==0) x=a;
    if (a%4==3) x=0;
    if (a%4==1) x=1;
    if (a%4==2) x=a+1;

    if (b%4==0) y=b;
    if (b%4==3) y=0;
    if (b%4==1) y=1;
    if (b%4==2) y=b+1;

    ll ans = y^x;
    printf ("%lld\n",ans);
    return 0;
}

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

int main()
{
    int n,m ; cin>> n>>m ;
    int sum =0 ;
    int arr[n] ;
    for (int i=0 ; i<n ; i++) {
        cin>>arr[i] ;
    }
   for (int r=0 ; r<n ; r++) {
    for (int j=0 ; j<n-1 ; j++) {
        if (arr[j]>arr[j+1]) {
            int Swap = arr[j] ;
            arr[j] = arr[j+1] ;
            arr[j+1]=Swap ;
        }
         }
       }

    for (int i=0 ; i<m ;i++) {
        sum = arr[i] + sum ;
    }
    cout<<sum ;


    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll n, t;
  cin >> n >> t;
  vector<ll> a(n);
  ll ans = t;
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 0; i < n-1; i++) ans += min(a.at(i+1) - a.at(i), t);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
int n;
int main()
{
	cin >> n;
	string s;
	cin >> s;
  	if(n>s.size()) cout<<s;
	else loop(i, 0, n)cout << s[i];
	if (s.size() > n) cout << "...";
}


Measured memory_bytes: 3600
package main

import "fmt"


func main() {
	var h, w int
	fmt.Scan(&h, &w)

	var board = make([]string, h)
	dx := []int{-1, 0, 1, -1, 1, -1, 0, 1}
	dy := []int{-1, -1, -1, 0, 0, 1, 1, 1}

	for i := 0; i < h; i++ {
		fmt.Scan(&board[i])
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if board[i][j] == '#'{
				fmt.Print("#")
				continue
			}
			cnt := 0
			for k := 0; k < 8; k++ {
				ni := i + dy[k]
				nj := j + dx[k]
				if 0 <= ni && ni < h && 0 <= nj && nj < w {
					if board[ni][nj] == '#' {
						cnt++
					}
				}

			}
			fmt.Print(cnt)
		}
		fmt.Println()
	}
}


Measured memory_bytes: 512
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		
		double money_sum=0;
		for(int i=0;i<N;i++) {
			String[] list = sc.nextLine().split(" ");
			double money = Double.parseDouble(list[0]);
			String value = list[1];
			if(value.equals("JPY")) {
				money_sum += money;
			}
			else {
				money_sum += money * 380000.0;
			}
		}
		
        System.out.println(money_sum);
	}
}

Measured memory_bytes: 21716
import java.lang.Math
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map(String::toInt)
    var ans = 1
    for (i in 1 until N) {
        for (j in 0 until i) {
            if (a[i] < a[j]) {
                --ans
                break
            }
        }
        ++ans
    }
    println(ans)
}

Measured memory_bytes: 37992
#include<bits/stdc++.h>
using namespace std;
#define For(i,n,k) for(int i=(n);i<(k);i++)
// ローリングハッシュ
// 二分探索で LCP を求める機能つき
struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const string &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }

    // get lcp(最長共通接頭辞) of S[a:] and T[b:]
    inline int getLCP(int a, int b) const {
        int len = min((int)hash1.size()-a, (int)hash1.size()-b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a+mid) != get(b, b+mid)) high = mid;
            else low = mid;
        }
        return low;
    }
};

void Main(){    
    int n,ans=0;string s;
    cin>>n>>s;
    RollingHash roriha(s);
    For(i,0,n){
        For(j,i+1,n){
            ans=max(ans,min(j-i,roriha.getLCP(i,j)));
        }
    } 
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    for(int i = 0; i < n; ++i){
        int a;
        cin >> a;
        que.push(a);
    }
    while(!que.empty() && m > 0){
        int foo = que.top();
        que.pop();
        foo /= 2;
        --m;
        if(foo > 0) que.push(foo);
    }
    ll ans = 0;
    while(!que.empty()){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
S = input()
N = len(S)-1
B = []
ans = 0

#長さからビット列を作る
for i in range(2**N):
    B.append(bin(i)[2:].zfill(N))
if N == 0:
    print(1)
    
else:
    for b in B:
        t = ""
        for i, plus in enumerate(b):
            t += S[i]
            if plus == "1":
                t += "+"

        t += S[-1]
        ans += sum([int(x) for x in t.split("+")])
        
    print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string.h>
using namespace std;
int main(){
int i,j,n,m,a,r,l,ans=0;
static int s[100001]={0};
scanf("%d%d",&n,&m);
for(i=1;i<n;i++){
scanf("%d",&a);
s[i]=s[i-1]+a;
}
r=0;
for(i=0;i<m;i++){
scanf("%d",&l);
ans=(ans+(abs(s[r+l]-s[r])%100000))%100000;
r=r+l;
}
printf("%d\n",ans);
return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
//using P = pair<int,int>;
using Graph = vector<vector<int>>;

const int N = 100005;
vector<pair<int, ll> > g[N];
ll dist[N];
 
void dfs(int v, int p){
	for(auto x : g[v]){
		if(x.first == p)continue;
		dist[x.first] = dist[v] + x.second;
		dfs(x.first, v);
	}
}
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);
 
	int n; cin>>n;
	for(int i = 1; i < n; i++){
		int u, v, w;
		cin>>u>>v>>w;
        //相手と距離
		g[u].push_back({v, w});
		g[v].push_back({u, w});
	}
    //根は1
	dist[1] = 0; dfs(1, -1);
	for(int i = 1; i <= n; i++){
        //dist[i]&1でビットごとのAND、すなわち奇数のとき1、偶数のとき0で塗分け可能。
		cout<<(dist[i]&1)<<'\n';
	}
 
 
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int n;
  cin>>n;
  double a=0;
  for(int i=0;i<n;i++){
    if(i%2==0)a++;
  }
  cout<<fixed<<setprecision(10)<<a/n<<endl;

  return 0;
}


Measured memory_bytes: 256
n,q=map(int,input().split())
s=list(input())
A=[list(map(int,input().split()))for i in range(q)]
total=[0]*(n+1)#累積和をとる配列
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        total[i+1]=total[i]+1
    else:
        total[i+1]=total[i]
for i in range(q):
    print(total[A[i][1]]-total[A[i][0]])


Measured memory_bytes: 31400
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk

string s;

int main() { 

  getline(cin, s);

  int l = 0, r = sz(s) - 1;

  int ans = 0;

  while (l < r) {
    if (s[l] != s[r]) {
      ans++;
    }
    l++; r--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    const int INF = 1e18 + 7;
    int mn = INF, mx = -INF;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }   
    if (mn < mx - 1) {
        cout << "No" << endl;
        return 0;
    }   

    if (mn == mx) {

        if (mn == n - 1) {
            cout << "Yes" << endl;
            exit(0);
        }   

        if (mn * 2 > n) {
            cout << "No" << endl;
        }   
        else {
            cout << "Yes" << endl;
        }   
        return 0;
    }

    int cnt_mx = 0;
    for (int i = 0; i < n; ++i)
        cnt_mx += a[i] == mx;

    int cnt_mn = 0;
    for (int i = 0; i < n; ++i)
        cnt_mn += a[i] == mn;
    
    if (cnt_mn >= mx) {
        cout << "No" << endl;
        return 0;
    }   

    int r = mx - cnt_mn;
    if (r * 2 > cnt_mx) {
        cout << "No" << endl;
        return 0;
    }   

    cout << "Yes" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  COMinit();
  ll m,n,k;
  cin >> m >> n >> k;
  ll ans=0;
  ll temp=0;
  temp=m*m;
  temp%=mod;
  temp*=COM(n+1,3);
  ans+=temp;
  temp=0;
  temp=n*n;
  temp%=mod;
  temp*=COM(m+1,3);
  ans+=temp;
  ans%=mod;
  ans*=COM(n*m-2,k-2);
  ans%=mod;
  cout << ans << endl;
return 0;}

Measured memory_bytes: 12160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll n,p, k, b, c, i, j, x, y, z = 1, m = 0,q;
ll a[200005] = {}, yy[100000] = {};
double xx,zz=0;
string s;
P pp[200005];
vector<ll> v;
char cc[100000][10];
int main() {
	
	cin>>n>>q ;
	rep(i, n-1){
		cin >> b>>c;
		b--; c--;
		pp[i].first = b;
		pp[i].second = c;
	}
	rep(i, q) {
		cin >> b >> c;
		b--;
		a[b] += c;
	}
	sort(pp, pp + n - 1);
	rep(i, n - 1) {
		b=pp[i].first;
		c=pp[i].second;
		a[c] += a[b];

	}



	rep(i,n)cout << a[i]<<" ";
	return 0;
}

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

class Stack{
private:
  int size;
  int array[200];
public:
  Stack(){
    size = 0;
  }
  bool isEmpty();
  void push(int num);
  int pop();
};

bool Stack::isEmpty(){
  if(size == 0) return true;
  else return false;
}

void Stack::push(int num){
  array[size++] = num;
}

int Stack::pop(){
  return array[--size];
}

int main(void){ 
  Stack st;
  char s[100];
  while(scanf("%s", s) != EOF){
    if(s[0] == '+'){
      int a = st.pop();
      int b = st.pop();
      st.push(a + b);
    }else if(s[0] == '-'){
      int a = st.pop();
      int b = st.pop();
      st.push(b - a);
    }else if(s[0] == '*'){
      int a = st.pop();
      int b = st.pop();
      st.push(a * b);
    }else{
      st.push(atoi(s));
    }
  }
  cout << st.pop() << endl;
  return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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 namespace std;

enum State {
    unseen, // 未訪問
    seen,   // 発見済み
    end     // 探索終了
};

vector<vector<int>> adj; // 隣接行列
int t = 0;  // 大域時刻
int d[110]; // 各頂点の頂点1からの最短距離
State s[110];


int main() {
    int n; cin >> n;
    adj.resize(n);
    rep(i, n) {
        int u, k; cin >> u >> k;
        --u;
        rep(j, k) {
            int v; cin >> v;
            --v;
            adj[i].emplace_back(v);
        }
    }

    // 初期化
    rep(i, n) {
        d[i] = INT_INF;
        s[i] = State::unseen;
    }
    d[0] = 0;
    queue<int> q;
    q.push(0);

    // BFS
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto &v: adj[u]) {
            if (d[v] == INT_INF) {
                q.push(v);
                d[v] = d[u] + 1;
            }
        }
    }

    // 出力
    rep(i, n) {
        int dist = (d[i] != INT_INF) ? d[i] : -1;
        cout << i+1 << ' ' << dist << endl;
    }
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    int n,m;
    cin>>n>>m;
    if (n%2==1){//ok
        for (int i=1;i<m+1;i++){
            cout<<i<<" "<<n-i<<endl;
        }
    }
    else{
        if (n%4==0){
            int k=n/4;
            for (int i=1;i<min(m+1,k+1);i++)cout<<i<<" "<<n-i+1<<endl;
            for (int i=k+1;i<m+1;i++)cout<<i<<" "<<n-i<<endl;
        }
        else{
            for (int i=1;i<min(m+1,(n+2)/4);i++){
                cout<<i<<" "<<n-i+1<<endl;
            }
            for (int i=(n+2)/4;i<m+1;i++){
                cout<<i<<" "<<n-i<<endl;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;

int main() {
	string s;
	cin >> s;
	int len = s.length();
	vector<int> dp(len + 1);

	if (len == 1) {
		cout << 1 << endl;
	}
	else if(len == 2){
		cout << (s[0] == s[1] ? 1 : 2) << endl;
	}
	else {
		dp[0] = 1;
		dp[1] = (s[0] == s[1] ? 1 : 2);
		dp[2] = (s[0] != s[1] && s[1] != s[2] ? 3 : 2);
		for (int i = 3;i < len;i++) {
			if (s[i] == s[i - 1]) {
				dp[i] = max(dp[i], dp[i - 3] + 2);
			}
			else {
				dp[i] = max(dp[i], dp[i-1] + 1);
			}
		}

		cout << dp[len - 1] << endl;

	}
}

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

int main() {
  int K, l;
  string S;
  cin >> K >> S;
  l = S.size();
  
  //cout << K << l << endl;
  
  if(K >= l){
    cout << S << endl;
  }
  if(K < l){
    for(int i = 0; i < K; i++){
      cout << S.at(i);
      //cout << "..." << endl;
    }
    cout << "..." << endl;
  }
  

 
  
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min({a+b,a+c,b+c})<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
        arr.append(i)
  if temp!=1:
    arr.append(temp)
  if arr==[]:
    arr.append(n)
  return arr

def main():
  a,b = map(int,input().split())
  a_ary = factorization(a)
  b_ary = factorization(b)
  
  result = 1
  for n in a_ary:
    result *= n
    if (n in b_ary):
      i = b_ary.index(n)
      b_ary.pop(i)
  for n in b_ary:
    result *= n
  
  print(result)

main()


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

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(i=a;i<b;i++)
#define inf         INT_MAX

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

using namespace std;
void solve()
{
    int n,i;
    ll ans=0;
    cin>>n;
    int a[n],b[n];
    rep(i,0,n)cin>>a[i];
    b[0]=a[0];
    rep(i,1,n)b[i]=max(a[i],b[i-1]);
    rep(i,0,n)ans+=b[i]-a[i];
    cout<<ans;
}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int A[50], B[50],C[50],D[50];
    for (int i=0; i<N; i++){
        cin >> A[i] >> B[i];
    }
    for (int i=0; i<M; i++){
        cin >> C[i] >> D[i];
    }
    int x;
    for (int i=0; i<N; i++){
        int min_diff=1000000000;
        for (int j=0; j<M; j++){
            int diff;
            diff=abs(A[i]-C[j])+abs(B[i]-D[j]);
            if (min_diff>diff){
                min_diff=diff;
                x=j+1;
            }
        }
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 256
s = input()

z = []
for i in range(2**4):
    a = ""
    b =  format(i, "04b")
    if b[0] == "1":
        a += "A"
    a += "KIH"
    if b[1] == "1":
        a += "A"
    a += "B"
    if b[2] == "1":
        a += "A"
    a += "R"
    if b[3] == "1":
        a += "A"
    z.append(a)

if s in z:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  long int a,b,r,GCD,LCM,a0,b0;
  while((scanf("%ld %ld\n",&a,&b))!=EOF){
    a0=a;
    b0=b;
    for(;;){
      r=a%b;
      a=b;
      b=r;
      if(b==0) break;
    }
    GCD=a;
    LCM=(a0*b0)/GCD;
    printf("%ld %ld\n",GCD,LCM);
  }
  return 0;
}



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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T;
	cin >> T;
	if(T < 600)
	{
		cout <<8;
	}
	else if(T < 800)
	{
		cout <<7;
	}
	else if(T < 1000)
	{
		cout <<6;
	}
	else if(T < 1200)
	{
		cout <<5;
	}
	else if(T < 1400)
	{
		cout <<4;
	}
	else if(T < 1600)
	{
		cout <<3;
	}
	else if(T < 1800)
	{
		cout <<2;
	}
	else
	{
		cout <<1;
	}
	
}

Measured memory_bytes: 3648
import math
m=6**8
c=[g:=0]*m
for a in[*open(0)][1].split():g=math.gcd(g,a:=int(a));c[a]+=1
print(('not','psaeitr'[any(sum(c[i::i])>1for i in range(2,m))::2]+'wise')[g<2],'coprime')

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[200100];
		int [] kinds = new int[200100];
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
			kinds[d[i]] ++;
		}
		Arrays.sort(kinds);
		int result = 0;
		for(int i = 0; i < kinds.length - k; i++) {
			result += kinds[i];
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 83084
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define pb push_back
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000];
int main()
{	ll n,sum=0; cin>>n;
	int w=0,tag=0;
	while(n) a[++w]=n%10,sum+=n%10,n/=10;
	reverse(a+1,a+w+1);
	for(rint i=1;i<w;i++)
	if(tag) sum=sum-a[i+1]+9;
	else if(a[i+1]!=9) sum=sum-1-a[i+1]+9,tag=1;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256