akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func swap(a int64, b int64) (int64, int64) {
	return b, a
}

func gcd(a int64, b int64) int64 {
	if b > a {
		a, b = swap(a, b)
	}
	if b == 0 {
		return a
	} else {
		return gcd(a%b, b)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int64) int64 {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int64(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func nextLong() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func nextByte() byte {
	sc.Scan()
	s := sc.Bytes()
	return s[0]
}

func main() {
	sc.Split(bufio.ScanWords)
	//ans := 1
	N := nextInt()
	K := nextInt()
	S := nextInt()
	if S != 1e9 {
		for i := 0; i < K; i++ {
			if i != K-1 {
				fmt.Printf("%d ", S)
			} else {
				if K == N {
					fmt.Printf("%d\n", S)
				} else {
					fmt.Printf("%d ", S)
				}
			}

		}
		for i := 0; i < N-K; i++ {
			if i != N-K-1 {
				fmt.Printf("%d ", S+1)
			} else {
				fmt.Printf("%d\n", S+1)
			}
		}

	} else {
		for i := 0; i < K; i++ {
			if i != K-1 {
				fmt.Printf("%d ", S)
			} else {
				if K == N {
					fmt.Printf("%d\n", S)
				} else {
					fmt.Printf("%d ", S)
				}
			}

		}
		for i := 0; i < N-K; i++ {
			if i != N-K-1 {
				fmt.Printf("%d ", 1)
			} else {
				fmt.Printf("%d\n", 1)
			}
		}

	}
}


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

using namespace std;

const ll MOD = (ll)1e9 + 7 ;
const int MAXN = 1e5 + 100;

void solve(){
    int k , n;
    cin >> k >> n;
    vector<int> a(n);
    for(auto & x: a)
        cin >> x;
    int mxgap = 0;
    for(int i = 0; i < n; ++i){
        if( i == n - 1){
            int gap = abs(k - a[i]) +  a[0];
            mxgap = max(mxgap, gap);
        } else {
            int next = a[i + 1];
            mxgap = max(mxgap, abs(next - a[i]));
        }
    }
    cout << k - mxgap << '\n';

}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
class Node:
    def __init__(self, val=None, prev=None, next=None):
        self.val = val
        self.prev = prev
        self.next = next

class DoublyLinkedList():
    def __init__(self):
        self.start = Node(val='START', prev=None, next=None)
        self.end = Node(val='END', prev=self.start, next=None)
        self.start.next = self.end

    def insert(self, x):
        new_node = Node(val=x, prev=self.end.prev, next=self.end)
        self.end.prev.next = new_node
        self.end.prev = new_node

    def dump(self):
        node_list = []
        crnode = self.start.next
        while crnode != self.end:
            node_list.append(crnode.val)
            crnode = crnode.next
        print(' '.join(list(map(str, node_list))))

    def extend(self, dll):
        self.end.prev.next = dll.start.next
        dll.start.next.prev = self.end.prev
        self.end = dll.end

n, q = list(map(int, input().split(' ')))
splice = [DoublyLinkedList() for i in range(n)]

for i in range(q):
    op, *val = list(map(int, input().split(' ')))
    if op == 0:
        splice[val[0]].insert(val[1])
    elif op == 1:
        splice[val[0]].dump()
    else:
        splice[val[1]].extend(splice[val[0]])
        splice[val[0]] = DoublyLinkedList()



Measured memory_bytes: 144272
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long ans=1;
		for(int i=0;i<n;i++) ans*=(n-i);
		System.out.println(ans);
		sc.close();
	}
}

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

int main() {

  int N;
  cin >> N;

  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int answer = 2001000;

  for (int i = -100; i <= 100; i++) {
    
    int cost = 0;
    
    for (int j = 0; j < N; j++) {
      cost += pow(abs(i - a[j]),2);
    }

    answer = min(answer, cost);

  }

  cout << answer << endl;
  
  return 0;

}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

void we_r_done(){cout<<"NO"; exit(0);}

void debug(string mssg){cout<<mssg; exit(0);}

struct rest{
    string name ;
    int point;
    int idx;
    rest(string s,  int p , int i){
        name = s;
        point = p;
        idx = i;
    }
};

bool operator<(rest a , rest b){

    if(a.name<b.name) return true;
    else if(a.name == b.name) return (a.point>b.point);
    return false;
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    int n;
    cin>>n;
    vector<rest>v;

    vector<rest>inp;

    for(int i=0; i<n; i++){
        string s;
        int p;
        cin>>s>>p;
        v.pb(rest(s,p,i+1));
    }

    sort(atoz(v));

    for(int i=0; i<v.size(); i++){

        printf("%d\n",v[i].idx);
    }

    return 0;
    ///return main();
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///priority_queue< int, vector< int >, greater< int > > minHeap;
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		String firstPart = s.substring(0, 4);
		String secondPart = s.substring(4, 12);
		System.out.println(firstPart + " " + secondPart);
		scan.close();
	}

}


