akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

struct edge{
    int b,t,c;
};

vector<edge> e;
int v=0; // 途中の頂点の個数

void put_e(int a,int ofs){ // +ofs a bit分の経路を作ろう
    if(a==0){
        e.push_back({0, -1, ofs});
    }else if(a==1){
        e.push_back({0, -1, ofs});
        e.push_back({0, -1, ofs+1});
    }else{
        int bef=0;
        if(ofs){
            e.push_back({0,++v,ofs});
            bef=v;
        }
        REP(i,a){
            if(i==a-1){
                e.push_back({bef, -1, (1 << i)});
                e.push_back({bef, -1, 0});
            }else{
                e.push_back({bef, ++v, (1 << i)});
                e.push_back({bef,   v, 0});
            }
            bef=v;
        }
        //e.push_back()
    }
}

int main(){
    int l;
    cin>>l;
    stack<bool> b;
    
    int o=0;
    bool stat=false;
    REPR(i,20){
        if(l&bit(i)){
            if(!stat){
                REP(j,i){
                    if(j==i-1){
                        e.push_back({v, -1, (1 << j)});
                        e.push_back({v, -1, 0});
                    }else{
                        e.push_back({v, v + 1, (1 << j)});
                        e.push_back({v, v + 1, 0});
                        v++;
                    }
                }
                stat=true;
            }else{
                e.push_back({i,-1,o});
            }
            o+=bit(i);
        }
    }
    cout<<v+2<<" "<<sz(e)<<endl;
    for(edge a:e){
        if(a.t==-1)a.t=v+1;
        cout<<a.b+1<<" "<<a.t+1<<" "<<a.c<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <algorithm>
#include <iterator>
#include <vector>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;

    string a;
    cin >> a;

    string b;
    b = a.substr(M - 1,1);

    if(N == M){
        if(b == "A"){
            cout << a.substr(0,M-1) << "a"  << endl;
        }else if(b == "B"){
            cout << a.substr(0,M-1) << "b"  << endl;
        }else{
            cout << a.substr(0,M-1) << "c"  << endl;
        }
    }else{

        if(b == "A"){
            cout << a.substr(0,M-1) << "a" << a.substr(M, N-M) << endl;
        }else if(b == "B"){
            cout << a.substr(0,M-1) << "b" << a.substr(M, N-M) << endl;
        }else{
            cout << a.substr(0,M-1) << "c" << a.substr(M, N-M) << endl;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
int n, h; cin >> n >> h;
vector<int> a(n), b(n); 
for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
sort(begin(a), end(a));
sort(begin(b), end(b));
int ans = 1e9, sum = 0;
for (int i = 0; i < n; ++i) sum += b[n-1-i], ans = min(ans,  i+1 + max(0, (h - sum + a[n-1]-1) / a[n-1]));
cout << ans << endl;
}

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

const int mod = 998244353;

int main() {
	int n;
	cin >> n;
	vector<int> cnt_in_depth(n), d(n);
	int f;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		f = d[0];
	}
	sort(begin(d), end(d));
	if (f != 0 || d[0] != 0) {
		cout << 0;
		return 0;
	}
	cnt_in_depth[0] = 1;
	int res = 1;
	for (int i = 1; i < n; i++) {
		int x = d[i];
		res = (1ll * res * (cnt_in_depth[x - 1])) % mod;
		cnt_in_depth[x]++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define mp make_pair
using namespace std;
using ll = long long;
const ll INF = 1LL << 30;
const ll LINF = 1LL << 60;
const double eps = 1e-5;
const ll MOD = 1000000007LL;
template <typename T>
void chmin(T& a, T b) {
    a = min(a, b);
};
template <typename T>
void chmax(T& a, T b) {
    a = max(a, b);
};
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
struct P {
    double x, y;
};
bool cmp(P& p1, P& p2) {
    if(p1.x == p2.x) {
        return p1.y < p2.y;
    }
    return p1.x < p2.x;
}
int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int n;
    cin >> n;
    if(x1 > x2) {
        swap(x1, x2);
        swap(y1, y2);
    }
    vector<ll> vv;
    vv.push_back(y1);
    vv.push_back(y2);
    vector<P> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i].x >> v[i].y;
        vv.push_back(v[i].y);
    }
    sort(all(vv));
    map<ll, ll> mp;
    for(int i = 0; i < vv.size(); i++) {
        mp[vv[i]] = i;
    }
    sort(all(v), cmp);
    vector<int> dp(vv.size() + 1, INF);
    double ans = 100.0 * (abs(y1 - y2) + abs(x1 - x2));
    double s;
    if(y1 < y2) {
        for(int i = 0; i < n; i++) {
            if(x1 <= v[i].x && v[i].x <= x2 && y1 <= v[i].y && v[i].y <= y2) {
                *lower_bound(all(dp), mp[v[i].y]) = mp[v[i].y];
            }
        }
        s = lower_bound(all(dp), INF) - dp.begin();

    } else {
        for(int i = 0; i < n; i++) {
            if(x1 <= v[i].x && v[i].x <= x2 && y2 <= v[i].y && v[i].y <= y1) {
                *lower_bound(all(dp), -mp[v[i].y]) = -mp[v[i].y];
            }
        }
        s = lower_bound(all(dp), INF) - dp.begin();
    }
    ans -= (20.0 - 5.0 * M_PI) * s;
    if(s > min(abs(y2 - y1), abs(x2 - x1))) {
        ans += (20.0 - 5.0 * M_PI);
        ans += (2.0 * 5.0 * M_PI) - 20.0;
    }
    printf("%.15lf\n", ans);
}


Measured memory_bytes: 18160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100005],w[100005],v[100005];
int main(){
	ll n,k,ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<n;i++){
		for(int j=k;j>=w[i];j--){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			ans=max(ans,dp[j]);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int r,c,i,j;
    int table[111][111] = {};
    cin >> r >> c;
    
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
            cin >> table[i][j];
        }
    }
    //横計算
    for(i = 0; i < r+1; i++){
        int sum1 = 0;
        for(j = 0; j < c; j++){
            sum1 += table[i][j];
        }
        table[i][c] = sum1;
    }
    //縦計算
    for(i=0; i < c+1; i++){
        int sum2 = 0;
        for(j=0; j < r; j++){
            sum2 += table[j][i];
        }
        table[r][i] = sum2;
    }
    
    //先に出力を作る
    for(i = 0; i < r+1; i++){
        for(j = 0; j <c; j++){
            cout << table[i][j] << " ";
        }
        cout << table[i][c] << endl;
    }
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,x,p=0,ans=0;
  cin>>n>>x;
  vector<int> a(n),b;
  rep(i,n) cin>>a[i];
  rep(i,n){
    p+=a[i];
    b.push_back(p);
    
  }
  rep(i,n+1){
    if(b[i]<=x){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
N = int(input())
A = np.array(list(map(int, input().split())))
l = 0
r = 0
c = 0

x = 0
s = 0

while (l < len(A)):
    while (x == s):
        r += 1
        if (r > len(A)):
            break
        x = x ^ A[r-1]
        s += A[r-1]
    if (r <= len(A)):
        x = x ^ A[r-1]
        s -= A[r-1]
    r -= 1
    c += (r - l)
    x = x ^ A[l]
    s -= A[l]
    l += 1

print(c)

Measured memory_bytes: 50764
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()

#define boost ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

const ll INF=1e18;
const ll inf=1e9;
const ld eps=1e-7;
const ld pi=acos(-1);
const int dx[4]={0,0 ,1,-1};
const int dy[4]={1,-1,0,0};
const int N=1e5+11;
const int M=1e6+11;
const int mod1=998244353;
const int mod2=1e9+7;

int main(){
  int d=1;
  int a,b;
  cin>>a>>b;
  int c=0;
  while(d<b){
    c++;
    d--;
    d+=a;
  }
  cout<<c;
}


Measured memory_bytes: 256
from math import factorial
from collections import Counter


N = int(input())
strings = [input() for _ in range(N)]

sorted_strings = [''.join(sorted(s)) for s in strings]
num_strings = Counter(sorted_strings).values()

num_anagram = int(sum(factorial(num) / (factorial(num-2) * 2) if num >= 2 else 0
                      for num in num_strings))
print(num_anagram)

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

bitset<10000> osenbei[10];
int ans;
int r,c;

void dfs(int deep);

int main()
{
    while(1)
    {
        cin >> r >> c;
        if(r==0 || c==0)
            break;
        for(int i=0;i<r;i++)
            for(int j=0;j<c;j++)
            {
                int osen;
                cin >> osen;
                osenbei[i][j] = osen;
            }
        ans = 0;
        dfs(0);
        cout << ans << endl;
    }
    return 0;
}


void dfs(int deep)
{
    if(deep==r)
    {
        int up,down;
        int temp_ans = 0;
        for(int j=0;j<c;j++)
        {
            up = down = 0;
            for(int i=0;i<r;i++)
            {
                if(osenbei[i][j])
                    up++;
                else
                    down++;
            }
            temp_ans += max(up,down);
        }
        ans = max(ans,temp_ans);
        return;
    }
    dfs(deep+1);
    osenbei[deep].flip();
    dfs(deep+1);
    osenbei[deep].flip();
}

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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];

bool x[N][N];

void initialize(){
  for(int i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  for(int i=0;i<2*N-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}

void printBoard(){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(x[i][j]){
	if(row[i]!=j) return;
      }
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cout<<((row[i]==j)?"Q":".");
    }
    cout<<endl;
  }
}

void recursive(int i){
  if(i==N){
    printBoard();
    return;
  }

  for(int j=0;j<N;j++){
    if(NOT_FREE==col[j]||NOT_FREE==dpos[i+j]||NOT_FREE==dneg[i-j+N-1]) continue;
    row[i]=j;
    col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
    recursive(i+1);
    row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
  }
}

int main(){
  initialize();

  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++) x[i][j]=false;
  }

  int k;
  cin>>k;
  for(int i=0;i<k;i++){
    int r,c;
    cin>>r>>c;
    x[r][c]=true;
  }

  recursive(0);

  return 0;
}



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

