akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static final int mod = (int)1e9 + 7;
	
	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int[] fac = new int[100001];
		fac[0] = 1;
		for(int i = 1; i <= 100000; ++i)
			fac[i] = (int)(1l * fac[i - 1] * i % mod);
		int N = sc.nextInt(), M = sc.nextInt();
		if(Math.abs(N - M) > 1)
			out.println(0);
		else
		{
			long ans = (int)(1l * fac[N] * fac[M] % mod);
			if(N == M)
				ans = ans * 2 % mod;
			out.println(ans);
 		}
		
		out.close();
	}
		
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(String s) throws FileNotFoundException{	br = new BufferedReader(new FileReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

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

		public boolean ready() throws IOException {return br.ready();} 
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define loop(i,a,b) for (int i=a; i<b; ++i)
using ll = long long;
const int mod = 998244353;
typedef pair<int , int> pairs;
typedef complex<ll> G;

const int N = 2e5 + 5;

int power(int a,int b){
    if(!b)
        return 1;
    int c=power(a,b/2);
    c=(1LL*c*c)%mod;
    if(b%2)
        c=(1LL*c*a)%mod;
    return c;
}


vector<int>adj[N];
vector<int>ans(N+1, 0);
void dfs(int s, int e) {
    ans[s] = 1;
    for(auto u : adj[s]) {
        if(u == e)continue;
        dfs(u, s );
        ans[s] += ans[u];
    }
}
void done() {

    int n;
    cin >> n;
    for(int i = 0;i < n-1;++i) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    dfs(1, 0);
    for(int i = 1;i < n+1;++i) {
        cout << ans[i] << " ";
    }


}

/*string solve_palindrome(const string& s)
{
    string a = s;
    reverse(a.begin(), a.end());
    //a = s + "#" + a;
    int c = 0;
    for (int i = 1; i < (int)a.size(); i++)
    {
        while (c != 0 && a[c] != a[i])
            c = pref[c - 1];
        if (a[c] == a[i])
            c++;
        pref[i] = c;
    }
    return s.substr(0, c);
}
*/


void solve()
{
    int n;
    cin >> n;
    vector<int>a(n);
    int d = 1e9 +1;
    for(int &c : a) {
        cin >> c;
        d = min(d, c);
    }
    bool ok = 1;
    for(int i = 1;i < n;++i)
        if(a[i - 1] > a[i])ok = 0;
    if(ok) {
        cout << "YES\n" << '\n';
        return;
    }


}

void another() {
    ll s = 0;
    int n ;
    cin >> n;
    vector<int>a(n);
    for(int &c : a)
        cin >> c;
    int d = 0;
    for(int c  : a) {
        d = max(d, c);
        s += d - c;
    }
    cout << s << '\n';

}
void test_case() {
    int t;
    cin >> t;
    while(t--)another();
}
int main() {

   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    another();
}


Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "Y"){
      cout << "Four" <<endl;
      break;
    }
    else if ( i == N - 1){
      cout << "Three" <<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sca = new Scanner(System.in);
		int k = sca.nextInt();
		int a = sca.nextInt();
		int b = sca.nextInt();

		int count = 2;
		boolean flag = false;
		for(int i = k; i <= b; i = k*count) {
			if(a <= i && i <= b) {
				flag = true;
				break;
			}
			count++;
		}

		if(flag) {
			System.out.println("OK");
		}
		else {
			System.out.println("NG");
		}

		// 後始末
		sca.close();
	}
}

Measured memory_bytes: 35832
#include<bits/stdc++.h>
#define int long long

const int N = 2e3, M = N * N;
const int Mo = 1e9 + 7;

int n, m;
int f[N + 10][N + 10], fac[M + 10], Inv[M + 10];

inline int ksm(int a, int b) {
    int ans = 1;
    for (; b; b >>= 1, a = 1LL * a * a % Mo)
        if (b & 1) ans = 1LL * ans * a % Mo;
    return ans;
}

inline int C(int n, int m) {
    if (m < n)
        return 0;
    // printf("%d %d %d %d\n", n, fac[m], Inv[n], Inv[m - n]);
    return 1LL * fac[m] * Inv[n] % Mo * Inv[m - n] % Mo;
}

signed main() {
    scanf("%lld%lld", &n, &m);
    if (m == 1) {
        printf("1\n");
        return 0;
    }
    fac[0] = fac[1] = 1;
    for (int i = 2; i <= M; i++)
        fac[i] = (1LL * fac[i - 1] * i) % Mo;
    Inv[M] = ksm(fac[M], Mo - 2);
    // for (int i = 1; i <= n; i++)
    //     printf("%d ", fac[i]);
    for (int i = M - 1; i >= 0; i--)
        Inv[i] = 1LL * Inv[i + 1] * (i + 1) % Mo;

    // for (int i = 1; i <= n; i++)
    //     printf("%d ", Inv[i]);
    f[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int  j= 0; j <= i; j++) {
            if (j == 0)
                f[i][j] = f[i - 1][j];
            else {
                f[i][j] = (f[i - 1][j] + 1LL * f[i][j - 1] * (n - j + 1) % Mo * 1LL * (C(m - 2, n - i + (n - j + 1) * (m - 1) - 1)) % Mo) % Mo;
                // printf("%d %d\n", C(m - 2, n - i + (n - j + 1) * (m - 1) - 1), n - i + (n - j + 1) * (m - 1) - 1);
            }
        }
    printf("%lld\n", f[n][n]);
    return 0;
}

