akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int x, n;
	cin >> x >> n;
	if(n==0){
		cout << x;
		return 0;
	}
	int arr[n];
	for(int i=0; i<n; ++i){
		cin >> arr[i];
	}
	int a=x, pos;
	sort(arr, arr+n);
	for(int i=0; i<n; ++i){
		if(arr[i] <= x && (i==n-1 || arr[i+1]>x)){
			pos=i;
		}
	}
	for(int i=pos; i>=0; --i){
		if(arr[i] == a){
			a-=1;
		}
		else{
			break;
		}
	}
	int b=x;
	for(int i=pos; i<n; ++i){
		if(arr[i] == b){
			b+=1;
		}
		else{
			break;
		}
	}
	if(x-a<b-x){
		cout << a;
	}
	else if(b-x<x-a){
		cout << b;
	}
	else{
		cout << min(a,b);
	}
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	int t,x; cin>>t>>x;

	double ans=t*1.0/x;
	cout<<fixed<<setprecision(10)<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
def gcd(n,m):
  if n>m:
    return gcd(m,n);
  if n==0:
    return m;
  return gcd(m-n*(m//n),n)
 
def lcm(x, y):
    return (x * y) // gcd(x, y)
  
n=int(input())
a=list(map(int,input().split()))
s=1
for i in a:
  s=lcm(s,i)
ans=0
for i in a:
  ans+=s//i
print(ans % 1000000007)

Measured memory_bytes: 4084
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    string S;
    cin >> N >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for (ll i = 0; i < N / 2; i++) {
        if (S[i] != S[i + N / 2]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    if(N == 1){
        cout << "Yes" << endstr;
        cout << 2 << endstr;
        cout << "1 1" << endstr;
        cout << "1 1" << endstr;
        return 0;
    }
    ll k = -1;
    for (ll i = 2; i <= N; i++) {
        if(2*N == i*(i-1)){
            k = i; break;
        }
    }
    
    if(k == -1){
        cout << "No" << endstr; return 0;
    }
    
    vl cnt(N, 0); vvl ans(k, vl(k, 0));
    ll idx = 1;
    REP(i, k) FOR(j, i+1, k){
        ans[i][j] = idx; ans[j][i] = idx; idx++;
    }
    
    cout << "Yes" << endstr;
    cout << k << endstr;
    REP(i, k){
        cout << ans[i].size()-1 << " ";
        REP(j, ans.size()){
            if(i == j) continue;
            cout << ans[i][j] << " ";
        }
        cout << endstr;
    }
    return 0;
}


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

int main(){
    //a,b.c作成
    //charは多めに作成
    char a[3+1],b[3+1],c[3+1];
    scanf("%s\n%s\n%s",a,b,c);
    //123番目を出力.
    //charは1文字ずれる
    printf("%c%c%c\n",a[1-1],b[2-1],c[3-1]);
    //a,b,cの出力が終わったのであとはreturnをする.
    return 0;
}


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

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> list = new ArrayList<Integer>();

		for (int i = 0; i < 3;i++) {

			list.add(input());

		}

		Collections.sort(list);
		System.out.println(list.get(0) + " " + list.get(1) + " " + list.get(2));
		close();

	}

	public static int input() {

		return scanner.nextInt();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  int ex , val;
  cin >> ex >> val;
  if(ex==0)
  {
      if(val==100)cout << 101 << endl;
      else
      cout << val << endl;

  }
  else if(ex==1)
  {
      if(val==100)cout << 101*100 ;
      else
      cout << val*100;
    cout << endl;
  }
  else {
        if(val==100)
        cout << 101*10000 << endl;
  else
        cout << val*10000 << endl;}

    }


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

int INF = 1'000'000'000;

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<vector<int>> med(401, vector<int>(401, INF));
    queue<tuple<int, int, int>> que; 
    int a, b, c;
    for (int i = 0; i < n; i++){
        cin >> a >> b >> c;
        que.push(tie(a, b, c));
        for (int x = 0; x < 401; x++){
            for (int y = 0; y < 401; y++){
                int p = x + a;
                int q = y + b;
                int r = med[x][y] + c;
                if (med[x][y] != INF) que.push(tie(p, q, r));
            }
        }
        while (que.size() > 0){
            a = get<0>(que.front());
            b = get<1>(que.front());
            c = get<2>(que.front());
            que.pop();
            med[a][b] = min(med[a][b], c);
        }
    }
    int ans = INF;
    int x = 0;
    int y = 0;
    while (1){
        x += ma;
        y += mb;
        if (x > 400 || y > 400) break;
        ans = min(ans, med[x][y]);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
using namespace std;

char s[110][110];
bool gx[110], gy[110];
int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				gx[j] = true;
				gy[i] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (gy[i]) {
			for (int j = 0; j < w; j++) {
				if (gx[j]) {
					cout << s[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long all = 1l;
    long zero_or_nine_is_no = 2l;
    long both_is_no = 1l;
    for(int i = 0;i<n;i++){
      all *= 10l;
      all %= 2000000014l;
      zero_or_nine_is_no *= 9l;
      zero_or_nine_is_no %= 2000000014l;
      both_is_no *= 8l;
      both_is_no %= 2000000014l;
    }
    long ans = all - zero_or_nine_is_no + both_is_no;
    ans %= 1000000007l;
    System.out.println(ans);
  }
}


Measured memory_bytes: 35540
N = int(input())
S = str(input())
lst_for_ans = []
for i in range(len(S)+1):
       I_count = S[:i].count("I")
       D_count = S[:i].count("D")
       lst_for_ans.append(I_count - D_count)

print(max(max(lst_for_ans),0))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

bool cmp(pii a,pii b){
	return a.S<b.S;
}

int find(vector<int> &dp,int t){
	int hi=sz(dp)-1,lo=-1;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(dp[m]<=t) lo=m;
		else hi=m;
	}
	return hi;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b,c; cin>>a>>b>>c;
	cout<<max(0ll,c-(a-b))<<"\n";
	return 0;
}



























Measured memory_bytes: 764
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	
	double m,D,a2;
	
	int n;
	while(1){
		cin >> n;
		if (n==0) break;
		int s[n];
		m=0, a2=0, D=0;
		for (int i=0; i<n; i++){
			cin >> s[i] ;
			m+=s[i];
		}
		m/=n;
		for (int i=0; i<n; i++){
			a2+=pow(s[i]-m, 2);
		}
		a2/=n;
		D=sqrt(a2);
		printf("%.8f\n", D);
	}
	return 0;
}

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

namespace CSharp_TestCode
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] s = new int[N];
            for (int i = 0; i < N; i++)
            {
                s[i] = int.Parse(Console.ReadLine());
            }

            List<int> S = s.OrderBy(x => x).ToList();

            int sum = s.Sum();
            if (s.All(x => x % 10 == 0)) Console.WriteLine("0");
            else
            {
                for (int i = 0; i < N; i++)
                {
                    if (sum % 10 != 0) break;
                    if (S[i] % 10 != 0) sum -= S[i];

                }
                Console.WriteLine(sum);
            }
        }

    }
}

