akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;cin>>n>>k;
	if(n >=k){
		n%=k;
	}
	if(n > k/2){
		n = abs(n - k);
	}
	cout<<n<<endl;
	return 0;
}



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

bool Check(const std::vector<int>::const_iterator It, int m)
{
    if(m == 0) return true;
    if(m <  0) return false;
    if(*It == -1) return false;
    return
        Check(It+1, m - *It) ||
        Check(It+1, m);
}

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<int> A(n+1);
    for(int i = 0; i < n; ++i){
        std::cin >> A[i];
    }
    A[n] = -1;
    
    int q;
    std::cin >> q;
    for(int i = 0; i < q; ++i){
        int m;
        std::cin >> m;
        std::cout << (Check(A.begin(), m) ? "yes" : "no") << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



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

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<vector<ll>>ed(2*n);
  ll mid=n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    ed[a].push_back(mid);
    ed[mid].push_back(b);
    ed[b].push_back(mid);
    ed[mid].push_back(a);
    mid++;


  }
  ll m;cin>>m;
  vector<ll>u(m),v(m);
  rep(i,m){
    cin>>u[i]>>v[i];
    u[i]--;v[i]--;
  }
  vector<bitset<50>>b(m);
  int f=0;
  function<void(int,int,int,int)>dfs=[&](int no,int pr,int g,int num){
    if(f)return;
    if(no>=n)b[num][no-n]=1;


    for(auto nn:ed[no]){
      if(nn==pr)continue;
      if(nn==g){f=1;return ;}
      dfs(nn,no,g,num);
    }
    if(!f&&no>=n)b[num][no-n]=0;

  };
  rep(i,m){
    f=0;
    dfs(u[i],-1,v[i],i);
    b[i].flip();
  }

  ll res=0;
  rep(i,1<<m){
    bitset<20>bit=i;
    bitset<50>f=0;
    f.flip();
    rep(j,m){
      if(bit[j])f&=b[j];
    }
    ll cnt=0;
    rep(j,n-1){
      cnt+=f[j];
    }
    ll cnt2=0;
    rep(j,m)cnt2+=bit[j];

    if(cnt2%2==0)res+=1ll<<cnt;
    else res-=1ll<<cnt;
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  int count=0;
  vector<int> sizes(N);
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    int flag=0;
    for(int j=0;j<count;j++){
      if(sizes.at(j)==tmp){
        flag=1;
        break;
      }
    }
    if(!flag){
      sizes.at(count)=tmp;
      count++;
    }
  }
  cout << count << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

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

    int ans = 100100;
    for (int i = 2; i < S.size(); i++) {
        int a = S[i - 2] - '0';
        int b = S[i - 1] - '0';
        int c = S[i] - '0';
        chmin(ans, abs(753 - (a * 100 + b * 10 + c)));
    }

    cout << ans << endl;
}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    cout << n * n * n << endl;
    return 0;
}


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

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

const int Nmax=114514;
int val[Nmax];
vi g[Nmax];
bool vis[Nmax];
int dfs(int v){
	if(vis[v])return 0;
	vis[v]=true;
	int res=val[v];
	for(auto to:g[v])
		res+=dfs(to);
	return res;
}

void No(){
	cout<<"NO"<<endl;
	exit(0);
}
void Yes(){
	cout<<"YES"<<endl;
	exit(0);
}

signed main(){
	string s=readString();
	int n=s.size();
	REP(i,n/2)
		val[i]=s[i]-s[n-1-i];
	for(int i=n/2;i>=1;i--)
		val[i]=val[i]-val[i-1];
	int q=read();
	REP(i,q){
		int l=read()-1,r=read();
		l=min(l,n-l);
		r=min(r,n-r);
		if(l>r)swap(l,r);
		g[l].PB(r);
		g[r].PB(l);
	}
	REP(i,n/2+1)if(!vis[i])
		if(dfs(i)%26)
			No();
	Yes();
}

Measured memory_bytes: 10496
#include<stdio.h>
#define N 100
int main(){
  int ans[N][N];
  int i,j,n;
  int u,k,v;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      ans[i][j] = 0;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d", &v);
      v--;
      ans[u][v] = 1;
    }
  }

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


  return 0;
}



Measured memory_bytes: 2108
import java.io.BufferedReader

fun main() = aising2019c()

