akhauriyash/Code-Regression huggingface dataset:
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright  2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <utility> // pair
#include <map>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>


using namespace std;

#define ll long long
#define lll __int128
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define INT_INF 0x7fffffff

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)

#define cio ios::sync_with_stdio(false); // Do not use it with "scanf" and other c input!
#define pb push_back
#define rep(i,a,b) for (int i = a;i <= b;i ++)
#define pre(i,a,b) for (int i = a;i >= b;i --)
#define REP(i,a,b) for (int i = a;i < b;i ++)

#define read(a,s,n) rep(i,s,n) scanf("%d",a + i);
#define READ(a,s,n) REP(i,s,n) scanf("%d",a + i);

#define read_ll(a,s,n) rep(i,s,n) scanf("%lld",a + i);
#define READ_ll(a,s,n) REP(i,s,n) scanf("%lld",a + i);

#define _T_(T) int T;scanf("%d",&T);while (T --)
#define __T _T_(TTESTCASES)
#define _E_(T) while (~T)

#define Tprint(a,s,e) {int f=1;REP(i,s,e){if(f)f=0;else printf(" ");printf("%d",a[i]);}}


#define endl '\n'

#define itn int
#define iny int
#define nit int
#define inr int
#define mian main
#define iman main
#define mina main
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int main()
{
    int n;
    scanf("%d",&n);
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    REP (i,0,n) if (s[i] == 'R') cnt ++;
    REP (i,0,cnt) if (s[i] =='W') ans ++;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3524
import math

n = int(input())
xlist = input().split()
xlist = [int(s) for s in xlist]
ylist = input().split()
ylist = [int(s) for s in ylist]
zlist = [abs(xlist[x] - ylist[x]) for x in range(n)]

ans1 = 0
ans2 = 0
ans3 = 0
for x in range(n):
    ans1 += abs(xlist[x] - ylist[x])
    ans2 += abs(xlist[x] - ylist[x])**2
    ans3 += abs(xlist[x] - ylist[x])**3
print(ans1)    
print(math.sqrt(ans2))
print(ans3**(1/3))
print(max(zlist))


Measured memory_bytes: 5696
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x, ans = 0;
    cin >> n;
    rep(i, 1, n) {
        cin >> x;
        if(x == ans + 1) {
            ans++;
        }
    }
    cout << (ans ? n - ans : -1) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

final class Main {

    public static final int PMAX = 60000;

    private Main() {
    }

    public static void main(final String[] argv) throws IOException {
        final BufferedReader inputReader =
                new BufferedReader(new InputStreamReader(System.in));
        boolean[] prime = new boolean[PMAX];
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for (int i = 2; i < PMAX; i++) {
            if (prime[i]) {
                for (int j = i * 2; j < PMAX; j += i) {
                    prime[j] = false;
                }
            }
        }
        while (true) {
            String input = inputReader.readLine();
            if (input == null) {
                break;
            }
            int index = Integer.parseInt(input);
            for (int i = index - 1; i >= 0; i--) {
                if (prime[i]) {
                    System.out.print(i + " ");
                    break;
                }
            }
            for (int i = index + 1; i < PMAX; i++) {
                if (prime[i]) {
                    System.out.println(i);
                    break;
                }
            }
        }
    }
}

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

int main() {
   int n;
   cin >> n;
   vector<int> h(n);
   rep(i, n) {
      cin >> h.at(i);
   }

   int count = 0, tmp = 0;

   rep(i, n - 1) {
      if (h[i] >= h[i + 1]) tmp++;
      else if(h[i] < h[i + 1] || h[i] == n - 2) tmp = 0;
      if (count < tmp) count = tmp;
   }

   cout << count << endl;
}

Measured memory_bytes: 640
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    ll ans=0;
    for(int i=0;i<n;i++){
        ll aa=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        ll bb=c.end()-upper_bound(c.begin(),c.end(),b[i]);

        ans+=aa*bb;
    }
    cout<<ans<<endl;
}


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

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


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

struct tast{
	int a,b;
}t[200000];

int N;
unsigned long long ti;

bool cmp(tast a,tast b){
	return a.b<b.b;
}

