akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
typedef long long ll;
bool is_prime(ll d) {
  if (d == 1) return false;
  if (d == 2) return true;
  if (d == 3) return true;
  if (d % 2 == 0) return false;
  for (ll i = 3; i*i <= d; i += 2) {
    if (d % i == 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  ll X;
  cin >> X;
  for (ll i = X; ; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      return 0;
    }
  }
}

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

int main(){
  
  int N; cin >> N;
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    int a; cin >> a;
    bool f = true;
    for( int i = 2; i * i <= a; i++ ){
      if( a % i == 0 ) f = false;
    }
    if( f ) ans++;

  }

  cout << ans << endl;
}



Measured memory_bytes: 3120
X = int(input())

dp = [False] * (X + 1)
cost = [100, 101, 102, 103, 104, 105]
dp[0] = True
for i in range(X):
    for j in range(6):
        if dp[i] and i + cost[j] <= X:
            dp[i + cost[j]] = True

if dp[-1]:
    print(1)
else:
    print(0)


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

int main() {
	int a,b;
	
	cin >> a >> b;
	
	if(a>b){
		cout << "a > b" << endl;
	}
	
	else if(a<b){
		cout << "a < b" << endl;
	}
	
	else{
		cout << "a == b" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1156
N = int(input())
D = dict()
for _ in range(N):
    cand = input()
    if cand not in D:
        D[cand] = 1
    else:
        D[cand] += 1
mx = max(D.values())
A = sorted(D.items(), key=lambda x: -x[1])
ans = []
for k, m in A:
    if m == mx:
        ans.append(k)
    else:
        break

B = sorted(ans)
for b in B:
    print(b)


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,x;cin >> n >> x;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(),a.end());
	int ans=0;
	rep(i,n){
		if(x-a.at(i)>=0){
			x-=a.at(i);
			ans++;
		}
		else break;
	}
	if(ans==n && x!=0) ans--;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <map>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <stack>
#include <queue>
#include <cstring>
#include <iterator>

#define FOR(n) for(int cnt=0;cnt<(n);++cnt)
#define FOR_R(it,cont) for(auto it=rbegin(cont);it!=rend(cont);++it)
#define FOR_F(it,cont) for(auto it=begin(cont);it!=end(cont);++it)
#define ALL(cont) begin(cont), end(cont)
#define LB(b,e,v) lower_bound(b,e,v)
#define UB(b,e,v) upper_bound(b,e,v)

using namespace std;
typedef pair<int,int> P;

int H,W;
char c[310][310];
int table[310][310][310];
int table2[310][310][310];
int fillTable2(int first, int restL, int restR) {
  if (table2[first][restL][restR]!=-1) {
    return table2[first][restL][restR];
  }
  if (restR == 0 || restL ==0) {
    return table2[first][restL][restR]=0;
  }
  bool flag = c[restL-1][first] == c[restR-1][first+1];
  return table2[first][restL][restR] = fillTable2(first,restL-1,restR-1) + (flag? 1:0);
}
int dp(int first, int restL, int restR) {
  if (table[first][restL][restR]!=-1) {
    return table[first][restL][restR];
  }
  if (restR == 0 || restL ==0) {
    return table[first][restL][restR]=0;
  }
  int sub = table2[first][restL][restR];
  sub += min(dp(first,restL-1,restR), dp(first,restL,restR-1));
  return table[first][restL][restR] = sub;
}
int main() {
  memset(table,-1,sizeof(table));
  memset(table2,-1,sizeof(table2));
  scanf("%d%d", &H, &W);
  FOR(H) {
    scanf("%s", c[cnt]);
  }
  for(int i=0;i<W-1;++i) {
    for(int j=0;j<=H;++j) {
      fillTable2(i,H,j);
    }
    for(int j=0;j<=H;++j) {
      fillTable2(i,j,H);
    }
  }
  int answer = 0;
  for(int i=0;i<W-1;++i) {
    answer += dp(i,H,H);
  }
  printf("%d\n", answer);
  return 0;
}


Measured memory_bytes: 233088
import math
N = int(input())
val = N / 1.08
val_min = math.floor(val)
val_max = val_min + 1
price_min = math.floor(val_min * 1.08)
price_max = math.floor(val_max * 1.08)
if price_min == N:
    print(val_min)
elif price_max == N:
    print(val_max)
else:
    print(":(")

Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair
#define MOD (LL)(1e9+7)

int N, B[100];
int main(){
	cin >> N;
	for(int i=0; i<N-1; i++){
		cin >> B[i];
	}
	int ans = B[0] + B[N-2];
	for(int i=1; i<N-1; i++){
		ans += min(B[i-1], B[i]);
	}
	cout << ans << endl;
}

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

constexpr ll N=100001;
vector <ll> tree[N];
vector <ll> exam (N,0);
map<pair<ll,ll>,ll> I;
vector <pair <ll,ll>> v(N);

ll maxcol=0;
void dfs(pair <int,int> now){
  ll ncol=1;

  for (auto i:tree[now.first]){
    if (exam[i]) continue;
    if (ncol==now.second) ncol++;
    exam[i]=ncol;
    I[make_pair(now.first,i)]=I[make_pair(i,now.first)]=ncol;
    maxcol=max(maxcol,ncol);

    dfs(make_pair(i,ncol));
    ncol++;
  }

}

  int main(){
    ll n;
    cin>>n;
    for (int i=0; i<n-1; i++){
      ll a,b;
      cin>>a>>b;
      tree[a].emplace_back(b);
      tree[b].emplace_back(a);
      v[i]=make_pair(a,b);
    }
    exam[1]=N;

    dfs(make_pair(1,0));


    cout<<maxcol<<endl;
    for (ll i=0;i<n-1; i++){
      cout<<I[v[i]]<<endl;
    }

  }


Measured memory_bytes: 23296
import sys

childs = list(map(int, input().split()))

A=childs[0]
B=childs[1]
res=0
if A<=3 or B<=21:
    print(0)
    sys.exit()
else:
    for n in range(4, A+1):
        for i in range(2, int(n**0.5)+1):
            if n % i == 0:
                if 10*i+n//i <= B and 10*i+n//i >= 22 and n//i >=2 and n//i <= 9 and i<=9:
                    res+=1
                if i != n // i:
                    if 10*(n//i)+i <= B and  10*(n//i)+i >= 22:
                        res+=1
print(res)

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
import java.util.function.*;

class Range {
	int start;
	int end;

	Range(int start, int end) {
		this.start = start;
		this.end = end;
	}

	Range(Range copy) {
		this(copy.start, copy.end);
	}

	boolean isIn(int x) {
		return start <= x && x < end;
	}

	boolean isEmpty() {
		return end - start <= 0;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int H = Integer.parseInt(sc.get());
		int W = Integer.parseInt(sc.get());
		int N = Integer.parseInt(sc.get());
		int startRow = Integer.parseInt(sc.get()) - 1;
		int startColumn = Integer.parseInt(sc.get()) - 1;
		char[] T = sc.get().toCharArray();
		char[] A = sc.get().toCharArray();

		Range[] turnY = new Range[N];
		Range[] turnX = new Range[N];
		if (T[N - 1] == 'U') {
			turnY[N - 1] = new Range(1, H);
		} else if (T[N - 1] == 'D') {
			turnY[N - 1] = new Range(0, H - 1);
		} else {
			turnY[N - 1] = new Range(0, H);
		}
		if (T[N - 1] == 'L') {
			turnX[N - 1] = new Range(1, W);
		} else if (T[N - 1] == 'R') {
			turnX[N - 1] = new Range(0, W - 1);
		} else {
			turnX[N - 1] = new Range(0, W);
		}

		for (int i = N - 2; i >= 0; i--) {
			Range y = turnY[i] = new Range(turnY[i + 1]);
			Range x = turnX[i] = new Range(turnX[i + 1]);
			if (A[i] == 'U' && y.end < H) {
				y.end++;
			} else if (A[i] == 'D' && y.start > 0) {
				y.start--;
			}
			if (A[i] == 'L' && x.end < W) {
				x.end++;
			} else if (A[i] == 'R' && x.start > 0) {
				x.start--;
			}

			if (T[i] == 'U' && y.start < H) {
				y.start++;
			} else if (T[i] == 'D' && y.end > 0) {
				y.end--;
			}
			if (T[i] == 'R' && x.end > 0) {
				x.end--;
			} else if (T[i] == 'L' && x.start < W) {
				x.start++;
			}
			if (y.isEmpty() || x.isEmpty()) {
				System.out.println("NO");
				return;
			}
		}
		if (turnY[0].isIn(startRow) && turnX[0].isIn(startColumn)) System.out.println("YES");
		else System.out.println("NO");
	}

	boolean isOn(int y, int x, int H, int W) {
		return 1 <= y && y <= H && 1 <= x && x <= W;
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				try {
					return (line = line != null && line.hasMoreTokens() ? line : new StringTokenizer(reader.readLine())).nextToken();
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
		});
	}
}

Measured memory_bytes: 39240
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int h, m, s;
        cin >> h >> m >> s;
        if(h == -1)
            return 0;

        m += h * 60;
        s += m * 60;

        s = 2 * 60 * 60 - s;
        printf("%02d:%02d:%02d\n", s/60/60, s/60%60, s%60);

        s *= 3;
        printf("%02d:%02d:%02d\n", s/60/60, s/60%60, s%60);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 100010;
int a[maxn];

struct node {
	int l,r;
	long long sum,lazy;
	void update(long long val){
		sum+=val*(r-l+1);
		lazy+=val;
	}
}tree[4*maxn];

void push_up(int x){
	tree[x].sum = tree[x<<1].sum+tree[x<<1|1].sum;
}

void push_down(int x){
	long long val = tree[x].lazy;
	if(val){
		tree[x<<1].update(val);
		tree[x<<1|1].update(val);
		tree[x].lazy = 0;
	}
}

void build(int x,int l,int r){
	tree[x].l = l,tree[x].r = r,tree[x].lazy = 0;
	if(l==r){
		tree[x].sum = a[l];
	} 
	else {
		int mid = (l+r)/2;
		build(x<<1,l,mid);
		build(x<<1|1,mid+1,r);
		push_up(x);
	}
}

void update(int x,int l,int r,long long val){
	int L = tree[x].l,R = tree[x].r;
	if(l<=L&&R<=r){
		tree[x].update(val);
	}
	else {
		push_down(x);
		int mid = (L+R)/2;
		if(l<=mid)update(x<<1,l,r,val);
		if(r>mid)update(x<<1|1,l,r,val);
		push_up(x);
	}
}


long long query(int x,int l,int r){
	int L = tree[x].l, R = tree[x].r;
	if(l<=L&&R<=r){
		return tree[x].sum;
	}
	else {
		long long sum = 0;
		push_down(x);
		int mid = (L+R)/2;
		if(l<=mid)sum+=query(x<<1,l,r);
		if(r>mid) sum+=query(x<<1|1,l,r);
		push_up(x);
		return sum;
	}
}

int main(){
	int n,m;
	while(cin>>n>>m){
		memset(a,0,sizeof(a));
		build(1,1,n);
		int l,r;
		for(int i=0;i<m;i++){
			cin>>l>>r;
			update(1,l,r,1);
		}
		int ans = 0;
		for(int i=1;i<=n;i++){
			if(query(1,i,i)==m)
				ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

//Mが非常に大きいので登場しうる余りが高々N+1個であることを移用して連想配列なりを用意する

int main() {
	ll N, M, A[100100];
	cin >> N >> M;
	map<ll, ll>cnt;
	cnt[0] = 1;
	ll sum = 0;
	for (ll i = 0; i < N; ++i) {
		ll a; cin >> a;
		sum += a;
		sum %= M;
		cnt[sum]++;
	}
	ll ans = 0;
	for (auto p : cnt) {
		ans += p.second*(p.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4224
import fractions
N = int(input())
A_array = list(map(int, input().split()))

if N == 2:
    print(max(A_array[0], A_array[1]))
    exit()

remove_index = []
for i, A in enumerate(A_array):
    if i == 0:
        gcd_max = A
        remove_index.append(i)
        continue
    gcd = fractions.gcd(gcd_max, A)
    # print(i, gcd_max, gcd)
    if gcd_max > gcd:
        gcd_max = gcd
        remove_index.append(i)
# print(remove_index)
# print(gcd_max, remove_index)

gcd_ans = gcd_max
for index in remove_index:
    gcd = 0
    for i, A in enumerate(A_array):
        if i == index:
            continue
        if gcd == 0:
            gcd = A
            continue
        # print(gcd,A)
        gcd = fractions.gcd(gcd, A)
        if gcd_ans >= gcd:
            break
    # print(gcd_ans,gcd)
    gcd_ans = max(gcd_ans, gcd)
print(gcd_ans)


Measured memory_bytes: 16484
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    long long ans = 0;
    for (int i = 3; i < n+2; i++)
    {
        ans += a[n-i/2];
    }
    cout << ans << endl;
    return 0;
}
//Saw the editorial

Measured memory_bytes: 3932
#include <stdio.h>

int main(void){
	
	int a,b,c;
	int buf;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > b){
		buf = a;
		a = b;
		b = buf;
	}
	if(b > c){
		buf = b;
		b = c;
		c = buf;
	}
	if(a > b){
		buf = a;
		a = b;
		b = buf;
	}
	
	printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 1024
N = 4010
p = 998244353
mi2 = [0] * N
inv = [0] * N
fac = [0] * N

def C(x, y):
    return fac[x] * inv[y] * inv[x - y] % p

def Calc(n, a, b):
    ans = 0
    for i in range(min(a, n) + 1):
        if i == b == 0:
            continue
        ans += C(a, i) * mi2[i] * C(n + b - 1, n - i) % p
    return ans % p

mi2[0] = fac[0] = inv[0] = inv[1] = 1
for i in range(1, N):
    mi2[i] = mi2[i - 1] * 2 % p
    fac[i] = fac[i - 1] * i % p
for i in range(2, N):
    inv[i] = inv[p % i] * (p - p // i) % p
for i in range(2, N):
    inv[i] = inv[i - 1] * inv[i] % p

k, n = map(int, input().split())
for i in range(2, 2 * k + 1):
    ans = 0
    cnt = min(k, (i - 1) >> 1) - max(i - k, 1) + 1
    if i & 1:
        ans += Calc(n, cnt, k - cnt * 2)
    else:
        ans += Calc(n, cnt, k - cnt * 2 - 1)
        ans += Calc(n - 1, cnt, k - cnt * 2 - 1)
    print(ans % p)

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

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

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

  string s; cin >> s;
  int ans = 0;
  rep(i, s.size()) if(s[i] == '1') ans++;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
if N == 1:
    print(1)
    quit()
if M > N//2:
    print(0)
    quit()

A = list(int(input()) for _ in range(M))
idx = 0
P = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1
a = -1
if len(A):
    if 1 == A[idx]:
        dp[1] = 0
        if idx < M-1:
            idx += 1

if len(A):
    for i in range(2, N+1):
        if i != A[idx]:
            dp[i] = (dp[i-1] + dp[i-2]) % P
        else:
            dp[i] = 0
            if idx < M-1:
                idx += 1
else:
    for i in range(2, N+1):
        dp[i] = (dp[i-1] + dp[i-2]) % P
print(dp[N])

Measured memory_bytes: 7424
#pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma") 
 
#include<bits/stdc++.h>
 
#define CFOR(i, str) for(int i = 0; (str)[i]!='\0'; (i)++)
#define FOR(i, s, r) for(int i = (s); i < (r); i++)
#define INF 1e9
#define NINF -1e9
#define SUM(a) accumulate(a.begin(), a.end(), 0)
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.rbegin(), v.rend())
#define vmax(v) *max_element(v.begin(), v.end())
#define vmin(v) *min_element(v.begin(), v.end())
#define cnt(v, n) count(v.begin(), v.end(), (n))
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define vpii vector<pair<int, int>>
#define vpic vector<pair<int, char>>
#define mp make_pair
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); //+ve = right, -ve = left
#define lld long long int
#define ulld unsigned long long int
typedef long long ll;
using namespace std;
 
ll binpow(ll a, ll b) { 
ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;
}
 
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
 
bool isPrime(ll n) { 
    if (n <= 1) return false; 
    if (n <= 3) return true; 
    if (n % 2 == 0 || n % 3 == 0) return false; 
    for (ll i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; 
    return true; 
}
void solve(){
    int n;
    cin>>n;
    int arr[n];
    map<int,int> mp;
    lld sum=0;
    for(int  i=0;i<n;i++)
    {
      cin>>arr[i];
      mp[arr[i]]++;
      sum+=arr[i];
    }
    int b;
    cin>>b;
    for(int i=1;i<=b;i++)
    {
        int a,c;
        cin>>a>>c;
        int w=mp[a];
        mp.erase(a);
        mp[c]+=w;
        lld diff=(c*w)-(a*w);
        sum+=diff;
        cout<<sum<<"\n";
    }
}
int main(){
   ios::sync_with_stdio(0);
   cin.tie(0);
   ll t;
   t=1;;
   while(t--)
   { 
   solve();
   }
   return 0;
}

Measured memory_bytes: 6900
#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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, K;
    cin >> N >> K;
    if (K == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << N - K << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	string s, ss, t;
	cin >> s >> t;
	ss = s + s;
	if (ss.find(t) != string::npos) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

#include <string>
using namespace std;
using ll = long long;

#define reps(i,s,n) for(int (i) = (s) ; (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)

string s1,s2;
int main(){
    cin >> s1 >> s2;
    if(s1.length() > s2.length()){//桁数で比較
        cout  << "GREATER" << endl;
        return 0;
    }else if(s1.length() < s2.length()){
        cout  << "LESS" << endl;
        return 0;
    }else {//桁数は同じ
//        for(int i = s1.length()-1; i >= 0; i--){
        for(int i = 0; i < s1.length(); i--){
//            cout << s1[i] << "|" << s2[i] << endl;
            if(s1[i] > s2[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(s1[i] < s2[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }

    return 0;
}

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

int64_t check(int64_t b, int64_t n) {
	int64_t result = 0;
	while (n > 0) {
		result += n % b;
		n /= b;
	}
	return result;
}

int main() {
	int64_t n, s;
	cin >> n >> s;
	for (int i = 2; i<1000000; ++i) {
		int64_t res = check(i,n);
		if (res == s) {
			cout << i << endl;
			return 0;
		}
	}
	int64_t dif = n - s;
	double ddif = dif;
	vector<int64_t> answer;
	for (int64_t p = 1; p*p<=dif; ++p) {
		if (dif%p == 0) {
			{
				int64_t b = p + 1;
				int64_t x = dif / p;
				int64_t y = s - x;
				if (x < b && y < b && y >= 0 && x+y==s) {
					answer.push_back(b);
				}
			}
			{
				int64_t b = dif/p+1;
				int64_t x = p;
				int64_t y = s - x;
				if (x < b && y < b && y >= 0 && x + y == s) {
					answer.push_back(b);
				}
			}
		}
	}
	if (answer.size() > 0) {
		sort(answer.begin(), answer.end());
		cout << answer[0] << endl;
		return 0;
	}
	if (n == s) {
		cout << n+1 << endl;
		return 0;
	}
	cout << -1 << endl;
	return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll n;
  string s;
  set<string> ch;
  bool momo = false;
  cin >> n;
  string w[1000];
  rep(i, n) {
    cin >> w[i];
    if(i && w[i - 1][w[i - 1].size() - 1] != w[i][0]) {
      momo = true;
    }
    ch.insert(w[i]);
  }
  if(ch.size() == n && momo == false) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
  int main () {
  int a, b;
  cin >> a >> b;
    
  int c;
    c=a+b;
      
   if (c%2==0) {
     cout << c/2 << endl;
   }
      
   else {
     cout << (c/2)+1 << endl;
   }
  }
  


Measured memory_bytes: 3588
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10;
int n , m , f[N] , g[N];
int Q , v[N] , d[N] , c[N];
vi G[N];

int main(){
  scanf("%d%d",&n,&m);
  rep(i,0,m) {
    int u,v;
    scanf("%d%d",&u,&v);
    G[u].pb(v);
    G[v].pb(u);
  }
  scanf("%d",&Q);
  rep(i,1,Q+1) scanf("%d%d%d",v+i,d+i,c+i);
  per(step,0,11) {
    rep(i,1,n+1) g[i]=f[i];
    rep(i,1,n+1) for(auto j:G[i])
      g[j]=max(g[j],f[i]);
    rep(i,1,Q+1) if(d[i]==step)
      g[v[i]]=max(g[v[i]],i);
    rep(i,1,n+1) f[i]=g[i];
  }
  rep(i,1,n+1) printf("%d\n",c[f[i]]);
  return 0;
}


Measured memory_bytes: 8440
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            String s = in.next();
            String t = in.next();

            char[] S = s.toCharArray();
            Arrays.sort(S);

            char[] T = t.toCharArray();
            Arrays.sort(T);
            for (int l = 0, r = T.length - 1; l < r; l++, r--) {
                char swap = T[l];
                T[l] = T[r];
                T[r] = swap;
            }

            System.out.println(new String(S).compareTo(new String(T)) < 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 27000
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main(){
    

    ll n;
    cin >> n;
    ll ans = 0;
    string a,b,c;
    cin >> a >> b >> c;
    for (ll i=0;i<n;i++){
        set <ll> s;
        s.insert(a[i]);
        s.insert(b[i]);
        s.insert(c[i]);
        ans += s.size() - 1;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
n,k=map(int,input().split())

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

if k!=10:
    print(len(Base_10_to_n(n,k)))
else:
    print(len(str(n)))

Measured memory_bytes: 3060
#include <stdio.h>

int main() {
    int n;
    scanf("%d", &n);

    int s = 0;
    int an[n];
    for (int i = 0; i < n; i++) {
        scanf("%d", &an[i]);
        s += an[i];
    }
    int av = s/n;

    int r1 = 0;
    int r2 = 0;
    int r3 = 0;
    for (int i = 0; i < n; i++) {
        r1 += (an[i]-av)*(an[i]-av);
        r2 += (an[i]-av-1)*(an[i]-av-1);
        r3 += (an[i]-av+1)*(an[i]-av+1);
    }

    int rm = (r1 < r2) ? r1 : r2;
    rm = (rm < r3) ? rm : r3;
    printf("%d\n", rm);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 main(void) {
	vi v(3); rep(i,3) cin >> v[i];
	SORT(v);
	out(v[0]+v[1]);
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;
const int mod = 1000000007;

int main(){
  ll N;
  cin >> N;
  int M=INFI;
  for(ll i=1; i*i<=N; i++){
    if(N%i){
      continue;
    }
    ll A,B;
    A = i;
    B = N/i;
    int digit_A=0,digit_B=0;
    while(A>0){
      digit_A++;
      A /= 10;
    }
    while(B>0){
      digit_B++;
      B /= 10;
    }
    int F;
    F = max(digit_A,digit_B);
    M = min(M,F);
  }
  cout << M << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long int t,i,j,h[10];

    for (i=0;i<10;i++)
    {
        scanf("%lld",&h[i]);
    }
    for (i=0;i<10;i++)
    {
        for (j=0;j<10-1-i;j++)
        {
            if(h[j]<h[j+1])
            {
                t=h[j]; h[j]=h[j+1]; h[j+1]=t;
            }   
        }
    }
    printf("%lld\n%lld\n%lld\n",h[0],h[1],h[2]);
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cassert>
#include <queue>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

using p = pair<lint, int>;

int main(){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e - a <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main() {
	int h, w;
	while (cin >> h >> w, h) {
		int f[22][22];
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				cin >> f[i][j];
			}
		}
		int ans = 0;
		for (int i = 1; i <= h; ++i) {
			for (int j = 1; j <= w; ++j) {
				for (int ii = 0; ii < i; ++ii) {
					if (i - ii < 3) continue;
					for (int jj = 0; jj < j; ++jj) {
						if (j - jj < 3)continue;
						int soto = 123456;
						int uchi = -1;
						int yous = 0;
						for (int x = ii; x < i; ++x) {
							for (int y = jj; y < j; ++y) {
								if (x == ii || x == i - 1 || y == jj || y == j - 1) {
									soto = min(soto, f[x][y]);
								}
								else {
									uchi = max(uchi, f[x][y]);
									yous -= f[x][y];
								}
							}
						}
						if (soto <= uchi) {
							yous = 0;
						}
						else {
							yous += soto * (i - ii - 2) * (j - jj - 2);
						}
						ans = max(ans, yous);
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

int main(){
	int h, w;

	cin >> h >> w;
	while(h != 0 || w != 0){
		int ans[2],min=100000;;
		ans[0]=1000;
		ans[1]=1000;
		int current=h*h+w*w;
		int anstmp=current;
	
		for(int i=1; i<10000; i++){
			for(int j=i+1; j<10000-i; j++){
				int tmp=i*i+j*j;
				if(tmp > current || (tmp == current && i>h) ){
					if(tmp < min || (tmp == min && ans[0] > i) ){
						min = tmp;
						ans[0]=i;
						ans[1]=j;
					}
				}
			}
		}
		cout << ans[0] << ' ' << ans[1] << endl;
		cin >> h >> w;
	}
}

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

using namespace std;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

void dfs(string s, char mx) {
	if (s.length() == n) {
    	cout << s << endl;
    } else {
    	for(char i = 'a'; i <= mx; ++i) {
        	dfs(s+i, (i==mx?mx+1:mx));
        }
    }
}

int main() {
    cin >> n;
	dfs("",'a');
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <vector>
using namespace std;
long long fpb(long long a, long long b){
	long long ret = 0;
	while(a % b != 0){
		ret = a % b;
		a = b;
		b = ret;
	}
	return b;
}
long long a, b;
int main(){
	while(cin >> a >> b){
		cout << fpb(a, b) << " " << (a*b)/fpb(a, b) << "\n";
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}



int main() {
    string s;
    cin >> s;
    if(s.size() < 4) cout << "No" << endl;
    else{
        if(s.substr(0,4) == "YAKI") cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String N = sc.nextLine();
        int Nint = Integer.parseInt(N);
        
        int[] ans = new int[100000];
        
        for (int x = 1; x <= 100; x++){
            for(int y = 1; y <= 100; y++){
                for(int z=1; z<=100; z++){
                    int i = (int)(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2))+x*y+y*z+z*x;
                    ans[i]++;
                }
            }
        }
        
        for(int i=1; i<Nint+1; i++){
            System.out.println(ans[i]);
        }
    }
}


Measured memory_bytes: 39212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxN = 1e5;

 const int mod =1e9+7; 
ll res = INT_MAX;
ll x =10;
 
int main()
 {
	//code
ll h1,m1,h2,m2,k;
cin>>h1>>m1>>h2>>m2>>k;
ll hd = h2-h1;
ll md = m2-m1;

 cout<<hd*60+md-k<<"\n";
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int mod = 1e5;
const int MAX = 1e7;

int main() {
    double r; cin >> r;
    cout << (double)2 * r * 3.1415926535897 << endl;
}


Measured memory_bytes: 3788
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
N,M = map(int,input().split())
a = [int(input()) for i in range(M)]

ans = 0

now = 0

dp = [0]*(N+1)
disable = [0]*(N+1)

for i in range(M):
    #print(i)
    disable[a[i]] = 1
    

waru = 10**9+7
dp[0] = 1

for i in range(1,N+1):
    if disable[i] == 1:
        dp[i] = 0
    else:
        dp[i] = ( dp[i-1] + dp[i-2] )  % waru

print(dp[N])


Measured memory_bytes: 22180
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
p = LI()

p.sort()
ans = 0
for i in range(K):
    ans += p[i]
print(ans)

Measured memory_bytes: 62352
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
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 FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
#define EPS 1e-6
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

void search(vector<string> &s, char c){
    int h = s.size(), w = s[0].size();
    int l = 100, r = -1, t = 100, b = -1;
    REP(i,h) REP(j,w){
        if (s[i][j] == c){
            l = min(l,j);
            r = max(r,j);
            t = min(t,i);
            b = max(b,i);
        }
    }
    if (l == 100) return;
    bool rec = 1;
    FOR(i,t,b) FOR(j,l,r){
        if (s[i][j] != c && s[i][j] != '_') rec = 0;
    }
    if (!rec) return;
    FOR(i,t,b) FOR(j,l,r){
        s[i][j] = '_';
    }
}

int main() {
    int n;
    cin >> n;
    while (n--){
        int h, w;
        cin >> h >> w;
        vector<string> s(h);
        REP(i,h) cin >> s[i];
        REP(z,7){
            for (char c = 'A'; c <= 'Z'; c++){
                search(s, c);
            }
        }
        bool sup = 0;
        REP(i,h) REP(j,w){
            if (s[i][j] != '.' && s[i][j] != '_') sup = 1;
        }
        cout << (sup ? "SUSPICIOUS" : "SAFE") << endl;
    }
    return 0;
}

Measured memory_bytes: 3208
n,m = (int(num) for num in input().split())

a = 1
b = n
for _ in range(m):
    l,r = (int(num) for num in input().split())
    if l > a:
        a = l
    if r < b:
        b = r
        
if b >= a:
    print(b-a+1)
else:
    print(0)

Measured memory_bytes: 47208
#DP-B

n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[float('inf')]*n
dp[0]=0
for i in range(1,n):
    for j in range(k):
        if i+j<n:
            dp[i+j]=min(dp[i+j],dp[i-1]+abs(h[i+j]-h[i-1]))

print(dp[-1])

Measured memory_bytes: 55264
n = int(input())
lis = []
lis2 = {}
lis3 = []
for _ in range(n):
  lis.append(input())

for w in lis:
  if w not in lis2.keys():
    lis2[w] = 1
  else:
    lis2[w] += 1

ma = max(lis2.values())

for k, v in lis2.items():
  if v == ma:
    lis3.append(k)

lis3.sort()

for a in lis3:
  print(a)

Measured memory_bytes: 35216
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
 
vector<int> bk[10];
vector<int> pr;
int dp[2001];
int n, k;
 
int main(){
    for(int i = 1; i < 2001; i++) dp[i] = -1;
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        int c, g; scanf("%d%d", &c, &g);
        g--;
        bk[g].push_back(c);
    }
    for(int i = 0; i < 10; i++){
        pr.clear();
        int sum = 0;
        sort(bk[i].begin(),bk[i].end(),greater<int>());
        for(int j = 0; j < bk[i].size(); j++){
            sum += bk[i][j];
            pr.push_back(sum+j*(j+1));
        }
        for(int j = k; j >= 0; j--){
            for(int u = 0; u < pr.size(); u++){
                if(j-u-1<0) break;
                if(dp[j-u-1] == -1) continue;
                dp[j] = max(dp[j],dp[j-u-1]+pr[u]);
            }
        }
    }
    printf("%d\n", dp[k]);
}

Measured memory_bytes: 1088
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
	static void Main()
	{
		var countStr = Console.ReadLine();
		int count = int.Parse(countStr);

		var line = Console.ReadLine();
		string[] array = line.Split(' ');

		int fourM = 0;
		int twoM = 0;
		int notM = 0;

		for (int i = 0; i < count; i++)
		{
			int num = int.Parse(array[i]);
			if (num % 4 == 0)
			{
				fourM++;
			}
			else if (num % 2 == 0)
			{
				twoM++;
			}
			else
			{
				notM++;
			}
		}

        if (twoM > 0)
            notM++;

		//Console.WriteLine(fourM);
		//Console.WriteLine(twoM);
		//Console.WriteLine(notM);

		if (fourM >= notM - 1)
		{
			Console.WriteLine("Yes");
		}
		else
		{
			Console.WriteLine("No");
		}
	}
}

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

int main() {
  int a ;
  string op ;
  int b ;
  
  cin >> a >> op >> b ;
  
  if(op=="+"){
    cout << a+b << endl;
  }
    
  if(op=="-"){
    cout << a-b << endl ;
  }
   
}
    

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n, m, a, b, color[100100];
vector<ll> G[100100];
bool nibu = true;

bool dfs(ll x, ll c){
    color[x] = c;
    for (ll i = 0; i < G[x].size(); i++){
        if (color[G[x][i]] == c) return false;
        if (color[G[x][i]] == 0 && !dfs(G[x][i], -c)) return false;
    }
    return true;
}

int main(void){
    // Your code here!
    cin >> n >> m;
    for (ll i = 0; i < m; i++){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if (dfs(1, 1)){
        ll katahou = 0;
        for (ll i = 1; i <= n; i++){
            if (color[i] == 1) katahou++;
        }
        cout << katahou * (n - katahou) - m << endl;
    } else {
        cout << n * (n - 1) / 2 - m << endl;
    }
}


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

const int M=100000;

int main()
{
	int w,h;
	while(cin>>w>>h,w)
	{
		int dp[4][100][100]={};
		//0->straight right,1->turn right,2->straight up,3->turn up
		
		dp[0][0][0]=1;
		dp[2][0][0]=1;

		for(int i=0;i<w;i++)
		{
			for(int j=0;j<h;j++)
			{
				if(i>0&&j>0)
				{
					dp[0][i][j]=(dp[0][i-1][j]+dp[1][i-1][j])%M;
					dp[1][i][j]=dp[2][i-1][j]%M;
					dp[2][i][j]=(dp[2][i][j-1]+dp[3][i][j-1])%M;
					dp[3][i][j]=dp[0][i][j-1]%M;
				}
				else if(i>0)
				{
					dp[0][i][j]=dp[0][i-1][j]%M;
				}
				else if(j>0)
				{
					dp[2][i][j]=dp[2][i][j-1]%M;
				}
			}
		}

		int ans=0;
		for(int i=0;i<4;i++)ans=(ans+dp[i][w-1][h-1])%M;

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

Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<int,int> p;

int main(){
    Int H, W; cin >> H >> W;

    if(W % 3 == 0 || H % 3 == 0){
        cout << 0 << endl; return 0;
    }

    // 縦に3等分した場合
    Int ans1 = H*(W/3+1) - H*(W/3);

    //横に3等分した場合
    Int ans2 = W*(H/3+1) - W*(H/3);

    // 縦に1回 横に1回切る場合
    Int ans3 = 1e18;
    rep1(i,W-1){
        vector<Int> S;
        S.push_back(H * i);
        S.push_back((H/2) * (W-i));
        if(H % 2 == 1) S.push_back((H/2 + 1) * (W-i));

        sort(S.begin(), S.end());
        ans3 = min(ans3, S.back()-S.front());
    }

    // 横に1回 縦に1回切る場合
    Int ans4 = 1e18;
    rep1(i,H-1){
        vector<Int> S;
        S.push_back(W * i);
        S.push_back((W/2) * (H-i));
        if(W % 2 == 1) S.push_back((W/2 + 1) * (H-i));

        sort(S.begin(), S.end());
        ans4 = min(ans4, S.back()-S.front());
    }

    cout << min(ans1, min(ans2, min(ans3, ans4))) << endl;
}


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

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> seen(n, 0);
    vector<bool> ok(n,false);
    int ans = 0;
    int cnt = 0;
    rep(i,m) {
        int a; string b;
        cin >> a >> b;
        a--;
        if (b == "WA" && ok[a] == false) seen[a]++;
        if (b == "AC") ok[a] = true;
    }
    rep(i,n) {
        cnt += ok[i];
        if (seen[i] != 0 && ok[i]) ans += seen[i];
    }

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

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<long long> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    long long ans=100000000000;
    long long temp;
    for(int i=0;i<n-k+1;i++){
        temp=abs(h[i]-h[i+k-1]);
        if(temp<ans){
            ans=temp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i<3;i++){
  if (S.at(i) == 'o'){
  count += 1;
  }
  }
  cout << 700+count*100;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string.h>
#include <string>
#include <cstring>
using namespace std;



int main(){
	int N;
	cin >> N;
	int i=0;
	int count =0;
	int a,b;
	for(i=0;i<N;i++){
		cin >> a >> b;
		b = b - a + 1;
		count+=b;
	}
	cout << count << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <tuple>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    //    ifstream in("input.txt");
    //    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if ((a*b)%2) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<bool> p(n, true);
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i == a) p[i - 1] = false;
    }

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] == false) {
            cnt++;
            p[i + 1] = true;
        }
    }

    cout << cnt << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int dp[2][333][333];
int N,M;

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    cin>>N>>M;
    dp[0][1][0]=1;

    rep(i,M){
        rep(j,N+1){
            rep(k,N+1){
                if(dp[i&1][j][k]==0)continue;
                int o=N-j-k;
                add(dp[(i+1)&1][j][k+1],dp[i&1][j][k]*o%mod);
                add(dp[(i+1)&1][j][k],dp[i&1][j][k]*k%mod);
                add(dp[(i+1)&1][j+k][0],dp[i&1][j][k]*j%mod);
                dp[i&1][j][k]=0;
            }
        }
    }

    cout<<dp[M&1][N][0]<<endl;
    return 0;
}


Measured memory_bytes: 1792