akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#define maxn 100003
using namespace std;
typedef long long LL;

const int K = 26;

int n,m;
int w,ind;
int nxt[maxn][K];
string s,t;

int main() {
	cin >> s >> t;
	n = s.length();
	m = t.length();
	for( int i = 0 ; i < K ; i++ )
		nxt[n][i] = -1;
	for( int i = n-1 ; i >= 0 ; i-- ) {
		for( int k = 0 ; k < K ; k++ )
			nxt[i][k] = nxt[i+1][k];
		int c = s[i] - 'a';
		nxt[i][c] = i;
	}
	for( int i = 0 ; i < m ; i++ ) {
		int c = t[i] - 'a';
		if( nxt[0][c] == -1 ) {
			puts("-1");
			return 0;
		}
		if( nxt[ind][c] == -1 ) {
			w++;
			ind = 0;
		}
		ind = nxt[ind][c] + 1;
		if( ind == n ) {
			w++;
			ind = 0;
		}
	}
	cout << (LL) w*n + ind << endl;
}


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

char s[20][20];
int main() {
	random_device rnd;
	int n; cin >> n;
	rep(i, n)cin >> s[i];
	int e = rnd() % n;
	rep(i, 1000) {
		cout << e + 1 << endl;
		int d; cin >> d; d--;
		if (s[e][d] == 'x')e = rnd() % n;
	}
}

