akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

class C
{
	static void Main()
	{
		var p3 = new[]
		{
			".aa",
			"a..",
			"a..",
		};
		var p4 = new[]
		{
			"aaef",
			"bbef",
			"ghcc",
			"ghdd",
		};

		var n = int.Parse(Console.ReadLine());
		if (n == 2) { Console.WriteLine(-1); return; }
		if (n == 3) { Console.WriteLine(string.Join("\n", p3)); return; }
		var c4 = n / 4 - 1;
		var n4 = n - 4 * c4;

		var r = new int[n].Select(_ => Enumerable.Repeat('.', n).ToArray()).ToArray();
		Copy(r, p4, 0, c4);
		Copy(r, n4 == 4 ? p4 : GetPattern(n4), 4 * c4, 1);
		Console.WriteLine(string.Join("\n", r.Select(x => new string(x))));
	}

	static void Copy(char[][] r, string[] p, int start, int count)
	{
		var pn = p.Length;
		for (int k = 0; k < pn * count; k += pn)
			for (int i = 0; i < pn; i++)
				for (int j = 0; j < pn; j++)
					r[start + k + i][start + k + j] = p[i][j];
	}

	static string[] GetPattern(int n)
	{
		var random = new Random();
		Func<P> next1 = () => new P { i = random.Next(n), j = random.Next(n - 1) };
		Func<P> next2 = () => new P { i = random.Next(n - 1), j = random.Next(n) };

		var qi = new Queue<P>();
		var qj = new Queue<P>();
		var u = new bool[n, n];
		var ui = new int[n];
		var uj = new int[n];
		for (int k = 0; k < n; k++)
		{
			while (true)
			{
				var p = next1();
				if (u[p.i, p.j] || u[p.i, p.j + 1]) continue;
				qi.Enqueue(p);
				u[p.i, p.j] = true;
				u[p.i, p.j + 1] = true;
				ui[p.i]++;
				uj[p.j]++; uj[p.j + 1]++;
				break;
			}
			while (true)
			{
				var p = next2();
				if (u[p.i, p.j] || u[p.i + 1, p.j]) continue;
				qj.Enqueue(p);
				u[p.i, p.j] = true;
				u[p.i + 1, p.j] = true;
				ui[p.i]++; ui[p.i + 1]++;
				uj[p.j]++;
				break;
			}
		}
		while (true)
		{
			if (ui.All(x => x == 3) && uj.All(x => x == 3))
				return ToPattern(n, qi.ToArray(), qj.ToArray());

			{
				var p = qi.Dequeue();
				u[p.i, p.j] = false;
				u[p.i, p.j + 1] = false;
				ui[p.i]--;
				uj[p.j]--; uj[p.j + 1]--;
			}
			while (true)
			{
				var p = next1();
				if (u[p.i, p.j] || u[p.i, p.j + 1]) continue;
				qi.Enqueue(p);
				u[p.i, p.j] = true;
				u[p.i, p.j + 1] = true;
				ui[p.i]++;
				uj[p.j]++; uj[p.j + 1]++;
				break;
			}

			if (ui.All(x => x == 3) && uj.All(x => x == 3))
				return ToPattern(n, qi.ToArray(), qj.ToArray());

			{
				var p = qj.Dequeue();
				u[p.i, p.j] = false;
				u[p.i + 1, p.j] = false;
				ui[p.i]--; ui[p.i + 1]--;
				uj[p.j]--;
			}
			while (true)
			{
				var p = next2();
				if (u[p.i, p.j] || u[p.i + 1, p.j]) continue;
				qj.Enqueue(p);
				u[p.i, p.j] = true;
				u[p.i + 1, p.j] = true;
				ui[p.i]++; ui[p.i + 1]++;
				uj[p.j]++;
				break;
			}
		}
	}

	static string[] ToPattern(int n, P[] pi, P[] pj)
	{
		var r = new int[n].Select(_ => Enumerable.Repeat('.', n).ToArray()).ToArray();
		for (int k = 0; k < n; k++)
		{
			r[pi[k].i][pi[k].j] = (char)('a' + k);
			r[pi[k].i][pi[k].j + 1] = (char)('a' + k);
			r[pj[k].i][pj[k].j] = (char)('n' + k);
			r[pj[k].i + 1][pj[k].j] = (char)('n' + k);
		}
		return r.Select(x => new string(x)).ToArray();
	}

	struct P
	{
		public int i, j;
	}
}


Measured memory_bytes: 28756
import sys
sys.setrecursionlimit(100000000)
n, runner, chaser = map(int, input().split())
runner -= 1
chaser -= 1
if runner == chaser:
    print(0)
    exit()

