akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(){
      int i,j,ans1=0,ans2=0,ans3=0,ans4=0,N;
      cin >> N;

      string s1;
      for(i=0;i<N;i++){
             cin >> s1 ;
            char& k = s1.front();
            char& l = s1.back();
            
            if(k == 'B' && l == 'A')ans1++;
            if(k == 'B' && l != 'A')ans2++;
            if(k != 'B' && l == 'A')ans3++;

            for(j = 0; j < s1[j] != '\0';j++){
                  if(s1[j] == 'A' && s1[j+1] =='B')ans4++;
            }
      }
      if(ans1 == 0){
            cout << ans4 + min(ans2,ans3) << endl;
      }else if(ans1 != 0 && ans2 + ans3 == 0){
            cout << ans4 +(ans1-1) << endl;
      }else{
            cout << (ans1 + min(ans2,ans3)) + ans4 << endl;      
      }
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
module Main (main) where

-- import Control.Monad
-- import Control.Monad.Trans.State
import Data.ByteString (ByteString)
-- import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Char8 as C8
import Data.Bool
-- import Data.Bits
-- import Data.Char
-- import Data.List
import Data.Maybe

main :: IO ()
main = do
  readInts >>= print . showAnswer . solve

type Output = Int

solve :: [Int] -> Output
solve [a,b] = maximum [a+b, a-b, a*b]

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

-- readStrings :: IO [String]
-- readStrings = map C8.unpack . C8.words <$> C8.getLine

-- readPair :: IO (Int, Int)
-- readPair = head . unfoldr readT <$> C8.getLine
--   where
--     readT = runStateT $
--       (,) <$> StateT (C8.readInt . C8.dropWhile isSpace)
--           <*> StateT (C8.readInt . B.unsafeTail)

-- readDate :: IO [Int]
-- readDate = map (fst . fromJust . C8.readInt) . concatMap (C8.split '/') . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | ByteString ByteString
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)       = bool "No" "Yes"  b
  show (YESNO b)       = bool "NO" "YES"  b
  show (AB b)          = bool "B"  "A"    b
  show (Number i)      = show i
  show (String s)      = s
  show (ByteString bs) = C8.unpack bs
  show (Compare o)     = ordering "<" "=" ">" o
  show (Compare2 o)    = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

-- | k 番目の文字に関数 f を適用する
indexMapBS :: Int -> (Char -> Char) -> ByteString -> ByteString
indexMapBS k f s = C8.concat [s1, C8.singleton (f c), s3]
  where
    (s1, s2) = C8.splitAt (k-1) s
    c = C8.head s2
    s3 = C8.tail s2

Measured memory_bytes: 380
#include<stdio.h>
    #include<string.h>
     
    int main(void){
      int  i, l, f = 0;
      char s[101], t[101];
     
      scanf("%s", s);
      scanf("%s", t);
      l = strlen(s);
      for(i = 0; i < l; i++) { 
        if( strncmp(&s[0], &t[i], l - i) == 0 ) {
          if( strncmp(&s[l - i], &t[0], i ) == 0 ) { 
            f = 1;
          }
        }
      }
      printf("%s\n", f ? "Yes" : "No");
     
      return 0;
    }

Measured memory_bytes: 128
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cctype>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
typedef long long LL;
const int N=100005;
int n;
LL k,b[N],L[N],R[N],tot,ans,Ans;
struct data{int id; LL u,v;} dat[N];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;	
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

bool cmp(data a,data b)
{
	return a.v-a.u>b.v-b.u;
}

