akhauriyash/Code-Regression huggingface dataset:
import math
a,b,c = [int(x) for x in input().split()]
c = math.radians(c)
s = a * b * math.sin(c) / 2
l = a + b + math.sqrt(a**2 + b**2 - 2*a*b*math.cos(c))
h = 2 * s / a
for i in [s,l,h]:
    print('{:.12f}'.format(i))



Measured memory_bytes: 5720
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  string s,t;
  cin >> s >> t;
  unordered_map<char,char> mps,mpt;
  REP(i, s.size()){
    bool flags = (mps.find(s[i]) != mps.end());
    bool flagt = (mpt.find(t[i]) != mps.end());
    if(flags) if(mps[s[i]] != t[i]){
      cout << "No";
      return 0;
    }
    if(flagt) if(mpt[t[i]] != s[i]){
      cout << "No";
      return 0;
    }
    if(!flags) mps[s[i]] = t[i];
    if(!flagt) mpt[t[i]] = s[i];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <stdio.h>

int main(void){

	int a,b;

	scanf("%d %d",&a,&b);

	if(a>b){
		printf("a > b\n");
	}else if(a<b){
		printf("a < b\n");
	}else if(a==b){
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 1800
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::BinaryHeap;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (x, y) =(line[0], line[1]);
    let mut heap: BinaryHeap<(u64, u64)> = BinaryHeap::new();

    for i in 0..3{
        let line = read_as_vec::<u64>();
        for elem in line{
            heap.push((elem, i));
        }
    }


    let (mut cur_red, mut cur_grn, mut cur_less) = (0, 0, 0);
    let mut ans: u64 = 0;
    //while cur_red + cur_grn + cur_less <= x+y{
    while let Some(value) = heap.pop(){
        let (taste, color) = (value.0, value.1);
        if color == 0{
            if cur_red == x{
                continue;
            }
            cur_red += 1;
        }else if color == 1{
            if cur_grn == y{
                continue;
            }
            cur_grn += 1;
        }else{
            cur_less += 1;
        }
        ans += taste;
        if cur_red + cur_grn + cur_less == x+y{
            break;
        }
    }

    println!("{}", ans);
}


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

using namespace std;

template<class T> inline bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

template<class T> inline bool chmax(T& a, T b){
  if(a < b){
    a = b;
    return true;
  }
  return false;
}

const long long INF = 1LL << 60;

int main(void){
  int N, W;
  cin >> N >> W;
  long long weight[N+10], value[N+10];
  for(int i = 0; i < N; i++){
    cin >> weight[i] >> value[i];
  }
  long long DP[N+10][W+10];
  for(int i = 0; i < N+10; i++){
    for(int j = 0; j < W+10; j++){
      DP[i][j] = 0;
    }
  }
  
  for(int i = 1; i <= N; i++){
    for(int omosa = 0; omosa <= W; omosa++){
      if(omosa + weight[i-1] <= W){
        chmax(DP[i][omosa+weight[i-1]], DP[i-1][omosa] + value[i-1]);
      }
      chmax(DP[i][omosa], DP[i-1][omosa]);
    }
  }
  
  cout << DP[N][W] << endl;
    
  return 0;
}



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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n - 1 - i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
  int x;
  cin>>x;
  int y = x%10;
  if(y==2||y==4||y==5||y==7||y==9){
    cout<<"hon";
  }
  else if(y==0||y==1||y==6||y==8){
    cout<<"pon";
  }
  else if(y==3){
    cout<<"bon";
  }
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001],b[100001];
P1 c[100001]={};
int main() {

	int n,m;

	cin>>n>>m;
	rep(i,n){
		cin>>a[i]>>b[i];
		c[i].first=a[i];
		c[i].second=b[i];
	}
	sort(c,c+n);

	ll total=0;
	int r=0;
	rep(i,n){
		if(m-r>c[i].second){
			total+=c[i].first*c[i].second;
			r+=c[i].second;
		}else{
			total+=c[i].first*(m-r);
			cout<<total<<endl;
			return 0;
		}
	}
	return 0;

}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    vector<bool> col(8, false);
    int a, w=0;
    for(int in=0;in<n;in++) {
        cin >> a;
        // cout << a << endl;
        if(a<=399) col.at(0)=true;
        else if(a<=799) col.at(1)=true;
        else if(a<=1199) col.at(2)=true;
        else if(a<=1599) col.at(3)=true;
        else if(a<=1999) col.at(4)=true;
        else if(a<=2399) col.at(5)=true;
        else if(a<=2799) col.at(6)=true;
        else if(a<=3199) col.at(7)=true;
        else w++;
    }

    // for(auto c:col) cout << c << endl;

    int sum = 0;
    for(int in=0;in<8;in++) {
        if(col.at(in)==true) sum++;
    }

    if(w!=n) {
        cout << sum << " " << sum+w << endl;
    }
    else {
        cout << 1 << " " << w << endl;
    }
    
    return 0;
}


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

