akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	
	int N, K, Q;
	cin >>N >>K >>Q;
	
	vector<int> A(Q);
	vector<int> B(N);
	vector<int> C(N);
	
	for(int i=0; i<Q; i++){
		
		cin >>A.at(i);
		
	}
	
	for(int i=0; i<Q; i++){
		
		B.at(A.at(i)-1)++;
		
	}
	
	for(int i=0; i<N; i++){
		
		if(K-Q+B.at(i)>0){
			
			cout <<"Yes" <<endl;
			
		}
		else{
			
			cout <<"No" <<endl;
			
		}
		
	}
	
	
	
}

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

using namespace std;

int main(){
	int n;
  	string s;
  	bool x;
  	cin >> n >> s;
  	if(n % 1) x = 0;
  	else{
  		if(s.substr(0,n/2) == s.substr(n/2)) x=1;
  		else x=0;
  	}
  	if(x == 1) cout << "Yes"<< endl;
  	else cout << "No" << endl;
}

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

using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define N 2000001
#define M 1000000007
#define INF 1000000000000000

ll gcd(ll a,ll b)
{
    if(b==0)return a;
    else return gcd(b,a%b);
}



int main()
{
    
      ll d,s,t;
      cin>>d>>t>>s;
      ll p=(d/s)+(d%s!=0);
      if(p>t)cout<<"No";
      else cout<<"Yes";
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<array>

int search(int);
int translate(std::array<int, 9>);

struct BoardStatus {
	std::array<int, 9> arrange = {};
	int distance = 0;
	int zero_position = 8;
};

int main()
{
	std::array<int, 9> board;
	for (int i = 0; i < 9; ++i)
		std::cin >> board[i];

	std::cout << search(translate(board)) << std::endl;

	return 0;
}

int search(int dest_num)
{
    if (dest_num == 46233) return 0;
    
	BoardStatus board;
	board.arrange = { 1, 2, 3, 4, 5, 6, 7, 8, 0};
	board.distance = 0;
	board.zero_position = 8;
	
	std::vector<BoardStatus> queue;
	queue.push_back(board);
	int pre_size = 0;
	int table[362880] = { };

	int move_direction[4] = { 1, -1, 3, -3 };

	while (pre_size != queue.size())
	{
		int now_size = queue.size();
		for (int queue_i = pre_size; queue_i < now_size; ++queue_i)
		{
			int zero_pos = queue[queue_i].zero_position;
			bool can_move[4] = {
				zero_pos % 3 != 2, zero_pos % 3 != 0,
				zero_pos / 3 != 2, zero_pos / 3 != 0
			};
			for (int condi_i = 0; condi_i < 4; ++condi_i)
			{
				if (!can_move[condi_i]) continue;

				board = queue[queue_i];
				int next_zero = zero_pos + move_direction[condi_i];

				board.arrange[board.zero_position] = board.arrange[next_zero];
				board.arrange[next_zero] = 0;
				board.zero_position = next_zero;
				board.distance++;

				int num_board = translate(board.arrange);
				if (!table[num_board] && num_board != 46233)
				{
					table[num_board] = board.distance;
					queue.push_back(board);
				}
				if (num_board == dest_num)
					return board.distance;
			}
		}
	}
	return -1;
}

int translate(std::array<int , 9> board)
{
	bool used[9]{};
	int count = 0, tmp, ret = 0, fac = 362880;
	for (int i = 0; i < 9; ++i)
	{
		count = 0;
		tmp = board[i];
		for (int j = 0; j < tmp; ++j)
			if (!used[j])
				count++;
		used[tmp] = true;
		fac /= 9 - i;
		ret += fac * count;
	}
	return ret;
}


Measured memory_bytes: 15748
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if(A<=8 && B<= 8) System.out.println("Yay!");
    else System.out.println(":(");
  }
}


Measured memory_bytes: 22996
A = {}
while True:
    p,s = map(int,input().split(','))
    if p == 0:
        break
    A [p] = s

while True:
    try:
        q = int(input())
    except EOFError:
        break
    st = {A [i] for i in A.keys() if i != q and A [i] > A [q]}
    print(len(st) + 1)