int main()
{
	n=getint(),k=getint();
	rep(i,1,n) b[i]=getint(),L[i]=getint(),R[i]=getint(),Ans+=b[i];
	rep(i,1,n) dat[i].u=-L[i]*b[i],dat[i].v=R[i]*(k-b[i]),dat[i].id=i;
	sort(dat+1,dat+1+n,cmp);
	rep(i,1,n) tot+=dat[i].u;
	rep(i,1,n)
	{
		if(tot-dat[i].u+dat[i].v>=0)
		{
			rep(j,i+1,n) if(tot-dat[j].u+dat[j].v>=0)
			{
				int p=dat[j].id;
				ans=k*(i-1);
				if(tot-dat[j].u>=0)
					ans+=(-tot-1)/L[p]+1;
				else ans+=b[p]+min(k-b[p],(-(tot-dat[j].u)-1)/R[p]+1);
				Ans=min(Ans,ans);
			}
			tot=tot-dat[i].u+dat[i].v;
			rep(j,1,i)
			{
				int p=dat[j].id;
				ans=k*i;
				if(tot-dat[j].v>=0) ans-=(k-b[p])+min((tot-dat[j].v)/L[p],b[p]);
				else ans-=tot/R[p];
				Ans=min(Ans,ans);
			}	
			break;
		}	
		tot-=dat[i].u;
		tot+=dat[i].v;
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 4864
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int K = sc.nextInt();
    	int[] D = new int[10];
    	for(int i=0;i<K;i++) {
    		D[sc.nextInt()]++;
    	}
    	int ans=0;
    	for(int i=0;i<=100000;i++) {
    		boolean flg=true;
    		if(i<N)continue;
    		int tmp=i;
    		while(tmp!=0) {
    			int mod=tmp%10;
    			if(D[mod]!=0)flg=false;
    			tmp=tmp/10;
    		}
    		if (flg==true) {
    			ans=i;
    			break;
    		}
    	}
    	
        System.out.println(ans);
        
        		
    }
}

