akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

int n,x,a;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n >> x;
	int l = 0;
	ll ans = 0;
	rep(i,n){
		cin >> a;
		int d = l - x + a;
		ans += max(d,0);
		a -= max(d,0);
		l = a;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 500000
#define data 2000000000

int LEFT[MAX/2+2],RIGHT[MAX/2+2];
int count;

void merge(int A[],int n,int left,int mid,int right){
	int n1=mid-left;
	int n2=right-mid;
	
	for(int i=0; i<n1; i++){
		LEFT[i]=A[left+i];
	}
	for(int i=0; i<n2; i++){
		RIGHT[i]=A[mid+i];
	}
	
	LEFT[n1]=RIGHT[n2]=data;
	int i=0,j=0;//新たにカウント用変数を宣言する
	int k;
	for(k=left; k<right; k++){
		count++;
		if(LEFT[i]<=RIGHT[j]){
			A[k]=LEFT[i++];
		}
		
		else{
			A[k]=RIGHT[j++];
		}
	}
}

void mergesort(int A[],int n,int left,int right){
	if(left+1<right){
		int mid=((left+right)/2);
		mergesort(A,n,left,mid);
		mergesort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}

int main(){
	int A[MAX],n,i;
	count=0;
	
	cin>>n;
	for(i=0; i<n; i++)
	cin>>A[i];
	
	mergesort(A,n,0,n);
	
	for(i=0; i<n; i++){
		if(i) cout<<" ";//iが非ゼロであれば空白を、そうでなければA[i]をcoutする。
		cout<<A[i];
	}
	cout<<endl;
	
	cout<<count<<endl;
	
	return 0;
	}


Measured memory_bytes: 6956
#include <bits/stdc++.h>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INF = 1e18;
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int main(){
  int n;
  cin>>n;
  vector<vector<pair<int,int>>> x(n);
  rep(i,n){
    int a;
    cin>>a;
    rep(j,a){
      int x_,y_;
      cin>>x_>>y_;
      x[i].push_back(make_pair(x_,y_));
      x[i][j].first--;
    }
  }
  int ans =0;
  rep(bit,(1<<n)){
    int count =0;
    bool f = false;
    rep(i,n){
      if(bit &(1<<i)){
        rep(j,x[i].size()){
          if(x[i][j].second==0&&bit&(1<<x[i][j].first))f=true;
          if(x[i][j].second==1&&!(bit&(1<<x[i][j].first)))f=true;
        }
      }
    } 
  if(!f){
    rep(t,n){
      if(bit&(1<<t))count++;
    }
  }
  ans=max(ans,count);
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<int, int>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const int INF = (int)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

int main() {
    kekek();
    vector<vector<long long>> dp(1000, vector<long long>(10));
    for (int i = 0; i <= 9; i++) {
        dp[1][i] = 1;
    }
    for (int i = 2; i < 1000; ++i) {
        for (int j = 0; j <= 9; j++) {
            if (j == 0) {
                dp[i][j] = dp[i - 1][1] + dp[i - 1][0];

            }
            else if (j == 9) {
                dp[i][j] = dp[i - 1][8] + dp[i - 1][9];
            }
            else {
                dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] + dp[i - 1][j + 1];
            }
        }
    }

    int n;
    cin >> n;
    int ncpy = n;
    int tn = 0;
    string ans = "";
    int len = -1;
    int dig = -1;
    bool f = false;
    for (int i = 1; ; i++) {
        if (f)
            break;
        for (int j = 1; j <= 9; j++) {
            if (n <= dp[i][j]) {
                len = i;
                dig = j;
                ans += ('0' + j);
                f = true;
                break;
            }
            else {
                n -= dp[i][j];
            }
        }
    }
    // cout << len << ' ' << dig << endl;
    len--;
    ncpy = n;
    while (ncpy != 0 && len != 0) {
        // cout << "ncpy: " << ncpy << " len: " << len <<  endl;
        for (int i = max(0, dig - 1); i <= min(9, dig + 1); i++) {
            // cout << "check i = " << i << endl;
            if (ncpy <= dp[len][i]) {
                // cout << "good" << endl;
                len--;
                ans += ('0' + i);
                dig = i;
                break;
            }
            else {
                // cout << "next" << endl;
                ncpy -= dp[len][i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
int cd(int i,int j){
     int a=i,b=j;
     if(a>b)swap(a,b);
     while(a!=0){
          b%=a;
          swap(a,b);

     }
     return b;
}
     signed main(){
     
      int  k;
      cin>>k;
     int t[k+1]={};
     for(int i=1;i<=k;i++)for(int j=1;j<=k;j++)t[cd(i,j)]++;
     int ans=0;
     for(int i=0;i<=k;i++)for(int j=1;j<=k;j++)ans+=t[i]*cd(i,j);
     cout<<ans<<endl;
      }

        


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,s,e) for(ll i=s;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1000000007;
const ll INF = 100000000000009;
ll i;

int main(){
    ll H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W-H*w-W*h+h*w<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ara[1000000];
char ara1[1000000];
int main()
{
    int i,j,k,l,n,ln,t,df,v=0,sum,fl=0;
    long long gun=1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&ara[i]);
        if(ara[i]%4==0)
        {
            fl++;
        }
        else if(ara[i]%2==0)
        {
            v++;
        }
    }
    v/=2;
    t=n/2;
    fl+=v;
    if(fl<t)
    {
        printf("No\n");
    }
    else
    {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 640
N,M = map(int,input().split())
s = []
for i in range(M):
    s.append(list(map(int,input().split())))
    s[i].pop(0)
p = list(map(int,input().split()))

res = 0

for bit in range(1<<N):
    ok = True
    for i in range(M):
        con = 0
        for v in s[i]:
            if bit & (1<<(v-1)): con += 1
        if con % 2 != p[i]: ok = False
    if ok: res += 1
print(res)

Measured memory_bytes: 9208
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<e?a=c:b=c;return d[a]<e?b:a};
const MOD = 1000000007;

function Main(input){
    let temp = input.trim();
    let temp2 = mapint(temp);
    let x = temp2[0];
    let a = temp2[1];

    if(x<a) console.log(0);
    else console.log(10);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int ma = 0,cnt = 0;
	string s;
	cin >> s;
	for(int i = 0;i < s.length();i++){
		if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') cnt++;
		else cnt = 0;
		ma = max(ma,cnt);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll a, v, b, w, t;
	cin>>a>>v>>b>>w>>t;
	if(a<b){
		if(b-a<=(v-w)*t) cout<<"YES\n";
		else cout<<"NO\n";
	}
	else{
		if(abs(b-a)<=(v-w)*t) cout<<"YES\n";
		else cout<<"NO\n";
	}


    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	int K;
	cin >> S >> K;
	REP(i, SZ(S)) {
		if (K == 0)break;
		if (S[i] == 'a')continue;
		if (S[i] + K > 'z') {
			K -= 'z' - S[i] + 1;
			S[i] = 'a';
		}
	}
	K %= 26;
	REP(i, K) {
		S[SZ(S) - 1]++;
		if (S[SZ(S) - 1] == 'z' + 1)S[SZ(S) - 1] = 'a';
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 200100

typedef struct {
	int num;
	int cnt;
} count;

int counter(int* base, int n, count* dst);
int max(int a, int b) {
	return a < b ? b : a;
}

int main() {
	int rw, i, a[SIZE], k, n, k_all;
	count c[SIZE];
	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)scanf("%d", &a[i]);
	k_all = counter(a, n, c);
	/* 確認用
	for (i = 0; i < k_all; i++) printf("%dが%d回, ", c[i].num, c[i].cnt);
	printf("\n");
	*/
	rw = 0;
	for (i = 1; i <= max(0, k_all - k); i++) rw += c[k_all - i].cnt;
	printf("%d", rw);
	return 0;
}

int counter(int* base, int n, count* dst) {
	int i, temp, cnt, cur;
	int num_sort(const void* a, const void* b) {
		return ((count*)a)->num - ((count*)b)->num;
	}
	int cnt_sort(const void* a, const void* b) {
		return ((count*)b)->cnt - ((count*)a)->cnt;
	}

	for (i = 0; i < n; i++) dst[i].num = base[i];
	qsort(dst, n, sizeof(count), num_sort);

	temp = dst[0].num - 1;
	cur = -1;
	for (i = 0; i < n; i++) {
		if (temp != dst[i].num) {
			temp = dst[i].num;
			cur++;
			dst[cur].num = temp;
			dst[cur].cnt = 1;
		}
		else {
			dst[cur].cnt++;
		}
	}

	cur++;
	qsort(dst, cur, sizeof(count), cnt_sort);

	return cur;
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n;
	n=n*2;
	int sum=0;
	int a[1001]={};
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
		if (i%2==1) sum+=a[i];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
#include<deque>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int sum = 0;
	rep(i, 0, b) {
		sum += a;
		if (sum%b == c) {
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 256
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.*;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N;
        String S;

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            S = in.next();

            int ans = 0;
            for (int i = 0; i <= 9; i++) {
                for (int j = 0; j <= 9; j++) {
                    for (int k = 0; k <= 9; k++) {
                        int cnt = 0;
                        for (int l = 0; l < N; l++) {
                            int c = S.charAt(l) - '0';
                            if (cnt == 0 && i == c) {
                                cnt++;
                            } else if (cnt == 1 && j == c) {
                                cnt++;
                            } else if (cnt == 2 && k == c) {
                                cnt++;
                            }

                            if (cnt == 3) {
                                ans++;
                                break;
                            }
                        }
                    }
                }
            }
            out.println(ans);
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

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

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

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

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int a[100005];
int main() {
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if ((c + b - 1) / b > (a + d - 1) / d)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3768
from heapq import heappush, heappop


def dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:
    # graph[v_from] = [(cost, v_to), ...]
    dist = [INF] * n
    prev_node = [-1] * n

    dist[v_s] = 0
    heap = [(0, v_s)]  # heap = [(dist[v], v), ...]
    while heap:
        dist2v, v_from = heappop(heap)
        if dist[v_from] < dist2v:
            continue
        for cost, v_to in graph[v_from]:
            dist_cand = dist2v + cost
            if dist_cand < dist[v_to]:
                dist[v_to] = dist_cand
                prev_node[v_to] = v_from
                heappush(heap, (dist[v_to], v_to))
    return dist, prev_node


n, m = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append((1, b))
    graph[b].append((1, a))

dist, prev_node = dijkstra(graph, n, 0)
# print(dist)
# print(prev_node)

print('Yes')
for i in range(1, n):
    print(prev_node[i] + 1)


Measured memory_bytes: 64140
N,K = map(int, input().split())
A = list(map(int, input().split()))
k = K.bit_length()
dv = [[0]*N for _ in range(k)]
dv[0] = [a-1 for a in A]
for turn in range(1,k):
    for town in range(N):
        dv[turn][town] = dv[turn-1][dv[turn-1][town]]

a = 0
for i in range(k):
    if (K>>i)&1:
        a = dv[i][a]
        
print(a+1)

Measured memory_bytes: 175860
# -*- coding: utf-8 -*-
from functools import reduce
from operator import mul

MOD = 1000000007

def power_func(a, b, mod):
    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

def nCr(n, r, mod):

    min_r = min(r, n-r)

    if min_r == 1: return n
    if min_r == 0: return 1

    bunsi = reduce(lambda x, y: (x * y) % mod, range(n, n-min_r, -1))
    bunbo = reduce(lambda x, y: (x * y) % mod, range(1, min_r + 1))

    return bunsi * power_func(bunbo, mod - 2, mod) % mod


n, a, b = [int(i) for i in input().split()]

print(((power_func(2, n, MOD) -1) - nCr(n, a, MOD)- nCr(n, b, MOD)) % MOD)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k, ans = 1;
  cin >> n >> k;

  rep(i, n) ans = min(k + ans, ans * 2);

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll dp[205][205];
int main(){FIN
    ll n,m,r;cin>>n>>m>>r;
    ll dp[n][n];
    REP(i,n) REP(j,n) dp[i][j] = inf;
    REP(i,n) dp[i][i] = 0;

    
    vll obj(r); REP(i,r) cin>>obj[i];
    REP(i,r) obj[i]--;
    REP(i,m){
        ll a,b,c;cin>>a>>b>>c;
        a--; b--;
        dp[a][b] = c;
        dp[b][a] = c;
    }
    REP(k,n){
        REP(i,n){
            REP(j,n) dp[i][j] = min(dp[i][j], dp[i][k]+dp[k][j]);
        }
    }
    VSORT(obj);
    ll ans=inf;

    do {
        ll dis=0;
        REP(i,r-1) dis += dp[obj[i+1]][obj[i]];
        // cout<<dis<<endl;
        ans = min(dis, ans);  
    } while(next_permutation(ALL(obj)));

    cout<<ans<<endl;
    // cout<<dp[3][100]<<endl;
    return 0;
}


Measured memory_bytes: 3924
import java.util.Scanner;
class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int input = scan.nextInt();
    	int[] num = new int[input];
    	int v;
    	int j;
    	
    	for(int i = 0; i < input; i++){
    		num[i] = scan.nextInt();
    	}
    	
    	for(int i = 1; i <= input - 1; i++){
    		for(int n = 0; n < input; n++){
    			if(n != input - 1){
        			System.out.print(num[n] + " ");
        		}else{
        			System.out.print(num[n]);
        		}
        	}
    		System.out.println("");
    		v = num[i];
    		j = i - 1;
    		while(j >= 0 && num[j] > v){
    			num[j + 1] = num[j];
    			j--;
    			num[j + 1] = v;
    		}
    	}
    	
    	for(int n = 0; n < input; n++){
    		if(n != input - 1){
    			System.out.print(num[n] + " ");
    		}else{
    			System.out.println(num[n]);
    		}
    	}
     }
     
}

Measured memory_bytes: 30668
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    n=len(s)
    if s==s[::-1] and s[:n//2]==s[n//2+1:]:
        print("Yes")
    else:
        print("No")

main()

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int h, w;
string a[10];

bool solve() {
    bool used[h][w];
    memset(used, false, sizeof(used));
    int i = 0, j = 0;
    while (true) {
        used[i][j] = true;
        if (i == h-1 && j == w-1) break;

        if (i+1 < h && a[i+1][j] == '#') i++;
        else if (j+1 < w && a[i][j+1] == '#') j++;
        else return false;
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (!used[i][j] && a[i][j] == '#')
                return false;
        }
    }
    return true;
}

void input() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve() ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x, y, z, w, h, n;std::cin >> w >> h >> n;
  ll u = h, s = 0, l = 0, r = w;
  re(i, n){
    std::cin >> x >> y >> z;
    if(z==1) l = max(l, x);
    if(z==2) r = min(r, x);
    if(z==3) s = max(s, y);
    if(z==4) u = min(u, y);
  }
  if(r<l||u<s) std::cout << 0 << '\n';
  else std::cout << (u-s)*(r-l) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int K;
    int A, B;
    cin >> K;
    cin >> A >> B;
    for (int i=0; i<1000; i++){
        if (A <= K*i and K*i <= B){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define int long long
#define DEBUG(x) cerr << #x << " = " << x << endl
struct BIT {
  int N;
  vector<int> data;
  void init(int n) {
    N = n;
    data = vector<int>(n + 1, 0);
  }
  void add(int a, int w) {
    ++a;
    for(int x = a; x <= N; x += x & -x) {
      data[x] += w;
    }
  }
  int sum(int a) {
    int ret = 0;
    for(int x = a; x > 0; x -= x & -x) {
      ret += data[x];
    }
    return ret;
  }
};
BIT bits[26];
signed main() {
  std::ios::sync_with_stdio(false);
  int N; cin >> N;
  REP(i, 26) bits[i].init(N);
  string S; cin >> S;
  REP(i, N) {
    bits[S[i] - 'a'].add(i, 1);
  }
  int Q; cin >> Q;
  while (Q--) {
    int t; cin >> t;
    if (t == 1) {
      int i; char c; cin >> i >> c;
      i--;
      bits[S[i] - 'a'].add(i, -1);
      S[i] = c;
      bits[S[i] - 'a'].add(i, 1);
    } else {
      int l, r; cin >> l >> r;
      int uniq = 0;
      REP(i, 26) {
        int sum = bits[i].sum(r) - bits[i].sum(l - 1);
        if (sum > 0) uniq++;
      }
      cout << uniq << endl;
    }
  }
}


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

int main(){
    long long n;
    cin>>n;
    vector<long long> v(n);
    for(long long i = 0; i < n; i++) cin>>v[i];
    map<long long, map<long long, long long>> m;

    for(long long i = 0; i < n; i++){
        m[i+1+v[i]][i+1]++;
    }

    long long count = 0;
    
    for(long long i = 0; i < n; i++){
        long long val = i+1-v[i];
        if(m.find(val) != m.end()){
            if(m[val].find(i+1) != m[val].end()){
                count += m[val].size()-1;
            }
            else{
                count += m[val].size();
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 35996
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    int a = 0;
    cin >> n;

    for (int i = 0; i < n; i++){
        string s;
        cin >> s;
        if (s == "Y"){
            a++;
          	break;
        }
        
    }
    if (a == 0){
        cout << "Three";
    }else{
        cout << "Four";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define int long long
const int inf = 0x3f3f3f3f;
const int maxn = 201110;
const int M = 1e9+7;
int n,m,k,ok;

signed main()
{
#ifdef ONLINE_JUDGE
#else
    //freopen("data.in", "r", stdin);
#endif
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;

int main(){
    int n,m;
    while(scanf(" %d %d", &n, &m),n){
        vector<int> s(n);
        rep(i,n) scanf(" %d", &s[i]);

        auto f = [&](int x){
            if(1+x <= s[0]) return INF;

            int L = 1;
            int ct = 0;
            int idx = 0;
            while(L+x <= s[n-1]){

                int nL = L+1;
                for(int i:{idx-1,idx})if(i>=0 && s[i]<L+x){
                    int add = max(1, x-abs(L-s[i]));
                    nL = max(nL, L+add);
                }

                ++ct;
                L = nL;
                while(idx < n-1 && s[idx] <= L) ++idx;
            }
            return ct+1;
        };

        int ok = 0, ng = 2222222;
        while(ng-ok>1){
            int x = (ok+ng)/2;
            if(f(x)>=m) ok = x;
            else ng = x;
        }

        if(ok==0 || f(ok)==INF) ok = -1;
        printf("%d\n", ok);
    }
    return 0;
}



Measured memory_bytes: 3556
import java.io.*;
import java.util.*;
class Lake
{
	private int x,area;
	Lake(int x , int area)
	{
		this.x = x;
		this.area = area;
	}
	public int getArea()
	{
		return this.area;
	}
	public int getX()
	{
		return this.x;
	}
}

public class Main
{
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] graph = br.readLine().toCharArray();
		Deque<Integer> down= new ArrayDeque<>();
		Deque<Lake> lakes  = new ArrayDeque<>();
		int sum = 0 ;
		for( int i= 0 ; i< graph.length ; i++)
		{
			if(graph[i] == '\\')
			{
				down.offer(i);		
			}
			else if(!down.isEmpty() && graph[i] =='/')
			{
				int a = i -  down.peekLast();
				sum += a ;
				while(!lakes.isEmpty() && (down.peekLast() < lakes.peekLast().getX()))
				{
					a += lakes.pollLast().getArea();
				}
				lakes.offer(new Lake(down.pollLast() , a ));
			}
		}
		sb.append(sum).append('\n')
		  .append(lakes.size()).append(' ');
			for(Lake l : lakes)
			{
				sb.append(l.getArea()).append(' '); 
			}
			sb.deleteCharAt(sb.length()-1).append('\n');
		System.out.print(sb);
	}
}

Measured memory_bytes: 25612
#include<stdio.h>
int main(){
	int i,j,H,W;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0)break;
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0||j==0||i==H-1||j==W-1)printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
using System;

namespace ABC134
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int D = int.Parse(input[1]);

            int count = 0;
            while (N > 0)
            {
                N -= 2 * D + 1;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(void){
    int age;
    scanf("%d",&age);
    switch(age){
        case 7:
            printf("YES");
            break;
        case 5:
            printf("YES");
            break;
        case 3:
            printf("YES");
            break;
        default:
            printf("NO");
    }
    return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if ((a + b) == c || (b + c) == a || (a + c) == b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main()
{
int m, init, a,b,sum=0, year, n, *result, *type, *fee, i, j, k, l, o, *out,p;
double *rate;
	cin >> m;
	out = new int[m];
	for(i=0;i<m;i++){
		cin >> init;
		cin >> year;
	cin >> n;
	type = new int[n];
	rate = new double[n];
	fee = new int[n];
	result = new int[n];
	for(j=0;j < n;j++){
		cin >> type[j] >> rate[j] >> fee[j];
		b=0;
		a = init;
		sum=0;
		if(type[j]==0){
			for(k=0; k <year ;k++){
				b = a * rate[j];
				sum = sum + b;
				a = a -fee[j];
			
			}
		
			result[j] = a +sum;
		
		}else{
			for(l=0;l<year;l++){
				b = a * rate[j];
				a = a + b - fee[j];
			}
			result[j] = a;
		}
	}
	
	for(o =0;o<n;o++){
		if(result[o] > out[i]){
		out[i] = result[o];
		}

	}


	}


	for(p=0;p < m;p++){
		cout << out[p]<<endl;
	}

	return 0;
}

Measured memory_bytes: 1312
#include<stdio.h>
#include <string.h>
#include <math.h>
int main(){
    int n, m, i;
    scanf("%d %d",&n,&m);
    int a[m];
    for(i=0;i<m;i++){
        scanf("%d",&a[i]);
        n -= a[i];
    }
    if(n<0){
        printf("-1");
    }else{
        printf("%d",n);
    }
    return 0;
}

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

int main()
{
  int n;
  int k;
  cin>>n;
  cin>>k;
  vector<int> nums(n);
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    nums[i]=x;
  }
    vector<int> dp(n,0);
    dp[0]=0;
    dp[1]=abs(nums[0]-nums[1]);
    for(int i=2;i<n;i++)
    {  
      dp[i]=INT_MAX;
  		for(int j=1;j<=k && (i-j)>=0 && j<n;j++)
          dp[i]=min(dp[i],dp[i-j]+abs(nums[i]-nums[i-j]));
    }
    cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 1024
def main():
    n=int(input())
    a=list(map(int,input().split()))
    d={0:[-1]}
    for j,i in enumerate(a):
        if i in d.keys():d[i].append(j)
        else:d[i]=[j]
    d=sorted([[i,min(j),len(j)] for i,j in d.items()],reverse=True)
    ans=[0]*n
    l=0
    m=n
    for k in range(len(d)-1):
        x,y,z=d[k]
        l+=z
        m=min(m,y)
        ans[m]+=(x-d[k+1][0])*l
    for i in ans:
        print(i)
main()

Measured memory_bytes: 37212
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	a := make([]int, N)
	b := make([]int, N)

	for i := 0; i < N; i++ {
		a[i], b[i] = getInt(), getInt()
	}

	cnt := 0
	for i := N - 1; i >= 0; i-- {
		d := b[i] - (a[i]+cnt)%b[i]
		d %= b[i]
		cnt += d

		a[i] += d
	}
	out(cnt)
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n;
ll a[100100];
bool dp[101][100100];

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	rep(i, n) {
		rep(j, 10010) {
			if (dp[i][j]) {
				dp[i + 1][j + a[i]] = 1;
				dp[i + 1][j] = dp[i][j];
			}
		}
	}
	ll MAX = 0;
	rep(i, 10010) {
		if (dp[n][i] && i % 10 != 0)MAX = max(MAX, (ll)i);
	}
	cout << MAX << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i].first.first >> l[i].first.second;
        l[i].second = i+1;
        l[i].first.second *= -1;
    }
    sort(l.begin(), l.end());
    for (int i = 0; i < n; i++) {
        cout << l[i].second << endl;
    } 
}

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

int main(){
    std::string T;
    std::cin >> T;
    for(int i=0; i<T.size(); i++){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }
   // if(T[T.size() - 1] == '?'){
   //     T[T.size() - 1] = 'D';
   // }
    
    std::cout << T << std::endl;
    
    return 0;
}



Measured memory_bytes: 3752
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,n;
    cin>>a>>b>>n;
    n=min(n,b-1);
    cout<<(a*n)/b - a*(n/b)<<'\n';
    return 0;   
}

Measured memory_bytes: 3652
a,b,c,d,e,f=map(int,input().split())
dp=[0]*(3000+1)
for i in range(f//c+1):
    for j in range(f//d+1):
        if c*i+d*j<=3000:
            dp[c*i+d*j]=c*i+d*j
for i in range(1,3001):
    dp[i]=max(dp[i],dp[i-1])
ans_den=min(100*a,100*b)
ans_num=0
ans=0
for i in range(f//a+1):
    for j in range(f//b+1):
        #so we have put 100*a*i +100*b*j amount of water 
        w=100*i*a+100*j*b
        if w>f or w==0:
            continue
        rem=f-w
        sugar_max=min(e*(i*a+j*b),rem)
        val=dp[sugar_max]
        if val/(w+val)>ans:
            ans=val/(w+val)
            ans_num=val
            ans_den=w+val
print(ans_den,ans_num)



Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll n;
vd x(101010),y(101010);
vc d(101010);
map<char,int> mp;

double calc(double t){
	double xmin = inf, ymin = inf;
	double xmax = -inf, ymax = -inf;
	double X,Y;
	rep(i,n){
		X = x[i] + dx[mp[d[i]]] * t;
		Y = y[i] + dy[mp[d[i]]] * t;
		chmin(xmin,X);
		chmin(ymin,Y);
		chmax(xmax,X);
		chmax(ymax,Y);
	}
	return (ymax-ymin) * (xmax-xmin);
}

int main(){
	mp['R'] = 0, mp['U'] = 1, mp['L'] = 2, mp['D'] = 3;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> y[i] >> d[i];
	}
	double left = 0, right = 1e8;
	double L;
	double R;
	rep(i,150){
		double m1 = (2.0*left + right) / 3.0;
		double m2 = (left + 2.0*right) / 3.0;
		double M1 = calc(m1);
		double M2 = calc(m2);
		if(M1 > M2){
			left = m1;
			L = M1;
		}else{
			right = m2;
			R = M2;
		}
	}
	printf("%.12f\n",R);
}

Measured memory_bytes: 1920
N = int(input())
xy = []
for i in range(N):
    t = []
    A = int(input())
    for l in range(A):
        t.append(list(map(int,input().split())))
    xy.append(t)
ans = 0
for i in range(2**N):
    p = []
    for l in range(N):
        if ((i >> l) & 1) == 1:
            p.append(1)
        else:
            p.append(0)
    c = 0
    if sum(p) > ans:
        for l in range(N):
            if p[l] != 0:
                for j in xy[l]:
                    if p[j[0] - 1] != j[1]:
                        c = 1
        if c == 0 and p != [1,1,1]:
            ans = sum(p)
print(ans)

Measured memory_bytes: 3064
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define ll  long long
#define all(v) v.begin(), v.end()
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<b;++i)
#define repb(i,a,b) for(LL i=a;i>b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n;

LL mul(LL a, LL b) {
	return (a*b) % mod;
}

LL add(LL a, LL b) {
	return (a+b+mod) % mod;
}

LL poww(LL a,LL n)
{
    if(n==0) return 1;
    LL val=poww(a,n/2);
    if(n%2==0) return (val*val)%mod;
    else return (((val*val)%mod)*a)%mod;
}

int main()
{
	FIO;
	cin >> n;
	LL ans = add(add(poww(10, n), -mul(2LL, poww(9, n))), poww(8, n));
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
int n;
int get(int x) {
    int res = 0;
    while(x) res += x % 10, x /= 10;
    return res;
}
int main() {
    scanf("%d", &n);
    int ans = get(1) + get(n - 1);
    for(int i = 1 ; i < n ; ++ i) ans = min(ans, get(i) + get(n - i));
    printf("%d\n", ans);
}

Measured memory_bytes: 256
N,M = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))
As.sort()
BCs = []
for _ in range(M):
    BCs.append(list(map(int,input().split(" "))))
BCs.sort(key=lambda x:x[1],reverse= True)
ia = 0 # A のindex
ibc = 0 # bcのindex
Asl = len(As)
BCsl = len(BCs)
endflag = False
while True:
    if ibc >= BCsl:
        endflag = True
        break

    temp = BCs[ibc]
    for _ in range(temp[0]):
        if ia >= Asl:
            endflag = True
            break
        if temp[1] > As[ia]:
            As[ia] = temp[1]
            ia += 1
        else:
            break
            endflag = True

    ibc += 1

    if endflag:
        break
print(sum(As))

Measured memory_bytes: 81620
#include<bits/stdc++.h>
using namespace std;
int dp[100][4][4][4];
bool isok(int i,int j,int k,int u)
{
	//0 1 2 3
	//A C G T
	if(i == 0&&k == 2&&u == 1)return 0;
	if(i == 0&&j == 2&&u == 1)return 0;
	if(j == 0&&k == 2&&u == 1)return 0;
	if(j == 0&&k == 1&&u == 2)return 0;
	if(j == 2&&k == 0&&u == 1)return 0; 
	return 1;
}
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<4;j++)
		{
			for(int k = 0;k<4;k++)
			{			
				if((i == 0&&j == 2&&k == 1)||
				   (i == 0&&j == 1&&k == 2)||
				   (i == 2&&j == 0&&k == 1))
				   continue;
				dp[2][i][j][k] = 1; 
			 } 
		}
	}
	for(int l = 3;l<100;l++)
	{
		for(int i =0;i<4;i++)
		{
			for(int j=0;j<4;j++)
			{
				for(int k=0;k<4;k++)
				{
					for(int u=0;u<4;u++)
					{
						if(isok(i,j,k,u))
							dp[l][j][k][u] += dp[l-1][i][j][k];
						dp[l][j][k][u]%=1000000007;
					}
				}
			}
		}
	}
	long long sum = 0;
	for(int i=0;i<4;i++)
	{
		for(int j=0;j<4;j++)
		{
			for(int k = 0;k<4;k++)
			{
				sum+=dp[n-1][i][j][k];
				sum = sum%(1000000007);
			}
		}	
	}
	cout<<sum<<endl;
} 

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int X, Y;
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

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

class Prefix {
private:
    int N; // 1 < N < 100
    std::string str1; //str1
    std::string str2; //str2
public:
    void run();
};

void Prefix::run() {
    std::cin >> N;
    std::cin >> str1;
    std::cin >> str2;
    int len = str1.size() + str2.size();
    for (int i = N;i > 0;i--) {
        std::string comp_str2 = str2.substr(0,i);
        for (int j = 0;j < N;j++){
            std::string comp_str1 = str1.substr(j,i);
            if (comp_str1 == comp_str2) {
                len += j - N;
                goto ans;
            }
        }
    }
ans:
    std::cout << len << std::endl;
}

int main() {
    Prefix prefix;
    prefix.run();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=200005;

void solve()
{
	ll n,a[100],i,s=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n-1;i++)
		s+=a[i];
	if(s>a[n-1])
		cout<<"Yes";
	else
		cout<<"No";
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

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

int main(){
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  int m1,m2;
  m1=min(min(min(a,b),c),d);
  m2=min(e,f);
  cout<<(a+b+c+d+e+f-m1-m2)<<endl;
  return 0;
}

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

int main() {
  string A,B,C; 
  cin >>A>>B>>C;
  int kazuA=A.size();
  int kazuB=B.size();
  if(A[kazuA-1]==B[0]&&B[kazuB-1]==C[0]){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>

using namespace std;

#define DT int
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
#define all(x) (x).begin(), (x).end()


int main() {
	ifstream fin("Text.txt");
	int i, j, i1,j1,q;
	DT a,b,c,d,n,m,k,t,pr=0,cn=0,ans=0;
	//scanf("%I64d", &n);
	scanf("%d", &n);
	list<DT>ls;
	forn(i, n) {
		scanf("%d", &a);
		if (i & 1)
			ls.push_back(a);
		else
			ls.push_front(a);
	}
	list<DT>::iterator it;
	if (n & 1) {
		it = ls.begin();
		while (it != ls.end()) {
			cout << (*it) << " ";
			it++;
		}
	}
	else {
		ls.reverse();
		it = ls.begin();
		while (it != ls.end()) {
			cout << (*it) << " ";
			it++;
		}
	}
	return 0;
}

Measured memory_bytes: 8448