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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;  cin >> s;
    vector<int> a(26);
    rep(i, s.size()) {
      a[s[i] - 'a']++;
    }
    rep(i, 26) {
      if (a[i] == 0) {
        char c;
        c = i + 'a';
        cout << c << '\n';
        return 0;
      }
    }
    cout << "None" << '\n';

    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
#define srep(i, j, k) for (int i = j; i < k; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

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; }

//�G���g�X�e�l�X���
vector<int> estora(vector<int> num) {
    int sel = 0;
    while (sel < num.size()) {
        int d = num[sel];
        for (int i = 0; i < num.size(); i++) {
            if (num[i] % d == 0 && num[i] != d && d != 1) {
                num.erase(num.begin() + i);
                i--;
            }
        }
        sel++;
    }
    return num;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
//i����ɑf���ɂ��Ă����Ȃ��Ƃ��܂��ł��Ȃ�&&�v�Z�ʃ��o�C
//�G�X�g���l�X��⿂őf����U����Ă����K�v�������肻��
vector<ll> fac(ll n, vector<ll> num) {
    ll kazu = n;
    for (int i = 2; i <= n; i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1)
        num[n]++;
    return num;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return num;
}
const int INF = 1001001001;

//mint�p�̒萔 (10��9�� + 7)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = n / x;
    if (n % x != 0)ans++;
    cout << ans * t;
    return 0;
}

Measured memory_bytes: 3628
# coding: utf-8
N, K = gets.split.map {|e| e.to_i}
h = gets.split.map {|e| e.to_i}

h.sort!.reverse!

K.times do |i|
  h.shift
end

if h.size == 0
  puts 0
else
  puts h.reduce(&:+)
end
            






Measured memory_bytes: 17648
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n);
	VLL bs;
	bool flag = true;
	rep(i, 1, n+1) {
		bs.push_back(scanLong());
		if(bs[i-1] > i)	flag = false;
	}
	if(!flag) {
		puts("-1");
		return 0;
	}
	VLL res;
	while(!bs.empty()) {
		rep(i, bs.size()+1, 1ll) {
			if(bs[i-1] == i) {
				bs.erase(bs.begin()+i-1);
				res.push_back(i);
				break;
			}
		}
	}

	rep(it, res.rbegin(), res.rend())	pll(*it), nl;

}


Measured memory_bytes: 256
#include <stdio.h>
long long gcd(long long a,long long b)
{
	long long n=a%b;
	while(n!=0)
	{
		a=b;
		b=n;
		n=a%b;
	}
	return b;
}
int main()
{
	long long i,n,m;
    long long ans=1;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&m);
		ans=ans/gcd(ans,m)*m;
	}
	printf("%lld\n",ans);
}

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


int prime[60000];


void sieve(){
	memset(prime, 1, sizeof prime);
	int i;
	for(i = 2;i*i <= 60000;i++){
		if(prime[i]){
			for(int j = 2;i*j <= 60000;j++){
				prime[i*j] = 0;
			}
		}
	}
}


