akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define pr1(a) (#a)<<"="<<(a)
#define pr2(a,b) pr1(a)<<", "<<pr1(b)
#define pr3(a,b,c) pr2(a,b)<<", "<<pr1(c)
#define pr4(a,b,c,d) pr3(a,b,c)<<", "<<pr1(d)
#define pr5(a,b,c,d,e) pr4(a,b,c,d)<<", "<<pr1(e)
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  int n;
  cin>>n;
  vector<int>A(n);
  cin>>A;

  P ans;
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++) 
      if(abs(A[i] - A[j]) % (n-1) == 0) ans = P(A[i],A[j]);

  cout<<ans.first<<" "<<ans.second<<endl;
  
  return 0;
}



Measured memory_bytes: 3108
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin>>n;
    vec(ld) v(n);
    rep(i,n){
        cin>>v[i];
    }
    sort(all(v));
    rep(i,n-1){
        v[i+1]=(v[i]+v[i+1])/(ld)2;
    }
    out(v[n-1]);
}

Measured memory_bytes: 3864
#include <stdio.h>

int main ()
{
    int n,w, sum=0;
    scanf("%d", &n);
    while(1)
    {
        w = n%10;
        n= n/10;
        sum=(sum*10)+w;
        if(n==0)
            break;
    }
    while(1)
    {
        w = sum%10;
        sum = sum/10;
        if(w==1)
            printf("9");
        else if(w==9)
            printf("1");
        if(sum==0)
            break;
    }
    return 0;
}


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int M;
    std::cin >> M;

    std::cout << (24 - M + 24) << std::endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
$ab = $a * $b;
$cd = $c * $d;
if( $ab > $cd ){
  echo $ab;
}elseif($ab < $cd){
  echo $cd;
}else{
  echo $cd;
}

?>

Measured memory_bytes: 4604
#include <stdio.h>

int main(void)
{
	int a, b;
	int l, s;
	int gcd, lcm;
	
	while (scanf("%d %d", &a, &b) != EOF){
		l = a;
		s = b;
		
		if (l < s){
			l = b;
			s = a;
		}
		
		while (s){
			l %= s;
			l += s;
			s = l - s;
			l -= s;
		}
		
		gcd = l;
		lcm = a / gcd * b;
		
		printf("%d %d\n", gcd, lcm);
	}
	
	return (0);
}

Measured memory_bytes: 1024
#define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
#define MAX 20
int main(void)
{
	int n, sum = 100000;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		sum += sum * 0.05;
		if (sum % 1000 != 0) {
			sum += 1000 - sum % 1000;
		}
	}
	printf("%d\n", sum);
}

Measured memory_bytes: 1184
#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;
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/numeric/interval.hpp>
// #include <boost/numeric/interval/io.hpp>
// #include <boost/intrusive/rbtree.hpp>
// #include <boost/geometry.hpp>
// #include <boost/geometry/geometries/linestring.hpp>
// #include <boost/geometry/geometries/polygon.hpp>
// #include <boost/geometry/geometries/point_xy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
using namespace::std;
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cfloat;
// typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define LINF 9223372036854775807
#define MOD 1000000007
#define endl "\n"
template<typename T=lint>T in(){return *istream_iterator<T>(cin);}
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    string s;
    cin>>s;
    if(s=="Sunny")cout<<"Cloudy"<<endl;
    if(s=="Cloudy")cout<<"Rainy"<<endl;
    if(s=="Rainy")cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ac = 0
    wa = 0
    tle = 0
    re = 0
    for i in range(n):
        a = input()
        if a == "AC":
            ac += 1
        elif a == "WA":
            wa += 1
        elif a == "TLE":
            tle += 1
        elif a == "RE":
            re += 1
    
    print("AC x ", ac)
    print("WA x ", wa)
    print("TLE x ", tle)
    print("RE x ", re)

if __name__ == "__main__":
    main()


Measured memory_bytes: 69828
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
const int MAXN = 2e5+10;
int cnt[MAXN];
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);  
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n;cin>>n;
    double z=ceil((double)n/1000);
    ll k=z*1000;
    cout<<abs(n-k)<<endl;
    return 0;
}


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

