akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}


//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

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

	int x;
	cin >> x;

	int ans = 0;


	//6→5...
	ans += x / 11;
	ans *= 2;

	x %= 11;
	//cout << x << endl;

	if (x > 0) {
		ans++;
		x -= 6;
	}
	if (x > 0) {
		ans++;
		x -= 5;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int len = s.length();
        long ans = 0;
        for (int bit = 0; bit < (1 << (len - 1)); bit++) {
            long wa = 0;
            long now = s.charAt(0) - '0';

            for (int i = 1; i < len; i++) {
                int tmp = s.charAt(i) - '0';
                if ((bit & (1 << len - 1 - i)) != 0) {
                    // +の場合
                    wa += now;
                    now = tmp;
                } else {
                    now *= 10;
                    now += tmp;
                }
            }
            wa += now;
            ans += wa;
        }
        System.out.println(ans);
        sc.close();
    }
}


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

using namespace std;

const int inf = 1000000000;

int n;
vector< pair<int,int> > X[202020];
vector< pair<int,int> > Y[202020];

vector< pair<int,int> > V[2][402020];
vector< pair<int,int> > W[2][402020];

int ans = inf;

int pos[202020];

bool cmp(const pair<int,int> &fr, const pair<int,int> &sc) {
	return fr.first < sc.first;
}

void check( vector< pair<int,int> >  &v,int mul) {
	if (v.size() <= 1) return ;
	sort(v.begin(),v.end(), cmp );

	pos[ v.size() ] = -1;
	for (int i = v.size() - 1; i >= 0; i--) 
	{
		if (v[i].second == -1)  pos[i] = i;
		else pos[i] = pos[i + 1];
	}

	for (int i = 0; i < v.size(); i++) if (v[i].second == 1) {
		if (pos[i] == -1) continue;
		else
			ans = min(ans, (-v[i].first + v[ pos[i] ].first)* mul );
	}
}

int main() {

	scanf("%d",&n);
	int xx,yy;
	char op[10];
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%s",&xx,&yy,op);
		if (op[0] == 'U') {
			Y[xx].push_back( make_pair(yy,1) );
			V[1][xx + yy].push_back( make_pair(yy,1) );
			W[0][yy - xx + 200000].push_back( make_pair(yy,1) );
		}
		else if (op[0] == 'R') {
			X[yy].push_back( make_pair(xx,1) );
			V[1][xx + yy].push_back( make_pair(yy,-1) );
			W[1][yy - xx + 200000].push_back( make_pair(yy,1) );
		}
		else if (op[0] == 'D') {
			Y[xx].push_back( make_pair(yy,-1) );
			V[0][xx + yy].push_back( make_pair(yy,-1) );
			W[1][yy - xx + 200000].push_back( make_pair(yy,-1) );
		}
		else if (op[0] == 'L') {
			X[yy].push_back( make_pair(xx,-1) );
			V[0][xx + yy].push_back( make_pair(yy,1) );
			W[0][yy - xx + 200000].push_back( make_pair(yy,-1) );
		}
	}

	for (int i = 0; i <= 200000; i++) {
		check( X[i],5);
		check( Y[i],5);
	}
	for (int i = 0; i <= 400000; i++) {
		check(V[0][i],10);
		check(W[0][i],10);
		check(V[1][i],10);
		check(W[1][i],10);
	}

	if (ans == inf) 
		printf("SAFE\n");
	else
		printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 69348
#include <stdio.h>
#define MAX 100000

int partition(int*,int,int);

int main(){
  int i, n, q, A[MAX];
  scanf("%d",&n);
  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  q = partition(A,0,n-1);

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

int partition(int* A, int p, int r){
  int x, i, j, temp;
  x = A[r];
  i = p - 1;
  for(j = p; j <= r-1; j++){
    if(A[j] <= x){
      i += 1;
      temp = A[j];
      A[j] = A[i];
      A[i] = temp;
    }
  }
  temp = A[r];
  A[r] = A[i+1];
  A[i+1] = temp;

  return i+1;
}

Measured memory_bytes: 992
use std::io;
use std::cmp;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let N: i32 = iter.next().unwrap().parse().unwrap();
    let K: i32 = iter.next().unwrap().parse().unwrap();
    println!("{}", if (N-1)/2>=K-1 { "YES" } else { "NO" });
}


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

#define int long long

void solve(int* col , vector<pair<int,int>>* edges){
	queue<int> q ;
	q.push(0) ;
	unordered_map<int,int> visited ;
	while(q.size()){
		int t = q.front() ;
		q.pop() ;
		int count = -1 ;
		for(auto i : edges[t]){
			if(col[i.second] > 0)
				count = i.second ;
		}
		int c = 1 ;
		 for(auto i : edges[t]){
			if(visited.count(i.first)) continue ;
			if(i.second == count) continue ;
			if(c == col[count]) {
				col[i.second] = edges[t].size() ;
				c++ ;
			}else{
				col[i.second] = c++ ;
			}
			q.push(i.first) ;
			visited[i.first] = 1 ;
		}
	}
}


