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

void solve()
{
	ll a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(a<b)
	{
		ll k1 = a+v*t;
		ll k2 = b+w*t;
		if(k1>=k2)
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}
	else
	{
		ll k1 = a-v*t;
		ll k2 = b-w*t;
		if(k1<=k2)
			cout<<"YES"<<endl;
		else 
			cout<<"NO"<<endl;
	}
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

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

int dp[1005][5000];

int main(){ //(以下https://drken1215.hatenablog.com/entry/2019/09/29/103500を参照)
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m), c(m, 0);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++){
            int t; cin >> t;
            t--;
            c[i] += (1 << t);
        }
    }
    for(int i = 0; i < 1005; i++){
        for(int j = 0; j < 5000; j++){
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < m; i++){
        for(int j = 0; j < (1<<n); j++){
            chmin(dp[i+1][j], dp[i][j]);
            int nj = j|c[i];
            chmin(dp[i][nj], dp[i][j] + a[i]);
        }
    }
    cout << (dp[m][(1<<n)-1] < INF ? dp[m][(1<<n)-1] : -1) << endl;
}

Measured memory_bytes: 23272
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

bitset<2000 * 2000 + 1> s;
int main() {
	INIT;
	int n;
	cin >> n;
	s[0] = 1;
	LL sum = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		sum += x;
		s |= s << x;
	}
	int z = (sum + 1) / 2;
	while (!s[z])z++;
	cout << z << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define reg register
#define maxn 1000001
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int nt[maxn], go[maxn], fi[maxn], n, cnt, sg[maxn];
void add(int x, int y){
    nt[++cnt] = fi[x]; fi[x] = cnt; go[cnt] = y;
}
void dfs(int x, int fa){
    for(int i = fi[x]; i; i = nt[i]){
        int v = go[i]; if(v == fa) continue;
        dfs(v, x); sg[x] ^= (sg[v] + 1);
    }
}
int main(){
    n = read();
    for(int i = 1; i < n; i++){
        int x = read(), y = read();
        add(x, y); add(y, x);
    }
    dfs(1, 0);
    if(sg[1] == 0) printf("Bob\n");
    else printf("Alice\n");
}

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

n = int(input())

a = [[i, int(input())] for i in range(n)]

ans = 0
tmp = 0

for i in range(10**5):
    tmp = a[tmp][1] - 1

    if tmp == 1:
        ans += i + 1
        break


print(ans if ans >= 1 else -1)


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    vector<long long> a(n+1),sa(n+2);
    for(i = 0;i <= n;i++) cin >> a[i];
    sa[n+1] = 0;
    for(i = n;i >= 0;i--) sa[i] = a[i] + sa[i+1];
    long long ans = 0;
    long long node = 1;
    for(i = 0;i < n;i++){
        if(a[i] >= node) {
            cout << -1 << endl;
            return;
        }
        ans += node;
        node = 2*(node-a[i]);
        if(node > sa[i+1]) node = sa[i+1];
    }
    if(a[i] == node) cout << ans+node << endl;
    else cout << -1 << endl;
}

int main(){
    solve();
}


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

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    int ans = 0;

    x -= z;

    while(1){
        if(x < 0){
            ans--;
            break;
        }

        x -= y + z;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]

ans = A[0][0] + sum(A[1])
now = ans
for i in range(N - 1):
    now = now - A[1][i] + A[0][i + 1]
    ans = max(ans, now)
print(ans)


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
const ll CHAR = 26;
ll dp[200005][30];

int main() {
    string S;
    cin >> S;
    ll N = S.length();
    REP(i, CHAR) {
        dp[N][i] = 1;
    }

    for (ll i = N - 1; i >= 0; --i) {
        ll m = INF;
        REP(j, CHAR) {
            m = std::min(m, dp[i + 1][j]);
        }
        REP(j, CHAR) {
            dp[i][j] = dp[i + 1][j];
            if (S[i] - 'a' == j)
                dp[i][j]++;
            dp[i][j] = std::min(dp[i][j], m + 1);
        }
    }


    string ans = "";
    ll n = INF;
    REP(i, CHAR) {
        n = std::min(n, dp[0][i]);
    }
    ll index = 0;
    char c = 0;
    while (n > 0) {
        REP(j, CHAR) {
            if (dp[index][j] == n) {
                if (n > 1) {
                    while (S[index] - 'a' != j) {
                        index++;
                    }
                }
                ans.push_back((char) ('a' + j));
                n--;
                break;
            }
        }
        index++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47492
public class Main {

	 public static void main(String[] args) {
		    java.util.Scanner scanner = new java.util.Scanner(System.in);
		    int n = scanner.nextInt();
		    int k = scanner.nextInt();
		    int kyori = 0;
		    for (int i = 0; i < n; i++) {
		    	int x = scanner.nextInt();
		    	kyori = kyori + Math.min(x, Math.abs(x - k));
		    }
		    System.out.println(kyori * 2);
		 }

}

Measured memory_bytes: 21972
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int main() {
    string s;
    cin >> s;
    int a[4];
    for (int j = 0; j < 4; ++j) a[j] = s[j] - '0';

    for (int n = 0; n < 8; ++n) {
        int v = a[0];
        string t = string(1, s[0]);
        for (int j = 0; j < 3; ++j) {
            if (n & (1 << j)) {
                v += a[j+1];
                t += string(1, '+');
            } else {
                v -= a[j+1];
                t += string(1, '-');
            }
            t += string(1, s[j+1]);
        }
        if (v == 7) {
            cout << t << "=7" << endl;
            return 0;
        }
    }
    return 0;
}
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	cin>>n>>x;
	int a[3];
	a[1]=n*x;
	a[0]=n+x;
	a[2]=n-x;
	sort(a,a+3);
	cout<<a[2];
}

Measured memory_bytes: 256
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();

    return max(a + b, max(a - b, a * b)).to_string();
}