tree = [[] for _ in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

def dfs(dists, start, d=0, p=-1):  
    dists[start] = d
    for neighbor in tree[start]:
        if neighbor == p:
            continue
        dfs(dists, neighbor, d+1, start)

def dist(start):
    dists = [0 for _ in range(n)]
    dfs(dists, start)
    return dists

furthest = 0
run_dist = dist(runner)
chs_dist = dist(chaser)
for i in range(n):
    if run_dist[i] < chs_dist[i]:
        furthest = max(furthest, chs_dist[i])

ans = furthest-1

print(ans)

Measured memory_bytes: 117108
import bisect



def find_num(lst, num):
    insert_index = bisect.bisect_left(lst, num)
    return insert_index


n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        cnt += find_num(lst=l[j+1:], num=l[i] + l[j])
print(cnt)


Measured memory_bytes: 53372
#include<cstdio>
#include<map>


using namespace std;

int main()
{
    int i, flag, n, k, d, ans, anum, dg;
    map<int,int>mp;

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

    for(i = 0; i < k; i++){
        scanf("%d", &d);
        mp[d] = 1;
    }
    i = n;
    while(1)
    {
        anum = i;
        flag = 0;
        while(anum!=0){
            dg = anum % 10;
            anum = anum / 10;
            if(mp[dg]==1){
                flag = 1;
                break;
            }
        }
        if(flag != 1){
            ans = i;
            break;
        }
        i++;

    }
    printf("%d\n", ans);

    return 0;
}


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

LL a,b,c,d,d1,ans=0;

LL gcd(LL a, LL b)
{
	return (b == 0 ? a : gcd(b, a % b));
}

int main(){
	cin>>a>>b>>c>>d;
	
	ans=b-a+1;

	LL s1=0,s2=0,s3=0;
	
	s1=b/c-a/c;
	if(a%c==0) s1++;

	s2=b/d-a/d;
	if(a%d==0) s2++;
	
	d1=c*d/gcd(c,d);
	
	
	
//	cout <<"??" << endl;
//	
//	flag=1;
//	while(flag==1){
//		flag=0;
//		for(int i=2;i*i<=min(c,d);i++){
//			if(c%i==0&&d%i==0){
//				flag=1;
//				d1/=i;
//				c/=i;
//				d/=i;
//				break;
//			}
//		}
//	}
	
	s3=b/d1-a/d1;
	if(a%d1==0) s3++;
	
	//cout<<s1<<" "<<s2<<" "<<s3<<endl;
	cout<<ans-s1-s2+s3<<endl;
	return 0;
}

Measured memory_bytes: 256
let split_on_char sep s =
  let r = ref [] in
  let j = ref (String.length s) in
  for i = String.length s - 1 downto 0 do
    if String.unsafe_get s i = sep then begin
      r := String.sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  String.sub s 0 !j :: !r
;;

let digit_number s =
  let l   = split_on_char ' ' s in
  let a   = int_of_string(List.nth l 0) in
  let b   = int_of_string(List.nth l 1) in
  let sum = a + b in
  let len = String.length(string_of_int(sum)) in
  print_endline(string_of_int(len))
;;

let rec read_lines ic = 
  try let line = input_line ic in
    digit_number line;
    line :: read_lines ic
  with End_of_file -> [];;

let lines = 
  read_lines stdin
;;

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

const long long mod=1000000007LL;
long long comb[2005][2005]={};

long long my(int n, int r)
{
	if (n<r)
	{
		return 0LL;
	}
	if (comb[n][r]!=0)
	{
		return comb[n][r];
	}
	if (n==0||r==0||n==r)
	{
		comb[n][r]=1LL;
		return comb[n][r];
	}
	comb[n][r]=(my(n-1,r-1)+my(n-1,r))%mod;
	return comb[n][r];
}

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	for (int i = 1; i <= k; ++i)
	{
		cout<<my(n-k+1,i)*my(k-1,i-1)%mod<<endl;
	}
	return 0;
}


