akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int d, t, s; cin >> d >> t >> s;
	if (d / (double) s <= (double) t) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  long long N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;
  cout << (max({ (N-1)/A, (N-1)/B, (N-1)/C, (N-1)/D, (N-1)/E }) + 1) + 4;
  return 0;
}

Measured memory_bytes: 256
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll dp[100010];
void solve()
{
	IN(n);
	vl v;
	FOR(i, 0, n)
	{
		IN(in);
		v.pb(in);
	}
	dp[0] = 0;
	FOR(i, 1, n)
	{
		dp[i] = min(dp[i - 1] + abs(v[i] - v[i - 1]), (i-2>=0?dp[i - 2] + abs(v[i] - v[i - 2]):MAX));
	}
	cout << dp[n - 1];
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 4676
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){
	
	fastio;
	deque<char> dq;
	string s;
	cin >> s;
	for(char ch : s){
		dq.push_back(ch);
	}

	int rev = 0,q,t,f;
	char ch;
	cin >> q;
	while(q--){
		cin >> t;
		if(t == 1){
			rev ^= 1;
		}else{
			cin >> f >> ch;
			if(rev){
				if(f == 1) dq.push_back(ch);
				else dq.push_front(ch);
			}else{
				if(f == 1) dq.push_front(ch);
				else dq.push_back(ch);
			}
		}
	}

	string ans;
	if(rev){
		while(sz(dq)){
			ans += dq.back();
			dq.pop_back();
		}
	}else{
		while(sz(dq)){
			ans += dq.front();
			dq.pop_front();
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1368
n, W = map(int, input().split())
dp = [[0 for _ in range(W + 1)] for i in range (n + 1)]
for i in range(1, n + 1):
    w, v = map(int, input().split())
    for j in range(1, W + 1):
        if w > j:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
print(dp[-1][-1])

Measured memory_bytes: 173448
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	a,b = readline() |> chomp |> split
	a = parse(BigInt, a)
	b = split(b,".")
	b = parseInt(b[2])+100*parseInt(b[1])
	println(div(a*b,100))
end

main()

Measured memory_bytes: 173624
a, b, c = gets.chomp.split(" ").map(&:to_i)

ans = 0
while true
  break if a == b && b == c
  a, b, c = [a, b, c].sort
  if a == b then
    a += 1
    b += 1
  else
    a += 2
  end
  ans += 1
end
puts ans

Measured memory_bytes: 3836
def main():
    N = int(input())
    S = input()
    if len(set(S)) == 1:
        return print(0)
    w = S.count(".")
    b = 0
    ans = w
    for s in S:
        if s == "#":
            b += 1
        else:
            w -= 1
        ans = min(ans, b+w)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53744
// @DateTime:    2020-04-26 20:12:50
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int mod = 1e9+7;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260811, P_2=999998639;
void add(int &a,int b) {a+=b; if(a>=mod) a-=mod;}
void dec(int &a,int b) {a-=b; if(a<0) a+=mod;}
int main()
{
    map<string , int> mp;
    int n;
    cin >> n;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s;
        mp[s]++;
    }cout << mp.size() ;
    
}

Measured memory_bytes: 19200
#2問目
NQ = input().split()
N,Q = int(NQ[0]), int(NQ[1])
S = input()
P = [input().split() for i in range(Q)]
 
#累積和
ruiseki = [0]*N
for i in range(1,N):
    if(S[i] == "C" and S[i-1] == "A"):
        ruiseki[i] = ruiseki[i-1] + 1
    else:
        ruiseki[i] = ruiseki[i-1]
 
for j in range(Q):
    print(ruiseki[int(P[j][1]) - 1] - ruiseki[int(P[j][0]) - 1])

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

int main(){
    int ans = 0;
    string s, t;
    cin >> s >> t;
    rep(i, 3){
        if (s[i] == t[i]){
            ans++;
        }
    }
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val array = readLine()
        ?.split(" ".toRegex())
        ?.toTypedArray()
        ?: arrayOf("")
    val stack = MyStack<Int>()
    array.forEach {
        try {
            val num = it.toInt()
            stack.push(num)
        } catch (e: NumberFormatException) {
            when (it) {
                "+" -> {
                    val b = stack.pop()
                    val a = stack.pop()
                    stack.push(a + b)
                }
                "-" -> {
                    val b = stack.pop()
                    val a = stack.pop()
                    stack.push(a - b)
                }
                "*" -> {
                    val b = stack.pop()
                    val a = stack.pop()
                    stack.push(a * b)
                }
            }
        }
    }
    println(stack.pop())
}

class MyStack<T> {
    private val list = mutableListOf<T>()

    fun push(newVal: T) {
        list.add(newVal)
    }

    fun pop(): T {
        val retVal = list.last()
        list.removeAt(list.lastIndex)
        return retVal
    }
}


Measured memory_bytes: 29736
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define U(v) cerr << #v << ": " << (v) << endl

int main() {
    string s;
    while (cin >> s) {
        if (s.size() % 2) {
            int i = s.size() / 2 - 1;
            for (; i >= 0; --i) {
                if (s[i] == s[s.size() - 1 - i] && s[i] == s[i + 1]) {

                } else {
                    break;
                }
            }
            cout << s.size() - i - 1 << endl;
        } else {
            int i = s.size() / 2 - 1;
            for (; i >= 0; --i) {
                if (s[i] == s[s.size() - 1 - i] && s[i] == s[i + 1]) {

                } else {
                    break;
                }
            }
            cout << s.size() - i - 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
int n;
signed main(){
    cin>>n;
    int ans=(n-1)/2;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
x = int(input())

if x == 1:
    a = 1
    b = 0
else:
    p = 1
    while True:
        while True:
            if x % p == 0:
                q = int(x / p)
                break
            else:
                p += 1
        ap = p
        am = p
        bp = 0
        bm = 0
        for i in range(200):
            if ap**4 + ap**3 * bp + ap**2 * bp**2 + ap * bp**3 + bp**4 == q:
                a = ap
                b = bp
                break
            elif am**4 + am**3 * bm + am**2 * bm**2 + am * bm**3 + bm**4 == q:
                a = am
                b = bm
                break
            ap += 1
            bp += 1
            am -= 1
            bm -= 1
        else:
            p += 1
            continue
        break

print('{} {}'.format(a, b))

Measured memory_bytes: 64644
#include <iostream>
#include <string>
using i64 = long long;

int main() {
    i64 a;
    std::string s;
    std::cin >> a >> s;
    std::string t;
    for (const char c : s) if (c != '.') t += c;
    const i64 b = std::stoi(t);

    std::cout << a * b / 100 << std::endl;

    return 0;
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

string rotate(const string& str ,int offset,int turn_count,int mask_interval){
  int base_mask = (1<<mask_interval) - 1;
  int current_mask = (base_mask << offset);

  string next_dial="";
  for(int i=0;i<str.size();i++){
    if((current_mask >> i) & 1){
      int next_num = (str[i] - '0' + turn_count) % 10;
      next_dial.push_back('0' + next_num);
    }
    else{
      next_dial.push_back(str[i]);
    }
  }
  return next_dial;
}

class State{
public:
  string dial;
  int cost;
  State(string _d,int _c) : dial(_d),cost(_c) {}
  State() : dial(""),cost(0) {}

  bool operator <(const State& s) const{
    return cost < s.cost;
  }

  bool operator >(const State& s) const{
    return cost > s.cost;
  }
};

int compute_dist(int lhs,int rhs){
  if(lhs > rhs){
    //0...rhs...lhs...9
    return (9-lhs + rhs + 1);
  }
  else if(lhs < rhs){
    //0...lhs...rhs...9
    return rhs - lhs;
  }
  return 0;
}

int main(){
  int total_dials;
  while(~scanf("%d",&total_dials)){
    if(total_dials == 0) break;
    
    string initial_state,unlocked_state;
    cin >> initial_state >> unlocked_state;
    map<string,int> dp;

    dp[initial_state] = 0;

    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(initial_state,0));

    while(!que.empty()){
      State s = que.top();
      que.pop();

      int change_idx = 0;
      for(int dial_idx = 0; dial_idx < s.dial.size(); dial_idx++){
	if(s.dial[dial_idx] == unlocked_state[dial_idx]) continue;
	change_idx = dial_idx;
	break;
      }
      int turn_count = compute_dist(s.dial[change_idx] - '0',unlocked_state[change_idx] - '0');
      for(int mask_interval = 1; change_idx + mask_interval <= s.dial.size(); mask_interval++){
	string candidate = rotate(s.dial,change_idx,turn_count,mask_interval);
	if(dp.find(candidate) == dp.end()){
	  dp[candidate] = s.cost + 1;
	  que.push(State(candidate,s.cost + 1));
	}
      }
    }

    printf("%d\n",dp[unlocked_state]);
  }
}

Measured memory_bytes: 2752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

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

	static class TaskA {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int[] A = new int[N];
			int[] B = new int[N];
			int[] C = new int[N];
			for(int i = 0; i < N; i++) {
				A[i] = in.nextInt();
			}
			for(int i = 0; i < N; i++) {
				B[i] = in.nextInt();
			}
			for(int i = 0; i < N; i++) {
				C[i] = in.nextInt();
			}
			Arrays.sort(A);
			Arrays.sort(C);
			
			long ans = 0L;
			for (int i=0; i < N; i++) {
				long a = binarySearchLB(A, B[i]);
				long c = binarySearchUB(C, B[i]);
				c = N - c;
				ans += a * c;
			}
			out.println(ans);
		}
	}
	
	static int binarySearchLB (int[] ar, int t) {
		int L = 0;
		int R = ar.length;
		while (L < R) {
			int M = (L+R) / 2;
			if (t <= ar[M]) R = M;
			else L = M+1;
		}
		return L;
	}
 
	static int binarySearchUB (int[] ar, int t) {
		int L = 0;
		int R = ar.length;
		while (L < R) {
			int M = (L+R) / 2;
			if (t >= ar[M]) L = M+1;
			else R = M;
		}
		return L;
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 53380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
vector<string> split(string s, char p){vector<string>v;stringstream m(s);string b;while(getline(m,b,p))v.push_back(b);return v;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main(){
    ll x, a, b; cin >> x >> a >> b;
    if (abs(x-a) < abs(x-b)) cout << "A\n";
    else cout << "B\n";
}


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

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

	int n = N % 10;
	string ans = "hon";
	if( n == 0 || n == 1 || n == 6 || n == 8 ) ans = "pon";
	else if( n == 3 ) ans = "bon";

	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	map<string, vector<vll>> mp;
	for (ll i = 0; i < n; i++) {
		string s;
		ll p;
		cin >> s >> p;
		mp[s].push_back({-p, i + 1});
	}
	for (auto i = mp.begin(); i != mp.end(); i++) {
		vector<vll> v = (i -> second);
		sort(all(v));
		for (ll j = 0; j < v.size(); j++) cout << v[j][1] << endl;
	}
}


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

int main() {
  string p = "aeiou";
  char c;
  cin >> c;
  int i; 
    
  for (i = 0; i < 5; i++) {
    if (c == p.at(i)) {
      cout << "vowel" << endl;
      break;
    }
  }
  
  if (i == 5) {
    cout << "consonant" << endl;
  }
}
  


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true){
      int n = sc.nextInt();
      int x = sc.nextInt();
      int N = 0;
      if(n==0 && x==0){
        break;
      }
      for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
          for(int k=j+1;k<=n;k++){
            int S = i + j + k;
            if(S==x){
              N++;
              S=0;
            }
          }
        }
      }
      System.out.println(N);
    }
  }
}


Measured memory_bytes: 26608
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; i < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int main() {
  int N;
  cin >> N;
  int val[N][3];
  rep(i,N){
    cin >> val[i][0] >> val[i][1] >> val[i][2];
  }
  int ans[N][3];
  ans[0][0] = val[0][0];
  ans[0][1] = val[0][1];
  ans[0][2] = val[0][2];

  srep(i,1,N) {
    ans[i][0] = max(ans[i-1][1],ans[i-1][2]) + val[i][0];
    ans[i][1] = max(ans[i-1][0],ans[i-1][2]) + val[i][1];
    ans[i][2] = max(ans[i-1][0],ans[i-1][1]) + val[i][2];
  }
  int answer = max(max(ans[N-1][0],ans[N-1][1]), ans[N-1][2]);
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 2560
n,c = map(int,input().split())
sushi = []
for _ in range(n):
  sushi.append(list(map(int,input().split())))
can = []

right1 = []
right2 = []
tmp = 0
for i in range(n):
  s,v = sushi[i]
  tmp += v
  right1.append([tmp-s,s])
  right2.append([tmp-2*s,s])
left1 = []
left2 = []
tmp = 0
for i in range(n)[::-1]:
  s,v = sushi[i]
  tmp += v
  left1.append([tmp-(c-s),c-s])
  left2.append([tmp-2*(c-s),c-s])
right1.sort()
left1.sort()
#print(right1)
#print(left1)

can.append(0)
can.append(right1[-1][0])
can.append(left1[-1][0])
#print(can)
for i in range(n):
  energy,s = right2[i]
  while left1[-1][1] + s >= c:
    left1.pop()
    if left1 == []:
      break
  else:
    can.append(energy + left1[-1][0])
    #print(s,left1[-1][1],left1)
    continue
  break
#print(can)
for i in range(n):
  energy,s = left2[i]
  while right1[-1][1] + s >= c:
    right1.pop()
    if right1 == []:
      break
  else:
    can.append(energy + right1[-1][0])
    #print(s,right1[-1][1],right1)
    continue
  break
print(max(can))
#print(can)

Measured memory_bytes: 112216
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long area,w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<((double)w*h/2)<<" "<<(x*2==w&&y*2==h);
    return 0;
}



Measured memory_bytes: 3792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
    int n, m; scanf("%d%d", &n, &m);

    vector<pair<int, int>> bs(n, make_pair(2, 1));
    bs[0] = make_pair(1, 1);

    while (m--) {
        int x, y; scanf("%d%d", &x, &y);
        x--, y--;

        bs[y].second++;
        bs[y].first |= bs[x].first;

        bs[x].second--;
        if (bs[x].second == 0) bs[x].first = 0;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (bs[i].first & 1) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    string s;
    cin>>s;
    ll ans=0, x=0, c=1;
    map<ll,ll> m;
    m[0]=1;
    bfor(i,sz(s),0)
    {
        x=(x+c*(s[i]-'0'))%2019;
        ans+=m[x];
        m[x]++;
        c=c*10%2019;
    }
    cout<<ans;
    
    return 0;
}



Measured memory_bytes: 3728
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T, bool maximum_mode = false>
struct online_RMQ {
    int n = 0, levels = 0;
    vector<vector<T>> range_min;

    online_RMQ(const vector<T> &values = {}) {
        for (T value : values)
            add(value);
    }

    static int largest_bit(int x) {
        return 31 - __builtin_clz(x);
    }

    static T better(T a, T b) {
        return (a < b) ^ maximum_mode ? a : b;
    }

    void add(T value) {
        n++;

        if (largest_bit(n) + 1 > levels) {
            levels = largest_bit(n) + 1;
            range_min.emplace_back();
        }

        range_min[0].push_back(value);

        for (int k = 1; k < levels; k++) {
            int index = range_min[k].size();
            range_min[k].push_back(better(range_min[k - 1][index], range_min[k - 1][index + (1 << (k - 1))]));
        }
    }

    T query(int a, int b) const {
        assert(0 <= a && a < b && b <= n);
        int level = largest_bit(b - a);
        return better(range_min[level][a], range_min[level][b - (1 << level)]);
    }
};


const long long LL_INF = (long long) 2e18 + 5;

struct oper {
    int L, R, C;

    bool operator<(const oper &other) const {
        return R < other.R;
    }
};

int N, M;
vector<oper> ops;
vector<long long> dp;

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

    cin >> N >> M;
    ops.resize(M);

    for (oper &op : ops) {
        cin >> op.L >> op.R >> op.C;
        op.L--; op.R--;
    }

    sort(ops.begin(), ops.end());
    online_RMQ<long long> rmq;
    dp.assign(N, LL_INF);
    dp[0] = 0;

    for (oper &op : ops) {
        while (rmq.n < op.R)
            rmq.add(dp[rmq.n]);

        dp[op.R] = min(dp[op.R], rmq.query(op.L, op.R) + op.C);
    }

    cout << (dp[N - 1] < LL_INF ? dp[N - 1] : -1) << '\n';
}


