akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int64 dp[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &w[i], &v[i]);
  }
  int len = 0;
  memset(dp, 255, sizeof(dp));
  dp[0] = 0;
  for (int i = 0; i < n; ++i) {
    len = min(len + w[i], m);
    for (int j = len; j >= w[i]; --j) {
      if (dp[j - w[i]] >= 0) {
        dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
      }
    }
  }
  int64 ret = 0;
  for (int i = 0; i <= len; ++i) {
    ret = max(ret, dp[i]);
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
 
class main
{
    static void Main(string[] args)
    {
        string[] read = Console.ReadLine().Split(' ');
 
        long A = int.Parse(read[0]);
        long B = int.Parse(read[1]);
        long C = int.Parse(read[2]);
        long K = int.Parse(read[3]);
 
        if(K <= A){
			Console.Write(K);
        }else if(K <= A + B)
        {
            Console.Write(A);
        }else
        {
            Console.Write(A - (K - (A + B)));
        }
    }
}

Measured memory_bytes: 27548
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int x,y;
	cin>>x>>y;
	if(x==0){
		if(y>0) cout<<y;
		else cout<<-y+1;
	}
	else if(y==0){
		if(x<0) cout<<-x;
		else cout<<x+1;
	}
	else if(x>=0 && y>=0){
		if(x>y){
			cout<<x-y+2;
		}
		else cout<<y-x;
	}
	else if(x<0 && y<0){
		if(x<y) cout<<y-x;
		else cout<<x-y+2;
	}
	else cout<<abs(abs(x)-abs(y))+1;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int A[200001];
int B[200001];

signed main()
{
	cin >> N;
	REP(i, N)
	{
		cin >> A[i];
		B[i] = A[i];
	}
	ARY_SORT(B, N);
	REP(i, N)
	{
		if (A[i] == B[N - 1])
		{
			cout << B[N - 2] << endl;
		}
		else
		{
			cout << B[N - 1] << endl;
		}
	}
}



Measured memory_bytes: 4736
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

long long c[64];

int main() {
	int M, D;
	scanf("%d %d", &M, &D);
	int res = 0;
	for (int m = 1; m <= M; m++) {
		for (int d = 22; d <= D; d++) {
			if (d % 10 >= 2 && (d / 10)*(d % 10) == m) {
				res++;
			}
		}
	}
	printf("%d", res);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
s = input()

ans = 0
for i in range(0, 1000):
    x = str(i).zfill(3)

    try:
        id1 = s.index(x[0])
        id2 = s.index(x[1], id1+1)
        id3 = s.index(x[2], id2+1)
        ans += 1
    except ValueError:
        continue

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int n, k;
double ret = 0;
void solve() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        double tmp = 1.0 / n;
        int now = i;
        while (now < k) {
            now *= 2;
            tmp /= 2;
        }
        ret += tmp;
    }
    printf("%.12f\n", ret);
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

bool check( int n ) {
    while( n ) {
        if( se.count(n%10) ) return true;
        n /= 10;
    } 
    return false;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, d, temp;
    cin >> n >> d;
    for( int i = 0; i < d; i++ ) {
        cin >> temp;
        se.insert( temp );
    }
    string ans;
    while( check(n) ) n++;
    cout << n << '\n';
    return 0;
}

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

using namespace std;

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	int g;
	int maxx = 0;
	for (int i=0 ; i<n ; i++) {
		int x;
		scanf("%d", &x);
		maxx = max(maxx, x);
		if (i) g = __gcd(g, x);
		else g = x;
	}
	if (k%g or k>maxx) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE\n");
	return 0;
}

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

long long n;
long long cnt[30] = {0};
string s;

long long solve();

int main() {
  cin >> n >> s;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 1;
  for(int i = 0; i < n; ++i) ++cnt[s[i] - 'a'];
  for(int i = 0; i < 26; ++i) {
    ans *= (cnt[i] + 1);
    ans %= N;
  }
  return ans - 1;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 1005;

int H, W;
char maze[MAX_N][MAX_N];
int dp[MAX_N][MAX_N];

bool isInField(int x, int y) {
  return 0 <= x && x < W && 0 <= y && y < H;
}

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

signed main()
{
  cin >> H >> W;
  REP(h,H) {
    REP(w,W) {
      cin >> maze[h][w];
    }
  } 

  dp[0][0] = 1;

  REP(y,H) {
    REP(x,W) {
      if(dp[y][x] == 0) {
        continue;
      }
      REP(d,2) {
        int nx = x + dx[d];
        int ny = y + dy[d];
        if(isInField(nx, ny) && maze[ny][nx] == '.') {
          dp[ny][nx] += dp[y][x];
          dp[ny][nx] %= MOD;
        }
      }
    }
  }

  cout << dp[H-1][W-1] << endl;

  return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N);
  vector<int> y(M);
  for (int i=0; i<N; i++) {
    cin >> x[i];
  }
  for (int i=0; i<M; i++) {
    cin >> y[i];
  }
  int XMAX=X;
  int YMIN=Y;
  for (int i=0; i<N; i++) {
    X=max(X, x[i]);
  }
  for (int i=0; i<M; i++) {
    Y=min(Y, y[i]);
  }
  if (X<Y) {
    cout << "No War" << endl;
  }
  else {
    cout << "War" << endl;
  }
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int a1[n];
	for(int i=0;i<n;i++)
	{
		a1[a[i]-1]=i+1;
	}
	for(int i=0;i<n;i++)
	{
		cout<<a1[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 1536
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            Array.Sort(a);
            Console.WriteLine(a[2] - a[0]);
        }
    }
}



