akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

def main():
    n = int(input())
    ary = [list(map(int, stdin.readline().split())) for _ in range(n)]
    dp = [[0 for _ in range(3)] for _ in range(n)]
    for k in range(n):
        for i in range(3):
            if k == 0:
                dp[k][i] = ary[k][i]
            else:
                dp[k][i] = ary[k][i] + max([dp[k-1][j] for j in range(3) if j != i])
    print(max(dp[n-1]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 72028
#include<iostream>
#include<cmath>
#include<string>
#include<cctype>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
        for(;;){
                int h,w;
                cin>>h>>w;
                if(h==0 && w==0) break;
                for(int j=0;j<h;j++){
                        for(int k=0;k<w;k++){
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}

Measured memory_bytes: 1108
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

int largestRectangleInHistogram(const vector<int> &h) {
  int n = h.size();
  deque<int> s; // stack
  vector<int> l(n), r(n);
  rep(i, n) {
    while (s.size() && h[s.back()] >= h[i]) s.pop_back();
    l[i] = s.size() ? (s.back() + 1) : 0;
    s.emplace_back(i);
  }
  s.clear();
  for (int i = n - 1; i >= 0; i--) {
    while (s.size() && h[s.back()] >= h[i]) s.pop_back();
    r[i] = s.size() ? s.back() : n;
    s.emplace_back(i);
  }
  int maxi = 0;
  rep(i, n) cmax(maxi, h[i] * (r[i] - l[i]));
  return maxi;
}

main() {
  int n;
  cin >> n;
  vector<int> h(n);
  cin >> h;
  cout << largestRectangleInHistogram(h) << endl;
}



Measured memory_bytes: 5856
n=int(input());f=["aabbc","hi..c","hi..d","g.jjd","gffee"];x=list("cdcd");a=[n*["."]for _ in range(n)];z={2:[-1],3:["abb","a.c","ddc"],5:["aabbc","hi..c","hi..d","g.jjd","gffee"],7:["..abc..","..abc..","aax..aa","bbx..bb","cc.yycc","..abc..","..abc.."]}
if n in z:print(*z[n]);exit()
if n%2:
  for i in range(5):
    for j in range(5):a[-i-1][-j-1]=f[i][j]
  n-=5
for i in range(0,n,2):a[i][i],a[i][i+1],a[i+1][i],a[i+1][i+1]=list("aabb")
if n%4:
  for i in range(0,n,2):a[i][(i+2)%n],a[i][(i+3)%n],a[i+1][(i+2)%n],a[i+1][(i+3)%n]=x
else:
  for i in range(0,n,2):a[n-i-2][i],a[n-i-2][i+1],a[n-i-1][i],a[n-i-1][i+1]=x
for i in a:print("".join(i))

Measured memory_bytes: 11892
open Scanf;;
open Printf;;

let rint () = scanf " %d" (fun x -> x);;
let rpoint () = scanf " %f %f" (fun x y -> x, y);;

let () =
  let n = rint () in
  let ps = Array.init n (fun _ -> rpoint ()) in
  Array.sort (fun (a, b) (c, d) -> compare (atan2 b a) (atan2 d c)) ps;
  let pi = acos ~-.1.0 in
  let x = ref 0.0 in
  let y = ref 0.0 in
  let j = ref 0 in
  let ans = ref 0.0 in
  let get_angle i = let (x, y) = ps.(i mod n) in if i < n then atan2 y x else atan2 y x +. 2.0 *. pi in
  for i = 0 to n - 1 do
    while !j < i + n && get_angle !j <= get_angle i +. pi do
      x := !x +. fst ps.(!j mod n);
      y := !y +. snd ps.(!j mod n);
      incr j;
    done;
    ans := max !ans (!x *. !x +. !y *. !y);
    x := !x -. fst ps.(i);
    y := !y -. snd ps.(i);
    ans := max !ans (!x *. !x +. !y *. !y);
  done;
  printf "%.15f\n" (sqrt !ans);


Measured memory_bytes: 2432
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

pair<int,int> cnt(int l,int ll)
{
  int tmp;
  pair<int,int> ans;
  tmp=l/(ll+1);
  ans=make_pair(tmp*ll,tmp);
  ans.first+=l%(ll+1);
  return ans;
}

int main()
{
  pair<int,int> p1,p2;
  int a,b,c,d,q,tmp,mi,ma,minseg,left,right,mid,x,i,l,tmp1;
  scanf("%d",&q);
  for (l=0;l<q;l++)
  {
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if (a==b+1)
    {
      tmp=1;
      left=a+b;
    }
    else if (a==b)
    {
      tmp=1;
      left=a+b;
    }
    else if (a+1==b)
    {
      tmp=1;
      left=0;
    }
    else
    {
      if (a<b)
      {
        mi=a;ma=b;
      }
      else
      {
        mi=b;ma=a;
      }
      tmp=ma/(mi+1);
      while (1)
      {
        //cout<<tmp<<endl;
        minseg=ma/tmp;
        if (ma%tmp!=0) minseg++;
        if (mi+1<minseg) tmp++;
        else break;
      }
      //cout<<tmp<<endl;
      left=0;right=a+b+1;
      while (right-left>1)
      {
        mid=(left+right)/2;
        p1=cnt(mid,tmp);
        p2=cnt(a+b-mid,tmp);
        swap(p2.first,p2.second);
        if (p1.first+p2.first<a) left=mid;
        else if (p1.first+p2.first>a) right=mid;
        else
        {
          if (((mid+1)%(tmp+1)==0)&&((a+b-mid)%(tmp+1)==0)) left=mid;
          else if ((mid%(tmp+1)==0)&&((a+b-mid+1)%(tmp+1)==0)) right=mid;
          else left=mid;
        }
      }
      //cout<<left<<endl;
      for (tmp1=left+10;tmp1>=left-10;tmp1--)
      {
        if ((tmp1<0)||(tmp1>a+b)) continue;
        p1=cnt(tmp1,tmp);
        p2=cnt(a+b-tmp1,tmp);
        swap(p2.first,p2.second);
        if (p1.first+p2.first==a)
        {
          if (((tmp1+1)%(tmp+1)==0)&&((a+b-tmp1)%(tmp+1)==0)) continue;
          if ((tmp1%(tmp+1)==0)&&((a+b-tmp1+1)%(tmp+1)==0)) continue;
          left=tmp1;
          break;
        }
      }
    }
      //cout<<"left:"<<left<<endl;
    for (i=c;i<=d;i++)
    {
      if (i<=left)
      {
        x=(i-1)%(tmp+1);
        if (x==tmp) printf("B");
        else printf("A");
      }
      else
      {
        //cout<<tmp<<endl;
        x=(a+b-i)%(tmp+1);
        if (x==tmp) printf("A");
        else printf("B");
      }
    }
    printf("\n");
  }
  return 0;
}

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

int h,m,s,r;
void b(){
    h=r/3600,m=(r%3600)/60,s=r%60;
    if(h/10<1)cout<<0;cout<<h<<":";
    if(m/10<1)cout<<0;cout<<m<<":";
    if(s/10<1)cout<<0;cout<<s<<endl;
}
int main(){
    while(cin>>h>>m>>s){
        if(h==-1)break;
        r=120*60-h*60*60-m*60-s;
        b();
        r*=3;
        b();
    }
}

Measured memory_bytes: 1160
N = int(input())
s = list(list(input()) for i in range(N))
for i in range(N):
    s[i].sort()
s.sort()
ans = 0
same = 1
for i in range(1,N):
    if s[i] == s[i-1]:
        ans += same
        same += 1
    else:
        same = 1
print(ans)

Measured memory_bytes: 24652
#include<stdio.h>
int main(){
	int a,b,c,d,e,n=9,i=1,t;
	scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
	if(n>a%10&&a%10!=0){n=a%10;}
	if(n>b%10&&b%10!=0){n=b%10;}
	if(n>c%10&&c%10!=0){n=c%10;}
	if(n>d%10&&d%10!=0){n=d%10;}
	if(n>e%10&&e%10!=0){n=e%10;}
	if(a%10==0&&b%10==0&&c%10==0&&d%10==0&&e%10==0&&n==9){n=0;i=0;}
	int A=1,B=1,C=1,D=1,E=1;
	if(a%10==0){A=0;}
	if(b%10==0){B=0;}
	if(c%10==0){C=0;}
	if(d%10==0){D=0;}
	if(e%10==0){E=0;}
	t=(a/10+b/10+c/10+d/10+e/10+A+B+C+D+E-i)*10+n;
	printf("\n%d",t);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=10+10;

int main()
{

    int n;
    while(~scanf("%d",&n)){
        int x,dd=1,sum=0;
        for(int i=0;i<n;i++){
            scanf("%d",&x);
            if(i==0) dd=x;
            dd=__gcd(dd,x);
        }
        while(dd%2==0){
            dd/=2;
            sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}




Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<stack>
#include<unordered_map>
#include<bitset>
#include<limits>
#include<complex>
#include<array>
#include <iostream>

using namespace std;
#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define REP(i,n) rep(i,0,n)
#define ll long long
int main()
{
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
    ll ans=0;
  if(A >= K) ans = K;
  else if (A+B >= K) ans =A;
  else ans=2*A+B-K;
  cout << ans << endl;
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    set<int> s;
    int A;
    for (int i = 0; i < N; i++) {
        cin >> A;
        s.insert(A);
    }
    if (s.size() == N) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#define ook order_of_key
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define MOD 998244353
#define MID (l+r)/2
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define mx 100003
#define pc(x) putchar_unlocked(x);
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds;
double n,m,d,jaw;
int main(){
	cin>>n>>m>>d;
	double jaw=(m-1)*(n-d)*2;
	jaw/=n;
	jaw/=n;
	if(d==0)
		jaw/=(double)(2);
	cout<<fixed<<setprecision(9)<<jaw;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FORr(i, j, 0)
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int N, K;
    cin >> N >> K;
    int latte = 0, malta = 0;
    rep(i, N) {
        int tmp = N;
        if(i + 1 < K) {
            int fact = i + 1;
            while(fact < K) {
                tmp *= 2;
                fact *= 2;
            }
        }
        chmax(latte, tmp);
        malta += latte / tmp;
    }
    printf("%.20f\n", (double)((double)malta/ (double)latte));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main implements Runnable {

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int size = s.length();
        int[] sequence = new int[100000];
        int idx = 0;
        int prevIdx = 0;
        int prev = s.charAt(0) - '0';
        for (int i = 1; i < size; i++) {
            int current = s.charAt(i) - '0';
            if (current != prev) {
                sequence[idx] = i - prevIdx;
                prevIdx = i;
                prev = current;
                idx++;
            }
        }
        sequence[idx] = size - prevIdx;

        int sum = 0;
        int least = Integer.MAX_VALUE;
        for (int i = 0; i <= idx; i++) {
            sum += sequence[i];
            least = Math.min(Math.max(sum, size - sum), least);
        }
        System.out.println(least);
    }
}


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

int main( void )
{
  int A, B;
  cin >> A >> B;
  int count = 0;
  
  for( int i = A; i <= B; i++ ) {
    if(  i % 10 == ( i / 10000 ) % 10 && ( i / 10 ) % 10 == ( i / 1000 ) % 10 )
      count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+9 + 7)




//cout<<fixed<<setprecision(10);
int main(){
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    s[k-1]-='A'-'a';
    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 3624
import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
    N, M = map(int, input().split())

    ball = [1] * N
    hasRed = [False] * N
    hasRed[0] = True

    for _ in range(M):
        fr ,to = map(int, input().split())
        fr -= 1
        to -= 1
        if hasRed[fr]:
            hasRed[to] = True
        ball[fr] -= 1
        if ball[fr] == 0:
            hasRed[fr] = False
        ball[to] += 1

    ans = 0
    for has, count in zip(hasRed, ball):
        if has and count > 0:
            ans += 1

    print(ans)


sol()

Measured memory_bytes: 4852
#include <stdio.h>
#include <string.h>
//using ll = long long;

int main(){
    int n, k, i;
    char s[1000000];
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%d",&k);
    for (i=0;i<n;i++){

        if(s[i] != s[k-1]){
            s[i] = '*';
        }
    }
    printf("%s\n",s);
    return 0;
}

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

using namespace std;

int main()
{
    string a,b;
    int x;
    cin>>a>>b;

    int c=stoi(a+b);
    x=sqrt(c);
    if(c-(x*x)==0)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


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

int search(const int array[], int high, int key)
{
	int low = 0;
	int mid;
	int n=-1;
	while(low<=high){
		mid = (low + high)/2;
		if( array[mid] == key ){
			n = mid;
			break;
		}else if ( array[mid] < key){
			low = mid + 1;
		}else{
			high = mid -1;
		}
	}
	return(n);
}

int main(void){
	int prime[5136];
	prime[1] = 2;
	prime[2] = 3;
	int ptr=3;
	for(int num=5; num<=50000; num++){
		bool f = false;
		for(int i=1; i<ptr; i++){
			if(prime[i]*prime[i] > num){
				break;
			}
			if(num%prime[i]==0) {
				f = true;
				break;
			}
		}
		if(!f) {
			prime[ptr++] = num;
		}
	}
	prime[ptr] = 50001;
	int n;
	while(cin >> n){
		if(!n) break;
		int count = 0;
		if(n%2==0){
			for(int i=1; prime[i] <= n/2; i++){
					if(search(prime,ptr,n-prime[i])!=-1) count++;
			}
		}else{
			if(search(prime,ptr,n-2)!=-1) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 884
def main():
    mod=10**9+7
    def square(x,y):
        ret=1
        xx=x
        while y:
            if y%2==1:
                ret=ret*xx%mod
            xx=xx**2%mod
            y//=2
        return ret
    n,k=map(int,input().split())
    ans=0
    dp=[0]*(k+1)
    for i in range(k,0,-1):
        x=square(k//i,n)
        for j in range(2,k//i+1):
            x=(x-dp[i*j])%mod
        dp[i]=x
        ans=(ans+x*i)%mod  
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 74940
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
ca=0
cb=0
cc=0
for i in range(n):
    if p[i]<=a:
        ca+=1
    elif a<p[i] and p[i]<=b:
        cb+=1
    else:
        cc+=1
print(min(ca,cb,cc))

Measured memory_bytes: 3064
s=input()
if s[0]==s[len(s)-1]and len(s)%2==0:
    print("First")
if s[0]==s[len(s)-1]and len(s)%2==1:
    print("Second")
if s[0]!=s[len(s)-1]and len(s)%2==0:
    print("Second")
if s[0]!=s[len(s)-1]and len(s)%2==1:
    print("First")

Measured memory_bytes: 3316
import java.io.*;

public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            System.out.println("a " + (a < b ? "<" : a > b ? ">" : "==") + " b");
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

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

grid = []

for _ in range(h):
    line = input().rstrip()
    if line.count('#') == 0:
        continue
    grid.append(line)


remove_columns = []

for c in range(w):
    for r in range(len(grid)):
        if grid[r][c] == '#':
            break
    else:
        remove_columns.append(c)

for line in grid:
    for i, l in enumerate(line):
        if i not in remove_columns:
            print(l, end='')
    print()



Measured memory_bytes: 4468
def solve():
    N, M = map(int, input().split())
    INF = 10 ** 9
    dp = [INF] * (10 ** 7)
    dp[0] = 0

    for _ in range(M):
        a, b = list(map(int, input().split()))
        for i in range(N + 1):
            if dp[i] == INF:
                continue
            dp[i+a] = min(dp[i+a], dp[i] + b)
    return min(dp[N:])

print(solve())

Measured memory_bytes: 193540
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

int a[3];

int main() {
  //  freopen("a.in", "r", stdin);
  //  freopen("a.out", "w", stdout);
  scanf("%d", &a[0]);
  scanf("%d", &a[1]);
  scanf("%d", &a[2]);
  sort(a, a + 3);
  printf("%d\n", a[2] * 10 + a[1] + a[0]);
  return 0;
}


Measured memory_bytes: 256
<>;
$_=<>;
$x=y/R//*y/G//*y/B//;
for$i(1..(@_=/./g)){
	for($i..@_-$i){
		$x-=($_[$_-$i]^$_[$_]^$_[$_+$i])eq W
	}
}
print$x


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

int main(){
  int N, K; cin >> N >> K; ll x[N], y[N];
  rep(i, N){
    cin >> x[i] >> y[i];
  }
  ll ans = longinf;
  if(K==2){
    rep(i, N){
      rep(j, N){
        if(i==j) continue;
        ans = min(abs(x[i]-x[j])*abs(y[i]-y[j]), ans);
      }
    }
    cout << ans << endl; return 0;
  }
  if(K==3){
    rep(i, N){
    rep(j, N){
      if(i==j) continue;
      rep(k, N){
        if(i==k || j==k) continue;
        ll R = max({x[i], x[j], x[k]});
        ll L = min({x[i], x[j], x[k]});
        ll U = max({y[i], y[j], y[k]});
        ll D = min({y[i], y[j], y[k]});
        ans = min(ans, (R-L)*(U-D));
      }
    }
    }
    cout << ans << endl; return 0;
  }
  rep(i, N){
    rep(j, N){
      if(i==j) continue;
      rep(k, N){
        if(i==k || j==k) continue;
        rep(l, N){
          if(i==l || j==l || k==l) continue;
          ll R = max({x[i], x[j], x[k], x[l]});
          ll L = min({x[i], x[j], x[k], x[l]});
          ll U = max({y[i], y[j], y[k], y[l]});
          ll D = min({y[i], y[j], y[k], y[l]});
          int cnt = 0;
          rep(m, N){
            if(x[m]>=L&&x[m]<=R&&y[m]<=U&&y[m]>=D)
              cnt++;
          }
          if(cnt>=K) ans = min(ans, (R-L)*(U-D));
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    Integer[] a=new Integer[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    Arrays.sort(a);
    int nc=a[n-1];
    int ck=a[0];
    for(int i=1;i<n-1;i++){
      if(calc(nc,ck)<calc(nc,a[i])){
        ck=a[i];
      }
    }
    System.out.println(nc+" "+ck);
  }
  static int calc(int n,int x){
    x=Math.min(x,n-x);
    return -(n/2-x);
  }
}

Measured memory_bytes: 64476
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n--){
    int h;
    cin >> h;
    if(k <= h) ans++;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
//AOJ0003 Is it a Right Triangle?
#include <stdio.h>

int main(){
	int i,num[3],line;
	scanf("%d",&line);
	for(i = 0; i < line; i++){
		if(scanf("%d %d %d",&num[0],&num[1],&num[2]) == EOF)break;
		if((num[0]*num[0] == num[1]*num[1]+num[2]*num[2])
			|| (num[1]*num[1] == num[0]*num[0]+num[2]*num[2])
			|| (num[2]*num[2] == num[0]*num[0]+num[1]*num[1]))
			printf("YES\n");
		else printf("NO\n");
		num[0]=0;num[1]=0;num[2]=0;
	}
	return 0;
}

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

int main(void){
   long long A,B,K;
   cin>>A>>B>>K;
   for(int i=0;i<K;i++){
      if(i%2==0){
         if(A%2!=0){
            A-=1;
         }
         B+=A/2;
         A/=2;
      }else{
         if(B%2!=0){
            B-=1;
         }
         A+=B/2;
         B/=2;
      }
   }
   cout<<A<<" "<<B<<endl;
   return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
// #include"myfile.h"

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(1e5 + 10)

using namespace std;



void solve() {
	string s;
	cin >> s;
	int n = s.length();

	int dp[n + 1][13] = {};

	for (int i = n; i >= 0; i--) {
		for (int mo = 0; mo < 13; mo++) {
			if (i == n) dp[i][mo] = (mo == 5);
			else {
				if (s[i] != '?')
					dp[i][mo] += dp[i + 1][(mo * 10 + s[i] - '0') % 13] % mod, dp[i][mo] %= mod;
				else
					for (int no = 0; no <= 9; no++)
						dp[i][mo] += dp[i + 1][(mo * 10 + no) % 13] % mod, dp[i][mo] %= mod;
			}
		}
	}

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

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 13896
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define ALL(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    string S;cin >>S;
    ll T=0,C=0;
    rep(i,S.size()){
        if(S[i]=='B'){
            T++;
        }
        else{
            C+=T;
        }
    }
    cout << C << endl;
}

Measured memory_bytes: 832
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;



int main(){
    
    ll x;
    cin>>x;

    ll t = 0;
    int ans=0;
    for(int i=1;i<=x;i++){
        t+=i;
        ans++;
        if(t>=x){
            cout<<ans<<endl;
            return 0;
        }
    }
    return 0;
    
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                //????????¨??????????????????
                string[] s = Console.ReadLine().Split(' ');
                int high = int.Parse(s[0]);
                int width = int.Parse(s[1]);


                //????????¨????????¨??????0???????????????????????????????????????
                if ((high == 0) && (width) == 0) break;


                for (int i = 0; i < high; i++)
                {
                    for (int j = 0; j < width; j++)
                    {
                        if ((i==0) || (i==high-1) || (j == 0) || (j == width-1))
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                    Console.Write("\n");
                }

                Console.Write("\n");

            }
        }
    }
}

Measured memory_bytes: 5296
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  vector<ll> p(n + 2, INF);
  FOR(i, 1, n + 1) cin >> p[i];
  
  vector<ll> idx(n + 1);
  FOR(i, 1, n + 1) {
    idx[p[i]] = i;
  }

  ll ans = 0;
  set<ll> s;
  FORR(i, n, 1) {
    s.insert(idx[i]);

    vector<ll> a(2, 0), b(2, n + 1);
    auto itr = s.find(idx[i]);
    rep(j, 2) {
      if (itr == s.begin()) break;
      a[j] = *(--itr);
    }
    itr = s.find(idx[i]);
    rep(j, 2) {
      itr++;
      if (itr == s.end()) break;
      b[j] = *(itr);
    }

    ll c = (a[0] - a[1]) * (b[0] - idx[i]) + (b[1] - b[0]) * (idx[i] - a[0]);
    ans += c * i;
  }
  cout << ans << endl;


  
  return 0;
}

Measured memory_bytes: 6528
'use strict'
 
function Main(input) {
  const takahashi = Number(input.split(' ')[0]);
  const chuhashi = Number(input.split(' ')[1]);
  const syohashi = Number(input.split(' ')[2]);
  //const K = Number(input.split(' ')[3]);
  const K = input.split(' ')[3];
  const Ka = Number(K.slice(-1));
 
  const answer = chuhashi - takahashi;
  
  if(Ka % 2 === 0 && answer !== 0) {
    console.log(answer * -1);
  } else {
    console.log(answer);
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7372
#include <cstdio>
using namespace std;

int main(){
	
	int R = 0;
	int G = 0;
	
	scanf("%d%d" ,&R,&G);
	
	int g = G*2;
	int a = 0;
	
	if(g==0){
		a = R*-1;
	}else{
		a = g-R;
	}
	
	printf("%d",a);
	
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc125/tasks/abc125_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int A_I_MAX = 1e9;

int N;
int A[N_MAX];

int l[N_MAX];
int r[N_MAX];

void solve() {
  REP(i, N) {
    l[i] = (i == 0 ? A[0] : gcd(l[i - 1], A[i]));
  }
  for (int i = N - 1; i >= 0; i--) {
    r[i] = (i == N - 1 ? A[N - 1] : gcd(r[i + 1], A[i]));
  }

  // DUMP(l, N);
  // DUMP(r, N);

  int ans = 0;
  REP(i, N) {
    int g;
    if (i == 0) g = r[1];
    else if (i == N - 1) g = l[N - 2];
    else g = gcd(l[i - 1], r[i + 1]);
    ans = max(ans, g);
  }
  printf("%d\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", A + i);
}

int main() {
  input();
  solve();
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

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

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

  int xor_all = 0;

  vector<int> A(n);
  for (auto &a : A) {
    cin >> a;
    xor_all ^= a;
  }

  for (auto &a : A) {
    cout << (xor_all ^ a) << " ";
  }
  cout << "\n";
  return 0;
}

Measured memory_bytes: 3984
#__author__ = "tatuo"
#__date__ = "$Mar 3, 2018 12:34:20 PM$"

import math
import re
import sys


def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result




arr_data = getinputdata()

n = int(arr_data[0][0])

x = "ABC" if n <1200 else "ARC"

print(x)

#s1 = arr_data[0][0][0]
#s2 = arr_data[1][0][1]
#s3 = arr_data[2][0][2]
#
#print(s1+s2+s3)
#


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    vector <int> v(n), c(n);
    cin >> n;
    for (int i = 0; i < n; i++)cin >> v[i];
    for (int i = 0; i < n; i++)cin >> c[i];
    int ans = 0;
    for (int i = 0; i < n;i++)if(v[i]>c[i])ans += v[i]-c[i];
    cout << ans << endl;
}

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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////
string s;

int main(){
    cin>>s;
    ll sum = 0;
    for(int i = 0;i<(1<<(s.size()-1));i++){
        ll r = 0,l=0;
        for(r=0;r<s.size()-1;r++){
            if((i&(1<<r)) != 0){
                sum += stoll(s.substr(l,r-l+1));
                l = r+1;
            }
        }
        sum += stoll(s.substr(l,r-l+1));
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#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(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c,d; 
    cin >> a >> b >> c >> d;
    if (a*b >= c*d){ cout << a*b <<endl; }
    else cout << c*d <<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 n = sc.nextInt();
        int[] people = new int[n];
        for (int i = 1; i <= n; i++) {
            people[sc.nextInt()-1] = i;
        }
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<n;i++){
            System.out.print(people[i]);
            if(i!=n-1){
                System.out.print(" ");
            }
        }
    }
}

Measured memory_bytes: 68700
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N;
map< vector<int>, int > dp;

int solve(vector<int>& vec, int sum = 0, int id = 1) {
    int res = 0;
    if(sum == 10) {
        res++;
        sum = 0; id = 1;
    }
    if(dp.count(vec)) return dp[vec];
    if(sum > 10) return 0;

    int add = 0;
    for(int i=id; i<=9; i++) {
        if(vec[i] > 0 && sum + i <= 10) {
            vec[i]--; sum += i;
            chmax(add, solve(vec, sum, i));
            vec[i]++; sum -= i;
        }
    }
    res += add;

    if(sum == 0) dp[vec] = res;
    return res;
}

signed main() {
    while(cin >> N, N) {
        dp.clear();
        vector<int> countManju(11);

        for(int i=0; i<N; i++) {
            int val; cin >> val;
            countManju[val]++;
        }
        
        int ans = 0;
        for(int i=1; i<5; i++) {
            int add = min(countManju[i], countManju[10 - i]);
            ans += add;
            countManju[i     ] -= add;
            countManju[10 - i] -= add;
        }
        ans += countManju[5] / 2;
        countManju[5] %= 2;

        ans += solve(countManju);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 12044
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

alias sread = () => readln.chomp();
enum MOD = 10 ^^ 9 + 7;

void main()
{
    long N, M;
    scan(N, M);
    auto uf = UnionFind(N);
    foreach (_; 0 .. M)
    {
        long X, Y, Z;
        scan(X, Y, Z);
        uf.unite(X - 1, Y - 1);
    }
    uf.size.writeln();
}

struct UnionFind
{
    private long[] rank;
    long[] data;
    long size;

    this(long N)
    {
        this.rank = new long[](N);
        this.data = iota!long(N).array;
        this.size = N;
    }

    long find(long x)
    {
        if (data[x] == x)
            return x;
        long r = this.find(data[x]);
        data[x] = r;
        return r;
    }

    void unite(long x, long y)
    {
        long rx = this.find(x);
        long ry = this.find(y);
        if (rx != ry)
        {
            this.size--;
            if (rank[rx] == rank[ry])
            {
                data[rx] = ry;
                rank[ry]++;
            }
            else if (rank[rx] < rank[ry])
                data[rx] = ry;
            else
                data[ry] = rx;
        }
    }

    bool isSame(long x, long y)
    {
        return this.find(x) == this.find(y);
    }
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mk make_pair
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;

int main(){
	int l, r, d;
	cin >> l >> r >> d;
	
	int cnt = 0;
	for(int i = l; i <= r; i++)
		if(i % d == 0)
			cnt++;
	
	cout << cnt << endl;	
	return 0;
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

vector<int> graph[200005];
int c[200005];
int ans[200005];
bool memo[200005];

void dfs(int sum,int to){
    if(memo[to])return;
    ans[to] = c[to]+sum;
    memo[to] = true;
    REP(i,graph[to].size()){
        dfs(ans[to],graph[to][i]);
    }
}

int main() {

    int n,q;
    cin >> n >> q;
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    REP(i,q){
        int p,x;
        cin >> p >> x;
        p--;
        c[p] += x;
    }
    dfs(0,0);
    for(int i = 0;i < n;i++){
        cout << ans[i];
        if(i != n-1)cout << " ";
        else cout << endl;
    }

    return 0;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
 
 
signed main() {
	ll h, w;
	cin >> h >> w;
	if (h == 1 or w == 1) {
		cout << 1 << endl;
		return 0;
	}
	ll sum = 0;
	sum += w * (h / 2);
	h %= 2;
	if (h) {
		sum += (w + 1) / 2;
	}
	cout << sum << endl;
}

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

void Main() {
  int n;
  std::cin >> n;

  std::cout << n * n * n << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int A, N;
    cin >> N;
    cin >> A;
    int r = N % 500;
    if (r <= A) {
        std::cout << "Yes" << '\n';
    } else {
        std::cout << "No" << '\n';
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  long long result = 0;
  map<string, int> countS;
  
  for (int i = 0; i < N; i++) {
  	string str;
    cin >> str;
    map<char, int> count;
    string tmp;
	int size = str.size();
    for (int j = 0; j < size; j++) {
    	count[str[j]] += 1;
    }
    for (auto p : count) {
  	  tmp += p.first;
  	  tmp += to_string(p.second);
    }
    if (countS[tmp] > 0) {
      	result += countS[tmp];
      	countS[tmp] += 1;
    } else {
    	countS[tmp] = 1;
    }
  }
  cout << result << endl;
}


Measured memory_bytes: 16644
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		for(int x=k+1;x<=n;x++){
			if(a[x-1]>a[x-k-1]){System.out.println("Yes");}
			else{System.out.println("No");}
		}
	}
}


Measured memory_bytes: 60580
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 200000
#define X 1000000007
using namespace std;
int n,m,t,a[N+5],f[N+5],g[N+5];char s[N+5];
int w[N+5][2];I void Work()
{
	#define DP() for(RI i=2;i<=n;++i) w[i][0]=w[i-1][1],w[i][1]=(w[i-1][0]+w[i-1][1])%X;
	w[1][1]=1;DP();RI t=(w[n][0]+w[n][1])%X;
	w[1][0]=1,w[1][1]=0;DP();printf("%d\n",(t+w[n][1])%X);
}
int main()
{
	RI i;for(scanf("%d%d%s",&n,&m,s+1),i=1;i<=m;++i) s[i]^s[i-1]&&++t,++a[t];
	if(t&1&&--t,!t) return Work(),0;if(n&1) return puts("0"),0;
	RI p=a[1]+(a[1]&1^1);for(i=3;i<=t;i+=2) a[i]&1&&(p=min(p,a[i]));
	for(f[0]=g[0]=1,i=2;i<=n;++i) f[i]=(g[i-2]+(i-p-3>=0?X-g[i-p-3]:0))%X,g[i]=(g[i-2]+f[i])%X;
	RI res=0;for(i=2;i<=p+1&&i<=n;++i) res=(1LL*i*f[n-i]+res)%X;return printf("%d\n",res),0;
}

Measured memory_bytes: 5788
package main

import (
        "fmt"
)

func solution(n, m int) int {
        n = n - 2
        m = m - 2
        if n < 0 {
                n = 1
        }
        if m < 0 {
                m = 1
        }
        return n * m
}

func main() {
        var n, m int
        fmt.Scan(&n, &m)
        fmt.Println(solution(n, m))
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    int d[10];
    rep(i,11){
        d[i]=0;
    }
    d[a]++;
    d[b]++;
    d[c]++;
    if(d[5]==2&&d[7]==1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    string S; cin >> S;
    int dp[N+1][N+1];
    rep(i,N+1) rep(j,N+1) dp[i][j]=0;
    for(int i=N-1;i>=0;i--){
        for(int j=N-1;j>=0;j--){
            if(i==j) continue;
            if(S[i]!=S[j]) dp[i][j]=0;
            else dp[i][j]=dp[i+1][j+1]+1;
        }
    }
    int ans=0;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            ans=max(ans,min(abs(i-j),dp[i][j]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 195584
(let ((n (read))
    (ki 0)
    (gu 0))
    (loop for i from 1 to n do
        (if (zerop (rem i 2))
            (incf gu)
            (incf ki)
        )
    )
    (format t "~D~%" (float (/ ki (+ ki gu))))
)

Measured memory_bytes: 24476
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

ll twos[64];

int main(void) {
    ll H;
    cin >> H;

    twos[0] = 1;
    for (int i = 1; i < 64; i++) {
        twos[i] = twos[i - 1] * 2;
    }
    if (H == 1) {
        cout << "1" << endl;
        return 0;
    }

    H = H & ~(0x1);
    // printf("%lld\n", H);
    // printf("%lld\n", twos[62]);
    // printf("%lld\n", twos[63]);

    ll acc = 0;
    for (int i = 0; i < 64; i++) {
        // printf("%lld\n", twos[i]);
        if (twos[i] > H) break;
        acc += twos[i];
    }

    cout << acc << endl;

    return 0;
}


Measured memory_bytes: 256