Measured memory_bytes: 23888
#include<bits/stdc++.h>
using namespace std;
int kai(int x, int y){
  if (y == 0)
    return 1;
  else
    return x*kai(x, y-1);
}
int main(){
  int N;
  cin >> N;
  int M = N;
  int keta = 0;
  while(1){
    if (N/10 == 0){
      keta += 1;
      break;
    }
    keta += 1;
    N /= 10;
  }
  int ans = 0;
  for (int i = 0; i < keta; i++){
    if (i == keta-1 && keta >= 3){
      if (i%2 == 0){
        if (M % kai(10, keta-1) == 0)
          ans += M - kai(10, keta-1) + 1;
        else
          ans += M - kai(10, keta-1) + 1;
      }
    }
    else if (keta == 1){
      ans += M;
    }
    else {
      if (i%2 == 0)
        ans += 9*pow(10, i); 
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  bool f = true;
  for (int i=0; i<s.size(); i++) {
    if (i % 2 == 0 && s[i] == 'L') f = false;
    if (i % 2 == 1 && s[i] == 'R') f = false;
  }
  if (f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,s,e;
    scanf("%lld%lld%lld",&n,&s,&e);
    printf("%lld\n",max(1LL*0,((n-1)*e+s)-((n-1)*s+e-1)));
    // 1000000000*999999999+1    -    999999999+1000000000
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# 二分木
import bisect


n,d,a = map(int,input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()
x = [ tmp[0] for tmp in xh]
damage = [0] * (n+1)

ans = 0
for i in range(n):
    damage[i+1] += damage[i]
    if( damage[i+1] >= xh[i][1] ):
        continue
    atk_num = (xh[i][1] - damage[i+1] - 1)//a +1
    ans += atk_num
    damage[i+1] += atk_num * a
    right = bisect.bisect_right(x, xh[i][0] + 2*d)
    if( right < n):
        damage[right+1] -= atk_num * a

print(ans)

Measured memory_bytes: 88412
import java.util.Scanner;

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

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();

		boolean a[] = new boolean[n];
		for (int i = 1, cnt = 0; cnt < m; cnt++, i++) {
			int an = sc.nextInt();
			while (an != i) i++;
			a[i] = true;
		}

		int cntA = 0;
		int cntB = 0;
		for (int i = 0; i < x; i++) {
			if (a[i]) cntA++;
		}
		for (int i = x + 1; i < n; i++) {
			if (a[i]) cntB++;
		}
		if (cntA > cntB)
			System.out.println(cntB);
		else
			System.out.println(cntA);
	}
}


Measured memory_bytes: 22996
import sys
input=sys.stdin.readline
import math

def main():
    N,M = map(int, input().split())
    X = sorted(list(map(int, input().split())))
    D = sorted([X[i+1]-X[i] for i in range(M-1)], reverse=True)
    print(sum(D[N-1:]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 13564
#include <cstdio>
#include <utility>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
template <typename head, typename... tail>
bool scan(head &h, tail&&... t){return scan(h) && scan(t...);}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	int r[6] = {};
	for (int n = in(); n; n--) {
		int h = in(); in();
		int t = h / 5 - 32;
		r[t < 0 ? 0 : t > 5 ? 5 : t]++;
	}
	for (int i = 0; i < 6; i++) {
		out(i + 1, ':');
		for (int j = 0; j < r[i]; j++)
			out('*');
		out('\n');
	}
}


Measured memory_bytes: 2448
def b_sort(ca)
  c = ca.dup
  s = 0
  c.sort_by{|i| [i[1], s += 1]}
end

def s_sort(ca)
  c = ca.dup
  c.size.times do |i|
    m = i
    i.upto(c.size - 1) do |j|
      if c[j][1] < c[m][1]
        m = j
      end
    end
    c[m], c[i] = c[i], c[m]
  end
  c
end

gets
a = gets.split.map do |e|
  e =~ /(\w)(\d+)/
  [$1, $2.to_i]
end
b, c = [b_sort(a), s_sort(a)].map do |d|
  d.map(&:join).join(' ')
end
puts "#{b}\nStable"
puts "#{c}\n#{b == c ? 'Stable' : 'Not stable'}"

Measured memory_bytes: 8696
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        MyScanner scn = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------

        /*
         * int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); //
         * read input as long double d = sc.nextDouble(); // read input as double String
         * str = sc.next(); // read input as String String s = sc.nextLine(); // read
         * whole line as String
         * 
         * int result = 3*n; out.println(result); // print via PrintWriter
         */

        // Stop writing your solution here. -------------------------------------
        String s = scn.next();
        // BigInteger input = new BigInteger(s);
        BigInteger ans = new BigInteger("0");

        for (int i = 0; i < s.length(); i++) {
            int val = s.charAt(i) - '0';
            ans = ans.add(BigInteger.valueOf(val));
        }
        out.println(ans.mod(BigInteger.valueOf(9)) == BigInteger.valueOf(0) ? "Yes" : "No");

        out.close();
    }

    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }

}

Measured memory_bytes: 49180
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>


int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    int low = std::max(a, c);
    int up = std::min(b, d);
     std::cout << std::max (0, up - low) << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int n =fr.nextInt() ;

 		if (n >= 30)
 			op.println("Yes") ;
 		else 
 			op.println("No") ;

		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next()) ;
		}
	}
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    ll ans = 0;
    Cin(int, k);
    for(int a = 1; a <= k; a ++){
        for(int b = 1; b <= k; b ++){
            for(int c = 1; c <= k; c ++){
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    Cout(ans);
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


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

const int MOD = 1e9 + 7;



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


/******************************************************************************************/


int main() {

	
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	}










	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int n, sum;
int a[205];
int main() {
	while(~scanf("%d", &n)){
		for(int i = 1; i <= 2 * n; i++) scanf("%d", &a[i]);
		sum = 0;
		sort(a + 1, a + 2 * n + 1);
		for(int j = 2 * n; j >= 1; j = j - 2){
			sum += a[j - 1];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Scan()
	s.Scan()
	ds := s.Text()

	dd := strings.Split(ds, " ")
	dn := make([]int, len(dd))
	for i, d := range dd {
		dn[i], _ = strconv.Atoi(d)
	}

	sum := 0
	for i := 0; i < len(dn); i++ {
		for j := i + 1; j < len(dn); j++ {
			sum += dn[i] * dn[j]
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
import math
N,D = map(int,input().split())
k = []
ans_2 = 0
ans_1 = 0
now = 0
for i in range(N):
    k.append(list(map(int,input().split())))
for i in range(0,N):
    for j in range(i+1,N):
        for _ in range(D):
            now += (k[i][_]-k[j][_])**2
        ans_1 = math.sqrt(now)
        if ans_1%1 == 0:
            ans_2 += 1
        now = 0
        ans_1 = 0
print(ans_2)


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

using namespace std;

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

vector<int> per;
int e[1030];
bool aru[1030];

bool func(int sude, int to, int st)
{
	int tmp=0;
	for(int i=0; i+sude<10; i++)
	{
		tmp|=(1<<per[sude+i]);
		if((to&tmp) && aru[tmp])
		{
			if(e[tmp]&(st|tmp))
			{
				//cout << tmp << ' ' << st << ' ' << e[tmp] << endl;
				//cout << 'a' << sude << ' ' << sude+i << ' ' << (st|tmp) << endl;
				return true;
			}
			if(func(sude+i+1, e[tmp], (st|tmp)))
			{
				//cout << 'b' << sude << ' ' << sude+i << ' ' << (st|tmp) << endl;
				return true;
			}
		}
	}
	return false;
}

int main()
{
	int n;
	string s;
	int u[10010];
	while(cin >> n && n>0)
	{
		per.clear();
		rep(i, 10) per.push_back(i);
		cin >> s;
		rep(i, 1024)
		{
			e[i]=0;
			aru[i]=false;
		}
		int sz=0;
		u[0]=-1;
		rep(i, n)
		{
			if(s[i]=='u')
			{
				sz++;
				u[sz]=i;
			}
		}
		rep(i, sz)
		{
			int tmp=0;
			for(int j=u[i]+1; j<u[i+1]-1; j++)
			{
				tmp|=(1<<((int)s[j]-(int)'0'));
				aru[tmp]=true;
				e[tmp]|=(1<<((int)s[j+1]-(int)'0'));
			}
		}
		//cout << e[1] << ' ' << e[2] << e[4] << endl;
		bool ikeru=false;
		do{
			if(func(0, (1<<10)-1 ,0))
			{
				ikeru=true;
				//rep(i, 10) cout << per[i];
				//cout << endl;
				break;
			}
		} while(next_permutation(per.begin(), per.end()));
		if(ikeru) cout << "UNSAFE" << endl;
		else cout << "SAFE" << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include <cstdio>
#include <climits>

int p[100010];
long long xv[100010], cv[100010];

int main(){
  int N, M; scanf("%d%d", &N, &M);
  for(int i = 1; i <= N; i++) scanf("%d", &p[i]);

  for(int i = 2; i <= N; i++){
    int s = p[i - 1], e = p[i];
    int n = (e > s ? e - s : e - s + M);

    int rs = 1 + e - n, re = e;

    if(rs < 1){
      xv[1]--; cv[1] += e + 1;
      xv[e + 1]++; cv[e + 1] -= e + 1;
      cv[e + 1] += n; cv[rs + M] -= n;
      xv[rs + M]--; cv[rs + M] += e + M + 1;
      xv[M + 1]++; cv[M + 1] -= e + M + 1;
    }
    else{
      cv[1] += n; cv[rs] -= n;
      xv[rs]--; cv[rs] += e + 1;
      xv[re + 1]++; cv[re + 1] -= e + 1;
      cv[re + 1] += n; cv[M + 1] -= n;
    }
  }

  for(int i = 2; i <= M; i++){
    xv[i] += xv[i - 1]; cv[i] += cv[i - 1];
  }

  long long ans = LLONG_MAX;

  for(int i = 1; i <= M; i++){
    long long res = xv[i] * i + cv[i];
    if(res < ans) ans = res;
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2176
from math import *
a, b, c = map(int, input().split())
theta = radians(c)
S = 0.5*a*b*sin(theta)
H = 2*S/a
L = sqrt(a*a + b*b - 2*a*b*cos(theta)) + a + b
print('%f %f %f' % (S, L, H))


Measured memory_bytes: 5712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp69 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();

            char[] s_ = s.ToCharArray();

            char[] s_reverse = s_.Reverse().ToArray();

            int A_index = Array.IndexOf(s_, 'A');

            int Z_index = Array.IndexOf(s_reverse, 'Z');

            Console.WriteLine(s.Length - A_index - Z_index);

        }
    }
}


Measured memory_bytes: 14176
/**
 *    author:  tourist
 *    created: 05.01.2020 11:08:10       
**/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll solve(ll n, ll a, ll b, ll m) {
  if (b == 0) return n * (a / m);
  if (a >= m) return n * (a / m) + solve(n, a % m, b, m);
  if (b >= m) return n * (n - 1) / 2 * (b / m) + solve(n, a, b % m, m);
  return solve((a + b * n) / m, (a + b * n) % m, m, b);
}

pair<long long, long long> GetKBest(int k, long long cx, long long cy) {
  long long high = (long long) sqrt(2 * k * (double) cx * (double) cy);
  long long low = max(0LL, high - cx - cy - 1);
  while (low < high) {
    long long mid = (low + high) >> 1;
    long long cnt = solve(mid / cx + 1, mid % cx, cx, cy) + (mid / cx + 1);
    if (cnt >= k) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  long long sx = 0, sy = 0;
  for (int x = 0; x * cx <= high; x++) {
    long long cc = (high - x * cx) / cy + 1;
    sx += cc * x;
    sy += cc * (cc - 1) / 2;
  }
  return {sx, sy};
}

bool Solvable(int k, int X, int Y) {
  auto a = make_pair(-1LL, -1LL), b = a;
  long long total = (long long) 1e9 + 7;
  long long low = 0, high = total;
  while (low < high) {
    long long mid = (low + high) >> 1;
    auto p = GetKBest(k, total - mid, mid);
    if (p.first <= X && p.second <= Y) {
      return true;
    }
    if (p.first >= X && p.second >= Y) {
      return false;
    }
    if (p.first < X) {
      a = p;
      low = mid + 1;
    } else {
      b = p;
      high = mid;
    }
  }
  return (a.second * (b.first - X) + b.second * (X - a.first) <= Y * (b.first - a.first));
}

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X > Y) {
    swap(X, Y);
  }
  int low = 3, high = (int) 2e6;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Solvable(mid, X, Y)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N,Q;cin>>N>>Q;
        if(N+Q==0) break;
        vector<string> A(N);
        vector<int> S(N),T(N);
        
        for(int i=0;i<N;i++){
            cin>>A[i];
            int a,b;cin>>a>>b;
            S[i]=b-a;
            T[i]=b;
        }
        
        for(int i=0;i<Q;i++){
            int a;cin>>a;
            bool ok=false;
            for(int j=0;j<N;j++){
                if(S[j]<a&&a<=T[j]){
                    cout<<A[j]<<" "<<a-S[j]<<endl;
                    ok=true;
                }
            }
            if(!ok) cout<<"Unknown"<<endl;
        }
    }
    
}



Measured memory_bytes: 3268
fun main(args: Array<String>) {
    fun divCnt(cnt: Int, nums: List<Int>): Int {
        return if (nums.all { it % 2 == 0 }) {
            divCnt(cnt + 1, nums.map { it / 2 })
        } else {
            cnt
        }
    }

    readLine()
    val nums =
        readLine()!!
            .split(" ")
            .map { it.toInt() }
    print(divCnt(0, nums))
}

Measured memory_bytes: 36060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll n, x;
    scl(n);
    vector<ll> v;
    v.push_back(0);
    for (int i = 1; i <= n; i++)
    {
        scl(x);
        v.push_back(x);
    }
    x = 1000;
    ll i = 1;
    while (i < n)
    {
        if (v[i] < v[i + 1])
        {
            ll d = x / v[i];
            x += (d * (v[i + 1] - v[i]));
        }
        i++;
    }
    pcl(x);
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	vector<int> a(3); CI a;
	sort(all(a),greater<int>());
	int k; CI k;

	REP(i, k) {
		a[0] = a[0] * 2;
	}
	int ans = 0;
	REP(i, 3) {
		ans += a[i];
	}
	CO ans EN;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;



int main(){	
	long long N;
	cin >> N;
	vector<ll> a(N);
	rep(i, N) cin >> a[i];
	ll m1 = 0, m2 = 0;
	rep(i, N) {
		if (m1 <= a[i]) {
			m2 = m1;
			m1 = a[i];
		} else if (m2 <= a[i]) {
			m2 = a[i];
		}
	}
	rep(i, N) {
		if (a[i] == m1) cout << m2 << endl; else cout << m1 << endl;
	}
	return 0;
}



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

const int MAX_S = 2005;
const int64_t MOD = 1000000007;
int64_t mem[MAX_S];
int S;

int64_t dp(int s) {
  if (s == 0) return 1;
  if (mem[s] != -1) return mem[s];
  int64_t ans = 0;
  for (int i = 3; i <= s; ++i) {
    ans = (ans + dp(s - i)) % MOD;
  }
  mem[s] = ans;
  return ans;
}

int main() {
  memset(mem, -1, sizeof(mem));
  scanf("%d", &S);
  printf("%lld\n", dp(S));
}


Measured memory_bytes: 3848
#include<iostream>

using namespace std;

int main(){
 	string s1,s2;
  	cin >> s1 >> s2;
  	int ans = 0;
  if(s1[0] == s2[0])	ans++;
  if(s1[1] == s2[1])	ans++;
  if(s1[2] == s2[2])	ans++;
  	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(void)
{
    double we;
    while(scanf("%lf",&we)!=EOF){
        if(we<=48) cout<<"light fly" << endl;
        else if(48<we&&we<=51) cout<<"fly"<<endl;
        else if(51<we&&we<=54) cout<<"bantam"<<endl;
        else if(54<we&&we<=57) cout<<"feather"<<endl;
        else if(57<we&&we<=60) cout<<"light"<<endl;
        else if(60<we&&we<=64) cout<<"light welter"<<endl;
        else if(64<we&&we<=69) cout<<"welter"<<endl;
        else if(69<we&&we<=75) cout<<"light middle"<<endl;
        else if(75<we&&we<=81) cout<<"middle"<<endl;
        else if(81<we&&we<=91) cout<<"light heavy"<<endl;
        else if(91<we) cout<<"heavy"<<endl;
    }
    return 0;
}


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

using namespace std;

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

  int ans = 0;
  while (true) {
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 == 0) A[i] /= 2;
      else goto END;
    }
    ans++;
  }

  END:
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cfenv>
#include <cmath>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 0x3f //plus infinite

typedef struct item{
  string name;
  int number;
  int money;
}item;

int A[10000000];

int main(){
  int N,M;
  cin >> N >> M;
  for(int i = 1;i <= M;i++){
    cin >> A[i];
    N-=A[i];
  }

  if(N >= 0){
    cout << N << endl;
  }else{
    cout << "-1" << endl;
  }

  


  return 0;
}

/*文字列の辞書順について
 *C++の順序では'0'～'9'→'A'～'Z'→'a'～'z'の順に
 *                       なっていることに注意しましょう。
 */

/*行単位での入力
 * getline(cin,文字列変数);
 */


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

int main()
{
  int N,K,harf,ans=0;
  cin >> N >> K;
  harf=K/2;
  rep(i,N)
  {
    int x;
    cin >> x;
    
    if(x <= harf)
      ans += 2 * x;
    else
      ans += 2 * (K - x);
  }
    cout << ans << endl;
}
    

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())),reverse = True)

edge = []

for i in range(1,N):
  if A[i] == A[i - 1] and A[i] not in edge:
    edge.append(A[i])
  elif A[i] == A[i - 3]:
    edge.append(A[i])
  
  if len(edge) == 2:
    break
    
if len(edge) <= 1:
  print(0)
else:
  print(edge[0] * edge[1])

Measured memory_bytes: 14224
S = raw_input()
a, b, c = 0, 0, 0
for s in S:
    if s == "a":
        a += 1
    if s == "b":
        b += 1
    if s == "c":
        c += 1
a, b, c = sorted([a, b, c], reverse = True)

if a - c <= 1:
    print "YES"
else:
    print "NO"


Measured memory_bytes: 2692
import numpy as np
from collections import Counter


def solve(string):
    n, *a = map(int, string.split())
    table = np.array([True] * (10**6 + 1))
    for _a in a:
        if table[_a]:
            table[2*_a::_a]=False
    i = np.array([k for k,v in Counter(a).items() if v==1],dtype=np.int)
    return str(table[i].sum())


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 57568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B, C, D;
cin >> A >> B >> C >> D;
while(true){
C -= B;
if(C <= 0){
    cout << "Yes" <<endl;
    break;
}
A -= D;
if(A <= 0){
    cout << "No" <<endl;
    break;
}
}



} 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,i,j,c1,c2;
    cin>>n;
    vector<int>h;
    for(i=0;i<n;i++)
    {
        cin>>x;
        h.push_back(x);
    }
    vector<int>dp(n,0);
    dp[1]=abs(h[0]-h[1]);
    for(i=2;i<n;i++)
    {
        c1=dp[i-1]+abs(h[i]-h[i-1]);
        c2=dp[i-2]+abs(h[i]-h[i-2]);
        dp[i]=min(c1,c2);
    }
    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 1144
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    K = int(readline())
    a = 1
    for _ in range(N):
        a = min(a+K, a*2)
    print(a)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(0);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a; cin >> a;
    double b; cin >> b;
    cout << (a*(ll)((b+0.001)*100))/100 << endl;
}

Measured memory_bytes: 3736
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	p := make([]float64, n)
	var max float64
	var sum float64
	for i := 0; i < n; i++ {
		var num float64
		fmt.Scan(&num)
		p[i] = (float64(1) + num) / float64(2)
		if i < k - 1 {
			sum += p[i]
		} else if i == k - 1 {
			sum += p[i]
			max = sum
		} else if i > k - 1 {
			dif := -p[i-k] + p[i]
			sum += dif
			if max < sum {
				max = sum
			}
		}
	}
	fmt.Println(max)
}


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

