akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>

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

bool compare(pair<int, int> a, pair<int, int> b) { return a.second > b.second; }

int main() {
  int n;
  cin >> n;
  int v[n];
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }

  map<int, int> aMap;
  for (int i = 0; i < n; i += 2) {
    if (aMap.find(v[i]) != aMap.end()) {
      aMap[v[i]] += 1;
    } else {
      aMap[v[i]] = 1;
    }
  }

  vector<pair<int, int>> aVec;
  copy(aMap.begin(), aMap.end(), back_inserter(aVec));
  sort(aVec.begin(), aVec.end(), compare);

  map<int, int> bMap;
  for (int i = 1; i < n; i += 2) {
    if (bMap.find(v[i]) != bMap.end()) {
      bMap[v[i]] += 1;
    } else {
      bMap[v[i]] = 1;
    }
  }
  vector<pair<int, int>> bVec;
  copy(bMap.begin(), bMap.end(), back_inserter(bVec));
  sort(bVec.begin(), bVec.end(), compare);


  int ans;
  if (aVec[0].first != bVec[0].first) {
    ans = n - (aVec[0].second + bVec[0].second);
  } else {
    ans = n - max(aVec[0].second + (bVec.size() > 1 ? bVec[1].second : 0),
                  bVec[0].second + (aVec.size() > 1 ? aVec[1].second : 0));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  int ans = 0;
  repi(i,1,n-1){
    bool ok = false;
    if(a[i-1] > a[i] and a[i] > a[i+1])ok = true;
    if(a[i-1] < a[i] and a[i] < a[i+1])ok = true;
    if(ok)ans++;
  }
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include<stdio.h>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
#define endl "\n"
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()

int main()
{
    int i,x,n,j,flag,temp=0;
    cin>>n;
    int a[n];

    for (i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n; i++)
    {
        if(a[i]!=i+1)
        {
            flag=1;
            break;
        }
    }
    for(j=0; j<n; j++)
    {
        if(a[j]==i+1)
        {
            break;
        }
    }
    if (flag==1)
    {
        x=a[i];
        a[i]=a[j];
        a[j]=x;
    }

    for(i=0; i<n-1 ; i++)
    {
        if(a[i]>a[i+1])
        {
            cout<<"NO"<<"\n";
            temp=1;
            break;
        }
    }
    if (temp==0)
        cout<<"YES"<<"\n";
    return 0;
}



Measured memory_bytes: 3636
using System;
using System.Linq;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var dp = new int[N,3];
        for (int i=0;i<N;++i)
        {
            var line = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            for (int j=0; j<3;++j)
            {
                if (i == 0) dp[i, j] = line[j];
                else
                {
                    if (j == 0) dp[i, 0] = Math.Max(dp[i-1,1],dp[i-1,2])+line[0];
                    if (j == 1) dp[i, 1] = Math.Max(dp[i - 1, 0], dp[i - 1, 2]) + line[1];
                    if (j == 2) dp[i, 2] = Math.Max(dp[i - 1, 0], dp[i - 1, 1]) + line[2];
                }
            }
        }
        var ans = Math.Max(dp[N-1,0],
            Math.Max(dp[N-1,1],dp[N-1,2]));
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 18356
h,w,d,i,f;main(c){for(;scanf(f="%d %d\n",&h,&w)*h;c=printf(f,--h,w))for(d=i=h*h+w*w;c;d++)for(h=d!=i?:h+1;c&&h<(w=sqrt(d-h*h));h++)c=w*w!=d-h*h;}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>

using IV = std::vector<int>;
IV ToFixedIntArray(std::istream& is, int n) {
	IV ret(n);
	auto* dst = ret.data();
	while(n > 0) {
		--n;
		is >> *dst++;
	}
	return ret;
}
#define CAT_I(x,y) x ## y
#define CAT(x,y) CAT_I(x, y)
#define FEach_P(ar, idx, from, step) \
	const int CAT(len,__LINE__) = (ar).size(); \
	for(auto idx=(from) ; idx<CAT(len, __LINE__) ; idx += (step))
#define FEach(ar, idx) FEach_P(ar, idx, 0, 1)

#define _For(idx, from, to, inc, cmp) \
	for(auto idx=(from) ; idx cmp (to) ; inc idx)
#define ForLE(idx, from, to) \
	_For(idx, from, to, ++, <=)
#define ForGE(idx, from, to) \
	_For(idx, from, to, --, >=)
#define ForLT(idx, from, to) \
	_For(idx, from, to, ++, <)
#define ForGT(idx, from, to) \
	_For(idx, from, to, --, >)
#define For(idx, from, to) \
	_For(idx, from, to, ++, <)
#define Assert(expr) if(!(expr)) {__builtin_trap();}

class GridFill {
	private:
		using IV2 = std::vector<IV>;
		IV2	_grid;
		int _curX,
			_curY;
		bool _dir;

		void _advance() {
			if(_dir) {
				_curX += 1;
				const int w = _grid[0].size();
				if(_curX >= w) {
					--_curX;
					++_curY;
					_dir ^= 1;
				}
			} else {
				_curX -= 1;
				if(_curX < 0) {
					_curX = 0;
					++_curY;
					_dir ^= 1;
				}
			}
		}
	public:
		GridFill(const int h, const int w) {
			_grid.resize(h);
			For(i, 0, h) {
				_grid[i].resize(w);
			}
			_curX = 0;
			_curY = 0;
			_dir = true;
		}
		void addColor(const int c, const int n) {
			For(i, 0, n) {
				_grid[_curY][_curX] = c;
				_advance();
			}
		}
		void print(std::ostream& os) const {
			const int w = _grid[0].size();
			for(auto& row : _grid) {
				For(i, 0, w) {
					if(i != 0) {
						os << ' ';
					}
					os << row[i];
				}
				os << '\n';
			}
			os.flush();
		}
};
void DisableIOSync() {
	std::cin.tie(0);
	std::cout.tie(0);
	std::ios::sync_with_stdio(false);
}
int main() {
	DisableIOSync();

	const auto hw = ToFixedIntArray(std::cin, 2);
	GridFill grid(hw[0], hw[1]);
	const int N = ToFixedIntArray(std::cin, 1)[0];
	const auto color = ToFixedIntArray(std::cin, N);
	const int len = color.size();
	For(i, 0, len) {
		grid.addColor(i+1, color[i]);
	}
	grid.print(std::cout);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, C;
    cin >> N >> C;
    vector<vector<P>> table(C);
    for(int i = 0; i < N; ++i){
        int s, t, c;
        cin >> s >> t >> c;
        --c;
        table[c].emplace_back(s, t);
    }
    vector<int> S(100005, 0);
    for(int i = 0; i < C; ++i){
        sort(table[i].begin(), table[i].end());
        int n = table[i].size();
        table[i].emplace_back(100001, 100001);
        int s = table[i][0].first, t = table[i][0].second;
        for(int j = 1; j < n; ++j){
            if(table[i][j].first == t)  t = table[i][j].second;
            else{
                ++S[s - 1], --S[t];
                s = table[i][j].first, t = table[i][j].second;
            }
        }
        if(s != 100001) ++S[s - 1], --S[t];
    }
    int ans = 0;
    for(int i = 0; i <= 100000; ++i){
        chmax(ans, S[i]);
        S[i + 1] += S[i];
    }
    cout << ans << endl;
}

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

using namespace std;

int k;
bool vis[100005][46]={};

void dfs(int mod, int sd){
	vis[mod][sd]=1;

	for(int i=0;i<=9;i++){
		int nmod = (mod*10+i)%k;
		if(sd+i<46){
			if(!vis[nmod][sd+i]){
				dfs(nmod,sd+i);
			}
		}
	}
}

int main(){
	cin >> k;
	dfs(0,0);

	int ans=46;
	for(int i=1;i<46;i++){
		if(vis[0][i]){
			ans=min(ans,i);
		}
	}

	cout << ans << endl;
}


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

int main(){
  char A,B;
   cin >> A >> B;
  if(A < B){
cout << "<" << endl;
  }
  if(A == B){
cout << "=" << endl;
  }
if(A > B){
  cout << ">" << endl;
}
}


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

int main(){
  int a, b;
  cin >> a >> b;
  if(a < b){
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }else if(b < a){
    for(int i = 0; i < a; i++){
      cout << b;
    }
  }else{
    for(int i = 0; i < b; i++){
      cout << a;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
using namespace std;
int main(){
    int n,ans=0,temp;
    set<int> s;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        s.insert(temp);
    }
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%d",&temp);
        if(s.count(temp))ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 7412
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    int D,N;
    cin >> D >> N;

    cout << (int)pow(100, D)*(N+(N==100)) << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String N = sc.next();

		int Sn = 0;

		for (int i = 0; i < N.length(); i++) {
			Sn += Integer.parseInt(String.valueOf(N.charAt(i)));
		}
		System.out.println(Integer.parseInt(N) % Sn == 0 ? "Yes" : "No");
	}

}


Measured memory_bytes: 21844
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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: u64,
        k: u64,
        x: u64,
        y: u64
    }

    println!("{}", n.saturating_sub(k) * y + std::cmp::min(n, k) * x);
}


