akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main implements Runnable {

	public static void main(String[] args) {

		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();

	}

	@Override
	public void run() {
		exec();
	}

	private void exec() {

		int m;
		int d;
		FastScanner sc = new FastScanner(System.in);
		m = sc.nextInt();
		d = sc.nextInt();

		int ans = 0;
		for(int i = 1 ; i <= m ; i++) {
			for(int j = 1 ; j <= d ; j++) {
				int d1 = j % 10;
				int d10 = j / 10;
				if(d1 < 2 || d10 < 2) continue;
				if((d10) * (d1) == i) {
					ans++;
				}
			}
		}

		System.out.println(ans);

	}

}

class FastScanner {

	private final InputStream in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	public FastScanner(InputStream in) {
		this.in = in;
	}

	private boolean hasNextByte() {
		if(ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if(buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if(hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while(hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}

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

}


Measured memory_bytes: 23508
// 4/29
// 過去問攻略

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
using namespace std;

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

    int N = S.size();
    int N2 = (N - 1) / 2;

    string before = S.substr(0, N2);
    string after = S.substr((N + 1) / 2, N2);

    bool ans = true;

    for (int i = 0; i < N; i++) {
        if (S[i] != S[N - 1 - i]) ans = false;
    }

    for (int i = 0; i < N2; i++) {
        if (before[i] != before[N2 - 1 - i]) ans = false;
        if (after[i] != after[N2 - 1 - i]) ans = false;
    }

    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl; 
}


Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]
cnt = sum(a < 0 for a in A)
sumabs = sum(abs(a) for a in A)
if cnt % 2 == 0:
    print(sumabs)
else:
    print(sumabs - 2 * min(abs(a) for a in A))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s, t;
	cin >> s >> t;
	if (t.substr(0, t.size() - 1) == s) Yes();
	else No();
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


//UnionFind木のテンプレ.parentには根のindexが入っている.
//根には連結成分のサイズが入っている.nはノード数.
class UnionFind{
public:
	vector<int> parent;
	UnionFind(){}
	UnionFind(int n){
		this->parent = vector<int>(n,-1);
	}
	int root(int x){
		if (this->parent[x] < 0) return x;
		this->parent[x] = root(this->parent[x]);
		return this->parent[x];
	}
	int unite(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		if (rx == ry) return false;
		if (this->parent[rx] > this->parent[ry]) swap(rx, ry);
		this->parent[rx] += this->parent[ry];
		this->parent[ry] = rx;
		return true;
	}
	int same(int x, int y){
		int rx = this->root(x);
		int ry = this->root(y);
		return rx == ry;
	}
	int size(int x){
		return -this->parent[this->root(x)];
	}
};

int main()
{
	int n, m;
	cin >> n >> m;
	UnionFind uf(n);
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		uf.unite(a, b);
	}
	int ans = 0;
	rep(i,n){
		ans = max(ans, uf.size(i));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4048
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

n = readInt()
s = sys.stdin.readline().strip()
k = readInt()

v = s[k - 1]
ss = list(s)
for i,c  in enumerate(s):
    if c != v:
        ss[i] = '*'
ret = ''.join(ss)
print(ret)

Measured memory_bytes: 21500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << 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; }

int main(){
  vi a(5);
  rep(i,5){
    cin >> a[i];
  }
  vi b(5);
  ll ans = 0;
  rep(i, 5){
    if(a[i]%10!=0){
      b[i] = a[i] + 10 - a[i] % 10;
    }
    else{
      b[i] = a[i];
    }
    ans += b[i];
  }
  vi c(5);
  rep(i, 5){
    if(a[i]%10!=0){
      c[i] = a[i] % 10;
    }
    else{
      c[i] = 10;
    }
  }
  sort(all(c));
  ans += -10 + c[0];
  print(ans);
}

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

int main() {
  int w, h, x, y;
  cin >> w >> h >> x >> y;

  printf("%lf %d\n", (double)w * (double)h / 2., (x * 2 == w && y * 2 == h));
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e5+8;
int val[inf][2];
int n, w;
int dp[110][100001];

int f(int index, int num){
     if(num==0) return 0;
     if(num<0) return 1e16;
     if(index==n) return 1e16;

     int&ans=dp[index][num];
     if(ans!=-1) return ans;

     ans=1e16;
     ans=min(ans, val[index][0]+f(index+1,num-val[index][1]));
     ans=min(ans, f(index+1,num));
     return ans;
}

int32_t main(){
     memset(dp, -1, sizeof(dp));
     cin>>n>>w;
     for(int i=0;i<n;i++){
          cin>>val[i][0]>>val[i][1];
     }
     int ans=0;
     for(int i=100000;i>=0;i--){
          int temp=f(0, i);
          if(temp<=w){
               cout<<i<<endl;
               return 0;
          }
     }
}



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

#define int long long
#define all(V) (V).begin(),(V).end()
#define umap unordered_map
#define uset unordered_set
#define br cout<<"\n";

const int MAXN=1e5+10, MOD=1e9+7;
int n,m;
int arr[MAXN];
int t[5*MAXN],lazy[5*MAXN];

int doit(int a,int b){
	return a+b;
}

void build(int start,int end,int index=1){
	if(start==end){
		t[index]=INT_MAX;
		return ;
	}
	int mid = start+end >> 1;
	build(start,mid,index << 1);
	build(mid+1,end,index<<1|1);
	t[index] = doit(t[index<<1], t[index<<1|1]);
}

void propagate(int start,int end,int index){
	t[index] = (end-start+1)*lazy[index];
	// bcz leaf not hv childs
	if(start!=end){
		lazy[index<<1] = lazy[index];
		lazy[index<<1|1] = lazy[index];
	}
	lazy[index]=-1;
}

int Query(int start,int end,int l,int r,int index=1){

	if(lazy[index]!=-1){
		propagate(start,end,index);
	}
	// out range
	if(r<start or end<l){
		return 0;
	}
	// in Raange
	if( l<=start and end<=r){
		return t[index];
	}
	int mid = start+end >>1;
	return doit(Query(start,mid,l,r,index<<1), Query(mid+1,end,l,r,index<<1|1));
}

void pUpdate(int start,int end,int point,int val,int index=1){
	if(start==end){
		t[index]=val;
		return ;
	}
	int mid = start+end>>1;
	if(point <= mid){
		pUpdate(start,mid,point,val,index<<1);
	}
	else{
		pUpdate(mid+1,end,point,val,index<<1|1);
	}
	t[index] = doit(t[index <<  1] , t[index << 1 | 1]);
}


void rangeUpdate(int start,int end,int l,int r,int val,int index){
	if(lazy[index]!= -1){
		propagate(start,end,index);
	}
	if(l>end or r<start){
		return;
	}
	// in range
	if(l<=start and end<=r){
		lazy[index]=val;
		propagate(start,end,index);
		return;
	}
	int mid = start+end>>1;
	rangeUpdate(start,mid,l,r,val,index<<1);
	rangeUpdate(mid+1,end,l,r,val,index<<1|1);
	t[index] = doit(t[index<<1],t[index<<1|1]);
}




signed main()
{
// 	#ifndef ONLINE_JUDGE
// 		freopen("./input.txt","r",stdin);
// 		freopen("./output.txt","w",stdout);
// 	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr);
	cin>>n>>m;
	memset(lazy,-1,sizeof lazy);
	build(0,n-1);
	for(int i=1; i<=m; i++){
		int q; cin>>q;
		if(q==1){
			int t; cin>>t;
			cout<<Query(0,n-1,t,t,1); br;
		}
		else{
			int s,t,x; cin>>s>>t>>x;
			rangeUpdate(0,n-1,s,t,x,1);
		}
	}	

}


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

using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef unsigned short us;
int main(){
    int n;cin>>n;
    int a[n][n];
    rep(i,n){
        rep(j,n-1){
            cin>>a[i][j];
            a[i][j]--;
        }
        a[i][n-1]=-1;
    }

    int index[n]={};
    //setにはできる試合だけ突っ込む
    set<pair<int,int>> st;
    int ans=0,fin=0;
    rep(i,n){
        int u=a[i][0];
        if(a[u][0]==i){
            st.insert(make_pair(min(u,a[u][0]),max(u,a[u][0])));
        }
    }

    for(int day=0;day<=n*(n-1)/2;day++){
        set<pair<int,int>> st_nextday;
        if(fin==n){
            cout<<day<<endl;return 0;
        }

        if(st.empty()){
            //ある日1試合もできないならそれ以上進まないから-1
            cout<<-1<<endl;return 0;
        }
        for(auto uv:st){
            int u=uv.first,v=uv.second;
            index[u]++;index[v]++;
            if(index[u]==n-1) fin++;
            if(index[v]==n-1) fin++;
            
            //試合を行う。
            //試合を行った人が翌日試合を行うかだけチェックする
            //bug begin
            int unv=a[u][index[u]];
            if(u!=-1&&unv!=-1){
                if(a[unv][index[unv]]==u){
                    st_nextday.insert(make_pair(min(u,unv),max(u,unv)));
                }
            }
            int vnv=a[v][index[v]];
            if(v!=-1&&vnv!=-1){
                if(a[vnv][index[vnv]]==v){
                    st_nextday.insert(make_pair(min(v,vnv),max(v,vnv)));
                }
            }
            //bugend
        }
        swap(st,st_nextday);
    }
    return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

ll n, m;
vector<ll> ve[100005];
ll a[100005];

bool f(ll p, ll q)
{
    if(a[p] == 3 - q)
    {
        return false;
    }
    if(a[p] == q) return true;
    a[p] = q;
    for(ll i = 0; i < ve[p].size(); i++)
    {
        if(!f(ve[p][i], 3 - q)) return false;
    }
    return true;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < m; i++)
    {
        ll t1, t2;
        scanf("%lld%lld", &t1, &t2);
        ve[t1].push_back(t2);
        ve[t2].push_back(t1);
    }
    if(f(1, 1))
    {
        ll cnt = 0;
        for(ll i = 1; i <= n; i++) if(a[i] == 1) cnt++;
        printf("%lld\n", cnt * (n - cnt) - m);
    }
    else printf("%lld\n", n * (n - 1) / 2 - m);
    return 0;
}


Measured memory_bytes: 7424
local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do
  t[i] = s:sub(i, i)
end

local r = 0
local g = 0
local b = 0
local rg, rb, gr, gb, br, bg = 0, 0, 0, 0, 0, 0

local ret = 0
for i = 1, n do
  if t[i] == "R" then
    ret = ret + gb + bg
    gr = gr + g
    br = br + b
    r = r + 1
  elseif t[i] == "G" then
    ret = ret + rb + br
    rg = rg + r
    bg = bg + b
    g = g + 1
  else
    ret = ret + rg + gr
    rb = rb + r
    gb = gb + g
    b = b + 1
  end
end
for mid = 1, n do
  if n < 1 + mid + mid then break end
  for left = 1, n do
    local center, right = left + mid, left + mid + mid
    if n < right then break end
    if t[left] ~= t[center] and t[center] ~= t[right] and t[left] ~= t[right] then
      ret = ret - 1
    end
  end
end
print(ret)


Measured memory_bytes: 2768
N = input()

if N[1:] == '111' or N[1:] == '222' or N[1:] == '333' or N[1:] == '444' or N[1:] == '555' or N[1:] == '666' or N[1:] == '777' or N[1:] == '888' or N[1:] == '999' or N[:3] == '111' or N[:3] == '222' or N[:3] == '333' or N[:3] == '444' or N[:3] == '555' or N[:3] == '666' or N[:3] == '777' or N[:3] == '888' or N[:3] == '999' or N[:3] == '000' or N == '1111' or N == '2222' or N == '3333' or N == '4444' or N == '5555' or N == '6666' or N == '7777' or N == '8888' or N == '9999' or N[1:] == '000':
	print('Yes')
	
else:
	print('No')

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

int main(){
  long long N,M,ans=0;
  cin >> N >> M;
  vector<int> A(N);
  vector<pair<int,int>> V(M);
  for(int i=0;i<N;i++) cin >> A[i];
  for(int i=0;i<M;i++){
    int b,c;
    cin >> b >> c;
    V[i] = make_pair(c,b);
  }
  sort(V.begin(),V.end());
  reverse(V.begin(),V.end());
  
  int i=0,m=0;
  while(i<N){
    for(int j=0;j<V[m].second;j++){
      A.push_back(V[m].first);
      i++;
      if(i==N) break;
    }
    m++;
    if(m==M) break;
  }
  
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  for(int i=0;i<N;i++) ans += A[i];
  cout << ans << endl;
  return 0;
}


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

//The Number of the Real Roots of a Cubic Equation
public class Main{

	int a, b, c, d;
	double EPS = 1e-8;
	List<Double> ans;
	
	double f(double x){
		return a*x*x*x + b*x*x + c*x + d;
	}
	double df(double x){
		return 3*a*x*x + 2*b*x + c;
	}
	void bs(double L, double R, boolean up){
		if(f(L)==0){
			ans.add(L); return;
		}
		if(f(R)==0){
			ans.add(R); return;
		}
		if(L <= 0 && 0 <= R && f(0)==0)return;
		while(R-L > 1e-12){
			double M = (L+R)/2;
			if(0 < f(M)){
				if(up)R=M;
				else L=M;
			}
			else if(f(M) < 0){
				if(up)L=M;
				else R=M;
			}
			else{
				ans.add(M); return;
			}
		}
		if(Math.abs(f(L)) < EPS)ans.add(L);
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		int INF = 1000000;
		while(T--!=0){
			a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt(); d = sc.nextInt();
			int D = b*b-3*a*c, rm = 0, rp = 0;
			ans = new ArrayList<Double>();
			if(0 <= D){
				double x0 = (-b-Math.sqrt(D))/3/a, x1 = (-b+Math.sqrt(D))/3/a;
				if(x1 < x0){
					double tmp = x1;
					x1 = x0;
					x0 = tmp;
				}
				bs(-INF, x0, 0 < df((x0-INF)/2));
				bs(x0, x1, 0 < df((x0+x1)/2));
				bs(x1, INF, 0 < df((x1+INF)/2));
			}
			else{
				bs(-INF, INF, 0 < df(0));
			}
			for(double d:ans){
				if(d == 0)continue;
				if(0 < d)rp++;
				else rm++;
			}
			System.out.println(rp+" "+rm);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int main()
{
	int x;
	stack<int> st;
	for (int n; cin >> n;) {
		if (n) {
			st.push(n);
		}
		else {
			cout << st.top() << endl;
			st.pop();
		}
	}
    return 0;
}

Measured memory_bytes: 1196
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 ans = "";
        if (a.length() > b.length()) {
            ans = "GREATER";
        } else if (a.length() < b.length()) {
            ans = "LESS";
        } else {
            for (int i=0; i<a.length();i++) {
                int an = Integer.parseInt(a.substring(i,i+1));
                int bn = Integer.parseInt(b.substring(i,i+1));
                if (an > bn) {
                    ans = "GREATER";
                    break;
                } else if (an < bn) {
                    ans ="LESS";
                    break;
                }
                ans = "EQUAL";
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
#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;

typedef long long int ll;
typedef tree< ll, null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 1e9 + 7;

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

  string s;
  cin >> s;
  ll n = s.length();
  vector < ll > dp1(2019, 0), dp2(2019, 0);
  dp1[s[0] - '0'] = 1;
  ll ans = 0;
  for(int i = 1; i < n; i++){
    ll num = s[i] - '0';
    dp2[num] = 1;
    for(int j = 0; j < 2019; j++){
      dp2[(10 * j + num) % 2019] += dp1[j];
    }
    ans += dp2[0];
    dp1 = dp2;
    dp2.assign(2019, 0);
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3744
import java.util.Scanner;

public class Main {

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

		long n = sc.nextLong();
		long k = sc.nextLong();
		long res = 0;
//		String s = sc.next();
//		String res = "";
		long semiFinal1 = n % k;
		long semiFinal2 = k - semiFinal1;
//		System.out.printf("%d %d\n", semiFinal1, semiFinal2);

		if(semiFinal1 < semiFinal2) {
			res = semiFinal1;
		} else {
			res = semiFinal2;
		}
		System.out.printf("%d", res);
		//System.out.println(res);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
    ll n,m ;
    cin >> n>> m;
  if(n%2==0){
     ll k= n/4 ;
          if(k<=m){
          for(ll i=1;i<=(n/4);i++){
              cout<<i<<" "<<n-i+1<<endl;
          }for (ll j=(n/4)+1;j<=m;j++){
          cout <<j<<" "<<n-j<<endl;
          
      }
          }
  else{
      for(ll i=1;i<=m;i++){
          cout<<i<<" "<<n-i+1<<endl;
      }
  }
  }
  
    
 else{
  rep(i,m){
  cout <<i+1<<" "<<n-i<<endl ; 
  } 
 }return 0;

}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double pi=acos(-1);
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n){ll r=1%P;for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
const double eps=1e-5;

ll lcm(ll a,ll b)
{
   return a*b/gcd(a,b);
}
int main()
{
    int k;
    cin>>k;
    cout<<lcm(k,360)/k<<endl;
}


Measured memory_bytes: 3600
#include<stdio.h>

int main(void){
	int x, t1, x1, x2, ans = 1;
	scanf("%d", &x);
	while(x--){
		scanf("%d%d%d", &t1, &x1, &x2);
		if(t1 < (x1 + x2))ans = 0;
		int mod_t1 = t1 % 2;
		int mod_x = (x1 + x2) % 2;
		if(mod_t1 != mod_x)ans = 0; 
	}
	if(ans)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
// #define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007LL
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll euclid(ll x,ll y,ll a,ll b)
{
  return (a-x)*(a-x)+(b-y)*(b-y);
}
// Constants //
bool comp(ll a,ll b)
{
  return a>b;
}
void solve()
{
  ll s,w;
  cin>>s>>w;
  if(w>=s)
    cout<<"unsafe";
  else
    cout<<"safe";
}

int main()
{ 
  ios;
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  ll t,i;
  t=1;
  // cin>>t;
  while(t--)
  {
    solve();
    // cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String result = "No";
		if(a <= c && b >= c) {
			result = "Yes";
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

size_t get_ans(unsigned x, std::vector<std::vector<unsigned>>& G, std::vector<ssize_t>& dp)
{
  size_t ans = 0;
  for (size_t i = 0; i < G[x].size(); ++i)
  {
    unsigned v = G[x][i];
    if (dp[v] == -1)
    { 
      dp[v] = get_ans(v, G, dp);
    }
    ans = std::max<size_t>(ans, dp[v] + 1);
  }
  dp[x] = ans;
  return ans;
}

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

  unsigned N, M, x, y;

  std::cin >> N >> M;

  std::vector<std::vector<unsigned>> G(N+1);
  std::vector<ssize_t> dp(N+1, -1);
  for (int i = 0; i < M; ++i)
  {
    std::cin >> x >> y;
    G[x].push_back(y);
  }
  size_t ans = 0;
  for (int i = 0; i < N+1; ++i)
  {
    if (!G[i].empty())
    { 
      ans = std::max(ans, get_ans(i, G, dp));
    }
  }
  std::cout << ans;

  return 0;
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i, j, k;
  int A,B, C, X;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> X;
  int cnt = 0;
  for(i=0; i<=A; i++){
    for(j=0; j<=B; j++){
      for(k=0; k<=C; k++){
        if (i * 500 + j * 100 + k * 50 == X){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

constexpr int MAXD = 10;

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

    vvi adj((MAXD+1)*N);

    for (int i=0;i<M;i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        for (int d=1;d<=MAXD;d++) {
            adj[d*N + a].push_back((d-1)*N + b);
            adj[d*N + b].push_back((d-1)*N + a);
        }
    }

    for (int i=0;i<N;i++) {
        for (int d=1;d<=MAXD;d++) {
            adj[d*N + i].push_back((d-1)*N + i);
        }
    }

    vi colors((MAXD+1)*N, 0);

    int Q;
    cin >> Q;
    vi qvs(Q);
    vi qcs(Q);
    vi qds(Q);

    for (int i=0;i<Q;i++) cin >> qvs[Q-1-i] >> qds[Q-1-i] >> qcs[Q-1-i];

    for (int i=0;i<Q;i++) {
        int col = qcs[i];
        int d = qds[i];
        int v = qvs[i];
        v--;

        if(colors[d*N + v] != 0) continue;

        queue<int> bfs;
        bfs.push(d*N + v);
        colors[d*N + v] = col;

        while (!bfs.empty()) {
            int cur = bfs.front();
            bfs.pop();

            for (int nbr : adj[cur]) {
                if (colors[nbr] == 0) {
                    colors[nbr] = col;
                    bfs.push(nbr);
                }
            }
        }
    }

    for (int i=0;i<N;i++) cout << colors[i] << "\n";

    return 0;
}


Measured memory_bytes: 67516
#include <iostream>
#include <fstream>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int p[100005];
    int num_AC[100005];
    int num_WA[100005];
    int num_WA_enter[100005];
    int sum1,sum2;
    string S[100005];
    for(int i = 0; i < M ; i ++){
        cin >> p[i];
        cin >> S[i];
    }
    for(int i = 0; i < M ; i ++){
        if(S[i] == "WA") num_WA[p[i]-1] += 1;
        if((S[i] == "AC") && (num_AC[p[i]-1] != 1)){
            num_AC[p[i]-1] = 1;
            num_WA_enter[p[i]-1] = num_WA[p[i]-1];
        }
    }
    sum1 = sum2 = 0;
    for(int i = 0; i < N ; i ++){
        sum1 += num_AC[i];
        sum2 += num_WA_enter[i];
    }
    cout << sum1 << ' ' << sum2 << endl;
}



Measured memory_bytes: 7296
import java.util.*;
public class Main{
	
	public static void main(String[] args){
        Scanner sn = new Scanner(System.in);
		int A = 0;
        int B = 0;
        int x = 0;
        int y = 0;
        int z = 0;
        int max = 0;

        try{
            String str = sn.nextLine();
            String[] strlist = str.split(" ",0);
            A = Integer.parseInt(strlist[0]);
            B = Integer.parseInt(strlist[1]);
            sn.close();
            if(A<-100 || 100< B){
                return;
            }
            x = A + B;
            y = A - B;
            z = A * B;
            max = Math.max(x,y);
            max = Math.max(max,z);
            System.out.println(max);
        }catch(Exception e){
            //do nothing
            return;
        }
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
 
 
#define ll long long
#define max 1000000000
 
 
#define biggestFactor (n)      for (ll j = 2; j <= sqrt(n); j++){if (n % j == 0){cout << n / j << "\n";break;}}
                               //First find smallest factor and then divide that factor and the answer itself is biggest factor
                          
using namespace std;

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

    ll n;
    cin >> n;
    ll v = 7% n;
    ll flag = 0;
    ll cna = -1;
        for (ll i = 0; i < 10000000; i++)
        {
            if (v % n == 0)
            {
                cna = i + 1;
                break;
            }
            else
            {
                v = (v * 10 + 7) % n;
            }
        }
        cout << cna;
    
	return 0;
}

Measured memory_bytes: 3652
#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>
#include<functional>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; map<string, int>mp;
  rep(i, N){
    string S; cin >> S;
    mp[S]++;
  }
  int ma = 0;
  for(auto k: mp){
    if(k.second>ma) ma=k.second;
  }
  for(auto k: mp){
    if(k.second==ma){
      cout << k.first << endl;
    }
  }
}

Measured memory_bytes: 25216
#include <stdio.h>
#include <stdlib.h>

struct stack{
	int num;
	struct stack *next;
};

struct stack *push (int i, struct stack *s){
	struct stack *top;
	top = (struct stack*) malloc (sizeof (struct stack*));
	top->num = i;
	top->next = s;
	return top;
}

struct stack *pop (struct stack *s){
	struct stack *tmp;
	tmp = s->next;
	free (s);
	return tmp;
}

int read_top (struct stack *s){
	return s->num;
}

int main(void) {
	int n;
	struct stack *stk;
	stk = (struct stack*) malloc (sizeof (struct stack*));
	stk->next = NULL;
	while (~scanf ("%d", &n)){
		if (n != 0) {stk = push (n, stk);}
		else {
			printf ("%d\n", read_top (stk));
			stk = pop (stk);
		}
	}
	free (stk);
	return 0;
}

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

int main(){
  string s;
  int k;
  cin>>s>>k;
  int n=s.size(); 
  rep(i,n){
    if(i==n-1){
      for(int j=0; j<k%26; j++){
        if(s[i]=='z') s[i]='a';
        else s[i]++;
      }
      break;
    }
    int t = ('z'-s[i]+1) % 26;
    if(t<=k){
      s[i]='a';
      k-=t;
    }
  }
  cout<<s<<endl;
}



Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    long long int l2=min(min(8*q,4*h),min(2*s,d)),l1=min({4*q,2*h,s});
    long long int ans=n/2*l2;ans+=n%2*l1;
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3584
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String[] firstArr = sc.nextLine().split(" ");
		int n = Integer.parseInt(firstArr[0]);
		int m = Integer.parseInt(firstArr[1]);
		
		ArrayList<ArrayList<Integer>> vectorList = new ArrayList<>();
		for(int i = 0 ; i < n;i++) {
			vectorList.add(new ArrayList<Integer>());
		}
		
		for(int i = 0; i < m;i++) {
			String[] lineArr = sc.nextLine().split(" ");
			int a = Integer.parseInt(lineArr[0]);
			int b = Integer.parseInt(lineArr[1]);
			vectorList.get(a-1).add(b-1);
		}
		
		sc.close();
		
		ArrayList<Integer> bestCycle = null;
		for(int i = 0; i < n;i++) {
			ArrayList<Integer> cycle = bfs(i, vectorList, n);
			if(cycle == null) {
				continue;
			}
			if(bestCycle == null || cycle.size() < bestCycle.size()) {
				bestCycle = cycle;
			}
		}
		
		if(bestCycle == null) {
			System.out.println("-1");
		}else {
			System.out.println(bestCycle.size());
			for(int point : bestCycle) {
				System.out.println(point+1);
			}
		}
		
	}
	
	public static ArrayList<Integer> bfs(int start, ArrayList<ArrayList<Integer>> vectorList, int n){
		
		final int INF = 1001001001;
		int[] dist = new int[n];
		int[] pre = new int[n];
		for(int i = 0; i < n; i++) {
			dist[i] = INF;
			pre[i] = -1;
		}
		dist[start] = 0;
		ArrayDeque<Integer> queue = new ArrayDeque<>();
		queue.push(new Integer(start));
		while(!queue.isEmpty()) {
			int point  = queue.pop();
			for(int nextPoint : vectorList.get(point)) {
				if(dist[nextPoint] != INF) {
					continue;
				}
				dist[nextPoint] = dist[point] + 1;
				queue.push(new Integer(nextPoint));
				pre[nextPoint] = point;
			}
		}
		
		int minDist = INF;
		int lastPointInMinPath = -1;
		for(int i = 0; i < n ;i++) {
			if(i == start) {
				continue;
			}
			for(int nextPoint : vectorList.get(i)) {
				if(nextPoint == start) {
					if(minDist > dist[i]) {
						minDist = dist[i];
						lastPointInMinPath = i;
					}
				}
			}
		}
		
		if(minDist == INF) {
			return null;
		}else {
			ArrayList<Integer> retList = new ArrayList<>();
			retList.add(0, new Integer(lastPointInMinPath));
			int v = pre[lastPointInMinPath];
			while(v != -1) {
				retList.add(0, new Integer(v));
				v = pre[v];
			}
			return retList;
		}
	}

}


Measured memory_bytes: 62588
def resolve():
    N, D, A = map(int, input().split())
    lXH = []
    while True:
        try:
            x, h = map(int, input().split())
            lXH.append([x, h])
        except:
            break
    lXHs = sorted(lXH, key=lambda k: k[0])
    from collections import deque
    q = deque()
    tot = 0
    ans = 0
    for i in range(N):
        x, h = lXHs[i]
        while len(q) > 0 and q[0][0] < x:
            qx, qh = q.popleft()
            tot -= qh
        h -= tot
        if h > 0:
            num = (h+A-1)//A
            ans += num
            dam = num*A
            tot += dam
            q.append([x+2*D, dam])
    print(ans)
resolve()

Measured memory_bytes: 94552
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,w; cin>>n>>w; vector<vector<long long int>>v(n,vector<long long int>(2)), dp(n+1,vector<long long int>(w+1,0));
  for(int i=0;i<n;i++)
  {
  	
  	cin>>v[i][0]>>v[i][1];
  }
  for(int i=1;i<=n;i++)
  for(int j=1;j<=w;j++)
  {
  	if(j<v[i-1][0])
  	dp[i][j]=dp[i-1][j];
  	else
  	dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1][0]]+v[i-1][1]);
  	
  }
  
  cout<<dp[n][w];
  	
}

Measured memory_bytes: 80256
from collections import Counter
n = int(input())
d_li = list(map(int,input().split()))
m = int(input())
t_li = list(map(int,input().split()))

d_counter = Counter(d_li)
t_counter = Counter(t_li)
t_most_counter = t_counter.most_common()
t_len = len(t_most_counter)
for i in range(t_len):
    dum = t_most_counter[i][0]
    if d_counter[dum] >= t_most_counter[i][1]:
        pass
    else:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 69088
#include  <bits/stdc++.h>
using namespace std;
int main(){
  int n,r,j;//jは内部
  cin>>n>>r;//参加回数　表示レ
  if(n>=10)
    cout<<r<<endl;
  else
    cout<<r+100*(10-n)<<endl;
    
    
    
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n + 1) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}





N,M = list(map(int,input().split()))
G  = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    G.union(a,b)
print(G.group_count()-2)



Measured memory_bytes: 13084
#pragma GCC optimize("-Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//order_of_key(x) : number of items less than x
//find_by_order(x) : iterator to x

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()

const ld pi=3.14159265359;
ll INF=1e18+10;
ll MOD=998244353;
ll mod=1e9+7;

inline ll add(ll a,ll b,ll m){
    if(a+b>m)return (a+b)-m;
    return a+b;
}

inline ll mul(ll a,ll b,ll m){
    if((a*b)<m)return a*b;
    return (a*b)%m;
}

int main()
{
    string s;cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
def main():
    A = [ list( map( int, input().split())) for _ in range(3)]
    N = int( input())
    B = [ int( input()) for _ in range(N)]
    T = [[0]*3 for _ in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    T[i][j] = 1
    ans = 'No'
    for i in range(3):
        if T[i][0]*T[i][1]*T[i][2] > 0:
            ans = 'Yes'
    for i in range(3):
        if T[0][i]*T[1][i]*T[2][i] > 0:
            ans = 'Yes'
    if T[0][0]*T[1][1]*T[2][2] > 0:
        ans = 'Yes'
    if T[0][2]*T[1][1]*T[2][0] > 0:
        ans = 'Yes'
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<i32>();
    let (a, b) = (line[0], line[1]);

    let (base, num) = (cmp::min(a, b), cmp::max(a, b));

    for i in 0..num{
        print!("{}", base);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n),cnt(1e6+10);
    for(auto &i:a) cin>>i;
    for(auto &i:cnt) i=0;
    
    //全体のGCDを取って2以上ならnot coprime
    int tmp = a[0];
    for(auto i:a){
        tmp = __gcd(tmp,i);
    }
    if(tmp>=2){
        cout<<"not coprime"<<endl;
        return 0;
    }

    //1を除き、同じ値があるならばsetwise coprime
    for(auto i:a){
        if(cnt[i]){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
        if(i!=1){
            cnt[i]++;
        }
    }

    //因数について、その倍数が配列中に複数存在するならsetwise coprime
    for(int i=2; i<=1e6; i++){
        int c = 0;
        for(int j=1; j*i<1e6; j++){
            c += cnt[j*i];
        }
        if(c>1){
            cout<<"setwise coprime"<<endl;
            return 0;
        }
    }
    cout<<"pairwise coprime"<<endl;
}

Measured memory_bytes: 11152
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>
#include <random>

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

using namespace std;
typedef long long int ll;
const ll INF = 10000000000;
const double PI = acos(-1);
const int mod = 1000000007;

ll dp[101][100001] = {0};

int main()
{
    ll n, W;
    cin >> n >> W;
    vector<ll> w(n + 1), v(n + 1);
    for (ll i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
    }

    for (ll j = 0; j <= 100000; j++) {
        dp[0][j] = INF;
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 0; j <= 100000; j++) {
            if (v[i] >= j) {
                dp[i][j] = min(dp[i - 1][j], w[i]);
            }
            else {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
            }
        }
    }
    
    ll ans = 0;
    for (ll j = 0; j <= 100000; j++) {
        if (dp[n][j] > W) break;
        ans = j;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 82528
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

bool isKaibun(string s) {
	// cout << s << endl;
	string rev = s;
	reverse(rev.begin(), rev.end());
	return s == rev;
}

int main(void) {
	string S;
	cin >> S;
	string ans = "Yes";
	if (!isKaibun(S)) ans ="No";
	if (!isKaibun(S.substr(0, (S.length() - 1) / 2))) ans ="No";
	if (!isKaibun(S.substr(S.length() / 2 + 1, (S.length() - 1) / 2))) ans ="No";
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int main(){
  int N,a[10010],M;
  cin>>N>>M;
  rep(i,M)cin>>a[i];
  long long s=N;
  rep(i,M)s-=a[i];
  if(s<0)cout<<"-1"<<endl;
  else cout<<s<<endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  cout << (abs(a - x) < abs(b - x) ? 'A' : 'B') << endl;


  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
vector < int > adj[100010];
int dp[100010][2];
long long mod = 1e9 + 7;
int dfs(int i = 0 , int p = -1 , bool black = 0)
{
    int &ret = dp[i][black];
    if(~ret)    return ret;

    int temp1 = 1 , temp2 = !black;
    for(auto x : adj[i])if(x!=p)        temp1 = (1LL*temp1*dfs(x,i,0))%mod;
    if(temp2)
        for(auto x : adj[i])if(x!=p)    temp2 = (1LL*temp2*dfs(x,i,1))%mod;
    return ret = (temp1 + temp2)%mod;
}
int main()
{
    cin >> n;
    for(int i = 0 ; i < n-1 ; i++)
    {
        int a, b;   cin >> a >> b;  a--,b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    memset(dp,-1,sizeof dp);
    cout << dfs() << '\n';
    return 0;
}


Measured memory_bytes: 14848
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    def f(n):
        a = LI()
        av = 1.0 * sum(a) / n

        return len([c for c in a if c <= av])


    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 10076
#include<stdio.h>

int main(){
    int i,n;

    scanf("%d", &n);
    
    int R[n];

    for(i=0;i<n;i++){
        scanf("%d", &R[i]);
    }
    
    int maxv = R[1] - R[0];
    int minv = R[0];

    for(i=1; i<n; i++){
        maxv = maxv < R[i] - minv ? R[i] - minv : maxv;
        minv = minv > R[i] ? R[i] : minv;
    }

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

    return 0;
}


Measured memory_bytes: 2552