akhauriyash/Code-Regression huggingface dataset:
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph2 {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	private int[] discover; //discover time stamp, -1 for undiscovered
	private int[] finish; //finish time stamp
	public Graph2() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1; //-1, index
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1; //-1, index
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public int DFS(int v, int t0) {
		discover[v] = t0;
		LinkedList<Integer> nb = adjList.get(v);
		Iterator<Integer> it = nb.iterator();
		int t = t0;
		while(it.hasNext()) {
			int w = it.next();
			if(discover[w] == -1) {
				t ++; //one forward step
				t = DFS(w, t);
			}
		}
		finish[v] = t + 1; //+1 for backtrack step
		return t + 1;
	}
	public void timeStamp() {
		int v;
		discover = new int[totalVertex];
		finish = new int[totalVertex];
		for(v = 0; v < totalVertex; v ++) discover[v] = -1; //-1: not discovered
		int t = 0;
		for(v = 0; v < totalVertex; v ++) {
			if(discover[v] == -1) { //for disconnected graph, restart from an unvisited node
				t = DFS(v, t);
				t ++;
			}
		}
		//display the result
		for(v = 0; v < totalVertex; v ++) {
			System.out.println((v + 1) + " " + (discover[v] + 1) + " " + (finish[v] + 1));
			//+1, node 0 -> 1, 1 -> 2, etc
		}
	}
}

	
public class Main {

	public static void main(String[] args) {
		Graph2 g = new Graph2();
		g.loadAdjList();
		g.timeStamp();

	}

}
//答案


Measured memory_bytes: 28080
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    int idx = 0;
    for (char c : s) {
        if (c == 'A') {
            idx = 1;
        } else if (c == 'B' && idx == 1) {
            idx++;
        } else if (c == 'C' && idx == 2) {
            cnt++;
            idx = 0;
        } else {
            idx = 0;
        }
    }
    OUT(cnt);
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int i,j,n,m;
   
   scanf("%d %d\n",&n,&m);
   
   int a[n][m];
   int b[m];
   int c[n];
   
   for (i=0; i<n; i++)
   {
       for (j=0; j<m; j++)
       {
           scanf("%d ",&a[i][j]);
       }
   }
   
   for (j=0; j<m; j++)
   scanf("%d\n",&b[j]);
   
   for (i=0; i<n; i++)
   c[i] = 0;
   
   for (i=0; i<n; i++)
   {
       for (j=0; j<m; j++)
       {
           c[i] += a[i][j] * b[j];
       }
       
   }
   
   for (i=0; i<n; i++)
   printf("%d\n",c[i]);
   
   return 0;
}


Measured memory_bytes: 2048
r, D, x_2000 = map(int, input().split())

x_2001 = r * x_2000 - D
x_2002 = r * x_2001 - D
x_2003 = r * x_2002 - D
x_2004 = r * x_2003 - D
x_2005 = r * x_2004 - D
x_2006 = r * x_2005 - D
x_2007 = r * x_2006 - D
x_2008 = r * x_2007 - D
x_2009 = r * x_2008 - D
x_2010 = r * x_2009 - D

print(x_2001)
print(x_2002)
print(x_2003)
print(x_2004)
print(x_2005)
print(x_2006)
print(x_2007)
print(x_2008)
print(x_2009)
print(x_2010)

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  string s;
  cin >> s;
  REP(i, 3) {
    if(s[i] == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
  val l = readLine
  val n = readInt

  def transform(i:Int,w:String):Unit = {
    if(i>0) {
      val op = readLine.split(" ")
      val start=op(1).toInt
      val end=op(2).toInt

      (op(0)) match {
        case "replace" => transform(i-1,(w take start) + op(3) + (w takeRight (w.length-end-1)))
        case "reverse" => transform(i-1,(w take start) + (w.slice(start,end+1).reverse) + (w takeRight (w.length-end-1)))
        case "print" => println(w.slice(start, end+1));transform(i-1,w)
      }
    }
  }

  transform(n,l)
}

Measured memory_bytes: 45100
#include <iostream>
#include <cstring>
#include <vector>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define MEM(arr,i) memset(arr,i,sizeof(arr))
#define pb push_back
using namespace std;

struct edge {
    int to,from,money,time;
};

vector<edge> E;
int V;

int d[111];

int wf(int p, int q, bool r){
    FOR(i,0,111)d[i]=100000000;
    d[p]=0;
    while(1){
        bool update=0;
        FOR(i,0,E.size()){
            edge e=E[i];
            int cost=r?e.time:e.money;
            if(d[e.to]>cost+d[e.from]){
                d[e.to]=cost+d[e.from];
                update=1;
            }
        }
        if(!update)break;
    }
    return d[q];
}

int main(){
    int n;
    while(1){
        E.clear();
        cin>>n>>V;
        if(n==0&&V==0) break;
        FOR(i,0,n){
            int a,b,m,t;
            cin>>a>>b>>m>>t;
            E.pb({a,b,m,t});
            E.pb({b,a,m,t});
        }
        int k;cin>>k;
        FOR(i,0,k){
            int p,q,r;
            cin>>p>>q>>r;
            cout<<wf(p,q,r)<<endl;
        }
    }
}

Measured memory_bytes: 1340
#!/usr/bin/env python3

n, k = map(int, input().split())
having_okasi = set()

for _ in range(k):
    d = int(input())
    if d == 1:
        having_okasi.add(input())
    else:
        having_okasi |= (set(input().split()))

print(n - len(having_okasi))

Measured memory_bytes: 9204
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> W >> H;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	int a = 0, b = 0;
	for (auto i : s) {
		for (auto j : i) {
			if (j == 'W')a++;
			else b++;
		}
	}
	vector<int>ans(W + 1);
	ans[0] = a;
	int ra = a, lb = 0;
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (s[j][i] == 'W')ra--;
			else lb++;
		}
		ans[i + 1] = ra + lb;
	}
	int ret = 0;
	for (int i = 0; i <= W; i++) {
		if (ans[ret] > ans[i])ret = i;
	}
	cout << ret << " " << ret + 1 << endl;
}