Measured memory_bytes: 7632
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n = 0;
	cin >> n;
	int i = 0; int j = 0;
	unsigned long long res = 0;
	while (n--){
		cin >> i;
		if (i < j){ 
			res += j - i;
			i = j;
		
		}
		j = i;
	}
	cout << res;

	//system("pause");
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
	if((0 <= (x-r) && (x+r) <= W) && (0 <= (y-r) && (y+r) <= H)) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
	int n,a[101],i,j,mini=200,max=-200,cnt,ans=100000000;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&a[i]);
		if(mini>a[i])mini=a[i];
		if(max<a[i])max=a[i];
	}
	for(j=mini; j<=max; j++){
		cnt=0;
		for(i=0; i<n; i++){
			cnt+=abs(a[i]-j)*abs(a[i]-j);
		}
		if(ans>cnt)ans=cnt;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
n,k=map(int,input().split())

d=0
a=[]
for i in range(k):
  a.append([])
for i in range(k):
  d=int(input())
  a[i]=list(map(int,input().split()))

answer=0
for i in range(1,n+1):
  t=0
  for j in range(k):
    if i in a[j]:
      t=1
  if t==0:
    answer+=1

print(answer)

Measured memory_bytes: 67604
#a, b, c, d = (int(i) for i in input().split())  
#W = [int(i) for i in input().split()] 

N= (int(input()))
flag = 0
A_list = []
B_list = []
AB_list = []
for i in range(N):
    a,b= (int(j) for j in input().split())  
    A_list.append(a)
    B_list.append(b)
    AB_list.append([a,b])
    pass
AB_list = sorted(AB_list, key=lambda x: x[1])
#print(AB_list)
now = 0
for ab in AB_list:
   now += ab[0]
   if ab[1] < now:
       flag = 1
       break
   pass
if flag == 1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 42804
using System;

class Program
{
    static int[] a;
    static int[] b;
    static int n;
    static int m;

    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        n = int.Parse(nm[0]);
        m = int.Parse(nm[1]);

        a = new int[m];
        b = new int[m];
        for (int i = 0; i < m; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            a[i] = int.Parse(ab[0]);
            b[i] = int.Parse(ab[1]);
        }

        var ans = 0;
        for (int i = 0; i < m; i++)
        {
            var v = new bool[n];
            m1(1, i, v);

            var all = true;
            for (int j = 0; j < n; j++) all &= v[j];
            if (!all) ans++;
        }

        Console.WriteLine(ans);
    }

    static void m1(int x, int i, bool[] v)
    {
        v[x - 1] = true;
        for (int j = 0; j < m; j++)
        {
            if (j != i)
            {
                if (a[j] == x && !v[b[j] - 1])
                {
                    m1(b[j], i, v);
                }
                else if (b[j] == x && !v[a[j] - 1])
                {
                    m1(a[j], i, v);
                }
            }
        }
    }
}


