akhauriyash/Code-Regression huggingface dataset:
x = input()
n = len(x)
s = 0
t = 0
cou = 0

for i in range(n):
    if x[i] == "S":
        s += 1
    elif x[i]== "T":
        if s >= 1:
            s -= 1
            cou += 1
print(n - cou * 2)

Measured memory_bytes: 3500
def main():
    N,M=map(int,input().split())
    pS=[[i for i in input().split()] for _ in range(M)]
    ac_wa=[[0,0] for _ in range(N)]
    ac_wa_count=[0,0]
    for p,S in pS:
        p=int(p)
        if S=='WA':
            ac_wa[p-1][1]+=1
        else:
            if ac_wa[p-1][0]==0:
                ac_wa[p-1][0]=1
                ac_wa_count[0]+=1
                ac_wa_count[1]+=ac_wa[p-1][1]
    print(*ac_wa_count)

main()

Measured memory_bytes: 36080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<pll> vp;

const ll mod = 1e9+7;
inline ll lcm(ll a, ll b){return a/__gcd(a,b)*b;}

class SegmentTree{
  int n;
  vp node;
public:
  SegmentTree(vp a){
    int n_ = a.size();
    n=1;
    while(n<n_)n*=2;
    node.resize(2*n-1, pll(1, 0));
    for(int i=0;i<n_;i++)node[n-1+i] = a[i];
    for(int i=n-2;i>=0;i--){
      pll vl = node[2*i+1], vr = node[2*i+2];
      ll len = lcm(vl.first, vr.first);
      ll cost = ( (len/vl.first%mod) * vl.second) + ( (len/vr.first%mod) * vr.second);
      node[i] = pll(len,cost%mod);
    }
  }
  
  pll INTV_LCM(int a,int b,int k=0,int l=0,int r=0){
    if(l>=r)r = n;
    if(r<=a || b<=l)return pll(1,0);
    if(a<=l && r<=b)return node[k];
    pll vl = INTV_LCM(a,b,2*k+1,l,(l+r)/2);
    pll vr = INTV_LCM(a,b,2*k+2,(l+r)/2,r);
    ll len = lcm(vl.first, vr.first);
    ll cost = ( (len/vl.first%mod) * vl.second) + ( (len/vr.first%mod) * vr.second);
    return pll(len, cost%mod);
  }
};

int main(){
  int n,q;
  cin >> n >> q;
  vector<int> p(n+1);
  for(int i=1;i<=n;i++)cin >> p[i];

  vector<pll> val(n);
  vector<int> use(n+1,0);
  for(int i=1;i<=n;i++){
    if(!use[i]){
      int cur = i;
      ll len = 0, sum = 0;
      
      do{
	len++; sum += p[cur];
	cur = p[cur];
      }while(cur != i);
      
      do{
	val[cur-1] = pll(len,sum%mod);
	use[cur] = 1;
	cur = p[cur];
      }while(cur != i);
    }
  }

  SegmentTree st(val);
  for(int i=0;i<q;i++){
    int l,r;
    cin >> l >> r;
    cout << (st.INTV_LCM(l-1,r)).second << endl;
  }
}

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

