akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w;
    cin >> h >> w;
    string a[1000];
    for (int i = 0;i < h;++i) cin >> a[i];
    vector<vector<int>> dp(h+1,vector<int>(w+1,0));
    dp[1][0] = 1;
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (a[i][j] == '.') dp[i+1][j+1] = (dp[i][j+1]+dp[i+1][j])%mod;
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll long long

// 構造体を定義
struct work {
    int a;
    int b;
};

// 比較関数を定義
bool comp_work(const work& left, const work& right) {
    return left.b == right.b ? left.a < right.a : left.b < right.b;
}

int main() {
	int n;
	//入力
	cin >> n;
	vector<work> w(n);
    rep(i, n) {
        cin >> w[i].a >> w[i].b;
    }
    //終了時刻でsort
    sort(w.begin(), w.end(), comp_work);

    /* 作業時間を加算して終了時刻と比較 */
    int total = 0;
    int flg = 0;
    rep(i,n) {
        total += w[i].a;
        if (total > w[i].b) {
            ++flg;
            break;
        }
    }
    if (flg==0)
    	std::cout << "Yes" << endl;
    else
        std::cout << "No" << endl;
}


Measured memory_bytes: 4840
#include<iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	int ans = 0;
	
	for (int i = a; i <= b; i++) {
		int Q = c % i;
		if (Q == 0) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


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

int c[500], s[500], f[500];
int departure[500];

int main() {
	int n;
	std::cin >> n;

	if (n == 1) {
		std::cout << 0 << std::endl;
		return 0;
	}

	for (int i = 0; i < n - 1; ++i)
		std::cin >> c[i] >> s[i] >> f[i];

	for (int i = 0; i < n - 1; ++i) {
		int ans = s[i];
		for (int j = i + 1; j < n - 1; ++j)
			ans = std::max(s[j], (ans + c[j - 1] + f[j] - 1) / f[j] * f[j]);

		ans += c[n - 2];

		std::cout << ans << std::endl;
	}

	std::cout << 0 << std::endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
W, V = [0], [0]
for _ in range(n):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)

dp = [[0]*(k+1) for _ in range(n+1)]

for i in range(1, n+1):
    for w in range(1, k+1):
        if w - W[i] >= 0:
            dp[i][w] = max(dp[i-1][w], dp[i-1][w-W[i]] + V[i])
        else:
            dp[i][w] = dp[i-1][w]
            
print(max(dp[-1]))

Measured memory_bytes: 120044
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, k;
	int p[10] = { 0 };
	scanf("%d%d", &n,&k);
	for (int i = 0; i < k; i++)
		scanf("%d", &p[i]);
	sort(p, p + k);
	for (int i = n; i <= 1000010; i++){
		int flag = 1;
		int t = i;
		while (t > 0 && flag){
			int b = t % 10;
			for (int s = 0; s < k&&flag; s++){
				if (p[s] == b)
					flag = 0;
			}
			t /= 10;
		}
		if (flag){
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

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

inline int read()
{
	int x=0; char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}

int main(){
    ll n;
    cin >> n;
    ll ans = n*(n+1)*(n+2)/6;
    ll u, v;
    rep(i, n-1) {
        u = read(); v = read();
        if (u>v) swap(u, v);
        ans -= u*(n-v+1);
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3580
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e3+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];


int main()
{
   string a,b;
   cin>>a>>b;
   ll i;
   for(i=0;i<a.size();i++){
      if(a[i]!=b[i]){
        cout<<"No"<<endl;
        return 0;
      }
   }
   cout<<"Yes"<<endl;
return 0;
}


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

class Program
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[][] xyzs = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        long max = 0;
        foreach (int x in new[] { -1, 1 })
        {
            foreach (int y in new[] { -1, 1 })
            {
                foreach (int z in new[] { -1, 1 })
                {
                    var values = Enumerable.Range(0, nm[0]).Select(p => xyzs[p][0] * x + xyzs[p][1] * y + xyzs[p][2] * z).OrderByDescending(value => value).Take(nm[1]).Sum();
                    max = Math.Max(values, max);
                }
            }
        }
        Console.WriteLine(max);
    }

}

Measured memory_bytes: 13664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;


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


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

template <typename T>
class FenwickTree {
	const int n;
	vector<T> data;
public:
	FenwickTree(int n_) : n(n_ + 1), data(n) {}
	T find(int p) const {
		p++;
		T res = 0;
		while (p > 0) {
			res += data[p];
			p &= p - 1;
		}
		return res;
	}
	T find(int l, int r) const {
		return find(r) - find(l - 1);
	}
	void add(int p, T val) {
		p++;
		while (p < n) {
			data[p] += val;
			p += p & -p;
		}
	}
	void update(int p, T val) {
		add(p, val - find(p));
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y;
	cin >> n >> q;
	FenwickTree<int> st(n);
	while (q--) {
		cin >> com >> x >> y; x--;
		if (com) {
			y--;
			printf("%d\n", st.find(x, y));
		}
		else {
			st.add(x, y);
		}
	}
	return 0;
}



Measured memory_bytes: 3316
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define debug(x) cout << #x << " is " << x << endl;
 
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
 
ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}
 
#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

struct custom_cmp{
	bool operator()(string i,string j){
		return sz(i)>sz(j);
	}
};

const int L=128;
const string A="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
//const string A="ab"; //testing 
int len;

priority_queue<string, vector<string>, custom_cmp> pq;

bool subset(string i){
	cout<<"? "<<i<<endl;
	
	int val;
	cin>>val;
	
	return val==len-sz(i);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	for (auto &it:A){
		string query;
		
		rep(x,0,L) query+=it;
		
		cout<<"? "<<query<<endl;
		
		int val;
		cin>>val;
		
		query="";
		
		rep(x,0,L-val) query+=it;
		len+=L-val;
		
		pq.push(query);
	}
	
	string s,t;
	while (sz(pq)!=1){
		s=pq.top(),pq.pop();
		t=pq.top(),pq.pop();
		
		//add t into s character by character
		
		int pos=0;
		
		rep(x,0,sz(t)){
			while (true){
				s.insert(s.begin()+pos,t[x]);
				
				if (subset(s)){
					pos++;
					break;
				}
				else {
					s.erase(s.begin()+pos);
					pos++;
				}
			}
		}
		
		pq.push(s);
	}
	
	
	cout<<"! "<<pq.top();
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N; cin>>N;

  vector<int> ve9,ve6;

  rep(i,20){
    ve9.emplace_back((int)pow(9,(19-i)));
    ve6.emplace_back((int)pow(6,(19-i)));
  }

  int ans=INF;
  rep(i,11112){
    int num9=i;
    int temp=0;
    int num=N;
    num-=num9*9;
    if(num<0) continue;
    int num6=num/6;

    temp+=num%6;

    rep(i,20){
      temp+=num9/ve9[i];
      num9%=ve9[i];
    }
    rep(i,20){
      temp+=num6/ve6[i];
      num6%=ve6[i];
    }
    mini(ans,temp);
  }
  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 768
s = input()
num_cap = len([i for i in s if i.isupper()])
indC = s.find("C")
print("AC") if num_cap == 2 and s.count("A") == 1 and s.count("C") == 1 and s[0] == "A" and 2 <= indC <= len(s)-2 else print("WA")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    string sa,sb;
    for (int i=0;i<b;i++) {
        sa+=to_string(a);
    }
    for (int j=0;j<a;j++) {
        sb+=to_string(b);
    }
    if (sa>=sb) {
        cout<<sb<<endl;
    } else {
        cout<<sa<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
//const ll MOD = 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n;
    cin >> n;
    ll a[100010], b[100010];
    rep(i, n + 1) cin >> a[i];
    rep(i, n) cin >> b[i];
    ll ans = 0;

    rep(i, n) {
        if (a[i] >= b[i]) {
            ans += b[i];
            a[i] = 0;
        } else {
            ans += a[i];
            b[i] -= a[i];

            if (a[i + 1] >= b[i]) {
                ans += b[i];
                a[i + 1] -= b[i];
            } else {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1792
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            B[i] = sc.nextLong();
        }

        int allZero = 0;
        Map<List<Long>, Pair> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            if (A[i] == 0 && B[i] == 0) {
                allZero++;
                continue;
            }
            long g = gcd(Math.abs(A[i]),Math.abs(B[i]));
            List<Long> ab = new ArrayList<>();
            List<Long> ba = new ArrayList<>();
            if (A[i] == 0) {
                ab.add(0L);
                ab.add(1L);
                ba.add(1L);
                ba.add(0L);
            } else if (B[i] == 0) {
                ab.add(1L);
                ab.add(0L);
                ba.add(0L);
                ba.add(1L);
            } else if ((A[i] > 0 && B[i] > 0) || (A[i] < 0 && B[i] < 0) ) {
                ab.add(Math.abs(A[i])/g);
                ab.add(Math.abs(B[i])/g);
                ba.add(-1L);
                ba.add(Math.abs(B[i])/g);
                ba.add(Math.abs(A[i])/g);
            } else {
                ab.add(-1L);
                ab.add(Math.abs(A[i])/g);
                ab.add(Math.abs(B[i])/g);
                ba.add(Math.abs(B[i])/g);
                ba.add(Math.abs(A[i])/g);
            }
            if (map.containsKey(ab)) {
                map.get(ab).ab++;
            } else if (map.containsKey(ba)) {
                map.get(ba).ba++;
            } else {
                map.put(ab,new Pair(1,0));
            }
        }
        //System.out.println(map);

        long ans = 1;
        for (Pair value: map.values()) {
            int cntAB = value.ab;
            int cntBA = value.ba;
            long tmp = 1;
            tmp += pow(2,cntAB);
            tmp %= MOD;

            tmp--;
            tmp %= MOD;
            tmp = tmp < 0 ? tmp+MOD : tmp;

            tmp += pow(2,cntBA);
            tmp %= MOD;

            tmp--;
            tmp %= MOD;
            tmp = tmp < 0 ? tmp+MOD : tmp;

            ans *= tmp;
            ans %= MOD;
        }

        ans--;
        ans %= MOD;
        ans = ans < 0 ? ans+MOD : ans;

        ans += allZero;
        ans %= MOD;
 
        System.out.println(ans);
    }

    private static class Pair {
        private int ab;
        private int ba;
        Pair(int ab , int ba) {
            this.ab = ab;
            this.ba = ba;
        }
    }

    private static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a%b);
    }

    private static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b%2 == 1) {
            return a*pow(a,b-1)%MOD;
        }
        long half = pow(a,b/2);
        return half*half%MOD;
    }
}


