akhauriyash/Code-Regression huggingface dataset:
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            char[] chars;

            chars = line.ToCharArray(0, line.Length);

            foreach (var c in chars)
            {
                if (Char.IsLower(c))
                {
                    Console.Write(Char.ToUpper(c));
                }
                else
                {
                    Console.Write(Char.ToLower(c));
                }
            }

            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 15876
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

ll arr[N],n;

int solve() 
{ 
    multiset<int> last; 
    for (int i = 0; i < n; i++) { 
        multiset<int>::iterator it = last.lower_bound(arr[i]); 
        if (it == last.begin()) 
            last.insert(arr[i]); 
        else { 
            it--; 
            last.erase(it); // erase the largest element smaller than arr[i] 
            last.insert(arr[i]); // and replace it with arr[i] 
        } 
    } 
    return last.size(); // our answer is the size of last 
} 

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	f(i,0,n){
		cin >> arr[i];
	}
	cout << solve() << '\n';
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    ll sum = 0;
    int len = (int)S.size()-1;
    for(int i = 0; i < (1 << len); i++){
        bitset<9> a(i);
        int pre = 0;
        rep(i, len) if(a.test(i)){
            sum += stoll(S.substr(pre, (i+1)-pre));
            pre = i+1;
        }
        sum += stoll(S.substr(pre));
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n, c;
	cin >> n >> c;
	bool d[c][100000];
	fill(d[0], d[0]+c*100000, false);
	for (int i = 0; i < n; i++) {
		int s, t, ch;
		cin >> s >> t >> ch;
		for (int i = s; i <= t; i++) {
			d[ch-1][i-1] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < 100000; i++) {
		int count = 0;
		for (int ch = 0; ch < c; ch++) {
			if (d[ch][i])
				count++;
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6552
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	cout << 0 << endl;
	fflush(stdout);
	string base="Vacant";
	string o="Male";
	string str; cin >> str;
	if(str==base){
		return 0;
	}
	else{
		int vi=0;
		if(str==o)vi=1;
		int l=1; int r=n;
		while(l<r){
			int mid=(l+r)/2;
			cout << mid << endl;
			fflush(stdout);
			cin >> str;
			if(str==base){
				return 0;
			}
			int mi=0;
			if(str==o)mi=1;
			if(mid%2==1){
				if(mi==vi)r=mid-1;
				else l=mid+1;
			}
			else{
				if(mi==vi)l=mid+1;
				else r=mid-1;
			}
		}
		cout << l << endl;
		fflush(stdout);
		cin >> str;
	}
}

Measured memory_bytes: 852
#include <iostream>

using namespace std;

int main()
{

    int n;

    cin >> n;

    int hyaku = n / 100;
    int ju = (n % 100) / 10;
    int ichi = (n % 10);

    bool res = false;

    if (hyaku == 7)
    {
        res = true;
    }
    if (ju == 7)
    {
        res = true;
    }
    if (ichi == 7)
    {
        res = true;
    }

    if (res)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3620
def f(n, x, a, p):
    if n == 0:
        return 1 if x > 0 else 0
    elif x <= 1 + a[n - 1]:
        return f(n - 1, x - 1, a, p)
    else:
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1], a, p)


def main():
    N, X = list(map(int, input().split(' ')))
    a, p = [1], [1]
    for i in range(N):
        a.append(a[i] * 2 + 3)
        p.append(p[i] * 2 + 1)
    print(f(N, X, a, p))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
U=[0]*N #u = x + y
V=[0]*N #v = x - y
parity = 0
for i in range(N):
    x,y = rl()
    U[i],V[i] = format(x+y,'+032b'), format(x-y,'+032b')
    parity += (x+y)%2

if parity == 0 or parity == N:
    parity //= N
    m = 31 if parity else 32
    print(m)
    d = [1 for i in range(m)]
    for i in range(1,31):
        d[i] = d[i-1]*2
    d.sort(reverse=True)
    print(*d, sep=' ')

    for i in range(N):
        res = ''
        u,v = U[i],V[i]

        ub,vb = [1]+list(map(int,u[1:-1])), [1]+list(map(int,v[1:-1]))
        if not parity:
            ub += [0]
            vb += [0]
        if u[0] == '-': ub = list(map(lambda x: x^1, ub))
        if v[0] == '-': vb = list(map(lambda x: x^1, vb))

        for ub_,vb_ in zip(ub,vb):
            if ub_==0 and vb_==0:
                res += 'L'
            elif ub_==1 and vb_==1:
                res += 'R'
            elif ub_==0 and vb_==1:
                res += 'D'
            else:
                res += 'U'
        print(res)
else:
    print(-1)


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

using namespace std;

const int N=1e5+10;

int ask(int pos){
        cout<<pos<<'\n';
        fflush(stdout);
        string ans;
        cin>>ans;
        if (ans=="Vacant") exit(0);
        return ans=="Male";
}
int main(){
        int n;
        cin>>n;
        int t0=ask(0);
        int ans=0;
        for(int i=19;i>=0;i--){
                int pos=ans+(1<<i);
                if (pos>=n) continue;
                int tcur=ask(pos);
                if (tcur==t0) ans=pos;
        }
}


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

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int count = Integer.parseInt(br.readLine());
		int pointOfTaro = 0;
		int pointOfHanako = 0;

		for (int i = 0; i < count; i++) {
			String[] strs = br.readLine().split(" ");
			if (0 < strs[0].compareTo(strs[1])) {
				pointOfTaro = pointOfTaro + 3;
			} else if (strs[0].compareTo(strs[1]) < 0) {
				pointOfHanako = pointOfHanako + 3;
			} else {
				pointOfTaro++;
				pointOfHanako++;
			}
		}
		System.out.println(pointOfTaro + " " + pointOfHanako);
	}
}

