akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main() {
	long long N;
	cin >> N;
	vector<pair<int, int>> A(N + 1);
	for (int i = 0; i < N; i++) {
		int AI;
		cin >> AI;
		A.at(i + 1).first = AI;
		A.at(i + 1).second = i + 1;
	}
	sort(A.begin(), A.end());
	for (int i = 0; i <= N; i++) {
		if (A.at(i).first == 0) continue;
		cout << A.at(i).second << " ";
	}
	cout << endl;
}

Measured memory_bytes: 4040
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())

    ans = []

    def solve(s, n):
        if n == N:
            ans.append(s)
            return

        for i in range(len(set(s)) + 1):
            solve(s + (chr(ord('a') + i)), n + 1)

    solve("a", 1)
    ans.sort()
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12656
#include<stdio.h>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int A,P;
  cin>>A>>P;
  P+=3*A;
  A=P/2;
  cout<<A;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        string s;
        cin >> s;
        if(s=="Sunny"){
            cout << "Cloudy" << endl;
            return 0;
        }
        if(s=="Cloudy"){
            cout << "Rainy" << endl;
            return 0;
        }
        cout << "Sunny" << endl;
        return 0;
}

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

int main(void) {
  ll N;
  cin >> N;
  vector<ll> H(N);
  REP(i, 0, N) cin >> H[i];

  const ll INF = 1LL << 60;
  vector<ll> dp(N, INF);
  dp[0] = 0;

  REP(i, 0, N) {
    if (i + 1 < N) {
      dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]));
    }
    if (i + 2 < N) {
      dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]));
    }
  }

  cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mp make_pair
#define mod 1000000007
#define qmod 998244353
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;
const ll LINF = LLONG_MAX;

int main(){
	ll a[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	ll n;
	cin>>n;
	ll b[n];
	for(ll i=0;i<n;i++){
		cin>>b[i];
	}
	bool ok[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			ok[i][j]=false;
			for(int k=0;k<n;k++){
				if(a[i][j]==b[k])
					ok[i][j]=true;
			}
		}
	}
	string res = "No";
	for(int i=0;i<3;i++){
		if(ok[i][0]&&ok[i][1]&&ok[i][2])
			res = "Yes";
	}
	for(int i=0;i<3;i++){
		if(ok[0][i]&&ok[1][i]&&ok[2][i])
			res = "Yes";
	}
	if(ok[0][0]&&ok[1][1]&&ok[2][2])
		res="Yes";
	if(ok[0][2]&&ok[1][1]&&ok[2][0])
		res = "Yes";
	cout<<res<<endl;

	


}

Measured memory_bytes: 256
package main

import (
  "fmt"
  "sort"
  "strings"
)

func contains_num(sn []string, s string) int{
  count := 0
  for _,e := range sn {
    if e == s {
      count++
    }
  }

  return count
}
func main() {
  var n int
  var base string
  sorted_strings := make(map[string]int)

  fmt.Scan(&n)
  count := 0
  for i:=0; i<n; i++ {
    fmt.Scan(&base)
    ss := strings.Split(base, "")
    sort.Strings(ss)
    s := strings.Join(ss, "")
    existed_num, ok := sorted_strings[s]
    if ok {
      count += existed_num
      sorted_strings[s]++
    } else {
      sorted_strings[s] = 1
    }
  }

  fmt.Println(count)
}


Measured memory_bytes: 12288
// AOJ 0397: Common-Prime Sort
// 2019.2.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX 100005
int N;
int a[MAX], b[MAX];
char f[MAX];

char notPrime[MAX] = { 1,1,0,0,1 };			// zero: if prime 
void sieve(int max)
{
	int i, j, b = (int)sqrt(max);
	for (i = 2; i < max; i += 2) notPrime[i] = 1;
	for (i = 3; i <= b; i += 2) {
		if (!notPrime[i]) {
			for (j = i * i; j < max; j += i) notPrime[j] = 1;
		}
	}
}

int cmp(const void *a, const void *b)
{
	return *(int *)a - *(int *)b;
}

int main()
{
	int i, j, k, max;

	N = in();
	max = 0;  for (i = 0; i < N; i++) {
		a[i] = b[i] = k = in();
		f[k] = 1;
		if (max < k) max = k;
	}
	qsort(b, N, sizeof(int), cmp);

	sieve(++max);
	for (i = N - 1; i >= 0; i--) {
		if (!notPrime[b[i]] && a[i] != b[i]) {
			for (j = b[i] << 1; j < max; j += b[i]) if (f[j]) break;
			if (j >= max) { puts("0"); return 0; }
		}
	}
	puts("1");
	return 0;
}