using namespace std;
const int N=1e5+5;

int main()
{
    int n,a,b,x[N];
    cin >> n >> a >> b;
    for(int i=0;i<n;i++) cin >> x[i];
    double mi=1e9;
    int ans;
    for(int i=0;i<n;i++) if(fabs(-0.006*x[i]+a-b)<mi)
    {
        ans=i+1;
        mi=fabs(-0.006*x[i]+a-b);
    }
    cout << ans << endl;
}


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

int main() {

    int N;

    cin >> N;
    int v[N];

    rep(i, N){
        cin >> v[i];
    }

    int tmp = 0;

    rep(i, N) {
        rep(j, N) {
            if (v[i] < v[j]) {
                tmp =  v[i];
                v[i] = v[j];
                v[j] = tmp;
            }
        }
    }

    long double sub = v[0];

    rep(i, N-1) {
        sub = (sub + v[i+1])/2.0;
    }

    cout << fixed << setprecision(10) << sub << endl;

    // rep(i, N){
    //     cout << v[i] << endl;
    // }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  int n,p; cin >>n>>p;
  int kisuu=0;
  int guusuu=0;
  for(int i=0;i<n;i++){
    int x;
    cin>>x;
    if( x%2==1 )kisuu++;
    else guusuu++;
  }
  if(p==1&&kisuu==0){
    cout <<0<<endl;
    return 0;
  }
  long long kotae=0;
  if(p==0&&kisuu==0)kotae=pow(2,n);
  else kotae=pow(2,n-1);
  cout<<kotae<<endl;
  return 0;
}