int top,S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(s[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(s[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(s));
        }
    }
    
    printf("%d\n",pop());
    
    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

struct query{
    int l, r, idx;
};

istream & operator >>(istream& is, query &q){
    return is>>q.l>>q.r;
}

int sqr(ll n){
    ll l = 1, r = n, ans;
    while(l <= r){
        ll mid = (l + r) >> 1, sq = mid * mid;
        if(sq < n){
            ans = mid;
            l = mid + 1LL;
        }
        else if(sq == n){
            return mid;
        }
        else{
            r = mid - 1LL;
        }
    }
    return ans;
}

void solve()
{
    //If you cannot approach a problem
    //directly in the way it is proposed then try to think from backwards
    int n, q;
    cin>>n>>q;
    int sq_n = sqr(n), c = 0;
    vector<int> A(n);
    for(int &i: A) cin>>i;
    query queries[q];
    F(int, i, 0, q - 1){
        cin>>queries[i];
        queries[i].l--;queries[i].r--;
        queries[i].idx = i;
    }
    sort(queries, queries + q, [&](query a, query b){
        return make_tuple(a.l / sq_n, a.r) < make_tuple(b.l / sq_n, b.r);
    });
    vector<int> count(n + 1, 0);
    vector<int> ans_q(q, -1);
    int prev_l = queries[0].l, prev_r = queries[0].l - 1;//[]
    F(int, i, 0, q - 1){
        while(queries[i].r > prev_r){
            prev_r ++;
            count[A[prev_r]] ++;
            if(count[A[prev_r]] == 1)
                c ++;
        }
        while(queries[i].l < prev_l){
            prev_l --;
            count[A[prev_l]] ++;
            if(count[A[prev_l]] == 1)
                c ++;
        }
        while(queries[i].r < prev_r){
            count[A[prev_r]] --;
            if(count[A[prev_r]] == 0)
                c --;
            prev_r--;
        }
        while(queries[i].l > prev_l){
            count[A[prev_l]] --;
            if(count[A[prev_l]] == 0)
                c --;
            prev_l ++;
        }
        ans_q[queries[i].idx] = c;
    }
    for(int a: ans_q)   
        cout<<a<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 15476
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll A[3] = {};
	cin >> A[0] >> A[1] >> A[2];

	sort(A, A + 3);
	ll n; cin >> n;
	rep(i, 0, n) {
		A[2] *= 2;
	}
	cout << A[0] + A[1] + A[2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long INF = 1LL << 60; 

int main()
{
  int A, B; cin >> A >> B;
  cout << ((B-1)+(A-1)-1)/(A-1) << endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var map = new bool[n, n];
            var map2 = new bool[n, n];
            var hvmax = 0;
            var vsub = new int[n];
            for (int i = 0; i < n; i++)
            {
                var s = Console.ReadLine().Trim();
                 var hsub = 0;
                for (int j = 0; j < n; j++)
                {
                    if (s[j] == '1')
                    {
                        map[i, j] = true;
                        map2[i, j] = true;
                        hsub++;
                        vsub[j]++;
                        if (i == n - 1) hvmax = Math.Max(hvmax, vsub[j]);
                    }
                    else
                    {
                        hvmax = Math.Max(hvmax, hsub);
                        hsub = 0;
                        hvmax = Math.Max(hvmax, vsub[j]);
                        vsub[j] = 0;
                    }
                }
                hvmax = Math.Max(hvmax, hsub);
            }
            var nmax = 0;
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                {
                    if(map[i,j])
                    {
                        var t = getNum(map, 1, -1, i, j, 1);
                        nmax = Math.Max(nmax, t);
                    }
                    if (map2[i,j])
                    {
                        var t2 = getNum(map2, 1, 1, i, j, 1);
                        nmax = Math.Max(nmax, t2);
                    }
                }
            Console.WriteLine(Math.Max(hvmax, nmax));
        }
    }
    public static int getNum (bool[,] map , int dx ,int dy ,int x, int y , int r)
    {
        var n = map.GetLength(0);
        map[x, y] = false;
        var nx = x + dx;  var ny = y + dy;
        if (nx >= 0 && nx < n && ny >= 0 && ny < n && map[nx, ny]) { return getNum(map, dx, dy, nx, ny, r + 1); }
        else return r;
    }
}

Measured memory_bytes: 9620
#include <bits/stdc++.h>
#include <iterator>
#include <algorithm>
#include <queue>
#include <set>
#include <bitset>
#include <vector>
#include <map>



#define IOS                    ios::sync_with_stdio();cin.tie(0);
#define tc()                int tc;scanf("%d",&tc);while(tc--)
#define endl                "\n"
#define FLOAT_COM(a,b)      if(abs(a-b)==1e-9)
#define LOOP(a,b)           for(i=a;i<b;i++)
#define VI                  vector<int>
#define VLL                 vector<long long>
#define PB                  push_back
#define MP                  make_pair



using namespace std;

//int i,j,k,l,temp;

void shomoy(){
    #ifndef ONLINE_JUDGE
        cerr<<"\nTime  :"<<1.0*clock()/CLOCKS_PER_SEC<<"  s\n";
    #endif

}

bool isprime(int n){
    int f;
    for(f=2;f*f<=n;f++){
        if(n%f==0)
            return false;
    }
    return true;
}


                      /*Driver Code Startes Here*/
int main(){IOS
    int i,n,count=0;
    char line[10000000];
    cin>>line;
    n = strlen(line);
    for(i=0;i<n;i++){
        count += (line[i] - '0');
    }
    if(count%9){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    


//shomoy();
return 0;
}

Measured memory_bytes: 3748
def sort_cmp(x, y):
    if x[2] == y[2]:
        return x[3] < y[3]
    else:
        return x[2] > x[2]


def solve(n):
    teams = []
    for i in range(n):
        teams.append(list(map(int, raw_input().split())))

    teams = sorted(teams, key=lambda x: -1e12 * x[2] + x[3] * 1e6 + x[0])

    A = []
    B = []
    threshold = 3
    for team in teams:
        if len(A) == 10:
            threshold = 2
        elif len(A) == 20:
            threshold = 1

        if B.count(team[1]) < threshold:
            A.append(team[0])
            B.append(team[1])

        if len(A) == 26:
            break

    for a in A:
        print(a)


while True:
    n = int(raw_input())
    if n == 0:
        break
    solve(n)

Measured memory_bytes: 4720
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, k, R, S, P, score;
bool win[100007];
string s;

void winPlus(char c) {
    if(c == 'r') score += P;
    if(c == 's') score += R;
    if(c == 'p') score += S;
}

int main () {
    fastIO;
    cin >> n >> k >> R >> S >> P >> s;

    for(li i = 0; i < n; i ++) {
        if(i < k) {
            win[i] = true;
            winPlus(s[i]);
        } else {
            if(s[i] == s[i - k] && win[i - k]) win[i] = false;
            else {
                winPlus(s[i]);
                win[i] = true;
            }
        }
    }

    cout << score;
}


Measured memory_bytes: 592
#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	string S, T;
	cin >> S >> T;
	
	for(uint i=0; i<N; i++) {
		cout << S[i] << T[i];
	}

	return 0;
}

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

int main(){
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    int tmp = k;
    while(true){
        if(tmp > b) break;
        if(tmp >= a && tmp <= b){
            cout << "OK" << endl;
            return 0;
        }
        tmp += k;
    }
    cout << "NG" << endl;
    return 0;
}


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

const int maxn = 200005;
int n, a[maxn], idx[maxn];
long long k;

int main() {
    cin >> n >> k;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int now = 1;
    bool flag = true;
    for (int i = 1; i <= k; i++){
        now = a[now];
        if (now == 1 || idx[now]){
            k -= idx[now];
            k %= (i-idx[now]);
            k += idx[now];
            for (int i = 1; i <= n; i++){
                if (idx[i] == k){
                    cout << i << "\n";
                    break;
                }
            }
            flag = false;
            break;
        }
        idx[now] = i;
    }
    if (flag) cout << now << "\n";
}


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


public class Main {

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

		int N = sc.nextInt();

		do {
			List<String> ins = new ArrayList<String>();
			List<String> outs = new ArrayList<String>();

			for (int n = 0 ; n < N ; n++) {
				ins.add(sc.next("."));
				outs.add(sc.next("."));
			}

			StringBuilder sb = new StringBuilder();
			int M = sc.nextInt();
			for (int m = 0 ; m < M ; m++) {
				String s = sc.next(".");
				if (ins.contains(s)) {
					sb.append(outs.get(ins.indexOf(s)));
				} else {
					sb.append(s);
				}
			}
			System.out.println(sb.toString());
			N = sc.nextInt();
		} while (N != 0);
	}
}

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