Measured memory_bytes: 2116
import bisect
I = [int(_) for _ in open(0).read().split()]
N = I[0]
A = [0] + I[1:1 + N]
U = [0] + I[1 + N::2]
V = [1] + I[2 + N::2]
G = [set() for _ in range(N + 1)]
for u, v in zip(U, V):
    G[u].add(v)
    G[v].add(u)
ans = [10**10] * (N + 1)
stack = [(0, 1, 1, A[1], 0)]
dp = [-10 ** 10] + [10 ** 10] * N
while stack:
    i, j, p, q, d = stack.pop()
    if d:
        dp[p] = q
        continue
    stack += [(j, i, p, dp[p], 1)]
    dp[p] = q
    ans[j] = bisect.bisect_left(dp, 10 ** 10) - 1
    while G[j]:
        k = G[j].pop()
        if i == k:
            continue
        q = A[k]
        p = bisect.bisect_left(dp, q)
        stack += [(j, k, p, q, 0)]
print(*ans[1:], sep='\n')


Measured memory_bytes: 112496
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <typeinfo>
#include <cstdlib>

int main(){
    int n;
    std::string s;
    std::cin >> n >> s;
    std::vector<int> a(n, 0), l1(n+1, 0), r0(n+1, 0);
    for(int i=0; i<n; i++){
        if(s[i]=='#') a[i]=1;
        l1[i+1] = l1[i]+a[i];
    }
    for(int i=n-1; i>=0; i--){
        r0[i] = r0[i+1]+(1-a[i]);
    }
    int min = n;
    for(int i=0; i<n+1; i++){
        min = std::min(l1[i]+r0[i], min);
    }

    std::cout << min << std::endl;
	return 0;
}


Measured memory_bytes: 2948
import java.io.*;
import java.util.*;

public class Main {
	static final int MOD = 1_000_000_007;
	static final boolean DEBUG = !true;
	
	long n;
	Map<Long, Map<Long, Integer>> memo = new TreeMap<>();

	void run() {
		n = in.nextLong() + 1;
		if (DEBUG) {
			boolean[][] nice = new boolean[(int) n][(int) n];
			for (int a = 0; a < n; a++) {
				for (int b = 0; a + b < n; b++) {
					int u = a ^ b;
					int v = a + b;
					if (u < n) {
						nice[u][v] = true;
					}
				}			
			}
			for (int u = 0; u < n; u++) {
				for (int v = 0; v < n; v++) {
					System.out.print(nice[u][v] ? "0" : ".");
				}			
				System.out.println();
			}
		}
		long level = 1;
		while (level < n) {
			memo.put(level, new TreeMap<>());
			level *= 2;
		}
		out.println(solve(level, 0));
	}

	int solve(long level, long x) {
		if (x >= n) {
			return 0;
		}
		if (x + 2 * level - 1 <= n) {
			return size(level);
		}
		level /= 2;
		if (memo.get(level).containsKey(x)) {
			return memo.get(level).get(x);
		}
		int res = solve(level, x);
		res += solve(level, x + level);
		res %= MOD;
		res += solve(level, x + 2 * level);
		res %= MOD;
		memo.get(level).put(x, res);
		return res;
	}
	
	int size(long level) {
		if (level == 1) {
			return 1;
		}
		return (int) (3L * size(level / 2) % MOD);
	}

	static MyScanner in;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		boolean stdStreams = true;
		String fileName = Main.class.getSimpleName().replaceFirst("_.*", "").toLowerCase();
		String inputFileName = fileName + ".in";
		String outputFileName = fileName + ".out";
		