Measured memory_bytes: 4552
#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
#pragma GCC target (sse, sse2, sse3, ssse3, sse4,popcnt,tune=native)

#include <bits/stdc++.h>

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define loop(i, n) for(int i=0; i<n; i++)
#define CIN   ios_base::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define SZ(a) (int)(a.size())
#define Read() freopen("input.cpp", "r", stdin)
#define Write() freopen("output.cpp", "w", stdout)
#define mem(a, v) memset(a, v, sizeof(a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Unique(x)  x.erase(unique(all(x)), x.end())
#define pi acos(-1.0)
#define vec vector
#define mp make_pair
#define paii pair<int, int>
#define padd pair<dd, dd>
#define pall pair<ll, ll>
#define fr first
#define sc second
//#define endl "\n"
#define vec vector

using namespace std;

#define int long long

const int MAXN = 2e5 + 47, inf = 1e17;

int n;

void read() {
    cin >> n;
}

void solve() {
    vec<vec<int> > comp((n + 1) / 2);
    if(n % 2 == 0) loop(i, SZ(comp)) comp[i].pb(i + 1), comp[i].pb(n - i);
    else {
        loop(i, SZ(comp) - 1) comp[i].pb(i + 1), comp[i].pb(n - i - 1);
        comp.back().pb(n);
    }/*
    for(auto &a :comp) {
        for(int &c : a) cout << c << " ";
        cout << endl;
    }*/

    vec<paii> ans;
    loop(a, SZ(comp)) {
        for(int p1 : comp[a]) {
            FOR(b, a + 1, SZ(comp)) {
                for(int p2 : comp[b]) ans.pb({p1, p2});
            }
        }
    }
    cout << SZ(ans) << endl;
    for(paii &p : ans) cout << p.fr << " " << p.sc << endl;
}

signed main() {
    #ifdef COFFEE_MACHINE
        Read();
        Write();
    #endif
    CIN;

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
ll nCr(ll n, ll r) 
{ 
    long long p = 1, k = 1;
    if (n - r < r) 
        r = n - r; 
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            long long m = __gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        }
    } 
    else
        p = 1; 
  
    return p;
} 
int main()
{
   Fast;
   int l;
   cin>>l;
   cout<<fixed<<setprecision(12)<<(double)(l*l*l)/27;
   
   XXX;
}




Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const double pi=acos(-1);