int main() {
	int n, m; cin >> n >> m;
	vector<int> s[10];
	bool p[10];

	for (int i = 0; i < m; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int buf; cin >> buf; s[i].push_back(1 << (buf - 1));
		}
	}
	for (int i = 0; i < m; i++) {
		int buf; cin >> buf;
		p[i] = buf;
	}

	int ans = 0;
	for (int i = 0b0000000000; i < 1 << n; i++) {
		bool ok = true;
		for (int j = 0; j < m; j++) {
			bool bbuf = false;
			for (int k : s[j]) {
				bbuf = (bbuf != (bool)(i & k));
			}
			if (bbuf != p[j]) { ok = false; break; }
		}
		if (ok) ans++;
	}

	cout << ans << endl;

	return 0;
}


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

int main(void) {
	// your code goes here
	int n;
	cin >> n;
	if(n<=3||n==5||n==6||n==9||n==10||n==13||n==17) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	f := (y - 2*x) / 2
	t := x - f
	if t >= 0 && f >= 0 && f*4+2*t == y {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1752
def main():
    N = int(input())
    if N <= 6:
        print(1)
    else:
        c = N // 11
        if N == c * 11:
            print(2 * c)
        elif N <= c * 11 + 6:
            print(c * 2 + 1)
        else:
            print(c * 2 + 2)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"unicode/utf8"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	K, err := strconv.Atoi(scanner.Text())

	if err != nil {
		panic(err)
	}

	scanner.Scan()
	S := scanner.Text()

	if K >= utf8.RuneCountInString(S) {
		fmt.Println(S)
	} else {
		fmt.Printf("%s...\n", S[:K])
	}
}


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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if (d < 0) {
    cout << "No" << endl;
  } else if (4 * a * b < sqr(d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

int dp[100005][105];
int vis[100005][105];
int wts[105];
int vs[105];
const int mxw = 1e9;

int solve(int cv, int i, int n){	
	if(cv <= 0) return 0;
	if(i == n) return mxw;
	if(vis[cv][i]) return dp[cv][i]; 

	vis[cv][i] = 1;
	dp[cv][i] = min(solve(cv, i + 1, n), wts[i]+solve(cv - vs[i], i + 1, n));
	
	return dp[cv][i];
}


int main(){
	int n, w;
	cin >> n >> w;
	int mxv = 0;
	for(int i = 0; i < n; i++){
		cin >> wts[i] >> vs[i];
		mxv += vs[i];
	}
	
	while(mxv >= 0){
		if(solve(mxv, 0, n) <= w) {
			cout << mxv << endl;
			return 0;
		}
		mxv--;
	}	
	cout << 0 << endl;
}



Measured memory_bytes: 82176
#include <stdio.h>

int main ()
{
	int a=0,b=0,c=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&a<=c&&b<=c)
	{printf("%d\n",a+b);
	}
	else if(a<=b&&a<=c&&b>=c)
	{printf("%d\n",a+c);
	}
	else if(b<=a&&b<=c&&a<=c)
	{
		printf("%d\n",b+a);
	
	}
	else if(b<=a&&b<=c&&a>=c)
	{
		printf("%d\n",b+c);
	
	}
	else if(c<=a&&c<=b&&a<=b)
	{
		printf("%d\n",c+a);
	
	}
	else if(c<=a&&c<=b&&a>=b)
	{
		printf("%d\n",c+b);
	
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
      
      long cnt = 0;
      String s;
      for(long i = 1; i <= n; i++) {
        s = Long.toString(i);
        if(s.length() % 2 == 1) {
          cnt++;
        }
      }
      System.out.println(cnt);


    }
}


Measured memory_bytes: 25932
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mt make_tuple
#define ll long long
#define eb emplace_back
#define fi first
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];}
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";}
#define mod(a,b) ((a%b +b)%b)
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define max(a,b) (a<b?b:a)
#define min(a,b) (a>b?b:a) 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++) 
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
 