Measured memory_bytes: 101820
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    int dp[N + 1];
    REP(i, N + 1) dp[i] = inf;
    dp[0] = 0;

    REP(i, N) {
        // 1
        dp[i + 1] = min(dp[i + 1], dp[i] + 1);

        // 6^n
        int s = 6;
        while(i + s <= N) {
            dp[i + s] = min(dp[i + s], dp[i] + 1);
            s *= 6;
        }

        // 9^n
        s = 9;
        while(i + s <= N) {
            dp[i + s] = min(dp[i + s], dp[i] + 1);
            s *= 9;
        }
    }

    print(dp[N]);

}


Measured memory_bytes: 640
program substring
  implicit none
  character(1000) :: s, t
  integer :: ns, nt, d = 1e9, x, i, j
  read(*,*) s
  read(*,*) t
  ns = len_trim(s)
  nt = len_trim(t)
  do i = 1, ns - nt + 1
    x = 0
    do j = 1, nt
      if (s(i + j - 1:i + j - 1) /= t(j:j)) x = x + 1
    end do
    d = min(d, x)
  end do
  write(*,'(i0)') d
end program substring

Measured memory_bytes: 2924
var lines = []; var result = 0;

var readline = require("readline");

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {

    var N = Number(lines[0].split(" ")[0]);
    var A = Number(lines[0].split(" ")[1]);
    var B = Number(lines[0].split(" ")[2]);

    A * N < B ? console.log(A * N) : console.log(B);
});