Measured memory_bytes: 30208
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  while(cin>>h>>w&&h&&w){
    for(int i=1;i<=h;++i){
      for(int j=1;j<=w;++j){
	if(i%2==j%2) cout<<"#";
	else cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#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.at(i);
  }
  sort(A.begin(),A.end());
  string ans="YES";
  for (int i=0;i<N-1;i++){
    if (A.at(i)==A.at(i+1)){
      ans="NO";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
use proconio::input;

fn solve(d: &usize, c: &Vec<usize>, s: &Vec<Vec<usize>>, t: &Vec<usize>) -> isize {
    let mut result: isize = 0;
    let mut contested: Vec<usize> = vec![0; 26];
    for i in 0..*d {
        result += s[i][t[i]] as isize;
        contested[t[i]] = i + 1;
        result -= contested.iter()
            .enumerate()
            .map(|pair| ((i + 1 - pair.1) * c[pair.0]) as isize)
            .sum::<isize>();
    }
    result
}

fn main() {
    input! {
        d: usize,
        c: [usize; 26],
        s: [[usize; 26]; d],
    }
    let mut t: Vec<usize> = (0..d).map(|_| rand::random::<usize>() % 26).collect();
    let mut result = solve(&d, &c, &s, &t);
    let limit: usize = 2000;
    for _ in 0..limit {
        let day = rand::random::<usize>() % d;
        let contest = rand::random::<usize>() % 26;
        let prev = t[day];
        t[day] = contest;
        let temp = solve(&d, &c, &s, &t);
        if temp < result {
            t[day] = prev;
        } else {
            result = temp;
        }
    }
    t.iter().for_each(|i| {
        println!("{}", i + 1);
    });
}

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


int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  if((a*100+b*10+c)%4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int len = s.length();
        String s2 = s+s;
        long k = in.nextLong();
        int cPerS = 0;
        boolean isAllSame = true;
        for(int i=1; i<len; i++) {
            if(s.charAt(i-1) != s.charAt(i)) {
                isAllSame = false;
                break;
            }
        }
        for(int i=1; i<len; i++) {
            if(s.charAt(i-1) == s.charAt(i)) {
                cPerS++;
                i++;
            }
        }
        int cPerS2 = 0;
        for(int i=1; i<len*2; i++) {
            if(s2.charAt(i-1) == s2.charAt(i)) {
                cPerS2++;
                i++;
            }
        }
        long result = (cPerS * k) + ((cPerS2 - cPerS - cPerS) * (k-1));
        if(isAllSame) {
            result = len * k / 2;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21712
<?php

$a=explode(' ',trim(fgets(STDIN)));
if($a[2]<$a[4]||$a[3]<$a[4]||$a[0]-$a[2]<$a[4]||$a[1]-$a[3]<$a[4]){
        echo "No".PHP_EOL;
}else{
        echo "Yes".PHP_EOL;
}



Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ld = long double;
int main(){ _;
  ld t,x;cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def search(field,hp,vp,item):
	if not (0<=hp<len(field)): return
	if not (0<=vp<len(field[hp])): return
	if item!=field[hp][vp]: return
	field[hp][vp]=True
	for dh,dv in [[0,1],[0,-1],[1,0],[-1,0]]:
		search(field,hp+dh,vp+dv,item)
#	search(field,hp-1,vp,item)
#	search(field,hp+1,vp,item)
#	search(field,hp,vp-1,item)
#	search(field,hp,vp+1,item)

def solve(field):
	count,valid_items=0,set(['@','#','*'])
	for i in range(len(field)):
		for j in range(len(field[i])):
			if field[i][j] in valid_items:
				search(field,i,j,field[i][j])
				count+=1
	return count

def main():
	line = input().strip()
	while line!='0 0':
		H,W = list(map(int,line.split(' ')))
		field = list()
		for _ in range(H):
			field.append(list(input().strip()))
		print(solve(field))
		line = input().strip()

if __name__=='__main__':
	main()

Measured memory_bytes: 21104
N = int(input())
A = list(map(int, input().split()))
mod = int(1e9) + 7
cA = [A[0]]
ans = 0
for i in range(1, N):
    cA.append(cA[-1] + A[i])
for i in range(N-1):
    ans += A[i] * ((cA[-1] - cA[i])%mod)
    ans %= mod
print(ans)

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

int main() {
    int n;
    cin >> n;
    bool s = false;
    for (int i = 1; i < 10; i++) {
        if (n % i == 0 && n / i < 10) s = true;
    }
    if (s) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


int main(){
  string str;
  cin >> str;
  int q;
  cin >> q;

  for (int i = 0; i < q; i++){
    string com, strpr, p;
    int a, b;
    cin >> com >> a >> b;
    if (com == "print") cout << str.substr(a, b-a+1) << endl;
    else if (com == "reverse") {
      string tmp = str.substr(a, b-a+1);
      int n = tmp.size();
      for (int i = 0; i < n; i++){str[i+a] = tmp[n-i-1];}
      }
    else if (com == "replace") {cin >> p; str = str.replace(a, b-a+1, p);}

}

return 0;
}

Measured memory_bytes: 3204
/**        بِسْمِ اللهِ الرَّحْمٰنِ الرَّحِيْمِ (In the name of God, the Most Gracious, the Most Merciful.)              */
/*
      Institution : Hajee Mohammad Danesh Science and Technology University,Dinajpur,Bangladesh.
      Name        : Ashikur Rahman Bhuyain (Asif)
      Email       : asifurr087@gmail.com
*/


#include <bits/stdc++.h>
using namespace std;
#define FasterIO    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define TIME        clock()*1.0/CLOCKS_PER_SEC
#define pi          acos(-1.0)
///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)
#define CEIL(a,b)   ((a/b)+((a%b)!=0))


#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())
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define nl                 printf("\n")

#define oh cout<<"Problem ta ki?  "<<endl;

///data type
#define ll long long int
#define SIZ 1000005

void solve()
{

   int x;
   cin>>x;
   int d=x/200;
   int r=10-d;
   cout<<r<<endl;
    return;
}

int main()
{
    int tc=1;
    //cin>>tc;
    for(int i=1; i<=tc; i++)
    {
        solve();
    }

    return 0;
}


 /*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/



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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll A,B;
ll ans;
ll i, j,k,l;

ll xo(ll a){
    switch(a%4){
        case 0:
            return a;
        case 1:
            return 1;
        case 2:
            return a + 1;
    }
    return 0;
}

int main(){
    scanf("%lld%lld", &A,&B);
    A = xo(A - 1);
    B = xo(B);
    printf("%lld", A ^ B);
    return 0;
}

Measured memory_bytes: 256
N=int(input())
array=input().split(" ")
sum=1
for j in range(N):
  if array[j]=="0":
    sum=0
if sum!=0:
  for i in range(N):
    sum=sum*int(array[i])
    if sum>1000000000000000000:
        sum=-1
        break
    else:
      continue
    break
print(sum)

Measured memory_bytes: 19440
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define F first
#define S second
 
#define ler freopen("inspection.in","r",stdin);freopen("inspection.out","w",stdout)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define rep(i,a,b) for(int i=a; i<b; i++)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define sz(a) ((int)(a).size())
#define debug cout<<"sakdasopk\n"
 
#define pdd pair<ld,ld> 
#define ll long long
#define ld long double
#define vi vector<int> 
#define pii pair<int,int>  
 
#define MAXN 3333
#define EPS 1e-8
#define INF 1e18L
#define LOG 19
#define int ll
	
int a, b, c, d, e, f;
int v1[MAXN], v2[MAXN];
int ansA=0, ansB=0;

void add(int x, int y){
	if(ansA==0) ansA=x, ansB=y;
	else if(x*ansB > ansA*y){
		ansA= x;
		ansB= y;
	}
}

 main(){
	cin >> a >> b >> c >> d >> e >> f;
	
	v1[0]= v2[0]= 1;
	for(int i=0; i<MAXN; i++){
		if(v1[i] && i+a*100 < MAXN)
			v1[i+a*100]=1;
		if(v1[i] && i+b*100 < MAXN)
			v1[i+b*100]=1;
			
		if(v2[i] && i+c < MAXN)
			v2[i+c]=1;
		if(v2[i] && i+d < MAXN)
			v2[i+d]=1;
	}

	for(int i=0; i<MAXN; i++){	
		if(!v2[i]) continue;
		for(int j=a*100; i+j<=f; j++){
			if(v1[j] && e*j >= i*100){
				add(i,j);
			}
		}
	}
	
	cout << ansB+ansA << " " << ansA << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int a[10005],x[105][105];
int h,w,n;
int main(){
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	int t=1;
	for (int i=1;i<=h;i++){
		if (i%2) {
			for (int j=1;j<=w;j++) {
				if (!a[t]) t++;
				x[i][j]=t,a[t]--;
			}
		}
		else for (int j=w;j>=1;j--) {
				if (!a[t]) t++;
				x[i][j]=t,a[t]--;
			}
	}
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++) printf("%d ",x[i][j]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
f = []
n.times do
  f.push gets.chomp.split.map(&:to_i)
end
q = []
n.times do
  q.push gets.chomp.split.map(&:to_i)
end

ans = -Float::INFINITY
d = 10
(2**d).times do |i|
  next if i == 0
  bits = i.to_s(2).split(//)
  (d - bits.length).times{bits.unshift('0')}

  profit = 0
  n.times do |j|
    count = 0
    10.times do |k|
      if f[j][k] == 1 && bits[k] == '1'
        count += 1
      end
    end
    # p count
    profit += q[j][count]
  end
  ans = profit if ans < profit
end

puts ans

Measured memory_bytes: 2556
using System;

public class Vector
{
    public double x { get; set; }
    public double y { get; set; }
}
public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var s = Array.ConvertAll(line.Trim().Split(','), double.Parse);
            var a = new Vector { x = s[0], y = s[1] };
            var b = new Vector { x = s[2], y = s[3] };
            var c = new Vector { x = s[4], y = s[5] };
            var d = new Vector { x = s[6], y = s[7] };
            var j = judgeTri(a, b, c, d) * judgeTri(a, b, d, c) * judgeTri(a, c, d, b) * judgeTri(b, c, d, a);
            if (j == 0) Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }
    }
    public static int judgeTri(Vector a, Vector b, Vector c, Vector p)
    {
        var ab = subVector(b, a);
        var bp = subVector(p, b);
        var bc = subVector(c, b);
        var cp = subVector(p, c);
        var ca = subVector(a, c);
        var ap = subVector(p, a);
        var c1 = ab.x * bp.y - ab.y * bp.x;
        var c2 = bc.x * cp.y - bc.y * cp.x;
        var c3 = ca.x * ap.y - ca.y * ap.x;
        if ((c1 > 0 && c2 > 0 && c3 > 0) || (c1 < 0 && c2 < 0 && c3 < 0)) return 0; // inside
        else return 1;  // outside
    }
    public static Vector subVector(Vector a, Vector b)
    {
        var c = new Vector();
        c.x = a.x - b.x;
        c.y = a.y - b.y;
        return c;
    }
}

Measured memory_bytes: 9128
n = input()
hs = map(int, raw_input().split())


dp = [0] * n
dp[n - 2] = abs(hs[n - 2] - hs[n - 1])
for i in range(n - 3, -1, -1):
    dp[i] = min(dp[i + 1] + abs(hs[i] - hs[i + 1]), dp[i + 2] + abs(hs[i] - hs[i + 2]))
print(dp[0])


Measured memory_bytes: 12060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	vector<int > dp(3);
	cin >> N;
	for(int day = 0; day<N; ++day){
		vector<int > c(3);
		vector<int > new_dp(3,0);
		for(int i = 0; i<3; i++){
			cin >> c[i];
		}
		// new_dp«Øªí 
		for(int i = 0; i<3; ++i){
			for(int j = 0; j<3; ++j){
				if(i != j)
					new_dp[i] = max(new_dp[i],c[i]+dp[j]);
			}
		}
		dp = new_dp;
	}
	cout << max({dp[0],dp[1],dp[2]});
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;
const int MOD = 1000000007;
const double pi = acos(-1);

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int K; cin >> K;
    K--;
    REP(i,N) if(S[i] == S[K]) cout << S[i] ;
    else cout << "*";
    cout << endl;
}

Measured memory_bytes: 3580
calc :: Int -> (Int, Int, Int)
calc n = (h, m, s)
  where
    h = (n `div` 60) `div` 60
    m = (n `div` 60) `mod` 60
    s = n `mod` 60


main = do
  t <- getLine
  let (h, m, s) = calc $ read t
  putStrLn $ show h ++ ":" ++ show m ++ ":" ++ show s

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

int main(void){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  
  for(int i=0;i<n;i++){
    if(i==k-1)s[i]+=32;
    
    cout<<s[i];
  }
  return 0;
  
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int factorial(int a) {
    int ans = 1;
    for (int i = 1; i <= a; ++i) 
        ans *= i;
    return ans;
}

int main() {
    ll x,k,d;
    scanf("%lld %lld %lld", &x, &k, &d);
    x = abs(x);
    ll tmp = x / d;
    if (tmp <= k) {
        x -= d * tmp;
        k -= tmp;
    } else {
        x -= d * k;
        k = 0;
    }
    d *= k % 2;
    x = abs(x - d) < abs(x + d) ? abs(x - d) : abs(x + d);
    printll(x);
    return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	string str; cin >> str;
	char c_min = 'z';
	for( char c : str ) c_min = min( c, c_min );
	k = min(k, 14);
	string tmp = "";
	while( k-- ){
		tmp += str;
		reverse( str.begin(), str.end() );
		tmp += str;
		if( k > 0 ) reverse( tmp.begin(), tmp.end() );
		vector<string> candy;
		for( int i = 0; i <= n; ++i ) candy.push_back( tmp.substr(i, n) );
		sort( candy.begin(), candy.end() );
		str = candy.front();
		if( k > 0 ) reverse( str.begin(), str.end() );
		tmp = "";
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 40308
def check_size arr
  ans=0
  while a=arr.shift
    case a
    when /[A-Z]+/
      ans+=a.size
    when /\d+/
      t=arr.shift
      ans+=a.to_i*(t==?(?check_size(arr):t.size)
    when ?)
      break
    end
  end
  ans
end

def get_ch arr,n
  #p [arr,n]
  while a=arr.shift
    case a
    when /[A-Z]+/
      l=a.size
      if n<l
        return a[n]
      end
      n-=l
    when /\d+/
      if arr[0]==?(
        arr.shift
        tarr=arr.dup
        l=check_size(tarr)
        #p [l,arr,tarr,n]
        if n<l*a.to_i
          n%=l
          return get_ch(arr,n)
        end
        arr=tarr
        n-=l*a.to_i
      else
        b=arr.shift
        l=b.size
        if n<l*a.to_i
          return b[n%l]
        end
        n-=l*a.to_i
      end
    end
  end
  #p [arr,n,"error"]
  #n
end

while gets
  a,b=$_.split
  break if a==?0
  cnt=b.to_i
  arr = a.scan(/[A-Z]+|\(|\)|\d+/)
#  p check_size arr
  puts get_ch(arr,cnt)||0
end

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

const static int NMAX = 100;
const static int WMAX = 10000;
static const int INF = (1 << 29);

struct item {
	int value, weight;
};

int main() {
	int bag[NMAX + 1][WMAX + 1];
	item items[NMAX + 1];
	int N, W;
	cin >> N >> W;
	items[0].value = items[0].weight = 0;
	for (int i = 1; i <= N; i++) {
		cin >> items[i].value >> items[i].weight;
	}
	fill(bag[0], bag[0] + WMAX + 1, 0);
	for (int i = 0; i <= N; i++) bag[i][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			if (j - items[i].weight >= 0) {
				bag[i][j] = max(bag[i-1][j - items[i].weight] + items[i].value, bag[i - 1][j]);
			}
			else {
				bag[i][j] = bag[i - 1][j];
			}
		}
	}
	cout << bag[N][W] << endl;
}

Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int main()
{
	long long n,m,z=0;
	cin>>n>>m;
	for(int i=m;i<=n+1;i++)
	{
		z+=i*(n-i+1)+1;
		z=z%mod;
		//long long q=i*n-i*(i-1)+1;
		//cout<<q<<endl;
	}
	cout<<z;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}


int main(){
  int n;
  cin>>n;
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

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

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

	N := nextInt()
	sum := 0
	for i := 0; i < N; i++ {
		a, b := nextInt(), nextInt()
		sum += b - a + 1
	}

	fmt.Println(sum)
}


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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    int ans = 0;
    if (A % 2 == B % 2 && B % 2 != C % 2)
    {
        A++;
        B++;
        ans++;
    }
    if (B % 2 == C % 2 && C % 2 != A % 2)
    {
        B++;
        C++;
        ans++;
    }
    if (C % 2 == A % 2 && A % 2 != B % 2)
    {
        C++;
        A++;
        ans++;
    }
    int x[3] = {A, B, C};
    sort(x, x + 3);
    ans += (2 * x[2] - x[0] - x[1]) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

void solve(){
    string s,t;
    int n,m,i,j,k,l,p;
    cin >> s >> t;
    n = s.length();
    m = t.length();

    vector< vector<int> > dp(n + 1, vector<int>(m + 1, 0));
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = 1 + dp[i][j];
            } else {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
            // cout << dp[i + 1][j + 1] << " ";
        }
        // cout << endc;
    }

    string ans = "";
    while(n && m){
        if(s[n - 1] == t[m - 1]){
            ans += s[n - 1];
            n--;
            m--;
        } else if(dp[n - 1][m] > dp[n][m - 1])n--;
        else m--;
    }

    reverse(all(ans));
    cout << ans << endc;
}

int32_t main(){
    init;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 38456
#include<stdio.h>
#include<string.h>

int main(void)
{
	char w[101];
	char check[101];
	int i,j,count=1;
	int flag=0;
	
	for(i=0; i <= 100; i++) w[i] = '\0';
	scanf("%s",w);
	
	
	for(i=0; i < 100; i++){
		if(w[i] == 'Z') flag = 1;
		for(j=i+1; j < 100; j++){ 
			if(w[i] == w[j]){
					if(flag == 1){
						 break;
					}
					count++;
					w[j] = 'Z';
			}
			
			if( (count % 2) == 0){
				check[i] = 'O';	
			}else if((count % 2 != 0) && flag != 1){
				check[i] = 'N';
			}else{
			}
			
		}
		
		
		flag = 0;
		count = 1;
	}
	
	flag = 0;
	for(i=0; i < 100; i++){
		if(check[i] == 'N') flag = 1;
	}
	
	if(flag == 0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 256
program main
  implicit none
  
  integer :: i,n,j,c,cc=0
  
  read(*,*)n
  
  do i = 1, n, 2
    c = 0
    do j = 1, n
      if (mod(i,j) == 0) then
        c = c + 1
      end if
    end do
    if (c == 8) then
      cc = cc + 1
    end if
  end do
  write(*,*)cc
end program main
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unordered_map<long long,long long>m;
#define MOD 1000000007
vector<long long>v[200005],v1;
char a[10000],b[10000],c[10000];
    long long i,n,x,k,y,count=0,pos;
bool fun(long long k)
{
    long long i,j=0;
    for(i=k;i<n;i++)
    {
        if(a[i]!=b[j])
            return false;
        j++;
    }
    return true;
}
int main()
{
   
    cin>>n;
    cin>>a>>b;
    pos=n;
    for(i=0;i<n;i++)
    {
        
            if(fun(i))
            {
                //cout<<pos<<" :"<<endl;
                pos=i;
                break;
            }
        
    }
    //cout<<pos<<endl;
    cout<<n+pos;
      
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,m;
    cin >> n >> m;
    priority_queue <int> q;
    ll answer = 0;
    REP(i,n){
        int a;
        cin >> a;
        q.push(a);
    }
    REP(i,m){
        int a;
        a = q.top();
        q.pop();
        q.push(a/2);
    }
    
    REP(i,n){
        answer += q.top();
        q.pop();
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
  ll N;
  cin>>N;
  ll Ans=0;
  for(ll i=1; i<=N; i++){
    ll C=N/i;
    Ans+=i*C*(C+1)/2;
  }
  cout<<Ans<<endl;
}
     

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			int n = scanner.nextInt();
			int count = 0;
			int pow = 1;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				if (a % 2 == 1) {
					count = count + pow * 2;
				} else {
					count = 2 * count + pow;
				}
				pow = pow * 3;
			}
			System.out.println(count);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
  int N;
  int X;
  std::vector<int> m;
  int total = 0;
  int count = 0;

  std::cin >> N >> X;

  for (int i = 0; i < N; i++) {
    int tmp = 0;
    std::cin >> tmp;
    m.push_back(tmp);
  }

  std::sort(m.begin(), m.end(), std::less<int>());
  for (int i = 0; i < m.size(); i++) {
    X -= m[i];
    count++;
  }
  if (X < 0) {
    return -1;
  }

  while (X > 0) {
    X -= m[0];
    if (X < 0) {
      break;
    }
    count++;
  }

  std::cout << count << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll a,b,c,d;
    cin >> a>>b>>c>>d;
    ll A=a*c;
    ll B=a*d;
    ll C=b*c;
    ll D=b*d;
    if(A>=B&&A>=C&&A>=D){
        cout<<A<<endl;
    }else if(B>=A&&B>=C&&B>=D){
        cout<<B<<endl;
    }else if(C>=A&&C>=B&&C>=D){
        cout<<C<<endl;
    }else{
        cout<<D<<endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

struct fenwick_tree {
    typedef int T;
    T n;
    vector<T> bit;

    // 各要素の初期値は 0
    fenwick_tree(T num) : bit(num+1, 0) { n = num; }

    // a_i += w
    void add(T i, T w) {
        for (T x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }
    // [1, i] の和を計算.
    T sum(T i) {
        T ret = 0;
        for (T x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
    // [left+1, right] の和を計算.
    T sum(T left, T right) {
        return sum(right) - sum(left);
    }
};

int main(){
    ll N, K; cin >> N >> K;
    vll a(N);
    rep(i, 0, N){
        cin >> a[i];
    }
    vll b(N);
    rep(i, 0, N){
        b[i] = a[i] - K;
    }   
    ll s = 0;
    vll asum(N+1);
    asum[0] = 0;
    ll mn = 0;
    rep(i, 1, N+1){
        s += b[i-1];
        asum[i] = s;
        mn = min(s, mn);
    }
    if(mn < 1){
        rep(i, 0, N+1){
            asum[i] += abs(mn)+1;
        }
    }
    Map m;
    vll v = asum;
    sort(v.begin(),v.end());
    ll t = 0;
    rep(i, 0, N+1){
        if(m.find(v[i]) == m.end()){
            m[v[i]] = t+1;
            t++;
        }else{
            continue;
        }
    }
    rep(i, 0, N+1){
        asum[i] = m[asum[i]];
    }
    fenwick_tree ftree(1000001);
    ll ans = 0;
    rrep(i, N, -1){
        ans += ftree.sum(asum[i]-1, 1000001);
        ftree.add(asum[i], 1);
    }
    prt(ans);
}

Measured memory_bytes: 22912
#include <stdio.h>

int main(){
  int a,b,i,n,k;
  while(scanf("%d",&n),n!=0){
    for(a=b=i=0;i<n;i++){
      scanf("%d",&k);
      if(k>1){ a++;}
       else b+=k; 
    }
    if(a==0) printf("NA\n");
     else printf("%d\n",a+b+1);
  }
  return 0;
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      long long A, B, C, D; cin >> A >> B >> C >> D; 
      long long E = (C*D)/__gcd(C, D); 
      long long fi = (A+C-1)/C;
      long long se = (B/C);
      long long res = B-A+1 - (se - fi + 1);
      fi = (A+D-1)/D;
      se = (B/D);
      res -= (se - fi + 1);
      fi = (A+E-1)/E;
      se = (B/E);
      res += (se - fi + 1);
      cout << res << "\n";
      return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  bool x=false;
  for(int i=0;i<2;i++){
  if(s.at(i)==s.at(i+1)&&s.at(i+1)==s.at(i+2))
  x=true;
  }
  if(x==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

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

int h,w,k,sum;
int ans[70][40];
char s[10][10];

int main()
{
	int x;
	scanf("%d%d%d",&h,&w,&k);
	for(int i=1;i<=h;i++) scanf("%s",s[i]+1);
	for(int tt=0;tt<(1<<w)-1;tt++)
	{
		ans[tt][0]=1;
		for(int i=1;i<=h;i++)
		{
			x=0;
			for(int j=1;j<=w;j++) if((tt&(1<<(j-1)))==0&&s[i][j]=='#') x++; 
			for(int j=k-x;j>=0;j--) ans[tt][j+x]+=ans[tt][j];
		}
		sum+=ans[tt][k];
	}
	printf("%d\n",sum);
	return 0;
}

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

int main () {
    int x;
    cin >> x;
    cout << (2 * x) * 3.14159265359 << endl;  
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000018
#define mod 1000000007
#define MAXN 100005

int n, a, b, h[MAXN], hp;

bool C(int mid)
{
    int ans = 0;
    //printf("mid  :  %lld\n", mid);
    for(int i = 0; i < n; i++){
        if(h[i] > b * mid){
            ans += ((h[i] - b * mid) + (a - b) - 1) / (a - b);
            //printf("ans : %lld\n", ans);
        }
    }
    return (ans <= mid);

}

void binary_serch(int lb, int ub)
{
    int mid;
    while(ub - lb > 1){
        mid = (ub + lb) / 2;
        if(C(mid)){
            ub = mid;
        }
        else{
            lb = mid;
        }
    }
    cout << ub << endl;

}

signed main()
{
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        hp = max(hp, h[i]);
    }
    //printf("n:%lld a:%lld b:%lld hp:%lld", n, a, b, hp);
    binary_serch(0, (hp + b - 1) / b);


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<queue<int>> a(n);
    int ans = 0, rem = 0;
    map<pair<int, int>, int> m, t;
    rep(i, n) {
        rep(ii, n - 1) {
            int tmp;
            cin >> tmp;
            tmp--;
            if (ii == 0) {
                pair<int, int> pt = make_pair(min(i, tmp), max(i, tmp));
                m[pt]++; t[pt]++;
            }
            else {
                a[i].push(tmp);
            }
        }
    }
    while(true) {
        map<int, bool> upd;
        for (auto x : t) {
            if (m[x.first] < 2) continue;
            upd[x.first.first] = true;
            upd[x.first.second] = true;
            m.erase(x.first);
        }
        t.clear();
        for (auto x : upd) {
            if (sz(a[x.first]) > 0) {
                int tmp = a[x.first].front();
                a[x.first].pop();
                pair<int, int> pt = make_pair(min(x.first, tmp), max(x.first, tmp));
                m[pt]++; t[pt]++;
            }
        }
        if (!sz(upd)) break;
        ans++;
    }
    rep(i, n) rem += sz(a[i]);
    if ((sz(m)) || (rem)) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////



int main() {
	
	ll K, A, B;
	cin >> K >> A >> B;

	if (B <= A || K <= A) {
		cout << 1 + K;
	}

	else {
		ll ex = (K - A + 1) / 2;
		ll bout = K - 2 * ex;

		cout << max(1 + K, 1 + bout + ex * (B - A));
	}

	system("PAUSE");
}


Measured memory_bytes: 504
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int pow2[10000]={1};
int main(){
    int N,K;
    cin>>N>>K;
    int now=0;
    while(pow2[now]<K){
        pow2[now+1]=pow2[now]*2;
        now++;
    }
    double ans=1.0/pow2[now];
    int checkN=2;
    while(checkN<=N){
        if(pow2[now]*checkN<K){
            now++;
            ans+=1.0/pow2[now];
            checkN++;
        }else{
            now--;
        }
    }
    cout<<setprecision(11) <<(double)ans/N;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,n;
  char c;
  int a=0;
  int score=0;
  int runner[3];
  int ining=0;
  int out=0;
  int event=1;
  char s[10];
  scanf("%d",&n);

  for(i=0; i < 3; i++) runner[i] = 0;
  for(;event<=n;){
    scanf("%s", s);

    if(s[1]=='I'/*HIT*/){ 
      if(runner[2]==1){
	score++;
	runner[2]--;
      }if(runner[1]==1){
	runner[2]++;
	runner[1]--;
      }
      if(runner[0]==1)
	{
	  runner[0]--;
	  runner[1]++;
	}
      runner[0]++;    
    }
    else if(s[1]=='O'/*HOMERUN*/){ 
      if(runner[2]==1){runner[2]--;score++;}	
      if(runner[1]){runner[1]--;score++;}
      if(runner[0]){runner[0]--;score++;}
      score++;
    }
    else if(s[1]=='U'/*OUT*/){
      out++;
      if(out==3){
	ining++;
	event++;
	out=0;
	runner[2]=0;runner[1]=0;runner[0]=0;
	printf("%d\n",score);
	score = 0;
      }
    }
  }
  return 0;
}

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

typedef long long ll;

main()
{
    int n;
    cin >> n;
    if(n <= 111){
        cout << 111;
    }
    else if(n <= 222){
        cout << 222;
    }
    else if(n <= 333){
        cout << 333;
    }
    else if(n <= 444){
        cout << 444;
    }
    else if(n <= 555){
        cout << 555;
    }
    else if(n <= 666){
        cout << 666;
    }
    else if(n <= 777){
        cout << 777;
    }
    else if(n <= 888){
        cout << 888;
    }
    else{
        cout << 999;
    }


}





///promy_pompom
//hello world


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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  for (int i = min(A, B); i > 0; i--) {
    if (A % i == 0 && B % i == 0) {
      K--;
      if (K == 0) {
        cout << i << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define light ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define REP(i,a,b) for(ll i = a; i < b; i++)
#define REPE(i,a,b) for(ll i = a; i <= b; i++)
#define REPR(i,a,b) for(ll i = a; i >= b; i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define bins(v, x) binary_search(v.begin(), v.end(), x)
const double pi = 2*acos(0.0);
const int INF = 1e9+1;
const int MOD = 1e9+7;
const int MOD1 = 998244353;

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define oset tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define osetll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
 
ll modExp(ll base, ll exp, ll mod) {
   ll res = 1;
   while (exp > 0) {
    	if (exp % 2 == 1) {
        	res= (res * base) % mod;
		}
      exp = exp >> 1;
      base = (base * base) % mod;
   }
   return res;
}

ll inverse(ll base, ll exp, ll mod) {
   return modExp(base, exp - 2, mod);
}

bool compare(const pair<int,int> &i, const pair<int,int> &j) {
   return (i.S > j.S || (i.S == j.S && i.F > j.F));
}

void test() {
   string s;
   cin >> s;
   int cnt = 0, ans = 0;
   for(int i = 0; i < s.size(); i++) {
      if(s[i] == 'R') {
         cnt++;
         ans = max(ans, cnt);
      } else {
         cnt = 0;
      }
   }
   cout << ans;
}

int main() {
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
   light;
   cout.precision(15);
   cout << fixed;

   int t = 1;
   //cin >> t;
   for(int i = 1; i <= t; i++) {
      //cout << "Case #" << i << ": ";
      test();
   }
   return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,x,y;
	long long ans=0;
	ios::sync_with_stdio(false);
	cin>>n>>k>>x>>y;
	for(int i=1;i<=n;++i){
		if(i<=k){
			ans+=x;
		}
		if(i>k){
			ans+=y;
		}
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256