using namespace std;
 using namespace __gnu_pbds;
 template <typename T>
 using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
 
//----------------------------------------------------------------------------------------------------------------------
  
  
void swap(char &a, char & b){
    char temp = a;
    a = b;
    b = temp;
 
}
 
const ll MOD = 998244353;
const int MAXN = 1e5 + 5;
 


//char grid[MAXN][MAXN];

void add_self(ll &a, ll b){
    a+= b;
    while(a > MOD){
        a-=MOD;
    }
}




vector< int > graph[MAXN];
bool curr[MAXN];
bool goal[MAXN];
bool visited[MAXN];
vector< int > ans;

ll inf = 1e18*1LL;




int main() {
    // freopen("x.in", "r", stdin);
    int n; int k;
    cin >> n >> k;
    vi arr (n);
    scanVec(arr,n);
    sort(all(arr));
    vector< bool > dp (k + 1);
    for(int i = 0;i <= k;i++){
        for(auto it : arr){
            if(i >= it && !dp[i - it]){
                dp[i] = true;
            }  
        }
    }
    
    if(dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
    
    return 0;
} 

Measured memory_bytes: 2560
#include <stdio.h>
int main(void) {
int E,Y,BASE;
BASE=1867;
scanf("%d %d",&E,&Y);
switch(E){
case 4:BASE+=63;
case 3:BASE+=14;
case 2:BASE+=44;
case 1:printf("%d\n",BASE+Y);
return 0;}
if(Y<=1911){printf("M%d\n",Y-BASE);}
else if(Y<=1925){printf("T%d\n",Y-1911);}
else if(Y<=1988){printf("S%d\n",Y-1925);}
else {printf("H%d\n",Y-1988);}
return 0;
}



Measured memory_bytes: 2104
dic = {"m":1000, "c":100, "x":10, "i":1}
dic_rev = {1000:"m", 100:"c", 10:"x", 1:"i"}
N = int(input())

for i in range(N):
    slist = list(map(str, input().split()))
    numlist = []
    for word in slist:
        before = 1
        word_sum = 0
        for c in word:
            if c in dic:
                word_sum += (int(before) * dic[c])
                before = 1
            else:
                before = c
        numlist.append(word_sum)

    wordsum = sum(numlist)

    ans = ""
    cnt = 1
    for w in reversed(str(wordsum)):
        if w == "0":
            tmp = ""
        elif w == "1":
            tmp = dic_rev[cnt]
        else:
            tmp = w + dic_rev[cnt]
        ans = tmp + ans
        cnt = cnt * 10

    print(ans)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
#define MAX         1000000 //10^5
#define ll          long long
#define bl          printf("\n")
#define pn(a)       printf("%d\n",a)
#define pc(a)       printf("%c\n",a)
#define pd(a)       printf("%lf\n",a)
#define pb(a)       push_back(a)
#define deb         printf("#####\n")
#define si(a)       scanf("%d",&a)
#define sii(a,b)    scanf("%d%d",&a,&b)
#define siii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sd(a)       scanf("%lf",&a)
#define sdd(a,b)    scanf("%lf%lf",&a,&b)
#define sddd(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define fl(a,n)     for(int i=a; i<n; i++)
#define rfl(n,a)    for(int i=n-1; i>=a; i--)

int t, cs, cnt, m, H, W, n, tmp, ans;
char hw[110][110];
int h[110], w[110];
int main()
{
    sii(H,W);
    fl(0,H)
    {
        for(int j=0; j<W; j++)
        {
            scanf(" %c",&hw[i][j]);
            if(hw[i][j] == '.')
            {
                h[i]++;
                w[j]++;
            }
        }
    }
    ///input done
    fl(0,H)
    {
        if(h[i] == W)
        {
            for(int j=0; j<W; j++)
            {
                hw[i][j] = 'x';
            }
        }
    }
    fl(0,W)
    {
        if(w[i] == H)
        {
            for(int j=0; j<H; j++)
            {
                hw[j][i] = 'x';
            }
        }
    }
    ///process done
    fl(0,H)
    {
        for(int j=0; j<W; j++)
        {
            if(hw[i][j] == 'x')
            {
                cnt++;
                continue;
            }
            printf("%c",hw[i][j]);
        }
        if(cnt != W)
            bl;
        cnt = 0;
    }


    return 0;
}


Measured memory_bytes: 256
n=int(input())
ans=[0]*n

for i in range(1,101):
  for j in range(i,101):
    for k in range(j,101):
      if 1<=(i+j+k)**2-(i*j+j*k+k*i)<=n:
        ll=len(set([i,j,k]))
        if ll==1:
          aa=1
        elif ll==2:
          aa=3
        else:
          aa=6
        ans[(i+j+k)**2-(i*j+j*k+k*i)-1]+=aa
for aa in ans:
  print(aa)

Measured memory_bytes: 9300
S = input()
AA = int(S[:2])
BB = int(S[2:])

## YY/MMの確認
isYYMM = False
isMMYY = False
if BB > 0 and BB < 13:
    isYYMM = True
if AA > 0 and AA < 13:
    isMMYY = True

if isYYMM and isMMYY:
    print("AMBIGUOUS")
elif isYYMM:
    print("YYMM")
elif isMMYY:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
#include <iostream> 
#include <sstream> // istringstream
#include <string> // 文字列
#include <algorithm> // アルゴリズム
#include <cmath> // 
#include <vector> // vector
#include <set> // set
#include <map> // map

using namespace std;

#define rep(i,n) for(int i = 0; i < n; i++) // for文の省略

int main()
{   
    // input sample
    long long N; 
    cin >> N;
    string S[N];
    for (int i=0; i<N; ++i) cin >> S[i];

    long long cnt[4] = {0};

    for (int i=0; i<N; ++i) {
        if (S[i] == "AC") {
            cnt[0]++;
        }
        else if (S[i] == "WA") {
            cnt[1]++;
        }
        else if (S[i] == "TLE") {
            cnt[2]++;
        }
        else if (S[i] == "RE") {
            cnt[3]++;
        }
    }

    cout << "AC x " << cnt[0] << endl;
    cout << "WA x " << cnt[1] << endl;
    cout << "TLE x " << cnt[2] << endl;
    cout << "RE x " << cnt[3] << endl;



    return 0;
}

Measured memory_bytes: 6748
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

//////////////////////////////////

vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int main() {
	int H, N;
	cin >> H >> N;
	vector<P>AB(N);
	for (int i = 0; i < N; ++i) {
		int a, b;
		cin >> a >> b;
		AB[i] = make_pair(a, b);
	}
	vector<vector<int>> data(N + 1, vector<int>(H + 1, INF));
	data[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= H; ++j) {
			data[i + 1][j] = min(data[i + 1][j], data[i][j]);
			data[i + 1][min(j + AB[i].first, H)] = min(data[i + 1][min(j + AB[i].first, H)], data[i + 1][j] + AB[i].second);
		}
	}
	cout << data[N][H] << endl;
}

