akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    int N;
    ll ans;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        int a,b;
        cin>>a>>b;
        ans+=b-a+1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split(" "))
r, s, p = map(int, input().split(" "))
t = input()

katsu = {}
katsu["r"] = "p"
katsu["s"] = "r"
katsu["p"] = "s"

score = {}
score["r"] = r
score["s"] = s
score["p"] = p

jibuns = ""
out_score = 0

jibuns = [katsu[aite] for aite in t]
out_score = 0
for i, jibun in enumerate(jibuns):
    if i >= k and jibuns[i-k] == jibun:
        nokoris = ["r", "s", "p"]
        nokoris.remove(jibun)
        if i+k <= n-1:
            if jibuns[i+k] != jibun:
                nokoris.remove(jibuns[i+k])
        jibun = nokoris[0]
        jibuns[i] = jibun
    else:
        out_score += score[jibun]

#print(jibuns)
print(out_score)

Measured memory_bytes: 4212
fun main(args: Array<String>) {
    val mod = (1e9 + 7).toLong()
    val n = readLine()!!.toLong()
    val xs = readLine()!!.split(' ').map { it.toLong() }

    var ans = 0L

    for (i in 0 until 60) {
        val a = xs.map { (it shr i) and 1 }.sum()
        val b = n - a
        ans += ((a * b) % mod) * ((1L shl i) % mod) % mod
        ans %= mod
    }

    println(ans)
}


Measured memory_bytes: 127964
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
using namespace std;
	
int main(){
	ll n, k, d;
	cin >> n >> k >> d;
	n = (n < 0)? -n : n;
	if(n/d < k){
		ll rem = k-n/d;
		if(!(rem&1))cout << abs(n%d) << endl;
		else{
			cout << d-n%d << endl;                                          
		}		 
	}
	else cout << n-d*k << endl;
	return 0;
}
















Measured memory_bytes: 3572
n, y = gets.chomp!.split(" ").map(&:to_i)
t = y / 1000 - n

0.upto(n) do |x|
    0.upto(n) do |y|
        next if x + y > n

        if 9 * x + 4 * y == t
            puts [x, y, n - x - y].join(" ")
            exit 0
        end
    end
end

puts "-1 -1 -1"


Measured memory_bytes: 3836
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int g[200][200];
int used[200][200];
int ans=0;

void dfs(int i, int j, int times){
    if(times<0 or used[i][j]>=times or g[i][j]==1) return;
    if(used[i][j]==-1) ans++;
    used[i][j]=times;
    dfs(i+1, j,times-1);
    dfs(i-1, j,times-1);
    dfs(i, j+1,times-1);
    dfs(i, j-1,times-1);
    dfs(i+1, j+1,times-1);
    dfs(i-1, j-1,times-1);
}

int main(){
    for (;;) {
        int t,n;
        cin >> t >> n;
        if(!t and !n)break;
        memset(g, 0, sizeof(g));
        memset(used, -1, sizeof(used));
        ans = 0;
        for (int i=0; i<n; i++) {
            int x,y;
            cin >> x >> y;
            g[x+100][y+100]=1;
        }
        int xx,yy;
        cin >> xx >> yy;
        dfs(xx+100,yy+100,t);
        cout << ans << endl;
    }
}

Measured memory_bytes: 1480
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;

    while(cin >> S >> T) {
        int ans = 0;
        int i = 0, j = 0;
        rep(k, 2) {
            rep(i, S.length()) {
                int tmp = 0;
                rep(j, S.length()) {
                    if (i + j == S.length()) break;
                    if (S[i+j] == T[j]) tmp++;
                    else tmp = 0;
                    ans = max(ans, tmp);
                }
                //dump(ans);
            }
            swap(S, T);
        }
        cout << ans << endl;
    }


    return 0;
}



Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N, K, X, Y;

    scanf("%d%d%d%d", &N, &K, &X, &Y);

    if(N <= K){
        printf("%d\n", X * N);
    }else{
        printf("%d\n", X * K + Y * (N - K));
    }

    return 0;
}