int main(){
	int n;
	sieve();
	while (cin >> n){
		for(int i = n-1;;i--){
			if(prime[i]){
				cout << i << ' ';
				break;
			}
		}
		for(int i = n+1;;i++){
			if(prime[i]){
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 3288
N = int(input())
S = input()
cnt = 0
pin = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            pin.append(str(i) + str(j) + str(k))

for i in range(1000):
    one = S.find(pin[i][0])
    two = S.find(pin[i][1], one + 1)
    three = S.find(pin[i][2], two + 1)
    if one != -1 and two != -1 and three != -1:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,W;
  cin >> N >> W;
  vector<int> w(N),v(N);
  for (int i=0;i<N;i++){
    cin >> w[i] >> v[i];
  }
  vector<vector<long long>> dp(N+1,vector<long long>(100010,1000000007));
  dp[0][0]=0;
  for (int i=0;i<N;i++){
    for (int sum=0;sum<100010;sum++){
      if (sum>=v[i]){
        dp[i+1][sum]=min(dp[i][sum],dp[i][sum-v[i]]+w[i]);
      }
      else {
        dp[i+1][sum]=dp[i][sum];
      }
    }
  }
  int ans=0;
  for (int V=0;V<100010;V++){
    if (dp[N][V]<=W){
      ans=V;
    }
  }
  cout << ans << endl;
}

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

public class Main {

    private static PrintWriter out = new PrintWriter(System.out);
    private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) throws IOException {

        st = new StringTokenizer(in.readLine());

        long A = Long.parseLong(st.nextToken());
        long B = Long.parseLong(st.nextToken());
        long C = Long.parseLong(st.nextToken());

        long count = 0, a, b, c;

        while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {


            if (A == B && B == C) {

                out.println(-1);
                out.flush();
                return;
            }
            
            a = A; b = B; c = C;
            
            A = (b + c) / 2;
            B = (a + c) / 2;
            C = (a + b) / 2;

            count++;
        }

        out.println(count);
        out.flush();
    }
}

Measured memory_bytes: 22996
MAX_INT = 10000000
N, T = map(int, input().split())
cl, tl = [], []

for i in range(N):
    c, t = map(int, input().split())
    cl.append(c)
    tl.append(t)

c_min = MAX_INT
for i in range(N):
    if tl[i] <= T:
        c_min = min(c_min, cl[i])

if c_min < MAX_INT:
    print(c_min)
else:
    print('TLE')

Measured memory_bytes: 3316
import numpy as np


def solve(n):
    if n in [1, 2]:
        return np.array([])
    res = np.array([["."] * n for _ in range(n)])
    block_5 = np.array([
        ["a", "a", "b", "b", "c"],
        ["d", "e", "e", ".", "c"],
        ["d", ".", ".", "f", "g"],
        ["h", ".", ".", "f", "g"],
        ["h", "i", "i", "j", "j"]
    ])
    if n == 5:
        return block_5
    if n == 10:
        res[0:5, 0:5] = block_5
        res[5:10, 5:10] = block_5
        return res
    block_3 = np.array([
        ["a", "a", "."],
        [".", ".", "a"],
        [".", ".", "a"]
    ])
    if n % 3 == 0:
        for i in range(0, n, 3):
            res[i:i + 3, i:i + 3] = block_3
        return res
    res_4 = 0
    res_7 = 0
    res_9 = 0
    if n % 4 == 0:
        res_4 = n // 4
    elif (n - 7) % 4 == 0 and n >= 7:
        res_4 = (n - 7) // 4
        res_7 = 1
    elif (n - 14) % 4 == 0 and n >= 14:
        res_4 = (n - 14) // 4
        res_7 = 2
    elif (n - 21) % 4 == 0 and n >= 21:
        res_4 = (n - 21) // 4
        res_7 = 3
    elif n == 13:
        res_4 = 1
        res_9 = 1
    elif n == 17:
        res_4 = 2
        res_9 = 1
    else:
        print(Error)

    block_4 = np.array([
        ["a", "b", "c", "c"],
        ["a", "b", "d", "d"],
        ["e", "e", "f", "g"],
        ["h", "h", "f", "g"],
    ])

    block_7 = np.array([
        [".", ".", "a", "b", "c", ".", "."],
        [".", ".", "a", "b", "c", ".", "."],
        ["d", "d", "e", "e", ".", "f", "f"],
        ["g", "g", ".", ".", "h", "i", "i"],
        ["j", "j", ".", ".", "h", "k", "k"],
        [".", ".", "l", "m", "n", ".", "."],
        [".", ".", "l", "m", "n", ".", "."]
    ])

    block_9 = np.array([
        ["a", "a", "b", "b", "c", "c", ".", ".", "."],
        ["d", "d", "e", "e", "f", "f", ".", ".", "."],
        ["g", "g", "h", "h", "i", "i", ".", ".", "."],
        [".", ".", ".", ".", ".", ".", "j", "k", "l"],
        [".", ".", ".", ".", ".", ".", "j", "k", "l"],
        [".", ".", ".", ".", ".", ".", "m", "n", "o"],
        [".", ".", ".", ".", ".", ".", "m", "n", "o"],
        [".", ".", ".", ".", ".", ".", "p", "q", "r"],
        [".", ".", ".", ".", ".", ".", "p", "q", "r"]
    ])

    base = 0
    for i in range(res_4):
        res[base:base + 4, base:base + 4] = block_4
        base += 4
    for i in range(res_7):
        res[base:base + 7, base:base + 7] = block_7
        base += 7
    for i in range(res_9):
        res[base:base + 9, base:base + 9] = block_9
        base += 9

    return res


def main():
    n = int(input())
    res = solve(n)
    if res.shape[0] == 0:
        print(-1)
    else:
        for i in range(res.shape[0]):
            print("".join(list(res[i, :])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 26104
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

int gcd(int a, int b){
	return a%b?gcd(b,a%b):b;
}

signed main() {
  INIT;
	VAR(int,n);
	VEC(int,a,n);
	int ans = a[0];
	REP(i, n){
		ans = min(ans, gcd(ans, a[i]));
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
a = input()

red = a.count("R")
whi = a.count("W")
l_red = 0
l_whi = 0

ans = min(l_whi, red) + abs(l_whi - red)
for i in range(N):
  if a[i] == "R":
    l_red += 1
    red -= 1
  else:
    l_whi += 1
    whi -= 1
  if min(l_whi, red) + abs(l_whi - red) < ans:
    ans = min(l_whi, red) + abs(l_whi - red)
print(ans)
  

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

/*int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << sqrt(pow((x1-x2),2)+pow((y1-y2),2)) << endl;
    return 0;
}

int main(){
    double a,b,c,S,L,h;
    double PI = acos(-1);
    cin >>a>>b>>c;
    S=a*b*sin(c*PI/180.0)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(c*PI/180.0));
    h=2*S/a;
    cout << fixed << setprecision(8) << S << endl << L << endl << h <<endl;
}

int main(){
    int n;
    while(cin >> n&&n!=0){
        double m=0,aa=0;
        vector<int> s(n);
        for(int i=0;i<n;i++){
            cin >> s.at(i);
            m+=s.at(i);
        }
        m=m/n;
        for(int i=0;i<n;i++){
            aa+=pow((s.at(i)-m),2);
        }   
        aa=aa/n;
        cout <<fixed<<setprecision(8)<< sqrt(aa) << endl;
    }
    return 0;
}*/

double mincos(vector<int> x,vector<int> y,int p){
    double D;
    for(int i=0;i<x.size();i++){ 
        if(x.at(i)>=y.at(i)){
        D+=pow((x.at(i)-y.at(i)),p);
        }
        else{
            D+=pow((y.at(i)-x.at(i)),p);
            }
    }
    return pow(D,1.0/p);
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for(int i=0;i<n;i++){
        cin >> x.at(i);
    }
    for(int i=0;i<n;i++){
        cin >> y.at(i);
    }
    vector <double> m(n);
    for(int i=0;i<n;i++){
        if(x.at(i)>=y.at(i)) m.at(i)=x.at(i)-y.at(i);
        else m.at(i)=y.at(i)-x.at(i);
    }
    sort(m.begin(),m.end());
    reverse(m.begin(),m.end());
    cout<<fixed<<setprecision(8)<<mincos(x,y,1)<<endl<<mincos(x,y,2)<<endl<<mincos(x,y,3)<<endl<<m.at(0)<<endl;
    return 0;
}


Measured memory_bytes: 3456
// ITP1_10_D Distance2
import java.io.*;

public class Main {
   public static void main(String[] args) {
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

      try{
         int n = Integer.parseInt(br.readLine());
         int[] x = new int[n];
         int[] y = new int[n];
         String strx[] = br.readLine().split(" ");
         for (int i = 0; i < n ;i++)
            x[i] = Integer.parseInt(strx[i]);

         String stry[] = br.readLine().split(" ");
         for (int i = 0; i < n; i++)
            y[i] = Integer.parseInt(stry[i]);

         minkowski(n, x, y);
      }

      catch (Exception e) {
         e.printStackTrace();
      }
   }

   private static void minkowski(int n, int[] x, int[] y) {
      double D1 = 0;
      double D2 = 0;
      double D3 = 0;
      double Dmax = 0;

      for (int i = 0; i < n; i++) {
         D1 += Math.abs(x[i] - y[i]);
         D2 += Math.pow(Math.abs(x[i] - y[i]), 2);
         D3 += Math.pow(Math.abs(x[i] - y[i]), 3);
         if (Dmax < Math.abs(x[i] - y[i]))
            Dmax = Math.abs(x[i] - y[i]);
      }

      System.out.println(D1);
      System.out.println(Math.sqrt(D2));
      System.out.println(Math.cbrt(D3));
      System.out.println(Dmax);
   }
}

Measured memory_bytes: 17092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector> // vectorを使うためにインクルードする
using namespace std;

int main() {
	int n;
	char a[50];
	float b;

	scanf("%d", &n);
	float sum = 0.0;

	for (int i = 0; i <n ;i++) {
		scanf("%f",&b);
		//printf("%f ", b);
		scanf("%s",a);
		//printf("%s", a);
		if (a[0]=='J') {
			sum += b;
		}
		else if (a[0]== 'B') {
			sum += b* 380000.0;
		}
		
	}
	printf("%f", sum);
}

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

ll N, T;
vector<ll> t;

int main() {
    cin >> N >> T;
    t.resize(N);
    for (int i = 0; i < N; i++) scanf("%Ld", &t[i]);
    ll sum = t[N-1] + T;
    for (int i = 0; i < N-1; i++) sum -= max((ll)0, t[i+1] - t[i] - T);
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

int gcd(int x, int y) {
    if (x < y) {
        swap(x, y);
    }
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

vector<int> xs;

int main(void) {
    int N, X;
    cin >> N >> X;

    xs.resize(N);
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        xs[i] = abs(x - X);
    }

    int ans = xs[0];
    for (int i = 1; i < N; i++) {
        ans = gcd(xs[i], ans);
    }

    cout << ans << endl;

    return 0;
}


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

const string YES = "Yes";
const string NO = "No";
/*
void solve(std::string S, std::string T){
    set<ll> s, t;
    for(ll i = 0; i < S.size(); ++i){
        if(S[i] != T[i]){
            s.insert(S[i]);
            t.insert(T[i]);
        }
    }
    if(s.size() > t.size()) cout << NO << endl;
    else cout << YES << endl;
}
*/

void solve(std::string S, std::string T){
    bool check = true;
    map<char, char> m, rm;
    for(int i = 0; i < S.size(); ++i){
        if(m.count(S[i])) if(m[S[i]] != T[i]) check = false;
        if(rm.count(T[i])) if(rm[T[i]] != S[i]) check = false;
        m[S[i]] = T[i];
        rm[T[i]] = S[i];
    }
    if(check) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


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

from itertools import product

N = int(input())

cnt = 0
# 候補となりうる10桁までの数字を列挙
for prod in product(['0', '3', '5', '7'], repeat=10):
    # チェック用に変形
    num = int(''.join(prod))
    s = str(num)
    # 753数ではない
    if (s.find('3') == -1 or s.find('5') == -1
            or s.find('7') == -1 or s.find('0') != -1):
        continue
    # N以下ではない
    if num > N:
        continue
    cnt += 1
print(cnt)


Measured memory_bytes: 44464
#include <stdio.h>
int main(void)
{
    int N, M, sum_days = 0;
    scanf("%i %i", &N, &M);
    for (int i = 0; i < M; i++)
    {
        int days;
        scanf("%i", &days);
        sum_days += days;
    }

    printf("%i\n", N >= sum_days ? N - sum_days : -1);
    return 0;
}

Measured memory_bytes: 1736
x=range(int(input()),0,-1)
P=[]
for _ in x:P+=[[int(i) for i in input().split()]]
P+=[P[0]]
for j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]
print(_*0.5-0.5)

Measured memory_bytes: 7732
#include<bits/stdc++.h>
using namespace std;
int H,W;
char t[100][100];
int main(){
  cin>>H>>W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>t[i][j];
    }
  }
  int ans=0;
  for(int i=1;i<H;i++){
    for(int j=0;j<W;j++){
      if(t[i][j]!='-')continue;
      bool flg=true;

      for(int di=-1;di<=1;di++)
        for(int dj=-1;dj<=1;dj++)
          if(0<=i+di&&i+di<H)
            if(0<=j+dj&&j+dj<W)
              if(t[i+di][j+dj]=='x'||(di==0&&t[i+di][j+dj]=='o'))
                flg=false;
      if(flg)ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

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

    ll index_a,index_z;
    rep(i,s.size()){
        if(s[i]=='A'){
            index_a=i;
            break;
        }
    }
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='Z'){
            index_z=i;
            break;
        }
    }

    cout<<index_z-index_a+1<<endl;

    return 0;
}

Measured memory_bytes: 3700
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(long int *)a - *(long int *)b;
}

int main(void)
{
	//変数の宣言
	int n;
	signed long int array[200010];
	long int mid;
	int i;
	long int ans=0;
	
	//データの読み込み
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%ld",&array[i]);
	}
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	
	
	//実際の処理
	
	for(i=0;i<n;i++){
		array[i]=array[i]-i-1;
	}
	
	qsort(array, n, sizeof(long int), asc);
	
	mid=array[(n-1)/2];
	
	for(i=0;i<n;i++){
		array[i]=array[i]-mid;
		array[i]=abs(array[i]);
		ans=ans+array[i];
	}
		
//	printf("計算部分終了\n");
	
	//出力
	
	printf("%ld",ans);
	
	
//	printf("結果の出力終了\n");
	
	return 0;
}


Measured memory_bytes: 3324
#include <cstdio>
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    char s[7];
    int l = 0, r = n - 1;
    printf("%d\n", l);
    fflush(stdout);
    scanf("%s", s);
    char ch = s[0];
    if (s[0] == 'V') return 0;
    while (1){
        int mid = (l + r + 1) / 2;
        printf("%d\n", mid);
        fflush(stdout);
        scanf("%s", s);
        if (s[0] == 'V') return 0;
        else if ((s[0] == ch && mid % 2 == 0) ||
                 (s[0] != ch && mid % 2)){
                    l = mid;
                 }
        else r = mid;
    }
}


Measured memory_bytes: 760
n, m = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map{|ai| [1, ai.to_i] }
m.times do
  b, c = gets.chomp.split.map(&:to_i)
  a << [b, c]
end

a = a.sort_by{|ai| -ai[1]}

sum = 0
a.each do |count, num|
  if count >= n
    sum += n * num
    break
  else
    sum += count * num
    n -= count
  end
end

puts(sum)

Measured memory_bytes: 33848
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import math


def get_rank(x, n):
    rank = 0
    for i in range(n):
        head_x = x[i]
        x_list = list(x[i:])
        ways = math.factorial(len(x_list))
        sorted_x_list = sorted(x_list)
        number = sorted_x_list.index(head_x)
        rank += (ways/len(x_list))*number
    return int(rank)


print(abs(get_rank(p, n) - get_rank(q, n)))

Measured memory_bytes: 3064
n = int(input())
s = [0] * n
inc = []
zeros = []
dec = []

for i in range(n):
    s[i] = input()
    start = 0
    minimum = 0
    now = 0
    for c in s[i]:
        if c == '(':now += 1
        else: now -= 1
        minimum = min(minimum, now)
    end = now
    
    if end == 0:
        zeros.append((minimum, i))
    elif start < end:
        inc.append((minimum, i))
    else:
        minimum = minimum - end
        dec.append((minimum, i))

inc.sort(reverse=True)
dec.sort()


now = 0
for (m, i) in inc:
    for c in s[i]:
        if c == '(':now += 1
        else: now -= 1
        if now < 0:
            print("No")
            exit()
        
for (m, i) in zeros:
    for c in s[i]:
        if c == '(':now += 1
        else: now -= 1
        if now < 0:
            print("No")
            exit()

for (m, i) in dec:
    for c in s[i]:
        if c == '(':now += 1
        else: now -= 1
        if now < 0:
            print("No")
            exit()

if now != 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 203756
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n;
char s[10];
int main() {
//	freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) if (s[i]=='7') { printf("Yes\n"); return 0; }
	printf("No\n");
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll a,b,ans=0;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    int temp=i;
    bool ok=true;
    vector<int> v;
    while(temp){
      v.push_back(temp%10);
      temp/=10;
    }
    rep(j,v.size()){
      int n=v.size();
      if(v[j]!=v[n-1-j]){
        ok=false;
      }
    }
    if(ok){
      ans++;
    }
  }
  cout << ans << endl;
return 0;}

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

int main()
{
    int A, B, K;
    cin >> K >> A >> B;

    int i = 0;
    bool flag = false;

    while (K * i <= B)
    {
        if (K * i >= A)
        {
            flag = true;
        }
        i++;
    }

    if (flag)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
}


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

string Str;
int Q,t,f;
char c;
bool rev = false;
int main() {
  cin >> Str >> Q;
  for (size_t i = 0; i < Q; i++) {
    cin >> t;
    if (t == 1) {
      rev = !rev;
    }else{
      cin >> f >> c;
      if ((f == 1 && !rev) || (f == 2 && rev)) {
        Str.insert(Str.begin(),c);
      }else{
        Str.push_back(c);
      }
    }
  }
  if (rev) {
    reverse(Str.begin(),Str.end());
  }
  cout << Str << endl;
  return 0;
}


Measured memory_bytes: 900
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while(true) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			
			if (h == 0 && w == 0) {
				scanner.close();
				return;
			}
			
			for(int j = 0; j < w; j++) {
				System.out.print("#");
			}
			System.out.println();
			for(int i = 0; i < h - 2; i++) {
				System.out.print("#");
				for(int j = 0; j < w - 2; j++) {
					System.out.print(".");
				}
				System.out.print("#");
				System.out.println();
			}
			for(int j = 0; j < w; j++) {
				System.out.print("#");
			}
			System.out.println();
			System.out.println();
		}
	}
}



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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int x; cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
    long long int x,k,d;
    cin>>x>>k>>d;
    if(x<0)
    x=(-x);
    long long int temp = x/d;
        long long int ans=1e18;
        if(temp<k)
        {
            ans=min(ans,abs(x-temp*d-((k-temp)%2)*d));
        }
        else
        ans=min(ans,abs(x-k*d));
    cout<<ans;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

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

	int begin=-1,end=-1;
	array<int,26> arr;
	arr.fill(0);
	if(str.size()==2){
		if(str[0]==str[1]){
			begin=1;
			end=2;
		}
	}
	else if(str.size()>2){
		for(int i=0;i<3;++i){
			++arr[str[i]-'a'];
		}
		for(const auto& val:arr){
			if(val>1){
				begin=1;
				end=3;
			}
		}

		if(begin<0 && end<0){
			for(int i=0;i<str.size()-3;++i){
				--arr[str[i]-'a'];
				++arr[str[i+3]-'a'];
				for(const auto& val:arr){
					if(val>1){
						begin=i+1+1;
						end=i+1+2+1;
						break;
					}
				}
				if(begin>0)break;
			}
		}
	}

	cout<<begin<<" "<<end<<endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 512