int main(){
	cin>>N;
	for(int i=0;i!=N;++i){
		scanf("%d%d",&t[i].a,&t[i].b);
	}
	sort(t,t+N,cmp);
	for(int i=0;i!=N;++i){
		ti+=t[i].a;
		if(ti>t[i].b){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    string s;
    cin >> s;
    vi abc(3);
    rep(i, s.size())
    {
        if (s[i] == 'a')
        {
            abc[0]++;
        }
        else if (s[i] == 'b')
        {
            abc[1]++;
        }
        else
        {
            abc[2]++;
        }
    }
    std::sort(all(abc));
    if (abc[2] - abc[0] > 1)
    {
        cout << "NO" << endl;
    }
    else
    {
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#pragma GCC optimize("02")
#define ll long long
#define _inline __inline__ __attribute__((always_inline))
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> _inline ios & operator >> (_Tp &x){
        static char ch,sgn; ch=gc(),sgn=0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}inc;
int a[8]={1,2,4,8,16,32,64,128};
int main(){
	int n;
	inc>>n;
	for(int i=0;i<8;i++){
		if(a[i]>n){
			printf("%d\n",a[i-1]);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
ll N, M;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>M;

    if(N == 1 && M == 1){
        cout<<1<<endl;
        return 0;
    }

    ll ans = 0;

    ans += max(0LL, N - 2LL) * max(0LL, M - 2LL);

    if(N == 1){
        ans += max(0LL, M - 2LL);
    }
    if(M == 1){
        ans += max(0LL, N - 2LL);
    }


    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n:usize,
        vlr0:[(u64,u64);n],
    }

    let calc = |l, r| {
        // スコアの計算
        if l <= r {
            r - l + 1
        } else {
            0
        }
    };
    /*
       2回目のコンテストで正解者が0の場合 → 1問とそれ以外に分ける
       2回のコンテストの両方とも正解者が0でない場合
         → 1問とそれ以外に分けた場合
         → 2つに分けた場合
       の2パターン
    */
    let mut max_score = 0;

    /* 1問とそれ以外に分けた場合 */
    let mut lmax = vlr0.clone();
    lmax.sort_by_key(|x| 1000000001 - x.0);
    let mut rmin = vlr0.clone();
    rmin.sort_by_key(|x| x.1);
    for lr in vlr0.iter() {
        let (l, r) = *lr;
        let lother = if l == lmax[0].0 { lmax[1].0 } else { lmax[0].0 };
        let rother = if r == rmin[0].1 { rmin[1].1 } else { rmin[0].1 };
        let score = calc(l, r) + calc(lother, rother);
        //println!("l:{} r:{} lrem:{} rrem:{} / {}", l, r, lrem, rrem, score);
        max_score = max(max_score, score);
    }

    /* 2つに分けた場合。 r0を含むグループか、l1を含むグループ の2つ。  */
    let r0 = vlr0.iter().min_by_key(|x| x.1).unwrap().1; // rの最小値
    let l1 = vlr0.iter().max_by_key(|x| x.0).unwrap().0; // lの最大値

    let mut vlr = vlr0.clone();
    vlr.sort_by_key(|p| p.1 * 0x100000000u64 + p.0);
    // vlr[0..i) を1回目のコンテストにする [l0,r0]
    // vlr[i..n) を2回目のコンテストにする [l1,r1]
    let mut l0 = 0;
    for i in 1..vlr.len() {
        if vlr[i - 1].0 > l0 {
            l0 = vlr[i - 1].0;
        }
        let r1 = vlr[i].1;
        let score = calc(l0, r0) + calc(l1, r1);
        //println!("l0:{} r:0{} l1:{}, r1:{} / {}", l0, r0, l1, r1, score);
        max_score = max(max_score, score);
    }

    println!("{}", max_score);
}


Measured memory_bytes: 10920
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<P> cities[101010];
    REP(i,m){
        int p,y;
        cin>>p>>y;
        cities[p].push_back({y,i});
    }
    P ans[101010];
    for(int i=1;i<=n;i++){
        sort(cities[i].begin(),cities[i].end());
        for(int j=0;j<cities[i].size();j++){
            //cout<<cities[i][j].second<<endl;
            ans[cities[i][j].second]={i,j+1};
        }
    }
    for(int i=0;i<m;i++){
        printf("%06d%06d\n",ans[i].first,ans[i].second);
    }
}


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

int main() {
  int n, ans;
  cin >> n;
  if(n < 10){
    ans= n ;
  }else if(n >= 10 && n < 100){
    ans = 9;
  }else if(n >= 100 && n < 1000){
    ans = n - 90;
  }else if( n >= 1000 && n < 10000){
    ans = 909;
  }else if( n >= 10000 && n < 100000){
    ans = n - 9090;
  }else{
    ans = 90909;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<iomanip>

using namespace std;
using ll=long long;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  string s;
  cin>>s;
  int x=s[0]+1;
  cout<<(char)x<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, T=0, x;
  cin >> N >> K;

  for(int i; i<N; i++){
    
    cin >> x;
    
    if( 2*x < K )
      T += 2*x;
    else
      T += 2*(K-x);
  }
  
  cout << T << endl;
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    vector<int> vec(101);
    for(int i=a;i<=b;i++) vec.at(i)++;
    for(int i=c;i<=d;i++) vec.at(i)++;
    int minute = 0;
    for(int i=0;i<=100;i++){
        if(vec.at(i)==2) minute++;
    }
    cout << max(0,minute-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int V = 2600;
const int E = 100000;
const int INF = 0x3f3f3f3f;
int head[V], to[E], cap[E], cst[E], nxt[E], eid;
void Init() {
	memset(head, -1, sizeof(head));
	eid = 0;
}
void _add_edge(int u, int v, int w, int c) {
	to[eid] = v;
	cap[eid] = w;
	cst[eid] = c;
	nxt[eid] = head[u];
	head[u] = eid++;
}
void add_edge(int u, int v, int w, int c) {
	_add_edge(u, v, w, c);
	_add_edge(v, u, 0, -c);
}
queue<int> que;
int dist[V], pre[V], inq[V];
bool SPFA(int s, int t) {
	memset(dist, 0x3f, sizeof(dist));
	memset(inq, 0, sizeof(inq));
	memset(pre, -1, sizeof(pre));
	dist[s] = 0;
	que.push(s);
	inq[s] = 1;
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		inq[u] = 0;
		for (int i = head[u]; ~i; i = nxt[i]) {
			int v = to[i];
			if (cap[i] > 0 && dist[v] > dist[u] + cst[i]) {
				dist[v] = dist[u] + cst[i];
				pre[v] = i;
				if (!inq[v]) {
					que.push(v);
					inq[v] = 1;
				}
			}
		}
	}
	return pre[t] != -1;
}
void MCMF(int s, int t) {
	int flow = 0, cost = 0;
	while (SPFA(s, t)) {
		int mn = INF;
		for (int u = t; u != s; u = to[pre[u] ^ 1]) mn = min(mn, cap[pre[u]]);
		flow += mn;
		for (int u = t; u != s; u = to[pre[u] ^ 1]) {
			cost += mn * cst[pre[u]];
			cap[pre[u]] -= mn;
			cap[pre[u] ^ 1] += mn;
		}
	}
	printf("%d\n", -cost);
}
int n, m;
char s[55][55];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf(" %s", s[i] + 1);
	}
	Init();
	int S = n * m + 1, T = S + 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (i < n && s[i][j] != '#' && s[i + 1][j] != '#') add_edge((i - 1) * m + j, i * m + j, INF, -1);
			if (j < m && s[i][j] != '#' && s[i][j + 1] != '#') add_edge((i - 1) * m + j, (i - 1) * m + j + 1, INF, -1);
			if (s[i][j] == 'o') {
				add_edge(S, (i - 1) * m + j, 1, 0);
			}
			if (s[i][j] != '#') {
				add_edge((i - 1) * m + j, T, 1, 0);
			}
		}
	}
	MCMF(S, T);
	return 0;
}

Measured memory_bytes: 3980
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n = int(input())
    s = input()
    ans = 1

    for i in range(1, n):
        if s[i-1] != s[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(1e5+5)

void solve()
{
    string s1,s2;
    cin>>s1>>s2;

    int l1 = s1.size() , l2 = s2.size();
    int dp[l1+1][l2+1];
    memset(dp,0,sizeof dp);
    for(int i=1;i<=l1;i++)
    {
        for(int j=1;j<=l2;j++)
        {
            if(s1[i-1] == s2[j-1])
                dp[i][j] = 1 + dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
        }
    }

    int i=l1,j=l2;
    string ans = "";
    while(i>0 && j>0)
    {
        if(s1[i-1] == s2[j-1])
        {
            ans += s1[i-1];
            i--,j--;
        }
        else
        {
            if(dp[i-1][j] >= dp[i][j-1])
                i--;
            else
                j--;
        }
    }

    reverse(ans.begin() , ans.end());
    cout<<ans<<"\n";
}

int main()
{
    fio;
    ll tc = 1;
   // cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

int main(){
  int K,S;
  cin>>K>>S;
  int X=0;
  int Y=0;
  int Z=0;
  int long count=0;
  
  for (int i=0; i<=K; i++){
    X=i;
    for (int j=0; j<=K; j++){
      Y=j;
      if (X+Y<=S && S-X-Y<=K)
        count++;
    }
  }
  
      
  cout<<count<<endl;
}
        

Measured memory_bytes: 256
from itertools import accumulate
while True:
    try:
        data = list(map(int, input().split(',')))
        l = data[0:10]
        v1 = data[10]
        v2 = data[11]

        l = list(accumulate(l))
        d = l[9] / (v1 + v2) * v1
        l.insert(0, 0)
        for i in range(len(l)):
            if l[i] < d <= l[i+1]:
                print(i+1)
                break
    except:
        break

Measured memory_bytes: 5644
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    List<Integer> list = new ArrayList<>();
    for ( int i = 1; i <= num; i++ ) {
      for ( int j = 1; j <= num; j++ ) {
        for ( int k = 1; k <= num; k++ ) {
          list.add(gcd(i, j, k) );
        }
      }
    }

    int sum = 0;
    for ( int n : list ) {
      sum += n;
    }
    System.out.println(sum);
  }

  private static int gcd(int i, int j, int k) {
    return gcd(gcd(i, j), k);
  }

  private static int gcd(int i, int j) {
    int buf1 = i;
    int buf2 = j;
    while ( true ) {
      if ( buf1 % buf2 == 0 ) break;
      int temp = buf1;
      buf1 = buf2;
      buf2 = temp % buf2;
    }
    return buf2;
  }
}


Measured memory_bytes: 113860
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vector<pii> r(n),b(n);
  rep(i,n) cin >> r.at(i).first >> r.at(i).second;
  rep(i,n) cin >> b.at(i).first >> b.at(i).second;
  sort(r.begin(),r.end());
  sort(b.begin(),b.end());
  vector<bool> select(n,false);
  int ans = 0;
  rep(i,n){
    int bx = b.at(i).first;
    int by = b.at(i).second;
    int id = -1;
    int maxy = -1;
    rep(j,n){
      if(select.at(j)) continue;
      int rx = r.at(j).first;
      int ry = r.at(j).second;
      if(rx < bx && ry < by){
        if(ry > maxy){
          id = j;
          maxy = ry;
        }
      }
    }
    if(id != -1){
      //cout << i << " " << id << endl;
      select.at(id) = true;
      ans++;
    }    
  }
  cout << ans << endl;
}

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

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++)
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 100;

