akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {

		long ans = 0;
//		double ans = 0.0;
//		int ans = 0;
//		String ans = "";

		Scanner sc = new Scanner(System.in);
//		double waru = 1000000007;


//		long k = sc.nextLong();
//		long m = sc.nextLong();
//		long n = sc.nextLong();

		int n = sc.nextInt();
		int m = sc.nextInt();
//		int k = sc.nextInt();
//		String s = sc.next();


//		String string = sc.next();

//		StringBuilder s = new StringBuilder(string);

//		String[] strArray = string.split("");

		boolean f = false;

//		String[] s = new String[n];

		int[] a = new int[n];
//		int[] b = new int[n];
//		int[][] a = new int[n][m];

//		long[] p = new long[a];
//		long[] q = new long[b];
//		long[] r = new long[c];

//		ArrayList<Long> list = new ArrayList<>();

		int count = 0;
		for (int i = 0; i < n; i++) {
			a[i]= sc.nextInt();
			count += a[i];
		}


//		for (int i = 0; i < h; i++) {
//			for(int j = 0; j < w; j++) {
//				a[i][j] = sc.nextInt();
//			}
//		}

//		Arrays.sort(a);
		System.err.println(count);
		for(int i = 0; i < n ; i++) {

			double tmp = (double) count / (4*m);
			System.err.println(a[i]+" "+tmp);
			if(a[i] < tmp) {

			} else {
				ans++;
				if(ans >= m) {
					f = true;
					break;
				}
			}
		}



		if(f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}




//		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 24916
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
char s[110][110];
int f[110][110];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(i==1&&j==1)f[i][j]=s[i][j]=='#';
			else{
				f[i][j]=1e9;
				if(i>1)f[i][j]=min(f[i][j],f[i-1][j]+(s[i][j]!=s[i-1][j]&&s[i][j]=='#'));
				if(j>1)f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j]!=s[i][j-1]&&s[i][j]=='#'));
			}
		}
	printf("%d\n",f[n][m]);
	return 0;
}

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

using namespace std;
using ll=long long;

const int N = 51;

long long bino[N][N];

void bino_table() {
    for (int i = 0; i < N; i++) {
        bino[i][0] = 1;
        bino[i][i] = 1;
    }
    for (int i = 1; i < N; i++) {
        for (int j = 1; j < i; j++) {
            bino[i][j] = (bino[i-1][j-1] + bino[i-1][j]) ;
        }
    }
}


void solve() {
    bino_table();
    cout << fixed << setprecision(8);
    int n, A, B;
    cin >> n >> A >> B;
    vector<ll> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end(), greater<ll>());
    double sum = 0;
    for (int i = 0; i < A; i++) {
        sum += a[i];
    }
    sum /= A;
    if (A>=n || a[A]!=a[0]) {
        int need = 0;
        for (int i = 0; i < A; i++) {
            if (a[i]==a[A-1]) need++;
        }
        int tot = 0;
        for (int i = 0; i < n; i++) {
            if (a[i]==a[A-1]) tot++;
        }
        ll res = bino[tot][need];
        cout << sum << "\n" << res; 
    } else {
        int i = A;
        for (; i < n;i++) {
            if (a[i] != a[0]) break;
        }
        ll res = 0;
        B = min(i, B);
        for (int j = A; j <= B; j++) {
            res += bino[i][j];
        }
        cout << sum << "\n" << res;
    }
}

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


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

namespace AtCoderExamCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            bool flag = true;

            if (S.Length + 1 != T.Length)
            {
                flag = false;
            }

            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] != T[i])
                {
                    flag = false;
                }
            }

            if (flag)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 25896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n, h, sum, A[MAXN];

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

    cin >> h >> n;
    for (ll i = 0; i < n; i++) cin >> A[i], sum += A[i];
    cout << (sum >= h ? "Yes" : "No") << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 1024
#include<stdio.h>