		Locale.setDefault(Locale.US);
		BufferedReader br;
		if (stdStreams) {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			br = new BufferedReader(new FileReader(inputFileName));
			out = new PrintWriter(outputFileName);
		}
		in = new MyScanner(br);
		int tests = 1;//in.nextInt();
		for (int test = 0; test < tests; test++) {
			new Main().run();
		}
		br.close();
		out.close();
	}
	
	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		MyScanner(BufferedReader br) {
			this.br = br;
		}
		
		void findToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
		}
		
		String next() {
			findToken();
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 8660
#include <iostream>

using namespace std;

int Flag;
char Data;

int main() {
	while((cin >> Data)) {
		if(Data == 'C') Flag = 1;
		if((Data == 'F') && (Flag == 1)) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int mod=1e9+7;
int H,W,T,n,m;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}

signed main(){
	read(H,W,T);n=H/__gcd(H,T);m=W/__gcd(W,T);
	write(fpow(fpow(2,n)+fpow(2,m)+fpow(2,__gcd(n,m))-3,__gcd(W,T)*__gcd(H,T)%(mod-1)));
}

Measured memory_bytes: 3588
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<llint>&ar,llint in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<llint>&ar,llint in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,m,i;cin>>n>>m;
	llint ans=0;
	static llint fre[100][100]={0};
	queue<vector<int>>que;
	for(i=0;i<m;i++){
		int u,v;llint f;
		cin>>u>>v>>f;u--;v--;
		fre[u][v]=f;
		fre[v][u]=f;
	}
	for(i=0;i<n;i++){
		fre[i][i]=big;
		vector<int>iti;
		iti.pub(i);
		que.push(iti);
	}
	while(que.size()>0){
		vector<int>rab=que.front();
		que.pop();
		if(rab.size()>=2){
			llint gen=0;
			for(auto it:rab){
				llint sai=big;
				for(auto itr:rab){
					mineq(sai,fre[it][itr]);
				}
				gen+=sai;
			}
			maxeq(ans,gen);
		}
		for(i=rab.back()+1;i<n;i++){
			bool ok=true;
			for(auto it:rab){
				if(fre[i][it]==0){ok=false;break;}
			}
			if(ok){
				auto rr=rab;
				rr.pub(i);
				que.push(rr);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3508
n = gets.to_i
nums = gets.split(' ').map(&:to_i)

result = 'APPROVED'
nums.each do |n|
  if n.even?
    result = 'DENIED' unless n % 3 == 0 || n % 5 == 0
  end
  next if result == 'DENIED'
end

puts result


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)
 
int n;
int x[10];
int y[10];
int b[10];
 
double dis(int a, int b, int c, int d) {
	double ans = sqrt((a - b) * (a - b) + (c - d) * (c - d));
	return ans;
}
 
int main() {
	cin >> n;
	rep(i, n) cin >> x[i] >> y[i];
	for (int i=0;i<n;i++) b[i] = i;
	double sum = 0;
	do {
		for (int i = 0; i < n - 1; i++) {
			sum += dis(x[b[i]],x[b[i+1]],y[b[i]],y[b[i+1]]);
		}
	} while (next_permutation(b, b + n));
	double k = 1;
	for (int i = 1; i <= n; i++) k *= i;
	cout << fixed << setprecision(10) << sum / k << endl;
	return 0;
}

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

using namespace std;

#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const int inf = 1e9+5; 

const double PI =  3.14159265;

int main(){
	IO;
	int n, c, w, v;
	cin>>n>>c;
	ll dp[c+1];
	memset(dp, 0,sizeof(dp[0])*(c+1));
	for(int i = 0; i<n ; i++){
		cin>>w>>v;
		for(int j = c-w; j>=0 ; j--){
			dp[j+w] = max(dp[j+w],dp[j]+v);		
		}
	}
	cout<<dp[c]<<'\n';
	return 0;
}


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

int gcd(int a, int b) {
  while(a!=b && a!=0 && b!=0) {
    if(a>b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  return max(a,b);
}

int main() {
  int n;
  cin >> n;
  vector<long> a(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (size_t i = 0; i < n-1; i++) {
    a[i+1] = gcd(a[i],a[i+1]);
  }
  cout << a[n-1] << endl;
}

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

int main()
{
  string S;
  cin >> S;
  if(S.at(0)=='S')
   {
       if(S.at(1)=='U')
       cout << 7 <<endl;
       else
       {
        cout << 1<< endl;
       }  
   }
     if(S.at(0)=='T')
   {
       if(S.at(1)=='U')
       cout << 5 <<endl;
       else
       {
        cout << 3<< endl;
       }  
   }
   if(S.at(0)=='W')
   {
       cout << 4 <<endl;
   }
   if(S.at(0)=='M')
   {
       cout <<6 <<endl;
   }
   if(S.at(0)=='F')
   {
       cout <<2<<endl;
   }
}

Measured memory_bytes: 256
chomp(my $str = <STDIN>);
my ($road_size, undef, $start) = split / /, $str;
my @roads;
chomp($str = <STDIN>);
my @gates = split / /, $str;


for (0..$road_size) {
    $roads[$_] = 0;
}

for (@gates) {
    $roads[$_] = 1;
}

my $front = cost(1);
my $back = cost(0);

print $front < $back ? $front : $back , "\n";

sub cost {
    my $now;
    my $cost = 0;
    if ($_[0] == 1) { # front
        for $now (($start + 1)..$road_size) {
            $cost += $roads[$now];
        }
    } else {
        for $now (0..($start - 1)) {
            $cost += $roads[$now];
        }
    }
    return $cost;
}


Measured memory_bytes: 640
'use strict'

const INF = 900719925474099;
function mapint(temp){
    return temp.split(' ').map((v)=>parseInt(v));
}
const MOD = 1000000007;

function Main(input){
    let temp = input.trim().split('\n');
    let n = mapint(temp[0])[0];
    let m = mapint(temp[0])[1];
    let a = new Array(m);

    let step = new Array(n+10).fill(0);
    step[0] = 1;

    for(let i=1;i<=m;i++){
        step[parseInt(temp[i])] = -1;
    }

    for(let i=0;i<n;i++){
        if(step[i] == -1) continue;
        if(step[i+1] != -1){
            step[i+1]+=step[i];
            step[i+1]%=MOD;
        }
        if(step[i+2] != -1){
            step[i+2]+=step[i];
            step[i+2]%=MOD;
        }
        //console.log(step);
    }

    console.log(step[n]);

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


Measured memory_bytes: 17112
from collections import deque
class Dinic:
    def __init__(self,number):
        self.table = [[0]*(number) for i in range(number)]
        self.n=number
    
    def add(self,x,y,f):
        self.table[x][y]=f
    
    def bfs(self,x):
        self.visit[x]=0
        h=deque()
        h.append(x)
        while h:
            y=h.popleft()
            for i in range(self.n):
                if self.visit[i]==-1 and self.table[y][i]>0:
                    self.visit[i]=self.visit[y]+1
                    h.append(i)
        return 0
    
    def dinic(self,s,t,f):
        if s==t:
            return f
        for i in range(self.n):
            if self.visit[i]>self.visit[s] and self.table[s][i]>0:
                df = self.dinic(i,t,min(f,self.table[s][i]))
                if df>0:
                    self.table[s][i]-=df
                    self.table[i][s]+=df
                    return df
        return 0
    
    def flow(self,s,t):
        ans=0
        inf=10**20
        while True:
            self.visit=[-1]*(self.n)
            self.bfs(s)
            if self.visit[t]==-1:
                break
            while True:
                df=self.dinic(s,t,inf)
                if df==0:
                    break
                ans+=df
        return ans
N=int(input())
P=[int(i) for i in input().split()]
inf=10**20
maxflow=Dinic(N+2)
for i in range(1,N+1):
    if P[i-1]>0:
        maxflow.add(i,N+1,P[i-1])
    else:
        maxflow.add(0,i,-P[i-1])
    for j in range(2*i,N+1,i):
        maxflow.add(i,j,inf)
ans=maxflow.flow(0,N+1)
num=sum([p for p in P if p>0])
print(num-ans)

Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 0109d
int main(){
    int h, w;
    cin >> h >> w;
    int a[h+1][w+1];
    rep(i, h)rep(j, w) cin >> a[i][j];
    vector<vector<P>> ans;
    rep(i, h){
        rep(j, w){
            if (i!=h-1){
                if(a[i][j]%2==1){
                    a[i][j]--;
                    a[i+1][j]++;
                    vector<P>  tmp;
                    tmp.push_back(P(i, j));
                    tmp.push_back(P(i+1, j));
                    ans.push_back(tmp);
                }
            }else{
                if(j==w-1) continue;
                if(a[i][j]%2==1){
                    a[i][j]--;
                    a[i][j+1]++;
                    vector<P>  tmp;
                    tmp.push_back(P(i, j));
                    tmp.push_back(P(i, j+1));
                    ans.push_back(tmp);
                }
            }
        }
    }
    int n = ans.size();
    cout << n << endl;
    rep(i, n){
        cout << ans[i][0].first+1 << ' ' << ans[i][0].second+1 << ' ' << ans[i][1].first+1 << ' ' << ans[i][1].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 9904
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int A = nextInt();
		int B = nextInt();
		int C = nextInt();




		System.out.println(A*B/2);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23124
#include <iostream>
#include <sstream>
#include <string>

int main()
{
    while (true)
    {
        std::string temp;
        std::getline(std::cin, temp, '\n');
        std::stringstream ss(temp);
        int loop = 0;
        int n, x;
        int* arr[2] = {&n, &x};
        
        while (std::getline(ss, temp, ' '))
        {
            *(arr[loop++]) = std::stoi(temp);
        }
        
        if (n == 0 && x == 0)
            break;
        
        int count = 0;
        
        for (int a = 1; a <= n; ++a)
            for (int b = a + 1; b <= n; ++b)
                for (int c = b + 1; c <= n; ++c)
                    if (a + b + c == x)
                        ++count;
        
        std::cout << count << std::endl;
    }
}


Measured memory_bytes: 3184
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 0; i <= n / 7; i++){
        for(int j = 0; j <= n / 4; j++){
            if(7 * i + 4 * j == n){
                printf("Yes\n");

                return 0;
            }
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s,t;
  cin>>s>>t;
  int cnt=0;
  int n=size(s);
  REP(i,n) {
    if(s[i]!=t[i])++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3800
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

long long int A[500010];

void MaxHeapify(int i, int H)
{
	int l = 2 * i;
	int r = 2 * i + 1;
	int largest;

	if (l <= H&&A[l] > A[i])
	{
		largest = l;
	}
	else
	{
		largest = i;
	}
	if (r <= H&&A[r] > A[largest])
	{
		largest = r;
	}
	
	if (largest != i)
	{
		int temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		MaxHeapify(largest, H);
	}
}

void BuiledMaxHeap(int H)
{
	for (int i = H / 2; i >= 1; i--)
	{
		MaxHeapify(i, H);
	}
}

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

	for (int i = 0; i < H; i++)
	{
		cin >> A[i + 1];
	}

	BuiledMaxHeap(H);

	for (int i = 0; i < H; i++)
	{
		printf(" %d", A[i + 1]);
	}
	printf("\n");

	return 0;
}


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

#define mp make_pair
#define pb push_back
#define x first
#define y second

using namespace std;

pair<int, int> a[222222];
long long an;
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%d%d",&a[i].x,&a[i].y);
	for(int i = 1; i <= n; ++i) if (a[i].x < a[i].y) swap(a[i].x, a[i].y);
	int mn1 = 1e9, mx1 = 0, mn2 = 1e9, mx2 = 0;
	int mx = 1, mn = 1;
	for(int i = 1; i <= n; ++i){
		mx2 = max(mx2, a[i].x);
		mn2 = min(mn2, a[i].x);
		mn1 = min(mn1, a[i].y);
		mx1 = max(mx1, a[i].y);
		if (a[mx].x < a[i].x) mx = i;
		if (a[mn].y > a[i].y) mn = i;
	}
	an = 1ll * (mx2 - mn2) * (mx1 - mn1);
	if (mx != mn && n > 2){
		vector<pair<int, int> > v;
		for(int i = 1; i <= n; ++i) if (i != mx && i != mn)	v.pb(a[i]);
		sort(v.begin(), v.end());
		int low = min(a[mx].y, min(a[mn].x, v[0].x));
		int high = max(a[mx].y, a[mn].x);
		for(int i = v.size() - 1; i >= 0; --i){
			if (v[i].x <= high) break;
			an = min(an, 1ll * (v[i].x - low) * (a[mx].x - a[mn].y));
			low = min(low, v[i].y);
			high = max(high, v[i].y);
		}
		an = min(an, 1ll * (high - low) * (a[mx].x - a[mn].y));
	}
	printf("%lld",an);
	return 0;
}

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

const int MAXN = 200200, MAXT = 10e9 + 200;

int n, t, temp, sol, last = -MAXT;

int main(void){
    cin >> n >> t;
    for (int i = 0; i < n; i++){
        cin >> temp;
        sol += t;
        sol -= max(0, last + t - temp);
        last = temp;
    }
    cout << sol << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C044
{
    class C107
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            string[] x = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int min = int.MaxValue;
            for (int i = 0; i <= N - K; i++)
            {
                int low = int.Parse(x[i]);
                int high = int.Parse(x[i + K - 1]);

                int nearer = Math.Min(Math.Abs(low), Math.Abs(high));
                int far = Math.Max(Math.Abs(low), Math.Abs(high));

                if ((long)low * high < 0)
                {
                    int total = far + 2 * nearer;
                    if (total < min) min = total;
                }
                else
                {
                    if (far < min) min = far;
                }

            }
            Console.WriteLine(min);
        }

    }
}


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

int main(){
  string s;
  cin >> s;
  bool a[26];
  for(int i = 0; i < 26; i++)
  {
    a[i] = false;
  }
  for(int i = 0; i < s.length(); i++)
  {
    a[s[i] - 'a'] = true;

  }
  for(int i = 0; i < 26; i++)
  {
    if(!a[i]){
      cout << (char)(i + 'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int a[n];
  rep(i,n)cin >> a[i];

  sort(a,a+n,greater<int>());

  int sum=0;
  rep(i,n)sum+=a[i];
  
  string ans="No";
  int cnt=0;
  rep(i,m){
    if(4*m*a[i]>=sum)cnt++;
    else break;
  }
  if(m<=cnt)ans="Yes";
  cout << ans << endl;
}

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

int main(){
	
	
	long long int N, mod = 1000000007, ans = 0;
	vector<long long int> A;
	vector<long long int> s;

	cin >> N;

	A.resize(N);
	s.resize(N+1);

	rep(i, N){
		cin >> A[i];
	}

	s[0] = 0;
	rep(i, N){
		s[i+1] = s[i] + A[i];
	}

	rep(i, N){
		ans = (ans + A[i]*((s[N] - s[i+1])%mod) )%mod;
	}

	cout << ans;
 
	return 0;
}

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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for( int i = 0; i < M; i++ ) cin >> B.at(i);
  
  vector<vector<int>> A(N, vector<int>(M));
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < M; j++ ){
      cin >> A.at(i).at(j);
    }
  }
  
  int total;
  int count = 0;
  for( int i = 0; i < N; i++ ){
    total = 0;
    for( int j = 0; j < M; j++ ){
      total += A.at(i).at(j) * B.at(j);
    }
    if( total + C > 0 ){
      count++;
    }
  }
  cout << count << endl;
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 100;
const int INF = 1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L

int main() {
	int K, N; cin >> K >> N;
	vector<int> v;
	for (int ii = 0; ii < N; ii++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}
	sort(v.begin(), v.end());
	int ans = K;
	for (int ii = 0; ii < N; ii++) {
		int tmp;
		if (ii != N - 1) {
			tmp = K - (v[ii + 1] - v[ii]);
		} else {
			tmp = v[ii] - v[0];
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 4260
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

int main(void) {
std::string s;
std::cin >> s;
int ans =700;
for(int i=0;i<3;i++){
    if(s[i]=='o'){
        ans+=100;
    }
}
std::cout << ans << std::endl;
    return 0;
}

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

int main() {
    int H, W;
    std::cin >> H >> W;
    for (int y = 0; y < H; ++y)
    for (int x = 0; x < W; ++x) {
        std::string cell;
        std::cin >> cell;
        if ("snuke" == cell) {
            std::printf("%c%d\n", 'A'+x, 1+y);
        }
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
m = len(format(max(a),"0b"))
b = []
for i in range(m):
  b.append(sum([1 for aa in a if (aa%(2**(i+1)))>=2**i]))
ans = 0
for i in range(m):
  ans += b[i]*(n-b[i])*(2**i)%(10**9+7)
ans %= 10**9+7
print(ans)

Measured memory_bytes: 137280
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
long long n, x, t, r;
int32_t main() {
    DAU
    cin >> n >> x >> t;
    r = n / x;
    if (n % x)
        ++r;
    cout << r * t;
    PLEC
}


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

int main() {
  int N, K, sam = 1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    if (sam < K){
      sam *= 2;
    }
    else {
      sam += K;
    }
  }
  cout << sam << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int i, x, b = 1000000, c = -1000000,  n;
  long long a = 0;
  cin >> i;
   for (n = 1; n <= i; n++){
     cin >> x;
     a = a + x;
     if (x < b){
       b = x;
     }
     if (x > c){
       c = x;
     }
   }
  cout << b << " " << c << " " << a << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	string S;
	cin>>S;
	int cb[200005];
	//区間[0,i)での黒の個数
	cb[0]=0;
	rep1(i,N){
		if(S[i-1]=='#')cb[i]=cb[i-1]+1;
		else cb[i]=cb[i-1];
	}
	int ans=500000;
	rep(i,N+1){
		int ch=cb[i];
		ch+=(N-i)-(cb[N]-cb[i]);
		ans=min(ans,ch);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string a;
	int letter[123],f=0;
	memset(letter,0,sizeof(letter));
	cin>>a;
	for(int i=0;i<a.size();i++){
		letter[a[i]]++;
	}
	for(int i=97;i<123;i++){
		if(letter[i]%2!=0){
			cout<<"No"<<endl;
			f=1;
			break;
		}
	}
	if(f==0){
		cout<<"Yes"<<endl;
	}
	return 0;
}

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

int main(){
    int n,A[100];
    cin >> n;
    
    for(int i=0; i <n ; i++) cin >> A[i];
    for(int x = n-1; x >= 0; x--){
        cout << A[x];
        if(x != 0)cout << " ";
    }
    cout << endl;
    
    return 0;
    
}



Measured memory_bytes: 3072
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <map>
#include <deque>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

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

    int q;
    cin >> q;

    deque<char> data;  
    REP(i,s.size())
    {
        data.push_back(s[i]);
    }
    //反転の状態 trueのとき通常
    bool ima = true;

    REP(i, q)
    {
        int t;
        cin >> t;
        if(t == 1)
        {
            ima = !ima;
        }
        else
        {
            int f;
            char c;
            cin >> f >> c;
            if(ima)
            {
                if(f == 1)
                {
                    data.push_front(c);
                }
                else
                {
                    //末尾
                    data.push_back(c);
                }
            }
            else
            {
                if(f == 1)
                {
                    data.push_back(c);
                }
                else
                {
                    //先頭
                    data.push_front(c);
                }
            }
        }
    }


    int n = data.size();
    
    if(ima)
    {
        REP(i,n)
        {
            //先頭から出力
            cout << data.front();
            data.pop_front();
        }
    }
    else
    {
        REP(i,n)
        {
            //末尾から出力
            cout << data.back();
            data.pop_back();
        }       
    }

    cout << endl;




    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
int yu(int a,int b);

int main(void){
	int n,i,max=0;
	scanf("%d",&n);
	int all[n];
	int h[n+1];
	int m[n+1];
	h[0] = 0; m[n] = 0;
	for(i=0;i<n;i++) scanf("%d",&all[i]);
	for(i=0;i<n;i++) h[i+1] = yu(h[i],all[i]);
	for(i=n-1;i>=0;i--) m[i] = yu(m[i+1],all[i]);
	
	for(i=0;i<n;i++){
		if(yu(h[i],m[i+1])>=max) max = yu(h[i],m[i+1]);
	}
	printf("%d\n",max);
	return 0;
}
int yu(int a,int b){
	int r;
	if(a>b){
		r = b;
		b = a;
		a = r;
	}
	if(a==0) return b;
	else return yu(b%a,a);
}

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

int LIS(vector <int> vec, bool is_strong = true) {
    const int INF = 1 << 30;
    int n = vec.size();
    vector <int> dp(n, INF);
    for (int i = 0; i < n; i++) {
        if (is_strong) *lower_bound(dp.begin(), dp.end(), vec[i]) = vec[i];
        else *upper_bound(dp.begin(), dp.end(), vec[i]) = vec[i];
    }
    return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}


// verified
//   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D&lang=jp
void AOJ_DPL_1_D() {
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cout << LIS(a) << '\n';
}

int main() {
    AOJ_DPL_1_D();
    return 0;
}


Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18
bool comp(const pair<int,int>& a,const pair<int,int>& b){
    return a.second<b.second;
}
int main(){
    string s;
    cin>>s;
    ll ans=0,cnt_0=0,cnt_1=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='0'){
            if(cnt_1==0){
                cnt_0++;
            }
            else{
                cnt_1--;
                ans+=2;
            }
        }
        else{
            if(cnt_0==0){
                cnt_1++;
            }
            else{
                cnt_0--;
                ans+=2;
            }

        }

    }
    cout<<ans<<endl;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
#define RANGE(i,n) for(int i=0;i<n;i++)
typedef long long ll;

using namespace std;

signed main() {
    int A, B, K;
    cin >> A >> B >> K;
    for(int i=100;i>0;i--){
      if(A%i==0 && B%i==0){
        K--;
        if(K==0)cout << i <<endl;
      }
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n=int(input())
    aa=list(map(int,input().split()))
    aa.reverse()
    print(*aa)
main()



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

using namespace std;

int main(){
  int n; cin >> n;
  vector<long long> a(n+1);
  vector<long long> b(n);
  long long sum=0;
  for(int i=0;i<n+1;i++){
    cin >> a[i];
    sum+=a[i]; //先に合計値を計算しておき、後で勇者が行動した後のモンスターの数を引く。
  }
  for(int i=0;i<n;i++){
    cin >> b[i];
  }
  //i番目の勇者はBiのうちできるだけAiを減らすために使い、余ったらAi+1を減らすために使う。
  //i番目の勇者についての処理
  for(int i=0;i<n;i++){
    if(a[i]<=b[i]){
      a[i+1]-=min(b[i]-a[i],a[i+1]);//先にこちらを書く。
      a[i]=0;
    }
    else if(a[i]>b[i]){
      a[i]-=b[i],a[i];
    }
  }
  long long left=0;//残ったモンスターの数を合計する。
  for(int i=0;i<n+1;i++){
    left += a[i];
  }
  cout << fixed << setprecision(15); //coutは6桁までしか表示できない。
  cout << sum-left << endl;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 2000000000;
constexpr auto MOD = 1000000007;

int main() {

	string s,t;
	cin >> s >> t;
	
	if (s.size() < t.size()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	bool find = false;

	rep(i, s.size() - t.size() + 1) {

		bool ok = true;

		rep(j, t.size()) {
			if (s[s.size() - t.size() - i + j] == t[j] || s[s.size() - t.size() - i + j] == '?')continue;
			ok = false;
		}

		if (ok) {
			find = true;
			rep(j, t.size())s[s.size() - t.size() - i + j] = t[j];
			break;
		}
	}

	if (find) {
		rep(i, s.size())if (s[i] == '?')s[i] = 'a';
		cout << s << endl;
	}
	else cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  string s;
  cin >> s;
  for(int i=0; i<s.size()/2+1; i++){
    if(s[i]!=s[s.size()-1-i]){
      cout << "No" << endl;return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    sort(all(S));

    int r = 0;
    int b = 0;
    REP(i, N) {
        if(S[i] == 'R') {
            r++;
        } else {
            b++;
        }
    }

    if(r > b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] num = new int[N];
		String judge = "APPROVED";
		for(int i = 0; i < N; i++){
			num[i] = sc.nextInt();
			if(num[i] % 2 == 0){
				if((num[i] % 3 != 0) && (num[i] % 5 != 0)){
					judge = "DENIED";
				}
			}
		}
		System.out.println(judge);
	}
}

Measured memory_bytes: 23252
import itertools

N = int(input())
ans = 0
list_753 = []

for i in range(10):
    list_753 += list(itertools.product("753",repeat = i))

for num in list_753:
    if len(set(num)) == 3 and int("".join(num)) <= N:
        ans += 1

print(ans)

Measured memory_bytes: 12660
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2


int main() {
	string s;
	cin >> s;
	if (s == "keyence") {
		puts("YES");
		return 0;
	}
	
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			string temp;
			for (int k = 0; k < s.size(); k++) {
				if (k < i || j < k) {
					temp += s[k];
				}
			}
			if (temp == "keyence") {
				puts("YES");
				return 0;
			}
		}
	}
	puts("NO");
	return 0;
}


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

using namespace std;
typedef long long  ll; 
int main(){
    int a,b,ya,yb;
    cin >> a >> b;
    for(int n = 0; n < 10000; n++){
        ya = n*8/100;
        yb = n*10/100;
        if(a == ya && b == yb){
            cout << n <<endl;
            return 0;
        }
    }
    cout << -1 <<endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace Atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x1 = int.Parse(input[0]);
            int y1 = int.Parse(input[1]);
            int x2 = int.Parse(input[2]);
            int y2 = int.Parse(input[3]);


                   int x3 = x2-(y2-y1);
                   int y3 = y2 - (x1 - x2);
                  int  x4 = x1-(y2-y1);
                  int  y4 = y1-(x1-x2);
                
            Console.WriteLine(x3 + " " + y3 + " " + x4 + " " + y4);
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[200005],n,b[200005];
const int mod=1e9+7;
int main(){
  
    cin>>n;
    for(int i=1;i<=n;i++){
    	int x,y;
    	cin>>x>>y;
    	a[i]=x-y;
    	b[i]=x+y;
    }
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
   ll ans=max(a[n]-a[1],b[n]-b[1]);
    cout<<ans;
	return 0;
}


Measured memory_bytes: 5160
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
#include <fstream>
 
  using namespace std;
   
 
//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ

  typedef long long ll;
  typedef long double lld;
  typedef unsigned long long ull;
  // ll INF = INT_MAX;
  // ll mod = 1000000007;
  // lld PI = 3.141592653;
 
// const int N = 2e5 + 5;



  // void solve(){

  //   int n,m;

  //   cin>>n>>m;
  //   for (int tt=0;tt<m;tt++){
  //     int x,y;
  //     cin>>x>>y;
  //     adj[x].push_back()
  //   }
  // }


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      // ifstream cin("input.txt");


 int n;
 cin>>n;
 vector<int> a(n);
 for (int i = 0;i<n;i++) cin>>a[i];
  int i = 0;
int f = 1;
while(i<n){
  while (i<n && a[i]!=f) i++;
  if (i==n){
    if (f==1) f=n+2;
    cout<<n-(f-1)<<"\n";
    // cout<<f<<endl;
    return 0;
  }
  f++;
}


}

Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>
#include <math.h>

#define LINE_BUF_SIZE 32

int main(){

    int N,M;
    int i,j,k;
    int len;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);     /*Nの取得*/
    sscanf(line,"%d",&N);

    char s[N+1][LINE_BUF_SIZE];

    for(i=1;i<=N;i++){
        fgets(s[i],sizeof(s),stdin);
        len = strlen(s[i]);
        s[i][len-1] = '\0';
    }

    fgets(line,sizeof(line),stdin);     /*Mの取得*/
    sscanf(line,"%d",&M);

    char t[M+1][LINE_BUF_SIZE];

    for(i=1;i<=M;i++){
        fgets(t[i],sizeof(t),stdin);
        len = strlen(t[i]);
        t[i][len-1] = '\0';
    }

    int max = 0;
    int count = 1;

    for(i=1;i<=N;i++){

        for(j=1;j<=M;j++){
            if(strcmp(s[i] , t[j]) == 0 && strlen(s[i]) == strlen(t[j]) ) count -= 1;
        }

        for(k=1;k<=N;k++){
            if(strcmp(s[i] , s[k]) == 0 && strlen(s[i]) == strlen(s[k]) && k != i ) count += 1;
        }

        if(max < count){
            max  = count;
        }

        count  = 1;

    }

    if(max > 0)printf("%d",max);
    else printf("0");

    return 0;

}

Measured memory_bytes: 128