Measured memory_bytes: 94208
# floor(N/m) = N % m

def divisors(n):
    D = []
    for d in range(1,int((n)**.5)+1):
        if n%d == 0:
            D.append(d)
            if n//d != d:
                D.append(n//d)
    return D

def solve(n):
    s = 0

    for d in divisors(n):
        m = d - 1
        if m and (m+1)*(n//m) == n:
            s += m
    return s


n = int(input())
print(solve(n))


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

int main() {
	int *S;
	int n,q,t;
	int cnt;
	
	cin>>n;
	S = new int[n];
	for(int i=0;i<n;++i){
		cin>>S[i];
	}
	cin>>q;
	cnt = 0;
	for(int i=0;i<q;++i){
		cin>>t;
		int st=0, ed=n-1, mid;
		if(S[st] == t || S[ed] == t)++cnt;
		else{
			while(ed-st>1){
				mid = (st + ed) / 2;
				if(S[mid] == t){
					++cnt;
					break;
				}else if(S[mid] > t){
					ed = mid;
				}else{
					st = mid;
				}
			}
		}
	}
	cout<<cnt<<endl;
	
	return 0;
}

Measured memory_bytes: 1568
def insertion_sort(A,N):
    for i in range(1,N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(' '.join(map(str,A)))
    
    
n = int(input())
test = list(map(int,input().split()))

print(' '.join(map(str,test)))
insertion_sort(test,n)



Measured memory_bytes: 5608
// AOJ GRL_6_A
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

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

using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vc;

const int INF = 0x3fffffff;

// ?????§???????±???????(Dinic??????bfs()??????????????¨Ford-Fulkerson???)
class Flow{
	public:
		int N;	// ????????°
		vector<vc> F, C, edge;	// F:????????°?????? C:???????????? edge:??£??\????????????
		vector<bool> bf;	// ??????????????£???????????????
		vector<int> lv;	// S??????????????¢

		// ????????????????????? n:????????°
		Flow(int n): F(n,vc(n)), C(n,vc(n)), N(n), edge(n) {}

		// f->t????????????c?????????????????????(??????f->t??????????????????????????????????????¨?????????)
		void addEdge(int f, int t, int c){
			F[f][t] += c;
			C[f][t] += c;
			edge[f].push_back(t);
			edge[t].push_back(f);
		}

		// ??????f->t?????¢????????????addEdge()???????????????????????????????????????????????¨??????
		void uniqueEdge(){
			for(auto e: edge){
				sort( e.begin(), e.end() );
				e.erase( unique( e.begin(), e.end() ), e.end() );
			}
		}

		// s????????????????????¢????±?????????????????????????????????¨DFS??§?????????????????????????????¢?´¢??????
		int bfs(int S, int T){
			lv.assign(N, 0);
			queue<int> que;
			que.push(S);
			lv[S] = 1;
			while( !que.empty() ){
				int n = que.front(); que.pop();
				for(auto v: edge[n]) if( !lv[v] && F[n][v] ){
					lv[v] = lv[n] + 1;
					que.push(v);
				}
			}
			return lv[T];
		}

		// ?¢?????????????DFS??§??¢???
		int dfs(int n, int c, int T){
			if( n == T ) return c;
			bf[n] = true;
			for(int v: edge[n]) if( F[n][v] && !bf[v] && lv[v] > lv[n] ){	// ??????????????¶??????????????¨bfs()?????????????????????
				int f = dfs(v, min(c, F[n][v]), T);
				F[n][v] -= f;
				F[v][n] += f;
				if( f > 0 ) return f;
			}
			return 0;
		}

		// ?????§???????±???????
		int maxFlow(int S, int T){
			if( S == T ) return INF;
			int ret = 0;
			while( bfs(S,T) )	// bfs()???????????´?????????????????????????????????
				for(int add; bf.assign(N,0), add = dfs(0, INF, T);) ret += add;
			return ret;
		}

		// ??????????????????????????????????????????
		int flow(int f, int t){ return C[f][t] - F[f][t]; }

		// ??£??\?????????????????????????¨???????????????????n=S,T??\????????´?????????????????????1/2????????????????????????????????????
		int flow(int n){
			int ret=0;
			for(int v: edge[n]) ret += abs( flow(n,v) );
			return ret;
		}

		// ??°???????????????????????????
		void clear(){ rep(i,N) rep(j,N) F[i][j] = C[i][j]; }
};

int main(){
	int V, E;
	cin >> V >> E;
	Flow fl(V);
	rep(i, E){
		int u, v, c;
		cin >> u >> v >> c;
		fl.addEdge( u, v, c );
		fl.maxFlow(0, V-1);
	}

	cout << fl.flow(0) << endl;

	return 0;
}

Measured memory_bytes: 3208
# -*- coding: utf-8 -*-
"""
A - ABC333
https://atcoder.jp/contests/abc109/tasks/abc109_a

"""
import sys


def solve(A, B):
    if A == 2 or B == 2:
        return 'No'
    return 'Yes'


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include <iostream>
#include <array>

namespace Dice
{

constexpr std::size_t NUM_OF_SIDE = 6;

class CoreDice {
public:
	CoreDice(const std::array<std::string, NUM_OF_SIDE>& label) : m_label(label) {}

public:
	const std::string& getLabel(std::size_t index) const { return m_label.at(index - 1); }

protected:
	//! label printed on its surface
	std::array<std::string, NUM_OF_SIDE> m_label;
};

class RollingDice : CoreDice {
public:
	RollingDice(const std::array<std::string, NUM_OF_SIDE>& labels)
		: CoreDice{labels}, m_table{{1, 2, 3, 4, 5, 6}} {}

public:
	void rollTowardNorth() {
		m_table = {{
			m_table.at(2 - 1), m_table.at(6 - 1), m_table.at(3 - 1),
			m_table.at(4 - 1), m_table.at(1 - 1), m_table.at(5 - 1)
		}};
	}
	void rollTowardSouth() {
		m_table = {{
			m_table.at(5 - 1), m_table.at(1 - 1), m_table.at(3 - 1),
			m_table.at(4 - 1), m_table.at(6 - 1), m_table.at(2 - 1)
		}};
	}
	void rollTowardEast() {
		m_table = {{
			m_table.at(4 - 1), m_table.at(2 - 1), m_table.at(1 - 1),
			m_table.at(6 - 1), m_table.at(5 - 1), m_table.at(3 - 1)
		}};
	}
	void rollTowardWest() {
		m_table = {{
			m_table.at(3 - 1), m_table.at(2 - 1), m_table.at(6 - 1),
			m_table.at(1 - 1), m_table.at(5 - 1), m_table.at(4 - 1)
		}};
	}

	const std::string& getLabel(std::size_t label) const {
		return m_label.at(m_table.at(label - 1) - 1);
	}

private:
	//! index transposition table
	std::array<std::size_t, NUM_OF_SIDE> m_table;
};

}	//!< namespace Dice

int main()
{
	std::array<std::string, Dice::NUM_OF_SIDE> label;
	std::cin >> label.at(1-1) >> label.at(2-1) >> label.at(3-1)
			 >> label.at(4-1) >> label.at(5-1) >> label.at(6-1);
	Dice::RollingDice dice{label};

	std::string command;
	std::cin >> command;

	for (std::size_t i = 0; i < command.length(); i++) {
		switch (command.at(i)) {
		case 'N': dice.rollTowardNorth(); break;
		case 'S': dice.rollTowardSouth(); break;
		case 'E': dice.rollTowardEast(); break;
		case 'W': dice.rollTowardWest(); break;
		default : std::cerr << "ERROR: irregular command!" << std::endl; break;
		}
	}
	std::cout << dice.getLabel(1) << std::endl;

	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

ifstream fin("file.in");
ofstream fout("file.out");

long long int nrnr, nr1, nr2;

struct str{
    long long int alb;
    long long int blk;
    bool check;
    vector <int> con;
} vec[100005];

void dfs(int poz){
    vec[poz].alb = 1;
    vec[poz].blk = 1;
    vec[poz].check = 1;
    for(int index = 0; index < vec[poz].con.size(); index++){
        if(!vec[vec[poz].con[index]].check){
            dfs(vec[poz].con[index]);
            vec[poz].alb = (vec[poz].alb * (vec[vec[poz].con[index]].alb + vec[vec[poz].con[index]].blk)) % 1000000007;
            vec[poz].blk = (vec[poz].blk * vec[vec[poz].con[index]].alb) % 1000000007;
        }
    }
    return;
}

int main()
{
    cin >> nrnr;
    while(cin >> nr1){
        cin >> nr2;
        vec[nr1].con.push_back(nr2);
        vec[nr2].con.push_back(nr1);
    }
    dfs(1);
    cout << (vec[1].alb + vec[1].blk) % 1000000007;
    return 0;
}


Measured memory_bytes: 10880
#include<stdio.h>
#define MAX 2000001 
int main(){
  int i,n,*a,*b,c[10000],max=0;

  scanf("%d",&n);

  a=malloc(sizeof(int)*n+1);
  b=malloc(sizeof(int)*n+1);

  
  for(i=0;i<=n-1;i++){
    scanf("%d",&a[i+1]);
    if(max<a[i+1])max=a[i+1];
  }

  for(i=0;i<=max+1;i++){
    c[i]=0;
  }

  for(i=0;i<=n-1;i++){
    c[a[i+1]]++;
  }

  for(i=1;i<=max+1;i++){
    c[i]=c[i]+c[i-1];
  }

  for(i=n;i>=0;i--){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",b[i]);
  }
  printf("\n");

  return 0;
}
  
  



Measured memory_bytes: 17528
# -*- coding: utf-8 -*-


if __name__ == '__main__':

    n = int(input())
    A = [int(a) for a in input().split(" ")]
    B = A.copy()
    B.sort()
    V = [False]*n
    T = {B[i]:i for i in range(n)}

    ans = 0
    s = min(A)

    for i in range(n):
        if V[i]:
            continue
        cur = i
        S = 0 # sum of weight
        m = 10000 # min of cycle(init max weight)
        an = 0 # length of cycle
        while not V[cur]:
            V[cur] = True
            an += 1
            v = A[cur]
            m = min(m, v)
            S += v
            cur = T[v]
        ans += min(S + (an - 2)*m, m + S + (an + 1)*s)

    print(ans)


Measured memory_bytes: 5724
'''
Let g(x) = 序列內數字唯一，且最多 x 個位置不同。
Let f(x) = 序列內數字唯一，且給定 x 個位置時，使這些位置不同的方法數。

題目所求是 C(N, N) f(N)。

其中 g(x) 代表有至少 N - x 個位置是相同。可以分三個部份填數字，注意順序會影響，所以要乘上全排序：
(1) N - x 個位置（數字必需相同）：C(M, N - x) * (N - x)! = P(M, N - x)
(2) 序列 A 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
(3) 序列 B 其餘位置（可以隨便填，但不能用到 (1) 的數字）：C(M - (N - x), x) * x! = P(M - (N - x), x)
g(x) = (1) * (2) * (3)

g(x) 是「選定 0 個位置，使這些位置不同的方法數」、「選定 1 個位置，使這些位置不同的方法數」、…、「選定 x 個位置，使這些位置不同的方法數」，即
g(x) = C(x, 0) f(0) + C(x, 1) f(1) + ... + C(x, x) f(x)
     = sum( C(x, i) * f(i) for i in [0, x] )
根據二項式反演，得到
f(x) = sum( (-1) ** (x - i) * C(x, i) * g(i) for i in [0, x] )
'''

class CombMod:
    def __init__(self, V, p):
        self.fact = [1] * V
        self.finv = [1] * V
        for i in range(1, V):
            self.fact[i] = self.fact[i - 1] * i % p
        self.finv[-1] = pow(self.fact[-1], p - 2, p)
        for i in range(V - 2, 0, -1):
            self.finv[i] = self.finv[i + 1] * (i + 1) % p
        self.p = p
        
    def fact(self, a):
        return self.fact[a]
    
    def finv(self, a):
        return self.finv[a]

    def comb(self, a, b):
        return self.fact[a] * self.finv[b] % self.p * self.finv[a - b] % self.p
        
    def perm(self, a, b):
        return self.fact[a] * self.finv[a - b] % self.p
    
    def hcomb(self, a, b):
        return self.comb(a + b - 1, b)


N, M = map(int, input().split())
mod = 10**9 + 7
tool = CombMod(max(N, M) + 10, mod)

f_N = 0
for i in range(0, N + 1):
    p1 = tool.perm(M, N - i)
    p2 = tool.perm(M - (N - i), i)
    g_i = p1 * p2 % mod * p2 % mod
    val = (-1)**((N - i) % 2) * tool.comb(N, i) % mod * g_i % mod
    f_N = (f_N + val) % mod
ans = tool.comb(N, N) * f_N % mod
print(ans)


Measured memory_bytes: 48248
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(min(b,d) - max(a,c) < 0) {
        cout << 0;
        return 0;
    }
    cout << min(b,d) - max(a,c);
    return 0;
}



Measured memory_bytes: 256
//Written by Rhitwik Saha//
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define mp          make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vb          vector<bool>
#define vc          vector<char>
#define vii         vector<pii>
//#define mi          map<int,int>
//#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define ub(x)       upper_bound(x)
#define lb(x)       lower_bound(x)
#define endl        '\n'
#define file        freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define fastio      ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
// #define N 			1e5+5
#define M           1000000007
#define MAX         100005
#define mem0(a)     memset(a,0,sizeof(a))
#define prec        cout<<std::setprecision(9)<<std::fixed
#define forn(i,a,b)  for(int i=a;i<b;i++)
int i,j,k;

void Anon_mouS(){
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	for(int &x:a){
		cin>>x;
	}
	sort(all(a));
	int ans=0;
	for(i=0;i<n-k;i++){
		ans+=a[i];
	}
	cout<<ans;
}
int32_t main(){
    fastio;
    // file;
    // sieve();
    int q=1;
    // cin>>q;
    while(q--)Anon_mouS();
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    FAST_IO
    
    ll a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
    
    return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

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


def main():
    rr = []

    while True:
        n,m = LI()
        if n == 0 and m == 0:
            break
        a = [I() for _ in range(n)]
        b = [I() for _ in range(m)]
        ar = [0] * (n+1)
        for i in range(n):
            ar[i+1] = ar[i] + a[i]
        ad = collections.defaultdict(int)
        for i in range(n+1):
            for j in range(i+1,n+1):
                ad[ar[j]-ar[i]] += 1
        br = [0] * (m+1)
        for i in range(m):
            br[i+1] = br[i] + b[i]
        bd = collections.defaultdict(int)
        for i in range(m+1):
            for j in range(i+1,m+1):
                bd[br[j]-br[i]] += 1

        r = 0
        for k in ad.keys():
            r += ad[k] * bd[k]

        rr.append(r)



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


print(main())




Measured memory_bytes: 78468
package main

import (
	"fmt"
	"math"
)

// 答えは下記のいずれか
// 最小値にいく前にカウントが尽きる
// 最小値
// 最小値の１個逆側(回数的に最小値にできない)
func main() {
	var x, k, d int
	fmt.Scan(&x, &k, &d)
	absX := AbsDiff(x, 0)
	var min int
	var count int
	if d < absX {
		min = absX % d
		count = absX / d
		if count >= k {
			min = absX - d*k
		}
	} else {
		min = absX - d
		count = 1
	}
	if k > count && (k-count)%2 != 0 {
		if min > 0 {
			min = min - d
		} else {
			min = min + d
		}
	}
	fmt.Println(AbsDiff(min, 0))
}

func AbsDiff(n1 int, n2 int) int {
	return int(math.Abs(float64(n1 - n2)))
}


Measured memory_bytes: 1836
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{string x;
 cin>>x;
 if (x[3]!='8')
 x[3]='8';
 cout<<x; 
 system("pause");                                                             
 return 0 ;
}        

Measured memory_bytes: 504
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main(){
  int N;cin>>N;
  vector<string> s(N);
  VI t(N);
  REP(i,N){
    cin>>s[i];
    cin>>t[i];
  }
  string x;cin>>x;
  int key=0;
  REP(i,N){
    if(s[i]==x){
      key=i;
    }
  }
  int ans=0;
  for(int i=key+1;i<N;i++){
    ans=ans+t[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 888
n = int(input())
ps = list(map(int,input().split()))
count = 0
for i in range(1,len(ps)-1):
    if ps[i]>ps[i-1] and ps[i]<ps[i+1]:
        count+=1
    elif ps[i]<ps[i-1] and ps[i]>ps[i+1]:
        count+=1
print(count)

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

class Dice{
public:
    int *arr;
    Dice(int arr2[]){arr = arr2;}

    void roll(char direction){
        int temp;
        switch(direction){
            case 'N':
                temp = arr[0]; arr[0] = arr[1]; arr[1] = arr[5]; arr[5] = arr[4]; arr[4] = temp;
                break;
            case 'E':
                temp = arr[0]; arr[0] = arr[3]; arr[3] = arr[5]; arr[5] = arr[2]; arr[2] = temp;
                break;
            case 'W':
                temp = arr[0]; arr[0] = arr[2]; arr[2] = arr[5]; arr[5] = arr[3]; arr[3] = temp;
                break;
            case 'S':
                temp = arr[0]; arr[0] = arr[4]; arr[4] = arr[5]; arr[5] = arr[1]; arr[1] = temp;
        }
    }

    int report(){return arr[0];}

    int rightside(int a, int b){
        string line = "NNNEEE";
        for(int i = 0; i < 6; i++){
            if(arr[0] == a) break;
            roll(line[i]);
        }
        roll('N');
        line = "EEE";
        for(int i = 0; i < 3; i++){
            if(arr[0] == b) break;
            roll(line[i]);
        }
        roll('S');
        return arr[2];
    }
    
};

int main(){
    int arr[6], q;
    for(int i = 0;i < 6; i++) cin >> arr[i];
    Dice dice(arr);

    cin >> q;
    for(int i = 0;i < q; i++){
        int a, b;
        cin >> a >> b;
        cout << dice.rightside(a, b) << endl;
    }

    return 0;
}



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

#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; rep(i_debug, v.size()) { cout << v[i_debug] << ",";}cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; rep(i_debug, m.size()) { rep(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; } cout << endl; } }

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> c(M);
    rep(i, M) {
        cin >> a[i];
        int b;
        cin >> b;
        int keys = 0;
        rep(j, b) {
            int c;
            cin >> c;
            --c;
            keys |= (1 << c);
        }
        c[i] = keys;
    }

    vector<vector<int>> dp(M + 1, vector<int>((int)pow(2, N), (int)1e9));
    dp[0][0] = 0;
    for (int m = 1; m <= M; m++) {
        int key    = c[m - 1];
        int cost   = a[m - 1];
        rep(i, pow(2, N)) {
            dp[m][i] = min(dp[m][i],dp[m-1][i]);
            dp[m][i | key] = min(dp[m][i | key], dp[m - 1][i] + cost);
        }
    }

    if (dp[M][pow(2, N) - 1] == (int)1e9) {
        cout << -1 << endl;
    } else {
        cout << dp[M][pow(2, N) - 1] << endl;
    }
}

Measured memory_bytes: 16384
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, double i)
{
    printf("%.20f", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

int main()
{

    int A, B, C, K;
    io >> A >> B >> C >> K;

    while (K--)
    {
        if (A >= B)
        {
            B *= 2;
        }
        else if (B >= C)
        {
            C *= 2;
        }
    }
    bool ans = (A < B && B < C);

    io << YesNo(ans) << BR;
}

Measured memory_bytes: 3760
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
  if p[i] == i + 1:
    p[i] = p[i + 1]
    p[i + 1] = i + 1
    ans += 1
if p[n - 1] == n:
  p[n - 1] = p[n - 2]
  p[n - 2] = n
  ans += 1
print(ans)

Measured memory_bytes: 20560
n,m=map(int,input().split())
ans='No'
a=[]
b=[]
for i in range(n):
    a1=list(input())
    a.append(a1)
for j in range(m):
    b1=list(input())
    b.append(b1)
for i in range(n-m+1):
    for j in range(n-m+1):
        if b==[l[i:i+m] for l in a[j:j+m]]:
            ans='Yes'
            break
print(ans)

Measured memory_bytes: 3064
import java.util.*

fun main(args:Array<String>){
    val scan=Scanner(System.`in`)
    var sum=0.0

    val n=scan.nextInt()
    var x:Double
    var u=""
    for (i in 0 until n){
        x=scan.nextDouble()
        u=scan.next()
        if (u=="BTC"){
            sum+=380000*x
        }
        else{
            sum+=x
        }
    }

    println(sum)
}

Measured memory_bytes: 29596
/*
     bitwise ^_^
*/

#include<bits/stdc++.h>
using namespace std;
const int mxn = 2*1e3+5;
int ar[mxn] , n;
int sum;
bitset< mxn*mxn > b;

int main()
{
	cin>>n;
	sum  = 0;
	b.set(0);
	for(int i  = 1;i <= n;i++)
	{
		cin>>ar[i];
		sum +=ar[i];
		b = b|(b<<ar[i]);
	}
	for(int i = (sum+1)/2; i <= sum; i++)
	{
		if(b[i])
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


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

int N;
string s[10000];

//UnionFind-----------------------------
int par[26],sz[26];
void init(){
    for(int i=0;i<26;i++){
        par[i]=i;
        sz[i]=1;
    }
}
int find(int x){
    return x==par[x]?x:par[x]=find(par[x]);
}
void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y)return;

    if(sz[x]<sz[y])swap(x,y);
    par[y]=x;
    sz[x]+=sz[y];
}
//--------------------------------------


void solve(){
    int in[26]={0};
    int out[26]={0};

    init();
    for(int i=0;i<N;i++){
        int o=s[i][0]-'a';
        int e=s[i][s[i].size()-1]-'a';

        in[o]++;
        out[e]++;
        unite(o,e);
    }

    int cnt=0;

    for(int i=0;i<26;i++){
        if(in[i]!=out[i]){
            cout<<"NG"<<endl;
            return;
        }

        if(in[i]&&i==par[i])cnt++;
    }

    if(cnt>1){
        cout<<"NG"<<endl;
        return;
    }
    cout<<"OK"<<endl;

}

int main(){
    while(cin>>N,N){
        for(int i=0;i<N;i++)cin>>s[i];
        solve();
    }
    return 0;
}

Measured memory_bytes: 2116
N,K=map(int,input().split())

if (N*(N-1)//2)-K<N-1:
  print(-1)
else:
  num = N*(N-1)//2-K
  print(num)
  for i in range(2,N+1):
    print("{} {}".format(1,i))
    num -= 1
    
  for i in range(2,N):
    for j in range(i+1,N+1):
      if num == 0:
        break
      else:
        print("{} {}".format(i,j))
        num -= 1



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

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

	string str;
	cin >> str;
	string res;
	for(int i=0; i<str.size(); i++){
		switch(str[i]){
			case('0'):
				res.push_back('0');
				break;
			case('1'):
				res.push_back('1');
				break;
			case('B'):
				if(!res.empty()) res.pop_back();
				break;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
sys.setrecursionlimit(100000)

N, M = [int(ele) for ele in input().split()]
edges = []

d = [-100000000000000000000000000000000000000000000000] * (N+1)
d_tmp = []

for _ in range(M):
    src, dst, w = [int(ele) for ele in input().split()]
    if src == 1:
        d[dst] = w
    edges.append([src, dst, w])

yet = [ele for ele in range(1, N+1)]


def main():
    print(d[-1] if bellman_ford() != -1 else "inf")


def bellman_ford():
    for _ in range(N - 1):
        for src, dst, w in edges:
            if d[dst] < w + d[src]:
                d[dst] = w + d[src]

    d_tmp = d[-1]

    for src, dst, w in edges:
        if d[dst] < w + d[src]:
            d[dst] = w + d[src]

    if d_tmp != d[-1]:
        return -1

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int n;cin >> n;
  map<int,int> mp;
  int i=0;
  while(mp[n]<1){
    mp[n]++;
    i++;
    if(n%2==1) n = 3*n+1;
    else n/=2;
  }
  cout << i+1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,i,j,tmp,arr[100],cnt=0,minj;
    
    scanf("%d",&n);
    if(n>100) exit(1);
    for(i=0;i<n;i++){
      scanf("%d",&arr[i]);
    }
    
    for(i=0;i<n;i++){
      minj=i;
        for(j=i;j<n;j++){
	  if(arr[minj]>arr[j]) minj=j;
        }
        if(minj!=i){
	  tmp=arr[i];
            arr[i]=arr[minj];
            arr[minj]=tmp;
            cnt++;
        }
    }
    
    for(i=0;i<n;i++){
      if(i!=0) printf(" ");
        printf("%d",arr[i]);
    }
    printf("\n%d\n",cnt);
    
    return 0;
}



Measured memory_bytes: 2104
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Combination{
	vector<ll> fac,finv,inv;
public:
	Combination(ll N){
		fac.resize(N+1);
		finv.resize(N+1);
		inv.resize(N+1);
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for(int i=2;i<=N;i++){
			fac[i] = fac[i-1] * i % atcoder_mod;
			inv[i] = atcoder_mod - inv[atcoder_mod%i] * (atcoder_mod/i) % atcoder_mod;
			finv[i] = finv[i-1] * inv[i] % atcoder_mod;
		}
	}
	ll Caluclation(ll n,ll r){
		if(n < r) return 0;
		if (n < 0 || r < 0) return 0;
		return fac[n] * (finv[r] * finv[n-r] % atcoder_mod) % atcoder_mod;
	}

};
ll BallBoxCombination6(ll n,ll k){
	Combination comb(n-1);
	return comb.Caluclation(n-1,k-1);
}

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

	ll N=in<ll>(),K=in<ll>();
	
	ll ans = BallBoxCombination6(N,K);
	out(ans);
	return 0;
}



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

using namespace std;
const int maxn = 2e5 + 4;
int a[maxn], type[maxn], q, cnt;
char b[maxn];

void _accepcted_by_one_hit_()
{
    #ifdef NTMA
        freopen("abc.inp", "r", stdin);
        freopen("abc.out", "w", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
int Round(double x)
{
    int a = x, b = x + 1;
    if (a - x > b - x) return b;
    else return a;
}
int main()
{	
	_accepcted_by_one_hit_();
    string s, t, v; cin >> s;
    t = v = "";
    int q; cin >> q;
    for(int i=1; i<=q; ++i) {
        cin >> type[i]; if (type[i] == 1) continue;
        else cin >> a[i] >> b[i];
    }
    for(int i=q; i>=1; --i){
        if (type[i] == 1) cnt = (cnt + 1) % 2;
        else {
            if (a[i] == 1) {
                if (cnt) t += b[i];
                else v += b[i]; 
            } else {
                if (cnt) v += b[i];
                else t += b[i];
            }
        }
    }
    if (cnt) reverse(s.begin(), s.end());
    reverse(t.begin(), t.end());
    s = v + s + t;
    cout << s;
}

Measured memory_bytes: 2992
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W,L;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> N>>a>>b;
	N -= a;
	N %= b;

	cout << N << endl;
	
	
	
	return 0;

}


Measured memory_bytes: 2304
#include <stdio.h>
int main(void){
     while(1){
         
    int w,money=0;
        scanf("%d",&w);
        if(w==-1){
            break; 
        }
        if(w>30){
            money+=160*(w-30);
            w=30;
        }
        if(w>20){
            money+=140*(w-20);
            w=20;
            
        }
        if(w>10){
            money+=(w-10)*125;
            w=10;
            
        }
        if(w>=0){
            money+=1150;
        }
        
        printf("%d\n",4280-money);
   }
   
   
    
}



Measured memory_bytes: 2040
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define gc() getchar()
#define digit(x) (x >= '0' && x <= '9')
int read()
{
	int x = 0, f = 1; char c=gc();
	while(!digit(c)){if(c == '-') f=-1; c=gc();}
	while(digit(c)) x = (x<<3) + (x<<1) + c - '0', c=gc();
	return x*f;
}

const int N = 100000, M = 100000;

int n, m;
int fa[N+5];
bool vs[N+5];
inline int Fa(int x)
{
	return fa[x] == x ? x : fa[x] = Fa(fa[x]);
}

vector<int> V[N+5];

void Dfs(int u, int f)
{
	for(register int i=0; i<V[u].size(); i++)
	{
		int v = V[u][i];
		
		if(v == f) continue;
		
		Dfs(v, u);
		
		if(vs[v])
		{
			printf("%d %d\n", v, u);
			vs[v] = !vs[v];
		}
		else
		{
			printf("%d %d\n", u, v);
			vs[u] = !vs[u];
		}
	}
}

int main()
{
//	freopen("degree.in", "r", stdin);
//	freopen("degree.out", "w", stdout);
	n=read();m=read();
	
	if(m&1)
	{
		printf("-1\n");
		return 0;
	}
	for(register int i=1; i<=n; i++) fa[i] = i;
	
	int u,v;
	for(register int i=1; i<=m; i++)
	{
		u = read(), v = read();
		
		int f1 = Fa(u), f2 = Fa(v);
		if(f1 == f2)
		{
			vs[u] = !vs[u];
			printf("%d %d\n", u, v);
		}
		else
		{
			fa[f1] = f2;
			V[u].push_back(v);
			V[v].push_back(u);
		}
	}
	Dfs(1, -1);
	return 0;
} 

Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int a, b; cin >> a >> b;
	if (10 <= a || 10 <= b) {
		cout << "-1" << endl;
		return 0;
	}

	cout << a * b << endl;

	return 0;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=2e5+50,P=1e9+7;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int n,m,k,a[N],g;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin);
	//freopen("my.out","w",stdout);
#endif
	scanf("%d%d",&n,&k); 
	rep(i,1,n){
		scanf("%d",a+i); 	
		cmax(m,a[i]); 
	}
	g=a[1];
	rep(i,2,n){
		g=gcd(g,a[i]); 
	}
	if(k%g==0&&k<=m)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<set>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))


int main() {
	string a,s;
	cin >> a>>s>>a;
	cout << "A" << s[0] << "C";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Row
{
    int a;
    int b;
    Row(int _a, int _b)
    {
        a = _a;
        b = _b;
    }
};

bool cmp(const Row &f, const Row &s)
{
    if (f.b == s.b) {
        return f.a > s.a;
    }
    return f.b < s.b;
}

void Main()
{
    int N; cin >> N;
    vector<Row> rows;
    rep(i, N)
    {
        int a; cin >> a;
        int b; cin >> b;
        rows.push_back(Row(a, b));
    }
    sort(rows.begin(), rows.end(), cmp);
    int current = 0;
    rep(i, N)
    {
        current += rows[i].a;
        if (current > rows[i].b) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


Measured memory_bytes: 2420
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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


    int N; cin >> N;
    vvi A(2, vi(N, 0));
    REP(i, 2)
        REP(j, N) cin >> A[i][j];

    int ans = 0;
    REP(i,N){
        int cnt = 0;
        int r = 0;
        REP(j,N){
            cnt += A[r][j];
            if (j == i) {
                r++;
                cnt += A[r][j];
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int k,n,a[maxn],b[maxn];
signed main(){
	k=read(),n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
	}
	int mx=0;
	for(int i=1;i<n;i++){
		b[i]=a[i+1]-a[i];
		mx=max(mx,b[i]);
	}
	b[n]=a[1]+k-a[n];
	mx=max(mx,b[n]);
	printf("%d\n",k-mx);
	return 0;
}


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

using namespace std;

int main() {
    int cnt = 0;
    string s;
    cin >> s;
    char c = s.front();
    for (int i = 0; i < s.size(); ++i) {
        cnt += (c != s.at(i));
        c = s.at(i);
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
N=int(input())
S=list(input() for _ in range(N))

from collections import Counter

cnt=Counter(S)
max_cnt=cnt.most_common()[0][1]
ans=[]
for k, v in cnt.items():
	if v!=max_cnt:
		continue
	ans.append(k)
print(*sorted(ans), sep="\n")

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

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 (a>b) { a=b; return 1; } return 0; }

ll myparse(string s){
	int n = s.size();
	ll ret = 0;
	rep(i, n){
		if(s[i] == '.') continue;
		ret *= 10;
		ret += s[i] - '0';
	}

	return ret;
}

ll npow(ll x, ll y){
	ll ret = 0;
	while(x % y == 0){
		x /= y;
		ret++;
	}

	return ret;
}

pii calc(string s){
	int n = s.size();
	ll x;
	if(s.find(".") == string::npos){
		x = stoll(s);
		return {npow(x, 2ll), npow(x, 5ll)};
	}

	x = myparse(s);
	int l = n - s.find(".") - 1;
	return {npow(x, 2ll) - l, npow(x, 5ll) - l};
}

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

	int n;
	cin >> n;

	map<pii, ll> mp;
	rep(i, n){
		string s;
		cin >> s;

		pii p = calc(s);
		if(mp.count(p) == 0) mp[p] = 0ll;
		mp[p]++;
	}

	vector<pii> v;
	for(auto x : mp){
		v.push_back(x.first);
	}

	ll ans = 0ll;
	int m = v.size();
	for(int i = 0; i < m; i++){
		if(v[i].first >= 0 && v[i].second >= 0){
			ans += mp[v[i]] * (mp[v[i]] - 1) / 2;
		}
		for(int j = i + 1; j < m; j++){
			if(v[i].first + v[j].first >= 0 && v[i].second + v[j].second >= 0){
				ans += mp[v[i]] * mp[v[j]];
			}
		}
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

#define N	500000

double xx[N + 1], yy[N + 1];

double cross2(double x1, double y1, double x2, double y2) {
	return x1 * y2 - x2 * y1;
}

double cross(int i, int j, int k) {
	return cross2(xx[j] - xx[i], yy[j] - yy[i], xx[k] - xx[i], yy[k] - yy[i]);
}

int main() {
	static int qu[N + 1];
	int n, i, l, head, cnt;

	scanf("%d%d", &n, &l);
	head = cnt = 0;
	xx[0] = 0, yy[0] = 0, qu[head + cnt++] = 0;
	for (i = 1; i <= n; i++) {
		int t, v;

		scanf("%d%d", &t, &v);
		xx[i] = xx[i - 1] - v;
		yy[i] = yy[i - 1] - (long long) v * t;
		if (i > 1) {
			while (cnt > 1 && xx[qu[head + 1]] - xx[i] >= l)
				head++, cnt--;
			yy[qu[head]] -= (xx[qu[head]] - xx[i] - l) * (yy[qu[head + 1]] - yy[qu[head]]) / (xx[qu[head + 1]] - xx[qu[head]]);
			xx[qu[head]] = xx[i] + l;
		}
		printf("%f\n", (yy[qu[head]] - yy[i]) / l);
		while (cnt > 1 && cross(qu[head + cnt - 2], qu[head + cnt - 1], i) <= 0)
			cnt--;
		qu[head + cnt++] = i;
	}
	return 0;
}


Measured memory_bytes: 18572