akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	int n;
	cin>>n;
	vector<int> x(n),y(n);
	rep(i,n){
		cin>>x[i];
		y[i]=x[i];
	}
	sort(x.begin(),x.end());

	int a=x[n/2];
	int b=x[n/2-1];
	rep(i,n){
		if(y[i]<a){
			cout<<a<<endl;
		}else{
			cout<<b<<endl;
		}
	}


}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    map<string,int> vote;
    rep(i,n){
        string S; cin >> S;
        vote[S]++;
    }

    int maxv = 0;
    for(auto x : vote){
        if(x.second > maxv) maxv = x.second;
    }
    for(auto it : vote){
        if(it.second == maxv){
            cout << it.first << endl;
        }
    }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf pri64f
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 500005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 1001
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int dir_X[] = {0,0,1,-1} ;
int dir_Y[] = {1,-1,0,0} ;

int dis[805][805] ;
char s[805][805] ;

void bfs( int Sx, int Sy)
{
    memset(dis,-1,sizeof(dis)) ;
    queue<pair< int,int > > q ;
    q.push(mp(Sx,Sy)) ; dis[Sx][Sy] = 0 ;

    while(!q.empty())
    {
        pair<int,int> u = q.front() ;
        q.pop() ;
        for(int i= 0 ; i<4 ; i++)
        {
            int x = u.xx + dir_X[i] ;
            int y = u.yy + dir_Y[i] ;
            if( dis[x][y] == -1 && s[x][y]!='#' )
            {
                q.push(mp(x,y)) ;
                dis[x][y] = dis[ u.xx ][ u.yy ] + 1 ;
            }
        }
    }
    return ;
}

int main()
{
    int i , j , k , l , m , n ;

    int H, W , K ;

    sf("%d %d %d",&H,&W,&K) ;

    for(i=1 ; i<=H ; i++) sf("%s",s[i]+1) ;

    for(i=1 ; i<=H ; i++)
    {
        for(j=1 ; j<=W ; j++)
        {
            if(s[i][j]=='S') bfs(i,j) ;
        }
    }

    int ret = INF ;

    for(i=1 ; i<=H ; i++)
    {
        for(j=1 ; j<=W ; j++)
        {
            if( dis[i][j]!=-1 && dis[i][j]<=K ) ret = min( ret , min(min( i-1,H-i),min(j-1,W-j)) ) ;
        }
    }
    if(ret%K) ret = ret/K + 1 ;
    else ret = ret/K ;

    printf("%d\n",1 + ret ) ;

    return 0 ;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int pos[200009],ans1[200009],ans2[200009];

int main()
{
    int i,j,n;
    cin >> n;
    for(i=1;i<=n;i++)
    {
        cin >> j;
        pos[j]=i;
    }
    for(i=n-1;i>=1;i--)
    {
        if(pos[i]<pos[i+1])
            ans1[i]=ans1[i+1];
        else ans1[i] = (n-i);
    }
    for(i=2;i<=n;i++)
    {
        if(pos[i]>pos[i-1])
            ans2[i]=ans2[i-1];
        else ans2[i]=i-1;
    }
    int ans = n;
    for(i=1;i<=n;i++)
    {
        ans=min(ans,ans1[i]+ans2[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int res = 0;
        for(int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == '1') {
                res++;
            }
        }
        res = Math.min(res, s.length()-res);
        System.out.println(res*2);
    }
}


Measured memory_bytes: 39448
using System;
using System.Collections.Generic;

namespace JKA// ??????
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
             {
                List<string> kakuno = new List<string> { };
                    string gh = Console.ReadLine();
                if (gh == null)
                { break; }
                int d = int.Parse(gh);
                while (true)
                { if (d == 0) { break; }
                    for (int i = 9; i >= 0; i--)
                    {
                        if (Math.Pow(2, i) <= d) { kakuno.Add("" + Math.Pow(2, i) + ""); d -= (int)Math.Pow(2, i); break; }
                    }
                }

                kakuno.Reverse();
                for (int i = 0; i < kakuno.Count; i++)
                {
                    Console.Write(kakuno[i]);
                    if (i != kakuno.Count - 1)
                    {
                        Console.Write(" ");
                    }
                }Console.WriteLine();
            }    Console.ReadLine();
            
        }
    }
}