int main()
{
  while(1){
    int e;
    cin >> e;
    if(e == 0) break;
    int ans = e + 1;
    for(int y = 0; y*y <= e; y++)
      for(int z = 0; z*z*z <= e; z++)
        if(y*y+z*z*z <= e)
          ans = min(ans,e-y*y-z*z*z+y+z);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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 long double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int K;
	cin >> K;
	int mod = 0;
	rep(i,K){
		mod *= 10;
		mod += 7;
		mod %= K;
		if(mod == 0){
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int d = a + b + c; //合計
	if(d - max(a,max(b,c)) == max(a,max(b,c)))cout << "Yes" << endl; //条件を満たすなら最大個数=合計の1/2
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# AGC009A - Multiple Array
def main():
    N, *AB = map(int, open(0).read().split())
    ans = 0
    for i, j in zip(*[iter(AB[::-1])] * 2):  # decide from the last one greedily
        ans += -(j + ans) % i
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25124
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;
int main()
{
    
    int n;
    cin >> n;
    vector<int>p(n);
    int ans = 0;
    int t = -1;
    for (int i = 0; i < n; i++) { 
        cin >> p[i];
        if (p[i] >= t) {
            ans++; t = p[i];
        }
    }

    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;
        if (a + b >= 0 && b >= 0) {
            for (int i = 0; i < a - 1; i++) {
                sum += b + 1 + i;
            }
        }
        if (a + b > 0 && b < 0) {
            for (int i = 0; i < a; i++) {
                sum += b + (i);
            }
        }
        if (a + b <= 0 && b < 0) {
            for (int i = 0; i < a - 1; i++) {
                sum += b + (i);
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll N; cin >> N;
	VLL a(100005);
	ll k;
	map<ll, ll>memo;
	for (int i = 0;i < N;i++) {
		cin >> k;
		a[k]++;
		if(k!=0)a[k - 1]++;
		a[k + 1]++;
	}
	sort(all(a));
	cout << a[100004] << endl;
}

Measured memory_bytes: 1024
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int m, k;
    cin >> m >> k;
    if (m == 1) {
        if (k == 0) cout << "0 0 1 1";
        else cout << -1;
        return 0;
    }
    if (k >= (1 << m)) {
        cout << -1;
        return 0;
    }
    for (int i = 0; i < (1 << m); i++) {
        if (i != k) cout << i << " ";
    }
    cout << k << " ";
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i != k) cout << i << " ";
    }
    cout << k;
}
/*

*/


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long
#define ae addEdge
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define vvi vector< vector<int> >
#define pii pair <int,int>
#define sortv sort(v.begin(),v.end())
#define sorta sort(a.begin(),a.end())
#define sortb sort(b.begin(),b.end())
#define sorts sort(s.begin(),s.end())

int main(){
	int n,k; cin>>n>>k;
	vi v;
	for(int i=0;i<n;i++){
		int a; cin>>a;
		v.pb(a);
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
		int mn=INT_MAX;
		int j=1;
		while(i-j>=0 && j<=k){
			if(dp[i-j]+abs(v[i-j]-v[i])<mn) mn=dp[i-j]+abs(v[i-j]-v[i]);
			j++;
		}
		dp[i]=mn;
	}
	
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
int n,m,s[100003],ton[100003],s1,s2,p[100003];
string t[100003];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		cin>>s[i]>>t[i];
		if(t[i]=="AC")
			if(ton[s[i]]==0)
				s1++,ton[s[i]]=1,s2+=p[s[i]];
		if(t[i]=="WA")
			if(ton[s[i]]==0)
				p[s[i]]++;
	}
	cout<<s1<<" "<<s2;
	return 0;
}


Measured memory_bytes: 6784
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if (s.equals(u)) a--;
        if (t.equals(u)) b--;

        System.out.println(a + " " + b);
    }
}

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