Measured memory_bytes: 11092
/*
                                                                           __                _________
                                                                          /  \              /  ______/
                                                                         /    \            /  /
                                                                        /  __  \          /  /
                                                                       /  /  \  \         |  |
                                                                      /  /____\  \        \  \
                                                                     /  ________  \        \  \______
                                                                    /__/        \__\        \________\
	
	I_love_Hacked;
	I_hate_pretest past;
	
    coder:xxjAc
    date:2018/3/4 
    
    I_love_Ac;
    I_hate_WA;
    I_hate_Tle;
    I_hate_RE;
    I_hate_CE;
    I_hate_Mle;
    
    I love Accepts very much;
*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
const int inf=1000000007;
unsigned long long M=0,A=0,R=0,C=0,H=0,ans;
string s;
int main(){
	int n;
	scanf("%d",&n);
	for (int i=0;i<n;i++){
		cin>>s;
		if (s[0]=='M'){
		    M++;
		}
		if (s[0]=='A'){
			A++;
		}
		if (s[0]=='R'){
			R++;
		}
		if (s[0]=='C'){
			C++;
		}
		if (s[0]=='H'){
			H++;
		}
	}
	ans=M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		String[] days={"SUN","MON","TUE","WED","THU","FRI","SAT","SUN","MON","TUE","WED","THU","FRI","SAT"};
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		long ans =-1;
		for(int i = 0;i<days.length;i++){
			if(W.equals(days[i])){
				ans=1;
				for(int k=i+1;k<days.length;k++){
					if("SUN".equals(days[k])){
						break;
					}
					ans++;
				}
			}
			if(ans != -1){
				break;
			}
		}
		System.out.println(ans);

	}


}


Measured memory_bytes: 20564
lis=[]
while True:
	w,h=[int(x) for x in input().split()]
	if w==0 and h==0:
		break
	else:
		lis.append([w,h])
c=1
for x in lis:
	w,h=x[0],x[1]
	for i in range(w):
		for j in range(h):
			if i%2==0:
				if j%2==0:
					print("#",end="")
				else:
					print(".",end="")
			else:
				if j%2==0:
					print(".",end="")
				else:
					print("#",end="")

		print()
	print()



Measured memory_bytes: 7012
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s;
		while((s=br.readLine())!=null)
		{
			String binary = Integer.toBinaryString(Integer.parseInt(s));	

			int n = binary.length();
			for(int i=n-1;i>0;i--){
				if(binary.charAt(i)=='0') continue;
				System.out.print((int)Math.pow(2, n-i-1)+" ");
			} 
			char last = binary.charAt(0);
			System.out.print(Integer.parseInt(last+"")*(int)Math.pow(2,n-1));
			System.out.println();
		}
	}
}

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

int main() {
  string S;
  cin>>S;
  int M=S.size();
  int N=0,A=0,B=0;
  for(int i=0;i<M;i++){
    if(S[i]=='S'){
      B++;
    }
    else{
      A++;
    }
    N=max(N,A-B);
  }
  cout<<N*2<<endl;
      
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int N;
    cin >> N;
    cout << ((N+1)/2)-1 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def find(Data, x):
    if Data[x] < 0:
        return x
    else:
        Data[x] = find(Data, Data[x])
        return Data[x] 

def unite(Data, a, b):
    a, b = find(Data, a), find(Data, b)
    if a == b:
        pass
    elif Data[a] < Data[b]:
        Data[a] = Data[a] + Data[b]
        Data[b] = a
    else:
        Data[b] = Data[b] + Data[a]
        Data[a] = b 

n, m = map(int, input().split())
UF = [-1 for i in range(n)]
for i in range(m):
    ai, bi = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    unite(UF, ai, bi)

ans = 0
for i in range(n):
    if UF[i] < 0: ans += 1 
print(ans - 1)

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

using namespace std;

int main(void) {
  long long int cnt = 0, n, i; scanf( "%lld", &n );
  vector<long long int> a( n ), a_plus( n ), a_minus( n ), ans( n, 0 );
  for(i = 0;i < n;i++) { scanf( "%lld", &a[i]) ; }
  for(i = 0;i < n;i++) { a_plus[i] = i + a[i]; a_minus[i] = i - a[i]; }
  for(i = 0;i < n;i++) { if( a_plus[i] < n ) { ans[ a_plus[i] ]++; } }
  for(i = 0;i < n;i++) { if( a_minus[i] < n && a_minus[i] > 0 ) { cnt += ans[ a_minus[i] ]; } }
  printf( "%lld\n", cnt );
  
  return 0;
}

Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>
#include <set>

int main(){
    long N;
    std::cin >> N;
    long temp1=1,temp2=1,temp3=1;;
    long MOD = 1000000000+7;
    for(long i=0; i<N; i++){
        temp1*=10;
        temp1%=MOD;
        temp2*=9;
        temp2%=MOD;
        temp3*=8;
        temp3%=MOD;
    }
    long result=temp1-temp2;
    result=result%MOD;
    result = result-temp2;
    result=result%MOD;
    if(result<0){
        result+=MOD;
    }
    result+=temp3;
    result%=MOD;
    std::cout << result << std::endl;
    return 0;
}

Measured memory_bytes: 3220
with open(0) as f:
    a, b, c, x = map(int, f.read().split())
cnt = 0
from itertools import product
for i,j,k in product(range(a+1), range(b+1), range(c+1)):
    if 500*i + 100*j + 50*k == x:
        cnt += 1
print(cnt) 

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int k, t;
    cin >> k >> t;

    vector<int> v(k);
    vector<pair<int, int>> val(t);
    for (int i = 0; i < t; ++i) {
        cin >> v[i];
        val[i] = {i + 1, v[i]};
    }
    sort(val.begin(), val.end(), [](auto &a, auto &b) {
        return a.second > b.second;
    });
    vector<int> ans(k);
    int id = 0;
    bool fl = false;
    for (auto &x: val) {
        if (id >= k)
            id = 1;
        if (!fl)
            for (; x.second > 0; id += 2) {
                if (x.second == 0)break;
                if (id >= k) {
                    fl = true;
                    break;
                }
                ans[id] = x.first;
                x.second--;
            }
        if (fl) {
            if (k % 2 == 0) {
                if (id >= k)
                    id = k - 1;
                for (; x.second > 0; id -= 2) {
                    if (x.second == 0)break;
                    ans[id] = x.first;
                    x.second--;
                }
            } else {
                if (id >= k)
                    id = 1;
                for (; x.second > 0; id += 2) {
                    if (x.second == 0)break;
                    ans[id] = x.first;
                    x.second--;
                }
            }
        }
    }
//    for (auto x: ans)cout << x << " ";
    cout << endl;
    int ct = 0;
    for (int i = 1; i < k; i++)if (ans[i] == ans[i - 1])ct++;
    cout << ct << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
static const int LEFT = -1000000;
static const int RIGHT = 1000000;
int main() {
    int K, X;
    cin >> K >> X;
    const int limit = min(RIGHT, X + K - 1);
    for (int i = max(LEFT, X - K + 1); i <= limit; i++)
        cout << i << " ";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n;
  cin >> n;
  ll na;
  na = abs(n);
  string s;
  char c;
  ll buf = 1;
  if(n != 0)
  for(i = 0; n != 0 /*&& i < 10*/; i++, buf *= -2){
    c = (n % (buf * 2) != 0) + '0';
    //cout << na % 2 << endl;
    s.push_back(c);
    if(c == '1') n -= buf;
    //cout << buf spa n spa s << endl;
  }
  else s.push_back('0');
  reverse(ALL(s));
  cout << s << endl;
 
  return 0;
}