Measured memory_bytes: 9808
def main():
    H, W = (int(i) for i in input().split())
    C = [[int(i) for i in input().split()] for j in range(10)]
    A = [[abs(int(i)) for i in input().split()] for j in range(H)]
    determined = set()
    from collections import deque
    notdetermined = deque()
    r = [0] * 10
    for k in range(10):
        r[k] = C[k][1]
    
    from itertools import permutations
    for sel in range(1,10):
        for p in permutations([0,2,3,4,5,6,7,8,9,],sel):
            cur = 0
            k = p[0]
            for i in p[1:]:
                cur += C[k][i]
                k = i
            else:
                cur += C[k][1]
            if cur < r[p[0]]:
                r[p[0]] = cur
    ans = 0
    for row in A:
        for a in row:
            ans += r[a]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42860
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if (H[i] < H[i+1]):
        H[i+1] -= 1
    

for j in range(N-1):
    if (H[j] > H[j+1]):
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 14252
// ProblemURL : https://atcoder.jp/contests/abc121/tasks/abc121_d
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	f := func(x int) int {
		if x == 0 {
			return 0
		}
		switch x % 4 {
		case 0:
			return x
		case 1:
			return 1
		case 2:
			return x + 1
		default:
			return 0
		}
	}

	if a > 0 {
		fmt.Println(f(b) ^ f(a-1))
	} else {
		fmt.Println(f(b))
	}
}


Measured memory_bytes: 512
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    else:
        for h in range(H):
            if h % 2 == 0:
                for w in range(W):
                    if w % 2 == 0:
                        print("#", end="")
                    else:
                        print(".", end="")
            else:
                for w in range(W):
                    if w % 2 == 0:
                        print(".", end="")
                    else:
                        print("#", end="")
            print ()
        print ()




Measured memory_bytes: 7000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[200010];