int N, Nr[MAX_N];
int main() {
	cin >> N; REP(i, N) scanf("%d", &Nr[i]);
	deque<pi> Q; Q.push_front(pi(N, 0));

	ll Ans = 0, Now = 0;
	for(int i=N-1; i>=0; i--) {
		while(true) {
			int ix, v; tie(ix, v) = Q.front(); 
			if(v > Nr[i]) {
				Q.pop_front();
				Now -= 1ll * v * (Q.front().one - ix);
			}else break;
		}
		Now += 1ll * Nr[i] * (Q.front().one - i);
		Ans += Now;
		Q.push_front(pi(i, Nr[i]));
	}
	printf("%lld\n", Ans);
	return 0;
}



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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int n, k, x, y;
    cin >> n >> k >> x >> y;

    if(n <= k) cout << x*n << endl;
    else{
        cout << x*k + (n-k)*y << endl;
    }

    return 0;
}

Measured memory_bytes: 3548
X = list(map(int,input()))

A = X[0]
B = X[1]
C = X[2]
D = X[3]

if A+B+C+D==7:
    print("{}+{}+{}+{}=7".format(A,B,C,D))
elif A+B+C-D==7:
    print("{}+{}+{}-{}=7".format(A,B,C,D))
elif A+B-C+D==7:
    print("{}+{}-{}+{}=7".format(A,B,C,D))
