akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int N;
    double t;
    cin >> N >> t;
    double result = 0.0;

    rep(i, N) {
        double xi, hi;
        cin >> xi >> hi;
        double candidate = (hi * t) / xi;
        result = max(candidate, result);
    }

    cout << fixed << setprecision(6) << result << endl;
}



Measured memory_bytes: 3296
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        var a = new List<string>(Console.ReadLine().Split(' '))
            .Select(x=>int.Parse(x)).ToList();
        if(a[0]<=a[2]&&a[2]<=a[0]+a[1]){ Console.WriteLine("YES");}
        else{Console.WriteLine("NO");}
    }
}


Measured memory_bytes: 13396
class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right

d = {}
def get_all_depth(t, u, p):
    d[u] = p
    if t[u].right is not None:
        get_all_depth(t, t[u].right, p+1)
    if t[u].left is not None:
        get_all_depth(t, t[u].left, p+1)

h = {}
def get_all_height(t, u):
    left, right = 0, 0
    if t[u].left is not None:
        left = get_all_height(t, t[u].left) + 1
    if t[u].right is not None:
        right = get_all_height(t, t[u].right) + 1
    tmp = max(left, right)
    h[u] = tmp
    return tmp

def get_sibling(t, u):
    par = t[u].parent
    if par is None:
        return -1
    left, right = t[par].left, t[par].right
    if left == u:
        if right is not None:
            return right
    elif left is not None:
        return left
    return -1

n = int(input())
t = {k: Node(None, None, None) for k in range(n)}
for _ in range(n):
    tmp = list(map(int, input().split()))
    if tmp[1] != -1:
        t[tmp[1]].parent = tmp[0] # 親
        t[tmp[0]].left = tmp[1] # 左の子
    if tmp[2] != -1:
        t[tmp[2]].parent = tmp[0] # 親
        t[tmp[0]].right = tmp[2] # 右の子

for node in range(n):
    if t[node].parent is None:
        get_all_depth(t, node, 0)
        get_all_height(t, node)
        break

for node in range(n):
    node_type = "internal node" if t[node].left is not None or t[node].right is not None else "leaf"
    if t[node].parent is None:
        node_type = "root"
        parent = -1
    else:
        parent = t[node].parent
    sibling = get_sibling(t, node)
    deg = 0
    if t[node].left is not None:
        deg += 1
    if t[node].right is not None:
        deg += 1
    print(  f"node {node}: parent = {parent}, sibling = {sibling}, "
            f"degree = {deg}, depth = {d[node]}, height = {h[node]}, {node_type}")


Measured memory_bytes: 5636
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  cin >> N;

  long long a[N];
  long long total = 0;
  long long n_neg = 0;
  long long minimum = 100000000000LL;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
    total += abs(a[i]);
    if (a[i] < 0)
      ++n_neg;
    minimum = min(minimum, abs(a[i]));
  }

  if (n_neg % 2 == 0)
    cout << total << endl;
  else {
    total -= 2 * minimum;
    cout << total << endl;
  }

  return 0;
}

Measured memory_bytes: 1024
class Main
  def self.run
    expressions = read_inputs
    expressions.each {|e| puts e.answer}
  end

  private

  def self.read_inputs
    expressions = []
    while true do
      a, op, b = gets.split(" ")
      break if op == "?"
      expressions << Expression.new(a.to_i, op, b.to_i)
    end
    expressions
  end
end

class Expression
  def initialize(a, op, b)
    @a, @op, @b = a, op, b
  end

  def answer
    case @op
      when "+" then @a + @b
      when "-" then @a - @b
      when "*" then @a * @b
      when "/" then @a / @b
      else ""
    end
  end
end

Main.run

Measured memory_bytes: 8552
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M; cin >> N >> M;
  if(N == 1 && M == 1) cout << 1 << endl;
  else if(N == 1 || M == 1) cout << max(N, M) - 2 << endl;
  else cout << N * M - 2 * (N + M) + 4 << endl;
}

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