Measured memory_bytes: 13396
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define LOCAL_DEBUG
#include <bits/stdc++.h>
using namespace	std;

typedef unsigned long long		ull;
typedef long long				ll;
typedef long double				ld; // GCC - long double, but VS - double

template<typename T> using vv	= vector<vector<T>>;
template<typename T> using pp   = pair<T, T>;

#define fr(i, n)                for(int i = 0; i < n; ++i)
#define rep(i, a, b)            for(int i = a; i <= b; ++i)
#define all(a)                  a.begin(), a.end()
#define rall(a)                 a.rbegin(), a.rend()
#define pb                      push_back
#define nl                      '\n'
#define file(name1, name2)      freopen(name1, "r", stdin); freopen(name2, "w", stdout);
#define zp_v(v)                 for(int i = 0; i < v.size(); ++i) cin >> v[i]
#define zp_vv(v)                fr(i, v.size())fr(j, v[i].size()) cin >> v[i][j];
#define print_v(v)              for (auto& u : v){ cout << u << ' '; }
#define print_vv(v)             for (auto& u : v){ for (auto& q : u) cout << q << ' '; cout << nl;}

struct T
{
	int a, b, c;

	T(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {};
};

istream& operator >> (istream& in, T& a)
{
	in >> a.a >> a.b >> a.c;
	return in;
}

int main()
{
#ifdef LOCAL_DEBUG
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<T> v(n);
	zp_v(v);

	vector<T> dp(n);
	dp[0] = v[0];

	rep(i, 1, n - 1)
	{
		
		dp[i].a = dp[i - 1].c + v[i].a;
		dp[i].b = dp[i - 1].c + v[i].b;
		dp[i].a = max(dp[i].a, dp[i - 1].b + v[i].a);
		dp[i].c = dp[i - 1].b + v[i].c;
		dp[i].b = max(dp[i].b, dp[i - 1].a + v[i].b);
		dp[i].c = max(dp[i].c, dp[i - 1].a + v[i].c);
	}

	--n;
	cout << max(dp[n].a, max(dp[n].b, dp[n].c));
	return 0;
}

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

int main() {
  int N; cin >> N;
  ll A[N][N]; rep(i,0,N) rep(j,0,N) cin >> A[i][j];
  
  vector<vector<bool>> check(N,vector<bool>(N,true));
  ll ans =0;
  rep(k,0,N) {
    rep(i,0,N) {
      rep(j,0,N) {
        if (A[i][j] > A[i][k] + A[k][j]) {
          cout << -1 << endl; return 0;
        }
        if (A[i][j] == A[i][k] + A[k][j] && A[i][k] != 0 && A[k][j] != 0) {
          check[i][j] = false;
        }
      }
    }
  }
  
  rep(i,0,N) rep(j,i+1,N) {
    if (check[i][j]) ans += A[i][j];
  }
  
  cout << ans <<endl; 
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int N;

void dfs(string s, char max_c){
    if(s.length() == N){
        cout << s << endl;
    }
    else{
        for(char c = 'a'; c<= max_c; c++){
            if(c == max_c){
                dfs(s+c, max_c+1);
            }
            else{
                dfs(s+c, max_c);
            }
        }
    }
}

int main()
{
    cin >> N;

    dfs("",'a');
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int, int> ii;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e5 + 5;

int n, m, vis[maxn];
vector<int> G[maxn], a[2];

void dfs(int u, int x) {
    a[x].pb(u);
    for (auto v : G[u]) {
        if(vis[v]) continue;
        vis[v] = 1;
        dfs(v, x);
        break;
    }
}

int main() {
    //freopen("test.txt", "r", stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    int u, v;
    rep(i, 0, m) {
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    vis[u] = vis[v] = 1;
    dfs(u, 0);
    dfs(v, 1);
    reverse(all(a[0]));
    cout << SZ(a[0]) + SZ(a[1]) << endl;
    for (auto i : a[0]) cout << i << ' ';
    for (auto i : a[1]) cout << i << ' ';
}



Measured memory_bytes: 9720
import sys
from collections import deque

K = int(sys.stdin.readline())

q = deque()
for i in range(1, 10):
    q.append(i)

#count = 0
#while count <= K:
for _ in range(K):
    n = q.popleft()
    #count += 1
    if n % 10 != 0:
        q.append(n*10 + n % 10 - 1)
    q.append(n*10 + n % 10)
    if n % 10 != 9:
        q.append(n*10 + n % 10 + 1)
print(n)

Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  string s;
  while (cin >> s, s != "-")
  {
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i)
    {
      int h;
      cin >> h;
      s = s.substr(h, s.size() - h) + s.substr(0, h);
    }
    cout << s << endl;
  }

  return 0;
}



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

#define loop(i,n) for(int i=1;i<=n;i++)
int a[100002];
int s[100002];

int main(){
  while(1){
    int n,k;
    cin>>n>>k;
    if(n==0)return 0;
    loop(i,n)cin>>a[i];
    s[1]=0;
    loop(j,k){
      s[1]+=a[j];
    }
    int m=s[1];
    loop(i,n-k+1){
      if(i==1)continue;
      s[i]=s[i-1]-a[i-1]+a[i+k-1];
      m=max(m,s[i]);
    }
    cout<<m<<endl;
  }
  return 0;
}

Measured memory_bytes: 3604
/*************************************************************************
  >         File: D.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 13 Aug 2016 08:10:59 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  if (s.size() == 2) {
    if (s[0] == s[1]) {
      cout << 1 << ' ' << 2 << endl;
    }
    else cout << "-1 -1" << endl;
  }
  else {
    for (int i = 0; i < s.size(); i++) if (i + 2 < s.size()) {
      set<char> sc;
      sc.insert(s[i]);
      sc.insert(s[i + 1]);
      sc.insert(s[i + 2]);
      if (sc.size() <= 2) {
        cout << i + 1  << ' ' << i + 3 << endl;
        return 0;
      }
    }
    cout << "-1 -1" << endl;
  }


  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int main(){
  int N;
  cin >> N;
  vector<int> F(1000, 0);
  for (int i = 1; i <= N; i++){
    int n = i;
    for (int j = 2; j * j <= n; j++){
      if (n % j == 0){
        while (n % j == 0){
          F[j]++;
          n /= j;
        }
      }
    }
    if (n != 1){
      F[n]++;
    }
  }
  long long ans = 1;
  for (int i = 0; i < 1000; i++){
    ans = ans * (F[i] + 1) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,k,res=0; cin>>n>>k;
  long long int a[n]; 
  for(long long int i=0; i<n; ++i) cin>>a[i];
  sort(a, a+n);
  // for(int i=0; i<n; ++i) cout<<a[i]<<' ';
  for(long long int i=0; i < n-k; ++i){
   	res += a[i];
  }
  cout<<res;
  return 0;
}


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

using namespace std;

const int maxn = 3005;

int dp[maxn][maxn];
pair<int, int> par[maxn][maxn];
int main()
{
    string s1, s2;
    cin >> s1 >> s2;
    int n1 = s1.length();
    int n2 = s2.length();
    for(int i = 1; i <= n1; i++){
        for(int j = 1; j <= n2; j++){
            if (s1[i - 1] == s2[j - 1]){
                if (1 + dp[i - 1][j - 1] > dp[i][j]){
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                    par[i][j] = {i - 1, j - 1};
                }
            } else {
                if (dp[i - 1][j] > dp[i][j - 1]){
                    dp[i][j] = dp[i - 1][j];
                    par[i][j] = {i - 1, j};
                } else {
                    dp[i][j] = dp[i][j - 1];
                    par[i][j] = {i, j - 1};
                }
            }
        }
    }
    for(int i = 0; i <= n1; i++){
        par[i][0] = {-1, -1};
    }
    for(int j = 0; j <= n2; j++){
        par[0][j] = {-1, -1};
    }
    int i = n1;
    int j = n2;
    vector<char> ans;
    while(par[i][j].first != -1 && par[i][j].second != -1){
        pair<int, int> tmp = par[i][j];
        if (s1[i - 1] == s2[j - 1]){
            ans.push_back(s1[i - 1]);
        }
        i = tmp.first;
        j = tmp.second;
    }
    reverse(ans.begin(), ans.end());
    for(auto ch : ans){
        cout << ch;
    }
    return 0;
}


Measured memory_bytes: 105984
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  int N; cin >> N;
  v<int> a(N),b(N);
  rep(i,N) cin >> a[i];
  rep(i,N) cin >> b[i];
  int res=0,dif=0;
  rep(i,N){
    if(b[i]-a[i]>=2){
      res+=(b[i]-a[i])/2;
    }
    if(a[i]>b[i]) dif+=a[i]-b[i];
  }
  if(res>=dif) Yes
  else No
  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] num = str.split(" ");
		long s = Long.parseLong(num[0]);
		long c = Long.parseLong(num[1]);
		if (2 * s >= c)
			System.out.println(c / 2);
		else {
			long k = (long) Math.floor((c - 2 * s) / 4);
			System.out.println(s + k);
		}

	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 998244353;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    ll n;
    cin >> n;
    cout << (n*(n-1))/2;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include<string>
using namespace std;
int main() {
	vector<int> line;
	char code[10];
	while (cin >> code) {
		
		if (code[0] >= '0'&&code[0] <= '9') {
			line.push_back(atoi(code));
		}
		else {
			switch (code[0]) {
			case '+':
				*(line.end() - 2) = *(line.end() - 2) + *(line.end() - 1);
				break;
			case'-':
				*(line.end() - 2) = *(line.end() - 2) - *(line.end() - 1);
				break;
			case'*':
				*(line.end() - 2) = *(line.end() - 2) * *(line.end() - 1);
				break;
			case'/':
				*(line.end() - 2) = *(line.end() - 2) / *(line.end() - 1);
				break;
			}
			line.pop_back();
		}
	}
	cout << line[0] << endl;
	return 0;
}

Measured memory_bytes: 1204
def hd(a,b):
    ans = ""
    if a == "H":
        ans = "H" if b == "H" else "D"
    else:
        ans = "D" if b == "H" else "H"

    return ans

def main():
    a , b = map(str, input().split())
    print(hd(a , b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){

  int N, A;
  cin >> N;
  int ans = 0;

  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    cin >> A;
    m[A] += 1;
  }

  for(auto i = m.begin(); i != m.end(); i++) {
    if(i->second % 2 == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string A;
  cin >> A;
  if(A[1]=='A' && A[2]=='C'||A[0]=='A'&& A[1]=='C'||A[2]=='A'&&A[3]=='C'||A[3]=='A'&&A[4]=='C'){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

template <class Itr>
auto Median(Itr first,Itr last){
    auto n = distance(first, last);
    sort(first,last);
    if(n % 2 == 1){
        return *(first+n/2);
    } else {
        return (*(first+n/2)+*(first+n/2-1))/2;
    }
}

signed main(){
    int n; cin >> n;
    vector<int>v(n);
    int ofs = 1;
    for(auto &i :v)
        cin >> i,i-=ofs++;
    int m = Median(v.begin(), v.end());
    int ans = 0;
    for(auto i :v)ans += abs(i-m);
    cout << ans << endl;
}





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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n;
	cin >> n;
	vector<double> v(n);
	for(int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	sort(v.begin(), v.end());

	double value = v[0];
	for(int i = 1; i < n; ++i)
	{
		value = (value + v[i]) / 2.0;
	}
	printf("%.7f", value);
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3820
n = int(input())
ans = 0

for i in range(1, n+1, 2):
  counter = 0
  for j in range(1, i+1):
    if i%j==0:
      counter += 1
    if counter > 8:
      break
  if counter == 8:
    ans += 1
    
print(ans)

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

int main()
{
  int n;
  cin>>n;
  
  pair<int,int> a[n];
  
  int x;
   
  for(int i=0;i<n;i++)
  {
  	cin>>x;
  	a[i].first=x;
  	a[i].second=i+1;
  }
  sort(a,a+n);
  for(int i=0;i<n;i++)
  {
  	cout<<a[i].second<<" ";
  }
  cout<<endl;
 return 0; 
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int alength=200000;

const double pi=3.14159265359;

int main() {
	double a,b,h,m;
    cin>>a>>b>>h>>m;
    double t=h*60+m;
    cout << std::fixed << std::setprecision(15);
    double x,y;x=t*0.5;y=m*6;//xは時
    double s=fabs(x-y);s=s/180*pi;
    cout<<sqrt(a*a+b*b-2*a*b*cos(s));
}

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

using namespace std;

int main(){
	map<string, int> m;
	int n; cin >> n;
	string s;
	for(int i = 0; i < n; ++i){
		cin >> s;
		m[s]++;
	}
	int maxv = 0;
	for(auto itr = m.begin(); itr != m.end(); ++itr) maxv = max(maxv, itr->second);
	for(auto itr = m.begin(); itr != m.end(); ++itr){
		if(itr->second == maxv) cout << itr->first << endl;
	}
}

Measured memory_bytes: 25216
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}
int a[105];

int main(void){
    int N, M, X;
    cin >> N >> M >> X;
    for (int i = 0; i < M; i++){
        int tmp;
        cin >> tmp;
        a[tmp] = 1;
    }
    int cnt = 0;
    int ans = 0;
    for (int i = X+1; i < N; i++){
        ans += a[i];
    }
    for (int i = X-1; i > 0; i--){
        cnt += a[i];
    }
    if (ans > cnt) ans = cnt;
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    using ll = long long;
    using P = pair<int,int>; 
     
    int main() {
          int n,m;
     cin >> n >> m;
     vector<int> a(n);
      rep(i,n)   cin >> a[i];
     
     int s=0;
     
     rep(i,n)  s+=a[i];
     
     int count=0;
     
     
     rep(i,n){
         if(a[i]*(4*m)>=s)  count++;
     }
        if(count>=m) cout <<"Yes"<< '\n';
        else cout <<"No"<< '\n';
      
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    vector<vector<char>> mat(h,vector<char>(w));
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            cin>>mat[i][j];
        }
    }
    vector<vector<int>> dp(h+1,vector<int>(w+1));
    dp[1][1]=1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(i==1 && j==1)
                continue;
            if(mat[i-1][j-1]=='.')
            {
                dp[i][j]=dp[i][j-1] + dp[i-1][j];
                dp[i][j]=dp[i][j]%1000000007;
            }
            else
            {
                dp[i][j]=0;
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return  0;
}

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

int main() {
  int n;
  cin >> n;
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
open Scanf
open Printf
open Array

let rv f p q = f q p

let () = scanf " %d %d" @@ fun n m ->
  let a = init m (fun _ -> scanf " %d" @@ fun v -> v) in
  sort compare a;
  let d = init (m-1) (fun i -> abs @@ a.(i+1) - a.(i)) in
  sort (rv compare) d;
  print_int @@
    if n >= m then 0
    else fst @@ fold_left (fun (sum,i) v ->
      if i>=n-1 then (sum+v,i+1) else (sum,i+1)
    ) (0,0) d

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 100010;
int cnt[N], ac[N], n;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	memset(cnt, 0, sizeof cnt);
	memset(ac, 0, sizeof ac);

	int p, m;
	string s;
	
	cin >> n >> m;
	Foz(i, m) {
		cin >> p >> s;
		if (ac[p]) continue;
		if (s == "WA") cnt[p]++;
		else ac[p] = 1;
	}

	int ans = 0, pen = 0;
	For(i, 1, n + 1) if (ac[i]) {
		ans++; pen += cnt[i];
	}
	cout << ans << ' ' << pen << '\n';
}



Measured memory_bytes: 1024
from collections import Counter as C;r=range(3);H,W,N,*L=map(int,open(0).read().split());K=[];M=[0]*10;M[0]=(H-2)*(W-2)
for a,b in zip(*[iter(L)]*2):
	for x in r:
		for y in r:
			if H-1>a-y>0<b-x<W-1:K+=[(a-y,b-x)]
for k,v in C(C(K).values()).items():M[0]-=v;M[k]+=v
print(*M)

Measured memory_bytes: 210424
#include<bits/stdc++.h>//万能头文件
using namespace std;
int main(){//主函数
    int a,b,c;//定义;
    cin>>a>>b>>c;//输入
    if(a==b&&a==c&&b==c){//判断三个数是否相等;
        cout<<1<<endl;//相等输出一;
        return 0;//退出,
    }
    if(a==b||b==c||a==c){//判断是否有两个数相等
        cout<<2<<endl;//有输出二,三个相等上面已经判断过了,不会再出现;
        return 0;//退出
    }
    cout<<3<<endl;//到这里还没退出,说明三个数都不相等,输出三
    return 0;//好习惯
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;



int main(){
    LL a,b,c;
    cin >> a >> b >> c;
    c*=2;
    LL x,y;
    cin >> x >> y;
    LL l;
    LL ans=0;
    if(a>=c){
        cout << x*c+min(max(y-x,0LL)*c,max(y-x,0LL)*b) << endl;
        return 0;
    }
    if(b>=c){
        cout << y*c+min(max(x-y,0LL)*c,max(x-y,0LL)*a) << endl;
        return 0;
    }
    if(a+b>=c){
        l=min(x,y);
        ans+=l*c;
        x-=l;
        y-=l;
        cout << ans+a*x+b*y << endl;
        return 0;
    }
    cout << a*x+b*y << endl;
    return 0;
}

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

// Educational DP/DPまとめコンテスト B-Frog2
// dp[i] := 足場iへ到達する最小コスト 
// 2020.5.31

int INF = 1e9+7;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  vector<int> h(N, 0);
  REP(i, N){
    cin >> h[i];
  }
  vector<int> dp(N+105, INF);
  dp[0] = 0;
  REP(i, N){
    for(int j = 1; j <= K; j++){
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll N;

string s;
void solve() {
    cin >> N;
    vll A(N),B(N),C(N-1);
    rep(i,N){
        cin >> A[i];
        A[i]--;
    }
    rep(i,N){
        cin >> B[i];
    }
    rep(i,N-1){
        cin >> C[i];
    }

    ll ans = B[A[0]], before=A[0];
    rng(i,1,N){
        ans += B[A[i]];
        if(before+1 == A[i]){
            ans += C[before];
        }
        before = A[i];
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3656
#include<stdio.h> 
#define N 36
  
typedef struct
{
  char suit;
  int value;
}Card;
  
int main()
{
  int i, j, n, min, flag = 0;
  Card a[N], b[N], a1, a2;
    
  scanf("%d", &n);
  for(i = 0; i < n; i++)
    {
      scanf(" %c%d", &a[i].suit, &a[i].value);
      b[i].suit = a[i].suit;
      b[i].value = a[i].value;
    }
  
  for(i = 0; i < n-1; i++)
    for(j = n-1; j > i; j--)
      if(a[j].value < a[j-1].value)
	{
	  a1 = a[j];
	  a2 = a[j-1];
	  a[j] = a2;
	  a[j-1] = a1;
	}
 
  for(i = 0; i < n; i++)
    {
      min = i;
      for(j = i; j < n; j++)
	{
	  if(b[j].value < b[min].value)
	    min = j;
	}
      a1 = b[i];
      a2 = b[min];
      b[i] = a2;
      b[min] = a1;
    }
 
  for(i = 0; i < n-1; i++)
    printf("%c%d ", a[i].suit, a[i].value);
  printf("%c%d\n", a[n-1].suit, a[n-1].value);
  printf("Stable\n");
   
  for(i = 0; i < n-1; i++)
    printf("%c%d ", b[i].suit, b[i].value);
  printf("%c%d\n", b[n-1].suit, b[n-1].value);
     
  for(i = 0; i <= n-1; i++)
    if(a[i].suit != b[i].suit)
      flag = 1;
   
  if(flag == 1) printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}

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

const int N = 1e6;
int cnt[N];
bool red[N];
int n, m;

int main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif // LC
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    fill_n(cnt + 1, n, 1);
    red[1] = true;
    for (int v, u, iter = 1; iter <= m; ++iter) {
        cin >> v >> u;
        --cnt[v];
        ++cnt[u];
        red[u] |= red[v];
        if (cnt[v] == 0) {
            red[v] = false;
        }
    }
    cout << accumulate(red + 1, red + n + 1, 0) << "\n";
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define all(vvv) vvv.begin(), vvv.end()
#define sz size()
#define s second
int n;
map <string, int> cnt;
vector <string> vec;
bool cmp(string a, string b) {
	return cnt[a] < cnt[b];
}
int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		string x;
		cin >> x;
		cnt[x]++;
		vec.pb(x);
	}
	int mx = -1e9;
	for(int i = 0; i < vec.sz; ++i) mx = max(mx, cnt[vec[i]]);
	set <string> ans;
	for(map <string, int> :: iterator it = cnt.begin(); it != cnt.end(); it++) {
		string k = (*it).first;
		if(cnt[k] == mx) ans.insert(k);
	}
	for(set <string> :: iterator it = ans.begin(); it != ans.end(); it++) cout << *it << '\n';
	return 0;
}

Measured memory_bytes: 34800
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
const int mxN=2e5;
const int MOD=1e9+7;
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;

int main()
{
    fastio;
    ll t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,x,m,i,sum=0,temp,val=-1;
        cin>>n>>x>>m;
        sum+=x;
        vector<ll>v;
        set<ll>s;
        v.pb(x);
        s.in(x);
        bool ok=false;
        for(i=1;i<n;i++)
        {
            temp=v[i-1]%m;
            temp*=temp;
            temp%=m;
            if(temp==0)
                break;
            if(s.count(temp)==1)
            {
                ok=true;
                val=temp;
                break;
            }
           v.pb(temp);
           sum+=v[i];
           s.in(temp);
        }

        ll tot=0;
        vector<ll>copy;
        if(ok)
        {
            bool ok1=false;
            for(i=0;i<v.size();i++)
            {
                if(v[i]==val)
                {
                    ok1=true;
                    copy.pb(val);
                    tot+=val;
                }
                else if(ok1)
                {
                    copy.pb(v[i]);
                    tot+=v[i];
                }
            }
        }


//        cout<<v.size()<<" "<<sum<<" "<<copy.size()<<" "<<tot<<endl;

        if(debug)
        {
            for(auto x:v)
            {
                cout<<x<<" ";
            }
            cout<<endl;


            for(auto x:copy)
            {
                cout<<x<<" ";
            }
            cout<<endl;
        }

        if(!ok)
        {
            cout<<sum<<endl;
            return 0;
        }


        ll left=n-v.size();
        ll summ=left/copy.size();
        summ*=tot;
        ll rem=left%copy.size();

        for(i=0;i<rem;i++)
        {
            summ+=copy[i];
        }

        cout<<sum+summ<<endl;



    }

}


Measured memory_bytes: 6712
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>

#define ll long long
#define scani(x) scanf("%i", &x)
#define scanll(x) scanf("%I64d", &x)
#define scanfl(x) scanf("%f", &x)
#define scanch(x) scanf("%c", &x)
#define scans(x) scanf("%s", x);
#define printi(x) printf("%i", x);
#define printll(x) printf("%I64d", x);
#define printfl(x) printf("%f", x);
#define printch(x) printf("%c", x);
#define prints(x) printf("%s", x);
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INFI (1 << 29)
#define INFL (1LL << 62)
#define sz(x) int(x.size())
#define fi first
#define se second
#define forn(i, n) for(ll i = 0; i < n; i++)
#define for1(i, n) for(ll i = 1; i <= n; i++)
#define ford(i, n) for(ll i = (n - 1); i >= 0; i--)
#define fori(i, n) for(ll i = n; i >= 1; i--)
#define fore(i, l, r) for(ll i = l; i <= r; i++)

using namespace std;

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

    string s;
    ll r = 0, W = 0;

    cin >> s;

    ford(i, sz(s))
    {
        W += (s[i] == 'W');

        if(s[i] == 'B')
            r += W;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 720
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
bool ng[210];
int main()
{
	int x,n,p;
	cin>>x>>n;
	memset(ng,false,sizeof(ng));
	rep(i,n){
		cin>>p;ng[p]=true;
	}
	int out=-1;
	rep(i,205){
		if(ng[i]) continue;
		if(abs(i-x)<abs(out-x)) out=i;
	}
	cout<<out<<endl;
}


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

int main(){
    long long int n;
    cin >> n;
    for(long long int i=sqrt(n);i>=1;i--){
        if(n % i == 0){
            cout << i + (n/i) - 2 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    string s;
    cin >> s;
    int n = (int) s.size();
    int ans = n;
    rep(i,n-1){
        if(s[i] != s[i+1]){
            ans = min(ans, max(i+1,n-i-1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int min = *min_element(a.begin(), a.end());
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] > min)
        {
            cnt++;
        }
    }
    // cout << cnt << endl;
    int ans;
    if (cnt % (k - 1) == 0)
    {
        ans = cnt / (k - 1);
    }
    else
    {
        ans = cnt / (k - 1) + 1;
    }

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


Measured memory_bytes: 640
#! /usr/bin/python3

while True:
    try:
        s=int(input())
        n=0
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for l in range(10):
                        if s == i+j+k+l: n+=1
        print(n)
    except:
        break

Measured memory_bytes: 6720
#include <stdio.h>

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

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

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

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    
    int sum = min(A, K);
    K -= sum;
    if (K > 0) {
        int zero = min(B, K);
        K -= zero;
    }
    
    sum -= K;
    
    cout << sum;
    return 0;
}

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

long long ary[200010];
int main(){
	long long N,T;
	cin>>N>>T;
	for(long long i=1;i<=N;i++){
		cin>>ary[i];
	}
	long long sum=0;
	for(long long i=1;i<N;i++){
		if(ary[i+1]-ary[i]>T) sum+=T;
		else sum+=(ary[i+1]-ary[i]);
	}
	sum+=T;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,A[100007],sum=0;
  cin >> N ;
  rep(i,N){
    cin >> A[i];
  }
  sort(A,A+N);
  rRep(i,N,1){
    A[i]=A[i-1];
  }
  A[0]=0;
  ll T=0;
  Rep(i,1,N+1){
    if(A[i]==A[i+1]){
      T++;
    }
    else{
      if((A[i]-A[i-1-T])%2==1){
        sum^=N-i+T+1;
      }
      T = 0;
    }
  }
  if(sum == 0){
    cout << "second" << endl;
  }
  else{
    cout << "first" <<  endl;
  }
}

Measured memory_bytes: 1024