int main(void){

while(1){
int a,b;
char op;

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

if(op == '?')
break;

if(op == '+'){

printf("%d\n",a+b);

}else if(op == '-'){

printf("%d\n",a-b);

}else if(op == '*'){

printf("%d\n",a*b);

}else if(op == '/'){

printf("%d\n",a/b);

}

}

return 0;

}

Measured memory_bytes: 600
use itertools::Itertools;
use proconio::input;
use proconio::marker::Usize1;

fn main() {
    input!(n: usize, p: [Usize1; n], q: [Usize1; n]);

    let perms = || (0..n).permutations(n);
    let a = perms().position(|perm| p == perm).unwrap();
    let b = perms().position(|perm| q == perm).unwrap();
    let ans = if a > b { a - b } else { b - a };

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


Measured memory_bytes: 2140
s=input()
l=len(s)
ans=101
if len(set(s))==1:
    print(0)
    exit()
for target in s:
    a=s
    for i in range(l):
        tmp=[]
        for j in range(l-i-1):
            if a[j]==target or a[j+1]==target:
                tmp.append(target)
            else:
                tmp.append(a[j])
        a=tmp
        if len(set(a))==1:
            ans=min(ans,i+1)
            break
print(ans)

Measured memory_bytes: 74112
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<(next<int>() > next<int>() ? "safe" : "unsafe")<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3632
import collections

n,m=map(int,input().split())
a=[int(i) for i in input().split()]

s=0
ans=0
l=[]

for i in a:
    s+=i
    l.append(s%m)

c=collections.Counter(l)

for p,q in c.items():
    if int(p)==0:
        ans+=q*(q+1)//2
    else:
        ans+=q*(q-1)//2


print(ans)

Measured memory_bytes: 17368
#include<iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include<unordered_map>
#define Amr_Abdelazim ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vvll vector<vector<ll> >
#define vpll vector<pair<ll,ll> >
#define P complex<ld>
#define X real()
#define Y imag()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rep(i,n)   for(int i=0;i<n;i++)
#define repp(i,s,n)   for(int i=s;i<=n;i++)
#define print(v) {for(auto i:v)cout<<i<<" ";cout<<"\n";}
#define mkp make_pair
#define clr(ar,v) memset(ar,v,sizeof(ar));
#define TC ll amr_abdelazim;cin>>amr_abdelazim;while(amr_abdelazim--)
#define popcnt(x) __builtin_popcount(x)
#define EPS 1e-9
#define INF 1000000000000000009
#define heeer cout<<"heeeeeeeeer\n";
using namespace std;
//freopen("output.txt", "w", stdout);
//freopen("input.txt", "r", stdin);
const int mod = 1000000007;
const double pi = acos(-1);
class cmp{
public:
	bool operator() (ll &A, ll &B){
		return A > B;
	}
};
bool by_sec(const pll &a, const pll &b){
	if ((abs(a.first) == abs(b.first)))
		return (abs(a.second) < abs(b.second));
	return (abs(a.first) < abs(b.first));
}
bool byth(const tuple<ll, ll, ld>& a, const tuple<ll, ll, ld>& b){
	return (get<2>(a) < get<2>(b));
}
ld dist(P a, P b){
	return (ld)abs(a - b);
}
ll fact[1000009], inv[1000009];
ll fp(ll a, ll b){
	if (b == 0)
		return 1;
	ll ans = fp(a, b / 2);
	ans = (ans * ans)%mod;
	if (b % 2 != 0)
		ans = (ans * (a%mod))%mod;
	return ans;
}
void FacInv(ll n){
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= n; i++)
	{
		fact[i] = ((i%mod) * fact[i - 1] % mod) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r){
	return (((fact[n] * inv[r]) % mod) * inv[n - r]) % mod;
}
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a%b);
}
ll max(ll a, ll b){
	if (a >= b)return a;
	else return b;
}
ll min(ll a, ll b){
	if (a <= b)return a;
	else return b;
}
const int N = 2 * 1000000 + 9;