int main(){
  double a,b,c;
  cin>>a>>b>>c;
  
  double s,l,h;
  s=a*b*sin(c*pi/180)/2;
  l=a+b+sqrt(a*a+b*b-2*a*b*cos(c*pi/180));
  h=2*s/a;
  
  cout<<fixed<<setprecision(10)<<s<<endl;
  cout<<fixed<<setprecision(10)<<l<<endl;
  cout<<fixed<<setprecision(10)<<h<<endl;

  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define mat vector<vec>

using namespace std;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll n,y;
  cin >> n >> y;

  for(ll i=0;i<2001;i++){
    for(ll j=0;j<2001;j++){
      if(i+j>n)continue;
      if(10000*i+5000*j+1000*(n-i-j)==y){
        cout << i << " " << j << " " << n-i-j <<  endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 3624
//前置き
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef  long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main(){
    // ========================================================
    int a;
    cin >> a;
    cout << a * a << endl;
}

//最大公約数
ll gcd(ll a, ll b) {  
    if (!b)  
        return a;  
    return gcd(b, a%b);  
}

//最小公倍数
ll lcm(ll a, ll b) {  
    return a*b/gcd(a,b);  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    string N, M;
    cin >> N >> M;
    rep(i,0,M.size())cout<<N[i]<<M[i];
    if(N.size()>M.size())cout<<N[N.size()-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
inline int read()
{
	rg int res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int A, B;
int main()
{
	cin >> A >> B;
	if(B==1)
		puts("0");
	else
		cout << (B - 2) / (A - 1) + 1 << endl;
	return 0;
}
//B

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
count = 0

for i in range(N):
    x -= a[i]
    if 0 < x:
        if i != N-1:
            count += 1
    elif x == 0:
        count += 1
        break
print(count)


Measured memory_bytes: 2940
N=int(input())
S=[input() for i in range(N)]
BXA=0;XA=0;BX=0;ans=0;
for s in S:
  ans+=s.count("AB")
  if(s[0]=='B' and s[-1]=='A'):
    BXA+=1
  elif(s[0]=='B'):
    BX+=1
  elif(s[-1]=='A'):
    XA+=1
#print(ans,min([XA,BX]))
if min([XA,BX])>0:
  ans+=min([XA,BX])+BXA
elif max([XA,BX])>0:
  ans+=BXA
else:
  ans+=max([BXA-1,0])
print(ans)
  
    

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

const ll MOD = (ll) 1e9 + 7;
const ll MAXN = (ll) 2e5 + 10;
const ll INF = (ll) 2242545357980376863;
const ld EPS = (ld) 1e-8;

map<ll, ll> mp;
ll a[MAXN];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> a[i];
		mp[a[i]] ++;
	}
	sort(a , a + n);
	reverse(a, a + n);
	ll ans = 0, v;
	for(int i = 0; i<n;i++){
		if(mp[a[i]] == 0) continue;
		
		v = 1;
		while(v <= a[i]){
			v *= 2ll;
		}
		mp[a[i]] --;
		if(mp[v-a[i]] >= 1){
			ans ++;
			mp[v-a[i]]--;
		} else mp[a[i]] ++;
	}
	cout << ans;
	return 0;
}


/*
                                 ____              ,----..               ,----..
   ,---,                       ,'  , `.           /   /   \             /   /   \
  '  .' \                   ,-+-,.' _ |          /   .     :           /   .     :
 /  ;    '.              ,-+-. ;   , ||         .   /   ;.  \         .   /   ;.  \
:  :       \            ,--.'|'   |  ;|        .   ;   /  ` ;        .   ;   /  ` ;
:  |   /\   \          |   |  ,', |  ':        ;   |  ; \ ; |        ;   |  ; \ ; |
|  :  ' ;.   :         |   | /  | |  ||        |   :  | ; | '        |   :  | ; | '
|  |  ;/  \   \        '   | :  | :  |,        .   |  ' ' ' :        .   |  ' ' ' :
'  :  | \  \ ,'        ;   . |  ; |--'         '   ;  \; /  |        '   ;  \; /  |
|  |  '  '--'          |   : |  | ,             \   \  ',  /          \   \  ',  /
|  :  :                |   : '  |/               ;   :    /            ;   :    /
|  | ,'                ;   | |`-'                 \   \ .'              \   \ .'
`--''                  |   ;/                      `---`                 `---`
                       '---'

*/



Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll K,T;
    cin >> K >> T;
    vector<ll> a(T);
    priority_queue<Pll> que;
    rep(i,T){
        cin >> a[i];
        que.push(make_pair(a[i],i));
    }
    ll cnt = 0;
    ll prev = -1;
    rep(i,K){
        auto p = que.top();
        if(prev == p.second){
            que.pop();
            if(!que.empty()){
                auto q = que.top();
                que.pop();
                if(q.first > 1){
                    que.push(make_pair(--q.first, q.second));
                }
                que.push(p);
                prev = q.second;
            }else{
                cnt++;
                if(p.first > 1){
                    que.push(make_pair(--p.first,p.second));
                }
                prev = p.second;
            }
        }else{
            que.pop();
            if(p.first > 1){
                que.push(make_pair(--p.first,p.second));
            }
            prev = p.second;
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 256
import itertools
x = int(input())
digits = len(str(x))
dic = {}
keta = []
for i in range(121):
    num = i ** 5    
    if (num > 10**(digits+2)):
        break
    if num > 10**(digits-2):
        dic[i] = num
        dic[-i] = -num
    elif num < 10**(digits+1):
        dic[i] = num
        dic[-i] = -num
        
for num1,num2 in itertools.combinations(dic.keys(), 2):
    a, b = dic[num1], dic[num2]
    if x == (a-b):
        ans = (num1,num2)
        break
    if x == (-a+b):
        ans = (num2,num1)
        break
print(f"{ans[0]} {ans[1]}")

Measured memory_bytes: 9236
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem0140 : Bus Line **/
int main()
{
	int N; cin>>N;
	int p1[] = {6, 7, 8, 9, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0};
	
	rep(z, N) {
		int s, t; cin>>s>>t;
		
		int ans=INF, a=-1, b=-1;
		for (int i=0; i<25; i++) {
			if (p1[i]==s) {
				int tt=1;
				for (int j=i; j<25; j++) {
					if (p1[j]==t) {
						if (ans>tt) {
							ans = tt;
							a = i;
							b = i+tt;
						}
						break;
					}
					tt++;
				}
			}
		}
		
		
		for (int i=a; i<b; i++) {
			if (i!=a) cout<<" ";
			cout << p1[i];
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
int a[maxn];
ll c=1e9+7;
ll qpow(ll a,ll b)
{
    ll res=1;
    while(b)
    {
        if(b&1)
            res=res*a%c;
        a=a*a%c;
        b>>=1;
    }
    return res;
}
int main()
{
    int n;
    scanf("%d",&n);
    int x;
    for(int i=0; i<n; i++)
    {
        scanf("%d",&x);
        a[x]++;
    }
    ll ans=0;
    int flag=0;
    if(n%2)
    {
        if(a[0]!=1)flag=1;
        else
        {
            for(int i=2;i<=n;i+=2)
            {
                if(a[i]!=2)
                {
                    flag=1;break;
                }
            }
            if(flag==0)ans=qpow(2,n/2);
        }
    }
    else
    {
            for(int i=1;i<=n;i+=2)
            {
                if(a[i]!=2)
                {
                    flag=1;break;
                }
            }
            if(flag==0)ans=qpow(2,n/2);
    }

    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const int INF = int(1e9);
const int N_MAX = int(1e4) + 10;

int N,M;
int A[13];
int X[13]; // i番目のマッチに必要な本数
// digit[i] 数字iに必要なマッチ (0はダミー)
int digit[] = {INF,2,5,5,4,5,6,3,7,6};

int dp[N_MAX]; // i本のマッチを(ちょうど)使って作れる最大桁数

int main()
{
  cin >> N >> M;
  REP(i,0,M) cin >> A[i];
  sort(A,A+M,greater<int>()); // 後のために並び替え
  REP(i,0,M) X[i] = digit[A[i]];

  // // X[i] を表示
  // REP(i,0,M) cout << X[i] << ", ";
  // cout << endl;

  // 配列dpの計算
  dp[0] = 0;
  // dp[1]以降を順に決定
  REP(i,1,N+1) {
    // dp[i]を求める (更新できなければ-INFのまま)
    dp[i] = -INF;
    REP(j,0,M) {
      // 数字A[j]を使う
      if (i - X[j] >= 0) dp[i] = max(dp[i], dp[i-X[j]] + 1);
    }
  }

  // // 答えの桁数はdp[N]
  // cout << dp[N] << endl;

  // 上位から決定(できるだけ大きい数字を上位の桁に使う)
  // dp[N]桁を順に決定していく
  int cnt = N;  // 残りのマッチ本数
  REP(i,0,dp[N]) {
    REP(j,0,M) {
      // 大きい数字A[j]から使えるか試す
      if (cnt-X[j] >= 0 && dp[cnt-X[j]] == dp[cnt] - 1) {
        // 数字A[j] が使える
        cout << A[j];
        cnt -= X[j];  //マッチを減らす
        break;
      }
    }
  }
  // cnt == 0 になるはず
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,m,ans;
int a[111111];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	int sum=0;
	rep(i,n){
		if(a[i]==0){
			ans+=sum/2;
			sum=0;
		}
		else{
			sum+=a[i];
		}
	}
	ans+=sum/2;
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#define ALP_SIZE 27
using namespace std;

char alps[ALP_SIZE] = "abcdefghijklmnopqrstuvwxyz";

int kind_str(string a, string b){
	int i;
	int number = 0;
	for(i=0;i<ALP_SIZE;i++){
		if(	a.find(alps[i]) != string::npos
		 && b.find(alps[i]) != string::npos){
			number++;
		}
	}
	return number;
}

int min(int a, int b){
	if(a>=b){
		return b;
	}else{
		return a;
	}
}

int max(int a, int b){
	if(a<=b){
		return b;
	}else{
		return a;
	}
}

int main(){
	int N;
	string S;
	cin >> N;
	cin >> S;
	int i;
	int kind_max = 0;
	for(i=0;i<N;i++){
		string before = S.substr(0, i);
		string after = S.substr(i, N - i);
		int kind_number = kind_str(before, after);
		kind_max = max(kind_max, kind_number);
	}

	cout << kind_max << endl;
	return 0;
}


Measured memory_bytes: 256
n, x = 0, 0
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  int a[n];
  map<int,int> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    int plus = i + a[i];
    int minus = i - a[i];
    mp[plus]++;
    ans += mp[minus];
  }
  COUT(ans);
  return 0;
}

Measured memory_bytes: 21324
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int A[26] = { 0 };
string S[60];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> S[i];
	int count[60][26] = { 0 };
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < S[i].size(); j++) {
			count[i][(S[i][j] - 'a')]++;
		}
	}
	int min = mod;
	for (int i = 0; i < 26; i++) {
		min = mod;
		for (int j = 0; j < n; j++) {
			if (count[j][i] < min)min = count[j][i];
		}
		A[i] = min;
	}
	string ans;
	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < A[i]; j++) {
			ans.push_back((char)i + 'a');
		}
	}
	cout << ans << endl;
}


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

int main() {
	int n = 0;
	cin >> n;
	vector<int> ans(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> ans[i];
	}
	vector<int> res(n, 0);
	int index = 0;
	for (int i = n - 1; i >= 0; i-= 2) {
		res[index] = ans[i];
		if (i - 1 >= 0) {
			res[n - 1 - index] = ans[i - 1];
		}
		index += 1;
	}
	for (int i = 0; i < n; i++) {
		cout << res[i] << " ";
	}
}

Measured memory_bytes: 3712
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort(key=lambda x:x[0]+x[1], reverse=True)
ans = 0
for i in range(n):
  if i % 2:
    ans -= l[i][1]
  else:
    ans += l[i][0]
print(ans)

Measured memory_bytes: 32224
#include<iostream>
#include<string>
using namespace std;
string ADD(string, string);
string MULTIPLE(string, string);
string ADD(string a, string b)
{
	string res = "";
	int carryitem = 0;
	int nowitem = 0;
	int a_len = a.length(), b_len = b.length();
	if (a_len < b_len)
	{
		swap(a, b);
		a_len = a.length();
		b_len = b.length();
	}
	for (int i = a_len - b_len; i > 0; --i)
	{
		b = '0' + b;
	}
	for (int i = a_len - 1; i >= 0; --i)
	{
		nowitem = a[i] + b[i] - 2 * '0' + carryitem;
		carryitem = nowitem / 10;
		nowitem %= 10;
		res = static_cast<char>(nowitem + '0') + res;
	}
	if (carryitem)
	{
		res = static_cast<char>(carryitem + '0') + res;
	}
	return res;
}
string MULTIPLE(string a, string b)
{
	string res = "";
	int a_len = a.length(), b_len = b.length();
	if (a_len < b_len)
	{
		swap(a, b);
		a_len = a.length();
		b_len = b.length();
	}

	for (int i = b_len - 1; i >= 0; --i)
	{
		string tmp = "";
		for (int j = 0; j < b[i] - '0'; j++)
		{
			tmp = ADD(tmp, a);
		}
		for (int k = 0; k < b_len - i - 1; k++)
		{
			tmp += '0';
		}
		res = ADD(res, tmp);
	}
	return res;
}

int main()
{

	long long  a; double b;
	cin >> a;
	cin >> b;

	long long k = (b) * 100 + 0.5;


	long long ans = a * k;

	cout << ans / 100;
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;


int main(){

    int n;
    cin>>n;

    long long load[n][n];

    rep(i,n)rep(k,n)cin>>load[i][k];
    bool one_path[n][n]={};

    rep(j,n){
        rep(i,n){
            rep(k,n){
                //最短経路のはずのload[i][k]が
                //他の都市を経由したものより長ければ
                //条件を満たす道路は存在しない
                if(load[i][k]>load[i][j]+load[j][k]){
                    cout<<"-1"<<endl;
                    return 0;
                }
                else if(load[i][k]==load[i][j]+load[j][k] && i!=j && j!=k){
                    //他の辺を経由していたら数えない
                    one_path[i][k]=true;
                }   
            }
        }
    }
    long long ans=0;

    for(int i=0;i<n;i++){
        for(int k=i+1;k<n;k++){
            //他の辺を経由していないければ道路の長さを追加
            if(!one_path[i][k]){
                ans+=load[i][k];
            }
        }
    }
    cout<<ans<<endl;

    return 0;

}
/*


*/


Measured memory_bytes: 1024
from collections import defaultdict, deque

N, M = map(int, input().split())
indeg = defaultdict(int)
E = defaultdict(list)
parent = defaultdict(list)
for _ in range(N+M-1):
    a, b = map(int, input().split())
    indeg[b] += 1
    E[a].append(b)
    parent[b].append(a)

q = deque([v for v in range(1, N+1) if indeg[v] == 0])
top_sort = []
while q:
    v = q.popleft()
    top_sort.append(v)
    for u in E[v]:
        indeg[u] -= 1
        if indeg[u] == 0:
            q.append(u)
            
max_path_len = defaultdict(int)
max_path_parent = defaultdict(int)
for v in top_sort:
    if len(parent[v]) == 0:
        max_path_parent[v] = 0
        continue
    for u in parent[v]:
        if max_path_len[v] < max_path_len[u] + 1:
            max_path_len[v] = max_path_len[u] + 1
            max_path_parent[v] = u

for v  in max_path_parent.values():
    print(v)

Measured memory_bytes: 74308
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX_INPUT_SIZE  1024
#define INPUT_FROM_FILE

int* createArray(int size, char* input);
void insertionSort(int size, int* array);
void trace(int size, int* array);

int
main(int argc, char* argv[])
{
    char input[MAX_INPUT_SIZE];

    int size = atoi(fgets(input, sizeof(input), stdin));

    while ((fgets(input, sizeof(input), stdin)) != NULL) {
        int* array = createArray(size, input);
        insertionSort(size, array);

        if (array != NULL) {
            delete [] array;
        }
    }

    return 0;
}


int*
createArray(int size, char* input)
{
    int* array = new int[size];

    if (array != NULL) {
        for (int i = 0; i < size; i++) {
            array[i] = i == 0 ?
                atoi(strtok(input, " ")) : atoi(strtok(NULL," "));
        }
    }

    return array;
}

void
insertionSort(int size, int *array)
{
    for (int i = 0; i < size; i++) {
        int curNum = array[i];
        for (int j = 0; j < i; j++) {
            if (curNum < array[j]) {
                int blockSize = (i - j) * sizeof(int);
                int* tmpBlock = new int[blockSize];
                if (tmpBlock == NULL) {
                    fprintf(stderr, "Error, no memory error");
                } else {
                    memcpy(tmpBlock, &array[j], blockSize);
                    memcpy(&array[j+1], tmpBlock, blockSize);
                    array[j] = curNum;

                    delete[] tmpBlock;
                }
                break;
            }
        }
        trace(size, array);
    }
}

void
trace(int size, int* array)
{
    for (int i = 0; i < size; i++) {
        if (i != 0) printf(" ");
        printf("%d", array[i]);
    }
    printf("\n");
}

Measured memory_bytes: 1016
n = int(input())
points = [list(map(int, input().strip().split())) for i in range(n)]
dp = [points[0]]

for i in range(1, n):
    dp.append([
        max(dp[-1][1] + points[i][0], dp[-1][2] + points[i][0]),
        max(dp[-1][0] + points[i][1], dp[-1][2] + points[i][1]),
        max(dp[-1][0] + points[i][2], dp[-1][1] + points[i][2]),
        ])

print(max(dp[-1]))



Measured memory_bytes: 50004
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main(void){
  long long int n; cin >> n;
  int k;
  if(n % 11 == 0) k = 0;
  else if(n % 11 >= 7) k = 2;
  else            k = 1;
  cout << ((n / 11) * 2) + k << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, A;
  bool f = true;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A;
    if (A % 2 == 0) {
      if (A % 3 != 0 && A % 5 != 0) {
        f = false;
      }
    }
  }
  if (f) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    rep(i,n-1){
        ans += i + 1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int ans = n;
    for (int i = 0; i <= n; i++) {
        int t6 = i, t9 = n - i;

        int c = 0;
        while (t6) {
            c += t6 % 6;
            t6 /= 6;
        }

        while (t9) {
            c += t9 % 9;
            t9 /= 9;
        }

        ans = min(ans, c);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

template <typename T> T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; }
template <typename T> T lcm(T a, T b) { return a / gcd(a,b) * b; }

ll N, M;
string S, T;

signed main()
{
    cin >> N >> M >> S >> T;

    ll L = lcm(N, M);
    map<ll, char> str;  // 答えの sparse な文字列
    ll n = 0;
    while(n * L / N < L) {
        ll ind = n * L / N;
        str[ind] = S[n];
        n++;
    }
    ll m = 0;
    while(m * L / M < L) {
        ll ind = m * L / M;
        if(str.count(ind) != 0 && str[ind] != T[m]) {
            printf("-1\n");
            return 0;
        }
        m++;
    }
    printf("%lld\n", L);
    return 0;
}


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

int main() {
	int ret=1;
	int n,a,sgn=0; cin>>n>>a;
	for(int i=1; i<n; i++) {
		int b;
		cin>>b;
		if(b==a)
			continue;
		if(sgn) {
			if(sgn*(a-b)>0)
				sgn=0, ret++;
		} else sgn=b>a?1:-1;
		a=b;
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> nums(100000+1,0);
    REP(i,n){
        int ai=0;
        cin >> ai;

        if(ai==0){
            nums[ai]+=1;
            nums[ai+1+1]-=1;
        }
        else if(ai==100000-1){
            nums[ai-1]+=1;
            nums[ai+1]-=1;
        }
        else{
            nums[ai-1]+=1;
            nums[ai+1+1]-=1;
        }
    }
    REP(i,100002) nums[i+1]+=nums[i];
    int ma = -1;
    REP(i,100001) ma = max(ma, nums[i]);
    cout << ma << endl;
    return 0;
}

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

int main(){
	priority_queue<int,vector<int>,greater<int> >que;
	vector<int> vec;
	int n,p;
	while(cin>>n){
		if(n==0)break;
		for(int j=0;j<n;j++){
			cin>>p;
			que.push(p);
		}
		int sum=0;
		int size=que.size();
		for(int i=0;i<size;i++){
			vec.push_back(sum);
			sum+=que.top();
			que.pop();
		}
		long long ans=0;
		int vsize=vec.size();
		for(int i=0;i<vsize;i++){
			ans+=vec[i];
		}
		while(!vec.empty())vec.pop_back();
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1316
N = int(input())
A, B = map(int, input().split())

L = list(map(int, input().split()))


ans = [0, 0, 0]
for i in L:
    if i <= A:
        ans[0] += 1
    elif i >= A + 1 and i <= B:
        ans[1] += 1
    else:
        ans[2] += 1

print(min(ans))

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())

if n == 1 and m == 1:
    print(1)
elif min(n, m) == 1 and max(n, m) >= 3:
    print(max(n, m) - 2)
else:
    print(max(n - 2, 0) * max(m - 2, 0))

Measured memory_bytes: 9236
# D - Knight

X, Y = map(int, input().split())
####

a = (2*Y - X) / 3
b = (2*X - Y) / 3

# https://qiita.com/derodero24/items/91b6468e66923a87f39f
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] % mod * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

if a%1 != 0 or b%1 != 0:
    print(0)
else:
    ans = cmb(int(a+b), int(min(a,b)), mod)
    print(ans)


Measured memory_bytes: 122016
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000003
   
int main(){
	int h,w,sx,sy,ex,ey,i,j,x,y;
	pair<int,int> t;
	cin>>h>>w;
	cin>>sx>>sy;
	cin>>ex>>ey;
	sx--;
	sy--;
	ex--;
	ey--;
	vector<vector<char>> board(h,vector<char>(w));

	for(i=0;i<h;i++){
		for(j=0;j<w;j++)
			cin>>board[i][j];
	}

	vector<vector<int>> dist(h,vector<int>(w));
	for(i=0;i<h;i++)
		for(j=0;j<w;j++)
			dist[i][j]=1e7;

	deque<pair<int,int>> q;
	q.push_front({sx,sy});
	dist[sx][sy]=0;
	int movex[]={0,-1,0,1};
	int movey[]={-1,0,1,0};
	while(!q.empty()){
		t=q.front();
		q.pop_front();
		
		for(i=0;i<4;i++){
			x=t.first+movex[i];
			y=t.second+movey[i];
			if(x<0 || x>=h || y<0 || y>=w || board[x][y]=='#')
				continue;
			if(dist[x][y] > dist[t.first][t.second]){
				dist[x][y]=dist[t.first][t.second];
				q.push_front({x,y});
			}
		}

		for(i=t.first-2;i<=t.first+2;i++){
			for(j=t.second-2;j<=t.second+2;j++){
				if(i<0 || i>=h || j<0 || j>=w || (i==t.first && j==t.second) ||board[i][j]=='#')
					continue;
				if(dist[i][j] > dist[t.first][t.second]+1){
					dist[i][j]=dist[t.first][t.second]+1;
					q.push_back({i,j});
				}
			}
		}
	}

	int ans = (dist[ex][ey]>=1e7)?-1:dist[ex][ey];
	cout<<ans<<endl;
}

Measured memory_bytes: 8560
#include<bits/stdc++.h>
using namespace std;
int gcd(int a ,int b){
  if(a==0)return b;
  return gcd(b%a,a);
}
int main()
{
  int k;
  cin>>k;
  int answer=0;
  for(int i = 1; i <= k ; i++){
    for(int j = 1 ; j <= k ; j++){
      for(int l = 1 ; l <= k ; l++ ){
        int m=gcd(i,j);
        answer+=gcd(m,l);
      }
    }
  }
  cout<<answer;
}


Measured memory_bytes: 3608
function Main(input) {
  lines = input.split("\n")
  n = lines[0] * 1
  v = lines[1].split(' ')
  c = lines[2].split(' ')
  ans = 0
  for(var i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) {
      ans = ans + (v[i] - c[i])
    }
  }
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <cstdio>
using namespace std;
typedef long long ll;
const int N=300010;
const int MOD=998244353;
int n;
ll a,b,k;
int fact[N],iact[N];
void readData(){
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
}
int fmi(int x,int y){
	int res=1;
	for(;y;x=1ll*x*x%MOD,y>>=1)
		if(y&1)
			res=1ll*res*x%MOD;
	return res;
}	
void init(){
	fact[0]=fact[1]=1;
	for(int i=2;i<=n;i++) fact[i]=1ll*fact[i-1]*i%MOD;
	iact[0]=iact[1]=1;
	iact[n]=fmi(fact[n],MOD-2);
	for(int i=n-1;i>=2;i--) iact[i]=1ll*iact[i+1]*(i+1)%MOD;
}
inline int C(int n,int m){
	return m<=n?1ll*fact[n]*iact[m]%MOD*iact[n-m]%MOD:0;
}
void solve(){
	int ans=0;
	for(ll x=0,y;x<=n&&a*x<=k;x++)
		if((k-a*x)%b==0){
			y=(k-a*x)/b;
			if(y<=n)
				(ans+=1ll*C(n,x)*C(n,y)%MOD)%=MOD;
		}
	printf("%d\n",ans<0?ans+MOD:ans);
}
int main(){
	readData();
	init();
	solve();
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
	string S;
	bool flag = true;
	bool al[26];
	for (size_t i = 0; i < 26; i++) {
		al[i] = true;
	}
	std::cin >> S;
	for (size_t i = 0; i < S.size(); i++) {
		al[S[i] - 'a'] = false;
	}
	for (size_t i = 0; i < 26; i++) {
		if (al[i]) {
			char x = 'a' + i;
			std::cout << x << '\n';
			flag = false;
			break;
		}
	}
	if (flag) {
		std::cout << "None" << '\n';
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;

int main(){
    int n,m;cin>>n>>m;
    vector<int> ans(n,1);
    vector<ll> h(n);
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<m;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        if(h[a]>h[b]) ans[b]=0;
        else if(h[b]>h[a]) ans[a]=0;
        else{
            ans[a]=0;
            ans[b]=0;
        }
    }
    int ANS=0;
    for(int i=0;i<n;i++){
        ANS+=ans[i];
    }
    cout<<ANS<<endl;
}

Measured memory_bytes: 4516
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 200005;
typedef pair<int, int> pii;

int N, fa[MAX_N];
bool vis[MAX_N], on[MAX_N];

vector<int> G[MAX_N], cir;

void find_circle(int u) {
  static bool pass[MAX_N];
  vis[u] = 1, pass[u] = 1;
  for (int v : G[u]) 
    if (!vis[v]) {
      find_circle(v);
    } else if (pass[v]) {
      int temp = u;
      while (true) {
	cir.push_back(temp), on[temp] = 1;
	if (temp == v) break;
	temp = fa[temp];
      }
    }
  pass[u] = 0;
}

pii SG[MAX_N];

void dfs(int u) {
  static int stamp, mex[MAX_N];
  for (int v : G[u]) 
    if (!on[v]) {
      dfs(v);
    }

  ++stamp;
  if (!on[u]) {
    for (int v : G[u])
      if (!on[v])
	mex[SG[v].first] = stamp;
    SG[u].first = 0;
    while (mex[SG[u].first] == stamp) SG[u].first++;
  } else {
    for (int v : G[u]) 
      if (!on[v])
	mex[SG[v].first] = stamp;
    SG[u].first = 0;
    while (mex[SG[u].first] == stamp) SG[u].first++;
    SG[u].second = SG[u].first + 1;
    while (mex[SG[u].second] == stamp) SG[u].second++;
  }
}

int value[MAX_N];

bool solve(int x) {
  int sz = cir.size();
  value[0] = x;
  
  for (int i = 1; i < sz; ++i) {
    if (value[i - 1] != SG[cir[i]].first) value[i] = SG[cir[i]].first;
    else value[i] = SG[cir[i]].second;
  }

  return value[sz - 1] != value[0];
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &fa[i]);
    G[fa[i]].push_back(i);
  }

  for (int i = 1; i <= N; ++i)
    if (!vis[i]) find_circle(i);

  for (int u : cir) 
    dfs(u);

  if (solve(SG[cir[0]].first) || (solve(SG[cir[0]].second) && value[cir.size() - 1] == SG[cir[0]].first)) {
    puts("POSSIBLE");
  } else {
    puts("IMPOSSIBLE");
  }
  
  return 0;
}


Measured memory_bytes: 24948
using System;
using System.Collections;

public class p0006
{
	p0006(){
		string str;
		char[] ch;
			
		while((str = Console.ReadLine()) != null){
			ch = str.ToCharArray();
			Array.Reverse(ch);
			Console.WriteLine(ch);
		}
	}
	
	public static int Main(string[] args){
		new p0006();
		return 0;
	}
}

Measured memory_bytes: 5264
/************************************************************
	> File Name: e.cpp
	> Author: TSwiftie
	> Mail: 2224273204@qq.com 
	> Created Time: Sun 31 May 2020 08:38:21 PM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int N = 2e5+10;
int a[N],b[N],n;
int gcd1(int a,int b){
	return b?gcd1(b,a%b):a;
}
int mul(int a,int b,int p){
	int res = 0;
	while(b){
		if(b&1) res = (res + a) % p;
		a = (a+a)%p;
		b >>= 1;
	}
	return b;
}
int ksm(int a,int b,int p){
	int res = 1;
	while(b){
		if(b&1) res = a * res % p;
		a = a * a % p;
		b >>= 1;
	}
	return res;
}
signed main(void){
	IOS;
	cin >> n;
	for(int i = 0;i < n;++i) cin >> a[i] >> b[i];
	sort(a,a+n);
	sort(b,b+n);
	if(n&1) cout << b[n/2]-a[n/2]+1 << endl;
	else cout << b[(n-1)/2]+b[(n+1)/2]-a[(n-1)/2]-a[(n+1)/2]+1 << endl;
	return 0;
}


Measured memory_bytes: 5220
n,k = map(int, input().split())
l = list(map(int,input().split()))
ok = max(l)
ng = 0

def solver(x):
    cnt = 0
    for logs in l:
        if logs % x == 0:
            cnt += (logs // x) -1
        else:
            cnt += logs// x
    if cnt <= k:
        return True
    else:
        return False

while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if solver(mid) == True:
        ok = mid
    else:
        ng = mid

print(ok)


Measured memory_bytes: 94144
import numpy as np
N = int(input())
Cord = np.zeros((N,2),dtype=int)
for T in range(0,N):
    Cord[T] = np.array([int(x) for x in input().split()])
Dist = 0
for T in range(0,N):
    for TT in range(T+1,N):
        Dist += np.linalg.norm(Cord[T,:]-Cord[TT,:])
print(Dist*2/N)

Measured memory_bytes: 27208