int main()
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int H, A;
    cin >> H >> A;
    int answer = H / A;
    if(H % A){
        answer++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, M = NMI()
    yak = set()
    i = 1
    while i * i <= M:
        if M % i == 0:
            yak.add(i)
            yak.add(M // i)
        i += 1
    yak = sorted(list(yak), reverse=True)
    for y in yak:
        if y * N <= M:
            print(y)
            exit()


if __name__ == "__main__":
    main()

Measured memory_bytes: 9476
#include <cstdio>
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){
    long N;
    scanf("%ld",&N);
    string s[N];
    for(long i=0;i<N;i++){
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
    }
    map<string,long> mp;

    for(long i=0;i<N;i++){
        mp[s[i]] ++;
    }
    long cnt = 0;
    for(pair<string,long> p:mp){
        if(p.second>1){
            cnt += p.second*(p.second-1)/2;
        }
    }
    cout<<cnt<<"\n";

}



Measured memory_bytes: 18176
using System;

class Program
{
    static void Main()
    {
       char[] alpha = Console.ReadLine().ToCharArray();
        for (int i = 0;i <alpha.Length; i++)
        {
            if (char.IsUpper(alpha[i]) == true)
            {
                alpha[i] =char.ToLower(alpha[i]);
            }
            else if (char.IsLower(alpha[i]) == true)
            {
                alpha[i]=char.ToUpper(alpha[i]);
            }
            Console.Write(alpha[i]);
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 15876
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

/*
6 4
a b c d e f
af -> 4c2
ae,bf -> 3c2
ad,be,cf -> 2c2
*/

/*
Log order calcuration of power
*/
ll bi_pow(ll x, ll n){
  ll res = 1;
  while (n>0){
    if (n%2==1) {res = res * x % MOD;}
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}

/*
Inverse element of MOD = 1e9+7
*/
ll inv_MOD(ll x){
  return bi_pow(x, MOD-2);
}

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

  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  REP(i,N) { cin >> A[i]; }

  sort(A.begin(), A.end());

  vector<ll> fact(N+1,1);
  vector<ll> inv_fact(N+1,1);
  REP3(i,1,N+1){
    fact[i] = fact[i-1]*i%MOD;
    inv_fact[i] = inv_MOD(fact[i]);
  }

  /*
  N=6 K=3
  0 1 2 3 4 5
  mi=0~3  5C2
  ma=2~5  5C2
  */

  ll sum_mi = 0;
  // calc min sum
  REP3(mi,0,N-K+1){
    // min * (N-mi)_C_(K-1)
    sum_mi += ((A[mi] * fact[N-mi-1] % MOD) * inv_fact[N-mi-K] % MOD) * inv_fact[K-1] % MOD;
    sum_mi %= MOD;
  }

  ll sum_ma = 0;
  // calc max sum
  REP3(ma,K-1,N){
    // max * (N-ma)_C_(K-1)
    sum_ma += ((A[ma] * fact[ma] % MOD) * inv_fact[ma-K+1] % MOD) * inv_fact[K-1] % MOD;
    sum_ma %= MOD;
  }

  ll ans = (sum_ma - sum_mi + MOD) % MOD;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>ww,cc,u;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL ar[100];
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n;
        if(n>=30)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3652
//abc138_b.cpp
//Sun Aug 18 20:46:31 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
	double a[n];
	double ans = 0;
	for (int i=0;i<n;i++){
		cin >> a[i];
		ans += 1/a[i];
	}

	ans = 1/ans;
	printf("%.10f\n",ans);
}

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

using namespace std;

using ll = long long;

constexpr ll inf = 1<<30;
int main(){
    int n;
    cin>>n;
    vector<int> l(2*n);
    for(auto & a : l) cin>>a;
    sort(l.rbegin(),l.rend());
    int ans = 0;
    for(int i=0;i<2*n;i+=2){
        ans += min(l[i],l[i+1]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())
ns = []
for _ in range(n):
    ns.append(int(input()))

print(lcm(ns))

Measured memory_bytes: 5344
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int isKaibun(string s);

int main(void){
    int A, B;
    cin >> A >> B;
    int cnt = 0;
    for(int i=A; i<=B; i++){
        if(isKaibun(to_string(i))){
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

int isKaibun(string s){
    for(int i=0; i<= s.length()/2; i++){
        if(s[i] != s[s.length()-1-i]){
            return 0;
        }
    }
    return 1;
}

Measured memory_bytes: 256
from math import floor, sqrt
from collections import Counter

def getPrimeFactor(x):
    ans = []
    for d in range(2, floor(sqrt(x)) + 1):
        while x % d == 0:
            ans.append(d)
            x //= d
    if x != 1:
        ans.append(x)
    return ans

N, P = map(int, input().split())

PFs = getPrimeFactor(P)
cnt = Counter(PFs)

ans = 1
for p, num in cnt.items():
    if num // N:
        ans *= p ** (num // N)
print(ans)


Measured memory_bytes: 3316
import heapq

n = int(input())
V = list(map(int, input().split()))

one = V[::2]
two = V[1:][::2]

one,two

one_count={}
one_len=len(one)
for o in one:
    if o in one_count:
        one_count[o] += 1
    else:
        one_count[o] = 1

for k,v in one_count.items():
    one_count[k] = one_len-v
one_count[10**6]=one_len
temp = [[k,v] for k,v in one_count.items()]
one = heapq.nsmallest(3,temp, key=lambda x: x[1])


two_len=len(two)
two_count={}

for t in two:
    if t in two_count:
        two_count[t] += 1
    else:
        two_count[t] = 1

for k,v in two_count.items():
    two_count[k] = two_len-v
two_count[10**6]=two_len
temp = [[k,v] for k,v in two_count.items()]
two = heapq.nsmallest(3,temp, key=lambda x: x[1])

mins = 1000000

for [one_key, one_value] in one:
    for [two_key, two_value] in two:
        if one_key != two_key:
            if (one_value + two_value) < mins:
                mins = one_value + two_value
print(mins)

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

public class Main {

        static int N;
        static int M;
        static int Q;

        static int[] a;
        static int[] b;
        static int[] c;
        static int[] d;

        static int Anumber = 0;
        static int count = 0;
        static int[] A;
        static int max = 0;

        public static void main(String[] args) {

                Scanner scan = new Scanner(System.in);

                N = scan.nextInt();
                M = scan.nextInt();
                Q = scan.nextInt();

                a = new int[Q];
                b = new int[Q];
                c = new int[Q];
                d = new int[Q];

                for (int i = 0; i < Q; i++) {
                        a[i] = scan.nextInt();
                        b[i] = scan.nextInt();
                        c[i] = scan.nextInt();
                        d[i] = scan.nextInt();
                }

                A = new int[N];

                Main.Aselect(1);

                System.out.println(max);


        }


        private static void Aselect(int first) {
                if (Anumber == N-1) {
                        for (int j = first; j <= M; j++) {
                                A[Anumber] = j; 

                                for (int i = 0; i < Q; i++) {
                                        if (A[b[i]-1]-A[a[i]-1] == c[i]) {
                                                count += d[i];
                                        }
                                }

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

                                count = 0;
                        }
                } else {
                        for (int j = first; j <= M; j++) {
                                A[Anumber] = j;
                                Anumber++;
                                Aselect(j);
                                Anumber--;
                        }
                }
        }

}

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

int n,a[109],i;

int main() {
  cin>>n;
  for(i=0;i<n;i++)
  cin>>a[i];
  for(i=0;i<n;i++)
  if(a[i]%2==0 && (a[i]%3!=0 && a[i]%5!=0)){
  cout<<"DENIED"<<endl; return 0;
  }
  cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int x, y;
  cin >> x >> y;
  if (y > x * 4 || y < x*2) {
    cout << "No" << endl;
    return 0;
  }

  if (y % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}



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

int main(){
  int a,b;cin>>a>>b;
  if(a>0) cout<<"Positive"<<endl;
  else if(b>0) cout << "Zero" << endl;
  else cout << (((b-a+1) & 1) ? "Negative":"Positive") << endl;
 return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		ArrayList<String> txt = new ArrayList<String>();
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '0' || s.charAt(i) == '1')
				txt.add(s.substring(i, i + 1));
			else if (!txt.isEmpty())
				txt.remove(txt.size() - 1);
		}
		for (int i = 0; i < txt.size(); i++)
			System.out.print(txt.get(i));
		System.out.println("");
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
int main()
{
    int N,i,j,c=0;
    char s[200];
    scanf("%d%s",&N,s);
    j=strlen(s);
    for(i=0;i<j;i++)
    {
        if (s[i]=='A')
        if (s[i+1]=='B')
        if (s[i+2]=='C')
        c++;
    }
    printf("%d",c);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

int main (){
	int n;
	cin >> n;
	int a[45];
	a[0] = 1;
	a[1] = 1;
	for (int i = 2;i<=n;i++){
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n]<<endl;

	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main()
{
    long long int s;
    long long int a,b,c,d;
    long long int m=1000000000;
    cin>>s;
    if(s/m==m)
    {
        cout<<0<<" "<<0<<" "<<m<<" "<<0<<" "<<0<<" "<<m<<endl;
    }
    else
    {
        a=s/m+1;
        b=1;
        c=m-s%m;
        d=m;
        cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
    }   
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<int> w(n);
    for(int i=0;i<n;++i) {
      cin >> w[i];
    }
    vector<vector<int>> dp(n, vector<int>(n, 0));
    for(int i=0;i<n-1;++i) {
      if(abs(w[i] - w[i+1]) <= 1) {
        dp[i][i+1] = 2;
      }
    }
    for(int i=2;i<n;++i) {
      for(int l=0;l<n-i;++l) {
        int r = l + i;
        if(dp[l+1][r-1] == r - l - 1 && abs(w[l] - w[r]) <= 1) {
          dp[l][r] = r - l + 1;
        }
        for(int k=l;k<=r-1;++k) {
          dp[l][r] = max(dp[l][r], dp[l][k] + dp[k+1][r]);
        }
      }
    }
    cout << dp[0][n-1] << endl;
  }
}



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_set>

using namespace std;

int main() {
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    bool path[n][n];
    fill(path[0], path[n], false);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        path[a-1][b-1] = true;
        path[b-1][a-1] = true;
    }
    
    int perm[n-1];
    iota(perm, perm+n-1, 1);
    
    unordered_set<int> ok;
    int pattern = 0;
    do
    {
        ok.clear();
        ok.insert(0);
        
        int prev = 0;
        for(int x : perm) {
            if(path[prev][x]) {
                ok.insert(x);
                prev = x;
            } else {
                break;
            }
        }
        
        if(ok.size() == (size_t)n) {
            pattern++;
        }
    }while(next_permutation(perm, perm+n-1));
    
    cout << pattern << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

  ll A,B;
  string S, T,U;
  cin >> S >> T;
  cin >> A >> B >> U;

  if(S==U){
    cout << A-1 << " "<<B << endl;
  }
  else{
    cout << A  << " "<< B-1 << endl;
  }

  

}

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

void rec(int d, long long val, vector<long long> &all) {
  all.push_back(val);

  if (d == 10) return;

  for (int j = -1; j <= 1; ++j) {
    int add = (val % 10) + j;
    if (add >= 0 && add <= 9) rec(d + 1, val * 10 + add, all);
  }
}

int main() {
  int K;
  cin >> K;
  vector<long long> all;
  for (int v = 1; v < 10; ++v) rec(1, v, all);

  sort(all.begin(), all.end());

  cout << all[K - 1] << endl;
}


Measured memory_bytes: 5344
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin>>p[i];

    int pmin = inf;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(pmin > p[i]) ans++;
        chmin(pmin, p[i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <ctime>


#ifndef _USEFUL_MACROS_
#define _USEFUL_MACROS_
#define INF (99999999/3)
#define N_PRIME 1000000007
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
//#define OUTPUT_DEBUG
#ifdef OUTPUT_DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x) do{}while(false)
#endif
#endif 

using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    vector<int> dp(n+1);
    
    REP(i,m) cin >> c[i];
    
    sort(c.begin(),c.end());
    REP(i,n+1)dp[i] = INF;
    
    dp[0] = 0;
    dp[1] = 1;
    
    REP(i,m){
        FOR(j,1,n+1){
            int index = j - c[i];
            if( index < 0 )continue;
            
            dp[j] = min(dp[index]+1,dp[j]);
        }
    }
    debug(c[0]);
    REP(i,n+1)
        debug(dp[i]);
    
    cout << dp[n] << endl;
    
    return 0;
}

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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is D.Unbalanced Strings
*/

int main(){
    string s; cin>>s;
    for(auto&c :s) c-='a';
    vector<vector<int>> a(s.length()+1,vector<int> (26,0));
    for(int i=1;i<=s.length();i++){
        a[i]=a[i-1];
        a[i][s[i-1]]++;
        if((i-2)>=0 && (a[i][s[i-1]]-a[i-2][s[i-1]]>=2)){
            cout<<i-1<<" "<<i;
            return 0;
        }
        if((i-3)>=0 && (a[i][s[i-1]]-a[i-3][s[i-1]]>=2)){
            cout<<i-2<<" "<<i;
            return 0;
        }
    }
    cout<<-1<<" "<<-1;
    return 0;
}


Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,d;
  cin >> a >> b;
  c=a;d=b;
  while (c!=d) {
    if (max(c,d)%min(c,d)==0) {c=d=min(c,d);}
    else {if (c>d) {c=c%d;} else {d=d%c;}}
  }
  cout << a/c*b << endl;
}


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

int main(){
    int A, B;
    string S, ans = "Yes";
    cin >> A >> B >> S;
    for(int i = 0; i < S.size(); ++i){
        if(i == A){
            if(!(S[i] == '-')){
                ans = "No";
                break;
            }
        }
        else if(!('0' <= S[i] && S[i] <= '9')){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) ((x < 0)?-(x):x)
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N,A;
	cin >> N >> A;
	vector<int> C(N);
	for(int i =0; i < N; i++) cin >> C[i];
	for(int i =0; i < N; i++) C[i] -=A;
	vector< vector<long long> > P(N+1,vector<long long>(10000,0));
	P[0][5000] =1;
	for(int i =0; i < N; i++) 
		for(int j =0; j < 10000; j++) {
			if(j+C[i] < 10000 && j+C[i] >= 0) P[i+1][j+C[i]] +=P[i][j];
			P[i+1][j] +=P[i][j];}
	cout << P[N][5000]-1 << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
    int n, m, AC = 0, WA = 0;
    cin >> n >> m;
	int bad[n+1] = {};
    vector<int> p(m);
    vector<string> s(m);
    vector<bool> first(n+1, true);
    for (int i = 0; i < m; i++) {
        cin >> p[i];
        cin >> s[i];
        if (first[p[i]]) {
            if (s[i] == "AC") {
                AC++;
                first[p[i]] = false;
				WA += bad[p[i]];
            } else if (s[i] == "WA") bad[p[i]]++;
        }
    }
    cout << AC << ' ' << WA << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  ll a,b,c;
  cin >> a >> b >> c;
  if(a==1)printf("Hello World");
  else printf("%lld",b+c);
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

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

    //cout << fixed << setprecision(15);

    string s;
    while (cin >> s)
    {

        string t1 = "JOI", t2 = "IOI";

        int n = s.size();
        int ans1 = 0, ans2 = 0;

        for (int i = 0; i < n - 2; ++i)
        {
            string tmp = s.substr(i, 3);
            //cout << tmp << endl;
            if (tmp == t1)
                ans1++;
            if (tmp == t2)
                ans2++;
        }
        cout << ans1 << "\n"
             << ans2 << endl;
    }
    return 0;
}



Measured memory_bytes: 3208
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


// bool judge(ll K){
// 	ll b;
// 	rep(i,N){
// 		b = a[i]-(N-1-K);
// 		if(b>0){
// 			K -= b/(N+1);
// 			if(b%(N+1)>0)K-=1;
// 		}
// 	}
// 	if(K>=0){
// 		return true;
// 	}else{
// 		return false;
// 	}
// }

int main(void){
	ll N, a[52], K=0,L;
	cin>>N;
	rep(i,N){
		cin>>a[i];
		K+=a[i];
	}
	K -= N*(N-1);//最低必要な回数。
	L = K;
	if(L>0){
		rep(i,N)a[i] += K;
		rep(i,N){
			if(K > a[i]/(N+1)){
				K -= a[i]/(N+1);
				a[i] %= N+1;
			}else{
				a[i] -= K*(N+1);
				break;
			}
		}
	}else{
		L=0;
	}
	//合計値がN(N-1)を下回った後のシミュレーション。
	// cout<<L<<endl;
	bool ok;
	while(1){
		ok = true;
		rep(i,N)if(a[i]>N-1){
			a[i] -= N+1;
			L++;
			ok=false;
			break;
		}
		if(ok)break;
		rep(i,N)a[i]++;
	}
	cout<<L<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    int A[101];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A,A+N);
    printf("%d",A[N-1]-A[0]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  string s; cin >> s;
  ll n = SZ(s);
  ll ans = n;
  REP(i,n-1){
    if(s[i] == s[i+1]) continue;
    ans = min(ans, max(i+1,n-(i+1)));
  }
  cout << ans << endl;
}


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

int main(){
    int K, N;
    int A, beforeA, firstA;
    cin >> K >> N;
    int max = 0;
    cin >> firstA;
    beforeA = firstA;
    for(int i=0; i<N-1; i++){
        cin >> A;
        if(A-beforeA > max){
            max = A-beforeA;
        }
        beforeA = A;
    }
    if(K+firstA-beforeA > max){
        max = K+firstA-beforeA;
    }
    cout << K - max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
signed main() {
	int a, b, n;
	cin >> n >> a >> b;
	if (n % (a + b) > a)cout << (n / (a + b)) * a + a << endl;
	else cout << (n / (a + b)) * a + n % (a + b) << endl;
	ggr
}


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

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

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

int t;
ll a[310], b[310], c[310], d[310];

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    return gcd(y, x%y);
}

void solve() {
    for (int i = 0; i < t; i++) {
        if (a[i] < b[i]) {
            cout << "No" << endl;
        } else if (b[i] > d[i]) {
            cout << "No" << endl;
        } else if (b[i] <= c[i]) {
            cout << "Yes" << endl;
        } else {
            ll r = a[i] % b[i];
            ll g = gcd(b[i], d[i]);
            if (r > c[i]) {
                cout << "No" << endl;
            } else {
                ll x = ((c[i]-r)%g == 0 ? (c[i]-r)/g+1: (c[i] - r + g - 1) / g);
                ll y = ((b[i]-r)%g == 0 ? (b[i]-r)/g-1 : (b[i] - r) / g);
                //cerr << x << " " << y << endl;
                if (x <= y) {
                    cout << "No" << endl;
                } else {
                    cout << "Yes" << endl;
                }
            }
        }
    }
}

void input() {
    cin >> t;
    for (int i = 0; i < t; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
}

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

    input();
    solve();
}


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

int main(){
  
  int n,k,x,y;
  int ans;
  
  cin >> n >> k >> x >> y;
  
  ans = min(n,k) * x;
  ans += max(0,n-k) * y;
  
  cout << ans;
    
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE TupleSections #-}

import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString.Char8 as C
import Data.List
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as UM

main = C.interact $ C.pack . show . sol . get

get = V.unfoldr (C.readInt . C.dropWhile (<'0')) . last . C.lines

sol as = V.sum $ runST $ do
  h <- V.unsafeThaw hst
  V.forM_ as $ \a -> do
    x <- UM.unsafeRead h a
    when (x>0) $ do
      when (x>1) $ UM.write h a 0
      mapM_ (\i -> UM.write h i 0) [2*a,3*a..m]
  V.unsafeFreeze h
  where
  m = V.maximum as
  hst = V.accumulate (+) (V.replicate (m+1) 0) $ V.map (,1) as :: V.Vector Int

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

bool check(int x, vector<int> &A, int K) {
    int N = A.size();
    vector<int> r(N);
    for(int i=0; i<N; ++i) r[i] = A[i] % x;
    sort(begin(r), end(r));

    vector<int> up(N + 1, 0), down(N + 1, 0);
    for(int i=0; i<N; ++i) {
        up[i + 1] = up[i] + x - r[i];
        down[i + 1] = down[i] + r[i];
    }

    for(int i=1; i+1<=N; ++i) {
        if(down[i] == up[N] - up[i] && down[i] <= K) return true;
    }
    return false;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int res = 1;
    int S = accumulate(begin(A), end(A), 0);
    for(int i=1, y = sqrt(S) + 1; i <= y; ++i) {
        if(S % i) continue;
        if(check(i, A, K)) res = max(res, i);
        if(check(S / i, A, K)) res = max(res, S / i);
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n=int(input())
	s = list(IN())
	s_odd=s[1::2]
	s_even=s[::2]
	if len(s)%2==1:
		s_even=s_even[::-1]
		ret = s_even+s_odd
	else:
		s_odd=s_odd[::-1]
		ret = s_odd+s_even
	print(*ret)
	
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

constexpr int N = 303, M = 310;
double ev[M][M][M];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  int a[4] = {0, 0, 0, 0};
  cin >> n;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a[x] += 1;
  }

  for(int k = 0; k < N; ++k) {
    for(int j = 0; j < N; ++j) {
      for(int i = 0; i < N; ++i) {
        if(!i && !j && !k) continue;
        double sum = n;
        if(i) sum += (double) i * ev[i - 1][j][k];
        if(j) sum += (double) j * ev[i + 1][j - 1][k];
        if(k) sum += (double) k * ev[i][j + 1][k - 1];
        ev[i][j][k] = sum / (i + j + k);
      }
    }
  }
  cout << setprecision(12) << fixed << ev[a[1]][a[2]][a[3]] << '\n';
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<ll> t(n);
	for (int i=0; i<n; i++)
		cin>>t[i];
	ll ret=t[0];
	for (int i=1; i<n; i++)
		ret=ret/__gcd(ret,t[i])*t[i];
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int q; cin >> q;
    vector<int> v;
    rep(i,q){
        int com; cin >> com;
        int k;
        if(com == 0 || com == 1)cin >> k;
        if(com == 0)v.push_back(k);
        else if(com == 1)cout << v[k] << endl;
        else v.pop_back();
    }
    return 0;
} 


Measured memory_bytes: 3924
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int n; cin >> n;
	vector<int>h(n);
	rep(i, n)cin >> h[i];
	int mx = 0;
	bool is = true;
	rep(i, n) {
		if (mx > h[i])is = false;
		chmax(mx, h[i] - 1);
	}
	cout << (is ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <string>

typedef long long ll;

using namespace std;

int main() {
    int A;
    string str;

    cin >> A;
    cin >> str;

    if (A < 3200) {
        cout << "red" << endl;
    } else {
        cout << str << endl;
    }

    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def getinputdata():
    # 配列初期化
    array_result = []

    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            array_temp = []

            if (data != ""):

                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:

        return array_result


arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])

for i in range(1, 1 + h):
    print(arr_data[i][0])
    print(arr_data[i][0])


Measured memory_bytes: 3316
import java.util.*;
public class Main{
        public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int  N = Integer.parseInt(sc.next());
	Set<Integer> stick = new HashSet<Integer>();
	    int dupli[] = new int[N];
	
	 Arrays.fill(dupli,0);
	for(int i = 0;i < N;i++){
	     int  in = Integer.parseInt(sc.next());
	     if(!(stick.add(in))){
		 dupli[i] = in;
		 stick.remove(in);
		}
	}
	Arrays.sort(dupli);
        long  ans = dupli[N - 1];
	ans   *=  dupli[N - 2];
	System.out.println(ans);
	}
}


Measured memory_bytes: 50796
'use strict';

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line) {
  var keywords = extractKeywords(line.trim());
  console.log(keywords.join(' '));
});

function extractKeywords(line) {
  var words = line.split(/[ \.,]/);
  return words.filter(function(word) {
    return word.length >= 3 && word.length <= 6;
  });
}

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

#define PI 3.14159265358979323846264338327950L

int main() {
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	long double hang = 30.0 * h;
	long double mang = 6.0 * m;
	long double rad = PI * 2 * (h / 12.0 + m / 720.0 - m / 60.0);
	long double resp = sqrt(a * a + b * b - 2 * a * b * cos(rad));
	printf("%.20llf", resp);
	return 0;
}

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll a, b; cin >> a >> b;
    cout << a * b << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

"""

"""

a, b, c, d = map(int, input().split())
monsters = [(a, b), (c, d)]
# health, damage
i = 0
while True:
    a_health, a_damage = monsters[i]
    d_health, d_damage = monsters[(i+1)% 2]

    d_health -= a_damage

    if d_health <= 0:
        if i == 0:
            print("Yes")
        else:
            print("No")
        break
    
    monsters[i] = (a_health, a_damage)
    monsters[(i+1)% 2] = (d_health, d_damage)
    i = (i+1) % 2




Measured memory_bytes: 61928
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int P = 100000;
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		long x[] = new long[n];
		x[0] = 0;
		for(int i=1;i<n;i++) {
			x[i] = sc.nextLong() + x[i-1];
		}
		int p = 0;
		long sum = 0;
		for(int i=0;i<m;i++) {
			int next = sc.nextInt();
			sum = (sum + abs( x[p + next] - x[p] ) ) % P;
			p = p + next;
		}
		System.out.println(sum);
	}

	public static void main(String[] args) {
		new Main().run();
	}

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

Measured memory_bytes: 13000
type t = { x : int; y : int }

let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i -> doit (sub s 0 i) (sub s (i + 1) (length s - i - 1) :: acc) in
  doit str []

let find_set s x =
  let rec doit x =
    if x <> s.(x).x then s.(x) <- {s.(x) with x = doit (s.(x).x)};
    s.(x).x in
  doit x

let unite s x y =
  let (a, b) = (find_set s x, find_set s y) in
  if s.(a).y > s.(b).y then s.(b) <- {s.(b) with x = a}
  else begin
    s.(a) <- {s.(a) with x = b};
    if s.(a).y = s.(b).y then s.(b) <- {s.(b) with y = s.(b).y + 1}
  end

let same_p s x y = find_set s x = find_set s y

let solve n q =
  let s = Array.init n (fun i -> { x = i; y = 0}) in
  let rec doit i =
    if i < q then begin
      begin match List.map int_of_string (split (read_line ()) ' ') with
      | 0 :: x :: y :: _ -> unite s x y
      | 1 :: x :: y :: _ -> print_endline (if same_p s x y then "1" else "0")
      | _ -> ()
      end;
      doit (i + 1)
    end in
  doit 0

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; q] -> solve n q
  | _ -> ()

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

int main(){
    int m, n;
    cin >> m >> n;
    vector<int> a(n);
    int sum = 0;

    rep(i, n){
        cin >> a.at(i);
        sum += a.at(i);
    }

    int ans = m - sum;
    

    if(ans >= 0){
        cout << ans << endl;
        } else 
        cout << "-1" << endl;

}


Measured memory_bytes: 3628