int main(){

int n;
cin >> n;
int d[n];
rep(i,n)cin >> d[i];
sort(d,d+n);
int count=1;
rep(i,n-1){
    if(d[i]<d[i+1])count++; 
}
cout << count << endl;
return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
const int MAX = 1000000;
bool prime[1000001];
bool dp[1000001];

void Init(){
	memset(dp, false, sizeof(dp));
	dp[0] = true;
}

void era(){
	prime[0] = prime[1] = false;
	for(int i = 2; i <= MAX; i++){
		if(prime[i]){
			for(int j = i*2; j <= MAX; j+=i) prime[j] = false;
		}
	}
}

int main(){
	int n, limit;
	memset(prime, true, sizeof(prime));
	era();
	while(cin >> n >> limit && ((n!=0)||(limit!=0))){
		Init();
		int maxc = 0;
		for(int i = 1; i <= n; i++){
			int tmp;
			cin >> tmp;
			for(int j = 0; j+tmp <= limit; j++){
				if(dp[j]){
					dp[j+tmp] = true;
					if(prime[j+tmp]&&maxc<j+tmp) maxc = j+tmp; 
				}
			}
		}
		if(!maxc) cout << "NA" << endl;
		else cout << maxc << endl;
	}
	return 0;
}

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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

signed main(void){
  int n;cin >> n;
  if(n%2){
    printf("%lf\n",(double)(n/2+1)/n);
  }else
    printf("%lf\n",0.5);
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    A=[list(map(int,input().split())) for _ in range(2)]
    S=[[0]*(N+1) for _ in range(2)]
    for i in range(2):
        for j in range(N):
            S[i][j+1]=S[i][j]+A[i][j]
    ans=0
    for i in range(N):
        tmp=S[0][i+1]+S[1][-1]-S[1][i]
        ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
using System;
using System.Linq;

class Problem {
    public static double ToRadian(double angle) {
        return Math.PI * angle / 180.0;
    }
    public static void Main() {
        var dat = Console.ReadLine().Split().Select(double.Parse).ToArray();
        Console.WriteLine(0.5 * dat[0] * dat[1] * Math.Sin(ToRadian(dat[2])));
        Console.WriteLine(dat[0] + dat[1] + Math.Sqrt(dat[0] * dat[0] + dat[1] * dat[1] - 2.0 * dat[0] * dat[1] * Math.Cos(ToRadian(dat[2]))));
        Console.WriteLine(dat[1] * Math.Sin(ToRadian(dat[2])));
    }
}


Measured memory_bytes: 9624
#include <stdio.h>

char sieve[1000001];

int main()
{
  int i, j, n, t;
  sieve[0] = sieve[1] = 1;
  for (i = 2; i * i <= 1000000; i++) {
    for (j = i * i; j <= 1000000; j += i) {
      sieve[j] = 1;
    }
  }
  while (scanf("%d", &n) != EOF) {
    t = 0;
    for (i = 1; i <= n; i++) {
      if (sieve[i] == 0) t++;
    }
    printf("%d\n", t);
  }
  return (0);
}

Measured memory_bytes: 1572
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;
const int MOD = 1000000000 + 7;

int main(){
  int n;
  std::cin >> n;

  ll power = 1;
  for (int i = 1; i <= n; i++) {
    power *= i;
    power %= MOD;
  }

  std::cout << power << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static int binarySearch(long Y , long A[]){
		int N = A.length;
		if(A[N - 1] < Y){
			return N;
		}
		if(A[0] >= Y){
			return 0;
		}
		int low = 0; // false
		int high = N - 1; // true
		while(low < high - 1){
			int mid = (low + high) / 2;
			if(A[mid] >= Y){
				high = mid;
			}else{
				low =  mid;
			}
		}
		return high;
	}
	// 幸福度X以上の握手の数
	static long numberOfHandshake(long X , long A[] ){
		int N = A.length;
		long ret = 0;
		for(int i = 0 ; i < N ; ++i){
			ret += N - binarySearch(X - A[i], A);
		}
		return ret;
	}
	static long totalHappiness(long X , long A[]){
		int N = A.length;
		long S[] = new long[N + 1];
		for(int i = 0 ; i < N ; ++i){
			S[i + 1] = S[i] + A[i];
		}
		long ret = 0;
		for(int i = 0 ; i < N ; ++i){
			int idx = binarySearch(X - A[i], A);
			ret += S[N] - S[idx] + (N - idx) * A[i];
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long M = sc.nextLong();
		long A[] = new long[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextLong();
		}
		sc.close();
		Arrays.sort(A);
		long low = 0; // ?
		long high = A[N - 1] * 2 + 1; // true
		while(low < high){
			long mid = (low + high) / 2;
			long c = numberOfHandshake(mid , A);
			if(c <= M){
				high = mid;
			}else{
				low = mid + 1;
			}
		}
		long c = numberOfHandshake(high, A);
		long h = totalHappiness(high, A);
		if(c != M){
			h += (high - 1) * (M - c);
		}
		System.out.println(h);
	}
}


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


void rectangle(int a, int b, int l[]){
	int area = a * b;
	int circumference = 2 * (a + b);
	l[0] = area;
	l[1] = circumference;
}

int main(){
	int width, height;
	int l[2];
	cin >> width >> height;
	rectangle(width, height, l);
	cout << l[0] << ' ' << l[1] << endl;
	return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 100010


int main(){
    IOS;
     
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    multiset<pii>s;
    s.insert({a[n-2],a[n-1]});
    s.insert({a[n-2],a[n-1]});
    ll ans=a[n-1];
    for(ll i=n-3;i>=0;--i){
    	auto it=s.end();it--;
    	pii p=*it; s.erase(it);
    	ans+=p.fi;
    	ll x=p.fi,y=p.se,z=a[i];
    	s.insert({min(y,z),max(y,z)});
    	s.insert({min(x,z),max(x,z)});
    }
    cout<<ans;
     
     
     
    return 0;
}


Measured memory_bytes: 17720
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       a: i32,
       b:i32,
       c:i32,
       mut k:i32,
    }

    let mut ans: i32 = 0;
    let mut d = min(k, a);
    ans += d;
    k -= d;
    d = min(k, b);
    k -= d;
    d = min(k, c);
    ans -= d;

    echo!(ans);
}


Measured memory_bytes: 2112
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int main(){
	int i,j,k,l,m,n;
	while(cin>>n){
		if(n==0) break;
		int mx=0, mn=2000;
		k=0;
		rep(i,n){
			cin >> m;
			mx = max(mx,m);
			mn = min(mn,m);
			k+=m;
		}
		cout << (k-mx-mn)/(n-2) << endl;
	}
}

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

bool check(long long N, long long i){
  while(N%i==0) N /= i;
  if(N%i==1) return true;
  else return false;
}

int main(){
  long long N;
  cin >> N;
  
  if(N==2){
    cout << 1 << endl;
    return 0;
  }
  
  long long ans=2;
  for(long long i=2;i*i<=N-1;i++){
    if((N-1)%i==0){
      if(i*i==N-1) ans++;
      else ans += 2;
    }
  }
  for(long long i=2;i*i<=N;i++){
    if(N%i==0){
      if(check(N,i)) ans++;
      if(i*i!=N) if(check(N,N/i)) ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() {
	string str;
	stack<int> S;
	int a, b;
	
	while(cin >> str){
		if(str == "+"){
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a+b);
		}
		else if(str == "-"){
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(b-a);
		}
		else if(str == "*"){
			a = S.top();
			S.pop();
			b = S.top();
			S.pop();
			S.push(a*b);
		}
		else{
			int num = atoi(str.c_str());
			S.push(num);
		}
	}
	cout << S.top() << endl;
}

Measured memory_bytes: 1200
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main(){
    string str;
    map<char,int> M;
    M['I']=1;M['V']=5;M['X']=10;M['L']=50;M['C']=100;M['D']=500;M['M']=1000;
    while(cin>>str){
        int ans=0;
        for(int i=0;i<str.size();i++){
            if(str.size()==i-1)ans+=M[str[i]];
            else if(M[str[i]]<M[str[i+1]])ans-=M[str[i]];
            else ans+=M[str[i]];
        }
        cout<<ans<<endl;
    }
}

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

int main() {
    int a, b; cin >> a >> b;
    if(a >= 13) cout << b << endl;
    else if(a >= 6) cout << b/2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
bl = [False]*n
now = 1
res = []
while True:
    if bl[now - 1]:
        break
    bl[now - 1] = True
    res.append(now)
    now = a[now - 1]
x = res.index(now)
roop = len(res) - x
if k <= x:
    print(res[k])
else:
    print(res[x + (k-x) % roop])

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

using namespace std;

int main()
{
    int a,b;
    int counter = 0,ans = 1;
    cin >> a >> b;
    while(ans < b)
    {
        --ans;
        ans += a;
        ++counter;
    }
    cout << counter;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  int  a, b, c, d, X, Y;
//  double  c;
//  long long  a, b, c, d, X, Y;
  int D, G;
  //char s[101][101]={};
  char sv[101]={};
  char ss[101]={};
//  char s_temp[101]={};
  char t[12]={};
//  char s[10000000000000000001]={};
  char s[2][100001]={};
  int len=0;
//  int N, M;
//  int A[1000000001]={};
  long long  A[101]={};
//  long int A[1001]={};
  long long  B[101]={};
  long long  C[101]={};
  int i,j,k;
  int flag=0;
  int tmp=0;
  int min=1000;
  int cnt=0;
  double ans=1000;
  int max=0;

  int  Cen_X=0;
  int  Cen_Y=0;
  long long  H=0;
  
  //  int ans=0;
  int str_len=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  int ans_o[1001]={};
  double N[1001]={};
  int ans_e[100001]={};
//  a=0;
//  scanf("%lld %lld", &a, &b);
  scanf("%d %d %d", &a, &b, &c);
//  cnt = strlen(t);
  //printf("%d\n",cnt);
  
//  for(i=0;i<cnt;i++){
//    a=a+(t[cnt-i-1]-'0') * ()(pow(10, i));
//  printf("%d\n",min);
//  }
      
//  if(flag==0)   printf("TLE\n");
  printf("%d\n", (a*b)/2);
  
return 0;
}


Measured memory_bytes: 128
import itertools
n, cs = map(int, input().split())
d = [list(map(int, input().split())) for i in range(cs)]
c = [list(map(int, input().split())) for i in range(n)]
color_count = [[0] * cs for i in range(3)]
for i, j in itertools.product(range(n), repeat=2):
  color_count[(i + j) % 3][c[i][j] - 1] += 1
ans = 10**20
for t in itertools.permutations(range(cs), 3):
  s = 0
  for l in range(3):
    for m in range(cs):
      s += color_count[l][m] * d[m][t[l]]
  ans = min(ans, s)
print(ans)


Measured memory_bytes: 5620
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
const int MAX = 1e5 + 50;

#define ll long long
int a[MAX];
int ans[MAX];
int find(int x){
	if(a[x] == x)return x;
	else {
		int tmp = find(a[x]);
		a[x] = tmp;
		return tmp;
	}
}

void Union(int x,int y){
	int x_h = find(x);
	int y_h = find(y);
	
	if(x_h != y_h)a[x_h] = y_h;
}
int main(){
	
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>ans[i];
		a[i] = i;
	}
		
	int tmp1,tmp2;
	for(int i=0;i<m;i++){
		cin>>tmp1>>tmp2;
		Union(tmp1,tmp2);
	}
	int cnt = 0;
	for(int i=1;i<=n;i++){
		if(find(i)==find(ans[i]))cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n; cin >> n;

	vector<int> v(n), c(n);

	rep(i, 0, n) cin >> v[i];
	rep(i, 0, n) cin >> c[i];

	int ans = 0, x = 0, y = 0;

	rep(i, 0, n) {
		if (v[i] > c[i]) {
			x += v[i];
			y += c[i];
		}
	}

	ans = x - y;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

using int64 = long long;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};

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

  int fac[100001] = {};
  for(int i = 2; i <= 100000; i++) {
    if(fac[i] != 0) continue;
    fac[i] = i;
    for(int j = i + i; j <= 100000; j += i) fac[j] = i;
  }


  UnionFind uf(100001 + N);
  for(int i = 0; i < N; i++) {
    int v = A[i];
    while(fac[v]) {
      uf.unite(fac[v], 100001 + i);
      v /= fac[v];
    }
  }

  vector< int > belong1[200001], belong2[200001];
  for(int i = 0; i < N; i++) {
    belong1[uf.find(i + 100001)].emplace_back(i);
    belong2[uf.find(i + 100001)].emplace_back(A[i]);
  }
  for(int i = 0; i < 200001; i++) {
    sort(begin(belong2[i]), end(belong2[i]));
    for(int j = 0; j < belong1[i].size(); j++) {
      A[belong1[i][j]] = belong2[i][j];
    }
  }

  cout << (int) (is_sorted(A, A + N)) << endl;
}





Measured memory_bytes: 15256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[200005];
int A[200005],B[200005];
ll ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        A[i]=a[i]+i+1;
        B[i]=(a[i]-i-1)*(-1);
        //cout<<A[i]<<" "<<B[i]<<endl;
    }
    sort(A,A+n); sort(B,B+n);
    for(int i=0;i<n;i++){
        ans=ans+(upper_bound(B,B+n,A[i])-lower_bound(B,B+n,A[i]));
    }
    cout<<ans<<endl;
    
    
}


Measured memory_bytes: 5940
/*
 * MIT License
 * 
 * Copyright (c) 2018 comp-prog-jp-library-standard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <iostream>
#include <vector>


/*
 * Sieve of Eratosthenes.
 * Returns a bool array of length (n + 1)
 * representing whether integers <= n are prime or not.
 * if i is a prime, p[i] == true holds.
 * if i is not a prime, p[i] == false holds.
 * header requirement: vector
 */
namespace procon {
std::vector<bool> eratosthenes(int n) {
  std::vector<bool> prime(n + 1);
  for (int i = 2; i <= n; ++i) {
    prime[i] = true;
  }
  for (int i = 2; i * i <= n; ++i) {
    if (not prime[i]) {
      continue;
    }
    for (int j = 2 * i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
} // namespace procon


// @depends_on library/cpp/src/math/eratosthenes.cpp

const int LIMIT = 100000000;

int main(void) {
  int n;
  std::cin >> n;
  std::vector<bool> primes = procon::eratosthenes(LIMIT);
  int count = 0;
  for (int i = 0; i < n; ++i) {
    int element;
    std::cin >> element;
    if (primes[element]) { count++; }
  }
  std::cout << count << std::endl;
}



Measured memory_bytes: 14912
import java.util.*;

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

        Scanner scan = new Scanner(System.in);
		
      	int N = scan.nextInt();
      	int A[] = new int[N];
      	int B[] = new int[N];
      	int C[] = new int[N - 1];
      
		for(int i = 0; i < N; i++){
			A[i] = scan.nextInt();
        }
		for(int i = 0; i < N; i++){
			B[i] = scan.nextInt();
        }
		for(int i = 0; i < N - 1; i++){
			C[i] = scan.nextInt();
        }
      	
      	int sum = 0;
      	for(int i = 0; i < N; i++){
        	sum = sum + B[A[i] - 1];
          	if(i + 1 < N) {
            	if(A[i + 1] - A[i] == 1) {
                	sum = sum + C[A[i] - 1];
                }
            }
        }
     	System.out.println(sum);
    }
}


Measured memory_bytes: 21716
N = int(input())
A = list(map(int, input().split()))

x = 1000000000000000000
res = 1

A.sort(reverse=True)

if A.count(0) > 0:
    print('0')
    exit()

for val in A:
    res = res * val
    if res > x:
        print('-1')
        break
else:
    print(res)


Measured memory_bytes: 21656
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 15 01:01:58 2020

@author: liang
"""
#ゼロパディング＋インデックス
#str(1).zfill(6) + str(a.index(2) + 1).zfill(6)
#index(x) が重い => indexを使わなくて良いようにする

N, M = map(int, input().split())
#d = [list() for _ in range(N)]
dic = dict()
dic2 = dict()
P = list()

#insert O(M)
for i in range(M):
    p, y = map(int,input().split())
    #d[p-1].append(y)
    if p not in dic.keys():
        dic[p] = [y]
    else:
        dic[p].append(y)
    P.append((p,y))

#year sort O(N log N) => 重い　dict使用
#for i in range(N):
#    d[i].sort()
for key in dic.keys():
    dic[key].sort()

for key in dic.keys():
    for i in range(len(dic[key])):
        dic2[dic[key][i]] = i+1
#search O(M)***
for i in range(M):
    p, y = P[i]
    ans = str(p).zfill(6)+str(dic2[y]).zfill(6)
    """
    # zfill 重い？
    ans = ''
    ans += '0'*( 6 - len(str(p))) + str(p)
    #t = dic[p].index(y)+1
    t = dic2[y]
    ans += '0'*( 6 - len(str(t))) + str(t)
    """
    print(ans)

Measured memory_bytes: 45340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	char str[7];
	scanf("%s",str);
	for (int i = 0; i < 3; ++i)
	{
		if(str[i] == '1')	printf("9");
		else printf("1");
	}
	puts("");
  return 0;
}

Measured memory_bytes: 128
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for(int i = 0 ; i < n; i++)
            cin >> a[i];

        int mx = 0;
        for(int i = 1; i < n; i++)
        {
            a[i] += a[i- 1];
            if(i >= k)
                mx = max(mx, a[i] - a[i - k]);
        }
        if(k == n)
            mx = a[n - 1];

        double ans = (mx + k) / 2.0;
        cout << fixed << setprecision(8) << ans << '\n';

    }
    
    return 0;
}



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

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e9 + 7, NMAX = 1e6 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;


signed main() {
    fast_work

    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; ++i) cin >> v[i];

    int answer = 0;

    for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
    for(int k = j + 1; k < n; ++k)
    if(v[i] < v[j] + v[k] && v[j] < v[i] + v[k] && v[k] < v[i] + v[j] && v[i] != v[j] && v[i] != v[k] && v[j] != v[k]) ++answer;

    cout << answer;
}






Measured memory_bytes: 3668
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i<N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[N-1]-a[0]);
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		sc.close();
		if (B / A >= C) {
			System.out.println(C);
		} else {
			System.out.println(B / A);
		}
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll dp[2020][2020];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    REP(i,N){
        cin >> A[i].first;
        A[i].second = i + 1;
    }
    sort(A.rbegin(), A.rend());
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    REP(i,N){
        for(int l=0;l<=i;l++){
            int r = (i - l);
            if(l + 1 <= N && ~dp[l][r]) chmax(dp[l+1][r], dp[l][r] + A[i].first * abs(A[i].second - l - 1));
            if(r + 1 <= N && ~dp[l][r]) chmax(dp[l][r+1], dp[l][r] + A[i].first * abs(A[i].second - (N - r)));
        }
    }
    ll ans = 0;
    REP(i,N+1) chmax(ans, dp[i][N-i]);
    cout << ans << endl;
}


Measured memory_bytes: 35532
hash = {}
gets.to_i.times do
  s = gets
  if hash.has_key?(s) then
    hash[s] += 1
  else
    hash[s] = 1
  end
end

gets.to_i.times do
  s = gets
  if hash.has_key?(s) then
    hash[s] -= 1
  else
    hash[s] = -1
  end
end

max = -10**10
str = ""
hash.each do |key,val|
  if max < val then
    max = val
    str = key
  end
end

if max < 0 then
  puts 0
else
  puts hash[str]
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N, K;
    cin >> N >> K;
    vec<lint> height(N);
    range(i, 0, N) cin >> height.at(i);
    sort(height.begin(), height.end(), greater<lint>());
    cout << accumulate(height.begin(), height.begin() + K, 0LL) << "\n";
}

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

public class Main
{
    public static void main(String[] args) throws IOException
    {
        long Total = Math.abs(readLong());
        long Moves = readLong();
        long AmountOneMove = readLong();

        if (Total / AmountOneMove <= Moves)
        {
            long remainingSteps = Moves - Total / AmountOneMove;
            System.out.println(Math.abs(remainingSteps % 2 == 0 ? Total % AmountOneMove : Total % AmountOneMove - AmountOneMove));
        }
        else
            System.out.println(Total - Moves * AmountOneMove);
    }


    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}

Measured memory_bytes: 32648
n,m = map(int,input().split())
ans = 0
que = []
for i in range(n):
    a = list(map(int,input().split()))
    que.append(a[1::])
for i in range(1,m+1):
    flag = True
    for j in range(n):
        if i not in que[j]:
            flag = False
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 3060
use proconio::{input, fastout};
#[fastout]
fn main() {
    input!{
        a: f64,
        b: f64,
        x: f64,
    }

    if 2.0*x/(a*a) - b > 0.0 {
        println!("{}", (2.0*b/a-2.0*x/(a*a*a)).atan().to_degrees()); 
        return;
    } else {
        println!("{}", (a*b*b/2.0/x).atan().to_degrees());
    }
}


Measured memory_bytes: 2872
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <queue>

using namespace std; 

typedef pair<int,int> P;

int W,H;

//tate[y][x]...(y,x)->(y+1,x)
bool tate[100][100];

//yoko[y][x]...(y,x)->(y,x+1)
bool yoko[100][100];

//スタートからの距離
int d[100][100];

//上下左右
const int dx[4]={0,0,-1,1};
const int dy[4]={-1,1,0,0};

const int INF=10000;


void bfs(){
	queue<P> que;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			d[i][j]=INF;
		}
	}
	que.push(P(0,0));
	d[0][0]=1;

	while(!que.empty()){
		int h,w;
		h=que.front().first;
		w=que.front().second;
		que.pop();
		if(h==H-1 && w==W-1) break;


		//上
		int nh=h-1,nw=w;
		if(0<=nh && tate[nh][w] && d[nh][nw]==INF){
			que.push(P(nh,nw));
			d[nh][nw]=d[h][w]+1;
		}

		//下
		nh=h+1,nw=w;
		if(h<H-1 && tate[h][w] && d[nh][nw]==INF){
			que.push(P(nh,nw));
			d[nh][nw]=d[h][w]+1;
		}

		//左
		nh=h,nw=w-1;
		if(0<=nw && yoko[h][nw] && d[nh][nw]==INF){
			que.push(P(nh,nw));
			d[nh][nw]=d[h][w]+1;
		}

		//右
		nh=h,nw=w+1;
		if(w<W-1 && yoko[h][w] && d[nh][nw]==INF){
			que.push(P(nh,nw));
			d[nh][nw]=d[h][w]+1;
		}

	}

}


int main(){

	while(cin>>W>>H,W){

		//初期化
		for(int i=0;i<100;i++){
			for(int j=0;j<100;j++) tate[i][j]=yoko[i][j]=false;
		}


		//マップ読み込み
		for(int i=0;i<2*H-1;i++){
			//横方向に移動が可能か
			if(i%2==0){
				for(int j=0;j<W-1;j++){
					int c;
					cin>>c;

					if(c==0) yoko[i/2][j]=true;
				}
			}//縦方向に移動が可能か
			else{
				for(int j=0;j<W;j++){
					int c;
					cin>>c;

					if(c==0) tate[i/2][j]=true;
				}
			}
		}

		bfs();
		if(d[H-1][W-1]==INF) d[H-1][W-1]=0;
		cout<<d[H-1][W-1]<<endl;

	}

	return 0;
}

Measured memory_bytes: 1272
#include<iostream> 
#include<string> 

using namespace std; 

int main() 
{
	int k; 
	string s; 
	cin >> k >> s; 

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

	return 0; 
}

Measured memory_bytes: 3632
X, K, D = map(int, input().split())
n = (K-X//D)//2
#print(n)
if X - K*D > 0:
    ans = X-K*D
elif X + D*K < 0:
    ans = abs(X+D*K)
else:
    ans = float('inf')
    for i in range(-1, 2):
        res = X + D*(2*(n+i)-K)
        ans = min(ans, abs(res))
        #print(res)

print(ans)

Measured memory_bytes: 9124
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int N,W;
	
	scanf("%d %d",&N,&W);
	vector<int> dp(W+1,0);
	
	for(int i=0;i<N;i++){
		int v,w,m;
		scanf("%d %d %d",&v,&w,&m);
		for(int k=0;m>0;k++){
			int key=min(m,(1<<k));
			m-=key;
			for(int j=W;j>=key*w;j--){
				dp[j]=max(dp[j],dp[j-key*w]+key*v);
			}
		}
	}
	
	int ans=0;
	for(int i=0;i<=W;i++) ans=max(ans,dp[i]);
	printf("%d\n",ans);
}


Measured memory_bytes: 3256
//Author - Tejas Pandey
#include <bits/stdc++.h>
#define loi long long int
using namespace std;
int main() {
	int a[26];
	memset(a,0,sizeof(a));
	int n;
	cin >> n;
	char s[n+1];
	cin >> s;
	for(int i = 0;i < n;i++)
	a[s[i]-'a']++;
	long long ans = 0;
	long mod = 1000000007; 
	for(int i = 0;i < 26;i++)
	{
		if(a[i])
		{
		loi fac = 1;
		for(int j = i+1; j < 26 ;j++)
		if(a[j])
		fac = (fac * (a[j]+1)%mod)%mod;
		ans = (ans+(a[i]*fac)%mod)%mod;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
<url:https://arc077.contest.atcoder.jp/tasks/arc077_b>
問題文============================================================
 1,…,n の n 個の整数からなる長さ n+1 の数列 a1,a2,…,an+1 が与えられます。
 この数列には 1,…,n のどの整数もかならず 1 回以上出現することが分かっています。
 
 k=1,…,n+1 のそれぞれについて、与えられた数列の長さ k の（連続とは限らない）部分列の個数を求め、
 109+7 で割ったあまりを出力して下さい。
 
 2 つの部分列が数列として同じであれば、元の数列での位置が異なっていたとしても、1 通りと数えます。
 
 数列 a の長さ k の部分列とは、a の要素のうち k 個を選んで、
 それらを順番を変えずに取り出して並べた数列のことを指します。
 例えば、数列 1,2,3,4,5 の長さ 3 の部分列には、
 1,3,5 や 1,2,3 などがあります。 一方で、3,1,2 や 1,10,100 はこの数列の部分列ではありません。
 
 1≤n≤10^5
 1≤ai≤n
 1,…,n のどの整数も必ず数列に出現する。
 n,ai は整数である。
=================================================================

解説=============================================================

 [ ~ ]x[ ~ ]x[ ~ ]
================================================================
*/

const ll MAX_N = 2e5 + 10;
const ll MOD = 1e9+7;
ll Inv[MAX_N];
ll fact[MAX_N];
ll factInv[MAX_N];
void Inv_init(){
    Inv[1] = 1;
    for(int i = 2; i < MAX_N; i++) {
        Inv[i] = Inv[MOD%i] * (MOD - MOD/i) % MOD;
    }
}
void fact_init(){
    fact[0] = fact[1] = factInv[0] = factInv[1] = 1;
    for(int i = 2; i < MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        factInv[i] = (factInv[i-1] * Inv[i])%MOD;
    }
}

// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
// 逆元 1/a % MOD
ll inversemod(ll a) { return powmod(a,MOD - 2);}
ll nCr(int n,int r) {
    if(n < r) return 0;
    return (fact[n] * (factInv[r] * factInv[n-r] % MOD)) % MOD;
}

void init(){
    Inv_init();
    fact_init();
}

void solve(){
    ll n; cin >> n;
    vector<ll> a(n+1); for(auto &in:a){ cin >> in; in--; }
    vector<ll> idx(n,-1);
    ll lx = -1,rx = -1;
    for(int i = 0; i <= n;i++){
        if(idx[a[i]] == -1) idx[a[i]] = i;
        else{ lx = idx[a[i]]; rx = idx[a[i]] = i;}
    }
    ll lnum = lx, mnum = rx - lx - 1, rnum = (n+1) - rx - 1;

    // output
    for(ll i = 1; i <= n+1; i++){
//        if(i <= lnum + rnum + 1){
//            cout << (nCr(n+1,i) - nCr(lnum+rnum,i-1) + MOD)%MOD << endl;
//        }else{
//            cout << nCr(n+1,i) << endl;
//        }
        cout << (nCr(n+1,i) - nCr(lnum+rnum,i-1) + MOD)%MOD << endl;

    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    init();
    solve();
	return 0;
}


Measured memory_bytes: 7424
#include<vector>
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
	int n;
	int i, input;
	double ans;
	vector<int> v;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> input;
		v.push_back(input);
	}

	sort(v.begin() ,v.end());

	ans = (double)(v[0] + v[1]) / 2;
	for (i = 2; i < n; i++) {
		ans = (double)(ans + v[i]) / 2;
	}

	printf("%.10lf\n", ans);

	return 0;
}



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

int main() {
  long long L, R;
  int min=2019;
  cin >> L >> R;
  for(long long i=L; i<R; i++){
    if(i%2019==0){
      min=0;
      break;
    }
    for(long long j=i+1; j<=R; j++){
      if(j%2019==0){
        min=0;
        break;
      }
      if((i*j)%2019<min) min=(i*j)%2019;
    }
  }
  cout << min <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#define int long long
using namespace std;

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

int cnt = 0;
bool used[4];
bool fl = false;
vector<int> g[4];

void dfs(int v) {
	cnt++;
	used[v] = true;
	if (cnt == 4) {
		cout << "YES";
		exit(0);
	} 
	bool ff = true;
	for (int to : g[v]) {
		if (!used[to]) {
			ff = false;
			dfs(to);
			break;
		}
	}
	if (ff) {
		cout << "NO";
		exit(0);
	}
}

signed main() {
	fast();
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(0);
	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long*)b)return 1;
    return -1;
}
int main()
{   int a,i,b,x,y,n,m,k;
    scanf("%d%d",&n,&k);
    char s[n+1];
    scanf("%s",s);
    for(i=0;i<n;i++){
    if(i==k-1){
        printf("%c",'a'+s[i]-'A');

    }else 
    printf("%c",s[i]);
    
    }
    
    return 0;
}


Measured memory_bytes: 128
/* ABC135-B.c
   Takatan */

#include<stdio.h>
#include<stdlib.h>
int main(void){
    int number, *array, change, i;
    change = 0;

    scanf( "%d" , &number);

    array = malloc(sizeof(int) * number);

    for(i=0; i < number; i++){
        scanf( "%d" , array+i);
        if(array[i]!=i+1){
            if(change==0){
                change = array[i];
            }else{
                if(change!=i+1){
                    printf( "NO\n" );
                    return 0;
                }
            }
        }
    }

    printf( "YES\n" );
    return 0;
}

Measured memory_bytes: 128