int32_t main(){
	int n; cin >> n ;
	vector<pair<int,int>> edges[n] ;
	int col[n-1] = {0} ;
	for(int i = 0 ; i < n-1 ; i++){
		int f , s ;
		cin >> f >> s ;
		f-- , s-- ;
		edges[f].push_back({s,i}) ;
		edges[s].push_back({f,i}) ;
	}
	solve(col,edges) ;
	cout << *max_element(col,col+n-1) << endl ;
	for(auto i : col) cout << i << '\n' ;

	return 0 ;
}



Measured memory_bytes: 12580
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int N;
    cin >> N;
    vector<int> H(N,0);
    int count = 0;
    int max = -1;
    RANGE(i,N){
        cin >> H[i];
        if(H[i] >= max){
            count ++;
            max = H[i];
        }
    }
    cout << count << endl;
}


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

int a[110],b[110][110],ary[110];
int main(){
	int N,M,cnt;
	cin>>N>>M;
	for(int i=1;i<=M;i++){
		cin>>a[i];
		ary[i]=0;
	}
	for(int i=1;i<=M;i++){
		cnt=0;
		for(int j=1;j<=N;j++){
			cin>>b[i][j];
			if(b[i][j]==a[i]) ary[j]++;
			else cnt++;
		}
		ary[a[i]]+=cnt;
	}
	for(int i=1;i<=N;i++){
		cout<<ary[i]<<endl;
	}
	return 0;
}

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

int main()
{
    ll n,k;
    cin>>k>>n;
    vector<ll> houses;
    ll i,x;
    ll maxv = 0;
    ll maxi = 0;
    for(i=0;i<n;i++)
    {
        cin>>x;
        houses.push_back(x);
    }
    houses.push_back(k+houses[0]);
    for(i=1;i<=n;i++)
    {
        x = (houses[i] - houses[i-1]);
        // cout<<x<<endl;
        if(x>maxv)
        {
            maxv = x;
            maxi = i;
        }
    }
    ll sum =0;
    for(i=1;i<=n;i++)
    {
        if(i==maxi)
        {
            continue;
        }
        sum += houses[i] - houses[i-1];
    }
    cout<<sum<<endl;
  
    return 0;
}


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

using namespace std;