Measured memory_bytes: 4352
nums = []
val = []
ans = []

while True:
	try:
		nums.append(int(raw_input()))
	except EOFError:
		num_list = sorted(list(set(nums)))
		for n in num_list:
			val.append(nums.count(n))
		ans.append(num_list[val.index(max(val))])
		tmp = max(val)
		val.remove(max(val))
		num_list.pop(val.index(tmp))
		while max(val) == tmp:
			ans.append(num_list[val.index(max(val))])
			num_list.pop(val.index(tmp))
			val.remove(max(val))
		for s in ans:
			print s
		break

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


int main() {
    ll n;
    cin>>n;
    vector<string> s(n);
    int count=1;
    rep(i,n){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    s.push_back(s.back());
    rep(i,n){
        if(s[i] != s[i+1]){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 15660
def bubbleSort(A, N): # N 個の要素を含む 0-オリジンの配列 A
    flag = 1 # 逆の隣接要素が存在する
    counter = 0
    while flag:
        flag = 0
        for j in range(N-1,0,-1):
            if A[j] < A[j-1]:
                counter += 1
                buf = A[j]
                A[j] = A[j-1]
                A[j-1] = buf
                flag = 1
    return A, counter

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    a, num = bubbleSort(a, N)
    for i in range(len(a)):
        if i != len(a)-1:
            print(a[i], end=" ")
        else:
            print(a[i])
    print(num)



Measured memory_bytes: 5604
N = int(input())
hi = list(map(int, input().split()))

flag = False
cnt = 0

for i in range(max(hi)):
    flag = False
    for h in hi:
        if h > i and not flag:
            cnt += 1
            flag = True
        elif h > i and flag:
            pass
        else:
            flag = False

print(cnt)


Measured memory_bytes: 3060
n = gets.chomp.to_f
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
e = gets.chomp.to_i
arr = [a,b,c,d,e]
city = 0
neck = a
arr.each_with_index{|i, ind|
  if neck > i
    city = ind
    neck = i
  end
}
city = city.to_f
puts (city + 4 - city + (n / neck).ceil).round


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


int main(){

	int n;
	char s[1][10];

	scanf("%s", s[0]);

	n = strlen(s[0]);

	int state = 1;
	if(n % 2 == 0) {
		for(int i = 0; i < n - 1; i+= 2) {
			if(s[0][i] == 'h' && s[0][i+1] == 'i') {
				state = 1;
			} else {
				state = 0;
			}
		}
	} else {
		state = 0;
	}

	if(state == 0) {
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

int point[100005];

int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        point[x]++;
        point[y]++;
    }
    for(int i=0;i<n;i++){
        if(point[i]%2==1){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 640
import std.stdio;
import std.conv;
import std.complex;
import std.algorithm;
import std.range;
import std.math;
import std.string;


void main()
{
    while(1){
        immutable int N = readln().chomp.to!uint;
        if(N == 0)
            break;
 
        Complex!real[] map2D = new Complex!real[N];
        map2D[0] = complex(0, 0);
 
        {
            immutable cpxDir = [complex(-1, 0), complex(0, -1), complex(1, 0), complex(0, 1)];
            size_t i = 1;
            foreach(e; iota(N-1).map!(a => readln.split[0..2].map!(to!uint)))
                map2D[i++] = map2D[e[0]] + cpxDir[e[1]];
        }

        auto mm = [map2D.map!"a.re".reduce!(max, min),
                   map2D.map!"a.im".reduce!(max, min)];

        writefln("%s %s", abs(mm[0][0] - mm[0][1]).round.to!int + 1, abs(mm[1][0] - mm[1][1]).round.to!int + 1);
    }
}

Measured memory_bytes: 2036
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

const int maxn = 22;
const int maxm = 150000;
double dp[maxn][maxm];
int a[maxn];

double rat (int x, int y) {
	return 1.0 * abs (x - y) / x;
}

int main () {
	int n, i, j, k;
	double ans, Min;
	while (~scanf ("%d", &n)) {
		for (i = 1; i <= n; ++i) scanf ("%d", &a[i]);
		memset (dp, 0x7f, sizeof (dp));
		for (i = 1; i < maxm; ++i) {
			dp[1][i] = rat(a[1], i);
		}
		for (i = 2; i <= n; ++i) {
			//Min = dp[0][0];
			for (j = 1; j < maxm; ++j) {
				for (k = 1; k * j < maxm; ++k) {
					dp[i][k * j] = min (dp[i][k * j], max(dp[i-1][j], rat (a[i], k * j)));
					//printf ("%lf %lf %lf\n", dp[i][k * j], dp[i-1][j], rat (a[i], k * j));
					//Min = min (Min, dp[i][k * j]);
				}
			}
			//printf ("Min: %lf\n", Min);
		}
		ans = dp[n][1];
		for (j = 2; j < maxm; ++j) {
			ans = min (ans, dp[n][j]);
		}
		printf ("%.12lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 26000
#include<stdio.h>
int P[100001];

int main(){

int n,k;
int x,x1,x2,x3;
while(1){
scanf("%d %d",&n,&k);
if(n==0&&k==0)break;
int s=0,max=0;

for(int i=0;i<n;i++)
{scanf("%d",&P[i]);}


for(int j=0;j<k;j++)
s+=P[j];
max=s;

for(int i=k;i<n;i++)
	{s+=P[i];s-=P[i-k];

if(s>max)max=s;}

printf("%d\n",max);
}
return 0;
}

Measured memory_bytes: 1416
#include <bits/stdc++.h>
const int MAX = 2e5 + 10;
typedef long long i64;
using namespace std;
int n;
int par[MAX];
int depth[MAX];
int ord[MAX];
vector<int> g[MAX];
void dfs(int v, int p = 0){
	par[v] = p;
	depth[v] = depth[p] + 1;
	for(auto nv: g[v]){
		if(nv == p)continue;
		dfs(nv, v);
	}
}
bool taken[MAX];
bool watched[MAX];
bool cmp(int a, int b){
	return depth[a] > depth[b];
}
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'



    cin >> n;
    for(int i = 0; i < n - 1 ; i++){
    	int a, b; cin >> a >> b;
    	//a--, b--;
    	g[a].push_back(b);
    	g[b].push_back(a);
    }
    dfs(1);
    bool ans = false;
    for(int i = 1; i <= n; i++)
    	ord[i] = i;
    sort(ord + 1, ord + n + 1, cmp);
    for(int i = 1; i <= n; i++){

    	int cur = ord[i];
    	//cout << cur << endl;
    	if(taken[cur])continue;
    	if(cur == 1)ans = true;
    	else{
    		if(taken[par[cur]])ans = true;
    		taken[par[cur]] = true;
    	}
    }

    cout << (ans ? "First" : "Second") << endl;

}



Measured memory_bytes: 9856
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
typedef long long LL;
const int MAXN = 100005;
LL a[MAXN];
int n;
LL judge(LL x)
{
    for(int i=1;i<=n;++i)
        x=x/a[i]*a[i];
    return x;
}
int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;++i)
        scanf("%lld", &a[i]);
    LL l=2, r=1e15;
    LL mid;
    LL Max=-1, Min=-1;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(judge(mid)>=2)
            r=mid-1, Min=mid;
        else
            l=mid+1;
    }
    l=2,r=1e15;
    while(l<=r)
    {
        mid=(l+r)>>1;
        if(judge(mid)>2)
            r=mid-1;
        else
            l=mid+1, Max=mid;
    }
    if(judge(Min)!=2||judge(Max)!=2)
        puts("-1");
    else
        printf("%lld %lld\n", Min, Max);
    return 0;
}



Measured memory_bytes: 1024
ABCD = list(map(int,input().split()))
A = ABCD[0]
B = ABCD[1]
C = ABCD[2]
D = ABCD[3]

while True:
    
    C = C - B
    if C <= 0:
        break
    A = A - D
    if A <= 0:
        break


if C <= 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9064
#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 n, m;
    cin >> n >> m;
    vector<int> c(m);
    for (int i=0; i<m; ++i) cin >> c[i];

    vector<int> dp(n+1, 50000);
    dp[0] = 0;
    for (int i=0; i<m; ++i) {
        for (int j=0; j+c[i]<=n; ++j) {
            dp[j+c[i]] = min(dp[j+c[i]], dp[j] + 1);
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
vector<ll> adj[N];
ll a[N];
ll dfs(ll u,ll pr){
    ll cnt=0,mx=0,sum=0;
    for(auto &v:adj[u]){
        if(v==pr)continue;
        cnt++;
        ll tmp = dfs(v,u);
        sum+=tmp;
        mx=max(mx,tmp);
    }
    if(!cnt)return a[u];

    if(a[u] > sum || a[u]<mx || 2*a[u] < sum){
        cout<<"NO";
        exit(0);
    }
    return 2*a[u]-sum;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];

    if(n==2){
        cout<<(a[1]==a[2]?"YES":"NO");
        return 0;
    }

    for(ll i=0,u,v;i<n-1;i++)cin>>u>>v,adj[u].push_back(v),adj[v].push_back(u);

    ll root=1;
    while(adj[root].size()==1)root++;
    ll ans=dfs(root,root);
    cout<<(ans?"NO":"YES");
}


Measured memory_bytes: 13184
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}


void main() {
	auto nums = readNums();
	immutable n = nums[0];
	immutable a = nums[1];
	immutable b = nums[2];
	immutable c = nums[3];
	auto bars = iota(0, n).map!((i) => readNums()[0]).array;
	
	void calculateMp(int l, int beforeMp, ulong used, scope void delegate(int, ulong) f) {
		foreach(mask; 1 .. (1UL << n)) {
			if(mask & used) {
				continue;
			}
			int createdLen = 0;
			int count = 0;
			foreach(i; 0 .. n) {
				if(mask & (1UL << i)) {
					createdLen += bars[i];
					++count;
				}
			}
			immutable mp = beforeMp + abs(createdLen - l) + 10 * (count - 1);
			f(mp, used | mask);
		}
	}
	
	int minMp = int.max;
	calculateMp(a, 0, 0, delegate(mp1, used1) {
		calculateMp(b, mp1, used1, delegate(mp2, used2) {
			calculateMp(c, mp2, used2, delegate(mp3, used3) {
				minMp = min(minMp, mp3);
			});
		});
	});
	writefln("%s", minMp);
}

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


int main(){


    int A , B; std::cin >> A >> B;

    int money = 0;

    if(A >= 13){
        money = B;
    }else if(A >= 6){
        money = B / 2;
    }else{
        money = 0;
    }

    std::cout <<money;
    
    system("pause");

    return 0;

}


Measured memory_bytes: 504
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,T;
  scanf("%d %d",&N,&T);
  int C[N],TT[N];
  int cost=100000;
  for(int i=0;i<N;i++){
    scanf("%d %d",&C[i],&TT[i]);
    if(T>=TT[i]){
      if(cost>C[i])cost=C[i];
    }
  }
  if(cost==100000){
    printf("TLE\n");
  }else{
  printf("%d\n",cost);
  }
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 3 != 0 and i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3652
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
4 2
5 2
2 1
8 3

output:
13
"""

import sys
from collections import namedtuple


def solve():
    for i, item in enumerate(item_list, 1):
        for cp in range(1, real_cp + 1):
            if item.w <= cp:
                values[i][cp] = max(values[i - 1][cp], values[i - 1][cp - item.w] + item.v)
            else:
                values[i][cp] = values[i - 1][cp]
    return values[-1][-1]


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    c_items, real_cp = map(int, _input[0].split())
    items = map(lambda x: x.split(), _input[1:])

    Item = namedtuple('Item', 'v w')
    item_list = (Item(v=int(v), w=int(w)) for v, w in items)

    values = [[0] * (real_cp + 1) for _ in range(c_items + 1)]
    ans = solve()
    print(ans)

Measured memory_bytes: 27872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int arr[200001],cost[200001];

void marge_sort(int l,int r)
{
	if(r-l==1)return;
	int mid = (l+r)/2;
	marge_sort(l,mid);
	marge_sort(mid,r);
	vector<int> v,c;
	int i = l,j = mid;
	int add = mid - l;
	while(i!=mid&&j!=r)
	{
		if(arr[i]<arr[j])
		{
			v.push_back(arr[i]);
			c.push_back(cost[i]);
			add--;
			i++;
		}
		else
		{
			v.push_back(arr[j]);
			c.push_back(cost[j]+add);
			j++;
		}
	}
	for(;i<mid;i++)
	{
		v.push_back(arr[i]);
		c.push_back(cost[i]);
	}
	for(;j<r;j++)
	{
		v.push_back(arr[j]);
		c.push_back(cost[j]);
	}
	for(int k = l;k<r;++k)
	{
		arr[k] = v[k-l];
		cost[k] = c[k-l];
	}

}

int main()
{
	int n;
	cin >> n;
	for(int i =0;i<n;i++)cin >> arr[i];
	marge_sort(0,n);
	//for(int i =0;i<n;i++)cout<<arr[i]<<endl;
	ll ans = 0;
	for(int i = 0;i<n;i++)
	{
		ans += cost[i];
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6728
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

int main(void) {
  cout.precision(12);

  string S;
  cin >> S;

  long red = 0;
  long blue = 0;

  for (char c: S) if (c == '0') red++; else blue++;

  cout << min(red, blue) * 2 << endl;

  return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll MOD = (ll)1e9 + 7;
const ll mxN = 200200;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll n, k;
	cin>>n>>k;
	vll A(n+1);
	for(int i=1;i<=n;i++) cin>>A[i];
	ll x = 1;
	vll cy;
	ll f;
	vector<bool> seen(n+1,false);
	while(1){
		cy.pb(x);
		seen[x]=true;
		x=A[x];
		if(seen[x]) {f = x;break;}
	}
	int i;
	for(i =0;cy[i]!=f && k;i++,k--);
	if(k==0) cout<<cy[i];
	else {
		k%=(cy.size()-i);
		cout<<cy[i+k];
	}
}


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

int main () 
{
  long long ans;
  int d;
  
  while (cin >> d){
    ans = 0;
    for (int i = 1; i * d < 600; i++){
      ans += i * d * i * d * d;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>

int main(){
	int N, M;
	int i, j, k, l, sc;
	_Bool t = 0;
	sc = scanf("%d %d", &N, &M);
	
	char A[N][N + 1], B[M][M + 1];
	
	for(i = 0; i < N; i ++){
		sc = scanf("%s", &A[i][0]);
	}
	for(i = 0; i < M; i ++){
		sc = scanf("%s", &B[i][0]);
	}
	
	for(k = 0; k < N - M + 1; k ++){
		for(l = 0; l < N - M + 1; l ++){
			t = 0;
			for(i = 0; i < M; i ++){
				for(j = 0; j < M; j ++){
					if(B[i][j] != A[k + i][l + j]){
						t = 1;
						break;
					}
				}
				if(t == 1) break;
			}
			if(i == M && j == M){
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  const int MOD = 1e9+7;
  ll n,k; cin >> n >> k;
  vi a(n); rep(i,n) cin >> a[i];
  ll ans = 0, cnt1 = 0, cnt2 = 0;
  rep(i,n){
    rep(j,n){
      if(a[i] > a[j]){
        if(i < j) cnt1++;
        cnt2++;
      }
    }
  }
  ans = cnt1*k;
  ans %= MOD;
  ans += k*(k-1)/2%MOD*cnt2;
  ans %= MOD;
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
 
int main(){
	int n,i,ans=0;
  scanf("%d",&n);
  int *p=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)scanf("%d",&p[i]);
	for(i=1;i<n-1;i++){
      if((p[i]>p[i+1] && p[i]<=p[i-1])||(p[i]<p[i+1] && p[i]>=p[i-1]))ans++;
    }
  printf("%d\n",ans);
  free(p);
  return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

f :: Char -> Char -> Maybe Char
f '0' 'A' = Just 'X'
f '1' 'A' = Just 'Y'
f '1' 'X' = Just 'Z'
f '0' 'Y' = Just 'X'
f '0' 'Z' = Just 'W'
f '1' 'Z' = Just 'B'
f '0' 'W' = Just 'B'
f '1' 'W' = Just 'Y'
f '0' 'B' = Just 'Y'
f '1' 'B' = Just 'X'
f _ _ = Nothing


main = map (maybe "No" (const "Yes") . mfilter (=='B') . ($'A') . foldr1 (>=>) . map f) . takeWhile (/="#") . lines <$> getContents >>= mapM_ putStrLn


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
	int g,r,b,N;
  in(r>>g>>b>>N);
  int a = N/r;
  int d = N/g;
  int ans = 0;
  for(int i=0;i<=a;i++){
   for(int j=0;j<=d;j++){
    if((N-i*r-j*g)>=0&&(N-i*r-j*g)%b==0)ans++;
   }
  }
  out(ans);
}
  

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

#define max 100

int main(){
  
  int n,l,i,k,q,j;
  int M[max][max],p[max];

  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d %d",&p[i-1],&p[i]);

  for (i=1; i<=n; i++)M[i][i] = 0;

  for (l=2; l<=n; l++) {
    for (i=1; i<=n-l+1; i++) {
      j = i + l - 1;
      M[i][j] = INT_MAX;
      for (k=i; k<=j-1; k++) {
	q = M[i][k] + M[k+1][j] + p[i-1]*p[k]*p[j];
	if (q < M[i][j]) {
	  M[i][j] = q;
	}
      }
    }
  }

  printf("%d\n",M[1][n]);


  return 0;
}

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

vector<pair<ll, ll>> prime_factor(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a =2; a * a <= n; a++) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) {
      ex++;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
} 


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

  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  const auto &v = prime_factor(n);


  int ans = 0;
  for(auto x : v) {
    int m = x.second;
    int cnt = 1;
    while (m - cnt >= 0 ) {
      m -= cnt;
      cnt++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

#define first f
#define second s

typedef pair<char, char> P;

int main(){
  map<P, char> edge;
  edge[P('A', '0')] = 'X';
  edge[P('A', '1')] = 'Y';
  edge[P('X', '1')] = 'Z';
  edge[P('Y', '0')] = 'X';
  edge[P('Z', '0')] = 'W';
  edge[P('Z', '1')] = 'B';
  edge[P('W', '0')] = 'B';
  edge[P('W', '1')] = 'Y';
  edge[P('B', '1')] = 'X';
  edge[P('B', '0')] = 'Y';

  string p;
  while(cin >> p){
    if(p == "#") break;
    char now = 'A';
    bool desert = false;
    map<P, char>::iterator it;
    for(int i = 0 ; i < p.size() ; i++){
      it = edge.find(P(now, p[i]));
      if(it == edge.end()){
	desert = true;
	break;
      }   
      else now = edge[P(now, p[i])];
    }
    if(now == 'B' && !desert) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gtl(x) getline(cin, (x))
#define PI acos(-1)
int main()
{
    int N, M, k, i;
    cin >> N >> M;
    int A[N+5];
    int x=0, sum=0;
    for(i=0; i<N; i++)
    {
        cin >> A[i];
        sum+=A[i];
    }
    for(i=0; i<N; i++)
    {
        if(A[i]*4*M>=sum)
        {
            x++;
        }
    }
    if(x>=M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


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

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

	long long ret = 0;
	for (long long i = 1; i <= n; ++i) {
		ret += n / i;
		if (n % i == 0) {
			--ret;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
	int x,y,w,h,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 2612
var
 a,b,t:int64;
begin
 readln(a,b);
 if a>b then
  begin
   t:=a; a:=b; b:=t;
  end;
 if (a<=0) and (b>=0) then writeln('Zero')
  else if (a<0) and (b<0) and (abs(a-b) mod 2=0) then writeln('Negative')
   else writeln('Positive');
end.

Measured memory_bytes: 128
#include <stdio.h>

int main() {
    int x,y;
    int t;
    for (;;){
        scanf("%d %d",&x,&y);
        if(x == 0 && y==0) break;
        
        if(x>y) t = x, x=y, y = t;
        printf("%d %d\n",x,y);
    }
    
    
    return 0;
}


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

typedef long long ll;

int main(){

  char s[15];
  char t[15];
  int i,n;
  int flag = 0;

  scanf("%s %s", s, t);
  n = strlen(s);
  for(i = 0;i < 26;i++){
    s[n] = 'a' + i;

    if(strncmp(s,t,n + 1) == 0) flag = 1;
  }

  if(flag) printf("Yes\n");

  else printf("No\n");

  return 0;
}


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

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

    int counter = 0;

    while(n || x)
    {
        for(int i=1; i<n-1; i++)
        {
            for(int j=i+1; j<n; j++)
            {
                if(j < x-(i+j) && x-(i+j) <= n) counter ++;
            }
        }
        cout << counter << endl;

        counter = 0;
        cin >> n >> x;
    }

    return 0;
}


Measured memory_bytes: 3080
#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];
  }
  set<int> s;
  for(int i=0; i<n; i++) s.insert(a[i]);

  if(s.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  vector<int>count(26);
  
  for(int i=0; i<S.size(); i++){
    int j = S[i] - 'a';
    count[j]++;
  }
  
  for(int i=0; i<26; i++){
    if(count[i]==0){
      char c = 'a'+i;
      cout << c << endl;
      break;
    }
    if(i==25){
      cout << "None" << endl;
    }
  }

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int sosuu(int X) {
	for (size_t i = 2; i < sqrt(X)+1; i++)
	{
		if (X % i == 0) return 0;
	}
	return 1;
}
int main() {
	vector <int>T;
	for (size_t i = 3; i < 55556; i++)
	{
		if (sosuu(i)==1 && i % 5 == 1)T.push_back(i);
	}
	int h;
	cin >> h;
	for (size_t i = 0; i < h; i++)
	{
		cout << T.at(i)<<endl;
	}
}

Measured memory_bytes: 256
def GCD(m, n):
    while n != 0:
        m, n = n, m % n
    return m

def gcd_all(a):
    n = len(a)
    gcd = a[0]
    for i in range(1, n):
        gcd = GCD(gcd, a[i])
    return gcd

def f(a):
    mx = 10**6
    p = set([])
    sieve = [i for i in range(mx + 1)]
    for i in range(2, int(mx**0.5 + 1)):
        for j in range(2 * i, mx + 1, i):
            if sieve[j] > i:
                sieve[j] = i
    pairwise_coprime = True
    for i in a:
        p2 = set([])
        while i > 1:
            p2.add(sieve[i])
            i //= sieve[i]
        for j in p2:
            if j in p:
                pairwise_coprime = False
                break
            p.add(j)
        if pairwise_coprime == False:
            break
    gcd = gcd_all(a)
    if pairwise_coprime == False and gcd == 1:
        return 'setwise coprime'
    elif pairwise_coprime:
        return 'pairwise coprime'
    else:
        return 'not coprime'

n = int(input())
a = list(map(int, input().split()))
print(f(a))


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

ll M = 1e7 + 7;

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);


	string s;
	cin >> s;

	int ans = 0;

	for (auto x : s)
	{
		ans = (ans % 9 + (x - '0') % 9) % 9;
	}

	if (ans % 9)
		cout << "No\n";
	else
		cout << "Yes\n";

	return 0;
}





Measured memory_bytes: 3692
#include<bits/stdc++.h>
typedef long long ll;
#define MOD (long long)(1e9+7)
using namespace std;

ll n,k,vis[5005];
ll p[5005],c[5005],sum[5005],ans=-1e18;
int main(){
    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> p[i];
    for(int i=1; i<=n; i++) cin >> c[i];
    for(int i=1; i<=n; i++){
        ll s=c[i];
        vector<ll> t; t.push_back(s);
        for(int j=p[i]; j!=i; j=p[j]) s+=c[j],t.push_back(s);
        int len=t.size();
        for(int j=0; j<len; j++){
            ll rest=k-j-1;
            if(rest<0) break;
            ans=max(ans,t[j]+(rest/len)*max(s,0LL));
        }
    }
    cout << ans;
}


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

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int sum = 0;
  for(int i = 0; i <= a; i++){
    for(int j = 0; j <= b; j++){
      for(int k = 0; k <= c; k++){
        int y = 500 * i + 100 * j + 50 * k;
        if(x == y) sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=55;
const int M=4005;
const int INF=0x3f3f3f;
const ull sed=31;
const int mod=1e8+7;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef pair<int,int>P;
 
int n,m,ans;
vector<int>sw[N];
int p[N],temp[N];
bool vis[N];
 
void dfs(int x)
{
    if(x==n+1)
    {
        memset(temp,0,sizeof(temp));
        for(int i=1;i<=n;i++)
        {
            if(!vis[i]) continue;
            for(int j=0;j<sw[i].size();j++)
            {
                int b=sw[i][j];
                temp[b]++;
            }
        }
        for(int i=1;i<=m;i++) if(temp[i]%2!=p[i]) return ;
        ans++;
        return ;
    }
    dfs(x+1);
    vis[x]=true;
    dfs(x+1);
    vis[x]=false;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int k;
        scanf("%d",&k);
        for(int j=0;j<k;j++)
        {
            int t;
            scanf("%d",&t);
            sw[t].push_back(i);
        }
    }
    for(int i=1;i<=m;i++) scanf("%d",&p[i]);
    dfs(1);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
H,W= list(map(int, input().split()))
N= int(input())
a= list(map(int, input().split()))
li=[[0]*W for i in range(H)]
color=0
x=0;y=0
r=0;vec=0
for i in a:
    color+=1
    for _ in range(i):
        li[x][y]=color
        if vec:
            if r==1:
                y+=1
            else:
                y-=1
        else:
            if r==0:
                x+=1
            else:
                x-=1
        try :
            if li[x][y]!=0:
                if vec:
                    if r==1:
                        y-=1
                    else:
                        y+=1
                else:
                    if r==0:
                        x-=1
                    else:
                        x+=1
                r+=1
                r%=4
                vec^=1
                if vec:
                    if r==1:
                        y+=1
                    else:
                        y-=1
                else:
                    if r==0:
                        x+=1
                    else:
                        x-=1
        except:
            if vec:
                if r==1:
                    y-=1
                else:
                    y+=1
            else:
                if r==0:
                    x-=1
                else:
                    x+=1
            r+=1
            r%=4
            vec^=1
            if vec:
                if r==1:
                    y+=1
                else:
                    y-=1
            else:
                if r==0:
                    x+=1
                else:
                    x-=1
for i in li:
    for j in i:
        print(j,end=" ")
    print("")





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

typedef unsigned long long uLL;
typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <int,pii> piii;
typedef pair <long long,long long> pll;
typedef pair <long long,pll> plll;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int MOD = 1000000007;

int n;
int a[ N ];
LL dp[ N ];

LL solve( int idx ) {
        if( idx > n ) return INF;
        if( idx == n ) return 0;
        if( dp[idx] != -1 ) return dp[idx];
        LL ret = INF;
        ret = solve( idx + 1 ) + abs( a[idx+1] - a[idx] );
        ret = min( ret , solve( idx + 2 ) + abs( a[idx+2] - a[idx] ) );
        return dp[idx] = ret;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( NULL );
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        memset( dp , -1 , sizeof( dp ) );
        cout << solve( 1 ) << endl;
        return 0;
}













Measured memory_bytes: 4608