Measured memory_bytes: 41728
#include <stdbool.h>
#include <stdio.h>

int h, w, c;
int memo[10][10] = {0};
bool added[10][10] = {0};
int stack[105][2] = {0};
int d[] = {1, 0, -1, 0};
int scnt;

void dfs(int col);
int solve(int now, int bf);
int max(int x, int y) { return x > y ? x : y; }

int main() {
  int i, j;
  while(1) {
    scanf("%d %d %d", &h, &w, &c);
    if(h + w + c == 0) break;
    scnt = 1;
    for(i = 0; i < h; ++i)
      for(j = 0; j < w; ++j) added[i][j] = 0;
    for(i = 0; i < h; ++i)
      for(j = 0; j < w; ++j) scanf("%d", &memo[i][j]);
    stack[0][0] = stack[0][1] = 0;
    added[0][0] = 1;
    dfs(memo[0][0]);
    printf("%d\n", solve(0, memo[0][0]));
  }
  return 0;
}

void dfs(int col) {
  int i, j;
  for(i = 0; i < scnt; ++i) {
    int x = stack[i][0], y = stack[i][1];
    for(j = 0; j < 4; ++j) {
      int nx = x + d[j], ny = y + d[1 ^ j];
      if(nx >= 0 && nx < h && ny >= 0 && ny < w &&
         (!added[nx][ny]) && memo[nx][ny] == col) {
        added[nx][ny] = 1;
        stack[scnt][0] = nx;
        stack[scnt][1] = ny;
        ++scnt;
      }
    }
  }
}