/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y)
{
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

void init()
{
	/*kai[0] = 1;
	for (int i = 1; i <= 10000; i++)
	{
		kai[i] = kai[i - 1] * i % mod;
	}*/
	
}

void output()
{
	
}

void solve()
{
	ll H, W, N;
	cin >> H >> W >> N;
	if (H > W)
	{
		cout << (N - 1) / H + 1 << endl;
	}
	else
	{
		cout << (N - 1) / W + 1 << endl;
	}
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string S;
  cin >> S;

  const char* s = S.c_str();
  size_t lose = 0;
  for (size_t i = 0; i < S.size(); i++) {
    if (s[i] == 'x') lose++;
  }

  if (lose >= 8) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

  return 0;
}

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

typedef pair<int, int> ii;

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

	vector<ii> arr(n);
	for (int i = 0; i < n; ++i) {
		cin >> arr[i].first;
		arr[i].second = i;
	}

	sort(arr.begin(), arr.end());
	vector<int> ans(n);
	for (int i = 0; i < n / 2; ++i) {
		ans[arr[i].second] = arr[n / 2].first;
	}
	for (int i = n / 2; i < n; ++i) {
		ans[arr[i].second] = arr[n / 2 - 1].first;
	}

	for (int i = 0; i < n; ++i) {
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 4480
/*
 * atcoder/abc97/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * なぜ部分文字列(substr)の長さをKで探索を打ち切って良いのか.
 * 答えとなるsubstrの長さがK+n(n>=1)だと仮定する. ---①
 * 長さK+nの部分文字列が存在するので長さ1, 2, 3, ..., K,...,K+(n-1)の部分文字列もそれぞれ存在する.
 * 先頭から1, 2, 3, ..., K+(n-1)までのそれぞれの部分は共通している.
 * よって1, 2, 3, ..., Kまでの部分文字列は必ずK+1よりも辞書順で小さい.
 * これは①に矛盾するので答えとなる部分文字列の長さの最大値はKである.
 */
string S;
int K, N;
vector<string> subs;
int counter[200] = {0};

void solve() {
  cin >> S >> K;
  N = S.size();
  for (int len=1; len<=K; len++) {
    for (int l=0; l+len<=N; l++) {
      subs.push_back(S.substr(l, len));
    }
  }
  sort(subs.begin(), subs.end());
  unique(subs.begin(), subs.end());
  cout << subs[K-1] << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

long gcd(long a, long b) { // aとbの最小公倍数（ユークリッドの互除法）
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

long lcm(vector<int> &a) { // 3つ以上の整数の最小公倍数
    long ans = 1;
    rep(i, a.size()) {
        ans = lcm(ans, a[i]);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    cout << lcm(a) << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b - a == c - b) cout<< "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
    int x;
    cin>>x;
    if(x>=400&&x<=599)
    {
        cout<<8<<endl;
    }
    else if(x>=600&&x<=799)
    {
        cout<<7<<endl;
    }
    else if(x>=800&&x<=999)
    {
        cout<<6<<endl;
    }
    else if(x>=1000&&x<=1199)
    {
        cout<<5<<endl;
    }
    else if(x>=1200&&x<=1399)
    {
        cout<<4<<endl;
    }
    else if(x>=1400&&x<=1599)
    {
        cout<<3<<endl;
    }
    else if(x>=1600&&x<=1799)
    {
        cout<<2<<endl;
    }
    else if(x>=1800&&x<=1999)
    {
        cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
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;}
 
ll int a[100000];
ll int b[100000];

int main(){
  ll int ans = 0;
  int n;
  cin >> n;
  REP(i, n+1) cin >> a[i];
  REP(i, n) cin >> b[i];
  REP(i, n){
    ll int taosu = min(a[i], b[i]);
    b[i] -= taosu;
    a[i] -= taosu;
    ans += taosu;
    taosu = min(a[i+1], b[i]);
    b[i] -= taosu;
    a[i+1] -= taosu;
    ans += taosu;
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);

  sort(S.begin(), S.end());
  S.push_back("");

  vector<string> ans;
  for (int i = 1, cnt = 1, Max = 0; i <= N; i++) {
    if (S.at(i - 1) != S.at(i)) {
      if (cnt > Max) {
        ans.clear();
        Max = cnt;
      }
      if (cnt >= Max) ans.push_back(S.at(i - 1));
      cnt = 1;
    }
    else cnt++;
  }

  for (int i = 0; i < ans.size(); i++) cout << ans.at(i) << "\n";
}

Measured memory_bytes: 19172
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	switch N {
	case 22:
		fmt.Println("Christmas Eve Eve Eve")
	case 23:
		fmt.Println("Christmas Eve Eve")
	case 24:
		fmt.Println("Christmas Eve")
	case 25:
		fmt.Println("Christmas")
	}
}


Measured memory_bytes: 512
implicit none
integer(8):: n,y,i,j,count

read(5,*) n,y
count=0

do i=0,n
    do j=0,n-i
    if (10000*i+5000*j+1000*(n-i-j)==y) then
        write(6,*) i,j,n-i-j
        count=1
        goto 100
    endif
    
    enddo
enddo

if (count==0) then
    write(6,*) -1,-1,-1
endif

100 end


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];
	}
	int tmp = a[0];
	int cnt = 1;
	int ans = 0;
	for(int i = 1; i < n; i++) {
		if(tmp == a[i]){
			cnt++;
		}
		else{
			tmp = a[i];
			ans += (cnt / 2);
			cnt = 1;
		}
	}
	ans += (cnt /2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
def hantei(x):
    k = 0
    for i in range(2, x//2):
        if x % i == 0:
            k += 1
    if k ==0:
        return x

c = True
while c:
    hantei(a)
    b = hantei(a)
    if b is not None:
        print(b)
        c = False
    elif b is None:
        a += 1

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);i++)
#define FOR2(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair
#define FAST ios_base::sync_with_stdio(false); cin.tie(0)

template<class T,class U>
ostream &operator<<(ostream &os,const pair<T,U> &x) {
    return os<<"("<<x.first<<","<<x.second<<")";
}

template<class T>
ostream &operator<<(ostream &os,const vector<T> &x) {
    os << '[';
    if ( !x.empty() ) {
        std::copy (x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
        os << "\b";
    }
    os << "]";
    return os;
}
template<class T>
ostream &operator<<(ostream &os,const vector<vector<T> > &x) {
    os << '[';
    if ( !x.empty() ) {
        for (auto v: x) os << v << ",";
        os << "\b";
    } else os << "[]";
    os << "]";
    return os;
}


vector<int> p, r;

void link(int x,int y) {
    if (r[x] > r[y]) p[y] = x;
    else {
        p[x] = y;
        if (r[x] == r[y]) r[y]++;
    }
}

int find_set(int i){
    if(p[i] != i) p[i] = find_set(p[i]);
    return p[i];
}

void dj_union(int i,int j){
    link(find_set(i),find_set(j));
}

int main() {
  //  freopen("in.txt","r",stdin);
    int n,m;cin>>n>>m;
    p.resize(n),r.resize(n,0);
    for (int i=0;i<n;i++) p[i]=i;
    vi pp(n);
    FOR(i,n) {cin>>pp[i];pp[i]--;}
    int x,y;

    FOR(i,m){
        cin>>x>>y;
        dj_union(--x,--y);
    }
    int cnt=0;
    FOR(i,n){
        if (find_set(i)==find_set(pp[i])) cnt++;
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define inf 0x3F3F3F3F
using namespace std;
int main(void)
{
	int a,b,c,ans=inf;
	scanf("%d%d%d",&a,&b,&c);
	ans=min(ans,abs(b-a)+abs(c-b));//abc
	ans=min(ans,abs(c-a)+abs(b-c));//acb
	ans=min(ans,abs(a-b)+abs(c-a));//bac
	ans=min(ans,abs(c-b)+abs(a-c));//bca
	ans=min(ans,abs(a-c)+abs(b-a));//cab
	ans=min(ans,abs(b-c)+abs(a-b));//cba
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N;

    scanf("%d", &N);

    int i;
    
    int *A = (int *) malloc(sizeof(int) * N);

    for(i = 0; i < N; i ++){
        scanf("%d", A + i);
    }
    int *B = (int *) malloc(sizeof(int) * N);
    
    for(i = 0; i < N; i ++){
        scanf("%d", B + i);
    }
    int *C = (int *) malloc(sizeof(int) * (N - 1));

    for(i = 0; i < N - 1; i ++){
        scanf("%d", C + i);
    }
    int current = A[0] - 1;
    int sum = B[current];
    int prev = current;

    for(i = 1; i < N; i ++){
        current = A[i] - 1;
        sum += B[current];

        if(current == prev + 1){
            sum += C[prev];
        }
        prev = current;
    }
    printf("%d\n", sum);
}

Measured memory_bytes: 128
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int array[3];
	int k;
	rep(i, 3) cin >> array[i];
	cin >> k;
	sort(array, array + 3);
	int ans = 0;
	rep(i, k) {
		array[2] = array[2] * 2;
		ans = array[0] + array[1] + array[2];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;
typedef long long LL;
LL i,j,k,m=999999999,n,s,w[100005];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)cin>>w[i];
	for(;j++<100;)
	{
		for(i=s=0;i++<n;)s+=(w[i]-j)*(w[i]-j);
		m=min(m,s);
	}
	cout<<m;
}

Measured memory_bytes: 384
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,k,ans=inf;
void rec(int x,int nr)
{
	if(nr==n+1)
	{
		ans=min(ans,x);
		return;
	}
	rec(x*2,nr+1);
	rec(x+k,nr+1);
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin>>n>>k;
    rec(1,1);
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool ok(int a, int b, int c) { return a*a+b*b==c*c; }
int main()
{
    int a, b, c, n;
    cin >> n;
    while (n--) {
        cin >> a >> b >> c;
        if (ok(a, b, c) || ok(b, c, a) || ok(c, a, b)) cout << "YES";
        else cout << "NO";
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 0
//
//  main.cpp
//  kyougi
//
//  Created by 寺林 一旭 on 2018/08/27.
//  Copyright © 2018年 寺林 一旭. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
 
    int num;
    vector<int> list;
    while(cin >> num)
    {
  
        list.push_back(num);
   
    }
    sort(list.begin(), list.end(), greater<int>());
    for(int i = 0 ; i< 3 ; i++)
    {
        cout<< list[i] <<endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3164
import math

def isprime(x):
    if x==2:
        return True

    if x<2 or x%2==0:
        return False

    i=3
    while i<=math.sqrt(x):
        if x%i==0:
            return False
        i=i+2
    return True
    
    
n=int(input())
a=[]

cnt=0
for i in range(n):
    m=int(input())
    if isprime(m):
        cnt+=1

print(cnt)


Measured memory_bytes: 5680
class BinaryHeap
  attr_reader :nodes

  def initialize
    @nodes = []
  end

  def push(node)
    nodes << node
    index = nodes.size - 1

    up_heap(index)
  end


  def pop
    node = nodes.pop
    return if nodes.size.zero?

    nodes[0] = node

    heap_down(0)
  end

  private

  def up_heap(index)
    return if index.zero?

    parent_index = (index - 1) / 2
    parent_node = nodes[parent_index]

    return if parent_node > nodes[index]

    nodes[parent_index] = nodes[index]
    nodes[index] = parent_node

    up_heap(parent_index)
  end

  def heap_down(parent_index)
    parent_node = nodes[parent_index]

    left_child_index = 2 * parent_index + 1
    right_child_index = 2 * (parent_index + 1)

    left_child_node, right_child_node = nodes.values_at(left_child_index, right_child_index)
    return if left_child_node.nil? && right_child_node.nil?

    max_node = [parent_node, left_child_node, right_child_node].compact.max
    return if max_node == parent_node

    if max_node == left_child_node
      nodes[left_child_index] = parent_node
      nodes[parent_index] = left_child_node
      heap_down(left_child_index)
    else
      nodes[right_child_index] = parent_node
      nodes[parent_index] = right_child_node
      heap_down(right_child_index)
    end
  end
end

class PriorityQueue
  def initialize
    @heap = BinaryHeap.new
  end

  def queue
    @heap.nodes
  end

  def enqueue(element)
    @heap.push(element)
  end

  def dequeue
    element = @heap.nodes[0]
    @heap.pop
    element
  end
end

N, M = gets.split.map(&:to_i)
h = Hash.new { |h, k| h[k] = [] }
queue = PriorityQueue.new
cnt = 0

N.times do
  a, b = gets.split.map(&:to_i)
  h[a] << b
end

1.upto(M) do |i|
  Array(h[i]).each { |b| queue.enqueue(b) }
  next if queue.queue.size.zero?

  cnt += queue.dequeue
end

p cnt

Measured memory_bytes: 16636
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n;
  cin >> n;
  vector<int> dp(n + 1);
  dp[0] = 1;
  rep(i, 3, n + 1) dp[i] = (dp[i - 3] + dp[i - 1]) % 1000000007;
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 3112
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def main():
    n, *x = (int(i) for i in sys.stdin.read().split())

    res = functools.reduce(gcd, [abs(x[i+1] - x[i]) for i in range(n)])

    print(res)

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 14548
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        q: usize,
        s: String,
        lr: [(usize1, usize1); q]
    }


    let matches: Vec<usize> = s.match_indices("AC").map(|(i, _)| i).collect();
    let mut bit = BIT::new(n);
    for k in matches {
        bit.add(k, 1);
    }
    for (l, r) in lr {
        println!("{}", bit.sum(l, r - 1));
    }
}

struct BIT {
    v: Vec<usize>,
    n: usize
}

impl BIT {
    #![allow(dead_code)]
    fn new(n: usize) -> BIT {
        let v = vec![0; n];
        BIT{
            v: v,
            n: n
        }
    }

    fn from(v: Vec<usize>) -> BIT {
        let mut bit = BIT::new(v.len());
        for (i, value) in v.iter().enumerate() {
            bit.add(i, *value);
        }
        bit
    }

    fn add(&mut self, index: usize, value: usize) {
        let mut x = index + 1;
        while x <= self.n {
            self.v[x - 1] += value;
            x += ((x as i64) & -(x as i64)) as usize;
        }
    }

    fn sum(&self, left: usize, right: usize) -> usize {
        self.sum0(right) - if left > 0 { self.sum0(left - 1) } else { 0 }
    }

    fn sum0(&self, right: usize) -> usize {
        let mut sum = 0;
        let mut x = right + 1;
        while x > 0 {
            sum += self.v[x - 1];
            x -= ((x as i64) & -(x as i64)) as usize;
        }
        sum
    }
}


Measured memory_bytes: 8956
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 1e18;
const int MAXN = 20;
char sl[MAXN],sr[MAXN],sm[MAXN];

int main(){
	int n;
	scanf("%d",&n);
	int L=0,R=n-1,mid;
	printf("%d\n",L);
	fflush(stdout);
	scanf("%s",sl);
	if(sl[0]=='V') return 0;
	while(L+1<R){
		mid=(L+R)/2;
		printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",sm);
		if(sm[0]=='V') return 0;
		if(sl[0]==sm[0]){
			if((mid-L-1)&1) L=mid,sl[0]=sm[0];
			else R=mid,sr[0]=sm[0];
		}else{
			if((mid-L-1)&1) R=mid,sr[0]=sm[0];
			else L=mid,sl[0]=sm[0];
		}
	}
	printf("%d\n",n-1);
	fflush(stdout);
	scanf("%s",sr);
    return 0;
}


Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
}
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
    }
    return 0;
}



Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
long long n,a[100010],x=1,f;
int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		if (a[i]==0) f=1;
	}
	if (f==1){
		cout<<0<<endl;
		return 0;
	}
	for (int i=0;i<n;i++){
		if (a[i]<=1000000000000000000/x)
			x*=a[i];
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 4428
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
	std::string s1, s2;
    std::cin >> s1 >> s2;
	std::cout << s2 << s1 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


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

int main(){
  int n;
  cin >> n;
  vector<string> s(n+10);
  vector<int> A(n+10);
  rep(i,n){
    cin >> s[i];
    A[i] = s[i].size();
  }
  rep(i,n-1){
    for(int j = i+1;j < n;++j){
      if(s[i] == s[j]){
        puts("No");
        return 0;
      }
    }
  }
  for(int i = 0;i < n-1;++i){
    if(s[i][A[i]-1] != s[i+1][0]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

typedef long long ll;

int N;
string S[50];

int main() {
    cin >> N;
    rep(i, N) cin >> S[i];

    map<char, int> ans;
    for (int i = 0; i < 26; i++) {
        char t = (char)('a' + i);

        map<char, int> target;

        int cnt = 0;
        bool flag = true;
        rep(j, N) {
            int tmp = 0;
            rep(k, S[j].size()) {
                if (S[j][k] == t) tmp++;
            } 
            if (tmp == 0) flag = false; 

            if (tmp > 0) {
                if (cnt == 0) cnt = tmp;
                else cnt = min(cnt, tmp);
            }
        }

        if (cnt > 0 && flag) {
            ans[t] = cnt;
        }
    }

    for (auto iter = ans.begin(); iter != ans.end(); iter++) {
        // cout << iter->first << iter->second << endl;
        string s1(iter->second, iter->first);
        cout << s1;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll W,a,b;
    cin >>W>>a>>b;
    
    
    cout << max(abs(a-b)-W,0LL) << endl;


    return 0;
    

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int n;
bool pd(int x){
    if(x==1)return 0;
    if(x==2)return 1;
    for(int i=2;i*i<=x;i++)if(x%i==0)return 0;
    return 1;

}
int main(){
    cin>>n;
    int k=11;
    while(n){
        if(pd(k)&&k%10==1){
            printf("%d ",k);n--;
        }
        k+=10;
    }
    puts("");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int n, t;
    int sum = 0;

    scanf("%d", &n);
    t = n;

    while(t>0) {
        sum += t%10;
        t /= 10;
    }

    if (0 == (n % sum)) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	char c;
	cin >> c;
	char d=c+1;
	cout<< d;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

const double PI = 3.14159265358979323846;

int map[17][17];

const int C[6] = {1, 5, 10, 50, 100, 500};

int main() {
    int r = 0;
    for (int i = 0; i < 6; ++i) {
        int temp;
        cin >> temp;
        r += C[i] * temp;
    }
    cout << ((r < 1000) ? 0 : 1) << endl;
    return 0;
}

Measured memory_bytes: 1164
a, b, c, d = [int(x) for x in input()]

bcd = [b, c, d]
var = [['+', '+', '+'],['+', '+', '-'], ['+', '-', '+'], ['+', '-', '-'], ['-', '+', '+'], ['-', '+', '-' ], ['-', '-', '+'], ['-', '-', '-']]
for va in var:
    ans = a
    for i, op in zip(bcd, va):
        if op == '+':
            ans += i
        else:
            ans -= i
    if ans == 7:
        print('{}{}{}{}{}{}{}=7'.format(a,va[0],b,va[1],c,va[2],d))
        break

Measured memory_bytes: 3064
N = int(input())

# Nの階乗を計算する
def factorial(N):
    f = [1] * (N+1)
    mod = 10 ** 9 + 7
    for i in range(1, N+1):
        f[i] = i * f[i - 1] % mod
    return f[-1]


print(factorial(N))

Measured memory_bytes: 6900
fn main() {
  let (n, x): (isize, isize) = read_tuple();
  
  if x == 1 || x == 2*n-1 {
    println!("No");
    return;
  }
  
  let ans = (1..2*n).map(|i| (i+x+n-2)%(2*n-1)+1).collect::<Vec<_>>();
  println!("Yes");
  print_vec(&ans, " ");
}

fn read_tuple<T1: std::str::FromStr, T2: std::str::FromStr>() -> (T1, T2) {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  let mut it = buf.trim().split_whitespace();
  let x = it.next().unwrap().parse::<T1>().ok().unwrap();
  let y = it.next().unwrap().parse::<T2>().ok().unwrap();
  (x, y)
}

fn print_vec<T: std::string::ToString>(vec: &Vec<T>, sep: &str) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
  println!("{}", out);
}

Measured memory_bytes: 14588
#include<stdio.h>
#define WHITE 0
#define GRAY  1
#define BLACK 2
#define MAX 100

int n;
int A[MAX][MAX];
int color[MAX];
int d[MAX],f[MAX];
int time;

void visit(int u)
{
  int v;
  
  color[u] = GRAY;
  d[u] = ++time;
  for( v = 0 ; v < n ; v++){
    if( A[u][v] == 0 ) continue;
    if( color[v] == WHITE ){
      visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void dfs()
{
  int u;
  for( u = 0 ; u < n ; u++ )color[u] = WHITE;
  time = 0;

  for( u = 0 ; u < n ; u++ ){
    if( color[u] == WHITE ) visit(u);
  }
  for( u = 0 ; u < n ; u++ ){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main()
{
  int i;
  int j;
  int u,k,v;

  scanf("%d",&n);
  for( i = 0 ; i < n ; i++){
    for( j = 0 ; j < n; j++){
      A[i][j] = 0;//とりあえず全部０にする
    }
  }
  for( i = 0 ; i < n ; i++ ){
    scanf("%d%d",&u,&k);
    u--;//配列は０から始まるので１ずつ引く
    for( j = 0 ; j < k ; j++ ){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
    }
  }
  dfs();
  for( i = 0 ; i < n; i++);
  return 0;
  
}



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

using pxy = pair<int, int>;

int factorial(int n) {
    if (n == 1){
        return 1;
    } else {
      return  n * factorial(n-1);
    }
}

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<pxy> vec(N);
    
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        vec.at(i).first = x;
        vec.at(i).second = y;
    }
    double sum = 0;
    double d2 = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            d2 = pow(vec.at(i).first - vec.at(j).first, 2) + pow(vec.at(i).second - vec.at(j).second, 2);
            sum += 2*factorial(N-1) * sqrt(d2);
        
        }
    }

    cout << fixed << setprecision(10) << sum / factorial(N) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
//#define mod 998244353
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;

ll pow(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modinv(ll a){
	return powm(a,mod-2)%mod;
}
int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t=1;
    //cin>>t;
    while(t--){
    	ll n,i,j,k;
    	cin>>n>>k;
    	ll sum[n+5]={0};
    	ll a[n+5];
    	for(i=1;i<=n+1;i++)
    	{
    		a[i]=i;
    		sum[i]=sum[i-1]+a[i];
		}
		ll ans=0;
		for(i=k;i<=n+1;i++)
		{
			ll x=sum[i];
			ll y=sum[n+1]-sum[n+1-i];
			ans=ans+(y-x+1)%mod;
			ans=ans%mod;
			
		}
		cout<<ans;
    	
    }}
    	

Measured memory_bytes: 6736
import collections


def main():
    routeList = [list(map(int,input().split())) for _ in range(3)]
    routeList = [i for inner in routeList for i in inner]
    ansList = collections.Counter(routeList)
    
    for i in ansList:
        if ansList[i] == 3:
            print("NO")
            exit()
    print('YES')
    

    


if __name__== "__main__":
    main() 











Measured memory_bytes: 3316
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        h: usize,
        w: usize,
        aaa: [String; h]
    };
    println!("{}", "#".repeat(w + 2));
    for aa in aaa {
        println!("#{}#", aa);
    }
    println!("{}", "#".repeat(w + 2));
}


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

int main() {
  int k, x;
  cin >> k >> x;
  if (500*k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL x;
    cin >> x;
    int c = 0;
    c += x / 500;
    c *= 1000;
    x = x % 500;
    c += x / 5 * 5;
    cout << c << endl;
    return 0;
}



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

L = []

if len(s) >= len(t):
  for i in range(len(s)-len(t)+1):
    if all([s[i+j]==t[j] or s[i+j]=='?' for j in range(len(t))]):
      l = str()
      for k in range(len(s)):
        if i <= k < i+len(t):
          l += t[k-i]
        elif s[k] == '?':
          l += 'a'
        else:
          l += s[k]
      L += [l]
      
if L:
  print(min(L))
else:
  print('UNRESTORABLE')

Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 3005
#define M 1000000007

ll dp[N][N], sum[N];

int main()
{
    int n;
    string s;
    cin >> n >> s;
    dp[1][1] = 1;
    for(int i = 2; i <= n; i++)
    {
        for(int j = 1; j <= n; j++) sum[j] = (sum[j - 1] + dp[i - 1][j]) % M;
        for(int j = 1; j <= i; j++)
        {
            if(s[i - 2] == '<') dp[i][j] = sum[j - 1];
            else dp[i][j] = (sum[n] - sum[j - 1] + M) % M;
        }
    }
    ll ans = 0LL;
    for(int i = 1; i <= n; i++) ans = (ans + dp[n][i]) % M;
    cout << ans << endl;
}


Measured memory_bytes: 69120
#include<stdio.h>
int main()
{
	int x;
	scanf("%d",&x);
	long long min=0x3f3f3f3f;
	for(int i=0;i<x;i++)
	{
		long long w;
		scanf("%lld",&w);
		int t=0;
		while(w%2==0)
		{
			t++;
			w=w/2;
			if(t>min)
				break;
		}
		if(min>t)
			min=t;

	}
	printf("%lld\n",min);
}

Measured memory_bytes: 128
import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout

sys.setrecursionlimit(10**9)
n=int(input())
arr=list(map(int,input().split()))
mult=1
flag=0
if 0 in arr:
    print(0)
else:
    for i in range(n):
        mult*=arr[i]
        if mult>10**18:
            flag=1
            break

    if flag==0:
        print(mult)
    else:
        print(-1)

Measured memory_bytes: 22532
import java.util.Scanner;

public class Main {

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

		String N = sc.nextLine();
		char[] ch = N.toCharArray();
		
		int sum = 0;
		for(int i=0; i<ch.length; i++)
			sum += (ch[i] - '0');
		
		if(sum % 9 == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
		sc.close();
	}

}

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

int main(){
    string s;
    long long k;
    cin >> s;
    cin >> k;
    k--;
    int res=0;
    for(int i=0;i<s.size();i++){
        if(s[i]!='1'){
            res = i;
            break;
        }
    }

    if(res<=k){
        cout << s[res] << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
typedef long long ll;
int main(void){

  string s,t,u;
  int a,b;
  
  cin>>s>>t;
  cin>>a>>b;
  cin>>u;
  if(u==s)a--;
  else b--;
  cout<<a<<" "<<b;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N,M,Q;
int a[51],b[51],c[51],d[51];
int arr[11];
int f(int next, int val){
    if(next == N+1){
        int ret=0;
        for(int i=1;i<=Q;i++){
            if(arr[b[i]]-arr[a[i]]==c[i])
                ret+=d[i];
        }
        return ret;
    }
    int ret=0;
    for(int i=val;i<=M;i++){
        arr[next]=i;
        ret=max(ret,f(next+1, i));
        arr[next]=0;
    }
    return ret;
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>M>>Q;
    for(int i=1;i<=Q;i++){ cin>>a[i]>>b[i]>>c[i]>>d[i]; }
    cout<<f(1,1);
}

Measured memory_bytes: 3640
//x???3???????±???????
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		
		String str = br.readLine();
		int num = Integer.parseInt(str);
		
		int result = (num * num * num);
		System.out.println(result);
	}

}

Measured memory_bytes: 24252
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// Nの入力
		int N = sc.nextInt();
		
		// Aiの入力
		ArrayList<Integer> a = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			a.add(sc.nextInt());
		}
		
		// Biは最初に全部合計しておく
		int sum = 0;
		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}

		// Ciの入力
		ArrayList<Integer> c = new ArrayList<>();
		for (int i = 0; i < N-1; i++) {
			c.add(sc.nextInt());
		}
		
		// Cの満足度を加算
		for (int i = 0; i < N-1; i++) {
			if (a.get(i) + 1 == a.get(i+1)) {
				sum += c.get(a.get(i)-1);
			}
		}
		
		// 結果の出力
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll n;
	cin >> n;
	vector <ll> a(n);
	vector <ll> b(n);
	a[0] = 0;
	for (int i = 1;i< n ;i++) {
		cin >> a[i]; 
		b[a[i]-1] ++;
	}
	for (int i =0;i<n;i++) {
		cout << b[i] << endl;
	}
	return 0;
}


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

using namespace std;
int a[25][25];
int b[25];

int main()
{
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c;
    cin >> n >> m >> c;
    int cnt=0;
    rep(i,0,m)
    {
        cin >> b[i];
    }
    rep(i,0,n)
    {
        int sum = 0;
        rep(j,0,m)
        {
            cin >> a[i][j];
            sum += a[i][j] * b[j];

        }
        if (sum + c > 0){

            cnt +=1;
        }

    }
    cout << cnt;
    return 0;
}


Measured memory_bytes: 3608