bool check(int x, int y)
{
    if( y < 2 * x ) return false;
    if( y > 4 * x ) return false;
    return ((y - 2 * x) % 2) == 0;
}

int main()
{
    int x, y;
    cin >> x >> y;
    if( check(x, y) )
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    
    return 0;    
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n , m;


void solve(int testCase){

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

    if(n > m)swap(n , m);
    while(m --){
            printf("%d" , n);
    }

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    char[] S = sc.nextLine().toCharArray();
    char[] T = sc.nextLine().toCharArray();
    int count = 0;
    for(int i = 0; i < S.length; i++){
      if(S[i] == T[i]){
        count++;
      }
    }
    System.out.println(count);
  }
}


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

int main(void) {
    int n;
    cin >> n;
    vector<int> t(n + 1);
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> t.at(i);
        sum += t.at(i);
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int p, x;
        cin >> p >> x;
        cout << sum + x - t.at(p) << endl;
    }
    return 0;
}

Measured memory_bytes: 3512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m,s;
	int k,j,i;
	int a[101];
	cin>>n>>m;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(k=1;k<=m;k++){
		s=1;
		while(n!=s){
			if(a[s]%k>a[s+1]%k){
				swap(a[s],a[s+1]);
				s++;
			}
			else s++;
		}
	}
	for(i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}

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

int t[20][20];
int dp[1<<16];
int n;

int solve(int bit){

  int ret = INT_MAX;
  if(dp[bit] != -1) return dp[bit];
  if(bit == (1<<n)-1) return 0;
  for(int i = 0; i < n; i++){
    int cost = t[i][0];
    for(int j = 0; j < n; j++){
      if(bit & (1<<j)) cost = min(cost, t[i][j+1]);
    }
    if(!(bit & (1<<i))) ret = min(ret, solve(bit | (1<<i)) + cost);
  }
  return dp[bit] = ret;
}


  int main(){


    while(cin >> n && n){

      memset(dp,-1,sizeof(dp));

      for(int i = 0; i < n; i++){
	for(int j = 0; j <= n; j++){
	  cin >> t[i][j];
	}
      }
      solve(0);
      cout << dp[0] << endl;
    }



  }

