akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
ll MOD = 1000000007LL;
int main(){
  int N;
  cin >> N;
  ll fact[N+1];
  fact[0] = 1LL;
  for(int i=1;i<=N;i++){
    fact[i] = fact[i-1] * i % MOD;
  }

  cout << fact[N] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
struct edge{
    int u,v;
    double cost;
    edge(int a,int b,double c):u(a),v(b),cost(c){}
    edge(){}
    bool operator<(const edge &d)const{
        return cost<d.cost;
    }
};
int uf_par[10000],uf_rank[10000];
void uf_init(int n){
    for(int i=0;i<n;i++){
        uf_par[i]=i;
        uf_rank[i]=0;
    }
}
int uf_find(int x){
    return (uf_par[x]==x)?(x):(uf_par[x]=uf_find(uf_par[x]));
}
void uf_unite(int x,int y){
    x=uf_find(x);
    y=uf_find(y);
    if(x==y)return;

    if(uf_rank[x]<uf_rank[y])uf_par[y]=x;
    else{
        uf_par[x]=y;
        if(uf_rank[x]==uf_rank[y])uf_rank[x]++;
    }
}
bool uf_same(int x,int y){
    return uf_find(x)==uf_find(y);
}
int main(){
    int x[10000],y[10000];
    int n,m;
    vector<edge>es;
    double sum=0.0,res=0.0;
    cin>>n>>m;
    uf_init(n);
    es.resize(m);
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--;b--;
        double dis=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
        es[i]=edge(a,b,-dis);
        sum+=dis;
    }
    sort(es.begin(),es.end());
    for(int i=0;i<m;i++){
        edge e=es[i];
        if(uf_same(e.u,e.v))continue;
        uf_unite(e.u,e.v);
        res+=e.cost;
    };
    cout<<fixed<<sum+res<<endl;

    return 0;
}

Measured memory_bytes: 1796
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] a = GetInts(N + 1);

		int[] tmp = new int[N + 1];
		int left = 0;
		int right = 0;
		for(int i = 0; i < N + 1; i++)
		{
			if(tmp[a[i]] == 0)
			{
				tmp[a[i]] = i + 1;
			}
			else
			{
				left = tmp[a[i]];
				right = i + 1;
				break;
			}
		}

		string[] ans = new string[N + 1];
		long mod = (long)(1e9 + 7);
		var mct = new ModCombTable(N + 1, mod);
		for(int K = 1; K <= N + 1; K++)
		{
			long all = mct.ModComb(N + 1, K);
			long dup = mct.ModComb(N - right + left, K - 1);
			long comb = (all - dup + mod) % mod;
			ans[K - 1] = comb.ToString();
		}

		Console.WriteLine(string.Join("\n", ans));
	}
}


public class ModCombTable
{
	private long[] f = null;
	private long[] fInv = null;
	private long mod;

	public ModCombTable(int N, long m)
	{
		mod = m;

		// calc factorial
		f = new long[N+1];
		f[0] = 1;
		for(int i = 1; i <= N; i++)
			f[i] = (f[i-1] * i) % mod;

		// calc factorial inverse
		fInv = new long[N+1];
		fInv[N] = ModInv(f[N]);
		for(int i = N; i > 0; i--)
			fInv[i-1] = (fInv[i] * i) % mod;
	}

	public long ModComb(long n, long k)
	{
		if(n < 0 || n < k)
			return 0;
		
		return (((f[n] * fInv[k]) % mod) * fInv[n-k]) % mod;
	}