int main()
{
    int N, L;

    cin >> N;
    cin >> L;

    int taste = 0;
    int min;    
    int a;
    for ( int i = 0; i < N; i ++ ) {
        a = L + i ;        
        taste += a;
        if ( i == 0 ) {
            min = a;
        } else {
            if ( abs(min) > abs(a) ) min = a;
        }
    }
    
    taste -= min;

    cout << taste << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        //static List<List<int>> G = new List<List<int>>();
        //static List<List<Edge>>G = new List<List<Edge>>();
        //static List<Edge> E = new List<Edge>();

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = Console.ReadLine().Split();
            Console.WriteLine($"{p[1]}{p[0]}");

            //Console.Out.Flush();
        }
        
        struct Edge
        {
            public int from;

            public int to;
            public long dist;
            public Edge(int t, long c)
            {
                from = -1;
                to = t;
                dist = c;
            }
            public Edge(int f, int t, long c)
            {
                from = f;
                to = t;
                dist = c;
            }

        }
    }
    
    public class Scanner
    {
        public int[] ReadSplitInt()
        {
            return ConvertAll(Console.ReadLine().Split(), int.Parse);
        }
        public long[] ReadSplitLong()
        {
            return ConvertAll(Console.ReadLine().Split(), long.Parse);
        }
        public double[] ReadSplit_Double()
        {
            return ConvertAll(Console.ReadLine().Split(), double.Parse);
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public void Swap<T>(ref T a, ref T b)
        {
            T keep = a;
            a = b;
            b = keep;
        }

        static public void Display<T>(T[,] array2d, int n, int m)
        {
            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < m; j++)
                {
                    Console.Write($"{array2d[i, j]} ");
                }
                Console.WriteLine();
            }
        }

        static public long LPow(int a, int b)
        {
            return (long)Pow(a, b);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<bool> dp1(F + 1, false);
  dp1[0] = true;
  for (int i = 0; i <= F - A; i++){
    if (dp1[i]){
      dp1[i + A] = true;
    }
  }
  for (int i = 0; i <= F - B; i++){
    if (dp1[i]){
      dp1[i + B] = true;
    }
  }
  vector<bool> dp2(F + 1, false);
  dp2[0] = true;
  for (int i = 0; i <= F - C; i++){
    if (dp2[i]){
      dp2[i + C] = true;
    }
  }
  for (int i = 0; i <= F - D; i++){
    if (dp2[i]){
      dp2[i + D] = true;
    }
  }
  double c = -1;
  int w = 0, s = 0;
  for (int i = 1; i <= F; i++){
    for (int j = 0; j <= F; j++){
      if (i * 100 + j <= F){
        if (j <= i * E){
          if (dp1[i] && dp2[j]){
            if (c < (double) j / (i * 100 + j)){
              c = j / (double) (i * 100 + j);
              w = i * 100;
              s = j;
            }
          }
        }
      }
    }
  }
  cout << w + s << ' ' << s << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define ALL(x) (x.begin(),x.end())
using namespace std;

int main(){
vector<ll> e(5);
pair<ll,ll> rr = make_pair(0,10);
for(ll i=0;i<5;i++){
  cin>>e[i];
  if(e[i]%10<rr.second&&e[i]%10!=0){
    rr = make_pair(i,e[i]%10);
  }
}
ll ans =0;
for(ll i=0;i<5;i++){
if(i==rr.first)
continue;
if(e[i]%10==0){
ans+=e[i];
}
else
ans+=e[i]+10-(e[i]%10);
}

ans+=e[rr.first];
cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]

use std::thread;
use std::io::{ self, Read };
use std::fmt;
use std::iter::Iterator;
use std::cmp::*;
use std::collections::*;
use std::str::*;
use std::mem::*;

#[derive(Default)]
struct Input {
    buf: Vec<String>
}

impl Input {
    fn new() -> Input {
        Input { buf: Vec::new() }
    }

    fn read<T: FromStr>(&mut self) -> T 
    where <T as FromStr>::Err: fmt::Debug {
        self.next().unwrap().parse::<T>().unwrap()
    }

    fn read_2<T: FromStr, U: FromStr>(&mut self) -> (T, U)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug {
        (self.read(), self.read())
    }

    fn read_3<T: FromStr, U: FromStr, V: FromStr>(&mut self) -> (T, U, V)
    where <T as FromStr>::Err: fmt::Debug,
          <U as FromStr>::Err: fmt::Debug,
          <V as FromStr>::Err: fmt::Debug {
        (self.read(), self.read(), self.read())
    }
    fn read_bytes(&mut self) -> Vec<u8> {
        self.next().unwrap().into_bytes()
    }

    fn read_n<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where <T as FromStr>::Err: fmt::Debug {
        let mut v = Vec::new();
        for _ in 0..n { v.push(self.read::<T>()); }
        v
    }
}

impl Iterator for Input {
    type Item = String;
    fn next(&mut self) -> Option<String> {
        while self.buf.is_empty() {
            let mut s = String::new();
            let _res = io::stdin().read_line(&mut s);
            self.buf = s.split_whitespace().map(|s| s.to_owned()).collect::<Vec<_>>();
            self.buf.reverse();
        }
        self.buf.pop()
    }
}

fn run() {
    let mut ip = Input::new();
    let (mut a, mut b, k): (i64, i64, i64) = ip.read_3();
    for _ in 0..k {
        b += a / 2;
        a /= 2;
        swap(&mut a, &mut b);
    }
    if k % 2 == 1 { swap(&mut a, &mut b); }
    println!("{} {}", a, b);
}

fn main() {
    let _ = thread::Builder::new()
        .stack_size(10 * 1024 * 1024)
        .spawn(run).unwrap()
        .join();
}

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

#define x first
#define y second
#define int64 long long
#define MaxN 200000

int64 Sum[MaxN+1];
int xorSum[MaxN+1];
int v[MaxN+1];
int N;

int main(){

    int i, j;
  	int64 res = 0;

    scanf("%d", &N);
    for(i = 1; i <= N; ++i) scanf("%d", &v[i]);
    for(i = 1; i <= N; ++i){
        xorSum[i] = xorSum[i-1] ^ v[i];
        Sum[i] = Sum[i-1] + v[i];
    }

    for(j = i = 1; i <= N; ++i)
    {
        if(j < i) j = i;
        while(j <= N && (Sum[j] - Sum[i - 1]) == (xorSum[j] ^ xorSum[i - 1])) ++j;
        --j;

        res = res + (j - i + 1);
    }

    printf("%lld\n", res);


return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int peper[15][15];

void paint(int x, int y)
{
	if (0 <= x && 0 <= y && x <= 9 && y <= 9)	peper[y][x]++;
}

int main(void)
{
	int x, y;
	int size;
	int dark = 0, blank = 0;
	int i, j;
	
	while (scanf("%d,%d,%d", &x, &y, &size) != EOF){
		peper[y][x]++;
		paint(x, y - 1);
		paint(x, y + 1);
		paint(x - 1, y);
		paint(x + 1, y);

		if (size > 1){
			paint(x + 1, y - 1);
			paint(x + 1, y + 1);
			paint(x - 1, y + 1);
			paint(x - 1, y - 1);
		}
		if (size > 2){
			paint(x, y - 2);
			paint(x, y + 2);
			paint(x - 2, y);
			paint(x + 2, y);
		}
	}
	
	for (i = 0; i < 10; i++){
		for (j = 0; j < 10; j++){
			if (peper[i][j] == 0)	blank++;
			if (dark < peper[i][j])	dark = peper[i][j];
		}
	}
	printf("%d\n%d\n", blank, dark);
	return (0);
}

Measured memory_bytes: 600
n  = int(input())
a = [int(input()) for i in range(n)]

# 0区間、偶数区間(2以上)、奇数区間、偶数区間(2以上)、0区間
dp = [[0] * (5) for i in range(n + 1)]
for i in range(n):
    dp[i + 1][0] = dp[i][0] + a[i]

    dp[i + 1][1] = min(dp[i][0:2]) + (a[i] % 2)
    if a[i] == 0:
        dp[i + 1][1] += 2
        
    dp[i + 1][2] = min(dp[i][0:3]) + (a[i] + 1) % 2
    
    dp[i + 1][3] = min(dp[i][0:4]) + (a[i] % 2)
    if a[i] == 0:
        dp[i + 1][3] += 2
        
    dp[i + 1][4] = min(dp[i][0:5]) + a[i]

print(min(dp[-1]))

Measured memory_bytes: 84688
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
	int ans=0;
	string s;
	getline(cin,s);
	for(int i=0;i<s.size();i++) {
		if(i==0) cout<<s[i];
		else if(i==s.size()-1) cout<<ans<<s[i];
		else if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z')) ans++; 
	}
	return 0;
}
//2019.7.29 LC

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
  while(1) {
    int x, y, cnt = 0;
    cin >> x >> y;
    if(x == 0 && y == 0)
      break;
    if(x < y) swap(x, y);
    
    while(1) {
      cnt++;
      x %= y;
      swap(x, y);
      if(y == 0) break;
    }
    cout << x << ' ' << cnt <<endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int n,y,m,d;
    cin>>n;
    int mil=(999/3-1/3)*200+(998-999/3+1/3)*195+1;
    while(n--){
        cin>>y>>m>>d;
        --y;
        int cnt=(y/3-1/3)*200+(y-1-y/3+1/3)*195;
        FOR(i,1,m){
            if(i%2==0&&(y+1)%3!=0) cnt+=19;
            else cnt+=20;
        }
        cnt+=d;
        cout<<mil-cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;

int main(int argc, char *argv[])
{
	int n;

	cin >> n;
	vector<int> c(n);
	for (int i=0; i<n; i++)
	{
		int a;
		cin >> a;
		c[a-1]=i+1;
	}

	for (int i=0; i<n; i++)
	{
		cout << c[i] << " ";
	}
	return 0;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    cout << max({ a*c , a*d, b*c, b*d }) << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<string,int> P;
int main()
{
    int n;
    cin>>n;
    map<string,int> m;
    rep(i,n)
    {
        string str;
        cin>>str;
        auto itr=m.find(str);
        if(itr!=m.end())m[str]++;
        else m[str]=1;
    }
    int t=0;
    for(auto itr=m.begin();itr!=m.end();itr++)
    {
        if(itr->second>t)t=itr->second;
    }
    cout<<endl;
    for (auto itr = m.begin(); itr!=m.end(); itr++)
    {
        if(itr->second==t)cout<<itr->first<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 25216
#include <stdio.h>

int main(void)
{
	int N;
	int *H;
	scanf("%d", &N);
	H = new int[N];

	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);

	int cnt =1;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < i; j++)
		{
			if (H[i] < H[j])
				break;

			if (j == i - 1)
				cnt++;
		}
	}

	printf("%d", cnt);
	rewind(stdin);
	getchar();

	delete[] H;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N,a,b,i,amax=0,bmax=0,anum,bnum,amax2,bmax2;
	cin >> N;
	vector<int> odd(100000), even(100000);
	REP(i, N/2) {
		cin >> a >> b;
		odd[a]++; even[b]++;
	}
	REP(i, 100000) {
		if (amax <= odd[i]) {
			amax2 = amax;
			amax = odd[i];
			anum = i;
		}
		else if (amax2 < odd[i]) {
			amax2 = odd[i];
		}
		if (bmax <= even[i]) {
			bmax2 = bmax;
			bmax = even[i];
			bnum = i;
		}
		else if (bmax2 < even[i]) {
			bmax2 = even[i];
		}
	}
	if (anum != bnum) {
		cout << (N / 2 - amax) + (N / 2 - bmax) << endl;
	}
	else {
		if (amax2 == 0) {//前半が全部同じ
			cout << (N / 2 - bmax2) << endl;
		}
		else if (bmax2 == 0) {//公判が全部同じ
			cout << (N / 2 - amax2) << endl;
		}
		else if (amax2 < bmax2) {//後半だけ次のやつにする
			cout << (N / 2 - amax) + (N / 2 - bmax2) << endl;
		}
		else if (amax2 > bmax2) {//前半だけ次のやつにする
			cout << (N / 2 - amax2) + (N / 2 - bmax) << endl;
		}
		else if (amax2 == bmax2){
			cout << (N / 2 - amax2) + (N / 2 - bmax2)<< endl;
			}
	}
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    K,S = map(int, readline().split())

    ans = 0
    for x in range(K+1):
        for y in range(K+1):
            if 0 <= S - x - y <= K:
                ans += 1 

    print(ans)


if __name__ == "__main__":
    main()


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

int main() {
  string s;
  cin >> s;
  bool ans = false;
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) ans = true;
  if(s[0] == s[3] && s[1] == s[2] && s[3] != s[1]) ans = true;
  if(s[0] == s[2] && s[1] == s[3] && s[2] != s[1]) ans = true;
  cout << ((ans)? "Yes" : "No") << endl;
  return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int X[N];
	vector<int> a(N);
	
	rep(i, N){
		cin >> X[i];
		a[i] = X[i];
	}
	
	sort(a.begin(), a.end());
	
	int r = a[N / 2], l = a[N / 2 - 1];
	
	rep(i, N){
		if(X[i] <= l)
			cout << r << endl;
		else
			cout << l << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3712
from itertools import product
N = int(input())
S = input()
S = [int(s) for s in S]
ans = 0
for q in product(range(10),repeat=3):
    i = 0
    for s in S:
        if s==q[i]:
            if i==2:
                ans += 1
                break
            else:
                i+=1
print (ans)

Measured memory_bytes: 41708
from itertools import product

H, W, K = map(int, input().split())
c = list()
for _ in range(H):
    c.append(input())

combiH = list(product([False, True], repeat=H))
combiW = list(product([False, True], repeat=W))

BLACK = ''.join(c).count('#')

result = 0
for redH in combiH:
    for redW in combiW:
        redRemovedInOneLine = ''
        for h in range(H):
            if redH[h]:
                continue
            for w in range(W):
                if redW[w]:
                    continue
                redRemovedInOneLine += c[h][w]
        
        if redRemovedInOneLine.count('#') == K:
            result += 1


print(result)


Measured memory_bytes: 8852
N = gets.to_i
S = gets.chomp
max = 0

for i in 0..N-1
  a = S[0, i]
  b = S[i..N]
  score = 0
  
  ('a'..'z').map do |char|
    score += a.include?(char) && b.include?(char) ? 1 : 0
  end
  
  if max < score then
    max = score
  end
end
 
puts max

Measured memory_bytes: 1788
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const int MAX_N = 100;

int N;
ll W;
ll w[MAX_N], v[MAX_N], wsum[4][MAX_N + 1];
vector<ll> wsp[4];

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

    cin >> N >> W;

    for (int i = 0; i < N; i++) {
        cin >> w[i];
        cin >> v[i];
        wsp[w[i] - w[0]].push_back(v[i]);
    }

    for (int i = 0; i < 4; i++) {
        sort(wsp[i].begin(), wsp[i].end(), greater<ll>());
        wsum[i][0] = 0;
        for (int j = 1; j <= wsp[i].size(); j++) {
            wsum[i][j] = wsum[i][j - 1] + wsp[i][j - 1];
        }
    }

    ll ans = 0;
    for (int i = 0; i <= wsp[0].size(); i++) {
        for (int j = 0; j <= wsp[1].size(); j++) {
            for (int k = 0; k <= wsp[2].size(); k++) {
                ll s = (i + j + k) * w[0] + j * 1 + k * 2;
                if (s <= W) {
                    ans = max(ans, wsum[0][i] + wsum[1][j] + wsum[2][k] + wsum[3][(W - s) / (w[0] + 3)]);
                }
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for ( int i = 0; cin >> ch; i++ ) {
    if ( ch == '\\' ) S1.push(i);
    else if ( ch == '/' && S1.size() > 0 ) {
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while ( S2.size() > 0 && S2.top().first > j ) {
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j, a));
    }
  }

  vector<int> ans;
  int t = 0;
  while ( S2.size() > 0 ) { ans.push_back(S2.top().second); S2.pop(); }
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for ( int i = 0; i < ans.size(); i++ ) {
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3200
X, Y = map(int, input().split())
mod = 10 ** 9 + 7


def prime_mod(n, m):
    S = 1
    for i in range(1, n+1):
        S *= i
        S %= m
    return S


def prime_inv_mod(n, m):
    invs = [0] * (n + 1)
    invs[1] = 1
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m
    return invs


a = 2 * Y - X
b = 2 * X - Y
if a % 3 != 0 or b % 3 != 0 or a < 0 or b < 0:
    print(0)
else:
    a //= 3
    b //= 3
    upper = prime_mod(a+b, mod)
    mod_inv = prime_inv_mod(max(a, b), mod)

    lower1 = 1
    lower2 = 1
    for i in range(1, a + 1):
        lower1 *= mod_inv[i]
        lower1 %= mod
    for i in range(1, b + 1):
        lower2 *= mod_inv[i]
        lower2 %= mod

    print((upper*lower1*lower2) % mod)

Measured memory_bytes: 43756
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
//if it can you can use
//#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for (auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for (auto i=(b)-1;i>=(a);i--)
#define REP(i,n) for (auto i=0;i<(n);i++)
#define RREP(i,n) for (auto i=(n)-1;i>=0;i--)
#define EACHIM(i,v) for(auto i : v)
#define EACH(i,v) for(auto &i : v)
#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MI map<string, int>
#define MD map<string, double>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second
#define SORT(v) sort(ALL(v));
#define int(x) int x; scanf("%d",&x);
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%d", &v[i]);
#define vvint(v,n1,n2) vector<vector<int> > v(n1, vector<int>(n2, 0)) ; REP(i,n1) REP(j,n1) scanf("%d", &v[i][j]);
#define vlint(v,n) vector<ll int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vvlint(v,n1,n2) vector<vector<ll int> > v(n1, vector<ll int>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%lld", &v[i][j]);
#define double(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); REP(i,n) scanf("%lf", &v[i]);
#define vvdoube(v,n1,n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%lf", &v[i][j]);
#define char(x) char x; scanf("%c",&x);
#define vchar(v,n) vector<char> v(n); REP(i,n) scanf("%c", &v[i]);
#define vvchar(v,n1,n2) vector<vector<char> > v(n1, vector<char>(n2, 0)); REP(i,n1) REP(j,n1) scanf("%c", &v[i][j]);
#define string(x) string x; cin >> x;
#define vstring(v,n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(int argc, char const *argv[]) {
    int n=0,l=0;
    std::cin >> n >> l;
    vstring(v, n)
    sort(v.begin(), v.end());
    string ans;
    EACH(s, v) ans += s;
    std::cout << ans << std::endl;
    return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  char a, b ;
  cin >> a >> b ;
  
  if(a=='H' && b=='H'){
    cout << "H" <<endl ;
  }
  else if(a=='D' && b=='D'){
    cout << "H" <<endl ;
  }
  else{
    cout << "D" <<endl ;
  }
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

int nums[100000];

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

    int gokei=0;

    rep(i, N) gokei = gokei ^ nums[i];

    rep(i, N){
        if (gokei ^ nums[i] != nums[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}


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

int main(){
  int N, X;
  cin >> N >> X;
  
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  
  int count = 1;
  int D = 0;
  
  for (int i = 0; i < N; i++) {
    D += L.at(i);
    if (D <= X) {
      count++;
    } else {
      break;
    }
  }
  cout << count << endl;

 
  
  
  
  return 0;
}


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

using namespace std;

int main(void)
{
    int decks_count;
    int paths_count;
    vector<vector<int> > next_decks;
    vector<int> heights;

    cin >> decks_count >> paths_count;

    for(int i = 0; i < decks_count; i++){
        int h;
        cin >> h;
        heights.push_back(h);
    }

    next_decks.resize(decks_count);

    for(int i = 0; i < paths_count; i++){
        int deck_a, deck_b;
        cin >> deck_a >> deck_b;

        next_decks[deck_a - 1].push_back(deck_b - 1);
        next_decks[deck_b - 1].push_back(deck_a - 1);
    }

    int good_count = 0;
    for(int i = 0; i < decks_count; i++){
        bool is_highest = true;
        for(auto next = next_decks[i].begin(); next != next_decks[i].end(); next++){
            if(heights[i] <= heights[*next]){
                is_highest = false;
                break;
            }
        }
        if(is_highest){
            good_count += 1;
        }
    }

    cout << good_count << endl;

    return 0;
}

Measured memory_bytes: 8712
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <cstdio>
#include <cmath>

using namespace std;

string str_week[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "All" };
map<string, int> W;
int s, n, t, p, m;
string week, sTime;

// 時間を進める(分単位)
void addTime ( int &hh, int &mm, int &ww, int x )
{
	static const int day = 24 * 60 * 60;
	static const int hou = 60 * 60;
	static const int min = 60;
	if (!x) { return; }
	int tt = hh * hou + mm * min + x * min;
	if (tt >= day) {
		ww <<= 1;
		tt %= day;
		if (ww >= (1 << 7)) { ww = 1; }
	}
	hh = tt / hou;
	tt %= hou;
	mm = tt / min;
}

// 突然変異可能な曜日・時間帯か調べる
bool isChange ( int hh, int mm, int ww )
{
	if ((W[week] & ww) == 0) { return false; }
	if (sTime == "All") { return true; }
	if (sTime == "Day" && (6 <= hh && hh < 18)) { return true; }
	if (sTime == "Night" && (18 <= hh || hh < 6)) { return true; }
	return false;
}

double prob = 0;

// 確率をシミュレーションする
double getProb ( int hh, int mm, int ww )
{
	double miss = 1.0;
	for (int i = 0; i < m; ++i) {
		bool hit = true;
		hit &= isChange(hh, mm, ww); // 卵の出現した時は変異の範囲内か
		addTime(hh, mm, ww, s);
		hit &= isChange(hh, mm, ww); // 孵化の時は変異の範囲内か
		if (hit) { // 出現から孵化まで変異の範囲内なので変化が起こる(失敗)
			miss *= prob;
		}
		addTime(hh, mm, ww, t - s); // ステージの終了まで時間を進める
	}
	return 1.0 - miss;
}

int main ( void )
{
	W["All"] = (1 << 7) - 1;
	for (int i = 0; i < 7; ++i) {
		W[str_week[i]] = 1 << i;
	}
	while (cin >> s >> n >> t >> week >> sTime >> p >> m) {
		if (s+n+t+p+m == 0 && week == sTime && week == "None") { break; }
		double ans = 0;
		prob = pow((p - 1.0)/ (double)p, n);
		for (int i = 0; i < 7; ++i) {
			for (int j = 0; j < 24; ++j) {
				for (int k = 0; k < 60; ++k) {
					ans = max(ans, getProb(j, k, W[str_week[i]]));
				}
			}
		}
		printf("%.10lf\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1280
n = gets.to_i
ns = gets.split.map(&:to_i)

# 尺取り法
c = r = sum = 0

n.times do |l|
  while r < n && (sum ^ ns[r] == sum + ns[r])
    sum += ns[r]
    r += 1
  end

  c += r - l

  if l == r
    r += 1
  else
    sum -= ns[l] # or ^=
  end
end

p c


Measured memory_bytes: 17028
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	bool y[105][105] = {};


	int n; cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a,b; cin >> a>>b;
		for (int j = 0; j < b; j++) {
			int z;
			cin >> z;
			y[a][z] = 1;
		}
	}
	
	int p; cin >> p;
	for (int i = 0; i < p; i++) {
		int s, d, t;
		cin >> s >> d >> t;
		queue<int>Q;
		Q.push(s);
		int h = 1;
		int R[105] = {};
		for (int j = 0; j <= 102; j++)
			R[j] = 999999;
		R[s] = 1;
		while (Q.size()) {
			int v = Q.front();
			h = R[v];
			h++;
		
			
			bool F[105] = {};
			for (int j = 1; j <= n; j++) {
				if (y[v][j] && R[j] > h) {
					R[j] = h;
					Q.push(j);
				}



			}
			Q.pop();	
		}
/*		for (int j = 0; j < n; j++)
			cout << R[j] << " ";*/
		if (R[d] <= t)cout << R[d] << endl;
		else cout << "NA" << endl;
	}
	
	return 0;

}

Measured memory_bytes: 3100
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
	reg T x=0;reg short f=1;reg char c=getchar();
	for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
	for(;isdigit(c);x=x*10+(c^48),c=getchar());
	return x*f;
}
const int MN=100005;
struct edge{int t,nxt;}es[MN<<1];
int h[MN],cnt;
inline void ins(int s,int t){
	es[++cnt]=(edge){t,h[s]};h[s]=cnt;es[++cnt]=(edge){s,h[t]};h[t]=cnt;
}
int n,f;
inline int dfs(int st,int fa){
	if(f)return 1;
	reg int son=0;
	for(reg int i=h[st];i;i=es[i].nxt)
		if(es[i].t!=fa)son+=dfs(es[i].t,st);
	if(son>1)return f=1;
	return !son;
}
int main(){
	n=read<int>();
	for(reg int i=1;i<n;i++)ins(read<int>(),read<int>());
	reg int ans=dfs(1,0);puts((ans|f)?"First":"Second");
	return 0;
}

Measured memory_bytes: 2176
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <ctype.h>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
string str;
int main()
{
  getline(cin,str);
  for(int i = 0; i <str.size();i++){
    if(isupper(str[i]) == 0){//小文字なら
	str[i] = toupper(str[i]);
	cout << str[i];
	continue;
      }
    else{
      str[i] = tolower(str[i]);
      cout << str[i];
    }
  }
  cout <<endl;
  return 0;
}

Measured memory_bytes: 1176
import java.util.Arrays;
import java.util.Scanner;

//Differential 2
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t--!=0){
			char[] a = sc.next().toCharArray();
			Arrays.sort(a);
			int m = Integer.parseInt(new String(a));
			char[] b = new char[8];
			for(int i=0;i<8;i++)b[i]=a[7-i];
			System.out.println(Integer.parseInt(new String(b))-m);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	VL c(5, 0);
	char C[5] = { 'M','A','R','C','H' };
	rep(i, n) {
		string s;
		cin >> s;
		rep(j, 5) {
			if (s[0] == C[j]) c[j]++;
		}
	}
	ll ans = 0;
	ans += c[0] * c[1] * (c[2] + c[3] + c[4]);
	ans += c[0] * c[2] * (c[3] + c[4]);
	ans += c[0] * c[3] * c[4];
	ans += c[1] * c[2] * (c[3] + c[4]);
	ans += c[1] * c[3] * c[4];
	ans += c[2] * c[3] * c[4];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
#define vv(a,b) vector< vector<int> > v(a,vector<int>(b,0));
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    string s;
    cin>>s;
    int n=s.length();
    n--;
    ll ans=0;
    for(int bit=0;bit<(1<<n);bit++)
    {
        
        ll t=0;
        rep(i,n+1)
        {
            t*=10;
            t+=s[i]-'0';
            if(i==n)
            {
                ans+=t;
                break;
            }
            if(bit & (1<<i))
            {
                ans+=t;
                t=0;

            }
            
        }
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    char in;
    bool is3 = true;
    for(int i = 0; i < n; i++){
        scanf("%c", &in);
        if(in == 'Y') is3 = false;
    }
    printf("%s", is3 ? "Three" : "Four");
    return 0;
}

Measured memory_bytes: 128
def resolve():
  n, k = map(int, input().split())
  h = []
  for i in range(n):
    h.append(int(input()))
  h.sort()
  ans = 1e9+5
  for i in range(n-k+1):
    ans = min(ans, h[i+k-1] - h[i])
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 7384
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));
		String readline = br.readLine();

		String[] set = readline.split(" ");

		int a = Integer.parseInt(set[0]);
		int b = Integer.parseInt(set[1]);

		System.out.println(a*b + " " + 2 * (a + b));
	}

}

Measured memory_bytes: 24428
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  if(N >= M){
    cout << 0 << endl;
    return 0;
  }

  vector<int> X(M);
  for(int i = 0; i < M; i++) cin >> X[i];
  sort(X.begin(), X.end());

  vector<int> dist(M-1);
  for(int i = 0; i < M-1; i++){
    dist[i] = X[i+1] - X[i];
  }
  sort(dist.rbegin(), dist.rend());

  int ans = 0;
  for(int i = N-1; i < M-1; i++){
    ans += dist[i];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

//ll mod = 1000000007;
ll mod = 998244353;

signed main()
{
    int n;
    cin >> n;
    int in_ab = 0;
    int first_b = 0;
    int last_a = 0;
    int first_b_and_last_a = 0;
    rep(i, n)
    {
        string s;
        cin >> s;
        rep(j, s.size() - 1)
        {
            if (s[j] == 'A' && s[j + 1] == 'B')
            {
                in_ab++;
            }
        }
        if (s[0] == 'B' && s[s.size() - 1] == 'A')
        {
            first_b_and_last_a++;
        }
        else
        {
            if (s[0] == 'B')
            {
                first_b++;
            }
            if (s[s.size() - 1] == 'A')
            {
                last_a++;
            }
        }
    }
    int ans = 0;
    if (first_b_and_last_a == 0)
    {
        ans = min(first_b, last_a) + in_ab;
    }
    else if (first_b == 0 && last_a == 0)
    {
        ans = in_ab + first_b_and_last_a - 1;
    }
    else
    {
        ans = first_b_and_last_a + min(first_b, last_a) + in_ab;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <queue>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  ll n;
  cin >> n;
  vector<vector<pair<int,int>>> t = vector<vector<pair<int,int>>>(n+1, vector<pair<int,int>>(0));
  vector<bool> flag = vector<bool>(n+1, false);
  //black == true;
  vector<bool> color = vector<bool>(n+1, false);
  queue<int> q;
  int tmpu, tmpv;
  ll tmpw;
  REP(i, n - 1)
  {
    cin >> tmpu >> tmpv >> tmpw;
    t[tmpu - 1].push_back({tmpv - 1,tmpw%2});
    t[tmpv - 1].push_back({tmpu - 1,tmpw%2});
  }
  color[0] = true;

  q.push(0);

  while (!q.empty())
  {
    for (auto kv : t[q.front()])
    {
      int node = kv.first;
      int w = kv.second;
      if (flag[node])
        continue;
      if (w == 0)
      {
        color[node] = color[q.front()];
      }
      else
      {
        color[node] = !color[q.front()];
      }
      q.push(node);
    }
    flag[q.front()] = true;
    q.pop();
  }
  REP(i, n)
  {
    if (color[i])
    {
      cout << '1' << endl;
    }
    else
    {
      cout << '0' << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 6400
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i32 K, X;
  cin >> K >> X;
  if(500*K >= X) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
	long W,H;
	long a;
	cin >> H >> W;
	if(W==1){
		cout << 1 << endl;
	}else if(H==1){
		cout << 1 << endl;
	}else{
		if(H%2==0){
			cout << H/2*W << endl;
		}else{
			if(W%2==0){
				cout << ((H/2)+1)*(W/2) + ((H/2))*(W/2)<< endl;
		}else{
			if(W==3){
				cout << (((H/2)+1)*((W/2)+1)) + (((H/2))*1) << endl;
			}else{
				cout << (((H/2)+1)*((W/2)+1)) + (((H/2))*((W/2)))<< endl;
			}
		}
	}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, list(input())))

def mod2_pascal(n):
    res = []
    for r in range(n+1):
        res.append(1 if n == (r | (n-r)) else 0)
    return res

b = []

if N >= 3:
    for i in range(N-1):
        b.append(abs(a[i]-a[i+1]))
    mod2_line = mod2_pascal(N-2)
    ans = 0
    for i in range(N-1):
        if mod2_line[i] == 1:
            ans += b[i]
    if b.count(0) == N-1 - b.count(2):
        b_divided_by_2 = list(map(lambda x:x//2, b))
        for i in range(N - 1):
            if mod2_line[i] == 1:
                ans += b_divided_by_2[i]
        if ans%2 == 1:
            print(2)
        else:
            print(0)
    else:
        print(ans % 2)

else:
    print(abs(a[1]-a[0]))


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

vector<long> divisor(long N) {
  vector<long> res;
  for (long i = 1; i * i <= N; i++) {
    if (N % i == 0) {
      res.push_back(i);
      if (i != N / i) {
        res.push_back(N / i);
      }
    }
  }
  return res;
}

int main() {

  int N, M;
  cin >> N >> M;

  int d = M / N;
  
  vector<long> v = divisor(M);

  long answer = 0;

  for (int i = 0; i < v.size(); i++) {
    if (v[i] <= d) {
      answer = max(answer, v[i]);
    }
  }

  cout << answer << endl;

}

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

using namespace std;

int main(){
    long long A=0,B=0,C=0,D=0,N=0,ans=0;
    string S;



    cin>>S;
    vector<long long> vec(N);

    for(long i=0;i<S.size();++i){
        if(i%2==0){
            if(S[i]=='0'){
                B++;
            }else{
                A++;
            }
        }else{
            if(S[i]=='0'){
                A++;
            }else{
                B++;
            }
        }
    }


    cout<<min(A,B)<<endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

long long int gcd(long long int a, long long int b) {
    if(b==0) return a;
    return gcd(b, a%b);
}
int main(void){
    long long int a, b;
    while(cin >> a >> b) {
        long long int g = gcd(a, b);
        cout << g << " " << a*b/g << endl;
    }
}

Measured memory_bytes: 1156
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("YES")
no = lambda: print("NO")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = int(input())
print(3.14*t*2)

Measured memory_bytes: 9128