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

public class Main {

    public static  void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
       int a = scanner.nextInt();
       int b = scanner.nextInt();
       int c = scanner.nextInt();
       int x = scanner.nextInt();
       int y = scanner.nextInt();
       int x_y_max = Math.max(x,y);

       int ans = a*x+b*y;
       for(int i = 0; i <= x_y_max*2; i += 2){
           ans = Math.min(a*check(x-i/2) + b*check(y-i/2) + c*i,ans);
           //System.out.println(ans);
       }
       System.out.println(ans);
    }
    public static int check(int z){
        if (z > 0){
            return z;
        }else{
            return 0;
        }
    }
}


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

int main(){
    /*入力*/
    int n;
    cin >> n; //n個
    vector<int> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i]; //足場の高さ
    }
    /**/
    vector<int> dp(n); // dp[i] = i番目の足場に行くまでの最小コスト
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2;i < n;i++){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),dp[i - 1] + abs(h[i] - h[i - 1]));
        //cout << " " << dp[i] << " " << dp[i - 2] + abs(h[i] - dp[i - 2]) << " " << dp[i - 1] + abs(h[i] - h[i - 1]) << endl;
    }

    cout << dp[n - 1] << endl;

    return 0;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;

int main(){

    int n, k; cin >> n >> k;

    double ans = 0;
    for(int i=1; i<=n; i++){
        if(k <= i){
            ans += 1/double(n);
        }
        else{
            int temp = 1;
            while(true){
                temp *= 2;
                if(k <= i*temp){
                    ans += 1/double(n)*1/double(temp);
                    break;
                }
            }
        }
    }

    cout << fixed << setprecision(20) << ans;

    return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int p = 1;
  while (k != 0) {
    p *= 2;
    k--;
  }
  cout << a + b + c + max({a, b, c}) * (p - 1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dwn(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
const int maxn=21;
const int maxm=1<<20;
const int mod=1000000007;
int f[2][maxm],trans[maxm][maxn];
int g[maxn][maxn];
int n,m,k;
int main() {
	n=read();m=read();k=read();
	memset(g,-1,sizeof(g));
	rep(i,1,k) {
		int a=read()-1,b=read()-1;
		g[a][b]=read();
	}
	rep(S,0,(1<<n)-1) {
		rep(i,0,n-1) if(!(S>>i&1)) {
			int k=n;
			rep(j,i+1,n-1) if(S>>j&1) {k=j;break;}
			if(k==n) trans[S][i]=S^(1<<i);
			else trans[S][i]=S^(1<<i)^(1<<k);
		}
	}
	int cur=0;f[0][0]=1;
	rep(i,0,m-1) {
		rep(j,0,n-1) {
			cur^=1;
			memset(f[cur],0,sizeof(f[cur]));
			int ok1=(g[i][j]<0||g[i][j]==1),ok2=g[i][j]<=0;
			rep(S,0,(1<<n)-1) {
				int& ans=f[cur^1][S];
				if(ok1) {
					if(S>>j&1) (f[cur][S]+=ans)%=mod;
					else (f[cur][trans[S][j]]+=ans)%=mod;
				}
				if(ok2) {
					if(!(S>>j&1)) (f[cur][S]+=ans)%=mod;
				}
			}
		}
		cur^=1;
	}
	int ans=0;
	rep(S,0,(1<<n)-1) (ans+=f[cur][S])%=mod;
	printf("%d\n",ans);
  	return 0;
}


Measured memory_bytes: 94464
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class c_id{
    public static void Main(){
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        List<City> cities = new List<City>();
        int[] counter = new int[n+1];
        for(int i=0; i<m; i++){
            int[] line = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var city = new City(line[0], line[1], i);
            cities.Add(city);
        }
        var sorted = cities.OrderBy(ct => ct.Pre).ThenBy(ct => ct.Year).ToList();
        string[] ans = new string[m];
        foreach(var c in sorted){
            counter[c.Pre]++;
            ans[c.Pos] = string.Format("{0:000000}",c.Pre) + string.Format("{0:000000}",counter[c.Pre]);
        }
        foreach(string s in ans){
            Console.WriteLine(s);
        }
    }
}
class City{
    public int Pre { set; get; }
    public int Year { set; get; }
    public int Pos { set; get; }
    public City(int pre, int year, int pos){
        Pre = pre;
        Year = year;
        Pos = pos;
    }
}


Measured memory_bytes: 36248
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int r[100010];
int mi[100010];
int mx[100010];
int c[100010];
int main()
{
	int x,k,q;
	scanf("%d",&x);
	int i;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
		scanf("%d",&r[i]);
	r[0]=0;
	mi[0]=c[0]=0;
	mx[0]=x;
	for(i=1;i<=k;i++)
	{
		mx[i]=mx[i-1];
		mi[i]=mi[i-1];
		if(i&1)
		{
			mi[i]=max(mi[i],min(r[i]-r[i-1]-c[i-1],mx[i]));
			c[i]=max(c[i-1]+mi[i-1]-r[i]+r[i-1],0)-mi[i];
		}
		else
		{
			mx[i]=min(mx[i],max(x-r[i]+r[i-1]-c[i-1],mi[i]));
			c[i]=min(c[i-1]+mx[i-1]+r[i]-r[i-1],x)-mx[i];
		}
	}
	scanf("%d",&q);
	int t,a;
	for(i=1;i<=q;i++)
	{
		scanf("%d%d",&t,&a);
		int p=upper_bound(r,r+k+1,t)-r-1;
		int ans;
		if(a<=mi[p])
			ans=mi[p]+c[p];
		else if(a>=mx[p])
			ans=mx[p]+c[p];
		else
			ans=a+c[p];
		if(p&1)
			ans=min(x,ans+t-r[p]);
		else
			ans=max(0,ans-t+r[p]);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2688
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll INF = 1e+18;
const ld EPS = 1e-12L;
const ld PI = acos(-1.L);
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  string t;
  cin >> t;
  rep(i, n){
    cout << s[i] << t[i];
  }
  cout << endl;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s,t = "Yes";
vector<int> v[N];
ll a,b,c,d,n,result;
// int a[N];

template <typename T> T gcd(T a, T b) {
  if(b == 0) return a;
  return gcd(b, a%b);
}

template <typename T> T lcm(T a, T b) {
  return a / gcd(a, b) * b ;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin >> a >> b >> c >> d;
  ll e = lcm(c,d);
  ll num_c = b/c - (a-1)/c;
  ll num_d = b/d - (a-1)/d;
  ll num_e = b/e - (a-1)/e;
  // cout << num_c << " : " << num_d << " : " << num_e << endl;
  cout << (b - a + 1) - (num_c + num_d - num_e) << endl;
}


Measured memory_bytes: 23680
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int N = Integer.parseInt(br.readLine());
	int odds = N / 2 + N % 2;

	System.out.println((double) odds / N);
    }
}

Measured memory_bytes: 21204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    CTimeGap solver = new CTimeGap();
    solver.solve(1, in, out);
    out.close();
  }

  static class CTimeGap {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      int n = in.nextInt();
      int[] time = new int[n + 1];
      for (int i = 1; i <= n; i++) {
        time[i] = in.nextInt();
      }

      Arrays.sort(time);
      for (int i = 0; i <= n; i++) {
        if (i + 2 <= n && time[i] == time[i + 1] && time[i + 1] == time[i + 2]) {
          out.println(0);
          return;
        }
      }

      for (int i = 1; i <= n; i += 2) {
        time[i] = (24 - time[i]) % 24;
      }

      Arrays.sort(time);
      int res = 114514;
      for (int i = 1; i <= n; i++) {
        res = Math.min(res, time[i] - time[i - 1]);
      }
      res = Math.min(24 - time[n], res);

      out.println(res);
    }

  }
}