@OptIn(ExperimentalStdlibApi::class)
fun aising2019c() = SimpleIO_aising2019c().exec {
    data class Coordinate(val y: Int, val x: Int)

    val (h, w) = readLine().split(" ").map { it.toInt() }
    val board = Array(h) { readLine().map { it == '#' }.toBooleanArray() }

    val around = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
    val visited = mutableSetOf<Coordinate>()
    var answer = 0L

    for (i in 0 until h) for (j in 0 until w) {
        val curr = Coordinate(i, j)
        if (!board[i][j] || !visited.add(curr)) continue

        var blackCount = 0L
        var whiteCount = 0L

        val queue = ArrayDeque(listOf(curr))

        while (queue.isNotEmpty()) {
            val poll = queue.removeFirst()
            val (y, x) = poll
            if (board[y][x]) blackCount++ else whiteCount++
            queue += around.map { Coordinate(y - it.first, x - it.second) }
                .filter {
                    it.y in 0 until h && it.x in 0 until w &&
                            board[it.y][it.x] != board[y][x] && visited.add(it)
                }
        }

        answer += blackCount * whiteCount
    }

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleIO_aising2019c(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private val sb: StringBuilder = StringBuilder()
    fun readLine(): String = br.readLine()!!
    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = print(any.toString() + separator)
    fun exec(action: SimpleIO_aising2019c.() -> Unit) = run {
        Thread(null, { action() }, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()
    }.run { kotlin.io.print(sb) }
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 86264
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int getK(int a,int b){
	if(a<b) swap(a,b);
	return (a-1)/(b+1)+1;
}
int a,b,l,r;
int K,N;
bool can(int x){
	int useb = x/(K+1);
	int usea = x - useb;
	if(usea>a || useb>b) return 0;
	int lefta = a - usea, leftb = b - useb;
	bool blast = x%(K+1)==0;
	// show(lefta);
	// show(leftb);
	// show(blast);
	if((lefta+1)*K<leftb+blast) return 0;
	return 1;
}
string le(int x,int l,int r){
	string s;
	for(int i=l;i<r;i++){
		if(i<x) s+= (i%(K+1)==K)?'B':'A';
	}
	return s;
}
string ri(int x,int l,int r){
	int useb = x/(K+1);
	int usea = x - useb;
	int lefta = a - usea, leftb = b - useb;
	int X = K;
	int relax = X*(lefta+1) - leftb;
	int fst = X-relax;
	string s;
	for(int i=l;i<r;i++){
		if(x<=i){
			char c='?';
			int y = i-x;
			if(y<fst){
				c = 'B';
			}else if(y==fst){
				c = 'A';
			}else{
				y -= fst+1;
				c = (y%(K+1)==K) ? 'A' : 'B';
			}
			s += c;
		}
	}
	return s;
	
}
signed main(){
	int Q;
	cin>>Q;
	rep(qt,Q){
		cin>>a>>b>>l>>r;
//		cin>>a>>b;
//		l = 1,r=a+b;
		l--;
		K = getK(a,b);
		N = a+b;
		int lb = 0, ub = N+1;
		while(ub-lb>1){
			int m = (ub+lb)/2;
			if(can(m)) lb = m;
			else ub = m;
		}
		int x = lb;

//		show(x);
		string ans = le(x,l,r) + ri(x,l,r);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var q = int.Parse(Console.ReadLine());
            var rightBuilder = new StringBuilder(s);
            var leftBuilder = new StringBuilder();
            var isReverse = false;
            Func<string, string> reverse = str =>
            {
                var builder = new StringBuilder(str.Length);
                for (var i = str.Length - 1; i >= 0; i--)
                {
                    builder.Append(str[i]);
                }
                return builder.ToString();
            };

            for (var i = 0; i < q; i++)
            {
                var query = Console.ReadLine().Trim().Split(' ');
                if (query[0] == "2")
                {
                    if (query[1] == "1")
                    {
                        if (isReverse) rightBuilder.Append(query[2]);
                        else leftBuilder.Append(query[2]);

                    }
                    else if (query[1] == "2")
                    {
                        if (isReverse) leftBuilder.Append(query[2]);
                        else rightBuilder.Append(query[2]);
                    }
                }
                else
                {
                    isReverse = !isReverse;
                }
            }
            var right = rightBuilder.ToString();
            var left = leftBuilder.ToString();
            var result = isReverse ? reverse(right) + left : reverse(left) + right;
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18740
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

bool is_prime(const int x) {
    assert(2 <= x);
    for (int i = 2; i < x; i++) {
        if (x % i == 0) { return false; }
    }
    return true;
}


long long N, M;

int main(int argc, char **argv) {
    std::cin >> N >> M;

    if (N == 1) {
        std::cout << M << std::endl;
        return 0;
    }

    long long ret = 1;

    for (long long i = 1; i <= M; i++) {
        if (i*i > M) { break; }
        if (M % i == 0) { 
            long long shou = M / i;
            if (shou >= N) {
                ret = std::max(ret, i);
            }
            if (i >= N) {
                ret = std::max(ret, shou);
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        int ansA = 0;
        int ansB = 0;

            outside: for(int a = -118;a <= 119;a++){
                for(int b = -119;b <= 118;b++){
                    if(Math.pow(a,5) - Math.pow(b,5) == x){
                        ansA = a;
                        ansB = b;
                        break outside;
                    }
                }
        }
        System.out.println(ansA + " " + ansB);
    }
}


Measured memory_bytes: 38872
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import java.util.TreeMap;

public class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		System.out.println(3 * n * n);
	}
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	string s, t;
	cin >> s >> t;
	int res = 0;
	rep (i, 3) res += (s[i] == t[i]);
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
 
int main(void) {
    char str[1001], tmp[1001], in[10];
    int q, a, b;
    int i;
     
    scanf("%s", str);
    scanf("%d", &q);
     
    while (q--) {
        scanf("%s %d %d", in, &a, &b);
        if (strcmp(in, "print") == 0) {
            for (i = a; i <= b; i++) putchar(str[i]);
            puts("");
        }
        else if (strcmp(in, "replace") == 0) {
            scanf("%s", tmp);
            strncpy(&str[a], tmp, b - a + 1);
        }
        else {      
            strcpy(tmp, str);
            for (i = 0; i <= b - a; i++) tmp[a + i] = str[b - i];
            strcpy(str, tmp);
        }
    }
     
    return 0;
}


Measured memory_bytes: 2112
function Main(input) {
	input = input.split("");
	var s1 = parseInt(input[0], 10);
	var s2 = parseInt(input[1], 10);
	var s3 = parseInt(input[2], 10);

    console.log(s1 + s2 + s3);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

inline int f(char c){
    return c == 'm'? 1000: c == 'c'? 100: c == 'x'? 10: 1;
}

int encode(string& s){
    int res = 0;
    string t = "";
    for(char c: s){
        if(isdigit(c))t += c;
        else res += (t.empty()? 1: stoi(t)) * f(c), t = "";
    }
    return res;
}

string decode(int n){
    string res = "";
    for(char c: "mcxi"){
        int a = n / f(c);
        res += a == 0? "": (a == 1? "": to_string(a)) + c;
        n %= f(c);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    while(n--){
        string s, t;
        cin >> s >> t;
        cout << decode(encode(s) + encode(t)) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1224
import sys


if __name__ == '__main__':
    N, L = map(int, input().split())

    eat_apple = 0
    min_abs_apple_taste = sys.maxsize
    apples = []
    for i in range(N):
        taste = L+(i+1)-1
        apples.append(taste)
        if min_abs_apple_taste > abs(taste):
            min_abs_apple_taste = abs(taste)
            eat_apple = taste

    answer = 0
    for apple in apples:
        if apple != eat_apple:
            answer += apple
    print(answer)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))

# rstrip().decode('utf-8')

#import numpy as np
import heapq

def main():
	h,w=MI()
	
	G=[]
	for _ in range(10):
		c=LI()
		G.append(c)
	#print(G)
	
	for k in range(10):
		for i in range(10):
			for j in range(10):
				G[i][j]=min(G[i][j],G[i][k]+G[k][j])
	
	ans=0
	for _ in range(h):
		row=LI()
		for val in row:
			if abs(val)!=1:
				ans+=G[val][1]
	print(ans)
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
n = int(input())
a, b = map(int, input().split())
P = list(map(int, input().split()))

B = [0, 0, 0]

for i in P:
    if i <= a:
        B[0] += 1
    elif i <= b:
        B[1] += 1
    else:
        B[2] += 1
print(min(B))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){
    double a,b=acos(-1);
    cin>>a;
    cout<<fixed<<setprecision(12)<<a*2*b;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=arr[i];
    }
    cout<<sum;
    
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
A = [0]*N
B = list(map(int,input().split()))

A[0] = B[0]
A[-1] = B[-1]

for i in range(N-2):
    if B[i] > B[i+1]:
        A[i+1] = B[i+1]
    else:
        A[i+1] = B[i]
       
print(sum(A))

Measured memory_bytes: 3188
import java.util.Scanner;

//マジで解法が思いつかなかったがbitDPをみて、まさかと思った
class Main{
	static long ans=0;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s="";
		double INF=11451419810.0d;
		double min=INF;
		while(sc.hasNext()) {
			min=INF;
			s=sc.nextLine();
			String[] sp=s.split(" ");
			double hako=Double.parseDouble(sp[0]);
			double[] en=new double[sp.length-1];
			for(int i=0; i<sp.length-1; i++) {
				en[i]=Double.parseDouble(sp[i+1]);
			}
			//pl(sp.length-1);
			double[][] rinsetu=new double[sp.length-1][sp.length-1];
			for(int i=0; i<sp.length-1; i++) {
				for(int j=0; j<sp.length-1; j++) {
					if(i==j) {
						rinsetu[i][j]=INF;
					}
					else {
						rinsetu[i][j]=2*Math.sqrt(en[i]*en[j]);
					}
				}
			}
			double[][] dp=new double[1<<(sp.length-1)][(sp.length-1)];
			for(int i=0; i<(1<<(sp.length-1)); i++) {
				for(int j=0; j<(sp.length-1); j++) {
					dp[i][j]=INF;	//DPテーブルの初期化（コスト最小化するので、初期値は十分に大きな正の値となる）
				}
			}
			for(int i=0;i<(sp.length-1);i++){
				dp[1<<i][i]=en[i];
			}
			for(int i=0; i<(1<<(sp.length-1))-1; i++) {		//すべての状態について探索する
				for(int j=0; j<(sp.length-1); j++) {
					if(dp[i][j]==INF) {
						continue;		//経路を確立していないなら経路をつくりだせないのでそのまま
					}
					else {	//経路が確立している時、経路を伸ばせるかどうかを判断する
						for(int k=0; k<(sp.length-1); k++) {
							if((i&(1<<k))!=0) {	//その頂点がすでに訪問済みの時は見ない（枝刈り）
								continue;
							}
							else if(rinsetu[j][k]==INF){	//すべての経路に対して行っている。　なので、ある頂点から別の頂点に伸びる辺が無いかもしれないので、無いときはスキップ
								continue;
							}
							else {		//上の2条件を満たした時、経路を伸ばせる
								int nexti=i+(1<<k);		//いまから向かう頂点の訪問フラグを立てる
								dp[nexti][k]=Math.min(dp[nexti][k], dp[i][j]+rinsetu[j][k]);	//経路の更新 最短なら更新、そうでなければ維持
								//pl("i = "+i+" j = "+j+" k = "+k+" nexti"+nexti+" bitDP[][]= "+dp[nexti][k]);
							}
						}
					}
				}
			}
			int all=(1<<(sp.length-1))-1;
			for(int i=0; i<(sp.length-1); i++) {
				if(dp[all][i]==INF) {
					continue;
				}
				else {
					double allcost=dp[all][i]+en[i];
					min=Math.min(min, allcost);
				}
			}
			if(min<hako+0.000001) {
				pl("OK");
				//pl(min);
			}
			else {
				pl("NA");
				//pl(min);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 35304
N = int(input())

fizz = N // 3
buzz = N // 5
fizzbuzz = N // 15

N_sum = N * (N + 1) // 2
fizz_sum = fizz * (fizz + 1) // 2
buzz_sum = buzz * (buzz + 1) // 2
fizzbuzz_sum = fizzbuzz * (fizzbuzz + 1) // 2

print(N_sum - fizz_sum * 3 - buzz_sum * 5 + fizzbuzz_sum * 15)

Measured memory_bytes: 9120
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
#include <sstream>
#include <cctype>
using namespace std;


int main(){
  int A, B;
  char  op;
  cin >> A >> op >> B;
  if(op == '+') cout << A+B << endl;
  else cout << A-B << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int l[60];
    for(int i=0;i<N;i++)cin>>l[i];
    sort(l,l+N);
    reverse(l,l+N);
    int res=0;
    for(int i=0;i<K;i++)res+=l[i];
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#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 flag=0;
  	sort(a.begin(),a.end());
  	for(int i=0;i<N-1;i++){
		if(a[i]==a[i+1]){
          flag=1;
          break;
        }
    }
  	if(flag==1){
		cout<<"NO"<<endl;
    }
  	else{
      cout<<"YES"<<endl;
    }
  return 0;
}

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

using namespace std;

struct Dinic {
    using F = int;
    const static F INF = 0x3f3f3f3f; 
    struct Edge {
        int v, bro; F cap;
        Edge() {}
        Edge(int _v, int _bro, F _cap) : v(_v), bro(_bro), cap(_cap) {}
    };
    vector<Edge> e;
    vector<int> pos, cur;
    int n, s, t, m;
    Dinic(int _n, int _s, int _t) : n(_n), s(_s), t(_t), m(0) {
        pos.assign(n, -1);
        cur.resize(n);
        d.resize(n);
        e.reserve(4e5);
    }
    void add(int u, int v, F c=INF) {
        assert(u < n && v < n);
        e.emplace_back(v, pos[u], c); pos[u] = m++;
        e.emplace_back(u, pos[v], 0); pos[v] = m++;
    }
    vector<int> d;
    bool bfs() {
        fill(d.begin(), d.end(), -1);
        d[s] = 0;
        queue<int> q; q.push(s);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (int i = cur[u] = pos[u]; i != -1; i = e[i].bro) {
                int v = e[i].v;
                if (d[v] == -1 && e[i].cap != 0) {
                    d[v] = d[u] + 1;
                    q.push(v);
                }
            }
        }
        return d[t] != -1;
    }
    F dfs(int u, F lim) {
        if (u == t) return lim;
        F tot = 0;
        for (int& i = cur[u]; i != -1; i = e[i].bro) {
            int v = e[i].v;
            if (e[i].cap != 0 && d[v] == d[u] + 1) {
                int flow = dfs(v, min(e[i].cap, lim-tot));
                tot += flow;
                e[i].cap -= flow;
                e[i^1].cap += flow;
                if (tot == lim) return lim;
            }
        }
        return tot;
    }
    F flow() {
        F res = 0;
        while (bfs()) {
            res += dfs(s, INF);
        }
        return res;
    }
};


void solve() {
    int n; cin >> n;
    vector<int> p(n), q(n);
    for (auto& x: p) {
        cin >> x;
    }
    for (auto& x: q) {
        cin >> x;
    }
    int s = 0;
    int cyc_cnt = 0;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        if (!a[i] && p[i] != i) {
            cyc_cnt++;
            for (int x = i; !a[x]; x = p[x]) {
                a[x] = cyc_cnt;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        if (!b[i] && q[i] != i) {
            cyc_cnt++;
            for (int x = i; !b[x]; x = q[x]) {
                b[x] = cyc_cnt;
            }
        }
    }
    int t = cyc_cnt + 1;
    Dinic mc(t+1, s, t);
    int res = 0;
    for (int i = 0; i < n; i++) {
        int x = p[i], y = q[i];
        if (x == i && y == i) continue;
        res++;
        if (x == i) mc.add(s, b[i], 1);
        else if (y == i) mc.add(a[i], t, 1);
        else {
            mc.add(a[i], b[i], 1);
            if (x == y) mc.add(b[i], a[i], 1);
        }
    }
    res -= mc.flow();
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 7936
# solution
import io
import math
import string

def col(n, m):
    X = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        X[a-1].append(b-1)
        X[b-1].append(a-1)
    C = [-1] * n
    c = 0
    for i in range(N):
        if C[i] >= 0: continue
        Q = [i]
        C[i] = c
        while Q:
            x = Q.pop()
            for y in X[x]:
                if C[y] == -1:
                    C[y] = C[x]
                    Q.append(y)
        c += 1
    return C

N, K, L = map(int, input().split())
A = col(N, K)
B = col(N, L)
D = {}
for a, b in zip(A, B):
    t = (a<<18) + b
    if t in D: D[t] += 1
    else: D[t] = 1

print(*[D[(a<<18)+b] for a, b in zip(A, B)])

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

using namespace std;
typedef long long ll;

const int n = 50;

int main() {
    ll k;
    cin >> k;
    cout << n << endl;

    vector<ll> ret(n, n - 1);
    for (int i = 0; i < k % n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)ret[j] += n;
            else ret[j]--;
        }
    }
    for (int i = 0; i < n; i++) ret[i] += k / n;

    for (int i = 0; i < n; i++) {
        if (i > 0)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s, t;
	cin>>s;
	for(int i = 0; i < s.size(); i+=2) t += s[i];
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 512
require 'matrix'
n,m,l=gets.split.map(&:to_i)
a=(0..n-1).map{|i| gets.split.map(&:to_i)}
b=(0..m-1).map{|i| gets.split.map(&:to_i)}
puts (Matrix[*a]*Matrix[*b]).to_a.map{|i| i*' '}*$/

Measured memory_bytes: 7556
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1e6 + 50;
const ll mod = 1e9 + 7;
const double E = 1e-9;
//int dx[] = {0, -1}, dy[] = {-1, 0};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int n;
ll dp[N][2][2];
ll f(int i, int zero, int nine){
    if(i == n)return zero == 1 && nine == 1;
    ll &ans = dp[i][zero][nine];
    if(ans == -1){
        ans = 0;
        for(int j = 0; j <= 9; j++){
            ans = (ans + f(i + 1, zero or j == 0, nine or j == 9)) % mod;
        }
    }
    return ans;
}
void solve(){
    cin >> n;
    cls(dp, -1);
    cout << f(0, 0, 0) % mod << '\n';
}  
int main(){
    FIN;
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve(); 
    }
    //EjecuteTime;
    return 0;
}  

Measured memory_bytes: 112908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
long double pi = 2 * acos(0.0);
const ll mod = 998244353;

ll h, w, k, xi, yi, x2, y2;
vector<vector<ll>> cost;
vector<string> mat;
vector<set<ll>> urc, ucc;

void dijkstra() {
    set<pair<ll, pair<ll, ll>>> s;
    s.emplace(make_pair(0, make_pair(xi - 1, yi - 1)));
    cost[xi - 1][yi - 1] = 0;
    while(!s.empty()) {
        pair<ll, pair<ll, ll>> node = *s.begin();
        s.erase(s.begin());
        ll r = node.second.first, c = node.second.second, d = node.first;
        for(ll i = 1; i <= k; i++) {
            if(c + i < w && mat[r][c + i] != '@') {
                if(cost[r][c + i] == INT_MAX) {
                    s.emplace(make_pair(d + 1, make_pair(r, c + i)));
                    cost[r][c + i] = d + 1;
                }
                else if(d + 1 > cost[r][c + i]) break;
            }
            else break;
        }
        for(ll i = 1; i <= k; i++) {
            if(c - i >= 0 && mat[r][c - i] != '@') {
                if(cost[r][c - i] == INT_MAX) {
                    s.emplace(make_pair(d + 1, make_pair(r, c - i)));
                    cost[r][c - i] = d + 1;
                }
                else if(d + 1 > cost[r][c - i]) break;
            }
            else break;
        }
        for(ll i = 1; i <= k; i++) {
            if(r + i < h && mat[r + i][c] != '@') {
                if(cost[r + i][c] == INT_MAX) {
                    s.emplace(make_pair(d + 1, make_pair(r + i, c)));
                    cost[r + i][c] = d + 1;
                }
                else if(d + 1 > cost[r + i][c]) break;
            }
            else break;
        }
        for(ll i = 1; i <= k; i++) {
            if(r - i >= 0 && mat[r - i][c] != '@') {
                if(cost[r - i][c] == INT_MAX) {
                    s.emplace(make_pair(d + 1, make_pair(r - i, c)));
                    cost[r - i][c] = d + 1;
                }
                else if(d + 1 > cost[r - i][c]) break;
            }
            else break;
        }
    }
}

void solve() {
    cin >> h >> w >> k;
    cin >> xi >> yi >> x2 >> y2;
    mat.resize(h); cost.resize(h); urc.resize(h); ucc.resize(w);
    
    for(ll i = 0; i < h; i++) cost[i].resize(w);
    for(ll i = 0; i < h; i++) {
        cin >> mat[i];
        for(ll j = 0; j < w; j++) {
            cost[i][j] = INT_MAX;
        }
    }
    dijkstra();
    if(cost[x2 - 1][y2 - 1] != INT_MAX) cout << cost[x2 - 1][y2 - 1];
    else cout << "-1";
}

int main() {
    ios_base :: sync_with_stdio(false); 
    cin.tie(nullptr);   
    ll t = 1;   
    //cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 58940
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef double dd;
typedef pair <int, int> pii;
#define pb push_back
#define pf push_front
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
#define mp make_pair
//const int mx = 1000 * 100 + 5;
int32_t main(){		
	ios_base::sync_with_stdio(false);
    cin.tie(0);	
	cout.tie(0);
	int fact[12];
	fact[0] = 1;
	for(int i = 1; i < 10; i++)
		fact[i] = fact[i - 1] * i;
	int n, t1 = 0, t2 = 0, a[10], b[10];
	cin >> n;
	for(int i = 1; i <= n; i++){
		int t = 0;
		cin >> a[i];
		for(int j = 1; j < i; j++)
			if(a[j] < a[i])
				t++;
		t1 += (a[i] - t - 1) * (fact[n - i]);
	}
	for(int i = 1; i <= n; i++){
		int t = 0;
		cin >> a[i];
		for(int j = 1; j < i; j++)
			if(a[j] < a[i])
				t++;
		t2 += (a[i] - t - 1) * (fact[n - i]);
	}
	cout << abs(t1 - t2) << endl;
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const ll MOD = 1e9+7;

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

  int n, k;
  cin >> n >> k;
  if (k <= (n+1)/2) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
int main()
{
	int t = 1;
//	cin>>t;
	
	while(t--)
	{
		int x;
		cin>>x;
		bool found = 1;
		while(x<=100540)
		{
			found = true;
			for(int i=2; i*i<=x;i++)
			{
				if(x%i==0)
				{
					found = false;
				}
			}
			if(found)
			{
				cout<<x<<"\n";
				break;
			}
			x++;
		}	
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i = 0;
	char S[11], T[] = "2019/04/30";
	scanf("%s", S);
	while (i <= 9) {
		if (S[i] < T[i]) break;
		if (S[i] > T[i]) {
			printf("TBD\n");
			return 0;
		}
		++i;
	}
	printf("Heisei\n");
	return 0;
}

Measured memory_bytes: 128
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    a = [list(map(int,input().split())) for _ in range(N)]
    MOD = 10**9+7
    
    dp = [1] + [0]*(1<<N)

    for i in range(N):
        use = [0]*((1<<N)+1)
        for s in range(1<<N):
            if dp[s] == 0:
                continue
            for j in range(N):
                jb = 1<<j
                if not (s&jb) and a[i][j]:
                    use[s^jb] += dp[s]
        dp = use
    
    print(dp[(1<<N)-1]%MOD)

if __name__ == "__main__":
    main()


Measured memory_bytes: 148620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<ll> s(n);
    rep(i, n) cin >> s[i];
    vector<vector<ll>> dp(n);
    dp[0].resize(n);
    rep(j, n) dp[0][j] = 0;
    ll ans = 0;
    
    rep(i, n) {
        if (i==0) continue;
        ll z = (n-2)/i;
        dp[i].resize(z+1);
        rep(j, z+1) {
            if (j==0) continue;
            if (((n-1)%j)==0 && n-1-i*j<=i*j) continue;
            if (n-1-i*j<=j) continue;
            dp[i][j] = dp[i-1][j] + s[n-1-i*j] + s[i*j];
            chmax(ans, dp[i][j]);
        }
    }
    
    
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15360
def string_trnase(N, A, B, s):
    passed = 0
    oversea = 0
    for i in range(0, len(s)):
        if passed == A + B:
            print('No')
        elif s[i] == 'c':
            print('No')
            continue
        elif s[i] == 'a':
            if passed < A+B:
                print('Yes')
                passed += 1
        elif s[i] == 'b':
            if passed < A+B and oversea < B:
                print('Yes')
                passed += 1
                oversea += 1
            else:
                print('No')
        else:
            print('No')



nums = input()
N = int(nums.split(' ')[0])
A = int(nums.split(' ')[1])
B = int(nums.split(' ')[2])
string_trnase(N, A, B, input())


Measured memory_bytes: 52056
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = words
printer = id

solver [s,k] = s4 !! (int k - 1)
  where
    s1 = L.tails s :: [String]
    s2 = L.sort s1 :: [String]
    s3 = concatMap inits s2 :: [String]
    s4 = myfil "" s3 :: [String]
    
myfil t [] = []
myfil t (a:as) = 
      if t < a
      then a:myfil a as
      else myfil t as

inits :: [a] -> [[a]]
inits [] = []
inits (x:xs) = inits' (x:) xs

inits' :: ([a]->[a]) -> [a] -> [[a]]
inits' pre [] = [pre []]
inits' pre (x:xs) = (pre []) : inits' (pre . (x:)) xs


Measured memory_bytes: 1404
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

clock_t start = clock();

void solve() {
    int x;
    cin >> x;
    cout << (x ^ 1) << '\n';
}

int main() {
    int T = 1;
    // cin >> T;
    while (T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll A;
  string b;
  cin >> A >> b;
  string k="";
  for(char c:b) {
    if(c!='.') {
      k += c;
    }
  }
  int n = atoi(k.c_str());
  A *= n;
  A /= 100;
  cout << A << endl;
  return 0;
}

Measured memory_bytes: 3624
N, M = gets.chomp.split(" ").map(&:to_i)
S = Array.new
M.times do
    S << gets.chomp.split(" ").map(&:to_i)[1..-1]
end
P = gets.chomp.split(" ").map(&:to_i)
answer = 0
for i in 0..2**N-1
    bin = format("%0#{N}b", i)
    all_on = true
    S.each_with_index do |s, idx|
        if s.map{|x| bin[x-1]}.count("1") % 2 != P[idx]
            all_on = false
            break
        end
    end
    answer += 1 if all_on
end
puts answer

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

int main() {
  int N;
  scanf("%d", &N);

  // 各要素が奇数になるまでに何回2で割れるかを数える  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int a = 0;
    scanf("%d", &a);
    if (a % 2 == 0) {
      while (a % 2 == 0) {
        ans++;
        a /= 2;
      }
    }
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC target("popcnt")  //https://godbolt.org/z/yQv94Y 

typedef long long int ll;
typedef unsigned long long int  ull;
typedef long double ld;

#define INF 1e9
#define pi 3.141592653589
#define e 2.718281828459
#define phi 1.618033988749
#define MOD 1000000007
#define printarr(arr,n){for(int i=0;i<(n);i++){cout<<arr[i]<<" ";}cout<<endl;}
#define foreach(it , l) for(auto it = l.begin(); it != l.end(); ++it)
#define xlr8 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define rev_sort(a) sort(a.rbegin(),a.rend());

struct Timer
{
    chrono::time_point<chrono::high_resolution_clock> start , end;
    chrono:: duration<float> dur;
    Timer()
    {
        start = chrono::high_resolution_clock::now();
    }
    ~Timer()
    {
        end = chrono::high_resolution_clock::now();
        dur = end - start;
        cout<<"\nTime Elapsed : " <<dur.count() << " s\n";
    }
};

ll sum() {return 0;}
template<typename T, typename... Args>
T sum(T a , Args... args)   {return a + sum(args...); }

//76149
template<int D, typename T> 
struct Vec : public vector<Vec<D - 1, T>> {
  static_assert(D >= 1, "Vector dimension must be greater than zero!");
  template<typename... Args>
  Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
  }
};
template<typename T>
struct Vec<1, T> : public vector<T> {
  Vec(int n = 0, T val = T()) : vector<T>(n, val) {
  }
};



int main()
{
    xlr8;
    int testCases  = 1;
    //cin>>testCases;
    while (testCases--)
    {
        ld a , b , h , m;
        cin>>a>>b>>h>>m;
        ld theta1 , theta2;
        ld omega1 = (2*pi)/(12*60) , omega2 = (2*pi)/60;

        theta1 = omega1*(h*60 + m);
        theta2 = omega2*(m);

        ld ans = a*a + b*b - 2*a*b*cos(theta1 - theta2);
        cout<<setprecision(12)<<fixed<<sqrt(ans)<<"\n";
    }
    
    

    

}


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

int main (){
    int N;
    int dig, sum=0, num;
    string str;

    cin >> N;

    num = N;

    while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
    }

    if(N % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<stdio.h>
  
#define AMAX 20
#define MMAX 200
 
int A[AMAX+1];
int n, q;

int solve( int p, int t, int res )
{
	return  ( n < p ) ? res: solve( p+1, t-A[p],  !t ) || solve( p+1, t,  !t  );
}
 
int main( void ) 
{
    int i;
    int num;
     
    scanf( "%d", &n );  
    for( i=0; i<n; i++ ) {
        scanf( "%d", &A[i] );
    }   
    scanf( "%d", &q );
    for( i=0; i<q; i++ ) {
        scanf( "%d", &num );
        if( solve( 0, num, 0 ) ) {
            printf( "yes\n" );      
        } else {
            printf( "no\n" );
        }
    }
    return 0;
}

Measured memory_bytes: 580
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

H, W = getNM()
maze = []
for i in range(H):
    m = list(input())
    maze.append(m)

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

memo = [[-1] * W for i in range(H)]

def counter(sx, sy):
    black_cnt = 0
    white_cnt = 0

    memo[sy][sx] = 1
    if maze[sy][sx] == "#":
        black_cnt += 1
    else:
        white_cnt += 1

    pos = deque([[sx, sy]])

    while len(pos) > 0:
        x, y = pos.popleft()

        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < W and 0 <= ny < H and maze[ny][nx] != maze[y][x] and memo[ny][nx] == -1:
                memo[ny][nx] = 1
                pos.append([nx, ny])
                if maze[ny][nx] == "#":
                    black_cnt += 1
                else:
                    white_cnt += 1
    return black_cnt * white_cnt

ans = 0
for i in range(H):
    for j in range(W):
        ans += counter(j, i)
print(ans)

Measured memory_bytes: 80600