akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
int n,m,o;
int t[1200][1200];
int dp[1200][1200];
int flg[1200][1200];
int isP[1000001];
int numx[1000001];
int numy[1000001];
int st[1000],size=0;
int MAXvalue,MAXno;
void make();
void init();

int main(){
  m=1000000;
  make();
  numy[1]=numx[1]=600;
  while(cin>>m>>n&&n){
    MAXvalue=MAXno=0;
    for(int i=0;i<1200;i++)for(int j=0;j<1200;j++)flg[i][j]=dp[i][j]=-1;

    flg[numy[n]][numx[n]]=n*isP[n];
    dp[numy[n]][numx[n]]=isP[n];
    for(int i=0;i<1200;i++){
      for(int j=0;j<1200;j++){
	if(t[i][j]==0||t[i][j]>m||dp[i][j]==-1)continue;
	//cout<<t[i][j]<<endl;
	dp[i+1][j-1]=dp[i+1][j]=dp[i+1][j+1]=0;
	for(int k=j-1;k<j+2;k++){
	  if(dp[i-1][k]==-1)continue;

	  if(dp[i-1][k]+isP[t[i][j]]>dp[i][j]){

	    dp[i][j]=dp[i-1][k]+isP[t[i][j]];
	    if(isP[t[i][j]])flg[i][j]=t[i][j];
	    else flg[i][j]=flg[i-1][k];

	  }else if(dp[i-1][k]+isP[t[i][j]]==dp[i][j]){

	    if(isP[t[i][j]])flg[i][j]=t[i][j];
	    else flg[i][j]=max(flg[i][j],flg[i-1][k]);

	  }
	}//k
	//cout<<t[i][j]<<' '<<flg[i][j]<<' '<<dp[i][j]<<endl;
	if(MAXvalue<dp[i][j]){
	  MAXvalue=dp[i][j];
	  MAXno=flg[i][j];
	}else if(MAXvalue==dp[i][j]){
	  MAXno=max(MAXno,flg[i][j]);
	}
      }//j

    }//i
    cout<<MAXvalue<<' '<<MAXno<<endl;
  }
  return 0;
}
void make(){
  for(int i=0;i<1200;i++){
    for(int j=0;j<1200;j++){
      dp[i][j]=t[i][j]=0;flg[i][j]=-1;
    }
  }

  for(int i=0;i<1000001;i++)isP[i]=1;
  
  isP[0]=isP[1]=0;
  for(int i=2;i*i<1000001;i++){
    if(!isP[i])continue;
    for(int j=i*i;j<1000001;j+=i){
      isP[j]=0;
    }
  }

  int nx,ny,cnt=2,z=1,k;
  nx=ny=600;
  t[600][600]=1;
  
  while(cnt<=m){
    //cout<<cnt<<endl;
    for(k=nx+1;k<=nx+z;k++){
      numy[cnt]=ny;numx[cnt]=k;
      t[ny][k]=cnt++;
      if(cnt>m)break;
    }
    nx+=z;
    
    for(k=ny-1;k>=ny-z;k--){
      numy[cnt]=k;numx[cnt]=nx;
      t[k][nx]=cnt++;
      if(cnt>m)break;
    }
    ny-=z;

    z++;
  
    
    for(k=nx-1;k>=nx-z;k--){
      numy[cnt]=ny;numx[cnt]=k;
      t[ny][k]=cnt++;
      if(cnt>m)break;
    }
    nx-=z;

    for(k=ny+1;k<=ny+z;k++){
      numy[cnt]=k;numx[cnt]=nx;
      t[k][nx]=cnt++;
      if(cnt>m)break;
    }
    ny+=z;
    
    z++;
  }
  /*
  for(int i=numy[37];i<=numy[43];i++){
    for(int j=numx[37];j<=numx[26];j++){
      printf("%3d ",t[i][j]);
    }
    cout<<endl;
  }
  */
}

Measured memory_bytes: 29760
#include <iostream>

using namespace std;