Measured memory_bytes: 23892
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,p[2][2020],B[4040],D[2020][2020];

void push(int x, int p)
{
	while (x <= 2*N){
		B[x] += p;
		x += x & (-x);
	}
}

int pop(int x)
{
	int r = 0;
	while (x){
		r += B[x];
		x -= x & (-x);
	}
	return r;
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=2*N;i++){
		char c; int v;
		scanf (" %c %d",&c,&v);
		p[c == 'B'][v] = i;
	}

	for (int i=0;i<=N;i++) for (int j=0;j<=N;j++) D[i][j] = 0x7fffffff;
	D[0][0] = 0;

	for (int i=0;i<=N;i++){
		if (i) push(p[0][i],+1);
		for (int j=0;j<=N;j++){
			if (j) push(p[1][j],+1);
			if (i + 1 <= N){
				D[i+1][j] = min(D[i+1][j],D[i][j]+i+j-pop(p[0][i+1]));
			}
			if (j + 1 <= N){
				D[i][j+1] = min(D[i][j+1],D[i][j]+i+j-pop(p[1][j+1]));
			}
		}
		for (int j=1;j<=N;j++) push(p[1][j],-1);
	}

	printf ("%d\n",D[N][N]);

	return 0;
}

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

int main() {
  int n, k, a;
  int b[200000] = {};
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    b[a-1]++;
  }
  sort(b, b+n, greater<int>());
  int ans = n;
  for (int i = 0; i < k; ++i) {
    ans -= b[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a,b,c,n,ans=0;
	cin >> a >> b >> c >> n;

	for (int i = 0; i <= 3000; i++) {
		for (int j = 0; j <= 3000; j++) {
			int tmp = a * i + b * j;
			if(tmp>n){
				continue;
			}
			if((n-tmp)%c==0){
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	stack<char>a;
	for(int i=0;i<n;i++){
		if(a.empty())a.push(s[i]);
		else if(a.top()=='('&&s[i]==')')a.pop();
		else a.push(s[i]);
	}
	int st=0,e=0;
	for(int i=0;!a.empty();i++){
		if(a.top()==')')e++;
		else st++;
		a.pop();
	}
	for(int i=0;i<e;i++)cout<<"(";
	cout<<s;
	for(int i=0;i<st;i++)cout<<')';
	cout<<endl;
}

Measured memory_bytes: 256
N = gets.to_i
ans = 0
1.upto((N**0.5).to_i) do |i|
  m = N/i - 1
  ans += m if m>0 && N % m == N / m
  #p [i,N,m,N/m,N%m,N % m == N / m]
end
p ans


Measured memory_bytes: 3836
def dfs(xt, yt, S, V, w):
    B = set()
    while(len(S) > 0):
        xi, yi = S.pop()
        A = []
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                xj, yj = xi + i, yi + j
                if xj < 0 or len(V) <= xj or yj < 0 or len(V[0]) <= yj:
                    continue
                if -1 <= i <= 1 and -1 <= j <= 1 and i * j == 0:
                    A.append((xj, yj))
                else:
                    B.add((xj, yj))

        for xj, yj in A:
            if xj == xt and yj == yt:
                return False, B, V, w
            if V[xj][yj] > 0:
                V[xj][yj] = -1
                S.append((xj, yj))

    B_new = []
    for x, y in B:
        if x == xt and y == yt:
            return False, B, V, w + 1
        if V[x][y] > 0:
            V[x][y] = -1
            B_new.append((x, y))
    return True, B_new, V, w

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = [list(map(lambda x: int(x == '.'), list(input()))) for _ in range(h)]

flag = True
B = [(ch, cw)]
w = -1
s[ch][cw] = -1
while flag:
    flag, B, s, w = dfs(dh, dw, B, s, w + 1)
    if flag and len(B) == 0:
        print(-1)
        break
else:
    print(w)


Measured memory_bytes: 170192
/* package codechef; // don't place package name! */
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Collections;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		    Scanner k=new Scanner(System.in);
		    int t;
		    t=k.nextInt();
		       long a[]=new long[t];
		       int f=0;
		       for(int i=0;i<t;i++)
		      {
		          a[i]=k.nextLong();
		          if(a[i]==0)
		          f=1;
		      }
		      if(f==1)
		      System.out.println("0");
		      else
		      {
		       int flag=0;
		       BigInteger b=new BigInteger("1");
		       BigInteger c=new BigInteger("1000000000000000000");
		       for(int i=0;i<t;i++)
		      {
		          if(BigInteger.valueOf(a[i]).compareTo(c)==1)
		          {
		              flag=1;
		              break;
		          }
		          b=b.multiply(BigInteger.valueOf(a[i]));
		          if(b.compareTo(c)==1)
		          {
		              flag=1;
		              break;
		          }
		      }
		      if(flag==1)
		      System.out.println("-1");
		      else
		      System.out.println(b);
		        }
	}
	}

Measured memory_bytes: 62052
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>

using namespace std;
typedef long long ll;

void Search(vector<int> X[],int id, int* count){
	(*count) += X[id].size();
}

int main()
{
	int N;
	int A[200001];
	cin >> N;
	for(int i = 2; i <= N; i++){
		cin >> A[i];
	}
	
	vector<int> X[200001];
	
	for(int i = 2; i <= N; i++){
		X[A[i]].push_back(i);
	}
	
	for(int i = 1; i <= N; i++){
		int count = 0;
		Search(X, i, &count);
		cout << count << endl;
	}
	
	return 0;
}


Measured memory_bytes: 15352
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;
const int maxn=2e5+10;
ll a[maxn];
ll l[maxn],r[maxn];
int main()
{
	IO;
	ll n;
	cin>>n;
	memset(l,0,sizeof(l));
	memset(r,0,sizeof(r));
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(i-a[i]>0){
			r[i-a[i]]++;
		}
		if(i+a[i]<=n){
			l[i+a[i]]++;
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++){
		ans+=l[i]*r[i];
	}
	cout<<ans<<endl;
 	return 0;
}







Measured memory_bytes: 8332
#include<cstdio>
int a[2005],n;
long long ans=200000000000000ll,x,tmp,mn[2005];
long long Min(long long x,long long y){return x<y?x:y;}
int main()
{
	scanf("%d%lld",&n,&x);
	for(int i=1;i<=n;++i)scanf("%d",a+i),mn[i]=200000000000000ll;
	for(int i=0;i<n;++i){
		tmp=x*i;
		for(int j=1;j<=n;++j)mn[j]=Min(mn[j],a[(j-1-i+n)%n+1]),tmp+=mn[j];
		ans=Min(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

def eratosthenes(upperBound):
    """エラトステネスの篩アルゴリズムによって、upperBound以下の素数すべてからなるリストを計算する。

    Args:
        upperBound(int): 計算したい素数リストに含まれる素数の上限値。
    Returns:
        list[int]: 計算された素数リスト。
    
    Examples:
    >>> eratosthenes(10)
    [2, 3, 5, 7]
    >>> eratosthenes(11)
    [2, 3, 5, 7, 11]
    """
    primeNumbers = []
    isPrime = [True for _ in range(upperBound + 1)]
    isPrime[0] = isPrime[1] = False
    divider = 0
    while divider <= math.sqrt(upperBound):
        if isPrime[divider]:
            # primeNumbers.append(divider)
            multiple = 2* divider
            while multiple <= upperBound:
                isPrime[multiple] = False
                multiple += divider
        divider += 1
    return [i for i in range(upperBound + 1) if isPrime[i]]

primeNumberList = eratosthenes(1000010)

def factorize(number):
    """与えられた整数を素因数分解する。素因数とその指数を辞書として返却する。

    Args:
        number(int) 
    Returns:
        dict[int,int] 素因数->指数の辞書。
    >>> factorize(6)
    {2: 1, 3: 1}
    >>> factorize(20)
    {2: 2, 5: 1}
    """
    exponents = {}
    for primeNumber in primeNumberList:
        while number%primeNumber == 0:
            number /= primeNumber
            if primeNumber in exponents:
                exponents[primeNumber] += 1
            else:
                exponents[primeNumber] = 1
    if number != 1:
        exponents[number] = 1
    return exponents

A,B = map(int,input().split())
gcd = fractions.gcd(A,B)
factorizedGcd = factorize(gcd)
print(len(factorizedGcd.keys()) + 1)

Measured memory_bytes: 17444
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int gcd(int a,int b){
    if(a==0)return b;
    if(b==0)return a;

    int M=max(a,b);
    int m=min(a,b);
    return gcd(m,M%m);
}

int main(){
    int N,A[100010],g[100010],ans=1;
    cin>>N;
    for(int i=0;i<N;++i)cin>>A[i];
    
        int L[100010],R[100010];

        //初期化
        L[0]=0,R[0]=0;

        //漸化式
        for(int i=1;i<N;++i){
            L[i]=gcd(L[i-1],A[i-1]);
            R[i]=gcd(R[i-1],A[N-i]);
        }

        for(int i=0;i<N;++i)
            ans=max(ans,gcd(L[i],R[N-1-i]));
    
    printf("%d\n",ans);
    return 0;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c,d; cin>>a>>b>>c>>d;
    if(a+b>c+d) cout<<"Left"<<endl;
    else if(a+b<c+d) cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main(){
    double x1,x2,x3,y1,y2,y3,n;
    double m;
    cin>>x1>>y1>>x2>>y2;
    x3 = (x2-x1)*(x2-x1);
    y3 = (y2-y1)*(y2-y1);
    n = x3+y3;
    m = sqrt(n);
    printf("%.8lf\n", m);
return 0;
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int>
#define pli pair<lli,int> 
#define X first
#define Y second
#define MAXN 300000
int MOD = 1e9 + 7;

vector <vector <long long>> modpow_martix(vector <vector <long long>> a, long long b) {
	int n = a.size();
	vector <vector <long long>> ans(n), zero(n);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) ans[i].push_back(1);
			else ans[i].push_back(0);
			zero[i].push_back(0);
		}
	}
	for (; b; b >>= 1) {
		if (b & 1) {
			vector <vector <long long>> ans2 = zero;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					for (int k = 0; k < n; ++k) {
						ans2[i][j] += (ans[i][k] * a[k][j] % MOD);
						if (ans2[i][j] >= MOD) ans2[i][j] -= MOD;
					}
				}
			}
			swap(ans, ans2);
		}
		vector <vector <long long>> aa = zero;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				for (int k = 0; k < n; ++k) {
					aa[i][j] += (a[i][k] * a[k][j] % MOD);
					if (aa[i][j] >= MOD) aa[i][j] -= MOD;
				}
			}
		}
		swap(aa, a);
	}
	return ans;
}