Measured memory_bytes: 2856
use proconio::marker::Chars;
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [Chars; n],
    }
    let mut hmap = HashMap::new();
    for item in "abcdefghijklmnopqrstuvwxyz".chars() {
        hmap.insert(item, 100);
    }

    for char_s in s {
        let mut hmap_tmp = HashMap::new();
        for c in &char_s {
            *hmap_tmp.entry(c).or_insert(0) += 1;
        }

        for item in "abcdefghijklmnopqrstuvwxyz".chars() {
            match hmap_tmp.get(&item) {
                Some(v) => {
                    *hmap.entry(item).or_insert(-1) = std::cmp::min(*v, *hmap.get(&item).unwrap());
                }
                None => {
                    hmap.insert(item, 0);
                }
            }
        }
    }

    let mut ans = Vec::new();
    for (key, val) in hmap {
        for _ in 0..val {
            if val != 100 && val != 0 {
                ans.push(key);
            }
        }
    }
    ans.sort();
    println!("{}", ans.iter().collect::<String>());
}


Measured memory_bytes: 2160
#include <iostream>

using namespace std;

int main()
{
    int n,h;
    int m = 0;
    int a[21]={};
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        int cnt = 0;
        cin>>h;
        a[i] = h;
        for(int j = 0;j < i;j ++)
        {
            if(a[i]>=a[j])
                cnt++;
            else
                break;
        }
        if(cnt >= i)
            m++;

    }
    cout<<m;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug = false;
            int itemCount = int.Parse(Reader.ReadLine());

            long[] items = Reader.ReadLine().Split(' ').Select(a=>long.Parse(a)).OrderByDescending(a=>a).ToArray();

            long ans = 0;
            for(int i=0; i<itemCount; i++) {
                ans+=items[i*2+1];
            }
            Console.WriteLine(ans);

        }



        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"



2
5 2 8 5 1 5






";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 52872
import kotlin.math.min

fun main() {
//    val builder = StringBuilder()

    val n = readInputLine().toInt()

    val aArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    if (n == 0) {
        if (aArr[0] != 1L) {
            println(-1)
        } else {
            println(1)
        }
    } else {
        if (aArr[0] != 0L) {
            println(-1)
            return
        }

        val minArr = LongArray(n + 1)
        val maxArr = LongArray(n + 1)

        minArr[n] = aArr[n]
        maxArr[n] = aArr[n]

        for (i in n - 1 downTo 0) {
            minArr[i] = (minArr[i + 1] + 1L) / 2L + aArr[i]
            maxArr[i] = maxArr[i + 1] + aArr[i]
        }

        val ans = LongArray(n + 1)
        ans[0] = 1L
        var usable = 1L

        for (i in 1..n) {
            if (usable * 2L < minArr[i]) {
                println(-1)
                return
            }
            ans[i] = min(usable * 2L, maxArr[i])
            usable = ans[i] - aArr[i]
        }

        println(ans.sum())
    }

//    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 57164
import sys

N = int(sys.stdin.readline().strip())

def factorization(n):
    arr = []
    temp = n
    # sqrtまで
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    """
    if arr == []:
        arr.append([n, 1])
    """
    return arr

# 素因数とその出現回数
factors = {}
for i in range(1, N+1):
    tmp = factorization(i)
    # print(tmp)
    for factor, count in tmp:
        if factor not in factors:
            factors[factor] = 0
        factors[factor] += count
# print(factors)

ans = 1
for factor, count in factors.items():
    ans *= (count + 1)
    ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 41708
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= 3500; i++) {
        for (int j = 1; j <= 3500; j++) {
            double k = (double)n * i * j / (4.0 * i * j - n * i - n * j);
            if (k > 0 && fabs(k - (long)k) < 1e-8) {
                printf("%d %d %ld\n", i, j, (long)k);
                return 0;
            }
        }
    }
}


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

int n;
int a[100005];
bool allzero=true;; //all 0s//
map <int, int> mint;
vector < pair<int, int> > vpair;

bool sortpairs(pair <int, int> a, pair <int, int> b)
{
    if (a.first<b.first)
    {
        return true;
    }

    return false;
}