Measured memory_bytes: 7628
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <climits>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long LL;

typedef pair<int, int> PII;
typedef vector<PII> VPII;

#define X first
#define Y second

int main(void) {
	int N, M;
	string s;
	while (cin >> N, N) {
		cin >> M >> s;

		string ioi("I");
		for (int i = 0; i < N; i++) {
			ioi += "OI";
		}

		int cnt = 0;
		for (int i = 0; i + ioi.size() <= s.size(); i++) {
			if (s.substr(i, ioi.size()) == ioi) {
				cnt++;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

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

int main(void) {
    int N;
    cin>>N;
    bool hit = false;
    int result;
    for (int i = 1; i * 1.08 <= N + 1; i++) {
        double d = i * 1.08;
        int d_i = d;
        if (d_i == N) {
            hit = true;
            result = i;
            break;
        }
    }
    if (hit) cout << result << endl;
    else cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define el "\n"
vector<int> v(10050, 0);

void solution() {
    for (int x=1; x<=101; ++x) {
        for (int y=1; y <= 101; ++y) {
            for (int z=1; z<= 101; ++z) {
                int sol = x*x + y*y + z*z + z*x + x*y + y*z;
                if (sol < 10050)
                    v[sol]++;
            }
        }
    }
}
  
int main() {
    solution();
    int n; cin >> n; 
    for (int i=1; i <= n; ++i) {
        cout << v[i] << el;
    }

    return 0;
}


Measured memory_bytes: 3672
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

int main(){
  ll i=0,N,M=19;
  cin>>N;
  pmat v(20);
  rep(i,19){
    v[i].pb(datas(i+1,0));
  }
  i=0;
  while(N>1){
    if(N%2==0){
      N/=2;
      v[i].pb(datas(i+1,N));
      M++;
    }else if(N%3==0){
      N/=3;
      v[i].pb(datas(i+1,N));
      v[i].pb(datas(i+1,N*2));
      M+=2;
    }else{
      N--;
      v[i].pb(datas(19,N));
      M++;
      i--;
    }
    i++;
  }
  cout<<20<<" "<<M<<endl;
  rep(i,20){
    for(auto j:v[i]){
      cout<<i+1<<" "<<j.first+1<<" "<<j.second<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
int main(){
    string a;
    cin >> a;
    if(a[a.length()-1] == 's'){
        cout << a + "es" << endl;
    }else{
        cout << a + 's' << endl;
    }
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics; // ★追加
class Program
{
    public static BigInteger GCD(BigInteger a, BigInteger b)
    {
        while (b != 0)
        {
            var c = a % b;
            a = b;
            b = c;
        }
        return a;
    }

    public static BigInteger LCM(BigInteger a, BigInteger b)
    {
        return (a / GCD(a, b)) * b;
    }
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var C = Enumerable.Range(0, N).Select(i => A[i] / GCD(A[0], A[i])).ToArray();
        BigInteger lcm = C[0];
        for (int i = 1; i < N; i++)
        {
            lcm = LCM(lcm, C[i]);
        }
        Modular invsum = 0;
        for (int i = 0; i < N; i++)
        {
            Modular x = 1;
            x /= A[i];
            invsum += x;
        }
        Console.WriteLine((int)(A[0] * invsum * (int)(lcm % 1000000007)));
    }
}
class Modular
{
    private const int M = 1000000007;
    private long value;
    public Modular(long value) { this.value = value; }
    public static implicit operator Modular(long a)
    {
        var m = a % M;
        return new Modular((m < 0) ? m + M : m);
    }
    public static Modular operator +(Modular a, Modular b)
    {
        return a.value + b.value;
    }
    public static Modular operator -(Modular a, Modular b)
    {
        return a.value - b.value;
    }
    public static Modular operator *(Modular a, Modular b)
    {
        return a.value * b.value;
    }
    public static Modular Pow(Modular a, int n)
    {
        switch (n)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
        }
    }
    public static Modular operator /(Modular a, Modular b)
    {
        return a * Pow(b, M - 2);
    }
    public static explicit operator int(Modular a)
    {
        return (int)a.value;
    }
}


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

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;

    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long sum = accumulate(a.begin(), a.end(), 0LL);

    long res = 1;
    for(long qq=1; qq*qq<sum; qq++) {
        if(sum % qq != 0) continue;

        for(long q : {qq, sum/qq}) {
            vector<long> b(n);
            copy(a.begin(), a.end(), b.begin());

            for(auto &x: b) x %= q;
            sort(b.begin(), b.end());

            long s = accumulate(b.begin(), b.end(), 0LL,
                    [=](long acc, long x) {return acc + (q-x);});

            long t = 0, r = 1e9;
            for(int i=0; i<n; i++) {
                r = min(max(t, s), r);
                t += b[i];
                s -= q - b[i];
            }
            r = min(max(t, s), r);

            if(r <= k)
                res = max(res, q);

        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include "unordered_map"
#include "map"
#include <cmath>
#include <climits>
#include "queue"
#include "tuple"
#include <algorithm>
#include <iomanip>
#include "sstream"
#include <math.h>

using ll=long long;
using ull=unsigned long long;
using ld=long double;
using namespace std;

//const double PI = M_PI;

template <typename T>
inline void printQueue(queue<T>&oq){queue<T>q(oq);int qCount=q.size();for(int i=0;i<qCount;++i){T qe=q.front();q.pop();
        cout<<qe;if(i!=qCount-1){cout << ", ";}q.push(qe);}cout << endl;}

template<typename T>
inline void PV(vector<T> v){int vc=v.size();for(int i=0;i<vc;++i){cout << v[i];if(i!=vc-1){cout<<", ";}}cout << endl;}

inline double round( double val )
{
    if( val < 0 ) return ceil(val - 0.5);
    return floor(val + 0.5);
}

int main() {
//    freopen("../input.txt","r",stdin);
//    freopen("../output.txt","w",stdout);
    ull n;
    cin >> n;
    int mn = INT_MAX;
    int mx = 0;
    for(int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        if(h < mn) {
            mn = h;
        }
        if(h > mx) {
            mx = h;
        }
    }
    cout << mx - mn;
}


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

using namespace std;
using namespace atcoder;
typedef long long ll;

/*
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
void Add(ll &pos,ll val){pos=mod(pos+val);}
void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
*/

#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

typedef long double dd;
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
dd EPS=1E-12;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second

#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
//#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;


using mint = modint998244353;
//using mint = modint1000000007;
//////////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    vector<mint>a(n),b(m);
    rep(i,0,n-1){ll x;cin>>x;a[i]=x;}
    rep(i,0,m-1){ll x;cin>>x;b[i]=x;}
    auto c=convolution(a,b);
    for(auto x:c)cout<<x.val()<<" ";
    
    return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back

int bexp(int a, int b)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a);

        a = (a * a); 
        b >>= 1;
    }
    return res;
}

#define N 200010
#define MOD 1000000007

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);

    int r, c, k;
    cin >> r >> c >> k;

    char a[6][6];
    int cnt = 0;
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            cin >> a[i][j];
        }
    }

    char b[6][6];
    int ans = 0; 
    int l = (1ll << 6);



    for (int i = 0; i < (1 << r); ++i)
    {
        for (int j = 0; j < (1 << c); ++j)
        {
            for (int k1 = 0; k1 < r; ++k1)
            {
                for (int m = 0; m < c; ++m)
                {
                    b[k1][m] = a[k1][m]; 
                }                    
            }

            int temp = i, p = 0;
            while (temp)
            {
                if (temp & 1)
                    for (int m = 0; m < c; ++m)
                    {
                        b[p][m] = '.';
                    }
                temp >>= 1;
                p++;
            }

            temp = j;
            p = 0;

            while (temp)
            {
                if (temp & 1)
                {
                    for (int m = 0; m < r; ++m)
                    {
                        b[m][p] = '.';
                    }
                }
                temp >>= 1;
                p++;
            }

            int c1 = 0;
            for (int k1 = 0; k1 < r; ++k1)
            {
                for (int m = 0; m < c; ++m)
                {
                    if (b[k1][m] == '#')
                        c1++;
                }
            }

            // cout << i << " " << j << " " << c << endl;
            if (c1 == k)
            {
                ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3660
import java.util.*;

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

        int N = stdin.nextInt();

        Integer a[] = new Integer[N];

        for (int i = 0; i < N; i++) {
            a[i] = stdin.nextInt();
        }

        Arrays.sort(a, Comparator.reverseOrder());

        int count = 1;

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

        System.out.println(count);
    }
}


Measured memory_bytes: 24916
#include<bits/stdc++.h>
#define ll                    long long int
#define loop(i ,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar_unlocked
#define gc                    getchar_unlocked
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define MAX                   1e9
#define MIN                   -1e9
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define vvi                   vector<vi>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define mini                  INT_MIN
using namespace std;
const int N = 10000101;
ll ma = 1e18;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll val = n;
  vector<int> v;
  for(ll i = 2; i*i <= n;i++)
  {
      //cout<<i<<" ";
      int cnt = 0;
      while(val % i == 0)
      {
         val = val/i;
         cnt++;
      }
      if(cnt > 0)
        v.pb(cnt);
  } 
  if(val > 1)
  v.pb(1);
  //cout<<v.size()<<" ";
  int an =0;
  for(int i : v)
  {
        //cout<<i<<" ";
        int sum = 0, ans =0;
        for(int j = 1; j<40;j++)
        {
          sum +=j;
            if(i >= sum)
            {
               ans = j;
            }
            else
              break;
        }
        an += ans;
  }
  if(n == 1)
  cout<<"0";
  else 
  cout<<an<<"\n";
}


Measured memory_bytes: 3656
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep(i,n)    for(ll i=1; i<=n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed

    ll i,j,k,kk,a,b;
    cin>>a>>b>>k;
    kk=k;
    vector<ll>all;
    for(i=a;i<=b&&k--; i++)
    {
        all.push_back(i);
    }
    for(i=b;i>=a&&kk--; i--){
        all.push_back(i);
    }
    sort(all.begin(),all.end());
    all.erase(unique(all.begin(),all.end()),all.end());

    for(i=0;i<all.size();i++)
        cout<<all.at(i)<<endl;




    return 0;
}





Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;

int main()
{
    int W, H, N;
    cin >> W >> H >> N;
    int tile[100][100];//[high(y)][width(x)]
    memset(tile, 0, sizeof(tile));//塗られていないのを0とする

    int counter=0;
    for(int i=0; i<N; i++){
        int x, y, a;
        cin >> x >> y >> a;
        if(a==1){
            for(int j=0; j<x; j++){
                for(int k=0; k<H; k++){
                    if(tile[k][j]==0){
                        tile[k][j]++;
                        counter++;
                    }
                }
            }
        }else if(a==2){
            for(int j=W-1; j>=x; j--){
                for(int k=0; k<H; k++){
                    if(tile[k][j]==0){
                        tile[k][j]++;
                        counter++;
                    }
                }
            }
        }else if(a==3){
            for(int j=0; j<W; j++){
                for(int k=0; k<y; k++){
                    if(tile[k][j]==0){
                        tile[k][j]++;
                        counter++;
                    }
                }
            }
        }else{
            for(int j=0; j<W; j++){
                for(int k=H-1; k>=y; k--){
                    if(tile[k][j]==0){
                        tile[k][j]++;
                        counter++;
                    }
                }
            }
        }
    }
    cout << H*W-counter << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        long top = 0;
        long result = 0;

        for (int i=0; i<N; i++) {
            if (A[i] > top) {
                top = A[i];
            } else if ((A[i] < top)) {
                result += (top-A[i]);
            }
        }
        
        System.out.println(result);
    }
}


Measured memory_bytes: 61564
#include <iostream>

using namespace std;

int main() {
	long long n, k;
	cin >> n >> k;
	int ans = 0, cnt = 0;
	double res = 0.0;

	for (int i = 1; i <= n; i++) {
		ans = i;
		double tmp = 1.0;
		while (ans < k) {
			ans *= 2;
			tmp /= 2.0; // ここで1/2の累乗を計算
		}
		res += tmp;
	}
	res /= n;
	printf("%.16f", res);
}

Measured memory_bytes: 256
/* Dynamic Programming implementation of LCS problem */
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
/* Returns length of LCS for X[0..m-1], Y[0..n-1] */
void lcs( char *X, char *Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
  
   /* Following steps build L[m+1][n+1] in bottom up fashion. Note 
      that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1] */
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
  
   // Following code is used to print LCS 
   int index = L[m][n]; 
  
   // Create a character array to store the lcs string 
   char lcs[index+1]; 
   lcs[index] = '\0'; // Set the terminating character 
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs[index-1] = X[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
} 
  
/* Driver program to test above function */
int main() 
{ 
  char X[3030] = {}; 
  char Y[3030] = {};
  scanf("%s%s", X, Y);
  int m = strlen(X); 
  int n = strlen(Y); 
  lcs(X, Y, m, n); 
  return 0; 
} 


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

int main(){
  int N,d[120];
  cin >> N;
  for(int i=0 ; i < N; i++) cin >> d[i];

  set<int> values; //insertするときに重複を除く
  for(int i = 0; i < N; i++){
      values.insert(d[i]); //挿入
  }
  cout << values.size();

}


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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int D;
intvec C(26);
intmat S;
intvec last(26,-1);
ll score;

void input() {
	cin>>D;
	init(C);
	S.resize(D);
	for(int i=0; i<D; i++) init(S[i],26);
}

ll calc(int d, int c) {
	ll res=S[d][c];
	for(int i=0; i<26; i++) {
		res-=C[c]*(d-last[c]);
	}
	return res;
}

void solve() {
	srand(time(NULL));
	for(int d=0; d<D; d++) {
		ll temps=-LLINF;
		int c=rand()%26,oldc,oldd;
		int cnt=0;
		while(c<26&&cnt<1000) {
			oldd=last[c];
			last[c]=d;
			if(chmax(temps,calc(d,c))) oldc=c;
			last[c]=oldd;
			if(temps<-2000) c=rand()%26;
			else c=rand()%27;
			cnt++;
		}
		assert(cnt<1000);
		score+=temps;
		last[oldc]=d;
		cout<<oldc+1<<endl;
	}
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3684
n=int(input())
a=0
b=0
ab=0
ans=0
for i in range(n):
    l=list(input())
    if l[0]=='B' and l[-1]=='A':
        ab+=1
    elif l[0]=='B':
        b+=1
    elif l[-1]=='A':
        a+=1
    for j in range(len(l)-1):
        if l[j]=='A' and l[j+1]=='B':
            ans+=1
if ab>0:
    ans+=ab-1
    if a>0 and b>0:
        ans+=2
        a-=1
        b-=1
        print(ans+min(a,b))
    elif a>0:
        print(ans+1)
    elif b>0:
        print(ans+1)
    else:
        print(ans)
else:
    print(ans+min(a,b))

Measured memory_bytes: 3188
_fib = [0] * 45

def fib(n):
    if n < 2:
        return 1
    if _fib[n] > 0:
        return _fib[n]
    _fib[n] = fib(n-1) + fib(n-2)
    return _fib[n]

n = int(input())
print(fib(n))



Measured memory_bytes: 5600
#include <stdio.h>
#include <stdlib.h>
#define LEN (1e5+3)

int *check(char *str, int n) {
    int *p = (int *)malloc((n+2)*sizeof(int));
    int i, cnt = 0;
    for(i = 0; i < n-1; ++i) {
        p[i] = cnt;
        if(str[i] == 'A' && str[i+1] == 'C') { ++cnt; ++i; p[i] = cnt; }
    }
    if(i == n - 1) { p[i] = cnt; }
    return p;
}

int solve(char *str, int *check, int l, int r){
    --l; --r;
    return check[r] - check[l];
}

int main(void)
{
    int n, q, i;
    scanf("%d %d", &n, &q);
    int l[n+1], r[n+1];
    char *str = (char *)malloc((n + 3)*sizeof(char));
    scanf("%s", str);
    int *list = check(str, n);
    for(i = 0; i < q; ++i) {
        scanf("%d %d", &l[i], &r[i]);
    }
    
    /*
    for(i = 0; i < n; ++i) {
        printf("%d ", list[i]);
    }
    
    printf("\n");
    */
    for(i = 0; i < q; ++i) {
        printf("%d\n", solve(str, list, l[i], r[i])); 
    }
    return 0;
}

Measured memory_bytes: 2048
package main

import (
    "fmt"
)

func main() {
    n := scanInt()
    s := scanString()
    red_count := 0
    blue_count := 0
    for i := 0; i < n; i++ {
        if s[i] == 'R' {
            red_count++
        } else {
            blue_count++
        }
    }
    if red_count > blue_count {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}

func scanInt() (num int) {
    fmt.Scan(&num)
    return
}

func scanInts(len int) (nums []int) {
    var num int
    for i := 0; i < len; i++ {
        fmt.Scan(&num)
        nums = append(nums, num)
    }
    return
}

func scanString() (str string) {
    fmt.Scan(&str)
    return
}

func scanStrings(len int) (strs []string) {
    var str string
    for i := 0; i < len; i++ {
        fmt.Scan(&str)
        strs = append(strs, str)
    }
    return
}

Measured memory_bytes: 512
N = int(input())

SP = []
for i in range(N):
    hoge = list(input().split())
    SP.append([hoge[0], int(hoge[1]), i+1])
SP = sorted(SP, key=lambda x:-x[1])
SP = sorted(SP, key=lambda x:x[0])

for i in SP:
    print(i[2])


Measured memory_bytes: 3060
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v,vv;
ll n,k,s[500],cnt,tmp;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>s[i];
        cnt+=s[i];
    }
    for(int i=1;i*i<=cnt;i++){
        if(cnt%i==0){
            vv.push_back(i);
            vv.push_back(cnt/i);
        }
    }
    sort(vv.begin(),vv.end());
    for(int i:vv){
        ll ans=0,xx=0;
        v={};
        tmp=cnt/i;
        for(int j=0;j<n;j++){
            v.push_back(s[j]%tmp);
            ans+=s[j]%tmp;
        }
        sort(v.begin(),v.end());
        for(int ii=0;ii<n-ans/tmp;ii++)xx+=v[ii];
        if(k>=xx){
            cout<<tmp<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <climits>
#include <queue>
#include <cstring>

using std::min;
using std::priority_queue;

const int MAXN=500005;
int n,k;
int p[MAXN],id[MAXN];
int he[MAXN],inD[MAXN];

struct line{int to,nex;}ed[MAXN<<1];

class segT{
#define ls (u<<1)
#define rs (ls|1)
	private:
		int minw[MAXN<<2];
		void upd(int u){
			minw[u]=min(minw[ls],minw[rs]);
		}
		void ist(int u,int l,int r,int pos,int x){
			if(l==r){
				minw[u]=min(minw[u],x);
				return;
			}
			int mid=l+r>>1;
			if(pos<=mid) ist(ls,l,mid,pos,x);
			else ist(rs,mid+1,r,pos,x);
			upd(u);
		}
		int qry(int u,int l,int r,int lp,int rp){
			if(lp<=l && r<=rp) return minw[u];
			int mid=l+r>>1,ret=INT_MAX;
			if(lp<=mid) ret=qry(ls,l,mid,lp,rp);
			if(rp>mid) ret=min(ret,qry(rs,mid+1,r,lp,rp));
			return ret;
		}
	public:
		segT(){memset(minw,0x7f,sizeof(minw));}
		void ist(int pos,int x){ist(1,1,n,pos,x);}
		int qry(int lp,int rp){return qry(1,1,n,lp,rp);}
#undef ls
#undef rs
}T;

inline void addE(int u,int v){
	static int cnt;
	ed[++cnt]=(line){v,he[u]};
	he[u]=cnt;
}

inline void build(){
	for(int i=n,v;i;--i){
		v=T.qry(id[i]-k+1,id[i]);
		if(v<=n){
			addE(id[i],id[v]);
			++inD[id[v]];
		}
		v=T.qry(id[i],id[i]+k-1);
		if(v<=n){
			addE(id[i],id[v]);
			++inD[id[v]];
		}
		T.ist(id[i],i);
	}
}

inline void topo_sort(){
	static priority_queue<int> pq;
	for(int i=1;i<=n;++i){
		if(!inD[i]) pq.push(-i);
	}
	for(int i=1,u;i<=n;++i){
		u=id[i]=-pq.top();
		pq.pop();
		for(int j=he[u],v;j;j=ed[j].nex){
			v=ed[j].to;
			if(--inD[v]==0) pq.push(-v);
		}
	}
}

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d",&p[i]);
	for(int i=1;i<=n;++i)
		id[p[i]]=i;
	build();
	topo_sort();
	for(int i=1;i<=n;++i)
		p[id[i]]=i;
	for(int i=1;i<=n;++i)
		printf("%d\n",p[i]);
	return 0;
}


Measured memory_bytes: 27512