Measured memory_bytes: 3372
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]
## math
DIVC = lambda x, y: -(-x//y)
DIVF = lambda x, y: x//y

def main():
    n = II()
    if n%2==0: print(n)
    else: print(n*2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

const int INF = 1e18;

vector <pi> d[4];

void solve() {
    int n, ans = INF; cin >> n;
    loop(i, n) {
        int x, y; char c;
        cin >> x >> y >> c;
        d[c == 'U' ? 0 : (c == 'R' ? 1 : (c == 'D' ? 2 : 3))].pb({ x, y });
    }
    sort(all(d[1]), [](pi p1, pi p2) { return p1.S < p2.S || (p1.S == p2.S && p1.F < p2.F); });
    sort(all(d[3]), [](pi p1, pi p2) { return p1.S < p2.S || (p1.S == p2.S && p1.F < p2.F); });
    for (pi p : d[1]) {
        auto it = lower_bound(all(d[3]), p, [](pi p1, pi p2) { return p1.S < p2.S || (p1.S == p2.S && p1.F < p2.F); });
        if (it != d[3].end() && it->S == p.S)
            ans = min(ans, (it->F - p.F) * 5);
    }
    sort(all(d[0]));
    sort(all(d[2]));
    for (pi p : d[0]) {
        auto it = lower_bound(all(d[2]), p);
        if (it != d[2].end() && it->F == p.F)
            ans = min(ans, (it->S - p.S) * 5);
    }
    loop(i, 4)
        sort(all(d[i]), [](pi p1, pi p2) { return (p1.F + p1.S < p2.F + p2.S) || (p1.F + p1.S == p2.F + p2.S && p1.F < p2.F); });
    for (int i = 1; i < 3; ++i)
        for (pi p : d[i]) {
            auto it = lower_bound(all(d[i == 1 ? 0 : 3]), p, [](pi p1, pi p2) { return (p1.F + p1.S < p2.F + p2.S) || (p1.F + p1.S == p2.F + p2.S && p1.F < p2.F); });
            if (it != d[i == 1 ? 0 : 3].end() && it->F + it->S == p.S + p.F)
                ans = min(ans, (it->F - p.F) * 10);
        }
    loop(i, 4)
        sort(all(d[i]), [](pi p1, pi p2) { return (p1.F - p1.S < p2.F - p2.S) || (p1.F - p1.S == p2.F - p2.S && p1.F < p2.F); });
    loop(i, 2)
        for (pi p : d[i]) {
            auto it = lower_bound(all(d[i ? 2 : 3]), p, [](pi p1, pi p2) { return (p1.F - p1.S < p2.F - p2.S) || (p1.F - p1.S == p2.F - p2.S && p1.F < p2.F); });
            if (it != d[i ? 2 : 3].end() && it->F - it->S == p.F - p.S)
                ans = min(ans, (it->F - p.F) * 10);
        }
    if (ans == INF)
        cout << "SAFE";
    else
        cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 8316
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N;
    cin >> N;
    string ans;
    do{
        N--;
        lint rem=N%26;
        ans+='a'+rem;
        N/=26;
    }while(N);
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3652
import itertools
n,m = map(int, input().split())
g = []
for _ in range(m):
  s = list(map(int, input().split()))
  g.append(s[1:])
p = list(map(int, input().split()))
num = 0
for i in list(itertools.product([0,1], repeat=n)):
  a = 0
  for j,k in enumerate(g):
    cnt = 0
    for l in k:
      cnt += i[l-1]
    if cnt%2==p[j]:
      a += 1
  if a == m:
    num+=1
print(num)

Measured memory_bytes: 9124
//#define _USE_MATH_DEFINES
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }
inline int safe_mul(const int x, const int y) __attribute__ ((warn_unused_result));

int64_t X;

struct TItem {
    int64_t b;
    int64_t l;
    int64_t r;
    int64_t sum;
    TItem(int _b, int _l, int _r) : b(_b), l(_l), r(_r), sum(r * (X - b) + b * l)
    {}
};

inline int64_t getsum(const vector<int64_t>& sum, const int idx, const int my) {
    auto result = sum[idx];
    if (my < idx) {
        result = sum[idx + 1];
        result -= sum[my + 1] - sum[my];
    }
    return result;
}

int main()
{
//    freopen("in.txt","r", stdin);
//    freopen("out.txt", "w", stdout);
//    cin.tie(0);
//    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n >> X;

    vector<TItem> a;
    int64_t need = 0;
    for (int i = 0; i < n; ++i) {
        int64_t b,l,u;
        cin >> b >> l >> u;
        a.emplace_back(b, l, u);
        need += b * l;
    }

    sort(begin(a), end(a), [](const TItem& lhs, const TItem& rhs) {return lhs.sum > rhs.sum;});

    vector<int64_t> sums(n + 1, 0);
    for (int i = 0; i < n; ++i) {
        sums[i + 1] = sums[i] + a[i].sum;
    }

    int64_t ans = X * n;

    for (int i = 0; i < n; ++i) {
        int64_t cursum = a[i].sum;
        int64_t r = n;
        int64_t l = -1;
        while (r - l > 1) {
            int mid = (l + r) >> 1;
            if (getsum(sums, mid, i) + cursum >= need)
                r = mid;
            else
                l = mid;
        }

        if (r < n) {
            int64_t curneed = need - getsum(sums, r, i);
            int64_t curadd = 0;
            if (curneed > 0) {
                if (curneed > a[i].l * a[i].b) {
                    curneed -= a[i].l * a[i].b;
                    curadd = a[i].b;
                    curadd += (curneed + a[i].r - 1) / a[i].r;
                } else {
                    curadd = (curneed + a[i].l - 1) / a[i].l;
                }
            }
            ans = min(ans, r * X + curadd);
        }
    }
    cout << ans << endl;
}


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

#define MAX_N 100003

using namespace std;

int N;
int V[MAX_N];
int dp[MAX_N];

int foo(int i){
    if(i == N-1){
        return 0;
    }
    /*Eins*/
    if(dp[i] != -1){
        return dp[i];
    }
    int a = foo(i+1)+(abs(V[i+1]-V[i]));
    /*Zwei*/
    if(i < N-2){
        int b = foo(i +2)+(abs(V[i+2]- V[i]));
        a = min(a,b);
    }
    dp[i] = a;
    return dp[i];
}

int main() {
    scanf("%d",&N);
    memset(&dp,-1,sizeof(dp));
    for(int i = 0; i < N; i++){
        scanf("%d",V+i);
    }
    printf("%d",foo(0));
}

Measured memory_bytes: 4096
N, X, Y = map(int, input().split())

def distance(i, j):
    d1 = abs(j-i)
    d2 = abs(i-X)+abs(j-Y)+1
    d3 = abs(i-Y)+abs(j-X)+1
    return min(d1, d2, d3)

ret = [0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        ret[distance(i,j)-1] += 1

for val in ret:
    print(val)

Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

bool isCorrectAns(const vector<vector<int>>& c, const vector<int>& a) {
  vector<int> b(3);
  for (int i = 0; i < 3; i++) {
    b[i] = c[i][i] - a[i];
  }

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (c[i][j] != (a[i] + b[j])) return false;
    }
  }

  return true;
}

int main() {

  vector<vector<int>> c(3, vector<int>(3));
  for (int j = 0; j < 3; j++) {
    for (int i = 0; i < 3; i++) {
      int val;
      cin >> val;
      c[i][j] = val;
    }
  }

  vector<int> a(3);
  for (int l = 0; l <= 100; l++) {
    for (int m = 0; m <= 100; m++) {
      for (int n = 0; n <= 100; n++) {
        a[0] = l; a[1] = m; a[2] = n;
        if (isCorrectAns(c, a)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stack>
using namespace std;
string s;
bool solve() {
  stack<char> stk;
  for(int i=0; i!=(int)s.length(); ++i) {
    if(s[i] == '[' || s[i] == '(') stk.push(s[i]);

    else if(s[i] == ']') {
      if(stk.empty()) return 0;
      if(stk.top() != '[') return 0;
      stk.pop();
    }
    else if(s[i] == ')') {
      if(stk.empty()) return 0;
      if(stk.top() != '(') return 0;
      stk.pop();
    }
  }
  return stk.empty();
}

int main() {
  while(getline(cin, s) && s != ".") {
    cout << (solve() ? "yes" : "no") << endl;
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll, ll>
#define forn(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

ll dp[3005][3005];

int main(){
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	ford(i, n - 1, 0){
		ford(j, m - 1, 0){
			if(s[i] == t[j]){
				dp[i][j] = 1 + dp[i + 1][j + 1];
			}
			else{
				dp[i][j] = max(dp[i][j + 1], dp[i + 1][j]);
			}
		}
	}
	int x, y;
	x = y = 0;
	while(1){
		if(x >= n || y >= m) break;
		if(s[x] == t[y]){
			cout << s[x];
			x++; y++;
		}
		else{
			if(dp[x + 1][y] > dp[x][y + 1]){
				x++;
			}
			else{
				y++;
			}
		}
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <cmath>

using namespace std;

int main(){
 int A,B,i,j,h,w=100;
 cin >> A >> B;
 if (A>B) {
   h=((A+24)/25)*2;
 } else {
   h=((B+24)/25)*2;
 }
 int C[100][100];
 for (i=0;i<h;++i) {
   for(j=0;j<w;++j) {
     if (j<50) {
       C[i][j]=1;
     } else {
       C[i][j]=0;
     }
   }
 }
 A--;
 B--;
 i=0;
 j=0;
 while (A>0) {
   C[i][j]=0;
   A--;
   j+=2;
   if (j==50) {
     j=0;
     i+=2;
   }
 }
 i=0;
 j=51;
 while (B>0) {
   C[i][j]=1;
   B--;
   j+=2;
   if (j==101) {
     j=51;
     i+=2;
   }
 }
 cout << h << " " << w << endl;
 for (i=0;i<h;++i) {
   for(j=0;j<w;++j) {
     if (C[i][j]==0) {
       cout << ".";
     } else {
       cout << "#";
     }
   }
   cout << endl;
 }
 return 0;
}


Measured memory_bytes: 256
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,w;
void solve(){
  cin>>n>>w;vvi v(2,vi(n+2,inf));vvi dp((int)1e5+10,vi(n+2,inf));
  rep(i,1,n)
    rep(j,0,1){
      cin>>v[j][i];
    }
  rep(i,0,n+1)dp[0][i]=0;
  // rep(j,1,n)if(v[0][j]<=w)dp[v[1][j]][j]=v[0][j];
  //dp[i][j] is max weight taken by consider all elements from 1 to j
  //with total weight i
  int ma=0;
  rep(j,1,n){
    rep(i,1,1e5)dp[i][j]=dp[i][j-1];
    rep(i,v[1][j],1e5){
    //first case if we choose jth element
    //second case if we don not choose jth element
    dp[i][j]=min(dp[i-v[1][j]][j-1]+v[0][j],dp[i][j-1]);
  }
}
  rep(i,0,1e5)rep(j,0,n)if(dp[i][j]<=w)ma=max(ma,i);
  cout<<ma;
}
int32_t main()
{
  ibs;cti;
  solve()
  /*,cout<<"\n"*/;
  // cout<<"\n";
  int xx=0;
  // int t;cin>>t;while(t--){/*xx++;cout<<"Case "<<xx<<":\n"*/;solve();cout<<"\n";}
  return 0;
}

Measured memory_bytes: 83840
//Bismillah Hir Rehmanir Rahim
//Allah knows best
#include<bits/stdc++.h>
using namespace std;
#define start ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f(i, a, n) for( i=a; i<n;i++)
#define ll long long
#define pi 3.141592653589793
#define vi              vector<int>
#define si              set<int>
#define pb              push_back
#define mp              make_pair
#define mod             1000000007
#define rr              return 0
#define ff              first
#define in              insert
#define ss              second
#define setbits(x)      __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)
#define deb(x)          cout << #x << " = " << x << endl
int main()
{
    start;
    ll i,j,n,m,k;
    string s;
    cin>>s;
    ll shim=0;
    for(i=0;i<s.size();i++)
    {
        shim+=(s[i]-'0');
    }
    if(shim%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    rr;
}


Measured memory_bytes: 3768
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(solve(n,a));
    }
    static int solve(int n, int[] a) {
        int[] l = new int[1000000];
        for(int i = 0; i < n; i ++) {
            l[a[i]] ++;
            l[a[i]+1] ++;
            l[a[i]+2] ++;
        }
        return l.Max();
    }
}

Measured memory_bytes: 18528
import java.io.*;
import java.util.*;
import java.math.*;
 
public class Main
{
    public static void main(String[]args)throws IOException
    {
         Scanner sc = new Scanner(System.in);
         int N = sc.nextInt();
         if(N%2==0)
         {
              System.out.println((N/2));
         }
         else
         {
              System.out.println((N/2)+1);
         }
    }
}
           


Measured memory_bytes: 21844
s = input().rstrip()

idx = 0
prev = s[idx]
idx += 1
ans = 1
while idx < len(s):
    if prev == s[idx]:
        if idx == len(s) - 1:
            break
        else:
            prev = s[idx:idx+2]
            idx += 2
            ans += 1
    else:
        prev = s[idx]
        idx += 1
        ans += 1
print(ans)

Measured memory_bytes: 3500
//package ;
import java.io.*;
import java.util.*;

public class Main {
	static double dp(int i,int take)
	{
		if(i==n)
			return (i-take > take) ?-1e9*1d:1;
		
		if(dp[i][take]!=-1)
			return dp[i][take];
		
		double takes=a[i]*dp(i+1,take+1);
		double leave=(1-a[i])*dp(i+1,take);
		if(leave > 0)
			takes+=leave;
		return dp[i][take]=takes;
	}
	static int n;
	static double[] a,dp[];
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		n=sc.nextInt();
		a=sc.nextDoubleArray(n);
		dp=new double[n][n];
		for(int i=0;i<n;i++)
			Arrays.fill(dp[i], -1);
		System.out.println(dp(0,0));
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

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

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		boolean hasnext() throws IOException {
			return br.ready();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		char[] nextCharArray() throws IOException {
			return br.readLine().toCharArray();
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] ans = new double[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextDouble();
			return ans;
		}

	}
}


Measured memory_bytes: 130640
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, A, B = sc.nextInt()
  val grouped = List
    .fill(N)(sc.nextInt())
    .groupBy(i => if (i <= A) "A" else if (i <= B) "B" else "C")
    .view
    .mapValues(_.length)
  println(List("A", "B", "C").map(grouped.getOrElse(_, 0)).min)
}


Measured memory_bytes: 55732
def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())

    dp = [0] * (N + 1)
    res = 1
    for i in range(3, N + 1):
        res += dp[i - 3]
        res %= MOD
        dp[i] = res

    print(dp[N])


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9196
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;

int n;
int num[105];
int main()
{
	int tot = 0;
	for(int i = 1; i <= 100; i++) {
		tot = 0;
		int x = i;
		while(true)
		{
			if(x & 1) break;
			tot++;
			x = x / 2;
		}
		num[i] = tot;
	}
	while(scanf("%d", &n) != EOF)	
	{
		int MAX = 0;
		int ans = 1;
		for(int i = 1; i <= n; i++) {
			if(num[i] > MAX)
			{
				ans = i;
				MAX = num[i];
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <cassert>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-9;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9 + 7;
const LL MAX = 51;

int h, w;
char a[MAX][MAX];
int dx[] = { 0, 0, 1, -1 };
int dy[] = { 1, -1, 0, 0 };

bool check(int x, int y)
{
	return x >= 0 && y >= 0 && x < h && y < w;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> h >> w;
	FOR(i, 0, h)
		FOR(j, 0, w)
		cin >> a[i][j];

	bool ok = 1;

	FOR(i, 0, h)
		FOR(j, 0, w)
	{
		if (a[i][j] == '.')
			continue;

		bool was = 0;

		FOR(k, 0, 4)
		{
			int x = i + dx[k];
			int y = j + dy[k];
			if (!check(x, y))
				continue;

			if (a[x][y] == '#')
				was = 1;
		}


		ok &= was;
	}

	if (ok)
		cout << "Yes";
	else
		cout << "No";

	cin >> h;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int  main()
{
    int a,b;
    while(1)
    {
        scanf("%d %d",&a,&b);
        if( a==0 && b==0)
        {
            break;
        }
        for(int i=1; i<=a; i++)
        {
            for(int j=1; j<=b; j++)
            {
                if((i+j)%2 == 0)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
           }
            return 0;
}



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


def solve(N: int, S: str):
    r = 0
    g = 0
    b = 0
    sub = 0
    for i in range(N):
        if S[i] == "R":
            r += 1
            for j in range(i + 1, N):
                if S[j] == "G":
                    if j * 2 - i < N and S[j * 2 - i] == "B":
                        sub += 1
                elif S[j] == "B":
                    if j * 2 - i < N and S[j * 2 - i] == "G":
                        sub += 1
        elif S[i] == "G":
            g += 1
            for j in range(i + 1, N):
                if S[j] == "R":
                    if j * 2 - i < N and S[j * 2 - i] == "B":
                        sub += 1
                elif S[j] == "B":
                    if j * 2 - i < N and S[j * 2 - i] == "R":
                        sub += 1
        else:
            b += 1
            for j in range(i + 1, N):
                if S[j] == "R":
                    if j * 2 - i < N and S[j * 2 - i] == "G":
                        sub += 1
                elif S[j] == "G":
                    if j * 2 - i < N and S[j * 2 - i] == "R":
                        sub += 1

    print(r * g * b - sub)
    return


# Generated by 1.1.6 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()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;



void solve(){
    int a,b;
    cin >> a >> b;
    if(a==1) a +=13;
    if(b==1) b += 13;
    string ans;
    if(a>b) ans = "Alice";
    else if(a<b) ans = "Bob";
    else ans = "Draw";
    cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>


int main (void)
{
  int n, a, b, i;
  scanf("%d", &n);
  for(i =1; i<= n; i++){
    a = i;
    if(a %3 ==0){
      printf(" %d", i);
    } else{
      for(;;){
        b = a % 10;
        if(b == 3){
          printf(" %d", i);
          break;
        } else if(a < 10)
        {
          break;
        }

        a = a/10;
      }
    }

  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1800
($N) = split(/\s+/, <>);

$n = 0;

if ($N < 10) {
    # 1..$N: $N
    $n = $N;
} elsif ($N < 100) {
    # 1..9: 9
    # 10..99: 0
    $n = 9;
} elsif ($N < 1000) {
    # 1..9: 9
    # 10..99: 0
    # 100..$N: $N + 1
    $n = 9 + ($N - 100 + 1);
} elsif ($N < 10000) {
    # 1..9: 9
    # 10..99: 0
    # 100..999: 900
    # 1000..$N: 0
    $n = 9 + 900;
} elsif ($N < 100000) {
    # 1..9: 9
    # 10..99: 0
    # 100..999: 900
    # 1000..9999: 0
    # 10000..$N: $N - 100000 + 1
    $n = 9 + 900 + ($N - 10000 + 1);
} elsif ($N == 100000) {
    $n = 9 + 900 + 90000;
}

print "$n\n";


Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,tmp,table[101];
	scanf("%d",&N);

	for(int i = 0; i <= 100; i++)table[i] = 0;

	for(int i = 0; i < N; i++){
		scanf("%d",&tmp);
		table[tmp]++;
	}

	if(table[100] == 100){
		printf("100\n");
		return 0;
	}

	for(int i = 99; i >= 1; i--){
		table[i] += table[i+1];
		if(i <= table[i]){
			printf("%d\n",i);
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 2728
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){
	int n;
	cin>>n;
	long long ans = 100000;
	for (int i = 0; i < n; i++)
	{
		ans += ans / 20;
		if(ans % 1000 != 0)
			ans = ans - ans % 1000 + 1000;
	}

	cout << ans << endl;

	return 0;
}

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

namespace Aojx
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s;
            while ((s = Console.ReadLine()) != null)
            {
                double v = double.Parse(s);
                double t = v / 9.8;
                double y = 4.9 * t * t;

                for (int i = 1;; i++)
                {
                    if (5 * i - 5 >= y)
                    {
                        Console.WriteLine(i);
                        break;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 5740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    cout << (in()+in())*in()/2 << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){

  int i, j, k, size, tmp;

  scanf("%d", &size);

  int arr[size];

  for(i = 0; i < size; i++)
    scanf("%d", &arr[i]);


  for(i = 1; i <= size-1; i++){

    //show arr during sorting.
    for(k = 0; k < size-1; k++)
      printf("%d ", arr[k]);
    printf("%d", arr[k]);
    printf("\n");

    tmp = arr[i];

    //insert arr[i] into the sorted sequence arr[0, ... , j-1]
    j = i - 1;
    while(j >= 0 && arr[j] > tmp){
      arr[j+1] = arr[j];
      j--;
    }
    arr[j+1] = tmp;

  }

  for(i = 0; i < size-1; i++)
    printf("%d ", arr[i]);
  printf("%d", arr[k]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
const int maxn = 500;
typedef pair<ll, ll>par;
const ll mod = 1e9+7;

int id[maxn];
ll a[maxn];
char s[maxn];

void add( int p ){

    for( int i = 63; i >= 0; i-- ){
        if( (a[p] >> i) & 1 ){
            if( id[i] == -1 ){
                id[i] = p;
                break;
            }else{
                a[p] ^= a[ id[i] ];
            }
        }
    }
}

bool can( int p ){
    for( int i = 63; i >= 0; i-- ){
        if( (a[p] >> i) & 1 ){
            if( id[i] == -1 ) return 0;
            a[p] ^= a[ id[i] ];
        }
    }

    return 1;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in", "r",stdin);
    #endif // acm


    int test;
    cin >> test;

    int n;
    while( test-- ){
        cin >> n;
        for( int i = 1; i <= n; i++ )
            cin >> a[i];

        cin >> (s+1);

        if( s[n] == '1' ){
            cout << "1\n";
            continue;
        }

        for( int i = 0; i <= 63; i++ )
            id[i] = -1;

        int winer = 0;
        for( int i = n; i >= 1; i-- ){
            if( s[i] == '0' )
                add(i);
            else
                if( !can(i) ){
                    winer = 1;
                    break;
                }
        }

        cout << winer << "\n";
    }

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define mp make_pair

using namespace std;

int main()
{

    int n, t, ti, ci;
    cin >> n >> t;

    vector < pair<int, int> > vp;
    for( int i = 0; i < n; i++ ){
        cin >> ci >> ti;
        vp.eb( mp(ci, ti) );
    }

    sort( all(vp) );
    
    for( int i = 0; i < n; i++ ){
        if( vp[i].second <= t ){
            cout << vp[i].first << endl;
            return 0;
        }
    }

    cout << "TLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;

	int c = 0;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) c++;
	}

	cout << N - 1 - max(0, c - 2 * K) << endl;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w;
  cin >> h >> w;
  vector<string> a(h);
  REP(i,h)cin >> a[i];
  set<int32> x,y;
  REP(i,h){
    map<char,int32> mp;
    REP(j,w)mp[a[i][j]]++;
    if(mp['#'] == 0)x.insert(i);
  }
  REP(j,w){
    map<char,int32> mp;
    REP(i,h){
      mp[a[i][j]]++;
    }
    if(mp['#'] == 0)y.insert(j);
  }
  REP(i,h){
    if(x.count(i))continue;
    REP(j,w){
      if(y.count(j))continue;
      cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
signed main(){
    int N;cin>>N;
    int s=0;
    bool f=false;
    rep(i,N){
        string S;cin>>S;
        if(S=="A")s++;
        else{
            s--;
            if(s<0)f=true;
        }
    }
    if(!f&&!s)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(void){
	
	int num,k;
	num = 0;

	string s;

	cin >> s;

	for (k = 0; k < 3; k++) {
		if (s[k] == '1')num++;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    N=len(S)
    ans=15-N+S.count("o")
    if ans>=8:
        print("YES")
    else:
        print("NO")

main()


Measured memory_bytes: 61956
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = a + b;

		switch (c) {
		case 3:
			System.out.println(3);
			break;
		case 4:
			System.out.println(2);
			break;
		case 5:
			System.out.println(1);
			break;
		}

	}

}

Measured memory_bytes: 22228
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-13;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int main(){
	int a;scanf("%d",&a);printf("%d\n",a/3);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int P, Q, R;
    cin >> P >> Q >> R;
    cout << min({P + Q, Q + R, R + P}) << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$oni = explode(' ', trim(fgets(STDIN)));
$child = explode(' ', trim(fgets(STDIN)));
$time = fgets(STDIN);

if ($oni[0] < $child[0]) {
    $x = $oni[0] + $oni[1] * $time;
    $y = $child[0] + $child[1] * $time;
    echo $x >= $y ?  'YES' : 'NO' ;
} else {
    $x = $oni[0] - $oni[1] * $time;
    $y = $child[0] - $child[1] * $time;
    echo $x <= $y ?  'YES' : 'NO' ;
}
?>

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

ll ModInverse(ll a, ll m)
{
  ll x = 0, y = 1, gcd = m;
  ll px = 1, py = 0, pgcd = a;
  ll temp = 0;
  while (gcd > 0){
    ll quotient = pgcd / gcd;
    temp = x;
    x = px - quotient * temp;
    px = temp;
    temp = y;
    y = py - quotient * temp;
    py = temp;
    temp = gcd;
    gcd = pgcd - quotient * temp;
    pgcd = temp;
  }
  while(px<0){ px += m; }
  return px;
}

map < ll, int > prime_factor(ll n) {
  static vector< int > primes;
  if( primes.size() == 0 ){
    vector< bool > prime(1000 + 1, true);
    for(int i = 2; i*i <= 1000; i++) {
      if(!prime[i]) continue;
      for(int j = i + i; j <= 1000; j += i) {
        prime[j] = false;
      }
    }
    for(int i = 2; i <= 1000; i++) {
      if( prime[i] ) primes.push_back(i);
    }
  }
  
  map< ll, int > ret;
  for(auto it = primes.begin(); it != primes.end(); ++it){
    ll ii = *it;
    while(n % ii == 0) {
      ret[ii]++;
      n /= ii;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  const int mb = 1000000007;
  int n;
  cin >> n;
  
  vector< map<ll,int> > b(n);
  map<ll,int> agr;
  vector< ll > modi(n);
  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    b[i] = prime_factor(a);
    for_each(b[i].begin(), b[i].end(), [&](const auto &mp){
      if( agr[mp.first] < mp.second ) agr[mp.first] = mp.second ;
    });
    modi[i] = ModInverse(a,mb);
  }
  
  ll c = 1;
  for_each(agr.begin(), agr.end(), [&](const auto &mp){
    for(int j=1; j<=mp.second; j++){
      c = ( c * mp.first ) % mb;
    }
  });
  
  ll tot = 0;
  for(int i=0;i<n;i++){
    tot = ( tot + c * modi[i] ) % mb;
  }
  cout << tot << endl;
  return 0;
}



Measured memory_bytes: 3968
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn color(val: usize) -> usize {
    if 1 <= val && val <= 399 {
        0
    } else if 400 <= val && val <= 799 {
        1
    } else if 800 <= val && val <= 1199 {
        2
    } else if 1200 <= val && val <= 1599 {
        3
    } else if 1600 <= val && val <= 1999 {
        4
    } else if 2000 <= val && val <= 2399 {
        5
    } else if 2400 <= val && val <= 2799 {
        6
    } else if 2800 <= val && val <= 3199 {
        7
    } else {
        8
    }
}

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut v = vec![0; 9];
    for i in 0..n {
        v[color(a[i])] += 1;
    }
    let min = {
        let mut val = 0;
        for i in 0..8 {
            if v[i] != 0 {
                val += 1;
            }
        }
        if v[8] != 0 {
            if val == 0 {
                val += 1;
            }
        }
        val
    };
    let max = {
        let mut val = 0;
        for i in 0..8 {
            if v[i] != 0 {
                val += 1;
            }
        }
        //let left = 8 - val;
        //val += std::cmp::min(left, v[8]);
        val += v[8];
        val
    };
    println!("{} {}", min, max);
}


Measured memory_bytes: 4352
N = int(input())
xy = list(list(map(int,input().split()))+[0]for i in range(N))
ans = 50
hoge = 0
p,q = 0,0

def func(n):
    xy[n][2] = 1
    if [xy[n][0]+p,xy[n][1]+q,0] in xy:
        func(xy.index([xy[n][0]+p,xy[n][1]+q,0]))
    if [xy[n][0]-p,xy[n][1]-q,0] in xy:
        func(xy.index([xy[n][0]-p,xy[n][1]-q,0]))
    


for i in range(N):
    for j in range(N):
        p,q = xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]
        for k in range(N):
            if xy[k][2] == 0:
                func(k)
                hoge += 1
        ans = min(hoge,ans)
        hoge = 0
        for k in range(N):
            xy[k][2] = 0
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()


#define LCS longest_common_subsequence
string longest_common_subsequence( const string S, const string T ) {
    vector<vector<int>> dp( S.size()+1, vector<int>(T.size()+1, 0) );

    rep( s, S.size() ) {
    rep( t, T.size() ) {
        dp[s+1][t+1] = max( dp[s][t+1], dp[s+1][t] );
        if( S[s] == T[t] ) dp[s+1][t+1] = dp[s][t] +1;
    }
    }

    int length = dp[S.size()][T.size()];
    string ans( length, ' ' );

    for( int i=length, s=S.size(), t=T.size(); i>0; i--,s--,t-- ) {
        for( ; dp[s-1][t] == i; s-- );
        for( ; dp[s][t-1] == i; t-- );
        ans[i-1] = S[s-1];
    }
    return ans;
}

int main() { cin.tie(0); ios::sync_with_stdio(false);
    string S, T; cin >> S >> T;
    cout << LCS( S, T ) << "\n";
}


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

int main(void){
	int n,gc=0,pc=0,res=0;
	char s[100000];
	scanf("%s",s);
	n = strlen(s);
	for(int i=0;i<n;i++){
		if(s[i] == 'g'){
			if(pc < gc){
				pc++;
				res++;
			}else{
				gc++;
			}
		}else{
			if(pc < gc){
				pc++;
			}else{
				gc++;
				res--;
			}
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
g = []
for _ in range(h):
    g.append(input())

ans = 0
from itertools import product
for i in product([0,1], repeat=h):
    for j in product([0,1], repeat=w):
        num = 0
        for a in range(h):
            for b in range(w):
                if g[a][b] == '#' and i[a] == 0 and j[b] == 0:
                    num += 1
        if num == k:
            ans += 1

print(ans)

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

int main()
{
    int n;
    cin >> n;
    if (n == 1)
        cout << 0 << endl;
    else
    {
        int64_t count = 0;
        int ima, mae, dif;
        cin >> mae;
        for (int i = 1; i < n; i++)
        {
            cin >> ima;
            if (ima < mae)
            {
                dif = mae - ima;
                count += dif;
                ima = mae;
            }
            mae = ima;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3616
//#pragma GCC optimize(2)
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, beg, end) for (int i = (beg); i < (end); i++)
const ll limit = 10000000;
bitset<limit+1> notPrime;
ll next(int i)
{
    while (notPrime[i] != 0)
    {
        i++;
    }
    return i;
}
unordered_map<ll, bool> pt;
bool isPrime(ll num)
{
    if (pt.find(num) != pt.end())
    {
        return pt[num];
    }
    if (num == 1)
    {
        pt.insert({num, false});
        return false;
    }
    if (num == 2 || num == 3)
    {
        pt.insert({num, true});
        return true;
    }
    if (num % 6 != 1 && num % 6 != 5)
    {
        pt.insert({num, false});
        return false;
    }
    if (num < limit && notPrime[num] == 0)
    {
        pt.insert({num, true});
        return true;
    }
    else if (num < limit && notPrime[num] == 1)
    {
        pt.insert({num, false});
        return false;
    }

    ll t = sqrtl(num);
    for (ll i = 5; i < t + 1; i++)
    {
        if (num % i == 0 || num % (i + 2) == 0)
        {
            pt.insert({num, false});
            return false;
        }
    }
    pt.insert({num, true});
    return true;
}

int main()
{
    long long b = limit;

    long long s = sqrtl(b) + 1;

    for (ll i = 2; i <= s; i++)
    {
        if (!notPrime[i])
        {
            for (ll j = i; j <= b / i; j++)
            {
                notPrime[i * j] = 1;
            }
        }
    }

    ll n;
    cin >> n;
    s = n / 2;
    ll ans = 0;
    if (n > limit)
    {
        if (isPrime(n))
        {
            cout << 1 << endl;
            return 0;
        }
    }

    for (ll i = 2; i <= n; i = next(i + 1))
    {
        ll k = i;
        while (k <= n)
        {
            ll d = n / k;
            if (k * d == n)
            {
                ans++;
            }
            else
            {
                break;
            }

            n = d;
            k *= i;
        }
        if (n > limit)
        {
            if (isPrime(n))
            {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		char[] input_chars = input.toCharArray();

		int count = 0;
		int len = input_chars.length;
		for(int i =0; i <len/2; i++){
			if(input_chars[i] != input_chars[len-1-i]){
				count++;
			}
		}

		System.out.print(count);
	}
}


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

int main(void){
    int N,K,i,j=0;
    scanf("%d%d",&N,&K);
    int* h;
    h=(int*)malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
        if(h[i]>=K){
            j++;
        }
    }
    printf("%d\n",j);
    free(h);
    return 0;
}

Measured memory_bytes: 512
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  n ; cin >> n ; 
    int  rem = (n%100)+4 ; 
    rem = ((rem/5)*100) ; 
    if (rem>n) cout << 0 << endl;
    else cout << 1 << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
long long int arr[2000];
int main(){
    long long int n,num,sum=0;
    memset(arr,0,sizeof(arr));
    cin>>n>>num;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    int i;
    for(i=0;i<n;i++){
        if(num>=arr[i]){
            sum+=1;
            num-=arr[i];
        }else break;
    }
    if(i==n&&num>0)sum--;
    cout<<sum<<endl;
return 0;
}


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

int main() {
  int N;
  int A[20][20] = {0};

  cin >> N;
  int num;
  for(int i = 0; i < N; ++i) {
    cin >> num;
    int x, y;
    for(int j = 0; j < num; ++j) {
      cin >> x >> y;
      A[i][x - 1] = y > 0 ? 1 : -1;
    }
  }

  int maxValue = 0;
  for(int i = 0; i < (1 << N); ++i) {
    // i は正直者と仮定するフラグ
    int B[20] = {0}; //
    int honestCount = 0;
    bool mujun = false;
    for(int j = 0; j < N; ++j) {
      // 正直と仮定する人かどうか
      bool isHonest = (i & (1 << j)) != 0;
      if(!isHonest) {
        continue;
      }
      honestCount++;
      for(int k = 0; k < N; ++k) {
        if(A[j][k] < 0 && (i & (1 << k)) != 0) {
          mujun = true;
          break;
        }
        if(A[j][k] > 0 && (i & (1 << k)) == 0) {
          mujun = true;
          break;
        }
        /*
        if(B[k] * A[j][k] < 0) {
          mujun = true;
          break;
        } else {
          B[k] += A[j][k];
        }
        */
      }
      if(mujun) {
        break;
      }
    }
    if(mujun) {
      continue;
    }
    maxValue = max(maxValue, honestCount);
  }

  cout << maxValue << endl;
  return 0;
}

Measured memory_bytes: 256