int main(void) {
    int K, X;
    cin >> K >> X;
    for(int i=-K+1; i<K; i++) {
        int now = X+i;
        if(now >= -1'000'000 && now <= 1'000'000) {
            cout << now << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int k, x;
    cin >> k >> x;
    for (int i=x-k+1; i < x+k; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
class Geng
{
private:
    int a[3000001];
    int n, k;
public:
    int mainop()
    {
        a[0] = 1;
        std::cin >> n >> k;
        for(int i = 1;i <= n;++ i)
            a[i] = std::min(a[i-1]+k, a[i-1]*2);
        std::cout << a[n];
        return 0;
    }
};
Geng Qingyuan;
int main()
{
    Qingyuan.mainop();
    return 0;
}

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

using namespace std;
typedef long long ll;

const int N = 200'010;
int n, a[N], cnt[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++) sum += 1ll * cnt[i] * (cnt[i] - 1) / 2;
    for (int i = 1; i <= n; i++) printf("%lld\n", sum - cnt[a[i]] + 1);
}


Measured memory_bytes: 5380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

vector<vector<int>> e;
vector<int> ts;
vector<int> dp;
vector<bool> done;

void DFS(int n) {
  if (done[n]) {
    return;
  }
  done[n] = true;
  for (auto to : e[n]) {
    DFS(to);
  }
  ts.push_back(n);
}

void solve(istream& cin, ostream& cout) {
  int n, m;
  cin >> n >> m;

  e = vector<vector<int>>(n, vector<int>(0));
  dp = vector<int>(n, 0);
  ts = vector<int>(0);
  done = vector<bool>(n, false);

  REP(i, m) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    e[x].push_back(y);
  }

  REP(i, n) {
    DFS(i);
  }

  int ans = 0;
  reverse(ts.begin(), ts.end());
  for (auto node : ts) {
    for (auto to : e[node]) {
      dp[to] = max(dp[to], dp[node] + 1);
    }
  }
  REP(i, n) {
    ans = max(dp[i], ans);
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010
#define EPS 0.000000001

bool comp(pair<int, int> a, pair<int, int> b) {
    return (a.first * b.second) > (b.first * a.second);
}

void solve() {
    int n;
    long double w;
    cin >> n >> w;

    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end(), comp);
    long double ans = 0;
    for (int i = 0; i < n; i++) {
        if (v[i].second <= w) {
            ans += v[i].first;
            w -= v[i].second;
        } else {
            ans += (v[i].first) * (w / (v[i].second));
            break;
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 4476
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	int a, b;
	cin >> a >> b;
	int x = max(a - 2 * b, 0);
	PRI(x);
	return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
	for(;;)
	{
		int a[1000],b[1000],c[1000],d[1000],e[1000],f,g,h,i,j,k,l[1000],n;
		j=0;
		scanf("%d",&k);
		if(k==0)
		{
			break;
		}
		for(n=1;n<=k;n++)
		{
			scanf("%d %d %d %d",&a[n],&b[n],&c[n],&d[n]);
			e[n]=b[n]*4+c[n]*9+d[n]*4;
		}
		scanf("%d %d %d %d",&f,&g,&h,&i);
		for(n=1;n<=k;n++)
		{
			if(b[n]<=f&&c[n]<=g&&d[n]<=h&&e[n]<=i)
			{
				j++;
				l[j]=a[n];
			}
		}
		if(j==0)
		{
			printf("NA\n");
		}
		else
		{
			for(n=1;n<=j;n++)
			{
				printf("%d\n",l[n]);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using ll = int_fast64_t;

bool judge(ll n, ll k){
        while(n%k==0) n/=k;
        return n%k==1;
}


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

        std::set<ll> st;
        ll m = n;
        for(ll i=2; i*i<=m; i++){
                if(m%i==0){
                        st.insert(i);
                        if(i*i!=m) st.insert(m/i);
                }
        }

        m = n-1;
        for(ll i=2; i*i<=m; i++){
                if(m%i==0){
                        st.insert(i);
                        if(i*i!=m) st.insert(m/i);
                }
        }

        ll ans = 1 + (n!=2);
        for(ll i: st) ans += judge(n, i);
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 512
if __name__ == '__main__':
    S = input()
    recur_num = (len(S) - 1) ** 2

    for i in range(recur_num):
        ope = []
        for j in range(len(S) - 1):
            if i & (2 ** j):
                ope.append("+")
            else:
                ope.append("-")

        if eval(S[0] + ope[0] + S[1] + ope[1] + S[2] + ope[2] + S[3]) == 7:
            print(S[0] + ope[0] + S[1] + ope[1] + S[2] + ope[2] + S[3] + "=7")
            break


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >> z;
    x-=z;
    cout << x/(y+z) << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
import collections
N,M=map(int,input().split())
L=collections.defaultdict(list)
p=[[int(j) for j in input().split()] for i in range(M)]
for x,y in sorted(p):
    L[x]+=[y]
for x,y in p:
    z=bisect.bisect(L[x],y)
    print("%06d%06d"%(x,z))


Measured memory_bytes: 41024
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> ls(n);
    for(int i=0; i<n; ++i){
        cin >> ls[i];
    }
    sort(ls.begin(), ls.end());
    int sum=accumulate(ls.begin(), ls.end()-1, 0);
    cout << (ls[n-1]<sum ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 30;
const int mod = 1e9 + 7;

int main() {
   int n, k;
   cin >> n >> k;
   vector<int> h(n);
   rep(i, n) cin >> h[i];
   vector<int> dp(n, inf);
   dp[0] = 0;
   rep(i, n) {
      for (int j = 1; j <= k; j++) {
         if (i - j < 0)
            break;
         dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
      }
   }
   cout << dp[n - 1] << endl;
   return 0;
}

Measured memory_bytes: 1024
object Main extends App {
  val N = Scanner.nextInt
  val M = Scanner.nextInt
  val G = Array.fill(N)(0)
  (0 until M).foreach(i => {
      G(Scanner.nextInt - 1) += 1
      G(Scanner.nextInt - 1) += 1
  })
  val p = new java.io.PrintWriter(System.out)
  G.foreach(p.println)
  p.flush
}

object Scanner {
  private val buf = new Array[Byte](1024)
  private var ptr = 0
  private var len = 0

  @inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
  @inline private def hasNextByte: Boolean = if (ptr >= len) {
      ptr = 0
      len = System.in.read(buf)
      len > 0
    } else {
      true
    }
  @inline private def hasNext: Boolean = {
    while (hasNextByte && !isPrintableChar(buf(ptr))) ptr += 1
    hasNextByte
  }
  @inline private def readByte: Byte = {
    if (hasNextByte) {
      val res = buf(ptr)
      ptr += 1
      res
    } else {
      -1
    }
  }

  def next: String = {
    if(!hasNext) ???
    val sb = new StringBuilder
    var b = readByte
    while (isPrintableChar(b)) {
      sb.append(b.toChar)
      b = readByte
    }
    sb.toString
  }
  def nextInt: Int = {
    val n = nextLong
    if (n < Int.MinValue || Int.MaxValue < n) ???
    n.toInt
  }
  def nextLong: Long = {
    if(!hasNext) ???
    var minus = false
    var b = readByte
    if (b == '-') {
      minus = true
      b = readByte
    }
    def go (b: Byte, n: Long = 0): Long =
      if ('0' <= b && b <= '9') go(readByte, n * 10 + b - '0')
      else if (minus) -n
      else n
    go(b)
  }
  def nextDouble: Double = next.toDouble
}

Measured memory_bytes: 26924
#include <stdio.h>
#include <math.h>
#include <string.h>

int main() {
	long long int N, i, n = 0, j;
	char S[64];
	memset(S, '0', sizeof(S));

	scanf("%lld", &N);

	if (N == 0) {
		printf("0");
		return 0;
	}
	else if (N > 0) {
		for (i = 0; n < N; i += 2) {
			n = n + (long long int)pow(2.0, (double)i);
			S[i] = '1';
		}
		i -= 2;
		for (j = 1; j <= i; j++) {
			if (N <= n - (long long int)pow(2.0, (double)(i - j))) {
				n = n - (long long int)pow(2.0, (double)(i - j));
				if (j % 2 == 1) {
					S[j] = '1';
				}
				else {
					S[j] = '0';
				}
			}
		}
	}
	else {
		for (i = 1; n > N; i += 2) {
			n = n - (long long int)pow(2.0, (double)i);
			S[i - 1] = '1';
		}
		i -= 2;
		for (j = 1; j <= i; j++) {
			if (N >= n + (long long int)pow(2.0, (double)(i - j))) {
				n = n + (long long int)pow(2.0, (double)(i - j));
				if (j % 2 == 1) {
					S[j] = '1';
				}
				else {
					S[j] = '0';
				}
			}
		}
	}

	S[i + 1] = '\0';
	printf("%s", S);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,K;
  cin>>N>>K;
  long long c=N/K;
  long long d=0;
  if(K%2==0){
    if(N%K<K/2){
      d=c;
    }
    else{
      d=c+1;
    }
  }   
  cout<<c*c*c+d*d*d<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int N; cin >> N;
    map<int, int>m;
    m[0]++;
    int D[N + 1]; rep(i, N) cin >> D[i + 1], m[D[i + 1]]++;
    D[0] = 0;
    vector<int> f, f_bit;
    for(auto itr = m.begin(); itr != m.end(); ++itr) {
        if(itr -> second > 2) {
            cout << 0 << endl;
            return 0;
        }else if(itr -> second == 2) {
            f.pb(24 - itr -> first);
            f.pb(itr -> first);
        }else {
            if(itr -> first != 0 && itr -> first != 12) f_bit.pb(itr -> first);
        }
    }
    if(m[0] == 2 || m[12] == 2) {
        cout << 0 << endl;
        return 0;
    }
    f.pb(0);
    if(m[12] == 1) f.pb(12);
    int M = f_bit.size();
    int ans = 0;
    for(int bit = 0; bit < (1 << M); ++bit) {
        int minv = 100;
        vector<int> tmp = f;
        for(int i = 0; i < M; ++i) {
            if(bit & (1 << i)) {
                tmp.pb(24 - f_bit[i]);
            }else {
                tmp.pb(f_bit[i]);
            }
        }
        for(int i = 0; i < tmp.size(); ++i) {
            for(int j = i + 1; j < tmp.size(); ++j) {
                minv = min(minv, min(abs(tmp[j] - tmp[i]), 24 - abs(tmp[j] - tmp[i])));
            }
        }
        ans = max(minv, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys


def resolve(in_):
    mod = 1000000007  # 10 ** 9 + 7
    n, k = map(int, in_.readline().split())
    n += 1

    # ans = 0
    ans = 1
    # while n >= k:
    while n > k:
        ans += (
            ((n + (n - k)) * k // 2) % mod - 
            ((1 + k - 1) * k // 2) % mod +
            1
            ) % mod
        ans %= mod
        k += 1
    return ans


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8996
#include<iostream>
#include<vector>

using namespace std;

vector<int> Deck;

void shuffle(int p, int c) {
  vector<int> tmp = Deck;
  for(int i=0; i<Deck.size(); i++) {
    if(i<c) {
      Deck[i] = tmp[p-1+i];
    }
    else if(c<=i && i<c+p-1) {
      Deck[i] = tmp[i-c];
    }
  }
}

int main() {
  int n, r;

  while(cin>>n>>r && n>0) {
    Deck.clear();
    for(int i=0; i<n; i++) {
      Deck.push_back(n-i);
    }
    for(int i=0; i<r; i++) {
      int p, c;
      cin>>p>>c;
      shuffle(p, c);
    }
    cout<<Deck[0]<<endl;
  }
}

Measured memory_bytes: 1216
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

template<typename T>
inline bool maxs(T& a, T const& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
inline bool mins(T& a, T const& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int N = rint();
  int W = rint();
  int dp[W+1] = {};
  dotimes(i, N) {
    int v = rint();
    int w = rint();
    for (int j = w; j <= W; j++)
      maxs(dp[j], dp[j-w] + v);
  }
  wint(dp[W]);
  return 0;
}



Measured memory_bytes: 2820
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
int n,x,y,temp;
bool flag=0; 
int main()
{
	temp=0;
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
	{
		scanf("%d%d",&x,&y);
		if (x==y)
		  {
		  	 temp++;
		  	 if (temp==3) flag=1;
		  }
		 else temp=0;
	}
	if (flag) printf("Yes");
	else printf("No");
	return 0; 
 } 

Measured memory_bytes: 3824
from fractions import gcd

N,M=map(int,input().split())
A=list(map(int,input().split()))

def lcm(a,b):
    return a*b//gcd(a,b)

H=[a//2 for a in A]
lcm_H=H[0] if N==1 else lcm(H[0],H[1])
for i in range(2,N):
    lcm_H=lcm(lcm_H,H[i])

def div2(a):
    ret=0
    while a:
        if a&1==0:
            a>>=1
            ret+=1
        else:
            break
    return ret

t=div2(A[0])
if t==0:
    print(0)
    exit()

for i in range(N):
    if div2(A[i])!=t:
        print(0)
        exit()
    A[i]>>=t

ans=M//lcm_H
ans=(ans+1)//2
print(ans)


Measured memory_bytes: 16308
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)

	sunuke := map[int]struct{}{}
	for i := 0; i < k; i++ {
		var d int
		fmt.Scanf("%d", &d)
		as := scanIntSlice(d)
		for _, a := range as {
			sunuke[a] = struct{}{}
		}
	}

	fmt.Printf("%d\n", n-len(sunuke))
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 2676
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long a[10000];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long ans = 0;
    for(int i = 0; i < n; i++){
        while(a[i]%2==0){
            ans++;
            a[i] /= 2;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

/**
 * @author ??\???
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int W = scanner.nextInt();
		int H = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int r = scanner.nextInt();
		scanner.close();
		
		if (((0 + r) <= x) && (x <= (W - 1))
				&& ((0 + r) <= y) && (y <= (H - 1))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 26336
void main()
{
    long n = rdElem;
    string[] s = 2.rdCol!string;

    dchar[] vh = new dchar[n];
    long result = 1L;
    long pos;
    while (pos < n)
    {
        if (s[0][pos] == s[1][pos])
        {
            vh[pos] = 'v';
            if (pos > 0)
            {
                if (vh[pos-1] == 'v') result *= 2;
            }
            else result *= 3;
            ++pos;
        }
        else
        {
            vh[pos] = 'h', vh[pos+1] = 'h';
            if (pos > 0)
            {
                if (vh[pos-1] == 'v') result *= 2;
                else result *= 3;
            }
            else result *= 6;
            pos += 2;
        }
        result %= mod;
    }

    result.writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < (int)s.length() && s[i] != '\0'; i++) {
        sum += s[i] - '0';
    }
    if (sum % 9 == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3780
W,H,N = map(int,raw_input().split())
ans = 0
X,Y = map(int,raw_input().split())
for i in range(N-1):
	X1,Y1 = map(int,raw_input().split())
	dX,dY = X1-X,Y1-Y
	s = 0 if dX*dY > 0 else 1
	ans += max(abs(dY),abs(dX)) + s*min(abs(dY),abs(dX))
	X,Y = X1,Y1
print ans

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int X = read(), Y = read();
    printf("%d\n", X+Y/2);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=2e5+5;
vi P[MAX];
int a[MAX],grundy[MAX],p[MAX],root,forb,n;
bool O[MAX];
int Find(int u){
	if (p[u]!=u)p[u]=Find(p[u]);
	return p[u];
}

void Union(int u,int v){
	p[Find(u)]=Find(v);
}

void dfs(int u){
	if (u==forb)return;
	if (!sz(P[u]))return;
	for (auto it:P[u])dfs(it);
	for (auto it:P[u])O[grundy[it]]=true;
	for (int i=0;i<=n+2;i++) if (!O[i]){grundy[u]=i;break;}
	for (auto it:P[u])O[grundy[it]]=false;
}

int32_t main()
{
  BOOST;
  cin>>n;
  iota(p+1,p+n+1,1);
  for (int i=1;i<=n;i++){
  	cin>>a[i];
  	if (Find(a[i])==Find(i))root=i;
  	else Union(a[i],i),P[a[i]].pb(i);
  }
  dfs(root);
  if (grundy[root]==grundy[a[root]]){
  	forb=a[root];
  	grundy[a[root]]++;
  	dfs(root);
  	if (grundy[root]!=grundy[a[root]]-1)cout<<"IM";
  }
  cout<<"POSSIBLE";
  return 0;
}


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

int main() {
int a,b;
	while(1){
cin>>a>>b;
if(a==0&&b==0)break;
if(a<b){
cout<<a<<" "<<b<<endl;
}else{cout<<b<<" "<<a<<endl;}}// your code goes here
	return 0;
}

Measured memory_bytes: 1160
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I'){
    cout<<"Yes"<<endl;
  }
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

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


int main(){
    int N;
    cin >> N;
    pair<pair<string, int>, int> rest[N];
    for(int i = 0; i < N; ++i){
        string S;
        int P;
        cin >> S >> P;
        rest[i] = make_pair(make_pair(S, -P), i+1);
    }
    sort(rest, rest + N);
    for(int i = 0; i < N; ++i) cout << rest[i].second << endl;
    return 0;
}




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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    if(s.at(0)==s.at(4)&&s.at(1)==s.at(3))
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

/*ll ma=998244353;
ll power(ll v,ll ti){
if(ti==1)
    return v;
ll x=power(v,ti/2);
x=(x*x)%ma;
if(ti%2==1)
    x=(x*v)%ma;
return x;

}
struct t{
int a,b;
};
vector<vector<t > >g;
vector<int> v;


ll n;


void dfs(int i,int sum){
v[i]=1;


for(int j=0;j<go[i].size();j++){
    int x=go[i][j].a;
    int y=go[i][j].b;
    if(v[x]==0){
        dfs(x,min(y,sum));

    }

}

}*/

 int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m;
cin>>n;
cin>>m;
vector<int> b(m);
for(int i=0;i<m;i++){
    int x;
    cin>>x;
    for(int j=0;j<x;j++){
        int y;
        cin>>y;
        y--;
        b[i]+=(1<<y);
    }
}

    int p[m];
    for(int i=0;i<m;i++)
        cin>>p[i];
        int an1=0;
for(int i=0;i<(1<<n);i++){
        int ans=0;
    for(int j=0;j<m;j++){
            int k1=(b[j]&i);
            int k2=0;
            while(k1>0){
                k2++;
                k1=k1&(k1-1);
            }
        if(p[j]==(k2%2))
            ans++;
    }
if(ans==m){

    an1++;
}
}
cout<<an1<<endl;

}


Measured memory_bytes: 256
#154d
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
e_list = [(1 + p) / 2 for p in p_list]
max_v = sum(e_list[:k])
ret = max_v
#print(e_list, e_list[:k])
for i in range(n - k):
  calc = ret - e_list[i] + e_list[i + k]
  max_v = max(max_v, calc)
  ret = calc
  #print(ret, e_list[i], e_list[i + k], calc)
print(max_v)

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

using namespace std; 

int main() {
	int N, T; 
	cin >> N >> T; 
	int c, t, low = 1001; 

	for(int i = 0; i < N; i++) {
		cin >> c >> t; 
		if(t <= T) {
			low = min(low, c); 
		} 
	}
	if(low == 1001) {
		cout << "TLE" << endl; 
	}
	else {
		cout << low << endl; 
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0) break;
        for(i=1;W>=i;i++){
            printf("#");
            if(i==W) printf("\n");
        }
        for(i=2;H>i;i++){
            for(j=1;W>=j;j++){
                if(j==1||j==W){
                printf("#");
                }
                else printf(".");
                if(j==W) printf("\n");
            }
        }
        for(i=1;W>=i;i++){
            printf("#");
            if(i==W) printf("\n");
        }
        printf("\n");
    }   
}

Measured memory_bytes: 1752
#include<iostream>
#include<algorithm>
const int INF=(1<<22);int dp[1000000],d[20],n,m;
int main(){std::cin>>n>>m;std::fill(dp,dp+n+1,INF);dp[0]=0;for(int i=0;i<m;++i)std::cin>>d[i];for(int i=0;i<m;++i)for(int j=d[i];j<=n;++j){dp[j]=std::min(dp[j],dp[j-d[i]]+1);}std::cout<<dp[n]<<std::endl;}

Measured memory_bytes: 1356
#include<stdio.h>

void trace(int A[], int N){
    int i ;
    for(i=0; i<N;i++){
        if(i>0){
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
}
void intsertionSort(int A[], int N){
    int i,j,v;
    for(i=1;i<=N-1;i++){
        v = A[i];
        j = i -1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        trace (A, N);
    }
}

int main(){
    int a,i,num[100];
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&num[i]);        
    }
    trace(num, a);
    intsertionSort(num,a);
}

Measured memory_bytes: 1812
#include <iostream>
using namespace std;
int main()
{
	int N, counter_ac = 0, counter_wa = 0, counter_tle = 0, counter_re = 0;
	cin >> N;
	string s;
	for (int i = 0; i < N; i++)
	{
		cin >> s;
		if (s == "AC")
		{
			counter_ac++;
		}
		else if (s == "WA")
		{
			counter_wa++;
		}
		else if (s == "TLE")
		{
			counter_tle++;
		}
		else if (s == "RE")
		{
			counter_re++;
		}
	}
	cout << "AC x " << counter_ac << endl;
	cout << "WA x " << counter_wa << endl;
	cout << "TLE x " << counter_tle << endl;
	cout << "RE x " << counter_re << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;

int main() {
	string S;
	cin >> S;

	u64 k = 2019;
	u64 ans = 0;
	boost::dynamic_bitset<> mat(S.size()+1);
	
	for(u64 b=0; b<S.size(); b++) {
		u64 tdiv = 0;
		u64 bs = 0;
		
		if(mat[b]) continue;
		
		for(u64 e=b; e<S.size(); e++) {
			tdiv = tdiv * 10 + S[e] - '0';
			bool r = (tdiv != 0);
			
			tdiv = tdiv - (tdiv / k) * k;
			
			if(r && tdiv == 0) {
				bs++;
				ans += bs;	
				
				if(mat[e+1]) break;
				mat[e+1] = 1;
			}
		}
	}

	cout << ans;

}


Measured memory_bytes: 3688
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001+5000;
//int arr[SIZE]={};
 
int main(){
	ll K;
	cin>>K;
	ll N=50;
	ll per=K%50,sla=K/50;
	vector<ll> vec;
	int i;
	cout<<50<<endl;
	if(1){
		for(i=0;i<per;i++){
			vec.push_back(sla+N);
		}
		for(;i<50;i++){
			vec.push_back(sla+N-per-1);
		}
		for(int i=0;i<vec.size()-1;i++){
			cout<<vec[i];
			cout<<" ";
		}
	}
	else{
		for(i=0;i<per;i++){
			vec.push_back(sla+N);
		}
		for(;i<50;i++){
			vec.push_back(0);
		}
		for(int i=0;i<vec.size()-1;i++){
			cout<<vec[i];
			cout<<" ";
		}
	}
	cout<<vec[vec.size()-1]<<endl;
	return 0;
}

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

int main()
{
  int a, b, c;
  int ans = 0;
  cin >> a >> b >> c;

  for (int i = a; i < b + 1; i ++) {
    if (c % i == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string
#include <vector> // vector
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << i << "\n"

#define int long long // at least int64 > 9*10^18

int ok(std::vector<int>& usable, int n) {
  while(n) {
    if(!usable[n%10]) return 0;
    n/=10;
  }
  return 1;
}

signed main() {
  int n,k;
  std::cin >> n >> k;
  std::vector<int> usable(10,1);
  rep(i,k) {
    int d;
    std::cin >> d;
    usable[d] = 0;
  }
  int t = 0;
  while(1) {
    if(ok(usable,n+t)) break;
    t++;
  }
  print(n+t);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using namespace std;
int main()
{
	string s;int sumc=0;
	bool tf1,tf2;
	tf2=1;
	getline(cin,s);
	for(int i=2;i<=s.size()-2;i++){
	    if(s[i]=='C')sumc++;
	    
	}
	for(int i=1;i<=s.size()-1;i++)if(s[i]!='C'&&s[i]>=65&&s[i]<=91)tf2=0;
	if(s[0]=='A'&&tf2&&sumc==1)cout<<"AC";else cout<<"WA";
	
		    
}

Measured memory_bytes: 256
inputs = []
while str = STDIN.gets
  if str.chomp == "0 0" then break end
  inputs << str.chomp
end

def describe_rectangle(h, w)
  # puts "h = #{h}, w = #{w}"
  output = ""
  for j in 1..h do
    for i in 1..w do
      if j % 2 == 1 then
        if i % 2 == 1 then
          output += "#"
        else
          output += "."
        end
      else
        if i % 2 == 1 then
          output += "."
        else
          output += "#"
        end
      end
    end
    output += "\n"
  end
  puts output
end

# puts inputs
for num in 0..inputs.length - 1 do
  rec = inputs[num].split(" ")
  # puts "rec = #{rec}"
  describe_rectangle(rec[0].to_i, rec[1].to_i)
  puts "\n"
end

Measured memory_bytes: 13968
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, D; cin >> N >> D;
    int ans = (N + D * 2) / (D * 2 + 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;
	vector<int> D(N, 0);
	rep (i, N) cin >> D[i];
	int M; cin >> M;
	vector<int> T(M, 0);
	rep (i, M) cin >> T[i];

	map<int,int> cnt; cnt.clear();
	rep (i, N) ++cnt[D[i]];
	rep (i, M) --cnt[T[i]];

	bool ok = true;
	map<int,int>::iterator it = cnt.begin();
	for (; it != cnt.end(); ++it){
		int d = (*it).first;
		int c = (*it).second;
		if (c < 0){
			ok = false;
		} // end if
	} // end for

	cout << (ok ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 11264
from math import ceil, floor
A, B = map(int, input().split())

ans = 10**10
for b in range(1, A+1):
    a = ceil(b*B/A)
    c = a*A - b*B
    
    if b + c > a > 0:
        ans = min(ans, a*A)
        
if ans == 10**10:
    ans = -1
print(ans)


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

int main(void) {
  int N, max = 0;
  cin >> N;
  map<string, int> mp;
  string S;
  for (int i = 0; i < N; i++) {
    cin >> S;
    auto itr = mp.find(S);
    if (itr != mp.end()) {
      mp[S]++;
    } else {
      mp[S] = 1;
    }
    if (mp[S] > max) {
      max = mp[S];
    }
  }
  for (auto i = mp.begin(); i != mp.end(); i++) {
    if (i->second == max) {
      cout << i->first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n,m;cin>>n>>m;
    ll k;cin>>k;
    ll ans =0;
    vl a,b;
    rep(i,n){
        ll x;
        cin>>x;
        a.push_back(x);
    }
    rep(i,m){
        ll x;cin>>x;
        b.push_back(x);
    }
    vl suma(n,0),sumb(m,0);
    suma[0]=a[0];sumb[0]=b[0];
    rep(i,n-1)suma[i+1]=suma[i]+a[i+1];
    rep(i,m-1)sumb[i+1]=sumb[i]+b[i+1];
    rep(i,n){
        ll w;
        w = k-suma[i];
        ll sum =0;
        //cout<<w<<endl;
        if(w>=0){
        auto it =upper_bound(been(sumb),w);
        int add = it-sumb.begin();
        sum = i+1+add;
        }
        ans=max(ans,sum);
    }
    auto it =upper_bound(been(sumb),k);

    ll sum = it-sumb.begin();
    cout<<max(ans,sum)<<endl;
}

Measured memory_bytes: 9524
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

/*
getsの安全なやつ、例
char s[5];
scanf("%4s%*[^\n]",s);
getchar();
*/

int max(int a,int b){
  if(a > b){
    return a;
  }else{
    return b;
  }
}

int dp[3010][3010];

int main(){
  char s[3010],t[3010];
  scanf("%3009s%*[^\n]",s);
  getchar();
  scanf("%3009s%*[^\n]",t);
  getchar();

  int s_size = 0;
  int t_size = 0;
  for(int i = 0;i < 3010;i++){
    if(s[i] == '\0')break;
    s_size++;
  }
  for(int i = 0;i < 3010;i++){
    if(t[i] == '\0')break;
    t_size++;
  }

  for(int i = 0;i < s_size;i++){
    for(int j = 0;j < s_size;j++){
      dp[i][j] = 0;
    }
  }

  int mark[s_size+1][t_size+1];
  for(int i = 0;i <= s_size;i++){
    for(int j = 0;j <= t_size;j++){
      mark[i][j] = 0;
    }
  }

  for(int i = 0;i <  s_size;i++){
    for(int j = 0;j < t_size;j++){
      if(s[i] == t[j]){
        dp[i+1][j+1] = dp[i][j]+1;
        mark[i+1][j+1] = 1;
      }else{
        dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
      }
    }
  }
  int mdp = dp[s_size][t_size];
  int keep = mdp;

  char cp[mdp];
  int s_start = s_size;
  int t_start = t_size;
  for(int i = s_start;i > 0;i--){
    for(int j = t_start;j > 0;j--){
      if(mark[i][j] == 1 && dp[i][j] == mdp){
        cp[mdp-1] = s[i-1];
        mdp--;
        t_start = j-1;
        i = i-1;
      }
    }
  }
  for(int i = 0;i < keep;i++){
    printf("%c",cp[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,M;
	cin>>N>>M;
	for(ll i=0;i<max(M,N);i++)
	{
	    cout<<min(N,M);
	}
}

Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int N;
	long long A, answer = 1LL; 
	long long big_num = 1000000000000000000LL; 
	cin >> N;
	
	//cout << "big_num literal: " << big_num << endl; 
	
	for(int i = 0; i < N; i++) { 
		cin >> A; 
		if(A == 0LL) {
			answer = 0LL; 
			break; 
		}
		
		if(answer > -1LL) {
			if( log10((double)A) + log10((double)answer) > 18.0 ) {
				answer = -1LL;
			} else {
				if(answer * A > big_num) {
					answer = -1LL; 
				}
				if(answer > -1LL)
					answer *= A; 
			}
		}
	}
	
	if(answer > big_num) {
		answer = -1; 
	}
	cout << answer << endl;
	
	return 0; 
} 


Measured memory_bytes: 3908
double x,y,r,X,Y,R;main(){for(;~scanf("%*d%lf%lf%lf%lf%lf%lf"+!!R*3,&x,&y,&r,&X,&Y,&R);printf("%d\n",x+R<r?2:x+r<R?-2:r+R>=x))x=hypot(x-X,y-Y);}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.nextLine();
        List<Integer> s = Stream.of(sc.nextLine().split(" "))
                .map(Integer::parseInt)
                .collect(Collectors.toList());
        sc.nextLine();
        int c = (int)Stream.of(sc.nextLine().split(" "))
                .map(Integer::parseInt)
                .filter(q -> linearSearch(s, q))
                .count();
        System.out.println(c);
    }

    public static boolean linearSearch(List<Integer> ss, Integer target) {
        for (Integer s: ss) {
            if (s.equals(target)) {
                return true;
            }
        }
        return false;
    }
}




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

int main(){
  
  int a,b;
  cin >> a >> b;
  
  if( 10 <= a ){
    
    cout << b << endl;
    
  }
  
  
  else{
    
    cout << b + 100*(10-a)<< endl;
    
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,M;
    string S,T;
    cin >> N >> M >> S >> T;
    long long i,j;
    long long k=1;
    for(i=0;i<N && k==1;i++){
        j=i*M/N;
        if(i*M==j*N && S[i]!=T[j]){
            k=0;
        }
    }
    
    if(k==0){
        cout << -1 << endl;
    }else{
        long long n,m,gcd;
        n=N;
        m=M;
        while(n*m!=0){
            if(n>m){
                n=n%m;
            }else{
                m=m%n;
            }
        }
        if(n>m){
            gcd=n;
        }else{
            gcd=m;
        }
        cout << N*M/gcd << endl;
    }
    
}


Measured memory_bytes: 512
h1, m1, h2, m2, k = map(int, input().split())
if h1 == h2:
    print(m2 - m1 - k)
else:
    x = 0
    x = 60 - m1
    x += m2
    x += 60 * (h2 - h1 - 1)
    print(x - k)


Measured memory_bytes: 61544
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<lint> a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    lint cnt = 0;
    repr(i, n){
        if((a[i] + cnt) % b[i] != 0){
            cnt += b[i] - ((a[i] + cnt) % b[i]);
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (a < b) {
    long long int tmp1 = t * v + a;
    long long int tmp2 = t * w + b;
    if (tmp1 >= tmp2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    long long int tmp1 = -1 * (t * v) + a;
    long long int tmp2 = -1 * (t * w) + b;
    if (tmp1 <= tmp2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3636