int main()
{
	Amr_Abdelazim

		ll n, k;
	cin >> n >> k;
	map<ll, ll>mp;
	rep(i, n){
		ll a;
		cin >> a;
		mp[a]++;
	}vll v;
	for (auto i : mp){
		v.push_back(i.second);
	}
	sort(all(v)); ll ans = 0;
	if (v.size()>k){
		ll df = v.size() - k;
		rep(i, df)ans += v[i];
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 17680
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long m=0, a=0, r=0, c=0, h=0;
    for(int i=0; i<n; i++){
        string str;
        cin >> str;
        char ch = str[0];
        if(ch == 'M') m++;
        if(ch == 'A') a++;
        if(ch == 'R') r++;
        if(ch == 'C') c++;
        if(ch == 'H') h++;
    }
    long long sum = 0;
    sum += m*a*r;
    sum += m*a*c;
    sum += m*a*h;
    sum += m*r*c;
    sum += m*r*h;
    sum += m*c*h;
    sum += a*r*c;
    sum += a*r*h;
    sum += a*c*h;
    sum += r*c*h;
    cout << sum << endl;
    return 0;
}

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

int main(void){
    int a,b;
    cin >> a >> b;
    int ans = a-2*b;
    if(ans<=0){
        ans = 0;
    }
    cout <<ans <<endl;
    
    return 0;
    
}















































Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;

ll dp[301][90001];
ll dp2[301][90001];
static ll mod = 998244353;

int main() {

  int N;
  cin >> N;
  int a[N+1];
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  ll all = 1;
  for (int i = 1; i <= N; i++) {
    all *= 3;
    all %= mod;
  }
  //
  dp[1][a[1]]+=1;
  dp[1][0]+=2;
  // Gだけ足す
  dp2[1][a[1]]+=1;
  dp2[1][0]+=1;
  for (int t_num = 2; t_num <= N; t_num++) {
    for (int i = 0; i <= sum; i++) {
      dp[t_num][i] = (dp[t_num][i]+(dp[t_num-1][i]*2))%mod;
      dp2[t_num][i] = (dp2[t_num][i]+dp2[t_num-1][i])%mod;
      if (i+a[t_num] <= 90000) {
        dp[t_num][i+a[t_num]] = (dp[t_num][i+a[t_num]]+dp[t_num-1][i])%mod;
        dp2[t_num][i+a[t_num]] = (dp2[t_num][i+a[t_num]]+dp2[t_num-1][i])%mod;
      }
    }
  }
  ll subtract = 0;
  ll add = 0;
  for (int i = ceil(sum/2.0); i <= sum; i++) {
    subtract += dp[N][i];
    subtract %= mod;
  }
  subtract *= 3;
  subtract %= mod;
  if (sum % 2 == 0) {
    add = dp2[N][sum/2];
    add %= mod;
  }
  add *= 3;
  add %= mod;
  ll ans_sub = (subtract - add) % mod;
  ll ans = (all - ans_sub) + 3*mod;
  ans %= mod;
  cout << ans << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
    if(n%10 == 7 || (n/10)%10 == 7 || (n/100)%10 == 7) cout <<"Yes";
    else cout <<"No";
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;
 
int main() {
	int n,r[200000],minr = 2000000000,ans = -2000000000;
	cin >> n;
	for(int i = 0; i < n; i++) cin >> r[i];
	for(int i = 0; i < n; i++) {
		ans = max(r[i] - minr,ans);
		minr = min(r[i],minr);
	}

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

Measured memory_bytes: 1940
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    int length,f=0;
char str[100];
  
cin>>str;
  length=strlen(str);
  //range=length/2;
for(int i=0;i<length/2;i++)
{ if(str[i]!=str[length-i-1])
     {f+=1; } 
}
 cout<<f;
  return 0;
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int H,W;
  cin >> H >> W;
  string S[H];
  REP(i,H) cin >> S[i];

  REP(y,H) {
    REP(x,W) {
      if (S[y][x] == '#') {
        cout << '#';
        continue;
      }
      int count = 0;
      REP(i,8) {
        int dx = dxs[i];
        int dy = dys[i];
        if (in(0, x+dx, W) && in(0, y+dy, H) && S[y+dy][x+dx] == '#') count++;
      }
      cout << count;
    }
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    print(chr(ord(input())+1))




main()


Measured memory_bytes: 5684
#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <string.h>

using namespace std;

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

    int hPlace = n / 100;
    int tPlace = (n / 10) % 10;
    int oPlace = n % 10;

    if(hPlace == 7  || tPlace == 7 || oPlace == 7) {
        cout<<"Yes";
    }
    else {
        cout<<"No";
    }

}

Measured memory_bytes: 3604
using System;
    using System.Text;
    using System.Collections.Generic;
    using static System.Math;
    using System.Linq;
    using static System.Array;

    namespace ConsoleApp2
    {
        class Program
        {


            static void Main(string[] args)
            {
            var N = long.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            //var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var ans = 0;
            for (int i = 0; i < N; i++)
            {
                if(i == 3)
                {

                }
                var dic1 = new Dictionary<char, bool>();
                for (int j = 0; j <= i; j++)
                {
                    if (!dic1.ContainsKey(S[j]))
                    {
                        dic1.Add(S[j], true);
                    }
                }
                var tmp = 0;
                for (int k = i+1; k < N; k++)
                {
                    if (dic1.ContainsKey(S[k]))
                    {
                        dic1.Remove(S[k]);
                        tmp++;
                    }
                }
                ans = Max(ans, tmp);
            }
                Console.WriteLine(ans);
            }
        }
    }


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

int main(){
  	int N, K, x[110], step = 0;
  
  	cin >> N >> K;
  	for(int i = 0;i < N; i++)	cin >> x[i];
  
  	for(int i = 0;i < N; i++){
      	if(x[i] <= abs(K-x[i]))	step += 2*x[i];
      	else if(x[i] > abs(K-x[i]))	step += 2*abs(K-x[i]);
    }
  
  	cout << step << endl;
  
  	return 0;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,x[100010],ans=0;
vector <int> v;

int main()
{
	cin>>n>>m;
	rep(i,m) scanf("%d",&x[i]);
	sort(x,x+m);
	rep(i,m-1) v.pb(x[i+1]-x[i]);//,cout<<x[i+1]<<' '<<x[i]<<' '<<x[i+1]-x[i]<<endl;
	int sz=(int)v.size();
	sort(v.begin(),v.end());
	//rep(i,sz) cout<<v[i]<<' ';
	//cout<<endl;
	rep(i,sz-(n-1)) ans+=v[i];
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 1276
a,b,c,d = input()
for i in range(2**3):
    x = ['-','-','-']
    for j in range(3):
        if i>>j&1:
            x[j] = '+'
    if eval(a+x[0]+b+x[1]+c+x[2]+d) == 7:
        print(a+x[0]+b+x[1]+c+x[2]+d + '=7')
        break

Measured memory_bytes: 9112
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const ld pi=acos(-1);
const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

    if(n==1 || m==1)
    {
        cout<<1;
        return;
    }

    int p=n*m;

    int ans=p/2+p%2;
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int num,temp,j,i,d,x,a[110],sum=0;
        scanf("%d%d",&d,&x);
        for(i = 0;i < n; i++)
        {
            scanf("%d",&a[i]);
        }
        for(i = 0;i < n;i++)
        {
            j=2;
            num=1;
            temp=a[i];
            while(a[i]+1<=d)
            {
                num++;
                a[i]=j*temp;
                j++;


            }
            sum += num;

        }
        printf("%d\n",sum+x);



    }
}


Measured memory_bytes: 128
def count(h_list):
    if len(h_list) == 0:
        return 0
    if len(h_list) == 1:
        return h_list[0]
    if 0 not in h_list:
        return 1 + count([x-1 for x in h_list])
    elif all(x == 1 for x in h_list):
        return 1
    return sum([count(x) for x in divide_by_zero(h_list)])


def divide_by_zero(arr):
    non_zero = []
    for ar in arr:
        if ar == 0:
            if non_zero:
                yield non_zero
                non_zero = []
        else:
            non_zero.append(ar)
    yield non_zero


n = int(input())
h_list = [int(x) for x in input().split(" ")]
print(count(h_list))


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
using namespace std;
int main() {
			int N;
            int X;
            int T;
	for (int i = 0; i<3; i++)
	{
		cin>>N;
        cin>>X;
        cin>>T;
	}
  int ans=0;
  if(N%X==0)
  {
  ans = (N/X);
    ans= ans*T;
  }
  else
  {
  ans = (N/X);
    ans= ans*T+T;
    
  }
  
	cout << ans << endl;
}

Measured memory_bytes: 3140
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    string S;
    cin >> S;
    if (S == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3624
S = gets.chomp.chars
Q = gets.to_i
queries = Q.times.map do
  gets.chomp.split
end

reversed = false
queries.each do |q|
  f = q[0].to_i
  if f == 1
    reversed = !reversed
  else
    f = q[1].to_i
    c = q[2]
    if f == 1
      if reversed
        S.push(c)
      else
        S.unshift(c)
      end
    else
      if reversed
        S.unshift(c)
      else
        S.push(c)
      end
    end
  end
end

ans = (reversed ? S.reverse : S).join('')
puts ans

Measured memory_bytes: 49276
import sys
import math
def solution():
    a,b,h,m=map(int,input().split())
    mins=m*6
    if(h==12):
        h=0
    hr=h*30+m/2
    angle=min((abs(hr-mins),360-abs(hr-mins)))
    c=a**2+b**2-(2*a*b*math.cos(angle*math.pi/180))
    c=c**(0.5)
    print(c)
if __name__ == "__main__":
    solution()
    

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

const int max_attempt=50000;
const int change_per_attempt=4;

int main()
{
	srand(1);


	int d;
	cin >> d;

	vector<int> c(26+1);
	for (int i=1;i<=26;++i)
	{
		cin >> c[i];
	}

	vector<vector<int>> s(d+1,vector<int>(26+1));
	for (int i=1;i<=d;++i)
	{
		for (int j=1;j<=26;++j)
		{
			cin >> s[i][j];
		}
	}
	vector<int> t(d+1);
	vector<int> t_backup(d+1);
	for (int i=1;i<=d;++i)
	{
		// cin >> t[i];
		t[i]=rand()%26+1;
	}

#ifdef NEVER_DEFINED
	int m;
	cin >> m;
	vector<pair<int,int>> q(m);

	for (int i=0;i<m;++i)
	{
		int dd,qq;
		cin >> dd >> qq;
		q[i]=make_pair(dd,qq);
	}
#endif

	vector<int> last(26+1);
	vector<set<int>> hh(26+1);
	vector<set<int>> hh_backup(26+1);
	for (int i=1;i<=26;++i)
	{
		last[i]=0;
		hh[i].insert(0);
		hh[i].insert(d+1);
	}


	int64_t score=0;
	for (int i=1;i<=d;++i)
	{
		score+=s[i][t[i]];
		last[t[i]]=i;
		hh[t[i]].insert(i);
		for (int j=1;j<=26;++j)
		{
			score-=c[j]*(i-last[j]);
		}
		//cout << score << endl;
	}

	for (int i=0;i<max_attempt;++i)
	{
		t_backup=t;
		hh_backup=hh;
		int prev_score=score;
		for (int j=0;j<change_per_attempt;++j)
		{
			//int dd=q[i].first;
			//int qq=q[i].second;
			int dd=rand()%d+1;
			int qq=rand()%26+1;
			int rr=t[dd];
			//int prev_score=score;

			score-=s[dd][rr];
			score+=s[dd][qq];
			auto it=hh[rr].find(dd);
			auto prev=it;
			--prev;
			auto next=it;
			++next;
			score-=(dd-*prev)*(*next-dd)*c[rr];

			hh[rr].erase(dd);
			t[dd]=qq;

			hh[qq].insert(dd);
			it=hh[qq].find(dd);
			prev=it;
			--prev;
			next=it;
			++next;
			score+=(dd-*prev)*(*next-dd)*c[qq];
		}

		//fprintf(stderr,"%d %lld %lld\n",i,prev_score,score);
		if (score<prev_score)
		{
			// get back to original
#ifdef NEVER_DEFINED
			t[dd]=rr;
			hh[rr].insert(dd);
			hh[qq].erase(dd);
#endif
			t=t_backup;
			hh=hh_backup;
			score=prev_score;
		}
	}

	fprintf(stderr,"%lld\n",score);
	for (int i=1;i<=d;++i)
	{
		cout << t[i] << endl;
	}

}






Measured memory_bytes: 3800
#include <iostream>
#include <cstring>
#include <string.h>

using namespace std;



int main()
{
    string a,b;
    cin>>a>>b;
    bool flag=false;

    string c=a+a;
    if( c.find(b)!=string::npos)
        flag=true;
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
  long N;
  cin>>N;
  vector<string> s(N);
  vector<long> p(5);
  if(N<=2){
    cout<<0<<endl;
    return 0;
  }
  for(int i=0;i<N;i++) cin>>s[i];
  //sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(s[i][0]=='M') p[0]++;
    if(s[i][0]=='A') p[1]++;
    if(s[i][0]=='R') p[2]++;
    if(s[i][0]=='C') p[3]++;
    if(s[i][0]=='H') p[4]++;
  }
  long ans=0;

  for(int i=0;i<=2;i++){
    for(int j=i+1;j<=3;j++){
      for(int k=j+1;k<=4;k++){
        ans += p[i]*p[j]*p[k];
      }
    }
  }

  cout<<ans<<endl;

  }


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

using namespace std;

int N;
int main(void) {
  cin >> N;
  auto v = vector<int>(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  int div4 = 0, div2 = 0;
  for (int i = 0; i < N; i++) {
    if (v[i] % 4 == 0) div4++;
    else if (v[i] % 2 == 0) div2++;
  }
  int rem = N - div4 - div2;
  if (div2 + div4 == N) cout << "Yes" << endl;
  else if (div4 * 2 + 1 == N) cout << "Yes" << endl;
  else if (div4 == rem) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int[] B = new int[N-1];
      for(int i=0; i<N - 1; i++){ B[i] = sc.nextInt();}
      int[] A = new int[N];
      for(int i=0; i<N; i++){ A[i] = 100001;}
      int ans=0;
      
      for(int i=0; i<N-1; i++){
      	int n = B[i];
        if(A[i]>n) A[i]=n;
        if(A[i+1]>n) A[i+1]=n;
      }
      for(int i=0; i<N; i++)
        ans += A[i];
      
      System.out.println(ans);

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
//関数
const long MOD=1000000007;
long powM(long x,long n){//both positive
    if(n<=0) return 1%MOD;//特殊
    if(n==1) return x%MOD;
    if(n%2==1) return x*powM(x,n-1)%MOD;
    
    long X=powM(x,n/2)%MOD;
    return (X*X)%MOD;
}


int main(void){
    //入力
    string L;
    cin>>L;
    
    //計算
    long N=L.size();
    long ans=0;
    long count=0;
    for(int i=0;i<=N;i++){
        if(i<N && L.at(i)=='0') continue;
        count++;
        
        ans+=powM(2,count-1)*powM(3,N-i-1);
        ans%=MOD;
        //cout<<i<<" "<<powM(2,count-1)*powM(3,N-i-1)<<endl;
    }
    
    //出力
    cout<<ans<<endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		out(ni() * ni());

	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 35620
import java.util.Scanner;

/**
 * べき乗
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=ja">NTL_1_B</a>
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();

		System.out.println(power(m, n));

		sc.close();
	}

	private static long power(long m, long n) {
		if (n == 0) return 1;
		long res = power(m, n / 2);
		if (n % 2 == 0) {
			return res * res % 1000000007;
		} else {
			return ((res * res % 1000000007) * m) % 1000000007;
		}
	}

}



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

using namespace std;
#define INFS (1LL<<28)
#define INF (1LL<<60)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
#define all(n) n.begin(),n.end()

int sn(int a,int b,int n){
  int x=(2*a+(n-1)*b%DEKAI);
  int y=n;  
  return x*y%DEKAI*500000004%DEKAI;
}

int cnt[3000];

signed main(){
  int n,k;
  cin>>n>>k;
  int a[3000];
  int re[5000];
  lp(i,n)cin>>a[i];
  // reverse(a,a+n);
  lp(i,n){
    re[i]=cnt[a[i]];
    for(int j=0;j<a[i];j++){
      cnt[j]++;
    }
    //cout<<re[i]<<endl;
  }
  lp(z,n){
    int i=z+n;
    re[i]=cnt[a[z]];
    for(int j=0;j<a[z];j++){
      cnt[j]++;
    }
    //cout<<re[i]<<endl;
  }
  int ans=0;
  lp(i,n){
    ans+=sn(re[i],re[n+i]-re[i],k);
    ans%=DEKAI;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
ans=[0]*n
for i in range(n,0,-1):
    if i*2>n:
        ans[i-1]=a[i-1]
    else:
        j=i
        k=0
        while j<=n:
            k+=ans[j-1]
            j+=i
        if k%2!=a[i-1]:
            ans[i-1]=1
m=sum(ans)
print(m)
for i in range(n):
    if ans[i]==1:
        print(i+1,end=' ')

Measured memory_bytes: 7276
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0;
    int limit = ceil((double)sum / (4 * m));
    for(int i = 0; i < n; ++i){
        if(a[i] < limit)    continue;
        ++cnt;
    }
    if(cnt >= m)    cout << "Yes\n";
    else    cout << "No\n";
}


Measured memory_bytes: 256
n=int(input())
s=input()
w=[0]*n
e=[0]*n
for i in range(n):
    if s[i]=="W":
        if i==0:
           w[i]+=1
        else:
            w[i]+=w[i-1]+1
            e[i]+=e[i-1]
    else:
        if i==0:
            e[i]+=1
        else:
            e[i]+=e[i-1]+1
            w[i]+=w[i-1]
min=9999999
for i in range(n):
    if i==0:
        num=e[n-1]-e[i]

    else:
        num=w[i-1]+e[n-1]-e[i]
    if min>num:
        min=num
print(min)


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

using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<int>> jobs(m);
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    if(a > m) continue;
    jobs[m-a].push_back(b);
  }
  priority_queue<int> q;
  long long ans=0;
  for(int i=m-1;i>=0;i--){
    for(int b:jobs[i]){
      q.push(b);
    }
    if(!q.empty()){
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define mset(s,t) memset(s,t,sizeof(s))
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
#define int long long
const int N = 5000005;
int n, q;
struct Seg{
  #define ls (u<<1)
  #define rs (u<<1|1)
  int minn[N],tag[N];
  void pushup(int u){
    minn[u]=min(minn[ls],minn[rs]);
  } 
  void pushdown(int u){
    if(tag[u]!=1e9){
      tag[ls]=min(tag[ls],tag[u]);
      tag[rs]=min(tag[rs],tag[u]);
      minn[ls]=min(minn[ls],tag[u]);
      minn[rs]=min(minn[rs],tag[u]);
      tag[u]=1e9;
    }
  }
  void build(int u,int l,int r){
    tag[u]=1e9,minn[u]=n;
    if(l==r)return;
    int mid=l+r>>1;
    build(ls,l,mid),build(rs,mid+1,r);
  }
  void update(int u,int l,int r,int ql,int qr,int dlt){
    pushdown(u);
    if(ql<=l&&r<=qr){
      minn[u]=min(minn[u],dlt);
      tag[u]=min(tag[u],dlt);
      return;
    }
    pushdown(u);
    int mid=l+r>>1;
    if(ql<=mid)update(ls,l,mid,ql,qr,dlt);
    if(qr>mid)update(rs,mid+1,r,ql,qr,dlt);
    pushup(u);
  }
  int query(int u,int l,int r,int pos){
    pushdown(u);
    if(l==r)return minn[u];
    int mid=l+r>>1;
    if(pos<=mid)return query(ls,l,mid,pos);
    else return query(rs,mid+1,r,pos);
  }
}row,col;
signed main(){
  n=read(),q=read();
  ll ans=1ll*(n-2)*(n-2);
  row.build(1,1,n);
  col.build(1,1,n);
  while(q--){
    int opt=read(),x=read();
    if(opt==1){
      int t=col.query(1,1,n,x);
      ans-=max(0ll,t-2);
      if(t-1>=2)row.update(1,1,n,2,t-1,x);
    }else{
      int t=row.query(1,1,n,x);
      ans-=max(0ll,t-2);
      if(t-1>=2)col.update(1,1,n,2,t-1,x);
    }
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 34852
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
int main()
{
ll n;
cin>>n;
if(n%2>0){
cout<<n/2+1<<endl;
}else{
    cout<<n/2<<endl;
}
}














Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
	int n;
	cin >> n;
	int sum = -n;
    set<int> s;
    int i = 1;
	while(sum < 0){
        sum += i;
        s.it(i);
        i++;
	}
	s.erase(sum);
	for(auto ite:s)P(ite);
	return  0;
}

Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

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

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int x = vs[0];
			int n = vs[1];
			if (n == 0) {
				Console.WriteLine(x);
				return;
			}
			HashSet<int> hs = Console.ReadLine().Split().Select(int.Parse).ToHashSet();

			int ans = x;
			int i = 0;
			while (true) {
				if (!hs.Contains(x - i)) {
					ans = x - i;
					break;
				} else if (!hs.Contains(x + i)) {
					ans = x + i;
					break;
				}
				i++;
			}
			Console.WriteLine(ans);
		}
	}
}


Measured memory_bytes: 28268
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



double x[3], y[3], r, m;

double len(int i, int j) {
	return sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
}

signed main() {
	rep(i,3) cin >> x[i] >> y[i];
	rep(i,3) x[i] -= x[2], y[i] -= y[2];
	r = abs(x[0]*y[1] - y[0]*x[1]) / (len(0,1)+len(1,2)+len(2,0));
	m = max(len(0,1), max(len(1,2), len(2,0)));
	printf("%.14lf\n", r*m / (r*2+m));
}

Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>

int main()

{
	int H, W;
	while(scanf("%d %d", &H, &W))
	{
		if (H==0 && W==H)
		{
			break;
		}
		int i;
		for ( i=0 ;i < H ; i++)
		{
			int j;
			for ( j=0 ;j < W ; j++)	
			{
			printf("#");
			}
			printf("\n");
		} printf("\n");		
	}
	

	return 0;
}


Measured memory_bytes: 2036
from queue import Queue

N = int(input())
H = list(map(int, input().split()))

que = Queue()
que.put(H)
ans = 0
while not que.empty():
    H = que.get()
    minh = min(H)
    H = [h - minh for h in H]
    ans += minh
    res = []
    for h in H:
        if h > 0:
            res.append(h)
        elif h == 0 and len(res) > 0:
            que.put(res)
            res = []
    if len(res) > 0:
        que.put(res)
print(ans)


Measured memory_bytes: 38892