akhauriyash/Code-Regression huggingface dataset:
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(n,x);
  Vi X(n);
  VIN(X)
  REP(i,n){
    if(X[i] > abs(x-X[i])) c += abs(x-X[i])*2;
    else c += X[i]*2;
  }
  OUT(c);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    string S;
    int n1,n2;
 
    cin >> S;
 
    n1 = (S[0] - '0') * 10 + (S[1] - '0');
    n2 = (S[2] - '0') * 10 + (S[3] - '0');
 
    if((n1 == 0 && n2 == 0) || (n1 > 12 && n2 > 12))cout << "NA" << endl;
    else if((n1 == 0 && n2 > 12) || (n2 == 0 && n1 > 12))cout << "NA" << endl;
    else if(n1 > 12 || n1 == 0)cout << "YYMM" << endl;
    else if(n2 > 12 || n2 == 0)cout << "MMYY" << endl;
    else cout << "AMBIGUOUS" << endl;
 
    return 0;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, T;
    cin >> N >> T;
    ll answer = 1e6;
    for (int i = 0; i < N; i++)
    {
        ll c, t;
        cin >> c >> t;
        if (t <= T)
        {
            answer = min(answer, c);
        }
    }
    if (answer == 1e6)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        String ans = "Yes";
        int dir = Math.abs(c-a);
        int ind = Math.max(Math.abs(b-a),Math.abs(c-b));
        if(dir>d&&ind>d) ans = "No";


        System.out.println(ans);
    }
}

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

int main()
{
  int n, m;
  int a[3] = {};
  char c;

  for ( int i = 0; i < 3; i++) {
    cin >> c;

    a[c - 'a']++;
  }

  if ( a[0] == 1 && a[1] == 1 && a[2] == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return (0);
}


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

int main() {
   int A,B,K;
   cin >> A >> B >> K;
   int count=0;
   int total=0;
   for (int i=1; i<=A; i++) {
       if (A%i==0 && B%i==0) total++;
   }
   for (int i=1; ; i++) {
       if (A%i==0 && B%i==0) count++;
       if (count==total-K+1) {
           cout << i << endl;break;
       }
   }
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
q = int(input())

c = Counter(a)

allsum = 0
for k,v in c.items():
    allsum += k*v
    
ans = []

for i in range(q):
    bi,ci = list(map(int,input().split()))
    allsum += ci*c[bi] - bi*c[bi]
    c[ci] = c[ci] + c[bi]
    c[bi] = 0
    ans.append(allsum)
    
for i in ans:
    print(i)

Measured memory_bytes: 27260
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.nextLine();
        String t = sc.nextLine();
        int ans = t.length();

        String[] as = s.split("");
        String[] at = t.split("");

        for (int i = 0; i < as.length - at.length + 1; i++) {
            int count = 0;
            for (int j = 0; j < at.length; j++) {
                if (as[i + j].equals(at[j])) {
                    count++;
                }
            }
            int tmp = at.length - count;
            ans = Math.min(ans, tmp);
        }
        System.out.println(ans);
    }
}


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

int main () {
  string S;
  cin >> S;
  int count = 0;
  for (int i = 0; i < 3; i++){
    if (S.at(i) == 'R') count++;
  }
  if ((S.at(1) != 'R') && (count == 2)) cout << 1 << endl;
  else  cout << count << endl;
}

Measured memory_bytes: 3544
import java.util.*;

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

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define mm (1e16)

ll Mod=(1e9+7);

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

    ll n,k; cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    vector<int>a(2020,0),b(2020,-1);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(v[j]<v[i]){
                a[i]++;
            }
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(b[v[i]]==-1)
            b[v[i]]=i;
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans=(ans+(k*a[i])%Mod + (b[v[i]]*((k*(k-1)/2)%Mod))%Mod)%Mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

ops = [
        ['+', '+', '+'],
        ['+', '+', '-'],
        ['+', '-', '+'],
        ['+', '-', '-'],
        ['-', '+', '+'],
        ['-', '+', '-'],
        ['-', '-', '+'],
        ['-', '-', '-'],
        ]