	public long ModInv(long x)
	{
		return ModPow(x, mod - 2);
	}

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


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


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

int main(){
    map<int,int> space;
    int a_size;

    while(cin >> a_size, a_size != 0){
        bool flug = false;
        int result = NULL;
        space.clear();
        for(int i=1; i<=a_size; i++){
            int n;
            cin >> n;
            if(flug == false){
                space[n]++;
                if(space[n] > a_size / 2){
                    result = n;
                    flug = true;
                }
            }
        }
        if(flug == false){
            cout << "NO COLOR" << endl;
        }else{
            cout << result << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 0
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, -1, mod)


def main():
    s=input()
    t=input()
    ans = inf
    for i in range(len(s) -len(t)+1):
        cnt = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                cnt += 1
        ans = min(ans, cnt)
    print(ans)
main()


Measured memory_bytes: 9328
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll d[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll n;
  cin>>n;
  n--;
  cout << d[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string a;
    while (getline(cin,a)&&a!="END OF INPUT"){
        int num=0;
        for(int i=0;i<a.length();++i){
            if(a[i]==' ') {
                cout << num;
                num=0;
            }else num++;
        }
        cout << num << endl;
    }
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m,n;
    while(cin >> m,m){
        vector<Pii> star(m);
        rep(i,m){
            int x,y; cin >> x >> y;
            star[i]={x,y};
        }
        cin >> n;
        set<Pii> s;
        rep(i,n){
            int x,y; cin >> x >> y;
            s.insert({x,y});
        }
        int ansx,ansy,ok=0;
        for (auto p:s){
            int x=p.first-star[0].first,y=p.second-star[0].second;
            rep(i,m){
                if (!s.count({star[i].first+x,star[i].second+y})) break;
                if (i==m-1) ok=1;
            }
            if (ok){ansx=x; ansy=y; break;}
        }
        cout << ansx << ' ' << ansy << endl;
    }
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
 
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
using namespace std;

int n;
ll a[20];

ll ans;


int main() {
	cin >> n;
	for(int i = 0; i < n; i++){
	    cin >> a[i];
	}
	ans = 1;
	for(int i = 0; i < n; i++){
	    ans *= 3;
	}
	ll mem = 1;
	for(int i = 0; i < n; i++){
	    if(a[i]%2 == 0){
	        mem *= 2;
	    }
	    else{
	        mem *= 1;
	    }
	}
	
	cout << ans-mem << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> G[300000];
ll d[300000];
const ll INF = 10000000000000000;
ll N, M;
ll S, T;

ll bfs(ll s) {
  for (ll i = 0; i < 3*N; i++) {d[i] = INF;}
  
  d[s] = 0;
  queue<ll> que;
  que.push(s);
  while (!que.empty()) {
    ll v = que.front(); que.pop();
    if (v == 3*T) {break;}
    
    for (ll i = 0; i < G[v].size(); i++) {
      ll to = G[v][i];
      if (d[to] == INF) {
        d[to] = d[v] + 1;
        que.push(to);
      } else {
        continue;
      }
    }
  }
  if (d[3*T] == INF) {return -1;}
  else {return d[3*T]/3;}
}

int main() {
  cin >> N >> M;
  for (ll i = 0; i < M; i++) {
    ll u, v; cin >> u >> v; u--; v--;
    G[3*u].push_back(3*v+1); G[3*u+1].push_back(3*v+2); G[3*u+2].push_back(3*v);
  }
  cin >> S >> T; S--; T--;
  
  cout << bfs(3*S) << endl;
}


Measured memory_bytes: 18944
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    L,R=MI()
    ans = inf
    for i in range(L,min(R+1,L+2019)):
        for j in range(i+1,min(R+1,L+2019)):
            ans = min(ans, i*j%2019)      
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 66348
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main()
{
  bool flag = true;
  int n;
  cin >> n;

  for(int i = 0; i < n; i++){
    char in;
    cin >> in;

    if(in == 'Y'){
      flag = false;
    }
  }

  if(flag) cout << "Three" << endl;
  else cout << "Four" << endl;

  return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double x[100005],r[100005];
bool c(double mid){
  double w,lx,rx;
  for(int i=0;i<n;i++){
    w = sqrt(r[i]*r[i]-mid*mid);
    if(r[i] < w) return false;
    if(i == 0){
      lx = x[i] - w;
      rx = x[i] + w;
    } else {
      lx = max(lx,x[i]-w);
      rx = min(rx,x[i]+w);
    }
    
  }
  
  return (lx<=rx);
}
int main(){
  double ly=0,ry=1000000;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x[i] >> r[i];
    ry = min(ry,r[i]);
  }
  double mid;
  for(int i=0;i<100;i++){
    mid = (ly+ry)/2;
    if(c(mid)) ly = mid;
    else ry = mid;
  }
  printf("%lf\n",mid);
  return(0);
}



Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int H, W;
    cin >> H >> W;
    VT<string> S(H);
    REP(i, H) cin >> S[i];
    VT<bool> heightValid(H), WidthValid(W);
    REP(i, H) {
        bool existsBlack = false;
        REP(j, W) {
            existsBlack |= S[i][j] == '#';
        }
        heightValid[i] = existsBlack;
    }
    REP(j, W) {
        bool existsBlack = false;
        REP(i, H) {
            existsBlack |= S[i][j] == '#';
        }
        WidthValid[j] = existsBlack;
    }
    REP(i, H) {
        if (heightValid[i]) {
            REP(j, W) {
                if (WidthValid[j]) {
                    putchar(S[i][j]);
                }
            }
            puts("");
        }
    }
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int d = c - (a - b);
    cout << (0 < d ? d : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned  long long
string s,ss;

int ar[1000005];

int main()
{
    ll x=0, r,i,j,mx,m,ans=0,a,b,c=0;
        cin>>a;
        for( i=1;i<=a;i++)
        cin>>ar[i];
            for(i=1;i<=a-1;i++){
                if(ar[i]<ar[i+1]){ar[i+1]--;}
                if(ar[i]>ar[i+1]){break;}
            }
              for(i=1;i<=a-1;i++){
                if(ar[i]>ar[i+1])c++;
            }
            if(c>=1)cout<<"No"<<endl;
            else cout<<"Yes"<<endl;


    return 0;
}



Measured memory_bytes: 640
//https://atcoder.jp/contests/arc081/tasks/arc081_b
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
constexpr ll MOD=1e9+7;
int main() {
    ll N; cin>>N;
    string S1,S2; cin>>S1>>S2;
    enum class Type {
        ROW, COL,
    };
	auto check_rc = [&](ll p) {
		return (S1.at(p) == S2.at(p)?Type::COL:Type::ROW);
	};
    auto add_pos = [](Type t){
        return (t==Type::COL)?1:2;
    };

    ll ans = 0;
    auto prev_rc = check_rc(0);
    ll pos = add_pos(prev_rc);
    if (prev_rc == Type::COL){
        ans = 3;
    } else {
        ans = 3*2;
    }

    while(pos<S1.size()){
        auto rc = check_rc(pos);
        if (prev_rc == Type::COL) {
            ans *= 2; //row,col両方
        } else {
            if (rc == Type::ROW) ans *= 3;
        }
        ans %= MOD;
        pos += add_pos(rc);
        prev_rc = rc;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int N,M,R,Ans=INF;
	cin>>N>>M>>R;
	int path[210][210];
	vector<int> r(R);
	for(int i=0;i<R;i++) cin>>r[i];
	for(int i=0;i<210;i++){
		for(int j=0;j<210;j++){
			path[i][j]=INF;
		}
	}
	for(int i=0;i<210;i++) path[i][i]=0;
	for(int i=0;i<M;i++){
		int a,b,c;
		cin>>a>>b>>c;
		path[a][b]=c;
		path[b][a]=c;
	}

	//ワーシャル・フロイト
	for(int k=1;k<210;k++){
		for(int i=1;i<210;i++){
			for(int j=1;j<210;j++){
				path[i][j]=min(path[i][k]+path[k][j],path[i][j]);
			}
		}
	}
	sort(r.begin(),r.end());
	do{
		int tmp=0;
		for(int i=0;i<r.size()-1;i++){
			tmp+=path[r[i]][r[i+1]];
		}
		Ans=min(Ans,tmp);
	}while(next_permutation(r.begin(),r.end()));
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 384
from heapq import heapify, heappop, heappush
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = []
heapify(A)
for i in range(M):
    B,C = map(int,input().split())
    BC.append((B,C))
BC.sort(key=lambda x:-x[1])
for S in BC:
    B,C = S
    for k in range(B):
        heappush(A,C)
        a = heappop(A)
        if a>=C:break
print(sum(A))

Measured memory_bytes: 25720
#include <iostream>
#include <vector>
#define MOD 1000000007
using namespace std;
int main(void){
    int n, m;
    vector<int> s, t;
    vector< vector<long long> > dp;
    cin >> n >> m;
    s.assign(n, 0);
    t.assign(m, 0);
    dp.assign(n+1, vector<long long>(m+1));
    for(int i=0;i<n;i++){
        cin >> s[i];
        dp[i+1][0] = 1;
    }
    for(int j=0;j<m;j++){
        cin >> t[j];
        dp[0][j+1] = 1;
    }
    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            long long tmp = 0;
            if(s[i-1] == t[j-1]){
                tmp = dp[i-1][j-1];
            }
            dp[i][j] = tmp + dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][m] << endl;
}


Measured memory_bytes: 32768
S = input()

ans1 = 'YYMM'
ans2 = 'MMYY'
ans3 = 'AMBIGUOUS'
ans4 = 'NA'

s1 = int(S[:2])
s2 = int(S[2:])

if 0 < s1 < 13 and 0 < s2 < 13:
  print(ans3) 
elif 0 < s1 < 13:
  print(ans2) 
elif 0 < s2 < 13:
  print(ans1) 
else:
  print(ans4)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	double btc=0.0;
	int jpy = 0;
	int n;
	double x;
	string u;
	int i;
	double ans = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> x >> u;
		if (u == "JPY")
			jpy += x;
		if (u == "BTC")
			btc += x;
	}
	ans = jpy;
	ans += (btc * 380000);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long n, m;
    std::cin >> n >> m;

    std::vector<long long> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    std::vector<long long> max(n);
    for (int i = 0; i < m; i++) {
        long long a, b;
        std::cin >> a >> b;
        a--;
        b--;

        max[a] = std::max(max[a], h[b]);
        max[b] = std::max(max[b], h[a]);
    }

    long long count = 0;
    for (int i = 0; i < n; i++) {
        if (h[i] > max[i]) {
            count++;
        }
    }

    std::cout << count << std::endl;
}


Measured memory_bytes: 4832
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[k] + l[j] > l[i] and l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 68224
import java.util.*;
import java.util.Scanner;
import java.lang.*;

public class Main {

    public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);
            String input = scanner.nextLine();
            String[] inputs = input.split(" ");

            int N = Integer.parseInt(inputs[0]);
            int M = Integer.parseInt(inputs[1]);

            int startPos = 0;
            int endPos = 100000;

            Map<Integer,Integer> LR = new LinkedHashMap();
            for (int i = 0;i < M;i++) {
                String strLR = scanner.nextLine();
                String[] arrayLR = strLR.split(" ");

                 int L = Integer.parseInt(arrayLR[0]);
                 int R = Integer.parseInt(arrayLR[1]);

                if (startPos <= L) {
                    startPos = L;
                }
                
                if (endPos >= R) {
                    endPos = R;
                }
            }
        

            if (endPos >= startPos) {
                System.out.println(endPos - startPos + 1);
            } else {
                System.out.println(0);
            }
            
            scanner.close();
    }
}

Measured memory_bytes: 91072
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

bool used[(int)2e5+10];
ll node[(int)2e5+10];
struct Edge{int to; ll cost;};
vector<Edge> es[(int)2e5+10];

void dfs(int k, ll v){
	node[k] = v;
	for(auto&e:es[k]){
		int to = e.to;
		ll cost = e.cost;
		if(node[to] != INF) continue;
		dfs(to, cost - v);
	}
}

void dfs2(int k, pll& v){
	if(used[k]) return;
	used[k] = true;
	if(k < 1e5) v.fi = min(v.fi, node[k]);
	else v.se = min(v.se, node[k]);
	for(auto& e :es[k]) dfs2(e.to, v);
}

int main(){
	int R, C, N;
	cin>>R>>C>>N;
	vi r(N), c(N), a(N);
	rep(i, 2e5+10) node[i] = INF;
	rep(i, N){
		cin>>r[i]>>c[i]>>a[i];
		r[i]--;	c[i]--;
		c[i]+=1e5;
		es[r[i]].pb({c[i], (ll)a[i]});
		es[c[i]].pb({r[i], (ll)a[i]});
	}
	vi st;
	rep(i, 2e5+10) {
		if(node[i] == INF){
			st.pb(i);
			node[i] = 0LL;
			dfs(i, 0LL);
		}
	}
	bool f = true;
	rep(i, 2e5){
		for(auto&e:es[i]){
			if(node[i]+node[e.to]!=e.cost) f=false;
		}
	}
	rep(i, st.size()){
		pll p = {INF,INF};
		dfs2(i, p);
		if(p.fi + p.se < 0) f = false;
	}
	// rep(i, R) cout<<" "<<i<<" "<<node[i]<<endl;
	// cout<<endl;
	// rep(i, C) cout<<" "<<i<<" "<<node[i+(int)1e5]<<endl;
	cout<<(f?"Yes":"No")<<endl;

}

Measured memory_bytes: 18300
a, b, c = map(int, input().split())
k = int(input())

def check(x, y):
    if (x >y):
        return True
    else:
        return False

for i in range(k+1):
    if check(c, b) and check(b, a):
        print("Yes")
        exit()
    if b >= c:
        c *= 2
    elif a >= b:
        b *= 2
    
print("No")

Measured memory_bytes: 9184
#include <stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c); 
	if (a <= b&&a<=c){
		if (b <= c){
			printf("%d %d %d\n", a, b, c);
		}
		else{
			printf("%d %d %d\n", a, c, b);
		}
	}
	else if (b <= a&&b<=c){
		if (a <= c){
			printf("%d %d %d\n", b, a, c);
		}
		else{
			printf("%d %d %d\n", b, c, a);
		}
	}
	else if (c <= a&&c<=b){
		if (a <= b){
			printf("%d %d %d\n", c, a, b);
		}
		else{
			printf("%d %d %d\n", c, b, a);
		}
	}
	return 0;
}

Measured memory_bytes: 2684
#include <stdio.h>

int main()
{
    int a,b,c,d;

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

    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    if(b>c){
        d = b;
        b = c;
        c = d;
    }
    if(a>b){
        d = a;
        a = b;
        b = d;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll n = in(), m = in();
	vector<ll>food(m, 0);
	REP(i, n) {
		ll k = in();
		REP(j, k) {
			ll foo = in();
			++food[foo - 1];
		}
	}
	ll cnt = 0;
	REP(i, m) {
		if (food[i] == n) {
			++cnt;
		}
	}
	cout << cnt << endl;
}

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

const int N = 1e5+1;
int cnt[2*N];

int main(){
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    long long l=s.length();
    long long ans=1+(l*(l-1))/2;
    long long cnt[26]={0};
    for(int i=0;i<s.length();i++) cnt[s[i]-'a']++;
    for(int i=0;i<26;i++) ans=ans-(cnt[i]*(cnt[i]-1))/2;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 888
#include <iostream>

#define ll long long

using namespace std;

int main() {
	int N, W;
	cin >> N;
	cin >> W;
	int weight[N];
	ll value[N];
	for(int i = 0; i < N; ++i) {
		cin >> weight[i];
		cin >> value[i];
	}
	ll dp[N+1][W+1];
	for (int i = 0; i <= N; ++i)
	{
		dp[i][0] = 0;
	}
	for (int i = 0; i <= W; ++i)
	{
		dp[0][i] = 0;
	}
	for (int i = 1; i <= N; ++i) {
		for (int j = 1; j <= W; ++j) {
			if (j-weight[i-1] >= 0) {
				dp[i][j] = max(dp[i-1][j-weight[i-1]]+value[i-1],dp[i-1][j]);
			} else {
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w,n;
  cin>>h>>w>>n;
  vector<Int> x(n),y(n);
  for(Int i=0;i<n;i++) cin>>x[i]>>y[i];

  vector<set<Int> > G(w+1);
  for(Int i=0;i<n;i++) G[y[i]].emplace(x[i]);
  for(Int i=0;i<=w;i++) G[i].emplace(h+1);

  Int i=1,j=1;
  Int ans=*G[j].upper_bound(i)-1;  
  while(1){
    if(G[j].count(i+1)) break;
    i++;
    chmin(ans,*G[j].upper_bound(i)-1);
    if(j+1<=w&&!G[j+1].count(i)) j++;
    chmin(ans,*G[j].upper_bound(i)-1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 31488
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------



int main(){
  int a=700;
  char s[3];
  cin >> s;
  for(int i=0;i<3;++i){
    if(s[i]=='o'){
      a=a+100;
    }
  }
  cout << a;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S_list = []
S = 0
for i in range(N+1):
    S += P[i]
    S_list.append(S)

B = []
for j in range(N-K+1):
    B.append(S_list[j+K]-S_list[j])
ans = max(B)
print(ans)
    



Measured memory_bytes: 25152
#include <bits/stdc++.h>
using namespace std;
 
const double eps=1e-7;
int H,h,W,w;
inline int val(int i,int j,int a,int b) {return ((i%h)||(j%w)) ? a : b;}
int main() {
	cin>>H>>W>>h>>w;
	if((!(H%h)) && (!(W%w))) return puts("No"),0;
	int v=(1e9-1)/(h*w-1);
	if((long long)v*(H*W-(H/h)*h*(W/w)*w)<=((H/h)*(W/w))) return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=H;i++,cout<<'\n')
		for(int j=1;j<=W;cout<<val(i,j,v,-v*(h*w-1)-1)<<' ',j++);
}

Measured memory_bytes: 2944
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

// Main Code
void solve() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    
    auto left = [n](int idx) -> int {
        if (idx == 0) return n - 1;
        else return idx - 1;
    };
    auto right = [n](int idx) -> int {
        if (idx == n - 1) return 0;
        else return idx + 1;
    };
    
    priority_queue<pair<ll, int>> pq;
    rep(i, n) {
        if (a[i] > b[i]) {
            cout << -1 << "\n";
            return;
        }
        if (a[i] < b[i]) {
            pq.push(pair<int, int>(b[i], i));
        }
    }
    ll cnt = 0;
    while (!pq.empty()) {
        int idx = pq.top().second;
        pq.pop();
        ll x = (b[idx] - a[idx]) / (b[left(idx)] + b[right(idx)]);
        if (x == 0) {
            cout << -1 << "\n";
            return;
        }
        cnt += x;
        b[idx] -= (b[left(idx)] + b[right(idx)]) * x;
        if (b[idx] < a[idx]) {
            cout << -1 << "\n";
            return;
        }
        if (b[idx] > a[idx]) {
            pq.push(pair<ll, int>(b[idx], idx));
        }
    }
    
    cout << cnt << "\n";
    return;
}


Measured memory_bytes: 10564
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b;
    cin >> a >> b;

    cout << (((a*b)%2 == 0) ? "Even" : "Odd") << endl;
    return 0;
}



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

using namespace std;
typedef long long ll;

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

  int h, w;
  cin >> h >> w;

  char grid [h][w];
  char result [2 * h][w];

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> grid[i][j];
    }
  }

  for (int i = 0; i < 2 * h; ++i) {
    for (int j = 0; j < w; ++j) {
      result[i][j] = grid[i / 2][j];
    }
  }

  for (int i = 0; i < 2 * h; ++i) {
    for (int j = 0; j < w; ++j) {
      cout << result[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 3668
from fractions import gcd
from functools import reduce

def gcdd(*numbers):
    return reduce(gcd, numbers)

n, k = map(int,input().split())
a = list(map(int,input().split()))

agcd = gcdd(*a)

if max(a) >= k and k%agcd ==0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 88172
from collections import Counter
h, w = [int(item) for item in input().split()]
cnt = Counter()
for i in range(h):
    cnt.update(input().rstrip())
odds = 0
two_mod4 = 0
for key in cnt.keys():
    if cnt[key] % 2 == 1:
        odds += 1
        if cnt[key] - 1 % 4 == 2:
            two_mod4 += 1
    else:
        if cnt[key] % 4 == 2:
            two_mod4 += 1

if w % 2 == 0 and h % 2 == 0:
    if odds > 0 or two_mod4 > 0:
        print("No")
    else:
        print("Yes")
elif w % 2 == 0:
    if odds > 0 or two_mod4 > w // 2:
        print("No")
    else:
        print("Yes")
elif h % 2 == 0:
    if odds > 0 or two_mod4 > h // 2:
        print("No")
    else:
        print("Yes")
else:
    if odds > 1 or two_mod4 > (h - 1) // 2 + (w - 1) // 2:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N - 1), b(N - 1);
    vector< vector<P> > edges(N);
    rep(i,N-1) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        edges[a[i]].push_back(make_pair(b[i], i));
        edges[b[i]].push_back(make_pair(a[i], i));
    }
    vector<bool> visited(N - 1, false);
    long long ans = 1;
    queue<LLP> que;
    que.push(make_pair(0, K));
    while (!que.empty()) {
        LLP p = que.front(); que.pop();
        ans = ans * p.second % MOD;
        if (ans <= 0) {
            cout << 0 << endl;
            return 0;
        }

        long long k_now = (p.second == K ? K - 1 : K - 2);
        
        for (int i = 0; i < edges[p.first].size(); i++) {
            if (!visited[edges[p.first][i].second]) {
                visited[edges[p.first][i].second] = true;
                que.push(make_pair(edges[p.first][i].first, k_now--));
            }
        }
    }

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

Measured memory_bytes: 8948
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

bool guu(string S){
 int N = sz(S);
  if(N%2 ==1) return false;
  rep(i,N/2){
	if(S[i]!=S[i+(N/2)]) return false;
  }
  return true;
}


int main() {
 int s;
  in(s);
  if(s==25)out("Christmas");
  else if(s==24) out("Christmas Eve");
  else if(s==23) out("Christmas Eve Eve");
  else if(s ==22) out("Christmas Eve Eve Eve");
 }


Measured memory_bytes: 256
import sys
from itertools import accumulate
input = sys.stdin.readline
N = int(input())
T = [0] + list(map(int,input().split()))
V = list(map(int,input().split()))
T = [2*t for t in T]
V = [2*v for v in V]

cT = list(accumulate(T))

fs = [lambda x : x, lambda x : -x + cT[-1]]
for i in range(N):
    fs.append(lambda x, i = i: max(V[i], -x+cT[i] + V[i], x-cT[i+1] + V[i]))

last = cT[-1]

vs = []
for x in range(last+1):
    temp = 10**10
    for f in fs:
        temp = min(temp,f(x))
    vs.append(temp)

ans = (sum(vs) + sum(vs[1:-1]))/8
print(ans)





Measured memory_bytes: 76036
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

const int nax = 3e5+5;
const int inf = 1e18+7;
const int mod = 1e9+7;

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * DO SOMETHING RATHER THAN DOING NOTHING
 * */
int dp[101][nax];

signed main(){
    fast;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cin>>b[i];
    }

    memset(dp, 0, sizeof(dp));

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            dp[i][j] = dp[i-1][j];
            if(a[i]<=j){
                dp[i][j] = max(dp[i][j], dp[i-1][j-a[i]]+b[i]);
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=m;i++){
        ans = max(ans, dp[n][i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 247408
import java.util.Scanner;

public class Main {

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

		int orientation = 1;
		StringBuilder forward = new StringBuilder();
		StringBuilder backward = new StringBuilder();
		for ( int i = 0 ; i < Q ; i++ ) {
			int T = sc.nextInt();
			if ( T == 1 ) {
				orientation = -orientation;
			} else {
				int F = sc.nextInt();
				String C = sc.next();
				F = 2 * F - 3;
				if ( orientation * F > 0 ) {
					forward.append(C);
				} else {
					backward.append(C);
				}
			}
		}
		String first = null;
		String second = null;
		if ( orientation > 0 ) {
			first = backward.toString();
			second = forward.toString();
		} else {
			first = forward.toString();
			second = backward.toString();
		}

		StringBuilder rev = new StringBuilder();
		for ( int i = first.length() - 1 ; i >= 0 ; i-- ) {
			rev.append(first.charAt(i));
		}

		String SS = S;
		if ( orientation < 0 ) {
			StringBuilder revS = new StringBuilder();
			for ( int i = S.length() - 1; i >= 0 ; i-- ) {
				revS.append(S.charAt(i));
			}
			SS = revS.toString();
		}

		System.out.println(rev.toString() + SS + second);
	}
}


Measured memory_bytes: 126660
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));
    int ans = 1<<30;
    REP(i,n-k+1) {
        ans = ans > v[i+k-1] - v[i] ? v[i+k-1] - v[i] : ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){

int W, H, a;
vector<long long> P, Q;
cin>>W>>H;
for(int i = 0; i < W; ++i){
cin>>a;
P.push_back(a);
}
for(int i = 0; i < H; ++i){
cin>>a;
Q.push_back(a);
}

sort(P.begin(), P.end());
sort(Q.begin(), Q.end());

long long ptr1, ptr2;
ptr1 = 0;
ptr2 = 0;
int c1 = W + 1;
int c2 = H + 1;
long long ans = 0;
while(ptr1 < W && ptr2 < H){
    if(P[ptr1] <= Q[ptr2]){
        ans += (long long)(c2 * P[ptr1++]);
        c1--;
    }
    else{
        ans += (long long)(c1 * Q[ptr2++]);
        c2--;
    }
}
while(ptr1 < W){
        ans += (long long)(c2 * P[ptr1++]);
        c1--;
}
while(ptr2 < H){
        ans += (long long)(c1 * Q[ptr2++]);
        c2--;
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 2676
# -*- coding: utf-8 -*-

import itertools


def mostProperComb(childs, x):
    tmp_sum = sum([c[1] for c in childs])
    if tmp_sum > x:
        print("IMPOSSIBLE")
        exit()

    total = tmp_sum + sum([c[0] for c in childs])

    sset = set([tmp_sum])
    for child in childs:
        rest = child[0] - child[1]
        tmp_set = set(sset)
        for s in sset:
            if s + rest <= x:
                tmp_set.add(s+rest)
        sset = tmp_set

    return (tuple(sorted([x, total-max(sset)], reverse=True)))


n = int(input())

p_list = [0] + list(map(int, input().split()))
x_list = list(map(int, input().split()))
c_list = [[] for i in range(n)]

if n == 1:
    print("POSSIBLE")
    exit()

for i in range(n):
    index = n-1-i

    if len(c_list[index]) == 0:
        c_list[index] = (x_list[index], 0)
        c_list[p_list[index]-1].append(index)
    else:
        childs = [c_list[child_index] for child_index in c_list[index]]
        c_list[index] = mostProperComb(childs, x_list[index])
        if not p_list[index] == 0:
            c_list[p_list[index]-1].append(index)

print("POSSIBLE")


Measured memory_bytes: 39920
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
	return b != 0 ? gcd(b, a%b) : a;
}
lli gcd(lli a, lli b) {
	return b != 0 ? gcd(b, a%b) : a;
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
lli lcm(lli a, lli b) {
	return a * b / gcd(a, b);
}

#define N_MAX 200000
#define MOD 1000000007

lli modpow(lli base, lli p)
{
	if (0 == p) {
		return 1;
	}
	if (0 == p % 2) {
		lli val = modpow(base, p / 2);
		return (val*val) % MOD;
	}
	else {
		return (modpow(base, p - 1)*base) % MOD;
	}
}

void solv()
{
	int N; scanf("%d", &N);
	int C[N_MAX];
	for (int i = 0; i < N; i++) {
		scanf("%d", C + i);
	}

	sort(C, C + N);

	lli sum = 0;
	lli num = modpow(2, N);
	if (1 == N) {
		sum = (lli)C[0];
	}
	else {
		lli num2 = modpow(2, N - 1), num4 = modpow(2, N - 2);
		for (int i = N - 1; i >= 0; i--) {
			lli val = (num2 + num4 * (lli)(N - i - 1)) % MOD;
			sum += (lli)C[i] * val;
			sum = sum % MOD;
		}
	}

	printf("%lld", (sum*num) % MOD);

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int ar[101];
  cin >> n;
  for(int i=0;i<=n-1;i++)
  {
    scanf("%d",&ar[i]);
  }
  int minn = INT_MAX;

  for(int i=1;i<=100;i++)
  {
    int sum=0;
    for(int j=0;j<=n-1;j++)
    {
      sum=sum+(abs(i-ar[j])*abs(i-ar[j]));
    }
    if(sum<minn)
    {
      minn = sum;
    }
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    char c;
    cin>>c;
    if(c-'a'<26 && c-'a'>=0){cout<<'a'<<endl;}
    else{cout<<'A'<<endl;}
}


Measured memory_bytes: 3620