Measured memory_bytes: 256
import math
N = int(input())
A = list(map(int, input().split()))
li = [0] * int(1e05)
for x in A:
    li[x-1] += 1
num = 0
for x in li:
    if x > 1:
        num += (x-1)/2
print(N-2*math.ceil(num))

Measured memory_bytes: 52984
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/

#define double long double

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

    int n; cin >> n;
    vector <double> A(n);
    for (double &i: A) cin >> i;

    //dp[i] => after 'i' tosses, dp[j] represents the probablity to getting 'j' heads, 0 <= j <= i
    //rest of code is implementation... 
    vector <double> dp(n+1, 0);
    dp[0] = 1;
    for (int coins = 0; coins < n; ++coins) {
        for (int i = coins+1; i >= 0; --i) {
            dp[i] = (i ? dp[i-1]*A[coins] : 0) + dp[i]*(1 - A[coins]);
        }
    }

    double ans = 0;
    for (int heads = 0; heads <= n; ++heads) {
        int tails = n - heads;
        if (heads > tails) ans += dp[heads];
    }

    cout << fixed << setprecision(10);
    cout << ans;



    return 0;
}


Measured memory_bytes: 3912
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n= int( input())
a = list(map(int, input().split()))

r=0
e=False

for i in range(0,n):
  while a[i]>0:
    if a[i]%2==0:
      a[i]=int(a[i]/2)
      r=r+1 
    else:
      break
print(r)


Measured memory_bytes: 4148
#include<iostream>
#include<vector>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

    const long long INF = 1LL << 60;
    long long dp[100010];
    long long h[100010];

int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> h[i];
    for(int i = 0; i < 100010; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < N; i++)
    {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
//Try until you reach your goal
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    str s,s1;
    cin>>s>>s1;
    ll ans=INT_MAX;
    for(ll i=0;i<=s.length()-s1.length();i++){
        ll ans1=0;
        for(ll j=0;j<s1.length();j++){
            if(s1[j]!=s[i+j]){
                ans1++;
            }
        }
        ans=min(ans1,ans);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;//scanf("%d",&n);
	int sum=0,m=0,b=n;
	while(n>0){
		m=n%10;
		n/=10;
		sum+=m;
	}
	if(b%sum==0) cout<<"Yes"<<endl;//printf("Yes\n");
	else if(b%sum!=0) cout<<"No"<<endl;//printf("No\n");
	return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
CA = []
for _ in range(N):
    tmp = list(map(int, input().split()))
    CA.append(tmp)

ans = -1
for i in range(2**N):
    tmp_cost = 0
    tmp_X = [0]*(M+1)
    for j in range(N):
        if ((i >> j) & 1):
            for k in range(M+1):
                tmp_X[k] += CA[j][k]
    for j in range(1, M+1):
        if tmp_X[j] < X:
            break
    else:
        if ans == -1:
            ans = tmp_X[0]
        else:
            ans = min(ans, tmp_X[0])
print(ans)


Measured memory_bytes: 9212
import java.util.*;

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

        int n = scn.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = scn.nextInt();
        }

        int min = a[0];
        int max = a[0];
        long sum = a[0];

        for (int i = 1; i < (n); i++) {
            min = Math.min(min,a[i]);
            max = Math.max(max,a[i]);
            sum = sum + (long)a[i];
        }

        System.out.println(min+" "+max+" "+sum);

        scn.close();


    }
}