Measured memory_bytes: 1424
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  string t = "keyence";
  string s; cin >> s;
  int n = s.size();
  REP (k, 8) {
    int j = 7 - k;
    dump(t.substr(0, k));
    dump(t.substr(n - j, j));
    if (s.substr(0, k) == t.substr(0, k) && s.substr(n - j, j) == t.substr(7 - j, j)) {
      cout << "YES" << endl; return 0;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

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

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

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

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	N := nextInt()
	K := nextInt()
	A := nextInts(N)
	a := make([]int, N)
	a[0] = A[0]
	for i := 1; i < N; i++ {
		if i-K >= 0 {
			a[i] = a[i-1] / A[i-K] * A[i]
			if A[i-K] < A[i] {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		} else {
			a[i] = a[i-1] * A[i]
		}
	}
	// for i := K; i < N; i++ {
	// 	if a[i] > a[i-1] {
	// 		fmt.Println("Yes")
	// 	} else {
	// 		fmt.Println("No")
	// 	}
	// }
}


Measured memory_bytes: 7512
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    string S;
    cin >> S;
    vector<int> vec(S.length());
    
    int Rcount = 0, Lcount = 0;
    for(int i=0; i<S.length(); i++) {
        if (S[i] == 'R') {
            Rcount++;
        } else {
            for (int j=i; j<S.length(); j++) {
                Lcount++;
                if (S[j+1] == 'R' || j == S.length()-1) {
                    if ((Rcount+Lcount)%2 == 0) {
                        vec[i-1] = vec[i] = (Rcount+Lcount)/2;
                    } else {
                       if (Rcount%2 == 0) {
                           vec[i-1] = (Rcount+Lcount-1)/2;
                           vec[i] = (Rcount+Lcount+1)/2;
                       } else {
                           vec[i-1] = (Rcount+Lcount+1)/2;
                           vec[i] = (Rcount+Lcount-1)/2;
                       } 
                    }
                    Rcount = 0;
                    Lcount = 0;
                    i = j;
                    break;
                }
            }
        }
    }
    
    for (auto x : vec) {
        cout << x << " ";
    }
    
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
char q[100010];
int q1[30];
int main()
{
    scanf("%s",q);
    int s=strlen(q);
    if(q[0]!=q[s-1])
        if(s&1)
            printf("First\n");
        else
            printf("Second\n");
    else
    {
        if(s&1)  printf("Second\n");

        else printf("First\n");
    }
}


Measured memory_bytes: 256
#include <complex>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const double EPS = 1e-7;
struct P{
	double x,y,z;
	P(double x,double y,double z) : x(x) , y(y) , z(z) {}
	P(){}
};
P operator + (P a,P b){
	a.x += b.x;
	a.y += b.y;
	a.z += b.z;
	return a;
}
P operator - (P a,P b){
	a.x -= b.x;
	a.y -= b.y;
	a.z -= b.z;
	return a;
}
double abs(P a){
	return sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
}
double det(vector< vector<double> > A){
	double ans = 1;
	for(int i = 0 ; i < A.size() ; i++){
		for(int j = i+1 ; j < A.size() ; j++){
			if( A[i][i] == 0 && A[j][i] != 0 ){
				swap(A[i],A[j]);
				ans *= -1;
				break;
			}
		}
		if( abs(A[i][i]) < 1e-9 ) return 0;
		ans *= A[i][i];
		for(int j = i+1 ; j < A.size() ; j++){
			for(int k = A.size()-1 ; k >= i ; k--){
				A[j][k] -= A[i][k] * A[j][i] / A[i][i];
			}
		}
	}
	return ans;
}

P calc(double k,P a){
	a.x *= k;
	a.y *= k;
	a.z *= k;
	return a;
}
double area(P a,P b,P c){
	b = b-a;
	c = c-a;
	double x = det({{b.y,b.z},{c.y,c.z}});
	double y = det({{b.z,b.x},{c.z,c.x}});
	double z = det({{b.x,b.y},{c.x,c.y}});
	return sqrt(x*x+y*y+z*z);
}
int main(){
	P uaz,ene,a,b,c;
	P vec;
	cin >> uaz.x >> uaz.y >> uaz.z;
	cin >> ene.x >> ene.y >> ene.z;
	cin >> a.x >> a.y >> a.z;
	cin >> b.x >> b.y >> b.z;
	cin >> c.x >> c.y >> c.z;
	
	uaz = uaz - a;
	ene = ene - a;
	b = b - a;
	c = c - a;
	a = a - a;
	vec = ene - uaz;
	double s = abs(vec);
	vec.x /= s;
	vec.y /= s;
	vec.z /= s;
	double l = -1000000 , r = 1000000;
	for( int _ = 0 ; _ < 128 ; _++ ){
		double m = (l+r) / 2.0;
		P pos1 = calc(m,vec) + uaz;
		P pos2 = calc(r,vec) + uaz;
		double D1 = det({{b.x,b.y,b.z},{c.x,c.y,c.z},{pos1.x,pos1.y,pos1.z}});
		double D2 = det({{b.x,b.y,b.z},{c.x,c.y,c.z},{pos2.x,pos2.y,pos2.z}});
		if( D1 * D2 > 0  ){
			r = m;
		}else{
			l = m;
		}
	}
	P hit = calc(l,vec) + uaz;
	//cout << fabs(abs(uaz-hit)-l) << endl;
	//while( abs(det({{b.x,b.y,b.z},{c.x,c.y,c.z},{hit.x,hit.y,hit.z}})) > EPS ){}
	//cout << hit.x << " " << hit.y << " " << hit.z << endl;
	if( l > EPS && fabs(abs(uaz-hit)-l)<EPS && fabs( abs(ene-hit) - (s-l) ) < EPS  ){
		double all = 0;
		int qq = 0;
		for(int k = 0 ; k < 1000000 ; k++)
			if(k%3==0&&k*(k+1)%2==0)qq++,qq%=k,all = area(a,b,c);
		int bb = 2*qq;
		if(bb){qq^=1;}
		all = area(a,b,c);
		double sub1 = area(a,b,hit);
		double sub2 = area(b,c,hit);
		double sub3 = area(c,a,hit);
		//cout << all << " " <<  sub1 + sub2 + sub3 << endl;
		if( fabs( all-(sub1+sub2+sub3) ) < EPS ){
			cout << "MISS" << endl;
		}else{
			cout << "HIT" << endl;
		}
	}else{
		cout << "HIT" << endl;
	}
	
	
}

Measured memory_bytes: 1248
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll a, b;
  cin >> a >> b;

  cout << (b % a == 0 ? a + b : b-a)  << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 2000009
#define ll long long
#define ld long double
#define ff first
#define ss second
#define inf 1000000005
#define mod 1000000007
using namespace std;
ll n, a[3009], dp[3009][3009];
ll get(int l, int r) {
    if(l > r)
        return 0ll;
    return dp[l][r];
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int len=1;len<=n;len++) {
        for(int l=1;l<=n-len+1;l++) {
            int r = l + len - 1;
            dp[l][r] = max(a[l] - get(l + 1, r), a[r] - get(l, r - 1));
        }
    }
    cout<<dp[1][n];
}


Measured memory_bytes: 49804
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
typedef long long int ll;
int main(){
	ll A,B,V,W,T;
	cin>>A>>V>>B>>W>>T;
	if(A<B){
		A+=V*T;
		B+=W*T;
		if(A>=B){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
	else{
		A-=V*T;
		B-=W*T;
		if(A<=B){
			cout<<"YES";
		}
		else{
			cout<<"NO";
		}
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    int h,a;
    cin>>h>>a;
    if(h%a==0) cout<<h/a<<endl;
    else cout<<(h/a)+1<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>

int main(){
	std::stack<int> train;
	int num;
	while(std::cin >> num){
		if(num == 0){
			std::cout << train.top() << std::endl;
			train.pop();
		}
		else {
			train.push(num);
		}
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

const ll mod = 1000000007LL;

#define MAX 100010
int n,a[MAX];

long long extgcd(long long a,long long b,long long& x,long long& y)
{
  long long d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

long long mod_inv(long long a,long long m)
{
  long long x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

const int MAXnCk = 400001;
ll fact[MAXnCk+1], fact_inv[MAXnCk+1];
void init_nCk(){
  fact[0] = fact_inv[0] = 1;
  REP(i,1,MAXnCk+1) {
    fact[i] = fact[i-1] * (ll)i % mod;
    fact_inv[i] = mod_inv(fact[i],mod);
  }
}

ll nCk(ll n,ll k){
  if( n < 0 || k < 0 || k > n ) return 0LL;
  if( n-k < k ) k = n-k;
  return fact_inv[k] * fact[n] % mod * fact_inv[n-k] % mod;
}

int getv() {
  map<int,int> mp;
  rep(i,n+1) {
    ++mp[a[i]];
  }
  for(auto v : mp) {
    if( v.second == 2 )  return v.first;
  }
  assert(false);
}

void compute() {

  if( n == 1 ){
    puts("1");
    puts("1");
    return;
  }
  
  init_nCk();
  cout << n << endl;
  vector<ll> vec(3,0);

  int cur = 0;
  int v = getv();
  rep(i,n+1) {
    if( a[i] == v ) { ++cur; continue; }
    ++vec[cur];
  }

  REP(k,2,n+2) {
    ll ans = nCk(n+1,k);
    if( vec[0]+vec[2]-(k-1) >= 0 ) {
      ans -= nCk(vec[0]+vec[2],k-1);
      while( ans < 0LL ) ans += mod;
    }
    cout << ans << endl;
  }
}

int main() {
  cin >> n;
  rep(i,n+1) cin >> a[i];
  compute();
  return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  int l[101];
  for (int i = 0; i < n; i++) cin >> l[i];
  sort(l, l + n, greater<int>());
  int res = 0;
  for (int i = 0; i < k; i++) res += l[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

// calc (a^n)%m
ll modpow(ll a,ll n,ll m) {
    if(n==1) return a%m;
    if(n%2==1) return (a*modpow(a,n-1,m))%m;
    ll b = modpow(a,n/2,m)%m;
    return (b*b)%m;
}

int main() {

    ll n,a,b;
    cin >> n >> a >> b;
    ll mod = 1000000007;
    ll out = modpow(2,n,mod)-1;
    ll A = 1;
    ll C = 1;
    rep(i,a) A = (A*(n-i))%mod;
    rep(i,a) C = (C*(i+1))%mod;
    ll B = 1;
    ll D = 1;
    rep(i,b) B = (B*(n-i))%mod;
    rep(i,b) D = (D*(i+1))%mod;
    out -= ((A*modpow(C,mod-2,mod))%mod+(B*modpow(D,mod-2,mod))%mod)%mod;
    if(out<0) out += mod;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
import scipy as sp
import scipy.sparse.csgraph as sg

N = [int(c) for c in input()]

for i in range(len(N)-1):
    if int(N[i]) + int(N[i+1]) < int(N[i]) - 1 + 9:
        N[i] -= 1
        for j in range(i+1, len(N)):
            N[j] = 9
num = sum(N)

print(num)



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

def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if s.count("3")>0 and s.count("5")>0 and s.count("7")>0 else 0
    for x in ["3","5","7"]:
        r += dfs(s+x)
    return r

print(dfs("0"))

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

int main(){
    int ans[20000];
    int i=0;
    char op;
    do{
        int a,b;
        cin >> a >> op >> b;
        if(op=='?'){
            ans[i] = -1;
            break;
        }else if (op == '+')
        {
            ans[i] = a+b;
        }else if (op == '-')
        {
            ans[i] = a-b;
        }else if (op == '*')
        {
            ans[i] = a*b;
        }else if (op == '/')
        {
            ans[i] = a/b;
        }
        i++;
    }while(op != '?');
    for(int j=0;j<i;j++){
        cout << ans[j] << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int N;
  scanf("%d", &N);
  int a, i, j, f[N][10], p[N][11], sum, max=0x80000000;

  for(i=0;i<N;i++)
    for(j=0;j<10;j++)
      scanf("%d", &f[i][j]);
  
  for(i=0;i<N;i++)
    for(j=0;j<11;j++)
      scanf("%d", &p[i][j]);
  
  for(i=1;i<1024;i++){
    sum=0;
    for(j=0;j<N;j++){
      a=(((i%(2<<0))>>0)&f[j][0])+
        (((i%(2<<1))>>1)&f[j][1])+
        (((i%(2<<2))>>2)&f[j][2])+
        (((i%(2<<3))>>3)&f[j][3])+
        (((i%(2<<4))>>4)&f[j][4])+
        (((i%(2<<5))>>5)&f[j][5])+
        (((i%(2<<6))>>6)&f[j][6])+
        (((i%(2<<7))>>7)&f[j][7])+
        (((i%(2<<8))>>8)&f[j][8])+
        (((i%(2<<9))>>9)&f[j][9]);
      sum+=p[j][a];
    }
    if(max<sum){
      max=sum;
    }
  }
  
  printf("%d\n", max);
  
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, m;
vector<vector<ll> > g;
ll dp[100100];

ll rec(ll i) {
    if(dp[i] != -1) return dp[i];

    ll res = 0;
    for(auto j : g[i]){
        res = max(res, rec(j) + 1);
    }

    return dp[i] = res;
}

int main() {
    cin >> n >> m;
    g.assign(n, vector<ll>());
    for(int i = 0; i < m; i++){
        ll x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
    }

    for(int i = 0; i < 100100; i++) dp[i] = -1;

    ll res = 0;
    for(int i = 0; i < n; i++){
        res = max(res, rec(i));
    }
    cout << res << endl;
}

Measured memory_bytes: 8576
<?php

//標準入力
class Scanner {
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
  public function next() {
      if($this->pointer >= $this->count) {
          $str = trim(fgets(STDIN));
          $this->arr = explode(' ', $str);
          $this->count = count($this->arr);
          $this->pointer = 0;
      }
      $result = $this->arr[$this->pointer];
      $this->pointer++;
      return $result;
  }
  public function hasNext() {
      return $this->pointer < $this->count;
  }
  public function nextInt() {
      return (int)$this->next();
  }
  public function nextDouble() {
      return (double)$this->next();
  }
}

//標準出力
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}



$sc = new Scanner();
$A = $sc->nextInt();
$P = $sc->nextInt();

$P = $P + $A * 3;

$ans = (int)($P/2);
echo $ans.PHP_EOL;


?>


Measured memory_bytes: 4728
#include <iostream> // cout, endl, cin
#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
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<ll> x(N);
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    ll ans = 1;
    ll cnt = 0;
    for(int i=0; i<N; i++){
        while(cnt*2+1 > x[i]){
            ans *= (cnt+1);
            ans %= mod;
            cnt--;
        }
        cnt++;
    }
    while(cnt){
        ans *= cnt;
        ans %= mod;
        cnt--;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns, MultiWayIf #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Int
import Data.Foldable
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int32 -> Int32
solve !n !k !an = VU.last $ V.last dp
 where
  dp :: V.Vector (VU.Vector Int32)
  dp = V.postscanl'
    (\(!dpi) (!i) -> VU.scanl'
      (\(!dpij) (!j) ->
        let !p = if j - fromIntegral (an VU.! i) - 1 >= 0
              then dpi VU.! (j - fromIntegral (an VU.! i) - 1)
              else 0
            !q = dpi VU.! j
            !a = dpij + q - p
        in  a `mod` (10 ^ 9 + 7)
      )
      1
      (VU.generate k (+ 1))
    )
    (VU.generate (k + 1) (\i -> if i == 0 then 1 else 0))
    (V.convert $ VU.generate n id)

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, k) <-
    (\(!vec) -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  an <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k an


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

int main(void){
	vector<int> a(3);
	cin>>a[0]>>a[1]>>a[2];
	sort(a.begin(),a.end());
	if(a[0] + a[1] == a[2]) cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

ll H, W;

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

	cin >> H >> W;

	if(H == 1 || W == 1)
		cout << 1 << "\n";
	else{
		ll ans = (H*W+1)/2;
		cout << ans << "\n";
	}

	return 0;		
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  vector<bool> rm_h(h, true), rm_w(w, true);
  rep(i, h) rep(j, w) if (a[i][j] == '#') {
    rm_h[i] = false;
    rm_w[j] = false;
  }
  rep(i, h) {
    if (rm_h[i]) continue;
    rep(j, w) {
      if (rm_w[j]) continue;
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int H = scan.nextInt();
		int W = scan.nextInt();
		int K = scan.nextInt();

		char[][] C = new char[H][W];

		for (int i = 0; i < H; i++) {
			C[i] = scan.next().toCharArray();
		}

		//WK変数
		int result = 0;

		//演算
		for (int i = 0; i < (int) Math.pow(2, H); i++) {
			for (int j = 0; j < (int) Math.pow(2, W); j++) {
				int black = 0;
				for (int k = 0; k < H; k++) {
					for (int l = 0; l < W; l++) {
						if ((i % (int) Math.pow(2, k + 1)) / (int) Math.pow(2, k) == 0 &&
								(j % (int) Math.pow(2, l + 1)) / (int) Math.pow(2, l) == 0) {
							if (C[k][l] == '#') {
								black++;
							}
							;
						}
					}
				}
				if (black == K) {
					result++;
				}

			}
		}

		//結果出力
		System.out.println(result);
	}
}

Measured memory_bytes: 35876
def first_positive(n,a):
    count = 0
    sum = a[0]
    #正ならTrue
    flag = True

    if a[0] <= 0:
        sum = 1
        count += abs(1 - a[0])

    for i in range(1,n):
        if sum + a[i] < 0 and flag == True:
            sum += a[i]
            flag = False
            continue
        elif sum + a[i] <= 0 and flag == False:
            flag = True
            count += abs(1 - sum - a[i])
            sum = 1
        elif sum + a[i] >= 0 and flag == True:
            flag = False
            count += abs(-1 - sum - a[i])
            sum = -1
        elif sum + a[i] > 0 and flag == False:
            sum += a[i]
            flag = True
            continue

    return count

def first_negative(n,a):
    count = 0
    sum = a[0]
    #正ならTrue
    flag = False

    if a[0] >= 0:
        sum = -1
        count += abs(-1 - a[0])

    for i in range(1,n):
        if sum + a[i] < 0 and flag == True:
            sum += a[i]
            flag = False
            continue
        elif sum + a[i] <= 0 and flag == False:
            flag = True
            count += abs(1 - sum - a[i])
            sum = 1
        elif sum + a[i] >= 0 and flag == True:
            flag = False
            count += abs(-1 - sum - a[i])
            sum = -1
        elif sum + a[i] > 0 and flag == False:
            sum += a[i]
            flag = True
            continue

    return count

if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]

    p = first_positive(n,a)
    n = first_negative(n,a)

    if p < n:
        print(p)
    else:
        print(n)


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    vector<int> c(m);
    vector<int> d(m);
    for (int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        int ans, minv = 1000000000;
        for (int j = 0; j < m; j++)
        {
            int mhk;
            mhk = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (minv == mhk) continue;
            minv = min(minv, mhk);
            if (minv == mhk) {
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll x,k,d;
int main(void){
    cin>>x>>k>>d;
    x=abs(x);
    if(x>0){
        if(x/d>k){
            cout<<x-d*k<<endl;
            return 0;
        }else{
            k=k-x/d;
            if(k%2==0){
                cout<<x%d<<endl;
                return 0;
            }else{
                cout<<abs(x%d-d)<<endl;
                return 0;
            }
        }
    }else{
        if(k%2==0){
            cout<<0<<endl;
            return 0;
        }else{
            cout<<d<<endl;
            return 0;
        }
    }

}



Measured memory_bytes: 3668
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int median(int a, int b, int c) {
    if (a > b) swap(a, b);
    return max(a, min(b, c));
}

template <typename UnaryPredicate>
int binsearch(int l, int r, UnaryPredicate p) { // [l, r), p is monotone
    assert (l < r);
    -- l;
    while (r - l > 1) {
        int m = (l + r) / 2;
        (p(m) ? r : l) = m;
    }
    return r; // = min { x in [l, r) | p(x) }, or r
}

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(2 * n - 1);
    repeat (x, 2 * n - 1) {
        scanf("%d", &a[x]);
    }
    // solve
    if ((n - 1) % 2 == 1) {
        vector<int> b(2 * n - 3);
        repeat (x, 2 * n - 3) {
            b[x] = median(a[x], a[x + 1], a[x + 2]);
        }
        a.swap(b);
        -- n;
    }
    int result = binsearch(1, 2 * n, [&](int limit) {
        vector<char> b(2 * n - 1);
        repeat (x, 2 * n - 1) {
            b[x] = a[x] > limit;
        }
        int result = b[n - 1];
        int dist = 2 * n;
        repeat (x, (2 * n - 1) - 2) {
            if ((b[x] != b[x + 1] and b[x + 1] == b[x + 2])
                    or (b[x] == b[x + 1] and b[x + 1] != b[x + 2])) {
                int ndist = abs((x + 1) - (n - 1));
                if (ndist < dist) {
                    dist = ndist;
                    result = b[x + 1];
                }
            }
        }
        return not result;
    });
    // output
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int n; cin >> n; int nn = n;
	int sum = 0;
	while(n != 0){
			sum += n % 10;
			n = n / 10;
	}
	if(nn % sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;

int main() {
    int n, q;
    cin >> n >> q;
 
    vector<tuple<int, int, int>> c;
    int s, t, x;
    for (int i = 0; i < n; i++) {
        cin >> s >> t >> x;
        c.emplace_back(s - x, 0, x);
        c.emplace_back(t - x, 1, x);
    }
 
    int d;
    for (int i = 0; i < q; i++) {
        cin >> d;
        c.emplace_back(d, 2, 0);
    }
    sort(ALL(c));

    multiset<int> w;
    for (const auto t : c) {
        if (get<1>(t) == 0) {
            w.insert(get<2>(t));
        } else if (get<1>(t) == 1) {
            w.erase(w.find(get<2>(t)));
        } else {
            if (w.size() == 0) {
                cout << -1 << endl;
            } else {
                cout << *(w.begin()) << endl;
            }
        }
    }
}


Measured memory_bytes: 18536