elif A+B-C-D==7:
    print("{}+{}-{}-{}=7".format(A,B,C,D))
elif A-B+C+D==7:
    print("{}-{}+{}+{}=7".format(A,B,C,D))
elif A-B+C-D==7:
    print("{}-{}+{}-{}=7".format(A,B,C,D))
elif A-B-C+D==7:
    print("{}-{}-{}+{}=7".format(A,B,C,D))
elif A-B-C-D==7:
    print("{}-{}-{}-{}=7".format(A,B,C,D))


Measured memory_bytes: 3064
import java.util
import java.util.Scanner

import scala.util.Sorting

/**
  * lewin のコードが速かったのでscalaだとどれぐらいの速度が出るのかみてみる
  */
object Main {
  def main(args: Array[String]): Unit = {
    val in = new Scanner(System.in)
    val n = in.nextInt()
    val k = in.nextInt()
    val q = in.nextInt()
    val arr = Array.fill(n)(in.nextInt())
    val solver = new TaskE
    println(solver.solve(n, k, q, arr))
  }

  class TaskE {
    def get(arr: Array[Int], k: Int, sm: Int, big: Int): Int = {
      var good = 0
      var tot = 0
      var ans = 0
      for {
        j <- arr.indices
      }{
        if (arr(j) < sm) {
          ans += Math.max(0, Math.min(tot - k + 1, good))
          good = 0
          tot = 0
        }
        else {
          tot += 1
          if (arr(j) <= big) good += 1
        }
      }
      ans += Math.max(0, Math.min(tot - k + 1, good))
      ans
    }

    def solve(n: Int, k: Int, q: Int, arr: Array[Int]): Int = {
      val brr = util.Arrays.copyOf(arr, arr.length)
      Sorting.quickSort(brr)
      var ret = brr(q - 1) - brr(0)
      for {
        small <- brr.indices
      } {
        var lo = small
        var hi = brr.length
        while (lo < hi) {
          val mid = (lo + hi) / 2
          if (get(arr, k, brr(small), brr(mid)) >= q) hi = mid
          else lo = mid + 1
        }
        if (lo < brr.length) ret = Math.min(ret, brr(lo) - brr(small))
      }
      ret
    }
  }

}