Measured memory_bytes: 25348
N = int(input())
a= list(map(int, input().split()))

left = [0] * N
right = [0] * N

left[0] = a[0]
right[-1] = a[-1]
for i in range(1, N):
    left[i] = a[i] + left[i-1]
for i in range(N-2, -1, -1):
    right[i] = a[i] + right[i+1]

# print(left)
# print(right)
ans = abs(left[0] - right[1])
for i in range(1, N-1):
    ans = min(ans, abs(left[i] - right[i+1]))
print(ans)


Measured memory_bytes: 28664
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <iostream>
#include <string>

int main()
{

    int n, m;

    scanf("%d", &n);
    scanf("%d", &m);

    std::cout << (pow(2, m) * (100 * (n - m) + 1900 * m)) << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  char a[3][3];
  rep(i,3){
    rep(r,3)cin >> a[i][r];
  }
  cout << a[0][0] << a[1][1]  << a[2][2] << endl;
}

Measured memory_bytes: 3564
// D - Megalomania
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);

	int n;
	cin >> n;
	vector<pair<long long, long long> > a(n);
	for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
	sort(a.begin(), a.end());
	bool ans = true;
	long long t = 0;
	for (int i = 0; i < n; i++) {
		t += a[i].second;
		if (t > a[i].first) {
			ans = false;
			break;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	int a, b, c;
	int l[10];

	int pattern_cnt;
	int len[1 << 10];
	int mp[1 << 10];

	cin >> n;
	cin >> a >> b >> c;

	pattern_cnt = 1 << n;

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

	for(int pattern = 1; pattern < pattern_cnt; ++pattern)
	{
		int cnt = 0;
		len[pattern] = 0;
		for(int i = 0; i < n; ++i)
		{
			if((pattern >> i) & 1)
			{
				len[pattern] += l[i];
				++cnt;
			}
		}
		mp[pattern] = (cnt - 1) * 10;
	}


	int ans = 1 << 30;
	for(int i = 1; i < pattern_cnt; ++i)
	{
		for(int j = 1; j < pattern_cnt; ++j)
		{
			for(int k = 1; k < pattern_cnt; ++k)
			{
				bool check = false;
				for(int m = 0; m < n; ++m)
				{
					int cnt = 0;
					cnt += (i >> m) & 1;
					cnt += (j >> m) & 1;
					cnt += (k >> m) & 1;
					if(cnt > 1)
					{
						check = true;
						break;
					}
				}

				if(check) continue;

				if(((i & j) & k) == 0)
				{
					ans = min(ans, mp[i] + mp[j] + mp[k] + abs(a - len[i]) + abs(b - len[j]) + abs(c - len[k]));
				}
			}
		}
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
from collections import defaultdict
import sys

input = lambda: sys.stdin.readline().rstrip()

def mod_inv(a):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, M
  while z1 != 1:
    d, m = divmod(z2, z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1%M

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(edge):
  grundy = [{} for i in range(3)]
  sum_g = [defaultdict(int, {0:W_sum}) for i in range(3)]
  W = W_last
  for i in range(N, 0, -1):
    for g, s, e in zip(grundy, sum_g, edge):
      if i in e:
        m = mex({g.get(j, 0) for j in e[i]})
        if m:
          g[i] = m
          s[g[i]] =  (s[g[i]] + W) % M
          s[0] =  (s[0] - W) % M
    W = W * B_inv % M
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(list)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].append(b)
  return e

N = int(input())
M = 998244353
B = pow(10, 18, M)
B_inv = mod_inv(B)
W_last = pow(B, N, M)
W_sum = (W_last - 1) * B * mod_inv(B-1) % M

edge = [read_edge() for i in range(3)]
sum_g = calc_grundy(edge)
ans = 0
for gx, sx in sum_g[0].items():
  for gy, sy in sum_g[1].items():
    gz = gx^gy
    sz = sum_g[2][gz]
    if sz:
      ans = (ans + sx*sy*sz) % M
print(ans)


Measured memory_bytes: 68588
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    def f(n):
        return ((1<<n)-(1-2*(n&1)))//3
    def k(x,n):
        return f(n)*s+(1-2*(n&1))*x
    a = LI()
    if a[0]%2 or a[1]%2 or a[2]%2:
        print(0)
        return
    if a[0] == a[1] == a[2]:
        print(-1)
        return
    s = sum(a)
    ans = 10**5
    for i in range(3):
        l = 0
        r = 10**5+1
        while r-l > 1:
            m = (l+r)>>1
            ka = k(a[i],m)
            if ka&((1<<m)-1) == 0:
                l = m
            else:
                r = m
        ans = min(ans, l)
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38512
n, m= map(int, input().split())

par = [-1]*n

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

def union(x, y):
    p,q=find(x), find(y)
    if p==q:
        return
    if p>q:
        p,q = q,p
    par[p] += par[q]
    par[q] = p

def size(x):
    return -par[find(x)]

def same(x,y):
    return find(x)==find(y)

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    union(a,b)

mx=0
for i in par:
    if i<0:
        mx=max(mx, -i)

print(mx)

Measured memory_bytes: 16828
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = nextInt()
		nums = append(nums, num)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	d := scanNums(n)
	sort.Ints(d)
	if d[(n/2) - 1] == d[n/2] {
		fmt.Println(0)
	} else {
		fmt.Println(d[n/2] - d[(n/2) - 1])
	}
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int N=405,M=100005;
int n,m,ans,u[M],v[M];
bool ck[N];
bitset<N> a[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u[i],&v[i]);
	}
	for(int i=1;i<=n;i++){
		bool flag=false;
		a[i][i]=true;
		for(int j=m;j>=1;j--){
			if(a[i][u[j]]&&a[i][v[j]]){
				flag=true;
				break;
			}else if(a[i][u[j]]){
				a[i][v[j]]=true;
			}else if(a[i][v[j]]){
				a[i][u[j]]=true;
			}
		}
		ck[i]=flag;
	}
	for(int i=1;i<=n;i++){
		if(!ck[i]){
			for(int j=i+1;j<=n;j++){
				if(!ck[j]){
					if((a[i]&a[j]).count()==0){
						ans++;
					}
				}
			}
		}
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
   int N,K;
   string S;
   char a,b,c,d,A,B,C;
  cin >> N >> K >> S;
  d = S.at(K-1);
  if(d == 'A' ){
      d = 'a';
    }
    else if (d == 'B'){
     d  = 'b';
    }
    else if (d == 'C'){
      d = 'c';
    }
   S.at(K-1) = d;
  cout << S << endl;
}

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

using namespace std;

template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


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

    std::map<long long, long long> counter;

    vector<long long> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A.at(i);
    }

    counter[0] = 0;

    for(int i = 1; i < N; ++i){
        long long diff = (A[i] + A[0]) - i;

        if(counter.find(diff) == counter.end()){
            counter[diff] = 1;
        }
        else{
            counter[diff] += 1;
        }
    }

    long long ret = counter[0];

    for(int i = 1; i < N; ++i){
        long long dif = -(A[i] - A[0] + i);
        if(counter.find(dif) != counter.end()){
            ret += counter[dif];
        }
    }

    cout << ret;
}


