akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter
import java.util.*
import java.math.*

val pw = PrintWriter(System.out)

fun main(args: Array<String>) {
    val (h, w) = readListOfInt()
    val c = mutableListOf<String>()
    for(i in 0 until h) {
        val row = read()
        c.add(row)
    }

    val c2 = mutableListOf<String>()
    for(i in 0 until h) {
        val row = c[i]
        c2.apply { 
            add(row)
            add(row)
        }
    }
	for(i in 0 until c2.size) {
		println(c2[i])
	}
    pw.flush()
}

fun inputList() = 
    readLine()!!.split(" ").map(String::toInt)

fun sum_digits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

/****** Decrared Functions ******/

// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }


fun println(value : Any) {
    pw.println(value)
}

fun gcd(a: Long, b: Long): Long = 
    if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
    if(b==0L) a else gcd(b, a % b)


Measured memory_bytes: 36080
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll k;
    cin >> k;
    cout << 50 << endl;
    
    vector<ll> ans;
    ll rest = k%50;
    rep(i, rest)ans.push_back(50);
    rep(i, 50-rest)ans.push_back(49-rest);

    ll n = k/50;
    rep(i, 50)cout << ans[i]+n << " ";
}

Measured memory_bytes: 256
N = gets.split('\n').map(&:to_i)
nums = gets.chomp.split(' ').map(&:to_f).sort
n = N[0].to_i
for i in 1..n-2 do 
  min1 = nums.min
  min1_index = nums.index(min1)
  nums.delete_at(min1_index)
  min2 = nums.min
  min2_index = nums.index(min2)
  nums.delete_at(min2_index)
  a = (min1+ min2)/2
  nums << a
end
ans = (nums[0] + nums[1])/2
puts ans

Measured memory_bytes: 1788
h = Hash.new()
str = String.new

("a".."z").each{|c| h[c] = 0}

while temp = gets
    str += temp.chomp.downcase
end

str.gsub!(/[^a-zA-Z]/, "")
str.each_char{|c| h[c] += 1 }
h.each{|k,v| puts "#{k} : #{v}" }


Measured memory_bytes: 6876
N = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(N[k-1])

Measured memory_bytes: 3060
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    n, m = MI()
    a_list = LI()
    c = 0
    votes = sum(a_list)
    for a in a_list:
        if a >= votes / (4 * m):
            c += 1

    if c < m:
        print("No")
    else:
        print("Yes")
    pass


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
using System;
namespace kozaiyApp
{
    public class B
    {
        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            string[] inputA = Console.ReadLine().Split(' ');
            int g = 0;
            for (int i = 0; i < M; i++)
            {
                g += int.Parse(inputA[i]);
            }

            if (g > N)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(N - g);
            }
        }
    }
}

Measured memory_bytes: 28304
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
using namespace std;
const int MOD=1000000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e14;

int dp[N];
bool vis[N];
vector<int>a[N];

void DFS(int node){
    vis[node]=1;
    for(int i=0;i<a[node].size();i++){
        int child=a[node][i];
        if(!vis[child])
            DFS(child);
        dp[node]=max(dp[node],1+dp[child]);
    }
}
int main() {
    fastio

    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        a[u].pb(v);
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            DFS(i);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 8320
#include <iostream>

int main() {
	int n, q, s, t;
	std::cin >> n;
	int S[n];
	for (s = 0; s < n; s++) {
		std::cin >> S[s];
	}
	std::cin >> q;
	int T[q];
	for (t = 0; t < q; t++) {
		std::cin >> T[t];
	}
	
	int left, right, mid;
	int C = 0;
	for (t = 0; t < q; t++) {
		left = 0;
		right = n;
		while (left < right) {
			mid = (left + right) / 2;
			if (S[mid] == T[t]) {
				C++;
				break;
			} else if (T[t] < S[mid]) {
				right = mid;
			} else {
				left = mid + 1;
			}
		}
	}
	
	std::cout << C << std::endl;
	
	return 0;
}


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

string s, t;
int dp[3005][3005];
vector<char> ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> s >> t;
    for(int i=0; i<s.length(); i++) {
        for(int j=0; j<t.length(); j++) {
            if(s[i]==t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }

    int i = s.length(), j = t.length();
    while(i>0 && j>0) {
        if(s[i-1]==t[j-1]) {
            ans.push_back(s[i-1]);
            i--; j--;
        } else if(dp[i][j-1] > dp[i-1][j]) j--;
        else i--;
    }
    reverse(ans.begin(), ans.end());
    for(int i=0; i<ans.size(); i++) cout << ans[i];

    return 0;
}


Measured memory_bytes: 35456
#! /usr/bin/env perl
use strict;
use warnings;

my $N = <>;
chomp $N;

my $str = <>;
chomp $str;

my ($s_str, $t_str) = split / /, $str;
my $s = [split //,$s_str];
my $t = [split //,$t_str];


for my $i(0..$N-1){
    print($s->[$i]);
    print($t->[$i]);
}

print("\n");



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}
		sc.close();

		int[][] a = new int[h][w];
		for (int i = 0; i < h; i++) {
			int cnt = 0;
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '.') {
					cnt++;
					a[i][j] = cnt;
				} else {
					cnt = 0;
				}
			}
			for (int j = w - 2; j >= 0; j--) {
				if (s[i][j] == '.') {
					a[i][j] = Math.max(a[i][j], a[i][j + 1]);
				}
			}
		}

		int[][] b = new int[h][w];
		for (int j = 0; j < w; j++) {
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				if (s[i][j] == '.') {
					cnt++;
					b[i][j] = cnt;
				} else {
					cnt = 0;
				}
			}
			for (int i = h - 2; i >= 0; i--) {
				if (s[i][j] == '.') {
					b[i][j] = Math.max(b[i][j], b[i + 1][j]);
				}
			}
		}

		int ans = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				int val = a[i][j] + b[i][j] - 1;
				ans = Math.max(ans, val);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 107612
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    ll k[1000]={};
    for(int i=1;i<=n;i++){
        int s=i;
        for(int j=2;j<=i;j++){
            if(s==1)break;
            if(s%j==0){
                k[j-1]++;
                s/=j;
                j--;
            }
        }
    }
    ll
    ans=1;
    for(ll i:k){
        ans*=i+1;
        ans%=INF;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  list<int> ls;
  int q;
  cin >> q;
  auto itr = ls.end();
  REP(i,q){
    int d;
    cin >> d;
    if(d==0){
      int x;
      cin >> x;
      itr = ls.insert(itr,x);
    }else if(d==1){
      int dis;
      cin >> dis;
      REP(i,abs(dis)){
        if(dis>0) itr++;
        else itr--;
      }
    }else{
      itr = ls.erase(itr);
    }
  }
  for(auto i:ls){
    cout << i << endl;
  }
}