Measured memory_bytes: 33288
dicc=dict()

n=int(input())
for i in range(n):
    ai=input()
    if ai in dicc:
        dicc[ai]=1-dicc[ai]
    else:
        dicc[ai]=1
        
icnt=0    
for i in dicc.values():
    icnt=icnt+i
      
print(icnt)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
int main() { 
    long double a;
    long double b;
    cin >> a >> b;
    b *= 100;
    (int)b;
    long double ans = a / 100 * b;
    ans = floor(ans);
    (ll)ans;
    cout <<  fixed << setprecision(0) << ans << endl;
}

Measured memory_bytes: 3776
#include<stdio.h>

int main(void) {
  int A,B,K,i,j=0;
  scanf("%d %d %d",&A,&B,&K);
  for(i=100;i>0;i--) {
    if(A%i==0 && B%i==0) {
      j++;
  	  if(j==K)printf("%d\n",i);
    }
  }
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 998244353;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int  n, s;
	cin >>n >>s;
	VI a(n);
	rep(i, n) cin >>a[i];
	
	VL dp(s+4); dp[0]=1;
	rep(i, n) repr(k, s, 0) {
		if(k+a[i] <= s) (dp[ k + a[i]] += dp[k]) %=MD;
		(dp[k] *=2  )%=MD;
	}
	cout << dp[s] <<"\n";
	return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <string>
#include <vector>
#include <cassert>

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

using namespace std;

int c_2_5() {
	//string s;
	int n;
	cin >> n;
	// int price[n];
	vector<int> price(n);
	REPEAT(i, n) {
		cin >> price[i];
	}
	int maxPrice[n];
	int currentMaxPrice;
	currentMaxPrice = 0;	// or -infinite
	for (int i = n - 1; i >= 0; i--) {
		if (price[i] > currentMaxPrice) {
			currentMaxPrice = price[i];
		}
		maxPrice[i] = currentMaxPrice;
	}
	int maxUp = maxPrice[1] - price[0];
	for (int i = 1; i < n - 1; i++) {
		const int diff = maxPrice[i + 1] - price[i];
		if (diff > maxUp) {
			maxUp = diff;
		}
	}
	cout << maxUp << "\n";
	return 0;
}

int main() {
	ios::sync_with_stdio(false);
	return c_2_5();
}



Measured memory_bytes: 4432
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int q;
    char x[1001], y[1001];
    int table[1001][1001];
    
    cin >> q;
    for (int i = 0; i < q; i++) {
	cin >> x >> y;
	int xl = strlen(x), yl = strlen(y);

	for (int i = 0; i < xl; i++)
	    for (int j = 0; j < yl; j++)
		if (x[i] == y[j])
		    table[i+1][j+1] = 1 + table[i][j];
		else
		    table[i+1][j+1] = max(table[i][j+1], table[i+1][j]);

	cout << table[xl][yl] << endl;
    }

    return 0;
}

Measured memory_bytes: 5076
#include <iostream>
#include <string.h>
using namespace std;
char s[105];
int ans,act,j,i,n,fr[105];
int main()
{
    cin>>n;
    cin>>s;
    ans=0;
    for(i=0;i<=n;i++)
    {
        //cut at position i
        memset(fr,0,sizeof(fr));
        for(j=0;j<i;j++)
        {
            fr[s[j]-'a']=1;
        }
        for(j=i;j<n;j++)
        {
            fr[s[j]-'a']|=2;
        }
        act=0;
        for(j=0;j<30;j++)
            if(fr[j]==3)
                act++;
        ans=max(ans,act);
    }
    cout<<ans<<'\n';
    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 sum = 0;
		//???????????????
		int c = sc.nextInt();
		//?¨?????????????
		int r = sc.nextInt();
		//???????????£?¨? ?¨???????????¨? ??¨??????????¨? ??????????????????????????????1??????
		int [][] list = new  int [c+1][r+1];
		//?????????????´? ??????
		for(int i = 0; i < c; i++){
			//?????????????´? ?¨????
			for(int j = 0; j< r; j++){
				list[i][j] = sc.nextInt();
			}
		}
		//
		for(int i = 0; i< c; i++){
			for(int j =0; j< r;j++){
				list[i][r]  += list[i][j]; //??? ????¨????
				list[c][j] += list[i][j]; //??? ????¨????
				list[c][r] += list[i][j]; //???????? ????¨????
			}
		}
		//??¨?????????
		//i<=c ?????????????????????????????????????????????
		for(int i = 0;i<=c;i++){
			//System.out.print(list[i][0] + " "); //??????????????????????????????????????£?????????
			//???<=??? ?????????????????????????????????????????????
			for(int j =0; j<=r;j++){
				//r????????????????????§??\???????????? ????????\?????????????????????????????????
				if(j == r){
					System.out.print(list[i][j]);
				}else{
					System.out.print(list[i][j] + " ");
				}
			}
			//??????
			System.out.println();
		}
	}
}