Measured memory_bytes: 13396
A = [input().split() for i in range(3)]
n = int(input())
B = [[False for i in range(3)] for j in range(3)]

for i in range(n):
    m = input()
    for j in range(3):
        for k in range(3):
            if A[j][k] == m:
                B[j][k] = True

for i in range(3):
    if B[i][0] and B[i][1] and B[i][2]:
        print("Yes")
        exit()
    if B[0][i] and B[1][i] and B[2][i]:
        print("Yes")
        exit()

if B[0][0] and B[1][1] and B[2][2]:
    print("Yes")
    exit()
if B[0][2] and B[1][1] and B[2][0]:
    print("Yes")
    exit()

print("No")

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;


int main() {
    int h, w, n; cin >> h >> w >> n;

    int ans = IINF;
    for(int i = 0; i <= h; i++){
        for(int j = 0; j <= w; j++){
            int sum = i * h + j * w - i * j;
            if(sum >= n) ans = min(ans, i + j);
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int INF = 1<<29;

int dp[256][16][128];
int stones[256][16][2];
int col[256];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while (true) {
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0) break;
  
    REP(i, N) {
      cin >> col[i];
      REP(j, col[i]) {
	REP(k, 2) cin >> stones[i][j][k];
      }
    }

    REP(i, N) REP(j, col[i]) REP(k, M+1) dp[i][j][k] = INF;
    REP(j, col[0]) dp[0][j][0] = 0;
    REP(j, col[1]) dp[1][j][1] = 0;
    REP(i, N-1) {
      REP(j, col[i]) {
	int x_now = stones[i][j][0], d_now = stones[i][j][1];
	REP(m, M+1) {
	  if (dp[i][j][m] == INF) continue;
	  REP(k, col[i+1]) {
	    int x_next = stones[i+1][k][0], d_next = stones[i+1][k][1];
	    int safe = (d_now + d_next) * abs(x_now - x_next);
	    dp[i+1][k][m] = min(dp[i+1][k][m], dp[i][j][m] + safe);
	  }
	  if (i < N-2 && m < M) {
	    REP(k, col[i+2]) {
	      int x_next = stones[i+2][k][0], d_next = stones[i+2][k][1];
	      int safe = (d_now + d_next) * abs(x_now - x_next);
	      dp[i+2][k][m+1] = min(dp[i+2][k][m+1], dp[i][j][m] + safe);
	    }
	  }
	}
      }
    }

    int ans = INF;
    REP(j, col[N-1]) REP(m, M+1) ans = min(ans, dp[N-1][j][m]);
    REP(j, col[N-2]) REP(m, M) ans = min(ans, dp[N-2][j][m]);
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  int ans = 0;
  int next = 1;
  int index = 1;
  int cnt = 1;
  while(1) {
    index = next;
    next = a[index - 1];
    // cout << index << endl;
    // cout << next << endl;
    if(next == 2) {
      ans = cnt;
      break;
    }
    if(cnt > N) {
      ans = -1;
      break;
    }
    cnt++;
  }
  cout << ans << endl;
  return 0;
}

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

const int64_t mod = 1e9 + 7;
int64_t fact[4013];

int64_t add_mod (int64_t a, int64_t b, int64_t m) {
    return (a + b) % m;
}

int64_t sub_mod (int64_t a, int64_t b, int64_t m) {
    return (a - b + m) % m;
}

int64_t mul_mod (int64_t a, int64_t b, int64_t m) {
    return (a * b) % m;
}

int64_t pow_mod (int64_t a, int64_t b, int64_t m) {
    int64_t res = 1, t = a;
    while (b) {
        if (b & 1)
            res = mul_mod(res, t, m);
        t = mul_mod(t, t, m);
        b >>= 1;
    }
    return res;
}

int64_t div_mod (int64_t a, int64_t b, int64_t m) {
    return mul_mod(a, pow_mod(b, m - 2, m), m);
}

int64_t ncr_mod (int64_t n, int64_t k, int64_t m) {
    return div_mod(fact[n], mul_mod(fact[n - k], fact[k], m), m);
}

void precalc (int64_t m) {
    fact[0] = 1;
    for (int64_t i = 1; i < 4013; ++i)
        fact[i] = mul_mod(fact[i - 1], i, m);
}

signed main () {
    precalc(mod);
    
    int64_t n, k;
    cin >> n >> k;
    for (int64_t moves = 1; moves <= k; ++moves) {
        if (moves <= n + 1 - k)
            cout << mul_mod(ncr_mod(k - 1, moves - 1, mod), ncr_mod(n + 1 - k, moves, mod), mod) << '\n';
        else
            cout << "0\n";
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int total = 0;
		for (int i = 0; i < n; i++) {
			total += Integer.parseInt(sc.next()) - 1;
		}

		System.out.println(total);

	}

}


Measured memory_bytes: 26452
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

long long M = 1000000007;

int n;
vector<vector<long long>> a;
vector<long long> dps, dp;

long long score(int b){
    if(dps[b] != 1ll<<62)return dps[b];
    vector<int> tmp(0);
    for(int i=0;i<n;++i)if((b|(1<<i))==b)tmp.push_back(i);
    long long res = 0;
    for(int i:tmp)for(int k:tmp)res+=a[i][k];
    dps[b] = res;
    return res;
}

// int bb;
// int s;
// vector<int> tmp;

long long solve(int b);
long long rmax(int i, int d, vector<int>* tmp,int s, int b);

long long solve(int b){
    if(dp[b] != 1ll<<62)return dp[b];
    if(b == 0)return 0;
    vector<int> tmp(0);
    for(int i=0;i<n;++i)if((b|(1<<i))==b)tmp.push_back(i);
    int s = tmp.size();
    long long res = -(1ll<<62);
    // for(int c=1;c<(1<<s);++c){
    //     int d = 0;
    //     for(int i=0;i<s;++i)if((c|(1<<i))==c){
    //         d += (1<<tmp[i]);
    //     }
    //     res = max(res,score(d)+solve(b-d));
    // }
    res = rmax(0,0,&tmp,s,b);
    dp[b] = res;
    return res;
}

long long rmax(int i, int d, vector<int>* tmp,int s, int b){
    if(i>=s){
        if(d!=0)return score(d)+solve(b-d);
        else return score(b);
    }
    return max(rmax(i+1, d + (1<<(*tmp)[i]), tmp, s, b), rmax(i+1, d, tmp, s, b) );
}

int main(int argc, char const *argv[]) {
    cin>>n;
    dp = vector<long long>(1<<n,1ll<<62);
    dps = vector<long long>(1<<n,1ll<<62);
    a = vector<vector<long long>>(n,vector<long long>(n));
    for(int i=0;i<n;++i)for(int k=0;k<n;++k)cin>>a[i][k];
    cout<<solve((1<<n)-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)

int main() {
  int n, k, c; cin >> n >> k >> c;
  string s; cin >> s;
  auto getPositions = [&]() {
    vector<int> res;
    for(int i = 0; i < n && res.size() < k;) {
      if(s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r;
  l = getPositions();
  reverse(s.begin(), s.end());
  r = getPositions();
  rep(i, k) r[i] = n-1-r[i];
  reverse(s.begin(), s.end());

  vector<int> lastL(n+1, -1);
  rep(i, k)lastL[l[i]+1] = i;
  rep(i, n) {
    if(lastL[i+1] == -1) lastL[i+1] = lastL[i];
  }
  vector<int> lastR(n+1, -1);
  rep(i, k)lastR[r[i]] = i;
  for(int i = n-1; i >= 0; --i) {
    if(lastR[i] == -1) lastR[i] = lastR[i+1];
  }

  rep(i, n) {
    if(s[i] == 'x') continue;
    int li = lastL[i];
    int ri = lastR[i+1];
    int cnt = 0;
    if(li != -1) cnt += li+1;
    if(ri != -1) cnt += ri+1;
    if(li != -1 && ri != -1 && r[ri]-l[li] <= c) --cnt;
    if(cnt >= k) continue;
    printf("%d\n", i+1);
  }

  return 0;
}


Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int k,x;
  cin>>k>>x;
  for(int i=x-k+1;i<=x+k-1;i++){
    cout<<i<<' ';
  }
  cout<<endl;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    sort(a.begin(), a.end());
    
    cout << a.at(2) - a.at(0) << endl;
    
    return 0;
}


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

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  int n;
  scanf("%d", &n);
  int l[n*2];
  for (int i = 0; i < n*2; i++) {
    scanf("%d", &l[i]);
  }
  qsort(l, n*2, sizeof(int), cmpnum);
  int answer = 0;
  for (int i = 0; i < n*2; i += 2) {
    answer += l[i];
  }
  printf("%d\n", answer);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ":" << x << "\n"
using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;

int main() {
	int INF = (int)pow(10, 8); // cout << INF;
  int H, N;
	cin >> H >> N;
	vi A(N), B(N); // int A_max = 0;
	rep(i, N) {
		cin >> A.at(i) >> B.at(i); // 魔法の番号iは0-ind
		// A_max = max(A_max, A.at(i));
	}	
	vi dp(H + 1, INF); dp.at(0) = 0; // ダメージjを与えるのに必要な魔力の最小値
	// for (int dpi : dp) cout << dpi << " "; cout << endl; //DB
	rep(i, N) {
		rep(j, H + 1) {
			dp.at(min(j + A.at(i), H)) = min(dp.at(min(j + A.at(i), H)), dp.at(j) + B.at(i));
		}
	}	
	int ans = dp.at(H);
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
  string S;
  cin >> S;
  int c;
  if(S.at(0) == 'o')c++;
  if(S.at(1) == 'o')c++;
  if(S.at(2) == 'o')c++;
  cout << 700+c*100 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {
	vint x(28);
	rep(i, 0, 28)
		cin >> x[i];
	vsort(x);
	int now = 1;
	rep(i, 0, 28) {
		if (x[i] != now) {
			while (x[i] != now) {
				cout << now << endl;
				now++;
			}
		}
		now++;
	}
	if (now < 31) {
		while (now < 31) {
			cout << now << endl;
			now++;
		}
	}
	return 0;
}

Measured memory_bytes: 3132
from collections import deque


def calc():
    q.appendleft(0)
    ans = 0
    d = '1'
    kc = 0
    for i, c in enumerate(S):
        if c != d:
            d = c
            if c == '0':
                if kc == K:
                    ans = max(ans, i - q.pop())
                else:
                    kc += 1
            else:
                q.appendleft(i)
    return max(ans, N - q.pop())


N, K = map(int, input().split())
S = input()
q = deque()
print(calc())


Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INF LONG_MAX
#define io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int32_t main()
{
    //io;
    boost;
    int a,b;
    cin>>a>>b;
    int ans=(a*b)/__gcd(a,b);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a , b ,c ,k;
  scanf("%d %d %d %d",&a,&b,&c,&k);
  
  int max = ((a>b?a:b)>c?(a>b?a:b):c);
  
  int ni = max;
  
  for(int i = 0;i < k;i ++){
    int temp = ni;
    ni = temp*2;
  }
  printf("%d",a+b+c+ni-max);
  
  return 0;
}


Measured memory_bytes: 128
import math

a,b=map(int,input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)
    return arr
  
a_list = factorization(a)
b_list = factorization(b)

a_b_and = set(a_list) & set(b_list)
print(len(a_b_and) + 1)


Measured memory_bytes: 3064
n = int(input())
s = str(input())
ans = []
a2z = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i in range(len(s)):
    index = a2z.index(s[i]) + n
    if index <= 25:
        tmp = a2z[index]
        ans.append(tmp)
    else:
        index -= 26
        tmp = a2z[index]
        ans.append(tmp)

print("".join(ans))


Measured memory_bytes: 3188
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int N=Integer.parseInt(in.next());
		
		int T[]=new int[N];
		for(int i=0;i<N;i++)T[i]=Integer.parseInt(in.next());
		
		int M=Integer.parseInt(in.next());

		int P[]=new int[M];
		int X[]=new int[M];
		for(int i=0;i<M;i++){
			P[i]=Integer.parseInt(in.next())-1;
			X[i]=Integer.parseInt(in.next());
		}
		
		int min[]=new int[M];
		for(int i=0;i<M;i++){
			for(int j=0;j<N;j++)
				min[i]=min[i]+T[j];
			for(int n=0;n<N;n++)
				if(P[i]==n){
					min[i]=min[i]-T[n]+X[i];
					break;
				}		
			System.out.println(min[i]);
		}
		in.close();
	}
	
}

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

int main(){
	ll x;
  	cin >> x;
  
  	ll s = 100;
  	int ans = 0;
  	while(s < x){
    	s *= 1.01;
      	ans++;
    }
  	
  	cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll N;
  cin >> N;
  vector<tuple<ll, ll, ll>> XAB(N);
  for (ll i = 0; i < N; i++)
  {
    ll a, b;
    cin >> a >> b;
    XAB.at(i) = make_tuple(a + b, a, b);
  }

  sort(XAB.begin(), XAB.end(), greater<tuple<ll, ll, ll>>());

  ll ans = 0;
  for (ll i = 0; i < N; i++)
  {
    if (i % 2 == 0)
      ans += get<1>(XAB.at(i));
    else
      ans -= get<2>(XAB.at(i));    
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int n, u, k, v;
	std::vector<std::vector<int> > G;
	std::vector<int> min_cost;
	std::vector<bool> is_searched;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	ifs >> n;
#else
	std::cin >> n;
#endif

	G.resize(n);
	is_searched.resize(n, false);
	min_cost.resize(n, -1);

	for(int i = 0; i < n; i++){
#if INPUT_FROM_FILE
		ifs >> u >> k;
#else
		std::cin >> u >> k;
#endif
		G[u - 1].resize(k);
		for(int j = 0; j < k; j++){
#if INPUT_FROM_FILE
			ifs >> v;
#else
			std::cin >> v;
#endif
			G[u - 1][j] = v - 1;
		}
	}

	min_cost[0] = 0;

	std::queue<int> que;
	
	que.push(0);
	while(!que.empty()){
		int n = que.front(); que.pop();

		for(int i = 0; i < G[n].size(); i++){
			int nn = G[n][i];
			
			if(min_cost[nn] < 0 || min_cost[nn] > min_cost[n] + 1){
				min_cost[nn] = min_cost[n] + 1;
				que.push(nn);
			}
		}
	}

	for(int i = 0; i < n; i++){
		std::cout << i + 1 << " " << min_cost[i] << std::endl;
	}


	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <set>
#define llint long long

using namespace std;

llint n, k;
llint p[200005];
llint d[200005], sumd[200005];
set<llint> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> p[i];
	
	p[0] = -100000;
	for(int i = 1; i <= n; i++){
		if(p[i-1] > p[i]) d[i] = 1;
	}
	for(int i = 1; i <= n; i++) sumd[i] = sumd[i-1] + d[i];
	
	llint ans = (n-k+1); bool flag = false;
	for(int i = 1; i+k-1 <= n; i++){
		if(sumd[i+k-1] - sumd[i] == 0) ans--, flag = true;
	}
	if(flag) ans++;
	//cout << ans << endl;
	
	bool premin = false, premax = false;
	bool curmin = false, curmax = false;
	for(int i = 1; i <= k-1; i++) S.insert(p[i]);
	for(int i = 1; i+k-1 <= n; i++){
		S.insert(p[i+k-1]);
		if(*S.begin() == p[i]) curmin = true;
		auto it = S.end(); it--;
		if(*it == p[i+k-1]) curmax = true;
		
		if(sumd[i+k-1] - sumd[i] != 0){
			if(premin && curmax) ans--;
		}
		//cout << i << " " << curmin << " " << curmax << endl;
		premin = curmin, premax = curmax;
		curmin = curmax = false;
		S.erase(p[i]);
		//cout << i << " " << ans << endl;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 14336
N, A, B = map(int, input().split())
def summ(X):
  a = X//10000
  b = (X - a*10000)//1000
  c = (X - a*10000 - b*1000)//100
  d = (X - a*10000 - b*1000 - c*100)//10
  e = X - a*10000 - b*1000 - c*100 - d*10
  return a+b+c+d+e
C = []
for i in range(1,N+1):
  if A <= summ(i) <= B:
    C.append(i)
print(sum(C))

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n, k;
  cin >> n >> k;

  vector<pll> a(n);
  REP(i, n)
    cin >> a[i].FI >> a[i].SE;

  sort(a.begin(), a.end());
  ll ans = 0;
  ll count = 0;
  REP(i, n){
    count += a[i].SE;
    if(count >= k){
      ans = a[i].FI;
      break;
    }
  }
  cout << ans << endl;

  
  
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    REP(i, n) cin >> p[i];

    int mini = 1001;
    int ans = 1000;
    for (int i = -1; i < 102; i++) {
        int tmp;
        if (find(p.begin(), p.end(), i) == p.end())
            tmp = abs(x - i);
        if (tmp < mini) {
            mini = tmp;
            ans = i;
        } else if (tmp == mini) {
            if (i < ans) ans = i;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define PP(m) REP(i, m.size()) cout << m[i] << endl;

vector<bool> isPrime;
ll primed = 0;

void eratosu(ll max){
  if (max < primed) return;
  else primed = max;

  if (max+1 > isPrime.size()) {
    isPrime.resize(max+1,true);
  }
  isPrime[0] = false;
  isPrime[1] = false;

  for(ll i = 2; i * i <= max; ++i) {
    if (isPrime[i]) {
      for(ll j = 2; i * j <= max; ++j) {
        isPrime[i*j] = false;
      }
    }
  }
}

int main() {
  int N;

  while (cin >> N && N) {
    eratosu(N);
    int c=0;
    REP(i, N/2+1) {
      if (isPrime[i] && isPrime[N-i]) {
        c++;
      }
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 1232
X,Y=map(int,input().split())
mod=10**9+7
def nCr(n,r,mod):
    r=min(r,n-r)
    number=denom=1
    for i in range(1,r+1):
        number=number*(n+1-i)%mod
        denom=denom*i%mod
    return number*pow(denom,mod-2,mod)%mod

if (X+Y)%3 !=0:
    print(0)
    exit()
n=((2*X)-Y)//3
m=((X+Y)//3)-n

if n<0 or m<0:
    print(0)
    exit()
print(nCr(n+m,min(n,m),mod))

Measured memory_bytes: 3064
// In His Name

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define gcd __gcd
#define int long long
#define ull unsigned long long

using namespace std;

typedef pair<int, int> pii;

const int N = 1e5 + 1e2, INF = 1e15;
/*int n, mx, W, v[N], w[N], ps[N], dp[110][N];*/

/*const int N = 1e5 + 1e2, INF = 1e15;*/
int n, W, mx, w[N], v[N], dp[110][N], ps[N];

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> W;
	for(int i = 1 ; i <= n ; i++){
        cin >> w[i] >> v[i];
	}
	for(int i = 1 ; i <= n ; i++){
        ps[i] = ps[i - 1] + v[i];
	}
	for(int i = 0 ; i <= n ; i++){
        for(int j = 0 ; j <= 1e5 ; j++){
            dp[i][j] = INF;
        }
	}
	for (int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= ps[i] ; j++){
            if(v[i] > j){
                dp[i][j] = dp[i - 1][j];
            }
            dp[i][j] = min(dp[i - 1][j] , dp[i - 1][j - v[i]] + w[i]);
        }
	}
	for (int i = 0; i <= n ; i++){
        for (int j = 0 ; j <= 1e5 ; j++){
            if (dp[i][j] <= W){
                mx = max (mx , j);
            }
        }
	}
	cout << mx + 1;
}
	/*cin >> n >> W;
	for (int i = 1 ; i <= n ; i++)
		cin >> w[i] >> v[i];
	for (int i = 1 ; i <= n ; i++)
		ps[i] = ps[i - 1] + v[i];
	for (int i = 0 ; i <= n ; i++){
		for (int j = 0 ; j <= 1e5 ; j++){
			dp[i][j] = INF;
		}
	}
	for (int i = 1 ; i <= v[0] ; i++){
		dp[0][i] = w[0];
	}
	for (int i = 1 ; i <= n ; i++){
		for (int j = 1 ; j <= ps[i] ; j++){
			if (v[i] > j){
				dp[i][j] = dp[i - 1][j];
			}
			dp[i][j] = min (dp[i - 1][j] , dp[i - 1][j - v[i]] + w[i]);
		}
	}
	for (int i = 0 ; i <= n ; i++){
		for (int j = 0 ; j <= 1e5 ; j++){
			if (dp[i][j] <= W){
				mx = max (mx , j);
			}
		}
	}
	cout << mx + 1;
}*/

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

typedef complex<double> P;

string dow[] = {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
};
int main(){
	int m,d;
	while( cin >> m >> d && m ){
		int h = 3;
		for(int i = 1 ; i <= 12 ; i++){
			for(int j = 1 ; j <= vector<int>{-1,31,29,31,30,31,30,31,31,30,31,30,31}[i] ; j++){
				
				if( i == m and j == d ){
					cout << dow[h] << endl;
					goto exit;
				}
				h = (h+1) % 7;
			}
		}
		exit:;
	}
	
			
			
}

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds
{   
    namespace io
    {
        const int MaxBuff = 1 << 21;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
    }

    template<class Type> inline Type read()
    {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

}

using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("duliu.in", "r", stdin);
	freopen ("duliu.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

int n, a[N], b[N], va[N], vb[N], fa[N];

int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

int tot;
inline int find_pos(int x) {
	return lower_bound(va + 1, va + tot + 1, x) - va;
}

bitset<N> vis;

int main () {

	File();

	n = read<int>() + 1;

	For (i, 1, n - 1)
		a[i] = read<int>(), a[n] ^= a[i];
	For (i, 1, n - 1)
		b[i] = read<int>(), b[n] ^= b[i];

	For (i, 1, n)
		va[i] = a[i], vb[i] = b[i];
	sort(va + 1, va + n + 1);
	sort(vb + 1, vb + n + 1);

	For (i, 1, n)
		if(va[i] != vb[i]) return puts("-1"), 0;

	tot = unique(va + 1, va + n + 1) - va - 1;
	For (i, 1, tot) fa[i] = i;

	For (i, 1, n) {
		a[i] = find_pos(a[i]); b[i] = find_pos(b[i]);
		int rtx = find(a[i]), rty = find(b[i]);
		if (rtx != rty) fa[rtx] = rty;
	}

	int ans = 0, sum = 0;
	For (i, 1, n - 1) if (a[i] != b[i])
		++ ans, vis[a[i]] = vis[b[i]] = true;
	vis[a[n]] = vis[b[n]] = true;

	For (i, 1, n) if (vis[i] && find(i) == i) ++ sum;

	printf ("%d\n", ans + max(0, sum - 1));

	return 0;

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn int

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


int main()
{
  ll n;
  cin >> n;
  string s = "";
  while(n != 0)
  {
    if(n % 2 != 0)
    {
      s = "1" + s;
      n--;
    }
    else s = "0" + s;
    n /= -2;
  }

  if(s == "") s = "0";

  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x; cin>>n>>d>>x;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin>>a.at(i);
    int j=1;
    while(j<=d){
      j+=a.at(i);
      x++;
    }
  }
  cout<<x<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); ++i) {
		if( s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C' ) { 
			cnt++;
			ans = max(ans, cnt);
		}
			
		else cnt = 0;	
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
/*  ex9_2
	masaaki52	*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//リストのノード（スタック内の各データ）の定義
typedef  struct stack{
  char elem;
  struct node *next;
}node;

//スタックにデータを追加
void push(node **first,char elem){
  //追加する分の領域を確保
  node *new = calloc(1,sizeof(node));
  if(new == NULL) exit(1);
  new->elem = elem;
  new->next = *first;
  *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
  char elem;
  node *tmp = *first;
  if(tmp == NULL) exit(1);
  elem = tmp->elem;
  *first = tmp->next;
  //取り出したノードのメモリを解放
  free(tmp);
  return elem;
}
    
int main(void){
  char string[100001];
  node *cube = NULL;//最初のノードの指す先
  int i,count = 0;
  scanf("%s",string);
  for(i=0;i<strlen(string);i++){
    //cubeが空ならstring[i]をcubeに入れる
    if(cube == NULL){
      push(&cube,string[i]);
    }
    //cubeが空でない場合
    //cubeに入った一番新しい文字とstring[i]が同じなら,string[i]をcubeに入れる
    else if(string[i] == cube->elem){
      push(&cube,string[i]);
    }
    //そうでないなら、cubeから一つ取り出して2個分カウントする
    else{
      pop(&cube);
      count += 2;
    }
  }
  printf("%d",count);
  return 0;
}

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

long gcd(long n, long m) 
{
	long a = n, b = m;

  	if (a < b) {
	long tmp = a; a = b; b = tmp; 
	}
	
	if (b == 0)		return a;
	else			gcd(b, a%b);
}


int main()
{
	long n;
	cin >> n;
	
	vector<long> a(n);

	REP(i, n) 	cin >> a.at(i);
	
	vector<long> L(n+1, 0), R(n+1, 0);
	
	for (int i = 0; i < n; i++) {
		L.at(i+1) = gcd(a.at(i), L.at(i));
		R.at(n-1-i) = gcd(a.at(n-1-i), R.at(n-i));
	}

	long gcd_max = 0;
	for (int i = 0; i < n; i++) {
		long m = R.at(i+1), n = L.at(i);
		gcd_max = max(gcd_max, gcd(m, n));
	}

	cout << gcd_max << endl;
}

Measured memory_bytes: 2560
n,m=map(int,input().split())
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))
ans=[]
for i in range(1,n+1):
    tmp=0
    for j in range(m):
        if i in ab[j]:
            tmp+=1
    ans.append(tmp)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
  int N,i = 0,ans = 0;
  scanf("%d",&N);
  int C[N],V[N];
  for(i = 0;i < N;i++) scanf("%d",&V[i]);
  for(i = 0;i < N;i++) scanf("%d",&C[i]);

  for(i = 0;i < N;i++) {

    if(V[i] - C[i] > 0) ans += V[i] - C[i];

  }

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
S=input()
T=input()

ma=0
mamax=0

for j in range(len(S)-len(T)+1):
  ma=0
  for i in range(len(T)):
      if T[i]==S[i+j]:
        ma+=1
  mamax=max(ma,mamax)
      
print(len(T)-mamax)

Measured memory_bytes: 8924
L,R = map(int,input().split())
ans = 2019**2
for i in range(L,R+1):
    for j in range(L,R+1):
        if(i!=j):
            hoge = (i*j)%2019
            if(hoge<ans):
                ans = hoge
            if((i*j)%2019 == 0):
                ans = 0
                break
    else:
        continue
    
    break
print(ans)

Measured memory_bytes: 3064
def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
size = 10**6 # size >= n
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, A, B, K = map(int,input().split())
ans = 0
for k in range(N + 1):
    if A * k > K:
        break
    if (K - A * k) % B != 0:
        continue
    l = (K - A * k) // B
    ans += nCr(N,k,mod) * nCr(N,l,mod)
    ans %= mod
print(ans)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int ans = 1;
  int nmax = 0;
  for (int i = 1; i <= n; i++) {
    int num = 0;
    int x = i;
    while (x % 2 == 0) {
      num++;
      x /= 2;
    }
    if (num > nmax) {
      ans = i;
      nmax = num;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
if(N==1){
    cout<<"1.0000000000"<<endl;
    return 0;
}

else if(N%2==1){
    double b;
    b=N/2+1;
    cout<<fixed<<setprecision(10)<<b/N;
}
else{
    cout<<"0.50000000"<<endl;
}
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
#define Q 500


main(){  
  int i,n,S[Q],j,q,T[N],count=0;
  
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){    
      if(S[i]==T[j]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
 
int main(void) {
   string b;
   cin >>  b;
   if(b == "A"){
       cout << "T" << endl;
   }else if(b == "C"){
       cout << "G" << endl;
   }else if(b == "G"){
       cout << "C" << endl;
   }else{
       cout << "A" << endl;
   }
    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	map<string,int> res;
	for(char s[3];~scanf("%*d,%s ",s);)
		res[s]++;
	
	printf("%d\n",res["A"]);
	printf("%d\n",res["B"]);
	printf("%d\n",res["AB"]);
	printf("%d\n",res["O"]);
	
	return 0;
}

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

int main(){
  int n,m;
  cin>> n >> m;
  priority_queue<int> a;
  double var;
  for (int i=0; i<n; i++) {
    cin>> var;
    a.push(var);
  }
  
  if (n==1) {
    a.push(a.top()/pow(2,m));
    a.pop();
    m=0;
  }
  while (m>0){
    var=a.top();
    a.pop();
    while (a.top()<=var && m>0){
      var/=2;
      m--;
    }
    a.push(var);
  }
  
  int64_t ans=0;
  while (!a.empty()){
    ans+=a.top();
    a.pop();
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
#define ll long long 
int main()
{
	ll n; cin>>n;
	ll pt=1;
	ll k=1;
	while(n>0)
	{
		n/=2;
 	if(n>0){
		pt+=(ll)(1LL<<k);
		k++;
	}
	}
	cout<<pt;
}
		
	

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

char a[1010][1024];
int dp[1010][1024];
void solve() {
    int n,m;
    cin >> n >> m;
    dp[1][1] = 1;
    for(int i=1;i<=n;++i){
        for(int e=1;e<=m;++e){
            char x;
            cin >> x;
            if(x=='.'){
                dp[i][e]+=dp[i-1][e];
                dp[i][e]+=dp[i][e-1];
            }
            dp[i][e]%=mod;
        }
    }

    cout << dp[n][m]<<"\n";
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
int N, i; string S, ans=""; cin >> N >> S;
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
map<char, int> D;
for(i=0; i<A.size(); i++){ D[A[i]]=i; }
for(i=0; i<S.size(); i++){ ans+=A[(D[S[i]]+N)%26]; }
cout << ans << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int ca;
  char a[3];
  while(scanf("%d",&ca)!=EOF){
    ca=ca%39;
    if(ca==0)ca=39;
    if(ca/10<=0)printf("3C0%d\n",ca);
    else printf("3C%d\n",ca);
  }
  return 0;
}


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

using ll=long long;
using ld=long double;

void solve(){
	int x,kyu;
	cin>>x;
	if(x>=400 && x<=599) kyu=8;
	if(x>=600 && x<=799) kyu=7;
	if(x>=800 && x<=999) kyu=6;
	if(x>=1000 && x<=1199) kyu=5;
	if(x>=1200 && x<=1399) kyu=4;
	if(x>=1400 && x<=1599) kyu=3;
	if(x>=1600 && x<=1799) kyu=2;
	if(x>=1800 && x<=1999) kyu=1; 
	cout<<kyu<<'\n';
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
void p(const vector<int>& xs) {
  cout<< xs.size() << ": ";
  for(const auto& x:xs) cout<<x<<",";
  cout<<endl;
}
vector<int> f(vector<int>& v, int size, string s, bool b3, bool b5, bool b7) {
  if (s.size() == size) {
    if(b3 && b5 && b7) v.push_back(stoi(s));
    return v;
  }
  f(v, size, s + "3", true, b5, b7);
  f(v, size, s + "5", b3, true, b7);
  f(v, size, s + "7", b3, b5, true);
  return v;
}
vector<int> v;
main() {
  for(int i=1;i<=9;++i) f(v, i, "", false, false, false);
  int N; cin>>N;
  int ans=0; for(auto i:v) if(i<=N) ++ans;
  cout<< ans <<endl;
}

Measured memory_bytes: 512
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		boolean firstFlag = true;
		while(stdIn.hasNext())
		{
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			if(a == 0 && b == 0)
			{
				break;
			}
			if(!firstFlag)
			{
				System.out.println("");
			}
			boolean existFlag = false;
			for(int i = a; i <= b; ++i)
			{
				if(i % 4 == 0 && i % 100 != 0 || i % 400 == 0)
				{
					System.out.println(i);
					existFlag = true;
				}
			}
			if(!existFlag)
			{
				System.out.println("NA");
			}
			firstFlag = false;
		}
	}
}

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

int main(){
  int N;
  int x = 0;
  cin >> N; 
  vector<int>L(N);
  rep(i,N)
    cin >> L.at(i);
  sort(L.begin(),L.end());
  rep(i,N)
  rep(j,i)
   rep(k,j)
    if(L.at(j) != L.at(k) && L.at(i) != L.at(k) && L.at(i) != L.at(j)){
      if (L.at(i) < L.at(k)+L.at(j)){
        x++;
      }
    }
  cout << x;
}

Measured memory_bytes: 3524
n, m = map(int, input().split())
coin = list(map(int, input().split()))
    
#dp = [[0]*(w+1) for _ in range(n+1)]
#dp[0] = [0]*(w+1)
dp = [999999]*(n+1)
dp[0] = 0

for i in range(1, n+1):
    dp[i] = min([dp[i-coin[j]]+1 if i-coin[j]<n and i-coin[j]>=0 else 999999 for j in range(m)])

            
print(dp[n])


Measured memory_bytes: 7260
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int s[n];
  sort(s,s+n);
  for(int i=0;i<n;i++) cin >> s[i];
  for(int i=1;i<=s[0];i++){
    if(n==2&&s[0]%i==0&&s[1]%i==0) cout << i << endl;
    else if(n==3&&s[0]%i==0&&s[1]%i==0&&s[2]%i==0) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 1180