int main()
{
    cin>>n;

    for (int i=1; i<=n; i++)
    {
        cin>>a[i];
        if (a[i]!=0)
        {
            allzero=false;
        }
    }

    if (allzero)
    {
        cout<<"Yes"<<endl;
        return 0;
    }

    for (int i=1; i<=n; i++)
    {
        mint[a[i]]++;
    }

    for (auto keyvalue : mint)
    {
        vpair.push_back(make_pair(keyvalue.first, keyvalue.second));
    }

    sort(vpair.begin(), vpair.end(), sortpairs);

    if (vpair.size()==2)
    {
        if (vpair[0].second==n/3 && vpair[1].second==2*n/3) //vpair[0] is expected to be 0//
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    if (vpair.size()==3)
    {
        if (vpair[0].second==n/3 && vpair[1].second==n/3 && vpair[2].second==n/3)
        {
            if ((vpair[0].first^vpair[1].first^vpair[2].first)==0)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;
}

Measured memory_bytes: 5372
#include <stdio.h>
int main(void){
    int in;
    int h,m,s;
    scanf("%d",&in);
    
    h = in / 3600;
    in %= 3600;
    
    m =in / 60;
    in %= 60;
    
    s =in;
    
    printf("%d:%d:%d\n",h,m,s);
  
    }
    // Your code here!


Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


int main(){
  
  int n;
  cin>>n;
  long long x[n];
  REP(i,n){
    cin>>x[i];
  }
  long long ans = 1;
  long long cnt = 0;
  stack<long long> s;
  long long temp;
  REP(i,n){
    if(x[i]>=2*(long long)s.size()+1){
      s.push(x[i]);
    }else{
      temp = 1 + s.size();
      ans *= temp;
      ans = mod(ans);
      cnt++;
    }
  }
  
  long long rest = (long long)n - cnt;
  REP(i,rest){
    ans *= (rest - (long long)i);
    ans = mod(ans);
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
k,s = map(int,input().split())
counter = 0

for x in range(k+1):
    if s-x > 2*k:
        continue
    for y in range(k+1):
        if s-x-y > k or s-x-y < 0:
            continue
        else:
            counter += 1
            
print(counter)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define MAX 510000
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    vl p(n);
    vl index(n+1);
    rep(i,n) {
        cin >> p[i];
        index[p[i]] = i;
    }
    multiset<ll> se;
    se.insert(n);
    se.insert(n);
    se.insert(-1);
    se.insert(-1);
    ll ans = 0;
    for(ll i=n; i>=1; i--){
        ll r,R,l,L;
        ll t = index[i];
        auto itr = se.lower_bound(t);
        r = *itr;
        itr++;
        R = *itr;
        itr--; itr--;
        l = *itr;
        itr--;
        L = *itr;
        ans += i * ((r-t)*(l-L) + (R-r)*(t-l));
        se.insert(index[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int a,b,k;


int main(){
  int ans=0;
  cin >> a>>b>>k;
  int t=101;
  for(int i=0;i<k;){
    
    t--;
    if (t==0)
      break;
    
    if (a%t==0){
      if (b%t==0){
        i++;
      }
    }
  }
  
  ans=t;


  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define true 1
#define false 0
int solve(int,int);
int n, q, *A, *m;

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

  scanf("%d",&q);
  m = (int *)malloc(q * sizeof(int));
  for(i = 0 ; i < q ; i++) scanf("%d",&m[i]);

  for(i = 0 ; i < q ; i++){
    if(solve(0,m[i]) == true) printf("yes\n"); 
    if(solve(0,m[i]) == false) printf("no\n"); }

  free(A);
  free(m);

  return 0;
}

int solve(int i, int m)
{
  int res1, res2, res;
  
  if(m == 0) return true;
  
  if(i >= n) return false;

  res1 = solve(i + 1, m);
  res2 = solve(i + 1, m-A[i]);

  if(res1 == true || res2 == true){
    if(res1 == true) res = res1;
    if(res2 == true) res = res2;
    return res; }
  else{
    res = false;
    return res; }
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e5,mod=1e9+7 ;


int main ()
{
    FASTIO;
    long double n , m;
    cin >> n >> m ;
    m *= 1000;
    long double ans = n*m;
    ll res = ans/1000;
    cout << res << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 3704
#include <stdio.h>

int main(void) {
	char we[][12]={"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	int x, y, i, k;
	
	while(1){
		scanf("%d %d", &x, &y);
		
		if(x==0 && y==0)
		break;
		
		int sum=y;
		
		for(i=1;i<x;i++){
			if(i==2)
			sum+=29;
			
			if(i==4 || i==6 || i==9 || i==11)
			sum+=30;
			
			if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12)
			sum+=31;
		}
		
		k=sum%7;
		
		printf("%s\n",we[k]);
		
	}
	
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  cin >>n;
  vector <ll> a,b,c;
  for(ll i=0;i<n;i++) {
    cin >>k;
    a.push_back(k);
  }
  for(ll i=0;i<n;i++) {
    cin >>k;
    b.push_back(k);
  }
  for(ll i=0;i<n;i++) {
    cin >>k;
    c.push_back(k);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  ll ans=0,s1=0,s2=0;
  for(ll i=0;i<n;i++){
    ll k=b[i];
    s1=lower_bound(a.begin(),a.end(),k)-a.begin();
    s2=upper_bound(c.begin(),c.end(),k)-c.begin();
    ans+=(n-s2)*s1;
  }

  cout <<ans<<endl;
}


Measured memory_bytes: 3316
N,K= map(int,input().split())
x=[0]*N
y=[0]*N
z=[0]*N
for i in range(N):
    x[i],y[i] = map(int,input().split())
    z[i] = (x[i],y[i])
    
ans=float("inf")
for s in x:
    for t in x:
        for u in y:
            for v in y:
                cnt=0
                for zz in z:
                    if s<= zz[0]<=t and u<=zz[1]<=v:
                        cnt +=1
                if cnt >=K:
                    tmp = (t-s)*(v-u)
                    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 74080
def btc2jpy(x):
    return 380000 * x


N = int(input())
jpy = 0
btc = 0
for i in range(N):
    x, u = input().split()
    x = float(x)
    if u == "JPY":
        jpy += x
    else:
        btc += x

result = jpy + btc2jpy(btc)
print(result)


Measured memory_bytes: 2940
import collections
N, K = map(int, input().split())
A = list(map(int, input().split()))
table = collections.defaultdict(int)

ans = 0
s = [0]*(N+1)
a = set()
for i in range(N):
    s[i+1] = s[i]+A[i]

s = [(s[i]-i) % K for i in range(N+1)]
for i in range(N+1):
    ans += table[s[i]]  # i番目まで取る組み合わせの数
    table[s[i]] += 1
    if i >= K-1:
        # Kで割ったあまりがKを超えることはないので、期限切れのものを引く
        table[s[i-K+1]] -= 1

print(ans)


Measured memory_bytes: 42120
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.Scanner;

/**
 *
 * @author arvin
 */
public class Main {
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        sc.nextLine();
        int a[]=new int[n];
        long dp[]=new long[n+5];
        String abc[]=sc.nextLine().split(" ");
        for(int i=0;i<n;i++)
           a[i]=Integer.parseInt(abc[i]);
        
        dp[n-1]=0;
        for(int i=n-2;i>=0;i--)
        {
            if(i+2==n)
                dp[i]=Math.min(dp[i+1]+Math.abs(a[i]-a[i+1]),dp[i+2]+Math.abs(a[i]-a[i+1]));
            else
                dp[i]=Math.min(dp[i+1]+Math.abs(a[i]-a[i+1]),dp[i+2]+Math.abs(a[i]-a[i+2]));
        }
        System.out.println(dp[0]);
    }
}


Measured memory_bytes: 38284
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 collections import Counter

def main():
    N, M = LI()
    XY = []
    for _ in range(M):
        XY.append(LI_())
    balls = [1] * N
    exp = set([0])
    for x, y in XY:
        balls[x] -= 1
        balls[y] += 1
        if x in exp:
            exp.add(y)
            if balls[x] == 0:
                exp.remove(x)
    ans = len(exp)
    return ans

print(main())

Measured memory_bytes: 28456
from collections import deque

n, m = map(int, input().split())

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

    g[a-1].append(b-1)
    g[b-1].append(a-1)

d = [-1] * n
d[0] = 0
b = [[] for _ in range(n)]
q = deque([0])
while q:
    v = q.popleft()
    for e in g[v]:
        if d[e] == -1:
            d[e] = d[v] + 1
            b[e].append(v)
            q.append(e)

if -1 in d:
    print("No")
else:
    print("Yes")
    for i in range(1, n):
        print(b[i][0]+1)


Measured memory_bytes: 44768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int x, a, b; cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    } else {
        cout << "B" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 21
int main() {
	int i;
	char s[SIZE] = "";
	scanf("%20s", s);
	for (i = 20; i >= 0; i--) {
		if (s[i] != '\0')
			printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;
const ll INF = 1LL<<50;

int main(){

int N,K;
cin>>N>>K;
ll h[N+1];
rep3(i,N){
    cin>>h[i];
}
ll dp[N+1];
dp[1]=0;
rep4(i,2,N){
    dp[i]=INF;
    rep4(j,max(i-K,(ll)1),i-1){
        dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));

    }

}
cout<<dp[N]<<endl;


return 0;
}

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

using namespace std;

 int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    string s;

    int k;
    cin>>k;

    cin>>s;
    if(k<s.size()){
    for(int i=0;i<k;i++){
        cout<<s[i];
    }cout<<"...";}
    else{
        for(int i=0;i<s.size();i++){
        cout<<s[i];
    }
    }
 return 0;

 }

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

int main()
{
	char s[150],t[150],m[150];
	int i,j,k;
	scanf("%s %s",s,t);
	strcpy(m,s);
	
	k = strlen(s);
	int l = 2;
	while(1)
	{
		j = s[k-1];
		for(i=1;i<k;i++)
		{
			s[k-i] = s[k-i-1];
			
		}
		s[0] = j;
		
		if(strcmp(s,t) == 0) {
			printf("Yes");
			break;
		}
		else if(strcmp(s,m) == 0)
		{
			printf("No");
			break;
		}
		 
	}
	
}

Measured memory_bytes: 3780
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	long long a,b,c,k;
	cin >> a >> b >> c >> k;
	if(a>=k){
		cout << k << endl;
		return 0;
	}else if(a+b>=k){
		cout << a << endl;
		return 0;
	}else if(a+b+c>=k){
		cout << a-(k-a-b) << endl;
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	if(n==1){
		cout<<"Yes"<<endl;
		cout<<2<<endl;
		cout<<1<<" "<<1<<endl;
		cout<<1<<" "<<1<<endl;
		return 0;
	}
	if(n==2){
		cout<<"No"<<endl;
		return 0;
	}
	int k=1;
	while(k*(k-1)/2<n) k++;
	if(k*(k-1)/2>n){
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	vector<int> v[10000];
	v[0].push_back(1);
	v[0].push_back(2);
	v[1].push_back(2);
	v[1].push_back(3);
	v[2].push_back(1);
	v[2].push_back(3);
	int c=4;
	for(int i=4; i<=k; i++){
		int c1=c;
		for(int j=0; j<i-1; j++){
			v[i-1].push_back(c);
			c++;
		}
		for(int j=0; j<i-1; j++){
			v[j].push_back(c1);
			c1++;
		}
	}
	cout<<k<<endl;
	for(int i=0; i<k; i++){
		cout<<v[i].size()<<" ";
		for(int j=0; j<v[i].size()-1; j++) cout<<v[i][j]<<" ";
		cout<<v[i][v[i].size()-1]<<endl;
	}

    return 0;
}

Measured memory_bytes: 2560
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort()
X = [XH[i][0] for i in range(N)]
ans = 0
res = 0
from bisect import bisect_left
cnt = [0]*(N+1)
for i in range(N):
    x, h = XH[i]
    res-=cnt[i]
    h-=res
    if h<=0:
        continue
    n = ((h-1)//A+1)
    j = bisect_left(X, x+D*2+1)
    cnt[j]+=n*A
    res += n*A
    ans+=n
print(ans)
    





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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    int N, K;
    cin >> N >> K;
    int res = 1;
    while (N / K > 0) {
        N /= K;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
(let ((a1 (read))
      (a2 (read))
      (a3 (read)))
  (princ (min (+ (abs (- a1 a2)) (abs (- a2 a3)))
              (+ (abs (- a2 a3)) (abs (- a3 a1)))
              (+ (abs (- a3 a1)) (abs (- a1 a2)))
              (+ (abs (- a3 a2)) (abs (- a2 a1)))
              (+ (abs (- a2 a1)) (abs (- a1 a3)))
              (+ (abs (- a1 a3)) (abs (- a3 a2))))))

Measured memory_bytes: 14056
N = input()
word = [["x"],["x"],["x"]]
for i in range(3):
    inp = input()
    word[i] = list(inp)

X = 0
for i in range(int(N)):
    _count = 0
    for j in range(2):
        for k in range(j+1,3):
            if word[j][i] == word[k][i]:
                _count += 1
    if _count == 1:
        count = 1
    elif _count == 0:
        count = 2
    else:
    	count = 0
    X += count



print (X)



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

using namespace std;

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

Measured memory_bytes: 7996
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	ll x,y;
	cin >> x >> y;

	ll ans=0;
	ll tmp=x;
	while(tmp<=y){
		ans++;
		tmp*=2;
	}
	cout << ans << endl;
	return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			var inputArray = retreiveStringArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
			var K = inputArray[1];

	


			//答えの出力
			var ans = K+N;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// 同じ手を出せないことによって生じる損失点数
		/// </summary>
		/// <param name="K"></param>
		/// <param name="point"></param>
		/// <param name="jankenList"></param>
		/// <returns></returns>
		private static long calLossPoint(long K, long point, HashSet<long> jankenList) {

			var changeList = new HashSet<long>();//K番先に同じ手がある場合、書き換える。書き換えた番号を覚えておくリスト
			var count = 0;
			foreach (var r in jankenList) {

				if (changeList.Contains(r)) {
					continue;
				}

				if (jankenList.Contains(r + K)) {
					count++;
					changeList.Add(r + K);
				}
			}
			return point * count;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 25784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

struct query{
  int type;//0=empty, 1=add ,2=set
  ll value;
  query(int a=0,ll b=0):type(a),value(b) {}
};

#define SIZE (1<<18)

ll INF=(1LL<<60);


struct segtree{
  query s[SIZE*2];
  ll t[SIZE*2];// sum-add
  ll u[SIZE*2];// min-set

  void init(){
    for(int i=0;i<SIZE*2;i++){
      s[i]=query();
    }
  }
  
  void func(int k,int l,int r,query q){
    if(q.type==1){
      if(s[k].type==0)s[k]=q;
      else s[k].value+=q.value;
      t[k]+=q.value*(r-l);
      u[k]+=q.value;
    }
    if(q.type==2){
      s[k]=q;
      t[k]=q.value*(r-l);
      u[k]=q.value;
    }
  }

  void compute(int k,int l,int r){
    query q=s[k];
    s[k]=query();
    if(q.type==0||r-l==1)return;
    int m=(l+r)/2;
    func(k*2+1,l,m,q);
    func(k*2+2,m,r,q);
  }

  void Update(int a,int b,query x,int k=0,int l=0,int r=SIZE){
    if(b<=l || r<=a)return;
    compute(k,l,r);
    if(a<=l && r<=b){
      func(k,l,r,x);
    }else{
      int m=(l+r)/2;
      Update(a,b,x,k*2+1,l,m);
      Update(a,b,x,k*2+2,m,r);
      t[k]=t[k*2+1]+t[k*2+2];
      u[k]=min(u[k*2+1],u[k*2+2]);
    }
  }

  // 1=add, 2=min
  ll Dfs(int type,int a,int b,int k=0,int l=0,int r=SIZE){
    if(b<=l || r<=a){
      if(type==1)return 0; //add
      if(type==2)return INF; // min
    }
    compute(k,l,r);
    if(a<=l && r<=b){
      if(type==1)return t[k];
      if(type==2)return u[k];
    }else{
      int m=(l+r)/2;
      ll lv=Dfs(type,a,b,k*2+1,l,m);
      ll rv=Dfs(type,a,b,k*2+2,m,r);
      if(type==1)return lv+rv; // add
      if(type==2)return min(lv,rv); // min
    }
  }

  ll Getsum(int a,int b){
    return Dfs(1,a,b);
  }

  ll Getmin(int a,int b){
    return Dfs(2,a,b);
  }
  
};

int N,Q,A,B;
int x[200001];

segtree T,U;

void pr(segtree &T){
  for(int i=0;i<10;i++){
    ll val=T.Getmin(i,i+1);
    if(val>=INF)cout<<"INF ";
    else cout<<val<<' ';
  }
  cout<<endl;
}

int main(){

  scanf("%d %d %d %d",&N,&Q,&A,&B);
  for(int i=1;i<=Q;i++){
    scanf("%d",&x[i]);
  }
  
  x[0]=A;
  
  T.Update(0,SIZE,query(2, INF ));
  U.Update(0,SIZE,query(2, INF ));
  
  T.Update(B,B+1,query(2, 0));
  T.Update(B,B+1,query(1, B));
  
  U.Update(B,B+1,query(2, 0));
  U.Update(B,B+1,query(2, SIZE-1-B));

  for(int i=1;i<=Q;i++){

    ll dist=abs(x[i-1]-x[i]);

    
    int p=x[i-1];
    int q=x[i];
    ll target=min( T.Getmin(q,SIZE)-q , U.Getmin(0,q+1)-(SIZE-1-q) );

    T.Update(0,SIZE,query(1,dist));
    U.Update(0,SIZE,query(1,dist));
    
    //    cout<<target<<endl;
    
    T.Update(p,p+1,query(2,target));
    T.Update(p,p+1,query(1,p));
    
    U.Update(p,p+1,query(2,target));
    U.Update(p,p+1,query(1,SIZE-1-p));


  }
  
  ll ans=INF;
  for(int i=0;i<SIZE;i++){
    ll target=T.Getmin(i,i+1)-i;
    ans=min(ans,target);
  }
  printf("%lld\n",ans);
  return 0;
}


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

long long w, h, ans=0;

int main() {
	cin >> w >> h;
	if(w%2==0){
		cout << ((w+1)/2)*h << endl;
	}
    else if(h==1 || w==1){
    	cout << 1 << endl;
    }
	else{
		cout << ((w+1)/2)*h - h/2 << endl;
	}
}

Measured memory_bytes: 256
from statistics import median, median_low, median_high


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
median = median(X)
#F = copy.deepcopy(X)
"""
F = X[:]
F.sort()

median1 = int(N/2 - 1)
median2 = int(N/2) 

if median.is_integer():
    median1 = median
    median2 = median
else:
    median1 = median - 0.5
    median2 = median + 0.5
"""
median1 = median_low(X)
median2 = median_high(X)
   
for i in range(N):
    #print(F, median1, median2)
    
    if X[i] < median:
        ans = median2
    else:
        ans = median1
    print(int(ans))

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] sas = Console.ReadLine().Split(' ');
            long a = long.Parse(sas[0]);
            long b = long.Parse(sas[1]);
            long c;
            long d;
            if (a >= b)
            {
                 c = a;
                d = b;
            }
            else
            {
                c = b;
                d = a;
            }
            long saidaikouyaku = 0;
            while (true)
            {


                if (c % d != 0)
                {
                    c = c % d;
                    if (d % c != 0)
                    {
                        d = d % c;
                    }
                    else
                    {
                        saidaikouyaku =  c;
                        break;
                    }
                }
                else
                {
                    saidaikouyaku = d;
                    break;
                }
            }
            if(saidaikouyaku == 1)
            {
                Console.WriteLine((a * b) );
            }
            else
            {
                Console.WriteLine((a * b) / saidaikouyaku);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;


int main(void){
    
    /*(x,y) = (??????,??????)*/
    int max_w;
    int number;
    int answer = 0;
    int casecounter = 1;
    while(cin >> max_w,max_w)
    {
        int dp[1002][1002] = {0};
        int w[1002] = {0},v[1002] = {0};
        cin >> number;
        for(int i  =1; i<= number;i++)
            scanf("%d%*c%d",&v[i],&w[i]);
        
        for(int j = 1; j<= number;j++)
            for(int k = 0;k<=max_w;k++)
            {
              if(j == 1 && k>=w[j])
                  dp[j][k] = v[j];
              else if(k >= w[j])
                  dp[j][k] = max(dp[j-1][k],v[j]+dp[j-1][k-w[j]]);
              else
                  dp[j][k] = dp[j-1][k];
     
                
            }
        int max = 0;
        for(int i = 1;i<=max_w;i++)
        {
            if(max < dp[number][i])
            {
                answer = i;
                max = dp[number][i];
            }
            
        }
        printf("Case %d:\n",casecounter);
        printf("%d\n",dp[number][answer]);
        printf("%d\n",answer);
        casecounter++;
    }
    return 0;
    
}

Measured memory_bytes: 5164
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;

int len;
ll n;
int dp[17][2],f[17];

int main(){
	int i;
	scanf("%lld",&n);
	while (n){
		f[++len]=n%10;
		n=n/10;
	}
	reverse(f+1,f+1+len);
	dp[1][1]=f[1]; dp[1][0]=f[1]-1;
	for (i=2;i<=len;i++){
		dp[i][1]=dp[i-1][1]+f[i];
		if (dp[i-1][0]>=0) dp[i][0]=dp[i-1][0]+9;
		if (f[i]) dp[i][0]=max(dp[i][0],dp[i-1][1]+f[i]-1);
	}
	printf("%d\n",max(dp[len][0],dp[len][1]));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int a[20], b[20], c[20];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n - 1; ++i) cin >> c[i];

  int count = 0;
  for (int i = 0; i < n; ++i) {
    count += b[a[i] - 1];
    if (i > 0 && a[i] - a[i - 1] == 1) count += c[a[i - 1] - 1];
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
// atcoder abc 176 c 
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long int arr[n],sum=0;
    int i;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    for(i=0;i<n-1;i++){
        if(arr[i]>arr[i+1]){
        sum+=abs(arr[i]-arr[i+1]);//sum of required ladder sum
        arr[i+1]=arr[i];//making the heights equal
        }
    }
    cout<<sum<<endl;

}

Measured memory_bytes: 5172
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

MAX_V = [0]
for t, v in zip(T, V):
    MAX_V[-1] = min(MAX_V[-1], v)
    MAX_V.extend([v] * (2 * t))

REAL_V = [0]
for i in range(len(MAX_V) - 1):
    REAL_V.append(min(REAL_V[-1] + 0.5, MAX_V[i + 1]))

REAL_V[-1] = 0
for i in reversed(range(len(MAX_V) - 1)):
    REAL_V[i] = min(REAL_V[i], REAL_V[i + 1] + 0.5, MAX_V[i])

ans = 0
for i in range(len(MAX_V) - 1):
    ans += ((REAL_V[i] + REAL_V[i + 1]) * 0.5) / 2
print(ans)


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll yen = A * X + B * Y;
    ll m = yen;
    if (X < Y) {
        for (int i = 0; i < X; ++i) {
            yen = yen - A - B + 2 * C;
            m = min(m, yen);
        }
        for (int i = 0; i < Y-X; ++i) {
            yen = yen - B + 2 * C;
            m = min(m, yen);
        }
    } else {
        for (int i = 0; i < Y; ++i) {
            yen = yen - A - B + 2 * C;
            m = min(m, yen);
        }
        for (int i = 0; i < X-Y; ++i) {
            yen = yen - A + 2 * C;
            m = min(m, yen);
        }
    }
    cout << m << endl;
}


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

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      String s = in.nextToken();
      char c = s.charAt(0);
      out.println(c >= 'a' && c <= 'z' ? 'a' : 'A');
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

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

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

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

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

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 32932
from operator import mul
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())

N, M = tuple(li())
Cs = []
for i in range(N):
    n = tuple(li())
    Cs.append(n)
# state:  x, y, z, point
state = [0, 0, 0, 0]
maximum = 0
trans = []
for per in range(8):
    ops = [1 if (per&4)>>2 else -1, 1 if (per&2)>>1 else -1, 1 if per&1 else -1]
    trans.clear()
    for i in range(N):
        trans.append(list(map(mul, Cs[i], ops)))
    trans.sort(key=lambda x: -sum(x))
    maximum = max(maximum, sum(sum(t) for t in trans[:M]))
        

print(maximum)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

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

  string S;
  cin >> S;

  int E[N]={0};
  int W[N]={0};
  int wcnt=0;
  FOR(i,1,N){
    if(S.at(i-1)=='W'){
      wcnt++;
    }
    W[i]=wcnt;
  }
  int ecnt=0;
  for(int i=N-2;i>=0;i--){
    if(S.at(i+1)=='E'){
      ecnt++;
    }
    E[i]=ecnt;
  }

  int MIN = INF;
  REP(i,N){
    MIN = min(MIN,W[i]+E[i]);
  }

  cout << MIN << endl;
}

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

void out_char (int num, string s, char c) {
    if(s.length() == num) {
        //tmp.push_back(s);
        cout << s << endl;
        return;
    }

    for(int i=0; i<c-'a'+1; i++){
        string cs = {char(i+'a')};
        out_char(num, s+cs, c);
    }
    string cs = {char(c+1)};
    out_char(num, s+cs, c+1);

}
int main() {
    int n;
    cin >> n;
    out_char(n, "a", 'a'); // 入力N, 現在の文字列, アルファベットをどこまで使ったか
}

Measured memory_bytes: 1536