akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main()
{

    string s;
    cin >> s;

    bool ok = true;

    for (int i = 0; i < s.length(); ++i)
    {
        if (i % 2 == 0)
        {
            if (s[i] == 'L')
                ok = false;
        }
        else
        {
            if (s[i] == 'R')
                ok = false;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}

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


#define M_MAX 20
#define N_MAX 50000
#define INFTY 1 << 29


int main(){


long long int n;
cin >> n;
int a=n/1000;
n-=(n/1000)*1000;
int b=n/100;
n-=(n/100)*100;
int c=n/10;
n-=(n/10)*10;
int d=n;

int N=3;

for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
	string t="---";
        for (int i = 0; i < (int)S.size(); ++i) {
            t[S[i]]='+';
        }
	int temps=0;
	if(t[0]=='-'){temps+=a;temps-=b;}
	else{temps+=a;temps+=b;}
	if(t[1]=='-'){temps-=c;}
	else{temps+=c;}
	if(t[2]=='-'){temps-=d;}
	else{temps+=d;}
	if(temps==7){
	cout << a<<t[0]<<b<<t[1]<<c<<t[2]<<d<<"=7";
	break;
	}

    }



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h1,m1,h2,m2,k;
    int t1,t2;
    int s,t;
    cin>>h1>>m1>>h2>>m2>>k;
    t1=h1*60+m1;
    t2=h2*60+m2;
    t=t2-t1;
    s=t-k;
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sca = new Scanner(System.in);
		int x1 = sca.nextInt();
		int x2 = sca.nextInt();
		int x3 = sca.nextInt();
		if((x1 + x2 + x3) >= 22) {
			System.out.println("bust");
		}
		else {
			System.out.println("win");
		}

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int H,N;
    cin >> H >> N;
    int A[N];
    rep(i,N) cin >> A[i];

    sort(A,A+N,greater<int>());

    int atk = 0;
    rep(i,N){
        atk += A[i];
        if(atk>=H){
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";
    
    return 0;
}

Measured memory_bytes: 3968
#include <stdio.h>
 
typedef struct _card {
    int number;
    char suit;
} CARD;
 
CARD A[100000], I[100000];
char inputs[1000000];
char *ptr = inputs;
 
void exchange(CARD *a, CARD *b);
int Partition(CARD A[], int p, int r);
void Quicksort(CARD A[], int p, int r);
 
int nextInt(void) {
    int v = 0;
    while (*ptr < '0' || *ptr > '9') ++ptr;
    while (*ptr >= '0' && *ptr <= '9') {
        v = v * 10 + (int)(*ptr - '0');
        ++ptr;
    }
    return v;
}
 
char nextSuit(void) {
    while (*ptr < 'A' || *ptr > 'Z') ++ptr;
    return *ptr;
}
 
int main(void) {
    int n;
    int stable = 1;
    int i, j, c, d;
     
    fread(inputs, sizeof(char), 1000000, stdin);
     
    n = nextInt();
     
    for (i = 0; i < n; ++i) {
        A[i].suit = nextSuit();
        A[i].number = nextInt();
        I[i] = A[i];
    }
     
    Quicksort(A, 0, n - 1);
     
    for (i = 0; i < n; ++i) {
        if (i == 0) {
            c = 0;
        } else if (A[i].number != A[i - 1].number) {
            c = 0;
        } else {
            ++c;
        }
        d = 0;
        for (j = 0; j < n; ++j) {
            if (I[j].number == A[i].number) {
                if (c == d) {
                    if (I[j].suit != A[i].suit) {
                        stable = 0;
                    }
                    break;
                }
                ++d;
            }
        }
        if (stable == 0) {
            break;
        }
    }
     
    if (stable == 1) {
        puts("Stable");
    } else {
        puts("Not stable");
    }
     
    for (i = 0; i < n; ++i) {
        printf("%c %d\n", A[i].suit, A[i].number);
    }
     
    return 0;
}
 
void exchange(CARD *a, CARD *b) {
    CARD t = *a;
    *a = *b;
    *b = t;
}
 
int Partition(CARD A[], int p, int r) {
    CARD x = A[r];
    int i = p - 1;
    int j;
    for (j = p; j < r; ++j) {
        if (A[j].number <= x.number) {
            ++i;
            exchange(&A[i], &A[j]);
        }
    }
    exchange(&A[i + 1], &A[r]);
    return i + 1;
}
 
void Quicksort(CARD A[], int p, int r) {
    int q;
    if (p < r) {
        q = Partition(A, p, r);
        Quicksort(A, p, q - 1);
        Quicksort(A, q + 1, r);
    }
}

Measured memory_bytes: 3924
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    if (N % 2 != 0) N *= 2;
    cout << N << endl;
    return 0;
}

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


def main():
    N = int(input())
    S = []
    T = []
    for i in range(N):
        s, t = input().split()
        S.append(s.strip())
        T.append(int(t))
    x = input().strip()
    ans = sum(T)
    for i in range(N):
        ans -= T[i]
        if S[i] == x:
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[10000001];
int main(){
	long long n,m,s=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>n-m;i--)
		s+=a[i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
N, W = map(int, (input().split()))
lst = [list(map(int, input().split())) for i in range(N)]

ans = [[0]*(10**5+10) for i in range(N+10)]
  
for i in range(N):
  for j in range(W+1):
    if j >= lst[i][0]:
      ans[i+1][j] = max(ans[i][j-lst[i][0]] + lst[i][1], ans[i][j])
    else:
      ans[i+1][j] = ans[i][j]
  
print(ans[N][W])

Measured memory_bytes: 121500
from collections import defaultdict

n, x, d = map(int, input().split())
if d == 0:
  if x == 0:
    print(1)
  else:
    print(n+1)
  exit()
L = []
C = defaultdict(int)
D = defaultdict(int)
for i in range(n+1):
  q, r = divmod(x*i, d)
  a = i*(i-1)//2
  b = i*(2*n-i-1)//2
  a += q
  b += q
  L.append((a, r, 1))
  L.append((b+1, r, -1))
L.sort()
ans = 0
for p, idx, b in L:
  if C[idx] > 0:
    ans += p - D[idx]
  C[idx] += b
  D[idx] = p
print(ans)

Measured memory_bytes: 186048
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

main = do
  [n,k] <- map read . words <$> getLine
  -- 2 <= n <= 10^5, 1 <= k <= 100
  h <- V.fromListN n . map read . words <$> getLine
  -- 1 <= hi <= 10^4
  let dp = V.create $ do
        dp <- VM.new n
        VM.write dp 0 0
        forM_ [1..n-1] $ \i -> do
          c <- forM [max 0 (i-k)..i-1] $ \j -> do
            c <- VM.read dp j
            return (c + abs (h V.! i - h V.! j))
          VM.write dp i (minimum c)
        return dp
  print (V.last dp :: Int)


Measured memory_bytes: 30972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int RSPtoPnt(char jan, int r, int s, int p){
	if(jan == 'r'){
		return p;
	}
	if(jan == 's'){
		return r;
	}
	if(jan == 'p'){
		return s;
	}
}
char win(char jan){
	if(jan == 'r') return 'p';
	if(jan == 's') return 'r';
	if(jan == 'p') return 's';
}
int main(void) {
	int n,k; cin >> n >> k;
	int r,s,p; cin >> r >> s >> p;
	string t; cin >> t;
	vector<string> subs(k);
	rep(i,n) subs[i%k] += t[i];
	int ans = 0;
	rep(i,k){
		vvi dp(subs[i].size(),vi(3,0));
		if(subs[i][0]=='s') dp[0][0]+=r;
		if(subs[i][0]=='p') dp[0][1]+=s;
		if(subs[i][0]=='r') dp[0][2]+=p;
		rep2(j,1,subs[i].size()){
			dp[j][0]=max(dp[j-1][1],dp[j-1][2]);
			dp[j][1]=max(dp[j-1][0],dp[j-1][2]);
			dp[j][2]=max(dp[j-1][1],dp[j-1][0]);
			if(subs[i][j]=='s') dp[j][0]+=r;
			if(subs[i][j]=='p') dp[j][1]+=s;
			if(subs[i][j]=='r') dp[j][2]+=p;
		}
		int add = max(dp[subs[i].size()-1][0],dp[subs[i].size()-1][1]);
		add = max(add,dp[subs[i].size()-1][2]);
		ans += add;
	}
	out(ans);


}




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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int ans = 0;
  for (int i = 0; i <= 100; i++) if (i >= A && i <= B && i >= C && i <= D) ans++;
  cout << max(ans - 1, 0) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n,m) for(int i=n;i<m;i++)
#define repn1(i,n,m) for(int i=n;i<=m;i++)
#define pb push_back
using namespace std;
typedef long long ll;
const int INF = 1e+8;

int main(){

    int N, W;
    int v[1001];
    int w[1001];
    int dp[101][10001];
    cin >> N >> W;
    memset(dp, 0, sizeof(dp));
    rep(i, N)cin >> v[i] >> w[i];
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j < w[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
 
    return 0;	
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000
#define MAX_E 100010

//// UnionFind
struct UnionFind{
	vector<int> v;
	UnionFind(int n) : v(n, -1) {}

	int find(int x) { return v[x] < 0 ? x : v[x] = find(v[x]); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if (-v[x] < -v[y]) swap(x, y);
		v[x] += v[y]; v[y] = x;
	}
	bool root(int x) { return v[x] < 0; }
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

//// Minimum Spanning Tree
//// Kruskal
struct  edge{ int u,v,cost; };
bool comp(const edge& e1,const edge& e2){return e1.cost<e2.cost;}
struct Kruskal{
	int V,E;
	edge es[MAX_E];
	void init(int v){V=v;E=0;}
	void add_edge(int u,int v,int cost){
		es[E++]=(edge){u,v,cost};
	}
	int mintree(){
		sort(es,es+E,comp);
		UnionFind uf(V);
		int res=0;
		for(int i=0;i<E;i++){
			edge e=es[i];
			if(!uf.same(e.u,e.v)){
				uf.unite(e.u,e.v);
				res+=e.cost;
			}
		}
		return res;
	}
};

Kruskal ks;

int v,e;
int main(){
	cin.sync_with_stdio(false);
	cin>>v>>e;
	ks.init(v);
	rep(i,e){
		int u,v,cost;
		cin>>u>>v>>cost;
		ks.add_edge(u,v,cost);
	}
	cout<<ks.mintree()<<endl;
	return 0;
}

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

int width, height, cnt = 0, direc[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

void dfs(char **s, int x, int y)
{
  int i, next_x = 0, next_y = 0;
  cnt++;
  for(i = 0; i < 4; i++)
    {
      next_x = x + direc[i][0];
      next_y = y + direc[i][1];
      //      printf("%d %d\n", next_x, next_y);
      if(next_x >= 0 && next_x < width && next_y >= 0 && next_y < height && s[next_y][next_x] == '.')
	{
	  //      printf("hoge");
	  s[next_y][next_x] = '#';
	  dfs(s, next_x, next_y);
	}
    }
}

void search(char **s)
{
  int i, j;

  for(i = 0; i < height; i++)
    {
      for(j = 0; j < width; j++)
	{
	  if(s[i][j] == '@')
	    {
	      dfs(s, j, i);
	    }
	}
    }
}

int main(void)
{
  int x, y, i, j;
  char **s;

  while(1)
    {
      scanf("%d %d", &width, &height);
      if(width == 0 && height == 0)
	{
	  break;
	}
      s = malloc(sizeof(char *) * height);

      for(i = 0; i < height; i++)
	{
	  s[i] = malloc(sizeof(char) * (width + 1));
	  scanf("%s", s[i]);
	}
      
      search(s);
      printf("%d\n", cnt);
      cnt = 0;
      /* printf("\n"); */

      /* for(i = 0; i < y; i++) */
      /* 	{ */
      /* 	  printf("%s", s[i]); */
      /* 	  printf("\n"); */
      /* 	} */
    }
  return 0;
}

Measured memory_bytes: 780
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-12;
const long long inf = 2e12 + 12;
const int MAXN = 2000006, MAXM = 102, Mod = 1000000007 , MAXLog = 20;

vector<int> adj[MAXN];


vector<int> z(string s) {
    int n = s.size();
    vector<int> z(n);
    int x = 0, y = 0;
    for (int i = 1; i < n; i++) {
        z[i] = max(0, min(z[i - x], y - i + 1));
        while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {
            x = i;
            y = i + z[i];
            z[i]++;
        }
    }
    return z;
}


int vis[MAXN];
int val[MAXN];
int dfs(int u) {
    vis[u] = 1;
    int &ret = val[u];
    for (int v : adj[u]) {
        if (vis[v] == 1)
            return oo;
        if (vis[v] == 2)
            ret = max(ret, 1 + val[v]);
        else
            ret = max(ret, dfs(v) + 1);
    }
    vis[u] = 2;
    return ret;
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    string s;
    cin >> s;
    string t;
    cin >> t;

    string str = s;
    while (str.size() < t.size() * 2)
        str += s;

    str = t + '$' + str + str;
//    cout << str << endl;
    vector<int> match = z(str);
    for (int i = t.size() + 1; i < str.size(); ++i) {
//        cout << i << ' ' << match[i] << endl;
        if (match[i] == t.size()) {
//            cout << "edge " << i - t.size() - 1 << ' ' << (i - 1) % s.size() << endl;
            adj[(i - t.size() - 1) % s.size()].push_back((i - 1) % s.size());
        }
    }


    int ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (!vis[i]) {
            ans = max(ans, dfs(i));
        }
    }

    if (ans >= oo) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }


    return 0;
}

Measured memory_bytes: 111840
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[200010],ans;
int main() {
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++) cin>>a[i]; 
	sort(a+1,a+n+1);
	for(int i=1;i<=n-m;i++) ans+=a[i];
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let INF = 100000000000000L

let makeGraph N es =
    let g = Array.init (N + 1) (fun _ -> [])
    for [a; b; c] in es do
        g.[a] <- (b, c) :: g.[a]
        g.[b] <- (a, c) :: g.[b]
    g

let dijkstra N K (g: (int * int) list []) =
    let d = Array.create (N + 1) INF
    d.[K] <- 0L
    let mutable q = Set.singleton (0L, K)

    let rec loop () =
        if not (Set.isEmpty q) then
            let (c', v) = Set.minElement q
            q <- Set.remove (c', v) q

            if int64 c' <= d.[v] then
                let es = g.[v]
                for b, c in es do
                    let s = d.[v] + int64 c
                    if s < d.[b] then
                        d.[b] <- s
                        q <- Set.add (s, b) q

            loop ()
    loop ()

    d

[<EntryPoint>]
let main _ =
    let N = read int
    let abcs = List.init (N - 1) (fun _ -> reads int)
    let [Q;K] = reads int
    let xys = List.init Q (fun _ -> reads int)

    let graph = makeGraph N abcs
    let dijk = dijkstra N K graph

    for [x; y] in xys do
        printfn "%i" (dijk.[x] + dijk.[y])

    0

Measured memory_bytes: 75560
n=gets.to_i

v=gets.chomp.split(" ").map { | x | x.to_i}

a = {}
b = {}
v.each_with_index { | item, idx |
  if (idx % 2 == 0) then
    a[item] = (a[item] || 0) + 1
  else
    b[item] = (b[item] || 0) + 1
  end
}
as = a.keys.to_a
as.sort! { | x,y | a[y] <=> a[x] }

bs = b.keys.to_a
bs.sort! { | x,y | b[y] <=> b[x] }

#p a
#p as
#p b
#p bs

if as[0] == bs[0] && a[as[0]] + b[bs[0]] == n then
#  p "A"
  d = a[as[0]]
elsif as[0] == bs[0] && a[as[1]] > b[bs[1]] then
#  p "B"
  d = n - a[as[1]] - b[bs[0]]
elsif as[0] == bs[0] then
#  p "C"
  d = n - a[as[0]] - b[bs[1]]
else
#  p "D"
  d = n - a[as[0]] - b[bs[0]]
end
puts d


Measured memory_bytes: 25616
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	int ans = 0;
	for (int i = 1; i <= n  ; i++){
		if(to_string(i).size() % 2 == 1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3800
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)

vector<int> v;
int dp[51][51][2505];

int dfs(int used, int num, int sum){
    if(used==0){
        if(num==0 && sum==0)return 1;
        else return 0;
    }
    if(dp[used][num][sum]!=-1)return dp[used][num][sum];
    
    int ret = 0;
    ret += dfs(used-1, num, sum);
    
    if(num-1>=0 && sum-v[used-1]>=0){
        ret += dfs(used-1, num-1, sum-v[used-1]);
    }
    
    return dp[used][num][sum] = ret;
}

signed main(){
    rep(i,51)rep(j,51)rep(k,2505)dp[i][j][k] = -1;
    
    int n,a;
    cin>>n>>a;
    v.resize(n);
    rep(i,n)cin>>v[i];
    
    int ans = 0;
    
    for(int i=1;i<=n;i++){
        ans += dfs(n,i,i*a);
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 51200
#include<iostream>
#include<algorithm>
using namespace std;
int num[3];
int main() {
	int w, h, r; cin>>w>>h;
	int x, y; cin>>x>>y>>r;
	if(x-r<0||x+r>w||y+r>h||y-r<0) cout<<"No\n";
	else cout<<"Yes\n";
	return 0;
}


Measured memory_bytes: 3100
local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local x=gcd(io.read("n","n"))

local counter=1
for i=2,math.sqrt(x) do
    if x%i==0 then
        while x%i==0 do
            x=math.floor(x/i)
        end
        counter=counter+1
    end
end
print(x~=1 and counter+1 or counter)

Measured memory_bytes: 760
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import qualified Data.Map as M
-- import qualified Data.Char as C
import qualified Data.List as L
-- import qualified Data.IntSet as I
-- import Debug.Trace
--------------------------------------------
readInt    = read :: String -> Int
readFloat  = read :: String -> Float
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
int2bin 0 =  []
int2bin n =  n `mod` 2 : int2bin (n `div` 2)
----------------------------------------------

main :: IO ()
main = do
  [x,a,b] <- getIntList
  putStrLn $ if abs(x-a) <= abs(x-b) then "A" else "B"


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int z=(a+b)/2;
    double z1=(double)(a+b)/2;
    if(z1-z==0)
        cout<<z<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int N;
    cin >> N;
    if(N%2 == 1){
        cout << 0;
    }
    else{
        long long int k = N;
        long long int count = 0;
        long long int m = 10;
        while(k >= m){
            count += k/m;
            m = m*5;
        }
        cout << count;
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int K;
    cin >> K;
    char answer = '1';
    for(int i = 0; i < min(K, (int)S.size()); i++)
    {
        if(S.at(i) > '1')
        {
            answer = S.at(i);
            break;
        }
    }
    cout << answer << endl;
    return 0;
}


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

using namespace std;

class DisjointSet {
 private:
  class Node {
    friend DisjointSet;

    std::size_t parent;
    std::size_t size;

    Node(const std::size_t parent, const std::size_t size) : parent(parent), size(size) {}
  };

  std::vector<Node> nodes;

 public:
  explicit DisjointSet(const std::size_t n) : nodes(n, Node(n, 1)) {}

  std::size_t size() const { return nodes.size(); }

  std::size_t size(const std::size_t x) { return nodes[root(x)].size; }

  std::size_t root(const std::size_t x) {
    if (nodes[x].parent == size()) return x;
    return nodes[x].parent = root(nodes[x].parent);
  }

  bool is_same(const std::size_t x, const std::size_t y) { return root(x) == root(y); }

  bool unite(const std::size_t x, const std::size_t y) {
    std::size_t rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (nodes[rx].size < nodes[ry].size) std::swap(rx, ry);
    nodes[rx].size += nodes[ry].size;
    nodes[ry].parent = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  DisjointSet ds(N);
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int a, int b) { return X[a] < X[b]; });
  stack<pair<int, int>> st;
  for (int i : idx) {
    int m = Y[i];
    while (!st.empty() && st.top().first < Y[i]) {
      m = min(m, st.top().first);
      ds.unite(i, st.top().second);
      st.pop();
    }
    st.push(make_pair(m, i));
  }
  for (int i = 0; i < N; i++) {
    cout << ds.size(i) << '\n';
  }
  return 0;
}


Measured memory_bytes: 8724
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar(aa%10+'0');
	return;
}
long long n,m,K;
long long a[100005],b[100005],tmp[100005];
void ksm(long long aa)
{
	while(aa)
	{
		if(aa&1) 
		{
			for(long long i=1;i<=n;++i) tmp[i]=a[b[i]];
			for(long long i=1;i<=n;++i) a[i]=tmp[i];
		}
		aa>>=1;
		for(long long i=1;i<=n;++i) tmp[i]=b[b[i]];
		for(long long i=1;i<=n;++i) b[i]=tmp[i];
	}
	return;
}
int main()
{
	n=read();
	for(long long i=1;i<=n;++i) a[i]=read(),b[i]=i;
	for(long long i=n;i>=1;--i) a[i]-=a[i-1];
	m=read(),K=read();
	for(long long i=1;i<=m;++i) 
	{
		long long x=read();
		swap(b[x],b[x+1]);
	}
	ksm(K);
	long long sum=0;
	for(long long i=1;i<=n;++i)
	{
		sum+=a[i];
		write(sum);puts("");
	}
	return 0;
}

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

int main(){
    int n;
    
    cin >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        int x;
        cin >> x;

        a[x-1] = i+1;
    }
    for(int i = 0;i < n-1;i++){
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
using namespace std;

int main(){
    int n,x;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        } else {
            x=i;
            do{
                if(x%10==3){
                    printf(" %d",i);
                    break;
                } else {
                    x=x/10;
                }
            }while(x);
        }
    }
    printf("\n");
}



Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
  FIO;
  // ifstream cin("input");
  ll a,b;
  cin>>a>>b;
  cout<<min(a%b,abs(a%b-b))<<endl;
  return 0;  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String[] input = Console.ReadLine().Split();
        int K = int.Parse(input[0]);
        int N = int.Parse(input[1]);
        input = Console.ReadLine().Split();
        int[] A = new int[N];
        A[0] = int.Parse(input[0]);
        int max = 0;
        for(int i = 1; i < N; i++)
        {
            A[i] = int.Parse(input[i]);
            if (A[i] - A[i - 1] > max) { max = A[i] - A[i - 1]; }
        }
        if (K-(A[N-1] - A[0]) > max) { max = K - (A[N - 1] - A[0]); }
        Console.WriteLine(K - max);
    }
}

Measured memory_bytes: 32604
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N,K;cin>>N>>K;
  vector<long>A(N);
  long ans=LONG_MAX;
  for(long i=0;i<N;i++)cin>>A[i];
  for(long i=0;i<(1<<N);i++){
    bitset<15>b(i);
    if(b.count()<K)continue;
    long M=0,s=0;
    
    for(long j=0;j<N;j++){
      if(b[j]){
        if(M>=A[j]){
          s+=M-A[j]+1;
          M=max(M+1,A[j]);
        }
      }
      M=max(M,A[j]);
    }
    ans=min(ans,s);
    
  }
  cout<<ans<<endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class x,class y> x sum(x a,y b){return a+b;}
template<class x,class y> x mul(x a,y b){return a*b;}
template<class x,class y> x sub(x a,y b){return a-b;}
template<class x,class y> x divi(x a,y b){return a/b;}

template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
#define N  1000005

int main()
{
    ios;
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
    	ll i,j,k,l,m,n;
    	cin>>n;
    	ll ans=(n*(n+1))/2;
    	ll x3=n/3;
    	ll x5=n/5;
    	ll x15=n/15;
    	x3=3*(x3*(x3+1))/2;
    	x5=5*(x5*(x5+1))/2;
    	x15=15*(x15*(x15+1))/2;
    	ans=ans-x3-x5+x15;
    	cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn=100005;
int n,a[maxn],b[maxn];
long long ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n+1;i++)scanf("%d",&a[i]);
	for (int i=1;i<=n;i++)scanf("%d",&b[i]);
	for (int i=n;i>=1;i--)
	{
		if (a[i+1]>=b[i]){ans+=b[i];b[i]=0;a[i+1]-=b[i];}
		else {ans+=a[i+1];b[i]-=a[i+1];a[i+1]=0;}
		if(b[i]>=a[i]) {ans+=a[i];b[i]=0;a[i]=0;}
		else {ans+=b[i];a[i]-=b[i];}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1024
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    X = int(input())
    dp = [0]*(X+1)
    dp[0] = 1

    for i in range(X):
        if dp[i]==0:
            continue
        for j in range(6):
            if i + (100 + j) <= X:
                dp[i + (100 + j)] = 1

    print(dp[X])
    # print(dp)


if __name__ == '__main__':
    main()

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

using namespace std;

const vector<__int128> divisor = {2, 3, 5};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    int64_t N;
    cin >> N;
    vector<int64_t> X(4);
    for (int i = 0; i < 4; i++) {
      cin >> X[i];
    }
    __int128 res = INT64_C(1) << 59;
    __int128 mx = N + 15;
    priority_queue<pair<__int128, __int128>, vector<pair<__int128, __int128>>,
                   greater<pair<__int128, __int128>>>
        que;
    que.push(make_pair(0, N));
    set<__int128> st;
    while (!que.empty()) {
      auto q = que.top();
      que.pop();
      __int128 c = q.first, n = q.second;
      if (c > res) continue;
      if (st.find(n) != st.end()) continue;
      st.insert(n);
      if (n == 0) {
        res = min(res, c);
        continue;
      }
      for (__int128 i = 0; i < 3; i++) {
        __int128 d = divisor[i];
        if (n % d == 0) {
          __int128 m = n / d;
          que.push(make_pair(
              c + min(static_cast<__int128>(X[i]), (n - m) * X[3]), m));
        } else {
          __int128 m = (n / d) * d;
          que.push(make_pair(c + (n - m) * X[3], m));
          if (m + d < mx) que.push(make_pair(c + (m + d - n) * X[3], m + d));
        }
      }
    }
    cout << (int64_t)res << '\n';
  }
  return 0;
}


Measured memory_bytes: 8576
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	static int mod =(int)1e9+7;
	static int nax = (int) 2e5+5;
    static  long[]fac ;
	static long[]inv_fac;
  public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	fac = new long[nax];
	inv_fac = new long[nax];
	fac[0] = 1;
	inv_fac[0] =1;
    for(int i = 1; i < nax; ++i) {
        fac[i] = mul(fac[i-1], i);
        inv_fac[i] = my_inv(fac[i]);
    }
	int n = scn.nextInt();
	int m = scn.nextInt();
	int k = scn.nextInt();
	ArrayList<int[]>block = new ArrayList<>();
	for(int i=0;i<k;i++)
	{
		int[]pos = new int[2];
		pos[0] = scn.nextInt();
		pos[1] = scn.nextInt();
		block.add(pos);
	}
	Collections.sort(block, new Comparator<int[]>() {
		public int compare(int[]a,int[]b)
		{
			return (a[0]+a[1])-(b[0]+b[1]);
		}
	});
	block.add(new int[] {n,m});
	long[]dp = new long[k+1];
	for(int i=0;i<=k;i++)
	{
		long temp= f(block.get(i)[0]-1,block.get(i)[1]-1);
		for(int j=0;j<i;j++)
		{
			if(block.get(j)[0]<=block.get(i)[0]&&block.get(j)[1]<=block.get(i)[1])
			{
				temp=sub(temp,mul(dp[j],f(block.get(i)[0]-block.get(j)[0],block.get(i)[1]-block.get(j)[1])));
			}
			
		}
		dp[i]=temp;
	}
	
	System.out.println(dp[k]);
}
  public static long mul(long fac2,long a)
  {
	  return (long)fac2*a%mod ;
  }
  public static  long binomial(int a,int b)
  {
	  if(a < 0 || b < 0 || b > a) {
	        return 0;
	    }
	  return mul(fac[a],mul(inv_fac[b],inv_fac[a-b]));
  }
  public static long my_inv(long fac2)
  {
	  return my_pow(fac2, mod - 2);
  }
  public static long my_pow(long a, long b) {
	    long res = 1;
	    while(b>0) {
	        if(b % 2==1) {
	            res = mul(res, a);
	        }
	        a = mul(a, a);
	        b /= 2;
	    }
	    return res;
	}
  public static long f(int a,int b)
  {
	  return binomial(a+b,b);
  }
  public static long sub(long temp, long l) {
	    return (temp - l + mod) % mod;
	}
}


Measured memory_bytes: 47336
#include <bits/stdc++.h>
using namespace std;
int i,j,k,n,m,x,y,t;
int main(){
	scanf("%d%d",&n,&m);
	if (n<=0&&m>=0)printf("Zero\n");
	else if (n<0){
		if (m-n+1&1)printf("Negative\n");
		else printf("Positive\n");
	}
	else printf("Positive\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
vector<int> makePrimes(int n) { // [2,n]
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    rep(p, 2, sqrt(n) + 2) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    rep(p, 2, n + 1) if (pr[p]) res.push_back(p);
    return res;
}
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X;

	auto vp = makePrimes(1000000);
	int ans = *lower_bound(all(vp), X);
	cout << ans << endl;
}







Measured memory_bytes: 4860
#include <iostream>
#include <algorithm>
#include <functional>
#include <list>
#include <vector>
#include <iterator>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <random>
#include <cstdio>
#include <sstream>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <chrono> 
#include <numeric> 

using llong = long long;
using ullong = unsigned long long;
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define FORD(i, s, n) for (int i = (s); i > (n); i--)
#define FORW(i, s, n, p) for (int i = (s); i < (n); i += p)
#define FORDW(i, s, n, p) for (int i = (s); i > (n); i -= p)

using namespace std;

int main()
{

	int nMax = 0, n;
	cin >> n;

	map <string, int> votes;

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

		string vote;
		cin >> vote;
		nMax = max(nMax, ++votes[vote]);

	}

	for (auto it : votes)
		if (it.second == nMax)
			cout << it.first << endl;

}

Measured memory_bytes: 25216
import math

a, b, x = [int(x) for x in input().split()]

if a * a * b // 2 <= x:
	y = a * a * b - x
	h = y * 2 / a / a
	t = math.atan2(h, a)
else:
	h = x * 2 / a / b
	t = math.pi / 2 - math.atan2(h, b)

print(math.degrees(t))


Measured memory_bytes: 38256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
double ans = 0;

int main() {
	scanf("%lld %lld", &N, &K);
	for(int i = 1; i <= N; i++) {
		ll X = i;
		ll cnt = 0;
		while(X < K) {
			cnt++;
			X *= 2;
		}
		// cout << 1.0 / N << " " << pow(0.5, cnt) << " \n";
		ans += (1.0 / N) * pow(0.5, cnt);
	}
	printf("%0.12lf\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

int memo[1000][1001];
int wmemo[1000][1001];
int otakara_price[1000];
int otakara_weight[1000];
int otakara_in[1000];

int get_max(int* wsum,int now,int max,int weight_max,int current_weight);

int main(void) {
	int W,N;
	int i;
	int casenum=1;
	int price,wsum;
	while(1) {
		scanf("%d",&W);
		if(W==0)break;
		scanf("%d",&N);
		for(i=0;i<N;i++) {
			scanf("%d,%d",&otakara_price[i],&otakara_weight[i]);
		}
		printf("Case %d:\n",casenum);
		memset(memo,0,sizeof(memo));
		memset(wmemo,0,sizeof(wmemo));
		price=get_max(&wsum,0,N,W,0);
		printf("%d\n",price);
		printf("%d\n",wsum);
		casenum++;
	}
	return 0;
}

int get_max(int* wsum,int now,int max,int weight_max,int current_weight) {
	int result,result2;
	int wresult,wresult2;
	if(now>=max) {
		*wsum=0;
		return 0;
	}
	if(memo[now][current_weight]>0) {
		*wsum=wmemo[now][current_weight];
		return memo[now][current_weight]-1;
	}
	/*»Ì¨óðüêÈ¢ê*/
	result=get_max(&wresult,now+1,max,weight_max,current_weight);
	/*»Ì¨óðüêéê*/
	if(current_weight+otakara_weight[now]<=weight_max) {
		result2=get_max(&wresult2,now+1,max,weight_max,
			current_weight+otakara_weight[now]);
		result2+=otakara_price[now];
		wresult2+=otakara_weight[now];
	} else {
		result2=0;
		wresult2=0;
	}
	/*ÇÁ¿ª¢¢©*/
	if(result2>result || (result2==result && wresult2<wresult)) {
		result=result2;
		wresult=wresult2;
	}
	/*É«Ý*/
	memo[now][current_weight]=result+1;
	wmemo[now][current_weight]=wresult;
	/*ÊðÔ·*/
	*wsum=wresult;
	return result;
}

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

long long int gcm( long long int n, long long int m ) {
	if( n < m ) {
		return gcm( m, n );
	}
	if( m == 0 ) {
		return n;
	} else {
		return gcm( m, n%m );
	}
}

long long int lcm( long long int n, long long int m ) {
	return n*m / gcm( n, m );
}



int main() {
	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a;
	for( size_t i = 0; i < n - 1; i++ ) {
		cin >> b;
		a = lcm( a, b );
	}
	cout << a << endl;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int N=1000100;
//对数组名取地址得到的是整个数组的地址
ll k[N];
int main() {
   int n; cin >> n;
   unsigned long long e = 1e18;
   unsigned long long sum = 1;
   int flag1 = 0;
   for(int i = 0; i < n; i++) {
     cin >> k[i];
     if(k[i] == 0) flag1 = 1;
   }
   if(flag1) cout << 0 << endl;
   else{
   int flag = 0;
   for(int i = 0; i < n; i++) {
     if(e/k[i] >= sum) sum *= k[i];
     else {
        flag = 1;
        cout << -1 << endl;
        break;
     }
   }
   if(!flag) cout << sum << endl;
   }
}


Measured memory_bytes: 4312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		int[][]a=new int[scn.nextInt()][3];
		for(int i=0;i<a.length;i++)for(int j=0;j<3;j++)a[i][j]=scn.nextInt();
		System.out.println(solve(a));
	}
	
	public static int solve(int[][]a) {
		int ans=Integer.MIN_VALUE;
		for(int j=0;j<3;j++)ans=Math.max(ans, a[0][j]);
		for(int i=1;i<a.length;i++) {
			for(int j=0;j<3;j++) {
				int max=Integer.MIN_VALUE;
				for(int k=0;k<3;k++)if(k!=j)max=Math.max(max, a[i-1][k]);
				a[i][j]+=max;
				ans=Math.max(a[i][j], ans);
			}
		}
		return ans;
	}

}


Measured memory_bytes: 96680
def main():
    A, B = map(int, input().split())
    S = input()
    for a in range(A):
        if S[a]=="-":
            return "No"
    if S[A]!="-":
        return "No"
    for b in range(B):
        if S[A+1+b]=="-":
            return "No"
    return "Yes"

if __name__ == '__main__':
    print(main())


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

typedef long long ll;
using namespace std;

int n, k;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int a[n];
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    vector<pair<ll, ll>> bc;
    for (int i = 0; i < m; i++) {
        ll b, c; cin >> b >> c;
        bc.push_back({ -c, b });
    }
    sort(a, a + n);
    sort(bc.begin(), bc.end());
    int cur = 0;
    for (int i = 0; i < bc.size(); i++) {
        ll c = -bc[i].first;
        ll b = bc[i].second;
        for (int i = cur; i < b + cur; i++) {
            if (i >= n || a[i] >= c) {
                cout << sum << endl;
                return 0;
            }
            sum += -a[i] + c;
        }
        cur += b;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 2804
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N,K; cin>>N>>K;
    vi v(N);
    rep(i,N) {
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int sum=0;
    rep(i,K) {
        sum+=v.at(i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 384
#include<stdio.h>
signed main(){
    int x,n,p[105];
   scanf("%d %d",&x,&n);
   int i;
   for(i=0;i<n;i++){
       scanf("%d",&p[i]);
   }
   int flag[105]={};
   int ans=0;
   for(i=0;i<n;i++){
       flag[p[i]]=1;
   }
    for(i=1;i<=101;i++){
        if(flag[i]==0){
            int abs1,abs2;
            abs1=x-ans;
            abs2=x-i;
            if(abs1<0){
                abs1=abs1*-1;
            }
            if(abs2<0){
                abs2=abs2*-1;
            }
            if(abs1>abs2){
                ans=i;
            }
        }
    }
    printf("%d\n",ans);
    return(0);
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int H, W, A, B;
    cin >> H >> W >> A >> B;
    REP (i, B) {
        REP (j, A) cout << '1';
        REP (j, W - A) cout << '0';
        cout << endl;
    }
    REP (i, H - B) {
        REP (j, A) cout << '0';
        REP (j, W - A) cout << '1';
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using Int = int64_t;
const Int inf = 1LL << 53;

int main() {
   for(;;) {
      Int h, w;
      std::cin >> h >> w;
      if( h == 0 && w == 0 ) {
         break;
      }
      auto xss = std::vector<std::vector<Int>>(h);
      for(Int i = 0; i < h; ++i) {
         for(Int k = 0; k < w; ++k) {
            Int t;
            std::cin >> t;
            xss[i].push_back(t);
         }
      }
      Int res = 0;
      for(Int y1 = 0; y1 < h; ++y1) {
         for(Int x1 = 0; x1 < w; ++x1) {
            for(Int y2 = y1+2; y2 < h; ++y2) {
               for(Int x2 = x1+2; x2 < w; ++x2) {
                  bool valid = true;
                  Int round_min = inf;
                  for(Int y = y1; y <= y2; ++y) {
                     round_min = std::min(round_min, xss[y][x1]);
                     round_min = std::min(round_min, xss[y][x2]);
                  }
                  for(Int x = x1; x <= x2; ++x) {
                     round_min = std::min(round_min, xss[y1][x]);
                     round_min = std::min(round_min, xss[y2][x]);
                  }
                  Int t = 0;
                  for(Int y = y1+1; y <= y2-1; ++y) {
                     for(Int x = x1+1; x <= x2-1; ++x) {
                        if( xss[y][x] >= round_min ) {
                           valid = false;
                        }
                        t += round_min - xss[y][x];
                     }
                  }
                  if( valid ) {
                     res = std::max(res, t);
                  }
               }
            }
         }
      }
      std::cout << res << std::endl;
   }
}



Measured memory_bytes: 3052
n = int(input())

w = [input() for _ in range(n)]

if len(w) != len(set(w)):
    print("No")
    exit()

for i in range(1, n):
    if w[i - 1][-1] != w[i][0]:
        print("No")
        exit()
else:
    print("Yes")


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

int main(){
    int n;
    long int y;
    cin>>n>>y;
    
    int a=-1; int b=-1; int c=-1;

    for(int i=0;i<=n;i++){
    
        
        for(int h=0;h+i<=n;h++){
            int j=n-i-h;
            long int total=i*10000+h*5000+j*1000;
            if(total==y){
                a=i; b=h; c=j;

            }
            else{
                int unko=0;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
                

}

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

using namespace std;

const int N = 1e5 + 50;

int n, m;
int dp[N];
vector<int> graph[N];
int a, b;
int in[N];

int solve(int node) {
    int& ret = dp[node];

    if(ret != -1)
        return ret;

    for(auto neigh : graph[node])
        ret = max(ret, solve(neigh) + 1);

    return ret;
}

void precomp() {
    for(int i = 0; i < n; ++i)
        if(graph[i].empty())
            dp[i] = 0;
}

void load() {
    scanf("%d%d", &n, &m);

    for(int i = 0; i < m; ++i) {
        scanf("%d%d", &a, &b);
        --a, --b;

        graph[a].push_back(b);
        //in[b]++;
    }

    precomp();

    for(int i = 0; i < n; ++i)
        if(dp[i] == -1)
            solve(i);

    printf("%d\n", *max_element(dp, dp + n));
}

int main() {
    memset(dp, -1, sizeof dp);

    load();
}


Measured memory_bytes: 7424