Measured memory_bytes: 41356
#include <stdio.h>
#include <stdlib.h>
int min(int a, int b ){
  if (a > b) {
    return b;
  } else {
    return a;
  }
}
int main(void) {
  int n,a[1000],ans;
  scanf("%d",&n );
  while(n){
    ans = 1000000;
    for (int i = 0; i < n; i++) {
      scanf("%d",&a[i] );
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i != j) {
          ans = min(ans, abs(a[j] - a[i]));
        }
      }
    }
    printf("%d\n",ans );
    scanf("%d",&n );
  }
  return 0;
}


Measured memory_bytes: 2600
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>edge[100005];
int n;
P R[100005];
bool bad = 0;
void dfs(int v,int u){
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		dfs(edge[v][i],v);
		int w = edge[v][i];
		P x = R[w];
		if(x.first < -1e7) continue;
		if(R[v].first > -1e7 && x.first%2 == R[v].first%2){
			bad = 1;
		}
		R[v].fi = max(R[v].first,x.first-1);
		R[v].sc = min(R[v].sc,x.sc+1);
	}
	if(R[v].fi > R[v].sc) bad = 1;
}
void make(int v,int val,int u){
	if(R[v].fi <= val-1 && val-1 <= R[v].sc) R[v] = mp(val-1,val-1);
	else R[v] = mp(val+1,val+1);
	for(int i=0;i<edge[v].size();i++){
		if(edge[v][i] == u) continue;
		make(edge[v][i],R[v].fi,v);
	}
}
int main()
{
	cin >> n;
	for(int i=1;i<n;i++){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	for(int i=1;i<=n;i++){
		R[i] = mp(-INF,INF);
	}int m; cin >> m;
	for(int i=0;i<m;i++){
		int v,a; scanf("%d%d",&v,&a);
		R[v] = mp(a,a);
	}
	dfs(1,-1);
	if(bad){
		puts("No"); return 0;
	}
	make(1,R[1].first+1,-1);
	puts("Yes");
	for(int i=1;i<=n;i++) printf("%d\n",R[i].fi);
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
}


Measured memory_bytes: 3636
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    auto inp = aryread();
    long cnt;
    while (!inp[1 .. $].all!(x => x == inp[0]))
    {
        cnt++;
        inp.sort();
        // writeln(inp);
        if (inp[1] == inp[2])
        {
            inp[0] += 2;
        }
        else
        {
            inp[0]++;
            inp[1]++;
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;


int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio

    ll n, i, j;
    cin>>n;
    ll dp[n+9], a[n+9];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }

    dp[n-1]=0;
    dp[n-2]=abs(a[n-1]-a[n-2]);
    for(i=n-3; i>=0; i--)
    {
        dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]), dp[i+2]+abs(a[i]-a[i+2]));
    }
    cout<<dp[0];
}



Measured memory_bytes: 5156
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;