Measured memory_bytes: 3888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int length = line.length();
		for (int i = 0; i < length; i++) {
			char ch = line.charAt(i);
			if (Character.isLowerCase(ch) == true) ch = Character.toUpperCase(ch);
			else ch = Character.toLowerCase(ch);
			System.out.print(ch);
		}
		System.out.println();
	}
}



Measured memory_bytes: 26920
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    //今から文字入力
    int a;
    int b;
    int c;
    cin>>a>>b>>c;
    if(a<b&&b<c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e9;

int main(){
    int N; cin>>N;
    vector<int> d(N+1);
    for(int i=1;i<=N;i++){
        int x; cin>>x;
        d.at(x)=i;
    }
    for(int i=1;i<=N;i++) cout<<d.at(i)<<' ';
    cout<<endl;

}



Measured memory_bytes: 1152
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		int id;
		Set<Integer> connNodes;

		Node(int id) {
			this.id = id;
			this.connNodes = new HashSet<>();
		}

	}

	static long MOD = 1000000007L;
	static int K;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		K = Integer.parseInt(tokens[1]);
		Node[] nodes = new Node[N];
		for (int i = 0; i < N; ++i) {
			nodes[i] = new Node(i);
		}
		for (int i = 0; i + 1 < N; ++i) {
			tokens = in.readLine().split(" ");
			int a = Integer.parseInt(tokens[0]) - 1;
			int b = Integer.parseInt(tokens[1]) - 1;
			nodes[a].connNodes.add(b);
			nodes[b].connNodes.add(a);
		}

		for (Integer i : nodes[0].connNodes) {
			nodes[i].connNodes.remove(0);
		}
		long result = count(nodes, 0, 1, K);
		System.out.println(result);
		in.close();
	}

	static long count(Node[] nodes, int index, int depth, long result) {
		if (depth >= 2) {
			for (int i = 0; i < nodes[index].connNodes.size(); ++i) {
				result *= (long) (K - 2 - i);
				result %= MOD;
			}
		} else {
			for (int i = 0; i < nodes[index].connNodes.size(); ++i) {
				result *= (long) (K - 1 - i);
				result %= MOD;
			}
		}
		for (Integer i : nodes[index].connNodes) {
			nodes[i].connNodes.remove(index);
		}
		for (Integer i : nodes[index].connNodes) {
			result = count(nodes, i, depth + 1, result);
		}
		return result;
	}

}