Measured memory_bytes: 18628
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define MAXN 100010
using namespace std;
ll i,j,k,n,m,c,ans,a[107][2],dp[107][MAXN];
int main()
{
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>a[i][0]>>a[i][1];


    fill(dp[0]+1,dp[0]+MAXN,1e18);

    for(i=1;i<=100;i++){
        for(j=0;j<MAXN;j++)
        {
            if(j>=a[i][1])
                dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i][1]]+a[i][0]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    for(i=MAXN-1;i>=0;i--)
    if(dp[n][i]<=k)
    {
        ans = i;
        break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 80128
h, w = map(int, input().split())

mass = []
for i in range(h):
    s = input()
    s += "."
    mass.append(s)
mass.append("." * (w + 1))
for i in range(h):
    for j in range(w):
        if mass[i][j] == "#":
            if mass[i][j + 1] != "#" and mass[i][j - 1] != "#" and mass[i + 1][j] != "#" and mass[i - 1][j] != "#":
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

template <typename T> struct BIT {
    int n;
    vector<T> bit;
    BIT(int n_) : n(n_ + 1), bit(n, 0) {
    }

    void add(int i, T x) {
        if (i == 0) {
            cout << "BIT add ERROR" << endl;
            exit(1);
        }
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[idx] += x;
        }
    }

    T sum(int i) {
        T s(0);

        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[idx];
        }
        return s;
    }
};

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

    unordered_map<int, int> mp;
    unordered_map<int, int> ball;

    rep(i, N) {
        int c;
        cin >> c;
        int now = i + 1;
        if (mp[c] == 0) {
            mp[c] = now;
        } else {
            ball[mp[c]] = now;
            mp[c] = now;
        }
    }

    vec<vec<int>> query(N+1);
    vec<int> l(Q), r(Q);
    rep(i, Q) {
        cin >> l[i] >> r[i];
        query[l[i]].push_back(r[i]);
    }

    BIT<ll> bit(N);
    map<pair<int, int>, int> ans;
    for (int i = N; i > 0; --i) {
        if (ball[i] != 0) bit.add(ball[i], 1);
        for (auto e : query[i]) {
            ans[{i, e}] = bit.sum(e);
        }
    }

    rep(i, Q) {
        cout << r[i] - l[i] + 1 - ans[{l[i], r[i]}] << endl;
    }
}


Measured memory_bytes: 103032
n,m=map(int,input().split())
h=list(map(int,input().split()))
mylist=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    mylist[a-1].append(h[b-1])
    mylist[b-1].append(h[a-1])
cnt=0
for i in range(len(mylist)):
    if len(mylist[i])==0:
        cnt+=1
    elif h[i]>max(mylist[i]):
        cnt+=1
print(cnt)

Measured memory_bytes: 22992
import numpy as np
n, m, c = (int(i) for i in input().split())
b = np.array([int(i) for i in input().split()])
a = np.array([[int(i) for i in input().split()] for i in range(n)])
ans = 0
for i in range(n):
    if sum(b*a[i]) + c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 20608
n = int(input())
d = [tuple(map(int, input().split())) for _ in range(n)]

for i in range(n-2):
    if d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1] and d[i + 2][0] == d[i + 2][1]:
        print("Yes")
        raise SystemExit(0)