def solve(ABCD: str):
    a = int(ABCD[0])
    b = int(ABCD[1])
    c = int(ABCD[2])
    d = int(ABCD[3])
    for i in range(8):
        t = a
        if ops[i][0] == "+":
            t += b
        else:
            t -=b
        if ops[i][1] == "+":
            t += c
        else:
            t -=c
        if ops[i][2] == "+":
            t += d
        else:
            t -=d
        if t == 7:
            print(f"{a}{ops[i][0]}{b}{ops[i][1]}{c}{ops[i][2]}{d}=7")
            break

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = next(tokens)  # type: str
    solve(ABCD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62128
#include<bits/stdc++.h>
using namespace std;
long long cnt (long long x){
    int c = 0;
    while(x!=0){
        x /= 10;
        c++;
    }

    return c;

}
int main(){
    long long n ;
    cin >> n;
    long long ans = 1e18;
    for(long long i = 1 ; i * i <= n ; i++){
        if (n % i)
        continue;
        ans = min (ans, max(cnt(i),cnt(n / i)));
    }
cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
const int MAXN = (int)3e3+7;
const ll INF = (ll)-1e18+7;

int N,M,P;
vector<pi> G[MAXN];
int vis[MAXN];
ll dis[MAXN];
queue<int> qu;

ll bfs() {
    while (!qu.empty()) qu.pop();
    memset(dis,0x3f,sizeof(dis));
    dis[1] = 0;vis[1] = 1;qu.push(1);
    while (!qu.empty()) {
        int k = qu.front();qu.pop();
        if (vis[k] >= 2500) dis[k] = INF;
        if (vis[k] >= 2501) continue;

        rep(i,0,G[k].size()-1) {
            int v = G[k][i].first;
            int cost = G[k][i].second;
            if (vis[v] >= 2500) continue;
            if (dis[v] > dis[k]+cost) {
                dis[v] = dis[k]+cost;
                if (dis[k] == INF) dis[v] = INF;
                qu.push(v);
                vis[v] ++;
            }
        }
    }
    return dis[N];
}

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

    cin >> N >> M >> P;
    rep(i,1,M) {
        int u,v,c;
        cin >> u >> v >> c;
        G[u].pb(make_pair(v,P-c));
    }
    ll res = bfs();
    if (res <= -1e18) cout << -1 << endl;
    else             cout << -min(res,0LL) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl
template <typename T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    for(int i = 0; i < vec.size(); i++) {
        os << vec.at(i) << (i + 1 == vec.size() ? "" : " ");
    }
    return os;
}

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> A(N);
    cin >> A;

    sort(all(A));

    int cnt = 0;
    int i = 0;
    rep(i, N) {
        if((X < A.at(i) && i != N - 1) || (X != A.at(i) && i == N - 1)) {
            break;
        }
        cnt++;
        X -= A.at(i);
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws java.io.IOException {

		Scanner scan = new Scanner(System.in);
		List<Integer> wTime = new ArrayList<Integer>();

		while (scan.hasNext()) {
			int t = Math
					.abs((scan.nextInt() * 3600 + scan.nextInt() * 60 + scan
							.nextInt())
							- (scan.nextInt() * 3600 + scan.nextInt() * 60 + scan
									.nextInt()));
			wTime.add(t);
		}
		for (int i = 0; i < wTime.size(); i++) {
			int tmp = wTime.get(i);
			int hh = tmp / 3600;
			tmp %= 3600;
			int mm = tmp / 60;
			int ss = tmp % 60;
			System.out.println(hh + " " + mm + " " + ss);
		}

	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)

int sumofdigit(int n){
    int ans = 0,a;
    while(n!=0){
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

int main(){
    int n,s;
    string res;
    cin >> n;
    s = sumofdigit(n);
    if(n%s == 0) res = "Yes";
    else res = "No";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
cards = list(map(int,input().split()))

A_score = cards.pop(0)
B_score = cards.pop(len(cards)-1)
B_score += sum(cards)
min_diff_score = abs(A_score - B_score)

for card in cards:
    A_score += card
    B_score -= card
    now_diff_score = abs(A_score - B_score)
    if now_diff_score < min_diff_score:
        min_diff_score = now_diff_score

print(min_diff_score)




Measured memory_bytes: 23800
object Main {
  def main(args: Array[String]): Unit = {
    val hotel_num         = io.StdIn.readInt
    val hotel_height      = io.StdIn.readLine.split(" ").map{_.toInt}
    var total_can_see_sea = 0
    var max_height        = 0

    (0 until hotel_height.length).foreach { i =>
      if(hotel_height(i) >= max_height) {
        total_can_see_sea += 1
        max_height = hotel_height(i)
      }
    }
    println(total_can_see_sea)

  }
}

Measured memory_bytes: 25400
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();

        long[] a = new long[N];
        for(int i = 0; i<N; i++) a[i] = sc.nextLong();

        long[][] keta = new long[46][2];

        for(int i = 0; i<46; i++) keta[i][0] = keta[i][1] = -1;
        keta[45][0] = 0;

        for(int k = 44; k>=0; k--) {
            long cnt = 0;
            for (int i = 0; i < N; i++) {
                cnt += (a[i] >> k)%2;
            }

            long mask = (K>>k)%2;
            if(keta[k+1][1] >= 0) keta[k][1] = Math.max(keta[k][1], keta[k+1][1] + (Math.max(N-cnt, cnt)<<k));
            if(keta[k+1][0] >= 0) {
                if(mask == 1) {
                    keta[k][1] =  Math.max(keta[k][1], keta[k+1][0] + (cnt<<k));
                    keta[k][0] =  Math.max(keta[k][0], keta[k+1][0] + ((N-cnt)<<k));
                }else{
                    keta[k][0] =  Math.max(keta[k][0], keta[k+1][0] + (cnt<<k));
                    //System.out.println(k + " " + cnt + " " + keta[k][0]);
                }
            }
        }
        System.out.println(Math.max(keta[0][0], keta[0][1]));
    }
}

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

using namespace std;

    void LCS(string s, string t) {

            int n = s.size(), m = t.size();

        vector<vector<int>> DP(n + 1, vector<int>(m + 1, 0));
        for (int i{1}; i <=n; i++) { // For every letter in text 1, compare it to a letter in text 2
            for (int j{1}; j <= m; j++) {
                if (s[i - 1] == t[j - 1]) {
                    DP[i][j] = DP[i - 1][j - 1] + 1;
                } else { // Not the same
                    DP[i][j] = max(DP[i - 1][j], DP[i][j - 1]);
                }
            }
        }
        
        //    for(i=0;i<=n;i++)
//    {
//        for(j=0;j<=m;j++)
//        {
//            cout<<DP[i][j]<<"  ";
//        }
//        cout<<"\n";
//    }


    list<char> res;
    int i=n,j=m;
    while(i-1>=0 && j-1>=0)
    {
        if(s[i-1]==t[j-1])
        {
            res.push_front(s[i-1]);
            i=i-1;
            j=j-1;
        }
        else
        {
            if(DP[i-1][j]>DP[i][j-1])
            {
                i--;
            }
            else
                j--;
        }
 
    }
    for(char x:res)
        cout<<x;
    }

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

        LCS(s,t);

    }


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> vc;
    for(int i = 0;i < n;i++) {
        double x;
        cin >> x;
        vc.push_back(x);
    }
    sort(vc.begin(), vc.end());
    double ave = vc[0];
    for(int i = 1;i < vc.size();i++) {
        ave = (ave + vc[i])/2;
    }

    cout << ave << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
ll vec[20];

signed main(){
	int r,d,x; cin>>r>>d>>x;
	vec[0]=x;
	rep(i,1,11){
		vec[i]=r*vec[i-1]-d;
	}
	rep(i,1,11){
		cout<<vec[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
bool prime(int x){
  if(x<=1) return false;
  for(int i=2;i*i<=x;i++){
    if(x%i==0) return false;
  }
  return true;
}
int main()	{
  int x;
  cin>>x;
  for(int i=x;;i++){
  bool primeex=prime(i);
  if(primeex==true){
    cout<<i<<endl;
    return 0;}
  }
}

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

int main() {

  int i , j , r , c , total , res , t;

  int T[101][101] = {};

  t = total = res = 0;

  cin >> r >> c;

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

    for(j = 0; j < c; j++) {

      cin >> T[i][j];

    }

  }

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

    for(j = 0; j < c; j++) {

      total += T[i][j];

      T[r][j] += T[i][j];

      cout << T[i][j] << " ";

    }

    cout << total << "\n";

    total = 0;

  }

  for(i = r; i < r + 1; i++) {

    for(j = 0; j < c; j++) {

      cout << T[i][j] << " ";

      total += T[i][j];

    }

    cout << total << "\n";

  }

  return 0;

}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n;
   cin>>n;
   string c={0,0,0,0};
   rep(i,n){
      char s;
      cin>>s;
      if(s=='P') c[0]++;
      if(s=='W') c[1]++;
      if(s=='G') c[2]++;
      if(s=='Y') c[3]++;      
   }
   if(c[3]!=0) cout<<"Four";
   else cout<<"Three";

   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0L;i--)
#define prep(i,n) for(int64_t i=1;i <= (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int d;
  cin >> d;
  cout << "Christmas ";
  rep(i,25-d){
    cout << "Eve ";
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
int main()
{
	int N, M ,Q;
	cin >> N >> M>> Q;
	vector< vector<int> > lines = vector< vector<int> >(N+1, vector<int>(N+1,0));
	vector< pair<int,int> > question(Q);
	int l,r;
	for(int i=0;i<M;i++){
		cin >> l >> r;
		lines[l][r] += 1;
	}

	// for(int i=0;i<lines.size();i++){
	// 	cout << lines[i].size() << endl;
	// }

	for(int i=0;i<Q;i++){
		cin >> l >> r;
		question[i] = make_pair(l,r);
	}

	for(int i=1;i<=N ;i++){
		for(int j=1;j<=N;j++){
			lines[i][j] += lines[i-1][j];
			lines[i][j] += lines[i][j-1];
			lines[i][j] -= lines[i-1][j-1];
			// cout << lines[i][j] << ",";
		}
		// cout << endl;
	}

	// for(int i=0;i<M;i++){
	// 	cout << lines[i].first << ":" << lines[i].second;
	// }
	int count = 0;
	int a,b;
	for(int i=0;i<Q;i++){
		a = question[i].first;
		b = question[i].second;
		cout << lines[b][b] - lines[a-1][b] -lines[b][a-1] + lines[a-1][a-1]  << endl;
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int gcd(int a,int b){
    int r;
    if(a<b) swap(a,b);
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int atcoder(){
    //入力
    string s;
    cin >> s;
    int ans=0;

    //処理
    for(int i=2; i<s.length(); i+=2){
        string tmp = s.substr(0,s.length()-i);
        if(tmp.substr(0,tmp.length()/2)==tmp.substr(tmp.length()/2,tmp.length()/2)){
            ans=(int)tmp.length();
            break;
        }
    }
    
    //出力
    cout << ans << ENT;
    return 0;
}

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


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

using namespace std; 

int main(){ 
  int n;
  cin>>n;
  int x;
  cin>>x;
  int c[100]={x};
  for (int i=1;i<n;i++){
    cin>>c[i];
  }
  int y=*min_element(c,c+n );
  int z=*max_element(c,c+n );
  cout<<z-y;
}
  

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N; cin >> N;
    vl A(3*N); REP(i, 3*N) cin >> A[i];
    multiset<ll> r, otr;
    priority_queue<ll, vector<ll>, greater<ll>> l;
    
    ll lsum = 0, rsum = 0;
    REP(i, N) {l.push(A[i]); lsum+= A[i];};
    FOR(i, N, 3*N) otr.insert(A[i]);
    while(r.size() < N){
        ll t = *otr.begin(); otr.erase(otr.begin()); r.insert(t); rsum += t;
    }
    
    ll ans = lsum - rsum;
    FOR(i, N, 2*N){
        ll cur = A[i];
        l.push(cur); lsum += cur; lsum -= l.top(); l.pop();
        if(otr.count(cur)){
            otr.erase(otr.find(cur));
        }
        else{
            r.erase(r.find(cur)); rsum -= cur;
            ll otrb = *otr.begin(); r.insert(otrb); rsum += otrb;
            otr.erase(otr.begin());
        }
        ans = max(ans, lsum-rsum);
    }
    cout << ans << endstr;
    return 0;
}


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

int main(){
  int R;
  cin >> R;
  if(R<1200){
    cout << "ABC" << endl;
  }else if(R<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int maxIndex = 0;
            List<Integer> list = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                list.add(in.nextInt());
            }

            Queue<Integer> queue = new ArrayDeque<>();
            int maxSum = 0;
            int sum = 0;
            for (int i = 0; i < N; i++) {
                int p = list.get(i);
                queue.add(p);
                sum += p;
                if (!queue.isEmpty() && i >= K) {
                    sum -= queue.poll();
                }
                if (maxSum < sum) {
                    maxSum = sum;
                    maxIndex = i;
                }
            }

            List<Integer> expectedList = new ArrayList<>();
            int maxItem = 0;
            for (int i = 0; i < K; i++) {
                int index = maxIndex - i;
                int j = list.get(index);
                expectedList.add(j);
                if (maxItem < j) {
                    maxItem = j;
                }
            }

            double[] expectedArray = new double[maxItem];
            double[] sumArray = new double[maxItem];
            for (int i = 0; i < maxItem; i++) {
                if (i == 0) {
                    expectedArray[i] = 1;
                    sumArray[i] = 1;
                }
                else {
                    expectedArray[i] = (sumArray[i - 1] + i + 1) / (i + 1);
                    sumArray[i] = sumArray[i - 1] + i + 1;
                }
            }

            double expectedValue = 0;
            for (int i : expectedList) {
                expectedValue += expectedArray[i - 1];
            }

            out.println(String.format("%.9f", expectedValue));
        }
    }
}

Measured memory_bytes: 87640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int n, a;
    cin >> n >> a;
    if(n%500 <= a){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

#define INF INT_MAX
#define F first
#define S second

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

int main(){
  int n;
  cin>>n;
  cout<<(1000-(n%1000))%1000<<endl;
  return 0;
}


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

using namespace std;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	
	sort(a,a+3);
	if(a[0]+a[1]==a[2]){
		cout << "Yes" <<endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 45

int post[MAX], pre[MAX], in[MAX], id, n;

void recon(int pre[], int in[], int N){
  int i, pos;

  for(i = 0 ; i < N ; i++){
    if(in[i] == pre[0]){
      pos = i;
      break;
    }
  }

  if(pos != 0)
    recon(pre+1, in, pos);
  
  if(pos != N-1)
    recon(pre+pos+1, in+pos+1, N-pos-1);
  
  post[id++] = pre[0]; 
}


int main(){
  int i;

  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    scanf("%d", &pre[i]);
  
  for(i = 0 ; i < n ; i++)
    scanf("%d", &in[i]); 
  
  recon(pre, in, n);

  for(i = 0 ; i < n-1 ; i++)
    printf("%d ",post[i]);
  printf("%d\n",post[i]);
  
  return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

using namespace std;

typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin>>s;
  int n=s.size();
  
  for (int i = n-1; i > 0; --i) {
    if(i%2!=0) continue;
    if(s.substr(0, i/2) == s.substr(i/2, i/2)) {
      cout<<i;
      return 0;
    }
  }
  
  return 0;
}

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

int main(){
    ll h;
    cin >> h;

    int k;
    k=-1;
    while(h!=0){
        h/=2;
        ++k;
    }

    ll ans;
    ans=0;
    rep(i,k){
        ans+=pow(2,i);
    }

    ans+=pow(2,k);

    cout << ans << endl;
    

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d.at(i);
    }
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += d.at(i) * d.at(j);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3592
h, w = map(int, input().split())
S = []
flag = True
for i in range(h):
    r = list(input())
    S.append(r)
for i in range(0,h-1):
    for j in range(0,w-1):
        if S[i][j]=='#' and S[i-1][j]=='.' and S[i][j-1]=='.' and S[i+1][j]=='.' and S[i][j+1]=='.':
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import sys

s = input()

if s.count(s[0]) == len(s):
    print(0)
    sys.exit()

dic = {'a': []}
for i in range(len(s)):
    if s[i] not in dic:
        dic[s[i]] = []
    dic[s[i]].append(i)

m = 100
for v in dic.values():
    v.append(len(s))
    dist = v[0]
    for i in range(len(v))[1:]:
        dist = max(dist, v[i] - v[i-1] - 1)
    m = min(m, dist)

print(m)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

ll gcd (ll x, ll y) { return y ? gcd(y,x%y) : x; }
ll lcm (ll x, ll y) { return x*y / gcd(x,y); }

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> T(n);
  ll ans = 1;
  rep(i,n) {
    cin >> T[i];
    ans /= gcd(ans, T[i]);
    ans *= T[i];
  }
  cout << ans << endl;
}

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

int s, idx=1, prevA;
set<int> a;

int main(){
    cin >> s;
    prevA = s;
    a.insert(s);
    while(true){
        idx++;
        prevA%2==0? prevA/=2: prevA=prevA*3+1;
        a.insert(prevA);
        if(a.size() != idx){
            break;
        }
    }
    cout << idx << endl;
}


Measured memory_bytes: 888
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGreedyTakahashi solver = new BGreedyTakahashi();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGreedyTakahashi {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            long x = sc.nextLong(), y = sc.nextLong(), z = sc.nextLong();
            long c = x;
            x = Math.max(0, x - z);
            z -= c;
            if (z > 0)
                y = Math.max(0, y - z);
            pw.println(x + " " + y);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 22996
import java.util.*;
import java.io.*;

public class Main {
   public static void main(String[] args) {
	   
	   	FastScanner in = new FastScanner();
	   	int k = in.nextInt();
	   	for(int i = 0; i < k; i++) {
	   		System.out.print("ACL");
	   	}
		
	}
	
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 32548
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int m,n,a[10005],b[10005],f[10005];
int main(){
	in(m);in(n);
    for(int i=1;i<=n;i++){
        in(a[i]);
        in(b[i]);
    }
    memset(f,0x3f,sizeof(f));
    f[0]=0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=m;j++){
            int x=max(0,j-a[i]);
            f[j]=min(f[j],f[x]+b[i]);
        }
    }
    printf("%d\n",f[m]);
	return 0;
}


Measured memory_bytes: 256
from math import sqrt

def eratosthenes(n):
    if n <= 1:
        return []
    prime = [2]
    lim = int(sqrt(n))
    num = list(range(3, n, 2))

    while lim > num[0]:
        prime.append(num[0])
        num = [i for i in num if i % num[0] != 0]
    
    return prime + num

X = int(input())

for p in eratosthenes(10**5):
    if p >= X:
        print(p)
        break
    elif X > 99991:
        print(100003)
        break

Measured memory_bytes: 45164
#include<iostream>
#include<string.h>

using namespace std;

int main(){
  int n;
  int num[110] = {0};
  char s[110][15];
  int p[110] = {0};
  
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> s[i] >> p[i];
    num[i] = i+1;
  }

  for(int i=0; i<n; i++){
    for(int j=0; j<n-1; j++){
      if(strcmp(s[j], s[j+1]) > 0){
	char stemp[15];
	strcpy(stemp, s[j]);
	strcpy(s[j], s[j+1]);
	strcpy(s[j+1], stemp);
	int ptemp = p[j];
	p[j] = p[j+1];
	p[j+1] = ptemp;
	int ntemp = num[j];
	num[j] = num[j+1];
	num[j+1] = ntemp;
      }
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n-1; j++){
      if(strcmp(s[j], s[j+1]) == 0){
	if(p[j] < p[j+1]){
	  char stemp[15];
	  strcpy(stemp, s[j]);
	  strcpy(s[j], s[j+1]);
	  strcpy(s[j+1], stemp);
	  int ptemp = p[j];
	  p[j] = p[j+1];
	  p[j+1] = ptemp;
	  int ntemp = num[j];
	  num[j] = num[j+1];
	  num[j+1] = ntemp;
	}
      }
    }
  }

  for(int i=0; i<n; i++){
    cout << num[i] << endl;
  }
  
  return(0);
}


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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
c = collections.Counter(prime_factorize(n))

ret = 0
for k, num in c.items():
    cnt = 1
    while True:
        num -= cnt
        if num >= 0:
            ret += 1
        else:
            break
        cnt += 1

print(ret)

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

int a[4], b[4];
bool visa[4], visb[4];

int main()
{
    //freopen("data.in", "r", stdin);
    int i, j, cnt1, cnt2;
    while(scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]) != EOF)
    {
        cnt1 = cnt2 = 0;
        memset(visa, false, sizeof visa);
        memset(visb, false, sizeof visb);
        for(i = 0; i < 4; i ++) 
            scanf("%d", &b[i]);
        for(i = 0; i < 4; i ++)
            if(!visa[i] && !visb[i] && a[i] == b[i])
                visa[i] = visb[i] = true, cnt1 ++;
        for(i = 0; i < 4; i ++)
        {
            if(!visa[i])
            {
                for(j = 0; j < 4; j ++)
                {
                    if(!visb[j] && a[i] == b[j])
                    {
                        cnt2 ++;
                        visa[i] = true;
                        visb[j] = true;
                        break;
                    }
                }
            }
        }
        printf("%d %d\n", cnt1, cnt2);
    }
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
x_i = [float(i) for i in input().split()]
y_i = [float(i) for i in input().split()]
abs_sub = []
D1,D2,D3=0.0,0.0,0.0
for i in range(len(x_i)):
#p==1
    D1 += ((x_i[i]-y_i[i])**2)**(1/2)
#p==2
    D2 +=(x_i[i]-y_i[i])**2
#p==3
    D3 +=(((x_i[i]-y_i[i])**2)**(1/2))**3
#p==inf
    abs_sub.append(((x_i[i]-y_i[i])**2)**(1/2))
D2 = D2**(1/2)
D3 = D3**(1/3)
D_inf=abs_sub[0]
for i in range(len(abs_sub)):
    if D_inf < abs_sub[i]:
        D_inf = abs_sub[i]
print("{:.6f}\n{:.6f}\n{:.6f}\n{:.6f}".format(D1,D2,D3,D_inf))


Measured memory_bytes: 5688
#include <stdio.h>
#include <string.h>
int max(int a,int b){if(a>b)return a;return b;}
int LCS(char a[],char b[],int m,int n)
{
    int L[m+1][n+1];
    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0 || j==0)
                L[i][j] = 0;
            else if(a[i-1] == b[j-1])
                L[i][j] = L[i-1][j-1]+1;
            else
                L[i][j] = max(L[i-1][j],L[i][j-1]);
        }
    }
    //printf("%d\n",L[m][n]);
    // Print All LCS
    int index = L[m][n];
    int t = index;
    char lcs[index+1];
    lcs[index] = '\0';
    int i = m ,j = n;
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            lcs[index-1] = a[i-1];
            i--;j--;index--;
        }
        else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
    }
    printf("%s",lcs);
    // End of function
}
int main()
{
	char str1[3010],str2[3010];
	scanf("%s %s",str1,str2);
	int m = strlen(str1);
	int n = strlen(str2);
	//printf("%d %d",len1,len2);
	LCS(str1,str2,m,n);
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll X, A;
char S[4];
ll mk[5];
ll i,j;
int main(){
    scanf("%s", &S);
    fornum(i,1,4){
        if(S[0]!=S[i]){
            break;
        }
    }
    if(i==4){
        printf("No");
        return 0;
    }
    fornum(i,0,4){
        if(mk[i]==1)
            continue;
        mk[i] = 1;
        fornum(j,i+1,4){
            if(S[i]==S[j]){
                mk[j] = 1;
                break;
            }
        }
        if(j==4){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
typedef long long LL;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; LL m; cin >> n >> m;
    vector<LL> data(n);
    LL sum = 0;
    for (auto &v : data)
        cin >> v, sum += v;
    int cnt = 0;
    for (auto &v : data) {
        if (v * 4 * m >= sum)
            cnt++;
    }
    if (cnt >= m)
        cout << "Yes\n";
    else
        cout << "No\n";
    

}


Measured memory_bytes: 256
#include <stdio.h>

#define N 200000

int main () {
    int i = 0,
        num = 0,
        inp = 0,
        maxv = 0, 
        minv = 0,
        array[N];

    scanf( "%d", &num );
    for ( i=0; i<num; i++ ) {
        scanf( "%d", &array[i] );
    }

    minv = array[0];
    maxv = array[1]-array[0];
    for ( i=1; i <= num-1; i++ ) {
        if ( maxv < array[i]-minv ) maxv = array[i]-minv;
        if ( minv > array[i] ) minv = array[i];
    }
    printf( "%d\n", maxv );

    return 0;
}



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

using namespace std;

static const double ESP = 1e-10;
static const double PI=3.14159265358979323846;


class Point {
public:
    double x, y;

    explicit Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
    Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
    Point operator * (double a) { return Point(a * x, a * y); }
    Point operator / (double a) { return Point(a / x, a / y); }

    double norm() { return x * x + y * y; }
    double abs() { return sqrt(norm()); }

    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x - p.x) < ESP && fabs(y - p.y) < ESP;
    }
};

typedef Point Vector;

int main() {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double theta1 = 2. * PI * ((double)h + (double)m / 60.) / 12.;
    double theta2 = 2. * PI * (double)m / 60.;

    Vector v1 = Vector(a * cos(theta1), a * sin(theta1));
    Vector v2 = Vector(b * cos(theta2), b * sin(theta2));

    cout << std::setprecision(20) << (v2 - v1).abs() << endl;

    return 0;
}


Measured memory_bytes: 4056
N, M, K = map(int, input().split())
A = [0] + [int(i) for i in input().split()]
B = [0] + [int(i) for i in input().split()]

N += 1
M += 1
for i in range(1, N) :
  A[i] += A[i - 1]
for i in range(1, M) :
  B[i] += B[i - 1]

ret = 0
a = N - 1
b = 0
while b < M :
  while a >= 0 and A[a] + B[b] > K :
    a -= 1
  if a >= 0 and A[a] + B[b] <= K :
    ret = max(ret, a + b)
  b += 1
  
print(ret)

Measured memory_bytes: 119828
n,m = map(int,input().split())
L = []
R = []

for i in range(m):
	l,r = map(int,input().split())
	L.append(l)
	R.append(r)

ans = min(R) - max(L) + 1

if ans >0:
	print(ans)
else:
	print(0)

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;



int main()
{
    int A,B;
    cin >>A >>B;
    int r=0;
    for(int i=A;i<=B;i++){
      if(i/10000==i%10 && i/1000%10==i/10%10 ) r++;
    }
    cout <<  r << endl; 
}  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <cmath>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs (int)1000000007;
#define MODn (int)1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, M, ans=1, yobi=1;
  std::cin >> N >> M;

  ranges(i, 1, max((int)sqrt(M)+1, N+1)){
    if(M%i==0){
      if(i>=N){
        ans = M/i;
        break;
      }else{
        if(M/i >= N){
          ans = max(ans, i);
        }
      }
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
def main(argv)
	(n, d) = gets.chomp.split(' ').map(&:to_i)
	
  a = [0] * n
  
  c = 1
  i = 0
  while true do
    m = [i + (d * 2), n - 1].min
    
    (i..m).each do |j|
      a[j] = c
    end
    
    break if m == n - 1 
    
    c += 1
    i = m + 1
  end
  
  puts a[n - 1].to_s
end

if self.to_s === 'main'
	main(ARGV)
end

Measured memory_bytes: 1788