Measured memory_bytes: 41944
#include<stdio.h>

int main(void)


{


 int a, b, c, i, x;


 x=0;


 scanf("%d %d %d",&a, &b, &c);


 for(i=a; i<=b; i++){


  if(c%i==0){


   x++;


  }


 }


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


 return 0;


}

Measured memory_bytes: 596
fo=0
fou=[0]
se=0
sev=[0]
fl=False
while fo<100:
  fo+=4
  fou.append(fo)
while se<100:
  se+=7
  sev.append(se)
n=int(input())
for i in fou:
  for j in sev:
    if n==i+j:
      fl=True
      print("Yes")
      break
  if fl:
    break
else:
  print("No")


Measured memory_bytes: 9188
/*
http://arc084.contest.atcoder.jp/tasks/arc084_a
*/
#include <iostream>
#include <algorithm>
using namespace std;

const int MAXN=100010;
int a[MAXN],b[MAXN],c[MAXN];
int sizeA=1,sizeB=1,sizeC=1;
long long sumB[MAXN];
long long sumC[MAXN];
int getCnt(int array[], int size, int target) {
	int left=0, right=size-1;
	int ansP=-1;
	while (left<=right) {
		int mid=(left+right)>>1;
		if (array[mid] >= target)
			right = mid-1;
		else
			left=mid+1, ansP=mid;
	}
	return ansP;
}

int main() {
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
		cin>>a[i];
	for (int i=0;i<n;i++)
		cin>>b[i];
	for (int i=0;i<n;i++)
		cin>>c[i];
	sort(a, a+n);
	sort(b, b+n);
	sort(c, c+n);

	sizeA=sizeB=sizeC=n;
	for (int i=0; i<sizeB; i++) {
		int ansP = getCnt(a, sizeA, b[i]);
		if (ansP == -1)
			sumB[i] = 0;
		else
			sumB[i] = ansP+1;
	}
	for (int i=1;i<sizeB;i++)
		sumB[i] += sumB[i-1];
	long long result = 0;
	for (int i=0;i<sizeC;i++) {
		int ansP = getCnt(b, sizeB, c[i]);
		if (ansP !=-1)
			result += sumB[ansP];
	}
	cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 2176
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
mal = lines[1].sort
limit = 10 ** 18

ans = 1
for i in 1..N do
  ans *= mal[i-1]
  if ans > limit then
    ans = -1
    break
  end
end

print ans

Measured memory_bytes: 25024
#include<vector>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      double x1,y1,x2,y2,x3,y3,x4,y4;
      scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
      if(fabs((x2-x1)*(y4-y3)-(y2-y1)*(x4-x3)) <=1e-10) printf("YES\n");
      else printf("NO\n");
    }
}

Measured memory_bytes: 1204
/*
AizuOnline A1104
Title
*/
#include <stdio.h>
#include <string.h>
#define min(x,y) (((x)<(y))?(x):(y))
#define max(x,y) (((x)>(y))?(x):(y))