Measured memory_bytes: 16368
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
    int h,w;
    cin>>h>>w;
    vector<vector<char> > s(h,vector<char>(w));
    REP(i,h) REP(j,w) cin>>s[i][j];

    REP(i,h){
        REP(j,w){
            if(s[i][j]=='.') continue;
            bool f=0;
            if(i!=0 && s[i-1][j]=='#') f=1;
            if(i!=h-1 && s[i+1][j]=='#') f=1;
            if(j!=0 && s[i][j-1]=='#') f=1;
            if(j!=w-1 && s[i][j+1]=='#') f=1;
            if(f==0){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    string s; cin >> s;
    int n = s.size();
    ll k; cin >> k;
    if(n == 1){
        cout << k/2 << endl;
        return 0;
    }
    int f = 0;
    REP(i, 1, n){
        if(s[0] != s[i]){
            f = 1;
        }
    }
    if(f == 0){
        cout << (n*k)/2  << endl;
        return 0;
    }
    s = s + s;
    ll ans = 0;
    REP(i, 0, s.size()-1){
        if(s[i] == s[i+1]){
            s[i+1] = '1';
        }
    }
    REP(i, 0, n){
        if(s[i] == '1'){
            ans++;
        }
    }
    REP(i, n, s.size()){
        if(s[i] == '1'){
            ans += k-1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("\\r\\n");
		for( ;sc.hasNext();) {
			String line = sc.nextLine();
			int i;
			boolean flg = false;
			String ans = "";
			for(i=0;i<26;i++) {
				ans = "";
				for(int j=0;j<line.length();j++) {
					if( 'a' <= line.charAt(j) && 'z' >= line.charAt(j) ) 
						ans += (char)( (line.charAt(j)-'a' + i ) % 26 + 'a' );
					else ans += line.charAt(j);
				}
				for(int j=0;j<line.length();j++) {
					String tmp = ans.substring(j);
					if( tmp.startsWith("this") || tmp.startsWith("that") || tmp.startsWith("the") ) flg = true;
				}
				if( flg ) break;
			}
			System.out.println(ans);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

typedef long long ll;

int main() {
	// your code goes here
	ll a, b, c;
	cin>>a>>b>>c;
	if(a%2==0 || b%2==0 || c%2==0) {
		cout<<0;
		return 0;
	}
	ll ans=min(a*b, min(b*c, c*a));
	cout<<ans;
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i < N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();
		boolean check = true;
		for(int i = 0; i < N; i++) {
			int num = list.get(i);
			if(num % 2 == 0) {
				if(num % 3 != 0 && num % 5 != 0) {
					check = false;
					break;
				}else {
					continue;
				}
			}else {
				continue;
			}
		}
		if(check) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
	}

}

Measured memory_bytes: 23508
fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let m: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let mut ab: Vec<(usize, usize)> = Vec::with_capacity(m);
    for _ in 0..m {
        let a: usize = iter.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = iter.next().unwrap().parse::<usize>().unwrap() - 1;
        ab.push((a, b));
    }
    ab.reverse();

    let mut utree = Utree::new(n);
    let mut cost: u64 = n as u64 *(n as u64 -1)/2;
    let mut ret = vec![];
    for i in 0..m {
        ret.push(cost);
        if !utree.is_same(ab[i].0, ab[i].1) {
            cost -= utree.get_size(ab[i].0) as u64 * utree.get_size(ab[i].1) as u64;
            utree.unite(ab[i].0, ab[i].1);
        }
    }
    ret.reverse();
    for i in 0..ret.len() {
        println!("{}", ret[i]);
    }
}

#[allow(dead_code)]
pub struct Utree {
    n: usize,
    par: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}
#[allow(dead_code)]
impl Utree {
    pub fn new(n: usize) -> Utree {
        Utree {
            n: n,
            par: (0..n).collect(),
            rank: vec![0; n],
            size: vec![1; n],
        }
    }
    pub fn find(&mut self, x: usize) -> usize {
        if self.par[x] == x {
            x
        } else {
            let parent = { self.par[x] };
            let ret = self.find(parent);
            self.par[x] = ret;
            ret
        }
    }
    pub fn unite(&mut self, mut x: usize, mut y: usize) {
        x = self.find(x);
        y = self.find(y);
        if x == y {
            return;
        };
        if self.rank[x] < self.rank[y] {
            self.par[x] = y;
            self.size[y] += self.size[x];
        } else {
            self.par[y] = x;
            self.size[x] += self.size[y];
            if self.rank[x] == self.rank[y] {
                self.rank[x] += 1;
            }
        }
    }
    pub fn is_same(&mut self, mut x: usize, mut y: usize) -> bool {
        x = self.find(x);
        y = self.find(y);
        x == y
    }
    pub fn get_size(&mut self, mut x: usize) -> usize {
        x = self.find(x);
        self.size[x]
    }
}

Measured memory_bytes: 13564
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	string s, a;
	cin >> s;
	a = s;
	reverse(s.begin(), s.end());
	if (a == s)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
num_list=list(map(int,input().split()))
length=len(num_list)
result=[]
for trial in range(0,length):
    for i in range(0,len(num_list)):
        #後ろから判定を行なっていく
        if(num_list[len(num_list)-1-i]==(len(num_list)-i)):
            del num_list[len(num_list)-1-i]
            #一個消しちゃったから+1
            result=[len(num_list)-i+1]+result
            break
if(len(result)==length):
    for l in range(0,len(result)):
        print(result[l])
else:
    print(-1)

Measured memory_bytes: 3064
while True:
    table = input().split()

    a = int(table[0])
    op = table[1]
    b = int(table[2])

    if op == '?':
        break

    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))



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

const int md = 1000000007;

int h,w,a,b;
long long fac[200200];
long long ans;

void gen_fac()
{
    fac[0]=1;
    for(int i=1;i<200020;i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=md;
    }
}

int inv_mod(long long num,long long tar) {
    long long pw[40];
    long long pwval=1,cur=1;
    pw[0]=1;
    pw[1]=num;
    while(pwval*2<=tar)
    {
        pw[cur+1]=pw[cur]*pw[cur];
        pw[cur+1]%=md;
        pwval*=2;
        cur++;
    }
    long long ret = pw[cur];
    long long left = tar-pwval;
    pwval/=2;
    for(int i=cur-1;i>=0;i--,pwval/=2)
    {
        if(pwval<=left)
        {
            left-=pwval;
            ret*=pw[i];
            ret%=md;
        }
    }
    return (int)ret;
}

main()
{
    gen_fac();
    scanf("%d %d %d %d",&h,&w,&a,&b);
    int rigth_sign1=b-1;
    int rigth_sign2=w-b-1;
    for(int i=0;i<h-a;i++)
    {
        int down_sign1=i;
        int down_sign2=h-i-1;
        long long pls=fac[rigth_sign1+down_sign1]*inv_mod(fac[rigth_sign1],md-2);
        pls%=md;
        pls*=inv_mod(fac[down_sign1],md-2);
        pls%=md;
        pls*=fac[rigth_sign2+down_sign2];
        pls%=md;
        pls*=inv_mod(fac[rigth_sign2],md-2);
        pls%=md;
        pls*=inv_mod(fac[down_sign2],md-2);
        pls%=md;
        //printf("%lld\n",pls);
        ans+=pls;
        ans%=md;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int minHp = sc.nextInt();
		for (int i = 0; i < N - 1; i++) {
			minHp = gcd(minHp, sc.nextInt());
		}

		System.out.println(minHp);

	}

	public static int gcd(int a, int b) {
	    if (b == 0) return Math.abs(a);
	    return gcd(b, a % b);
	}
}


Measured memory_bytes: 48128
#include<iostream>
using namespace std;
int A,B,C,D;
main()
{
  cin>>A>>B>>C>>D;
  while(true)
  {
    C-=B;
    if(C<=0)
    {
      cout<<"Yes"<<endl;
      return 0;
    }
    A-=D;
    if(A<=0)
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3624
//ALDS1_2_C Sort I - Stable Sort
#include <iostream>
using namespace std;

struct Card
{
    char mark;
    int number;
};

void swap(Card& n1, Card& n2)
{
    Card temp;
    temp = n1;
    n1 = n2;
    n2 = temp;
}

void trace(Card c[], int n)
{
    for(int i=0; i<n; i++ ) {
        cout << c[i].mark << c[i].number;
        if(i<n-1) cout << " ";
    }
    cout << endl;
}


void bubbleSort(Card a[],int l)
{
    for(int i = 0; i < l-1; i++) {
        for(int j = (l-1); j >= (i+1); j--) {
            if (a[j].number < a[j-1].number) {
                swap(a[j],a[j-1]);
            }
        }        
    }
}

void sectionSort(Card a[],int l)
{
    int mini;
    for(int i = 0; i < l; i++) {
        mini = i;
        for(int j = i; j < l; j++) {
            if (a[j].number < a[mini].number) {
                mini = j;
            }
        }
        if (a[i].number != a[mini].number) {
            swap(a[i],a[mini]);
        }    
    }
}
bool isStable(Card b[], Card s[], int l)
{
    for(int i = 0; i < l; i++)
    {
        if(b[i].mark != s[i].mark || b[i].number != s[i].number ) {
            return false;
        }
    }
    return true;
}

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

    Card c[36],b[36],s[36];

    for(int i=0; i<l; i++) {
        cin >> c[i].mark >> c[i].number;
        b[i].mark = s[i].mark = c[i].mark;
        b[i].number = s[i].number = c[i].number;
    }
    bubbleSort(b,l);
    trace(b,l);
    cout << "Stable" << endl;
    sectionSort(s,l);
    trace(s,l);
    isStable(b,s,l) ? (cout << "Stable" << endl) : cout << "Not stable" << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;

void fnd(int x, int y, int tmp1, int tmp2){
  int md=(x+y+1)/2, tmp;
  cout<<md<<endl;
  fflush(0);
  string s;
  cin>>s;
  if(s=="Male"){
    tmp=0;
  }
  else if(s=="Female"){
    tmp=1;
  }
  else{
    return;
  }
  if(tmp1==tmp2){
    if(tmp==tmp1){
      if((md-x+1)%2==0){
        fnd(x, md, tmp, tmp);
      }
      else{
        fnd(md, y, tmp, tmp);
      }
    }
    else{
      if((md-x+1)%2==0){
        fnd(md, y, tmp, tmp2);
      }
      else{
        fnd(x, md, tmp1, tmp);
      }
    }
  }
  else{
      if(tmp==tmp1){
        if((md-x+1)%2==0)
          fnd(x, md, tmp1, tmp);
        else
          fnd(md, y, tmp, tmp2);
      }
      else{
        if((md-x+1)%2==0)
          fnd(md, y, tmp, tmp2);
        else
          fnd(x, md, tmp1, tmp);
      }
  }
}


int main(){
  int n, tmp1, tmp2, tmp3;
  cin>>n;
  cout<<0<<endl;
  fflush(0);
  string s;
  cin>>s;
  if(s=="Male"){
    tmp1=0;
  }
  else if(s=="Female"){
    tmp1=1;
  }
  else{
    return 0;
  }
  cout<<n-1<<endl;
  fflush(0);
  cin>>s;
  if(s=="Male"){
    tmp2=0;
  }
  else if(s=="Female"){
    tmp2=1;
  }
  else{
    return 0;
  }
  cout<<n/2<<endl;
  fflush(0);
  cin>>s;
  if(s=="Male"){
    tmp3=0;
  }
  else if(s=="Female"){
    tmp3=1;
  }
  else{
    return 0;
  }
  if(tmp1==tmp3){
    if((n/2+1)%2==0)
      fnd(0, n/2, tmp1, tmp3);
    else
      fnd(n/2, n-1, tmp3, tmp2);
  }
  else{
    if((n/2+1)%2==0)
      fnd(n/2, n-1, tmp3, tmp2);
    else
      fnd(0, n/2, tmp1, tmp3);
  }
  return 0;
}




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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

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

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

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

	int H=in(),W=in();
	vector<vector<int>> M(H,vector<int>(W,0)),D(H,vector<int>(W,1<<30));

	int black=0,white=0;
	REP(i,H){
		string S=in<string>();
		REP(j,W){
			if(S[j]=='#'){
				M[i][j]=1;
				black++;
			}
			else white++;
		}
	}
	D[0][0]=0;
	queue<int> Q;
	Q.push(0);
	while(!Q.empty()){
		int V=Q.front();
		Q.pop();
		int u=V%W,v=V/W;
		if(u>0 && D[v][u-1]>=1<<30 && M[v][u-1]==0){
			D[v][u-1]=D[v][u]+1;
			Q.push(u-1+v*W);
		}
		if(u<W-1 && D[v][u+1]>=1<<30 && M[v][u+1]==0){
			D[v][u+1]=D[v][u]+1;
			Q.push(u+1+v*W);
		}
		if(v>0 && D[v-1][u]>=1<<30 && M[v-1][u]==0){
			D[v-1][u]=D[v][u]+1;
			Q.push(u+(v-1)*W);
		}
		if(v<H-1 && D[v+1][u]>=1<<30 && M[v+1][u]==0){
			D[v+1][u]=D[v][u]+1;
			Q.push(u+(v+1)*W);
		}
	}
	out(D[H-1][W-1]>=1<<30 ? -1 : white-D[H-1][W-1]-1);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
int n,a[101],a1,a2,m,p;
main(){
  cin>>n>>m;
  r(i,n)cin>>a[i];
  r(i,n){
    if(a[i]%2)a1++;
    else a2++;
  }
  p=pow(2,a2);
  if(m){
    if(a1){a1--;
      if(a1)p*=pow(2,a1);
    }else p=0;
  }else{
    if(a1)a1--;
    if(a1)p*=pow(2,a1);
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
set<int>st;
int main(){
    lli n, t;
    cin >> n >> t;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i + j <= n){
                int k = n - (i + j);
                if(1LL*i*10000 + 1LL*j * 5000 + 1LL*k * 1000 == t)
                    return cout << i << ' ' << j << ' ' << k, 0;
            }
        }
    }

    return cout << -1 << ' ' << -1 << ' ' << -1, 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  ll sum=0;
  ll tmp=1;
  while(n!=0)
  {
    sum+=tmp;
    tmp *= 2;
    n/=2;
  }
  cout<<sum;
  return 0;
}

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

using namespace std;
typedef long long int ll;

ll INF = 114514191919119;

int main(){

    ll A, B;
    cin >> A >> B;

    if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    } 

}

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

int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    string t = s;
    sort(t.begin(), t.end());

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 3936
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b = li()
grid = []
for i in range(100):
    if i < 50:
        grid.append(["."]*100)
    else:
        grid.append(["#"]*100)
                     
for i in range(b-1):
    grid[i//25][2*(i%50)] = "#"

    
for j in range(a-1):
    grid[(-j-1)//25][2*(j%50)] = "."
    
    
print(100, 100)
for i in range(100):
    print("".join(grid[i]))

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

int n;
string s;
vector<int>a,b,c;
vector<vector<int>>h,k;
int x,y,z;

int main(void){
    cin>>n>>s;
    int len=s.length();
    if(len<=n) cout<<s<<endl;
    else cout<<s.erase(n)<<"..."<<endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

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

#define MAX_N 91
#define MAX_M 91
int m, n;

bool ice[MAX_N][MAX_M];
int r_x[] = {0, 1, 0, -1}, r_y[] = {-1, 0, 1, 0};

int dfs(int x, int y, int ans) {
  if ((0 <= x && x < m) == false) return ans-1;
  if ((0 <= y && y < n) == false) return ans-1;
  if (ice[y][x] == false) return ans-1;

  int max_ans = 0;
  rep(i, 4) {
    int tx = x + r_x[i];
    int ty = y + r_y[i];
    ice[y][x] = false;
    max_ans = max(max_ans, dfs(tx, ty, ans+1));
    ice[y][x] = true;
  }
  return max_ans;
}

int main() {
  while (true) {
    cin >> m;
    cin >> n;
    if (m == 0 && n == 0) break;

    rep(i, n) {
      rep(j, m) {
        int k;
        cin >> k;
        if (k == 1) ice[i][j] = true;
        else        ice[i][j] = false;
      }
    }
    //
    int answer = 0;
    rep(i, n) rep(j, m) answer = max(answer, dfs(j, i, 1));
    cout << answer << '\n';
  }
  return 0;
}

Measured memory_bytes: 1164
#include <stdio.h>

int main(){
  int i,j,n,k,l,h,A[100][100];

  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",&k,&l);
    for(j=0;j<l;j++){
      scanf("%d",&h);
      A[k-1][h-1]=1;
    }
  }

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

 return 0;
  
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <math.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;

int find(string s, char val, string from)
{
  if (from == "top")
  {
    for (int i = 0; i < s.size(); i++)
    {
      if(s.at(i) == val) return i;
    }
  }
  else if(from == "bottom")
  {
    for (int i = s.size(); i>=0, i--;) {
      if(s.at(i) == val) return i;
    }
  }
}

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

  int pa, pz;
  pa = find(S, 'A', "top");
  pz = find(S, 'Z', "bottom");

  cout << pz-pa+1 << endl;
}


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

int main(){
  	int N;
  	cin >> N;
  	int min_div = 30;
  	for (int i = 0; i < N; i++){
      	int x;
      	cin >> x;
      	int res = 0;
      	while (x%2==0){
          	x /= 2;
          	res++;
        }
      	min_div = res < min_div ? res : min_div;
    }
  	cout << min_div << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"No"<<endl;return 0;}
//template

//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  int ans=0;
  for(int i=1;i<N-1;i++)if((v[i+1]-v[i])*(v[i]-v[i-1])>0)ans++;
  cout<<ans<<endl;
}


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

using namespace std;
typedef long long ll;
const int N = 105 , Mod = 1e9 + 7 , G = 3 , INF = 0x3f3f3f3f;
double PI = acos(-1);

struct Virt{
    double x , y;
    Virt(double _x = 0.0 , double _y = 0.0):x(_x) , y(_y){}
};

Virt operator + (Virt x , Virt y){return Virt(x.x + y.x , x.y + y.y);}
Virt operator - (Virt x , Virt y){return Virt(x.x - y.x , x.y - y.y);}
Virt operator * (Virt x , Virt y){return Virt(x.x * y.x - x.y * y.y , x.x * y.y + x.y * y.x);}

int read(){
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-') f = -1 ; ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar();}
	return x * f;
}

ll f[N][N] , c[N][N];

int main(){
	int n = read();
	for(int i = 0 ; i <= n ; i++){
		c[i][0] = 1;
		for(int j = 1 ; j <= i ; j++)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % Mod;
	}
	f[1][n] = f[1][n - 1] = 1;
	for(int i = 1 ; i <= n ; i++)
		for(int j = -i ; j <= i ; j++)
			if(f[i][j + n])
			for(int s = max(1 , abs(j)) ; s <= n - i ; s++)
				if((j + s) % 2 == 0)
				for(int ss = 0 ; ss <= s ; ss++){
					int val = (j - s >> 1) + ss;
					if(val < -n || val > n) continue;
					f[i + s][val + n] = (f[i + s][val + n] + c[i + s][s] * f[i][j + n] % Mod * c[s][ss] % Mod) % Mod;
				}
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,k;cin>>a>>b>>c>>k;
	for(int i=1;i<=k;i++){
		if(a*2+b+c==max(a*2+b+c,max(a+b*2+c,a+b+c*2)))a*=2;
		else if(a+b*2+c==max(a*2+b+c,max(a+b*2+c,a+b+c*2)))b*=2;
		else c*=2;
	}
	cout<<a+b+c<<endl;
}

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

typedef long long ll;

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

using namespace std;

typedef struct p {
  string name;
  int time;
} p;

int main() {
  int n, q;
  cin >> n >> q;
  queue<p> ps;
  rep(i, n) {
    p elem = { string(""), 0 };
    cin >> elem.name;
    cin >> elem.time;
    ps.push(elem);
  }
  
  int time = 0;
  while (1) {
    if (ps.size() == 0) break;
    p elem = ps.front();
    time += min(elem.time, q);
    elem.time -= min(elem.time, q);
    if (elem.time > 0)  {
      ps.pop();
      ps.push(elem);
    } else {
      ps.pop();
      cout << elem.name << " " << time << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6236
#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<string,int>;

int main(){
  int n;
  cin >> n;
  vector<tuple<string,int,int>> p(n);
  rep(i,n){
    string S;
    int P;
    cin >> S >> P;
    p[i] = make_tuple(S,-P,i+1);
  }
  sort(p.begin(),p.end());
  rep(i,n){
    cout << get<2>(p[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    bool ans = false;
    for(int i = 0; i <= 25; i++){
        for(int j = 0; j <= 15; j++){
            if(i*4 + j*7 == n){
                ans = true;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;            
    }
    return 0;
}


Measured memory_bytes: 256
x,n = map(int, input().split())
p = set(map(int, input().split()))
ans = set(range(102))
ans = sorted(list(ans - p))
now = 110
a = 0
for i in ans:
  if abs(x-i) < now:
    a = i
    now = abs(x-i)
print(a)
  


Measured memory_bytes: 9136
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l=make_divisors(s)
ans=1
for y in l[1:]:
    x=[i%y for i in a]
    x.sort()
    ss=sum(x)
    l1=[0]
    for i in range(n):
        l1.append(l1[-1]+x[i])
    l2=[0]
    for i in range(n):
        l2.append(l2[-1]+y-x[-i-1])
    l2.reverse()
    c=-1
    for i in range(n+1):
        if l1[i]==l2[i]:
            c=l1[i]
            break
    if c>-1 and c<=k:
        ans=max(ans,y)

print(ans)


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

int main()
{
    int k,n;
    cin >> k >> n;
    vector<int> a(n);
    for(auto& ai:a) cin >> ai;

    int max_d = a[0] + (k - a[n-1]);
    rep(i,n-1) {
        max_d = max(max_d, a[i+1]-a[i]);
    }

    cout << k - max_d << endl;
    return 0;
}

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

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int total = 0;
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		total += a[i];
		}
	
	string res;
	int count = 0;
	for (int i = 0; i < n; ++i)
		if (a[i] >= float(total) / (4 * m)) 
			++count;
	if (count >= m) res = "Yes";
	else res = "No";

	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
int main(void){
    lint N,K;
    cin >> N >> K;
    lint* a = new lint[N];
    for(lint i = 0;i < N;i++)
        cin >> a[i];
    lint x = 0;
    x++;
    N -= K;
    while(N > 0){
        x++;
        N -= K-1;
    }
    cout << x;
    return 0;
}

Measured memory_bytes: 1148
// Problem : E - Red Scarf
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define fi first
#define se second
#define pb push_back
 
#define ll long long
#define pii pair<int, int>
//#define int ll
const int MOD = 1000000007;

int a[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int t = 0;
    rep(i, n) {
    	cin >> a[i];
    	t ^= a[i];
    }
    rep(i, n) {
    	cout << (t ^ a[i]) << ' ';
    }
}



Measured memory_bytes: 4392
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  char str[8][10]={"black","blue","lime","aqua",
		   "red","fuchsia","yellow","white"};
  int col[8][3]={{0,0,0},{0,0,255},{0,255,0},
		 {0,255,255},{255,0,0},{255,0,255},
		 {255,255,0},{255,255,255}};
  while(1){
    string s;
    cin>>s;
    if(s=="0")break;
    vi v(3,0);
    rep(i,3){
      if('a'<=s[i*2+1] && s[i*2+1]<='f')v[i]+=10+(s[i*2+1]-'a');
      else v[i]+=s[i*2+1]-'0';
      v[i]*=16;
      if('a'<=s[i*2+2] && s[i*2+2]<='f')v[i]+=10+(s[i*2+2]-'a');
      else v[i]+=s[i*2+2]-'0';
    }
    int ans=INF;
    rep(i,8){
      int tmp=0;
      rep(j,3)tmp+=(col[i][j]-v[j])*(col[i][j]-v[j]);
      ans=min(ans,tmp);
    }
    rep(i,8){
      int tmp=0;
      rep(j,3)tmp+=(col[i][j]-v[j])*(col[i][j]-v[j]);
      if(tmp==ans){
	cout<<str[i]<<endl;
	break;
      }
    }

  }
}

Measured memory_bytes: 3124
N, M, Q = STDIN.gets.split(' ').map(&:to_i)
A, B, C, D = (1..Q).map { STDIN.gets.split(' ').map(&:to_i) }.transpose

max = 0

(1..M).to_a.repeated_combination(N) do |x|
  sum = 0

  Q.times do |i|
    if x[B[i] - 1] - x[A[i] - 1] == C[i]
      sum += D[i]
    end
  end

  max = sum if max < sum
end

print max


Measured memory_bytes: 14564
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<ll, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
#define LEAD (lead && !i)
#define LIM (lim && i == buc[pos])
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int n;
int a[N];
ll ans, sum;

int main() {
    n = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= n; i++) {
        ans += (a[i] + sum) / 2;
        if (a[i]) {
            (sum += a[i]) %= 2;
        } else {
            sum = 0;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 640