akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp14
{
    class Class3 
    {
        static void Main()
        {
            var In = Console.ReadLine().Split();
            long N = long.Parse(In[0]);
            long M = long.Parse(In[1]);
            long ans = 0;
            if (N == 1 & M == 1)
            {
                ans = 1;
            }
            else if (N == 1 || M == 1)
            {
                ans = N * M - 2>0?N*M-2:0;
                
            }
            else
            {
                ans = N * M - (2 * N + 2 * M - 4);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//1行目の入力
		int N = sc.nextInt();
		//2行目の入力
		int[] A = new int[N];
		for(int i=0; i<N; i++){
			A[i]  = sc.nextInt();
		}
		//A[i]を並び替える
		int val;
		int j;
		for(int i=1; i<N; i++){
			val = A[i];
			j = i;
			while(j>0 && A[j-1]>val){
				A[j] = A[j-1];
				j--;
			}
			A[j] =val;
		}
		//残る種類を求める
		int count = 0;
		int temp = 0;
		for(int i=N-1; i>=1; i--){
			if(A[i] > A[i-1]*2){
				temp = i;
				count  =  N-i;
				break;
			}
		}
		if(count==0){
			count = N;
		}
		int sum;
		if(temp!=0){
			for(int i = temp-1; i>=0; i--){
				sum = 0;
				for(int k = i; k>=0; k--){
					sum += A[k];
				}
				if(sum*2>=A[i+1]){
					count++;
				}else{
					break;
				}
			}
		}
		//出力
		System.out.println(count);

	}

}


Measured memory_bytes: 48896
def resolve():
    '''
    code here
    '''
    N, M = [int(item) for item in input().split()]
    queries = [[int(item)-1 for item in input().split()] for _ in range(M)]

    memo = [['w'] for _ in range(N)]
    memo[0] = ['r']
    is_first_0 = True
    for x, y in queries:
        if 'r' in memo[x]:
            memo[y] += ['r']
            if 'w' in memo[x]:
                memo[x].remove('w')
            else:
                memo[x].remove('r')
        else:
            memo[y] += ['w']
            memo[x].remove('w')
    res = 0
    for line in memo:
        for item in set(line):
            if item == 'r':
                res += 1
    print(res)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 35736
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<n; ++i)

template <class T>
void print_answer(vector<T>& a) {
    for (auto& x : a)
        cout << x << endl;
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> A;
    for (int i=0; i<n; ++i) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    for (int i=k; i<n; ++i) {
        if (A.at(i) / (double)A.at(i-k) > 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3820
import itertools


def main():
    N, M, X = list(map(int, input().split(' ')))
    price = list()
    effect = list()
    for _ in range(N):
        data = list(map(int, input().split(' ')))
        price.append(data[0])
        effect.append(data[1:])
    INF = 10**10
    min_money = INF
    for pattern in itertools.product([0, 1], repeat=N):
        progress = [0 for _ in range(M)]
        for i in range(N):
            for j in range(M):
                progress[j] += pattern[i] * effect[i][j]
        ok = True
        for j in range(M):
            if progress[j] < X:
                ok = False
                break
        if ok:
            money = sum([p * m for p, m in zip(pattern, price)])
            if money < min_money:
                min_money = money
    if min_money == INF:
        print(-1)
    else:
        print(min_money)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;

int main(){

    long long n,x;

    cin >> n >> x;

    if(x == 1 || x == 2*n-1){
        cout <<"No"<<endl;
        return 0;
    }
    cout << "Yes"<<endl;
    if(x <= n){
        for(long long i=n;i>=1;i--)
            if(i!=x)
                cout << i<<endl;
        cout <<x << endl;
        for(long long i=2*n-1;i>n;i--)
            cout << i <<endl;

    }
    else{
        for(long long i=n-1;i>=1;i-- )
            cout << i<<endl;
        cout <<x << endl;
        for(long long i=2*n-1;i>=n;i--)
            if(i!=x)
                cout << i <<endl;
    }
}

Measured memory_bytes: 1536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;


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

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int mod = pow(10, 9) + 7;



int main(){

  int a, b;
  cin >> a >> b;
  if(a <=9 && b <= 9){
    cout << a*b << endl;
  } else {
    cout << -1 << endl;
  }

}

Measured memory_bytes: 256
func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

// ABC178A
let i = readInt()
if i == 0 {
    print(1)
} else {
    print(0)
}


Measured memory_bytes: 7756
#include<cstdio>
#include<algorithm>
using namespace std; 
#define MAXN 100
int a[3][MAXN+5],n,ans=-1e8;
int p[MAXN+5],q[MAXN+5];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			if(i==1) p[j]=p[j-1]+a[i][j];
		}
	for(int i=n;i>=1;i--)
		q[i]=q[i+1]+a[2][i];
	for(int i=1;i<=n;i++)
		ans=max(ans,p[i]+q[i]);
	printf("%d\n",ans);
}


Measured memory_bytes: 128
n, k =map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
ans = 10000000000000000
#print(h)
for i in range(n-k+1):
    if h[i+(k-1)] - h[i] <= ans:
        ans = h[i+(k-1)] - h[i]
print(ans)

Measured memory_bytes: 50392
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
    int N, W;
    cin >> N >> W;
    vector<pair<int, ll>> G(N);
    for (int i=0; i<N; i++) {
        cin >> G[i].first >> G[i].second;
    }

    vector<vector<ll>> dp(N+1, vector<ll>(W+1, 0));  // 使う品物0~N、重さ0~N
    for (int i=1; i<=N; i++) {
        for (int j=0; j<=W; j++) {
            if (0 <= j-G[i-1].first) {
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-G[i-1].first] + G[i-1].second);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << *max_element(dp[N].begin(), dp[N].end()) << endl;

    return 0;
}

Measured memory_bytes: 80256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int a,b,k;
int c=0;
int d[106];
int main()
{
    scanf("%d %d %d",&a,&b,&k);
    for(int i=a;i<=min(a+k-1,b);i++)
    {
    printf("%d\n",i);
    }
    for(int j=b;j>=max(b-k+1,a+k);j--)
    {
        d[++c]=j;
    }
    sort(d+1,d+1+c);
    for(int z=1;z<=c;z++)
    printf("%d\n",d[z]);
    return 0;
}

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

#define za ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod %1000000007
#define moz 1000000007
#define nl "\n"
#define S second
#define F first
#define PB push_back
#define MP make_pair
#define V vector
//#define P pair
#define LEN length()
#define SZ size()
#define loop(i,a,b) for(int i=(a);i<=(b);i++)
typedef long long ll;
typedef complex<ll> P;
#define X real()
#define Y imag()


int main()
{
    za ;
    string s;
    cin >> s;
    loop(i,0,s.LEN-1)
    {
        if(i%2==0) cout << s[i];
    }
    cout << nl;
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<int> po,ne,z;
  REP(i,n) {
    int x;
    cin >> x;
    if(x>0) po.push_back(x);
    else if(x<0) ne.push_back(x);
    else z.push_back(x);
  }
  sort(po.begin(),po.end());
  sort(ne.begin(),ne.end());
  if(po.empty()) {
    if(ne.size() == n) {
      int answer = ne[n-1];
      REP(i,n-1) answer += abs(ne[i]);
      cout << answer << endl;
      int tmp = ne[n-1];
      REP(i,n-1) {
        cout << tmp << " " << ne[i] << endl;
        tmp -= ne[i];
      }
      return 0;
    }
    po.push_back(z.back());
    z.pop_back();
  }
  if(po.size() == n) {
    int answer = -po[0];
    FOR(i,1,n) answer += po[i];
    cout << answer << endl;
    int tmp = po[0];
    FOR(i,1,n-1) {
      cout << tmp << " " << po[i] << endl;
      tmp -= po[i];
    }
    cout << po.back() << " " << tmp << endl;
    return 0;
  }
  int answer = 0;
  for(auto x:ne) answer += abs(x);
  for(auto x:po) answer += abs(x);
  cout << answer << endl;
  while(!z.empty()) {
    ne.push_back(z.back());
    z.pop_back();
  }
  REP(i, po.size()-1) {
    cout << ne.back() << " " << po[i] << endl;
    ne.back() -= po[i];
  }
  for(auto x:ne) {
    cout << po.back() << " " << x << endl;
    po.back() -= x;
  }
  return 0;
}


Measured memory_bytes: 2424
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int k;
int a[114514];
signed main() {
	cin >> k;
	rep(i, k)cin >> a[i];
	int l = 2, r = inf, mid;
	while (r - l > 1) {
		mid = (l + r) / 2;
		int s = mid;
		rep(i, k)s = s / a[i] * a[i];
		if (s > 2)r = mid;
		else l = mid;
	}
	int nl = 1, nr = inf, nm;
	while (nr - nl > 1) {
		nm = (nl + nr) / 2;
		int ns = nm;
		rep(i, k)ns = ns / a[i] * a[i];
		if (ns >= 2)nr = nm;
		else nl = nm;
	}
	int ml = nl + 1, mr = l;
	rep(i, k) {
		ml = ml / a[i] * a[i];
		mr = mr / a[i] * a[i];
	}
	if (ml != 2 || mr != 2)puts("-1");
	else cout << nl + 1 << " " << l << endl;
	ggr
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

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

range calc(range n, int a)
{
    return range(a * ((n.first - 1) / a + 1), a * (n.second / a + 1) - 1);
}

int main(int argc, char *argv[])
{
    int k;
    scanf("%d", &k);
    vector<int> a;
    for (int ik = 0; ik < k; ++ik)
    {
        int ai;
        scanf("%d", &ai);
        a.push_back(ai);
    }

    range curr(2, 2);
    for (int ik = k - 1; ik >= 0; --ik)
    {
        curr = calc(curr, a[ik]);
        if (curr.first > curr.second)
        {
            puts("-1");
            return 0;
        }
        // printf("%d %d\n", curr.first, curr.second);
    }
    printf("%lld %lld\n", curr.first, curr.second);
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace std;
using P=pair<int,int>;
using G=vector<vector<int>>;
using ll=long long;

const ll MAX = 1000000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


pair<ll,ll> route(ll x,ll y){
	ll pl=x+y;
	if(x%3==0){
		ll m=(2*x-y)/3;
		ll n=(2*y-x)/3;
		return make_pair(n,m);
	}else{
		return make_pair(0,0);
	}
}




int main(int argc, char **argv){
	ll x,y;cin>>x>>y;

	if((x+y)%3 != 0){
		cout<<0<<endl;
		return 0;
	}

	COMinit();

	ll dx,dy;
	dx=(2*y-x)/3; dy=(2*x-y)/3;

	if(dx<0||dy<0){
		cout<<0<<endl;
		return 0;
	}
	
	cout<<COM(dx+dy,dx)<<endl;
}


Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
const int MAX_V=100100;
struct edge
{
	int to,cap,rev;
	edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};
vector<edge> G[MAX_V];
bool used[MAX_V];
void add_edge(int from,int to,int cap)
{
	edge new_edge1(to,cap,G[to].size());
	G[from].pb(new_edge1);
	edge new_edge2(from,cap,G[from].size()-1);
	G[to].pb(new_edge2);
}
int dfs(int v,int t,int f)
{
	if(v==t)return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to]&&e.cap>0)
		{
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0)
			{
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int flow=0;
int N;
int max_flow(int s,int t)
{
	for(;;)
	{
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(f==0)return flow;
		flow+=f;
	}
}
int ex[505][505];
int E,Q;
int ind(int A,int B){for(int i=0;i<G[A].size();i++)if(G[A][i].to==B)return i;}
void increase(int A,int B)
{
	int id = ind(A,B);
	edge &e = G[A][id];
	e.cap++;
}
int decrease(int A,int B)
{
	int id = ind(A,B);
	edge &e = G[A][id];
	int ret = e.cap;
	e.cap=0;
	return ret;
}
int up_query(int A,int B)
{
	increase(A,B);
	increase(B,A);
	return max_flow(0,N-1);
}
int down_query(int A,int B)
{
	int c = decrease(A,B);
	decrease(B,A);
	if(c==2)swap(A,B);
	if(c==1)return flow;
	else
	{
		memset(used,0,sizeof(used));
		if(dfs(A,B,1)>0)return flow;
		memset(used,0,sizeof(used));
		dfs(N-1,B,1);
		memset(used,0,sizeof(used));
		dfs(A,0,1);
		flow--;
		return flow;
	}
}
int main()
{
	scanf("%d %d %d",&N,&E,&Q);
	for(int i=0;i<E;i++)
	{
		int F,T;
		scanf("%d %d",&F,&T);
		F--;T--;
		ex[F][T]=1;
		ex[T][F]=1;
	}
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			add_edge(i,j,ex[i][j]);
		}
	}
	max_flow(0,N-1);
	for(int i=0;i<Q;i++)
	{
		int M,A,B;
		scanf("%d %d %d",&M,&A,&B);
		A--;B--;
		if(M==1)printf("%d\n",up_query(A,B));
		else printf("%d\n",down_query(A,B));
	}
}

Measured memory_bytes: 7696
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int a, b;
	cin >> a >> b;
	cout << a + b / 2 << "\n";


	return 0;
}

Measured memory_bytes: 892
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

int main()
{
    int x = 0;
    int y = 0;
    int total = 0;
    int backcheck = 0;
    
    scanf("%d %d",&x,&y);
    
    if (x == 1)
    {
        total = total + 300000;
        
        if (y == 1)
        {
            total = total + 300000 + 400000;
            backcheck = 1;
        }
    }
    else if (x == 2)
    {
        total = total + 200000;
    }
    
    else if (x == 3)
    {
        total = total + 100000;
    }
    
    if (y == 1)
    {
        if (backcheck != 1)
        {
            total = total + 300000;
        }
    }
    
    else if (y == 2)
    {
        total = total + 200000;
    }
    
    else if (y == 3)
    {
        total = total + 100000;
    }
    
    
    printf("%d",total);
}


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


int main() {
	ll n,h,MAX=0;
	vector<ll> b;
	cin>>n>>h;
	for(int i=0;i<n;i++){
		ll l,r;
		cin>>l>>r;
		MAX=max(MAX,l);
		b.push_back(r);
	}
	sort(b.begin(),b.end());reverse(b.begin(),b.end());
	ll ans=0,k=0;
	while(h>0){
		h-=b[k];
		ans++;
		k++;
		if(k==n||b[k]<MAX){
			break;
		}
	}
	cout << ( h>0 ? ans+(h+MAX-1)/MAX:ans);
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for (int i=0;i<H;++i) cin >> S[i];
    vector<vector<ll>> sum(2*H+1,vector<ll>(H+1,0))
                        ,dp(H+1,vector<ll>(H+1));
    ll ans=0;
    for (int i=0;i<W-1;++i){
        for (int j=0;j<=2*H;++j){
            for (int k=0;k<H;++k){
                int l=H-j+k;
                sum[j][k+1]=sum[j][k]+(0<=l&&l<H&&S[H-1-k][i]==S[H-1-l][i+1]);
            }
        }
        for (int j=0;j<=H;++j)
            for (int k=0;k<=H;++k)
                dp[j][k]=INF;
        dp[H][H]=0;
        for (int j=H;j>=0;--j){
            for (int k=H;k>=0;--k){
                if (j) dp[j-1][k]=min(dp[j-1][k],dp[j][k]+sum[k+H-j][H]-sum[k+H-j][H-j]);
                if (k) dp[j][k-1]=min(dp[j][k-1],dp[j][k]+sum[k+H-j][H]-sum[k+H-j][H-j]);
            }
        }
        ans+=dp[0][0];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 2560
#include <iostream>

using namespace std;
using ll = long long;

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

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

  int L[n];
  rep(i, n) cin >> L[i];
  int D[n];

  D[0] = 0;
  for (int i = 1; i < n + 1; ++i) { D[i] = D[i - 1] + L[i - 1]; }

  int ans = 0;
  rep(i, n + 1) {
    if (D[i] <= x) { ++ans; }
  }

  cout << ans << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String inputA1 = sc.next();
		String inputB1 = sc.next();
		String inputA2 = sc.next();
		String inputB2 = sc.next();
		String inputA3 = sc.next();
		String inputB3 = sc.next();

		int townA1 = Integer.parseInt(inputA1);
		int townB1 = Integer.parseInt(inputB1);
		int townA2 = Integer.parseInt(inputA2);
		int townB2 = Integer.parseInt(inputB2);
		int townA3 = Integer.parseInt(inputA3);
		int townB3 = Integer.parseInt(inputB3);

		List<Integer> towns = new ArrayList<>();
		towns.add(townA1);
		towns.add(townB1);
		towns.add(townA2);
		towns.add(townB2);
		towns.add(townA3);
		towns.add(townB3);

		List<Integer> result = new ArrayList<>();
		result.add(0);
		result.add(0);
		result.add(0);
		result.add(0);
		for(int i : towns) {
			result.set(i-1, result.get(i-1)+1);
		}

		int onceCount = 0;
		int twiceCount = 0;
		for(int c : result) {
			if(c == 1) {
				onceCount += 1;
			}else if(c == 2) {
				twiceCount += 1;
			}
		}

		if(onceCount == 2 && twiceCount == 2) {
			System.out.println("YES");
			sc.close();
		}else{
			System.out.println("NO");
			sc.close();
		}
	}
}

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

#define LL long long

const int maxN = 1 << 21, mod = 924844033, g = 5, gi = 554906420;

struct Node
{
	int to, next;
}edge[maxN + 1];

int lim, n, cnt, tot;
int f[maxN + 1], r[maxN + 1], size[maxN + 1];
int a[maxN + 1], head[maxN + 1];
int fac[maxN + 1], inv[maxN + 1];
int A[maxN + 1], B[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline int ADD(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }

inline int SUB(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }

inline int mpow(int a, int x)
{
	int ans = 1;
	while(x)
	{
		if(x & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		x >>= 1;
	}
	return ans;
}

inline void add(int x, int y)
{
	tot ++;
	edge[tot].to = y;
	edge[tot].next = head[x];
	head[x] = tot;
}

inline void dfs(int u, int pa)
{
	size[u] = 1;
	for(int i = head[u]; i; i = edge[i].next)
	{
		int v = edge[i].to;
		if(v == pa) continue;
		dfs(v, u);
		size[u] += size[v];
	}
	if(pa) a[ size[u] ] ++, a[ n - size[u] ] ++;
}

inline int C(int n, int m)
{
	if(n < m) return 0;
	return 1ll * fac[n] * inv[n - m] % mod * inv[m] % mod;
}

inline void NTT(int *a, int type)
{
	for(int i = 0; i < lim; i++)
		if(i < r[i]) swap(a[i], a[ r[i] ]);
	for(int mid = 1; mid < lim; mid <<= 1)
	{
		int wn = mpow(type == 1 ? g : gi, (mod - 1) / (mid << 1));
		for(int i = 0; i < lim; i += (mid << 1))
		{
			int w = 1;
			for(int j = 0; j < mid; j++, w = 1ll * w * wn % mod)
			{
				int x = a[i + j], y = 1ll * w * a[i + mid + j] % mod;
				a[i + j] = ADD(x, y); a[i + mid + j] = SUB(x, y);
			}
		}
	}
	if(type == -1)
	{
		int inv = mpow(lim, mod - 2);
		for(int i = 0; i < lim; i++) a[i] = 1ll * a[i] * inv % mod;
	}
}

int main()
{
	n = read();
	for(int i = 1; i < n; i++)
	{
		int x = read(), y = read();
		add(x, y); add(y, x);
	}

	dfs(1, 0);

	fac[0] = 1;
	for(int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[n] = mpow(fac[n], mod - 2);
	for(int i = n - 1; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;

	for(int i = 0; i <= n; i++) A[i] = 1ll * a[n - i] * fac[n - i] % mod;
	for(int i = 0; i <= n; i++) B[i] = inv[i];

	lim = 1, cnt = 0;
	while(lim <= (n << 1)) lim <<= 1, cnt ++;
	for(int i = 0; i < lim; i++) r[i] = (r[i >> 1] >> 1) | ((i & 1) << cnt - 1);

	NTT(A, 1); NTT(B, 1);
	for(int i = 0; i < lim; i++) A[i] = 1ll * A[i] * B[i] % mod;
	NTT(A, -1);

	reverse(A, A + n + 1);
	for(int i = 0; i <= n; i++) A[i] = 1ll * A[i] * inv[i] % mod;
	for(int i = 1; i <= n; i++) printf("%d\n", SUB(1ll * n * C(n, i) % mod, A[i]));
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, a1, a2, a3);
  out((a1 + a2 + a3) >= 22 ? "bust" : "win");
}


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

int sod(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int ans = 0;

  for (int i = 1; i <= N; i++) {
    if (A <= sod(i) && sod(i) <= B) ans += i;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
s = int(input())


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return n * 3 + 1


owned = {s}
n = 2
a = f(s)
while a not in owned:
    owned.add(a)
    a = f(a)
    n += 1
print(n)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    x=n%10;
    if(x==0||x==1||x==6||x==8)
        cout<<"pon"<<endl;
    else if(x==3)
        cout<<"bon"<<endl;
    else
        cout<<"hon"<<endl;

}


Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

// #define int long long

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  // int N;
  // int M;
  // array<int, 1000000> A;
  string S;
  // string T;

  cin >> S;

  bool flag = true;

  for (auto it = S.begin(); it < S.end(); ++it) {
    for (auto it1 = it + 1; it1 < S.end(); ++it1) {
      if (*it == *it1) flag = false;
      if (!flag) break;
      
      
    }
  }

  if (flag) cout << "yes" << endl;
  else cout << "no" << endl;
  
  
  
  // cin >> N;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;
  // cout << num << endl;
  
  return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  if(s[int(s.size())-1] == 's') cout << s << "es" << endl;
  else cout << s << "s" << endl;
  return 0;
}



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

#if __has_include(<local.h>)
#include <local.h>
#endif

using namespace std;

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())
#define ALL(x) (x).begin(),(x).end()

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define IPOW(x,y) LL(pow(x,y))

//Debug
#ifdef LOCAL_H
#define TEST cout << "OK\n"
#define DEBUG(a) a
#else
#define TEST
#define DEBUG(a)
#endif

#ifdef LOCAL_H
[[maybe_unused]]
#endif
const double PI = M_PI;
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const int INF = int(999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const LL LL_INF = LL(999999999999999999);
#ifdef LOCAL_H
[[maybe_unused]]
#endif
const long long MOD = int(1000000007);

//Settings
#ifdef LOCAL_H
const bool DO_BENCHMARK = true;
#endif
const int DOUBLE_ACCURACY = 15;
const int RUN_SOLVE = 1;

#ifndef LOCAL_H
const bool DO_BENCHMARK = false;
#endif

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    for(int do_solve_time = 0;do_solve_time < RUN_SOLVE;do_solve_time++){
        void solve();
        if(DO_BENCHMARK){
            clock_t clock_start = clock();
            solve();
            clock_t clock_end = clock();
            const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
            cout << "\n------------------------------------\n" << time << "[ms]\n";
        }
        else solve();
    }
}

/************************************************************************************************************************************************/
void solve(){
    int N;
    cin >> N;
    vector<int> A (N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    SORT(A);
    vector<bool> canPut (1000001,true);
    int ans = 0;
    for(int i = 0;i < N;i++){
        if(canPut[A[i]]){
            if(i == N-1 || A[i] != A[i+1]){
                ans++;
            }
            for(int j = A[i];j <= 1000000;j+=A[i]){
                canPut[j] = false;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 4336
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramA a = new ProgramA();
            a.main();//実行する

        }

    }
    //ABC170
    class ProgramA
    {
        public void main()
        {
            //入力
            int D = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int n = 26;

            long[] c = new long[n];
            long[] count = new long[n];

            for (int i = 0; i < n; i++)
                c[i] = long.Parse(s[i]);
            
            for (int i = 0;i < D;i++)
            {
                long[] score = new long[n];
                string[] t = Console.ReadLine().Split(' ');

                for (int j = 0; j < n; j++)
                    score[j] = long.Parse(t[j]);

                Console.WriteLine(1);
            }

        }
    }

    class ProgramB
    {
        public void main()
        {

        }
    }

    class ProgramC
    {
        public void main()
        {

            

        }
    }

    

}






Measured memory_bytes: 28116
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
l=[]
for i in [a,b,c,d,e]:
    l.append([(10-i%10)%10,i])

l.sort()
ans=0

for i in range(5):
    if i<=3:
        ans+=l[i][0]+l[i][1]
    else:
        ans+=l[i][1]

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int N;
ll c[10000];
vector<vector<int>> edge;

int order[10000];
int scnt = 0;
bool used[10000];
void dfs(int pos) {
	for (int i = 0; i < edge[pos].size(); i++) {
		auto nxt = edge[pos][i];
		if (!used[nxt]) {
			order[nxt] = scnt;
			scnt++;
			used[nxt] = true;
			dfs(nxt);
		}
	}
}

int main() {
	cin >> N;
	edge.resize(N);
	for (int i = 0; i < N - 1; i++) {
		int c, d;
		cin >> c >> d;
		c--, d--;
		edge[c].push_back(d);
		edge[d].push_back(c);
	}
	ll M = 0;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> c[i];
		ans += c[i];
		M = max(M, c[i]);
	}
	ans -= M;
	cout << ans << endl;
	sort(c, c + N);

	order[0] = 0, scnt = 1, used[0] = true;
	dfs(0);

	for (int i = 0; i < N; i++) {
		cout << c[N - 1 - order[i]] << " ";
	}
	cout << endl;
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    vector<int> mp(1000005, 0);
    for(auto a : A) mp[a]++;
    sort(A.begin(), A.end());
    int cnt = 1;
    for(int i=0; i<N; i++)
    {
        if(i<N-1 && A[i] == A[i+1])
        {
            cnt++;
            continue;
        }
        if(mp[A[i]] != cnt)
        {
            cnt = 1;
            continue;
        }
        cnt = 1;
        for(int j=2*A[i]; j<1000005; j+=A[i])
        {
            mp[j]++;
        }
    }
    int ans = 0;
    for(auto a : A)
    {
        if(mp[a]==1) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7916
#include <iostream>
using namespace std;
int main(void) {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n - i; j++) {
      if (i + 5 * j + 10 * (n - i - j) == y) {
        cout << n - i - j << " " << j << " " << i << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int const MAX_N = 32000000;
vector<long long> prime;
vector<bool> is_prime(MAX_N,true);
void Eratosthenes() {
    is_prime[0] = is_prime[1] = false;
    for (long long i = 2;i*i < MAX_N;++i) if (is_prime[i]) for (long long j = 2*i;j < MAX_N;j += i) is_prime[j] = false;
    for (long long i = 0;i < MAX_N;++i) if (is_prime[i]) prime.push_back(i);
}

vector<pair<long long,int>> prime_factorization(long long a) {
    vector<pair<long long,int>> prime_factor;
    if (is_prime[0]) Eratosthenes();
    for (long long& i : prime) {
        if (i*i > a) break;
        if (a%i == 0) {
            pair<long long,long long> p = make_pair(i,0);
            while (a%i == 0) {
                a /= i;
                p.second++;
            }
            prime_factor.push_back(p);
        }
    }
    if (a != 1) prime_factor.push_back(make_pair(a,1));
    return prime_factor;
}

void rec(vector<long long>& div,vector<pair<long long,int>>& fact,int i,long long d) {
    if (i == fact.size()) {
        div.push_back(d);
        return;
    }
    for (int j = 0;j <= fact[i].second;++j) {
        rec(div,fact,i+1,d);
        d *= fact[i].first;
    }
}

// unsorted
vector<long long> divisor(long long a) {
    vector<long long> div;
    vector<pair<long long,int>> prime_factor = prime_factorization(a);
    rec(div,prime_factor,0,1);
    return div;
}

ll extGcd(ll a,ll b,ll &p,ll &q) {
    if (b == 0) {
        p = 1;
        q = 0;
        return a;
    }  
    ll d = extGcd(b,a%b,q,p);  
    q -= a/b*p;  
    return d;  
}

int main() {
    Eratosthenes();
    ll n;
    cin >> n;
    vector<pair<long long,int>> p = prime_factorization(2*n);
    int m = p.size();
    ll ans = 1e18;
    if (m == 1) ans = 2*n-1;
    for (int s = 0;s < (1<<m);++s) {
        ll u = 1,v;
        for (int j = 0;j < m;++j) if ((s>>j)&1) for (int i = 0;i < p[j].second;++i) u *= p[j].first;
        v = 2*n/u;
        ll x,y;
        extGcd(u,v,x,y);
        // cout << u*x << " " << v*y << endl;
        if (u*x == 0 || v*y == 0) continue;
        ans = min(ans,abs(x*u));
    }
    cout << ans << newl;
}

Measured memory_bytes: 23488
#include <cstdio>
#include <cstring>

#define N 100

static int n;
static int m[ N ];
static int p[ N ][ N ];
static int l[ N ];
static int k;

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int res = -1;

    scanf ( "%d", &n );
    if ( !( n ) ) break ;

    memset ( p, 0, sizeof ( p ) );
    memset ( l, 0, sizeof ( l ) );
    for ( i = 0; i < n; ++i )
    {
      scanf ( "%d", &m[ i ] );

      for ( j = 0; j < m[ i ]; ++j )
      {
        int t;

        scanf ( "%d", &t );
        p[ i ][ t - 1 ] = 1;
      }
    }
    scanf ( "%d", &k );
    for ( i = 0; i < k; ++i )
    {
      scanf ( "%d", &l[ i ] );
      --l[ i ];
    }

    for ( i = 0; i < n; ++i )
    {
      for ( j = 0; j < k; ++j )
      {
        if ( !p[ i ][ l[ j ] ] ) break ;
      }
      if ( j != k ) continue ;
      if ( res == -1 )
      {
        res = i + 1;
      }
      else
      {
        res = -1;
        break ;
      }
    }

    printf ( "%d\n", res );
  }

}

Measured memory_bytes: 0
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder
import kotlin.math.max
import kotlin.math.min

object BMain{
    fun solve(){
        val s = next()
        val t = next()

        var ans = 100000

        for(i in 0 until s.length - t.length + 1){
            var num = 0
            for (j in t.indices){
                if(s[i+j] != t[j]) num++
            }

            ans = min(ans, num)
        }
        println(ans)
    }





    // Scanner based on uwi-san's Java code
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun nextDouble() = next().toDouble()
}

fun main(){
    BMain.solve()
}



Measured memory_bytes: 34144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, a);
    Cout((n % 500 <= a) ? "Yes" : "No");
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;
using System.Runtime.InteropServices.ComTypes;
using System.Xml.Schema;
using System.ComponentModel.DataAnnotations;
using System.Security.Cryptography;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var mNum = Ai.Count(a => a < 0);
            Ai = Ai.Select(a => Abs(a)).ToArray();
            var sum = Ai.Sum();
            if (mNum % 2 == 0)
                WriteLine(sum);
            else
                WriteLine(sum - 2 * Ai.Min());
        }
        static long Gcd(long x, long y) => y == 0 ? x : Gcd(y, x % y);

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 39456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    REPR(i, 101) {
        if (i == 0) continue;
        if (A % i == 0 && B % i == 0) {
            cnt++;
            if (cnt == K) {
                cout << i << endl;
            }
        }
    }
    return (0^_^0);
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


signed main() {
  int A, B, Q; 
  cin >> A >> B >> Q;

  vector<int> s(A+1, -INF);
  REP(i, A) cin >> s[i+1];

  vector<int> t(B+1, -INF);
  REP(i, B) cin >> t[i+1];

  s.emplace_back(INF);
  t.emplace_back(INF);

  vector<int> X(Q);
  REP(i, Q) cin >> X[i];

  for(int x : X){
    int c1 = upper_bound(ALL(s), x)-s.begin();
    int c2 = upper_bound(ALL(t), x)-t.begin();

    int a = s[c1]-x, b = x-s[c1-1], c = t[c2]-x, d = x-t[c2-1];
    cout << min(min(max(b, d), max(a, c)), min(min(a, d)*2+max(a, d), min(b, c)*2+max(b, c))) << endl;
  }

  return 0;
}

Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
vector<int> v(100005);
int main() {
	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> v[i];
	bool ans = true;
	int maxi = v[0];
	for(int i=1;i<n;i++) {
		if(v[i] < maxi-1) ans = false;
		maxi = max(maxi,v[i]);
	}
	if(ans) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
	vector<int> f;
	bool t[200000] = {};
	bool fl=false;
	int n,m;
	int a,b;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		if(a==1){
			f.push_back(b);
		}else if(b==n){
			t[a] = true;
		}
	}
	for(int i=0;i<f.size();i++){
		if(t[f[i]]){
			fl=true;
			break;
		}
	}
	cout<< (fl?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}


Measured memory_bytes: 1020
n = int(input())
a,b,c = list(map(int,input().split()))
dp = [[0]*3 for _ in range(n)]
dp[0][0] = a
dp[0][1] = b
dp[0][2] = c
for i in range(1,n):
  a,b,c = list(map(int,input().split()))
  dp[i][0] = max(dp[i-1][1],dp[i-1][2])+a
  dp[i][1] = max(dp[i-1][0],dp[i-1][2])+b
  dp[i][2] = max(dp[i-1][0],dp[i-1][1])+c
  
ans = max(dp[n-1][0],dp[n-1][1],dp[n-1][2])
print(ans)


Measured memory_bytes: 22772
X, N = map(int, input().split())
P = [int(p) for p in input().split()]
A = X
B = X

while True:
  if B in P:
    B += 1
  else:
    break

while True:
  if A in P:
    A -= 1
  else:
    break
a = abs(X - A)
b = abs(X - B)
if a < b:
  print(A)
elif a > b:
  print(B)
else:
  print(min(A, B))



Measured memory_bytes: 9192