akhauriyash/Code-Regression huggingface dataset:
(L,R)=(int(x)for x in input().split())
 
if (R-L>=2019):
    print ( 0 )
    exit()

a = []

for i in range (R-L+1):
    
    x = L + i
    a.append((x)%2019)        

    
ans = 2019

for i in range (R-L+1):

    for j in range (R-L+1):

        if i == j :
            continue
        
        ans_tmp = ( a[i] * a[j] )%2019
        
        if ans_tmp < ans:
            ans = ans_tmp
        
print (ans)


Measured memory_bytes: 3064
x, y = map(int, input().split())

crane_legs_tmp = 2*x
if crane_legs_tmp > y:
    print("No")
elif crane_legs_tmp == y:
    print("Yes")
else:
    flag = 0
    for i in range(x):
        if (x - (i+1))*2 + (i+1)*4 == y:
            flag = 1
            break
    if flag == 1:
        print("Yes")
    else :
        print("No")

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

using namespace std;

vector<tuple<int, int, int>> edges;
int n, m;

int group[501];
int getGroup(int u) {
	if(group[u] == u) return u;
	return group[u] = getGroup(group[u]);
}

pair<vector<tuple<int, int, int>>, int> krus(int v1, int v2) {
	for(int i = 1; i <= n; i++) group[i] = i;

	pair<vector<tuple<int, int, int>>, int> ret;
	ret.second = 0;

	for(auto &e: edges) {
		int cost, u, v;
		tie(cost, u, v) = e;
		if(u == v1 and v == v2) continue;
		if((u = getGroup(u)) != (v = getGroup(v))) {
			group[v] = u;
			ret.second += cost;
			ret.first.push_back(e);
			if(ret.first.size() == n - 1) break;
		}
	}

	return ret;
}

int main(void) {
	scanf("%d %d", &n, &m);
	while(m--) {
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		edges.push_back(make_tuple(c, u, v));
	}

	sort(edges.begin(), edges.end());

	auto orig = krus(0, 0);
	int ans[2] = {0, 0};

	for(auto e: orig.first) {
		int u, v, cost;
		tie(cost, u, v) = e;
		auto cur = krus(u, v);
		if(cur.first.size() != n - 1 or cur.second != orig.second) {
			ans[0]++;
			ans[1] += cost;
		}
	}

	printf("%d %d\n", ans[0], ans[1]);
	return 0;
}