Measured memory_bytes: 103564
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			int C = in.nextInt();
			int total = 0;
			String ans = "NO";
			for(int i = 0; i <= A * B; i++) {
				total += A;
				if(total % B == C) {
					ans = "YES";
					break;
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 24916
def solve(i, m):
  if dp[i][m] != -1:
    return dp[i][m]
 
  if m == 0:
    dp[i][m] = 1
  elif i >= n:
    dp[i][m] = 0
  elif solve(i+1, m):
    dp[i][m] = 1
  elif solve(i+1, m-A[i]):
    dp[i][m] = 1
  else:
    dp[i][m] = 0
 
  return dp[i][m]
 
 
 
n = input()
A = map(int, raw_input().split())
p = input()
m = map(int, raw_input().split())
 
dp = [[-1 for col in range(2000)] for row in range(n+1)]
 
for i in range(p):
  if solve(0, m[i]):
    print 'yes'
  else:
    print 'no'

Measured memory_bytes: 6716
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
	ll n;
	ll ans = 0;
	cin >> n;

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

	ll num = n; // 素因数分解する変数num 

  bool sosu=true;
	for (ll i = 2; i*i<= n; i++) {
    ll cnt=0;
		while (num%i == 0) { // 素数で割り切れなくなるまで割っていく
			cnt++;//割った個数を配列に足す
			num /= i;
      sosu=false;
		}
    if(cnt==0) continue;
    repo(j,100){
        if(j*(j+1)/2<=cnt && cnt<(j+1)*(j+2)/2) {
        ans+=j;
        break;
      }
    }
	}

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

  if(num!=1) ans++;
	cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)                  //COMMON FOR LOOP (ITERATOR)
#define itr(x,n) for(int x=0;x<n;x++)                                   //COMMON FOR LOOP (VARIABLE)
#define itrab(x,a,b) for(int x=a;x<b;x++)                               //FOR LOOP WITH SPECIFIED START/END
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn                         //PRINTS VECTOR,SET,MAP OF INTS
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn    //PRINTS VECTOR,SET,MAP OF PAIRS
#define sz(x) (ll)((x).size())

#define pi   3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF  1000000000
#define INFF 1000000000000000000

typedef long long int ll;               //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;
typedef vector<vb> vvb;

const ll M=1000000007;                  //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){             //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){                     //FERMAT INVERSE
    return power(x,m-2,m);
}
ll nCr(ll n, ll r){                     //nCr MOD P  
    vl fac(10);
    if (r==0) 
        return 1;
    return (fac[n]*inv(fac[r],M)%M*inv(fac[n-r],M)%M)%M;
}
struct comp{                            //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff<b.ff);
    else
        return (a.ss>b.ss);
}
void sieve(){                           //SIEVE OF ERATOSTHENES
    vector<bool> pr(1000000+1,1);
    for(ll i=2;i*i<=1000000;i++)
        if(pr[i]==1)
            for(ll j=i*i;j<=1000000;j+=i)
                pr[j]=0;
}
bool isValid(ll i, ll j, vst &v, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=1&&i<=n&&j>=1&&j<=m&&v[i][j]!='#'){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    standardVar;
    ld d,t,s;
    cin>>d>>t>>s;
    if(d/s<=t){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
  int a ,b ;cin >>a >>b;//densya
  int c,d;cin>>c>>d;//bus
  int A = min(a,b);
  int B = min(c,d);
  cout<<A+B<<endl;
  
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <map>
#include<string>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int K,X;
  cin >> K >> X;

  if(K*500 >= X) cout << "Yes" << endl;
  else cout << "No" << endl;

 return 0;
}


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

int main() {
  int N;
  cin >> N;
  int tmp;
  int count =0 ;

  for(int i=1; i<N+1; i++){
    cin >> tmp;
    if(i%2 == 0)continue;
    if(tmp%2 !=0){
      count++;
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 3632
x, y ,z, k = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)

now = [0, 0, 0]
que = [[A[0] + B[0] + C[0], 0, 0, 0]]
memory = [[0, 0, 0]]
ans = []
while len(ans) < k:
  maxli = max(que, key = lambda x:x[0])
  ans.append(maxli[0])
  now = maxli[1:]
  que.remove(maxli)
  a = A[min(now[0] + 1, x - 1)]
  b = B[min(now[1] + 1, y - 1)]
  c = C[min(now[2] + 1, z - 1)]
  if [min(now[0] + 1, x - 1), now[1], now[2]] not in memory:
    que.append([a + B[now[1]] + C[now[2]], min(now[0] + 1, x - 1), now[1], now[2]])
    memory.append([min(now[0] + 1, x - 1), now[1], now[2]])
  if [now[0], min(now[1] + 1, y - 1), now[2]] not in memory:
    que.append([A[now[0]] + b + C[now[2]], now[0], min(now[1] + 1, y - 1), now[2]])
    memory.append([now[0], min(now[1] + 1, y - 1), now[2]])
  if [now[0], now[1], min(now[2] + 1, z - 1)] not in memory:
    que.append([A[now[0]] + B[now[1]] + c, now[0], now[1], min(now[2] + 1, z - 1)])
    memory.append([now[0], now[1], min(now[2] + 1, z - 1)])

print(*ans, sep = "\n")

Measured memory_bytes: 4852
#include<iostream> 
 #include<iomanip>
 #include<algorithm>
 #include<cmath>
 #include<string>
 #include<cstring>
 using namespace std;
 long long n,a,b,i,ans;
 int main()
{
	cin>>n;
	for(i=sqrt(n);i>=1;i--)
	{
        if(n%i==0)
        {
        	break;
		}
	} 
	b=n/i;
	while(b)
	{
		b=b/10;
		ans++;
	}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256