int main () {
	int n;
	lli m;
	cin >> n >> m;
	vector <vector <long long>> ma(n);
	fop (i,0,n) {
                ma[i].resize(n);
                fop (j,0,n) {
                        cin >> ma[i][j];
                }
        }
	vector <vector <long long>> aa = modpow_martix(ma, m);
	lli ans = 0;
	fop (i,0,n) {
                fop (j,0,n) {
		        ans += aa[i][j];
                }
	}
	cout << ans % MOD << endl;
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

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

int dp[N], a[N], sum[N];

int main() {
	FREOPEN();
	int n;
	cin >> n;
	int m = 0;
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d ", &x);
		if (a[m] == x) continue;
		a[++m] = x;
	}
	dp[0] = 1;
	for (int i = 1; i <= m; i++) {
		dp[i] = (dp[i - 1] + sum[a[i]]) % MOD;
		sum[a[i]] += dp[i - 1];
		sum[a[i]] %= MOD;
	}
	printf("%d", dp[m]);
	return 0;
}


Measured memory_bytes: 2560
n,k = map(int,input().split())
alist = list(map(int,input().split()))
flist = list(map(int,input().split()))
alist.sort()
flist.sort(reverse = True)
L = -1
R = 10 ** 18
while R-1 > L:
  mid = (R +L)//2
  count = 0
  loop_count = 0
  for i in flist:
    if alist[loop_count] > mid // i:
      count += alist[loop_count] - mid // i
    loop_count += 1
  if count > k:
    L = mid
  else:
    R = mid