print("No")


Measured memory_bytes: 62544
import sys
input = sys.stdin.readline

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

# topological順序の計算
s = []
s.append(0)
parent = [-1]*n
order = []
while s:
    x = s.pop()
    order.append(x)
    for nx in g[x]:
        if nx == parent[x]:
            continue
        parent[nx] = x
        s.append(nx)

color = [0]*n
for v in order:
    ng = color[v]
    c = 1
    for u in g[v]:
        if u == parent[v]:
            continue
        if c == ng:
            c += 1
        color[u] = c
        c += 1

ans = []
for a, b in e:
    if parent[a] == b:
        ans.append(color[a])
    else:
        ans.append(color[b])

print(len(set(ans)))
print('\n'.join(map(str,ans)))

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

using namespace std;

using ll = long long;

bool is_prime(int n) {
    if (n % 2 == 0) return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

vector<int> divisor(int n) {
    vector<int> res;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

vector<int> sieve(int n) {
    vector<int> res;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.emplace_back(i);
        for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> cnt(n + 1, 0);
    for (int i = 1; i <= n; i += 2) {
        vector<int> d(divisor(i));
        if (d.size() == 8) cnt[i]++;
    }

    for (int i = 1; i <= n; i++) {
        cnt[i] += cnt[i - 1];
    }
    cout << cnt[n] << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
arr = []
arr << gets.chomp
ans = 'Yes'
(N-1).times do
  prev = arr[-1][-1]
  w = gets.chomp
  if w[0].chomp != prev || arr.include?(w)
    ans = 'No'
  else
    arr << w
  end
end

puts ans

Measured memory_bytes: 14332
N=int(input())
p=list(map(int, input().split()))
p = [0] + p
ans = 0
ids = []
flag = 0
if N == 2:
    i=1
    if p[i]==i or p[i+1]==i+1:
        print(1)
        exit()
for i in range(1, N):
    if flag:
        flag = 0
        continue
    if p[i]==i:
        if p[i+1]==i+1:
            # ids.append((i, i+1))
            ans += 1
            flag = 1
            continue
        else:
            # ids.append((i, i+1))
            ans += 1
if p[N] == N and not flag:
    # ids.append((N-1, N))
    ans += 1
print(ans)


Measured memory_bytes: 84836
n,m = map(int,input().split())
h = list(map(int,input().split()))
ans = [1] * n
for i in range(m):
  a,b, = map(int,input().split())
  if h[a-1] >= h[b-1]:
    ans[b-1] =0
  if h[a-1] <= h[b-1]:
    ans[a-1] = 0
print(sum(ans))

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

int main() {
	int a[3];
	int k;
	int ma = 0;
	int ans = 0;
	for (int i = 0;i < 3;i++) {
		cin >> a[i];
		ans += a[i];
		ma = max(ma, a[i]);
	}
	cin >> k;
	ans -= ma;
	for (int i = 1;i <= k;i++) {
		ma *= 2;
	}
	ans += ma;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect_left

def main():
    N, Q = LI()
    XST = []
    for _ in range(N):
        s, t, x = LI()
        XST.append([x, s, t])
    D = []
    for _ in range(Q):
        D.append(II())
    ans = [-1] * Q
    nexts = [-1] * Q
    XST.sort()
    for x, s, t in XST:
        i = bisect_left(D, s - x)
        end = bisect_left(D, t - x)
        while i < end:
            if nexts[i] == -1:
                ans[i] = x
                nexts[i] = end
                i += 1
            else:
                i = nexts[i]
    for y in ans:
        print(y)
    return

main()


Measured memory_bytes: 58548
<?php
        do
        {
                $input = preg_split('//',trim(fgets(STDIN)),NULL,PREG_SPLIT_NO_EMPTY);
                if(0 == $input[0])
                {
                        break;
                }
                $cnt = count($input);

//var_dump($input);
//var_dump($cnt);

                $sum = 0;
                for($loop_cnt = 0; $loop_cnt < $cnt; $loop_cnt++)
                {
                        $sum += $input[$loop_cnt];
                }
                echo $sum . "\n";
        }while(1);
?>


Measured memory_bytes: 9632
#include <stdio.h>
 
int main(void) {
    int m, f, r;
    char c[6] = {'F','A','B','C','D'};
    int grade;
     
    while (scanf("%d %d %d", &m, &f, &r), ~m || ~f || ~r) {
        if (!(~m && ~f)) grade = 0;
        else if (m + f >= 80) grade = 1;
        else if (m + f >= 65) grade = 2;
        else if (m + f >= 50) grade = 3;
        else if (m + f >= 30) {
            if (r >= 50) grade = 3;
            else grade = 4;
             
        }
        else grade = 0;
         
         
        printf("%c\n", c[grade]);
    }
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n, h;
  cin >> n;
  int old_h = 0;
  int ans = 0;
  for(int i = 0; i < n; ++i)
  {
    cin >> h;
    ans += max(0, h - old_h);
    old_h = h;
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3628
from itertools import product
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

ans = float('inf')
for select in product(range(4), repeat=N):
    tmp = 0

    a = [L[i] for i in range(N) if select[i] == 1]
    b = [L[i] for i in range(N) if select[i] == 2]
    c = [L[i] for i in range(N) if select[i] == 3]

    if not (a and b and c):
        continue

    tmp += (max(0, len(a) - 1)) * 10
    tmp += (max(0, len(b) - 1)) * 10
    tmp += (max(0, len(c) - 1)) * 10

    a = sum(a)
    b = sum(b)
    c = sum(c)
    tmp += abs(A - a) + abs(B - b) + abs(C - c)
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
  int main()
 {
 
       ll n,m;cin>>n>>m;
        vector<vector<ll> > v(n+1,vector<ll>(m+1,0));
        
        for(ll i=1;i<=n;i++)
        {
            for(ll j=1;j<=m;j++)
            {
                char ch;
                cin>>ch;
                ch=='#'? v[i][j]=0:v[i][j]=1;
                
            }
        }
        vector<vector<ll> > dp(n+1);
     for(int i = 1 ; i <= n ;i++){
         dp[i].resize(m+1);
         if(i == 1)dp[1][1]=1;
         for(int j = 1 ; j <= m ; j++ ){
             if(i==1 and j==1 )continue;
             if(v[i][j]==0)continue;
             else{
                 if(v[i-1][j]!=0)dp[i][j]+=dp[i-1][j];
                 if(v[i][j-1]!=0)dp[i][j]+=dp[i][j-1];
                 dp[i][j]%=mod;
             }
         }
     }
     cout<<dp[n][m];
    return 0;
 }
 


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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int A;
    double B;
    cin >> A >> B;
    int C=(int)(B*100+0.000001);
    int ans = A*C;
    cout << ans/100 << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

int gcd(int x,int y){
    if(y==0) return x;
    return gcd(y,x % y);
}
int main(){
        int N;
        cin >> N;
        vector<int>tairyoku(N);
        for (int i = 0 ; i < N ; i++)cin >> tairyoku[i];
        int gcds = 0;
        for (int i = 0 ; i < N ; i++) gcds = gcd(gcds , tairyoku[i]);
        cout << gcds << endl;
        
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a,b;
	cin>>a;
	cin>>b;
	int c=a.size(),d=b.size();
	int s1=min(c,d),s2=max(c,d);
	for(int i=0; i<=s1-1; i++)
		cout<<a[i]<<b[i];
	if(c>d)
		for(int i=s1; i<=s2-1; i++)
			cout<<a[i];
	else for(int i=s1; i<=s2-1; i++)
			cout<<b[i];
	return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)
#define allof(v) (v).begin(), (v).end()

inline bool ok(li x) {
	li cnt = 0;
	repp(i, 1, x + 1) {
		if (x % i == 0)++cnt;
	}
	return cnt == 8;
}

int main(void)
{
	string s;
	li k;
	cin >> s >> k;
	k--;

	li non1 = 0;
	li n = s.size();
	rep(i, n) {
		if (s[i] != '1') {
			break;
		}
		non1++;
	}

	if (non1 > k) {
		cout << 1 << endl;
	} else {
		cout << s[non1] << endl;
	}


	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

total = abs(a[0])

for i in range(1, n):
    total += abs(a[i] - a[i-1])

total += abs(a[-1])

#print('total: ' + str(total))

for i in range(n):
    if i == 0:
        org = abs(a[i]) + abs(a[i] - a[i+1])
        skip = abs(a[i+1])
        print(total - org + skip)
        continue
    if i == n - 1:
        org = abs(a[i-1] - a[i]) + abs(a[i])
        skip = abs(a[i-1])
        print(total - org + skip)
        continue

    org = abs(a[i-1] - a[i]) + abs(a[i] - a[i+1])
    skip = abs(a[i-1] - a[i+1])
    print(total - org + skip)

Measured memory_bytes: 64364
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    string s;
    cin >> s;
    int count;
    int mx=100000000;
    for(int i=0; i<s.size()-2; i++){
        string num;
        num.push_back(s[i]);
        num.push_back(s[i+1]);
        num.push_back(s[i+2]);
        count = abs(stoi(num)-753);
        //cout << count <<endl;
        mx = min(count,mx);
    }
    cout << mx <<endl;
}

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

#define ll long long
#define llong long long
#define REP(i,n) for(auto i=0;i<n;++i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define FOR(i,a,b) for(auto i=a;i<b++i)
#define ALL(v) v.begin(),v.end()
#define pb push_back

using namespace std;

struct edge{int from, to, cost;};

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

  vector<pair<int, int>> g[n];
  vector<int> cond[n];
  REP(i,m){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    g[a].push_back(make_pair(b, c));
    cond[b].pb(a);
  }

  queue<edge> que;
  REPI(itr,g[0]){
    que.push({0,itr->first, itr->second});
  }

  int t = 0;
  while(!que.empty()){
    queue<edge> que_tmp;
    while(!que.empty()){
      edge tp = que.front();
      que.pop();

      tp.cost--;
      if(tp.cost == 0){
        int next = tp.to;
        REPI(itr,cond[next]){
          if(*itr == tp.from){
            cond[next].erase(itr);
            break;
          }
        }
        if(cond[next].empty()){
          REPI(itr, g[next]){
            que_tmp.push({next, itr->first, itr->second});
          }
        }
      }else{
        que_tmp.push(tp);
      }
    }
    while(!que_tmp.empty()){
      edge ed = que_tmp.front(); que_tmp.pop();
      que.push(ed);
    }
    t++;
  }

  printf("%d\n", t);
  return 0;
}




Measured memory_bytes: 3300
<?php

$a = [];
$a[] = explode(' ',trim(fgets(STDIN)));
$a[] = explode(' ',trim(fgets(STDIN)));
$a[] = explode(' ',trim(fgets(STDIN)));

$n= trim(fgets(STDIN));

$b = [];
for ($i =0;$i<$n;$i++){
    $b[] = trim(fgets(STDIN));
}

//var_dump($a,$n,$b);

$aa = [[0,0,0],[0,0,0],[0,0,0]];
for($i=0;$i<3;$i++){
    for ($y=0;$y<3;$y++){

        if (in_array($a[$i][$y],$b)){
            $aa[$i][$y] = 1;
        }
    }
    if (min($aa[$i]) === 1){
        echo 'Yes'.PHP_EOL;exit;
    }
}

for ($i=0;$i<3;$i++){
    if ($aa[0][$i] + $aa[1][$i] + $aa[2][$i] === 3){
        echo 'Yes'.PHP_EOL;exit;
    }
}

if ($aa[0][0] + $aa[1][1]+$aa[2][2] === 3 || $aa[0][2] + $aa[1][1]+$aa[2][0] === 3) {
    echo 'Yes'.PHP_EOL;exit;
}

echo 'No'.PHP_EOL;


//var_dump($aa);

Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll dp[100005][3];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll a, b, c;
		cin >> a >> b >> c;
		dp[i][0] = max(dp[i - 1][1] + a, dp[i - 1][2] + a);
		dp[i][1] = max(dp[i - 1][0] + b, dp[i - 1][2] + b);
		dp[i][2] = max(dp[i - 1][1] + c, dp[i - 1][0] + c);
	}
	ll ans = 0;
	rep(i, 3) ans = max(ans, dp[n][i]);
	cout << ans << endl;
}

Measured memory_bytes: 5936
#include <bits/stdc++.h>
using namespace std;
int main() {
  int D, G, p[11], c[11];
  cin >> D >> G;
  for (int i = 0; i < D; i++) {
    cin >> p[i] >> c[i];
  }

  int ans = 1e9;
  for (int mask = 0; mask < (1 << D); mask++) {
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < D; i++) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      } else {
        rest_max = i;
      }
    }
    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = (G - s + s1 -1) / s1;
      if (need >= p[rest_max]) {
        continue;
      }
      num += need;
    }
    ans = min(ans,num);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <tuple>

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    string s[n];
    for(int i=0; i<n; ++i){
        cin >> s[i];
    }

    string sorted_s[n];
    // 挿入ソートで探す
    for(int i=0; i<n; ++i){
        int min_idx = 0;
        for(int j=0; j<n; ++j){
            for(int k=0; k<l; ++k){
                if(s[min_idx].substr(k, 1) < s[j].substr(k, 1)){
                    // cout << s[min_idx].substr(k, 1) << ">" << s[j].substr(k, 1) << endl;
                    break; // kのループを脱出, minは維持される
                }
                else if(s[min_idx].substr(k, 1) > s[j].substr(k, 1)){
                    // cout << s[min_idx].substr(k, 1) << "<" << s[j].substr(k, 1) << endl;
                    min_idx = j;
                    break; // kのループを脱出, minは入れ替わる
                }
                else{
                    // cout << s[min_idx].substr(k, 1) << "=" << s[j].substr(k, 1) << endl;
                // それ以外ならば次の桁へ進む
                }
            }
        }
        sorted_s[i] = s[min_idx];
        s[min_idx] = string(l, 'z');
    }

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

Measured memory_bytes: 256
from numpy.fft import rfft, irfft
import numpy as np

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))