fn exec() {
    let mut sc = Scanner::new();
    let a: i32 = sc.ne();
    let b: i32 = sc.ne();
    if a == b {
        println!("Draw");
        std::process::exit(0);
    }
    let alice = a == 1 || (b != 1 && a > b);
    println!("{}", if alice { "Alice" } else { "Bob" });
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
    
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
    
struct test{
    int p;
    int q;
    int r;
    int s;
    
    bool operator <(const test& right) const {
        return s < right.s;
    }
};
    
int solve(int a, int b, int c){
    int n;
    cin >> n;
    vector<struct test> v;
    vector<int> ans(a+b+c, -1);
    REP(i, n){
        int p, q, r, s;
        cin >> p >> q >> r >> s;
        p--; q--; r--;
        v.push_back((test){p, q, r, s});
        if(s == 1) ans[p] = ans[q] = ans[r] = 1;
    }
    sort(v.begin(), v.end());
    
    int i = 0;
    while(v[i].s == 0){
        int u = ans[v[i].p] + ans[v[i].q] + ans[v[i].r];
        if(u == 1){
            if(ans[v[i].p] == -1) ans[v[i].p] = 0;
            if(ans[v[i].q] == -1) ans[v[i].q] = 0;
            if(ans[v[i].r] == -1) ans[v[i].r] = 0;
        }
        
        i++;
    }
    
    REP(j, a+b+c) if(ans[j] == -1) ans[j] = 2;
    REP(j, a+b+c) cout << ans[j] << endl; 
}
    
int main(){
    while(true){
        int a, b, c;
        cin >> a >> b >> c;
        if(a == 0) return 0;
        solve(a, b, c);
    }
}

        

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

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


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll dp[15][15],A[300001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll n,sum=0;
 cin>>n;
 for(int i=1;i<=n;i++)
 {

     ll d=i,cnt=0;
     while(d!=0)
     {
        A[cnt]=d%10;
        cnt++;
        d/=10;
     }
     if(A[0]!=0)
     dp[A[cnt-1]][A[0]]++;

     //cout<<i<<" "<<dp[A[cnt-1]][A[0]]<<" "<<A[cnt-1]<<" "<<A[0]<<endl;
     sum+=2*dp[A[0]][A[cnt-1]];
     if(A[0]==A[cnt-1])
     {
         sum--;
     }
     //cout<<dp[A[0]][A[cnt-1]]<<" "<<sum<<endl;
 }
 cout<<sum<<endl;
return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int pre, now;
  int preflag=0, nowflag;
  int count;
  cin >> pre;
  for (int i=0; i<N-1; i++) {
    cin >> now;
    if (pre < now) {
      nowflag=1;
    } else if (pre > now) {
      nowflag=-1;
    }
    if (preflag == nowflag) count++;
    preflag = nowflag;
    pre = now;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

//v:0-index

struct UnionFind{
    ll par[200010];
    ll r[200010];

    UnionFind(ll n){
        rep(i,n){
            par[i]=i;
            r[i]=0;
        }
    }

    ll find(ll x){
        if(par[x]==x)
        return x;
        else return par[x] =find(par[x]);
    }

    void unite(ll x,ll y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(r[x] <r[y]){
            par[x] =y;
        }
        else{
            par[y] =x;
            if(r[x] ==r[y]) r[x]++;
        }
    }

    bool same(ll x,ll y){
        return find(x) ==find(y);
    }
};

struct edge{  
    ll u,v,cost;
};

bool comp(const edge& e1,const edge& e2){
    return  e1.cost <e2.cost;
}

vector<edge> es;
ll V,E;

ll  kruskal(ll V){
    sort(all(es),comp);
    UnionFind uf(V);
    ll res=0;
    rep(i,(ll)es.size()){
        edge e=es[i];
        if(!uf.same(e.u,e.v)){
            uf.unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll s,t,w;
    cin>>V>>E;
    es.resize(E);
    rep(i,E){
        cin>>s>>t>>w;
        es[i]={s,t,w};
    }
    /*
    rep(i,es.size()){
        cout<<es[i].u<<" "<<es[i].v<<" "<<es[i].cost<<endl;
    }
    cout<<endl;
    */
    ll ans=kruskal(V);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5348
h = Array.new(4){ Array.new(3){ Array.new(10,0) } }
n = gets.to_i
n.times do
  a,b,c,d = gets.split.map(&:to_i)
  h[a-1][b-1][c-1] += d
end
 
for i in 0...4
  puts "#"*20 if i>0
  for j in 0...3
    puts " "+h[i][j].join(" ")     
  end
end


Measured memory_bytes: 6900
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int X[3];
	cin >> X[0] >> X[1] >> X[2];
	sort(X, X+3);
	cout<< X[0] << " " << X[1] << " " << X[2] <<endl;
	return 0;
}

Measured memory_bytes: 3152
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    let n = get!(usize);
    let mut r = get!(u64);
    for _ in 1..n {
        let t = get!(u64);
        r = lcm(r, t);
    }
    println!("{}", r);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n, m, q;
    cin >> n >> m >> q;

    vll a(q), b(q), c(q), d(q);
    REP(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }

    ll res = 0, xxx = n + m - 2;
    REP(bi, 1LL << xxx) {
        vll v(n, 1);
        ll id = 1;
        REP(i, xxx) {
            if ((bi >> i) & 1) {
                v[id]++;
                if (v[id] == m) {
                    FOR(j, id, n - 1) v[j] = m;
                    break;
                }
            }
            else {
                v[id + 1] = v[id];
                if (++id == n) break;
            }
        }
        ll mem = 0;
        REP(i, q) {
            if (v[b[i]] - v[a[i]] == c[i]) mem += d[i];
        }
        chmax(res, mem);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;

int main() {
    int N, X, Y; cin >> N >> X >> Y;
    X--; Y--;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dist[i][j] = j-i;
    
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dist[i][j] = min(dist[i][j], abs(dist[i][X])+1+abs(dist[Y][j]));
    
    vector<int> ans(N+1,0);
    for (int i = 0; i < N; i++)
    {
        for (int j = i+1; j < N; j++)
        {
            ans[dist[i][j]]++;
        }        
    }
    for (int i = 1; i < N; i++)
    {
        cout << ans[i] << '\n';
    }
    
    
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    set<int> st;
    rep(i,n){
        int x;cin>>x;
        st.insert(x);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	int s;
	cin >> s;
	vector<int>V;
	V.push_back(s);
	int ans;
	for (int i = 0; i < 1000; ++i) {
		if (V[V.size() - 1] % 2 == 0) {
			V.push_back(V[V.size() - 1]/2);
		}
		else {
			V.push_back(V[V.size() - 1] * 3 + 1);
		}
		for (int j = 0; j < V.size()-1; ++j) {
			for (int k = j + 1; k < V.size(); ++k) {
				if (V[j] == V[k]) {
					ans = k;
					cout << k+1 << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,k,a[2010],num[2010],tmp,ans;
int main(){
	scanf("%d%d",&n,&k),tmp=1ll*k*(k-1)/2%mod;
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]),++num[a[i]];
		for(int j=1;j<n;++j)ans=(ans+k*(a[j]>a[i]))%mod;
	}
	for(int i=2000;i>=1;--i)num[i]+=num[i+1];
	for(int i=1;i<=n;++i)ans=(ans+1ll*tmp*num[a[i]+1])%mod;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
num = []
(1..N).each do |i|
  num.push i
end
nums = num.permutation(N).to_a
res = []

2.times{
  a = gets.split.map(&:to_i)
  res.push nums.index(a)
}
p (res[0] - res[1]).abs

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

#define max(a, b) ((a > b) ? a : b)
#define min(a, b) ((a < b) ? a : b)

#define forn(n) for(int i = 0; i < n; i++)
#define fork(k, n) for(int i = k; i < n; i++)

#define pb(n) push_back(n);

typedef long long ll;
typedef double dbl;

const int MX = 1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;


int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
	//Code here bby
  double d, t, s;
  cin>>d>>t>>s;
  if(d/t <= s){
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;

void solve()
{
    int n; cin>>n;
    struct camel
    {
        int k;
        int dif;
    };
    vector<camel> lft,rgt;
    i64 ans=0;

    for(int i=0; i<n; ++i)
    {
        int k,l,r; cin>>k>>l>>r;
        if(l>r) lft.push_back({k-1,l-r}),ans+=r;
        else rgt.push_back({k,r-l}),ans+=l;
    }
    int L=lft.size();
    vector<vector<int>> lls(n);
    for(auto c: lft)
    {
        lls[min(L-1,c.k)].push_back(c.dif);
    }
    priority_queue<int> ll;
    for(int i=L-1; i>=0; i--)
    {
        for(int d: lls[i]) ll.emplace(d);
        if(ll.empty()) continue;
        ans+=ll.top();
        ll.pop();
    }

    vector<vector<int>> rrs(n+1);
    for(auto c: rgt)
    {
        rrs[max(L,c.k)].push_back(c.dif);
    }
    priority_queue<int> rr;
    for(int i=L; i<n; i++)
    {
        for(int d: rrs[i]) rr.emplace(d);
        if(rr.empty()) continue;
        ans+=rr.top();
        rr.pop();
    }
    cout << ans << "\n";
}

main()
{
    int T; cin>>T;
    while(T--)
    {
        solve();
    }
}

Measured memory_bytes: 17624
#include<stdio.h>
 
int main(){
 long int a,b,ab,tmp,r,retval;
  retval=scanf("%ld %ld",&a,&b);
  if(a>b){
    tmp=a;
    a=b;
    b=tmp;
  }
  ab=a*b;
  r=b%a;
  while(r!=0){
    b=a;
    a=r;
    r=b%a;
  }
  printf("%ld",ab/a);
  return 0;
}	


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main()
{
    unsigned long long int a,b;
    //while(scanf("%llu %llu",&a,&b)){
        scanf("%llu %llu",&a,&b);
        unsigned long long int i=0;
        while(a<=b){
            a*=2;
            i++;
            /*if(a>=500000000000000000){
                break;
            }*/
        }
        /*while(a*pow(2,i)<=b){
            i++;
            if(a>=500000000000000000){
                break;
            }
            printf("%llu\n\n",a*(unsigned long long int)pow(2,i));
        }*/
        printf("%llu",i);
   // }
    
}


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

using namespace std;

#define MP make_pair
#define FF first
#define SS second

using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using PILL = pair<LL,PII>;

const LL INF = 1e15;
const int UB = 400010;

int N, M, S, Gl;
map<PLL,int> ids;
LL dist[UB];
void dijk(vector<vector<PLL>>& G){
  priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
  fill(dist, dist+UB, INF);
  pq.push(PLL(0,ids[MP(S,0)]));
  dist[ids[MP(S,0)]] = 0;

  while(!pq.empty()){
	PLL p = pq.top();
	pq.pop();
	if(p.FF > dist[p.SS])
	  continue;
	  
	for(auto&& e: G[p.SS]){
	  if(p.FF + e.SS < dist[e.FF]){
		dist[e.FF] = p.FF + e.SS;
		pq.push(MP(dist[e.FF], e.FF));
	  }
	}
  }
}

int main(){
  cin >> N >> M >> S >> Gl;
  --S;
  --Gl;
  int id = 0;
  
  vector<vector<int>> tms(N);
  ids[MP(0,S)] = id++;
  tms[S].push_back(0);
  vector<vector<PLL>> G(UB);
  for(int i=0;i<M;++i){
	int u, v, t, c;
	cin >> u >> v >> t >> c;
	--u;
	--v;
	if(!ids.count(MP(u,t)))
	  ids[MP(u,t)] = id++;
	if(!ids.count(MP(v,t+c)))
	  ids[MP(v,t+c)] = id++;
	tms[u].push_back(t);
	tms[v].push_back(t+c);
	G[ids[MP(u,t)]].emplace_back(ids[MP(v,t+c)], 0);
  }

  for(int i=0;i<N;++i){
	sort(begin(tms[i]), end(tms[i]));
	tms[i].erase(unique(begin(tms[i]), end(tms[i])), end(tms[i]));
	for(int j=0;j+1<tms[i].size();++j){
	  G[ids[MP(i,tms[i][j])]].emplace_back(ids[MP(i,tms[i][j+1])], tms[i][j+1] - tms[i][j]);
	}
  }

  dijk(G);
  LL ans = INF;
  for(auto&& t: tms[Gl])
	ans = min(ans, dist[ids[MP(Gl,t)]]);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 60960
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int r,g,b;
  int res;
  cin>>r>>g>>b;
  res=r*100+g*10+b;
  if(res%4==0) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    var n = parseInt(input[0], 10);
    var b = input[1].split(' ');
    b = b.map(str => parseInt(str, 10));
    var aSumMax = 0;
    for(var i = 0; i < n; i++){
        switch(i){
            case 0:
                aSumMax += b[0];
                break;
            case n-1:
                aSumMax += b[n-2];
                break;
            default:
                aSumMax += Math.min(b[i-1],b[i])
        }
    }

	console.log(aSumMax);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
	boost
	ll n,W;
	cin>>n>>W;
	pair<ll,ll> p[n+1];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>p[i].fi>>p[i].se;
		sum+=p[i].se;
	}
	ll dp[n][sum+1]={0};
	for(ll i=1;i<=sum;i++)
	{
		if(i>p[0].se)dp[0][i]=inf;
		else dp[0][i]=p[0].fi;
	}
	for(ll i=1;i<n;i++)
	{
		for(ll j=0;j<=sum;j++)
		{
			dp[i][j]=min(dp[i-1][j],p[i].fi+dp[i-1][max(0LL,j-p[i].se)]);
		}
	}
	for(ll i=sum;i>=0;i--)
	{
		if(dp[n-1][i]<=W)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
    int n, m, odd_2, even_2, total;
    cin >> n >> m;
    even_2 = n*(n-1)/2;
    odd_2 = m*(m-1)/2;
    total = odd_2 + even_2;
    if(n == 1 && m == 1){
        cout << 0 << endl;
    }else if(n==0){
        cout << odd_2 << endl;
    }else if(m==0){
        cout << even_2 << endl;
    }else{
        
        cout << total << endl;
    }
    return 0;
}

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

def solve(s: str):
    print(s.count("1"))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    s = input()
    solve(str(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940