print(R)

Measured memory_bytes: 119500
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dp[110000];
Int dep[110000];
Int dpr[110000];

Int far(Int x, Int y){
    if(dep[x] < dep[y])return dp[y];
    else return dpr[x];
}

vector<Int> edge[110000];
void dfs(Int x, Int last = -1){
    dp[x] = 0;
    for(auto to:edge[x]){
        if(to == last)continue;
        dep[to] = dep[x] + 1;
        dfs(to, x);
        dp[x] = max(dp[x], dp[to] + 1);
    }
}

void dfs2(Int x, Int last = -1){
    vector<int> vec;
    vec.push_back(0);
    if(last != -1)vec.push_back(dpr[x] + 1);
    for(auto to:edge[x]){
        if(to == last)continue;
        vec.push_back(dp[to] + 1);
    }
    sort(vec.rbegin(), vec.rend());
    for(auto to:edge[x]){
        if(to == last)continue;
        if(vec[0] == dp[to] + 1) dpr[to] = vec[1];
        else dpr[to] = vec[0];
        dfs2(to, x);
    }
}

int main(){
    Int n, u, v;
    cin >> n;
    for(int i = 0;i < n-1;i++){
        cin >> u >> v;u--,v--;
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(0);
    dfs2(0);
    Int triangle = 0;
    for(int i = 0;i < n;i++){
        if(edge[i].size() <= 2)continue;
        vector<int> vec;
        for(auto to:edge[i]){
            vec.push_back(far(i, to)+1);
        }
        sort(vec.rbegin(), vec.rend());
        Int a = vec[0], b = vec[1], c = vec[2];
        bool done = false;
        if(a == b && b == c)triangle = max(triangle, a + b - 1);
        else triangle = max(triangle, max(a+c, b+c));
        
    }
    for(int i = 1;i <= n;i++){
        if(i <= 2 || i > triangle)cout << 1;
        else cout << 0;
    }cout << endl;
    return 0;
}


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

using namespace std;

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

#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--)

ll const INF = 1000000000000000000;
int const I_MAX = 2147483647;
ll const MOD = 1e9 + 7;
int const POW_MAX = 1e5;

// nCr
ll po[POW_MAX + 2];
ll mod_pow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
ll mod_inv (ll x) {
  return mod_pow(x, MOD - 2) % MOD;
}
ll comb(int n, int r) {
  return (((po[n] * mod_inv(po[r])) % MOD) * mod_inv(po[n - r])) % MOD;
}
// greatest common divisor
ll gcd(ll a, ll b) {
  while (a % b != 0) {
    ll tmp = a;
    a = b;
    b = tmp % b;
  }
  return b;
}

struct GreaterP {
  bool operator() (P a, P b) {
    return a.first > b.first;
  }
};

int N, M;
priority_queue<P, vector<P>, GreaterP> pq;

int main() {
  scanf("%d %d", &N, &M);
  rep(i, N) {
    int a, b;
    scanf("%d %d", &a, &b);
    pq.push(P(a, b));
  }

  ll money = 0;
  int buy = 0;
  while(!pq.empty()) {
    P a = pq.top();
    pq.pop();
    if (buy + a.second >= M) {
      money += (ll) (M - buy) * a.first;
      break;
    } else {
      money += (ll) a.first * a.second;
      buy += a.second;
    }
  }
  printf("%lld\n", money);
}


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

int main(){
    string s;
    string divide[4] = {"dream","dreamer","eraser","erase"} ;
    cin >> s;

    reverse(s.begin(), s.end());
    for(int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

    bool judge = true;
    int i = 0;
    for(i ; i < s.size();){
        bool can = false;
        for(int j = 0; j < 4; j++){
            if(s.substr(i,divide[j].size()) == divide[j]){
                can = true;
                i += divide[j].size();
            }
        }
        if(!can) {
            judge = false;
            break;
        }
    }

    if(judge) cout << "YES" << endl;
    else cout << "NO" << endl;

}

Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    O = list(input())
    E = list(input())
    for o, e in zip(O, E):
        print(o, e, end='', sep='')
    if len(O) > len(E):
        print(O[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MAX 5005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,ha[MAX],hb[MAX],ta=0,tb=0;
char a[MAX],b[MAX];
int main()
{
	n=read();
	scanf("%s%s",a,b);
	if(a[0]=='1') ha[++ta]=0;
	if(b[0]=='1') hb[++tb]=0;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a[i-1]) ha[++ta]=i;
		if(b[i]!=b[i-1]) hb[++tb]=i;
	}
	int ANS=INF;
	for(int i=0;i<=tb;i+=2)
	{
		int sm=0,p1=1,p2=1;
		while(p2<=i)
			sm+=hb[p2],p2++;
		while(p1<=ta&&p2<=tb)
			sm+=abs(ha[p1]-hb[p2]),p1++,p2++;
		while(p1<=ta)
			sm+=n-ha[p1],p1++;
		while(p2<=tb)
			sm+=n-hb[p2],p2++;
		ANS=min(ANS,sm);
	}
	for(int i=0;i<=ta;i+=2)
	{
		int sm=0,p1=1,p2=1;
		while(p1<=i)
			sm+=ha[p1],p1++;
		while(p1<=ta&&p2<=tb)
			sm+=abs(ha[p1]-hb[p2]),p1++,p2++;
		while(p1<=ta)
			sm+=n-ha[p1],p1++;
		while(p2<=tb)
			sm+=n-hb[p2],p2++;
		ANS=min(ANS,sm);
	}
	printf("%d",ANS);
	return 0;
}


Measured memory_bytes: 3828
h,w = map(int, input().split())
fields = []
for i in range(h):
    s = list(input())
    fields.append(s)

mvs = [(0,1),(0,-1),(1,0),(-1,0)]
for i in range(h):
    for j in range(w):
        if fields[i][j] == "#":
            cnt = 0
            for dy,dx in mvs:
                next_y,next_x = i+dy,j+dx# 次の選び方を
                if 0 <= next_y < h and 0 <= next_x < w:
                    if fields[next_y][next_x] == "#":
                        cnt += 1
            if cnt == 0:
                print("No")
                exit()


print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

const int INF = 1000000000;

int main()
{
    int N;
    cin >> N;
    vector<int> heights(N);
    rep(i, 0, N) cin >> heights[i];

    vector<int> cost(N+5, INF);
    cost[0] = 0;
    rep(from, 0, N-1)
    {
        cost[from+1] = min(cost[from+1], cost[from] + abs(heights[from]-heights[from+1]));
        cost[from+2] = min(cost[from+2], cost[from] + abs(heights[from]-heights[from+2]));
    }

    cout << cost[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
f = sys.stdin

def get_v(c):
    v = 0
    for ci in c:
        v *= 10
        v += ci
    return v

c = (1,4,1,4,1,2,1,2)

for line in f:
    p = list(map(int, line.split()))
    min_waiting = None
    min_c = None
    for i in range(len(c)):
        ci = c[i:] +c[:i]
        waiting = sum(max(0, p[i] - ci[i]) for i in range(len(c)))
        if min_waiting == None or min_waiting > waiting:
            min_waiting = waiting
            min_c = ci
        elif min_waiting == waiting and get_v(min_c) > get_v(ci):
            min_c = ci
    print(*min_c)
            
    

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

void solve(){
	int N, M;
	cin >> N >> M;
	vector<vector<char> > grid(N,vector<char>(M));
	vector<vector<ll> >  dp(N,vector<ll>(M,-1));
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			cin >> grid[i][j];
		}
	}
	
	// filling initial values
	dp[N-1][M-1] = 1;
	for(int i = M-1; i >= 0; i--){
		if(grid[N-1][i] == '#')
		{
			for(int j = i; j >= 0; j--){
				dp[N-1][j] = 0;
			}
			break;
		}
		else dp[N-1][i] = 1;
	}
	for(int i = N-1; i >= 0; i--){
		if(grid[i][M-1] == '#')
		{
			for(int j = i; j >= 0; j--){
				dp[j][M-1] = 0;
			}
			break;
		}
		else dp[i][M-1] = 1;
	}
	
	for(int i = N-2; i >= 0; i--){
		for(int j = M-2; j >= 0; j--){
			if(grid[i][j] == '#'){
				dp[i][j] = 0;
				continue;
			}
			dp[i][j] = (dp[i+1][j]%MOD + dp[i][j+1]%MOD)%MOD;
		}
	}
	cout << dp[0][0] << endl;
}

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

	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	return 0;
}




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

char s[2000005], t[2000006];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        int l = i;
        int cnt = 0;
        while (l <= n && (s[l] == 'A' || (s[l] == 'B' && s[l + 1] == 'C'))) {
            if (s[l] == 'A') t[++cnt] = 'A', ++l;
            else t[++cnt] = 'X', l += 2;
        }
        int tot = 0;
        for (int j = 1; j <= cnt; ++j)
            if (t[j] == 'A') ++tot;
            else ans += tot;
        i = l;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll a, b, c,k;
	cin >> a >> b >> c>>k;
	for (ll i = 0; i < k; i++) {
		if (a == max({ a,b,c })) {
			a *= 2;
		}
		else if (b== max({ a,b,c })) {
			b *= 2;
		}
		else{
			c*= 2;
		}
		
	}
	cout << a + b + c << endl;

}

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