int solve(int now, int bf) {
  if(now == 5) return scnt;
  int i, j, ans = scnt, nscnt = scnt;
  for(i = 1; i <= 6; ++i) {
    scnt = nscnt;
    if(bf == i || (now == 4 && i != c)) continue;
    dfs(i);
    ans = max(solve(now + 1, i), ans);
    for(j = scnt - 1; j >= nscnt; --j) {
      int x = stack[j][0], y = stack[j][1];
      added[x][y] = 0;
      --scnt;
    }
  }
  return ans;
}


Measured memory_bytes: 2124
import java.lang.reflect.Array;
import java.math.*;
import java.util.*;
public class Main
{
	static Scanner sc=new Scanner(System.in);
	static final int MAX=100000+5;
	public static void main(String[] args)
	{
		int n=sc.nextInt();
		if(n==3||n==5||n==7)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

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

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    map<int, int> a;
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            a[i]++;
            n /= i;
        }
    }
    if (n > 1) a[n]++;
    int ans = 0;
    for (auto x : a) {
        int c = x.second;
        for (int i = 1; ; i++) {
            int res = (i * (i + 1)) / 2;
            if (res > c) {
                ans += i - 1;
                break;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3596
import math
N, M =map(int,input().split())
ans=0

if abs(N-M)==0:
    ans=math.factorial(N)*math.factorial(M)*2
elif abs(N-M)==1:
    ans=math.factorial(N)*math.factorial(M)
else:
    ans=0

ans=ans%(10**9+7)

print(ans)

Measured memory_bytes: 5184
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>
#include <atcoder/fenwicktree>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, q, a, b; ll c;
    cin >> n >> q;
    atcoder::fenwick_tree<ll> fw(n);
    for(int i=0;i<n;++i) {
        cin >> a;
        fw.add(i, a);
    }
    for(int i=0;i<q;++i) {
        cin >> a >> b >> c;
        if(a == 0) {
            fw.add(b, c);
        } else {
            cout << fw.sum(b, c) << endl;
        }
    }
}

Measured memory_bytes: 8228
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 3010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE2][SIZE2];
bool finished[SIZE2][SIZE2];
LL A[SIZE];
string s, t;
LL solve2(LL a,LL b) {
	if (a < 0 or b<0) return 0;
	if (finished[a][b]) return DP[a][b];
	finished[a][b] = true;
	
	DP[a][b] = max(solve2(a-1,b),solve2(a,b-1));
	DP[a][b] = max(DP[a][b], solve2(a - 1, b - 1) + (s[a] == t[b]));
	return DP[a][b];
}
string solve3(LL a, LL b) {
	if (a < 0 or b < 0) return "";
	if (DP[a][b] == DP[a - 1][b]) return solve3(a-1, b);
	if (DP[a][b] == DP[a][b-1]) return solve3(a, b-1);
	if (DP[a][b] == DP[a - 1][b-1]) return solve3(a-1, b-1);
	return solve3(a - 1, b - 1)+s[a];
}

LL solve() {
	cin >> s >> t;
	solve2(s.size() - 1, t.size() - 1);
	cout << solve3(s.size() - 1, t.size() - 1) << endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 96000
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    vector<vector<vector<vector<int>>>>dp(4,vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(N,0))));
    int a,b,c,d;
    int num;
    for(int i=0;i<64;i++){
        c=i%4;b=(i/4)%4;a=((i/4)/4)%4;
        num=100*(a+1)+10*(b+1)+(c+1);
        if(num!=123&&num!=213&&num!=132){
            dp[a][b][c][2]=1;
        }
    }
    for(int i=2;i<N-1;i++){//N=3から
        for(int j=0;j<64;j++){
            c=j%4;b=(j/4)%4;a=((j/4)/4)%4;
            for(int k=0;k<4;k++){
                num=1000*(a+1)+100*(b+1)+10*(c+1)+(k+1);
                if(num-1000*(a+1)!=123&&num-1000*(a+1)!=213&&num-1000*(a+1)!=132&&num-100*(b+1)!=1023&&num-10*(c+1)!=1203){
                    dp[b][c][k][i+1]+=dp[a][b][c][i];
                    dp[b][c][k][i+1]%=1000000007;
                }
            }
        }
    }
    int sub=0;
    for(int i=0;i<64;i++){
        c=i%4;b=(i/4)%4;a=((i/4)/4)%4;
        sub+=dp[a][b][c][N-1];
        sub%=1000000007;
    }
    cout<<sub<<endl;
}

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