//Global data section
int x,y;
int w,h;
char dir;
char *dd="NESW";
char directive[10];
int operand;
//
main()
{
        while(EOF!=scanf("%d %d",&w,&h) && (w||h))
        {
#ifdef DEBUG
                printf("%d %d\n",w,h);
#endif
                x=1;y=1;dir=0;

                while(1)
                {
                        scanf("%s ",directive);
                        if(0==strcmp("STOP",directive))         
                                break;
                        if(0==strcmp("LEFT",directive))
                                dir=(dir+3)%4;
                        if(0==strcmp("RIGHT",directive))
                                dir=(dir+1)%4;
                        if(0==strcmp("FORWARD",directive))
                        {
                                scanf("%d",&operand);
#ifdef DEBUG
                        printf("%s %d\n",directive,operand);
#endif
                                switch( dir)
                                {
                                case 0:
                                        y=min(y+operand,h);
                                        break;
                                case 1:
                                        x=min(x+operand,w);
                                        break;
                                case 2:
                                        y=max(y-operand,1);
                                        break;
                                case 3:
                                        x=max(x-operand,1);
                                        break;
                                }
#ifdef DEBUG
                                printf("%d %d %d\n",dir,x,y);
#endif

                        }
                        if(0==strcmp("BACKWARD",directive))
                        {
                                scanf("%d",&operand);
#ifdef DEBUG
                        printf("%s %d\n",directive,operand);
#endif
                                switch( dir)
                                {
                                case 2:
                                        y=min(y+operand,h);
                                        break;
                                case 3:
                                        x=min(x+operand,w);
                                        break;
                                case 0:
                                        y=max(y-operand,1);
                                        break;
                                case 1:
                                        x=max(x-operand,1);
                                        break;
                                }
#ifdef DEBUG
                                printf("%d %d %d\n",dir,x,y);
#endif
                        }
                }
                printf("%d %d\n",x,y);
        }

return(0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define A 100000000
#define B 10000
using  namespace std;
typedef long long ll;
struct Info
{
    ll sum;
    int p, q, r;
    bool operator<(const Info& rhs) const
    {
        return sum < rhs.sum;
    }
};

int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
    sort(a.begin(), a.end(), greater<ll>() );
    sort(b.begin(), b.end(), greater<ll>() );
    sort(c.begin(), c.end(), greater<ll>() );

    priority_queue<Info> que;
    Info info = {a[0]+b[0]+c[0], 0, 0, 0};
    que.push(info);
  	map<ll, bool> mp;
	int l = 0;
    while (l < k) {
        Info info1 = que.top();
		que.pop();
        int p, q, r;
        p = info1.p;
        q = info1.q;
        r = info1.r;
      	ll num = (p+1)*A + (q+1)*B + (r+1);
      	if (!mp[num]) {
          	mp[num] = true;
          	++l;
          	ll sum = info1.sum;
            cout << sum << endl;
            if (p+1 < x) {
                Info info2 = {a[p+1]+b[q]+c[r], p+1, q, r};
                que.push(info2);
            }
            if (q+1 < y) {
                Info info2 = {a[p]+b[q+1]+c[r], p, q+1, r};
                que.push(info2);
            }
            if (r+1 < x) {
                Info info2 = {a[p]+b[q]+c[r+1], p, q, r+1};
                que.push(info2);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))

S = 0
for i, a in enumerate(A):
    S += (-1)**i * a

ans = [0] * N
ans[0] = S
for i, a in enumerate(A[:-1], start=1):
    S *= -1
    S += 2 * a
    ans[i] = S

print(*ans)

Measured memory_bytes: 14028
/*
Author : Chandan Agrawal
College : Poornima College of Engg. jaipur, Raj
Mail : chandanagrawal23@gmail.com


" when you are not practicing someone else is ,
 and the day u meet them u will lose "

*/
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 200050

#define ll long long
#define ld long double
#define lli long long int

#define pb push_back
#define INF 1000000000000
#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))

#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define mci map<char,lli>
#define vi vector<lli>
#define vbool vector<bool>
#define seti set<lli>
#define pii pair<lli,lli>
#define pcc pair<char,char>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvec(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvec(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;

// chandan1,2
void chandan1(){int y=1;return;}
void chandan2(){
        loop(i,10){
        lli x=1;
    }
    return(chandan1());
}


int main(){
fastio
lli t=1;
//cin>>t;
chandan2();
while(t--) {
    lli k;
    cin>>k;
    if(k%2==0 or k%5==0)
        print(-1);
    else
    {
        lli ans = 0;
        lli cnt=0;
        while(true)
        {
            ans = ans*10 + 7;
            ans%=k;
            cnt++;
            if(ans==0)
                break;
        }
        print(cnt);
    }


  }
return 0;
}


Measured memory_bytes: 3648
s = input()
t = input()

count = len(s) - len(t) + 1
ans = 10**6
for i in range(count):
    a = 0
    for j in range(len(t)):
        #print(s[j+i], t[j])
        if s[j+i] != t[j]:
            a += 1
    if a < ans:
        ans = a
print(ans)

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

using namespace std;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template<typename T>
void chmin(T& s,T t){
    s=min(s,t);
}
template<typename T>
void chmax(T& s,T t){
    s=max(s,t);
}


int main(){
    int lx,ux;
    int ly,uy;
    int W,H,N;
    cin>>W>>H>>N;
    lx=ly=0;
    ux=W;
    uy=H;
    REP(i,N){
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1){
            chmax(lx,x);
        }
        if(a==2){
            chmin(ux,x);
        }
        if(a==3){
            chmax(ly,y);
        }
        if(a==4){
            chmin(uy,y);
        }
    }
    cout<<max(0,uy-ly)*max(0,ux-lx)<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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
    L=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K=I()
    print(L[K-1])

main()


Measured memory_bytes: 38256
from sys import stdin, stdout
from collections import deque, defaultdict
import math as m

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	s = rll()[0]
	t = rll()[0]
	m, n = len(s), len(t)
	dp = [[0 for __ in range(n)] for _ in range(m)]

	#dp[i][j] = LCs of s0,...,si and t0,...,tj

	def pprint(M):
		for row in M:
			print(row)
		print("~~~")
	
	dp[0][0] = 1 if s[0] == t[0] else 0
	for c in range(1, n):
		dp[0][c] = max(dp[0][c-1], 1 if s[0] == t[c] else 0)
	for r in range(1, m):
		dp[r][0] = max(dp[r-1][0], 1 if s[r] == t[0] else 0)

	for r in range(1, m):
		for c in range(1, n):
			dp[r][c] = max(dp[r][c], dp[r-1][c], dp[r][c-1])
			if s[r] == t[c]:
				dp[r][c] = max(dp[r][c], 1 + dp[r-1][c-1])

	ans = deque()
	i, j = m - 1, n - 1
	while i >= 0 and j >= 0:
		if s[i] == t[j]:
			ans.appendleft(s[i])
			i -= 1
			j -= 1
		else:
			up, left = NINF, NINF
			if i - 1 >= 0:
				up = dp[i-1][j]
			if j - 1 >= 0:
				left = dp[i][j-1]
			if up >= left:
				i -= 1
			else:
				j -= 1
	print("".join(x for x in ans))
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 123996
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let k: i64 = read();
    let s2 = s.clone() + &s;
    let mut before_char = ';';
    let mut cnt = 0;
    for c in s2.clone().chars() {
        if c == before_char {
            cnt += 1;
            before_char = ';';
        } else {
            before_char = c;
        }
    }
    let unique: std::collections::HashSet<char> = s2.chars().collect();
    let ans = if unique.len() == 1 {
        (s.len() as i64 * k) / 2
    } else if cnt % 2 == 0 {
        (cnt + 1) / 2 * k
    } else {
        ((cnt + 1) / 2 * k) - 1
    };
    println!("{}", ans)
}


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

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

  int ans=0;
  int num=0;
  bool flag=false;

  int n=s.length();
  rep(i,n){
    string a="";
    a+=s[i];
    if(a=="A" || a=="C" ||a=="G" || a=="T"){
      if(!flag){
	flag=true;
	num=1;
      }else num++;
    }else flag=false;
    if(ans<num)ans=num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;
typedef pair<int,pair<int,int> > ipii;
typedef pair<pii,pii> pi4;
const int vbi=999999999;

/*void cin_bin(){
	char bin[10000];
	gets(bin);
}*/

vector<int> jz10_2(int a){
	vector<int> ans;
	while(a!=0){
		ans.pb(a%2);
		a/=2;
	}
	reverse(ans.begin(),ans.end());
	return ans;
}

int n,m;
int S,E;
vector<int> v[100010];
bool vis[100010][3];

void bfs(int st){
	queue<piii> q;
	q.push(mer(mer(0,0),S));
	while(!q.empty()){
		piii x;
		x=q.front();
		q.pop();
		int kkp=x.fi.fi,an=x.fi.se,now=x.se;
		if(now==E&&an==0){
			cout<<kkp;
			return;
		}
		if(vis[now][an])
			continue;
		vis[now][an]=true;
		for(int i=0;i<v[now].size();i++){
			int nextt=v[now][i],nkkp=kkp,nan=an+1;
			if(nan==3){
				nan=0;
				nkkp++;
			}
			q.push(mer(mer(nkkp,nan),nextt));
		}
	}
	cout<<-1;
}

int main(){
	//my English name is Veex
	//clock_t start1=clock();
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int ui,vi;
		cin>>ui>>vi;
		v[ui].pb(vi);
	}
	cin>>S>>E;
	bfs(S);
	//cout<<endl<<((double)(clock()-start1)/CLOCKS_PER_SEC);
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
int main() {
    ll X; cin >> X;
    ll ans = 0;
    ll a = 100;
    while(true){
        ans++;
        a = floor(a*1.01);
        if (a>=X) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
d=dict()
n=int(input())
for i in range(n):
    s=input()
    if s in d:
        d[s]+=1
    else:
        d[s]=1
d=list(d.items())
d.sort(key=lambda x:x[0])
d.sort(key=lambda x:x[1],reverse=True)
#print(d)
m=len(d)
for i in range(m):
    if d[i][1]==d[0][1]:
        print(d[i][0])
    else:
        break


Measured memory_bytes: 41564
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	ll q;
	cin>>s>>q;
	deque<char> d;
	rep(i,s.size())d.push_back(s[i]);
	bool rev=false;
	while(q--){
		ll op;
		cin>>op;
		if(op==1)rev=!rev;
		else{
			ll f;
			char c;
			cin>>f>>c;
			if((f==1)^rev)d.push_front(c);
			else d.push_back(c);
		}
	}
	string ans;
	for(auto x:d)ans.push_back(x);
	if(rev)reverse(all(ans));
	puta(ans);
}

Measured memory_bytes: 1368
#include <iostream>
using namespace std;
int main()
{
	long long a,b;
	char o;
	cin>>a>>o>>b;
	if(1<=a && b<=10^9){
		if(o=='+')
		cout<<a+b;
		else
		if(o=='-')
		cout<<a-b;
	}
	return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
 
int main() {
    int N;
    int tag[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> N;
    cout << tag[N-1] << endl;
}

Measured memory_bytes: 256