XYZ = list(map(int, input().split()))
tmp = XYZ[0]
XYZ[0] = XYZ[1]
XYZ[1] = tmp
tmp = XYZ[0]
XYZ[0] = XYZ[2]
XYZ[2] = tmp
print(" ".join(str(n) for n in XYZ))

Measured memory_bytes: 8932
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ll a[5];
  	for(ll i = 0 ; i < 5 ; i++ ) cin >> a[i];
  	for(ll i = 0 ; i < 5 ; i++ ) 
      	if(a[i] == 0 ) {
        	cout << i + 1;
          	return 0;
        }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,x;
  cin >> n >> x;
  vi l(n+1,0);
  REP(i,n) cin >> l[i];
  int d = 0;
  int ans = 0;
  while(ans<n+1&&d<=x){
    d += l[ans++];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef CLASS_MODINT
#define CLASS_MODINT

#include <cstdint>

template <std::uint32_t mod>
class modint {
private:
	std::uint32_t n;
public:
	modint() : n(0) {};
	modint(std::int64_t n_) : n((n_ >= 0 ? n_ : mod - (-n_) % mod) % mod) {};
	static constexpr std::uint32_t get_mod() { return mod; }
	std::uint32_t get() const { return n; }
	bool operator==(const modint& m) const { return n == m.n; }
	bool operator!=(const modint& m) const { return n != m.n; }
	modint& operator+=(const modint& m) { n += m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator-=(const modint& m) { n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
	modint& operator*=(const modint& m) { n = std::uint64_t(n) * m.n % mod; return *this; }
	modint operator+(const modint& m) const { return modint(*this) += m; }
	modint operator-(const modint& m) const { return modint(*this) -= m; }
	modint operator*(const modint& m) const { return modint(*this) *= m; }
	modint inv() const { return (*this).pow(mod - 2); }
	modint pow(std::uint64_t b) const {
		modint ans = 1, m = modint(*this);
		while (b) {
			if (b & 1) ans *= m;
			m *= m;
			b >>= 1;
		}
		return ans;
	}
};

#endif // CLASS_MODINT

#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
using modulo = modint<998244353>;
int main() {
	int N; string S;
	cin >> N >> S;
	int a = 0, b = 0, c = 0, num = 0;
	modulo way = 1;
	for (int i = 0; i < 3 * N; ++i) {
		vector<int> vp = { a, b, c };
		sort(vp.begin(), vp.end());
		if (S[i] == 'R') ++a;
		if (S[i] == 'G') ++b;
		if (S[i] == 'B') ++c;
		vector<int> vs = { a, b, c };
		sort(vs.begin(), vs.end());
		if (vp[0] != vs[0]) {
			way *= num;
			--num, --a, --b, --c;
		}
		else if (vp[1] != vs[1]) {
			way *= vp[2] - vp[1];
			++num;
		}
	}
	for (int i = 1; i <= N; ++i) way *= i;
	cout << way.get() << '\n';
	return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	int n;
	cin>>n;
	int x=1,y=10;
	int sum=0;
	while(x<n)
	{//cout<<x<<"!!!!!!!!!!!!!!!!!!!!"<<endl;
		if(n/x>0&&n/x<=10)
		{//cout<<"yes"<<endl;
			a=(n/x)*x;
			b=n-a;//cout<<a<<" "<<b<<endl;
			sum+=a/x;//cout<<sum<<endl;
			if(b<10)
			{//cout<<"&"<<endl;
				sum+=b;
				cout<<sum;
				return 0;
			}
			else
			{
				sum+=b%10;
				while(y<b)
				{//cout<<"a"<<endl;
					sum+=b%(y*10)/y;
					//cout<<sum<<"@@"<<endl;
					y*=10;
				}
			}
			cout<<sum;
			return 0;
		}
		else x*=10/*,cout<<"no"<<endl*/;
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
NList = []
for i in range(N):
  S = input()
  NList.append(S)

ans = NList.count("AC")
print("AC x ", str(ans))
ans = NList.count("WA")
print("WA x ", str(ans))
ans = NList.count("TLE")
print("TLE x ", str(ans))
ans = NList.count("RE")
print("RE x ", str(ans))

Measured memory_bytes: 16292
from collections import defaultdict
from math import gcd

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

d = {}
for a, b in X:
    if a == b == 0:
        pass
    elif a == 0:
        if b > 0:
            b = 1
        else:
            b = -1
    elif b == 0:
        if a > 0:
            a = 1
        else:
            a = -1
    else:
        v = gcd(a, b)
        a //= v
        b //= v

    if (a > 0 and b >= 0) or (a < 0 and b <= 0):
        pair = (abs(a), abs(b))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][0] += 1
    else:
        pair = (abs(b), abs(a))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][1] += 1

mod = 10 ** 9 + 7
zero = 0
ans = 1
for p in d:
    if p == (0, 0):
        zero = d[p][1]
    else:
        a, b = d[p]
        ans *= pow(2, a, mod) + pow(2, b, mod) - 1
        ans %= mod
        
print((ans + zero - 1) % mod)


Measured memory_bytes: 144432
h,w=map(int,input().split())
HW=[list(map(int,input().split())) for _ in range(h)]

ans=0
DP=[[0]*(w+2) for _ in range(h+2)]
for i in range(1,h+1):
    for j in range(1,w+1):
        if HW[i-1][j-1]==1:DP[i][j]=0
        else:
            DP[i][j]=min(DP[i-1][j-1],DP[i-1][j],DP[i][j-1])+1
            ans=max(ans,DP[i][j])

print(ans**2)


Measured memory_bytes: 55216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
#define INF 1007654321
#define PI 3.14159265358979
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repp(i, s, e) for(int i = (s); i <= (e); ++i)
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0)
template<typename T>
ostream& operator<<(ostream &os, const vector<T> &v) { for (auto x : v) os << x << " "; return os << "\n"; }
template<typename U, typename V>
ostream& operator<<(ostream &os, const pair<U, V> &p) { return os << "(" << p.first << "," << p.second << ")";}

int main() {
    ll K; cin >> K;
    ll q = K / 50, r = K % 50;
    int N = 50;
    vector<ll> A(N);
    rep(i, N) {
        A[i] = q + N - 1;
    }
    rep(i, N) {
        if(i < r) A[i] += N - r + 1;
        else A[i] -= r;
    }
    cout << N << "\n";
    rep(i, N) cout << A[i] << " ";
    cout << "\n";
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n;cin>>n;
  std::vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  int res=0;
  for(int i=1;i<n-1;i++){
    if(v[i-1]<v[i]&&v[i]<v[i+1]){
      res++;
    }
    else if(v[i+1]<v[i]&&v[i]<v[i-1]){
      res++;
    }
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
def calc_x(a, b, c, d, e, f)
  (e * c - b * f) / (a * e - b * d)
end

def calc_y(a, b, c, d, e, f)
  (c - a * calc_x(a, b, c, d, e, f)) / b
end

loop do
  s = gets
  break if s.nil?
  a, b, c, d, e, f = s.chomp.split.map(&:to_f)
  x = calc_x(a, b, c, d, e, f)
  y = calc_y(a, b, c, d, e, f)
  puts "#{'%.3f' % (x.zero? ? 0 : x)} #{'%.3f' % (y.zero? ? 0 : y)}"
end

Measured memory_bytes: 6140
public class Main {
	public static void  main(String[] args){
		 for(int x = 1 ; x < 10 ; x++ ){
			 for(int y = 1 ; y < 10 ; y++){
				 int z = x * y ;
			System.out.println(x+"x"+y+"="+z);
			 }
		 }
		
	}
}

Measured memory_bytes: 24144
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;
int main(void) {
  string s;
  lld q, o, f;
  char c;
  bool v = false;
  cin >> s >> q;
  deque<char> d(s.c_str(), s.c_str() + s.length());
  for (int i = 0; i < q; i++) {
    cin >> o;
    if (o == 1) {
      v = !v;
    } else {
      cin >> f >> c;
      if ((f == 1 && !v) || (f == 2 && v)) {
        d.push_front(c);
      } else {
        d.push_back(c);
      }
    }
  }
  if (v) {
    for (auto c = d.end() - 1; c >= d.begin(); c--) {
      cout << *c;
    }
  } else {
    for (auto c = d.begin(); c < d.end(); c++) {
      cout << *c;
    }
  }
  cout << "\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int h,w;
string s[105];
int main()
{
	cin>>h>>w;
	for (int i=1;i<=h;i++)
	{
		cin>>s[i];
	}
	for (int i=1;i<=h;i++)
	{
		int flag=1;
		for (int j=1;j<=w;j++)
		if (s[i][j-1]=='#') flag=0;
		if (flag)
		{
			h--;
			for (int j=i;j<=h;j++)
			s[j]=s[j+1];
			i--;
		}
	}
	for (int i=1;i<=w;i++)
	{
		int flag=1;
		for (int j=1;j<=h;j++)
		if (s[j][i-1]=='#') flag=0;
		if (flag)
		{
			w--;
			for (int j=1;j<=h;j++)
			for (int k=i;k<=w;k++)
			s[j][k-1]=s[j][k];
			i--;
		}
	}
	for (int i=1;i<=h;i++)
	{
		for (int j=0;j<=w-1;j++)
		cout<<s[i][j];
		cout<<endl;
	}
	return 0;
}

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

vector<vector<pair<int,int>>> g(100010);
int ans[100010];

bool used[100010];

void dfs(int v,int w){
    if(w%2==0) ans[v]=1;
    else ans[v]=0;
    for(auto i:g[v]){
        if(!used[i.first]){
            used[i.first]=true;
            dfs(i.first,i.second+w);
        }
    }
    

}

int main(){
    int n;
    cin>>n;
    int u,w,v;
    for(int i=0;i<n-1;i++){
        cin>>u>>v>>w;
        u--,v--;
        g[u].push_back(make_pair(v,w));
        g[v].push_back(make_pair(u,w));
    }
    
    dfs(0,0);
    for (int i = 0; i < n; i++)
    {
        cout<<ans[i]<<endl;
    }
    

    

}

Measured memory_bytes: 7680
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<numeric>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

ll K;
ll A[100000];

int main() {
	cin >> K;


	REP(i, K) {
		cin >> A[i];
	}

	if (A[K - 1] == 2) {
		pair<ll, ll> result({ 2, 3 });
		for (ll k = K - 2; k >= 0; k--) {
			//cout << result.first << " to " << result.second << endl;
			//cout << "A[k] = " << A[k] << endl;
			ll A_k = A[k];

			ll lower = (result.first + A_k - 1) / A_k;
			ll upper = result.second / A_k;

			//cout << "lower = " << lower << ", upper = " << upper << endl;
			if (lower > upper) {
				cout << -1 << endl;
				return 0;
			}
			else {
				result = pair<ll, ll>({ lower * A_k, (upper + 1) * A_k - 1 });
			}
		}

		cout << result.first << " " << result.second << endl;
		//system("pause");
		return 0;
	}
	else {
		cout << -1 << endl;
		return 0;
	}
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	long long  n;
	cin >> n;
	long long power = 1;
	for(long long i = 1; i <= n; i++) {
		power *= i;
		power = power % (1000000000 + 7);
	}
	cout << power << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main(){
    string s; cin >> s;
    stack<char> st;

    rep(i,s.length()){
        if(st.empty()) st.push(s[i]);
        else if(st.top() == 'S' && s[i] == 'T'){
            st.pop();
        }else st.push(s[i]);
    }
    cout << st.size();

}

Measured memory_bytes: 3832
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE
std::vector<bool> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return is_prime;
}

void solve(void)
{
  string str;
  cin>>str;
  str[3] = '8';
  cout<<str<<endl;

  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 1000


int main(void){
	int i,n;
	scanf("%d",&n);
	double p[n];
	
	for(i=0;i<n;i++){
		scanf("%lf",&p[i]);
	}
	double q[n+1];
	for(i=0;i<=n;i++){
		scanf("%lf",&q[i]);
	}
	
	double c[n+1][n+1];
	double d[n+1];
	c[0][0]=q[0];
	d[0]=p[0]+q[0];
	
	for(i=1;i<=n;i++){
		c[i][i]=q[i];
		c[i-1][i]=p[i-1]+(q[i-1]+q[i])*2;
		d[i]=d[i-1]+p[i]+q[i];
	}
	int j,k;
	double s,t;
	for (i=1; i<n; i++){
		for (j=0; j<n-i; j++) {
			s = c[j][j] + c[j+1][i+j+1];
				for (k=j; k<i+j; k++) {
					t = c[j][k+1] + c[k+2][i+j+1];
					if (s>t){
						s=t;
					}
				}
				c[j][i+j+1] = s + d[i+j] - d[j-1] + q[i+j+1];
			}
	}
	printf("%lf\n", c[0][n]);
	return 0;
}


Measured memory_bytes: 3756
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;cin>>s;
    ll k;cin>>k;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1'&&k>1){
            k--;
        }
        else{
            cout<<s[i]<<endl;
            return 0;
        }
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,s;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x;
		int c=x;
		while(c){
			if(c%2==0) s++,c/=2;
			else break;
		}
	}
	cout<<s<<endl; 
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    ll f[n+100];
    rep(0,i,n)f[i]=0;
    rep(1,i,n+1){
        for(ll j=i;j<=n;j+=i)++f[j];
    }
    rep(1,i,n)f[i]+=f[i-1];
    cout<<f[n-1];
}


Measured memory_bytes: 11448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
const ll MOD=1000000007;



int main() {
    ll N;
    cin>>N;
    vector<ll> buka(N,0);
    rep(i,N-1){
        ll a;
        cin>>a;
        a--;
        buka.at(a)++;
    }
    rep(i,N){cout<<buka.at(i)<<endl;}
}

Measured memory_bytes: 4784