Measured memory_bytes: 9276
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    char ch;
    cin >> ch;

    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    	cout << "vowel" << endl;
    else
    	cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 	int n; cin>>n;
  	for (int i=0;i<=n/4;i++){
    	for (int j=0;j<=n/7;j++){
        	if((4*i+7*j)==n){cout<<"Yes"<<endl; return 0;}
        }
    }
  	cout<<"No"<<endl;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	count := map[int]int{}

	sizeA := nextInt()
	for i := 0; i < sizeA; i++ {
		count[nextInt()]++
	}
	sizeB := nextInt()
	for i := 0; i < sizeB; i++ {
		count[nextInt()]--
	}
	// fmt.Println(count)

	keys := []int{}
	for k := range count {
		keys = append(keys, k)
	}
	sort.Ints(keys)
	for _, k := range keys {
		if count[k] == 1 {
			fmt.Println(k)
		}
	}
}



Measured memory_bytes: 31284
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX / 2;
constexpr lint LINF = LLONG_MAX / 2;
constexpr double eps = 1e-9;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
lint mypow(lint a, lint b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	lint memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
std::string to_string(std::vector<int>& vec) {
	std::string res = "[";
	rep(i, vec.size() - 1)res += std::to_string(vec[i]) + ", ";
	res += std::to_string(vec.back()) + "]";
	return res;
}
int main() {
	int a,b,c,k;
	std::cin>>a>>b>>c>>k;
	if(k<=a)std::cout<<k<<std::endl;
	else if(k<=a+b)std::cout<<a<<std::endl;
	else std::cout<<a-(k-(a+b))<<std::endl;
	return 0;
}

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

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> v(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        v[i] = abs(x - X);
    }
    int res = gcd(v[0], v[1]);
    for (int i = 2; i < N; i++)
        res = gcd(res, v[i]);

    cout << res << endl;
    return 0;
}

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

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

    int n, mi = 100, ma = - 100;
    cin >> n;
    vector<int> A(n);
    REP(i, n){
        cin >> A[i];
        mi = min(mi, A[i]);
        ma = max(ma, A[i]);
    }

    int ans = 1e9;
    for(int i = mi; i <= ma; i++){
        int cnt = 0;
        REP(j, n){
            cnt += (i - A[j]) * (i - A[j]);
        } 
        ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import queue
from sys import maxsize as INFTY
from collections import namedtuple
Q = namedtuple("Q", "u c")

n = int(input())
dic = {}

for _ in range(n):
    a = [int(x) for x in input().split()]
    a.reverse()

    u, k = a.pop(), a.pop()
    for _ in range(k):
        v, c = a.pop(), a.pop()
        dic[(u, v)] = c


def bfs(n, s):
    res = [INFTY] * n
    q = queue.Queue()
    q.put(Q(s, 0))

    while q.qsize() != 0:
        p = q.get()
        if res[p.u] <= p.c: continue
        res[p.u] = p.c

        for i in range(n):
            if i == p.u: continue
            v = (p.u, i)
            if v not in dic: continue
            q.put(Q(i, p.c + dic[v]))
    return res


ans = bfs(n, 0)
for i in range(n):
    print(i, ans[i])



Measured memory_bytes: 8880
#include <stdio.h>
int main(void){
	int i,c=0;
	char s[11],a[11];
	scanf("%s",s);
	for(i=0;s[i]!='\0';i++){
		if(s[i]=='0'){
			a[c++]=s[i];
		}
		else if(s[i]=='1'){
			a[c++]=s[i];
		}
		else{
			c--;
			if(c<0)
				c=0;
			a[c]='\0';
		}
	}
	a[c]='\0';
	puts(a);
	return 0;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int x = 0;
    int ans = 0;

    for (char c : S) {
        if (c == 'I') x++;
        else x--;
        ans = max(x, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <cstdlib> 
#include <math.h>
#define gap cout<<endl;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define INF 1<<30
#define present(c,x) ((c).find(x) != (c).end())

int main(){

string s;
cin>>s;
int n=sz(s);
fo(i,n) cout<<'x';
cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include <string>
using namespace std;

int main(){
    int N;
    vector<int> d;

    cin>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        d.emplace_back(a);
    }

    sort(d.begin(),d.end());

    int ans=0;

    ans=d[N/2]-d[N/2-1];

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n,m; cin>>n>>m;
    if(n+m>=24)cout<<(n+m-24)<<endl;
    else cout<<n+m<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int ans = 0;
	for (int r = 0; r <= (N / R); r++) {
		for (int g = 0; g <= (N / G); g++) {
			int rest = N - r * R - g * G;
			if (rest % B == 0 && rest >= 0) {
				ans++;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int H, W;

	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		rep(i, H) {
			rep(j, W) {
				if ((i + j) % 2 == 0) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}




	return 0;
}



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

int main(void){
	
	int x,a,b;
	
	cin>>x>>a>>b;
	
	if(a-b>=0){
		cout<<"delicious"<<endl;
	}
	else if(a+x-b>=0){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"dangerous"<<endl;
	}

	return 0;
}


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

using namespace std;

int main(){
    long long N; cin >> N;
    vector<long long> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    int count=0;
    int res=0;
    for(int i=1; i<N; i++){
        if(H[i-1]>=H[i]){
            count++;
        }else{
            if(res<count){
                res=count;
            }
            count=0;
        }
    }
    if(res<count){
        res=count;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		
		for(;;) {
			int n = sc.nextInt(), m = sc.nextInt();
			if((n|m)==0) break;
			int h[] = new int[n+1], w[] = new int[m+1];
			for(int i=0;i<n;i++) h[i+1] = sc.nextInt() + h[i];
			for(int j=0;j<m;j++) w[j+1] = sc.nextInt() + w[j];
			short[] len = new short[1500 * 1000 + 1];
			
			for(int i=0;i<n;i++) for(int j=i+1;j<=n;j++) len[h[j] - h[i]]++;
			int cnt = 0;
			for(int i=0;i<m;i++) for(int j=i+1;j<=m;j++) 
				cnt += len[w[j] - w[i]];
			System.out.println(cnt);
		}
	}

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

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

Measured memory_bytes: 157744
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;

    cin >> N;

    int e[101] = {};

    for (int i = 2; i <= N; i++) {
        int cur = i;
        for (int j = 2; j <= i; j++) {
            while (cur % j == 0) {
                cur /= j;
                e[j] += 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i <= N - 1; i++) {
        for (int j = i + 1; j <= N; j++) {
            for (int k = 0; k <= N; k++) {
                if (i == k || j == k) {
                    continue;
                }
                if (e[i] >= 4 && e[j] >= 4 && e[k] >= 2) {
                    ans++;
                }
            }
        }
    }

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (i == j) continue;
            if (e[i] >= 24 && e[j] >= 2) ans++;
            if (e[i] >= 14 && e[j] >= 4) ans++;
        }
        if (e[i] >= 74) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
int main(){
	int i,n,r;
	int p,c;
	int yama[50],a[50],*src,*dest;
	while(scanf("%d%d",&n,&r)==2&&(n|r)){
		for(i=0;i<n;i++)yama[i] = n-i;
		while(r--){
			scanf("%d%d",&p,&c);
			memcpy(a,yama+(p-1),c*sizeof(int));
			memmove(yama+c,yama,(p-1)*sizeof(int));
			memcpy(yama,a,c*sizeof(int));
		}
		printf("%d\n",*yama);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
double a[100005];
int32_t main() {
	int n,i;
	cin>>n;
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	double ans=0;
	for(i=1;i<n;i++)
	{
		a[i]=(a[i]+a[i-1])/2;	
	}
	cout<<setprecision(13)<<a[n-1];
	
	
}


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

using namespace std;

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

    vector <int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    int count = 0;
    for (int i = 0; i < N; i++){
        x -= a[i];
        if (x < 0){
            break;
        }
        count++;
    }
    
    if (x > 0){
        count--;
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 200000;
static const int MIN = -1000000000;

int main()
{
	int a,n,temp;
	int count=0;
	long m = MIN;
	int index = 0;
	int buf[MAX];

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

	temp = buf[0];
	for(int j=1; j<n; j++){
		// cout << buf[j];
		if(m < buf[j]-temp){
			m = buf[j] - temp;
		}
		if(temp > buf[j]){
			temp = buf[j];
		}
	}

	cout << m << endl;

	return 0;
}

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

int main(){

    int a1, a2, a3, b1, b2, b3;
    cin >> a1 >> b1;
    cin >> a2 >> b2;
    cin >> a3 >> b3;

    vector<int> path(5, 0);
    path[a1]++; path[b1]++;
    path[a2]++; path[b2]++;
    path[a3]++; path[b3]++;

    int odd = count(path.begin(), path.end(), 1);
    int even = count(path.begin(), path.end(), 2);

    if(even == 2 && odd == 2) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<vector>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll N;
    cin>>N;
    ll n=N;
    int ans=0;
    for (int i=0;i<to_string(n).length();i++){
        ll y=pow(10,i+1);
        ll x=N%y;
        N-=x;
        ans+=x*10/y;
    }
    if (n%ans==0){
        cout<<"Yes"<<'\n';
    }else{
        cout<<"No"<<'\n';
    }
}

Measured memory_bytes: 256
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

x = arr_data[0][0]

mysum=0


for v in x:
    
    mysum+=int(v)
    
#print(mysum,int(x))
    
    
print("Yes" if int(x) % mysum ==0 else "No")

Measured memory_bytes: 3064
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();
    let n = s.len();

    let mut t0_count = 0;
    let mut t1_count = 0;

    for i in 0..n {
        if i % 2 == 0 {
            if s[i] == '0' {
                t1_count += 1;
            } else {
                t0_count += 1;
            }
        } else {
            if s[i] == '1' {
                t1_count += 1;
            } else {
                t0_count += 1;
            }
        }
    }
    println!("{}", std::cmp::min(t0_count, t1_count));
}


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

int main(){
    while (1){
        int n;
        cin >> n;
        if (n == 0) break;
        int m;
        cin >> m;
        vector<int> ox(m);
        vector<int> oy(m);
        for (int i = 0; i < m; i++){
            cin >> ox[i] >> oy[i];
        }
        vector<int> dx(m, 0);
        vector<int> dy(m, 0);
        vector<int> rev_dx(m, 0);
        vector<int> rev_dy(m, 0);
        for (int i = 1; i < m; i++){
            dx[i] = ox[i] - ox[i-1];
            dy[i] = oy[i] - oy[i-1];
            rev_dx[i] = ox[m - i - 1] - ox[m - i];
            rev_dy[i] = oy[m - i - 1] - oy[m - i];
        }

        for (int i = 0; i < n; i++){
            cin >> m;
            vector<int> ix(m);
            vector<int> iy(m);
            vector<int> sx(m, 0);
            vector<int> sy(m, 0);
            for (int j = 0; j < m; j++){
                cin >> ix[j] >> iy[j];
            }
            for (int j = 1; j < m; j++){
                sx[j] = ix[j] - ix[j-1];
                sy[j] = iy[j] - iy[j-1];
            }
            if ((sx == dx && sy == dy) || (sx == rev_dx && sy == rev_dy)){
                cout << i + 1 << endl;
                continue;
            }
            for (int j = 0; j < m; j++) sx[j] = -sx[j];
            if ((sy == dx && sx == dy) || (sy == rev_dx && sx == rev_dy)){
                cout << i + 1 << endl;
                continue;
            }
            for (int j = 0; j < m; j++) sy[j] = -sy[j];
            if ((sx == dx && sy == dy) || (sx == rev_dx && sy == rev_dy)){
                cout << i + 1 << endl;
                continue;
            }
            for (int j = 0; j < m; j++) sx[j] = -sx[j];
            if ((sy == dx && sx == dy) || (sy == rev_dx && sx == rev_dy)){
                cout << i + 1 << endl;
                continue;
            }
        }
        cout << "+++++" << endl;
    }
}



Measured memory_bytes: 3020
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		int m = Math.min(s.length() + t.length() - n, Math.min(s.length(), t.length()));

		for (int i = m; i >= 0; i--) {
			if (s.substring(s.length() - i).equals(t.substring(0, i))) {
				System.out.println(s.length() + t.length() - i);
				break;
			}
		}
	}
}


Measured memory_bytes: 9808
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = Integer.parseInt(scan.next());
		int[] A = new int[N + 1];
		int[] B = new int[N + 1];
		int[] C = new int[N + 1];
		
		for(int i = 1; i <= N; ++i) {
			int in = Integer.parseInt(scan.next());
			A[i] = in;
		}
		
		for(int i = 1; i <= N; ++i) {
			int in = Integer.parseInt(scan.next());
			B[i] = in;
		}
		
		for(int i = 1; i <= (N - 1); ++i) {
			int in = Integer.parseInt(scan.next());
			C[i] = in;
		}

		int sum = 0;
		
		for(int i = 1; i <= N; ++i) {
			sum += B[A[i]];
			
			if(i > 1 && A[i] == (A[i - 1] + 1)) {
				sum += C[A[i - 1]];
			}
		}
		
		pw.print(sum);
		
		scan.close();
		pw.close();
	}
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll X, Y;
    cin >> X >> Y;

    ll ans = 0;
    while (X <= Y) {
        ans++;
        X *= 2;
    }

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

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define F first
#define S second
#define OUT(x) cout << (x) << "\n"
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main() {
    int data[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    int x, y;
    cin >> x >> y;

    OUT(data[x] == data[y] ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (int i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(int n, int k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  int n;
  cin>>n;
  vi a(n),b(n),c(n-1);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n-1) cin>>c[i];
  ll ans=0;
  rep(i,n){
    ans+=b[a[i]-1];
    if(i!=0&&a[i]==1+a[i-1]){
      ans+=c[a[i-1]-1];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
import numpy as np
import sys

n = int(input())
dp = np.zeros(n, dtype=int)
h = np.array([int(x) for x in input().split()])
dp[1] = abs(h[1] - h[0])
for i in range(n - 2):
	dp[i + 2] = min(dp[i + 1] + abs(h[i + 2] - h[i + 1]), dp[i] + abs(h[i + 2] - h[i]))
print(dp[n - 1])
	


Measured memory_bytes: 23088
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val k = sc.nextInt()

  val odd = (1..k).map { it }.filter { it % 2 == 0 }.size
  val even = (1..k).map { it }.filter { it % 2 != 0 }.size

  println(odd * even)

}


Measured memory_bytes: 37604
def dfs(s):
    stack = []
    push, pop = stack.append, stack.pop
    push([s,[]])

    ans = 0

    while stack:
        ss, lst = pop()
        if ss == '':
            ans += sum(lst)
        for i in range(1,len(ss)+1):
            push([ss[i:] , lst + [int(ss[:i])]])
    return ans

s = input()
print(dfs(s))

Measured memory_bytes: 3064
use std::io::Read;
use std::ops::AddAssign;

const MAX: i64 = 100_001;
const MOD: i64 = 1_000_000_007;

struct BinaryIndexedTree<T> {
    array: Vec<T>,
}

impl<T: Default + Copy + AddAssign> BinaryIndexedTree<T> {
    // N個の値のprefix sumを管理する
    fn new(n: usize) -> BinaryIndexedTree<T> {
        BinaryIndexedTree {
            array: vec![Default::default(); n],
        }
    }

    // iは1-indexed
    fn add(&mut self, i: usize, x: T) {
        assert!(1 <= i && i < self.array.len());

        // ループ内でのビット演算のためにi32にキャスト。競プロの範囲では多分問題は起こらない。
        let mut i = i as i32;
        let size = self.array.len() as i32;
        while i < size {
            self.array[i as usize] += x;
            i += i & -i;
        }
    }

    // iは1-indexed
    fn sum(&self, i: usize) -> T {
        assert!(1 <= i && i < self.array.len());

        // ループ内でのビット演算のためにi32にキャスト。競プロの範囲では多分問題は起こらない。
        let mut i = i as i32;
        let mut sum = Default::default();
        while i > 0 {
            sum += self.array[i as usize];
            i -= i & -i;
        }
        return sum;
    }

    fn clear(&mut self) {
        for i in 0..self.array.len() {
            self.array[i] = Default::default();
        }
    }
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n = iter.next().unwrap().parse().unwrap();
    let a: Vec<i64> = (0..n)
        .map(|_| iter.next().unwrap().parse().unwrap())
        .collect();

    let target_count = (n as i64 * (n + 1) as i64 / 2 + 1) / 2;
    let offset = n + 2;
    let mut bit = BinaryIndexedTree::new(offset * 2);
    let mut lb = 0;
    let mut ub = a.iter().max().unwrap() + 1;

    while ub - lb > 1 {
        let mb = (ub + lb) / 2;
        let mut count = 0;
        let mut sum = 0;
        bit.clear();
        bit.add(offset, 1);

        for i in 0..n {
            if a[i] >= mb {
                sum += 1;
            } else {
                sum -= 1;
            }
            let pos = (sum + offset as i32) as usize;
            count += bit.sum(pos);
            bit.add(pos, 1);
        }
        //        dbg!(mb, count, target_count);
        if count >= target_count {
            lb = mb;
        } else {
            ub = mb;
        }
    }
    println!("{}", lb);
}


Measured memory_bytes: 8444
n,a,b,c,d = map(int, input().split())
s="a"
s+=input()

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i]=="#" and s[i+1]=="#":
    ans="No"

if ans=="No":
  print(ans)
else:
  if c < d:
    print(ans)
  else:
    ans="No"
    for i in range(b-1,d):
      if s[i]=="." and s[i+1]=="." and s[i+2]==".":
        ans="Yes"
    print(ans)
      


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

struct RollingHash {

    typedef long long int_type;
    typedef pair<int_type,int_type> hash_type;

    int_type base1;
    int_type base2;
    int_type mod1;
    int_type mod2;
    vector<int_type> hash1;
    vector<int_type> hash2;
    vector<int_type> pow1;
    vector<int_type> pow2;

    RollingHash() : base1(1007), base2(1009), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n=s.size();
        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);
        for (int i=0;i<n;++i) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    hash_type get(int l, int r) {
        int_type t1 = (hash1[r] - hash1[l] * pow1[r-l] % mod1 + mod1) % mod1;
        int_type t2 = (hash2[r] - hash2[l] * pow2[r-l] % mod2 + mod2) % mod2;
        return make_pair(t1,t2); 
    }

    int lcp(int l1, int r1, int l2, int r2) {
        int len = min(r1-l1,r2-l2);
        int lb = 0;
        int ub = len + 1;
        int mid;
        while(ub-lb>1) {
            mid = (ub+lb) / 2;
            if (get(l1,l1+mid)==get(l2,l2+mid)) lb = mid;
            else ub = mid;
        }
        return lb;
    }

};

int main() {
    int N; cin >> N;
    string S; cin >> S;
    RollingHash RH; RH.init(S);

    int high = N;
    int low = 0;
    int mid;
    while(high - low > 1) {
        mid = (high+low) / 2;
        map<pair<ll,ll>,int> used;
        bool check = false;
        for (int i=0;i+mid<=N;i++) {
            pair<ll,ll> p = RH.get(i,i+mid);
            if (used.find(p)==used.end()) used[p]=i;
            else if(i-used[p]>=mid){
                check = true;
                break;
            }
        }
        if(check) low = mid;
        else high = mid;
    }

    cout << low << endl;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define P pair<int,int>
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int t=0;
    REP(i,s.size()){
        if(s[i] == 'E'){
            t++;
        }
    }
    int ans=t;
    if(s[0]=='E'){
        ans--;
        t--;
    }
    FOR(i,1,s.size()){
        int x = t;
        if(s[i] == 'E') x--;
        if(s[i-1] == 'W') x++;
        ans = min(ans,x);
        t = x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;
int main(){
    string s;
    cin >> s;
    v1 atLR(0);
    int n = s.size();
    v1 ans(n, 0);
    rep(i, n-1){
        if(s[i] == 'R' && s[i+1] == 'L'){
            atLR.push_back(i);
        } 
    }
    if(s[n-2] == 'R') atLR.push_back(n-2);
    int N = atLR.size();
    for(int j = 0; j <= atLR[0]; j++){
        if((atLR[0]-j)%2 == 0) ans[atLR[0]]++;
        else ans[atLR[0]+1]++;
    }
    for(int i = 0; i <N-1; i++){
        for(int j = atLR[i]+1; j <= atLR[i+1]; j++){
            if(s[j] == 'L'){
                if((atLR[i] - (j-1))%2 == 0) ans[atLR[i]+1]++;
                else ans[atLR[i]]++;
            }else{
                if((atLR[i+1] - j)%2 == 0) ans[atLR[i+1]]++;
                else ans[atLR[i+1]+1]++;
            }
        }
    }
    for(int j = atLR[N-1]+1; j < n; j++){
        if((atLR[N-1]-(j-1))%2 == 0) ans[atLR[N-1]+1]++;
        else ans[atLR[N-1]]++;
    }
    rep(i, n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4092
#include <stdio.h>
#include <math.h>

double max(double a, double b){
	return a >= b ? a : b;
}

int main(){
	double x1, y1, x2, y2, x3, y3, A, B, C, K, R = 0;
	scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
	A = hypot(x1 - x2, y1 - y2);
	B = hypot(x2 - x3, y2 - y3);
	C = hypot(x3 - x1, y3 - y1);
//	printf("(A, B, C) = (%lf, %lf, %lf)\n", A, B, C);
	K = sqrt((A + B + C) / ((A + B - C) * (B + C - A) * (C + A - B)));
//	printf("K = %lf\n", K);
	R = max(R, A / (2 * (1 + A * K)));
	R = max(R, B / (2 * (1 + B * K)));
	R = max(R, C / (2 * (1 + C * K)));
	printf("%.12lf\n", R);
	return 0;
}

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

#define endl '\n'

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

    int n;
    cin >> n;
    int a = -1, b;
    for(int I = 0; I < n; I++) {
        int aa, bb;
        cin >> aa >> bb;
        if(aa > a) {
            a = aa;
            b = bb;
        }
    }
    cout << (a + b);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
typedef long long ll;
ll MOD = 1e9+7;

using namespace std;

ll a[300000];

int main()
{
	int n;
	ll ans=0;
	
	cin>>n;
	for(int i=0;i<3*n;i++)
		cin>>a[i];
	sort(a,a+(3*n));
	reverse(a,a+(3*n));
	for(int i=0;i<n;i++)
	{
		ans+=a[1+i*2];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    char c[n + 1];
    bool flag = true;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        if (c[i] == 'Y') flag = false;
    }
    if (!flag) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
def judge(S):
    N = len(S)
    if S[:(N-1)//2] != S[(N+1)//2:][::-1]:
        return False
    elif S[:(N-1)//2] != S[(N+1)//2:]:
        return False
    else:
        return True


S = input()
if judge(S):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
#define int long long int
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);

void solve(std::string S)
{
  if ((S.size() % 2) != 0)
  {
    YesNo(false);
    return;
  }
  rep(i, S.size())
  {
    if (i & 1)
    {
      if (S[i] != 'i')
      {
        YesNo(false);
        return;
      }
    }
    else
    {
      if (S[i] != 'h')
      {
        YesNo(false);
        return;
      }
    }
  }
  YesNo(true);
}

signed main()
{
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<functional>
#include<iomanip>

#define LLI long long int

using namespace std;

int main(){
	int A,B;cin>>A>>B;
	int ans=0;
	for(ans=0;ans<40;ans++){
		if((A-1)*ans+1>=B)break;
	}
	cout<<ans<<endl;
	return 0;
}



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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;
const ll Mod = 1e9+7;
int n;
vector<int> Adj[100010];
ll dp[100010][2];

ll Solve(int x,bool Black,int Par=-1)
{
    ll & Res = dp[x][Black];
    if(Res != -1)
        R Res;
    Res = 1;
    for(int i=0;i<Adj[x].sz;i++)
    {
        int to = Adj[x][i];
        if(to == Par)
            continue;
        if(Black)
        {
            Res *= Solve(to,0,x);
            Res %= Mod;
        }
        else
        {
            Res *= ((Solve(to,1,x)+Solve(to,0,x))%Mod);
            Res %= Mod;
        }
    }
    R Res;
}


int main()
{

    SPEED;
    int a,b;
    cin >> n ;
    for(int i = 0 ; i < n-1 ; i++)
    {
        cin >> a >> b;
        Adj[a].pb(b);
        Adj[b].pb(a);
    }
    Mdp;
    cout << (Solve(1,0)+Solve(1,1))%Mod << endl;


    R 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
using namespace std;
#define lli long long 
char a[1000][1000];
int h,w;
lli solve()
{
    lli dp[h][w];
    lli mod=1000000007;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=1;i<h;i++)
    { 
      if(a[0][i]=='#') 
      break; 
      dp[0][i]=1;
    }
    for(int i=1;i<w;i++)
    { 
      if(a[i][0]=='#') 
      break;
      dp[i][0]=1;
    }
    for(int i=1;i<h;i++)
    {
          for(int j=1;j<w;j++)
          {    if(a[i][j]=='#')
               dp[i][j]=0;
               else
               {
               dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod; 
               }
          }
    }
    return dp[h-1][w-1];
}
int main() 
{     //int h,w;
      cin>>h; cin>>w;
     // int a[h][w];
      for(int i=0;i<h;i++)
      {
          for(int j=0;j<w;j++)
          {
            cin>>a[i][j];
          }
      }
      cout<<solve();
}


Measured memory_bytes: 12420
{-# OPTIONS_GHC -Wall #-}

readInt :: String -> Int
readInt = read

binarySearch :: Int -> Int -> (Int -> Bool) -> Int
binarySearch lo hi f
    | lo+1 == hi = lo
    | otherwise  = if f mid then binarySearch mid hi f else binarySearch lo mid f
        where mid = (lo+hi) `div` 2

inf :: Int
inf = 1010000000000000000

isOk :: Int -> [Int] -> Int -> Int -> Bool
isOk _ [] _ _ = True
isOk 0 _ _ _  = False
isOk k xs@(w:ws) p r
    | w > r     = isOk (k-1) xs p p
    | otherwise = isOk k ws p (r-w)

solve :: Int -> [Int] -> Int
solve k ws = succ $ binarySearch 0 inf (not . isOk')
    where
        isOk' p = isOk k ws p p

main :: IO ()
main = do
    [_, k] <- fmap (map readInt . words) getLine
    ws <- fmap (map readInt . words) getContents
    let ans = solve k ws
    print ans



Measured memory_bytes: 14656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
ld N,M;
cin >> N >> M ;
ld sum=0;
ll count=0;
vector<ll> v(N);
for(ll i=0 ; i<N ;i++){
  cin >> v[i];
}
for(ll i=0 ; i<N ;i++){
  sum+=v[i];
}
for(ll i=0 ; i<N ;i++){
  if((sum/(4*M))<=v[i]){
    count+=1;
}
}
if(count>=M){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

int main(){
  int r,g;
  cin >> r >> g;
  cout << g*2-r << endl;
  return 0;
}


Measured memory_bytes: 256
import math

def main():
  x1, x2, x3, x4, x5 = map(int, input().split()) # スペース区切り入力
  x = [x1, x2, x3, x4, x5]
  for i in range(5):
    if x[i] == 0:
      print(i+1)
      break
    else:
      continue
    
if __name__ == '__main__':
  main()


Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int W;
int w[110],v[110];
int dp[120010];
bool F[120000];

signed main(){
	cin>>N>>W;
	REP(i,N){
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<=100000;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(int i=0;i<N;i++){
		for(int j=100000;0<=j;j--){
			if(dp[j]!=INF){
				dp[j+v[i]]=min(dp[j+v[i]],dp[j]+w[i]);
			}
		}
	}
	for(int i=100000;0<=i;i--){
		if(dp[i]<=W){
			cout<<i<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <math.h>
#include <algorithm>
using namespace std;

typedef long long ll;
const int maxn = 200200;

void solve()
{
    int a,b;
    cin >> a >> b;
    int ans;
    if (a % b > 0) ans = a / b + 1;
    else ans = a / b;
    cout << ans << endl;
}

void sec(){

}

int main()
{
    int t;
    solve();
    return (0);
}





Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char N[1000];
	scanf("%s", N);

	int i, j, k;
	for (i = 0; N[i] != '\0'; i++) {
		;
	}

	int flag = 0;
	for (j = 0, k = i - 1; j <= i / 2; j++, k--) {
		if (N[j] != N[k]) {
			flag = 1;
			break;
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
def count2(number):
    count = 0
    while True:
        if number % 2 == 0:
            count = count + 1
            number = number / 2
        else:
            break
    return count

N = int(input())
A_list = list(map(int, input().split())) 

answer = min(list(map(count2, A_list)))
    
print(answer)

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

int main(){
    int N;
    int odd=0,even=0;
    cin>>N;
    while(N--){
        int a;
        cin>>a;
        if(a%2)odd++;
        else even++;
    }
    if(odd%2){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Double S,L,H;
		int a,b;
		double angleC;
		final double PI = 3.14159265358979323846;
		Scanner scan = new Scanner(System.in);
		a=scan.nextInt();
		b=scan.nextInt();
		angleC=scan.nextDouble()/180*PI;
		scan.close();
		S=a*b*Math.sin(angleC)/2;
		L=a+b+Math.sqrt(a*a+b*b-2*a*b*Math.cos(angleC));
		H=b*Math.sin(angleC);
		System.out.println(S + "\n" + L + "\n" + H);
	}
}


Measured memory_bytes: 27964