#define INF 1000000007
#define mem(dp,a) memset(dp,a,sizeof dp)
#define flash ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define f(i,n) for (ll i=0;i<n;i++)
#define sieve(j,mp) for(ll j=i*i ; j<=mp ; j+=i)
#define pb(x) push_back(x)
#define mp(x,y) push_back(make_pair(x,y))
#define tr(c,it) for(((c).begin())it=(c).begin();it!=(c).end();it++)
#define test ll t=1; while(t--)
#define F first
#define S second
ll dp[100010];
ll mul(ll a,ll b)
{
    ll res=0;
    a%=INF;
    while (b)
    {
        if(b&1)res=(res+a)%INF;
        a=(2*a)%INF;
        b>>=1;
    }
    return res%INF;
}
ll dfs(ll x, vector<ll> g[],ll p)
{
    ll cw=1;
    f(i,g[x].size())
    {
        if(g[x][i]!=p)
        cw=mul(cw,dfs(g[x][i],g,x));
    }
    dp[x]=cw;
    ll cb=1;
    f(i,g[x].size())
    if(g[x][i]!=p)
    cb=cb*dp[g[x][i]]%INF;
    return (cw+cb)%INF;
}
main()
{
    flash
    clock_t launch=clock();
    test
    {
        ll n,x,y; cin>>n;
        vector<ll> g[n+1];
        bool vis[n+1];
        mem(vis,false);
        f(i,n-1)
        {
            cin>>x>>y;
            g[x].pb(y);
            g[y].pb(x);
        }
        cout<<dfs(1,g,-1)%INF<<endl;
    }
    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
    return 0;
}