Measured memory_bytes: 14496
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using static System.Math;
using static System.Console;
class Simple
{
    int A, B, C, X;
    void Solve() {
        //input
        A = io.Int;
        B = io.Int;
        C = io.Int;
        X = io.Int;
        //cal
        var cnt = 0;
        for (int a = 0; a <= A; ++a) {
            for (int b = 0; b <= B; ++b) {
                var t = X - 500 * a - 100 * b;
                if (t % 50 == 0) {
                    var c = t / 50;
                    if (0 <= c && c <= C) {
                        cnt++;
                    }
                }
            }
        }
        //ret
        WriteLine(cnt);
    }
    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}
class SimpleIO
{
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length)
            return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "")
            st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

string s,t;

int main()
{
	cin>>s>>t;
	cout<<t+s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int n;
    int a[101];
    double ans;
    scanf("%d",&n);
    for (int i = 1;i<=n ; i++) {
        scanf("%d",&a[i]);
        ans = ans + (double)1/(a[i]);
    }
    ans = (double)1/ans;
    printf("%f",ans);
}

Measured memory_bytes: 128
l, r = map(int, input().split())

n= 0
if r - l > 2019:
	n = l + 2019
else:
	n = r

min = 2019

for i in range(l, n):
	for j in range(l+1, n+1):
		mod = (i*j) % 2019
		if mod < min:
			min = mod