Measured memory_bytes: 1712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
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;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<ll, ll, greater<ll> >::iterator;

ll dp[3001][3001] = { 0 };

//1959
int main() {
//	ios_base::sync_with_stdio(false);
//	cin.tie(0);
//	cout.tie(0);

	// long long?
	string s,t;
	cin >> s >> t;

	for (int i = 0; i != s.length(); ++i) {
		for (int j = 0; j != t.length(); ++j) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
			}
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
			dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
		}
	}

	int idx1 = s.length();
	int idx2 = t.length();
	string str = "";
	while (1) {
		if (dp[idx1][idx2] == dp[idx1 - 1][idx2]) {
			idx1--;
		}
		else if (dp[idx1][idx2] == dp[idx1][idx2 - 1]) {
			idx2--;
		}
		else {
			str = s[idx1 - 1] + str;
			idx1--;
			idx2--;
		}

		if (idx1 <= 0 || idx2 <= 0) {
			break;
		}
	}

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 70656
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    vector<long long> solve(int n, int k) {
        const long long MOD = 1e9 + 7;
        const int N = n + 123;
        vector<vector<long long>> C(N + 1, vector<long long>(N + 1, 0));

        for (int i = 0; i <= N; ++i) {
            C[i][0] = 1;
            for (int j = 1; j <= i; ++j) {
                (C[i][j] = C[i - 1][j - 1] + C[i - 1][j]) %= MOD;
            }
        }

        auto calc = [&](int n, int m, int k) {
            long long res = 1;
            (res *= C[n - 1][k - 1]) %= MOD;
            (res *= C[m + 1][k]) %= MOD;
            return res;
        };

        vector<long long> res(k, 0);

        for (int i = 0; i < k; ++i) {
            res[i] = calc(k, n - k, i + 1);
        }

        return res;
    }

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    Solution sol;
    auto res = sol.solve(n, k);
    for (int i = 0; i < k; ++i) {
        cout << res[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 35584
str_in = []
while True:
    try :
        str_in.append(input()) 
    except :
        break
s = str_in[0]
p = str_in[1]

flag = False
for i in range(0, len(s)):
    flag = True
    for j in range(0, len(p)):
        if (s[(i + j) % len(s)] != p[j]):
            flag = False
            break
    if (flag):
        break
if (flag):
    print('Yes')
else :
    print('No')


Measured memory_bytes: 5568
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (int &e : A) {
		cin >> e;
	}
	int cnt = 0, i = 0;
	while (i < N) {
		
		int dir = 0;
		while (i + 1 < N) {
			if (A[i + 1] < A[i]) {
				if (dir == 2) {
					break;
				}
				dir = 1;
			}
			else if (A[i + 1] > A[i]) {
				if (dir == 1) {
					break;
				}
				dir = 2;
			}
			++i;
		}
		++i;
		++cnt;
	}
	cout << cnt << endl;
	cin >> ws;
}

Measured memory_bytes: 640
#include<stdio.h>
#include <math.h>

int main(){
double ans;
int a,b,x;
scanf("%d %d %d",&a,&b,&x);
double h=(double)x/(double)(a*a);
//printf("%lf\n",h);
double s=(double)a*h;
//printf("%lf\n",s);
double sS=(double)(a*b/2);
//printf("%lf\n",sS);
double c;
double a1;
double a2;
double b1;
if(sS ==s){
	ans=atan2(a,b)/M_PI*180.0;
}else if(sS < s){
    
	c=(s*2.0/(double)a)-(double)b;
//	printf("%lf\n",c);
	ans= atan2(1,(double)a/((double)b-c))/M_PI*180.0;
	}

else{
  //  printf("c\n");
	a1=s*2.0/(double)b;
	a2=(double)a-a1;
	//printf("%lf    %lf\n",a1,a2);
	b1=a2*(double)b/a1;
	//printf("%lf\n",b1);
	ans=atan2(b1,a2);
	//printf("%lf\n",ans);
	ans=ans/M_PI*180.0;
}
printf("%.9lf",ans);
}



Measured memory_bytes: 128
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
xyh=array(N)
N.times do|i|
    xyh[i]=get_i
end
xyh.sort!{|x,y| y[2]<=>x[2]}
ans_x=-1
ans_y=-1
ans_h=-1
101.times do|cx|
    101.times do|cy|
        nh=-1
        flag=true
        xyh.each do|x,y,h|
            if h.zero?
                unless nh<=h+(x-cx).abs+(y-cy).abs
                  flag=false
                  break
                end
                next
            end
            if nh==-1
                nh=h+(x-cx).abs+(y-cy).abs
            else
                if nh!=(h+(x-cx).abs+(y-cy).abs)
                    flag=false
                    break
                end
            end 
        end
        if flag
            ans_x=cx
            ans_y=cy
            ans_h=nh
            break
        end
    end
    if(ans_h!=-1)
        break
    end
end
puts [ans_x,ans_y,ans_h].join(" ")

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

struct s
{
	int a; //连续0的起点
	int b; //连续个数
};

s p; 
vector
 vec;
string str;
int n, k; 
int num;
int M = 0;
const int maxn = 100000 + 5;
int mem[maxn];
int ans[maxn];

void Count(int start, int end)
{
	//cout << "start: " << start << " end: " << end << endl;
	int cnt = 0;
	cnt += end - start + 1;
	for(int i = start-1; i >= 0; i--) //left
	{
		if(str[i] == '1') cnt++; 
		else break; 
	}
	for(int i = end+1; i <= n; i++) //right
	{
		if(str[i] == '1') cnt++; 
		else break;
	}
	if(cnt > M) M = cnt;
}

void solve()
{
	int start = 0; 
	while(1)
	{	
		int end = start + k - 1; 
		if(end > num-1) break;
		Count(vec[start].a, vec[end].a + vec[end].b - 1);
		start++;
	}
}
	
int main()
{
	cin >> n >> k; getchar();
	getline(cin, str);
	int flag = 0;
	p.b = 0;
	for(int i = 0; i < n; i++) 
		if(str[i] == '0')
		{
			p.b++;
			if(flag == 0)
			{
				p.a = i; //记录起点 	
				flag = 1;
			}
			if(i == n-1) vec.push_back(p);
		}
		else 
		{
			if(flag)
			{
				flag = 0;
				vec.push_back(p);
				p.b = 0;
			}
		}

	if(k >= vec.size()) cout << n << endl;
	else
	{
		num = vec.size();
		solve();
		cout << M << endl;
	}
}

Measured memory_bytes: 1020
C = [list(map(int, input().split())) for _ in range(3)]
a1 = 0
b1 = C[0][0] - a1
b2 = C[0][1] - a1
b3 = C[0][2] - a1
a2 = C[1][0] - b1
a3 = C[2][0] - b1
if C[1][1] == a2 + b2 and C[1][2] == a2 + b3 and C[2][1] == a3 + b2 and C[2][2] == a3 + b3:
    print('Yes')
else :
    print('No')

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

using namespace std;

int main(){
    int x,n;
    scanf("%d %d",&x,&n);
    int smaller = x;
    int bigger = x;
    int a[n];
    for(int i = 0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for (int i = 0; i < n; i++)
    {
        if(a[i]==bigger)
        bigger++;
        if(a[n-i-1]==smaller)
        smaller--;
    }
    if(x-smaller>bigger-x)
        printf("%d",bigger);
    else
        printf("%d",smaller);
    
}

Measured memory_bytes: 3764
#n,a,b = [int(i) for i in input().split()]
from collections import deque

n,m=[int(i) for i in input().split()]
oya=[[] for i in range(n)]
ko=[[] for i in range(n)]
for i in range(n+m-1):
    aa,bb=[int(i)-1 for i in input().split()]
#    print(aa,bb)
    oya[bb].append(aa)
    ko[aa].append(bb)


root=0
for i in range(n+m):
    if len(oya[i])==0:
        root=i
        break
oya[root]=['root']

#print(oya)
#print(ko)

d = deque([root])
while len(d) > 0:
    x = d.popleft()
    for i in ko[x]:
        if len(oya[i])!=1:
            oya[i].remove(x)
        else: d.append(i)

#print(oya)
#print(ko)

for i in range(n):
    if oya[i][0] == 'root':
        print(0)
    else:
        print(oya[i][0]+1)




Measured memory_bytes: 34200
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

typedef struct data {
    char name_[11];
    int time_;
} data_t;

int main(void)
{
    int n, q, curTime = 0;
    cin >> n >> q;
    queue<data_t> que;
    for (int i = 0; i < n; i++) {
        data_t tmp;
        scanf("%s%d%*c", tmp.name_, &tmp.time_);
        que.push(tmp);
    }
    while (!(que.empty())) {
        data_t tmp = que.front(); que.pop();
        if (tmp.time_ - q <= 0) {
            curTime += tmp.time_;
            cout << tmp.name_ << " " << curTime << endl;
        } else {
            tmp.time_ -= q;
            curTime += q;
            que.push(tmp);
        }
    }

    return 0;
}

Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-10;
const bool debug = 0;
//----------------------//

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

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	ll x = abs(a - c), y = abs(b - d);
	
	ll ans;
	if (x == 0) {
		ans = y;
	} else {
		ans = y + x - 1;
		ans -= x / (x / gcd(x, y)) - 1;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  vector<double> l(N+2),r(N+2),v(N+2);
  l[0] = 0.0;
  r[0] = 0.0;
  v[0] = 0.0;
  double T_sum = 0;
  for(int i=1; i<=N; i++){
    int T;
    cin >> T;
    l[i] = T_sum;
    T_sum += T;
    r[i] = T_sum;
  }
  for(int i=1; i<=N; i++){
    cin >> v[i];
  }
  cerr << T_sum << endl;
  l[N+1] = T_sum;
  r[N+1] = T_sum;
  v[N+1] = 0.0;
  double ans = 0.0;
  double v_pre = 0.0;
  for(double a=0.50; a<=T_sum; a+=0.50){
    double v_now = INF;
    for(int i=0; i<=N+1; i++){
      if(a < l[i]){
        chmin(v_now, v[i]+(l[i]-a));
      }else if(r[i] < a){
        chmin(v_now, v[i]+(a-r[i]));
      }else{
        chmin(v_now, v[i]);
      }
    }
    ans += 0.2500*(v_pre + v_now);
    v_pre = v_now;
    // cerr << fixed << setprecision(10) << ans << endl;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int apos, zpos;
    
    for(apos = 0; s[apos] != 'A'; apos++);
    for(zpos = s.size()-1; s[zpos] != 'Z'; zpos--);

    cout << zpos-apos+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    string s,t,u;
    cin>>s>>t>>u;
    cout<<(char)(s[0]-('a'-'A'))<<(char)(t[0]-('a'-'A'))<<(char)(u[0]-('a'-'A'))<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 200005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<int,int> pii;

lint A[MAX];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,ans,ns;
    cin>>n;
    for(lint i=1;i<=n;i++) cin>>A[i];
    ans=1000;
    for(lint i=1;i<n;i++){
        ns=0;
        if(A[i+1]>A[i])
            ns=ans/A[i];
        ans+=(A[i+1]-A[i])*ns;
    }
    cout<<ans;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        int n, m;
        cin >> n >> m;
        int h[1505] = {}, w[1505] = {};
        int sumh[1505] = {}, sumw[1505] = {};
        map<int, int> hh;
        ll ans = 0;
        if (n == 0 ) break;
        rep(i, n) cin >> h[i];
        rep(i, m) cin >> w[i];
        rep(i, n) sumh[i + 1] = sumh[i] + h[i];
        rep(i, m) sumw[i + 1] = sumw[i] + w[i];
        rep(i, n)rep2(j, i + 1, n + 1) {
            hh[sumh[j] - sumh[i]]++;
        }
        rep(i, m)rep2(j, i + 1, m + 1) {
            ans += hh[sumw[j] - sumw[i]];
        }
        cout << ans << endl;
    }
}

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

using namespace std;

const int N = (int) 1e5 + 10;
set<int>pot;

typedef struct{
	int t, x, y;
}Point;

Point points[N];

int main (){
	int tmp = 2;
	int k = 0;
	
	/*while(k < 20){
		pot.insert(tmp);
		tmp = tmp * 2;
		
		k++;
	}*/
	
	int n;
	
	scanf("%d", &n);
	
	for(int i = 0 ; i < n ; i++){
		scanf("%d%d%d", &points[i].t, &points[i].x, &points[i].y);
	}
	
	int time = 0;
	bool ok = true;
	
	for(int i = 0 ; i < n ; i++){
		int dis;
		//cout << time << '\n';
		if(i == 0){
			dis = points[i].t - (points[i].x + points[i].y);
		}else{
			dis = points[i].t - time - (abs(points[i - 1].x - points[i].x) + abs(points[i - 1].y - points[i].y));
		}
		
		if(dis < 0){
			ok = false;
			break;
		}
		
		if(dis % 2 == 0){
		
			time = points[i].t;
			
		}else{
			ok = false;
			break;
		}
	}	
	
	if(ok){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define LIMIT 200000


int main(void) {
  /* code */
  int n;
  int i,j;
  int R[LIMIT];
  int max;
  int min;
  int jud;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    jud = 1;
    scanf("%d",&R[i]);
    if(i == 0) {
      min = R[i];
    }else {
      if(min > R[i]){
        min = R[i];
        jud = 0;
      }
      if(i == 1){
        max = R[1] - R[0];
      }else if(jud == 1){
        if(max < R[i] - min){
          max = R[i] - min;
        }
      }
    }
  }


  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

struct edge {
	int u, v, cost;
	edge (int from, int to, int d )
		: u(from), v(to), cost(d) { }
};

const int MAX_N = 100;
const int MAX_E = 100*99/2;
int par[MAX_N];
int rank[MAX_N];
vector<edge> es;

int V, E;	//  頂点数と辺数

// n要素で初期化
int init_union_find (int n )
{
	rep (i, n ){
		par[i] = i;
		rank[i] = 0;
	} // end for
}

// 木の根を求める
int find (int x )
{
	if (par[x] == x )
		return x;

	// 親を遡る
	return par[x] = find (par[x] );
}

// xとyの属する集合をマージ
void unite (int x, int y )
{
	x = find (x);
	y = find (y);

	// 親が一緒なら何もしない
	if (x == y )
		return;

	// ランクが小さい方の木をぶら下げる
	if (rank[x] < rank[y] ){
		// x を y にぶら下げる
		par[x] = y;
	}else{
		// ランクが同じか rank[x] > rank[y]
		par[y] = x;
		if (rank[x] == rank[y] )
			rank[x]++;
	} // end if
}

// xとyが同じ集合に属するか否か
bool same (int x, int y )
{
	return (find (x) == find (y) );
}

bool comp (const edge& e1, const edge& e2 )
{
	return e1.cost < e2.cost;
}

int kruskal (void )
{
	sort (ALL (es ), comp );
	init_union_find (V );
	int res = 0;
	rep (i, E ){
		edge e = es[i];
		if (!same (e.u, e.v ) ){
			unite (e.u, e.v );
			res += e.cost;
		} // end if
	} // end rep

	return res;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.carden_lentern", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		es.clear();
		int m;
		scanf ("%d", &m );
		rep (i, m ){
			int from, to, cost;
			scanf ("%d,%d,%d", &from, &to, &cost );
			es.push_back (edge (from, to, cost ) );
		} // end rep
		E = m;
		V = n;
		int ans = kruskal();	// 最小全域木の経路の長さ
		int res = ans/100 - (V-1);
		printf ("%d\n", res );
	} // end loop

	return 0;
}

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

#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 size(x) ll(x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

int main() {
  int n;
  bool flag = false;
  cin >> n;
  rep1(i,10){
    rep1(j,10){
      if(i*j == n){
        flag = true;
        break;
      }
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n; cin>>n;
    vector<pair<long,long>> a(n);
    for(int i=0;i<n;i++)
        cin>>a[i].first>>a[i].second;
    sort(begin(a),end(a),[](auto x,auto y){return x.second<y.second;});
    cout<<a[0].first+a[0].second;
}

Measured memory_bytes: 1792
import math
import itertools

n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
t=[i for i in range(n)]
x=math.factorial(n)
ans=0
for v in itertools.permutations(s, n):
    for j in range(len(v)-1):
        ans+=(abs(v[j][0]-v[j+1][0])**2+abs(v[j][1]-v[j+1][1])**2)**0.5
        
print(ans/x)

Measured memory_bytes: 3188
a = list(map(int, input().split()))
k = []
for i in range(0, a[0]):
  b = list(map(int, input().split()))
  del b[0]
  k += b

kk = 0
for i in range(1, a[1] + 1):
  if k.count(i) == a[0]:
    kk += 1
print(kk)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 A, B, N;
  cin >> A >> B >> N;
  int64 smaller = min(B - 1, N);
  int64 l = (A * smaller) / B;
  int64 r = smaller / B;
  cout << l - r << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<long double,long double> point;
typedef complex<long double> Point;
const ll MAX = 3000;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    priority_queue<ll> q1,q2;
    vector<P> v;
    rep(i,q){
        ll f,x;
        cin >> f >> x;
        if (f == 1) q1.push(x);
        else q2.push(x);
        v.push_back(P(f,x));
    }
    ll ans = (n-2)*(n-2),m1 = INF,m2 = INF,c1 = n-2,c2 = n-2;
    rep(i,q){
        ll f,x;
        tie(f,x) = v[i];
        if (f == 1){
            ll cnt = 0;
            while (!q1.empty() && q1.top() >= x){
                cnt++;
                q1.pop();
            }
            ans -= c2*cnt;
            chmin(c1,x-2);
        }
        else{
            ll cnt = 0;
            while (!q2.empty() && q2.top() >= x){
                cnt++;
                q2.pop();
            }
            ans -= c1*cnt;
            chmin(c2,x-2);
        }
    }
    PRINT(ans);
}


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

using namespace std;

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

    vector<int64_t> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    int64_t ans = 0;
    while (1) {
        bool ok(true);
        for (int j = 0; j < N; j++) {
            if (arr[j] % 2 == 0) {
                arr[j] /= 2;
            } else {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans++;
        } else {
            break;
        }                
    }

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int maxTime =  sc.nextInt();
		int minCost = 10000;
		for(int i = 0; i < num; i ++) {
			int crtCost = sc.nextInt();
			if(sc.nextInt() <= maxTime) {
				minCost = Math.min(minCost, crtCost);
			}
		}
		System.out.println(minCost == 10000 ? "TLE" : minCost);
	}
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>

using namespace std;

const long long P=1000000007ll;
long long n,k,f[10001];

long long qpow(long long a,int x){
	if(x<0)return 1;
	long long s=1ll;
	while(x){if(x&1)(s*=a)%=P;(a*=a)%=P;x>>=1;}
	return s;
}

int main(){
	scanf("%lld%lld",&n,&k);
	f[0]=1ll;
	for(int i=1;i<n;++i){for(int j=i;j;--j)f[j]=(f[j+1]+f[j-1])%P;f[0]=f[1];}
	printf("%lld",f[n-k]*qpow(2ll,n-k-1)%P);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }

int main() {
	int t;
	// cin >> t;
    t = 1;

	while(t--) {
		int n, x;
		cin >> n;
        
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            cin >> x;
            if (i % 2 == 0)
                cnt += (x % 2);
        }
        
        cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll INF = 1<<29;
int main(){
long double w,h;
ll x,y;cin>>w>>h>>x>>y;
long double ans=0.0;
if(x!=w/2||y!=h/2){
    ans=w*h/2;
    cout<<setprecision(12)<<ans<<endl;
    cout<<0<<endl;
}
if(x==w/2&&y==h/2){
    ans=w*h/2;
    cout<<setprecision(12)<<ans<<endl;
    cout<<1<<endl;
}

}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int X, A; cin >> X >> A;
	if (X < A) {
		cout << 0 << endl;
	} else {
		cout << 10 << endl;
	}
}



Measured memory_bytes: 256
n, k = map(int, input().split())

ans = 0
if k % 2 == 0:
    a = ((n+k//2)//k)
    ans += max(0, a*(a-1)*(a-2))
    ans += a*(a-1)*3
    ans += a

a = n//k
ans += max(0, a*(a-1)*(a-2))
ans += a*(a-1)*3
ans += a


print(ans)


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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

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

int main(){

  int h,w;cin>>h>>w;
  string s[h];

  rep(i,0,h)cin>>s[i];

  rep(i,0,h){
    rep(j,0,w){
      if(s[i][j]=='#')continue;
      int count=0;
      rep(k,0,8){
        int x=j+dx[k],y=i+dy[k];
        if(x<w&&x>=0&&y<h&&y>=0&&s[y][x]=='#')count++;
      }
      s[i][j]=char(count+'0');
    }
  }
  rep(i,0,h){
    out(s[i]);
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD = (1e+9) +7;
int main(){
  int n,k;
  int a[101];
  /* dp[何人目][それまでに配った飴の数] = 組み合わせ総数 */
  int dp[101][100001] = {};
  dp[0][0] = 1;
  cin >> n >> k;
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=n;i++){
    for(int j=0;j<=k;j++){
      dp[i][j] = (j?dp[i][j-1]:0) + dp[i-1][j];
      if(j>a[i]) dp[i][j] -= dp[i-1][j-a[i]-1];
      dp[i][j] = (dp[i][j]>0?dp[i][j] % MOD: (dp[i][j] + MOD) %MOD);
    }
  }
  cout << dp[n][k] << endl;
}

Measured memory_bytes: 39680
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

ll N,M;
ll A[100001];
ll sum[100001];
map<int,ll> cnt;

int main(){
    cin>>N>>M;
    repn(i,N){
        cin>>A[i];
        A[i]%=M;
    }

    repn(i,N) sum[i]=(sum[i-1]+A[i])%M; 
    for(int i=0;i<=N;i++) cnt[sum[i]%M]++;

    ll ans=0;
    for(auto e:cnt){
        ans+=e.second*(e.second-1);
    }
    ans/=2;

    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n=0;
  string s;
  cin >> s;
  for(int i=0;i<4;++i) {
    if(s[i] == '+') ++n;
    if(s[i] == '-') --n;
  }
  cout << n << endl;
}




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

using namespace std;

int main()
{
  int n,count=0;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a.begin(),a.end());
  for(int k=0;k<n;k++){
    for(int j=0;j<k;j++){
      for(int i=0;i<j;i++){
      //  cout<<i<<" "<<j<<" "<<k<<endl;
        if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k])
          break;
        if(a[i]+a[j]>a[k])
          count++;
      }
    }
  }
  cout<<count<<endl;
}

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


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    long long ans = (long long)a*c;
    long long tmp = (long long)a*d;
    ans = max(ans,tmp);
    tmp = (long long)b*d;
    ans = max(ans,tmp);
    tmp = (long long)b*c;
    ans = max(ans,tmp);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <assert.h>
#include <vector>

#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	int limit;
	int md[N2][N2];
	// vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(Node *cur_n, int depth, int pre) {
		if(cur_n->md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n->md > limit) return false;
		int s_x = cur_n->space / N;
		int s_y = cur_n->space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node new_n = *cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			//incremental manhattan distance
			new_n.md -= md[new_x * N + new_y][new_n.puzzle[new_x * N + new_y] - 1];
			new_n.md += md[s_x * N + s_y][new_n.puzzle[new_x * N + new_y] - 1];

			swap(new_n.puzzle[new_x * N + new_y], new_n.puzzle[s_x * N + s_y]);
			new_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(&new_n, depth + 1, i)){
				// path[depth] = i;
				return true;
			}
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			// path.resize(limit);
			if(dfs(&s_node, 0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <string.h>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

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

    vector<int> v;
    v.push_back(a);

    int new_v;
    for (int i = 0; i < 10000; ++i) 
    {
        new_v = ( v[i] % 2 == 0 ? v[i] / 2 : 3 * v[i] + 1 );
        if (find(v.begin(), v.end(), new_v) != v.end() )
        {
            cout << i+2;
            break;
        }
        else
        {
            v.push_back(new_v);
        }

    }
    

    return 0;
}

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

int main() {
    long long x;
    cin >> x;
    long long n = 100;
    long long ans = 0;
    while(n < x) {
        double t = n * 1.01;
        n = t;
        ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int h, w, k;
int calc(vstr s, vbool H, vbool W) {
    int res = 0;
    rep(i, h) {
        if (H[i]) continue;
        rep(j, w) {
            if (W[j]) continue;
            if (s[i][j] == '#') res++;
        }
    }
    return res;
}

int main() {
    cin >> h >> w >> k;
    vstr c(h);
    rep(i, h) cin >> c[i];

    int ans = 0;
    rep(i, (1<<h)) {
        vbool H(h, false);
        int tmp = i;
        int count = 0;
        while(tmp > 0) {
            if (tmp&1) H[count] = true;
            count++;
            tmp >>= 1;
        }
        rep(j, (1<<w)) {
            vbool W(w, false);
            int tmp = j;
            int count = 0;
            while(tmp > 0) {
                if (tmp&1) W[count] = true;
                count++;
                tmp >>= 1;
            }
            if (calc(c, H, W) == k) ans++;
        }
    }

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

Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> pii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define rep(i,a,b) for(int i=a;i<=int(b);i++)
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);
const ll M  = 1e9+7 ;
const int N = 100100;
const int inf = INT_MAX;
const double eps = 1e-7;
const ll iinf = -1e18 ;
//////////////////////    Hi    ^_^  hack me if you can :P


string s;

int main()
{
    speed;
    int n;
    cin >> n;
    cin >> s;
    int op = 0;
    int nop = 0;
    int cl = 0;
    int ncl = 0;
    string t = s;
    lop(i,sz(s))
    {
        if (s[i] == ')')
        {
            if (op)
            {
                op--;
            }
            else nop++;
        }
        else if (s[i] == '(')
        {
            bool ok = 0;
            rep(j,i+1,sz(s)-1)
            {
                if (s[j] == ')')
                {
                    s[j] = '-';
                    ok = 1;
                    break;
                }
            }
            if (ok) continue;
            ncl++;
            op++;
        }
    }

    while (nop--) cout << '(';
    cout << t ;
    while (ncl--) cout << ')';
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  while (true) {
    int minv, e;
    std::cin >> e;
    if (e == 0) break;
    minv = e;
    
    for (int z = 0; z*z*z <= e; z++) {
      for (int y = 0; y*y+z*z*z <= e; y++) {
        int v = e - y*y -z*z*z + y + z;
        if (v < minv) minv = v;
      }
    }
    
    std::cout << minv << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160