akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int x, int a, int b) {
    if (b <= a) {
      return "delicious";
    }
    if (b - a <= x) {
      return "safe";
    }
    return "dangerous";
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    int a = reader.nextInt();
    int b = reader.nextInt();
    out.println(solve(x, a, b));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

using ll  = long long;

int main()
{
	ll N;
	scanf("%lld", &N);

	ll ans = 0;
	ll p = 2;
	while (p * p <= N) {
		ll count = 0;
		while (N % p == 0) {
			N /= p;
			count++;
		}
		ll tmpans = 0;
		for (ll i = 1; i <= count; i++) {
			count -= i;
			tmpans++;
		}
		ans += tmpans;
		p++;
	}
	if (N > 1) {
		ans++;
	}

	printf("%lld\n", ans);

	return 0;
}


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

int main() {

	ll n; cin >> n;
	ll ans = 9223372036854775807LL;
	for (ll i = 1; i * i <= n; i++) {
		if ((double)n / i == floor((double)n / i)) {
			ans = min(ans, i + n / i - 2);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    string W[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0; i<7; i++) if(S == W[i]){
        cout << 7-i << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]

#%%
C = {}
for i in A:
    if i in C:
        C[i] += 1
    else:
        C[i] = 1

ans = 0    
for i in C.keys():
    ans += C[i] * (C[i]-1) // 2
    
for i in A:
    dec =  C[i] * (C[i]-1) // 2 - (C[i]-1) * (C[i]-2) //2
    print(ans - dec)


Measured memory_bytes: 25644
n = int(input())
s = []
t = []
for i in range(n):
    a,b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

ans = 0
flag = False
for i in range(n):
    if(flag):
        ans += t[i]
    if(x==s[i]):
        flag = True 
print(ans)
    

Measured memory_bytes: 3060
#include<stdio.h>

int main(){

    int a,b;

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

    if(a > b){
         printf("a > b\n");
   }else if(a<b){
         printf("a < b\n");
   }else{
         printf("a == b\n");
   }

    return 0;
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int w = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int aa = Math.min(a, b);
        int bb = Math.max(a, b);

        int i = bb - (aa + w);
        if (i < 0) {
            System.out.println(0);
        } else {
            System.out.println(i);
        }
    }
}


Measured memory_bytes: 35852
import sys
import math
from functools import reduce

input = sys.stdin.readline

K = int(input())
ans = 0
for a in range(1,K+1):
    for b in range(a,K+1):
        for c in range(b,K+1):
            s = set([a,b,c])
            if len(s) == 1:
                ans += reduce(math.gcd,[a,b,c]) 
            elif len(s) == 2:
                ans += reduce(math.gcd,[a,b,c]) * 3
            else:
                ans += reduce(math.gcd,[a,b,c]) * 6
            
print(ans)

Measured memory_bytes: 9656
#include <iostream>
using namespace std;
int main() {
	int n, a, b, ans = 0, sum, x;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; i++) {
		sum = 0;
		x = i;
		while (x != 0) {
			sum += x % 10;
			x /= 10;
		}
		if (a <= sum && sum <= b) ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();

        List<Integer> list = new ArrayList<>();
        for (int i=1; i <= 100; i++) {
            if (A % i == 0 && B % i == 0 ) {
                list.add(i);
            }
        }
        System.out.println(list.get(list.size() - K));

    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#define ll long long

int main(){
	int n,d;
	scanf("%d%d",&n,&d);
	ll ans=0,time=0;
	ll k=0,pos=1;
	for(int i=0;i<n;i++){
		ll t;
		int f;
		scanf("%lld%d",&t,&f);
		ll tt=t-time;
		if(llabs(f-pos)>tt){
			puts("-1");
			return 0;
		}else if((pos-1)+(f-1)<=tt){
			//1階に寄る
			ans+=(pos-1)*k;
			k=1;
		}else{
			ans+=tt*k;
			k++;
			if(k>d){
				puts("-1");
				return 0;
			}
		}
		pos=f;
		time=t;
	}
	ans+=(pos-1)*k;
	printf("%lld\n",ans);
}


Measured memory_bytes: 2108
a,b,m = map(int,input().split())
a_list = [int(x.strip()) for x in input().split()]
b_list = [int(x.strip()) for x in input().split()]
ans = min(a_list)+min(b_list)
for i in range(m):
  ai,bi,ci = map(int,input().split())
  ch = a_list[ai-1]+b_list[bi-1]-ci
  if ch < ans:
    ans = ch
print(ans)

Measured memory_bytes: 24756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  string x = "Yes";
   cin >> N;

  for (int i=0; i< (N.size()/2); i++) {
    if(N.at(i*2 +1)=='R'){
      x = "No";
      break;
    }
    }
  for (int i=0; i< (N.size()/2); i++) {
    if(N.at(i*2)=='L'){
      x = "No";
      break;
    }
    }
  if (N == "L"){x="No";}
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) clog<<#x<<": "<<x<<endl
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define mkp make_pair
#define fr(i,n) for(i = 0 ; i < n ; i++)
int main()
{
    fio
    int ir,dr,n,i,j,k;
    cin>>n>>dr;
    if(n<10)
        ir = dr+100*(10-n);
    else
        ir = dr;
    cout<<ir;
    return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
const double eps = 1e-7;
int N, M, K, Q, T;

int main()
{
	int i, j;
	ll n, m;
	scanf("%lld%lld", &n, &m);
	if (n == 1LL || m == 1LL) {
		printf("1");
		return 0;
	}
	ll a = (m + 1) / 2;
	ll b = m / 2;
	printf("%lld", a*((n + 1) / 2) + b * (n / 2));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  sort(vec.begin(), vec.end());
  cout<<vec.at(N/2)-vec.at(N/2-1)<<endl;
}

Measured memory_bytes: 3760
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
  num = input()
  if num == 0:
    break
  lis = [0]*num
  for i in range(num):
    n = input()
    if i == 0:
      lis[0] = n
    else:
      lis[i] = max( lis[i-1] + n , n )
  print max(lis)

Measured memory_bytes: 4412
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        String[] z =s.nextLine().split(" ");
        int n=Integer.parseInt(z[0]);
        int d=Integer.parseInt(z[1])*2+1;
        for(int i=1;i<= 1000;i++){
            if(n <= d*i){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 21844
class UnionFind:
    def __init__(self, n):
        self.data=[-1 for i in range(n)]

    def root(self,x):
        if self.data[x]<0:
            return x
        else:
            self.data[x]=self.root(self.data[x])
            return self.data[x]

    def uni(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if(x==y):
            return
        if self.data[y]<self.data[x]:
            x,y=y,x
        self.data[x]+= self.data[y]
        self.data[y] = x

    def same(self,x,y):
        return self.root(x)==self.root(y)

    def size(self,x):
        return -self.data[self.root(x)]

n,w,h=map(int,input().split())
slime_w = [[]for i in range(w)]
slime_h = [[]for i in range(h)]
uf=UnionFind(n)
f=False
for i in range(n):
    x,y=map(int,input().split())
    if x==1 or y==1 or x==w or y==h:
        f=True
    x,y=x-1,y-1
    slime_w[x].append(i)
    slime_h[y].append(i)
for i in range(h):
    if len(slime_h[i])>1:
        p=slime_h[i][0]
    for j in range(1,len(slime_h[i])):
        uf.uni(p,slime_h[i][j])
for i in range(w):
    if len(slime_w[i])>1:
        p=slime_w[i][0]
    for j in range(1,len(slime_w[i])):
        uf.uni(p,slime_w[i][j])
count=[-e-1 for e in uf.data if e<0]
if f:
    print(sum(count)+(len(count)-1+len(count)-1 if len(count)!=1 else 0))
else:
    print(sum(count)+(len(count)+len(count)-1 if len(count)!=1 else 0))


Measured memory_bytes: 23684
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> P;
int n,s[500000],ss[500000];
P p[500000];
signed main(){
  cin>>n;
  for(int i=0,a,b;i<n;i++)cin>>a>>b,p[i]=P(a,b);
  sort(p,p+n);
  s[0]=p[0].second;
  ss[0]=s[0]-p[0].first;
  for(int i=1;i<n;i++)s[i]+=s[i-1]+p[i].second,ss[i]=s[i]-p[i].first;
  for(int i=n-2;i>=0;i--)ss[i]=max(ss[i+1],ss[i]);
  int ans=-1e16;
  for(int i=0;i<n;i++)ans=max(ans,p[i].first+ss[i]-(i?s[i-1]:0));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 18704
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define ff first
#define int long long
#define pi pair<int,int>
#define ss second 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)


int32_t main() { 
	boost;
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt=0;
    while(true){
        if(cnt%2==0 && c>b){
            c-=b;
            cnt++;
        }
        else if(cnt%2==1 && a>d){
            a-=d;
            cnt++;
        }
        else
            break;
    }
    if(cnt%2==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, a, b;

    cin>>n>>a>>b;

    cout<<min(a * n, b)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
//    cout << fixed << setprecision(10);
    int k,n;
    cin>>k>>n;
    vector<int> a(n), b(n);
    int m =0;
    cin>>a[0];
    for(int i=1; i<n; i++){
        cin>>a.at(i);
        m =max( a.at(i)-a.at(i-1), m);
    }
    m =max(m, k-a.at(n-1)+a.at(0));
    cout<<k-m<<endl;

}

Measured memory_bytes: 1792
#include <array>
#include <algorithm>
#include <iostream>
#include <vector>

struct Point {
    int a, b, c, d;
};


int impl(std::vector<int>& prev, const int N, const int M, std::vector<Point> const& conds)
{
    if (static_cast<int>(prev.size()) == N + 1) {
        // calc points

        auto point = 0;
        for (auto const& cond : conds) {
            if (prev.at(cond.b) - prev.at(cond.a) == cond.c) {
                point += cond.d;
            }
        }
        return point;
    }

    auto max = 0;
    for (auto next = prev.back(); next <= M; next++) {
        prev.push_back(next);
        max = std::max(max, impl(prev, N, M, conds));
        prev.pop_back();
    }

    return max;
}


int main()
{
    int N, M, Q;
    std::cin >> N >> M >> Q;

    std::vector<Point> conds;
    conds.reserve(Q);

    for (auto i = 0; i < Q; i++) {
        int a, b, c, d;
        std::cin >> a >> b >> c >> d;
        conds.push_back({a, b, c, d});
    }

    std::vector<int> number_holder(1, 1);
    number_holder.reserve(N + 1);

    std::cout << impl(number_holder, N, M, conds) << std::endl;

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<string> str = {"dreameraser","dreamerase","dreamer","dream","eraser","erase"};
signed main(){
    string s;cin >> s;
    int n = s.size();
    auto check = [&](int i,string t){
    
        return s.substr(i,(int)t.size()) == t;
    };
    for(int now = 0;now < n;){
        bool found = false;
        rep(i,6){
            if(check(now,str[i])){
                now += (int)str[i].size();
                found = true;
                break;
            }
        }
        if(!found){
            cout << "NO" << endl;
            return 0;
        }

    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;
struct pos{
  int x;
  int y;
};
int main(){
  int a = 0;
  cin >> a;
  vector<pos> iti(a);
  for(int i = 0;i <= a - 1;i++){
    cin >> iti[i].x >> iti[i].y;
  }
  double goukei = 0;
  for(int i = 0;i <= a - 2;i++){
    for(int j = i + 1;j <= a - 1;j++){
      goukei += pow(pow(abs(iti[i].x - iti[j].x),2) + pow(abs(iti[i].y - iti[j].y),2),0.5);
    }
  }
  goukei = (goukei * (a - 1) * 2) / (a * (a - 1));
  cout << fixed << setprecision(10) << goukei << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int a,b,r,G,R,L,tmp;
  while(cin >> a >> b){
    R = a; L = b;
    if(b > a){
      tmp = a; a = b; b = tmp;
    }
    while(1){
	  r = a % b;
	  if(r == 0)
	    break;
	  a = b;
	  b = r;
	   }
    G = b;
    R = R / G;
    L = L / G;
    cout << G <<" "<< R*L*G << endl;
  }
}

Measured memory_bytes: 0
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

type ModInt = MVal of int64

[<RequireQualifiedAccess>]
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] // 型名とモジュール名の重複を許す
module ModInt =
    let modulo = (int64 1e9) + 7L

    let inline init (x: ^a) : ModInt =
        let x = (int64 x) % modulo
        match x with
        | _ when x < 0L -> MVal (x + modulo)
        | _ when x >= modulo -> MVal (x - modulo)
        | _ -> MVal x

    let value (MVal x) = x

    let value2 (x: ModInt) (y: ModInt) = (value x, value y)

    let toString (MVal v) : string = sprintf "%d" v

    /// 拡張ユークリッドの互除法
    /// a (mod m) における逆元 a^-1
    let inline inverse (MVal a) : ModInt =
        let mutable (a, b, u, v) = (a, modulo, 1L, 0L)
        while b > 0L do
            let t = a / b
            a <- a - (t * b)
            let tmp = a
            a <- b
            b <- tmp
            u <- u - (t * v)
            let tmp = u
            u <- v
            v <- tmp
        init u

type ModInt with
    static member inline (+) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l + r)

    static member inline (-) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l - r)

    static member inline (*) (lhs: ModInt, rhs: ModInt) : ModInt =
        let l, r = ModInt.value2 lhs rhs
        ModInt.init (l * r)

    /// a / b = a * b^-1 (mod m)
    static member inline (/) (lhs: ModInt, rhs: ModInt) : ModInt =
        let r = ModInt.inverse rhs
        lhs * r

    /// a^n (mod m) 繰り返しニ乗法
    /// O(log n)
    static member inline Pow (a: ModInt, n: int64) : ModInt =
        let mutable (res, a, n) = (ModInt.init 1, a, n)
        while n > 0L do
            if (n &&& 1L) = 1L then res <- res * a
            a <- a * a
            n <- n >>> 1
        res

[<EntryPoint>]
let main _ =
    let n = read int64

    let mutable ans = ModInt.init 1L
    for i in 1L..n do ans <- ans * ModInt.init i

    printfn "%s" (ModInt.toString ans)
    0 // return an integer exit code


Measured memory_bytes: 16216
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,sum;
  sum=0;
  cin>>N;
  int C[N]={0};
  int V[N]={0};
  for(i=0;i<N;i++){
  cin>>V[i];
  }
   for(i=0;i<N;i++){
  cin>>C[i];
  }
  for(i=0;i<N;i++){
  if(C[i]<V[i]){
  sum=sum+V[i]-C[i];
  }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1'000'000'007;
// const ll MOD = 998244353;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    string S, T;
    cin >> S >> T;
    int N = S.size();
    int M = T.size();
    ll ans = INFLL;
    for(int i = 0; i < N; i++){
        // if(i + M > N)continue;
        string tmp = S.substr(i, M);
        if(tmp.size() < M)continue;
        // dump(tmp);
        ll cnt = 0;
        rep(j,M)cnt += T[j] != tmp[j];
        chmin(ans, cnt);
    }
    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

signed main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int N;
    vector<int> A;
    vector<int> color(9, 0);
    cin >> N;
    A.resize(N);
    REP(i, N) {
        cin >> A[i];
        int ind = A[i] / 400;
        if(ind > 8) { ind = 8; }
        color[ind]++;
    }

    int c_min = 0, c_max = 0;

    // 8 のみ
    bool eight = true;
    REP(i, 8) {
        if(color[i] > 0) {
            eight = false;
            break;
        }
    }
    if(eight && color[8] > 0) {
        c_min = 1;
    }
    else {
        REP(i, 8) {
            if(color[i] > 0) {
                c_min++;
                c_max++;
            }
        }
    }
    c_max += color[8];

    printf("%lld %lld\n", c_min, c_max);

    return 0;
}


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

using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; in(N);
  int K; in(K);
  string S; in(S);

  int count = 0, before = S[0];
  vi v;
  rep(i, N) {
    if (S[i] == before)
      ++count;
    else {
      v.push_back(count);
      count = 1;
    }
    before = S[i];
  }
  v.push_back(count);

  out(N-max((int)v.size() - 2*K, 1));

  return 0;
}


Measured memory_bytes: 972
#include <stdio.h>
int main(){
  int N,A[100],i,j,flag=1,count=0,temp;
  scanf("%d",&N);
  for(i=0;i<N;i++)
	scanf("%d",&A[i]);
  while(flag){
	flag = 0;
	for(j=N-1;1<=j;j--){
	  if(A[j]<A[j-1]){
		temp=A[j-1];
		A[j-1]=A[j];
		A[j]=temp;
		flag=1;
		count++;
	  }
	}
  }
  for(i=0;i<N;i++){
	printf("%d",A[i]);
	if(i == N-1){
	  printf("\n");
	  break;
	}
	printf(" ");
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2144
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double L = sc.nextInt();
        
        //max a*b*c
        // a + b + c 
        double a = 100 * L / 3;

        System.out.println(a*a*a/100/100/100);
    }
}

Measured memory_bytes: 21588
#include<stdio.h>
#include<stdlib.h>
long long int l[100005], r[100005];
long long int max(long long int a, long long int b)
{
	if (a > b)return a;
	else return b;
}
int asc(const void* a, const void* b)
{
	if (r[*(int*)a] > r[*(int*)b])return 1;
	if (r[*(int*)a] < r[*(int*)b])return -1;
	if (l[*(int*)a] > l[*(int*)b])return 1;
	if (l[*(int*)a] < l[*(int*)b])return -1;
	return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &l[i], &r[i]);
	int c[100005];
	for (i = 0; i < n; i++)
		c[i] = i;
	qsort(c, n, sizeof(int), asc);
	long long int max1[100005], max2[100005];
	max1[0] = l[c[0]];
	for (i = 1; i < n; i++)
		max1[i] = max(max1[i - 1], l[c[i]]);
	max2[n - 1] = l[c[n - 1]];
	for (i = n - 2; i >= 0; i--)
		max2[i] = max(max2[i + 1], l[c[i]]);
	long long int ans1 = 0;
	for (i = 0; i < n - 1; i++)
		if (ans1 < max(r[c[0]] - max1[i] + 1, 0) + max(r[c[i + 1]] - max2[i + 1] + 1, 0))
			ans1 = max(r[c[0]] - max1[i] + 1, 0) + max(r[c[i + 1]] - max2[i + 1] + 1, 0);
	long long int ans2 = 0;
	long long int max31, max32, count;
	max31 = 0;
	for (i = 0; i < n; i++)
		if (max31 < l[i])
			max31 = l[i];
	count = 0;
	for (i = 0; i < n; i++)
		if (l[i] == max31)
			count++;
	if (count > 1)
		max32 = max31;
	else
	{
		max32 = 0;
		for (i = 0; i < n; i++)
			if (max32 < l[i] && l[i] != max31)
				max32 = l[i];
	}
	if (l[c[0]] == max31)
	{
		if (ans2 < r[c[0]] - l[c[0]] + 1 + max(r[c[1]] - max32 + 1, 0))
			ans2 = r[c[0]] - l[c[0]] + 1 + max(r[c[1]] - max32 + 1, 0);
	}
	else
	{
		if (ans2 < r[c[0]] - l[c[0]] + 1 + max(r[c[1]] - max31 + 1, 0))
			ans2 = r[c[0]] - l[c[0]] + 1 + max(r[c[1]] - max31 + 1, 0);
	}
	for (i = 1; i < n; i++)
	{
		if (l[c[i]] == max31)
		{
			if (ans2 < r[c[i]] - l[c[i]] + 1 + max(r[c[0]] - max32 + 1, 0))
				ans2 = r[c[i]] - l[c[i]] + 1 + max(r[c[0]] - max32 + 1, 0);
		}
		else
		{
			if (ans2 < r[c[i]] - l[c[i]] + 1 + max(r[c[0]] - max31 + 1, 0))
				ans2 = r[c[i]] - l[c[i]] + 1 + max(r[c[0]] - max31 + 1, 0);
		}
	}
	printf("%lld\n", max(ans1, ans2));
	return 0;
}

Measured memory_bytes: 3700
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='#'
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()


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

int main(){
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  if(a1>=a2 && a1>=a3){
    if(a2<=a3){
      cout << a1-a2;
    }
    else if(a2>a3){
      cout << a1-a3;
    }
  }
  
  else if(a2>=a1 && a2>=a3){
    if(a1<=a3){
      cout << a2-a1;
    }
    else if(a1>a3){
      cout << a2-a3;
    }
  }
  
  else if(a3>=a2 && a3>=a1){
    if(a2<=a1){
      cout << a3-a2;
    }
    else if(a2>a1){
      cout << a3-a1;
    }
  }
  
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int ans = 0, n, b[100] = {0};
  cin >> n;
  for(int i = 0; i < n - 1; i++){
    cin >> b[i];
  }
  ans += b[0];
  for(int i = 0; i < n - 2; i++){
    if(b[i] < b[i + 1]){
      ans += b[i];
    }else{
      ans += b[i + 1];
    }
  }
  ans += b[n - 2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// delete when handing in
// delete when proceedig next 
#define EXE
#ifdef EXE
// -------------------------------------------------------
#include <iostream>
#include <string>
#include <stdio.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
using namespace std;


;

vector<pair<int, int>> find_reverse(vector<pair<int, int>> map, int i) {
	vector<pair<int, int>> out_vec;
	int index = 0;
	for (auto m : map) {
		if (m.second == i) {
			out_vec.push_back(make_pair(index, m.first));
		}
		index++;
	}
	return out_vec;
}

vector<pair<int, int>> find(vector<pair<int, int>> map, int i) {
	vector<pair<int, int>> out_vec;
	int index = 0;
	for (auto m : map) {
		if (m.first == i) {
			out_vec.push_back(make_pair(index, m.second));
		}
		index++;
	}
	return out_vec;
}




int main() {
	long N;
#ifdef DEBUG
	N = 9445;

    
#else
	cin >> N;
#endif
	long sub = 0;
	for (int i = 0; i < 10000; i++) {
		long money = i * 1000;
		if (money >= N) {
			sub = money - N;
			break;
		}
	}

	std::cout << sub << endl;

#ifdef DEBUG
	int z;
	cin >> z;
#endif
	return 0;
}


// -------------------------------------------------------
#endif

Measured memory_bytes: 3200
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int d = 0;
        int ans = 1;
        for (int i = 0; i < n; i++) {
            d += sc.nextInt();
            if (d <= x) ans ++;
        }
        System.out.println(ans);

    }
}

Measured memory_bytes: 21972
def main():
    n = int(input())
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    cnt = 0
    while n > 0:
        cnt += 1
        n = n - 26 ** cnt

    ans = ''
    if n == 0:
        print(''.join(['z' for _ in range(cnt)]))
        return

    n -= 1
    for i in range(cnt):
        ans = alphabet[n % 26] + ans
        n //= 26

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61584
#include <iostream>

using namespace std;

int main(){
  int N, i;
  cin >> N;
  string u[N];
  long double x[N], sum=0;
  for(i=0; i<N; i++) cin >> x[i] >> u[i];
  for(i=0; i<N; i++){
      if(u[i][0] == 'J'){
        sum += x[i];
      }else{
        sum += x[i]*380000;
      }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    // cin.tie(NULL);
    
 ll h,w;
  cin>>h>>w;
 int sum=0;
 if(h==1||w==1)cout<<"1\n";
 else{
 if(h%2==0&&w%2==0)
 {cout<<(h/2)*(w/2)+(w/2)*(h/2)<<endl;}
 else if(h%2!=0&&w%2==0)
 {
     cout<<(w/2)*((h/2)+1)+(w/2)*(h/2)<<endl;
 }
  else if(w%2!=0&&h%2==0)
 {
     cout<<((w/2)+1)*((h/2))+(w/2)*(h/2)<<endl;
 }
 else
 {
     cout<<((w/2)+1)*((h/2)+1)+(w/2)*(h/2)<<endl;
 }
 }
//  sum=(int)ceil(w/2.0)*(int)ceil(h/2.0)+(int)floor(w/2.0)*(int)floor(h/2.0);
//  cout<<sum<<endl;

}

Measured memory_bytes: 256
s=input()
t=input()
ns,nt=0,0
anss,anst=s,t
sl,tl=[],[]
for i in range(len(s)):
    if s[i] in sl:
        pass
    else:
        ns+=1
        sl.append(s[i])
        anss=anss.replace(s[i],str(ns))
    if t[i] in tl:
        pass
    else:
        nt+=1
        tl.append(t[i])
        anst=anst.replace(t[i],str(nt))
print('Yes' if anss==anst else 'No')

Measured memory_bytes: 107248
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD:usize = 1e9 as usize + 7;

fn main() {
    input!{
      h: usize,
      w: usize,
      aa: [chars; h],
    }
    let mut dp = vec![vec![0; w]; h];
    dp[0][0] = 1;

    for i in 0..h {
        for j in 0..w {
            if i+1 < h && aa[i+1][j] == '.' {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] = dp[i+1][j] % MOD;
            }
            if j+1 < w && aa[i][j+1] == '.' {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] = dp[i][j+1] % MOD;
            }
        }
    }
    println!("{}", dp[h-1][w-1]);
}


Measured memory_bytes: 16636
h,w = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
d = [[0]*w for _ in range(h)]
def nxt(i,j):
  if i%2 == 0 and j == w-1:
    return i+1,j
  elif i%2 == 1 and j == 0:
    return i+1,j
  elif i%2 == 0:
    return i,j+1
  else:
    return i,j-1
i,j = 0,0
cnt = 0
ans = []
while True:
  k,l = nxt(i,j)
  if k == h:
    break
  if a[i][j] % 2 == 1:
    cnt += 1
    a[k][l] += 1
    ans.append([i+1,j+1,k+1,l+1])
  i,j = k,l
print(cnt)
for l in ans:
  print(*l)

Measured memory_bytes: 32280
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MAX 100000000
#define pb push_back
using namespace std; 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
  
int main(){
  int n,m;
  int x,y,c,t;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0){
      break;
    }
    int C[m][m],T[m][m];
    for(int i = 0;i < m;i++){
      for(int j = 0;j < m;j++){
	T[i][j] = MAX;
	C[i][j] = MAX;
      }
    }
    for(int i = 0;i < n;i++){
      cin >> y >> x >> c >> t;
      y--;x--;
      C[y][x] = c;
      C[x][y] = c;
      T[y][x] = t;
      T[x][y] = t;
    }
    for(int k = 0;k < m;k++){
      for(int i = 0;i < m;i++){
	for(int j = 0;j < m;j++){
	  if(T[i][k] != MAX && T[k][j] != MAX){
	    T[i][j] = min(T[i][j],T[i][k] + T[k][j]);
	  }
	  if(C[i][k] != MAX && C[k][j] != MAX){
	    C[i][j] = min(C[i][j],C[i][k]+C[k][j]);
	  }
	}
      }
    }
    int a;
    cin >> a;
    for(int i = 0;i < a;i++){
      int p,q,r;
      cin >> p >> q >> r;
      p--;q--;
      int minc = MAX,mint = MAX;
      if(r == 1){
	P(T[p][q]);
      }else if(r == 0){
	P(C[p][q]);
      }
    }
  }
  return 0;
}

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

long a, b, c, k;
int main() {
  cin >> a >> b >> c >> k;
  long sum = 0;
  sum += min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  sum -= min(c, k);
  cout << sum << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  set<int> A,B,C;

  int s;
  cin>>s;
  cin>>s;
  for(int i=0,a;i<s;i++) cin>>a,A.insert(a);
  cin>>s;
  for(int i=0,a;i<s;i++) cin>>a,B.insert(a);
  cin>>s;
  for(int i=0,a;i<s;i++) cin>>a,C.insert(a);

  //for(int p:C) cout<<p<<endl;
  
  for(int p:A)
    if(!B.count(p) && C.count(p)) C.erase(p);

  //for(int p:C) cout<<p<<endl;
  
  cout<<C.size()<<endl;
  
  return 0;
}

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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

const int MX = 1e5+5;
LL inp[MX], freq[MX];

int main() {
	LL n,q;
	LL sum = 0;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> inp[i];
		freq[inp[i]]++;
		sum += inp[i];
	}

	LL b,c;
	cin >> q;
	while(q--) {
		cin >> b >> c;
		LL diff = (c-b);

		sum += diff * freq[b];

		freq[c] += freq[b];
		freq[b] = 0;

		cout << sum << endl;
	}

	return 0;
}


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

typedef long long int ll;

int main(){
    int b;
    while(cin >> b, b){
        for(ll l=(1<<20); l>=0; l--){
            ll bunshi = b-l*(l+1)/2;
            ll bunbo = l+1;
            if(bunshi>0 && bunshi%bunbo == 0){
                cout << bunshi/bunbo << " " << l+1 << endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007

int main (){
    int n,m;
    bool flag=true;
    cin >> n >> m;
    vector<int>a(n,0);
    vector<bool>b(n,false);
    rep(i,m){
        int s,c;
        cin >> s >> c;
        if(b[s-1]==false){
            a[s-1]=c;
            b[s-1]=true;
        }else if(b[s-1]==true&&a[s-1]==c) continue;
        else flag=false;
    }
    if(flag){
        if(b[0]==false&&n!=1) a[0]=1; 
    }
    if(flag){
        if(n!=1&&a[0]!=0)rep(i,n) cout << a[i];
        else if(n==1) cout << a[0];
        else if(n!=1&&a[0]==0) cout << -1;
        cout << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    double x1,y1,x2,y2,x3,y3,x4,y4,d;
    while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
        d=(x2-x1)*(x4-x3)+(y2-y1)*(y4-y3);
        
        if(abs(d)<1E-10&&((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))&&((x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)))cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll d[100010][109],n;
vector<pair<ll, ll> > v;

ll dp(ll w, ll ind) {

    if(w<0)
        return -inf;

    if(ind>=n)
        return 0;

    if(d[w][ind]!=-inf)
        return d[w][ind];

    return d[w][ind] = max(dp(w, ind+1), v[ind].s + dp(w-v[ind].f, ind+1));
}

int main()
{
   ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll w;
    cin>>n>>w;
    for(ll i=1; i<=n; i++) {
        ll x,y;
        cin>>x>>y;
        v.push_back({x, y});
    }
    for(ll i=0; i<=100000; i++) {
        for(ll j=0; j<=n; j++)
            d[i][j] = -inf;
    }

    cout<<dp(w, 0)<<"\n";

    return 0;
}


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

int main(){
int h,n,t=0;
int a;
cin >> h>>n;
rep(i,n){cin>>a;
    t +=a;
    }
    if(t >=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,M,a,b,res=0,now=1;
  P arr[100001];
  cin >> N >> M;
  REP(i,M){
    cin >> a >> b;
    arr[i] = P(a,b);
  }
  sort(arr,arr+M,cmp);
  for(int i=0;i<M;i++){
    if(arr[i].second > now && arr[i].first >= now){
      now = arr[i].second;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



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

int main()
{
	int n;
	char t[100], a[100];
	
	while (cin >> n, n){
		for (int i = 0; i < n; i++){
			cin >> t[i] >> a[i];
		}
		int m;
		string s;
		cin >> m;
		for (int i = 0; i < m; i++){
			char c;
			
			cin >> c;
			
			for (int j = 0; j < n; j++){
				if (c == t[j]){
					c = a[j];
					break;
				}
			}
			
			s += c;
		}
		
		cout << s << endl;
	}
	
	return (0);
}

Measured memory_bytes: 1324
n,y=map(int,input().split())
count=0
for a in range(n+1):
    for b in range(n+1-a):
            if 10000*a+5000*b+1000*(n-b-a)==y:
                print(a,b,n-a-b)
                count=count+1
                break
    else:
        continue
    break
if count==0:
    print(-1,-1,-1)
else:
    pass

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    string s;
    cin >> s;
    intl cnt_r = 0; 
    intl cnt_g = 0; 
    intl cnt_b = 0;
    rep(i,n){
        cnt_r += (s[i] == 'R');
        cnt_g += (s[i] == 'G');
        cnt_b += (s[i] == 'B');
    }
    intl ans = cnt_r * cnt_g * cnt_b;
    rep(i,n){
        repi(j,i + 1,n){
            if(s[i] == s[j])continue;
            bool r = ((s[i] == 'R')||(s[j] == 'R'));
            bool g = ((s[i] == 'G')||(s[j] == 'G'));
            bool b = ((s[i] == 'B')||(s[j] == 'B'));
            intl idx = 2 * j - i;
            if(!r)ans -= (s[idx] == 'R');
            else if(!g)ans -= (s[idx] == 'G');
            else ans -= (s[idx] == 'B');

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

Measured memory_bytes: 3588
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
int n,m,k;

using ll = long long;
const int mod = 1e9 + 7;
int fac[N], finv[N];

ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init_fac_mod(int nima){
    //only when mod is prime
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= nima; ++i)
        fac[i]=(ll)fac[i-1]*i%mod;
    finv[nima] = quick_pow(fac[nima], mod-2);
    for(int i = nima-1; i; --i)
        finv[i] = (ll)finv[i+1]*(i+1)%mod;
}

int c(int n, int m){
    //n!/(m!(n-m)!)
    return ((ll)((ll)fac[n] * finv[m] % mod) * finv[n - m] )% mod;
}

int c_2(int n, int m){
    ll res = 1;
    for (int i = 0; i < n; i++){
        (res *= n-i)%=mod;
        (res/= i+1)%=mod;
    }
    return res;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m>>k;
    
    
    ll d = 0;
    for (int i = 1; i < n; i++){
        d += (ll)i*(n-i)%mod*m%mod*m%mod;
        d%= mod;
    }
    
    for (int i = 1; i < m; i++){
        d += (ll)i*(m-i)%mod*n%mod*n%mod;
        d %= mod;
    }
    
    init_fac_mod(n*m-2);
    cout<<d*c(n*m-2, k-2)%mod<<endl;
    
    
    
    
    return 0;
}



Measured memory_bytes: 1792
num = int(input())
t = [int(n) for n in input().split()]
t = sorted(t)

valid = True

if num % 2 == 1: # odd
  check = list(range(0,num+1,2))[1:]
  
  valid1 = t[0] == 0
  valid2 = check == t[2::2] # even, skip first
  valid3 = check == t[1::2] # odd
  valid = valid1 and valid2 and valid3
  
  if not valid:
    print(0)
  else:
    ans = 2**((num-1)//2) % (10**9 + 7)
    print(ans)
  
else: # even 
  check = list(range(1,num,2))
  
  valid1 = True
  valid2 = check == t[::2] # even
  valid3 = check == t[1::2] # odd
  valid = valid1 and valid2 and valid3
  
  if not valid:
    print(0)
  else:
    ans = 2**((num)//2) % (10**9 + 7)
    print(ans)


  
  

Measured memory_bytes: 20456