print(min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int n;
int height[100000],dp[100000];
void read()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>height[i];
    }
}
int max(int a,int b)
{
    if(a<b)
    return a;
    else
    return b;
}
int solve()
{
    dp[0]=0;
    dp[1]=abs(height[1]-height[0]);
    for(int i=2;i<n;i++)
    {
     dp[i]=min(abs(height[i]-height[i-1])+dp[i-1],abs(height[i]-height[i-2])+dp[i-2]);   
    }
    return dp[n-1];
}
int main() {
	read();
	cout<<solve();
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int a[200002],b[200002];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	long long ans=0;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(a,a+n,cmp);
	for (int i=0;i<n;i++){
		if (a[0]==b[i]){
			cout<<a[1]<<endl;
		}
		else cout<<a[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
L,R = map(int, input().split())
l = L//2019
r = R//2019
m = L%2019
n = R%2019

ans = 2018
if l != r:
  print(0)
  exit()
else:
  for i in range(m,n):
    for j in range(i+1,n+1):
      ans = min((i*j) % 2019, ans)
      if ans == 0:
        print(ans)
        exit()
      
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int64_t N, K;
  int64_t ans=0;
  cin >> N;
  vector<int64_t> A(N);
  for (int64_t i=0; i<N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  if (N%2==0) {
    K = (N-2)/2;
    ans = A.at(N-1);
    for (int64_t j=0; j<K; j++) {
      ans = ans + 2*A.at(N-(j+2));
    }
    cout << ans << endl;
  }
  else {
    K = (N-3)/2;
    ans = A.at(N-1) + A.at(N-K-2);
    for (int64_t l=0; l<K; l++) {
      ans = ans + 2*A.at(N-(l+2));
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 4808
import java.util.Scanner;

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

			int a = Integer.parseInt(sc.next());
			int all = 0;
			for (int i = 0; i < a; i++) {
				all += Integer.parseInt(sc.next());
			}
			System.out.println(all - a);
		}

	}

}


Measured memory_bytes: 25300
#include <cstdio>
#include <utility>

using namespace std;

#define int long long
#define dotimes(i, n) for (int i = 0, i##max__ = (n); i < i##max__; i++)
#define whole(f, x, ...) ([&](decltype((x)) c) { return (f)(begin(c), end(c), ## __VA_ARGS__); })(x)

int rint() {
  int x;
  scanf("%lld", &x);
  return x;
}

void wint(int x) {
  printf("%lld\n", x);
}

template<typename T> int size(T const& c) { return static_cast<int>(c.size()); }
template <typename T> bool maxs(T& a, T const& b) { return a < b ? a = b, true : false; }
template <typename T> bool mins(T& a, T const& b) { return a > b ? a = b, true : false; }

signed main() {
  const int M = rint();
  auto update = [](pair<int, int>& p, pair<int, int>& a) {
    int t = p.first + a.first;
    if (t < 10) {
      p.first = t;
      p.second += a.second + 1;
    } else {
      p.first = t - 9;
      p.second += a.second + 2;
    }
  };
  pair<int, int> r(0, -1);
  dotimes(i, M) {
    int d = rint();
    int c = rint();
    pair<int, int> p(0, -1), a(d, 0);
    for (; c; c >>= 1) {
      if (c & 1) {
        update(p, a);
      }
      update(a, a);
    }
    update(r, p);
  }
  wint(r.second);
  return 0;
}


Measured memory_bytes: 1724
n,x=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if A[i]+A[i+1]>x:
        ans+= A[i]+A[i+1]-x
        A[i+1] = max(0,x-A[i])
print(ans)


Measured memory_bytes: 19904
if __name__ == '__main__':
    C = [list(map(int, input().split())) for _ in range(3)]
    flag = True
    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[i][j] - C[i][j+1] != C[ni][j] - C[ni][j+1]:
                        flag = False
                        break

    for i in range(2):
            for ni in range(i+1,3):
                for j in range(2):
                    if C[j][i] - C[j+1][i] != C[j][ni] - C[j+1][ni]:
                        flag = False
                        break
    
    if flag:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#define int long long
using namespace std;
int a[123456], test[123456];
signed main() {
	int n, ans = 0; string s; cin >> s;
	int sum = s.size() - 1, h = 0;
	while (sum - h > 0) {
		if (s[h] != s[sum]) {
			if (s[h] != 'x' && s[sum] != 'x') {
				cout << -1 << endl; return 0;
			}
			if (s[h] == 'x') {
				sum++;
			}
			else if (s[sum] == 'x') {
				h--;
			}
			ans++;
		}
		h++; sum--;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define ma 100000000
#define mod 1000000007
const ll  INF=10000000000000;
using namespace std;
int dp[1000000][2];
int a[101];
int n,k;
int f(int k,int p){

    if(dp[k][p]!=-1) {return dp[k][p];}
    for(int i=0;i<n;i++){
        /*cout<<k<<" "<<p<<"\n";
        cout<<dp[k][p]<<" "<<a[i]<<"\n";*/
        if(k>=a[i]){
            int ans=f(k-a[i],1-p);
            if(ans==p){
                dp[k][p]=p;
                dp[k][1-p]=1-p;
                return dp[k][p];
            }
        }
    }
    dp[k][p]=1-p;
    dp[k][1-p]=p;
    return dp[k][p];

}
int main()
{
    IOS;
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>a[i];
    f(k,0);
    if(dp[k][0]) cout<<"Second";
    else cout<<"First";
    return 0;
}


Measured memory_bytes: 12800
from fractions import gcd

A, B = map(int, input().split())


def divisor(n):
    i = 1
    xs = []
    while i * i <= n:
        if n % i == 0:
            xs.append(i)
            xs.append(n//i)
        i += 1
    return set(xs)


ad, bd = divisor(A), divisor(B)
xs = list(sorted(ad & bd))

ans = [1]
for x in xs:
    flag = True
    for k in ans:
        if gcd(x, k) != 1:
            flag = False
            break
    if flag:
        ans.append(x)
print(len(set(ans)))


Measured memory_bytes: 7204
#include<bits/stdc++.h>
using namespace std;
	#define author          "Sihare0riginals"
	#define ss       		string 
	#define lli      		long long int
	#define ld       		long double
	#define f        		first
	#define s        		second
	#define all(v)   		v.begin(),v.end()
	#define I(a,i)			memset(a,i,sizeof(a));
	#define pb       		push_back
	#define mp       		make_pair
	#define L(i,start,end)  for(lli i=start;i<=end;i++)
	#define R(i,start,end)  for(lli i=start;i>=end;i--)
	#define ip(n) 			cin>>n;lli ip[n+1];L(i,1,n)cin>>ip[i];
const lli LINF = 1e18,mod=1e9+7;
void Bl0ck_M0mb0();


signed main()
{
	Bl0ck_M0mb0();
	lli t=1;
	//cin>>t;
	while(t--){
		lli n,k;
		cin>>n>>k;
		lli ip[n+1];
		L(i,1,n)
		cin>>ip[i];
		sort(ip+1,ip+n+1);
		lli ans=0;
		L(i,1,k)
		ans+=ip[i];
		cout<<ans<<endl;
	}
	return 0;
}


















void Bl0ck_M0mb0(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	#ifndef ONLINE_JUDGE
	freopen("ip.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif
}
/*
#define dbg1D(i,start,end,arr) for(lli i=start;i<=end;i++) cout<<i<<"th : "<<arr[i]<<endl;
#define dbg2D(i,j,s1,e1,s2,e2,arr) for(lli i=s1;i<=e1;i++){cout<<i<<"th :";for(lli j=s2;j<=e2;j++)cout<<arr[i][j]<<" ";cout<<endl;}
#define M map<lli,lli> \n #define sz(s) s.size()-1
#define P pair<lli,lli> 
#define V vector<lli>
lli dx[4]={-1, 0, 0, +1};
lli dy[4]={0, -1, +1, 0};
lli power(lli a,lli b,lli m){ if(b==0) return 1; if(b==1) return a%m;
 	lli t=power(a,b/2,m); t=(t*t)%m; if(b&1) t=(t*a)%m; return t;}
lli modInverse(lli a, lli m) { return power(a, m-2, m); } */

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(a, b) for (a = 0; a < b; a++)


int main(){
  
  int N, M;
  cin >> N >> M;
  
  if (N == M) {
    
    cout << "Yes" << endl; 
  } else {
    
    cout << "No" << endl;
  }
  return 0;
  
}

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

int main() {
    int N;
     cin >> N;
     bool f=0;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10; j++)
        {
            if(N==i*j){
                f=1;
                break;
            }
        }
        
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
K,S = [int(i) for i in input().rstrip().split()]

lst_temp = [ int(i) for i in range(K + 1)]

recCnt = 0
for x in lst_temp:
  for y in lst_temp:
    z = S - x - y 
    if z >= 0 and z <= K:
      recCnt += 1
      
print(recCnt)



Measured memory_bytes: 3060
[n, x] = list(map(int, input().split()))
for i, a in enumerate(sorted(list(map(int, input().split())))):
    x -= a
    if x == 0:
        print(i+1)
        break
    elif x < 0:
        print(i)
        break
if x > 0:
    print(n - 1)

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

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

std::string s;
int n;

int main() {
    std::cin >> s;
    n = s.size();
    for (int i = 0; i < n; ++i) {
        if (s[i] == s[i + 1]) {
            printf("%d %d\n", i + 1, i + 2);
            return 0;
        }
        if (s[i] == s[i + 2]) {
            printf("%d %d\n", i + 1, i + 3);
            return 0;
        }
    }
    puts("-1 -1");
    return 0;
}

Measured memory_bytes: 512
s = input()
oddone = ''
evenone = ''

for i in range(len(s)):
    if i % 2 == 1:
        oddone += '1'
        evenone += '0'
    else:
        oddone += '0'
        evenone += '1'

def diffCount(s1, s2):
    count = 0
    if len(s1) != len(s2):
        print('error')
        return

    for i in range(len(s1)):
        if s1[i] != s2[i]:
            count += 1

    return count

print(min(diffCount(s, oddone), diffCount(s, evenone)))



Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <queue>

using namespace std;

int main(){
  int n,a,b,c,i,j,k;
  string s;
  cin >> s;
  if(s.size()==2)cout << s << endl;
  else cout << s[2] << s[1] << s[0] << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.collection.mutable

object Main extends App {

  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val islands = Array.tabulate(n) { _ ⇒ Nil: List[(Int, Int)]}
  for (_ ← 0 until m){
    val Array(a, b, c) = readLine.trim.split(' ').map(_.toInt)
    islands(a - 1) ::= (b - 1, c)
  }
  val minTime = Array.tabulate(n){_ ⇒ Int.MaxValue}.also{ar ⇒ ar(0) = 0}
  val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse).also{q ⇒ q.enqueue((0, 0))}
  while (queue.nonEmpty){
    val (current, time) = queue.dequeue()
    if (minTime(current) == time && current != n - 1){
      for ((next, c) ← islands(current)) {
        if (time <= c && minTime(next) > c) {
          minTime(next) = c
          queue.enqueue((next, c))
        }
      }
    }
  }

  var lastTime = -1
  for (from ← islands.indices){
    islands(from).filter(_._1 == n - 1).foreach{
      case (_, c) if minTime(from) <= c && lastTime < c ⇒ lastTime = c
      case _ ⇒
    }
  }
  println(lastTime)
  implicit class Extend[T](value: T){
    def also(func: T ⇒ Unit): T = {func(value); value}
    def let[A](func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 461588
from math import atan, degrees

a, b, x = map(float, input().split())

if a * a * b == x:
    print(0)
elif x > a * a * b // 2:
    print(90 - degrees(atan(a / (2 * (b - x / a ** 2)))))
else:
    print(90 - degrees(atan((2 * x / (a * b)) / b)))

Measured memory_bytes: 3060
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
def primes(n):
    primfac = []
    d = 2
    while d*d <= n:
        while (n % d) == 0:
            primfac.append(d)  # supposing you want multiple factors repeated
            n //= d
        d += 1
    if n > 1:
       primfac.append(n)
    return primfac

yaku = []
for i in range(2,n+1):
    yaku = yaku + (primes(i))


from collections import defaultdict
yakunum = defaultdict(int)
for i in yaku:
    yakunum[i] += 1


over2, over4, over14, over24, over74 = 0,0,0,0,0
for i in yakunum.values():

    if i > 1:
        over2 += 1
    if i > 3:
        over4 += 1
    if i > 13:
        over14 += 1
    if i > 23:
        over24 += 1
    if i > 73:
        over74 += 1

#print(over2, over4, over14, over24, over74 )
ans = over74 + (over24*over2)-(over24) + (over14*over4)-over14 + ((over4)*(over4-1)*(over2-2))//2

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int s = 1;
vector<int> dat;
void init(int n_) {
	while (s < n_)s *= 2;
	dat.resize(2 * s - 1);
	for (int i = s - 1; i <= n_ + s - 2; i++)dat[i] = i - (s - 2);
	for (int i = s - 2; i >= 0; i--)dat[i] = max(dat[2 * i + 1], dat[2 * i + 2]);
 }

void add(int k, int x) {
	k += s - 2;
	dat[k] = x;
	while (k > 0) {
		k = (k - 1) / 2;
		dat[k] = max(dat[2 * k + 1], dat[2 * k + 2]);
	}
}

int query(int a, int b, int k = 0, int l = 0, int r = s) {
	if (r <= a || b <= l)return 0;
	if (a <= l && r <= b)return dat[k];
	int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
	int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
	return max(vl, vr);
}

int n;
int BIT[200010];

void add2(int k, int x) {
	while (k <= n) {
		BIT[k] = (BIT[k] + x) % mod;
		k += k & -k;
	}
}

int sum(int k) {
	int res = 0;
	while (k > 0) {
		res = (res + BIT[k]) % mod;
		k -= k & -k;
	}
	return res;
}

P a[200010];
int d[200010];
int d2[200010];
int ans = 1;

signed main() {
	cin >> n;
	init(n);
	for (int i = 1; i <= n; i++)cin >> a[i].first >> a[i].second;
	sort(a + 1, a + n + 1);
	for (int i = n; i >= 1; i--) {
		int x = 0;
		if (a[n].first < a[i].first + a[i].second)x = n;
		else x = lower_bound(a, a + n, P(a[i].first + a[i].second, 0)) - a - 1;
		d[i] = query(i - 1, x);
		add(i, d[i]);
	}
	d2[1] = 1;
	add2(d[1], 1);
	for (int i = 2; i <= n; i++) {
		int x = 1 + sum(i - 1);
		d2[i] = x;
		add2(d[i], x);
	}
	for (int i = 1; i <= n; i++)ans = (ans + d2[i]) % mod;
	cout << ans << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t N=1e5; cin>>N;
    vector<int64_t> A(N+1,0);
    A.back()=1e8;
    rep(n,0,N+1) cin>>A.at(n);

    if(N==0){
        if(A.front()==1) cout<<1<<endl;
        else cout<<-1<<endl;
        return 0;
    }
    if(A.front()!=0){
        cout<<-1<<endl;
        return 0;
    }
    

    vector<int64_t> minL(N+1,1),maxL(N+1,1);
    rep(n,1,N+1){
        maxL.at(n)=min(INT64_MAX/2,2*(maxL.at(n-1)-A.at(n-1)));
    }

    int64_t sumA=0,ans=0;
    _rep(n,N,0){
        minL.at(n)=A.at(n);
        if(n!=N){
            minL.at(n)+=minL.at(n+1)/2;
            if(minL.at(n+1)%2) minL.at(n)++;
        }

        if(maxL.at(n)<sumA/2+(sumA%2)+A.at(n) || minL.at(n)>sumA+A.at(n) || maxL.at(n)<minL.at(n)){
            cout<<-1<<endl;
            return 0;
        }

        sumA=min(maxL.at(n),sumA+A.at(n));
        ans+=sumA;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 5576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}




int main(){
	int n;
	cin>>n;
	int a[2][n];
	for(int i=0; i<n; i++) cin >> a[0][i];
	for(int i=0; i<n; i++) cin >> a[1][i];
	
	int dp[2][n];
	dp[0][0]=a[0][0];
	for(int i=1; i<n; i++) dp[0][i]=dp[0][i-1]+a[0][i];
	dp[1][0]=dp[0][0]+a[1][0];
	for(int i=1; i<n; i++) dp[1][i]=max( dp[0][i]+a[1][i], dp[1][i-1]+a[1][i] );
	
	cout<<dp[1][n-1]<<endl;
	
	return 0;
}




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

using namespace std;

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

    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    int ans = *max_element(a, a + n) - *min_element(a, a + n);
    cout << ans << endl;

    return 0;
}

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

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

int main() {
    string s, t;
    cin >> s >> t;

    REP(i, 26) {
        auto ss = s.find('a' + i);
        auto tt = t.find('a' + i);
        if (tt != string::npos && ss == string::npos) {
            cout << -1 << endl;
            return 0;
        }
    }

    ll ans = 0;
    ll l = s.size();
    ll curr = 0;
    for (char c : t) {
        auto pos = s.find(c, curr);
        if (pos == string::npos) {
            ans += l - curr;
            pos = s.find(c);
            ans += 1ll + (ll)pos;
            curr = pos + 1;
            curr != l;
        } else {
            ans += 1ll + ((ll)pos - curr);
            curr = pos + 1;
            curr != l;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640