Measured memory_bytes: 13568
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
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)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

// solution 
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
        f: usize,
    }

    let mut mizu;
    let mut sato;
    let mut candidate = Vec::with_capacity(1_000);

    for ac in 0..f/(100*a)+1 {
        for bc in 0..(f-ac*a*100)/(100*b)+1 {
            mizu = (a*ac+b*bc)*100;
            if mizu == 0 { continue }
            for cc in 0..(f-mizu)/c+1 {
                for dc in 0..(f-mizu-c*cc)/d+1 {
                    sato = c*cc+d*dc;
                    if sato <= e*(mizu/100) {
                        candidate.push((mizu, sato));
                    }
                }
            }
        }
    }

    let mut cand = candidate[0];
    for &c in candidate.iter() {
        if cand.0 * c.1 > cand.1 * c.0 {
            cand = c
        }
    }
    println!("{} {}", cand.0+cand.1, cand.1);
}



Measured memory_bytes: 19704
#include <cstdio>
using namespace std;

long sum_array(long A[], int N) {
  long sum = 0;
  for (int i=0; i<N; i++) {
    sum += A[i];
  }
  return sum;
}

int main() {
  int N;
  scanf("%d", &N);

  bool inZero = false;
  int num_minus = 0;
  long min_A = 1000000000;
  long A[N];

  for (int i=0; i<N; i++) {
    long a;
    scanf("%ld", &a);
    if (a < 0){
      num_minus++;
      a *= -1;
    }
    if (a < min_A)
      min_A = a;
    A[i] = a;
  }
  long ans;
  if (min_A == 0 || num_minus%2 == 0) {
    ans = sum_array(A, N);
  } else {
    ans = sum_array(A, N) - 2*min_A;
  }
  printf("%ld\n", ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    string K;
    cin>>K;
    int D;
    cin>>D;

    vector<vector<long long>> A(K.size(), vector<long long>(D));
    vector<vector<long long>> B(K.size(), vector<long long>(D));
    long long M = 1000000007LL;

    for (int i=0; i<10; i++)
    {
        A[K.size()-1][i%D]++;
        if (i<=K[K.size()-1]-'0')
            B[K.size()-1][i%D]++;
    }

    for (int i=(int)K.size()-2; i>=0; i--)
    for (int j=0; j<D; j++)
    for (int k=0; k<10; k++)
    {
        int t = ((j-k)%D+D)%D;
        A[i][j] += A[i+1][t];
        A[i][j] %= M;
        if (k < K[i]-'0')
            B[i][j] += A[i+1][t],
            B[i][j] %= M;
        if (k == K[i]-'0')
            B[i][j] += B[i+1][t],
            B[i][j] %= M;
    }

    cout<<(B[0][0]-1+M)%M<<endl;
}


Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main( void )
{
	int n;
	while ( cin >> n && n )
	{
		vector <int> values;
		for ( int i = 0; i < n; i++ )
		{
			int v;
			cin >> v;
			values.push_back( v );
		}

		sort( values.begin(), values.end() );

		int s;
		cin >> s;

		int left  = 0;
		int right = n - 1;
		int answer = 0;
		while ( left <= right )
		{
			int m = ( left + right ) / 2;
			if ( s == values[m] )
			{
				answer++;
				break;
			}
			else if ( s > values[m] )
			{
				left = m + 1;
				answer++;
			}
			else if ( s < values[m] )
			{
				right = m - 1;
				answer++;
			}
		}

		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int a,b,i,k,ans,flag=0;
    scanf("%d\n",&k);
    scanf("%d %d",&a,&b);
    for(i=0; i<=b-a; i++){
        ans = a+i;
        if(ans%k==0)flag++;
    }
    if(flag==0)printf("NG");
    else printf("OK");
    return 0;
}

Measured memory_bytes: 1736
import numpy as np
n,w=map(int,input().split())
WV=[list(map(int,input().split())) for _ in range(n)]

dp=np.zeros(w+1,int)
for i in range(n):
  w,v=WV[i]
  dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[-1])


Measured memory_bytes: 15504