Measured memory_bytes: 1828
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> red(N), blue(N);
    vector<vector<int>> G(N, vector<int>());
    vector<bool> used(N, false);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        red[i] = {a, b};
    }

    rep(i, N) {
        int c, d;
        cin >> c >> d;
        blue[i] = {c, d};
    }

    sort(all(red), [](pair<int, int> a, pair<int, int> b) {
        return a.second > b.second;
    });
    sort(all(blue),
         [](pair<int, int> a, pair<int, int> b) { return a.first < b.first; });

    int cnt = 0;
    rep(i, N) {
        rep(j, N) {
            if (used[j])
                continue;
            if (blue[j].first > red[i].first &&
                blue[j].second > red[i].second) {
                used[j] = true;
                cnt++;
                break;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
	double r;
	cin>>r;

	r = 2*acos(-1)*r;

	cout<<fixed<<setprecision(2)<<r;
 
 
	return 0;
}

Measured memory_bytes: 3820
using System;
//using System.Collections.Generic;
//using System.Collections;
using System.Linq;

namespace solution
{
  class Class1
  {
    static void Main()
    {
      int N = int.Parse(Console.ReadLine());
      int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();

      SelectionSort(A, N);
    }

    static void SelectionSort(int[] A, int N)
    {
      int count = 0;

      for (int i = 0; i < N - 1; i++)
      {
        int minj = i;
        for (int j = i + 1; j <= N - 1; j++)
        {
          if (A[j] < A[minj]) minj = j;
        }

        if (minj != i) count++;

        int temp = A[minj];
        A[minj] = A[i];
        A[i] = temp;
      }

      var As = A.Select(x => x.ToString()).ToArray();
      Console.WriteLine(String.Join(" ", As));
      Console.WriteLine(count);
    }
  }
}








Measured memory_bytes: 9644
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n >= m :
    print(0)
    exit()
x.sort()

dif=[]
tmp=0
for i, xi in enumerate(x) :
    if i == 0 :
        tmp = xi
        continue
    dif.append(xi-tmp)
    tmp=xi

dif.sort()
for i in range(n-1):
    dif.pop()

print(sum(dif))
    

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

int main()
{
	char cupName[3] = {'A', 'B', 'C'};
	map<char, int> cup;
	char c1, c2;
	int i;

	cup['A'] = 1;
	cup['B'] = 0;
	cup['C'] = 0;
	while (scanf("%1c,%1c", &c1, &c2) != EOF) {
		cin.ignore(0xFF, '\n');
		cup[c1] ^= cup[c2];
		cup[c2] ^= cup[c1];
		cup[c1] ^= cup[c2];
	}

	for (i = 0; i < 3; i++)
		if (cup[cupName[i]]) cout<<cupName[i]<<endl;

	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
超立方体のハミルトン路
思いついた
編集途中
*/

ll n,a,b,change=0;
vector<ll> ans;

void dfs(vector<ll> &v,ll a,ll b,ll size,ll musk){
	if(size==2){
		v.push_back(a);
		v.push_back(b);
		return;
	}
	ll c,d;
	rep(i,n){
		if(!(musk & (1<<i)) && ((a^b) & (1<<i))){
			c=i;
			break;
		}
	}
	rep(i,n){
		if(!(musk & (1<<i)) && (i!=c)){
			d=i;
			break;
		}
	}
	dfs(v,a,a^(1<<d),size/2,musk+(1<<c));
	dfs(v,a^(1<<c)^(1<<d),b,size/2,musk+(1<<c));
}

int main(void){
	cin>>n>>a>>b;
	ll t=0;
	if(__builtin_popcount(a^b)%2==0){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
		dfs(ans,a,b,1<<n,0);
		rep(i,ans.size()){
			cout<<ans[i]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0

signed main() {
	int n;
	cin >> n;
	int dp[100007];
	dp[0] = 0;
	for (int i = 1; i < 100005; i++) {
		dp[i] = 500000;
	}
	for (int i = 1; i <= n; i++) {
		dp[i] = min(dp[i], dp[i - 1] + 1);
		for (int j = 6; j <= i; j *= 6) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
		for (int j = 9; j <= i; j *= 9) {
			dp[i] = min(dp[i], dp[i - j] + 1);
		}
	}
	cout << dp[n] << endl;

	END;
}


Measured memory_bytes: 1024
def PrimeFactorization(m):
    pf = {}
    for i in range(2, int(m ** 0.5) + 1):
        while m % i == 0:
            pf[i] = pf.get(i, 0) + 1
            m //= i
    if m > 1:
        pf[m] = 1
    return pf


def lcmlist(l):
    from collections import defaultdict
    d = defaultdict(int)
    for i in set(l):
        for k, v in PrimeFactorization(i).items():
            if v > d[k]:
                d[k] = v
    n = 1
    for k, v in d.items():
        n *= k ** v
    return n

n=int(input())
a=list(map(int,input().split()))
x=lcmlist(a)
ans=0
for i in a:
  ans+=x//i
ans%=1000000007
print(ans)

Measured memory_bytes: 5092
s = input()
set1 = {"W","N","S","E"}
set2 = {"W","E"}
set3 = {"N","S"}

if set(s) == set1:
    print("Yes")
elif set(s) == set2:
    print("Yes")
elif set(s) == set3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

const ll INF = 1000000000;

template <typename T>
struct Edge
{
    int to;
    T cap;
    int rev;
    int id;
};

template <typename T>
struct Flow
{
    int n;
    vector<int> d;
    vector<int> nx;
    vector<vector<Edge<T>>> g;
    
    Flow(){}
    
    Flow(int n) : n(n){
        d.resize(n);
        nx.resize(n);
        g.resize(n);
    }
    
    void add_edge(int from, int to, T cap, int id = -1){
        g[from].push_back((Edge<T>){to, cap, (int)g[to].size(), id});
        g[to].push_back((Edge<T>){from, 0, (int)g[from].size() - 1, -1});
    }
    
    void bfs(int r){
        fill(d.begin(), d.end(), n);
        queue<int> que;
        d[r] = 0;
        que.push(r);
        while(que.size()){
            int u = que.front();
            que.pop();
            for(Edge<T> e : g[u]){
                int v = e.to;
                if(e.cap > 0 && d[v] == n){
                    d[v] = d[u] + 1;
                    que.push(v);
                }
            }
        }
    }
    
    T dfs(int u, int s, T f){
        if(u == s) return f;
        for(int &i = nx[u]; i < (int)g[u].size(); i++){
            Edge<T> &e = g[u][i];
            int v = e.to;
            if(d[v] <= d[u] || e.cap == 0) continue;
            T fl = dfs(v, s, min(f, e.cap));
            if(fl > 0){
                e.cap -= fl;
                g[e.to][e.rev].cap += fl;
                return fl;
            }
        }
        return 0;
    }
    
    T max_flow(int r, int s){
        T res = 0;
        while(true){
            bfs(r);
            if(d[s] == n) return res;
            for(int i = 0; i < n; i++) nx[i] = 0;
            for(T f; (f = dfs(r, s, INF)) > 0;) res += f;
        }
    }
};

struct Bipartite_Matching
{
    int n;
    int m;
    Flow<int> g;
    vector<int> match;
    
    Bipartite_Matching(int n, int m) : n(n), m(m){
        g.n = n + m + 2;
        g.d.resize(g.n);
        g.nx.resize(g.n);
        g.g.resize(g.n);
        for(int i = 0; i < n; i++) g.add_edge(n + m, i, 1);
        for(int i = n; i < n + m; i++) g.add_edge(i, n + m + 1, 1);
    }
    
    void add_edge(int i, int j, int id = -1){
        g.add_edge(i, j + n, 1, id);
    }
    
    int max_matching(){
        g.max_flow(n + m, n + m + 1);
        for(int i = 0; i < n; i++){
            for(int j = 1; j < (int)g.g[i].size(); j++){
                if(g.g[i][j].cap == 0) match.push_back(g.g[i][j].id);
            }
        }
        return (int)match.size();
    }
};

int main()
{
    int n;
    cin >> n;
    int a[102], b[102], c[102], d[102];
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for(int i = 0; i < n; i++) cin >> c[i] >> d[i];
    Bipartite_Matching g(n, n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(a[i] < c[j] && b[i] < d[j]) g.add_edge(i, j);
        }
    }
    cout << g.max_matching() << endl;
}


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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a,b,k,i,f;
	vector<ll> v;
	cin>>a>>b>>k;
	f=__gcd(a,b);
	for(i=1;i<=f;i++){
		if(f%i==0){
				
			v.push_back(i);
			//cout<<i<<endl;
		}
	}sort(v.rbegin(),v.rend());
	cout<<v[k-1];
}

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

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

	for(string name, type; cin >> name >> type && type != "X";) {
		string ans = "";
		int prev = 0;
		for(unsigned i = 0; i < name.size(); ++i) {
			if(name[i] == '_' || isupper(name[i])) {
				if(type == "D") {
					name[prev] = tolower(name[prev]);
					if(prev) ans += '_';
				}
				else {
					name[prev] = toupper(name[prev]);
				}

				ans += name.substr(prev, i - prev);
				prev = i;
				if(name[i] == '_') ++prev;
			}
		}
		
		if(type == "D") {
			name[prev] = tolower(name[prev]);
			if(prev) ans += '_';
		}
		else {
			name[prev] = toupper(name[prev]);
		}

		ans += name.substr(prev);
		if(type == "L") ans[0] = tolower(ans[0]);
		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1188
N, W = map(int, input().split())

w = [0] * (N + 1)
v = [0] * (N + 1)

for i in range(1, N + 1):
    w[i], v[i] = map(int, input().split())
    
MAX_W = 1000000
dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for weight in range(1, W + 1):
        if weight - w[i] >= 0:#入れられる可能性があるかどうか
            dp[i][weight] = max(dp[i][weight], dp[i - 1][weight-w[i]] + v[i])#ある場合は、直前まででLimitがweight-w[i]の最大値と比較
#dp[i][weight] = i-1番目までの品から重さがweight以下になるように選んだ時の価値の最大値
        dp[i][weight] = max(dp[i-1][weight], dp[i][weight])

print(dp[N][W])

Measured memory_bytes: 120556
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
int main(){
   // T{
       ll n;
       cin>>n;
       vector<ll>ar(n);
       for(ll i=0; i<n; i++)cin>>ar[i];
        ll ans=0;

        for(ll i=1; i<n; i++){
           if(ar[i-1]>ar[i]){ans+=(ar[i-1]-ar[i]);
        
            ar[i]+=(ar[i-1]-ar[i]);
            }

        }
        cout<<ans<<endl;
}



Measured memory_bytes: 4832
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

ll count(ll bit){
    if(bit == 0) return 0;
    return count(bit >> 1) + (bit & 1);
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll N; cin >> N;
  vector<ll> A(N);
  vector<vector<ll>> x(N,vector<ll>(N,-1)), y(N,vector<ll>(N,-1));
  REP(i,N){
    cin >> A[i];
    REP(j,A[i]){
      cin >> x[i][j] >> y[i][j];
      x[i][j]--; // 0-indexed
    }
  }
  ll ans = 0,tmp = 0;
  bool flg = true;
  vector<ll> list(N);
  for (ll bit = 0; bit < (1 << N); ++bit) {
    	flg = true; tmp = 0;
    	list.resize(N,-1);
    	for(ll i = 0; i < N; ++i){
      		if(!(bit & (1 << i))) continue;
        	REP(j,A[i]){
                    ll t = x[i][j];
           			if(((bit >> t) & 1) ^ y[i][j]) flg = false;
      		}
  		}
    	if(flg) ans = max(ans,count(bit));
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    int N;
    cin>>N;
    long long T;
    T=N%10+(N/10)%10+(N/100)%10+(N/1000)%10+(N/10000)%10+(N/100000)%10+(N/1000000)%10+(N/10000000)%10+(N/100000000)%10;
    
    if(N%T==0){
         cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string s1,s2,s;
    int n1,n2;
    cin>>s1>>s2>>n1>>n2>>s;
    if(s==s1)n1--;
    if(s==s2)n2--;
    cout<<(n1>0?n1:0)<<' '<<(n2>0?n2:0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>                        //  ifstream, ofstream

using namespace std;
void mainA() {
	int N;
	cin >> N;
	//
	int minSum = 0x10000000 - 1;
	for (int A = 1; A < N; A++) {
		int B = N - A;
		int a = A;
		int b = B;
		int sum = 0;
		do {
			sum+=a % 10;
			a /= 10;
		} while (a > 0 && minSum>sum);

		do {
			sum += b % 10;
			b /= 10;
		} while (b > 0 && minSum>sum);
		if (minSum > sum)minSum = sum;
	}
	cout << minSum << endl;
	//cout << "end" << endl;
	return ;
}

int main()
{
	mainA();
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def input(): return sys.stdin.readline().rstrip()


def main():
    x, k, d = map(int, input().split())
    desired = abs(x) // d
    if k <= desired:
        if x < 0:
            x += k * d
        else:
            x -= k * d
        print(abs(x))
        return
    if x < 0:
        x += desired * d
    else:
        x -= desired * d
    if (k - desired) % 2 == 0:
        print(abs(x))
        return
    if x == 0:
        print(d)
    elif x > 0:
        x -= d
        print(abs(x))
    elif x < 0:
        x += d
        print(abs(x))


if __name__ == '__main__':
    main()

Measured memory_bytes: 61968
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

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

int main(){
  ll N; cin >> N;
  vector<ll> a(N); rep(i,N) cin >> a[i];
  sort(a.begin(), a.end() , greater<ll>());

  ll ans = 0;
  rep(i,N){
    if(i % 2 == 0) ans += a[i];
    else ans -= a[i];
  }
  cout << ans << endl;
}


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

struct Card {char suit, value;};

bool inStable(struct Card C1[], struct Card C2[], int N) {
  for (int i = 0; i < N; i++) {
    if(C1[i].suit != C2[i].suit) {
      return false;
    }
  }
  return true;
}

void bubble (struct Card A[], int N) {
  bool flag = 1;
  int i = 0;
  while (flag) {
    flag = 0;
    for (int j = N - 1; j >= i + 1; j--) {
      if (A[j].value < A[j - 1].value) {
        swap(A[j], A[j - 1]);
        flag = 1;
      }
    }
  }
}

void selection (struct Card A[], int N) {
  int i = 0;
  for (i = 0; i < N; i++) {
    int minj = i;
    for (int j = i; j < N; j++) {
      if (A[j].value < A[minj].value) {
        minj = j;
      }
    }
    if (i != minj) {
      swap(A[i], A[minj]); 
    }
  }
}

void print(struct Card A[], int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

int main() {
  Card C1[100], C2[100];
  int N;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> C1[i].suit >> C1[i].value;
  }
  
  for (int i = 0; i < N; i++) {
    C2[i] = C1[i];
  }
  
  bubble(C1, N);
  selection(C2, N);
  
  print(C1, N);
  cout << "Stable" << endl;
  
  print(C2, N);
  if(inStable(C1, C2, N)) {
    cout << "Stable" << endl;
  }
  else {
    cout <<"Not stable" << endl;
  }
}



Measured memory_bytes: 3096
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = (int)1e9 + 7;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e7;
	
	
	void doIt() {
		int N = sc.nextInt();
		long[] num = new long[N + 1];
		Arrays.fill(num, 2);
		num[1] = 1;
		for(int i = 2; i <= N; i++) {
			for(int j = i * 2; j <= N; j += i) {
				num[j]++;
			}
		}
		long sum = 0;
		for(int i = 1; i <= N; i++) {
			sum += i * num[i];
		}
		System.out.println(sum);
		//System.out.println(Arrays.toString(num));
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
 
}

Measured memory_bytes: 116144
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=120;
int con[N][N],n,m;
int curp,c[N][N];
int S,T;
namespace Flow {
	const int N=220;
	int head[N],cur[N],dep[N];
	struct ed { int to,next,f; };
	vector<ed> e;
	void init() { e.clear(); memset(head,-1,sizeof(head)); }
	void ad(int x,int y,int f) {
//		cout<<"ad"<<x<<' '<<y<<' '<<f<<endl;
		e.PB((ed){y,head[x],f}); head[x]=e.size()-1;
		e.PB((ed){x,head[y],0}); head[y]=e.size()-1;
	}
	queue<int> q;
	bool bfs() {
		memcpy(cur,head,sizeof(cur));
		memset(dep,-1,sizeof(dep));
		while(!q.empty()) q.pop();
		q.push(S),dep[S]=0;
		while(!q.empty()) {
			int u=q.front(); q.pop();
			for(int k=head[u];~k;k=e[k].next) if(e[k].f) {
				int v=e[k].to;
				if(dep[v]==-1) {
					dep[v]=dep[u]+1;
					if(v==T) return 1;
					q.push(v);
				}
			}
		}
		return 0;
	}
	int dfs(int u,int f) {
		if(u==T||!f) return f; int ret=0,tmp;
		for(int &k=cur[u];~k;k=e[k].next) if(e[k].f) {
			int v=e[k].to;
			if(dep[v]==dep[u]+1&&(tmp=dfs(v,min(f,e[k].f)))) {
				e[k].f-=tmp,e[k^1].f+=tmp;
				ret+=tmp,f-=tmp;
				if(!f) break;
			}
		}
		return ret;
	}
	void work() { while(bfs()) dfs(S,1e9); }
	void check() {
		for(int u=1;u<=n;++u) {
//			cout<<u<<':';
			for(int k=head[u];~k;k=e[k].next) if(!e[k].f) {
				int v=e[k].to;
//				cout<<v<<" - "<<k<<' ';
				if(v>=n+1&&v<=2*n) {
					v-=n;
					c[v][curp]=u;
					con[u][v]--;
				}
			}
//			cout<<endl;
		}
	}
}
int C[N][N];
int D[N][N],E[N][N];
vector<int> col[N][N];
int main() {
	 rd(n),rd(m);
	 for(int i=1;i<=n;++i)
	 	for(int j=1;j<=m;++j)
	 		rd(C[i][j]);
	S=2*n+1,T=2*n+2;
	for(int i=1;i<=n;++i) {
		for(int j=1;j<=m;++j) col[i][(C[i][j]-1)/m+1].PB(C[i][j]);
		for(int j=1;j<=m;++j) con[(C[i][j]-1)/m+1][i]=col[i][(C[i][j]-1)/m+1].size();
	}
	for(int i=1;i<=m;++i) {
		curp=i;
		Flow::init();
		for(int j=1;j<=n;++j) for(int k=1;k<=n;++k) if(con[j][k]) Flow::ad(j,k+n,1);
		for(int j=1;j<=n;++j) Flow::ad(S,j,1),Flow::ad(j+n,T,1);
		Flow::work();
		Flow::check();
	}
//	for(int i=1;i<=m;++i,puts(""))
//		for(int j=1;j<=n;++j) printf("%d ",c[j][i]);
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=m;++j) {
			int tmp=col[i][c[i][j]].back();
			col[i][c[i][j]].pop_back();
			printf("%d ",tmp);
			D[(tmp-1)/m+1][j]=tmp;
		}
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=m;++j)
			printf("%d ",D[i][j]);
	return 0;
}

Measured memory_bytes: 1532
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    int N;
    cin>>N;
    int pa=2100000000;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        int cou=0;
        while(!(a%2)){
            a/=2;
            cou++;
        }
        pa=min(pa,cou);
    }
    cout<<pa<<endl;
    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007


int main(){
    int a,b;cin >> a >> b;
    if((a+b)%2!=0){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << (a+b)/2 << endl;
    }
    return 0;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7')
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 3592
{-# LANGUAGE BangPatterns #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as UV

main=B.interact $ B.pack.g.take 2.B.lines
g [!s,!t]=mk "" (ls-1) (lt-1) where
    ls = B.length s
    lt = B.length t
    rd si ti = (bb V.! si) UV.! ti
    mk !as si ti
        | si<0 || ti<0 = as
        | B.index s si == B.index t ti = mk (B.index s si : as) (si-1) (ti-1)
        | rd (si+1) ti > rd si (ti+1) = mk as si (ti-1)
        | otherwise = mk as (si-1) ti
    bb :: V.Vector (UV.Vector Int)
    bb = V.constructN (ls+1) mi where
        mi vi | i==0 = UV.replicate (lt+1) 0 | otherwise = UV.constructN (lt+1) mj where
            i = V.length vi
            mj vij |j==0 = 0 | otherwise = if B.index s (i-1) == B.index t (j-1)
                then 1 + V.last vi UV.! (j-1)
                else max (UV.last vij) (V.last vi UV.! j)
                where j = UV.length vij

Measured memory_bytes: 76028
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
int b=N;
for(int i=1; i<N; i++){
b*=i;
}
vector<int>x(N);
vector<int>y(N);
double count=0;
for(int i=0; i<N; i++){
cin>>x.at(i);
cin>>y.at(i);
}
for(int i=0; i<N; i++){
for(int j=0; j<N; j++){
count+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
}
}
cout<< fixed << setprecision(10) <<count/N<<endl;
}

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

namespace tst
{
    class Program
    {   
        static void InsertionSort(int[] A, int n, int g, ref int cnt)
        {
            for (int i=g ;i<=n-1; i++)
            {
                int v = A[i];
                int j = i - g;
                while (j >= 0 && A[j] > v)
                {
                    A[j + g] = A[j];
                    j -= g;
                    cnt++;
                }
                A[j + g] = v;

            }
        }
        static void ShellSort(int[]A, int n)
        {
            int cnt = 0;
            List<int> G = new List<int>();
            //4倍数配列
            for (int i = 1; i <= n; i *= 4)
            {
                G.Add(i);
            }
            G.Reverse();
            int m = G.Count();
            
            for (int i = 0; i <= m - 1; i++)
            {
                InsertionSort(A, n, G[i], ref cnt);
            }
            //mとG={ , }を表示
            Console.WriteLine(m);
            for (int i = 0; i < m; i++)
            {
                Console.Write((i == 0 ? "" : " ") + G[i]);
            }
            Console.WriteLine();
            Console.WriteLine(cnt);
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(A[i]);
            }
        }
        static void Main(string[] args)
        {
            //nは繰り返しの回数
            int n = int.Parse(Console.ReadLine());
            int[] A = new int[n];
            //n回入力
            for (int i=0; i<n; i++)
            {
                A[i]= int.Parse(Console.ReadLine());
            }

            ShellSort(A, n);
        }
    }
}


Measured memory_bytes: 23636
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n, m; cin >> n >> m;
    vint a(n);
    rep(i, m){
        int x, y; cin >> x >> y;
        x--; y--;
        if(x>y) swap(x, y);
        if(x==0) a[y]++;
        else {a[x]++; a[y]++;}
    }

    int odd = 0;
    rep(i, n){
        if(a[i]%2==1) odd++;
    }

    if(odd==0) pr("YES");
    else pr("NO");
    return 0;}

Measured memory_bytes: 3784
D = int(input())
c = list(map(int, input().split()))
s = []
for k in range(D):
    s.append(list(map(int, input().split())))

#print(s)
ans = [s[0].index(max(s[0]))+1 for k in range(D)]

for k in range(D):
    print(ans[k])

Measured memory_bytes: 9508
n=gets.to_i
tempSumDoll = 0
fourDollCakeMax = (n/4).to_i
sevenDollCakeMax = (n/7).to_i
(0..fourDollCakeMax).each do |fourDollCakeNumber|
  (0..sevenDollCakeMax).each do |sevenDollCakeNumber|
    tempSumDoll = fourDollCakeNumber * 4 + sevenDollCakeNumber * 7
    break if(tempSumDoll >= n)
  end
  break if(tempSumDoll == n)
end
puts tempSumDoll == n ? :Yes : :No

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,d,x;
	vector<int> v;
	cin>>n>>d>>x;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(a);
	}
	int sum=x;
	for(int i=0;i<n;i++){
		int cnt=1,buf=1;
		while(buf*v[i]<d){
			cnt++;
			buf++;
		}
		sum+=cnt;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
mini=999999999
for i in range(100):
    t=0
    for j in range(n):
        t+=pow(x[j]-1-i,2)
        #print(t)
    mini=min(t,mini)
    #print(mini)
    
print(mini)

Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
int n,dp[2003][2003],a[6003],ans,tg,MX[2003],cur;
vector<int>A,B,C;
void add(int x,int y,int z){A.push_back(x),B.push_back(y),C.push_back(z);}
int main(){
	cin>>n;
	for(int i=1;i<=3*n;i++)cin>>a[i]; 
	memset(dp,-1,sizeof(dp));
	memset(MX,-1,sizeof(MX));
	dp[a[1]][a[2]]=dp[a[2]][a[1]]=MX[a[1]]=MX[a[2]]=cur=0;
	for(int i=3;i<3*n;i+=3){
		if(a[i]==a[i+1]&&a[i]==a[i+2]){tg++;continue;}
		A.clear(),B.clear(),C.clear();
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		if(a[i+1]>a[i+2])swap(a[i+1],a[i+2]);
		if(a[i]>a[i+1])swap(a[i],a[i+1]);
		for(int j=1;j<=n;j++){
		if(a[i]==a[i+1])if(dp[j][a[i]]>=0)add(j,a[i+2],dp[j][a[i]]+1);
		if(a[i+1]==a[i+2])if(dp[j][a[i+1]]>=0)add(j,a[i],dp[j][a[i+1]]+1);
		}
		if(dp[a[i]][a[i]]>=0)add(a[i+1],a[i+2],dp[a[i]][a[i]]+1);
		if(dp[a[i+1]][a[i+1]]>=0)add(a[i],a[i+2],dp[a[i+1]][a[i+1]]+1);
		if(dp[a[i+2]][a[i+2]]>=0)add(a[i],a[i+1],dp[a[i+2]][a[i+2]]+1);
		add(a[i],a[i+1],cur),add(a[i+1],a[i+2],cur),add(a[i],a[i+2],cur);
		for(int j=i;j<i+3;j++)for(int k=1;k<=n;k++)if(MX[k]>=0)add(a[j],k,MX[k]);
		for(int j=0;j<(int)A.size();j++)if(dp[A[j]][B[j]]<C[j])
			dp[A[j]][B[j]]=dp[B[j]][A[j]]=C[j],MX[A[j]]=max(MX[A[j]],C[j]),MX[B[j]]=max(MX[B[j]],C[j]),cur=max(cur,C[j]);
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++)if(dp[i][j]>=0)ans=max(ans,dp[i][j]);
		if(dp[i][i]>=0)if(i==a[3*n])ans=max(ans,dp[i][i]+1);
	}
	printf("%d",ans+tg);
}


Measured memory_bytes: 19540
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int n;cin>>n;
 if(n % 1000 == 0) cout << 0 << endl;
 else {
   cout << 1000 - (n % 1000) << endl;
 }



 return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <cmath>
#include <deque>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <iomanip>
using namespace std;
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define pf push_front
#define fs first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,flag=0,sum=0; cin>>n;
    for(ll i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        {
            flag+=1;
        }
        else
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int k;
    cin >> k;
    int x = 7 % k;
    int i = 1;
    set<int> s;
    while(s.count(x) == 0){
        if(x == 0){
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % k;
        i++;
    }
    cout << -1 << endl;
}

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



int main()
{

    string a;
    cin>>a;
    if(a=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(a=="Cloudy")
    {
        cout<<"Rainy"<<endl;

    }
    else if(a=="Rainy")
    {
        cout<<"Sunny"<<endl;

    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    if (A < 10 && B < 10) System.out.println(A * B);
    else {
      System.out.println(-1);
    }
  }
}


Measured memory_bytes: 21844
a,b = map(str,input().split())#整数を文字列として入力
S = a+b
P = S.count("-")
if P == 1:
  print("Zero")
elif P == 2:
  if (int(b) - int(a)) % 2 ==0:
    print("Negative")
  else:
    print("Positive")
else:
  print("Positive")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////



 
int main(){fastio
    //inf=100;//消して！！！！！！！！！！！！！！
    
    ll n,K;cin>>n>>K;
    ll h[n+1];rep(i,1,n)cin>>h[i];h[0]=0;
    ll dp[n+1][n+1][n+1];
    rep(i,0,n)rep(j,0,n)rep(k,0,n)dp[i][j][k]=inf;
    dp[0][0][0]=0;
    rep(i,1,n){
        rep(j,0,n){
            if(j-1>=0)rep(k,0,i-1)dp[i][j][k]=dp[i-1][j-1][k];
            rep(p,0,i-1){
                Min(dp[i][j][i],dp[i-1][j][p]+max(h[i]-h[p],0));
            }
        }
    }
    /*
    rep(i,0,n){
        rep(j,0,n){
            rep(k,0,n){
                cout<<dp[i][j][k]<<" ";
            }cout<<endl;
        }cout<<endl;
    }cout<<endl;
    */
    ll ans=inf;
    rep(j,0,K){
        rep(p,0,n)Min(ans,dp[n][j][p]);
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 213376
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
k = [x for x in range(X+1,N)]
b = [x for x in range(0,X)]
right = 0
left = 0
for i in range(len(A)):
  if A[i] in k:
    right += 1
  elif A[i] in b:
    left += 1
print(min(right,left))

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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define sz(a) (int)a.size()

#define oo 1000000007LL
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 100007

int f[5][maxN];
int a[5][maxN];

int main() {

    int n;
    scanf("%d", &n);

    fto (i, 1, 2) {
        fto (j, 1, n) scanf("%d", &a[i][j]);
    }

    fto (i, 1, 2) {
        fto (j, 1, n) f[i][j] = max(f[i-1][j], f[i][j-1])+a[i][j];
    }

    cout << f[2][n] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

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

  int t[200001];
  Rep(i, N) cin >> t[i];

  int sum = 0;
  for(int i=1; i<N; i++) {
    if( t[i] - t[i-1] <= T ) sum += t[i] - t[i-1];
    else sum += T;
  }

  sum += T;

  cout << sum << endl;
}


Measured memory_bytes: 1792
<?php
$n = int();
$A = ints();
$min = 10**10;
for($i = 1; $i <= 100; $i++){
    $tmp = 0;
    foreach($A as $a){
        $tmp+=($a-$i)**2;
    }
    chmin($min, $tmp);
}
echo $min,"\n";


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

function o(...$val){
    if(count($val)==1)$val = array_shift($val);
    $trace = debug_backtrace();
    echo $trace[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0){
            echo "empty array";
        }elseif(!is_array(current($val))){
            echo "array: ";
            echo implode(" ", addIndex($val))."\n";
        }else{
            echo "array:array\n";
            if(isCleanArray($val)){
                foreach($val as $row)echo implode(" ", addIndex($row))."\n";
            }else{
                foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row))."\n";
            }
        }
    }else{
        echo $val."\n";
    }
}
function addIndex($val){
    if(!isCleanArray($val)){
        $val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);
    }
    return $val;
}
function isCleanArray($array){
    $clean = true;
    $i = 0;
    foreach($array as $k => $v){
        if($k != $i++)$clean = false;
    }
    return $clean;
}
/**
 * 座圧対象の配列を渡すと以下の値を返す
 * ・圧縮された配列
 * ・復元用のMap
 * ・圧縮用のMap
 **/
function atsu($array){
    $a = array_flip($array);
    $fuku = array_flip($a);
    sort($fuku);
    $atsu = array_flip($fuku);
    foreach($array as $i => $val)$array[$i] = $atsu[$val];
    return [$array, $fuku, $atsu];
}
//配列の最大公約数
function gcdAll($array){
    $gcd = $array[0];
    for($i = 1; $i < count($array); $i++){
        $gcd = gcd($gcd, $array[$i]);
    }
    return $gcd;
}

//最大公約数
function gcd($m, $n){
    if(!$n)return $m;
    return gcd($n, $m % $n);
}

//配列の最小公倍数
function lcmAll($array){
    $lcm = $array[0];
    for($i = 1; $i < count($array); $i++){
        $lcm = lcm($lcm, $array[$i]);
    }
    return $lcm;
}

//最小公倍数
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}
//ビットカウント-1の数を数える
function popcount($x){
    $con = 0;
    while ($x) {
        $x &= $x-1;
        ++$con;
    }
    return $con;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int x; cin >> x; 
    int tmp = x / 100;
    int r = x % 100;
    if(r == 0) {
        cout << 1 << endl;
        return 0;
    }
    if(r > tmp * 5) cout << 0 << endl;
    else cout << 1 << endl;
}

Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(i, a, b) for(int i = a; i <= b; i++)
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, b, a) for(int i = b; i >= a; i--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define mem(a, b) memset(a, b, sizeof(a));
#define mem0(a) memset(a, 0, sizeof(a));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(m) repp(i, 1, m){ll a, b; cin >> a >> b; v[a].pb(b), v[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define endl "\n"
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll x;
    cin >> x;
    ll y = x/500;
    x -= y*500;
    y = 1000*y;
    x = x/5;
    x = x*5;
    y += x;
    cout << y;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

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

int main(){
	int n,now,ans=0;
	int lower=1000000;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>now;
		if(lower>=now){
			ans++;
			lower=now;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	int n, m;
	cin >> n >> m;
	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define all(x) x.begin(), x.end()

const int N = 2e5 + 1;
int vis[N], dis[N];
vector<vector<int>> v(N);
//read question carefully!

int ans = 0;
void dfs(int node, int ss)
{
    vis[node] = 1;
    ans++;
    for (int child : v[node])
    {
        if (!vis[child])
        {

            dfs(child, ss);
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;

        // for (int i = 0; i < n; ++i)
        // {
        //     vis[i] = 0;
        //     v[i].clear();
        // }
        for (int i = 0; i < m; ++i)
        {
            int a, b;
            cin >> a >> b;
            v[a].push_back(b);
            v[b].push_back(a);
        }
        vector<int> res;
        for (int i = 1; i <= n; ++i)
        {
            ans = 0;
            if (!vis[i])
            {
                dfs(i, ans);
                res.push_back(ans);
            }
        }
        if (res.size() == 1)
        {
            cout << n << "\n";
        }
        else
        {
            int tot = 0;
            bool f = 1;
            int ma = 0;
            for (int c : res)
            {
                ma = max(c, ma);
            }
            cout << ma << "\n";
        }
    }
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if(a < b){
		if((a < c)&&(c < b)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}else{
		if((b < c)&&(c < a)){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> pri(n);
    for(int i=0; i<n; i++){
        cin>> pri[i];
    }
    sort(pri.begin(),pri.end());
    int sm=0;
    for(int i=0; i<k; i++){
        sm = sm + pri[i];
    }
    cout << sm << endl;
}




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

#include <math.h>
#include <stdlib.h>


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n);
    for(int i= 0; i < n; i++) cin >> a[i];
    int ans = 1;
    int pos = 1;
    int sml= a[0];
    while(pos < n){
        if(a[pos] < sml) ans++;
        sml = min(sml, a[pos]);
        pos++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mpi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x;
	cin >> n >> x;
	int a[n],b[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	for(int i=0;i<n;i++)
	{
		if(b[i]>x)
		{
			b[i] = x;
		}
	}
	for(int i=0;i<n-1;i++)
	{
		if(b[i]+b[i+1]>x)
		{
			b[i+1] = x-b[i];
		}
	}
	lld ans = 0;
	for(int i=0;i<n;i++)
	{
		ans+=(lld)abs(b[i]-a[i]);
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4424
#include<stdio.h>
int main(void)
{
	int a,b,x,m=0,k=0;
	scanf("%d %d %d", &a, &b, &x);
	while(m<x)
	{
		if(a<b*2)
		{
			if(x-m<=500&&a>b)
			{
				m+=500;
				k+=b;
			}
			else
			{
				m+=1000;
				k+=a;
			}
		}
		else
		{
			m+=500;
			k+=b;
		}
	}
	printf("%d\n", k);
	
	return 0;
}


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

void getClosest(int x, ll num, vector<ll> &coins){
	ll cnt = 1;
	ll acc = x;
	while(acc <= num){
		coins.push_back(acc);
		acc = acc*x;
		cnt++;
	}
}

ll sol(vector<ll> &coins, ll num){
	vector<vector<ll>> dp(num+1, vector<ll>(coins.size()+1, 0));
	for(int i=1;i<num+1;i++){
		dp[i][0] = INT_MAX;
	}
	for(int i=1;i<num+1;i++){
		for(int j=1;j<coins.size()+1;j++){
			if(i-coins[j-1] >= 0)
				dp[i][j] = min(dp[i][j-1], dp[i-coins[j-1]][j]+1);
			else
				dp[i][j] = dp[i][j-1];

		}
	}
	return dp[num][coins.size()];
}

int main(){
	long long int n;
	cin >> n;
	if(n < 6){
		cout << n << endl;
		return 0;
	}
	vector<ll> coins;
	coins.push_back(1);
	getClosest(6, n, coins);
	getClosest(9, n, coins);
	cout << sol(coins, n) << endl;


	return 0;
}

Measured memory_bytes: 13568