int main(){
  int N; cin >> N;
  int A[20],B[20],C[20];
  for(int i=0; i<N; i++) cin >> A[i];
  for(int i=0; i<N; i++) cin >> B[i];
  for(int i=0; i<N-1; i++) cin >> C[i];
  
  int sum=0;
  int prev=-1;
  for(int i=0; i<N; i++){
    sum+=B[A[i]-1];
    if(prev==A[i]-1) sum+=C[prev-1];
    prev=A[i];
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 256
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 line = "";

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            char[] str = line.toCharArray();
            char c;
            int u;
            for (int i = 0; i < str.length / 2; i++) {
                c = str[i];
                u = str.length - 1 - i;
                str[i] = str[u];
                str[u] = c;
            }
            System.out.println(str);
        }
    }
}

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

int main() {
  int H,W;
  cin >> H >> W;
  for (int i=-2; i<W; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i=0; i<H; i++) {
    cout << '#';
    string s;
    cin >> s;
    cout << s;
    cout << '#' << endl;
  }
  for (int i=-2; i<W; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 256
import heapq
def sol(inp=input):
    s=3
    n,m=map(int,inp().split())
    G={(i+1,j):set() for i in range(n) for j in range(s)}
    for _ in range(m):
        u,v=map(int,inp().split())
        for i in range(s):
            G[(u,i)].add((v,(i+1)%s))
    s,t=map(int,inp().split())
    visited={(s,0)}
    que=[]
    heapq.heappush(que,(0,(s,0)))
    while len(que)>0:
        step,u=heapq.heappop(que)
        for v in G[u]:
            if v not in visited:
                visited.add(v)
                heapq.heappush(que,(step+1,v))
            if v==(t,0):
                return (step+1)//3
    return -1
print(sol())

Measured memory_bytes: 142072
#include <stdio.h>

int main (){
	int h, a;
	scanf("%d %d", &h, &a);
	scanf("%d\n", h / a + 1);
	
	h % a == 0 ? printf("%d\n", h / a) : printf("%d\n", h / a + 1);
	
	return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll memo[1001];
int calc(int idx, vector<string>& v){
  int N = v.size();
  if(idx == N) return 1;
  if(memo[idx] != -1) return memo[idx];
  ll &res = memo[idx];
  res = 0;
  string s;
  string mask[4] = {
    "0xxxxxxx",
    "110yyyyx10xxxxxx",
    "1110yyyy10yxxxxx10xxxxxx",
    "11110yyy10yyxxxx10xxxxxx10xxxxxx"
  };
  for(int l = 0; l < 4; l++){
    if(idx + l == N) return res;
    s += v[idx + l];
    bool y_judge[256] = {};
    bool ok = true;
    REP(i, mask[l].size()) {
      if(mask[l][i] == 'y'){
        y_judge[s[i]] = true;
      }
      if(mask[l][i] == '0' && s[i] == '1') ok = false;
      if(mask[l][i] == '1' && s[i] == '0') ok = false;
    }
    if(l >= 1 && !y_judge['x'] && !y_judge['1']) ok = false;
    if(!ok) continue;
    ll cnt1 = 1, cnt2 = 1;
    REP(i, mask[l].size()){
      if(mask[l][i] == 'y' && s[i] == 'x') cnt1 <<= 1;
      if(mask[l][i] == 'x' && s[i] == 'x') cnt2 <<= 1;
    }
    if(l >= 1 && !y_judge['1']) cnt1--;
    cnt1 %= 1000000;
    cnt2 %= 1000000;
    ll add = cnt1 * cnt2 * calc(idx + 1 + l, v);
    res += add % 1000000;
    res %= 1000000;
  }
  return res;
}
int main(){
  int N;
  while(cin>>N && N){
    vector<string> v(N);
    REP(i, N) cin>>v[i];
    memset(memo, -1, sizeof(memo));
    cout<<calc(0, v)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1992
import decimal,math
from collections import Counter,defaultdict
from fractions import gcd
from bisect import bisect_right,bisect_left
decimal.getcontext().prec = 100
 
s = (raw_input())
t = (raw_input())
n=len(s)
m=len(t)
dp=[]
for i in range(n+1):
	lp=[]
	for j in range(m+1):
		lp.append(0)
	dp.append(lp)
# ans=""	
for i in range(0,n+1):
	for j in range(0,m+1):
		if(i==0 or j==0):
			continue
		if(s[i-1]==t[j-1]):
			dp[i][j]=1+dp[i-1][j-1]
			# ans=ans+s[i-1]
		else:
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])
			# if(dp[i][j]==dp[i-1][j]):
			# 	ans=ans+s[i-1]
			# else:
			# 	ans=ans+t[j-1]
ii = dp[n][m]
ans=""
i=n
j=m
while(i>0 and j>0):
	if(s[i-1]==t[j-1]):
		ans=ans+s[i-1]
		i=i-1
		j=j-1
	elif(dp[i-1][j]>dp[i][j-1]):
		i=i-1
	else:	
		j=j-1	
print ans[::-1]		

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

int main(){
  int N; cin>>N;
  int h[105];
  for(int i=0;i<N;i++) cin>>h[i];
  int ans = 0;
  int l = 0;
  while(l < N){
    l = 0;
    while(h[l] == 0) l++;
    if(l >= N) break;
    for(int r=l;r<N;r++){
      if(h[r] == 0) break;
      else h[r]--;
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
typedef long long ll;

class UnionFind{
  int v[200000];
  int deep[200000];
  public:
  UnionFind(){
    for(int i=1;i<200000;i++){
      v[i]=i;
      deep[i] = 0;
    }
  }

  int root(int x){
    if(v[x]==x)return x;
    else return v[x] = root(v[x]);
  }

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

  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(deep[x] > deep[y]){
            v[y] = x;
    }else{
      if(deep[x] == deep[y])deep[y]++;
      v[x] = y;
    }
    return;
  }
};

using namespace std;

int main(){
  UnionFind uf;
  ll i,j,k,n,m,l;
  cin >> n >> m;
  for(i=0;i<m;i++){
    int x,y,z;
    cin >> x >> y >> z;
    uf.unite(x,y);
  }
  bool ch[n+1]={};
  int cnt=0;
  for(i=1;i<=n;i++){
    if(ch[uf.root(i)]==0){
      ch[uf.root(i)]=1;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int n;
    string s;
    cin>>n>>s;
    //S=1,W=2
    for(int x=1;x<=2;x++){
        for(int y=1;y<=2;y++){
            int a[100001]={};
            a[0]=x,a[1]=y;
            for(int i=1;i<n;i++){
                if(a[i]==1){
                    if(s[i]=='o'){
                        a[i+1]=a[i-1];
                    }
                    if(s[i]=='x'){
                        if(a[i-1]==1) a[i+1]=2;
                        else a[i+1]=1;
                    }
                }
                if(a[i]==2){
                    if(s[i]=='x'){
                        a[i+1]=a[i-1];
                    }
                    if(s[i]=='o'){
                        if(a[i-1]==1) a[i+1]=2;
                        else a[i+1]=1;
                    }
                }
            }
            bool ok=false;
            if(a[0]==a[n]){
                if(a[0]==1){
                    if((s[0]=='o'&&a[n-1]==a[1])||(s[0]=='x'&&a[n-1]!=a[1])) ok=true;
                }
                if(a[0]==2){
                    if((s[0]=='x'&&a[n-1]==a[1])||(s[0]=='o'&&a[n-1]!=a[1])) ok=true;
                }
            }
            if(ok){
                for(int i=0;i<n;i++){
                    if(a[i]==1) cout<<'S';
                    else cout<<'W';
                }
                cout<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 896
if __name__ == '__main__':
    ans = float("inf")
    n = int(input())
    a = list(map(int, input().split()))

    b = [0]*n
    b[0] = a[0]
    for i in range(1,n):
        b[i] = a[i] + b[i-1]

    for i in range(0,n-1):
        ans = min(ans, abs(2*b[i]-b[n-1]))
    print(ans)


Measured memory_bytes: 24960
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll seg[1000001];
ll ht[1000001];
ll arr[1000001];
ll n;
void update(ll low,ll high,ll index,ll pos,ll val)
{
    if(low>high or low>pos or high<pos)
        return;
    if(low==high)
    {
        seg[index]=val;
        return;
    }
    ll mid = (low+high)/2;
    update(low,mid,2*index,pos,val);
    update(mid+1,high,2*index+1,pos,val);
    seg[index] = max(seg[2*index],seg[2*index+1]);
}
ll query(ll low,ll high,ll index,ll l,ll r)
{
    if(low>high or low>r or high<l)
        return 0;
    if(low>=l and high<=r)
        return seg[index];
    ll mid = (low+high)/2;
    return max(query(low,mid,2*index,l,r),query(mid+1,high,2*index+1,l,r));
}
signed main()
{
    fast;
    cin>>n;
    ll i;
    for(i=0;i<n;i++)
        cin>>ht[i];
    for(i=0;i<n;i++)
        cin>>arr[i];
    ll ans = 0;
    for(i=0;i<n;i++)
    {
        ll p = arr[i]+query(0,n,1,0,ht[i]-1);
        update(0,n,1,ht[i],p);
        ans = max(ans,p);
    }
    cout<<ans;
}

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

#define LMAX 105

int FindNumber(char c,char s[]);

int main(void){
	char w[LMAX],loop;
	scanf("%s",w);
	if(strlen(w)%2!=0){
		printf("No\n");
		return 0;
	}else{
		for(loop='a';loop<='z';loop++){
			if(FindNumber(loop,w)%2!=0){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

int FindNumber(char c,char s[]){
	int num=0,i;
	for(i=0;s[i]!='\0';i++){
		if(s[i]==c){
			num++;
		}
	}
	return num;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 998244353
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

ll modpow(ll a, ll b){
    ll ans=1;
        while(b>0){
        if(b%2==1)ans=ans*a%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

int main(){

    int n,m,k;
    cin>>n>>m>>k;

    vl pow_m1(n);
    ll num=1;
    rep(i,n){
        pow_m1[i]=num;
        num=(num*(m-1))%MOD;
    }

    vl n1Ck(k+1);

    vl factorial(n),inverse(n);
    factorial[0]=1;
    inverse[0]=1;
    repa(i,1,n){
        factorial[i]=(factorial[i-1]*i)%MOD;
        inverse[i]=modpow(factorial[i],MOD-2)%MOD;
    }
    rep(i,k+1){
        n1Ck[i]=(((factorial[n-1]*inverse[i])%MOD)*inverse[n-1-i])%MOD;
    }

    ll ans=0;

    rep(i,k+1){
        // cerr<<i<<"  n-1Ci="<<n1Ck[i]<<"  pow_m1[n-i-1]="<<pow_m1[n-i-1]<<"\n";
        // ans=(ans+(n1Ck[i]*(m*pow_m1[n-i-1])%MOD)%MOD)%MOD;
        ll tmp=(m*pow_m1[n-i-1])%MOD;
        tmp=(n1Ck[i]*tmp)%MOD;
        ans=(ans+tmp)%MOD;

        // cerr<<ans<<"\n\n";
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 9528
#include<bits/stdc++.h>
using namespace std;
int n;
int a[21];
int b[21];
int c[21];
int res=0;
int main()
{
  cin>>n;
  for(int i=1;i<=n;i++)
      cin>>a[i];
  for(int i=1;i<=n;i++)
      cin>>b[i];
  for(int i=1;i<=n-1;i++)
      cin>>c[i];
  a[0]=-1;
  for(int i=1;i<=n;i++)
      {res+=b[a[i]];
       if(a[i]==a[i-1]+1) res+=c[a[i-1]];}
  cout<<res;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define BIG 100000000

ll  lcm(ll a,ll b)
{
    ll GCD=__gcd(a,b);
    ll lcm=(a*b)/GCD;
    return lcm;
}
ll dp[100005];
ll weight[1000005],value[1000005];
ll total,val;
ll call(ll n)
{
    if(n>=total)
        return 0;

    if(dp[n]!=-1)
        return dp[n];

    ll res1=BIG,res2=BIG;

   // if(weight[n]+c<=val)
    res1=abs(weight[n]-weight[n+1]) + call(n+1);
    if(n+2<=total) res2=abs(weight[n]-weight[n+2]) + call(n+2);
    //cout<<n<<" "<<res1<<" "<<res2<<endl;
    dp[n]=min(res1,res2);
    return dp[n];

}
int main()
{
    cin>>total;
    for ( int i = 1; i <=total; ++i )
        cin>>weight[i];

    memset(dp, -1, sizeof(dp));
    ll ret=call(1);
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
struct nian
{
    char name[20];
    int l,r;
}year[1005];
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        if(n==0&&m==0) break;
        for(int i=0;i<n;i++)
        {
            scanf("%s %d %d",year[i].name,&year[i].l,&year[i].r);
            year[i].l=year[i].r-year[i].l+1;
        }
        while(m--)
        {
            int tmp,k=-1,flag;
            scanf("%d",&tmp);
            for(int i=0;i<n;i++)
            {
                if(tmp>=year[i].l&&tmp<=year[i].r)
                {
                    flag=i;
                    k=tmp-year[i].l+1;
                    break;
                }
            }
            if(k==-1) puts("Unknown");
            else
            {
                printf("%s %d\n",year[flag].name,k);
            }
        }
    }
    return 0;
}

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, k, i;
  cin >> k >> n;
  vi arr(n + 1);
  REP(i, 0, n)  cin >> arr[i];
  arr[n] = arr[0] + k;

  int l = 0;
  REP(i, 0, n)
    l = max(l, arr[i + 1] - arr[i]);

  int ans = k - l;

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


Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;

int N;
vector<P> a;

bool compare_y(P a, P b) {
  return a.second < b.second;
}

// [l, r)
double closest_pair(int l, int r) {
  int n = r - l;
  if(r - l <= 1) return 2e9; // 1点しかない
  int m = (l + r) / 2;
  int x = a[m].first;
  int d = min(closest_pair(l, m), closest_pair(m, r));
  inplace_merge(a.begin() + l, a.begin() + m, a.begin() + r, compare_y); // 二つのソート済み配列をマージする 範囲指定->(先頭,中間,最後)

  vector<P> b;
  FOR(i,l,r){
    if(abs(a[i].first - x) >= d) continue;
    FOR(j,0,b.size()){
      // 近いものから見て行く
      int dx = a[i].first - b[b.size() - j - 1].first;
      int dy = a[i].second - b[b.size() - j - 1].second;
      if(dy >= d) break; // 枝狩り?
      d = min(d, dx * dx + dy * dy);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  a.resize(N);
  FOR(i,0,N)cin>>a[i].first>>a[i].second;
  sort(a.begin(), a.end());
  cout<<closest_pair(0, N)<<endl;

}


Measured memory_bytes: 12488
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	ll n,v[mx],c[mx],i,j;
	cin>>n;
	for(i=0;i<n;i++){
	    cin>>v[i];
	    
	}
	for(i=0;i<n;i++){
	    cin>>c[i];
	    
	}
	ll ans=0;
	for(i=0;i<n;i++){
	    if(v[i]-c[i]> 0)
	    ans+= (v[i]-c[i]);
	    
	}
	cout<<ans;
    return 0;
}























Measured memory_bytes: 2304
use std::io::Read;
use std::collections::HashSet;

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

    let answer = solve(&buf);

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

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

    let s = iterator.next().unwrap();

    let mut set_list: Vec<HashSet<char>> = vec![HashSet::new(); s.len()];
    for (i, c) in s.chars().enumerate() {
        set_list[i].insert(c);
    }

    let mut done = false;
    let mut count = 0;
    while !done {
        for c in 'a' as u8..'z' as u8 + 1 {
            let c = c as char;
            if set_list.iter().all(|set| set.contains(&c)) {
                done = true;
                break;
            }
        }
        if !done {
            for i in 0..(set_list.len() - 1) {
                let next = set_list[i + 1].clone();
                set_list[i].extend(next);
            }
            set_list.pop();
            count += 1;
        }
    }

    return count.to_string();
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
    }
    Arrays.sort(a);
    Arrays.sort(b);
    int ans = a[N-1] + b[0];
    System.out.println(ans);
  }
}


Measured memory_bytes: 87400
import sys


def check(newLine, index, row, col):
    count = 0

    # 左と右
    if index % col != 0:# 0列でない
        if newLine[index - 1] == "#":
            count += 1
    if index % col != col - 1:# 末列でない
        if newLine[index + 1] == "#":
            count += 1
    # 上と下
    if index >= col: #首行でない
        if newLine[index - col] == "#":
            count += 1
    if index < col * (row - 1):#末行でない
        if newLine[index + col] == "#":
            count += 1

    # 上の左と右 0 <= index + col + 1 < len(newLine) and
    if index >= col and index % col != 0: #首行でない かつ　0列でない
        if newLine[index - col - 1] == "#":
            count += 1
    if index >= col and index % col != col - 1: #首行でない かつ　末列でない
        if newLine[index - col + 1] == "#":
            count += 1
    # 下の左と右
    if index < col * (row - 1) and index % col != 0:
        if newLine[index + col - 1] == "#":
            count += 1
    if index < col * (row - 1) and index % col != col - 1:
        if newLine[index + col + 1] == "#":
            count += 1

    newLine[index] = str(count)
    return newLine


def main(row,col,lines):

    newLine = list("".join(lines))
    for index, value in enumerate(newLine):
        if value == ".":
            newLine = check(newLine, index, row, col)
    for i in range(0, len(newLine), col):
        print("".join(newLine[i:i + col]))


if __name__ == '__main__':
    #lines = ['6 6', '#####.', '#.#.##', '####.#', '.#..#.', '#.##..', '#.#...']
    # lines = ['6 5', '.##.#', '.####', '..##.', '..#..', '.....', '.....']
    #lines = ['3 5', '.....', '.#.#.', '.....']

    row, col = map(int, input().split())
    lines = list(str(input()) for i in range(row))
    #lines = []
    #for l in sys.stdin:
    #    lines.append(l.rstrip('\r\n'))
    main(row,col,lines)


Measured memory_bytes: 3188
#include<cstdio>
#include<iostream>
#define MAX 100000
#define INF 1000000001
using namespace std;

struct Card {

    char suit;
    int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card C[], int left, int mid, int right) {

    int n1, n2, i, j, k;
    n1 = mid - left;
    n2 = right - mid;
    for (i = 0; i < n1; i++) {
	L[i].suit = C[left+i].suit;
	L[i].value = C[left+i].value;

    }
    for (i = 0; i < n2; i++) {
	R[i].suit = C[mid+i].suit;
	R[i].value = C[mid+i].value;

    }
    L[n1].value = INF;
    R[n2].value = INF;
    i = 0;
    j = 0;
    for (k = left; k < right; k++) {
	if (L[i].value <= R[j].value) {
	    C[k].suit = L[i].suit;
	    C[k].value = L[i].value;
	    i++;
	}
	else {
	    C[k].suit = R[j].suit;
	    C[k].value = R[j].value;
	    j++;
	}
    }
}

void mergeSort(struct Card C[], int left, int right) {
    if (left+1 < right) {
	int mid = (left + right ) / 2;
	mergeSort(C, left, mid);
	mergeSort(C, mid, right);
	merge(C, left, mid, right);
    }
}


bool isStable(struct Card C1[], struct Card C2[], int n) {
    for (int i = 0; i < n; i++) {
	if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int partition(struct Card C[], int p, int r) {
    int x, i, j;
    x = C[r].value;
    i = p-1;
    for (j = p; j < r; j++) {
	if (C[j].value <= x) {
	    i++;
	    Card t = C[i];
	    C[i] = C[j];
	    C[j] = t;		    
	}
    }
    Card t = C[i+1];
    C[i+1] = C[r];
    C[r] = t;
 
    return i+1;
}


void quickSort(struct Card C[], int p, int r) {
    if (p < r) {
	int q = partition(C, p, r);
	quickSort(C, p, q-1);
	quickSort(C, q+1, r);
    }
}

int main() {
    
    int n, i;
    Card C1[MAX], C2[MAX];
    
    scanf("%d", &n);
    
    for(i = 0; i < n; i++) {
	//??¨???
	scanf("%*c%c", &C1[i].suit);
	scanf("%d", &C1[i].value);
    }
    
    for(i = 0; i < n; i++) {
	C2[i] = C1[i];
    }
    quickSort(C1, 0, n-1);
    mergeSort(C2, 0, n);

    // output
    if (isStable(C1, C2, n)) printf("Stable\n");
    else printf("Not stable\n");

    for (i = 0; i < n; i++) printf("%c %d\n", C1[i].suit, C1[i].value);

}

Measured memory_bytes: 3536
# AtCoder Beginner Contest 152 - B
# -*- encoding: UTF-8 -*-
a, b = map(int, input().split())

c = ""
l = ""

if a > b:
  c = b
  l = a
else:
  c = a
  l = b

st = ""
for i in range(l):
  st = st + str(c)

print(st)


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

int main(){
  cout<<setprecision(10)<<fixed;
  int n,k; cin>>n>>k;
  double ans=0;
  for(int d=1; d<=n; d++){//d:dice
    int now=d;
    double coin=1;
    while(now<k){
      now*=2;
      coin*=(double)1/2;
    }
    ans+=coin;
  }
  double p=1/(double)n;
  ans*=p;
  cout<<ans<<endl;
}



Measured memory_bytes: 3736
#include<stdio.h>
int main(){
	long int a,b,n;
	long int p[80000];
	p[0]=2;
	n=1;
	for(a=3;a<1000000;a++){
		for(b=0;b<n;b++){
			if(a%p[b]==0){break;}
			if(a/p[b]<p[b]){
				p[n]=a;
				n++;
				break;
			}
		}
	}
	p[n]=1000000;
	for(;;){
		if(scanf("%ld",&a)==EOF){break;}
		n=0;
		while(a>=p[n]){
			n++;
		}
		if(a<2){n=0;}
		printf("%ld\n",n);
	}
	return 0;
}

Measured memory_bytes: 572
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;using ull=unsigned long long;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

class mod_int{
private:
    ull mod,cnt_div;
    map<ull,ull>inv;
    ull pow_mod(ull x,ull y){x%=mod;return(y==0?1:y%2==0?pow_mod(x*x%mod,y/2):x*pow_mod(x,y-1))%mod;}
public:
    mod_int(ull mod,ull max_pos_arg=0,ull cnt_div=2):mod(mod),cnt_div(cnt_div){}
    ull operator()(ull n){return n%mod;}
    ull plus (ull lhs,ull rhs){lhs%=mod;rhs%=mod;return(lhs+rhs)                                                          %mod;}
    ull minus(ull lhs,ull rhs){lhs%=mod;rhs%=mod;return(max(lhs,rhs)-min(lhs,rhs))                                        %mod;}
    ull multi(ull lhs,ull rhs){lhs%=mod;rhs%=mod;return(lhs*rhs)                                                          %mod;}
    ull div  (ull lhs,ull rhs){lhs%=mod;rhs%=mod;return(inv.count(rhs)?lhs*inv[rhs]:lhs*(inv[rhs]=pow_mod(rhs,mod-cnt_div)))%mod;}
};
constexpr ll mod=1000000007,sz=100000;
mod_int mi(mod,sz);
vector<ll>fact_mod(sz+1);
ll stair_mod(ll n)
{
    ll ret=0;
    for(ll a=n,b=0;a>=0;a-=2,b+=1)ret=mi.plus(ret,mi.div(mi.div(fact_mod[a+b],fact_mod[a]),fact_mod[b]));
    return ret;
}
int main()
{
    fact_mod[0]=1;REP1(i,sz)fact_mod[i]=fact_mod[i-1]%mod*i%mod;

    ll n=in(),m=in();
    vector<ll>a(m);REP(i,m)a[i]=in();a.push_back(n+1);

    ll now=0,ans=1;
    REPC(ai,a){
        ans=mi.multi(ans,stair_mod(ai-now-1));
        now=ai+1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    long long n, d;
    cin >> n >> d;
    d = d*d;
    int ans = 0;
    for (int i=0; i<n; ++i) {
        long long x, y;
        cin >> x >> y;
        long long nd = x*x + y*y;
        if (nd <= d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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

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

int main() {
	ll h, n;
	cin >> h >> n;
	vector<int> a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	puts(sum >= h ? "Yes" : "No");

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve(int N) {
    VI a(N);
    for_each(ALL(a), [](int &e){cin >> e;});
    SORT(a);
    int ans = INF;
    REP(i, N - 1) ans = min(ans, a[i + 1] - a[i]);
    cout << ans << endl;
    return;
}

signed main(void) {
    LL n, m, p, a, b, c, x, y, z, q;
    string s;
    bool f = false;
    while (cin >> n, n) {
        solve(n);
        //return 0;
    }
}

Measured memory_bytes: 3040
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=1e6+6;
int a[N],b[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	
	if(n&1){
		printf("%d",b[n/2+n%2]-a[n/2+n%2]+1);
	}
	else{
		int ans=(((b[n/2+1]+b[n/2])/2.0)-((a[n/2+1]+a[n/2])/2.0))*2+1;
		printf("%d",ans);
	}
}


Measured memory_bytes: 5400
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long
#define MOD 1000000007

int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  for(int i=0; i<N; i++)
    cin >> C[i];
  C.push_back(0);
  vector<int> next(N, -1);
  {
    map<int, int> tmp;
    for(int i=0; i<N; i++) {
      if(C[i] != C[i+1]) {
	if(tmp.find(C[i]) != tmp.end()) {
	  next[tmp[C[i]]] = i;
	  tmp[C[i]] = i;
	} else {
	  tmp[C[i]] = i;
	}
      }
    }
  }

  vector<ll> dp(N, 0);
  dp[0] = 1;
  for(int i=0; i<N; i++) {
    if(i != 0) {
      dp[i] += dp[i-1];
      dp[i] %= MOD;
    }
    if(next[i] != -1) {
      dp[next[i]] += dp[i];
      dp[next[i]] %= MOD;
    }
  }
  cout << dp[N-1] << endl;

  return 0;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

template<int64 mod>
struct ModInt{
  int64 x;
  constexpr ModInt(int64 y = 0):x((y%mod+mod)%mod){}
  constexpr ModInt& operator+=(const ModInt& a){
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  constexpr ModInt& operator-=(const ModInt& a){
    if((x -= a.x) < 0)x += mod;
    return *this;
  }
  constexpr ModInt& operator*=(const ModInt& a){
    x = x * a.x % mod;
    return *this;
  }
  constexpr ModInt& operator/=(const ModInt& a){
    *this *= a.inv();
    return *this;
  }
  constexpr ModInt operator-() const {
    return ModInt(-x);
  }
  constexpr ModInt operator+(const ModInt& a) const {
    return ModInt(*this) += a;
  }
  constexpr ModInt operator-(const ModInt& a) const {
    return ModInt(*this) -= a;
  }
  constexpr ModInt operator*(const ModInt& a) const {
    return ModInt(*this) *= a;
  }
  constexpr ModInt operator/(const ModInt& a) const {
    return ModInt(*this) /= a;
  }
  constexpr ModInt operator++(){
    *this += ModInt(1);
    return *this;
  }
  constexpr ModInt operator++(int){
    ModInt old = *this;
    ++*this;
    return old;
  }
  constexpr ModInt operator--(){
    *this -= ModInt(1);
    return *this;
  }
  constexpr ModInt operator--(int){
    ModInt old = *this;
    --*this;
    return old;
  }
  constexpr bool operator==(const ModInt& a) const {
    return x == a.x;
  }
  constexpr bool operator!=(const ModInt& a) const {
    return x != a.x;
  }
  constexpr ModInt pow(int64 r) const {
    if(!r)return 1;
    ModInt res = pow(r>>1);
    res *= res;
    if(r & 1) res *= *this;
    return res;
  }
  constexpr ModInt inv() const {
    return pow(mod-2);
  }
  friend istream& operator>>(istream& is, ModInt& a){
    int64 t;
    is >> t;
    a = ModInt(t);
    return is;
  }
  friend ostream& operator<<(ostream& os, const ModInt& a){
    return os << a.x;
  }
};
using mint = ModInt<MOD>;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  vector<mint> fact(r2+c2+3,1);
  REP(i,r2+c2+2){
    fact[i+1] = fact[i] * (mint)(i+1);
  }
  vector<mint> invfact(r2+c2+3);
  invfact[r2+c2+2] = fact[r2+c2+2].inv();
  FORR(i,r2+c2+1,0){
    invfact[i] = invfact[i+1] * (mint)(i+1);
  }
  auto comb = [&](int32 n, int32 r){
    return fact[n] * invfact[r] * invfact[n-r];
  };
  auto g = [&](int32 x,int32 y){
    return comb(x+y+2,x+1) - 1;
  };
  mint ans = g(r2,c2) - g(r1-1,c2) - g(c1-1,r2) + g(c1-1,r1-1);
  ANS(ans);
  return 0;
}

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

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    int cnt, ans = t.size();
    for (int i = 0; i <= s.size() - t.size(); ++i)
    {
        cnt = 0;
        for (int j = 0; j < t.size(); ++j)
        {
            cnt += s.at(i + j) != t.at(j);
        }
        ans = std::min(ans, cnt);
    }

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

Measured memory_bytes: 3628
using System;
class Program
{
	static void Main(string[] args)
	{
		// 入力
		string s = Console.ReadLine();

    if (Char.IsUpper(Convert.ToChar(s)))
    {
      Console.WriteLine("A");  
    }
    else
    {
      Console.WriteLine("a");  
    }
  }
}

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

using namespace std;

int main() {
    int n, a[101];
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    int r = 5000000;
    for(int m=-100; m<=100; m++) {
        int t = 0;
        for(int i=0; i<n; i++) {
            int c = a[i] - m;
            t += c * c;
        }
        r = min(r, t);
    }
    cout << r << endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    top = a[0]
    ans = 0

    for i in range(n):
        if a[i] < top:
            ans += top - a[i]
        else:
            top = a[i]

    print(ans)


main()


Measured memory_bytes: 32256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a == b) {
			System.out.println(c);
		} else if (a == c) {
			System.out.println(b);
		} else {
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 23636
N = input()
MM = input().split()
list1 =[]
for i in MM:
  x = int(i)
  list1.append(x)
list1.sort(reverse = True)
total = 0
for i in range(len(list1)):
  if i%2 ==0:
    total += list1[i]
  else:
    total -= list1[i]
print(total)

Measured memory_bytes: 8972
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int s, arg = 2;
	scanf("%d", &s);
	set<int> a;
	for(; ; ++arg)
	{
		a.insert(s);
		if(s % 2)
		{
			s = 3 * s + 1;
		}
		else
		{
			s /= 2;
		}
		if(a.find(s) != a.end())
		{
			printf("%d\n", arg);
			return 0;
		}
	}
}

Measured memory_bytes: 256