C = [0]*(10**5+1)
for a in A:
    C[a] += 1

L = 2*10**5+4

CC = rfft(np.array(C), L)
X = (irfft(CC*CC)+0.5).astype(int)
count = 0
ans = 0
for i in reversed(range(L)):
    x = X[i]
    if count + x >= M:
        ans += i*(M-count)
        break
    ans += i*x
    count += x

print(ans)

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

int main(){
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if( s1[ s1.size() - 1 ] == s2[0] && s2[s2.size() - 1] == s3[0] ) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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; }

const int INF = 1e9;
const int N_MAX = 1e5+10;

int main() {
    IOS
    int n;
    cin >> n;
    ll h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    ll dp[N_MAX];
    for (int i = 0; i < N_MAX; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
import math

n = int(input())
k = round((1 + math.sqrt(1 + 8 * n)) / 2)

if k * (k - 1) == 2 * n:
    print("Yes")
    ss = [[0 for j in range(k - 1)] for i in range(k)]

    cnt = 1
    for i in range(1, k):
        for j in range(k - i):
            ss[i - 1][i + j - 1] = cnt
            ss[i + j][i - 1] = cnt
            cnt += 1

    print(k)
    for s in ss:
        print(k - 1, " ".join([str(i) for i in s]))
else:
    print("No")

Measured memory_bytes: 45404
def qqq(n):

    a = int(n/100)
    if a == 7: 
        return "Yes" 
    
    n %= 100
    b = int(n/10)
    if b == 7:
        return "Yes"
    
    n %= 10
    if n == 7:
        return "Yes"

    return "No"

if __name__ == '__main__':
    N = int(raw_input())
    print qqq(N)

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

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

    sort(a.begin(), a.end());
    if (a[0] + a[1] == a[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
h , w = map(int, input().split())
mi=h*w
s=h*w
for i in range(h):
    s1=w*i
    if w%2==0 or (h-i)%2==0:
        s2=(s-s1)//2
        s3=s2
    elif h-i<w:
        s2=(h-i)*(w-1)//2
        s3=(h-i)*(w+1)//2
    else:
        s2=(h-i-1)//2*w
        s3=(h-i+1)//2*w
    d=abs(min(s1,s2,s3)-max(s1,s2,s3))
    if d<mi:
        mi=d
for i in range(w):
    s1=h*i
    if (w-i)%2==0 or h%2==0:
        s2=(s-s1)//2
        s3=s2
    elif w-i<h:
        s2=(w-i)*(h-1)//2
        s3=(w-i)*(h+1)//2
    else:
        s2=(w-i-1)//2*h
        s3=(w-i+1)//2*h
    d=abs(min(s1,s2,s3)-max(s1,s2,s3))
    if d<mi:
        mi=d
print(mi)


Measured memory_bytes: 3064
n = int(input())
dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]
plist = list(map(float, input().split()))
dp[1][0], dp[1][1] = 1 - plist[0], plist[0]
for i in range(1, n):
    p = plist[i]
    for j in range(i + 1):
        dp[i + 1][j] += dp[i][j] * (1 - p)
        dp[i + 1][j + 1] += dp[i][j] * p
print(sum(dp[-1][n // 2 + 1:]))

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

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

  int un = 0, up = 0;
  for (int i = 0; i < X; i++) {
    for (int j = 0; j < A.size(); j++) {
      if (A[j] == i) un++;
    }  
  }
  for (int i = X; i < N + 1; i++) {
    for (int j = 0; j < A.size(); j++) {
      if (A[j] == i) up++;
    }      
  }
  cout << min(un, up) << endl;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=1e5+5;
const ll INF=0x3f3f3f3f3f3f3f3f;
int a[maxn];
struct node
{
    int l,r;
    ll diff,lz;
}tree[4*maxn];
void build(int l,int r,int cur)
{
    tree[cur].l=l;
    tree[cur].r=r;
    if(l==r)
        return;
    int mid=(l+r)>>1;
    build(l,mid,cur<<1);
    build(mid+1,r,cur<<1|1);
    return;
}
void push_up(int cur)
{
    tree[cur].diff=tree[cur<<1].diff+tree[cur<<1|1].diff;
    return;
}
void push_down(int cur)
{
    if(tree[cur].lz!=0)
    {
        tree[cur<<1].diff+=(tree[cur<<1].r-tree[cur<<1].l+1)*tree[cur].lz;
        tree[cur<<1].lz+=tree[cur].lz;
        tree[cur<<1|1].diff+=(tree[cur<<1|1].r-tree[cur<<1|1].l+1)*tree[cur].lz;
        tree[cur<<1|1].lz+=tree[cur].lz;
        tree[cur].lz=0;
    }
    return;
}
void add(int l,int r,ll val,int cur)
{
    if(l>r) return;
    if(tree[cur].l>=l&&tree[cur].r<=r)
    {
        tree[cur].diff+=(tree[cur].r-tree[cur].l+1)*val;
        tree[cur].lz+=val;
        return;
    }
    if(tree[cur].l>r||tree[cur].r<l)
        return;
    push_down(cur);
    add(l,r,val,cur<<1);
    add(l,r,val,cur<<1|1);
    push_up(cur);
    return;
}
ll diff0[maxn];
void together(int cur)
{
    if(tree[cur].l==tree[cur].r)
    {
        diff0[tree[cur].l]=tree[cur].diff;
        return;
    }
    push_down(cur);
    together(cur<<1);
    together(cur<<1|1);
    push_up(cur);
    return;
}
ll minn[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    build(0,m-1,1);
    ll base=0;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i+1])
        {
            base+=(ll)(a[i+1]-a[i]);
            add(a[i]+1,a[i+1]-1,-1,1);
            add(a[i+1],a[i+1],a[i+1]-a[i]-1,1);
        }
        else
        {
            base+=(ll)(m-a[i]+a[i+1]);
            add(0,0,-(m-a[i]),1);
            add(1,a[i+1]-1,-1,1);
            add(a[i+1],a[i+1],m-a[i]+a[i+1]-1,1);
            add(a[i]+1,m-1,-1,1);
        }
    }
    together(1);
    minn[0]=base;
    for(int i=1;i<=m;i++)
        minn[i]=minn[i-1]+diff0[i-1];
    ll ans=INF;
    for(int i=1;i<=m;i++)
        ans=min(ans,minn[i]);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int K;
    cin>>K;
    if(K>n*(n-1)/2-n+1){
        cout<<-1<<endl;
        return 0;
    }
    vector<int> e1,e2;
    rep(i,n-1){
        e1.push_back(0);
        e2.push_back(i+1);
    }
    int nokori = (n-1)*(n-2)/2-K;
    rep(i,n-1)rep(j,i){
        if(nokori==0)break;
        e1.push_back(i+1);
        e2.push_back(j+1);
        --nokori;
    }
    int dist[n][n];
    rep(i,n)rep(j,n)dist[i][j]=inf;
    rep(i,n)dist[i][i]=0;
    rep(i,e1.size()){
        dist[e1[i]][e2[i]]=1;
        dist[e2[i]][e1[i]]=1;
    }
    rep(i,n)rep(j,n)rep(k,n){
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
    }
    int cnt = 0;
    rep(i,n)rep(j,n){
        if(dist[i][j]==2)++cnt;
    }
    assert(cnt==2*K);
    cout<<e1.size()<<endl;
    rep(i,e1.size()){
        cout<<e1[i]+1<<" "<<e2[i]+1<<endl;
    }
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int tmp=0;
    long long ans=0;
    for (int i=0; i<N; i++){
        int A;
        cin >> A;
        if (A==0){
            tmp=0;
            continue;
        }
        A+=tmp;

        ans+=A/2;
        tmp=A%2;
    }
    cout << ans << '\n';
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int L[N];
	
	rep(i, N)
		cin >> L[i];
		
	sort(L, L+N);
	
	int sum = 0;
	rep(i, N-1)
		sum += L[i];
		
	if(L[N-1] < sum)
		cout << "Yes";
	else
		cout << "No";
	
	return 0;
}

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

int main() {
    int N; cin >> N;
    map<int, int> D;
    rep(i,N) {
        int d; cin >> d;
        D[d]++;
    }
    vector<int> D2(100001,0);
    int prev = 0;
    for (auto x : D) {
        int d = x.first;
        for (int i = prev + 1; i < d; i++) D2[i] = D2[prev];
        D2[d] = D2[prev] + x.second;
        prev = d;
    }


    int res = 0;
    for (int i = 0; i < 100001; i++) {
        if (D2[i] == N/2) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 3584
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 2000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[15][15];
int ans,a[15],b[15],n,m,k;

inline bool jud()
{
	int tmp=0;
	rep(i,1,n) rep(j,1,m)
	{
		if(s[i][j]=='#'&&a[i]&&b[j]) tmp++;
	}
	if(tmp==k) return true; return false;
}

inline void dfs2(int u)
{
	if(u==m+1) {if(jud()) ans++; return;}
	b[u]=0; dfs2(u+1);
	b[u]=1; dfs2(u+1);
}

inline void dfs1(int u)
{
	if(u==n+1) {dfs2(1); return;}
	a[u]=0; dfs1(u+1);
	a[u]=1; dfs1(u+1);
}

int main()
{
	n=read(); m=read(); k=read(); rep(i,1,n) scanf("%s",s[i]+1);
	dfs1(1); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3716
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[][] points = new int[n+1][3];
		for(int i=1;i<=n;i++){
		    points[i][0] =scn.nextInt();
		    points[i][1] =scn.nextInt();
		    points[i][2] =scn.nextInt();
		}
		// System.out.println(maxHappiness(1,points,-1));
		int[][] memo = new int[n+1][3];
		System.out.println(maxHappiness_memoized(1,points,-1,memo));

	}


    public static int maxHappiness_memoized(int day, int[][] points , int activityOnPrevDay,int[][] memo) {
    		if(day==points.length)return 0;
      		if(activityOnPrevDay!=-1 && memo[day][activityOnPrevDay]!=0)return memo[day][activityOnPrevDay];
    		int ans = Integer.MIN_VALUE;
    		for (int i = 0; i < 3; i++) {
    			if (i != activityOnPrevDay) {
    				int ca = points[day][i] + maxHappiness_memoized(day + 1, points, i,memo);
    				ans = Math.max(ans, ca);
    			}
    		}
    		if(activityOnPrevDay!=-1)
    		    memo[day][activityOnPrevDay]=ans;
    		return ans;
    }
}


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

int main()
{
    int h;
    int w;
    while(1)
    {
        cin>>h>>w;
        if(h==0&&w==0)break;
        for(int i=0;i<h; i++)
        {
            for(int s=0; s<w; s++)
            {
                cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=100050;
int n,m,k;
int fa[maxn];
ll ans[maxn],temp[maxn],size[maxn];
PII mp[maxn],mmp[maxn];
int get(int x){if(x!=fa[x]) fa[x]=get(fa[x]); return fa[x];}
void merge(int x,int y)
{
	x=get(x),y=get(y);
	if(x==y) return ;
	fa[x]=y;
	size[y]+=size[x];
}
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++) fa[i]=i,size[i]=1;
	for(int i=1;i<=m;i++)
	{
		int x,y;read(x),read(y);
		merge(x,y);
		mp[i]=make_pair(x,y);
	}
	for(int i=1;i<=k;i++)
	{
		int x,y;read(x),read(y);
		mmp[i]=make_pair(x,y);
	}
	for(int i=1;i<=m;i++)
	{
		int x=mp[i].first,y=mp[i].second;
		if(get(x)==get(y)) ans[x]--,ans[y]--;
	}
	for(int i=1;i<=k;i++)
	{
		int x=mmp[i].first,y=mmp[i].second;
		if(get(x)==get(y)) ans[x]--,ans[y]--;
	}
	for(int i=1;i<=n;i++)
	{
		ans[i]+=size[get(i)]-1;
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll as[1000000]={0};
bool v[1000000]={0};
vector<ll> arr[200000];
void dfs(ll s)
{ v[s]=true;
   for(auto it=arr[s].begin();it!=arr[s].end();++it)
   {
       if(!v[*it])
       {
           dfs(*it);
       }
       as[s]=max(as[*it]+1,as[s]);
   }
}
int main()
{
  ll n,m;
  cin>>n>>m;
  ll a,b;
  for(ll x=0;x<m;x++)
  {   cin>>a>>b;
      arr[a].push_back(b);}
  for(int x=1;x<=n;x++)
  {
      if(!v[x])
        dfs(x);
  }
  ll ans=0;
  for(int x=0;x<=n;x++)
    ans=max(ans,as[x]);
    cout<<ans<<endl;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int n, a=0, b = 0;
  cin >> n;
  vector<int> card(n,0);

  for(int i = 0; i < n; i++){
      cin >> card[i];
  }
  sort(card.begin(), card.end());
  int i=n-1;
  while(i>=0){
      a+=card[i];
      i--;
      b+=card[i];
      i--;
  }

  cout << a-b << endl;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int x[5];
	for(int i=0;i<5;i++)cin>>x[i];
	for(int i=0;i<5;i++)if(x[i]==0)
	{
		cout<<i+1<<endl;
		break;
	}
	return 0;
}

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

int n;
int color;

signed main()
{
	while (true) {
		cin >> n;
		if (n == 0) break;

		vector<pair<int, int> > vpii;
		for (int i=1; i<=n; i++) {
			cin >> color;
			if (i == 1) {
				vpii.push_back(make_pair(color, 1));
				continue;
			}
			if (i % 2 == 0) {
				//??¶??°??????
				if (vpii[vpii.size()-1].first == color) {
					vpii[vpii.size()-1].second += 1;
				} else {
					vpii[vpii.size()-1].first = color;
					vpii[vpii.size()-1].second += 1;
					if (vpii.size() >= 2 && vpii[vpii.size()-2].first == color) {
						vpii[vpii.size()-2].second += vpii[vpii.size()-1].second;
						vpii.pop_back();
					}
				}
			} else {
				//?\???°??????
				if (vpii[vpii.size()-1].first == color) {
					vpii[vpii.size()-1].second += 1;
				} else {
					vpii.push_back(make_pair(color, 1));
				}
			}
		}

		int ans = 0;
		rep(i,vpii.size()) {
			//printf("color = %d, num = %d\n", vpii[i].first, vpii[i].second);
			if (vpii[i].first == 0) {
				ans += vpii[i].second;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3084
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    long long n,k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i=0; i<n; i++)cin >> a[i];
    long long x=0,count=0,sum=0,base=1,ans=0;
    while(base*2<=k)base*=2;
    for(long long j=base; j>0; j/=2){
        if(x+j>k)continue;
        count=0;
        for(long long i=0; i<n; i++){
            if(a[i]&j)count++;
        }
        if(count*2<n)x+=j;
    }
    cerr << base << " " << x << endl;
    for(int i=0; i<n; i++)sum+=a[i]^x;
    ans=sum;
    sum=0;x=0;
    //貪欲回避
    base/=2;
    for(long long j=base; j>0; j/=2){
        if(x+j>k)continue;
        count=0;
        for(long long i=0; i<n; i++){
            if(a[i]&j)count++;
        }
        if(count*2<n)x+=j;
    }
    cerr << x << endl;
    for(int i=0; i<n; i++)sum+=a[i]^x;
    cout << max(ans,sum) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    set<int> P;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        P.insert(a);
    }
    cout<<P.size()<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] cs = s.toCharArray();

        int x = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (cs[i] == 'I') {
                x++;
            } else {
                x--;
            }

            max = Math.max(x, max);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 22612