int main(){
  ll N,count=0;
  cin>>N;
  vector<ll> A(N+1),B(N);
  for(int i=0; i<N+1; i++){
    cin>>A[i];
  }
  for(int i=0; i<N; i++){
    cin>>B[i];
  }
  for(int i=0; i<N; i++){
    if(A[i]>=B[i]){
      count+=B[i];
      A[i]-=B[i];
    }
    else{
      count+=A[i];
      if(A[i+1]>=B[i]-A[i]){
        count+=B[i]-A[i];
        A[i+1]-=B[i]-A[i];
      }
      else{
        count+=A[i+1];
        A[i+1]=0;
      }
      A[i]=0;
    }
  }
  cout<<count<<endl;
}
        

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 0
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 2010

int N, K, Q;
int A[MAX_N] = {};

signed main()
{
    cin >> N >> K >> Q;
    REP(i, N) { cin >> A[i]; }

    int ans = LLINF;
    REP(i, N) {
        // 基準となる x
        int x = A[i];
        DBG("i: %lld x: %lld\n", i, x);
        vector<int> sep[MAX_N];
        int sep_size = 0;
        REP(j, N) {
            // x 以上の値だけ sep に入れる
            if(A[j] >= x) {
                sep[sep_size].push_back(A[j]);
            }
            else {
                if(sep[sep_size].size() > 0) {
                    SORT(sep[sep_size]);
                    sep_size++;
                }
            }
        }
        if(sep[sep_size].size() > 0) {
            SORT(sep[sep_size]);
            sep_size++;
        }
        REP(j, sep_size) {
            DBG("  j: %lld\n    ", j);
            REP(k, sep[j].size()) {
                DBG("%lld ", sep[j][k]);
            }
            DBG("\n");
        }
        // 各グループから取得できる数はグループのサイズ Y - K + 1
        vector<int> getable;
        REP(j, sep_size) {
            int getable_cnt = sep[j].size() - K + 1;    // 取得できる数
            REP(k, getable_cnt) { getable.push_back(sep[j][k]); }
        }
        SORT(getable);
        if(getable.size() < Q) { continue; }
        int max_x = getable[Q-1];
        ans = min(ans, max_x - x);
        DBG("  ans: %lld\n", ans);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main(){
    ll n;
    cin>>n;
    ll ma=1000000000000000000;
    ll sum=1;
    ll a;
    ll cnt=0;
    for(ll i=0;i<n;++i){
        cin>>a;
        if(a==0){
            cout<<0<<endl;
            return 0;
        }
        if(sum*a>ma||sum*a<=0){
            sum=1;
            cnt++;
        }
        else sum*=a;
    }
    if(sum!=0&&cnt!=0)sum=-1;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

int main(){
  int h1, m1, h2, m2, K, t1, t2,h_a, m_a;
  cin >> h1 >> m1 >> h2 >> m2 >> K;
	t1 = 60 * h1 + m1;
  	t2 = 60 * h2 + m2;

  	m_a = t2-t1-K;
  
  cout << m_a << endl;
  return 0;
}


Measured memory_bytes: 3160
n=int(input())
a=list(map(int,input().split()))
ans=0
l=1
v=a[0]
for i in range(1,n):
    if a[i]==v:
        l+=1
    else:
        ans+=l//2
        l=1
        v=a[i]
ans+=l//2
print(ans)

Measured memory_bytes: 3064
PROGRAM-ID.                      ABC_053_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 x       PIC 9(4).

PROCEDURE                        DIVISION.
    ACCEPT x.

    IF x < 1200 THEN
        DISPLAY "ABC"
    ELSE
        DISPLAY "ARC"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
N, M = map(int, input().split())
A = []
B = []

for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        flag = 0
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] != B[k][l]:
                    flag = 1
                    break
        if flag == 0:
            print("Yes")
            break
    if flag == 0:
        break
        
if flag == 1:
    print("No")


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
//#define int long long
#define lint long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<lint,lint> P;
const lint inf=1e18+7;
const int MOD=1000000007;
struct Nums{
    long long n;
    vector<long long> kaijo;
    Nums(int N){
        n=N;
        kaijo.push_back(1);
        for(long long i=1;i<=n;i++){
            kaijo.push_back((kaijo[i-1]*i)%MOD);
        }
    }
    long myPow(long x, long n, long m){
        if(n == 0)
            return 1;
        if(n % 2 == 0)
            return myPow(x * x % m, n / 2, m);
        else
            return x * myPow(x, n - 1, m) % m;
    }
    long long modinv(long long a, long long m) {
        long long b = m, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        u %= m;
        if (u < 0) u += m;
        return u;
    }
    long long comb(long long N,long long K,long long rest){
        long long res=kaijo[N]*modinv(kaijo[K],rest)%rest;
        res*=modinv(kaijo[N-K],rest);
        res%=rest;
        return res;
    }
};

lint gcd(lint a,lint b){
  if(b==0){
    return a;
  }
  else{
    return gcd(b,a%b);
  }
}
signed main(){
  lint n;cin>>n;
  vector<lint> a(n);
  vector<lint> b(n);
  map<P,lint> memo;
  Nums lib(n+5);
  lint cnt0=0;
  lint a0=0;lint b0=0;
  rep(i,n){
      cin>>a[i]>>b[i];
      if(a[i]==0&&b[i]==0){
          cnt0++;
          continue;
      }
      if(a[i]==0){
          ++a0;
          continue;
      }
      if(b[i]==0){
          ++b0;
          continue;
      }
    lint ba=abs(a[i]);lint bb=abs(b[i]);
    lint g=gcd(ba,bb);
    if(a[i]<0){
        a[i]*=-1;b[i]*=-1;
    }
    P buf={a[i]/g,b[i]/g};
    memo[buf]+=1;
  }
  lint res=1;
  for(auto it=memo.begin();it!=memo.end();++it){
      lint buf=0;
      P mp;
      if(it->second==0){
          continue;
      }
      mp.first=(it->first).second;
      mp.second=(it->first).first;
      
      if(mp.first<0){
          mp.first*=-1;
          //mp.second*=1;
      }
      else{
          mp.second*=-1;
      }
      lint cur=0;
      auto it2=memo.find(mp);
      if(it2!=memo.end()){
          cur+=it2->second;
          it2->second=0;
      }
      /*
      mp.first*=-1;
      mp.second*=-1;
      auto it3=memo.find(mp);
      if(it3!=memo.end()){
          cur+=it3->second;
          it3->second=0;
      }*/
      buf=lib.myPow(2,it->second,MOD);
      buf+=lib.myPow(2,cur,MOD)-1+MOD;
      buf%=MOD;
      res*=buf;
      res%=MOD;
      it->second=0;
  }
  res*=lib.myPow(2,a0,MOD)+lib.myPow(2,b0,MOD)-1;
  res%=MOD;
  res+=cnt0+MOD-1;
  res%=MOD;
  cout<<res<<"\n";
  return 0;
}

Measured memory_bytes: 20244
<?php

while (true) {
    fscanf(STDIN, '%d %d', $height, $width);
    if ($height == 0 && $width == 0) break;
    
    $rentangle = new Rectangle($height, $width);
    Drawer::drawObject($rentangle);
    
}

class Rectangle
{
    private $height;
    private $width;
    private $char = '#';
    
    public function __construct($height, $width)
    {
        $this->height = $height;
        $this->width  = $width;
    }
    
    public function draw()
    {
        for ($i = 0; $i < $this->height; $i++) {
            $this->drawLine($this->width, $this->char);
        }
    }
    
    public function drawLine()
    {
        echo str_repeat($this->char, $this->width), PHP_EOL;
    }
}

class Drawer
{
    public static function drawObject($object)
    {
        $object->draw();
        Self::drawEmptyLine();
    }
    
    public static function drawEmptyLine()
    {
        echo PHP_EOL;
    }
}

Measured memory_bytes: 15368
s = input()

res = [0] * len(s)
cnt_r = 0
cnt_l = 0
curr = "R"
last_idx = 0

for idx, char in enumerate(s):
    if curr == "R":
        if char == "R":
            cnt_r += 1
            continue
        else:
            res[idx] += cnt_r // 2
            res[idx - 1] += (cnt_r - cnt_r // 2)
            last_idx = idx
            curr = "L"
            cnt_r = 0
            cnt_l = 1
            continue
    else:
        if char == "L":
            cnt_l += 1
            continue
        else:
            res[last_idx - 1] += cnt_l // 2
            res[last_idx] += cnt_l - (cnt_l // 2)
            curr = "R"
            cnt_l = 0
            cnt_r = 1

res[last_idx - 1] += cnt_l // 2
res[last_idx] += cnt_l - (cnt_l // 2)

print(*res)

Measured memory_bytes: 6400
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n, m;
    cin >> n >> m;

    vector< vector<int> > v(m);
    rep(i, n){
        int x;
        cin >> x;
        v[x % m].emplace_back(x);
    }
    rep(i, m){
        SORT(v[i]);
    }

    int ans = 0;
    rep(i, m / 2 + 1){
        if(i == 0 || (m % 2 == 0 && i == m / 2)){
            ans += (int)v[i].size() / 2;
        }else{
            int j = (int)v[i].size();
            int k = (int)v[m - i].size();
            ans += min(j, k);
            int cnt = 0;
            if(j < k){
                REP(l, 1, v[m - i].size()){
                    if(v[m - i][l] == v[m - i][l - 1]){
                        ++cnt;
                        ++l;
                    }
                }
                ans += min(cnt, (k - j) / 2);
            }else if(j > k){
                REP(l, 1, v[i].size()){
                    if(v[i][l] == v[i][l - 1]){
                        ++cnt;
                        ++l;
                    }
                }
                ans += min(cnt, (j - k) / 2);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	char S[110],T[110];
	scanf("%s",S+1),scanf("%s",T+1);
	printf("%s%s",T+1,S+1);
	return 0;
}


Measured memory_bytes: 256